1(module $Mem
2  (memory (export "shared") 1 1 shared)
3)
4
5(thread $T1 (shared (module $Mem))
6  (register "mem" $Mem)
7  (module
8    (memory (import "mem" "shared") 1 10 shared)
9    (func (export "run")
10      (i32.atomic.store (i32.const 0) (i32.const 42))
11      (i32.atomic.store (i32.const 4) (i32.const 1))
12    )
13  )
14  (invoke "run")
15)
16
17(thread $T2 (shared (module $Mem))
18  (register "mem" $Mem)
19  (module
20    (memory (import "mem" "shared") 1 1 shared)
21    (func (export "run")
22      (local i32 i32)
23      (i32.atomic.load (i32.const 4))
24      (local.set 0)
25      (i32.atomic.load (i32.const 0))
26      (local.set 1)
27
28      ;; store results for checking
29      (i32.store (i32.const 24) (local.get 0))
30      (i32.store (i32.const 32) (local.get 1))
31    )
32  )
33
34  (invoke "run")
35)
36
37(wait $T1)
38(wait $T2)
39
40(module $Check
41  (memory (import "Mem" "shared") 1 1 shared)
42
43  (func (export "check") (result i32)
44    (local i32 i32)
45    (i32.load (i32.const 24))
46    (local.set 0)
47    (i32.load (i32.const 32))
48    (local.set 1)
49
50    ;; allowed results: (L_0 = 1 && L_1 = 42) || (L_0 = 0 && L_1 = 0) || (L_0 = 0 && L_1 = 42)
51
52    (i32.and (i32.eq (local.get 0) (i32.const 1)) (i32.eq (local.get 1) (i32.const 42)))
53    (i32.and (i32.eq (local.get 0) (i32.const 0)) (i32.eq (local.get 1) (i32.const 0)))
54    (i32.and (i32.eq (local.get 0) (i32.const 0)) (i32.eq (local.get 1) (i32.const 42)))
55    (i32.or)
56    (i32.or)
57    (return)
58  )
59)
60
61(assert_return (invoke $Check "check") (i32.const 1))
62