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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
target triple = "x86_64-pc-linux-gnu"
declare i64 @printf(i8*, ...)
@printf_d = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@printf_c = private unnamed_addr constant [3 x i8] c"%c\00", align 1
%S = type { i64*, i64* }
attributes #0 = { alwaysinline }
define private %S @addI(%S %s.0) #0 {
%bsp.0 = extractvalue %S %s.0, 1
%t.0 = load i64, i64* %bsp.0
store i64 undef, i64* %bsp.0
%bsp.1 = getelementptr i64, i64* %bsp.0, i64 1
%t.1 = load i64, i64* %bsp.1
%t.2 = add i64 %t.0, %t.1
store i64 %t.2, i64* %bsp.1
%s.1 = insertvalue %S %s.0, i64* %bsp.1, 1
ret %S %s.1
}
define private %S @ltI(%S %s.0) #0 {
%bsp.0 = extractvalue %S %s.0, 1
%t.0 = load i64, i64* %bsp.0
store i64 undef, i64* %bsp.0
%bsp.1 = getelementptr i64, i64* %bsp.0, i64 1
%t.1 = load i64, i64* %bsp.1
%t.2 = icmp slt i64 %t.0, %t.1
%t.3 = zext i1 %t.2 to i64
store i64 %t.3, i64* %bsp.1
%s.1 = insertvalue %S %s.0, i64* %bsp.1, 1
ret %S %s.1
}
define private %S @pop_b1(%S %s.0) #0 {
%bsp.0 = extractvalue %S %s.0, 1
store i64 undef, i64* %bsp.0
%bsp.1 = getelementptr i64, i64* %bsp.0, i64 1
%s.1 = insertvalue %S %s.0, i64* %bsp.1, 1
ret %S %s.1
}
define private %S @print_int(%S %s.0) #0 {
%bsp.0 = extractvalue %S %s.0, 1
%t.0 = load i64, i64* %bsp.0
store i64 undef, i64* %bsp.0
call i64 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @printf_d, i64 0, i64 0), i64 %t.0)
%bsp.1 = getelementptr i64, i64* %bsp.0, i64 1
%s.1 = insertvalue %S %s.0, i64* %bsp.1, 1
ret %S %s.1
}
define private %S @push_b(i64 %n, %S %s.0) #0 {
%bsp.0 = extractvalue %S %s.0, 1
%bsp.1 = getelementptr i64, i64* %bsp.0, i64 %n
%t.0 = load i64, i64* %bsp.1
%bsp.2 = getelementptr i64, i64* %bsp.0, i64 -1
store i64 %t.0, i64* %bsp.2
%s.1 = insertvalue %S %s.0, i64* %bsp.2, 1
ret %S %s.1
}
define private %S @pushI(i64 %i, %S %s.0) #0 {
%bsp.0 = extractvalue %S %s.0, 1
%bsp.1 = getelementptr i64, i64* %bsp.0, i64 -1
store i64 %i, i64* %bsp.1
%s.1 = insertvalue %S %s.0, i64* %bsp.1, 1
ret %S %s.1
}
define private %S @subI(%S %s.0) #0 {
%bsp.0 = extractvalue %S %s.0, 1
%t.0 = load i64, i64* %bsp.0
store i64 undef, i64* %bsp.0
%bsp.1 = getelementptr i64, i64* %bsp.0, i64 1
%t.1 = load i64, i64* %bsp.1
%t.2 = sub i64 %t.0, %t.1
store i64 %t.2, i64* %bsp.1
%s.1 = insertvalue %S %s.0, i64* %bsp.1, 1
ret %S %s.1
}
define private %S @update_b(i64 %n1, i64 %n2, %S %s.0) #0 {
%bsp.0 = extractvalue %S %s.0, 1
%bsp.1 = getelementptr i64, i64* %bsp.0, i64 %n1
%t.0 = load i64, i64* %bsp.1
%bsp.2 = getelementptr i64, i64* %bsp.0, i64 %n2
store i64 %t.0, i64* %bsp.2
ret %S %s.0
}
define private %S @updatepop_b01(%S %s.0) #0 {
%bsp.0 = extractvalue %S %s.0, 1
%t.0 = load i64, i64* %bsp.0
store i64 undef, i64* %bsp.0
%bsp.1 = getelementptr i64, i64* %bsp.0, i64 1
store i64 %t.0, i64* %bsp.1
%s.1 = insertvalue %S %s.0, i64* %bsp.1, 1
ret %S %s.1
}
define private i64 @peek_b(%S %s) #0 {
%bsp = extractvalue %S %s, 1
%t = load i64, i64* %bsp
ret i64 %t
}
define private {i64, %S} @_s1(i64 %arg, %S %s.000) #0 {
%s.001 = call %S @pushI(i64 %arg, %S %s.000)
%s.100 = call %S @pushI(i64 2, %S %s.001)
%s.101 = call %S @push_b(i64 1, %S %s.100)
%s.102 = call %S @ltI(%S %s.101)
%t.0 = call i64 @peek_b(%S %s.102)
%s.103 = call %S @pop_b1(%S %s.102)
%t.1 = trunc i64 %t.0 to i1
br i1 %t.1, label %l.0, label %else.1
l.0:
%s.200 = call %S @pop_b1(%S %s.103)
%s.201 = call %S @pushI(i64 1, %S %s.200)
%r = call i64 @peek_b(%S %s.201)
%s.202 = call %S @pop_b1(%S %s.201)
%rval.0 = insertvalue {i64,%S} undef, i64 %r, 0
%rval.1 = insertvalue {i64,%S} %rval.0, %S %s.202, 1
ret {i64, %S} %rval.1
else.1:
%s.300 = call %S @pushI(i64 1, %S %s.103)
%s.301 = call %S @push_b(i64 1, %S %s.300)
%s.302 = call %S @subI(%S %s.301)
%arg.0 = call i64 @peek_b(%S %s.302)
%s.302.0 = call %S @pop_b1(%S %s.302)
%ret.0 = call {i64,%S} @_s1(i64 %arg.0, %S %s.302.0)
%r.0 = extractvalue {i64, %S} %ret.0, 0
%s.302.1 = extractvalue {i64, %S} %ret.0, 1
%s.303 = call %S @pushI(i64 %r.0, %S %s.302.1)
%s.304 = call %S @pushI(i64 2, %S %s.303)
%s.305 = call %S @push_b(i64 2, %S %s.304)
%s.306 = call %S @subI(%S %s.305)
%arg.1 = call i64 @peek_b(%S %s.306)
%s.306.0 = call %S @pop_b1(%S %s.306)
%ret.1 = call {i64,%S} @_s1(i64 %arg.1, %S %s.306.0)
%r.1 = extractvalue {i64, %S} %ret.1, 0
%s.306.1 = extractvalue {i64, %S} %ret.1, 1
%s.307 = call %S @pushI(i64 %r.1, %S %s.306.1)
%s.308 = call %S @update_b(i64 1, i64 2, %S %s.307)
%s.309 = call %S @updatepop_b01(%S %s.308)
%s.310 = call %S @addI(%S %s.309)
%relse = call i64 @peek_b(%S %s.310)
%s.311 = call %S @pop_b1(%S %s.310)
%rval.2 = insertvalue {i64,%S} undef, i64 %relse, 0
%rval.3 = insertvalue {i64,%S} %rval.2, %S %s.311, 1
ret {i64, %S} %rval.3
}
define private {i64, %S} @_s2(i64 %arg, %S %s.000) {
%ret = tail call {i64,%S} @_s1(i64 %arg, %S %s.000)
ret {i64, %S} %ret
}
define i64 @main() {
%stack = alloca [10000 x i64]
%asp = getelementptr [10000 x i64], [10000 x i64]* %stack, i64 0, i64 0
%bsp = getelementptr [10000 x i64], [10000 x i64]* %stack, i64 0, i64 9999
%s.001 = insertvalue %S undef, i64* %asp, 0
%s.002 = insertvalue %S %s.001, i64* %bsp, 1
%ret = call {i64,%S} @_s2(i64 43, %S %s.002)
%r = extractvalue {i64, %S} %ret, 0
call i64 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @printf_d, i64 0, i64 0), i64 %r)
call i64 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @printf_c, i64 0, i64 0), i64 10)
ret i64 0
}
|