decompiled_code:
void MIPS_make_binop()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
MIPS_list* MIPS_make_binop(ir_item* item)
{
}

canonical_original_code:
struct MIPS_list *MIPS_make_binop(struct ir_item *item)
{
}

variable_types: struct ir_item { enum ir_type { IR_EMPTY=0, IR_DATA=1, IR_BINOP=2, IR_UNOP=3, IR_COPY=4, IR_GOTO=5, IR_BRANCH=6, IR_LABEL=7, IR_LIDX=8, IR_RIDX=9, IR_ADDR=10, IR_LDEREF=11, IR_RDEREF=12, IR_ENTER=13, IR_LEAVE=14, IR_PARAM=15, IR_CALL=16, IR_RET=17, IR_RET_VAL=18, IR_RETRIEVE=19 } type; union { struct { struct address { enum addr_type { ADDR_EMPTY=0, ADDR_SYMBOL=1, ADDR_SYMBOL_NAME=2, ADDR_IMM_INT=3, ADDR_IMM_CHAR=4, ADDR_IMM_STRING=5 } type; union { int integer; char character; char *string; struct symbol_info { enum symbol_type { SYM_NONE=0, SYM_FUN=1, SYM_VAR=2, SYM_LITERAL=3 } symbol_type; char *name; struct scope_info { struct symbol_info *symbols; struct scope_info *parent; struct scope_info *next; struct scope_info *children; } *scope; union { struct { struct type { enum basic_type { T_VOID=0, T_INT=1, T_CHAR=2, T_INT_ARRAY=3, T_CHAR_ARRAY=4 } type; int elements; } var_type; struct codegen_info { enum storage_type { ST_UNKNOWN=0, ST_REG=1, ST_LOCAL=2, ST_GLOBAL=3 } storage; int size; union { int reg; int offset; }; } codegen; }; struct { struct type ret_type; struct scope_info *params; }; char *literal; }; struct symbol_info *next; } *symbol; char *symbol_name; }; } x; union { enum ir_binop { IR_PLUS=0, IR_MINUS=1, IR_TIMES=2, IR_DIV=3, IR_AND=4, IR_OR=5 } binop; enum ir_unop { IR_NEG=0 } unop; enum ir_relop { IR_EQ=0, IR_NEQ=1, IR_GT=2, IR_GTE=3, IR_LT=4, IR_LTE=5 } relop; }; }; struct { char *name; enum ir_data { DATA_RAW=0, DATA_STRING=1 } data_type; union { int bytes; char *text; }; }; struct { char *label; int offset; }; }; } *

return_type: struct MIPS_list { struct MIPS_instruction { enum MIPS_opcode { MIPS_add=0, MIPS_sub=1, MIPS_addi=2, MIPS_mult=3, MIPS_div=4, MIPS_lw=5, MIPS_lb=6, MIPS_sw=7, MIPS_sb=8, MIPS_mfhi=9, MIPS_mflo=10, MIPS_and=11, MIPS_andi=12, MIPS_or=13, MIPS_ori=14, MIPS_slt=15, MIPS_slti=16, MIPS_bgt=17, MIPS_bge=18, MIPS_blt=19, MIPS_ble=20, MIPS_sll=21, MIPS_srl=22, MIPS_beq=23, MIPS_bne=24, MIPS_jal=25, MIPS_jr=26, MIPS_b=27, MIPS_la=28, MIPS_li=29 } opcode; struct MIPS_operand { enum MIPS_operand_type { MIPS_OPERAND_NONE=0, MIPS_REG=1, MIPS_IMM_32=2, MIPS_IMM_8=3, MIPS_OFFSET=4, MIPS_SYMBOL=5 } type; union { int reg; int imm32; char imm8; int offset; char *symbol; }; } x; } instr; struct MIPS_list *next; } *

user_defined_types: struct ir_item { enum ir_type type; union { struct { struct address x; union { enum ir_binop binop; enum ir_unop unop; enum ir_relop relop; }; }; struct { char *name; enum ir_data data_type; union { int bytes; char *text; }; }; struct { char *label; int offset; }; }; }

user_defined_types: struct MIPS_list { struct MIPS_instruction instr; struct MIPS_list *next; }

user_defined_types: struct MIPS_instruction { enum MIPS_opcode opcode; struct MIPS_operand x; }

user_defined_types: struct MIPS_operand { enum MIPS_operand_type type; union { int reg; int imm32; char imm8; int offset; char *symbol; }; }


repo: marcinlos/cmm-compiler

decompiled_code:
// attributes: thunk
void MIPS_make_unop()
{
MIPS_make_binop_constprop_0();
}

canonical_decompiled_code:
void func2()
{
func0();
}

original_code:
MIPS_list* MIPS_make_unop(ir_item* item)
{
}

canonical_original_code:
struct MIPS_list *MIPS_make_unop(struct ir_item *item)
{
}

user_defined_types: enum ir_type { IR_EMPTY=0, IR_DATA=1, IR_BINOP=2, IR_UNOP=3, IR_COPY=4, IR_GOTO=5, IR_BRANCH=6, IR_LABEL=7, IR_LIDX=8, IR_RIDX=9, IR_ADDR=10, IR_LDEREF=11, IR_RDEREF=12, IR_ENTER=13, IR_LEAVE=14, IR_PARAM=15, IR_CALL=16, IR_RET=17, IR_RET_VAL=18, IR_RETRIEVE=19 }

user_defined_types: enum MIPS_opcode { MIPS_add=0, MIPS_sub=1, MIPS_addi=2, MIPS_mult=3, MIPS_div=4, MIPS_lw=5, MIPS_lb=6, MIPS_sw=7, MIPS_sb=8, MIPS_mfhi=9, MIPS_mflo=10, MIPS_and=11, MIPS_andi=12, MIPS_or=13, MIPS_ori=14, MIPS_slt=15, MIPS_slti=16, MIPS_bgt=17, MIPS_bge=18, MIPS_blt=19, MIPS_ble=20, MIPS_sll=21, MIPS_srl=22, MIPS_beq=23, MIPS_bne=24, MIPS_jal=25, MIPS_jr=26, MIPS_b=27, MIPS_la=28, MIPS_li=29 }

user_defined_types: struct address { enum addr_type type; union { int integer; char character; char *string; struct symbol_info *symbol; char *symbol_name; }; }

user_defined_types: enum ir_data { DATA_RAW=0, DATA_STRING=1 }

user_defined_types: enum MIPS_operand_type { MIPS_OPERAND_NONE=0, MIPS_REG=1, MIPS_IMM_32=2, MIPS_IMM_8=3, MIPS_OFFSET=4, MIPS_SYMBOL=5 }

user_defined_types: enum addr_type { ADDR_EMPTY=0, ADDR_SYMBOL=1, ADDR_SYMBOL_NAME=2, ADDR_IMM_INT=3, ADDR_IMM_CHAR=4, ADDR_IMM_STRING=5 }

user_defined_types: enum ir_binop { IR_PLUS=0, IR_MINUS=1, IR_TIMES=2, IR_DIV=3, IR_AND=4, IR_OR=5 }

user_defined_types: enum ir_relop { IR_EQ=0, IR_NEQ=1, IR_GT=2, IR_GTE=3, IR_LT=4, IR_LTE=5 }

user_defined_types: struct symbol_info { enum symbol_type symbol_type; char *name; struct scope_info *scope; union { struct { struct type var_type; struct codegen_info codegen; }; struct { struct type ret_type; struct scope_info *params; }; char *literal; }; struct symbol_info *next; }

user_defined_types: enum symbol_type { SYM_NONE=0, SYM_FUN=1, SYM_VAR=2, SYM_LITERAL=3 }

user_defined_types: struct scope_info { struct symbol_info *symbols; struct scope_info *parent; struct scope_info *next; struct scope_info *children; }

user_defined_types: struct type { enum basic_type type; int elements; }

user_defined_types: struct codegen_info { enum storage_type storage; int size; union { int reg; int offset; }; }

user_defined_types: enum basic_type { T_VOID=0, T_INT=1, T_CHAR=2, T_INT_ARRAY=3, T_CHAR_ARRAY=4 }

user_defined_types: enum storage_type { ST_UNKNOWN=0, ST_REG=1, ST_LOCAL=2, ST_GLOBAL=3 }


decompiled_code:
// attributes: thunk
void MIPS_make_copy()
{
MIPS_make_binop_constprop_0();
}

canonical_decompiled_code:
void func3()
{
func0();
}

original_code:
MIPS_list* MIPS_make_copy(ir_item* item)
{
}

canonical_original_code:
struct MIPS_list *MIPS_make_copy(struct ir_item *item)
{
}

user_defined_types: struct ir_item { enum ir_type type; union { struct { struct address x; union { enum ir_binop binop; enum ir_unop unop; enum ir_relop relop; }; }; struct { char *name; enum ir_data data_type; union { int bytes; char *text; }; }; struct { char *label; int offset; }; }; }

user_defined_types: struct MIPS_list { struct MIPS_instruction instr; struct MIPS_list *next; }

user_defined_types: struct MIPS_instruction { enum MIPS_opcode opcode; struct MIPS_operand x; }


decompiled_code:
__int64 __fastcall MIPS_make_goto(__int64 a1)
{
unsigned int v1; // eax
__int64 v2; // rdx
__int64 v3; // rdx
__int64 v4; // rcx
__int64 v5; // r8
__int64 v6; // r9
__int64 v8; // [rsp+0h] [rbp-48h] BYREF

v1 = MIPS_mksymbol(*(_QWORD *)(a1 + 16));
MIPS_mk1(&v8, 27LL, v1, v2);
return MIPS_single_code(&v8, 27LL, v3, v4, v5, v6, v8);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
unsigned int v1; // eax
__int64 v2; // rdx
__int64 v3; // rdx
__int64 v4; // rcx
__int64 v5; // r8
__int64 v6; // r9
__int64 v8; // [rsp+0h] [rbp-48h] BYREF

v1 = MIPS_mksymbol(*(_QWORD *)(a1 + 16));
MIPS_mk1(&v8, 27LL, v1, v2);
return MIPS_single_code(&v8, 27LL, v3, v4, v5, v6, v8);
}

original_code:
MIPS_list* MIPS_make_goto(ir_item* item)
{
    return MIPS_single_code(MIPS_mk1(
            MIPS_b,
            MIPS_mksymbol(item->x.symbol_name)));
}

canonical_original_code:
struct MIPS_list *MIPS_make_goto(struct ir_item *item)
{
    return MIPS_single_code(MIPS_mk1(
            MIPS_b,
            MIPS_mksymbol(item->x.symbol_name)));
}

user_defined_types: enum ir_type { IR_EMPTY=0, IR_DATA=1, IR_BINOP=2, IR_UNOP=3, IR_COPY=4, IR_GOTO=5, IR_BRANCH=6, IR_LABEL=7, IR_LIDX=8, IR_RIDX=9, IR_ADDR=10, IR_LDEREF=11, IR_RDEREF=12, IR_ENTER=13, IR_LEAVE=14, IR_PARAM=15, IR_CALL=16, IR_RET=17, IR_RET_VAL=18, IR_RETRIEVE=19 }

user_defined_types: enum MIPS_opcode { MIPS_add=0, MIPS_sub=1, MIPS_addi=2, MIPS_mult=3, MIPS_div=4, MIPS_lw=5, MIPS_lb=6, MIPS_sw=7, MIPS_sb=8, MIPS_mfhi=9, MIPS_mflo=10, MIPS_and=11, MIPS_andi=12, MIPS_or=13, MIPS_ori=14, MIPS_slt=15, MIPS_slti=16, MIPS_bgt=17, MIPS_bge=18, MIPS_blt=19, MIPS_ble=20, MIPS_sll=21, MIPS_srl=22, MIPS_beq=23, MIPS_bne=24, MIPS_jal=25, MIPS_jr=26, MIPS_b=27, MIPS_la=28, MIPS_li=29 }

user_defined_types: struct MIPS_operand { enum MIPS_operand_type type; union { int reg; int imm32; char imm8; int offset; char *symbol; }; }


decompiled_code:
// attributes: thunk
void MIPS_make_branch()
{
MIPS_make_binop_constprop_0();
}

canonical_decompiled_code:
void func5()
{
func0();
}

original_code:
MIPS_list* MIPS_make_branch(ir_item* item)
{
}

canonical_original_code:
struct MIPS_list *MIPS_make_branch(struct ir_item *item)
{
}

user_defined_types: struct address { enum addr_type type; union { int integer; char character; char *string; struct symbol_info *symbol; char *symbol_name; }; }

user_defined_types: enum ir_data { DATA_RAW=0, DATA_STRING=1 }

user_defined_types: enum MIPS_operand_type { MIPS_OPERAND_NONE=0, MIPS_REG=1, MIPS_IMM_32=2, MIPS_IMM_8=3, MIPS_OFFSET=4, MIPS_SYMBOL=5 }


decompiled_code:
// attributes: thunk
void MIPS_make_lidx()
{
MIPS_make_binop_constprop_0();
}

canonical_decompiled_code:
void func6()
{
func0();
}

original_code:
MIPS_list* MIPS_make_lidx(ir_item* item)
{
}

canonical_original_code:
struct MIPS_list *MIPS_make_lidx(struct ir_item *item)
{
}

user_defined_types: enum addr_type { ADDR_EMPTY=0, ADDR_SYMBOL=1, ADDR_SYMBOL_NAME=2, ADDR_IMM_INT=3, ADDR_IMM_CHAR=4, ADDR_IMM_STRING=5 }

user_defined_types: enum ir_binop { IR_PLUS=0, IR_MINUS=1, IR_TIMES=2, IR_DIV=3, IR_AND=4, IR_OR=5 }

user_defined_types: enum ir_relop { IR_EQ=0, IR_NEQ=1, IR_GT=2, IR_GTE=3, IR_LT=4, IR_LTE=5 }


decompiled_code:
// attributes: thunk
void MIPS_make_ridx()
{
MIPS_make_binop_constprop_0();
}

canonical_decompiled_code:
void func7()
{
func0();
}

original_code:
MIPS_list* MIPS_make_ridx(ir_item* item)
{
}

canonical_original_code:
struct MIPS_list *MIPS_make_ridx(struct ir_item *item)
{
}

user_defined_types: struct symbol_info { enum symbol_type symbol_type; char *name; struct scope_info *scope; union { struct { struct type var_type; struct codegen_info codegen; }; struct { struct type ret_type; struct scope_info *params; }; char *literal; }; struct symbol_info *next; }

user_defined_types: enum symbol_type { SYM_NONE=0, SYM_FUN=1, SYM_VAR=2, SYM_LITERAL=3 }

user_defined_types: struct scope_info { struct symbol_info *symbols; struct scope_info *parent; struct scope_info *next; struct scope_info *children; }


decompiled_code:
// attributes: thunk
void MIPS_make_addr()
{
MIPS_make_binop_constprop_0();
}

canonical_decompiled_code:
void func8()
{
func0();
}

original_code:
MIPS_list* MIPS_make_addr(ir_item* item)
{
}

canonical_original_code:
struct MIPS_list *MIPS_make_addr(struct ir_item *item)
{
}

user_defined_types: struct type { enum basic_type type; int elements; }

user_defined_types: struct codegen_info { enum storage_type storage; int size; union { int reg; int offset; }; }

