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.

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