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.

285 lines
9.7 KiB

@hashmod = global i32 0
@maxn = global i32 10000000
@maxm = global i32 10000000
@bucket = global [10000000 x i32] zeroinitializer
@head = global [10000000 x i32] zeroinitializer
@next = global [10000000 x i32] zeroinitializer
@nextvalue = global [10000000 x i32] zeroinitializer
@key = global [10000000 x i32] zeroinitializer
@value = global [10000000 x i32] zeroinitializer
@cnt = global i32 0
@keys = global [10000000 x i32] zeroinitializer
@values = global [10000000 x i32] zeroinitializer
@requests = global [10000000 x i32] zeroinitializer
@ans = global [10000000 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 @hash(i32 %arg.k) {
entry:
%t0 = alloca i32
store i32 %arg.k, i32* %t0
%t1 = load i32, i32* %t0
%t2 = load i32, i32* @hashmod
%t3 = srem i32 %t1, %t2
ret i32 %t3
}
define i32 @insert(i32 %arg.k, i32 %arg.v) {
entry:
%t6 = alloca i32
%t30 = alloca i32
%t4 = alloca i32
store i32 %arg.k, i32* %t4
%t5 = alloca i32
store i32 %arg.v, i32* %t5
%t7 = load i32, i32* %t4
%t8 = call i32 @hash(i32 %t7)
store i32 %t8, i32* %t6
%t9 = load i32, i32* %t6
%t10 = getelementptr inbounds [10000000 x i32], [10000000 x i32]* @head, i32 0, i32 %t9
%t11 = load i32, i32* %t10
%t12 = icmp eq i32 %t11, 0
%t13 = zext i1 %t12 to i32
%t14 = icmp ne i32 %t13, 0
br i1 %t14, label %if.then.1, label %if.end.2
if.then.1:
%t15 = load i32, i32* @cnt
%t16 = add i32 %t15, 1
store i32 %t16, i32* @cnt
%t17 = load i32, i32* %t6
%t18 = getelementptr inbounds [10000000 x i32], [10000000 x i32]* @head, i32 0, i32 %t17
%t19 = load i32, i32* @cnt
store i32 %t19, i32* %t18
%t20 = load i32, i32* @cnt
%t21 = getelementptr inbounds [10000000 x i32], [10000000 x i32]* @key, i32 0, i32 %t20
%t22 = load i32, i32* %t4
store i32 %t22, i32* %t21
%t23 = load i32, i32* @cnt
%t24 = getelementptr inbounds [10000000 x i32], [10000000 x i32]* @value, i32 0, i32 %t23
%t25 = load i32, i32* %t5
store i32 %t25, i32* %t24
%t26 = load i32, i32* @cnt
%t27 = getelementptr inbounds [10000000 x i32], [10000000 x i32]* @next, i32 0, i32 %t26
store i32 0, i32* %t27
%t28 = load i32, i32* @cnt
%t29 = getelementptr inbounds [10000000 x i32], [10000000 x i32]* @nextvalue, i32 0, i32 %t28
store i32 0, i32* %t29
ret i32 0
if.end.2:
%t31 = load i32, i32* %t6
%t32 = getelementptr inbounds [10000000 x i32], [10000000 x i32]* @head, i32 0, i32 %t31
%t33 = load i32, i32* %t32
store i32 %t33, i32* %t30
br label %while.cond.3
while.cond.3:
%t34 = load i32, i32* %t30
%t35 = icmp ne i32 %t34, 0
%t36 = zext i1 %t35 to i32
%t37 = icmp ne i32 %t36, 0
br i1 %t37, label %while.body.4, label %while.end.5
while.body.4:
%t38 = load i32, i32* %t30
%t39 = getelementptr inbounds [10000000 x i32], [10000000 x i32]* @key, i32 0, i32 %t38
%t40 = load i32, i32* %t39
%t41 = load i32, i32* %t4
%t42 = icmp eq i32 %t40, %t41
%t43 = zext i1 %t42 to i32
%t44 = icmp ne i32 %t43, 0
br i1 %t44, label %if.then.6, label %if.end.7
while.end.5:
%t61 = load i32, i32* @cnt
%t62 = add i32 %t61, 1
store i32 %t62, i32* @cnt
%t63 = load i32, i32* @cnt
%t64 = getelementptr inbounds [10000000 x i32], [10000000 x i32]* @next, i32 0, i32 %t63
%t65 = load i32, i32* %t6
%t66 = getelementptr inbounds [10000000 x i32], [10000000 x i32]* @head, i32 0, i32 %t65
%t67 = load i32, i32* %t66
store i32 %t67, i32* %t64
%t68 = load i32, i32* %t6
%t69 = getelementptr inbounds [10000000 x i32], [10000000 x i32]* @head, i32 0, i32 %t68
%t70 = load i32, i32* @cnt
store i32 %t70, i32* %t69
%t71 = load i32, i32* @cnt
%t72 = getelementptr inbounds [10000000 x i32], [10000000 x i32]* @key, i32 0, i32 %t71
%t73 = load i32, i32* %t4
store i32 %t73, i32* %t72
%t74 = load i32, i32* @cnt
%t75 = getelementptr inbounds [10000000 x i32], [10000000 x i32]* @value, i32 0, i32 %t74
%t76 = load i32, i32* %t5
store i32 %t76, i32* %t75
%t77 = load i32, i32* @cnt
%t78 = getelementptr inbounds [10000000 x i32], [10000000 x i32]* @nextvalue, i32 0, i32 %t77
store i32 0, i32* %t78
ret i32 0
if.then.6:
%t45 = load i32, i32* @cnt
%t46 = add i32 %t45, 1
store i32 %t46, i32* @cnt
%t47 = load i32, i32* @cnt
%t48 = getelementptr inbounds [10000000 x i32], [10000000 x i32]* @nextvalue, i32 0, i32 %t47
%t49 = load i32, i32* %t30
%t50 = getelementptr inbounds [10000000 x i32], [10000000 x i32]* @nextvalue, i32 0, i32 %t49
%t51 = load i32, i32* %t50
store i32 %t51, i32* %t48
%t52 = load i32, i32* %t30
%t53 = getelementptr inbounds [10000000 x i32], [10000000 x i32]* @nextvalue, i32 0, i32 %t52
%t54 = load i32, i32* @cnt
store i32 %t54, i32* %t53
%t55 = load i32, i32* @cnt
%t56 = getelementptr inbounds [10000000 x i32], [10000000 x i32]* @value, i32 0, i32 %t55
%t57 = load i32, i32* %t5
store i32 %t57, i32* %t56
ret i32 1
if.end.7:
%t58 = load i32, i32* %t30
%t59 = getelementptr inbounds [10000000 x i32], [10000000 x i32]* @next, i32 0, i32 %t58
%t60 = load i32, i32* %t59
store i32 %t60, i32* %t30
br label %while.cond.3
}
define i32 @reduce(i32 %arg.k) {
entry:
%t80 = alloca i32
%t83 = alloca i32
%t98 = alloca i32
%t99 = alloca i32
%t79 = alloca i32
store i32 %arg.k, i32* %t79
%t81 = load i32, i32* %t79
%t82 = call i32 @hash(i32 %t81)
store i32 %t82, i32* %t80
%t84 = load i32, i32* %t80
%t85 = getelementptr inbounds [10000000 x i32], [10000000 x i32]* @head, i32 0, i32 %t84
%t86 = load i32, i32* %t85
store i32 %t86, i32* %t83
br label %while.cond.8
while.cond.8:
%t87 = load i32, i32* %t83
%t88 = icmp ne i32 %t87, 0
%t89 = zext i1 %t88 to i32
%t90 = icmp ne i32 %t89, 0
br i1 %t90, label %while.body.9, label %while.end.10
while.body.9:
%t91 = load i32, i32* %t83
%t92 = getelementptr inbounds [10000000 x i32], [10000000 x i32]* @key, i32 0, i32 %t91
%t93 = load i32, i32* %t92
%t94 = load i32, i32* %t79
%t95 = icmp eq i32 %t93, %t94
%t96 = zext i1 %t95 to i32
%t97 = icmp ne i32 %t96, 0
br i1 %t97, label %if.then.11, label %if.end.12
while.end.10:
ret i32 0
if.then.11:
store i32 0, i32* %t98
%t100 = load i32, i32* %t83
store i32 %t100, i32* %t99
br label %while.cond.13
if.end.12:
%t114 = load i32, i32* %t83
%t115 = getelementptr inbounds [10000000 x i32], [10000000 x i32]* @next, i32 0, i32 %t114
%t116 = load i32, i32* %t115
store i32 %t116, i32* %t83
br label %while.cond.8
while.cond.13:
%t101 = load i32, i32* %t99
%t102 = icmp ne i32 %t101, 0
%t103 = zext i1 %t102 to i32
%t104 = icmp ne i32 %t103, 0
br i1 %t104, label %while.body.14, label %while.end.15
while.body.14:
%t105 = load i32, i32* %t98
%t106 = load i32, i32* %t99
%t107 = getelementptr inbounds [10000000 x i32], [10000000 x i32]* @value, i32 0, i32 %t106
%t108 = load i32, i32* %t107
%t109 = add i32 %t105, %t108
store i32 %t109, i32* %t98
%t110 = load i32, i32* %t99
%t111 = getelementptr inbounds [10000000 x i32], [10000000 x i32]* @nextvalue, i32 0, i32 %t110
%t112 = load i32, i32* %t111
store i32 %t112, i32* %t99
br label %while.cond.13
while.end.15:
%t113 = load i32, i32* %t98
ret i32 %t113
}
define i32 @main() {
entry:
%t118 = alloca i32
%t121 = alloca i32
%t124 = alloca i32
%t128 = alloca i32
%t117 = call i32 @getint()
store i32 %t117, i32* @hashmod
%t119 = getelementptr inbounds [10000000 x i32], [10000000 x i32]* @keys, i32 0, i32 0
%t120 = call i32 @getarray(i32* %t119)
store i32 %t120, i32* %t118
%t122 = getelementptr inbounds [10000000 x i32], [10000000 x i32]* @values, i32 0, i32 0
%t123 = call i32 @getarray(i32* %t122)
store i32 %t123, i32* %t121
%t125 = getelementptr inbounds [10000000 x i32], [10000000 x i32]* @requests, i32 0, i32 0
%t126 = call i32 @getarray(i32* %t125)
store i32 %t126, i32* %t124
call void @starttime()
store i32 0, i32* %t128
br label %while.cond.16
while.cond.16:
%t129 = load i32, i32* %t128
%t130 = load i32, i32* %t118
%t131 = icmp slt i32 %t129, %t130
%t132 = zext i1 %t131 to i32
%t133 = icmp ne i32 %t132, 0
br i1 %t133, label %while.body.17, label %while.end.18
while.body.17:
%t134 = load i32, i32* %t128
%t135 = getelementptr inbounds [10000000 x i32], [10000000 x i32]* @keys, i32 0, i32 %t134
%t136 = load i32, i32* %t135
%t137 = load i32, i32* %t128
%t138 = getelementptr inbounds [10000000 x i32], [10000000 x i32]* @values, i32 0, i32 %t137
%t139 = load i32, i32* %t138
%t140 = call i32 @insert(i32 %t136, i32 %t139)
%t141 = load i32, i32* %t128
%t142 = add i32 %t141, 1
store i32 %t142, i32* %t128
br label %while.cond.16
while.end.18:
store i32 0, i32* %t128
br label %while.cond.19
while.cond.19:
%t143 = load i32, i32* %t128
%t144 = load i32, i32* %t124
%t145 = icmp slt i32 %t143, %t144
%t146 = zext i1 %t145 to i32
%t147 = icmp ne i32 %t146, 0
br i1 %t147, label %while.body.20, label %while.end.21
while.body.20:
%t148 = load i32, i32* %t128
%t149 = getelementptr inbounds [10000000 x i32], [10000000 x i32]* @ans, i32 0, i32 %t148
%t150 = load i32, i32* %t128
%t151 = getelementptr inbounds [10000000 x i32], [10000000 x i32]* @requests, i32 0, i32 %t150
%t152 = load i32, i32* %t151
%t153 = call i32 @reduce(i32 %t152)
store i32 %t153, i32* %t149
%t154 = load i32, i32* %t128
%t155 = add i32 %t154, 1
store i32 %t155, i32* %t128
br label %while.cond.19
while.end.21:
call void @stoptime()
%t157 = load i32, i32* %t124
%t158 = getelementptr inbounds [10000000 x i32], [10000000 x i32]* @ans, i32 0, i32 0
call void @putarray(i32 %t157, i32* %t158)
ret i32 0
}