user_defined_types: enum basic_type { T_VOID=0, T_INT=1, T_CHAR=2, T_INT_ARRAY=3, T_CHAR_ARRAY=4 }


decompiled_code:
// attributes: thunk
void MIPS_make_lderef()
{
MIPS_make_binop_constprop_0();
}

canonical_decompiled_code:
void func9()
{
func0();
}

original_code:
MIPS_list* MIPS_make_lderef(ir_item* item)
{
}

canonical_original_code:
struct MIPS_list *MIPS_make_lderef(struct ir_item *item)
{
}

user_defined_types: struct ir_item { enum ir_type type; union { struct { struct address x; union { enum ir_binop binop; enum ir_unop unop; enum ir_relop relop; }; }; struct { char *name; enum ir_data data_type; union { int bytes; char *text; }; }; struct { char *label; int offset; }; }; }

user_defined_types: struct MIPS_list { struct MIPS_instruction instr; struct MIPS_list *next; }

user_defined_types: enum storage_type { ST_UNKNOWN=0, ST_REG=1, ST_LOCAL=2, ST_GLOBAL=3 }


decompiled_code:
// attributes: thunk
void MIPS_make_rderef()
{
MIPS_make_binop_constprop_0();
}

canonical_decompiled_code:
void func10()
{
func0();
}

original_code:
MIPS_list* MIPS_make_rderef(ir_item* item)
{
}

canonical_original_code:
struct MIPS_list *MIPS_make_rderef(struct ir_item *item)
{
}

user_defined_types: enum ir_type { IR_EMPTY=0, IR_DATA=1, IR_BINOP=2, IR_UNOP=3, IR_COPY=4, IR_GOTO=5, IR_BRANCH=6, IR_LABEL=7, IR_LIDX=8, IR_RIDX=9, IR_ADDR=10, IR_LDEREF=11, IR_RDEREF=12, IR_ENTER=13, IR_LEAVE=14, IR_PARAM=15, IR_CALL=16, IR_RET=17, IR_RET_VAL=18, IR_RETRIEVE=19 }

user_defined_types: struct MIPS_instruction { enum MIPS_opcode opcode; struct MIPS_operand x; }

user_defined_types: enum MIPS_opcode { MIPS_add=0, MIPS_sub=1, MIPS_addi=2, MIPS_mult=3, MIPS_div=4, MIPS_lw=5, MIPS_lb=6, MIPS_sw=7, MIPS_sb=8, MIPS_mfhi=9, MIPS_mflo=10, MIPS_and=11, MIPS_andi=12, MIPS_or=13, MIPS_ori=14, MIPS_slt=15, MIPS_slti=16, MIPS_bgt=17, MIPS_bge=18, MIPS_blt=19, MIPS_ble=20, MIPS_sll=21, MIPS_srl=22, MIPS_beq=23, MIPS_bne=24, MIPS_jal=25, MIPS_jr=26, MIPS_b=27, MIPS_la=28, MIPS_li=29 }


original_code:
MIPS_list* MIPS_make_enter(ir_item* item)
{
    MIPS_list* node = MIPS_empty_list();
    node->instr = MIPS_mk3(
            MIPS_sw,
            MIPS_mkreg(30),
            MIPS_mkreg(29),
            MIPS_mkoffset(-4));
    MIPS_append_item(node, MIPS_mk3(
            MIPS_sw,
            MIPS_mkreg(31),
            MIPS_mkreg(29),
            MIPS_mkoffset(-8)));
    MIPS_append_item(node, MIPS_mk3(
            MIPS_la,
            MIPS_mkreg(30),
            MIPS_mkreg(29),
            MIPS_mkoffset(0)));
    int n = 3;
    MIPS_append_item(node, MIPS_mk3(
            MIPS_la,
            MIPS_mkreg(29),
            MIPS_mkreg(29),
            MIPS_mkoffset(-n)));
    return node;
}

canonical_original_code:
struct MIPS_list *MIPS_make_enter(struct ir_item *item)
{
    struct MIPS_list *node = MIPS_empty_list();
    node->instr = MIPS_mk3(
            MIPS_sw,
            MIPS_mkreg(30),
            MIPS_mkreg(29),
            MIPS_mkoffset(-4));
    MIPS_append_item(node, MIPS_mk3(
            MIPS_sw,
            MIPS_mkreg(31),
            MIPS_mkreg(29),
            MIPS_mkoffset(-8)));
    MIPS_append_item(node, MIPS_mk3(
            MIPS_la,
            MIPS_mkreg(30),
            MIPS_mkreg(29),
            MIPS_mkoffset(0)));
    int n = 3;
    MIPS_append_item(node, MIPS_mk3(
            MIPS_la,
            MIPS_mkreg(29),
            MIPS_mkreg(29),
            MIPS_mkoffset(-n)));
    return node;
}

variable_types: struct MIPS_list { struct MIPS_instruction { enum MIPS_opcode { MIPS_add=0, MIPS_sub=1, MIPS_addi=2, MIPS_mult=3, MIPS_div=4, MIPS_lw=5, MIPS_lb=6, MIPS_sw=7, MIPS_sb=8, MIPS_mfhi=9, MIPS_mflo=10, MIPS_and=11, MIPS_andi=12, MIPS_or=13, MIPS_ori=14, MIPS_slt=15, MIPS_slti=16, MIPS_bgt=17, MIPS_bge=18, MIPS_blt=19, MIPS_ble=20, MIPS_sll=21, MIPS_srl=22, MIPS_beq=23, MIPS_bne=24, MIPS_jal=25, MIPS_jr=26, MIPS_b=27, MIPS_la=28, MIPS_li=29 } opcode; struct MIPS_operand { enum MIPS_operand_type { MIPS_OPERAND_NONE=0, MIPS_REG=1, MIPS_IMM_32=2, MIPS_IMM_8=3, MIPS_OFFSET=4, MIPS_SYMBOL=5 } type; union { int reg; int imm32; char imm8; int offset; char *symbol; }; } x; } instr; struct MIPS_list *next; } *

variable_types: n int

user_defined_types: struct MIPS_operand { enum MIPS_operand_type type; union { int reg; int imm32; char imm8; int offset; char *symbol; }; }

user_defined_types: struct address { enum addr_type type; union { int integer; char character; char *string; struct symbol_info *symbol; char *symbol_name; }; }

user_defined_types: enum ir_data { DATA_RAW=0, DATA_STRING=1 }


decompiled_code:
// attributes: thunk
void MIPS_make_leave()
{
MIPS_make_binop_constprop_0();
}

canonical_decompiled_code:
void func12()
{
func0();
}

original_code:
MIPS_list* MIPS_make_leave(ir_item* item)
{
}

canonical_original_code:
struct MIPS_list *MIPS_make_leave(struct ir_item *item)
{
}

user_defined_types: enum MIPS_operand_type { MIPS_OPERAND_NONE=0, MIPS_REG=1, MIPS_IMM_32=2, MIPS_IMM_8=3, MIPS_OFFSET=4, MIPS_SYMBOL=5 }

user_defined_types: enum addr_type { ADDR_EMPTY=0, ADDR_SYMBOL=1, ADDR_SYMBOL_NAME=2, ADDR_IMM_INT=3, ADDR_IMM_CHAR=4, ADDR_IMM_STRING=5 }

user_defined_types: enum ir_binop { IR_PLUS=0, IR_MINUS=1, IR_TIMES=2, IR_DIV=3, IR_AND=4, IR_OR=5 }


decompiled_code:
// attributes: thunk
void MIPS_make_param()
{
MIPS_make_binop_constprop_0();
}

canonical_decompiled_code:
void func13()
{
func0();
}

original_code:
MIPS_list* MIPS_make_param(ir_item* item)
{
}

canonical_original_code:
struct MIPS_list *MIPS_make_param(struct ir_item *item)
{
}

user_defined_types: enum ir_relop { IR_EQ=0, IR_NEQ=1, IR_GT=2, IR_GTE=3, IR_LT=4, IR_LTE=5 }

user_defined_types: struct symbol_info { enum symbol_type symbol_type; char *name; struct scope_info *scope; union { struct { struct type var_type; struct codegen_info codegen; }; struct { struct type ret_type; struct scope_info *params; }; char *literal; }; struct symbol_info *next; }

user_defined_types: enum symbol_type { SYM_NONE=0, SYM_FUN=1, SYM_VAR=2, SYM_LITERAL=3 }


decompiled_code:
// attributes: thunk
void MIPS_make_call()
{
MIPS_make_binop_constprop_0();
}

canonical_decompiled_code:
void func14()
{
func0();
}

original_code:
MIPS_list* MIPS_make_call(ir_item* item)
{
}

canonical_original_code:
struct MIPS_list *MIPS_make_call(struct ir_item *item)
{
}

user_defined_types: struct scope_info { struct symbol_info *symbols; struct scope_info *parent; struct scope_info *next; struct scope_info *children; }

user_defined_types: struct type { enum basic_type type; int elements; }

user_defined_types: struct codegen_info { enum storage_type storage; int size; union { int reg; int offset; }; }


decompiled_code:
// attributes: thunk
void MIPS_make_ret()
{
MIPS_make_binop_constprop_0();
}

canonical_decompiled_code:
void func15()
{
func0();
}

original_code:
MIPS_list* MIPS_make_ret(ir_item* item)
{
}

canonical_original_code:
struct MIPS_list *MIPS_make_ret(struct ir_item *item)
{
}

user_defined_types: struct ir_item { enum ir_type type; union { struct { struct address x; union { enum ir_binop binop; enum ir_unop unop; enum ir_relop relop; }; }; struct { char *name; enum ir_data data_type; union { int bytes; char *text; }; }; struct { char *label; int offset; }; }; }

user_defined_types: struct MIPS_list { struct MIPS_instruction instr; struct MIPS_list *next; }

user_defined_types: enum basic_type { T_VOID=0, T_INT=1, T_CHAR=2, T_INT_ARRAY=3, T_CHAR_ARRAY=4 }


decompiled_code:
// attributes: thunk
void MIPS_make_ret_val()
{
MIPS_make_binop_constprop_0();
}

canonical_decompiled_code:
void func16()
{
func0();
}

original_code:
MIPS_list* MIPS_make_ret_val(ir_item* item)
{
}

canonical_original_code:
struct MIPS_list *MIPS_make_ret_val(struct ir_item *item)
{
}

user_defined_types: enum ir_type { IR_EMPTY=0, IR_DATA=1, IR_BINOP=2, IR_UNOP=3, IR_COPY=4, IR_GOTO=5, IR_BRANCH=6, IR_LABEL=7, IR_LIDX=8, IR_RIDX=9, IR_ADDR=10, IR_LDEREF=11, IR_RDEREF=12, IR_ENTER=13, IR_LEAVE=14, IR_PARAM=15, IR_CALL=16, IR_RET=17, IR_RET_VAL=18, IR_RETRIEVE=19 }

user_defined_types: struct MIPS_instruction { enum MIPS_opcode opcode; struct MIPS_operand x; }

user_defined_types: enum storage_type { ST_UNKNOWN=0, ST_REG=1, ST_LOCAL=2, ST_GLOBAL=3 }


decompiled_code:
// attributes: thunk
void MIPS_make_retrieve()
{
MIPS_make_binop_constprop_0();
}

canonical_decompiled_code:
void func17()
{
func0();
}

original_code:
MIPS_list* MIPS_make_retrieve(ir_item* item)
{
}

canonical_original_code:
struct MIPS_list *MIPS_make_retrieve(struct ir_item *item)
{
}

user_defined_types: enum MIPS_opcode { MIPS_add=0, MIPS_sub=1, MIPS_addi=2, MIPS_mult=3, MIPS_div=4, MIPS_lw=5, MIPS_lb=6, MIPS_sw=7, MIPS_sb=8, MIPS_mfhi=9, MIPS_mflo=10, MIPS_and=11, MIPS_andi=12, MIPS_or=13, MIPS_ori=14, MIPS_slt=15, MIPS_slti=16, MIPS_bgt=17, MIPS_bge=18, MIPS_blt=19, MIPS_ble=20, MIPS_sll=21, MIPS_srl=22, MIPS_beq=23, MIPS_bne=24, MIPS_jal=25, MIPS_jr=26, MIPS_b=27, MIPS_la=28, MIPS_li=29 }

user_defined_types: struct MIPS_operand { enum MIPS_operand_type type; union { int reg; int imm32; char imm8; int offset; char *symbol; }; }

user_defined_types: struct address { enum addr_type type; union { int integer; char character; char *string; struct symbol_info *symbol; char *symbol_name; }; }


decompiled_code:
__int64 empty_operand()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func0()
{
return 0LL;
}

original_code:
static MIPS_operand empty_operand(void)
{
    MIPS_operand op;
    op.type = MIPS_OPERAND_NONE;
    return op;
}

canonical_original_code:
static struct MIPS_operand empty_operand()
{
    struct MIPS_operand op;
    op.type = MIPS_OPERAND_NONE;
    return op;
}

variable_types: struct MIPS_operand { enum MIPS_operand_type { MIPS_OPERAND_NONE=0, MIPS_REG=1, MIPS_IMM_32=2, MIPS_IMM_8=3, MIPS_OFFSET=4, MIPS_SYMBOL=5 } type; union { int reg; int imm32; char imm8; int offset; char *symbol; }; }


decompiled_code:
char *__fastcall MIPS_op_name(unsigned int a1)
{
if ( a1 > 0x1D )
_assert_fail("0 && \"MIPS_op_name: invalid opcode\"", "mips.c", 0x2Au, "MIPS_op_name");
return CSWTCH_9[a1];
}

canonical_decompiled_code:
char *__fastcall func1(unsigned int a1)
{
if ( a1 > 0x1D )
_assert_fail("0 && \"MIPS_op_name: invalid opcode\"", "mips.c", 0x2Au, "MIPS_op_name");
return CSWTCH_9[a1];
}

original_code:
const char* MIPS_op_name(MIPS_opcode opcode)
{
    switch (opcode)
    {
    case MIPS_add: return "add"; break;
    case MIPS_sub: return "sub"; break;
    case MIPS_addi: return "addi"; break;
    case MIPS_mult: return "mult"; break;
    case MIPS_div: return "div"; break;
    case MIPS_lw: return "lw"; break;
    case MIPS_lb: return "lb"; break;
    case MIPS_sw: return "sw"; break;
    case MIPS_sb: return "sb"; break;
    case MIPS_mfhi: return "mhfi"; break;
    case MIPS_mflo: return "mflo"; break;
    case MIPS_and: return "and"; break;
    case MIPS_andi: return "andi"; break;
    case MIPS_or: return "or"; break;
    case MIPS_ori: return "ori"; break;
    case MIPS_slt: return "slt"; break;
    case MIPS_slti: return "slti"; break;
    case MIPS_bgt: return "bgt"; break;
    case MIPS_bge: return "bge"; break;
    case MIPS_blt: return "blt"; break;
    case MIPS_ble: return "ble"; break;
    case MIPS_sll: return "sll"; break;
    case MIPS_srl: return "srl"; break;
    case MIPS_beq: return "beq"; break;
    case MIPS_bne: return "bne"; break;
    case MIPS_jal: return "jal"; break;
    case MIPS_jr: return "jr"; break;
    case MIPS_b: return "b"; break;
    case MIPS_la: return "la"; break;
    case MIPS_li: return "li"; break;
    }
    ((void) sizeof ((0 && "MIPS_op_name: invalid opcode") ? 1 : 0), __extension__ ({ if (0 && "MIPS_op_name: invalid opcode") ; else __assert_fail ("0 && \"MIPS_op_name: invalid opcode\"", "mips.c", 42, __extension__ __PRETTY_FUNCTION__); }));
    return "INVALID";
}

