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.

74 lines
1.9 KiB

@a = global i32 1
@b = global i32 0
@c = global i32 1
@d = global i32 2
@e = global i32 4
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 @main() {
entry:
%t0 = alloca i32
store i32 0, i32* %t0
%t1 = load i32, i32* @a
%t2 = load i32, i32* @b
%t3 = mul i32 %t1, %t2
%t4 = load i32, i32* @c
%t5 = sdiv i32 %t3, %t4
%t6 = load i32, i32* @e
%t7 = load i32, i32* @d
%t8 = add i32 %t6, %t7
%t9 = icmp eq i32 %t5, %t8
%t10 = zext i1 %t9 to i32
%t11 = icmp ne i32 %t10, 0
br i1 %t11, label %land.rhs.4, label %lor.rhs.3
if.then.1:
store i32 1, i32* %t0
br label %if.end.2
if.end.2:
%t38 = load i32, i32* %t0
call void @putint(i32 %t38)
%t40 = load i32, i32* %t0
ret i32 %t40
lor.rhs.3:
%t25 = load i32, i32* @a
%t26 = load i32, i32* @b
%t27 = load i32, i32* @c
%t28 = mul i32 %t26, %t27
%t29 = sub i32 %t25, %t28
%t30 = load i32, i32* @d
%t31 = load i32, i32* @a
%t32 = load i32, i32* @c
%t33 = sdiv i32 %t31, %t32
%t34 = sub i32 %t30, %t33
%t35 = icmp eq i32 %t29, %t34
%t36 = zext i1 %t35 to i32
%t37 = icmp ne i32 %t36, 0
br i1 %t37, label %if.then.1, label %if.end.2
land.rhs.4:
%t12 = load i32, i32* @a
%t13 = load i32, i32* @a
%t14 = load i32, i32* @b
%t15 = add i32 %t13, %t14
%t16 = mul i32 %t12, %t15
%t17 = load i32, i32* @c
%t18 = add i32 %t16, %t17
%t19 = load i32, i32* @d
%t20 = load i32, i32* @e
%t21 = add i32 %t19, %t20
%t22 = icmp sle i32 %t18, %t21
%t23 = zext i1 %t22 to i32
%t24 = icmp ne i32 %t23, 0
br i1 %t24, label %if.then.1, label %lor.rhs.3
}