object MathLib {
section module {
}
section data {
int rax = 0
int rbx = 0
int rcx = 0
int rdx = 0
int Swap_a = 0
int Swap_b = 0
int Swap_temp = 0
int __funcret_TestReturn = 0
int Add_a = 0
int Add_b = 0
int __funcret_Add = 0
int Subtract_a = 0
int Subtract_b = 0
int __funcret_Subtract = 0
int Multiply_a = 0
int Multiply_b = 0
int __funcret_Multiply = 0
int Divide_a = 0
int Divide_b = 0
int __funcret_Divide = 0
int Power_base = 0
int Power_exp = 0
int Power_i = 0
int __funcret_Power = 0
int Factorial_n = 0
int __funcret_Factorial = 0
int Abs_x = 0
int __funcret_Abs = 0
int Max_a = 0
int Max_b = 0
int __funcret_Max = 0
int Min_a = 0
int Min_b = 0
int __funcret_Min = 0
}
section code {
function PROC_UNIT_INIT:
ret
function PROC_Swap:
mov Swap_a, rbx
mov Swap_b, rcx
mov Swap_temp, Swap_a
mov Swap_a, Swap_b
mov Swap_b, Swap_temp
PROC_END_Swap:
ret
function FUNC_TestReturn:
mov __funcret_TestReturn, 100
FUNC_END_TestReturn:
mov rax, __funcret_TestReturn
ret
function FUNC_Add:
mov Add_a, rbx
mov Add_b, rcx
mov __funcret_Add, Add_a
add __funcret_Add, Add_b
FUNC_END_Add:
mov rax, __funcret_Add
ret
function FUNC_Subtract:
mov Subtract_a, rbx
mov Subtract_b, rcx
mov __funcret_Subtract, Subtract_a
sub __funcret_Subtract, Subtract_b
FUNC_END_Subtract:
mov rax, __funcret_Subtract
ret
function FUNC_Multiply:
mov Multiply_a, rbx
mov Multiply_b, rcx
mov __funcret_Multiply, Multiply_a
mul __funcret_Multiply, Multiply_b
FUNC_END_Multiply:
mov rax, __funcret_Multiply
ret
function FUNC_Divide:
mov Divide_a, rbx
mov Divide_b, rcx
cmp Divide_b, 0
jne ELSE_0
mov __funcret_Divide, 0
jmp ENDIF_1
ELSE_0:
mov __funcret_Divide, Divide_a
div __funcret_Divide, Divide_b
ENDIF_1:
FUNC_END_Divide:
mov rax, __funcret_Divide
ret
function FUNC_Power:
mov Power_base, rbx
mov Power_exp, rcx
mov __funcret_Power, 1
mov Power_i, 1
FOR_4:
cmp Power_i, Power_exp
jg ENDFOR_5
mul __funcret_Power, Power_base
FOR_CONTINUE_6:
add Power_i, 1
jmp FOR_4
ENDFOR_5:
FUNC_END_Power:
mov rax, __funcret_Power
ret
function FUNC_Factorial:
mov Factorial_n, rbx
cmp Factorial_n, 1
jg ELSE_7
mov __funcret_Factorial, 1
jmp ENDIF_8
ELSE_7:
mov rcx, Factorial_n
sub rcx, 1
push rbx
mov rbx, rcx
push Factorial_n
call FUNC_Factorial
pop Factorial_n
pop rbx
mov rdx, rax
mov __funcret_Factorial, Factorial_n
mul __funcret_Factorial, rdx
ENDIF_8:
FUNC_END_Factorial:
mov rax, __funcret_Factorial
ret
function FUNC_Abs:
mov Abs_x, rbx
cmp Abs_x, 0
jge ELSE_11
mov __funcret_Abs, 0
sub __funcret_Abs, Abs_x
jmp ENDIF_12
ELSE_11:
mov __funcret_Abs, Abs_x
ENDIF_12:
FUNC_END_Abs:
mov rax, __funcret_Abs
ret
function FUNC_Max:
mov Max_a, rbx
mov Max_b, rcx
cmp Max_a, Max_b
jle ELSE_15
mov __funcret_Max, Max_a
jmp ENDIF_16
ELSE_15:
mov __funcret_Max, Max_b
ENDIF_16:
FUNC_END_Max:
mov rax, __funcret_Max
ret
function FUNC_Min:
mov Min_a, rbx
mov Min_b, rcx
cmp Min_a, Min_b
jge ELSE_19
mov __funcret_Min, Min_a
jmp ENDIF_20
ELSE_19:
mov __funcret_Min, Min_b
ENDIF_20:
FUNC_END_Min:
mov rax, __funcret_Min
ret
}
}