fcf55d621afceb3bbe2422e6e23787a72be8a376
[satcheck.git] / clang / test / userprog2_unannotated.c
1 #include <stdio.h>
2 #include <threads.h>
3 #include <stdatomic.h>
4
5 #include "libinterface.h"
6
7 int x;
8 int y;
9 int gr1;
10 int gr2;
11
12 static void a(void *obj)
13 {
14         int r1=load_32(&y);
15         if (r1) {
16                 r1=42;
17         } else {
18                 r1=0;
19         }
20
21         store_32(&x, r1);
22
23         store_32(&gr1, r1);
24         printf("r1=%d\n",r1);
25 }
26
27 static void b(void *obj)
28 {
29         int r2=load_32(&x);
30         store_32(&y, 42);
31
32         store_32(&gr2, r2);
33         printf("r2=%d\n",r2);
34 }
35
36 int user_main(int argc, char **argv)
37 {
38         thrd_t t1, t2;
39
40         store_32(&x, 0);
41         store_32(&y, 0);
42
43         printf("Main thread: creating 2 threads\n");
44         thrd_create(&t1, (thrd_start_t)&a, NULL);
45         thrd_create(&t2, (thrd_start_t)&b, NULL);
46
47         thrd_join(t1);
48         thrd_join(t2);
49         printf("Main thread is finished\n");
50         int lgr1=load_32(&gr1);
51
52         int lgr2=load_32(&gr2);
53         if (lgr1==42) {
54                 if (lgr2==42) {
55                 } else {
56                 }
57         } else {
58         }
59
60         return 0;
61 }