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.

71 lines
1.7 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 @ifWhile() {
entry:
%t0 = alloca i32
%t1 = alloca i32
store i32 0, i32* %t0
store i32 0, i32* %t0
store i32 0, i32* %t1
store i32 3, i32* %t1
%t2 = load i32, i32* %t0
%t3 = icmp eq i32 %t2, 5
%t4 = zext i1 %t3 to i32
%t5 = icmp ne i32 %t4, 0
br i1 %t5, label %if.then.1, label %if.else.2
if.then.1:
br label %while.cond.4
if.else.2:
br label %while.cond.7
if.end.3:
%t22 = load i32, i32* %t1
ret i32 %t22
while.cond.4:
%t6 = load i32, i32* %t1
%t7 = icmp eq i32 %t6, 2
%t8 = zext i1 %t7 to i32
%t9 = icmp ne i32 %t8, 0
br i1 %t9, label %while.body.5, label %while.end.6
while.body.5:
%t10 = load i32, i32* %t1
%t11 = add i32 %t10, 2
store i32 %t11, i32* %t1
br label %while.cond.4
while.end.6:
%t12 = load i32, i32* %t1
%t13 = add i32 %t12, 25
store i32 %t13, i32* %t1
br label %if.end.3
while.cond.7:
%t14 = load i32, i32* %t0
%t15 = icmp slt i32 %t14, 5
%t16 = zext i1 %t15 to i32
%t17 = icmp ne i32 %t16, 0
br i1 %t17, label %while.body.8, label %while.end.9
while.body.8:
%t18 = load i32, i32* %t1
%t19 = mul i32 %t18, 2
store i32 %t19, i32* %t1
%t20 = load i32, i32* %t0
%t21 = add i32 %t20, 1
store i32 %t21, i32* %t0
br label %while.cond.7
while.end.9:
br label %if.end.3
}
define i32 @main() {
entry:
%t23 = call i32 @ifWhile()
ret i32 %t23
}