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