-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinterpcd_2ct_alt.check.c
73 lines (73 loc) · 1.42 KB
/
interpcd_2ct_alt.check.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*****************************************
Emitting C Generated Code
*******************************************/
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
/**************** Snippet ****************/
void Snippet(int* x0) {
int x1 = 0;
while (0 <= x1 && x1 < 2) {
if (0 == x1) {
int x2 = x0[6] + 1;
x0[6] = x2;
int x3 = x0[0] + 10;
x0[1] = x0[4] == x3 ? x0[5] : ({
int x4 = x0[x3];
x0[6] = x2 + 1 + 1;
x0[4] = x3;
x0[5] = x4;
x4;
});
x1 = 1;
}
if (1 == x1) {
int x5 = x0[6] + 1;
x0[6] = x5;
int x6 = 4 + x0[1] + 10;
x0[2] = x0[4] == x6 ? x0[5] : ({
int x7 = x0[x6];
x0[6] = x5 + 1 + 1;
x0[4] = x6;
x0[5] = x7;
x7;
});
x1 = 2;
}
}
}
/*****************************************
End of C Generated Code
*******************************************/
int init(int* s) {
for (int i=0; i<100; i++) {
s[i] = 0;
}
return 0;
}
int bounded(int low, int high) {
int x = nondet_uint();
if (x < low) {
x = low;
}
if (x > high) {
x = high;
}
return x;
}
int main(int argc, char* argv[]) {
int s1[100];
init(s1);
int s2[100];
init(s2);
int x = bounded(0, 20);
s1[0] = x;
int i = 10+bounded(0, 20);
s1[i] = 1;
s2[0] = x;
Snippet(s1);
Snippet(s2);
__CPROVER_assert(s1[6]==s2[6], "timing leak");
return 0;
}