canonical_original_code:
char *MIPS_op_name(enum MIPS_opcode opcode)
{
    switch (opcode)
    {
    case MIPS_add: return "add"; break;
    case MIPS_sub: return "sub"; break;
    case MIPS_addi: return "addi"; break;
    case MIPS_mult: return "mult"; break;
    case MIPS_div: return "div"; break;
    case MIPS_lw: return "lw"; break;
    case MIPS_lb: return "lb"; break;
    case MIPS_sw: return "sw"; break;
    case MIPS_sb: return "sb"; break;
    case MIPS_mfhi: return "mhfi"; break;
    case MIPS_mflo: return "mflo"; break;
    case MIPS_and: return "and"; break;
    case MIPS_andi: return "andi"; break;
    case MIPS_or: return "or"; break;
    case MIPS_ori: return "ori"; break;
    case MIPS_slt: return "slt"; break;
    case MIPS_slti: return "slti"; break;
    case MIPS_bgt: return "bgt"; break;
    case MIPS_bge: return "bge"; break;
    case MIPS_blt: return "blt"; break;
    case MIPS_ble: return "ble"; break;
    case MIPS_sll: return "sll"; break;
    case MIPS_srl: return "srl"; break;
    case MIPS_beq: return "beq"; break;
    case MIPS_bne: return "bne"; break;
    case MIPS_jal: return "jal"; break;
    case MIPS_jr: return "jr"; break;
    case MIPS_b: return "b"; break;
    case MIPS_la: return "la"; break;
    case MIPS_li: return "li"; break;
    }
    ((void) sizeof ((0 && "MIPS_op_name: invalid opcode") ? 1 : 0), __extension__ ({ if (0 && "MIPS_op_name: invalid opcode") ; else __assert_fail ("0 && \"MIPS_op_name: invalid opcode\"", "mips.c", 42, __extension__ __PRETTY_FUNCTION__); }));
    return "INVALID";
}

variable_types: enum MIPS_opcode { MIPS_add=0, MIPS_sub=1, MIPS_addi=2, MIPS_mult=3, MIPS_div=4, MIPS_lw=5, MIPS_lb=6, MIPS_sw=7, MIPS_sb=8, MIPS_mfhi=9, MIPS_mflo=10, MIPS_and=11, MIPS_andi=12, MIPS_or=13, MIPS_ori=14, MIPS_slt=15, MIPS_slti=16, MIPS_bgt=17, MIPS_bge=18, MIPS_blt=19, MIPS_ble=20, MIPS_sll=21, MIPS_srl=22, MIPS_beq=23, MIPS_bne=24, MIPS_jal=25, MIPS_jr=26, MIPS_b=27, MIPS_la=28, MIPS_li=29 }

return_type: char *


decompiled_code:
__int64 MIPS_mkimm32()
{
return 2LL;
}

canonical_decompiled_code:
__int64 func2()
{
return 2LL;
}

original_code:
MIPS_operand MIPS_mkimm32(int n)
{
    MIPS_operand op;
    op.type = MIPS_IMM_32;
    op.imm32 = n;
    return op;
}

canonical_original_code:
struct MIPS_operand MIPS_mkimm32(int n)
{
    struct MIPS_operand op;
    op.type = MIPS_IMM_32;
    op.imm32 = n;
    return op;
}

return_type: struct MIPS_operand { enum MIPS_operand_type { MIPS_OPERAND_NONE=0, MIPS_REG=1, MIPS_IMM_32=2, MIPS_IMM_8=3, MIPS_OFFSET=4, MIPS_SYMBOL=5 } type; union { int reg; int imm32; char imm8; int offset; char *symbol; }; }


decompiled_code:
__int64 MIPS_mkimm8()
{
return 3LL;
}

canonical_decompiled_code:
__int64 func3()
{
return 3LL;
}

original_code:
MIPS_operand MIPS_mkimm8(char c)
{
    MIPS_operand op;
    op.type = MIPS_IMM_8;
    op.imm8 = c;
    return op;
}

canonical_original_code:
struct MIPS_operand MIPS_mkimm8(char c)
{
    struct MIPS_operand op;
    op.type = MIPS_IMM_8;
    op.imm8 = c;
    return op;
}

variable_types: c char

user_defined_types: enum MIPS_operand_type { MIPS_OPERAND_NONE=0, MIPS_REG=1, MIPS_IMM_32=2, MIPS_IMM_8=3, MIPS_OFFSET=4, MIPS_SYMBOL=5 }


decompiled_code:
__int64 MIPS_mkreg()
{
return 1LL;
}

canonical_decompiled_code:
__int64 func4()
{
return 1LL;
}

original_code:
MIPS_operand MIPS_mkreg(int reg)
{
    MIPS_operand op;
    op.type = MIPS_REG;
    op.reg = reg;
    return op;
}

canonical_original_code:
struct MIPS_operand MIPS_mkreg(int reg)
{
    struct MIPS_operand op;
    op.type = MIPS_REG;
    op.reg = reg;
    return op;
}

variable_types: reg int


decompiled_code:
__int64 MIPS_mkoffset()
{
return 4LL;
}

canonical_decompiled_code:
__int64 func5()
{
return 4LL;
}

original_code:
MIPS_operand MIPS_mkoffset(int offset)
{
    MIPS_operand op;
    op.type = MIPS_OFFSET;
    op.offset = offset;
    return op;
}

canonical_original_code:
struct MIPS_operand MIPS_mkoffset(int offset)
{
    struct MIPS_operand op;
    op.type = MIPS_OFFSET;
    op.offset = offset;
    return op;
}

variable_types: offset int


decompiled_code:
__int64 __fastcall MIPS_mksymbol(const char *a1)
{
strdup(a1);
return 5LL;
}

canonical_decompiled_code:
__int64 __fastcall func6(const char *a1)
{
strdup(a1);
return 5LL;
}

original_code:
MIPS_operand MIPS_mksymbol(const char* symbol)
{
    MIPS_operand op;
    op.type = MIPS_SYMBOL;
    op.symbol = strdup(symbol);
    return op;
}

canonical_original_code:
struct MIPS_operand MIPS_mksymbol(char *symbol)
{
    struct MIPS_operand op;
    op.type = MIPS_SYMBOL;
    op.symbol = strdup(symbol);
    return op;
}

variable_types:
symbol
char *


decompiled_code:
void __fastcall MIPS_free_operand(__int64 a1)
{
if ( !a1 )
_assert_fail("operand && \"MIPS_free_operand: NULL argument\"", "mips.c", 0x60u, "MIPS_free_operand");
if ( *(_DWORD *)a1 == 5 )
free(*(void **)(a1 + 8));
}

canonical_decompiled_code:
void __fastcall func7(__int64 a1)
{
if ( !a1 )
_assert_fail("operand && \"MIPS_free_operand: NULL argument\"", "mips.c", 0x60u, "MIPS_free_operand");
if ( *(_DWORD *)a1 == 5 )
free(*(void **)(a1 + 8));
}

original_code:
void MIPS_free_operand(MIPS_operand* operand)
{
    ((void) sizeof ((operand && "MIPS_free_operand: NULL argument") ? 1 : 0), __extension__ ({ if (operand && "MIPS_free_operand: NULL argument") ; else __assert_fail ("operand && \"MIPS_free_operand: NULL argument\"", "mips.c", 96, __extension__ __PRETTY_FUNCTION__); }));
    switch (operand->type)
    {
    case MIPS_SYMBOL: free(operand->symbol); break;
    }
}

canonical_original_code:
void MIPS_free_operand(struct MIPS_operand *operand)
{
    ((void) sizeof ((operand && "MIPS_free_operand: NULL argument") ? 1 : 0), __extension__ ({ if (operand && "MIPS_free_operand: NULL argument") ; else __assert_fail ("operand && \"MIPS_free_operand: NULL argument\"", "mips.c", 96, __extension__ __PRETTY_FUNCTION__); }));
    switch (operand->type)
    {
    case MIPS_SYMBOL: free(operand->symbol); break;
    }
}

variable_types: struct MIPS_operand { enum MIPS_operand_type { MIPS_OPERAND_NONE=0, MIPS_REG=1, MIPS_IMM_32=2, MIPS_IMM_8=3, MIPS_OFFSET=4, MIPS_SYMBOL=5 } type; union { int reg; int imm32; char imm8; int offset; char *symbol; }; } *

return_type: void


decompiled_code:
int __fastcall MIPS_write_operand(char *a1, int a2, const char *a3)
{
int result; // eax
unsigned int v4; // er8
__int64 v5; // rdx

switch ( a2 )
{
case 1:
switch ( (int)a3 )
{
case 0:
strcpy(a1, "$zero");
return 5;
case 1:
*(_DWORD *)a1 = 7627044;
return 3;
case 28:
*(_DWORD *)a1 = 7366436;
return 3;
case 29:
*(_DWORD *)a1 = 7369508;
return 3;
case 30:
*(_DWORD *)a1 = 7366180;
return 3;
case 31:
*(_DWORD *)a1 = 6386212;
return 3;
default:
if ( (unsigned int)((_DWORD)a3 - 2) <= 1 )
{
sprintf(a1, "$v%d", (unsigned int)((_DWORD)a3 - 2));
return 3;
}
if ( (unsigned int)((_DWORD)a3 - 4) <= 3 )
{
sprintf(a1, "$a%d", (unsigned int)((_DWORD)a3 - 4));
return 3;
}
v4 = (_DWORD)a3 - 8;
if ( (unsigned int)((_DWORD)a3 - 8) <= 7 )
goto LABEL_20;
v4 = (_DWORD)a3 - 16;
if ( (unsigned int)((_DWORD)a3 - 16) <= 7 )
{
sprintf(a1, "$s%d", v4);
result = 3;
}
else
{
if ( (unsigned int)((_DWORD)a3 - 24) <= 1 )
{
LABEL_20:
sprintf(a1, "$t%d", v4);
return 3;
}
v5 = (unsigned int)((_DWORD)a3 - 26);
if ( (unsigned int)v5 > 1 )
_assert_fail("0 && \"MIPS_write_operand: invalid operand type\"", "mips.c", 0xB2u, "MIPS_write_operand");
sprintf(a1, "$k%d", v5);
result = 3;
}
return result;
}
case 2:
case 4:
return sprintf(a1, "%d", a3);
case 3:
a3 = (const char *)(unsigned int)(char)a3;
return sprintf(a1, "%d", a3);
case 5:
return sprintf(a1, "%s", a3);
default:
return -1;
}
}

canonical_decompiled_code:
int __fastcall func11(char *a1, int a2, const char *a3)
{
int result; // eax
unsigned int v4; // er8
__int64 v5; // rdx

switch ( a2 )
{
case 1:
switch ( (int)a3 )
{
case 0:
strcpy(a1, "$zero");
return 5;
case 1:
*(_DWORD *)a1 = 7627044;
return 3;
case 28:
*(_DWORD *)a1 = 7366436;
return 3;
case 29:
*(_DWORD *)a1 = 7369508;
return 3;
case 30:
*(_DWORD *)a1 = 7366180;
return 3;
case 31:
*(_DWORD *)a1 = 6386212;
return 3;
default:
if ( (unsigned int)((_DWORD)a3 - 2) <= 1 )
{
sprintf(a1, "$v%d", (unsigned int)((_DWORD)a3 - 2));
return 3;
}
if ( (unsigned int)((_DWORD)a3 - 4) <= 3 )
{
sprintf(a1, "$a%d", (unsigned int)((_DWORD)a3 - 4));
return 3;
}
v4 = (_DWORD)a3 - 8;
if ( (unsigned int)((_DWORD)a3 - 8) <= 7 )
goto LABEL_20;
v4 = (_DWORD)a3 - 16;
if ( (unsigned int)((_DWORD)a3 - 16) <= 7 )
{
sprintf(a1, "$s%d", v4);
result = 3;
}
else
{
if ( (unsigned int)((_DWORD)a3 - 24) <= 1 )
{
LABEL_20:
sprintf(a1, "$t%d", v4);
return 3;
}
v5 = (unsigned int)((_DWORD)a3 - 26);
if ( (unsigned int)v5 > 1 )
_assert_fail("0 && \"MIPS_write_operand: invalid operand type\"", "mips.c", 0xB2u, "MIPS_write_operand");
sprintf(a1, "$k%d", v5);
result = 3;
}
return result;
}
case 2:
case 4:
return sprintf(a1, "%d", a3);
case 3:
a3 = (const char *)(unsigned int)(char)a3;
return sprintf(a1, "%d", a3);
case 5:
return sprintf(a1, "%s", a3);
default:
return -1;
}
}

original_code:
int MIPS_write_operand(char* buffer, MIPS_operand operand)
{
    switch (operand.type)
    {
    case MIPS_SYMBOL:
        return sprintf(buffer, "%s", operand.symbol);
        break;
    case MIPS_OFFSET:
    case MIPS_IMM_32:
        return sprintf(buffer, "%d", operand.imm32);
        break;
    case MIPS_IMM_8:
        return sprintf(buffer, "%d", (int) operand.imm8);
        break;
    case MIPS_REG:
        switch (operand.reg)
        {
        case 0: return sprintf(buffer, "$zero");
        case 1: return sprintf(buffer, "$at");
        case 28: return sprintf(buffer, "$gp");
        case 29: return sprintf(buffer, "$sp");
        case 30: return sprintf(buffer, "$fp");
        case 31: return sprintf(buffer, "$ra");
        default:
        {
            int r = operand.reg;
            if (r >= 2 && r <= 3)
                return sprintf(buffer, "$v%d", r - 2);
            else if (r >= 4 && r <= 7)
                return sprintf(buffer, "$a%d", r - 4);
            else if (r >= 8 && r <= 15)
                return sprintf(buffer, "$t%d", r - 8);
            else if (r >= 16 && r <= 23)
                return sprintf(buffer, "$s%d", r - 16);
            else if (r >= 24 && r <= 25)
                return sprintf(buffer, "$t%d", r - 16);
            else if (r >= 26 && r <= 27)
                return sprintf(buffer, "$k%d", r - 26);
            else
                ((void) sizeof ((0 && "MIPS_write_operand: invalid operand type") ? 1 : 0), __extension__ ({ if (0 && "MIPS_write_operand: invalid operand type") ; else __assert_fail ("0 && \"MIPS_write_operand: invalid operand type\"", "mips.c", 178, __extension__ __PRETTY_FUNCTION__); }));
        }
        break;
        }
        break;
    }
    return -1;
}

