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.

380 lines
12 KiB

@INF = global i32 1879048192
@size = global [10 x i32] zeroinitializer
@to = global [100 x i32] zeroinitializer
@cap = global [100 x i32] zeroinitializer
@rev = global [100 x i32] zeroinitializer
@used = global [10 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 void @my_memset(i32* %arg.arr, i32 %arg.val, i32 %arg.n) {
entry:
%t2 = alloca i32
%t0 = alloca i32
store i32 %arg.val, i32* %t0
%t1 = alloca i32
store i32 %arg.n, i32* %t1
store i32 0, i32* %t2
br label %while.cond.1
while.cond.1:
%t3 = load i32, i32* %t2
%t4 = load i32, i32* %t1
%t5 = icmp slt i32 %t3, %t4
%t6 = zext i1 %t5 to i32
%t7 = icmp ne i32 %t6, 0
br i1 %t7, label %while.body.2, label %while.end.3
while.body.2:
%t8 = load i32, i32* %t2
%t9 = getelementptr inbounds i32, i32* %arg.arr, i32 %t8
%t10 = load i32, i32* %t0
store i32 %t10, i32* %t9
%t11 = load i32, i32* %t2
%t12 = add i32 %t11, 1
store i32 %t12, i32* %t2
br label %while.cond.1
while.end.3:
ret void
}
define void @add_node(i32 %arg.u, i32 %arg.v, i32 %arg.c) {
entry:
%t13 = alloca i32
store i32 %arg.u, i32* %t13
%t14 = alloca i32
store i32 %arg.v, i32* %t14
%t15 = alloca i32
store i32 %arg.c, i32* %t15
%t16 = load i32, i32* %t13
%t17 = load i32, i32* %t13
%t18 = getelementptr inbounds [10 x i32], [10 x i32]* @size, i32 0, i32 %t17
%t19 = load i32, i32* %t18
%t20 = mul i32 %t16, 10
%t21 = add i32 %t20, %t19
%t22 = getelementptr inbounds [100 x i32], [100 x i32]* @to, i32 0, i32 %t21
%t23 = load i32, i32* %t14
store i32 %t23, i32* %t22
%t24 = load i32, i32* %t13
%t25 = load i32, i32* %t13
%t26 = getelementptr inbounds [10 x i32], [10 x i32]* @size, i32 0, i32 %t25
%t27 = load i32, i32* %t26
%t28 = mul i32 %t24, 10
%t29 = add i32 %t28, %t27
%t30 = getelementptr inbounds [100 x i32], [100 x i32]* @cap, i32 0, i32 %t29
%t31 = load i32, i32* %t15
store i32 %t31, i32* %t30
%t32 = load i32, i32* %t13
%t33 = load i32, i32* %t13
%t34 = getelementptr inbounds [10 x i32], [10 x i32]* @size, i32 0, i32 %t33
%t35 = load i32, i32* %t34
%t36 = mul i32 %t32, 10
%t37 = add i32 %t36, %t35
%t38 = getelementptr inbounds [100 x i32], [100 x i32]* @rev, i32 0, i32 %t37
%t39 = load i32, i32* %t14
%t40 = getelementptr inbounds [10 x i32], [10 x i32]* @size, i32 0, i32 %t39
%t41 = load i32, i32* %t40
store i32 %t41, i32* %t38
%t42 = load i32, i32* %t14
%t43 = load i32, i32* %t14
%t44 = getelementptr inbounds [10 x i32], [10 x i32]* @size, i32 0, i32 %t43
%t45 = load i32, i32* %t44
%t46 = mul i32 %t42, 10
%t47 = add i32 %t46, %t45
%t48 = getelementptr inbounds [100 x i32], [100 x i32]* @to, i32 0, i32 %t47
%t49 = load i32, i32* %t13
store i32 %t49, i32* %t48
%t50 = load i32, i32* %t14
%t51 = load i32, i32* %t14
%t52 = getelementptr inbounds [10 x i32], [10 x i32]* @size, i32 0, i32 %t51
%t53 = load i32, i32* %t52
%t54 = mul i32 %t50, 10
%t55 = add i32 %t54, %t53
%t56 = getelementptr inbounds [100 x i32], [100 x i32]* @cap, i32 0, i32 %t55
store i32 0, i32* %t56
%t57 = load i32, i32* %t14
%t58 = load i32, i32* %t14
%t59 = getelementptr inbounds [10 x i32], [10 x i32]* @size, i32 0, i32 %t58
%t60 = load i32, i32* %t59
%t61 = mul i32 %t57, 10
%t62 = add i32 %t61, %t60
%t63 = getelementptr inbounds [100 x i32], [100 x i32]* @rev, i32 0, i32 %t62
%t64 = load i32, i32* %t13
%t65 = getelementptr inbounds [10 x i32], [10 x i32]* @size, i32 0, i32 %t64
%t66 = load i32, i32* %t65
store i32 %t66, i32* %t63
%t67 = load i32, i32* %t13
%t68 = getelementptr inbounds [10 x i32], [10 x i32]* @size, i32 0, i32 %t67
%t69 = load i32, i32* %t13
%t70 = getelementptr inbounds [10 x i32], [10 x i32]* @size, i32 0, i32 %t69
%t71 = load i32, i32* %t70
%t72 = add i32 %t71, 1
store i32 %t72, i32* %t68
%t73 = load i32, i32* %t14
%t74 = getelementptr inbounds [10 x i32], [10 x i32]* @size, i32 0, i32 %t73
%t75 = load i32, i32* %t14
%t76 = getelementptr inbounds [10 x i32], [10 x i32]* @size, i32 0, i32 %t75
%t77 = load i32, i32* %t76
%t78 = add i32 %t77, 1
store i32 %t78, i32* %t74
ret void
}
define i32 @dfs(i32 %arg.s, i32 %arg.t, i32 %arg.f) {
entry:
%t90 = alloca i32
%t120 = alloca i32
%t138 = alloca i32
%t79 = alloca i32
store i32 %arg.s, i32* %t79
%t80 = alloca i32
store i32 %arg.t, i32* %t80
%t81 = alloca i32
store i32 %arg.f, i32* %t81
%t82 = load i32, i32* %t79
%t83 = load i32, i32* %t80
%t84 = icmp eq i32 %t82, %t83
%t85 = zext i1 %t84 to i32
%t86 = icmp ne i32 %t85, 0
br i1 %t86, label %if.then.4, label %if.end.5
if.then.4:
%t87 = load i32, i32* %t81
ret i32 %t87
if.end.5:
%t88 = load i32, i32* %t79
%t89 = getelementptr inbounds [10 x i32], [10 x i32]* @used, i32 0, i32 %t88
store i32 1, i32* %t89
store i32 0, i32* %t90
br label %while.cond.6
while.cond.6:
%t91 = load i32, i32* %t90
%t92 = load i32, i32* %t79
%t93 = getelementptr inbounds [10 x i32], [10 x i32]* @size, i32 0, i32 %t92
%t94 = load i32, i32* %t93
%t95 = icmp slt i32 %t91, %t94
%t96 = zext i1 %t95 to i32
%t97 = icmp ne i32 %t96, 0
br i1 %t97, label %while.body.7, label %while.end.8
while.body.7:
%t98 = load i32, i32* %t79
%t99 = load i32, i32* %t90
%t100 = mul i32 %t98, 10
%t101 = add i32 %t100, %t99
%t102 = getelementptr inbounds [100 x i32], [100 x i32]* @to, i32 0, i32 %t101
%t103 = load i32, i32* %t102
%t104 = getelementptr inbounds [10 x i32], [10 x i32]* @used, i32 0, i32 %t103
%t105 = load i32, i32* %t104
%t106 = icmp ne i32 %t105, 0
br i1 %t106, label %if.then.9, label %if.end.10
while.end.8:
ret i32 0
if.then.9:
%t107 = load i32, i32* %t90
%t108 = add i32 %t107, 1
store i32 %t108, i32* %t90
br label %while.cond.6
if.end.10:
%t109 = load i32, i32* %t79
%t110 = load i32, i32* %t90
%t111 = mul i32 %t109, 10
%t112 = add i32 %t111, %t110
%t113 = getelementptr inbounds [100 x i32], [100 x i32]* @cap, i32 0, i32 %t112
%t114 = load i32, i32* %t113
%t115 = icmp sle i32 %t114, 0
%t116 = zext i1 %t115 to i32
%t117 = icmp ne i32 %t116, 0
br i1 %t117, label %if.then.11, label %if.end.12
if.then.11:
%t118 = load i32, i32* %t90
%t119 = add i32 %t118, 1
store i32 %t119, i32* %t90
br label %while.cond.6
if.end.12:
store i32 0, i32* %t120
%t121 = load i32, i32* %t81
%t122 = load i32, i32* %t79
%t123 = load i32, i32* %t90
%t124 = mul i32 %t122, 10
%t125 = add i32 %t124, %t123
%t126 = getelementptr inbounds [100 x i32], [100 x i32]* @cap, i32 0, i32 %t125
%t127 = load i32, i32* %t126
%t128 = icmp slt i32 %t121, %t127
%t129 = zext i1 %t128 to i32
%t130 = icmp ne i32 %t129, 0
br i1 %t130, label %if.then.13, label %if.else.14
if.then.13:
%t131 = load i32, i32* %t81
store i32 %t131, i32* %t120
br label %if.end.15
if.else.14:
%t132 = load i32, i32* %t79
%t133 = load i32, i32* %t90
%t134 = mul i32 %t132, 10
%t135 = add i32 %t134, %t133
%t136 = getelementptr inbounds [100 x i32], [100 x i32]* @cap, i32 0, i32 %t135
%t137 = load i32, i32* %t136
store i32 %t137, i32* %t120
br label %if.end.15
if.end.15:
%t139 = load i32, i32* %t79
%t140 = load i32, i32* %t90
%t141 = mul i32 %t139, 10
%t142 = add i32 %t141, %t140
%t143 = getelementptr inbounds [100 x i32], [100 x i32]* @to, i32 0, i32 %t142
%t144 = load i32, i32* %t143
%t145 = load i32, i32* %t80
%t146 = load i32, i32* %t120
%t147 = call i32 @dfs(i32 %t144, i32 %t145, i32 %t146)
store i32 %t147, i32* %t138
%t148 = load i32, i32* %t138
%t149 = icmp sgt i32 %t148, 0
%t150 = zext i1 %t149 to i32
%t151 = icmp ne i32 %t150, 0
br i1 %t151, label %if.then.16, label %if.end.17
if.then.16:
%t152 = load i32, i32* %t79
%t153 = load i32, i32* %t90
%t154 = mul i32 %t152, 10
%t155 = add i32 %t154, %t153
%t156 = getelementptr inbounds [100 x i32], [100 x i32]* @cap, i32 0, i32 %t155
%t157 = load i32, i32* %t79
%t158 = load i32, i32* %t90
%t159 = mul i32 %t157, 10
%t160 = add i32 %t159, %t158
%t161 = getelementptr inbounds [100 x i32], [100 x i32]* @cap, i32 0, i32 %t160
%t162 = load i32, i32* %t161
%t163 = load i32, i32* %t138
%t164 = sub i32 %t162, %t163
store i32 %t164, i32* %t156
%t165 = load i32, i32* %t79
%t166 = load i32, i32* %t90
%t167 = mul i32 %t165, 10
%t168 = add i32 %t167, %t166
%t169 = getelementptr inbounds [100 x i32], [100 x i32]* @to, i32 0, i32 %t168
%t170 = load i32, i32* %t169
%t171 = load i32, i32* %t79
%t172 = load i32, i32* %t90
%t173 = mul i32 %t171, 10
%t174 = add i32 %t173, %t172
%t175 = getelementptr inbounds [100 x i32], [100 x i32]* @rev, i32 0, i32 %t174
%t176 = load i32, i32* %t175
%t177 = mul i32 %t170, 10
%t178 = add i32 %t177, %t176
%t179 = getelementptr inbounds [100 x i32], [100 x i32]* @cap, i32 0, i32 %t178
%t180 = load i32, i32* %t79
%t181 = load i32, i32* %t90
%t182 = mul i32 %t180, 10
%t183 = add i32 %t182, %t181
%t184 = getelementptr inbounds [100 x i32], [100 x i32]* @to, i32 0, i32 %t183
%t185 = load i32, i32* %t184
%t186 = load i32, i32* %t79
%t187 = load i32, i32* %t90
%t188 = mul i32 %t186, 10
%t189 = add i32 %t188, %t187
%t190 = getelementptr inbounds [100 x i32], [100 x i32]* @rev, i32 0, i32 %t189
%t191 = load i32, i32* %t190
%t192 = mul i32 %t185, 10
%t193 = add i32 %t192, %t191
%t194 = getelementptr inbounds [100 x i32], [100 x i32]* @cap, i32 0, i32 %t193
%t195 = load i32, i32* %t194
%t196 = load i32, i32* %t138
%t197 = add i32 %t195, %t196
store i32 %t197, i32* %t179
%t198 = load i32, i32* %t138
ret i32 %t198
if.end.17:
%t199 = load i32, i32* %t90
%t200 = add i32 %t199, 1
store i32 %t200, i32* %t90
br label %while.cond.6
}
define i32 @max_flow(i32 %arg.s, i32 %arg.t) {
entry:
%t203 = alloca i32
%t207 = alloca i32
%t201 = alloca i32
store i32 %arg.s, i32* %t201
%t202 = alloca i32
store i32 %arg.t, i32* %t202
store i32 0, i32* %t203
br label %while.cond.18
while.cond.18:
%t204 = icmp ne i32 1, 0
br i1 %t204, label %while.body.19, label %while.end.20
while.body.19:
%t205 = getelementptr inbounds [10 x i32], [10 x i32]* @used, i32 0, i32 0
call void @my_memset(i32* %t205, i32 0, i32 10)
%t208 = load i32, i32* %t201
%t209 = load i32, i32* %t202
%t210 = call i32 @dfs(i32 %t208, i32 %t209, i32 1879048192)
store i32 %t210, i32* %t207
%t211 = load i32, i32* %t207
%t212 = icmp eq i32 %t211, 0
%t213 = zext i1 %t212 to i32
%t214 = icmp ne i32 %t213, 0
br i1 %t214, label %if.then.21, label %if.end.22
while.end.20:
ret i32 0
if.then.21:
%t215 = load i32, i32* %t203
ret i32 %t215
if.end.22:
%t216 = load i32, i32* %t203
%t217 = load i32, i32* %t207
%t218 = add i32 %t216, %t217
store i32 %t218, i32* %t203
br label %while.cond.18
}
define i32 @main() {
entry:
%t219 = alloca i32
%t220 = alloca i32
%t229 = alloca i32
%t230 = alloca i32
%t233 = alloca i32
store i32 0, i32* %t219
store i32 0, i32* %t220
%t221 = call i32 @getint()
store i32 %t221, i32* %t219
%t222 = call i32 @getint()
store i32 %t222, i32* %t220
%t223 = getelementptr inbounds [10 x i32], [10 x i32]* @size, i32 0, i32 0
call void @my_memset(i32* %t223, i32 0, i32 10)
br label %while.cond.23
while.cond.23:
%t225 = load i32, i32* %t220
%t226 = icmp sgt i32 %t225, 0
%t227 = zext i1 %t226 to i32
%t228 = icmp ne i32 %t227, 0
br i1 %t228, label %while.body.24, label %while.end.25
while.body.24:
store i32 0, i32* %t229
store i32 0, i32* %t230
%t231 = call i32 @getint()
store i32 %t231, i32* %t229
%t232 = call i32 @getint()
store i32 %t232, i32* %t230
%t234 = call i32 @getint()
store i32 %t234, i32* %t233
%t235 = load i32, i32* %t229
%t236 = load i32, i32* %t230
%t237 = load i32, i32* %t233
call void @add_node(i32 %t235, i32 %t236, i32 %t237)
%t239 = load i32, i32* %t220
%t240 = sub i32 %t239, 1
store i32 %t240, i32* %t220
br label %while.cond.23
while.end.25:
%t241 = load i32, i32* %t219
%t242 = call i32 @max_flow(i32 1, i32 %t241)
call void @putint(i32 %t242)
call void @putch(i32 10)
ret i32 0
}