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.

49 lines
1.2 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 void @reverse(i32 %arg.n) {
entry:
%t0 = alloca i32
store i32 %arg.n, i32* %t0
%t1 = alloca i32
store i32 0, i32* %t1
%t2 = load i32, i32* %t0
%t3 = icmp sle i32 %t2, 1
%t4 = icmp ne i32 %t3, 0
br i1 %t4, label %if.then.1, label %if.else.3
if.then.1:
%t5 = call i32 @getint()
store i32 %t5, i32* %t1
%t6 = load i32, i32* %t1
call void @putint(i32 %t6)
br label %if.end.2
if.end.2:
ret void
if.else.3:
%t8 = call i32 @getint()
store i32 %t8, i32* %t1
%t9 = load i32, i32* %t0
%t10 = sub i32 %t9, 1
call void @reverse(i32 %t10)
%t12 = load i32, i32* %t1
call void @putint(i32 %t12)
br label %if.end.2
}
define i32 @main() {
entry:
%t14 = alloca i32
store i32 200, i32* %t14
%t15 = load i32, i32* %t14
call void @reverse(i32 %t15)
ret i32 0
}