forked from trailofbits/deepstate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Squares.c
42 lines (35 loc) · 825 Bytes
/
Squares.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <stdio.h>
#include <stdlib.h>
int square(int x) {
return x*x;
}
#ifdef DEEPSTATE_TEST
#include <deepstate/DeepState.h>
DeepState_EntryPoint(test_main) {
const char *new_args[2];
new_args[0] = "deepstate";
new_args[1] = DeepState_CStr(8);
DeepState_Assert(0 == old_main(2, new_args));
}
int main(int argc, const char *argv[]) {
DeepState_InitOptions(argc, argv);
return 0 == DeepState_Run();
}
// TODO(artem): yes this is awful but avoids another `ifdef`.
#define main old_main
#endif
int main(int argc, char *argv[]) {
if (argc != 2) {
printf("Usage: %s <integer>\n", argv[0]);
return -1;
}
int x = atoi(argv[1]);
int y = square(x);
if (y + 4 == 29) {
printf("You found the secret number\n");
return 0;
} else {
printf("Secret NOT found\n");
return -1;
}
}