1
; RUN: opt < %s -basicaa -gvn -S | grep "tmp47 = phi i32 "
3
%struct.anon = type { i32 (i32, i32, i32)*, i32, i32, [3 x i32], i8*, i8*, i8* }
4
@debug = external constant i32 ; <i32*> [#uses=0]
5
@counters = external constant i32 ; <i32*> [#uses=1]
6
@trialx = external global [17 x i32] ; <[17 x i32]*> [#uses=1]
7
@dummy1 = external global [7 x i32] ; <[7 x i32]*> [#uses=0]
8
@dummy2 = external global [4 x i32] ; <[4 x i32]*> [#uses=0]
9
@unacceptable = external global i32 ; <i32*> [#uses=0]
10
@isa = external global [13 x %struct.anon] ; <[13 x %struct.anon]*> [#uses=3]
11
@.str = external constant [4 x i8] ; <[4 x i8]*> [#uses=0]
12
@.str1 = external constant [3 x i8] ; <[3 x i8]*> [#uses=0]
13
@.str2 = external constant [1 x i8] ; <[1 x i8]*> [#uses=0]
14
@.str3 = external constant [4 x i8] ; <[4 x i8]*> [#uses=0]
15
@.str4 = external constant [3 x i8] ; <[3 x i8]*> [#uses=0]
16
@.str5 = external constant [4 x i8] ; <[4 x i8]*> [#uses=0]
17
@.str6 = external constant [2 x i8] ; <[2 x i8]*> [#uses=0]
18
@.str7 = external constant [4 x i8] ; <[4 x i8]*> [#uses=0]
19
@.str8 = external constant [4 x i8] ; <[4 x i8]*> [#uses=0]
20
@.str9 = external constant [4 x i8] ; <[4 x i8]*> [#uses=0]
21
@.str10 = external constant [4 x i8] ; <[4 x i8]*> [#uses=0]
22
@.str11 = external constant [2 x i8] ; <[2 x i8]*> [#uses=0]
23
@.str12 = external constant [4 x i8] ; <[4 x i8]*> [#uses=0]
24
@.str13 = external constant [2 x i8] ; <[2 x i8]*> [#uses=0]
25
@.str14 = external constant [5 x i8] ; <[5 x i8]*> [#uses=0]
26
@.str15 = external constant [5 x i8] ; <[5 x i8]*> [#uses=0]
27
@.str16 = external constant [4 x i8] ; <[4 x i8]*> [#uses=0]
28
@.str17 = external constant [4 x i8] ; <[4 x i8]*> [#uses=0]
29
@.str18 = external constant [3 x i8] ; <[3 x i8]*> [#uses=0]
30
@.str19 = external constant [4 x i8] ; <[4 x i8]*> [#uses=0]
31
@.str20 = external constant [4 x i8] ; <[4 x i8]*> [#uses=0]
32
@.str21 = external constant [4 x i8] ; <[4 x i8]*> [#uses=0]
33
@.str22 = external constant [4 x i8] ; <[4 x i8]*> [#uses=0]
34
@.str23 = external constant [5 x i8] ; <[5 x i8]*> [#uses=0]
35
@.str24 = external constant [4 x i8] ; <[4 x i8]*> [#uses=0]
36
@.str25 = external constant [6 x i8] ; <[6 x i8]*> [#uses=0]
37
@.str26 = external constant [5 x i8] ; <[5 x i8]*> [#uses=0]
38
@.str27 = external constant [6 x i8] ; <[6 x i8]*> [#uses=0]
39
@r = external global [17 x i32] ; <[17 x i32]*> [#uses=0]
40
@.str28 = external constant [3 x i8] ; <[3 x i8]*> [#uses=0]
41
@.str29 = external constant [5 x i8] ; <[5 x i8]*> [#uses=0]
42
@pgm = external global [5 x { i32, [3 x i32] }] ; <[5 x { i32, [3 x i32] }]*> [#uses=4]
43
@.str30 = external constant [3 x i8] ; <[3 x i8]*> [#uses=0]
44
@.str31 = external constant [13 x i8] ; <[13 x i8]*> [#uses=0]
45
@.str32 = external constant [3 x i8] ; <[3 x i8]*> [#uses=0]
46
@.str33 = external constant [4 x i8] ; <[4 x i8]*> [#uses=0]
47
@.str34 = external constant [20 x i8] ; <[20 x i8]*> [#uses=0]
48
@numi = external global i32 ; <i32*> [#uses=7]
49
@.str35 = external constant [10 x i8] ; <[10 x i8]*> [#uses=0]
50
@counter = external global [5 x i32] ; <[5 x i32]*> [#uses=2]
51
@itrialx.2510 = external global i32 ; <i32*> [#uses=0]
52
@.str36 = external constant [43 x i8] ; <[43 x i8]*> [#uses=0]
53
@.str37 = external constant [42 x i8] ; <[42 x i8]*> [#uses=0]
54
@corr_result = external global i32 ; <i32*> [#uses=0]
55
@.str38 = external constant [3 x i8] ; <[3 x i8]*> [#uses=0]
56
@.str39 = external constant [5 x i8] ; <[5 x i8]*> [#uses=0]
57
@.str40 = external constant [47 x i8] ; <[47 x i8]*> [#uses=0]
58
@correct_result = external global [17 x i32] ; <[17 x i32]*> [#uses=1]
59
@.str41 = external constant [46 x i8] ; <[46 x i8]*> [#uses=0]
60
@.str42 = external constant [32 x i8] ; <[32 x i8]*> [#uses=0]
61
@.str43 = external constant [44 x i8] ; <[44 x i8]*> [#uses=1]
62
@.str44 = external constant [21 x i8] ; <[21 x i8]*> [#uses=1]
63
@.str45 = external constant [12 x i8] ; <[12 x i8]*> [#uses=1]
64
@.str46 = external constant [5 x i8] ; <[5 x i8]*> [#uses=1]
65
@.str47 = external constant [12 x i8] ; <[12 x i8]*> [#uses=1]
67
declare i32 @neg(i32, i32, i32)
69
declare i32 @Not(i32, i32, i32)
71
declare i32 @pop(i32, i32, i32)
73
declare i32 @nlz(i32, i32, i32)
75
declare i32 @rev(i32, i32, i32)
77
declare i32 @add(i32, i32, i32)
79
declare i32 @sub(i32, i32, i32)
81
declare i32 @mul(i32, i32, i32)
83
declare i32 @divide(i32, i32, i32)
85
declare i32 @divu(i32, i32, i32)
87
declare i32 @And(i32, i32, i32)
89
declare i32 @Or(i32, i32, i32)
91
declare i32 @Xor(i32, i32, i32)
93
declare i32 @rotl(i32, i32, i32)
95
declare i32 @shl(i32, i32, i32)
97
declare i32 @shr(i32, i32, i32)
99
declare i32 @shrs(i32, i32, i32)
101
declare i32 @cmpeq(i32, i32, i32)
103
declare i32 @cmplt(i32, i32, i32)
105
declare i32 @cmpltu(i32, i32, i32)
107
declare i32 @seleq(i32, i32, i32)
109
declare i32 @sellt(i32, i32, i32)
111
declare i32 @selle(i32, i32, i32)
113
declare void @print_expr(i32)
115
declare i32 @printf(i8*, ...)
117
declare i32 @putchar(i32)
119
declare void @print_pgm()
121
declare void @simulate_one_instruction(i32)
123
declare i32 @check(i32)
125
declare i32 @puts(i8*)
127
declare void @fix_operands(i32)
129
declare void @abort()
131
declare i32 @increment()
133
declare i32 @search()
135
define i32 @main(i32 %argc, i8** %argv) {
137
%argc_addr = alloca i32 ; <i32*> [#uses=1]
138
%argv_addr = alloca i8** ; <i8***> [#uses=1]
139
%retval = alloca i32, align 4 ; <i32*> [#uses=2]
140
%tmp = alloca i32, align 4 ; <i32*> [#uses=2]
141
%i = alloca i32, align 4 ; <i32*> [#uses=21]
142
%num_sol = alloca i32, align 4 ; <i32*> [#uses=4]
143
%total = alloca i32, align 4 ; <i32*> [#uses=4]
144
%"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0]
145
store i32 %argc, i32* %argc_addr
146
store i8** %argv, i8*** %argv_addr
147
store i32 0, i32* %num_sol
148
store i32 1, i32* @numi
151
bb: ; preds = %cond_next97
152
%tmp1 = load i32, i32* @numi ; <i32> [#uses=1]
153
%tmp2 = getelementptr [44 x i8], [44 x i8]* @.str43, i32 0, i32 0 ; <i8*> [#uses=1]
154
%tmp3 = call i32 (i8*, ...) @printf( i8* %tmp2, i32 %tmp1 ) ; <i32> [#uses=0]
159
%tmp5 = load i32, i32* %i ; <i32> [#uses=1]
160
%tmp6 = load i32, i32* %i ; <i32> [#uses=1]
161
%tmp7 = getelementptr [17 x i32], [17 x i32]* @trialx, i32 0, i32 %tmp6 ; <i32*> [#uses=1]
162
%tmp8 = load i32, i32* %tmp7 ; <i32> [#uses=1]
163
%tmp9 = call i32 @userfun( i32 %tmp8 ) ; <i32> [#uses=1]
164
%tmp10 = getelementptr [17 x i32], [17 x i32]* @correct_result, i32 0, i32 %tmp5 ; <i32*> [#uses=1]
165
store i32 %tmp9, i32* %tmp10
166
%tmp11 = load i32, i32* %i ; <i32> [#uses=1]
167
%tmp12 = add i32 %tmp11, 1 ; <i32> [#uses=1]
168
store i32 %tmp12, i32* %i
171
bb13: ; preds = %bb4, %bb
172
%tmp14 = load i32, i32* %i ; <i32> [#uses=1]
173
%tmp15 = icmp sle i32 %tmp14, 16 ; <i1> [#uses=1]
174
%tmp1516 = zext i1 %tmp15 to i32 ; <i32> [#uses=1]
175
%toBool = icmp ne i32 %tmp1516, 0 ; <i1> [#uses=1]
176
br i1 %toBool, label %bb4, label %bb17
178
bb17: ; preds = %bb13
182
bb18: ; preds = %bb49
183
%tmp19 = load i32, i32* %i ; <i32> [#uses=1]
184
%tmp20 = getelementptr [5 x { i32, [3 x i32] }], [5 x { i32, [3 x i32] }]* @pgm, i32 0, i32 %tmp19 ; <{ i32, [3 x i32] }*> [#uses=1]
185
%tmp21 = getelementptr { i32, [3 x i32] }, { i32, [3 x i32] }* %tmp20, i32 0, i32 0 ; <i32*> [#uses=1]
186
store i32 0, i32* %tmp21
187
%tmp22 = load i32, i32* %i ; <i32> [#uses=1]
188
%tmp23 = getelementptr [13 x %struct.anon], [13 x %struct.anon]* @isa, i32 0, i32 0 ; <%struct.anon*> [#uses=1]
189
%tmp24 = getelementptr %struct.anon, %struct.anon* %tmp23, i32 0, i32 3 ; <[3 x i32]*> [#uses=1]
190
%tmp25 = getelementptr [3 x i32], [3 x i32]* %tmp24, i32 0, i32 0 ; <i32*> [#uses=1]
191
%tmp26 = load i32, i32* %tmp25 ; <i32> [#uses=1]
192
%tmp27 = getelementptr [5 x { i32, [3 x i32] }], [5 x { i32, [3 x i32] }]* @pgm, i32 0, i32 %tmp22 ; <{ i32, [3 x i32] }*> [#uses=1]
193
%tmp28 = getelementptr { i32, [3 x i32] }, { i32, [3 x i32] }* %tmp27, i32 0, i32 1 ; <[3 x i32]*> [#uses=1]
194
%tmp29 = getelementptr [3 x i32], [3 x i32]* %tmp28, i32 0, i32 0 ; <i32*> [#uses=1]
195
store i32 %tmp26, i32* %tmp29
196
%tmp30 = load i32, i32* %i ; <i32> [#uses=1]
197
%tmp31 = getelementptr [13 x %struct.anon], [13 x %struct.anon]* @isa, i32 0, i32 0 ; <%struct.anon*> [#uses=1]
198
%tmp32 = getelementptr %struct.anon, %struct.anon* %tmp31, i32 0, i32 3 ; <[3 x i32]*> [#uses=1]
199
%tmp33 = getelementptr [3 x i32], [3 x i32]* %tmp32, i32 0, i32 1 ; <i32*> [#uses=1]
200
%tmp34 = load i32, i32* %tmp33 ; <i32> [#uses=1]
201
%tmp35 = getelementptr [5 x { i32, [3 x i32] }], [5 x { i32, [3 x i32] }]* @pgm, i32 0, i32 %tmp30 ; <{ i32, [3 x i32] }*> [#uses=1]
202
%tmp36 = getelementptr { i32, [3 x i32] }, { i32, [3 x i32] }* %tmp35, i32 0, i32 1 ; <[3 x i32]*> [#uses=1]
203
%tmp37 = getelementptr [3 x i32], [3 x i32]* %tmp36, i32 0, i32 1 ; <i32*> [#uses=1]
204
store i32 %tmp34, i32* %tmp37
205
%tmp38 = load i32, i32* %i ; <i32> [#uses=1]
206
%tmp39 = getelementptr [13 x %struct.anon], [13 x %struct.anon]* @isa, i32 0, i32 0 ; <%struct.anon*> [#uses=1]
207
%tmp40 = getelementptr %struct.anon, %struct.anon* %tmp39, i32 0, i32 3 ; <[3 x i32]*> [#uses=1]
208
%tmp41 = getelementptr [3 x i32], [3 x i32]* %tmp40, i32 0, i32 2 ; <i32*> [#uses=1]
209
%tmp42 = load i32, i32* %tmp41 ; <i32> [#uses=1]
210
%tmp43 = getelementptr [5 x { i32, [3 x i32] }], [5 x { i32, [3 x i32] }]* @pgm, i32 0, i32 %tmp38 ; <{ i32, [3 x i32] }*> [#uses=1]
211
%tmp44 = getelementptr { i32, [3 x i32] }, { i32, [3 x i32] }* %tmp43, i32 0, i32 1 ; <[3 x i32]*> [#uses=1]
212
%tmp45 = getelementptr [3 x i32], [3 x i32]* %tmp44, i32 0, i32 2 ; <i32*> [#uses=1]
213
store i32 %tmp42, i32* %tmp45
214
%tmp46 = load i32, i32* %i ; <i32> [#uses=1]
215
call void @fix_operands( i32 %tmp46 )
216
%tmp47 = load i32, i32* %i ; <i32> [#uses=1]
217
%tmp48 = add i32 %tmp47, 1 ; <i32> [#uses=1]
218
store i32 %tmp48, i32* %i
221
bb49: ; preds = %bb18, %bb17
222
%tmp50 = load i32, i32* @numi ; <i32> [#uses=1]
223
%tmp51 = load i32, i32* %i ; <i32> [#uses=1]
224
%tmp52 = icmp slt i32 %tmp51, %tmp50 ; <i1> [#uses=1]
225
%tmp5253 = zext i1 %tmp52 to i32 ; <i32> [#uses=1]
226
%toBool54 = icmp ne i32 %tmp5253, 0 ; <i1> [#uses=1]
227
br i1 %toBool54, label %bb18, label %bb55
229
bb55: ; preds = %bb49
230
%tmp56 = call i32 @search( ) ; <i32> [#uses=1]
231
store i32 %tmp56, i32* %num_sol
232
%tmp57 = getelementptr [21 x i8], [21 x i8]* @.str44, i32 0, i32 0 ; <i8*> [#uses=1]
233
%tmp58 = load i32, i32* %num_sol ; <i32> [#uses=1]
234
%tmp59 = call i32 (i8*, ...) @printf( i8* %tmp57, i32 %tmp58 ) ; <i32> [#uses=0]
235
%tmp60 = load i32, i32* @counters ; <i32> [#uses=1]
236
%tmp61 = icmp ne i32 %tmp60, 0 ; <i1> [#uses=1]
237
%tmp6162 = zext i1 %tmp61 to i32 ; <i32> [#uses=1]
238
%toBool63 = icmp ne i32 %tmp6162, 0 ; <i1> [#uses=1]
239
br i1 %toBool63, label %cond_true, label %cond_next
241
cond_true: ; preds = %bb55
242
store i32 0, i32* %total
243
%tmp64 = getelementptr [12 x i8], [12 x i8]* @.str45, i32 0, i32 0 ; <i8*> [#uses=1]
244
%tmp65 = call i32 (i8*, ...) @printf( i8* %tmp64 ) ; <i32> [#uses=0]
248
bb66: ; preds = %bb79
249
%tmp67 = load i32, i32* %i ; <i32> [#uses=1]
250
%tmp68 = getelementptr [5 x i32], [5 x i32]* @counter, i32 0, i32 %tmp67 ; <i32*> [#uses=1]
251
%tmp69 = load i32, i32* %tmp68 ; <i32> [#uses=1]
252
%tmp70 = getelementptr [5 x i8], [5 x i8]* @.str46, i32 0, i32 0 ; <i8*> [#uses=1]
253
%tmp71 = call i32 (i8*, ...) @printf( i8* %tmp70, i32 %tmp69 ) ; <i32> [#uses=0]
254
%tmp72 = load i32, i32* %i ; <i32> [#uses=1]
255
%tmp73 = getelementptr [5 x i32], [5 x i32]* @counter, i32 0, i32 %tmp72 ; <i32*> [#uses=1]
256
%tmp74 = load i32, i32* %tmp73 ; <i32> [#uses=1]
257
%tmp75 = load i32, i32* %total ; <i32> [#uses=1]
258
%tmp76 = add i32 %tmp74, %tmp75 ; <i32> [#uses=1]
259
store i32 %tmp76, i32* %total
260
%tmp77 = load i32, i32* %i ; <i32> [#uses=1]
261
%tmp78 = add i32 %tmp77, 1 ; <i32> [#uses=1]
262
store i32 %tmp78, i32* %i
265
bb79: ; preds = %bb66, %cond_true
266
%tmp80 = load i32, i32* @numi ; <i32> [#uses=1]
267
%tmp81 = load i32, i32* %i ; <i32> [#uses=1]
268
%tmp82 = icmp slt i32 %tmp81, %tmp80 ; <i1> [#uses=1]
269
%tmp8283 = zext i1 %tmp82 to i32 ; <i32> [#uses=1]
270
%toBool84 = icmp ne i32 %tmp8283, 0 ; <i1> [#uses=1]
271
br i1 %toBool84, label %bb66, label %bb85
273
bb85: ; preds = %bb79
274
%tmp86 = getelementptr [12 x i8], [12 x i8]* @.str47, i32 0, i32 0 ; <i8*> [#uses=1]
275
%tmp87 = load i32, i32* %total ; <i32> [#uses=1]
276
%tmp88 = call i32 (i8*, ...) @printf( i8* %tmp86, i32 %tmp87 ) ; <i32> [#uses=0]
279
cond_next: ; preds = %bb85, %bb55
280
%tmp89 = load i32, i32* @numi ; <i32> [#uses=1]
281
%tmp90 = add i32 %tmp89, 1 ; <i32> [#uses=1]
282
store i32 %tmp90, i32* @numi
285
bb91: ; preds = %cond_next, %entry
286
%tmp92 = load i32, i32* @numi ; <i32> [#uses=1]
287
%tmp93 = icmp sgt i32 %tmp92, 5 ; <i1> [#uses=1]
288
%tmp9394 = zext i1 %tmp93 to i32 ; <i32> [#uses=1]
289
%toBool95 = icmp ne i32 %tmp9394, 0 ; <i1> [#uses=1]
290
br i1 %toBool95, label %cond_true96, label %cond_next97
292
cond_true96: ; preds = %bb91
295
cond_next97: ; preds = %bb91
296
%tmp98 = load i32, i32* %num_sol ; <i32> [#uses=1]
297
%tmp99 = icmp eq i32 %tmp98, 0 ; <i1> [#uses=1]
298
%tmp99100 = zext i1 %tmp99 to i32 ; <i32> [#uses=1]
299
%toBool101 = icmp ne i32 %tmp99100, 0 ; <i1> [#uses=1]
300
br i1 %toBool101, label %bb, label %bb102
302
bb102: ; preds = %cond_next97, %cond_true96
303
store i32 0, i32* %tmp
304
%tmp103 = load i32, i32* %tmp ; <i32> [#uses=1]
305
store i32 %tmp103, i32* %retval
308
return: ; preds = %bb102
309
%retval104 = load i32, i32* %retval ; <i32> [#uses=1]
313
declare i32 @userfun(i32)