Skip to content

Instantly share code, notes, and snippets.

@csabahruska
Created February 24, 2018 22:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save csabahruska/0122b73529f4c377173454e1743eeea4 to your computer and use it in GitHub Desktop.
Save csabahruska/0122b73529f4c377173454e1743eeea4 to your computer and use it in GitHub Desktop.
LLVM jump table crash with x64 JIT
; ModuleID = 'basic'
source_filename = "<string>"
declare i64 @_prim_int_print(i64)
define <{ i64*, i64 }> @grinMain(i64* %_heap_ptr_.0) {
grinMain.entry:
%nodeAddress.4 = bitcast i64* %_heap_ptr_.0 to <{ i64, [1 x i64] }>*
store <{ i64, [1 x i64] }> <{ i64 0, [1 x i64] [i64 1] }>, <{ i64, [1 x i64] }>* %nodeAddress.4, align 1
%_heap_ptr_.5 = bitcast i64* %_heap_ptr_.0 to <{ i64, [2 x i64*], [1 x i64] }>*
%_heap_ptr_.6 = getelementptr inbounds <{ i64, [2 x i64*], [1 x i64] }>, <{ i64, [2 x i64*], [1 x i64] }>* %_heap_ptr_.5, i32 1
%_heap_ptr_.7 = bitcast <{ i64, [2 x i64*], [1 x i64] }>* %_heap_ptr_.6 to i64*
%nodeAddress.11 = bitcast i64* %_heap_ptr_.7 to <{ i64, [1 x i64] }>*
store <{ i64, [1 x i64] }> <{ i64 0, [1 x i64] [i64 10000] }>, <{ i64, [1 x i64] }>* %nodeAddress.11, align 1
%_heap_ptr_.12 = bitcast i64* %_heap_ptr_.7 to <{ i64, [2 x i64*], [1 x i64] }>*
%_heap_ptr_.13 = getelementptr inbounds <{ i64, [2 x i64*], [1 x i64] }>, <{ i64, [2 x i64*], [1 x i64] }>* %_heap_ptr_.12, i32 1
%_heap_ptr_.14 = bitcast <{ i64, [2 x i64*], [1 x i64] }>* %_heap_ptr_.13 to i64*
%node.16 = insertvalue <{ i64, [2 x i64*] }> <{ i64 1, [2 x i64*] undef }>, i64* %_heap_ptr_.0, 1, 0
%node.17 = insertvalue <{ i64, [2 x i64*] }> %node.16, i64* %_heap_ptr_.7, 1, 1
%tag.18 = extractvalue <{ i64, [2 x i64*] }> %node.17, 0
%nodeAddress.19 = bitcast i64* %_heap_ptr_.14 to <{ i64, [2 x i64*] }>*
store <{ i64, [2 x i64*] }> %node.17, <{ i64, [2 x i64*] }>* %nodeAddress.19, align 1
%_heap_ptr_.20 = bitcast i64* %_heap_ptr_.14 to <{ i64, [2 x i64*], [1 x i64] }>*
%_heap_ptr_.21 = getelementptr inbounds <{ i64, [2 x i64*], [1 x i64] }>, <{ i64, [2 x i64*], [1 x i64] }>* %_heap_ptr_.20, i32 1
%_heap_ptr_.22 = bitcast <{ i64, [2 x i64*], [1 x i64] }>* %_heap_ptr_.21 to i64*
%node.24 = insertvalue <{ i64, [1 x i64*] }> <{ i64 2, [1 x i64*] undef }>, i64* %_heap_ptr_.14, 1, 0
%tag.25 = extractvalue <{ i64, [1 x i64*] }> %node.24, 0
%nodeAddress.26 = bitcast i64* %_heap_ptr_.22 to <{ i64, [1 x i64*] }>*
store <{ i64, [1 x i64*] }> %node.24, <{ i64, [1 x i64*] }>* %nodeAddress.26, align 1
%_heap_ptr_.27 = bitcast i64* %_heap_ptr_.22 to <{ i64, [2 x i64*], [1 x i64] }>*
%_heap_ptr_.28 = getelementptr inbounds <{ i64, [2 x i64*], [1 x i64] }>, <{ i64, [2 x i64*], [1 x i64] }>* %_heap_ptr_.27, i32 1
%_heap_ptr_.29 = bitcast <{ i64, [2 x i64*], [1 x i64] }>* %_heap_ptr_.28 to i64*
%eval_result.30 = tail call <{ i64*, <{ i64, [2 x i64*], [1 x i64] }> }> @eval(i64* %_heap_ptr_.29, i64* %_heap_ptr_.22)
%_heap_ptr_.31 = extractvalue <{ i64*, <{ i64, [2 x i64*], [1 x i64] }> }> %eval_result.30, 0
%node.32 = extractvalue <{ i64*, <{ i64, [2 x i64*], [1 x i64] }> }> %eval_result.30, 1
%"r'" = extractvalue <{ i64, [2 x i64*], [1 x i64] }> %node.32, 2, 0
%grinMain_result.33 = call i64 @_prim_int_print(i64 %"r'")
%grinMain_wrapped_result.34 = insertvalue <{ i64*, i64 }> undef, i64* %_heap_ptr_.31, 0
%grinMain_wrapped_result.35 = insertvalue <{ i64*, i64 }> %grinMain_wrapped_result.34, i64 %grinMain_result.33, 1
ret <{ i64*, i64 }> %grinMain_wrapped_result.35
error_block: ; No predecessors!
%error_result.36 = tail call i64 @_prim_int_print(i64 666)
unreachable
}
define <{ i64*, <{ i64, [2 x i64*] }> }> @upto(i64* %_heap_ptr_.37, i64* %m, i64* %n) {
upto.entry:
%eval_result.38 = tail call <{ i64*, <{ i64, [2 x i64*], [1 x i64] }> }> @eval(i64* %_heap_ptr_.37, i64* %m)
%_heap_ptr_.39 = extractvalue <{ i64*, <{ i64, [2 x i64*], [1 x i64] }> }> %eval_result.38, 0
%node.40 = extractvalue <{ i64*, <{ i64, [2 x i64*], [1 x i64] }> }> %eval_result.38, 1
%"m'" = extractvalue <{ i64, [2 x i64*], [1 x i64] }> %node.40, 2, 0
%eval_result.41 = tail call <{ i64*, <{ i64, [2 x i64*], [1 x i64] }> }> @eval(i64* %_heap_ptr_.39, i64* %n)
%_heap_ptr_.42 = extractvalue <{ i64*, <{ i64, [2 x i64*], [1 x i64] }> }> %eval_result.41, 0
%node.43 = extractvalue <{ i64*, <{ i64, [2 x i64*], [1 x i64] }> }> %eval_result.41, 1
%"n'" = extractvalue <{ i64, [2 x i64*], [1 x i64] }> %node.43, 2, 0
%"b'.44" = icmp sgt i64 %"m'", %"n'"
switch i1 %"b'.44", label %error_block [
i1 true, label %switch.bool_True.45
i1 false, label %switch.bool_False.47
]
switch.bool_True.45: ; preds = %upto.entry
br label %switch.exit.67
switch.bool_False.47: ; preds = %upto.entry
%"m1'.48" = add i64 %"m'", 1
%node.50 = insertvalue <{ i64, [1 x i64] }> <{ i64 0, [1 x i64] undef }>, i64 %"m1'.48", 1, 0
%tag.51 = extractvalue <{ i64, [1 x i64] }> %node.50, 0
%nodeAddress.52 = bitcast i64* %_heap_ptr_.42 to <{ i64, [1 x i64] }>*
store <{ i64, [1 x i64] }> %node.50, <{ i64, [1 x i64] }>* %nodeAddress.52, align 1
%_heap_ptr_.53 = bitcast i64* %_heap_ptr_.42 to <{ i64, [2 x i64*], [1 x i64] }>*
%_heap_ptr_.54 = getelementptr inbounds <{ i64, [2 x i64*], [1 x i64] }>, <{ i64, [2 x i64*], [1 x i64] }>* %_heap_ptr_.53, i32 1
%_heap_ptr_.55 = bitcast <{ i64, [2 x i64*], [1 x i64] }>* %_heap_ptr_.54 to i64*
%node.57 = insertvalue <{ i64, [2 x i64*] }> <{ i64 1, [2 x i64*] undef }>, i64* %_heap_ptr_.42, 1, 0
%node.58 = insertvalue <{ i64, [2 x i64*] }> %node.57, i64* %n, 1, 1
%tag.59 = extractvalue <{ i64, [2 x i64*] }> %node.58, 0
%nodeAddress.60 = bitcast i64* %_heap_ptr_.55 to <{ i64, [2 x i64*] }>*
store <{ i64, [2 x i64*] }> %node.58, <{ i64, [2 x i64*] }>* %nodeAddress.60, align 1
%_heap_ptr_.61 = bitcast i64* %_heap_ptr_.55 to <{ i64, [2 x i64*], [1 x i64] }>*
%_heap_ptr_.62 = getelementptr inbounds <{ i64, [2 x i64*], [1 x i64] }>, <{ i64, [2 x i64*], [1 x i64] }>* %_heap_ptr_.61, i32 1
%_heap_ptr_.63 = bitcast <{ i64, [2 x i64*], [1 x i64] }>* %_heap_ptr_.62 to i64*
%node.65 = insertvalue <{ i64, [2 x i64*] }> <{ i64 4, [2 x i64*] undef }>, i64* %m, 1, 0
%node.66 = insertvalue <{ i64, [2 x i64*] }> %node.65, i64* %_heap_ptr_.55, 1, 1
%item.70 = extractvalue <{ i64, [2 x i64*] }> %node.66, 0
%node.71 = insertvalue <{ i64, [2 x i64*] }> undef, i64 %item.70, 0
%item.72 = extractvalue <{ i64, [2 x i64*] }> %node.66, 1, 1
%node.73 = insertvalue <{ i64, [2 x i64*] }> %node.71, i64* %item.72, 1, 1
%item.74 = extractvalue <{ i64, [2 x i64*] }> %node.66, 1, 0
%node.75 = insertvalue <{ i64, [2 x i64*] }> %node.73, i64* %item.74, 1, 0
br label %switch.exit.67
switch.exit.67: ; preds = %switch.bool_False.47, %switch.bool_True.45
%_heap_ptr_.76 = phi i64* [ %_heap_ptr_.42, %switch.bool_True.45 ], [ %_heap_ptr_.63, %switch.bool_False.47 ]
%upto_result.77 = phi <{ i64, [2 x i64*] }> [ <{ i64 3, [2 x i64*] undef }>, %switch.bool_True.45 ], [ %node.75, %switch.bool_False.47 ]
%upto_wrapped_result.78 = insertvalue <{ i64*, <{ i64, [2 x i64*] }> }> undef, i64* %_heap_ptr_.76, 0
%upto_wrapped_result.79 = insertvalue <{ i64*, <{ i64, [2 x i64*] }> }> %upto_wrapped_result.78, <{ i64, [2 x i64*] }> %upto_result.77, 1
ret <{ i64*, <{ i64, [2 x i64*] }> }> %upto_wrapped_result.79
error_block: ; preds = %upto.entry
%error_result.80 = tail call i64 @_prim_int_print(i64 666)
unreachable
}
define <{ i64*, <{ i64, [1 x i64] }> }> @sum(i64* %_heap_ptr_.81, i64* %l) {
sum.entry:
%eval_result.82 = tail call <{ i64*, <{ i64, [2 x i64*], [1 x i64] }> }> @eval(i64* %_heap_ptr_.81, i64* %l)
%_heap_ptr_.83 = extractvalue <{ i64*, <{ i64, [2 x i64*], [1 x i64] }> }> %eval_result.82, 0
%l2.84 = extractvalue <{ i64*, <{ i64, [2 x i64*], [1 x i64] }> }> %eval_result.82, 1
%tag.85 = extractvalue <{ i64, [2 x i64*], [1 x i64] }> %l2.84, 0
switch i64 %tag.85, label %error_block [
i64 3, label %switch.CNil.86
i64 4, label %switch.CCons.89
]
switch.CNil.86: ; preds = %sum.entry
br label %switch.exit.99
switch.CCons.89: ; preds = %sum.entry
%x = extractvalue <{ i64, [2 x i64*], [1 x i64] }> %l2.84, 1, 0
%xs = extractvalue <{ i64, [2 x i64*], [1 x i64] }> %l2.84, 1, 1
%eval_result.90 = tail call <{ i64*, <{ i64, [2 x i64*], [1 x i64] }> }> @eval(i64* %_heap_ptr_.83, i64* %x)
%_heap_ptr_.91 = extractvalue <{ i64*, <{ i64, [2 x i64*], [1 x i64] }> }> %eval_result.90, 0
%node.92 = extractvalue <{ i64*, <{ i64, [2 x i64*], [1 x i64] }> }> %eval_result.90, 1
%"x'" = extractvalue <{ i64, [2 x i64*], [1 x i64] }> %node.92, 2, 0
%sum_result.93 = tail call <{ i64*, <{ i64, [1 x i64] }> }> @sum(i64* %_heap_ptr_.91, i64* %xs)
%_heap_ptr_.94 = extractvalue <{ i64*, <{ i64, [1 x i64] }> }> %sum_result.93, 0
%node.95 = extractvalue <{ i64*, <{ i64, [1 x i64] }> }> %sum_result.93, 1
%"s'" = extractvalue <{ i64, [1 x i64] }> %node.95, 1, 0
%"ax'.96" = add i64 %"x'", %"s'"
%node.98 = insertvalue <{ i64, [1 x i64] }> <{ i64 0, [1 x i64] undef }>, i64 %"ax'.96", 1, 0
br label %switch.exit.99
switch.exit.99: ; preds = %switch.CCons.89, %switch.CNil.86
%_heap_ptr_.100 = phi i64* [ %_heap_ptr_.83, %switch.CNil.86 ], [ %_heap_ptr_.94, %switch.CCons.89 ]
%sum_result.101 = phi <{ i64, [1 x i64] }> [ zeroinitializer, %switch.CNil.86 ], [ %node.98, %switch.CCons.89 ]
%sum_wrapped_result.102 = insertvalue <{ i64*, <{ i64, [1 x i64] }> }> undef, i64* %_heap_ptr_.100, 0
%sum_wrapped_result.103 = insertvalue <{ i64*, <{ i64, [1 x i64] }> }> %sum_wrapped_result.102, <{ i64, [1 x i64] }> %sum_result.101, 1
ret <{ i64*, <{ i64, [1 x i64] }> }> %sum_wrapped_result.103
error_block: ; preds = %sum.entry
%error_result.104 = tail call i64 @_prim_int_print(i64 666)
unreachable
}
define <{ i64*, <{ i64, [2 x i64*], [1 x i64] }> }> @eval(i64* %_heap_ptr_.105, i64* %q) {
eval.entry:
%tag.106 = load i64, i64* %q, align 1
switch i64 %tag.106, label %error_block [
i64 4, label %tag.switch.CCons.107
i64 0, label %tag.switch.CInt.116
i64 3, label %tag.switch.CNil.123
i64 2, label %tag.switch.Fsum.128
i64 1, label %tag.switch.Fupto.135
]
tag.switch.CCons.107: ; preds = %eval.entry
%nodeAddress.108 = bitcast i64* %q to <{ i64, [2 x i64*] }>*
%node.109 = load <{ i64, [2 x i64*] }>, <{ i64, [2 x i64*] }>* %nodeAddress.108, align 1
%item.110 = extractvalue <{ i64, [2 x i64*] }> %node.109, 0
%node.111 = insertvalue <{ i64, [2 x i64*], [1 x i64] }> undef, i64 %item.110, 0
%item.112 = extractvalue <{ i64, [2 x i64*] }> %node.109, 1, 1
%node.113 = insertvalue <{ i64, [2 x i64*], [1 x i64] }> %node.111, i64* %item.112, 1, 1
%item.114 = extractvalue <{ i64, [2 x i64*] }> %node.109, 1, 0
%node.115 = insertvalue <{ i64, [2 x i64*], [1 x i64] }> %node.113, i64* %item.114, 1, 0
br label %tag.switch.exit.144
tag.switch.CInt.116: ; preds = %eval.entry
%nodeAddress.117 = bitcast i64* %q to <{ i64, [1 x i64] }>*
%node.118 = load <{ i64, [1 x i64] }>, <{ i64, [1 x i64] }>* %nodeAddress.117, align 1
%item.119 = extractvalue <{ i64, [1 x i64] }> %node.118, 0
%node.120 = insertvalue <{ i64, [2 x i64*], [1 x i64] }> undef, i64 %item.119, 0
%item.121 = extractvalue <{ i64, [1 x i64] }> %node.118, 1, 0
%node.122 = insertvalue <{ i64, [2 x i64*], [1 x i64] }> %node.120, i64 %item.121, 2, 0
br label %tag.switch.exit.144
tag.switch.CNil.123: ; preds = %eval.entry
%nodeAddress.124 = bitcast i64* %q to <{ i64 }>*
%node.125 = load <{ i64 }>, <{ i64 }>* %nodeAddress.124, align 1
%item.126 = extractvalue <{ i64 }> %node.125, 0
%node.127 = insertvalue <{ i64, [2 x i64*], [1 x i64] }> undef, i64 %item.126, 0
br label %tag.switch.exit.144
tag.switch.Fsum.128: ; preds = %eval.entry
%nodeAddress.129 = bitcast i64* %q to <{ i64, [1 x i64*] }>*
%node.130 = load <{ i64, [1 x i64*] }>, <{ i64, [1 x i64*] }>* %nodeAddress.129, align 1
%item.131 = extractvalue <{ i64, [1 x i64*] }> %node.130, 0
%node.132 = insertvalue <{ i64, [2 x i64*], [1 x i64] }> undef, i64 %item.131, 0
%item.133 = extractvalue <{ i64, [1 x i64*] }> %node.130, 1, 0
%node.134 = insertvalue <{ i64, [2 x i64*], [1 x i64] }> %node.132, i64* %item.133, 1, 0
br label %tag.switch.exit.144
tag.switch.Fupto.135: ; preds = %eval.entry
%nodeAddress.136 = bitcast i64* %q to <{ i64, [2 x i64*] }>*
%node.137 = load <{ i64, [2 x i64*] }>, <{ i64, [2 x i64*] }>* %nodeAddress.136, align 1
%item.138 = extractvalue <{ i64, [2 x i64*] }> %node.137, 0
%node.139 = insertvalue <{ i64, [2 x i64*], [1 x i64] }> undef, i64 %item.138, 0
%item.140 = extractvalue <{ i64, [2 x i64*] }> %node.137, 1, 1
%node.141 = insertvalue <{ i64, [2 x i64*], [1 x i64] }> %node.139, i64* %item.140, 1, 1
%item.142 = extractvalue <{ i64, [2 x i64*] }> %node.137, 1, 0
%node.143 = insertvalue <{ i64, [2 x i64*], [1 x i64] }> %node.141, i64* %item.142, 1, 0
br label %tag.switch.exit.144
tag.switch.exit.144: ; preds = %tag.switch.Fupto.135, %tag.switch.Fsum.128, %tag.switch.CNil.123, %tag.switch.CInt.116, %tag.switch.CCons.107
%_heap_ptr_.145 = phi i64* [ %_heap_ptr_.105, %tag.switch.CCons.107 ], [ %_heap_ptr_.105, %tag.switch.CInt.116 ], [ %_heap_ptr_.105, %tag.switch.CNil.123 ], [ %_heap_ptr_.105, %tag.switch.Fsum.128 ], [ %_heap_ptr_.105, %tag.switch.Fupto.135 ]
%v.146 = phi <{ i64, [2 x i64*], [1 x i64] }> [ %node.115, %tag.switch.CCons.107 ], [ %node.122, %tag.switch.CInt.116 ], [ %node.127, %tag.switch.CNil.123 ], [ %node.134, %tag.switch.Fsum.128 ], [ %node.143, %tag.switch.Fupto.135 ]
%tag.147 = extractvalue <{ i64, [2 x i64*], [1 x i64] }> %v.146, 0
switch i64 %tag.147, label %error_block [
i64 0, label %switch.CInt.148
i64 3, label %switch.CNil.149
i64 4, label %switch.CCons.150
i64 1, label %switch.Fupto.151
i64 2, label %switch.Fsum.170
]
switch.CInt.148: ; preds = %tag.switch.exit.144
%"x'1" = extractvalue <{ i64, [2 x i64*], [1 x i64] }> %v.146, 2, 0
br label %switch.exit.176
switch.CNil.149: ; preds = %tag.switch.exit.144
br label %switch.exit.176
switch.CCons.150: ; preds = %tag.switch.exit.144
%y = extractvalue <{ i64, [2 x i64*], [1 x i64] }> %v.146, 1, 0
%ys = extractvalue <{ i64, [2 x i64*], [1 x i64] }> %v.146, 1, 1
br label %switch.exit.176
switch.Fupto.151: ; preds = %tag.switch.exit.144
%a = extractvalue <{ i64, [2 x i64*], [1 x i64] }> %v.146, 1, 0
%b = extractvalue <{ i64, [2 x i64*], [1 x i64] }> %v.146, 1, 1
%upto_result.152 = tail call <{ i64*, <{ i64, [2 x i64*] }> }> @upto(i64* %_heap_ptr_.145, i64* %a, i64* %b)
%_heap_ptr_.153 = extractvalue <{ i64*, <{ i64, [2 x i64*] }> }> %upto_result.152, 0
%w.154 = extractvalue <{ i64*, <{ i64, [2 x i64*] }> }> %upto_result.152, 1
%tag.155 = extractvalue <{ i64, [2 x i64*] }> %w.154, 0
switch i64 %tag.155, label %error_block [
i64 4, label %tag.switch.CCons.156
i64 3, label %tag.switch.CNil.164
]
tag.switch.CCons.156: ; preds = %switch.Fupto.151
%item.157 = extractvalue <{ i64, [2 x i64*] }> %w.154, 0
%node.158 = insertvalue <{ i64, [2 x i64*] }> undef, i64 %item.157, 0
%item.159 = extractvalue <{ i64, [2 x i64*] }> %w.154, 1, 1
%node.160 = insertvalue <{ i64, [2 x i64*] }> %node.158, i64* %item.159, 1, 1
%item.161 = extractvalue <{ i64, [2 x i64*] }> %w.154, 1, 0
%node.162 = insertvalue <{ i64, [2 x i64*] }> %node.160, i64* %item.161, 1, 0
%nodeAddress.163 = bitcast i64* %q to <{ i64, [2 x i64*] }>*
store <{ i64, [2 x i64*] }> %node.162, <{ i64, [2 x i64*] }>* %nodeAddress.163, align 1
br label %tag.switch.exit.168
tag.switch.CNil.164: ; preds = %switch.Fupto.151
%item.165 = extractvalue <{ i64, [2 x i64*] }> %w.154, 0
%node.166 = insertvalue <{ i64 }> undef, i64 %item.165, 0
%nodeAddress.167 = bitcast i64* %q to <{ i64 }>*
store <{ i64 }> %node.166, <{ i64 }>* %nodeAddress.167, align 1
br label %tag.switch.exit.168
tag.switch.exit.168: ; preds = %tag.switch.CNil.164, %tag.switch.CCons.156
%_heap_ptr_.169 = phi i64* [ %_heap_ptr_.153, %tag.switch.CCons.156 ], [ %_heap_ptr_.153, %tag.switch.CNil.164 ]
%item.177 = extractvalue <{ i64, [2 x i64*] }> %w.154, 0
%node.178 = insertvalue <{ i64, [2 x i64*], [1 x i64] }> undef, i64 %item.177, 0
%item.179 = extractvalue <{ i64, [2 x i64*] }> %w.154, 1, 1
%node.180 = insertvalue <{ i64, [2 x i64*], [1 x i64] }> %node.178, i64* %item.179, 1, 1
%item.181 = extractvalue <{ i64, [2 x i64*] }> %w.154, 1, 0
%node.182 = insertvalue <{ i64, [2 x i64*], [1 x i64] }> %node.180, i64* %item.181, 1, 0
br label %switch.exit.176
switch.Fsum.170: ; preds = %tag.switch.exit.144
%c = extractvalue <{ i64, [2 x i64*], [1 x i64] }> %v.146, 1, 0
%sum_result.171 = tail call <{ i64*, <{ i64, [1 x i64] }> }> @sum(i64* %_heap_ptr_.145, i64* %c)
%_heap_ptr_.172 = extractvalue <{ i64*, <{ i64, [1 x i64] }> }> %sum_result.171, 0
%z.173 = extractvalue <{ i64*, <{ i64, [1 x i64] }> }> %sum_result.171, 1
%tag.174 = extractvalue <{ i64, [1 x i64] }> %z.173, 0
%nodeAddress.175 = bitcast i64* %q to <{ i64, [1 x i64] }>*
store <{ i64, [1 x i64] }> %z.173, <{ i64, [1 x i64] }>* %nodeAddress.175, align 1
%item.183 = extractvalue <{ i64, [1 x i64] }> %z.173, 0
%node.184 = insertvalue <{ i64, [2 x i64*], [1 x i64] }> undef, i64 %item.183, 0
%item.185 = extractvalue <{ i64, [1 x i64] }> %z.173, 1, 0
%node.186 = insertvalue <{ i64, [2 x i64*], [1 x i64] }> %node.184, i64 %item.185, 2, 0
br label %switch.exit.176
switch.exit.176: ; preds = %switch.Fsum.170, %tag.switch.exit.168, %switch.CCons.150, %switch.CNil.149, %switch.CInt.148
%_heap_ptr_.187 = phi i64* [ %_heap_ptr_.145, %switch.CInt.148 ], [ %_heap_ptr_.145, %switch.CNil.149 ], [ %_heap_ptr_.145, %switch.CCons.150 ], [ %_heap_ptr_.169, %tag.switch.exit.168 ], [ %_heap_ptr_.172, %switch.Fsum.170 ]
%eval_result.188 = phi <{ i64, [2 x i64*], [1 x i64] }> [ %v.146, %switch.CInt.148 ], [ %v.146, %switch.CNil.149 ], [ %v.146, %switch.CCons.150 ], [ %node.182, %tag.switch.exit.168 ], [ %node.186, %switch.Fsum.170 ]
%eval_wrapped_result.189 = insertvalue <{ i64*, <{ i64, [2 x i64*], [1 x i64] }> }> undef, i64* %_heap_ptr_.187, 0
%eval_wrapped_result.190 = insertvalue <{ i64*, <{ i64, [2 x i64*], [1 x i64] }> }> %eval_wrapped_result.189, <{ i64, [2 x i64*], [1 x i64] }> %eval_result.188, 1
ret <{ i64*, <{ i64, [2 x i64*], [1 x i64] }> }> %eval_wrapped_result.190
error_block: ; preds = %switch.Fupto.151, %tag.switch.exit.144, %eval.entry
%error_result.191 = tail call i64 @_prim_int_print(i64 666)
unreachable
}
.text
.file "<string>"
.globl grinMain # -- Begin function grinMain
.p2align 4, 0x90
.type grinMain,@function
grinMain: # @grinMain
.cfi_startproc
# BB#0: # %grinMain.entry
pushq %rbx
.Lcfi0:
.cfi_def_cfa_offset 16
subq $48, %rsp
.Lcfi1:
.cfi_def_cfa_offset 64
.Lcfi2:
.cfi_offset %rbx, -16
movq %rdi, %rax
movq $1, 8(%rax)
movq $0, (%rax)
leaq 32(%rax), %rcx
movq $10000, 40(%rax) # imm = 0x2710
movq $0, 32(%rax)
leaq 64(%rax), %rdx
movq %rcx, 80(%rax)
movq %rax, 72(%rax)
movq $1, 64(%rax)
movq %rdx, 104(%rax)
movq $2, 96(%rax)
leaq 96(%rax), %rdx
subq $-128, %rax
leaq 8(%rsp), %rdi
movq %rax, %rsi
callq eval
movq 8(%rsp), %rbx
movq 40(%rsp), %rdi
callq _prim_int_print
movq %rax, %rcx
movq %rbx, %rax
movq %rcx, %rdx
addq $48, %rsp
popq %rbx
retq
.Lfunc_end0:
.size grinMain, .Lfunc_end0-grinMain
.cfi_endproc
# -- End function
.globl upto # -- Begin function upto
.p2align 4, 0x90
.type upto,@function
upto: # @upto
.cfi_startproc
# BB#0: # %upto.entry
pushq %r15
.Lcfi3:
.cfi_def_cfa_offset 16
pushq %r14
.Lcfi4:
.cfi_def_cfa_offset 24
pushq %r12
.Lcfi5:
.cfi_def_cfa_offset 32
pushq %rbx
.Lcfi6:
.cfi_def_cfa_offset 40
subq $88, %rsp
.Lcfi7:
.cfi_def_cfa_offset 128
.Lcfi8:
.cfi_offset %rbx, -40
.Lcfi9:
.cfi_offset %r12, -32
.Lcfi10:
.cfi_offset %r14, -24
.Lcfi11:
.cfi_offset %r15, -16
movq %rcx, %r15
movq %rdx, %r14
movq %rdi, %r12
leaq 48(%rsp), %rdi
callq eval
movq 48(%rsp), %rsi
movq 80(%rsp), %rbx
leaq 8(%rsp), %rdi
movq %r15, %rdx
callq eval
movq 8(%rsp), %rax
cmpq 40(%rsp), %rbx
setg %cl
jg .LBB1_1
# BB#2: # %upto.entry
testb %cl, %cl
jne .LBB1_5
# BB#3: # %switch.bool_False.47
incq %rbx
movq %rbx, 8(%rax)
movq $0, (%rax)
movq %r15, 48(%rax)
movq %rax, 40(%rax)
movq $1, 32(%rax)
leaq 32(%rax), %rcx
addq $64, %rax
movl $4, %edx
jmp .LBB1_4
.LBB1_1:
movl $3, %edx
# implicit-def: %R14
# implicit-def: %RCX
.LBB1_4: # %switch.exit.67
movq %rdx, 8(%r12)
movq %rax, (%r12)
movq %r14, 16(%r12)
movq %rcx, 24(%r12)
movq %r12, %rax
addq $88, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
.LBB1_5: # %error_block
movl $666, %edi # imm = 0x29A
callq _prim_int_print
.Lfunc_end1:
.size upto, .Lfunc_end1-upto
.cfi_endproc
# -- End function
.globl sum # -- Begin function sum
.p2align 4, 0x90
.type sum,@function
sum: # @sum
.cfi_startproc
# BB#0: # %sum.entry
pushq %r14
.Lcfi12:
.cfi_def_cfa_offset 16
pushq %rbx
.Lcfi13:
.cfi_def_cfa_offset 24
subq $88, %rsp
.Lcfi14:
.cfi_def_cfa_offset 112
.Lcfi15:
.cfi_offset %rbx, -24
.Lcfi16:
.cfi_offset %r14, -16
movq %rsi, %rax
movq %rdi, %rcx
leaq 8(%rsp), %rdi
movq %rcx, %rsi
movq %rax, %rdx
callq eval
movq 8(%rsp), %rax
movq 16(%rsp), %rcx
xorl %edx, %edx
cmpq $3, %rcx
je .LBB2_1
# BB#2: # %sum.entry
cmpq $4, %rcx
jne .LBB2_5
# BB#3: # %switch.CCons.89
movq 32(%rsp), %r14
movq 24(%rsp), %rdx
leaq 48(%rsp), %rdi
movq %rax, %rsi
callq eval
movq 48(%rsp), %rdi
movq 80(%rsp), %rbx
movq %r14, %rsi
callq sum
addq %rbx, %rcx
xorl %edx, %edx
jmp .LBB2_4
.LBB2_1:
xorl %ecx, %ecx
.LBB2_4: # %switch.exit.99
addq $88, %rsp
popq %rbx
popq %r14
retq
.LBB2_5: # %error_block
movl $666, %edi # imm = 0x29A
callq _prim_int_print
.Lfunc_end2:
.size sum, .Lfunc_end2-sum
.cfi_endproc
# -- End function
.globl eval # -- Begin function eval
.p2align 4, 0x90
.type eval,@function
eval: # @eval
.cfi_startproc
# BB#0: # %eval.entry
pushq %r14
.Lcfi17:
.cfi_def_cfa_offset 16
pushq %rbx
.Lcfi18:
.cfi_def_cfa_offset 24
subq $40, %rsp
.Lcfi19:
.cfi_def_cfa_offset 64
.Lcfi20:
.cfi_offset %rbx, -24
.Lcfi21:
.cfi_offset %r14, -16
movq %rdx, %rbx
movq %rdi, %r14
movq (%rbx), %rax
cmpq $4, %rax
ja .LBB3_16
# BB#1: # %eval.entry
jmpq *.LJTI3_0(,%rax,8)
.LBB3_2: # %tag.switch.Fupto.135
movq 16(%rbx), %rcx
movq (%rbx), %rdx
movq 8(%rbx), %rax
jmp .LBB3_7
.LBB3_3: # %tag.switch.CNil.123
movq (%rbx), %rdx
# implicit-def: %RAX
jmp .LBB3_6
.LBB3_4: # %tag.switch.CInt.116
movq (%rbx), %rdx
movq 8(%rbx), %rdi
# implicit-def: %RAX
# implicit-def: %RCX
cmpq $4, %rdx
ja .LBB3_16
.LBB3_8: # %tag.switch.exit.144
jmpq *.LJTI3_1(,%rdx,8)
.LBB3_9: # %switch.Fupto.151
leaq 8(%rsp), %rdi
movq %rax, %rdx
callq upto
movq 32(%rsp), %rcx
movq 24(%rsp), %rax
movq 8(%rsp), %rsi
movq 16(%rsp), %rdx
cmpq $3, %rdx
je .LBB3_13
# BB#10: # %switch.Fupto.151
cmpq $4, %rdx
jne .LBB3_16
# BB#11: # %tag.switch.CCons.156
movq %rdx, (%rbx)
movq %rax, 8(%rbx)
movq %rcx, 16(%rbx)
jmp .LBB3_14
.LBB3_12: # %switch.Fsum.170
movq %rsi, %rdi
movq %rax, %rsi
callq sum
movq %rax, %rsi
movq %rcx, %rdi
movq %rdi, 8(%rbx)
movq %rdx, (%rbx)
# implicit-def: %RAX
# implicit-def: %RCX
jmp .LBB3_15
.LBB3_5: # %tag.switch.Fsum.128
movq (%rbx), %rdx
movq 8(%rbx), %rax
.LBB3_6: # %tag.switch.exit.144
# implicit-def: %RCX
.LBB3_7: # %tag.switch.exit.144
# implicit-def: %RDI
cmpq $4, %rdx
jbe .LBB3_8
.LBB3_16: # %error_block
movl $666, %edi # imm = 0x29A
callq _prim_int_print
.LBB3_13: # %tag.switch.CNil.164
movq %rdx, (%rbx)
.LBB3_14: # %switch.exit.176
# implicit-def: %RDI
.LBB3_15: # %switch.exit.176
movq %rdx, 8(%r14)
movq %rsi, (%r14)
movq %rax, 16(%r14)
movq %rcx, 24(%r14)
movq %rdi, 32(%r14)
movq %r14, %rax
addq $40, %rsp
popq %rbx
popq %r14
retq
.Lfunc_end3:
.size eval, .Lfunc_end3-eval
.cfi_endproc
.section .rodata,"a",@progbits
.p2align 3
.LJTI3_0:
.quad .LBB3_4
.quad .LBB3_2
.quad .LBB3_5
.quad .LBB3_3
.quad .LBB3_2
.LJTI3_1:
.quad .LBB3_15
.quad .LBB3_9
.quad .LBB3_12
.quad .LBB3_15
.quad .LBB3_15
# -- End function
.section ".note.GNU-stack","",@progbits
; ModuleID = 'basic'
source_filename = "<string>"
declare i64 @_prim_int_print(i64)
define <{ i64*, i64 }> @grinMain(i64* %_heap_ptr_.0) #0 {
grinMain.entry:
%nodeAddress.4 = bitcast i64* %_heap_ptr_.0 to <{ i64, [1 x i64] }>*
store <{ i64, [1 x i64] }> <{ i64 0, [1 x i64] [i64 1] }>, <{ i64, [1 x i64] }>* %nodeAddress.4, align 1
%_heap_ptr_.5 = bitcast i64* %_heap_ptr_.0 to <{ i64, [2 x i64*], [1 x i64] }>*
%_heap_ptr_.6 = getelementptr inbounds <{ i64, [2 x i64*], [1 x i64] }>, <{ i64, [2 x i64*], [1 x i64] }>* %_heap_ptr_.5, i32 1
%_heap_ptr_.7 = bitcast <{ i64, [2 x i64*], [1 x i64] }>* %_heap_ptr_.6 to i64*
%nodeAddress.11 = bitcast i64* %_heap_ptr_.7 to <{ i64, [1 x i64] }>*
store <{ i64, [1 x i64] }> <{ i64 0, [1 x i64] [i64 10000] }>, <{ i64, [1 x i64] }>* %nodeAddress.11, align 1
%_heap_ptr_.12 = bitcast i64* %_heap_ptr_.7 to <{ i64, [2 x i64*], [1 x i64] }>*
%_heap_ptr_.13 = getelementptr inbounds <{ i64, [2 x i64*], [1 x i64] }>, <{ i64, [2 x i64*], [1 x i64] }>* %_heap_ptr_.12, i32 1
%_heap_ptr_.14 = bitcast <{ i64, [2 x i64*], [1 x i64] }>* %_heap_ptr_.13 to i64*
%node.16 = insertvalue <{ i64, [2 x i64*] }> <{ i64 1, [2 x i64*] undef }>, i64* %_heap_ptr_.0, 1, 0
%node.17 = insertvalue <{ i64, [2 x i64*] }> %node.16, i64* %_heap_ptr_.7, 1, 1
%tag.18 = extractvalue <{ i64, [2 x i64*] }> %node.17, 0
%nodeAddress.19 = bitcast i64* %_heap_ptr_.14 to <{ i64, [2 x i64*] }>*
store <{ i64, [2 x i64*] }> %node.17, <{ i64, [2 x i64*] }>* %nodeAddress.19, align 1
%_heap_ptr_.20 = bitcast i64* %_heap_ptr_.14 to <{ i64, [2 x i64*], [1 x i64] }>*
%_heap_ptr_.21 = getelementptr inbounds <{ i64, [2 x i64*], [1 x i64] }>, <{ i64, [2 x i64*], [1 x i64] }>* %_heap_ptr_.20, i32 1
%_heap_ptr_.22 = bitcast <{ i64, [2 x i64*], [1 x i64] }>* %_heap_ptr_.21 to i64*
%node.24 = insertvalue <{ i64, [1 x i64*] }> <{ i64 2, [1 x i64*] undef }>, i64* %_heap_ptr_.14, 1, 0
%tag.25 = extractvalue <{ i64, [1 x i64*] }> %node.24, 0
%nodeAddress.26 = bitcast i64* %_heap_ptr_.22 to <{ i64, [1 x i64*] }>*
store <{ i64, [1 x i64*] }> %node.24, <{ i64, [1 x i64*] }>* %nodeAddress.26, align 1
%_heap_ptr_.27 = bitcast i64* %_heap_ptr_.22 to <{ i64, [2 x i64*], [1 x i64] }>*
%_heap_ptr_.28 = getelementptr inbounds <{ i64, [2 x i64*], [1 x i64] }>, <{ i64, [2 x i64*], [1 x i64] }>* %_heap_ptr_.27, i32 1
%_heap_ptr_.29 = bitcast <{ i64, [2 x i64*], [1 x i64] }>* %_heap_ptr_.28 to i64*
%eval_result.30 = tail call <{ i64*, <{ i64, [2 x i64*], [1 x i64] }> }> @eval(i64* %_heap_ptr_.29, i64* %_heap_ptr_.22)
%_heap_ptr_.31 = extractvalue <{ i64*, <{ i64, [2 x i64*], [1 x i64] }> }> %eval_result.30, 0
%node.32 = extractvalue <{ i64*, <{ i64, [2 x i64*], [1 x i64] }> }> %eval_result.30, 1
%"r'" = extractvalue <{ i64, [2 x i64*], [1 x i64] }> %node.32, 2, 0
%grinMain_result.33 = call i64 @_prim_int_print(i64 %"r'")
%grinMain_wrapped_result.34 = insertvalue <{ i64*, i64 }> undef, i64* %_heap_ptr_.31, 0
%grinMain_wrapped_result.35 = insertvalue <{ i64*, i64 }> %grinMain_wrapped_result.34, i64 %grinMain_result.33, 1
ret <{ i64*, i64 }> %grinMain_wrapped_result.35
error_block: ; No predecessors!
%error_result.36 = tail call i64 @_prim_int_print(i64 666)
unreachable
}
define <{ i64*, <{ i64, [2 x i64*] }> }> @upto(i64* %_heap_ptr_.37, i64* %m, i64* %n) #0 {
upto.entry:
%eval_result.38 = tail call <{ i64*, <{ i64, [2 x i64*], [1 x i64] }> }> @eval(i64* %_heap_ptr_.37, i64* %m)
%_heap_ptr_.39 = extractvalue <{ i64*, <{ i64, [2 x i64*], [1 x i64] }> }> %eval_result.38, 0
%node.40 = extractvalue <{ i64*, <{ i64, [2 x i64*], [1 x i64] }> }> %eval_result.38, 1
%"m'" = extractvalue <{ i64, [2 x i64*], [1 x i64] }> %node.40, 2, 0
%eval_result.41 = tail call <{ i64*, <{ i64, [2 x i64*], [1 x i64] }> }> @eval(i64* %_heap_ptr_.39, i64* %n)
%_heap_ptr_.42 = extractvalue <{ i64*, <{ i64, [2 x i64*], [1 x i64] }> }> %eval_result.41, 0
%node.43 = extractvalue <{ i64*, <{ i64, [2 x i64*], [1 x i64] }> }> %eval_result.41, 1
%"n'" = extractvalue <{ i64, [2 x i64*], [1 x i64] }> %node.43, 2, 0
%"b'.44" = icmp sgt i64 %"m'", %"n'"
switch i1 %"b'.44", label %error_block [
i1 true, label %switch.bool_True.45
i1 false, label %switch.bool_False.47
]
switch.bool_True.45: ; preds = %upto.entry
br label %switch.exit.67
switch.bool_False.47: ; preds = %upto.entry
%"m1'.48" = add i64 %"m'", 1
%node.50 = insertvalue <{ i64, [1 x i64] }> <{ i64 0, [1 x i64] undef }>, i64 %"m1'.48", 1, 0
%tag.51 = extractvalue <{ i64, [1 x i64] }> %node.50, 0
%nodeAddress.52 = bitcast i64* %_heap_ptr_.42 to <{ i64, [1 x i64] }>*
store <{ i64, [1 x i64] }> %node.50, <{ i64, [1 x i64] }>* %nodeAddress.52, align 1
%_heap_ptr_.53 = bitcast i64* %_heap_ptr_.42 to <{ i64, [2 x i64*], [1 x i64] }>*
%_heap_ptr_.54 = getelementptr inbounds <{ i64, [2 x i64*], [1 x i64] }>, <{ i64, [2 x i64*], [1 x i64] }>* %_heap_ptr_.53, i32 1
%_heap_ptr_.55 = bitcast <{ i64, [2 x i64*], [1 x i64] }>* %_heap_ptr_.54 to i64*
%node.57 = insertvalue <{ i64, [2 x i64*] }> <{ i64 1, [2 x i64*] undef }>, i64* %_heap_ptr_.42, 1, 0
%node.58 = insertvalue <{ i64, [2 x i64*] }> %node.57, i64* %n, 1, 1
%tag.59 = extractvalue <{ i64, [2 x i64*] }> %node.58, 0
%nodeAddress.60 = bitcast i64* %_heap_ptr_.55 to <{ i64, [2 x i64*] }>*
store <{ i64, [2 x i64*] }> %node.58, <{ i64, [2 x i64*] }>* %nodeAddress.60, align 1
%_heap_ptr_.61 = bitcast i64* %_heap_ptr_.55 to <{ i64, [2 x i64*], [1 x i64] }>*
%_heap_ptr_.62 = getelementptr inbounds <{ i64, [2 x i64*], [1 x i64] }>, <{ i64, [2 x i64*], [1 x i64] }>* %_heap_ptr_.61, i32 1
%_heap_ptr_.63 = bitcast <{ i64, [2 x i64*], [1 x i64] }>* %_heap_ptr_.62 to i64*
%node.65 = insertvalue <{ i64, [2 x i64*] }> <{ i64 4, [2 x i64*] undef }>, i64* %m, 1, 0
%node.66 = insertvalue <{ i64, [2 x i64*] }> %node.65, i64* %_heap_ptr_.55, 1, 1
%item.70 = extractvalue <{ i64, [2 x i64*] }> %node.66, 0
%node.71 = insertvalue <{ i64, [2 x i64*] }> undef, i64 %item.70, 0
%item.72 = extractvalue <{ i64, [2 x i64*] }> %node.66, 1, 1
%node.73 = insertvalue <{ i64, [2 x i64*] }> %node.71, i64* %item.72, 1, 1
%item.74 = extractvalue <{ i64, [2 x i64*] }> %node.66, 1, 0
%node.75 = insertvalue <{ i64, [2 x i64*] }> %node.73, i64* %item.74, 1, 0
br label %switch.exit.67
switch.exit.67: ; preds = %switch.bool_False.47, %switch.bool_True.45
%_heap_ptr_.76 = phi i64* [ %_heap_ptr_.42, %switch.bool_True.45 ], [ %_heap_ptr_.63, %switch.bool_False.47 ]
%upto_result.77 = phi <{ i64, [2 x i64*] }> [ <{ i64 3, [2 x i64*] undef }>, %switch.bool_True.45 ], [ %node.75, %switch.bool_False.47 ]
%upto_wrapped_result.78 = insertvalue <{ i64*, <{ i64, [2 x i64*] }> }> undef, i64* %_heap_ptr_.76, 0
%upto_wrapped_result.79 = insertvalue <{ i64*, <{ i64, [2 x i64*] }> }> %upto_wrapped_result.78, <{ i64, [2 x i64*] }> %upto_result.77, 1
ret <{ i64*, <{ i64, [2 x i64*] }> }> %upto_wrapped_result.79
error_block: ; preds = %upto.entry
%error_result.80 = tail call i64 @_prim_int_print(i64 666)
unreachable
}
define <{ i64*, <{ i64, [1 x i64] }> }> @sum(i64* %_heap_ptr_.81, i64* %l) #0 {
sum.entry:
%eval_result.82 = tail call <{ i64*, <{ i64, [2 x i64*], [1 x i64] }> }> @eval(i64* %_heap_ptr_.81, i64* %l)
%_heap_ptr_.83 = extractvalue <{ i64*, <{ i64, [2 x i64*], [1 x i64] }> }> %eval_result.82, 0
%l2.84 = extractvalue <{ i64*, <{ i64, [2 x i64*], [1 x i64] }> }> %eval_result.82, 1
%tag.85 = extractvalue <{ i64, [2 x i64*], [1 x i64] }> %l2.84, 0
switch i64 %tag.85, label %error_block [
i64 3, label %switch.CNil.86
i64 4, label %switch.CCons.89
]
switch.CNil.86: ; preds = %sum.entry
br label %switch.exit.99
switch.CCons.89: ; preds = %sum.entry
%x = extractvalue <{ i64, [2 x i64*], [1 x i64] }> %l2.84, 1, 0
%xs = extractvalue <{ i64, [2 x i64*], [1 x i64] }> %l2.84, 1, 1
%eval_result.90 = tail call <{ i64*, <{ i64, [2 x i64*], [1 x i64] }> }> @eval(i64* %_heap_ptr_.83, i64* %x)
%_heap_ptr_.91 = extractvalue <{ i64*, <{ i64, [2 x i64*], [1 x i64] }> }> %eval_result.90, 0
%node.92 = extractvalue <{ i64*, <{ i64, [2 x i64*], [1 x i64] }> }> %eval_result.90, 1
%"x'" = extractvalue <{ i64, [2 x i64*], [1 x i64] }> %node.92, 2, 0
%sum_result.93 = tail call <{ i64*, <{ i64, [1 x i64] }> }> @sum(i64* %_heap_ptr_.91, i64* %xs)
%_heap_ptr_.94 = extractvalue <{ i64*, <{ i64, [1 x i64] }> }> %sum_result.93, 0
%node.95 = extractvalue <{ i64*, <{ i64, [1 x i64] }> }> %sum_result.93, 1
%"s'" = extractvalue <{ i64, [1 x i64] }> %node.95, 1, 0
%"ax'.96" = add i64 %"x'", %"s'"
%node.98 = insertvalue <{ i64, [1 x i64] }> <{ i64 0, [1 x i64] undef }>, i64 %"ax'.96", 1, 0
br label %switch.exit.99
switch.exit.99: ; preds = %switch.CCons.89, %switch.CNil.86
%_heap_ptr_.100 = phi i64* [ %_heap_ptr_.83, %switch.CNil.86 ], [ %_heap_ptr_.94, %switch.CCons.89 ]
%sum_result.101 = phi <{ i64, [1 x i64] }> [ zeroinitializer, %switch.CNil.86 ], [ %node.98, %switch.CCons.89 ]
%sum_wrapped_result.102 = insertvalue <{ i64*, <{ i64, [1 x i64] }> }> undef, i64* %_heap_ptr_.100, 0
%sum_wrapped_result.103 = insertvalue <{ i64*, <{ i64, [1 x i64] }> }> %sum_wrapped_result.102, <{ i64, [1 x i64] }> %sum_result.101, 1
ret <{ i64*, <{ i64, [1 x i64] }> }> %sum_wrapped_result.103
error_block: ; preds = %sum.entry
%error_result.104 = tail call i64 @_prim_int_print(i64 666)
unreachable
}
define <{ i64*, <{ i64, [2 x i64*], [1 x i64] }> }> @eval(i64* %_heap_ptr_.105, i64* %q) #0 {
eval.entry:
%tag.106 = load i64, i64* %q, align 1
switch i64 %tag.106, label %error_block [
i64 4, label %tag.switch.CCons.107
i64 0, label %tag.switch.CInt.116
i64 3, label %tag.switch.CNil.123
i64 2, label %tag.switch.Fsum.128
i64 1, label %tag.switch.Fupto.135
]
tag.switch.CCons.107: ; preds = %eval.entry
%nodeAddress.108 = bitcast i64* %q to <{ i64, [2 x i64*] }>*
%node.109 = load <{ i64, [2 x i64*] }>, <{ i64, [2 x i64*] }>* %nodeAddress.108, align 1
%item.110 = extractvalue <{ i64, [2 x i64*] }> %node.109, 0
%node.111 = insertvalue <{ i64, [2 x i64*], [1 x i64] }> undef, i64 %item.110, 0
%item.112 = extractvalue <{ i64, [2 x i64*] }> %node.109, 1, 1
%node.113 = insertvalue <{ i64, [2 x i64*], [1 x i64] }> %node.111, i64* %item.112, 1, 1
%item.114 = extractvalue <{ i64, [2 x i64*] }> %node.109, 1, 0
%node.115 = insertvalue <{ i64, [2 x i64*], [1 x i64] }> %node.113, i64* %item.114, 1, 0
br label %tag.switch.exit.144
tag.switch.CInt.116: ; preds = %eval.entry
%nodeAddress.117 = bitcast i64* %q to <{ i64, [1 x i64] }>*
%node.118 = load <{ i64, [1 x i64] }>, <{ i64, [1 x i64] }>* %nodeAddress.117, align 1
%item.119 = extractvalue <{ i64, [1 x i64] }> %node.118, 0
%node.120 = insertvalue <{ i64, [2 x i64*], [1 x i64] }> undef, i64 %item.119, 0
%item.121 = extractvalue <{ i64, [1 x i64] }> %node.118, 1, 0
%node.122 = insertvalue <{ i64, [2 x i64*], [1 x i64] }> %node.120, i64 %item.121, 2, 0
br label %tag.switch.exit.144
tag.switch.CNil.123: ; preds = %eval.entry
%nodeAddress.124 = bitcast i64* %q to <{ i64 }>*
%node.125 = load <{ i64 }>, <{ i64 }>* %nodeAddress.124, align 1
%item.126 = extractvalue <{ i64 }> %node.125, 0
%node.127 = insertvalue <{ i64, [2 x i64*], [1 x i64] }> undef, i64 %item.126, 0
br label %tag.switch.exit.144
tag.switch.Fsum.128: ; preds = %eval.entry
%nodeAddress.129 = bitcast i64* %q to <{ i64, [1 x i64*] }>*
%node.130 = load <{ i64, [1 x i64*] }>, <{ i64, [1 x i64*] }>* %nodeAddress.129, align 1
%item.131 = extractvalue <{ i64, [1 x i64*] }> %node.130, 0
%node.132 = insertvalue <{ i64, [2 x i64*], [1 x i64] }> undef, i64 %item.131, 0
%item.133 = extractvalue <{ i64, [1 x i64*] }> %node.130, 1, 0
%node.134 = insertvalue <{ i64, [2 x i64*], [1 x i64] }> %node.132, i64* %item.133, 1, 0
br label %tag.switch.exit.144
tag.switch.Fupto.135: ; preds = %eval.entry
%nodeAddress.136 = bitcast i64* %q to <{ i64, [2 x i64*] }>*
%node.137 = load <{ i64, [2 x i64*] }>, <{ i64, [2 x i64*] }>* %nodeAddress.136, align 1
%item.138 = extractvalue <{ i64, [2 x i64*] }> %node.137, 0
%node.139 = insertvalue <{ i64, [2 x i64*], [1 x i64] }> undef, i64 %item.138, 0
%item.140 = extractvalue <{ i64, [2 x i64*] }> %node.137, 1, 1
%node.141 = insertvalue <{ i64, [2 x i64*], [1 x i64] }> %node.139, i64* %item.140, 1, 1
%item.142 = extractvalue <{ i64, [2 x i64*] }> %node.137, 1, 0
%node.143 = insertvalue <{ i64, [2 x i64*], [1 x i64] }> %node.141, i64* %item.142, 1, 0
br label %tag.switch.exit.144
tag.switch.exit.144: ; preds = %tag.switch.Fupto.135, %tag.switch.Fsum.128, %tag.switch.CNil.123, %tag.switch.CInt.116, %tag.switch.CCons.107
%_heap_ptr_.145 = phi i64* [ %_heap_ptr_.105, %tag.switch.CCons.107 ], [ %_heap_ptr_.105, %tag.switch.CInt.116 ], [ %_heap_ptr_.105, %tag.switch.CNil.123 ], [ %_heap_ptr_.105, %tag.switch.Fsum.128 ], [ %_heap_ptr_.105, %tag.switch.Fupto.135 ]
%v.146 = phi <{ i64, [2 x i64*], [1 x i64] }> [ %node.115, %tag.switch.CCons.107 ], [ %node.122, %tag.switch.CInt.116 ], [ %node.127, %tag.switch.CNil.123 ], [ %node.134, %tag.switch.Fsum.128 ], [ %node.143, %tag.switch.Fupto.135 ]
%tag.147 = extractvalue <{ i64, [2 x i64*], [1 x i64] }> %v.146, 0
switch i64 %tag.147, label %error_block [
i64 0, label %switch.CInt.148
i64 3, label %switch.CNil.149
i64 4, label %switch.CCons.150
i64 1, label %switch.Fupto.151
i64 2, label %switch.Fsum.170
]
switch.CInt.148: ; preds = %tag.switch.exit.144
%"x'1" = extractvalue <{ i64, [2 x i64*], [1 x i64] }> %v.146, 2, 0
br label %switch.exit.176
switch.CNil.149: ; preds = %tag.switch.exit.144
br label %switch.exit.176
switch.CCons.150: ; preds = %tag.switch.exit.144
%y = extractvalue <{ i64, [2 x i64*], [1 x i64] }> %v.146, 1, 0
%ys = extractvalue <{ i64, [2 x i64*], [1 x i64] }> %v.146, 1, 1
br label %switch.exit.176
switch.Fupto.151: ; preds = %tag.switch.exit.144
%a = extractvalue <{ i64, [2 x i64*], [1 x i64] }> %v.146, 1, 0
%b = extractvalue <{ i64, [2 x i64*], [1 x i64] }> %v.146, 1, 1
%upto_result.152 = tail call <{ i64*, <{ i64, [2 x i64*] }> }> @upto(i64* %_heap_ptr_.145, i64* %a, i64* %b)
%_heap_ptr_.153 = extractvalue <{ i64*, <{ i64, [2 x i64*] }> }> %upto_result.152, 0
%w.154 = extractvalue <{ i64*, <{ i64, [2 x i64*] }> }> %upto_result.152, 1
%tag.155 = extractvalue <{ i64, [2 x i64*] }> %w.154, 0
switch i64 %tag.155, label %error_block [
i64 4, label %tag.switch.CCons.156
i64 3, label %tag.switch.CNil.164
]
tag.switch.CCons.156: ; preds = %switch.Fupto.151
%item.157 = extractvalue <{ i64, [2 x i64*] }> %w.154, 0
%node.158 = insertvalue <{ i64, [2 x i64*] }> undef, i64 %item.157, 0
%item.159 = extractvalue <{ i64, [2 x i64*] }> %w.154, 1, 1
%node.160 = insertvalue <{ i64, [2 x i64*] }> %node.158, i64* %item.159, 1, 1
%item.161 = extractvalue <{ i64, [2 x i64*] }> %w.154, 1, 0
%node.162 = insertvalue <{ i64, [2 x i64*] }> %node.160, i64* %item.161, 1, 0
%nodeAddress.163 = bitcast i64* %q to <{ i64, [2 x i64*] }>*
store <{ i64, [2 x i64*] }> %node.162, <{ i64, [2 x i64*] }>* %nodeAddress.163, align 1
br label %tag.switch.exit.168
tag.switch.CNil.164: ; preds = %switch.Fupto.151
%item.165 = extractvalue <{ i64, [2 x i64*] }> %w.154, 0
%node.166 = insertvalue <{ i64 }> undef, i64 %item.165, 0
%nodeAddress.167 = bitcast i64* %q to <{ i64 }>*
store <{ i64 }> %node.166, <{ i64 }>* %nodeAddress.167, align 1
br label %tag.switch.exit.168
tag.switch.exit.168: ; preds = %tag.switch.CNil.164, %tag.switch.CCons.156
%_heap_ptr_.169 = phi i64* [ %_heap_ptr_.153, %tag.switch.CCons.156 ], [ %_heap_ptr_.153, %tag.switch.CNil.164 ]
%item.177 = extractvalue <{ i64, [2 x i64*] }> %w.154, 0
%node.178 = insertvalue <{ i64, [2 x i64*], [1 x i64] }> undef, i64 %item.177, 0
%item.179 = extractvalue <{ i64, [2 x i64*] }> %w.154, 1, 1
%node.180 = insertvalue <{ i64, [2 x i64*], [1 x i64] }> %node.178, i64* %item.179, 1, 1
%item.181 = extractvalue <{ i64, [2 x i64*] }> %w.154, 1, 0
%node.182 = insertvalue <{ i64, [2 x i64*], [1 x i64] }> %node.180, i64* %item.181, 1, 0
br label %switch.exit.176
switch.Fsum.170: ; preds = %tag.switch.exit.144
%c = extractvalue <{ i64, [2 x i64*], [1 x i64] }> %v.146, 1, 0
%sum_result.171 = tail call <{ i64*, <{ i64, [1 x i64] }> }> @sum(i64* %_heap_ptr_.145, i64* %c)
%_heap_ptr_.172 = extractvalue <{ i64*, <{ i64, [1 x i64] }> }> %sum_result.171, 0
%z.173 = extractvalue <{ i64*, <{ i64, [1 x i64] }> }> %sum_result.171, 1
%tag.174 = extractvalue <{ i64, [1 x i64] }> %z.173, 0
%nodeAddress.175 = bitcast i64* %q to <{ i64, [1 x i64] }>*
store <{ i64, [1 x i64] }> %z.173, <{ i64, [1 x i64] }>* %nodeAddress.175, align 1
%item.183 = extractvalue <{ i64, [1 x i64] }> %z.173, 0
%node.184 = insertvalue <{ i64, [2 x i64*], [1 x i64] }> undef, i64 %item.183, 0
%item.185 = extractvalue <{ i64, [1 x i64] }> %z.173, 1, 0
%node.186 = insertvalue <{ i64, [2 x i64*], [1 x i64] }> %node.184, i64 %item.185, 2, 0
br label %switch.exit.176
switch.exit.176: ; preds = %switch.Fsum.170, %tag.switch.exit.168, %switch.CCons.150, %switch.CNil.149, %switch.CInt.148
%_heap_ptr_.187 = phi i64* [ %_heap_ptr_.145, %switch.CInt.148 ], [ %_heap_ptr_.145, %switch.CNil.149 ], [ %_heap_ptr_.145, %switch.CCons.150 ], [ %_heap_ptr_.169, %tag.switch.exit.168 ], [ %_heap_ptr_.172, %switch.Fsum.170 ]
%eval_result.188 = phi <{ i64, [2 x i64*], [1 x i64] }> [ %v.146, %switch.CInt.148 ], [ %v.146, %switch.CNil.149 ], [ %v.146, %switch.CCons.150 ], [ %node.182, %tag.switch.exit.168 ], [ %node.186, %switch.Fsum.170 ]
%eval_wrapped_result.189 = insertvalue <{ i64*, <{ i64, [2 x i64*], [1 x i64] }> }> undef, i64* %_heap_ptr_.187, 0
%eval_wrapped_result.190 = insertvalue <{ i64*, <{ i64, [2 x i64*], [1 x i64] }> }> %eval_wrapped_result.189, <{ i64, [2 x i64*], [1 x i64] }> %eval_result.188, 1
ret <{ i64*, <{ i64, [2 x i64*], [1 x i64] }> }> %eval_wrapped_result.190
error_block: ; preds = %switch.Fupto.151, %tag.switch.exit.144, %eval.entry
%error_result.191 = tail call i64 @_prim_int_print(i64 666)
unreachable
}
attributes #0 = { "no-jump-tables"="true" }
.text
.file "<string>"
.globl grinMain # -- Begin function grinMain
.p2align 4, 0x90
.type grinMain,@function
grinMain: # @grinMain
.cfi_startproc
# BB#0: # %grinMain.entry
pushq %rbx
.Lcfi0:
.cfi_def_cfa_offset 16
subq $48, %rsp
.Lcfi1:
.cfi_def_cfa_offset 64
.Lcfi2:
.cfi_offset %rbx, -16
movq %rdi, %rax
movq $1, 8(%rax)
movq $0, (%rax)
leaq 32(%rax), %rcx
movq $10000, 40(%rax) # imm = 0x2710
movq $0, 32(%rax)
leaq 64(%rax), %rdx
movq %rcx, 80(%rax)
movq %rax, 72(%rax)
movq $1, 64(%rax)
movq %rdx, 104(%rax)
movq $2, 96(%rax)
leaq 96(%rax), %rdx
subq $-128, %rax
leaq 8(%rsp), %rdi
movq %rax, %rsi
callq eval
movq 8(%rsp), %rbx
movq 40(%rsp), %rdi
callq _prim_int_print
movq %rax, %rcx
movq %rbx, %rax
movq %rcx, %rdx
addq $48, %rsp
popq %rbx
retq
.Lfunc_end0:
.size grinMain, .Lfunc_end0-grinMain
.cfi_endproc
# -- End function
.globl upto # -- Begin function upto
.p2align 4, 0x90
.type upto,@function
upto: # @upto
.cfi_startproc
# BB#0: # %upto.entry
pushq %r15
.Lcfi3:
.cfi_def_cfa_offset 16
pushq %r14
.Lcfi4:
.cfi_def_cfa_offset 24
pushq %r12
.Lcfi5:
.cfi_def_cfa_offset 32
pushq %rbx
.Lcfi6:
.cfi_def_cfa_offset 40
subq $88, %rsp
.Lcfi7:
.cfi_def_cfa_offset 128
.Lcfi8:
.cfi_offset %rbx, -40
.Lcfi9:
.cfi_offset %r12, -32
.Lcfi10:
.cfi_offset %r14, -24
.Lcfi11:
.cfi_offset %r15, -16
movq %rcx, %r15
movq %rdx, %r14
movq %rdi, %r12
leaq 48(%rsp), %rdi
callq eval
movq 48(%rsp), %rsi
movq 80(%rsp), %rbx
leaq 8(%rsp), %rdi
movq %r15, %rdx
callq eval
movq 8(%rsp), %rax
cmpq 40(%rsp), %rbx
setg %cl
jg .LBB1_1
# BB#2: # %upto.entry
testb %cl, %cl
jne .LBB1_5
# BB#3: # %switch.bool_False.47
incq %rbx
movq %rbx, 8(%rax)
movq $0, (%rax)
movq %r15, 48(%rax)
movq %rax, 40(%rax)
movq $1, 32(%rax)
leaq 32(%rax), %rcx
addq $64, %rax
movl $4, %edx
jmp .LBB1_4
.LBB1_1:
movl $3, %edx
# implicit-def: %R14
# implicit-def: %RCX
.LBB1_4: # %switch.exit.67
movq %rdx, 8(%r12)
movq %rax, (%r12)
movq %r14, 16(%r12)
movq %rcx, 24(%r12)
movq %r12, %rax
addq $88, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
.LBB1_5: # %error_block
movl $666, %edi # imm = 0x29A
callq _prim_int_print
.Lfunc_end1:
.size upto, .Lfunc_end1-upto
.cfi_endproc
# -- End function
.globl sum # -- Begin function sum
.p2align 4, 0x90
.type sum,@function
sum: # @sum
.cfi_startproc
# BB#0: # %sum.entry
pushq %r14
.Lcfi12:
.cfi_def_cfa_offset 16
pushq %rbx
.Lcfi13:
.cfi_def_cfa_offset 24
subq $88, %rsp
.Lcfi14:
.cfi_def_cfa_offset 112
.Lcfi15:
.cfi_offset %rbx, -24
.Lcfi16:
.cfi_offset %r14, -16
movq %rsi, %rax
movq %rdi, %rcx
leaq 8(%rsp), %rdi
movq %rcx, %rsi
movq %rax, %rdx
callq eval
movq 8(%rsp), %rax
movq 16(%rsp), %rcx
xorl %edx, %edx
cmpq $3, %rcx
je .LBB2_1
# BB#2: # %sum.entry
cmpq $4, %rcx
jne .LBB2_5
# BB#3: # %switch.CCons.89
movq 32(%rsp), %r14
movq 24(%rsp), %rdx
leaq 48(%rsp), %rdi
movq %rax, %rsi
callq eval
movq 48(%rsp), %rdi
movq 80(%rsp), %rbx
movq %r14, %rsi
callq sum
addq %rbx, %rcx
xorl %edx, %edx
jmp .LBB2_4
.LBB2_1:
xorl %ecx, %ecx
.LBB2_4: # %switch.exit.99
addq $88, %rsp
popq %rbx
popq %r14
retq
.LBB2_5: # %error_block
movl $666, %edi # imm = 0x29A
callq _prim_int_print
.Lfunc_end2:
.size sum, .Lfunc_end2-sum
.cfi_endproc
# -- End function
.globl eval # -- Begin function eval
.p2align 4, 0x90
.type eval,@function
eval: # @eval
.cfi_startproc
# BB#0: # %eval.entry
pushq %r14
.Lcfi17:
.cfi_def_cfa_offset 16
pushq %rbx
.Lcfi18:
.cfi_def_cfa_offset 24
subq $40, %rsp
.Lcfi19:
.cfi_def_cfa_offset 64
.Lcfi20:
.cfi_offset %rbx, -24
.Lcfi21:
.cfi_offset %r14, -16
movq %rdx, %r14
movq %rdi, %rbx
movq (%r14), %rax
cmpq $1, %rax
jle .LBB3_4
# BB#1: # %eval.entry
cmpq $2, %rax
je .LBB3_6
# BB#2: # %eval.entry
cmpq $3, %rax
jne .LBB3_13
# BB#3: # %tag.switch.CNil.123
movq (%r14), %rdx
# implicit-def: %RAX
jmp .LBB3_7
.LBB3_4: # %eval.entry
testq %rax, %rax
jne .LBB3_14
# BB#5: # %tag.switch.CInt.116
movq (%r14), %rdx
movq 8(%r14), %rdi
# implicit-def: %RAX
# implicit-def: %RCX
cmpq $1, %rdx
jg .LBB3_9
.LBB3_16: # %tag.switch.exit.144
testq %rdx, %rdx
je .LBB3_23
# BB#17: # %tag.switch.exit.144
cmpq $1, %rdx
jne .LBB3_24
# BB#18: # %switch.Fupto.151
leaq 8(%rsp), %rdi
movq %rax, %rdx
callq upto
movq 32(%rsp), %rcx
movq 24(%rsp), %rax
movq 8(%rsp), %rsi
movq 16(%rsp), %rdx
cmpq $3, %rdx
je .LBB3_21
# BB#19: # %switch.Fupto.151
cmpq $4, %rdx
jne .LBB3_24
# BB#20: # %tag.switch.CCons.156
movq %rdx, (%r14)
movq %rax, 8(%r14)
movq %rcx, 16(%r14)
jmp .LBB3_22
.LBB3_6: # %tag.switch.Fsum.128
movq (%r14), %rdx
movq 8(%r14), %rax
.LBB3_7: # %tag.switch.exit.144
# implicit-def: %RCX
jmp .LBB3_8
.LBB3_13: # %eval.entry
cmpq $4, %rax
je .LBB3_15
jmp .LBB3_24
.LBB3_14: # %eval.entry
cmpq $1, %rax
jne .LBB3_24
.LBB3_15: # %tag.switch.Fupto.135
movq 16(%r14), %rcx
movq (%r14), %rdx
movq 8(%r14), %rax
.LBB3_8: # %tag.switch.exit.144
# implicit-def: %RDI
cmpq $1, %rdx
jle .LBB3_16
.LBB3_9: # %tag.switch.exit.144
cmpq $2, %rdx
je .LBB3_12
# BB#10: # %tag.switch.exit.144
cmpq $3, %rdx
je .LBB3_23
# BB#11: # %tag.switch.exit.144
cmpq $4, %rdx
je .LBB3_23
.LBB3_24: # %error_block
movl $666, %edi # imm = 0x29A
callq _prim_int_print
.LBB3_12: # %switch.Fsum.170
movq %rsi, %rdi
movq %rax, %rsi
callq sum
movq %rax, %rsi
movq %rcx, %rdi
movq %rdi, 8(%r14)
movq %rdx, (%r14)
# implicit-def: %RAX
# implicit-def: %RCX
jmp .LBB3_23
.LBB3_21: # %tag.switch.CNil.164
movq %rdx, (%r14)
.LBB3_22: # %switch.exit.176
# implicit-def: %RDI
.LBB3_23: # %switch.exit.176
movq %rdx, 8(%rbx)
movq %rsi, (%rbx)
movq %rax, 16(%rbx)
movq %rcx, 24(%rbx)
movq %rdi, 32(%rbx)
movq %rbx, %rax
addq $40, %rsp
popq %rbx
popq %r14
retq
.Lfunc_end3:
.size eval, .Lfunc_end3-eval
.cfi_endproc
# -- End function
.section ".note.GNU-stack","",@progbits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment