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.

82 lines
2.5 KiB

declare i32 @get_int()
declare float @get_float()
declare i32 @get_char()
declare i32 @get_int_array(i32*)
declare i32 @get_float_array(float*)
declare void @put_int(i32)
declare void @put_float(float)
declare void @put_char(i32)
declare void @put_int_array(i32, i32*)
declare void @put_float_array(i32, float*)
define void @func_febonacci(i32* %arg0) {
label_func_febonaccifuncBB:
%op1 = alloca i32*
store i32* %arg0, i32** %op1
%op2 = alloca i32
store i32 2, i32* %op2
%op3 = load i32*, i32** %op1
%op4 = getelementptr i32, i32* %op3, i32 0
%op5 = load i32, i32* %op4
store i32 0, i32* %op4
%op6 = load i32*, i32** %op1
%op7 = getelementptr i32, i32* %op6, i32 1
%op8 = load i32, i32* %op7
store i32 1, i32* %op7
br label %label_cond_while_0
label_func_febonacciretBB: ; preds = %label_after_while_2
ret void
label_cond_while_0: ; preds = %label_func_febonaccifuncBB, %label_while_1
%op9 = load i32, i32* %op2
%op10 = icmp slt i32 %op9, 10
br i1 %op10, label %label_while_1, label %label_after_while_2
label_while_1: ; preds = %label_cond_while_0
%op11 = load i32, i32* %op2
%op12 = load i32*, i32** %op1
%op13 = getelementptr i32, i32* %op12, i32 %op11
%op14 = load i32, i32* %op13
%op15 = load i32, i32* %op2
%op16 = sub i32 %op15, 1
%op17 = load i32*, i32** %op1
%op18 = getelementptr i32, i32* %op17, i32 %op16
%op19 = load i32, i32* %op18
%op20 = load i32, i32* %op2
%op21 = sub i32 %op20, 2
%op22 = load i32*, i32** %op1
%op23 = getelementptr i32, i32* %op22, i32 %op21
%op24 = load i32, i32* %op23
%op25 = add i32 %op19, %op24
store i32 %op25, i32* %op13
%op26 = load i32, i32* %op2
%op27 = load i32, i32* %op2
%op28 = add i32 %op27, 1
store i32 %op28, i32* %op2
br label %label_cond_while_0
label_after_while_2: ; preds = %label_cond_while_0
br label %label_func_febonacciretBB
}
define i32 @main() {
label_mainfuncBB:
%op0 = alloca i32
store i32 0, i32* %op0
%op1 = alloca [10 x i32]
%op2 = getelementptr [10 x i32], [10 x i32]* %op1, i32 0, i32 0
call void @func_febonacci(i32* %op2)
%op3 = getelementptr [10 x i32], [10 x i32]* %op1, i32 0, i32 2
%op4 = load i32, i32* %op3
store i32 %op4, i32* %op0
br label %label_mainretBB
label_mainretBB: ; preds = %label_mainfuncBB
%op5 = load i32, i32* %op0
ret i32 %op5
}