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