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.

344 lines
10 KiB

@maxm = global i32 1005
@maxn = global i32 105
@n = global i32 0
@m = global i32 0
@u = global [1005 x i32] zeroinitializer
@v = global [1005 x i32] zeroinitializer
@c = global [1005 x i32] zeroinitializer
@fa = global [1005 x i32] zeroinitializer
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 @quick_read() {
entry:
%t0 = alloca i32
%t2 = alloca i32
%t3 = alloca i32
%t1 = call i32 @getch()
store i32 %t1, i32* %t0
store i32 0, i32* %t2
store i32 0, i32* %t3
br label %while.cond.1
while.cond.1:
%t4 = load i32, i32* %t0
%t5 = icmp slt i32 %t4, 48
%t6 = zext i1 %t5 to i32
%t7 = icmp ne i32 %t6, 0
br i1 %t7, label %while.body.2, label %lor.rhs.4
while.body.2:
%t12 = load i32, i32* %t0
%t13 = icmp eq i32 %t12, 45
%t14 = zext i1 %t13 to i32
%t15 = icmp ne i32 %t14, 0
br i1 %t15, label %if.then.5, label %if.end.6
while.end.3:
br label %while.cond.7
lor.rhs.4:
%t8 = load i32, i32* %t0
%t9 = icmp sgt i32 %t8, 57
%t10 = zext i1 %t9 to i32
%t11 = icmp ne i32 %t10, 0
br i1 %t11, label %while.body.2, label %while.end.3
if.then.5:
store i32 1, i32* %t3
br label %if.end.6
if.end.6:
%t16 = call i32 @getch()
store i32 %t16, i32* %t0
br label %while.cond.1
while.cond.7:
%t17 = load i32, i32* %t0
%t18 = icmp sge i32 %t17, 48
%t19 = zext i1 %t18 to i32
%t20 = icmp ne i32 %t19, 0
br i1 %t20, label %land.rhs.10, label %while.end.9
while.body.8:
%t25 = load i32, i32* %t2
%t26 = mul i32 %t25, 10
%t27 = load i32, i32* %t0
%t28 = add i32 %t26, %t27
%t29 = sub i32 %t28, 48
store i32 %t29, i32* %t2
%t30 = call i32 @getch()
store i32 %t30, i32* %t0
br label %while.cond.7
while.end.9:
%t31 = load i32, i32* %t3
%t32 = icmp ne i32 %t31, 0
br i1 %t32, label %if.then.11, label %if.else.12
land.rhs.10:
%t21 = load i32, i32* %t0
%t22 = icmp sle i32 %t21, 57
%t23 = zext i1 %t22 to i32
%t24 = icmp ne i32 %t23, 0
br i1 %t24, label %while.body.8, label %while.end.9
if.then.11:
%t33 = load i32, i32* %t2
%t34 = sub i32 0, %t33
ret i32 %t34
if.else.12:
%t35 = load i32, i32* %t2
ret i32 %t35
if.end.13:
ret i32 0
}
define i32 @find(i32 %arg.x) {
entry:
%t45 = alloca i32
%t36 = alloca i32
store i32 %arg.x, i32* %t36
%t37 = load i32, i32* %t36
%t38 = load i32, i32* %t36
%t39 = getelementptr inbounds [1005 x i32], [1005 x i32]* @fa, i32 0, i32 %t38
%t40 = load i32, i32* %t39
%t41 = icmp eq i32 %t37, %t40
%t42 = zext i1 %t41 to i32
%t43 = icmp ne i32 %t42, 0
br i1 %t43, label %if.then.14, label %if.end.15
if.then.14:
%t44 = load i32, i32* %t36
ret i32 %t44
if.end.15:
%t46 = load i32, i32* %t36
%t47 = getelementptr inbounds [1005 x i32], [1005 x i32]* @fa, i32 0, i32 %t46
%t48 = load i32, i32* %t47
%t49 = call i32 @find(i32 %t48)
store i32 %t49, i32* %t45
%t50 = load i32, i32* %t36
%t51 = getelementptr inbounds [1005 x i32], [1005 x i32]* @fa, i32 0, i32 %t50
%t52 = load i32, i32* %t45
store i32 %t52, i32* %t51
%t53 = load i32, i32* %t45
ret i32 %t53
}
define i32 @same(i32 %arg.x, i32 %arg.y) {
entry:
%t54 = alloca i32
store i32 %arg.x, i32* %t54
%t55 = alloca i32
store i32 %arg.y, i32* %t55
%t56 = load i32, i32* %t54
%t57 = call i32 @find(i32 %t56)
store i32 %t57, i32* %t54
%t58 = load i32, i32* %t55
%t59 = call i32 @find(i32 %t58)
store i32 %t59, i32* %t55
%t60 = load i32, i32* %t54
%t61 = load i32, i32* %t55
%t62 = icmp eq i32 %t60, %t61
%t63 = zext i1 %t62 to i32
%t64 = icmp ne i32 %t63, 0
br i1 %t64, label %if.then.16, label %if.end.17
if.then.16:
ret i32 1
if.end.17:
ret i32 0
}
define i32 @prim() {
entry:
%t65 = alloca i32
%t71 = alloca i32
%t88 = alloca i32
%t136 = alloca i32
store i32 0, i32* %t65
br label %while.cond.18
while.cond.18:
%t66 = load i32, i32* %t65
%t67 = load i32, i32* @m
%t68 = icmp slt i32 %t66, %t67
%t69 = zext i1 %t68 to i32
%t70 = icmp ne i32 %t69, 0
br i1 %t70, label %while.body.19, label %while.end.20
while.body.19:
%t72 = load i32, i32* %t65
%t73 = add i32 %t72, 1
store i32 %t73, i32* %t71
br label %while.cond.21
while.end.20:
store i32 1, i32* %t65
br label %while.cond.26
while.cond.21:
%t74 = load i32, i32* %t71
%t75 = load i32, i32* @m
%t76 = icmp slt i32 %t74, %t75
%t77 = zext i1 %t76 to i32
%t78 = icmp ne i32 %t77, 0
br i1 %t78, label %while.body.22, label %while.end.23
while.body.22:
%t79 = load i32, i32* %t65
%t80 = getelementptr inbounds [1005 x i32], [1005 x i32]* @c, i32 0, i32 %t79
%t81 = load i32, i32* %t80
%t82 = load i32, i32* %t71
%t83 = getelementptr inbounds [1005 x i32], [1005 x i32]* @c, i32 0, i32 %t82
%t84 = load i32, i32* %t83
%t85 = icmp sgt i32 %t81, %t84
%t86 = zext i1 %t85 to i32
%t87 = icmp ne i32 %t86, 0
br i1 %t87, label %if.then.24, label %if.end.25
while.end.23:
%t124 = load i32, i32* %t65
%t125 = add i32 %t124, 1
store i32 %t125, i32* %t65
br label %while.cond.18
if.then.24:
%t89 = load i32, i32* %t65
%t90 = getelementptr inbounds [1005 x i32], [1005 x i32]* @u, i32 0, i32 %t89
%t91 = load i32, i32* %t90
store i32 %t91, i32* %t88
%t92 = load i32, i32* %t65
%t93 = getelementptr inbounds [1005 x i32], [1005 x i32]* @u, i32 0, i32 %t92
%t94 = load i32, i32* %t71
%t95 = getelementptr inbounds [1005 x i32], [1005 x i32]* @u, i32 0, i32 %t94
%t96 = load i32, i32* %t95
store i32 %t96, i32* %t93
%t97 = load i32, i32* %t71
%t98 = getelementptr inbounds [1005 x i32], [1005 x i32]* @u, i32 0, i32 %t97
%t99 = load i32, i32* %t88
store i32 %t99, i32* %t98
%t100 = load i32, i32* %t65
%t101 = getelementptr inbounds [1005 x i32], [1005 x i32]* @v, i32 0, i32 %t100
%t102 = load i32, i32* %t101
store i32 %t102, i32* %t88
%t103 = load i32, i32* %t65
%t104 = getelementptr inbounds [1005 x i32], [1005 x i32]* @v, i32 0, i32 %t103
%t105 = load i32, i32* %t71
%t106 = getelementptr inbounds [1005 x i32], [1005 x i32]* @v, i32 0, i32 %t105
%t107 = load i32, i32* %t106
store i32 %t107, i32* %t104
%t108 = load i32, i32* %t71
%t109 = getelementptr inbounds [1005 x i32], [1005 x i32]* @v, i32 0, i32 %t108
%t110 = load i32, i32* %t88
store i32 %t110, i32* %t109
%t111 = load i32, i32* %t65
%t112 = getelementptr inbounds [1005 x i32], [1005 x i32]* @c, i32 0, i32 %t111
%t113 = load i32, i32* %t112
store i32 %t113, i32* %t88
%t114 = load i32, i32* %t65
%t115 = getelementptr inbounds [1005 x i32], [1005 x i32]* @c, i32 0, i32 %t114
%t116 = load i32, i32* %t71
%t117 = getelementptr inbounds [1005 x i32], [1005 x i32]* @c, i32 0, i32 %t116
%t118 = load i32, i32* %t117
store i32 %t118, i32* %t115
%t119 = load i32, i32* %t71
%t120 = getelementptr inbounds [1005 x i32], [1005 x i32]* @c, i32 0, i32 %t119
%t121 = load i32, i32* %t88
store i32 %t121, i32* %t120
br label %if.end.25
if.end.25:
%t122 = load i32, i32* %t71
%t123 = add i32 %t122, 1
store i32 %t123, i32* %t71
br label %while.cond.21
while.cond.26:
%t126 = load i32, i32* %t65
%t127 = load i32, i32* @n
%t128 = icmp sle i32 %t126, %t127
%t129 = zext i1 %t128 to i32
%t130 = icmp ne i32 %t129, 0
br i1 %t130, label %while.body.27, label %while.end.28
while.body.27:
%t131 = load i32, i32* %t65
%t132 = getelementptr inbounds [1005 x i32], [1005 x i32]* @fa, i32 0, i32 %t131
%t133 = load i32, i32* %t65
store i32 %t133, i32* %t132
%t134 = load i32, i32* %t65
%t135 = add i32 %t134, 1
store i32 %t135, i32* %t65
br label %while.cond.26
while.end.28:
store i32 0, i32* %t65
store i32 0, i32* %t136
br label %while.cond.29
while.cond.29:
%t137 = load i32, i32* %t65
%t138 = load i32, i32* @m
%t139 = icmp slt i32 %t137, %t138
%t140 = zext i1 %t139 to i32
%t141 = icmp ne i32 %t140, 0
br i1 %t141, label %while.body.30, label %while.end.31
while.body.30:
%t142 = load i32, i32* %t65
%t143 = getelementptr inbounds [1005 x i32], [1005 x i32]* @u, i32 0, i32 %t142
%t144 = load i32, i32* %t143
%t145 = load i32, i32* %t65
%t146 = getelementptr inbounds [1005 x i32], [1005 x i32]* @v, i32 0, i32 %t145
%t147 = load i32, i32* %t146
%t148 = call i32 @same(i32 %t144, i32 %t147)
%t149 = icmp ne i32 %t148, 0
br i1 %t149, label %if.then.32, label %if.end.33
while.end.31:
%t165 = load i32, i32* %t136
ret i32 %t165
if.then.32:
br label %while.cond.29
if.end.33:
%t150 = load i32, i32* %t136
%t151 = load i32, i32* %t65
%t152 = getelementptr inbounds [1005 x i32], [1005 x i32]* @c, i32 0, i32 %t151
%t153 = load i32, i32* %t152
%t154 = add i32 %t150, %t153
store i32 %t154, i32* %t136
%t155 = load i32, i32* %t65
%t156 = getelementptr inbounds [1005 x i32], [1005 x i32]* @u, i32 0, i32 %t155
%t157 = load i32, i32* %t156
%t158 = call i32 @find(i32 %t157)
%t159 = getelementptr inbounds [1005 x i32], [1005 x i32]* @fa, i32 0, i32 %t158
%t160 = load i32, i32* %t65
%t161 = getelementptr inbounds [1005 x i32], [1005 x i32]* @v, i32 0, i32 %t160
%t162 = load i32, i32* %t161
store i32 %t162, i32* %t159
%t163 = load i32, i32* %t65
%t164 = add i32 %t163, 1
store i32 %t164, i32* %t65
br label %while.cond.29
}
define i32 @main() {
entry:
%t166 = alloca i32
%t168 = alloca i32
%t170 = alloca i32
%t167 = call i32 @quick_read()
store i32 %t167, i32* %t166
%t169 = call i32 @quick_read()
store i32 %t169, i32* %t168
store i32 0, i32* %t170
br label %while.cond.34
while.cond.34:
%t171 = load i32, i32* %t170
%t172 = load i32, i32* %t168
%t173 = icmp slt i32 %t171, %t172
%t174 = zext i1 %t173 to i32
%t175 = icmp ne i32 %t174, 0
br i1 %t175, label %while.body.35, label %while.end.36
while.body.35:
%t176 = load i32, i32* %t170
%t177 = getelementptr inbounds [1005 x i32], [1005 x i32]* @u, i32 0, i32 %t176
%t178 = call i32 @quick_read()
store i32 %t178, i32* %t177
%t179 = load i32, i32* %t170
%t180 = getelementptr inbounds [1005 x i32], [1005 x i32]* @v, i32 0, i32 %t179
%t181 = call i32 @quick_read()
store i32 %t181, i32* %t180
%t182 = load i32, i32* %t170
%t183 = getelementptr inbounds [1005 x i32], [1005 x i32]* @c, i32 0, i32 %t182
%t184 = call i32 @quick_read()
store i32 %t184, i32* %t183
%t185 = load i32, i32* %t170
%t186 = add i32 %t185, 1
store i32 %t186, i32* %t170
br label %while.cond.34
while.end.36:
%t187 = call i32 @prim()
ret i32 %t187
}