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.

149 lines
3.9 KiB

@seed = global i32 0
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 @rand() {
entry:
%t0 = load i32, i32* @seed
%t1 = mul i32 %t0, 19980130
%t2 = add i32 %t1, 23333
%t3 = srem i32 %t2, 100000007
store i32 %t3, i32* @seed
%t4 = load i32, i32* @seed
%t5 = icmp slt i32 %t4, 0
%t6 = zext i1 %t5 to i32
%t7 = icmp ne i32 %t6, 0
br i1 %t7, label %if.then.1, label %if.end.2
if.then.1:
%t8 = load i32, i32* @seed
%t9 = add i32 %t8, 100000007
store i32 %t9, i32* @seed
br label %if.end.2
if.end.2:
%t10 = load i32, i32* @seed
ret i32 %t10
}
define i32 @fib(i32 %arg.c, i32 %arg.n, i32 %arg.d) {
entry:
%t11 = alloca i32
store i32 %arg.c, i32* %t11
%t12 = alloca i32
store i32 %arg.n, i32* %t12
%t13 = alloca i32
store i32 %arg.d, i32* %t13
%t14 = load i32, i32* %t12
%t15 = icmp eq i32 %t14, 0
%t16 = zext i1 %t15 to i32
%t17 = icmp ne i32 %t16, 0
br i1 %t17, label %if.then.3, label %lor.rhs.5
if.then.3:
%t22 = load i32, i32* %t11
%t23 = add i32 %t22, 1
%t24 = sdiv i32 %t23, 2
%t25 = load i32, i32* %t13
%t26 = mul i32 %t25, 2
%t27 = srem i32 %t26, 3
%t28 = add i32 %t24, %t27
ret i32 %t28
if.end.4:
%t29 = load i32, i32* %t11
%t30 = add i32 %t29, 1
%t31 = load i32, i32* %t12
%t32 = sub i32 %t31, 1
%t33 = load i32, i32* %t13
%t34 = add i32 %t33, 1
%t35 = sdiv i32 %t34, 2
%t36 = call i32 @fib(i32 %t30, i32 %t32, i32 %t35)
%t37 = load i32, i32* %t11
%t38 = sub i32 %t37, 2
%t39 = sdiv i32 %t38, 2
%t40 = load i32, i32* %t12
%t41 = sub i32 %t40, 2
%t42 = load i32, i32* %t13
%t43 = sub i32 %t42, 3
%t44 = srem i32 %t43, 2
%t45 = call i32 @fib(i32 %t39, i32 %t41, i32 %t44)
%t46 = add i32 %t36, %t45
ret i32 %t46
lor.rhs.5:
%t18 = load i32, i32* %t12
%t19 = icmp eq i32 %t18, 1
%t20 = zext i1 %t19 to i32
%t21 = icmp ne i32 %t20, 0
br i1 %t21, label %if.then.3, label %if.end.4
}
define i32 @main() {
entry:
%t47 = alloca i32
%t48 = alloca i32
%t49 = alloca i32
store i32 0, i32* %t47
store i32 0, i32* %t48
%t50 = call i32 @getint()
store i32 %t50, i32* %t49
%t51 = call i32 @getint()
store i32 %t51, i32* @seed
call void @starttime()
br label %while.cond.6
while.cond.6:
%t53 = load i32, i32* %t48
%t54 = load i32, i32* %t49
%t55 = icmp slt i32 %t53, %t54
%t56 = zext i1 %t55 to i32
%t57 = icmp ne i32 %t56, 0
br i1 %t57, label %while.body.7, label %while.end.8
while.body.7:
%t58 = load i32, i32* %t48
%t59 = srem i32 %t58, 2
%t60 = icmp eq i32 %t59, 0
%t61 = zext i1 %t60 to i32
%t62 = icmp ne i32 %t61, 0
br i1 %t62, label %if.then.9, label %if.else.10
while.end.8:
call void @stoptime()
ret i32 0
if.then.9:
%t63 = load i32, i32* %t47
%t64 = call i32 @rand()
%t65 = sdiv i32 %t64, 10007
%t66 = load i32, i32* %t48
%t67 = load i32, i32* %t47
%t68 = call i32 @fib(i32 %t65, i32 %t66, i32 %t67)
%t69 = srem i32 %t68, 256
%t70 = sub i32 %t63, %t69
store i32 %t70, i32* %t47
br label %if.end.11
if.else.10:
%t71 = load i32, i32* %t47
%t72 = call i32 @rand()
%t73 = srem i32 %t72, -10007
%t74 = load i32, i32* %t48
%t75 = load i32, i32* %t48
%t76 = call i32 @fib(i32 %t73, i32 %t74, i32 %t75)
%t77 = srem i32 %t76, 256
%t78 = add i32 %t71, %t77
store i32 %t78, i32* %t47
br label %if.end.11
if.end.11:
%t79 = load i32, i32* %t47
%t80 = srem i32 %t79, 256
store i32 %t80, i32* %t47
%t81 = load i32, i32* %t47
call void @putint(i32 %t81)
call void @putch(i32 10)
%t84 = load i32, i32* %t48
%t85 = add i32 %t84, 1
store i32 %t85, i32* %t48
br label %while.cond.6
}