-
Notifications
You must be signed in to change notification settings - Fork 0
/
stack.wat
116 lines (116 loc) · 1.77 KB
/
stack.wat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
(module
(table 0 anyfunc)
(memory $0 1)
(data (i32.const 12) "\00\00\00\00")
(export "memory" (memory $0))
(export "stacks" (func $stacks))
(func $stacks (; 0 ;) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
(block $label$0
(block $label$1
(block $label$2
(br_if $label$2
(i32.eq
(get_local $1)
(i32.const 2)
)
)
(br_if $label$0
(i32.eq
(get_local $1)
(i32.const 1)
)
)
(set_local $2
(i32.const 0)
)
(br_if $label$1
(get_local $1)
)
(set_local $2
(i32.const -1)
)
(br_if $label$1
(i32.gt_s
(tee_local $1
(i32.load offset=12
(i32.const 0)
)
)
(i32.const 511)
)
)
(i32.store offset=12
(i32.const 0)
(i32.add
(get_local $1)
(i32.const 1)
)
)
(i32.store
(i32.add
(i32.shl
(get_local $1)
(i32.const 2)
)
(i32.const 16)
)
(get_local $0)
)
(return
(get_local $0)
)
)
(set_local $2
(i32.load
(i32.add
(i32.shl
(i32.load offset=12
(i32.const 0)
)
(i32.const 2)
)
(i32.const 16)
)
)
)
)
(return
(get_local $2)
)
)
(block $label$3
(br_if $label$3
(i32.lt_s
(tee_local $1
(i32.load offset=12
(i32.const 0)
)
)
(i32.const 1)
)
)
(i32.store offset=12
(i32.const 0)
(tee_local $1
(i32.add
(get_local $1)
(i32.const -1)
)
)
)
(return
(i32.load
(i32.add
(i32.shl
(get_local $1)
(i32.const 2)
)
(i32.const 16)
)
)
)
)
(i32.const -1)
)
)