canonical_original_code:
int MIPS_write_operand(char *buffer, struct MIPS_operand operand)
{
    switch (operand.type)
    {
    case MIPS_SYMBOL:
        return sprintf(buffer, "%s", operand.symbol);
        break;
    case MIPS_OFFSET:
    case MIPS_IMM_32:
        return sprintf(buffer, "%d", operand.imm32);
        break;
    case MIPS_IMM_8:
        return sprintf(buffer, "%d", (int) operand.imm8);
        break;
    case MIPS_REG:
        switch (operand.reg)
        {
        case 0: return sprintf(buffer, "$zero");
        case 1: return sprintf(buffer, "$at");
        case 28: return sprintf(buffer, "$gp");
        case 29: return sprintf(buffer, "$sp");
        case 30: return sprintf(buffer, "$fp");
        case 31: return sprintf(buffer, "$ra");
        default:
        {
            int r = operand.reg;
            if (r >= 2 && r <= 3)
                return sprintf(buffer, "$v%d", r - 2);
            else if (r >= 4 && r <= 7)
                return sprintf(buffer, "$a%d", r - 4);
            else if (r >= 8 && r <= 15)
                return sprintf(buffer, "$t%d", r - 8);
            else if (r >= 16 && r <= 23)
                return sprintf(buffer, "$s%d", r - 16);
            else if (r >= 24 && r <= 25)
                return sprintf(buffer, "$t%d", r - 16);
            else if (r >= 26 && r <= 27)
                return sprintf(buffer, "$k%d", r - 26);
            else
                ((void) sizeof ((0 && "MIPS_write_operand: invalid operand type") ? 1 : 0), __extension__ ({ if (0 && "MIPS_write_operand: invalid operand type") ; else __assert_fail ("0 && \"MIPS_write_operand: invalid operand type\"", "mips.c", 178, __extension__ __PRETTY_FUNCTION__); }));
        }
        break;
        }
        break;
    }
    return -1;
}

variable_types:
buffer
char *

variable_types: r int

return_type: int


decompiled_code:
char *__fastcall MIPS_write_instr(char *s, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, int a7, int a8, __int64 a9, int a10, __int64 a11, int a12, __int64 a13)
{
char *v14; // rax
char *v15; // rbp
char *result; // rax
char *v17; // rbp
char *v18; // rdi
char *v19; // rbp
char *v20; // rbp
char *v21; // rbp

v14 = MIPS_op_name(a7);
v15 = &s[sprintf(s, " %s ", v14)];
switch ( a7 )
{
case 0:
case 1:
case 2:
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
case 17:
case 18:
case 19:
case 20:
case 21:
case 22:
case 23:
case 24:
v17 = &v15[MIPS_write_operand(v15, a8, (const char *)a9)];
*(_WORD *)v17 = 8236;
v17 += 2;
*v17 = 0;
v18 = &v17[MIPS_write_operand(v17, a10, (const char *)a11)];
*(_WORD *)v18 = 8236;
v18 += 2;
*v18 = 0;
MIPS_write_operand(v18, a12, (const char *)a13);
result = s;
break;
case 3:
case 4:
case 29:
v21 = &v15[MIPS_write_operand(v15, a8, (const char *)a9)];
strcpy(v21, ", ");
MIPS_write_operand(v21 + 2, a10, (const char *)a11);
result = s;
break;
case 5:
case 6:
case 7:
case 8:
case 28:
v19 = &v15[MIPS_write_operand(v15, a8, (const char *)a9)];
*(_WORD *)v19 = 8236;
v19 += 2;
*v19 = 0;
v20 = &v19[MIPS_write_operand(v19, a12, (const char *)a13)];
*(_WORD *)v20 = 40;
*(_WORD *)&v20[MIPS_write_operand(v20 + 1, a10, (const char *)a11) + 1] = 41;
result = s;
break;
case 9:
case 10:
case 25:
case 26:
case 27:
MIPS_write_operand(v15, a8, (const char *)a9);
goto LABEL_3;
default:
LABEL_3:
result = s;
break;
}
return result;
}

canonical_decompiled_code:
char *__fastcall func12(char *s, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, int a7, int a8, __int64 a9, int a10, __int64 a11, int a12, __int64 a13)
{
char *v14; // rax
char *v15; // rbp
char *result; // rax
char *v17; // rbp
char *v18; // rdi
char *v19; // rbp
char *v20; // rbp
char *v21; // rbp

v14 = func1(a7);
v15 = &s[sprintf(s, " %s ", v14)];
switch ( a7 )
{
case 0:
case 1:
case 2:
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
case 17:
case 18:
case 19:
case 20:
case 21:
case 22:
case 23:
case 24:
v17 = &v15[func11(v15, a8, (const char *)a9)];
*(_WORD *)v17 = 8236;
v17 += 2;
*v17 = 0;
v18 = &v17[func11(v17, a10, (const char *)a11)];
*(_WORD *)v18 = 8236;
v18 += 2;
*v18 = 0;
func11(v18, a12, (const char *)a13);
result = s;
break;
case 3:
case 4:
case 29:
v21 = &v15[func11(v15, a8, (const char *)a9)];
strcpy(v21, ", ");
func11(v21 + 2, a10, (const char *)a11);
result = s;
break;
case 5:
case 6:
case 7:
case 8:
case 28:
v19 = &v15[func11(v15, a8, (const char *)a9)];
*(_WORD *)v19 = 8236;
v19 += 2;
*v19 = 0;
v20 = &v19[func11(v19, a12, (const char *)a13)];
*(_WORD *)v20 = 40;
*(_WORD *)&v20[func11(v20 + 1, a10, (const char *)a11) + 1] = 41;
result = s;
break;
case 9:
case 10:
case 25:
case 26:
case 27:
func11(v15, a8, (const char *)a9);
goto LABEL_3;
default:
LABEL_3:
result = s;
break;
}
return result;
}

original_code:
char* MIPS_write_instr(char* buffer, MIPS_instruction instr)
{
    char* p = buffer;
    p += sprintf(buffer, "    %s ", MIPS_op_name(instr.opcode));
    switch (instr.opcode)
    {
    case MIPS_add:
    case MIPS_sub:
    case MIPS_addi:
    case MIPS_and:
    case MIPS_andi:
    case MIPS_or:
    case MIPS_ori:
    case MIPS_slt:
    case MIPS_slti:
    case MIPS_sll:
    case MIPS_srl:
    case MIPS_bgt:
    case MIPS_bge:
    case MIPS_blt:
    case MIPS_ble:
    case MIPS_beq:
    case MIPS_bne:
        p += MIPS_write_operand(p, instr.x);
        p += sprintf(p, ", ");
        p += MIPS_write_operand(p, instr.y);
        p += sprintf(p, ", ");
        p += MIPS_write_operand(p, instr.z);
        break;
    case MIPS_mult:
    case MIPS_div:
    case MIPS_li:
        p += MIPS_write_operand(p, instr.x);
        p += sprintf(p, ", ");
        p += MIPS_write_operand(p, instr.y);
        break;
    case MIPS_lw:
    case MIPS_lb:
    case MIPS_la:
    case MIPS_sw:
    case MIPS_sb:
        p += MIPS_write_operand(p, instr.x);
        p += sprintf(p, ", ");
        p += MIPS_write_operand(p, instr.z);
        p += sprintf(p, "(");
        p += MIPS_write_operand(p, instr.y);
        p += sprintf(p, ")");
        break;
    case MIPS_mfhi:
    case MIPS_mflo:
    case MIPS_jal:
    case MIPS_jr:
    case MIPS_b:
        MIPS_write_operand(p, instr.x);
        break;
    }
    return buffer;
}

canonical_original_code:
char *MIPS_write_instr(char *buffer, struct MIPS_instruction instr)
{
    char *p = buffer;
    p += sprintf(buffer, "    %s ", MIPS_op_name(instr.opcode));
    switch (instr.opcode)
    {
    case MIPS_add:
    case MIPS_sub:
    case MIPS_addi:
    case MIPS_and:
    case MIPS_andi:
    case MIPS_or:
    case MIPS_ori:
    case MIPS_slt:
    case MIPS_slti:
    case MIPS_sll:
    case MIPS_srl:
    case MIPS_bgt:
    case MIPS_bge:
    case MIPS_blt:
    case MIPS_ble:
    case MIPS_beq:
    case MIPS_bne:
        p += MIPS_write_operand(p, instr.x);
        p += sprintf(p, ", ");
        p += MIPS_write_operand(p, instr.y);
        p += sprintf(p, ", ");
        p += MIPS_write_operand(p, instr.z);
        break;
    case MIPS_mult:
    case MIPS_div:
    case MIPS_li:
        p += MIPS_write_operand(p, instr.x);
        p += sprintf(p, ", ");
        p += MIPS_write_operand(p, instr.y);
        break;
    case MIPS_lw:
    case MIPS_lb:
    case MIPS_la:
    case MIPS_sw:
    case MIPS_sb:
        p += MIPS_write_operand(p, instr.x);
        p += sprintf(p, ", ");
        p += MIPS_write_operand(p, instr.z);
        p += sprintf(p, "(");
        p += MIPS_write_operand(p, instr.y);
        p += sprintf(p, ")");
        break;
    case MIPS_mfhi:
    case MIPS_mflo:
    case MIPS_jal:
    case MIPS_jr:
    case MIPS_b:
        MIPS_write_operand(p, instr.x);
        break;
    }
    return buffer;
}

variable_types: struct MIPS_instruction { enum MIPS_opcode { MIPS_add=0, MIPS_sub=1, MIPS_addi=2, MIPS_mult=3, MIPS_div=4, MIPS_lw=5, MIPS_lb=6, MIPS_sw=7, MIPS_sb=8, MIPS_mfhi=9, MIPS_mflo=10, MIPS_and=11, MIPS_andi=12, MIPS_or=13, MIPS_ori=14, MIPS_slt=15, MIPS_slti=16, MIPS_bgt=17, MIPS_bge=18, MIPS_blt=19, MIPS_ble=20, MIPS_sll=21, MIPS_srl=22, MIPS_beq=23, MIPS_bne=24, MIPS_jal=25, MIPS_jr=26, MIPS_b=27, MIPS_la=28, MIPS_li=29 } opcode; struct MIPS_operand { enum MIPS_operand_type { MIPS_OPERAND_NONE=0, MIPS_REG=1, MIPS_IMM_32=2, MIPS_IMM_8=3, MIPS_OFFSET=4, MIPS_SYMBOL=5 } type; union { int reg; int imm32; char imm8; int offset; char *symbol; }; } x; }

variable_types:
p
char *


decompiled_code:
void __fastcall MIPS_free_instr(__int64 a1)
{
if ( !a1 )
_assert_fail("instruction && \"MIPS_free_instr: NULL argument passed\"", "mips.c", 0xFDu, "MIPS_free_instr");
MIPS_free_operand(a1 + 8);
MIPS_free_operand(a1 + 24);
MIPS_free_operand(a1 + 40);
}

canonical_decompiled_code:
void __fastcall func13(__int64 a1)
{
if ( !a1 )
_assert_fail("instruction && \"MIPS_free_instr: NULL argument passed\"", "mips.c", 0xFDu, "MIPS_free_instr");
func7(a1 + 8);
func7(a1 + 24);
func7(a1 + 40);
}

original_code:
void MIPS_free_instr(MIPS_instruction* instruction)
{
    ((void) sizeof ((instruction && "MIPS_free_instr: NULL argument passed") ? 1 : 0), __extension__ ({ if (instruction && "MIPS_free_instr: NULL argument passed") ; else __assert_fail ("instruction && \"MIPS_free_instr: NULL argument passed\"", "mips.c", 253, __extension__ __PRETTY_FUNCTION__); }));
    MIPS_free_operand(&instruction->x);
    MIPS_free_operand(&instruction->y);
    MIPS_free_operand(&instruction->z);
}

canonical_original_code:
void MIPS_free_instr(struct MIPS_instruction *instruction)
{
    ((void) sizeof ((instruction && "MIPS_free_instr: NULL argument passed") ? 1 : 0), __extension__ ({ if (instruction && "MIPS_free_instr: NULL argument passed") ; else __assert_fail ("instruction && \"MIPS_free_instr: NULL argument passed\"", "mips.c", 253, __extension__ __PRETTY_FUNCTION__); }));
    MIPS_free_operand(&instruction->x);
    MIPS_free_operand(&instruction->y);
    MIPS_free_operand(&instruction->z);
}

variable_types: struct MIPS_instruction { enum MIPS_opcode { MIPS_add=0, MIPS_sub=1, MIPS_addi=2, MIPS_mult=3, MIPS_div=4, MIPS_lw=5, MIPS_lb=6, MIPS_sw=7, MIPS_sb=8, MIPS_mfhi=9, MIPS_mflo=10, MIPS_and=11, MIPS_andi=12, MIPS_or=13, MIPS_ori=14, MIPS_slt=15, MIPS_slti=16, MIPS_bgt=17, MIPS_bge=18, MIPS_blt=19, MIPS_ble=20, MIPS_sll=21, MIPS_srl=22, MIPS_beq=23, MIPS_bne=24, MIPS_jal=25, MIPS_jr=26, MIPS_b=27, MIPS_la=28, MIPS_li=29 } opcode; struct MIPS_operand { enum MIPS_operand_type { MIPS_OPERAND_NONE=0, MIPS_REG=1, MIPS_IMM_32=2, MIPS_IMM_8=3, MIPS_OFFSET=4, MIPS_SYMBOL=5 } type; union { int reg; int imm32; char imm8; int offset; char *symbol; }; } x; } *


