7a49e2efa1c10fb9f43a49b30fe9b50ac6f330d1
[satcheck.git] / clang / test / fib_easy_true.c
1 /* Adapted from: https://svn.sosy-lab.org/software/sv-benchmarks/trunk/c/pthread/fib_bench_true-unreach-call.c */
2
3 #include <assert.h>
4 #include <stdbool.h>
5 #include <threads.h>
6 #include "libinterface.h"
7
8 /* volatile */ int i, j;
9
10 #define NULL 0
11
12 void t1(void* arg) {
13
14   int t1, t2;
15
16   t1 = load_32(&i);
17   t2 = load_32(&j);
18   store_32(&i, t1 + t2);
19
20   t1 = load_32(&i);
21   if (t1 > 3) {
22     assert(0);
23   }
24 }
25
26 void t2(void* arg) {
27
28   int t1, t2;
29
30   t1 = load_32(&j);
31   t2 = load_32(&i);
32   store_32(&j, t1 + t2);
33
34   t1 = load_32(&j);
35   if (t1 > 3) {
36     assert(0);
37   }
38 }
39
40 int user_main(int argc, char **argv)
41 {
42   thrd_t a, b;
43
44   store_32(&i, 1);
45   store_32(&j, 1);
46
47   thrd_create(&a, t1, NULL);
48   thrd_create(&b, t2, NULL);
49
50   thrd_join(a);
51   thrd_join(b);
52
53   return 0;
54 }