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.

104 lines
2.5 KiB

@lim = global i32 0
@mod = global i32 1000000007
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 @fun(i32 %arg.n, i32 %arg.dep) {
entry:
%t0 = alloca i32
store i32 %arg.n, i32* %t0
%t1 = alloca i32
store i32 %arg.dep, i32* %t1
%t2 = load i32, i32* %t0
%t3 = icmp eq i32 %t2, 1
%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:
%t6 = load i32, i32* %t1
ret i32 %t6
if.else.2:
%t7 = load i32, i32* %t0
%t8 = srem i32 %t7, 2
%t9 = icmp eq i32 %t8, 0
%t10 = zext i1 %t9 to i32
%t11 = icmp ne i32 %t10, 0
br i1 %t11, label %if.then.4, label %if.else.5
if.end.3:
ret i32 0
if.then.4:
%t12 = load i32, i32* %t0
%t13 = sdiv i32 %t12, 2
%t14 = load i32, i32* %t1
%t15 = add i32 %t14, 1
%t16 = call i32 @fun(i32 %t13, i32 %t15)
ret i32 %t16
if.else.5:
%t17 = load i32, i32* %t0
%t18 = mul i32 %t17, 3
%t19 = add i32 %t18, 1
%t20 = load i32, i32* @lim
%t21 = icmp sle i32 %t19, %t20
%t22 = zext i1 %t21 to i32
%t23 = icmp ne i32 %t22, 0
br i1 %t23, label %if.then.7, label %if.else.8
if.end.6:
ret i32 0
if.then.7:
%t24 = load i32, i32* %t0
%t25 = mul i32 %t24, 3
%t26 = add i32 %t25, 1
%t27 = load i32, i32* %t1
%t28 = add i32 %t27, 1
%t29 = call i32 @fun(i32 %t26, i32 %t28)
ret i32 %t29
if.else.8:
ret i32 0
if.end.9:
ret i32 0
}
define i32 @main() {
entry:
%t31 = alloca i32
%t32 = alloca i32
%t30 = call i32 @getint()
store i32 %t30, i32* @lim
store i32 0, i32* %t31
store i32 1, i32* %t32
call void @starttime()
br label %while.cond.10
while.cond.10:
%t34 = load i32, i32* %t32
%t35 = load i32, i32* @lim
%t36 = icmp sle i32 %t34, %t35
%t37 = zext i1 %t36 to i32
%t38 = icmp ne i32 %t37, 0
br i1 %t38, label %while.body.11, label %while.end.12
while.body.11:
%t39 = load i32, i32* %t31
%t40 = load i32, i32* %t32
%t41 = call i32 @fun(i32 %t40, i32 0)
%t42 = add i32 %t39, %t41
%t43 = srem i32 %t42, 1000000007
store i32 %t43, i32* %t31
%t44 = load i32, i32* %t32
%t45 = add i32 %t44, 1
store i32 %t45, i32* %t32
br label %while.cond.10
while.end.12:
call void @stoptime()
%t47 = load i32, i32* %t31
call void @putint(i32 %t47)
ret i32 0
}