decompiled_code:
__int64 __fastcall calc_escaped_size(char *a1)
{
char v1; // al
unsigned int v2; // er8

v1 = *a1;
v2 = 0;
if ( *a1 )
{
while ( 1 )
{
++a1;
if ( v1 == 34 )
goto LABEL_9;
if ( v1 > 34 )
{
if ( v1 == 92 )
goto LABEL_9;
goto LABEL_4;
}
if ( v1 <= 10 )
{
if ( v1 <= 8 )
goto LABEL_4;
LABEL_9:
v1 = *a1;
v2 += 2;
if ( !*a1 )
return v2;
}
else
{
if ( v1 == 13 )
goto LABEL_9;
LABEL_4:
v1 = *a1;
++v2;
if ( !*a1 )
return v2;
}
}
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *a1)
{
char v1; // al
unsigned int v2; // er8

v1 = *a1;
v2 = 0;
if ( *a1 )
{
while ( 1 )
{
++a1;
if ( v1 == 34 )
goto LABEL_9;
if ( v1 > 34 )
{
if ( v1 == 92 )
goto LABEL_9;
goto LABEL_4;
}
if ( v1 <= 10 )
{
if ( v1 <= 8 )
goto LABEL_4;
LABEL_9:
v1 = *a1;
v2 += 2;
if ( !*a1 )
return v2;
}
else
{
if ( v1 == 13 )
goto LABEL_9;
LABEL_4:
v1 = *a1;
++v2;
if ( !*a1 )
return v2;
}
}
}
return v2;
}

original_code:
int calc_escaped_size(const char* text)
{
    int n = 0;
    while (*text)
    {
        switch(*text++)
        {
        case '\t': n += 2; break;
        case '\n': n += 2; break;
        case '\"': n += 2; break;
        case '\\': n += 2; break;
        case '\r': n += 2; break;
        default: ++ n; break;
        }
    }
    return n;
}

canonical_original_code:
int calc_escaped_size(char *text)
{
    int n = 0;
    while (*text)
    {
        switch(*text++)
        {
        case '\t': n += 2; break;
        case '\n': n += 2; break;
        case '\"': n += 2; break;
        case '\\': n += 2; break;
        case '\r': n += 2; break;
        default: ++ n; break;
        }
    }
    return n;
}

variable_types:
text
char *


original_code:
char* escape_string(char* dest, const char* src)
{
    char* p = dest;
    while (*src)
    {
        switch(*src)
        {
        case '\t': strcpy(p, "\\t"); p += 2; break;
        case '\n': strcpy(p, "\\n"); p += 2; break;
        case '\"': strcpy(p, "\\\""); p += 2; break;
        case '\\': strcpy(p, "\\\\"); p += 2; break;
        case '\r': strcpy(p, "\\r"); p += 2; break;
        default: *p ++ = *src; break;
        }
        ++ src;
    }
    return dest;
}

canonical_original_code:
char *escape_string(char *dest, char *src)
{
    char *p = dest;
    while (*src)
    {
        switch(*src)
        {
        case '\t': strcpy(p, "\\t"); p += 2; break;
        case '\n': strcpy(p, "\\n"); p += 2; break;
        case '\"': strcpy(p, "\\\""); p += 2; break;
        case '\\': strcpy(p, "\\\\"); p += 2; break;
        case '\r': strcpy(p, "\\r"); p += 2; break;
        default: *p ++ = *src; break;
        }
        ++ src;
    }
    return dest;
}

variable_types:
dest
char *

variable_types:
src
char *


decompiled_code:
char *__fastcall escape_alloc(char *a1)
{
int v1; // eax
char *v2; // rax

v1 = calc_escaped_size(a1);
v2 = (char *)malloc(v1);
return escape_string(v2, a1);
}

canonical_decompiled_code:
char *__fastcall func2(char *a1)
{
int v1; // eax
char *v2; // rax

v1 = func0(a1);
v2 = (char *)malloc(v1);
return func1(v2, a1);
}

original_code:
char* escape_alloc(const char* text)
{
    char* buffer = malloc(calc_escaped_size(text));
    return escape_string(buffer, text);
}

canonical_original_code:
char *escape_alloc(char *text)
{
    char *buffer = malloc(calc_escaped_size(text));
    return escape_string(buffer, text);
}


decompiled_code:
__int64 __fastcall ctx_pop_scope(__int64 a1)
{
__int64 result; // rax

result = *(_QWORD *)(*(_QWORD *)(a1 + 16) + 8LL);
*(_QWORD *)(a1 + 16) = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
__int64 result; // rax

result = *(_QWORD *)(*(_QWORD *)(a1 + 16) + 8LL);
*(_QWORD *)(a1 + 16) = result;
return result;
}

original_code:
static void ctx_pop_scope(context* ctx)
{
    ctx->scope = ctx->scope->parent;
}

canonical_original_code:
static void ctx_pop_scope(struct context *ctx)
{
    ctx->scope = ctx->scope->parent;
}

variable_types: struct context { struct ir_code { struct ir_list { struct ir_item { enum ir_type { IR_EMPTY=0, IR_DATA=1, IR_BINOP=2, IR_UNOP=3, IR_COPY=4, IR_GOTO=5, IR_BRANCH=6, IR_LABEL=7, IR_LIDX=8, IR_RIDX=9, IR_ADDR=10, IR_LDEREF=11, IR_RDEREF=12, IR_ENTER=13, IR_LEAVE=14, IR_PARAM=15, IR_CALL=16, IR_RET=17, IR_RET_VAL=18, IR_RETRIEVE=19 } type; union { struct { struct address { enum addr_type { ADDR_EMPTY=0, ADDR_SYMBOL=1, ADDR_SYMBOL_NAME=2, ADDR_IMM_INT=3, ADDR_IMM_CHAR=4, ADDR_IMM_STRING=5 } type; union { int integer; char character; char *string; struct symbol_info { enum symbol_type { SYM_NONE=0, SYM_FUN=1, SYM_VAR=2, SYM_LITERAL=3 } symbol_type; char *name; struct scope_info { struct symbol_info *symbols; struct scope_info *parent; struct scope_info *next; struct scope_info *children; } *scope; union { struct { struct type { enum basic_type { T_VOID=0, T_INT=1, T_CHAR=2, T_INT_ARRAY=3, T_CHAR_ARRAY=4 } type; int elements; } var_type; struct codegen_info { enum storage_type { ST_UNKNOWN=0, ST_REG=1, ST_LOCAL=2, ST_GLOBAL=3 } storage; int size; union { int reg; int offset; }; } codegen; }; struct { struct type ret_type; struct scope_info *params; }; char *literal; }; struct symbol_info *next; } *symbol; char *symbol_name; }; } x; union { enum ir_binop { IR_PLUS=0, IR_MINUS=1, IR_TIMES=2, IR_DIV=3, IR_AND=4, IR_OR=5 } binop; enum ir_unop { IR_NEG=0 } unop; enum ir_relop { IR_EQ=0, IR_NEQ=1, IR_GT=2, IR_GTE=3, IR_LT=4, IR_LTE=5 } relop; }; }; struct { char *name; enum ir_data { DATA_RAW=0, DATA_STRING=1 } data_type; union { int bytes; char *text; }; }; struct { char *label; int offset; }; }; } item; struct ir_list *next; } *codes; struct symbol_table { struct scope_info *top_level; struct symbol_info *literals; } table; } *code; struct ir_list *last; struct scope_info *scope; int tmp_counter; int label_counter; } *

user_defined_types: struct context { struct ir_code *code; struct ir_list *last; struct scope_info *scope; int tmp_counter; int label_counter; }

user_defined_types: struct ir_code { struct ir_list *codes; struct symbol_table table; }

user_defined_types: struct ir_list { struct ir_item item; struct ir_list *next; }


decompiled_code:
_QWORD *make_code_struct()
{
_QWORD *v0; // rax
_QWORD *v1; // r12

v0 = malloc(0x18uLL);
*v0 = 0LL;
v1 = v0;
clean_symbol_table(v0 + 1);
return v1;
}

canonical_decompiled_code:
_QWORD *func1()
{
_QWORD *v0; // rax
_QWORD *v1; // r12

v0 = malloc(0x18uLL);
*v0 = 0LL;
v1 = v0;
clean_symbol_table(v0 + 1);
return v1;
}

original_code:
static ir_code* make_code_struct(void)
{
    ir_code* code = malloc(sizeof(ir_code));
    code->codes = ((void *)0);
    clean_symbol_table(&code->table);
    return code;
}

canonical_original_code:
static struct ir_code *make_code_struct()
{
    struct ir_code *code = malloc(sizeof(ir_code));
    code->codes = ((void *)0);
    clean_symbol_table(&code->table);
    return code;
}

variable_types: struct ir_code { struct ir_list { struct ir_item { enum ir_type { IR_EMPTY=0, IR_DATA=1, IR_BINOP=2, IR_UNOP=3, IR_COPY=4, IR_GOTO=5, IR_BRANCH=6, IR_LABEL=7, IR_LIDX=8, IR_RIDX=9, IR_ADDR=10, IR_LDEREF=11, IR_RDEREF=12, IR_ENTER=13, IR_LEAVE=14, IR_PARAM=15, IR_CALL=16, IR_RET=17, IR_RET_VAL=18, IR_RETRIEVE=19 } type; union { struct { struct address { enum addr_type { ADDR_EMPTY=0, ADDR_SYMBOL=1, ADDR_SYMBOL_NAME=2, ADDR_IMM_INT=3, ADDR_IMM_CHAR=4, ADDR_IMM_STRING=5 } type; union { int integer; char character; char *string; struct symbol_info { enum symbol_type { SYM_NONE=0, SYM_FUN=1, SYM_VAR=2, SYM_LITERAL=3 } symbol_type; char *name; struct scope_info { struct symbol_info *symbols; struct scope_info *parent; struct scope_info *next; struct scope_info *children; } *scope; union { struct { struct type { enum basic_type { T_VOID=0, T_INT=1, T_CHAR=2, T_INT_ARRAY=3, T_CHAR_ARRAY=4 } type; int elements; } var_type; struct codegen_info { enum storage_type { ST_UNKNOWN=0, ST_REG=1, ST_LOCAL=2, ST_GLOBAL=3 } storage; int size; union { int reg; int offset; }; } codegen; }; struct { struct type ret_type; struct scope_info *params; }; char *literal; }; struct symbol_info *next; } *symbol; char *symbol_name; }; } x; union { enum ir_binop { IR_PLUS=0, IR_MINUS=1, IR_TIMES=2, IR_DIV=3, IR_AND=4, IR_OR=5 } binop; enum ir_unop { IR_NEG=0 } unop; enum ir_relop { IR_EQ=0, IR_NEQ=1, IR_GT=2, IR_GTE=3, IR_LT=4, IR_LTE=5 } relop; }; }; struct { char *name; enum ir_data { DATA_RAW=0, DATA_STRING=1 } data_type; union { int bytes; char *text; }; }; struct { char *label; int offset; }; }; } item; struct ir_list *next; } *codes; struct symbol_table { struct scope_info *top_level; struct symbol_info *literals; } table; } *

user_defined_types: struct symbol_info { enum symbol_type symbol_type; char *name; struct scope_info *scope; union { struct { struct type var_type; struct codegen_info codegen; }; struct { struct type ret_type; struct scope_info *params; }; char *literal; }; struct symbol_info *next; }


decompiled_code:
__int64 __fastcall ctx_push_scope(__int64 a1, __int64 a2)
{
__int64 result; // rax

result = sym_add_child_scope(*(_QWORD *)(a1 + 16));
*(_QWORD *)(a1 + 16) = a2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2)
{
__int64 result; // rax

result = sym_add_child_scope(*(_QWORD *)(a1 + 16));
*(_QWORD *)(a1 + 16) = a2;
return result;
}

original_code:
static void ctx_push_scope(context* ctx, scope_info* scope)
{
    sym_add_child_scope(ctx->scope, scope);
    ctx->scope = scope;
}

canonical_original_code:
static void ctx_push_scope(struct context *ctx, struct scope_info *scope)
{
    sym_add_child_scope(ctx->scope, scope);
    ctx->scope = scope;
}

variable_types:
scope
struct scope_info *

user_defined_types: struct symbol_table { struct scope_info *top_level; struct symbol_info *literals; }

user_defined_types: enum ir_data { DATA_RAW=0, DATA_STRING=1 }

user_defined_types: enum addr_type { ADDR_EMPTY=0, ADDR_SYMBOL=1, ADDR_SYMBOL_NAME=2, ADDR_IMM_INT=3, ADDR_IMM_CHAR=4, ADDR_IMM_STRING=5 }

user_defined_types: enum ir_binop { IR_PLUS=0, IR_MINUS=1, IR_TIMES=2, IR_DIV=3, IR_AND=4, IR_OR=5 }

user_defined_types: enum ir_relop { IR_EQ=0, IR_NEQ=1, IR_GT=2, IR_GTE=3, IR_LT=4, IR_LTE=5 }

user_defined_types: enum symbol_type { SYM_NONE=0, SYM_FUN=1, SYM_VAR=2, SYM_LITERAL=3 }

user_defined_types: struct scope_info { struct symbol_info *symbols; struct scope_info *parent; struct scope_info *next; struct scope_info *children; }


decompiled_code:
__int64 __fastcall ctx_push_new_scope(__int64 a1)
{
__int64 v1; // r12
__int64 v2; // rbp
__int64 result; // rax

v1 = *(_QWORD *)(a1 + 16);
v2 = sym_mkscope(v1);
result = sym_add_child_scope(v1);
*(_QWORD *)(a1 + 16) = v2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
__int64 v1; // r12
__int64 v2; // rbp
__int64 result; // rax

v1 = *(_QWORD *)(a1 + 16);
v2 = sym_mkscope(v1);
result = sym_add_child_scope(v1);
*(_QWORD *)(a1 + 16) = v2;
return result;
}

original_code:
static void ctx_push_new_scope(context* ctx)
{
    scope_info* parent = ctx->scope;
    scope_info* scope = sym_mkscope(parent);
    sym_add_child_scope(parent, scope);
    ctx->scope = scope;
}

canonical_original_code:
static void ctx_push_new_scope(struct context *ctx)
{
    struct scope_info *parent = ctx->scope;
    struct scope_info *scope = sym_mkscope(parent);
    sym_add_child_scope(parent, scope);
    ctx->scope = scope;
}

variable_types: struct scope_info { struct symbol_info { enum symbol_type { SYM_NONE=0, SYM_FUN=1, SYM_VAR=2, SYM_LITERAL=3 } symbol_type; char *name; struct scope_info *scope; union { struct { struct type { enum basic_type { T_VOID=0, T_INT=1, T_CHAR=2, T_INT_ARRAY=3, T_CHAR_ARRAY=4 } type; int elements; } var_type; struct codegen_info { enum storage_type { ST_UNKNOWN=0, ST_REG=1, ST_LOCAL=2, ST_GLOBAL=3 } storage; int size; union { int reg; int offset; }; } codegen; }; struct { struct type ret_type; struct scope_info *params; }; char *literal; }; struct symbol_info *next; } *symbols; struct scope_info *parent; struct scope_info *next; struct scope_info *children; } *

user_defined_types: struct ir_item { enum ir_type type; union { struct { struct address x; union { enum ir_binop binop; enum ir_unop unop; enum ir_relop relop; }; }; struct { char *name; enum ir_data data_type; union { int bytes; char *text; }; }; struct { char *label; int offset; }; }; }

user_defined_types: struct type { enum basic_type type; int elements; }

user_defined_types: struct codegen_info { enum storage_type storage; int size; union { int reg; int offset; }; }

user_defined_types: enum ir_type { IR_EMPTY=0, IR_DATA=1, IR_BINOP=2, IR_UNOP=3, IR_COPY=4, IR_GOTO=5, IR_BRANCH=6, IR_LABEL=7, IR_LIDX=8, IR_RIDX=9, IR_ADDR=10, IR_LDEREF=11, IR_RDEREF=12, IR_ENTER=13, IR_LEAVE=14, IR_PARAM=15, IR_CALL=16, IR_RET=17, IR_RET_VAL=18, IR_RETRIEVE=19 }


decompiled_code:
__int64 __fastcall process_expr_id(__int64 a1, __int64 a2)
{
__int64 v2; // rax

printf("expr_id (%s)\n", *(const char **)(a1 + 8));
v2 = ctx_lookup_isra_0(*(_QWORD *)(a1 + 8), *(_QWORD *)(a2 + 16));
if ( v2 )
return ir_mksymbol(v2);
fprintf(stderr, "[%s]: Error: unknown identifier `%s'\n", "???", *(const char **)(a1 + 8));
return ir_mkempty();
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, __int64 a2)
{
__int64 v2; // rax

printf("expr_id (%s)\n", *(const char **)(a1 + 8));
v2 = func9(*(_QWORD *)(a1 + 8), *(_QWORD *)(a2 + 16));
if ( v2 )
return ir_mksymbol(v2);
fprintf(stderr, "[%s]: Error: unknown identifier `%s'\n", "???", *(const char **)(a1 + 8));
return ir_mkempty();
}

original_code:
static address process_expr_id(expr* exp, context* ctx)
{
    printf("expr_id (%s)\n", exp->id);
    symbol_info* info = ctx_lookup(exp->id, ctx);
    if (info == ((void *)0))
    {
        fprintf(stderr, "[%s]: Error: unknown identifier `%s'\n",
                "???", exp->id);
        return ir_mkempty();
    }
    else
        return ir_mksymbol(info);
}

canonical_original_code:
static struct address process_expr_id(struct expr *exp, struct context *ctx)
{
    printf("expr_id (%s)\n", exp->id);
    struct symbol_info *info = ctx_lookup(exp->id, ctx);
    if (info == ((void *)0))
    {
        fprintf(stderr, "[%s]: Error: unknown identifier `%s'\n",
                "???", exp->id);
        return ir_mkempty();
    }
    else
        return ir_mksymbol(info);
}

variable_types: struct expr { enum expr_type { EXP_ID=0, EXP_INT=1, EXP_CHAR=2, EXP_STRING=3, EXP_PLUS=100, EXP_MINUS=101, EXP_TIMES=102, EXP_DIV=103, EXP_EQ=104, EXP_NEQ=105, EXP_LTE=106, EXP_GTE=107, EXP_LT=108, EXP_GT=109, EXP_AND=110, EXP_OR=111, EXP_UNMINUS=150, EXP_NEG=151, EXP_INDEX=200, EXP_CALL=201 } type; union { union { struct { struct expr *left; struct expr *right; }; struct { char *id; struct expr_list { struct expr *expression; struct expr_list *next; } *args; }; struct { struct expr *expression; struct expr *index; }; }; union { char *string; int integer; char character; }; }; } *

variable_types: struct context { struct ir_code { struct ir_list { struct ir_item { enum ir_type { IR_EMPTY=0, IR_DATA=1, IR_BINOP=2, IR_UNOP=3, IR_COPY=4, IR_GOTO=5, IR_BRANCH=6, IR_LABEL=7, IR_LIDX=8, IR_RIDX=9, IR_ADDR=10, IR_LDEREF=11, IR_RDEREF=12, IR_ENTER=13, IR_LEAVE=14, IR_PARAM=15, IR_CALL=16, IR_RET=17, IR_RET_VAL=18, IR_RETRIEVE=19 } type; union { struct { struct address x; union { enum ir_binop { IR_PLUS=0, IR_MINUS=1, IR_TIMES=2, IR_DIV=3, IR_AND=4, IR_OR=5 } binop; enum ir_unop { IR_NEG=0 } unop; enum ir_relop { IR_EQ=0, IR_NEQ=1, IR_GT=2, IR_GTE=3, IR_LT=4, IR_LTE=5 } relop; }; }; struct { char *name; enum ir_data { DATA_RAW=0, DATA_STRING=1 } data_type; union { int bytes; char *text; }; }; struct { char *label; int offset; }; }; } item; struct ir_list *next; } *codes; struct symbol_table { struct scope_info *top_level; struct symbol_info *literals; } table; } *code; struct ir_list *last; struct scope_info *scope; int tmp_counter; int label_counter; } *

return_type: struct address { enum addr_type { ADDR_EMPTY=0, ADDR_SYMBOL=1, ADDR_SYMBOL_NAME=2, ADDR_IMM_INT=3, ADDR_IMM_CHAR=4, ADDR_IMM_STRING=5 } type; union { int integer; char character; char *string; struct symbol_info { enum symbol_type { SYM_NONE=0, SYM_FUN=1, SYM_VAR=2, SYM_LITERAL=3 } symbol_type; char *name; struct scope_info { struct symbol_info *symbols; struct scope_info *parent; struct scope_info *next; struct scope_info *children; } *scope; union { struct { struct type { enum basic_type { T_VOID=0, T_INT=1, T_CHAR=2, T_INT_ARRAY=3, T_CHAR_ARRAY=4 } type; int elements; } var_type; struct codegen_info { enum storage_type { ST_UNKNOWN=0, ST_REG=1, ST_LOCAL=2, ST_GLOBAL=3 } storage; int size; union { int reg; int offset; }; } codegen; }; struct { struct type ret_type; struct scope_info *params; }; char *literal; }; struct symbol_info *next; } *symbol; char *symbol_name; }; }

user_defined_types: struct address { enum addr_type type; union { int integer; char character; char *string; struct symbol_info *symbol; char *symbol_name; }; }

user_defined_types: struct expr { enum expr_type type; union { union { struct { struct expr *left; struct expr *right; }; struct { char *id; struct expr_list *args; }; struct { struct expr *expression; struct expr *index; }; }; union { char *string; int integer; char character; }; }; }


decompiled_code:
__int64 __fastcall process_expr_string(__int64 a1, __int64 *a2)
{
printf("expr_string (%s)\n", *(const char **)(a1 + 8));
return ctx_mkliteral_isra_0(*(_QWORD *)(a1 + 8), *a2);
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, __int64 *a2)
{
printf("expr_string (%s)\n", *(const char **)(a1 + 8));
return func12(*(_QWORD *)(a1 + 8), *a2);
}

original_code:
static address process_expr_string(expr* exp, context* ctx)
{
    printf("expr_string (%s)\n", exp->string);
    return ctx_mkliteral(exp->string, ctx);
}

canonical_original_code:
static struct address process_expr_string(struct expr *exp, struct context *ctx)
{
    printf("expr_string (%s)\n", exp->string);
    return ctx_mkliteral(exp->string, ctx);
}

user_defined_types: struct context { struct ir_code *code; struct ir_list *last; struct scope_info *scope; int tmp_counter; int label_counter; }

user_defined_types: enum expr_type { EXP_ID=0, EXP_INT=1, EXP_CHAR=2, EXP_STRING=3, EXP_PLUS=100, EXP_MINUS=101, EXP_TIMES=102, EXP_DIV=103, EXP_EQ=104, EXP_NEQ=105, EXP_LTE=106, EXP_GTE=107, EXP_LT=108, EXP_GT=109, EXP_AND=110, EXP_OR=111, EXP_UNMINUS=150, EXP_NEG=151, EXP_INDEX=200, EXP_CALL=201 }

user_defined_types: struct expr_list { struct expr *expression; struct expr_list *next; }

user_defined_types: enum basic_type { T_VOID=0, T_INT=1, T_CHAR=2, T_INT_ARRAY=3, T_CHAR_ARRAY=4 }

user_defined_types: enum storage_type { ST_UNKNOWN=0, ST_REG=1, ST_LOCAL=2, ST_GLOBAL=3 }


decompiled_code:
unsigned int __fastcall process_statement(__int64 a1, __int64 *a2)
{
unsigned int result; // eax

result = *(_DWORD *)a1;
if ( *(_DWORD *)a1 == 101 )
return process_return_constprop_0(*(const void **)(a1 + 24));
if ( result > 0x65 )
{
if ( result != 102 && result != 200 )
goto LABEL_10;
}
else if ( result > 2 )
{
if ( result == 100 )
return process_expr_isra_0(*(const char ***)(a1 + 24), a2);
LABEL_10:
_assert_fail("0 && \"process_statement: unknown statement type\"", "ir_generator.c", 0xA0u, "process_statement");
}
return result;
}

canonical_decompiled_code:
unsigned int __fastcall func15(__int64 a1, __int64 *a2)
{
unsigned int result; // eax

result = *(_DWORD *)a1;
if ( *(_DWORD *)a1 == 101 )
return func7(*(const void **)(a1 + 24));
if ( result > 0x65 )
{
if ( result != 102 && result != 200 )
goto LABEL_10;
}
else if ( result > 2 )
{
if ( result == 100 )
return func14(*(const char ***)(a1 + 24), a2);
LABEL_10:
_assert_fail("0 && \"process_statement: unknown statement type\"", "ir_generator.c", 0xA0u, "process_statement");
}
return result;
}

original_code:
static void process_statement(stmt* statement, context* ctx)
{
    switch (statement->type)
    {
    case STM_ASSIGN: break;
    case STM_COMPOUND: break;
    case STM_EXP:
        process_expr(statement->expression, ctx);
        break;
    case STM_FOR: break;
    case STM_IF: break;
    case STM_RETURN:
        process_return(statement->expression, ctx);
        break;
    case STM_WHILE: break;
    default:
        ((void) sizeof ((0 && "process_statement: unknown statement type") ? 1 : 0), __extension__ ({ if (0 && "process_statement: unknown statement type") ; else __assert_fail ("0 && \"process_statement: unknown statement type\"", "ir_generator.c", 160, __extension__ __PRETTY_FUNCTION__); }));
        break;
    }
}

canonical_original_code:
static void process_statement(struct stmt *statement, struct context *ctx)
{
    switch (statement->type)
    {
    case STM_ASSIGN: break;
    case STM_COMPOUND: break;
    case STM_EXP:
        process_expr(statement->expression, ctx);
        break;
    case STM_FOR: break;
    case STM_IF: break;
    case STM_RETURN:
        process_return(statement->expression, ctx);
        break;
    case STM_WHILE: break;
    default:
        ((void) sizeof ((0 && "process_statement: unknown statement type") ? 1 : 0), __extension__ ({ if (0 && "process_statement: unknown statement type") ; else __assert_fail ("0 && \"process_statement: unknown statement type\"", "ir_generator.c", 160, __extension__ __PRETTY_FUNCTION__); }));
        break;
    }
}

variable_types: struct stmt { enum stmt_type { STM_IF=0, STM_WHILE=1, STM_FOR=2, STM_EXP=100, STM_RETURN=101, STM_ASSIGN=102, STM_COMPOUND=200 } type; union { struct { char *name; struct expr { enum expr_type { EXP_ID=0, EXP_INT=1, EXP_CHAR=2, EXP_STRING=3, EXP_PLUS=100, EXP_MINUS=101, EXP_TIMES=102, EXP_DIV=103, EXP_EQ=104, EXP_NEQ=105, EXP_LTE=106, EXP_GTE=107, EXP_LT=108, EXP_GT=109, EXP_AND=110, EXP_OR=111, EXP_UNMINUS=150, EXP_NEG=151, EXP_INDEX=200, EXP_CALL=201 } type; union { union { struct { struct expr *left; struct expr *right; }; struct { char *id; struct expr_list { struct expr *expression; struct expr_list *next; } *args; }; struct { struct expr *expression; struct expr *index; }; }; union { char *string; int integer; char character; }; }; } *index; struct expr *expression; }; struct { struct stmt *init; struct expr *condition; struct stmt *update; struct stmt *body; struct stmt *else_body; }; struct stmt_list { struct stmt *statement; struct stmt_list *next; } *list; }; } *

user_defined_types: struct stmt { enum stmt_type type; union { struct { char *name; struct expr *index; struct expr *expression; }; struct { struct stmt *init; struct expr *condition; struct stmt *update; struct stmt *body; struct stmt *else_body; }; struct stmt_list *list; }; }

user_defined_types: struct ir_code { struct ir_list *codes; struct symbol_table table; }

user_defined_types: struct symbol_table { struct scope_info *top_level; struct symbol_info *literals; }

user_defined_types: struct ir_list { struct ir_item item; struct ir_list *next; }

user_defined_types: enum ir_data { DATA_RAW=0, DATA_STRING=1 }

user_defined_types: struct symbol_info { enum symbol_type symbol_type; char *name; struct scope_info *scope; union { struct { struct type var_type; struct codegen_info codegen; }; struct { struct type ret_type; struct scope_info *params; }; char *literal; }; struct symbol_info *next; }


decompiled_code:
__int64 __fastcall process_toplevel(__int64 a1, __int64 *a2)
{
__int64 result; // rax

if ( *(_DWORD *)a1 == 1 )
result = process_fun(a1, a2);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func18(__int64 a1, __int64 *a2)
{
__int64 result; // rax

if ( *(_DWORD *)a1 == 1 )
result = func17(a1, a2);
return result;
}

original_code:
static void process_toplevel(node* node, context* ctx)
{
    switch (node->type)
    {
    case NODE_DECL: process_decl(node, ctx); break;
    case NODE_FUN: process_fun(node, ctx); break;
    }
}

canonical_original_code:
static void process_toplevel(struct node *node, struct context *ctx)
{
    switch (node->type)
    {
    case NODE_DECL: process_decl(node, ctx); break;
    case NODE_FUN: process_fun(node, ctx); break;
    }
}

variable_types: struct node { enum node_type { NODE_DECL=0, NODE_FUN=1 } type; union { struct fun_def { struct decl { enum value_type { TYPE_INT=0, TYPE_CHAR=1, TYPE_VOID=2 } type; int is_extern; struct decltor_list { struct decltor { enum decltor_type { DECLTOR_FUN=0, DECLTOR_ARRAY=1, DECLTOR_SIMPLE=2 } type; char *name; union { struct decl_list { struct decl *declaration; struct decl_list *next; } *params; struct expr { enum expr_type { EXP_ID=0, EXP_INT=1, EXP_CHAR=2, EXP_STRING=3, EXP_PLUS=100, EXP_MINUS=101, EXP_TIMES=102, EXP_DIV=103, EXP_EQ=104, EXP_NEQ=105, EXP_LTE=106, EXP_GTE=107, EXP_LT=108, EXP_GT=109, EXP_AND=110, EXP_OR=111, EXP_UNMINUS=150, EXP_NEG=151, EXP_INDEX=200, EXP_CALL=201 } type; union { union { struct { struct expr *left; struct expr *right; }; struct { char *id; struct expr_list { struct expr *expression; struct expr_list *next; } *args; }; struct { struct expr *expression; struct expr *index; }; }; union { char *string; int integer; char character; }; }; } *elements; }; } *declarator; struct decltor_list *next; } *declarators; } *signature; struct decl_list *declarations; struct stmt_list { struct stmt { enum stmt_type { STM_IF=0, STM_WHILE=1, STM_FOR=2, STM_EXP=100, STM_RETURN=101, STM_ASSIGN=102, STM_COMPOUND=200 } type; union { struct { char *name; struct expr *index; struct expr *expression; }; struct { struct stmt *init; struct expr *condition; struct stmt *update; struct stmt *body; struct stmt *else_body; }; struct stmt_list *list; }; } *statement; struct stmt_list *next; } *statements; } *function; struct decl *declaration; }; struct node *next; } *

user_defined_types: struct node { enum node_type type; union { struct fun_def *function; struct decl *declaration; }; struct node *next; }

user_defined_types: struct fun_def { struct decl *signature; struct decl_list *declarations; struct stmt_list *statements; }

user_defined_types: struct decl { enum value_type type; int is_extern; struct decltor_list *declarators; }

user_defined_types: struct stmt_list { struct stmt *statement; struct stmt_list *next; }

user_defined_types: struct ir_item { enum ir_type type; union { struct { struct address x; union { enum ir_binop binop; enum ir_unop unop; enum ir_relop relop; }; }; struct { char *name; enum ir_data data_type; union { int bytes; char *text; }; }; struct { char *label; int offset; }; }; }

user_defined_types: struct decltor_list { struct decltor *declarator; struct decltor_list *next; }

user_defined_types: struct decltor { enum decltor_type type; char *name; union { struct decl_list *params; struct expr *elements; }; }

user_defined_types: enum addr_type { ADDR_EMPTY=0, ADDR_SYMBOL=1, ADDR_SYMBOL_NAME=2, ADDR_IMM_INT=3, ADDR_IMM_CHAR=4, ADDR_IMM_STRING=5 }

user_defined_types: enum ir_binop { IR_PLUS=0, IR_MINUS=1, IR_TIMES=2, IR_DIV=3, IR_AND=4, IR_OR=5 }

user_defined_types: enum ir_relop { IR_EQ=0, IR_NEQ=1, IR_GT=2, IR_GTE=3, IR_LT=4, IR_LTE=5 }

user_defined_types: enum symbol_type { SYM_NONE=0, SYM_FUN=1, SYM_VAR=2, SYM_LITERAL=3 }

user_defined_types: struct scope_info { struct symbol_info *symbols; struct scope_info *parent; struct scope_info *next; struct scope_info *children; }


decompiled_code:
int __fastcall next_label(char *a1)
{
__int64 v1; // rdx

v1 = (unsigned int)label_counter++;
return sprintf(a1, "__L%d__", v1);
}

canonical_decompiled_code:
int __fastcall func0(char *a1)
{
__int64 v1; // rdx

v1 = (unsigned int)label_counter++;
return sprintf(a1, "__L%d__", v1);
}

original_code:
void next_label(char* buffer)
{
    sprintf(buffer, "__L%d__", label_counter++);
}

canonical_original_code:
void next_label(char *buffer)
{
    sprintf(buffer, "__L%d__", label_counter++);
}


decompiled_code:
_QWORD *MIPS_empty_list()
{
_QWORD *result; // rax

result = malloc(0x40uLL);
result[7] = 0LL;
return result;
}

canonical_decompiled_code:
_QWORD *func0()
{
_QWORD *result; // rax

result = malloc(0x40uLL);
result[7] = 0LL;
return result;
}

original_code:
MIPS_list* MIPS_empty_list(void)
{
    MIPS_list* node = malloc(sizeof(MIPS_list));
    node->next = ((void *)0);
    return node;
}

canonical_original_code:
struct MIPS_list *MIPS_empty_list()
{
    struct MIPS_list *node = malloc(sizeof(MIPS_list));
    node->next = ((void *)0);
    return node;
}

variable_types: struct MIPS_list { struct MIPS_instruction { enum MIPS_opcode { MIPS_add=0, MIPS_sub=1, MIPS_addi=2, MIPS_mult=3, MIPS_div=4, MIPS_lw=5, MIPS_lb=6, MIPS_sw=7, MIPS_sb=8, MIPS_mfhi=9, MIPS_mflo=10, MIPS_and=11, MIPS_andi=12, MIPS_or=13, MIPS_ori=14, MIPS_slt=15, MIPS_slti=16, MIPS_bgt=17, MIPS_bge=18, MIPS_blt=19, MIPS_ble=20, MIPS_sll=21, MIPS_srl=22, MIPS_beq=23, MIPS_bne=24, MIPS_jal=25, MIPS_jr=26, MIPS_b=27, MIPS_la=28, MIPS_li=29 } opcode; struct MIPS_operand { enum MIPS_operand_type { MIPS_OPERAND_NONE=0, MIPS_REG=1, MIPS_IMM_32=2, MIPS_IMM_8=3, MIPS_OFFSET=4, MIPS_SYMBOL=5 } type; union { int reg; int imm32; char imm8; int offset; char *symbol; }; } x; } instr; struct MIPS_list *next; } *

user_defined_types: struct MIPS_list { struct MIPS_instruction instr; struct MIPS_list *next; }

user_defined_types: struct MIPS_instruction { enum MIPS_opcode opcode; struct MIPS_operand x; }

user_defined_types: struct MIPS_operand { enum MIPS_operand_type type; union { int reg; int imm32; char imm8; int offset; char *symbol; }; }


decompiled_code:
void __fastcall MIPS_free_list(void *ptr)
{
void *v1; // rbx
void *v2; // rdi

if ( ptr )
{
v1 = ptr;
do
{
MIPS_free_instr(v1);
v2 = v1;
v1 = (void *)*((_QWORD *)v1 + 7);
free(v2);
}
while ( v1 );
}
}

canonical_decompiled_code:
void __fastcall func1(void *ptr)
{
void *v1; // rbx
void *v2; // rdi

if ( ptr )
{
v1 = ptr;
do
{
MIPS_free_instr(v1);
v2 = v1;
v1 = (void *)*((_QWORD *)v1 + 7);
free(v2);
}
while ( v1 );
}
}

original_code:
void MIPS_free_list(MIPS_list* codes)
{
    while (codes != ((void *)0))
    {
        MIPS_free_instr(&codes->instr);
        MIPS_list* tmp = codes;
        codes = codes->next;
        free(tmp);
    }
}

canonical_original_code:
void MIPS_free_list(struct MIPS_list *codes)
{
    while (codes != ((void *)0))
    {
        MIPS_free_instr(&codes->instr);
        struct MIPS_list *tmp = codes;
        codes = codes->next;
        free(tmp);
    }
}

user_defined_types: enum MIPS_opcode { MIPS_add=0, MIPS_sub=1, MIPS_addi=2, MIPS_mult=3, MIPS_div=4, MIPS_lw=5, MIPS_lb=6, MIPS_sw=7, MIPS_sb=8, MIPS_mfhi=9, MIPS_mflo=10, MIPS_and=11, MIPS_andi=12, MIPS_or=13, MIPS_ori=14, MIPS_slt=15, MIPS_slti=16, MIPS_bgt=17, MIPS_bge=18, MIPS_blt=19, MIPS_ble=20, MIPS_sll=21, MIPS_srl=22, MIPS_beq=23, MIPS_bne=24, MIPS_jal=25, MIPS_jr=26, MIPS_b=27, MIPS_la=28, MIPS_li=29 }

user_defined_types: enum MIPS_operand_type { MIPS_OPERAND_NONE=0, MIPS_REG=1, MIPS_IMM_32=2, MIPS_IMM_8=3, MIPS_OFFSET=4, MIPS_SYMBOL=5 }


decompiled_code:
__int64 __fastcall out_data(__int64 a1)
{
int v1; // eax
char *v2; // rbp
char v4[128]; // [rsp+0h] [rbp-118h] BYREF
char s[152]; // [rsp+80h] [rbp-98h] BYREF

sprintf(v4, "%s:\t\t", *(const char **)(a1 + 8));
v1 = *(_DWORD *)(a1 + 16);
if ( v1 )
{
if ( v1 == 1 )
{
v2 = (char *)escape_alloc(*(_QWORD *)(a1 + 24));
sprintf(s, ".ascii \"%s\"", v2);
free(v2);
strcat(v4, s);
}
}
else
{
sprintf(s, ".space %d", *(unsigned int *)(a1 + 24));
strcat(v4, s);
}
return single_line(v4);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
int v1; // eax
char *v2; // rbp
char v4[128]; // [rsp+0h] [rbp-118h] BYREF
char s[152]; // [rsp+80h] [rbp-98h] BYREF

sprintf(v4, "%s:\t\t", *(const char **)(a1 + 8));
v1 = *(_DWORD *)(a1 + 16);
if ( v1 )
{
if ( v1 == 1 )
{
v2 = (char *)escape_alloc(*(_QWORD *)(a1 + 24));
sprintf(s, ".ascii \"%s\"", v2);
free(v2);
strcat(v4, s);
}
}
else
{
sprintf(s, ".space %d", *(unsigned int *)(a1 + 24));
strcat(v4, s);
}
return single_line(v4);
}

original_code:
static line_list* out_data(ir_item* item)
{
    char buffer[128];
    char data[128];
    sprintf(buffer, "%s:\t\t", item->name);
    switch (item->data_type)
    {
    case DATA_RAW:
        sprintf(data, ".space %d", item->bytes);
        strcat(buffer, data);
        break;
    case DATA_STRING:
    {
        char* escaped = escape_alloc(item->text);
        sprintf(data, ".ascii \"%s\"", escaped);
        free(escaped);
        strcat(buffer, data);
        break;
    }
    }
    return single_line(buffer);
}

canonical_original_code:
static struct line_list *out_data(struct ir_item *item)
{
    char buffer[128];
    char data[128];
    sprintf(buffer, "%s:\t\t", item->name);
    switch (item->data_type)
    {
    case DATA_RAW:
        sprintf(data, ".space %d", item->bytes);
        strcat(buffer, data);
        break;
    case DATA_STRING:
    {
        char *escaped = escape_alloc(item->text);
        sprintf(data, ".ascii \"%s\"", escaped);
        free(escaped);
        strcat(buffer, data);
        break;
    }
    }
    return single_line(buffer);
}

variable_types: struct ir_item { enum ir_type { IR_EMPTY=0, IR_DATA=1, IR_BINOP=2, IR_UNOP=3, IR_COPY=4, IR_GOTO=5, IR_BRANCH=6, IR_LABEL=7, IR_LIDX=8, IR_RIDX=9, IR_ADDR=10, IR_LDEREF=11, IR_RDEREF=12, IR_ENTER=13, IR_LEAVE=14, IR_PARAM=15, IR_CALL=16, IR_RET=17, IR_RET_VAL=18, IR_RETRIEVE=19 } type; union { struct { struct address { enum addr_type { ADDR_EMPTY=0, ADDR_SYMBOL=1, ADDR_SYMBOL_NAME=2, ADDR_IMM_INT=3, ADDR_IMM_CHAR=4, ADDR_IMM_STRING=5 } type; union { int integer; char character; char *string; struct symbol_info { enum symbol_type { SYM_NONE=0, SYM_FUN=1, SYM_VAR=2, SYM_LITERAL=3 } symbol_type; char *name; struct scope_info { struct symbol_info *symbols; struct scope_info *parent; struct scope_info *next; struct scope_info *children; } *scope; union { struct { struct type { enum basic_type { T_VOID=0, T_INT=1, T_CHAR=2, T_INT_ARRAY=3, T_CHAR_ARRAY=4 } type; int elements; } var_type; struct codegen_info { enum storage_type { ST_UNKNOWN=0, ST_REG=1, ST_LOCAL=2, ST_GLOBAL=3 } storage; int size; union { int reg; int offset; }; } codegen; }; struct { struct type ret_type; struct scope_info *params; }; char *literal; }; struct symbol_info *next; } *symbol; char *symbol_name; }; } x; union { enum ir_binop { IR_PLUS=0, IR_MINUS=1, IR_TIMES=2, IR_DIV=3, IR_AND=4, IR_OR=5 } binop; enum ir_unop { IR_NEG=0 } unop; enum ir_relop { IR_EQ=0, IR_NEQ=1, IR_GT=2, IR_GTE=3, IR_LT=4, IR_LTE=5 } relop; }; }; struct { char *name; enum ir_data { DATA_RAW=0, DATA_STRING=1 } data_type; union { int bytes; char *text; }; }; struct { char *label; int offset; }; }; } *

variable_types:
buffer
char [128]

variable_types:
data
char [128]

variable_types:
escaped
char *

return_type: struct line_list { char *line; struct line_list *next; } *

user_defined_types: struct address { enum addr_type type; union { int integer; char character; char *string; struct symbol_info *symbol; char *symbol_name; }; }

user_defined_types: struct symbol_info { enum symbol_type symbol_type; char *name; struct scope_info *scope; union { struct { struct type var_type; struct codegen_info codegen; }; struct { struct type ret_type; struct scope_info *params; }; char *literal; }; struct symbol_info *next; }

user_defined_types: struct type { enum basic_type type; int elements; }

user_defined_types: struct codegen_info { enum storage_type storage; int size; union { int reg; int offset; }; }


decompiled_code:
__int64 __fastcall MIPS_translate(_DWORD *a1)
{
__int64 result; // rax

result = (unsigned int)*a1;
switch ( *a1 )
{
case 2:
result = MIPS_make_binop();
break;
case 3:
result = MIPS_make_unop();
break;
case 4:
result = MIPS_make_copy();
break;
case 5:
result = MIPS_make_goto();
break;
case 6:
result = MIPS_make_branch();
break;
case 8:
result = MIPS_make_lidx();
break;
case 9:
result = MIPS_make_ridx();
break;
case 0xA:
result = MIPS_make_addr();
break;
case 0xB:
result = MIPS_make_lderef();
break;
case 0xC:
result = MIPS_make_rderef();
break;
case 0xD:
result = MIPS_make_enter();
break;
case 0xE:
result = MIPS_make_leave();
break;
case 0xF:
result = MIPS_make_param();
break;
case 0x10:
result = MIPS_make_call();
break;
case 0x11:
result = MIPS_make_ret();
break;
case 0x12:
result = MIPS_make_ret_val();
break;
case 0x13:
result = MIPS_make_retrieve();
break;
default:
return result;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(_DWORD *a1)
{
__int64 result; // rax

result = (unsigned int)*a1;
switch ( *a1 )
{
case 2:
result = MIPS_make_binop();
break;
case 3:
result = MIPS_make_unop();
break;
case 4:
result = MIPS_make_copy();
break;
case 5:
result = MIPS_make_goto();
break;
case 6:
result = MIPS_make_branch();
break;
case 8:
result = MIPS_make_lidx();
break;
case 9:
result = MIPS_make_ridx();
break;
case 0xA:
result = MIPS_make_addr();
break;
case 0xB:
result = MIPS_make_lderef();
break;
case 0xC:
result = MIPS_make_rderef();
break;
case 0xD:
result = MIPS_make_enter();
break;
case 0xE:
result = MIPS_make_leave();
break;
case 0xF:
result = MIPS_make_param();
break;
case 0x10:
result = MIPS_make_call();
break;
case 0x11:
result = MIPS_make_ret();
break;
case 0x12:
result = MIPS_make_ret_val();
break;
case 0x13:
result = MIPS_make_retrieve();
break;
default:
return result;
}
return result;
}

original_code:
static MIPS_list* MIPS_translate(ir_item* item)
{
    switch (item->type)
    {
    case IR_BINOP: return MIPS_make_binop(item);
    case IR_UNOP: return MIPS_make_unop(item);
    case IR_COPY: return MIPS_make_copy(item);
    case IR_GOTO: return MIPS_make_goto(item);
    case IR_BRANCH: return MIPS_make_branch(item);
    case IR_LIDX: return MIPS_make_lidx(item);
    case IR_RIDX: return MIPS_make_ridx(item);
    case IR_ADDR: return MIPS_make_addr(item);
    case IR_LDEREF: return MIPS_make_lderef(item);
    case IR_RDEREF: return MIPS_make_rderef(item);
    case IR_ENTER: return MIPS_make_enter(item);
    case IR_LEAVE: return MIPS_make_leave(item);
    case IR_PARAM: return MIPS_make_param(item);
    case IR_CALL: return MIPS_make_call(item);
    case IR_RET: return MIPS_make_ret(item);
    case IR_RET_VAL: return MIPS_make_ret_val(item);
    case IR_RETRIEVE: return MIPS_make_retrieve(item);
    }
}

canonical_original_code:
static struct MIPS_list *MIPS_translate(struct ir_item *item)
{
    switch (item->type)
    {
    case IR_BINOP: return MIPS_make_binop(item);
    case IR_UNOP: return MIPS_make_unop(item);
    case IR_COPY: return MIPS_make_copy(item);
    case IR_GOTO: return MIPS_make_goto(item);
    case IR_BRANCH: return MIPS_make_branch(item);
    case IR_LIDX: return MIPS_make_lidx(item);
    case IR_RIDX: return MIPS_make_ridx(item);
    case IR_ADDR: return MIPS_make_addr(item);
    case IR_LDEREF: return MIPS_make_lderef(item);
    case IR_RDEREF: return MIPS_make_rderef(item);
    case IR_ENTER: return MIPS_make_enter(item);
    case IR_LEAVE: return MIPS_make_leave(item);
    case IR_PARAM: return MIPS_make_param(item);
    case IR_CALL: return MIPS_make_call(item);
    case IR_RET: return MIPS_make_ret(item);
    case IR_RET_VAL: return MIPS_make_ret_val(item);
    case IR_RETRIEVE: return MIPS_make_retrieve(item);
    }
}

user_defined_types: struct ir_item { enum ir_type type; union { struct { struct address x; union { enum ir_binop binop; enum ir_unop unop; enum ir_relop relop; }; }; struct { char *name; enum ir_data data_type; union { int bytes; char *text; }; }; struct { char *label; int offset; }; }; }

user_defined_types: enum ir_type { IR_EMPTY=0, IR_DATA=1, IR_BINOP=2, IR_UNOP=3, IR_COPY=4, IR_GOTO=5, IR_BRANCH=6, IR_LABEL=7, IR_LIDX=8, IR_RIDX=9, IR_ADDR=10, IR_LDEREF=11, IR_RDEREF=12, IR_ENTER=13, IR_LEAVE=14, IR_PARAM=15, IR_CALL=16, IR_RET=17, IR_RET_VAL=18, IR_RETRIEVE=19 }

user_defined_types: enum ir_data { DATA_RAW=0, DATA_STRING=1 }

user_defined_types: enum basic_type { T_VOID=0, T_INT=1, T_CHAR=2, T_INT_ARRAY=3, T_CHAR_ARRAY=4 }

user_defined_types: enum storage_type { ST_UNKNOWN=0, ST_REG=1, ST_LOCAL=2, ST_GLOBAL=3 }


original_code:
line_list* ir_output(ir_item item)
{
    switch (item.type)
    {
    case IR_EMPTY: return ((void *)0);
    case IR_DATA: return out_data(&item);
    case IR_LABEL: return out_label(&item);
    }
    MIPS_list* list = MIPS_translate(&item), *mp = list;
    line_list* lines = ((void *)0), *end = lines;
    char buffer[128];
    while (mp != ((void *)0))
    {
        MIPS_write_instr(buffer, mp->instr);
        end = append_line(end, buffer);
        if (lines == ((void *)0))
            lines = end;
        mp = mp->next;
    }
    MIPS_free_list(list);
    return lines;
}

canonical_original_code:
struct line_list *ir_output(struct ir_item item)
{
    switch (item.type)
    {
    case IR_EMPTY: return ((void *)0);
    case IR_DATA: return out_data(&item);
    case IR_LABEL: return out_label(&item);
    }
    struct MIPS_list *list = MIPS_translate(&item); struct MIPS_list *mp = list;
    struct line_list *lines = ((void *)0); struct line_list *end = lines;
    char buffer[128];
    while (mp != ((void *)0))
    {
        MIPS_write_instr(buffer, mp->instr);
        end = append_line(end, buffer);
        if (lines == ((void *)0))
            lines = end;
        mp = mp->next;
    }
    MIPS_free_list(list);
    return lines;
}

variable_types: struct ir_item { enum ir_type { IR_EMPTY=0, IR_DATA=1, IR_BINOP=2, IR_UNOP=3, IR_COPY=4, IR_GOTO=5, IR_BRANCH=6, IR_LABEL=7, IR_LIDX=8, IR_RIDX=9, IR_ADDR=10, IR_LDEREF=11, IR_RDEREF=12, IR_ENTER=13, IR_LEAVE=14, IR_PARAM=15, IR_CALL=16, IR_RET=17, IR_RET_VAL=18, IR_RETRIEVE=19 } type; union { struct { struct address { enum addr_type { ADDR_EMPTY=0, ADDR_SYMBOL=1, ADDR_SYMBOL_NAME=2, ADDR_IMM_INT=3, ADDR_IMM_CHAR=4, ADDR_IMM_STRING=5 } type; union { int integer; char character; char *string; struct symbol_info { enum symbol_type { SYM_NONE=0, SYM_FUN=1, SYM_VAR=2, SYM_LITERAL=3 } symbol_type; char *name; struct scope_info { struct symbol_info *symbols; struct scope_info *parent; struct scope_info *next; struct scope_info *children; } *scope; union { struct { struct type { enum basic_type { T_VOID=0, T_INT=1, T_CHAR=2, T_INT_ARRAY=3, T_CHAR_ARRAY=4 } type; int elements; } var_type; struct codegen_info { enum storage_type { ST_UNKNOWN=0, ST_REG=1, ST_LOCAL=2, ST_GLOBAL=3 } storage; int size; union { int reg; int offset; }; } codegen; }; struct { struct type ret_type; struct scope_info *params; }; char *literal; }; struct symbol_info *next; } *symbol; char *symbol_name; }; } x; union { enum ir_binop { IR_PLUS=0, IR_MINUS=1, IR_TIMES=2, IR_DIV=3, IR_AND=4, IR_OR=5 } binop; enum ir_unop { IR_NEG=0 } unop; enum ir_relop { IR_EQ=0, IR_NEQ=1, IR_GT=2, IR_GTE=3, IR_LT=4, IR_LTE=5 } relop; }; }; struct { char *name; enum ir_data { DATA_RAW=0, DATA_STRING=1 } data_type; union { int bytes; char *text; }; }; struct { char *label; int offset; }; }; }

variable_types: struct line_list { char *line; struct line_list *next; } *


decompiled_code:
char *__fastcall basic_type_string(unsigned int a1)
{
if ( a1 > 4 )
_assert_fail("0 && \"basic_type_string: invalid basic type\"", "types.c", 0x24u, "basic_type_string");
return CSWTCH_1[a1];
}

canonical_decompiled_code:
char *__fastcall func0(unsigned int a1)
{
if ( a1 > 4 )
_assert_fail("0 && \"basic_type_string: invalid basic type\"", "types.c", 0x24u, "basic_type_string");
return CSWTCH_1[a1];
}

original_code:
static const char* basic_type_string(basic_type b)
{
    switch (b)
    {
    case T_VOID:
        return "void";
    case T_INT:
    case T_INT_ARRAY:
        return "int";
    case T_CHAR:
    case T_CHAR_ARRAY:
        return "char";
    default:
        ((void) sizeof ((0 && "basic_type_string: invalid basic type") ? 1 : 0), __extension__ ({ if (0 && "basic_type_string: invalid basic type") ; else __assert_fail ("0 && \"basic_type_string: invalid basic type\"", "types.c", 36, __extension__ __PRETTY_FUNCTION__); }));
        return ((void *)0);
    }
}

canonical_original_code:
static char *basic_type_string(enum basic_type b)
{
    switch (b)
    {
    case T_VOID:
        return "void";
    case T_INT:
    case T_INT_ARRAY:
        return "int";
    case T_CHAR:
    case T_CHAR_ARRAY:
        return "char";
    default:
        ((void) sizeof ((0 && "basic_type_string: invalid basic type") ? 1 : 0), __extension__ ({ if (0 && "basic_type_string: invalid basic type") ; else __assert_fail ("0 && \"basic_type_string: invalid basic type\"", "types.c", 36, __extension__ __PRETTY_FUNCTION__); }));
        return ((void *)0);
    }
}

variable_types: enum basic_type { T_VOID=0, T_INT=1, T_CHAR=2, T_INT_ARRAY=3, T_CHAR_ARRAY=4 }


decompiled_code:
__int64 __fastcall type_from_ast(unsigned int a1)
{
__int64 result; // rax

if ( a1 <= 2 )
LODWORD(result) = CSWTCH_5[a1];
return (unsigned int)result;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int a1)
{
__int64 result; // rax

if ( a1 <= 2 )
LODWORD(result) = CSWTCH_5[a1];
return (unsigned int)result;
}

original_code:
type type_from_ast(value_type t)
{
    basic_type basic;
    switch (t)
    {
    case TYPE_VOID: basic = T_VOID; break;
    case TYPE_INT: basic = T_INT; break;
    case TYPE_CHAR: basic = T_CHAR; break;
    }
    type tt;
    tt.type = basic;
    return tt;
}

canonical_original_code:
struct type type_from_ast(enum value_type t)
{
    enum basic_type basic;
    switch (t)
    {
    case TYPE_VOID: basic = T_VOID; break;
    case TYPE_INT: basic = T_INT; break;
    case TYPE_CHAR: basic = T_CHAR; break;
    }
    struct type tt;
    tt.type = basic;
    return tt;
}

variable_types: enum value_type { TYPE_INT=0, TYPE_CHAR=1, TYPE_VOID=2 }

variable_types: struct type { enum basic_type { T_VOID=0, T_INT=1, T_CHAR=2, T_INT_ARRAY=3, T_CHAR_ARRAY=4 } type; int elements; }


decompiled_code:
_BOOL8 __fastcall type_is_array(int a1)
{
return (unsigned int)(a1 - 3) <= 1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(int a1)
{
return (unsigned int)(a1 - 3) <= 1;
}

original_code:
int type_is_array(type t)
{
    return t.type == T_INT_ARRAY || t.type == T_CHAR_ARRAY;
}

canonical_original_code:
int type_is_array(struct type t)
{
    return t.type == T_INT_ARRAY || t.type == T_CHAR_ARRAY;
}


decompiled_code:
__int64 __fastcall type_print(char *s, __int64 a2)
{
char *v2; // rax
char *v3; // rbx
__int64 result; // rax

v2 = basic_type_string(a2);
v3 = &s[sprintf(s, "%s", v2)];
if ( type_is_array(a2) )
result = &v3[sprintf(v3, "[%d]", a2 >> 32)] - s;
else
result = v3 - s;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(char *s, __int64 a2)
{
char *v2; // rax
char *v3; // rbx
__int64 result; // rax

v2 = func0(a2);
v3 = &s[sprintf(s, "%s", v2)];
if ( func2(a2) )
result = &v3[sprintf(v3, "[%d]", a2 >> 32)] - s;
else
result = v3 - s;
return result;
}

original_code:
int type_print(char* buffer, type t)
{
    const char* b = basic_type_string(t.type);
    char* p = buffer;
    p += sprintf(buffer, "%s", b);
    if (type_is_array(t))
    {
        p += sprintf(p, "[%d]", t.elements);
    }
    return p - buffer;
}

canonical_original_code:
int type_print(char *buffer, struct type t)
{
    char *b = basic_type_string(t.type);
    char *p = buffer;
    p += sprintf(buffer, "%s", b);
    if (type_is_array(t))
    {
        p += sprintf(p, "[%d]", t.elements);
    }
    return p - buffer;
}

variable_types:
buffer
char *

variable_types:
b
char *

variable_types:
p
char *


decompiled_code:
_QWORD *ir_empty_list()
{
_QWORD *result; // rax

result = malloc(0x48uLL);
result[8] = 0LL;
return result;
}

canonical_decompiled_code:
_QWORD *func0()
{
_QWORD *result; // rax

result = malloc(0x48uLL);
result[8] = 0LL;
return result;
}

original_code:
ir_list* ir_empty_list(void)
{
    ir_list* node = malloc(sizeof(ir_list));
    node->next = ((void *)0);
    return node;
}

canonical_original_code:
struct ir_list *ir_empty_list()
{
    struct ir_list *node = malloc(sizeof(ir_list));
    node->next = ((void *)0);
    return node;
}

variable_types: struct ir_list { struct ir_item { enum ir_type { IR_EMPTY=0, IR_DATA=1, IR_BINOP=2, IR_UNOP=3, IR_COPY=4, IR_GOTO=5, IR_BRANCH=6, IR_LABEL=7, IR_LIDX=8, IR_RIDX=9, IR_ADDR=10, IR_LDEREF=11, IR_RDEREF=12, IR_ENTER=13, IR_LEAVE=14, IR_PARAM=15, IR_CALL=16, IR_RET=17, IR_RET_VAL=18, IR_RETRIEVE=19 } type; union { struct { struct address { enum addr_type { ADDR_EMPTY=0, ADDR_SYMBOL=1, ADDR_SYMBOL_NAME=2, ADDR_IMM_INT=3, ADDR_IMM_CHAR=4, ADDR_IMM_STRING=5 } type; union { int integer; char character; char *string; struct symbol_info { enum symbol_type { SYM_NONE=0, SYM_FUN=1, SYM_VAR=2, SYM_LITERAL=3 } symbol_type; char *name; struct scope_info { struct symbol_info *symbols; struct scope_info *parent; struct scope_info *next; struct scope_info *children; } *scope; union { struct { struct type { enum basic_type { T_VOID=0, T_INT=1, T_CHAR=2, T_INT_ARRAY=3, T_CHAR_ARRAY=4 } type; int elements; } var_type; struct codegen_info { enum storage_type { ST_UNKNOWN=0, ST_REG=1, ST_LOCAL=2, ST_GLOBAL=3 } storage; int size; union { int reg; int offset; }; } codegen; }; struct { struct type ret_type; struct scope_info *params; }; char *literal; }; struct symbol_info *next; } *symbol; char *symbol_name; }; } x; union { enum ir_binop { IR_PLUS=0, IR_MINUS=1, IR_TIMES=2, IR_DIV=3, IR_AND=4, IR_OR=5 } binop; enum ir_unop { IR_NEG=0 } unop; enum ir_relop { IR_EQ=0, IR_NEQ=1, IR_GT=2, IR_GTE=3, IR_LT=4, IR_LTE=5 } relop; }; }; struct { char *name; enum ir_data { DATA_RAW=0, DATA_STRING=1 } data_type; union { int bytes; char *text; }; }; struct { char *label; int offset; }; }; } item; struct ir_list *next; } *

user_defined_types: struct ir_list { struct ir_item item; struct ir_list *next; }


decompiled_code:
void __fastcall ir_free_list(void *ptr)
{
void *v1; // rbx
void *v2; // rdi

if ( ptr )
{
v1 = ptr;
do
{
ir_free_item(v1);
v2 = v1;
v1 = (void *)*((_QWORD *)v1 + 8);
free(v2);
}
while ( v1 );
}
}

canonical_decompiled_code:
void __fastcall func1(void *ptr)
{
void *v1; // rbx
void *v2; // rdi

if ( ptr )
{
v1 = ptr;
do
{
ir_free_item(v1);
v2 = v1;
v1 = (void *)*((_QWORD *)v1 + 8);
free(v2);
}
while ( v1 );
}
}

original_code:
void ir_free_list(ir_list* codes)
{
    while (codes != ((void *)0))
    {
        ir_free_item(&codes->item);
        ir_list* tmp = codes;
        codes = codes->next;
        free(tmp);
    }
}

canonical_original_code:
void ir_free_list(struct ir_list *codes)
{
    while (codes != ((void *)0))
    {
        ir_free_item(&codes->item);
        struct ir_list *tmp = codes;
        codes = codes->next;
        free(tmp);
    }
}

user_defined_types: enum addr_type { ADDR_EMPTY=0, ADDR_SYMBOL=1, ADDR_SYMBOL_NAME=2, ADDR_IMM_INT=3, ADDR_IMM_CHAR=4, ADDR_IMM_STRING=5 }

user_defined_types: enum ir_binop { IR_PLUS=0, IR_MINUS=1, IR_TIMES=2, IR_DIV=3, IR_AND=4, IR_OR=5 }

user_defined_types: enum ir_relop { IR_EQ=0, IR_NEQ=1, IR_GT=2, IR_GTE=3, IR_LT=4, IR_LTE=5 }

user_defined_types: enum symbol_type { SYM_NONE=0, SYM_FUN=1, SYM_VAR=2, SYM_LITERAL=3 }