You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
2.1 KiB

declare i32 @getint()
declare float @getfloat()
declare i32 @getarray(i32* %arg.a)
declare i32 @getfarray(float* %arg.a)
declare i32 @getch()
declare void @putint(i32 %arg.x)
declare void @putfloat(float %arg.x)
declare void @putarray(i32 %arg.n, i32* %arg.a)
declare void @putfarray(i32 %arg.n, float* %arg.a)
declare void @putch(i32 %arg.x)
declare void @starttime()
declare void @stoptime()
define i32 @deepWhileBr(i32 %arg.a, i32 %arg.b) {
entry:
%t2 = alloca i32
%t10 = alloca i32
%t22 = alloca i32
%t0 = alloca i32
store i32 %arg.a, i32* %t0
%t1 = alloca i32
store i32 %arg.b, i32* %t1
store i32 0, i32* %t2
%t3 = load i32, i32* %t0
%t4 = load i32, i32* %t1
%t5 = add i32 %t3, %t4
store i32 %t5, i32* %t2
br label %while.cond.1
while.cond.1:
%t6 = load i32, i32* %t2
%t7 = icmp slt i32 %t6, 75
%t8 = zext i1 %t7 to i32
%t9 = icmp ne i32 %t8, 0
br i1 %t9, label %while.body.2, label %while.end.3
while.body.2:
store i32 0, i32* %t10
store i32 42, i32* %t10
%t11 = load i32, i32* %t2
%t12 = icmp slt i32 %t11, 100
%t13 = zext i1 %t12 to i32
%t14 = icmp ne i32 %t13, 0
br i1 %t14, label %if.then.4, label %if.end.5
while.end.3:
%t28 = load i32, i32* %t2
ret i32 %t28
if.then.4:
%t15 = load i32, i32* %t2
%t16 = load i32, i32* %t10
%t17 = add i32 %t15, %t16
store i32 %t17, i32* %t2
%t18 = load i32, i32* %t2
%t19 = icmp sgt i32 %t18, 99
%t20 = zext i1 %t19 to i32
%t21 = icmp ne i32 %t20, 0
br i1 %t21, label %if.then.6, label %if.end.7
if.end.5:
br label %while.cond.1
if.then.6:
store i32 0, i32* %t22
%t23 = load i32, i32* %t10
%t24 = mul i32 %t23, 2
store i32 %t24, i32* %t22
%t25 = icmp ne i32 1, 0
br i1 %t25, label %if.then.8, label %if.end.9
if.end.7:
br label %if.end.5
if.then.8:
%t26 = load i32, i32* %t22
%t27 = mul i32 %t26, 2
store i32 %t27, i32* %t2
br label %if.end.9
if.end.9:
br label %if.end.7
}
define i32 @main() {
entry:
%t29 = alloca i32
store i32 0, i32* %t29
store i32 2, i32* %t29
%t30 = load i32, i32* %t29
%t31 = load i32, i32* %t29
%t32 = call i32 @deepWhileBr(i32 %t30, i32 %t31)
ret i32 %t32
}