decompiled_code:
__int64 __fastcall stmt_eval_while(__int64 a1)
{
return m_while_stmt(*(_QWORD *)(a1 + 16));
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
return m_while_stmt(*(_QWORD *)(a1 + 16));
}

original_code:
void stmt_eval_while(statement* s) {
    m_while_stmt(s->data.loopdata.cBlock);
}

canonical_original_code:
void stmt_eval_while(struct stmt_struct *s) {
    m_while_stmt(s->data.loopdata.cBlock);
}


repo: willghatch/cpslc

decompiled_code:
__int64 __fastcall stmt_eval_repeat(__int64 a1)
{
return m_repeat_stmt(*(_QWORD *)(a1 + 16));
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
return m_repeat_stmt(*(_QWORD *)(a1 + 16));
}

original_code:
void stmt_eval_repeat(statement* s) {
    m_repeat_stmt(s->data.loopdata.cBlock);
}

canonical_original_code:
void stmt_eval_repeat(struct stmt_struct *s) {
    m_repeat_stmt(s->data.loopdata.cBlock);
}

variable_types: struct stmt_struct { enum stmt_type_enum { assign_stmt=0, if_stmt=1, while_stmt=2, repeat_stmt=3, for_stmt=4, stop_stmt=5, return_stmt=6, read_stmt=7, write_stmt=8, proc_stmt=9, null_stmt=10 } type; union { struct htslist_struct { struct slist_struct { struct slist_struct *next; void *data; } *head; struct slist_struct *tail; } *if_conditionals; struct slist_struct *exprList; struct expression_struct { struct type_info { int ty_size; char *ty_name; enum type_kind { Integer=0, Char=1, Boolean=2, String=3, Array=4, Record=5, UndefinedType=6 } ty_kind; struct type_info *ty_next; union { struct { struct type_info *RangeType; int min; int max; } ty_subrange; struct { struct type_info *ElementType; struct type_info *IndexType; int min; int max; } ty_array; struct { struct id_info { char *id_name; int id_addr; int id_label; int id_level; struct type_info *id_type; enum identifier_kind { Constant_id=0, Type=1, Variable=2, FParameter=3, Field=4, Procedure=5, Function=6 } id_kind; struct id_info *id_left; struct id_info *id_right; struct id_info *id_next; struct expression_struct *const_expr; struct slist_struct *typedIdentLists; int param_size; int pointer_p; } *FirstField; } ty_record; } ty_form; } *type; enum expr_kind_enum { constant_expr=0, operation_bin=1, operation_un=2, registerVal=3, globalVar=4, localVar=5, functionCall=6, typecast=7 } kind; int int_val; char char_val; int bool_val; char *str_val; int str_const_index; struct expression_struct *offsetExpr; int pointer_p; int to_pointer_p; union { struct { struct expression_struct *operand1; struct expression_struct *operand2; enum operator_enum { op_and=0, op_or=1, op_not=2, op_negate=3, op_add=4, op_sub=5, op_mult=6, op_div=7, op_mod=8, op_equal=9, op_nequal=10, op_gt=11, op_lt=12, op_gte=13, op_lte=14 } op; } opdata; int reg_number; struct id_info *id; struct stmt_struct *funcCall; struct expression_struct *innerExpr; } edata; } *expression; struct { struct stmt_struct *init; struct conditional_struct { struct expression_struct *condition; enum BranchType_enum { bt_equal0=0, bt_nequal0=1 } branchType; struct htslist_struct *statements; } *cBlock; } loopdata; struct { struct expression_struct *lvalue; struct expression_struct *rvalue; } assigndata; struct { char *name; struct slist_struct *paramExprs; } procdata; } data; } *

return_type: void

user_defined_types: struct stmt_struct { enum stmt_type_enum type; union { struct htslist_struct *if_conditionals; struct slist_struct *exprList; struct expression_struct *expression; struct { struct stmt_struct *init; struct conditional_struct *cBlock; } loopdata; struct { struct expression_struct *lvalue; struct expression_struct *rvalue; } assigndata; struct { char *name; struct slist_struct *paramExprs; } procdata; } data; }

user_defined_types: struct htslist_struct { struct slist_struct *head; struct slist_struct *tail; }

user_defined_types: struct expression_struct { struct type_info *type; enum expr_kind_enum kind; int int_val; char char_val; int bool_val; char *str_val; int str_const_index; struct expression_struct *offsetExpr; int pointer_p; int to_pointer_p; union { struct { struct expression_struct *operand1; struct expression_struct *operand2; enum operator_enum op; } opdata; int reg_number; struct id_info *id; struct stmt_struct *funcCall; struct expression_struct *innerExpr; } edata; }

user_defined_types: struct conditional_struct { struct expression_struct *condition; enum BranchType_enum branchType; struct htslist_struct *statements; }

user_defined_types: struct type_info { int ty_size; char *ty_name; enum type_kind ty_kind; struct type_info *ty_next; union { struct { struct type_info *RangeType; int min; int max; } ty_subrange; struct { struct type_info *ElementType; struct type_info *IndexType; int min; int max; } ty_array; struct { struct id_info *FirstField; } ty_record; } ty_form; }

user_defined_types: struct id_info { char *id_name; int id_addr; int id_label; int id_level; struct type_info *id_type; enum identifier_kind id_kind; struct id_info *id_left; struct id_info *id_right; struct id_info *id_next; struct expression_struct *const_expr; struct slist_struct *typedIdentLists; int param_size; int pointer_p; }


decompiled_code:
__int64 __fastcall stmt_eval_for(__int64 a1)
{
return m_for_stmt(*(_QWORD *)(a1 + 8), *(_QWORD *)(a1 + 16));
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
return m_for_stmt(*(_QWORD *)(a1 + 8), *(_QWORD *)(a1 + 16));
}

original_code:
void stmt_eval_for(statement* s) {
    m_for_stmt(s->data.loopdata.init, s->data.loopdata.cBlock);
}

canonical_original_code:
void stmt_eval_for(struct stmt_struct *s) {
    m_for_stmt(s->data.loopdata.init, s->data.loopdata.cBlock);
}

user_defined_types: enum stmt_type_enum { assign_stmt=0, if_stmt=1, while_stmt=2, repeat_stmt=3, for_stmt=4, stop_stmt=5, return_stmt=6, read_stmt=7, write_stmt=8, proc_stmt=9, null_stmt=10 }

user_defined_types: enum expr_kind_enum { constant_expr=0, operation_bin=1, operation_un=2, registerVal=3, globalVar=4, localVar=5, functionCall=6, typecast=7 }

user_defined_types: struct slist_struct { struct slist_struct *next; void *data; }

user_defined_types: enum BranchType_enum { bt_equal0=0, bt_nequal0=1 }

user_defined_types: enum type_kind { Integer=0, Char=1, Boolean=2, String=3, Array=4, Record=5, UndefinedType=6 }

user_defined_types: enum operator_enum { op_and=0, op_or=1, op_not=2, op_negate=3, op_add=4, op_sub=5, op_mult=6, op_div=7, op_mod=8, op_equal=9, op_nequal=10, op_gt=11, op_lt=12, op_gte=13, op_lte=14 }

user_defined_types: enum identifier_kind { Constant_id=0, Type=1, Variable=2, FParameter=3, Field=4, Procedure=5, Function=6 }


decompiled_code:
__int64 stmt_eval_stop()
{
return m_stop_stmt();
}

canonical_decompiled_code:
__int64 func6()
{
return m_stop_stmt();
}

original_code:
void stmt_eval_stop(statement* s) {
    m_stop_stmt();
}

canonical_original_code:
void stmt_eval_stop(struct stmt_struct *s) {
    m_stop_stmt();
}


decompiled_code:
__int64 __fastcall stmt_eval_return(__int64 a1)
{
if ( *(_QWORD *)(a1 + 8) )
m_store_ret_val();
return m_function_end();
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
if ( *(_QWORD *)(a1 + 8) )
m_store_ret_val();
return m_function_end();
}

original_code:
void stmt_eval_return(statement* s) {
    expr* e = s->data.expression;
    if (e != ((void *)0)) {
        m_store_ret_val(e);
    }
    m_function_end();
}

canonical_original_code:
void stmt_eval_return(struct stmt_struct *s) {
    struct expression_struct *e = s->data.expression;
    if (e != ((void *)0)) {
        m_store_ret_val(e);
    }
    m_function_end();
}

variable_types: struct expression_struct { struct type_info { int ty_size; char *ty_name; enum type_kind { Integer=0, Char=1, Boolean=2, String=3, Array=4, Record=5, UndefinedType=6 } ty_kind; struct type_info *ty_next; union { struct { struct type_info *RangeType; int min; int max; } ty_subrange; struct { struct type_info *ElementType; struct type_info *IndexType; int min; int max; } ty_array; struct { struct id_info { char *id_name; int id_addr; int id_label; int id_level; struct type_info *id_type; enum identifier_kind { Constant_id=0, Type=1, Variable=2, FParameter=3, Field=4, Procedure=5, Function=6 } id_kind; struct id_info *id_left; struct id_info *id_right; struct id_info *id_next; struct expression_struct *const_expr; struct slist_struct { struct slist_struct *next; void *data; } *typedIdentLists; int param_size; int pointer_p; } *FirstField; } ty_record; } ty_form; } *type; enum expr_kind_enum { constant_expr=0, operation_bin=1, operation_un=2, registerVal=3, globalVar=4, localVar=5, functionCall=6, typecast=7 } kind; int int_val; char char_val; int bool_val; char *str_val; int str_const_index; struct expression_struct *offsetExpr; int pointer_p; int to_pointer_p; union { struct { struct expression_struct *operand1; struct expression_struct *operand2; enum operator_enum { op_and=0, op_or=1, op_not=2, op_negate=3, op_add=4, op_sub=5, op_mult=6, op_div=7, op_mod=8, op_equal=9, op_nequal=10, op_gt=11, op_lt=12, op_gte=13, op_lte=14 } op; } opdata; int reg_number; struct id_info *id; struct stmt_struct { enum stmt_type_enum { assign_stmt=0, if_stmt=1, while_stmt=2, repeat_stmt=3, for_stmt=4, stop_stmt=5, return_stmt=6, read_stmt=7, write_stmt=8, proc_stmt=9, null_stmt=10 } type; union { struct htslist_struct { struct slist_struct *head; struct slist_struct *tail; } *if_conditionals; struct slist_struct *exprList; struct expression_struct *expression; struct { struct stmt_struct *init; struct conditional_struct { struct expression_struct *condition; enum BranchType_enum { bt_equal0=0, bt_nequal0=1 } branchType; struct htslist_struct *statements; } *cBlock; } loopdata; struct { struct expression_struct *lvalue; struct expression_struct *rvalue; } assigndata; struct { char *name; struct slist_struct *paramExprs; } procdata; } data; } *funcCall; struct expression_struct *innerExpr; } edata; } *


decompiled_code:
__int64 __fastcall stmt_eval_read(__int64 a1)
{
return m_read_stmt(*(_QWORD *)(a1 + 8));
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
return m_read_stmt(*(_QWORD *)(a1 + 8));
}

original_code:
void stmt_eval_read(statement* s) {
    slist* lvalExprs = s->data.exprList;
    m_read_stmt(lvalExprs);
}

canonical_original_code:
void stmt_eval_read(struct stmt_struct *s) {
    struct slist_struct *lvalExprs = s->data.exprList;
    m_read_stmt(lvalExprs);
}

variable_types: struct slist_struct { struct slist_struct *next; void *data; } *


decompiled_code:
__int64 __fastcall stmt_eval_write(__int64 a1)
{
return m_write_stmt(*(_QWORD *)(a1 + 8));
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
return m_write_stmt(*(_QWORD *)(a1 + 8));
}

original_code:
void stmt_eval_write(statement* s) {
    slist* lvalExprs = s->data.exprList;
    m_write_stmt(lvalExprs);
}

canonical_original_code:
void stmt_eval_write(struct stmt_struct *s) {
    struct slist_struct *lvalExprs = s->data.exprList;
    m_write_stmt(lvalExprs);
}


decompiled_code:
__int64 __fastcall stmt_eval_proc(__int64 a1)
{
__int64 v1; // rbp
__int64 v2; // rbx
__int64 v3; // r12

v1 = *(_QWORD *)(a1 + 16);
v2 = scopeLookup(*(_QWORD *)(a1 + 8));
if ( !v2 )
yyerror("Unknown function or procedure name");
v3 = *(_QWORD *)(v2 + 24);
funcArgList_checkAndAddPointerPs(v2, v1);
return m_func_call(*(unsigned int *)(v2 + 12), v1, v3);
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1)
{
__int64 v1; // rbp
__int64 v2; // rbx
__int64 v3; // r12

v1 = *(_QWORD *)(a1 + 16);
v2 = scopeLookup(*(_QWORD *)(a1 + 8));
if ( !v2 )
yyerror("Unknown function or procedure name");
v3 = *(_QWORD *)(v2 + 24);
funcArgList_checkAndAddPointerPs(v2, v1);
return m_func_call(*(unsigned int *)(v2 + 12), v1, v3);
}

original_code:
void stmt_eval_proc(statement* s) {
    char* name = s->data.procdata.name;
    slist* paramExprs = s->data.procdata.paramExprs;
    ID* proc = scopeLookup(name);
    if (proc == ((void *)0)) {
        yyerror("Unknown function or procedure name");
    }
    TYPE* t = proc->id_type;
    funcArgList_checkAndAddPointerPs(proc, paramExprs);
    int funcLabel = proc->id_label;
    m_func_call(funcLabel, paramExprs, t);
}

canonical_original_code:
void stmt_eval_proc(struct stmt_struct *s) {
    char *name = s->data.procdata.name;
    struct slist_struct *paramExprs = s->data.procdata.paramExprs;
    struct id_info *proc = scopeLookup(name);
    if (proc == ((void *)0)) {
        yyerror("Unknown function or procedure name");
    }
    struct type_info *t = proc->id_type;
    funcArgList_checkAndAddPointerPs(proc, paramExprs);
    int funcLabel = proc->id_label;
    m_func_call(funcLabel, paramExprs, t);
}

variable_types:
name
char *

variable_types: struct id_info { char *id_name; int id_addr; int id_label; int id_level; struct type_info { int ty_size; char *ty_name; enum type_kind { Integer=0, Char=1, Boolean=2, String=3, Array=4, Record=5, UndefinedType=6 } ty_kind; struct type_info *ty_next; union { struct { struct type_info *RangeType; int min; int max; } ty_subrange; struct { struct type_info *ElementType; struct type_info *IndexType; int min; int max; } ty_array; struct { struct id_info *FirstField; } ty_record; } ty_form; } *id_type; enum identifier_kind { Constant_id=0, Type=1, Variable=2, FParameter=3, Field=4, Procedure=5, Function=6 } id_kind; struct id_info *id_left; struct id_info *id_right; struct id_info *id_next; struct expression_struct { struct type_info *type; enum expr_kind_enum { constant_expr=0, operation_bin=1, operation_un=2, registerVal=3, globalVar=4, localVar=5, functionCall=6, typecast=7 } kind; int int_val; char char_val; int bool_val; char *str_val; int str_const_index; struct expression_struct *offsetExpr; int pointer_p; int to_pointer_p; union { struct { struct expression_struct *operand1; struct expression_struct *operand2; enum operator_enum { op_and=0, op_or=1, op_not=2, op_negate=3, op_add=4, op_sub=5, op_mult=6, op_div=7, op_mod=8, op_equal=9, op_nequal=10, op_gt=11, op_lt=12, op_gte=13, op_lte=14 } op; } opdata; int reg_number; struct id_info *id; struct stmt_struct { enum stmt_type_enum { assign_stmt=0, if_stmt=1, while_stmt=2, repeat_stmt=3, for_stmt=4, stop_stmt=5, return_stmt=6, read_stmt=7, write_stmt=8, proc_stmt=9, null_stmt=10 } type; union { struct htslist_struct { struct slist_struct { struct slist_struct *next; void *data; } *head; struct slist_struct *tail; } *if_conditionals; struct slist_struct *exprList; struct expression_struct *expression; struct { struct stmt_struct *init; struct conditional_struct { struct expression_struct *condition; enum BranchType_enum { bt_equal0=0, bt_nequal0=1 } branchType; struct htslist_struct *statements; } *cBlock; } loopdata; struct { struct expression_struct *lvalue; struct expression_struct *rvalue; } assigndata; struct { char *name; struct slist_struct *paramExprs; } procdata; } data; } *funcCall; struct expression_struct *innerExpr; } edata; } *const_expr; struct slist_struct *typedIdentLists; int param_size; int pointer_p; } *

variable_types: struct type_info { int ty_size; char *ty_name; enum type_kind { Integer=0, Char=1, Boolean=2, String=3, Array=4, Record=5, UndefinedType=6 } ty_kind; struct type_info *ty_next; union { struct { struct type_info *RangeType; int min; int max; } ty_subrange; struct { struct type_info *ElementType; struct type_info *IndexType; int min; int max; } ty_array; struct { struct id_info { char *id_name; int id_addr; int id_label; int id_level; struct type_info *id_type; enum identifier_kind { Constant_id=0, Type=1, Variable=2, FParameter=3, Field=4, Procedure=5, Function=6 } id_kind; struct id_info *id_left; struct id_info *id_right; struct id_info *id_next; struct expression_struct { struct type_info *type; enum expr_kind_enum { constant_expr=0, operation_bin=1, operation_un=2, registerVal=3, globalVar=4, localVar=5, functionCall=6, typecast=7 } kind; int int_val; char char_val; int bool_val; char *str_val; int str_const_index; struct expression_struct *offsetExpr; int pointer_p; int to_pointer_p; union { struct { struct expression_struct *operand1; struct expression_struct *operand2; enum operator_enum { op_and=0, op_or=1, op_not=2, op_negate=3, op_add=4, op_sub=5, op_mult=6, op_div=7, op_mod=8, op_equal=9, op_nequal=10, op_gt=11, op_lt=12, op_gte=13, op_lte=14 } op; } opdata; int reg_number; struct id_info *id; struct stmt_struct { enum stmt_type_enum { assign_stmt=0, if_stmt=1, while_stmt=2, repeat_stmt=3, for_stmt=4, stop_stmt=5, return_stmt=6, read_stmt=7, write_stmt=8, proc_stmt=9, null_stmt=10 } type; union { struct htslist_struct { struct slist_struct { struct slist_struct *next; void *data; } *head; struct slist_struct *tail; } *if_conditionals; struct slist_struct *exprList; struct expression_struct *expression; struct { struct stmt_struct *init; struct conditional_struct { struct expression_struct *condition; enum BranchType_enum { bt_equal0=0, bt_nequal0=1 } branchType; struct htslist_struct *statements; } *cBlock; } loopdata; struct { struct expression_struct *lvalue; struct expression_struct *rvalue; } assigndata; struct { char *name; struct slist_struct *paramExprs; } procdata; } data; } *funcCall; struct expression_struct *innerExpr; } edata; } *const_expr; struct slist_struct *typedIdentLists; int param_size; int pointer_p; } *FirstField; } ty_record; } ty_form; } *

variable_types: funcLabel int


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

if ( a1 )
{
result = (unsigned int)*a1;
switch ( *a1 )
{
case 0:
result = stmt_eval_assign((__int64)a1);
break;
case 1:
result = stmt_eval_if((__int64)a1);
break;
case 2:
result = stmt_eval_while((__int64)a1);
break;
case 3:
result = stmt_eval_repeat((__int64)a1);
break;
case 4:
result = stmt_eval_for((__int64)a1);
break;
case 5:
result = stmt_eval_stop();
break;
case 6:
result = stmt_eval_return((__int64)a1);
break;
case 7:
result = stmt_eval_read((__int64)a1);
break;
case 8:
result = stmt_eval_write((__int64)a1);
break;
case 9:
result = stmt_eval_proc((__int64)a1);
break;
default:
return result;
}
}
return result;
}

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

if ( a1 )
{
result = (unsigned int)*a1;
switch ( *a1 )
{
case 0:
result = func1((__int64)a1);
break;
case 1:
result = func2((__int64)a1);
break;
case 2:
result = func3((__int64)a1);
break;
case 3:
result = func4((__int64)a1);
break;
case 4:
result = func5((__int64)a1);
break;
case 5:
result = func6();
break;
case 6:
result = func7((__int64)a1);
break;
case 7:
result = func8((__int64)a1);
break;
case 8:
result = func9((__int64)a1);
break;
case 9:
result = func10((__int64)a1);
break;
default:
return result;
}
}
return result;
}

original_code:
void stmt_eval(statement* s) {
    if (s == ((void *)0)) {
        return;
    }
    stmt_type t = s->type;
    switch(t) {
        case assign_stmt:
            stmt_eval_assign(s);
            return;
        case if_stmt:
            stmt_eval_if(s);
            return;
        case while_stmt:
            stmt_eval_while(s);
            return;
        case repeat_stmt:
            stmt_eval_repeat(s);
            return;
        case for_stmt:
            stmt_eval_for(s);
            return;
        case stop_stmt:
            stmt_eval_stop(s);
            return;
        case return_stmt:
            stmt_eval_return(s);
            return;
        case read_stmt:
            stmt_eval_read(s);
            return;
        case write_stmt:
            stmt_eval_write(s);
            return;
        case proc_stmt:
            stmt_eval_proc(s);
            return;
        default:
            return;
    }
}

canonical_original_code:
void stmt_eval(struct stmt_struct *s) {
    if (s == ((void *)0)) {
        return;
    }
    enum stmt_type_enum t = s->type;
    switch(t) {
        case assign_stmt:
            stmt_eval_assign(s);
            return;
        case if_stmt:
            stmt_eval_if(s);
            return;
        case while_stmt:
            stmt_eval_while(s);
            return;
        case repeat_stmt:
            stmt_eval_repeat(s);
            return;
        case for_stmt:
            stmt_eval_for(s);
            return;
        case stop_stmt:
            stmt_eval_stop(s);
            return;
        case return_stmt:
            stmt_eval_return(s);
            return;
        case read_stmt:
            stmt_eval_read(s);
            return;
        case write_stmt:
            stmt_eval_write(s);
            return;
        case proc_stmt:
            stmt_eval_proc(s);
            return;
        default:
            return;
    }
}

variable_types: enum stmt_type_enum { assign_stmt=0, if_stmt=1, while_stmt=2, repeat_stmt=3, for_stmt=4, stop_stmt=5, return_stmt=6, read_stmt=7, write_stmt=8, proc_stmt=9, null_stmt=10 }


freeSlist

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

if ( ptr )
{
v1 = ptr;
do
{
v2 = v1;
v1 = (_QWORD *)*v1;
free(v2);
}
while ( v1 );
}
}

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

if ( ptr )
{
v1 = ptr;
do
{
v2 = v1;
v1 = (_QWORD *)*v1;
free(v2);
}
while ( v1 );
}
}

original_code:
void freeSlist(slist* list) {
    if (list == ((void *)0)) {
        return;
    }
    slist* n = list->next;
    free(list);
    freeSlist(n);
}

canonical_original_code:
void freeSlist(struct slist_struct *list) {
    if (list == ((void *)0)) {
        return;
    }
    struct slist_struct *n = list->next;
    free(list);
    freeSlist(n);
}


mkHtslist

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

result = malloc(0x10uLL);
*result = 0LL;
result[1] = 0LL;
return result;
}

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

result = malloc(0x10uLL);
*result = 0LL;
result[1] = 0LL;
return result;
}

original_code:
htslist* mkHtslist() {
    htslist* l;
    l = malloc(sizeof(htslist));
    l->head = ((void *)0);
    l->tail = ((void *)0);
    return l;
}

canonical_original_code:
struct htslist_struct *mkHtslist() {
    struct htslist_struct *l;
    l = malloc(sizeof(htslist));
    l->head = ((void *)0);
    l->tail = ((void *)0);
    return l;
}

variable_types: struct htslist_struct { struct slist_struct { struct slist_struct *next; void *data; } *head; struct slist_struct *tail; } *


decompiled_code:
void __fastcall slist_append(_QWORD *a1, __int64 a2)
{
while ( a1 )
{
if ( !*a1 )
{
*a1 = mkSlist(a2);
return;
}
a1 = (_QWORD *)*a1;
}
}

canonical_decompiled_code:
void __fastcall func2(_QWORD *a1, __int64 a2)
{
while ( a1 )
{
if ( !*a1 )
{
*a1 = mkSlist(a2);
return;
}
a1 = (_QWORD *)*a1;
}
}

original_code:
void slist_append(slist* ls, void* elem) {
    if (ls == ((void *)0)) {
    } else if (ls->next == ((void *)0)) {
        ls->next = mkSlist(elem);
    } else {
        slist_append(ls->next, elem);
    }
}

canonical_original_code:
void slist_append(struct slist_struct *ls, void *elem) {
    if (ls == ((void *)0)) {
    } else if (ls->next == ((void *)0)) {
        ls->next = mkSlist(elem);
    } else {
        slist_append(ls->next, elem);
    }
}

variable_types:
elem
void *


decompiled_code:
void init_registerState()
{
registerState = (__int64)malloc(0x44uLL);
clear_regstate(registerState);
}

canonical_decompiled_code:
void func1()
{
registerState = (__int64)malloc(0x44uLL);
func0(registerState);
}

original_code:
void init_registerState() {
    registerState = malloc(sizeof(regstate));
    clear_regstate(registerState);
}


decompiled_code:
void *__fastcall cp_regstate(void *src, void *dest)
{
return memmove(dest, src, 0x44uLL);
}

canonical_decompiled_code:
void *__fastcall func2(void *src, void *dest)
{
return memmove(dest, src, 0x44uLL);
}

original_code:
void cp_regstate(regstate* in, regstate* out) {
    for (int i = 0; i < 17; ++i) {
        out->reg[i] = in->reg[i];
    }
}

canonical_original_code:
void cp_regstate(struct regstate_struct *in, struct regstate_struct *out) {
    for (int i = 0; i < 17; ++i) {
        out->reg[i] = in->reg[i];
    }
}

variable_types: struct regstate_struct { int reg[17]; } *

variable_types:
out
struct regstate_struct *

variable_types: i int


getReg

decompiled_code:
__int64 __fastcall getReg(__int64 a1)
{
__int64 v1; // rax

v1 = 0LL;
while ( *(_DWORD *)(a1 + 4 * v1) )
{
if ( ++v1 == 17 )
return 0xFFFFFFFFLL;
}
*(_DWORD *)(a1 + 4LL * (int)v1) = 1;
return (unsigned int)(v1 + 8);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
__int64 v1; // rax

v1 = 0LL;
while ( *(_DWORD *)(a1 + 4 * v1) )
{
if ( ++v1 == 17 )
return 0xFFFFFFFFLL;
}
*(_DWORD *)(a1 + 4LL * (int)v1) = 1;
return (unsigned int)(v1 + 8);
}

original_code:
int getReg(regstate* state) {
    for (int i = 0; i < 17; ++i) {
        if (!state->reg[i]) {
            state->reg[i] = 1;
            return i + 8;
        }
    }
    return -1;
}

canonical_original_code:
int getReg(struct regstate_struct *state) {
    for (int i = 0; i < 17; ++i) {
        if (!state->reg[i]) {
            state->reg[i] = 1;
            return i + 8;
        }
    }
    return -1;
}

return_type: int


freeReg

decompiled_code:
void __fastcall freeReg(__int64 a1, int a2)
{
if ( a2 )
*(_DWORD *)(a1 + 4LL * (a2 - 8)) = 0;
}

canonical_decompiled_code:
void __fastcall func4(__int64 a1, int a2)
{
if ( a2 )
*(_DWORD *)(a1 + 4LL * (a2 - 8)) = 0;
}

original_code:
void freeReg(regstate* state, int r) {
    if (r == 0)
        return;
    state->reg[r-8] = 0;
}

canonical_original_code:
void freeReg(struct regstate_struct *state, int r) {
    if (r == 0)
        return;
    state->reg[r-8] = 0;
}

variable_types: r int


doUnaryOperator

decompiled_code:
__int64 __fastcall doUnaryOperator(int a1, __int64 a2)
{
unsigned int v2; // eax
unsigned int v3; // er12
__int64 result; // rax

v2 = evalExpr(a2);
v3 = v2;
if ( a1 == 2 )
{
m_not(v2, v2);
result = v3;
}
else
{
if ( a1 == 3 )
m_negate(v2, v2);
result = v3;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, __int64 a2)
{
unsigned int v2; // eax
unsigned int v3; // er12
__int64 result; // rax

v2 = func1(a2);
v3 = v2;
if ( a1 == 2 )
{
m_not(v2, v2);
result = v3;
}
else
{
if ( a1 == 3 )
m_negate(v2, v2);
result = v3;
}
return result;
}

original_code:
int doUnaryOperator(openum op, expr* operand) {
    int reg1 = evalExpr(operand);
    switch(op) {
        case op_not:
            m_not(reg1, reg1);
            break;
        case op_negate:
            m_negate(reg1, reg1);
            break;
    }
    return reg1;
}

canonical_original_code:
int doUnaryOperator(enum operator_enum op, struct expression_struct *operand) {
    int reg1 = evalExpr(operand);
    switch(op) {
        case op_not:
            m_not(reg1, reg1);
            break;
        case op_negate:
            m_negate(reg1, reg1);
            break;
    }
    return reg1;
}

variable_types: enum operator_enum { op_and=0, op_or=1, op_not=2, op_negate=3, op_add=4, op_sub=5, op_mult=6, op_div=7, op_mod=8, op_equal=9, op_nequal=10, op_gt=11, op_lt=12, op_gte=13, op_lte=14 }


evalExpr

decompiled_code:
__int64 __fastcall evalExpr(__int64 a1)
{
_DWORD *v2; // r13
unsigned int v3; // er12
unsigned int v4; // eax
__int64 result; // rax
unsigned int v6; // er12
unsigned int v7; // er12
__int64 v8; // r14
_DWORD *v9; // rax
_DWORD *v10; // rax
unsigned int v11; // ebp
unsigned int v12; // eax
__int64 v13; // rax
unsigned int v14; // er14
__int64 v15; // r14
_DWORD *v16; // rsi
_DWORD *v17; // rax
unsigned int v18; // eax
__int64 v19; // r12
_DWORD *v20; // rax
__int64 v21; // r15
_DWORD *v22; // rax
_DWORD *v23; // rax
unsigned int v24; // eax
_DWORD *v25; // r13
_DWORD *v26; // rax
_DWORD *v27; // rax

while ( 2 )
{
v2 = *(_DWORD **)a1;
switch ( *(_DWORD *)(a1 + 8) )
{
case 0:
v19 = (unsigned int)getReg(registerState);
m_load_constant(a1, v19);
return (unsigned int)v19;
case 1:
return doBinaryOperator(*(unsigned int *)(a1 + 72), *(_QWORD *)(a1 + 56), *(_QWORD *)(a1 + 64));
case 2:
return doUnaryOperator(*(_DWORD *)(a1 + 72), *(_QWORD *)(a1 + 56));
case 3:
v6 = *(_DWORD *)(a1 + 56);
goto LABEL_8;
case 4:
v7 = getReg(registerState);
v8 = (unsigned int)getReg(registerState);
m_load_global_address(*(unsigned int *)(*(_QWORD *)(a1 + 56) + 12LL), v8);
v9 = newRegExpr(v8, int_type);
v10 = newBinOpExpr(4u, *(_QWORD *)(a1 + 40), (__int64)v9);
v11 = evalExpr(v10);
if ( (unsigned int)isWord_p(v2) || (unsigned int)isByte_p(v2) )
{
v12 = isByte_p(v2);
m_load_word_from_addr(v7, v11, 0LL, v12);
}
else
{
m_copy_reg(v7, v11);
}
freeReg(registerState, v11);
return v7;
case 5:
v6 = getReg(registerState);
v13 = *(_QWORD *)(a1 + 56);
v14 = *(_DWORD *)(v13 + 8);
if ( *(_DWORD *)(a1 + 48) || *(_DWORD *)(v13 + 84) )
{
m_load_frame_word(v6, v14, 0LL, 0LL, 0LL);
v15 = *(_QWORD *)(a1 + 40);
v16 = newRegExpr(v6, int_type);
v17 = newBinOpExpr(4u, (__int64)v16, v15);
v6 = evalExpr(v17);
if ( (unsigned int)isWord_p(v2) || (unsigned int)isByte_p(v2) )
{
v18 = isByte_p(v2);
m_load_frame_word(v6, 0LL, v18, 0LL, v6);
}
}
else
{
v21 = (unsigned int)getReg(registerState);
m_copy_fp(v21);
v22 = newRegExpr(v21, int_type);
v23 = newBinOpExpr(4u, *(_QWORD *)(a1 + 40), (__int64)v22);
LODWORD(a1) = evalExpr(v23);
if ( (unsigned int)isWord_p(v2) || (unsigned int)isByte_p(v2) )
{
v24 = isByte_p(v2);
m_load_frame_word(v6, v14, v24, 0LL, (unsigned int)a1);
}
else
{
v25 = newNumExpr(v14);
v26 = newRegExpr(a1, int_type);
v27 = newBinOpExpr(4u, (__int64)v26, (__int64)v25);
a1 = (unsigned int)evalExpr(v27);
m_copy_reg(v6, a1);
}
freeReg(registerState, (unsigned int)a1);
}
goto LABEL_8;
case 6:
stmt_eval(*(_QWORD *)(a1 + 56));
if ( (unsigned int)isWord_p(v2) || (unsigned int)isByte_p(v2) )
{
v3 = getReg(registerState);
v4 = isByte_p(v2);
m_load_frame_word(v3, (unsigned int)-*v2, v4, 1LL, 0LL);
m_move_stack_ptr((unsigned int)-*v2);
result = v3;
}
else
{
v6 = getReg(registerState);
v20 = newNumExpr(-*v2);
m_load_constant(v20, v6);
m_bin_op_to_r1("add", v6, 29LL);
LABEL_8:
result = v6;
}
return result;
case 7:
a1 = *(_QWORD *)(a1 + 56);
continue;
default:
JUMPOUT(0xAD6LL);
}
}
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
_DWORD *v2; // r13
unsigned int v3; // er12
unsigned int v4; // eax
__int64 result; // rax
unsigned int v6; // er12
unsigned int v7; // er12
__int64 v8; // r14
_DWORD *v9; // rax
_DWORD *v10; // rax
unsigned int v11; // ebp
unsigned int v12; // eax
__int64 v13; // rax
unsigned int v14; // er14
__int64 v15; // r14
_DWORD *v16; // rsi
_DWORD *v17; // rax
unsigned int v18; // eax
__int64 v19; // r12
_DWORD *v20; // rax
__int64 v21; // r15
_DWORD *v22; // rax
_DWORD *v23; // rax
unsigned int v24; // eax
_DWORD *v25; // r13
_DWORD *v26; // rax
_DWORD *v27; // rax

while ( 2 )
{
v2 = *(_DWORD **)a1;
switch ( *(_DWORD *)(a1 + 8) )
{
case 0:
v19 = (unsigned int)getReg(registerState);
m_load_constant(a1, v19);
return (unsigned int)v19;
case 1:
return func3(*(unsigned int *)(a1 + 72), *(_QWORD *)(a1 + 56), *(_QWORD *)(a1 + 64));
case 2:
return func0(*(_DWORD *)(a1 + 72), *(_QWORD *)(a1 + 56));
case 3:
v6 = *(_DWORD *)(a1 + 56);
goto LABEL_8;
case 4:
v7 = getReg(registerState);
v8 = (unsigned int)getReg(registerState);
m_load_global_address(*(unsigned int *)(*(_QWORD *)(a1 + 56) + 12LL), v8);
v9 = newRegExpr(v8, int_type);
v10 = newBinOpExpr(4u, *(_QWORD *)(a1 + 40), (__int64)v9);
v11 = func1(v10);
if ( (unsigned int)isWord_p(v2) || (unsigned int)isByte_p(v2) )
{
v12 = isByte_p(v2);
m_load_word_from_addr(v7, v11, 0LL, v12);
}
else
{
m_copy_reg(v7, v11);
}
freeReg(registerState, v11);
return v7;
case 5:
v6 = getReg(registerState);
v13 = *(_QWORD *)(a1 + 56);
v14 = *(_DWORD *)(v13 + 8);
if ( *(_DWORD *)(a1 + 48) || *(_DWORD *)(v13 + 84) )
{
m_load_frame_word(v6, v14, 0LL, 0LL, 0LL);
v15 = *(_QWORD *)(a1 + 40);
v16 = newRegExpr(v6, int_type);
v17 = newBinOpExpr(4u, (__int64)v16, v15);
v6 = func1(v17);
if ( (unsigned int)isWord_p(v2) || (unsigned int)isByte_p(v2) )
{
v18 = isByte_p(v2);
m_load_frame_word(v6, 0LL, v18, 0LL, v6);
}
}
else
{
v21 = (unsigned int)getReg(registerState);
m_copy_fp(v21);
v22 = newRegExpr(v21, int_type);
v23 = newBinOpExpr(4u, *(_QWORD *)(a1 + 40), (__int64)v22);
LODWORD(a1) = func1(v23);
if ( (unsigned int)isWord_p(v2) || (unsigned int)isByte_p(v2) )
{
v24 = isByte_p(v2);
m_load_frame_word(v6, v14, v24, 0LL, (unsigned int)a1);
}
else
{
v25 = newNumExpr(v14);
v26 = newRegExpr(a1, int_type);
v27 = newBinOpExpr(4u, (__int64)v26, (__int64)v25);
a1 = (unsigned int)func1(v27);
m_copy_reg(v6, a1);
}
freeReg(registerState, (unsigned int)a1);
}
goto LABEL_8;
case 6:
stmt_eval(*(_QWORD *)(a1 + 56));
if ( (unsigned int)isWord_p(v2) || (unsigned int)isByte_p(v2) )
{
v3 = getReg(registerState);
v4 = isByte_p(v2);
m_load_frame_word(v3, (unsigned int)-*v2, v4, 1LL, 0LL);
m_move_stack_ptr((unsigned int)-*v2);
result = v3;
}
else
{
v6 = getReg(registerState);
v20 = newNumExpr(-*v2);
m_load_constant(v20, v6);
m_bin_op_to_r1("add", v6, 29LL);
LABEL_8:
result = v6;
}
return result;
case 7:
a1 = *(_QWORD *)(a1 + 56);
continue;
default:
JUMPOUT(0xAD6LL);
}
}
}

original_code:
int evalExpr(expr* e) {
    int reg = -1;
    int offsetReg, addrReg;
    TYPE* t = e->type;
    switch(e->kind) {
        case constant_expr:
            reg = getReg(registerState);
            m_load_constant(e, reg);
            break;
        case operation_bin:
            reg = doBinaryOperator(e->edata.opdata.op, e->edata.opdata.operand1, e->edata.opdata.operand2);
            break;
        case operation_un:
            reg = doUnaryOperator(e->edata.opdata.op, e->edata.opdata.operand1);
            break;
        case typecast:
            reg = evalExpr(e->edata.innerExpr);
            break;
        case globalVar:
            reg = getReg(registerState);
            int addrReg = getReg(registerState);
            int globalIndex = e->edata.id->id_label;
            m_load_global_address(globalIndex, addrReg);
            addrReg = evalExpr(newBinOpExpr(op_add, e->offsetExpr, newRegExpr(addrReg, int_type)));
            if(isWord_p(t) || isByte_p(t)) {
                m_load_word_from_addr(reg, addrReg, 0, isByte_p(t));
            } else {
                m_copy_reg(reg, addrReg);
            }
            freeReg(registerState, addrReg);
            break;
        case localVar:
            reg = getReg(registerState);
            int staticOffset = e->edata.id->id_addr;
            if(e->pointer_p || e->edata.id->pointer_p) {
                m_load_frame_word(reg, staticOffset, 0, 0, 0);
                reg = evalExpr(newBinOpExpr(op_add, newRegExpr(reg, int_type), e->offsetExpr));
                if(isWord_p(t) || isByte_p(t)) {
                    m_load_frame_word(reg, 0, isByte_p(t), 0, reg);
                }
            } else {
                addrReg = getReg(registerState);
                m_copy_fp(addrReg);
                addrReg = evalExpr(newBinOpExpr(op_add, e->offsetExpr, newRegExpr(addrReg, int_type)));
                if(isWord_p(t) || isByte_p(t)) {
                    m_load_frame_word(reg, staticOffset, isByte_p(t), 0, addrReg);
                } else {
                    addrReg = evalExpr(newBinOpExpr(op_add, newRegExpr(addrReg, int_type), newNumExpr(staticOffset)));
                    m_copy_reg(reg, addrReg);
                }
                freeReg(registerState, addrReg);
            }
            break;
        case functionCall:
            stmt_eval(e->edata.funcCall);
            if(isWord_p(t) || isByte_p(t)) {
                reg = getReg(registerState);
                m_load_frame_word(reg, -(t->ty_size), isByte_p(t), 1, 0);
                m_move_stack_ptr(-t->ty_size);
            } else {
                reg = getReg(registerState);
                m_load_constant(newNumExpr(-t->ty_size), reg);
                m_bin_op_to_r1("add", reg, 29);
            }
            break;
        case registerVal:
            reg = e->edata.reg_number;
        default:
            break;
    }
    return reg;
}

canonical_original_code:
int evalExpr(struct expression_struct *e) {
    int reg = -1;
    int offsetReg; int addrReg;
    struct type_info *t = e->type;
    switch(e->kind) {
        case constant_expr:
            reg = getReg(registerState);
            m_load_constant(e, reg);
            break;
        case operation_bin:
            reg = doBinaryOperator(e->edata.opdata.op, e->edata.opdata.operand1, e->edata.opdata.operand2);
            break;
        case operation_un:
            reg = doUnaryOperator(e->edata.opdata.op, e->edata.opdata.operand1);
            break;
        case typecast:
            reg = evalExpr(e->edata.innerExpr);
            break;
        case globalVar:
            reg = getReg(registerState);
            int addrReg = getReg(registerState);
            int globalIndex = e->edata.id->id_label;
            m_load_global_address(globalIndex, addrReg);
            addrReg = evalExpr(newBinOpExpr(op_add, e->offsetExpr, newRegExpr(addrReg, int_type)));
            if(isWord_p(t) || isByte_p(t)) {
                m_load_word_from_addr(reg, addrReg, 0, isByte_p(t));
            } else {
                m_copy_reg(reg, addrReg);
            }
            freeReg(registerState, addrReg);
            break;
        case localVar:
            reg = getReg(registerState);
            int staticOffset = e->edata.id->id_addr;
            if(e->pointer_p || e->edata.id->pointer_p) {
                m_load_frame_word(reg, staticOffset, 0, 0, 0);
                reg = evalExpr(newBinOpExpr(op_add, newRegExpr(reg, int_type), e->offsetExpr));
                if(isWord_p(t) || isByte_p(t)) {
                    m_load_frame_word(reg, 0, isByte_p(t), 0, reg);
                }
            } else {
                addrReg = getReg(registerState);
                m_copy_fp(addrReg);
                addrReg = evalExpr(newBinOpExpr(op_add, e->offsetExpr, newRegExpr(addrReg, int_type)));
                if(isWord_p(t) || isByte_p(t)) {
                    m_load_frame_word(reg, staticOffset, isByte_p(t), 0, addrReg);
                } else {
                    addrReg = evalExpr(newBinOpExpr(op_add, newRegExpr(addrReg, int_type), newNumExpr(staticOffset)));
                    m_copy_reg(reg, addrReg);
                }
                freeReg(registerState, addrReg);
            }
            break;
        case functionCall:
            stmt_eval(e->edata.funcCall);
            if(isWord_p(t) || isByte_p(t)) {
                reg = getReg(registerState);
                m_load_frame_word(reg, -(t->ty_size), isByte_p(t), 1, 0);
                m_move_stack_ptr(-t->ty_size);
            } else {
                reg = getReg(registerState);
                m_load_constant(newNumExpr(-t->ty_size), reg);
                m_bin_op_to_r1("add", reg, 29);
            }
            break;
        case registerVal:
            reg = e->edata.reg_number;
        default:
            break;
    }
    return reg;
}

variable_types: reg int

variable_types: offsetReg int

variable_types: addrReg int

variable_types: globalIndex int

variable_types: staticOffset int


evalExprToPointer

decompiled_code:
__int64 __fastcall evalExprToPointer(__int64 a1)
{
unsigned int v1; // eax
__int64 v2; // r12
int v3; // ebp
_DWORD *v4; // r13
_DWORD *v5; // rax
_DWORD *v6; // rax
_DWORD *v7; // rax
_DWORD *v8; // rax

v1 = getReg(registerState);
v2 = *(_QWORD *)(a1 + 40);
v3 = v1;
if ( *(_DWORD *)(a1 + 8) == 4 )
{
m_load_global_address(*(unsigned int *)(*(_QWORD *)(a1 + 56) + 12LL), v1);
}
else
{
m_copy_fp(v1);
v4 = newNumExpr(*(_DWORD *)(*(_QWORD *)(a1 + 56) + 8LL));
v5 = newRegExpr(v3, int_type);
v6 = newBinOpExpr(4u, (__int64)v5, (__int64)v4);
v3 = evalExpr((__int64)v6);
}
v7 = newRegExpr(v3, int_type);
v8 = newBinOpExpr(4u, (__int64)v7, v2);
return evalExpr((__int64)v8);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
unsigned int v1; // eax
__int64 v2; // r12
int v3; // ebp
_DWORD *v4; // r13
_DWORD *v5; // rax
_DWORD *v6; // rax
_DWORD *v7; // rax
_DWORD *v8; // rax

v1 = getReg(registerState);
v2 = *(_QWORD *)(a1 + 40);
v3 = v1;
if ( *(_DWORD *)(a1 + 8) == 4 )
{
m_load_global_address(*(unsigned int *)(*(_QWORD *)(a1 + 56) + 12LL), v1);
}
else
{
m_copy_fp(v1);
v4 = newNumExpr(*(_DWORD *)(*(_QWORD *)(a1 + 56) + 8LL));
v5 = newRegExpr(v3, int_type);
v6 = newBinOpExpr(4u, (__int64)v5, (__int64)v4);
v3 = func1((__int64)v6);
}
v7 = newRegExpr(v3, int_type);
v8 = newBinOpExpr(4u, (__int64)v7, v2);
return func1((__int64)v8);
}

original_code:
int evalExprToPointer(expr* e) {
        int reg = getReg(registerState);
        expr* offsetExpr = e->offsetExpr;
        int globalP = e->kind == globalVar;
        if (globalP) {
            m_load_global_address(e->edata.id->id_label, reg);
        } else {
            m_copy_fp(reg);
            reg = evalExpr(newBinOpExpr(op_add, newRegExpr(reg, int_type), newNumExpr(e->edata.id->id_addr)));
        }
        reg = evalExpr(newBinOpExpr(op_add, newRegExpr(reg, int_type), offsetExpr));
        return reg;
}

canonical_original_code:
int evalExprToPointer(struct expression_struct *e) {
        int reg = getReg(registerState);
        struct expression_struct *offsetExpr = e->offsetExpr;
        int globalP = e->kind == globalVar;
        if (globalP) {
            m_load_global_address(e->edata.id->id_label, reg);
        } else {
            m_copy_fp(reg);
            reg = evalExpr(newBinOpExpr(op_add, newRegExpr(reg, int_type), newNumExpr(e->edata.id->id_addr)));
        }
        reg = evalExpr(newBinOpExpr(op_add, newRegExpr(reg, int_type), offsetExpr));
        return reg;
}

variable_types: struct expression_struct { struct type_info { int ty_size; char *ty_name; enum type_kind { Integer=0, Char=1, Boolean=2, String=3, Array=4, Record=5, UndefinedType=6 } ty_kind; struct type_info *ty_next; union { struct { struct type_info *RangeType; int min; int max; } ty_subrange; struct { struct type_info *ElementType; struct type_info *IndexType; int min; int max; } ty_array; struct { struct id_info { char *id_name; int id_addr; int id_label; int id_level; struct type_info *id_type; enum identifier_kind { Constant_id=0, Type=1, Variable=2, FParameter=3, Field=4, Procedure=5, Function=6 } id_kind; struct id_info *id_left; struct id_info *id_right; struct id_info *id_next; struct expression_struct *const_expr; struct slist_struct { struct slist_struct *next; void *data; } *typedIdentLists; int param_size; int pointer_p; } *FirstField; } ty_record; } ty_form; } *type; enum expr_kind_enum { constant_expr=0, operation_bin=1, operation_un=2, registerVal=3, globalVar=4, localVar=5, functionCall=6, typecast=7 } kind; int int_val; char char_val; int bool_val; char *str_val; int str_const_index; struct expression_struct *offsetExpr; int pointer_p; int to_pointer_p; union { struct { struct expression_struct *operand1; struct expression_struct *operand2; enum operator_enum { op_and=0, op_or=1, op_not=2, op_negate=3, op_add=4, op_sub=5, op_mult=6, op_div=7, op_mod=8, op_equal=9, op_nequal=10, op_gt=11, op_lt=12, op_gte=13, op_lte=14 } op; } opdata; int reg_number; struct id_info *id; struct stmt_struct { enum stmt_type_enum { assign_stmt=0, if_stmt=1, while_stmt=2, repeat_stmt=3, for_stmt=4, stop_stmt=5, return_stmt=6, read_stmt=7, write_stmt=8, proc_stmt=9, null_stmt=10 } type; union { struct htslist_struct { struct slist_struct *head; struct slist_struct *tail; } *if_conditionals; struct slist_struct *exprList; struct expression_struct *expression; struct { struct stmt_struct *init; struct conditional_struct { struct expression_struct *condition; enum BranchType_enum { bt_equal0=0, bt_nequal0=1 } branchType; struct htslist_struct *statements; } *cBlock; } loopdata; struct { struct expression_struct *lvalue; struct expression_struct *rvalue; } assigndata; struct { char *name; struct slist_struct *paramExprs; } procdata; } data; } *funcCall; struct expression_struct *innerExpr; } edata; } *

variable_types: globalP int


doBinaryOperator

decompiled_code:
__int64 __fastcall doBinaryOperator(int a1, __int64 a2, __int64 a3)
{
unsigned int v4; // er12
unsigned int v5; // eax
unsigned int v6; // ebp

v4 = evalExpr(a2);
v5 = evalExpr(a3);
v6 = v5;
switch ( a1 )
{
case 0:
m_bin_op_to_r1("and", v4, v5);
freeReg(registerState, v6);
break;
case 1:
m_bin_op_to_r1("or", v4, v5);
freeReg(registerState, v6);
break;
case 4:
m_bin_op_to_r1("add", v4, v5);
freeReg(registerState, v6);
break;
case 5:
m_bin_op_to_r1("sub", v4, v5);
freeReg(registerState, v6);
break;
case 6:
m_mult_op(v4, v5, v4);
freeReg(registerState, v6);
break;
case 7:
m_divide_op(v4, v5, v4);
freeReg(registerState, v6);
break;
case 8:
m_modulo_op(v4, v5, v4);
freeReg(registerState, v6);
break;
case 9:
m_compare_mips_op("beq", v4, v5, v4);
freeReg(registerState, v6);
break;
case 10:
m_compare_mips_op("bne", v4, v5, v4);
freeReg(registerState, v6);
break;
case 11:
m_compare_mips_op("bgtz", v4, v5, v4);
freeReg(registerState, v6);
break;
case 12:
m_compare_mips_op("bltz", v4, v5, v4);
freeReg(registerState, v6);
break;
case 13:
m_compare_mips_op("bgez", v4, v5, v4);
freeReg(registerState, v6);
break;
case 14:
m_compare_mips_op("blez", v4, v5, v4);
freeReg(registerState, v6);
break;
default:
return v4;
}
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1, __int64 a2, __int64 a3)
{
unsigned int v4; // er12
unsigned int v5; // eax
unsigned int v6; // ebp

v4 = func1(a2);
v5 = func1(a3);
v6 = v5;
switch ( a1 )
{
case 0:
m_bin_op_to_r1("and", v4, v5);
freeReg(registerState, v6);
break;
case 1:
m_bin_op_to_r1("or", v4, v5);
freeReg(registerState, v6);
break;
case 4:
m_bin_op_to_r1("add", v4, v5);
freeReg(registerState, v6);
break;
case 5:
m_bin_op_to_r1("sub", v4, v5);
freeReg(registerState, v6);
break;
case 6:
m_mult_op(v4, v5, v4);
freeReg(registerState, v6);
break;
case 7:
m_divide_op(v4, v5, v4);
freeReg(registerState, v6);
break;
case 8:
m_modulo_op(v4, v5, v4);
freeReg(registerState, v6);
break;
case 9:
m_compare_mips_op("beq", v4, v5, v4);
freeReg(registerState, v6);
break;
case 10:
m_compare_mips_op("bne", v4, v5, v4);
freeReg(registerState, v6);
break;
case 11:
m_compare_mips_op("bgtz", v4, v5, v4);
freeReg(registerState, v6);
break;
case 12:
m_compare_mips_op("bltz", v4, v5, v4);
freeReg(registerState, v6);
break;
case 13:
m_compare_mips_op("bgez", v4, v5, v4);
freeReg(registerState, v6);
break;
case 14:
m_compare_mips_op("blez", v4, v5, v4);
freeReg(registerState, v6);
break;
default:
return v4;
}
return v4;
}

original_code:
int doBinaryOperator(openum op, expr* operand1, expr* operand2) {
    int reg1 = evalExpr(operand1);
    int reg2 = evalExpr(operand2);
    switch(op) {
        case op_and:
            m_bin_op_to_r1("and", reg1, reg2);
            freeReg(registerState, reg2);
            break;
        case op_or:
            m_bin_op_to_r1("or", reg1, reg2);
            freeReg(registerState, reg2);
            break;
        case op_add:
            m_bin_op_to_r1("add", reg1, reg2);
            freeReg(registerState, reg2);
            break;
        case op_sub:
            m_bin_op_to_r1("sub", reg1, reg2);
            freeReg(registerState, reg2);
            break;
        case op_mult:
            m_mult_op(reg1, reg2, reg1);
            freeReg(registerState, reg2);
            break;
        case op_div:
            m_divide_op(reg1, reg2, reg1);
            freeReg(registerState, reg2);
            break;
        case op_mod:
            m_modulo_op(reg1, reg2, reg1);
            freeReg(registerState, reg2);
            break;
        case op_equal:
            m_compare_mips_op("beq", reg1, reg2, reg1);
            freeReg(registerState, reg2);
            break;
        case op_nequal:
            m_compare_mips_op("bne", reg1, reg2, reg1);
            freeReg(registerState, reg2);
            break;
        case op_gt:
            m_compare_mips_op("bgtz", reg1, reg2, reg1);
            freeReg(registerState, reg2);
            break;
        case op_lt:
            m_compare_mips_op("bltz", reg1, reg2, reg1);
            freeReg(registerState, reg2);
            break;
        case op_gte:
            m_compare_mips_op("bgez", reg1, reg2, reg1);
            freeReg(registerState, reg2);
            break;
        case op_lte:
            m_compare_mips_op("blez", reg1, reg2, reg1);
            freeReg(registerState, reg2);
            break;
    }
    return reg1;
}

canonical_original_code:
int doBinaryOperator(enum operator_enum op, struct expression_struct *operand1, struct expression_struct *operand2) {
    int reg1 = evalExpr(operand1);
    int reg2 = evalExpr(operand2);
    switch(op) {
        case op_and:
            m_bin_op_to_r1("and", reg1, reg2);
            freeReg(registerState, reg2);
            break;
        case op_or:
            m_bin_op_to_r1("or", reg1, reg2);
            freeReg(registerState, reg2);
            break;
        case op_add:
            m_bin_op_to_r1("add", reg1, reg2);
            freeReg(registerState, reg2);
            break;
        case op_sub:
            m_bin_op_to_r1("sub", reg1, reg2);
            freeReg(registerState, reg2);
            break;
        case op_mult:
            m_mult_op(reg1, reg2, reg1);
            freeReg(registerState, reg2);
            break;
        case op_div:
            m_divide_op(reg1, reg2, reg1);
            freeReg(registerState, reg2);
            break;
        case op_mod:
            m_modulo_op(reg1, reg2, reg1);
            freeReg(registerState, reg2);
            break;
        case op_equal:
            m_compare_mips_op("beq", reg1, reg2, reg1);
            freeReg(registerState, reg2);
            break;
        case op_nequal:
            m_compare_mips_op("bne", reg1, reg2, reg1);
            freeReg(registerState, reg2);
            break;
        case op_gt:
            m_compare_mips_op("bgtz", reg1, reg2, reg1);
            freeReg(registerState, reg2);
            break;
        case op_lt:
            m_compare_mips_op("bltz", reg1, reg2, reg1);
            freeReg(registerState, reg2);
            break;
        case op_gte:
            m_compare_mips_op("bgez", reg1, reg2, reg1);
            freeReg(registerState, reg2);
            break;
        case op_lte:
            m_compare_mips_op("blez", reg1, reg2, reg1);
            freeReg(registerState, reg2);
            break;
    }
    return reg1;
}


decompiled_code:
__int64 __fastcall evalExpr_pointerUpdate(__int64 a1)
{
unsigned int v1; // ebp
__int64 v2; // r12
_DWORD *v3; // rax

v1 = getReg(registerState);
m_load_frame_word(v1, *(unsigned int *)(*(_QWORD *)(a1 + 56) + 8LL), 0LL, 0LL, 0LL);
v2 = *(_QWORD *)(a1 + 40);
v3 = newRegExpr(v1, int_type);
return doBinaryOperator(4, (__int64)v3, v2);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
unsigned int v1; // ebp
__int64 v2; // r12
_DWORD *v3; // rax

v1 = getReg(registerState);
m_load_frame_word(v1, *(unsigned int *)(*(_QWORD *)(a1 + 56) + 8LL), 0LL, 0LL, 0LL);
v2 = *(_QWORD *)(a1 + 40);
v3 = newRegExpr(v1, int_type);
return func3(4, (__int64)v3, v2);
}

original_code:
int evalExpr_pointerUpdate(expr* e) {
    int ptrReg = getReg(registerState);
    int staticOffset = e->edata.id->id_addr;
    m_load_frame_word(ptrReg, staticOffset, 0, 0, 0);
    ptrReg = doBinaryOperator(op_add, newRegExpr(ptrReg, int_type), e->offsetExpr);
    return ptrReg;
}

canonical_original_code:
int evalExpr_pointerUpdate(struct expression_struct *e) {
    int ptrReg = getReg(registerState);
    int staticOffset = e->edata.id->id_addr;
    m_load_frame_word(ptrReg, staticOffset, 0, 0, 0);
    ptrReg = doBinaryOperator(op_add, newRegExpr(ptrReg, int_type), e->offsetExpr);
    return ptrReg;
}

variable_types: ptrReg int


getFPLabel

decompiled_code:
__int64 getFPLabel()
{
return (unsigned int)fplabelcounter++;
}

canonical_decompiled_code:
__int64 func0()
{
return (unsigned int)fplabelcounter++;
}

original_code:
int getFPLabel() {
    return fplabelcounter++;
}


decompiled_code:
_BOOL8 __fastcall typedidentlists_equalp(_QWORD *a1, _QWORD *a2)
{
_BOOL8 result; // rax
__int64 **v3; // rbx
__int64 **v4; // rbp
bool v5; // al
bool v6; // dl

result = 0LL;
if ( *a1 == *a2 )
{
v3 = (__int64 **)a1[2];
v4 = (__int64 **)a2[2];
v5 = v3 != 0LL;
v6 = v4 != 0LL;
if ( v4 && v3 )
{
while ( !strcmp((const char *)v3[1], (const char *)v4[1]) )
{
v3 = (__int64 **)*v3;
v4 = (__int64 **)*v4;
v5 = v3 != 0LL;
v6 = v4 != 0LL;
if ( !v3 || !v4 )
goto LABEL_9;
}
result = 0LL;
}
else
{
LABEL_9:
result = !v6 && !v5;
}
}
return result;
}

original_code:
int typedidentlists_equalp(typedidentlist* l, typedidentlist* r) {
    if (l->type != r->type) {
        return 0;
    }
    slist* nl = l->names;
    slist* nr = r->names;
    while(nl != ((void *)0) && nr != ((void *)0)) {
        if (strcmp(nl->data, nr->data)) {
            return 0;
        }
        nl = nl->next;
        nr = nr->next;
    }
    if (nl != ((void *)0) || nr != ((void *)0)) {
        return 0;
    }
    return 1;
}

canonical_original_code:
int typedidentlists_equalp(struct typedidentlist_struct *l, struct typedidentlist_struct *r) {
    if (l->type != r->type) {
        return 0;
    }
    struct slist_struct *nl = l->names;
    struct slist_struct *nr = r->names;
    while(nl != ((void *)0) && nr != ((void *)0)) {
        if (strcmp(nl->data, nr->data)) {
            return 0;
        }
        nl = nl->next;
        nr = nr->next;
    }
    if (nl != ((void *)0) || nr != ((void *)0)) {
        return 0;
    }
    return 1;
}

variable_types: struct typedidentlist_struct { struct type_info { int ty_size; char *ty_name; enum type_kind { Integer=0, Char=1, Boolean=2, String=3, Array=4, Record=5, UndefinedType=6 } ty_kind; struct type_info *ty_next; union { struct { struct type_info *RangeType; int min; int max; } ty_subrange; struct { struct type_info *ElementType; struct type_info *IndexType; int min; int max; } ty_array; struct { struct id_info { char *id_name; int id_addr; int id_label; int id_level; struct type_info *id_type; enum identifier_kind { Constant_id=0, Type=1, Variable=2, FParameter=3, Field=4, Procedure=5, Function=6 } id_kind; struct id_info *id_left; struct id_info *id_right; struct id_info *id_next; struct expression_struct { struct type_info *type; enum expr_kind_enum { constant_expr=0, operation_bin=1, operation_un=2, registerVal=3, globalVar=4, localVar=5, functionCall=6, typecast=7 } kind; int int_val; char char_val; int bool_val; char *str_val; int str_const_index; struct expression_struct *offsetExpr; int pointer_p; int to_pointer_p; union { struct { struct expression_struct *operand1; struct expression_struct *operand2; enum operator_enum { op_and=0, op_or=1, op_not=2, op_negate=3, op_add=4, op_sub=5, op_mult=6, op_div=7, op_mod=8, op_equal=9, op_nequal=10, op_gt=11, op_lt=12, op_gte=13, op_lte=14 } op; } opdata; int reg_number; struct id_info *id; struct stmt_struct { enum stmt_type_enum { assign_stmt=0, if_stmt=1, while_stmt=2, repeat_stmt=3, for_stmt=4, stop_stmt=5, return_stmt=6, read_stmt=7, write_stmt=8, proc_stmt=9, null_stmt=10 } type; union { struct htslist_struct { struct slist_struct { struct slist_struct *next; void *data; } *head; struct slist_struct *tail; } *if_conditionals; struct slist_struct *exprList; struct expression_struct *expression; struct { struct stmt_struct *init; struct conditional_struct { struct expression_struct *condition; enum BranchType_enum { bt_equal0=0, bt_nequal0=1 } branchType; struct htslist_struct *statements; } *cBlock; } loopdata; struct { struct expression_struct *lvalue; struct expression_struct *rvalue; } assigndata; struct { char *name; struct slist_struct *paramExprs; } procdata; } data; } *funcCall; struct expression_struct *innerExpr; } edata; } *const_expr; struct slist_struct *typedIdentLists; int param_size; int pointer_p; } *FirstField; } ty_record; } ty_form; } *type; int pointerP; struct slist_struct *names; } *

variable_types:
r
struct typedidentlist_struct *

user_defined_types: struct typedidentlist_struct { struct type_info *type; int pointerP; struct slist_struct *names; }


decompiled_code:
_BOOL8 __fastcall typedIdentList_list_equalp(__int64 **a1, __int64 **a2)
{
bool v2; // al
bool v3; // dl
__int64 **v4; // rbp
__int64 **v5; // rbx
_BOOL8 result; // rax

v2 = a1 != 0LL;
v3 = a2 != 0LL;
if ( !a1 )
return !v3 && !v2;
v4 = a2;
v5 = a1;
do
{
if ( !v3 )
break;
result = typedidentlists_equalp(v5[1], v4[1]);
if ( !result )
return result;
v5 = (__int64 **)*v5;
v4 = (__int64 **)*v4;
v2 = v5 != 0LL;
v3 = v4 != 0LL;
}
while ( v5 );
return !v3 && !v2;
}

original_code:
int typedIdentList_list_equalp(slist* l, slist* r) {
    while(l != ((void *)0) && r != ((void *)0)) {
        if(!typedidentlists_equalp(l->data, r->data)) {
            return 0;
        }
        l = l->next;
        r = r->next;
    }
    if(l != ((void *)0) || r != ((void *)0)) {
        return 0;
    }
    return 1;
}

canonical_original_code:
int typedIdentList_list_equalp(struct slist_struct *l, struct slist_struct *r) {
    while(l != ((void *)0) && r != ((void *)0)) {
        if(!typedidentlists_equalp(l->data, r->data)) {
            return 0;
        }
        l = l->next;
        r = r->next;
    }
    if(l != ((void *)0) || r != ((void *)0)) {
        return 0;
    }
    return 1;
}

variable_types: struct slist_struct { struct slist_struct *next; void *data; } *

variable_types:
r
struct slist_struct *


decompiled_code:
__int64 __fastcall calcSize_typedIdentList_list(_QWORD *a1)
{
unsigned int i; // er8
__int64 v2; // rax
int *v3; // rdx
int v4; // ecx
_QWORD *v5; // rax
int v6; // edx

for ( i = 0; a1; a1 = (_QWORD *)*a1 )
{
v2 = a1[1];
v3 = *(int **)v2;
v4 = *(_DWORD *)(v2 + 8);
v5 = *(_QWORD **)(v2 + 16);
v6 = *v3;
if ( v5 )
{
if ( v4 )
v6 = 4;
do
{
v5 = (_QWORD *)*v5;
i += v6;
}
while ( v5 );
}
}
return i;
}

original_code:
int calcSize_typedIdentList_list(slist* params) {
    int size = 0;
    while (params != ((void *)0)) {
        typedidentlist* til = params->data;
        TYPE* ty = til->type;
        int pointerP = til->pointerP;
        int tysize = ty->ty_size;
        slist* names = til->names;
        while (names != ((void *)0)) {
            size += pointerP ? 4 : tysize;
            names = names->next;
        }
        params = params->next;
    }
    return size;
}

canonical_original_code:
int calcSize_typedIdentList_list(struct slist_struct *params) {
    int size = 0;
    while (params != ((void *)0)) {
        struct typedidentlist_struct *til = params->data;
        struct type_info *ty = til->type;
        int pointerP = til->pointerP;
        int tysize = ty->ty_size;
        struct slist_struct *names = til->names;
        while (names != ((void *)0)) {
            size += pointerP ? 4 : tysize;
            names = names->next;
        }
        params = params->next;
    }
    return size;
}

variable_types: size int

variable_types: struct type_info { int ty_size; char *ty_name; enum type_kind { Integer=0, Char=1, Boolean=2, String=3, Array=4, Record=5, UndefinedType=6 } ty_kind; struct type_info *ty_next; union { struct { struct type_info *RangeType; int min; int max; } ty_subrange; struct { struct type_info *ElementType; struct type_info *IndexType; int min; int max; } ty_array; struct { struct id_info { char *id_name; int id_addr; int id_label; int id_level; struct type_info *id_type; enum identifier_kind { Constant_id=0, Type=1, Variable=2, FParameter=3, Field=4, Procedure=5, Function=6 } id_kind; struct id_info *id_left; struct id_info *id_right; struct id_info *id_next; struct expression_struct { struct type_info *type; enum expr_kind_enum { constant_expr=0, operation_bin=1, operation_un=2, registerVal=3, globalVar=4, localVar=5, functionCall=6, typecast=7 } kind; int int_val; char char_val; int bool_val; char *str_val; int str_const_index; struct expression_struct *offsetExpr; int pointer_p; int to_pointer_p; union { struct { struct expression_struct *operand1; struct expression_struct *operand2; enum operator_enum { op_and=0, op_or=1, op_not=2, op_negate=3, op_add=4, op_sub=5, op_mult=6, op_div=7, op_mod=8, op_equal=9, op_nequal=10, op_gt=11, op_lt=12, op_gte=13, op_lte=14 } op; } opdata; int reg_number; struct id_info *id; struct stmt_struct { enum stmt_type_enum { assign_stmt=0, if_stmt=1, while_stmt=2, repeat_stmt=3, for_stmt=4, stop_stmt=5, return_stmt=6, read_stmt=7, write_stmt=8, proc_stmt=9, null_stmt=10 } type; union { struct htslist_struct { struct slist_struct { struct slist_struct *next; void *data; } *head; struct slist_struct *tail; } *if_conditionals; struct slist_struct *exprList; struct expression_struct *expression; struct { struct stmt_struct *init; struct conditional_struct { struct expression_struct *condition; enum BranchType_enum { bt_equal0=0, bt_nequal0=1 } branchType; struct htslist_struct *statements; } *cBlock; } loopdata; struct { struct expression_struct *lvalue; struct expression_struct *rvalue; } assigndata; struct { char *name; struct slist_struct *paramExprs; } procdata; } data; } *funcCall; struct expression_struct *innerExpr; } edata; } *const_expr; struct slist_struct *typedIdentLists; int param_size; int pointer_p; } *FirstField; } ty_record; } ty_form; } *

variable_types: pointerP int

variable_types: tysize int


declareFunc

decompiled_code:
__int64 __fastcall declareFunc(__int64 a1, __int64 **a2, __int64 a3, __int64 a4)
{
unsigned int v4; // er13
__int64 v7; // r14
__int64 result; // rax
int v9; // er12
int v10; // eax
unsigned int v11; // ebx
__int64 v12; // rax
int v13; // eax
__int64 v14; // r9

v7 = IDsearch(a1, *((_QWORD *)&scope + currscope - 1));
if ( v7 )
{
if ( *(_DWORD *)(v7 + 32) == 5 - ((a4 == 0) - 1) )
{
result = typedIdentList_list_equalp(*(__int64 ***)(v7 + 72), a2);
if ( (_DWORD)result )
v4 = *(_DWORD *)(v7 + 12);
else
result = yyerror("Formal parameters differ between function declarations");
}
else
{
result = yyerror("Identifier already defined");
}
}
else
{
v4 = getFPLabel(a1);
v12 = newid();
*(_QWORD *)(v12 + 24) = a4;
*(_DWORD *)(v12 + 32) = 5 - ((a4 == 0) - 1);
*(_QWORD *)(v12 + 72) = a2;
*(_DWORD *)(v12 + 12) = v4;
v13 = calcSize_typedIdentList_list(a2);
*(_DWORD *)(v14 + 80) = v13;
result = addIdToTable_noAddrMove(v14, (char *)&scope + 8 * currscope - 8);
}
if ( a3 )
{
m_add_function_label(v4);
v9 = calcSize_typedIdentList_list(a2);
v10 = getSizeOfScopeVars(*((_QWORD *)&scope + currscope));
v11 = -v10;
m_move_stack_ptr((unsigned int)(v10 - v9));
m_set_fp_to_sp(v11);
eval_stmt_list(a3);
result = m_function_end(v4);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 **a2, __int64 a3, __int64 a4)
{
unsigned int v4; // er13
__int64 v7; // r14
__int64 result; // rax
int v9; // er12
int v10; // eax
unsigned int v11; // ebx
__int64 v12; // rax
int v13; // eax
__int64 v14; // r9

v7 = IDsearch(a1, *((_QWORD *)&scope + currscope - 1));
if ( v7 )
{
if ( *(_DWORD *)(v7 + 32) == 5 - ((a4 == 0) - 1) )
{
result = func2(*(__int64 ***)(v7 + 72), a2);
if ( (_DWORD)result )
v4 = *(_DWORD *)(v7 + 12);
else
result = yyerror("Formal parameters differ between function declarations");
}
else
{
result = yyerror("Identifier already defined");
}
}
else
{
v4 = func0(a1);
v12 = newid();
*(_QWORD *)(v12 + 24) = a4;
*(_DWORD *)(v12 + 32) = 5 - ((a4 == 0) - 1);
*(_QWORD *)(v12 + 72) = a2;
*(_DWORD *)(v12 + 12) = v4;
v13 = func3(a2);
*(_DWORD *)(v14 + 80) = v13;
result = addIdToTable_noAddrMove(v14, (char *)&scope + 8 * currscope - 8);
}
if ( a3 )
{
m_add_function_label(v4);
v9 = func3(a2);
v10 = getSizeOfScopeVars(*((_QWORD *)&scope + currscope));
v11 = -v10;
m_move_stack_ptr((unsigned int)(v10 - v9));
m_set_fp_to_sp(v11);
eval_stmt_list(a3);
result = m_function_end(v4);
}
return result;
}

original_code:
void declareFunc(char* name, slist* params, htslist* body, TYPE* t) {
    ID* func = IDsearch(name, scope[currscope-1]);
    int flabel, predeclared = 0;
    ID_KIND funcproc = t == ((void *)0) ? Procedure : Function;
    if (func != ((void *)0)) {
        predeclared = 1;
        if (func->id_kind != funcproc) {
            yyerror("Identifier already defined");
        } else if (!typedIdentList_list_equalp(func->typedIdentLists, params)) {
            yyerror("Formal parameters differ between function declarations");
        } else {
            flabel = func->id_label;
        }
    } else {
        flabel = getFPLabel();
        func = newid(name);
        func->id_kind = funcproc;
        func->id_type = t;
        func->typedIdentLists = params;
        func->id_label = flabel;
        func->param_size = calcSize_typedIdentList_list(params);
        addIdToTable_noAddrMove(func, scope+(currscope-1));
    }
    if (body != ((void *)0)) {
        m_add_function_label(flabel);
        int paramSize = calcSize_typedIdentList_list(params);
        int fullScopeSize = getSizeOfScopeVars(scope[currscope]);
        int nonParamSize = fullScopeSize - paramSize;
        m_move_stack_ptr(nonParamSize);
        m_set_fp_to_sp(-fullScopeSize);
        eval_stmt_list(body);
        m_function_end(flabel);
    }
}

canonical_original_code:
void declareFunc(char *name, struct slist_struct *params, struct htslist_struct *body, struct type_info *t) {
    struct id_info *func = IDsearch(name, scope[currscope-1]);
    int flabel; int predeclared = 0;
    enum identifier_kind funcproc = t == ((void *)0) ? Procedure : Function;
    if (func != ((void *)0)) {
        predeclared = 1;
        if (func->id_kind != funcproc) {
            yyerror("Identifier already defined");
        } else if (!typedIdentList_list_equalp(func->typedIdentLists, params)) {
            yyerror("Formal parameters differ between function declarations");
        } else {
            flabel = func->id_label;
        }
    } else {
        flabel = getFPLabel();
        func = newid(name);
        func->id_kind = funcproc;
        func->id_type = t;
        func->typedIdentLists = params;
        func->id_label = flabel;
        func->param_size = calcSize_typedIdentList_list(params);
        addIdToTable_noAddrMove(func, scope+(currscope-1));
    }
    if (body != ((void *)0)) {
        m_add_function_label(flabel);
        int paramSize = calcSize_typedIdentList_list(params);
        int fullScopeSize = getSizeOfScopeVars(scope[currscope]);
        int nonParamSize = fullScopeSize - paramSize;
        m_move_stack_ptr(nonParamSize);
        m_set_fp_to_sp(-fullScopeSize);
        eval_stmt_list(body);
        m_function_end(flabel);
    }
}

variable_types:
name
char *

variable_types: struct htslist_struct { struct slist_struct *head; struct slist_struct *tail; } *

variable_types: struct type_info { int ty_size; char *ty_name; enum type_kind { Integer=0, Char=1, Boolean=2, String=3, Array=4, Record=5, UndefinedType=6 } ty_kind; struct type_info *ty_next; union { struct { struct type_info *RangeType; int min; int max; } ty_subrange; struct { struct type_info *ElementType; struct type_info *IndexType; int min; int max; } ty_array; struct { struct id_info { char *id_name; int id_addr; int id_label; int id_level; struct type_info *id_type; enum identifier_kind { Constant_id=0, Type=1, Variable=2, FParameter=3, Field=4, Procedure=5, Function=6 } id_kind; struct id_info *id_left; struct id_info *id_right; struct id_info *id_next; struct expression_struct { struct type_info *type; enum expr_kind_enum { constant_expr=0, operation_bin=1, operation_un=2, registerVal=3, globalVar=4, localVar=5, functionCall=6, typecast=7 } kind; int int_val; char char_val; int bool_val; char *str_val; int str_const_index; struct expression_struct *offsetExpr; int pointer_p; int to_pointer_p; union { struct { struct expression_struct *operand1; struct expression_struct *operand2; enum operator_enum { op_and=0, op_or=1, op_not=2, op_negate=3, op_add=4, op_sub=5, op_mult=6, op_div=7, op_mod=8, op_equal=9, op_nequal=10, op_gt=11, op_lt=12, op_gte=13, op_lte=14 } op; } opdata; int reg_number; struct id_info *id; struct stmt_struct { enum stmt_type_enum { assign_stmt=0, if_stmt=1, while_stmt=2, repeat_stmt=3, for_stmt=4, stop_stmt=5, return_stmt=6, read_stmt=7, write_stmt=8, proc_stmt=9, null_stmt=10 } type; union { struct htslist_struct *if_conditionals; struct slist_struct *exprList; struct expression_struct *expression; struct { struct stmt_struct *init; struct conditional_struct { struct expression_struct *condition; enum BranchType_enum { bt_equal0=0, bt_nequal0=1 } branchType; struct htslist_struct *statements; } *cBlock; } loopdata; struct { struct expression_struct *lvalue; struct expression_struct *rvalue; } assigndata; struct { char *name; struct slist_struct *paramExprs; } procdata; } data; } *funcCall; struct expression_struct *innerExpr; } edata; } *const_expr; struct slist_struct *typedIdentLists; int param_size; int pointer_p; } *FirstField; } ty_record; } ty_form; } *

variable_types: struct id_info { char *id_name; int id_addr; int id_label; int id_level; struct type_info { int ty_size; char *ty_name; enum type_kind { Integer=0, Char=1, Boolean=2, String=3, Array=4, Record=5, UndefinedType=6 } ty_kind; struct type_info *ty_next; union { struct { struct type_info *RangeType; int min; int max; } ty_subrange; struct { struct type_info *ElementType; struct type_info *IndexType; int min; int max; } ty_array; struct { struct id_info *FirstField; } ty_record; } ty_form; } *id_type; enum identifier_kind { Constant_id=0, Type=1, Variable=2, FParameter=3, Field=4, Procedure=5, Function=6 } id_kind; struct id_info *id_left; struct id_info *id_right; struct id_info *id_next; struct expression_struct { struct type_info *type; enum expr_kind_enum { constant_expr=0, operation_bin=1, operation_un=2, registerVal=3, globalVar=4, localVar=5, functionCall=6, typecast=7 } kind; int int_val; char char_val; int bool_val; char *str_val; int str_const_index; struct expression_struct *offsetExpr; int pointer_p; int to_pointer_p; union { struct { struct expression_struct *operand1; struct expression_struct *operand2; enum operator_enum { op_and=0, op_or=1, op_not=2, op_negate=3, op_add=4, op_sub=5, op_mult=6, op_div=7, op_mod=8, op_equal=9, op_nequal=10, op_gt=11, op_lt=12, op_gte=13, op_lte=14 } op; } opdata; int reg_number; struct id_info *id; struct stmt_struct { enum stmt_type_enum { assign_stmt=0, if_stmt=1, while_stmt=2, repeat_stmt=3, for_stmt=4, stop_stmt=5, return_stmt=6, read_stmt=7, write_stmt=8, proc_stmt=9, null_stmt=10 } type; union { struct htslist_struct { struct slist_struct { struct slist_struct *next; void *data; } *head; struct slist_struct *tail; } *if_conditionals; struct slist_struct *exprList; struct expression_struct *expression; struct { struct stmt_struct *init; struct conditional_struct { struct expression_struct *condition; enum BranchType_enum { bt_equal0=0, bt_nequal0=1 } branchType; struct htslist_struct *statements; } *cBlock; } loopdata; struct { struct expression_struct *lvalue; struct expression_struct *rvalue; } assigndata; struct { char *name; struct slist_struct *paramExprs; } procdata; } data; } *funcCall; struct expression_struct *innerExpr; } edata; } *const_expr; struct slist_struct *typedIdentLists; int param_size; int pointer_p; } *

variable_types: flabel int

variable_types: predeclared int

variable_types: paramSize int

variable_types: fullScopeSize int

variable_types: nonParamSize int


decompiled_code:
__int64 __fastcall funcArgList_checkAndAddPointerPs(__int64 a1, _QWORD *a2)
{
_QWORD *i; // r15
__int64 result; // rax
_QWORD *v5; // rbp
__int64 v6; // r14
int j; // er13
__int64 v8; // r12

for ( i = *(_QWORD **)(a1 + 72); i; i = (_QWORD *)*i )
{
result = i[1];
v5 = *(_QWORD **)(result + 16);
v6 = *(_QWORD *)result;
for ( j = *(_DWORD *)(result + 8); v5; a2 = (_QWORD *)*a2 )
{
if ( !a2 )
result = yyerror("Not enough arguments");
v8 = a2[1];
if ( *(_QWORD *)v8 != v6 )
result = yyerror("Function arg type mismatch");
if ( j )
{
result = (unsigned int)(*(_DWORD *)(v8 + 8) - 4);
if ( (unsigned int)result > 1 )
result = yyerror("Non-lvalue used where a pass-by-reference variable was needed");
*(_DWORD *)(v8 + 52) = 1;
}
v5 = (_QWORD *)*v5;
}
}
if ( a2 )
result = yyerror("too many arguments");
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, _QWORD *a2)
{
_QWORD *i; // r15
__int64 result; // rax
_QWORD *v5; // rbp
__int64 v6; // r14
int j; // er13
__int64 v8; // r12

for ( i = *(_QWORD **)(a1 + 72); i; i = (_QWORD *)*i )
{
result = i[1];
v5 = *(_QWORD **)(result + 16);
v6 = *(_QWORD *)result;
for ( j = *(_DWORD *)(result + 8); v5; a2 = (_QWORD *)*a2 )
{
if ( !a2 )
result = yyerror("Not enough arguments");
v8 = a2[1];
if ( *(_QWORD *)v8 != v6 )
result = yyerror("Function arg type mismatch");
if ( j )
{
result = (unsigned int)(*(_DWORD *)(v8 + 8) - 4);
if ( (unsigned int)result > 1 )
result = yyerror("Non-lvalue used where a pass-by-reference variable was needed");
*(_DWORD *)(v8 + 52) = 1;
}
v5 = (_QWORD *)*v5;
}
}
if ( a2 )
result = yyerror("too many arguments");
return result;
}

original_code:
void funcArgList_checkAndAddPointerPs(ID* function, slist* paramExprs) {
    slist* idlists = function->typedIdentLists;
    while (idlists != ((void *)0)) {
        typedidentlist* idlist = idlists->data;
        TYPE* t = idlist->type;
        int pointerP = idlist->pointerP;
        slist* names = idlist->names;
        while (names != ((void *)0)) {
            if (paramExprs == ((void *)0)) {
                yyerror("Not enough arguments");
            }
            expr* e = paramExprs->data;
            if (e->type != t) {
                yyerror("Function arg type mismatch");
            }
            if (pointerP) {
                if (e->kind != globalVar && e->kind != localVar) {
                    yyerror("Non-lvalue used where a pass-by-reference variable was needed");
                }
                e->to_pointer_p = 1;
            }
            paramExprs = paramExprs->next;
            names = names->next;
        }
        idlists = idlists->next;
    }
    if (paramExprs != ((void *)0)) {
        yyerror("too many arguments");
    }
}

canonical_original_code:
void funcArgList_checkAndAddPointerPs(struct id_info *function, struct slist_struct *paramExprs) {
    struct slist_struct *idlists = function->typedIdentLists;
    while (idlists != ((void *)0)) {
        struct typedidentlist_struct *idlist = idlists->data;
        struct type_info *t = idlist->type;
        int pointerP = idlist->pointerP;
        struct slist_struct *names = idlist->names;
        while (names != ((void *)0)) {
            if (paramExprs == ((void *)0)) {
                yyerror("Not enough arguments");
            }
            struct expression_struct *e = paramExprs->data;
            if (e->type != t) {
                yyerror("Function arg type mismatch");
            }
            if (pointerP) {
                if (e->kind != globalVar && e->kind != localVar) {
                    yyerror("Non-lvalue used where a pass-by-reference variable was needed");
                }
                e->to_pointer_p = 1;
            }
            paramExprs = paramExprs->next;
            names = names->next;
        }
        idlists = idlists->next;
    }
    if (paramExprs != ((void *)0)) {
        yyerror("too many arguments");
    }
}

variable_types:
paramExprs
struct slist_struct *

variable_types: struct typedidentlist_struct { struct type_info { int ty_size; char *ty_name; enum type_kind { Integer=0, Char=1, Boolean=2, String=3, Array=4, Record=5, UndefinedType=6 } ty_kind; struct type_info *ty_next; union { struct { struct type_info *RangeType; int min; int max; } ty_subrange; struct { struct type_info *ElementType; struct type_info *IndexType; int min; int max; } ty_array; struct { struct id_info { char *id_name; int id_addr; int id_label; int id_level; struct type_info *id_type; enum identifier_kind { Constant_id=0, Type=1, Variable=2, FParameter=3, Field=4, Procedure=5, Function=6 } id_kind; struct id_info *id_left; struct id_info *id_right; struct id_info *id_next; struct expression_struct { struct type_info *type; enum expr_kind_enum { constant_expr=0, operation_bin=1, operation_un=2, registerVal=3, globalVar=4, localVar=5, functionCall=6, typecast=7 } kind; int int_val; char char_val; int bool_val; char *str_val; int str_const_index; struct expression_struct *offsetExpr; int pointer_p; int to_pointer_p; union { struct { struct expression_struct *operand1; struct expression_struct *operand2; enum operator_enum { op_and=0, op_or=1, op_not=2, op_negate=3, op_add=4, op_sub=5, op_mult=6, op_div=7, op_mod=8, op_equal=9, op_nequal=10, op_gt=11, op_lt=12, op_gte=13, op_lte=14 } op; } opdata; int reg_number; struct id_info *id; struct stmt_struct { enum stmt_type_enum { assign_stmt=0, if_stmt=1, while_stmt=2, repeat_stmt=3, for_stmt=4, stop_stmt=5, return_stmt=6, read_stmt=7, write_stmt=8, proc_stmt=9, null_stmt=10 } type; union { struct htslist_struct { struct slist_struct { struct slist_struct *next; void *data; } *head; struct slist_struct *tail; } *if_conditionals; struct slist_struct *exprList; struct expression_struct *expression; struct { struct stmt_struct *init; struct conditional_struct { struct expression_struct *condition; enum BranchType_enum { bt_equal0=0, bt_nequal0=1 } branchType; struct htslist_struct *statements; } *cBlock; } loopdata; struct { struct expression_struct *lvalue; struct expression_struct *rvalue; } assigndata; struct { char *name; struct slist_struct *paramExprs; } procdata; } data; } *funcCall; struct expression_struct *innerExpr; } edata; } *const_expr; struct slist_struct *typedIdentLists; int param_size; int pointer_p; } *FirstField; } ty_record; } ty_form; } *type; int pointerP; struct slist_struct *names; } *

variable_types: struct expression_struct { struct type_info { int ty_size; char *ty_name; enum type_kind { Integer=0, Char=1, Boolean=2, String=3, Array=4, Record=5, UndefinedType=6 } ty_kind; struct type_info *ty_next; union { struct { struct type_info *RangeType; int min; int max; } ty_subrange; struct { struct type_info *ElementType; struct type_info *IndexType; int min; int max; } ty_array; struct { struct id_info { char *id_name; int id_addr; int id_label; int id_level; struct type_info *id_type; enum identifier_kind { Constant_id=0, Type=1, Variable=2, FParameter=3, Field=4, Procedure=5, Function=6 } id_kind; struct id_info *id_left; struct id_info *id_right; struct id_info *id_next; struct expression_struct *const_expr; struct slist_struct { struct slist_struct *next; void *data; } *typedIdentLists; int param_size; int pointer_p; } *FirstField; } ty_record; } ty_form; } *type; enum expr_kind_enum { constant_expr=0, operation_bin=1, operation_un=2, registerVal=3, globalVar=4, localVar=5, functionCall=6, typecast=7 } kind; int int_val; char char_val; int bool_val; char *str_val; int str_const_index; struct expression_struct *offsetExpr; int pointer_p; int to_pointer_p; union { struct { struct expression_struct *operand1; struct expression_struct *operand2; enum operator_enum { op_and=0, op_or=1, op_not=2, op_negate=3, op_add=4, op_sub=5, op_mult=6, op_div=7, op_mod=8, op_equal=9, op_nequal=10, op_gt=11, op_lt=12, op_gte=13, op_lte=14 } op; } opdata; int reg_number; struct id_info *id; struct stmt_struct { enum stmt_type_enum { assign_stmt=0, if_stmt=1, while_stmt=2, repeat_stmt=3, for_stmt=4, stop_stmt=5, return_stmt=6, read_stmt=7, write_stmt=8, proc_stmt=9, null_stmt=10 } type; union { struct htslist_struct { struct slist_struct *head; struct slist_struct *tail; } *if_conditionals; struct slist_struct *exprList; struct expression_struct *expression; struct { struct stmt_struct *init; struct conditional_struct { struct expression_struct *condition; enum BranchType_enum { bt_equal0=0, bt_nequal0=1 } branchType; struct htslist_struct *statements; } *cBlock; } loopdata; struct { struct expression_struct *lvalue; struct expression_struct *rvalue; } assigndata; struct { char *name; struct slist_struct *paramExprs; } procdata; } data; } *funcCall; struct expression_struct *innerExpr; } edata; } *


printHelp

decompiled_code:
void __fastcall __noreturn printHelp(int status)
{
puts("The incredible, amazing, and stupendous cpslc written by William Hatch.");
puts("Compiles CPSL programs into mips assembly suitable for spim or MARS");
puts("I/O to/from stdout/stdin unless otherwise specified with these flags.");
puts("Options:");
puts("-v --verbose print symbol table");
puts("-h --help print this message");
puts("-f <file> --file <file> set input file");
puts("-o <file> --output <file> set output file");
putchar(10);
exit(status);
}

canonical_decompiled_code:
void __fastcall __noreturn func0(int status)
{
puts("The incredible, amazing, and stupendous cpslc written by William Hatch.");
puts("Compiles CPSL programs into mips assembly suitable for spim or MARS");
puts("I/O to/from stdout/stdin unless otherwise specified with these flags.");
puts("Options:");
puts("-v --verbose print symbol table");
puts("-h --help print this message");
puts("-f <file> --file <file> set input file");
puts("-o <file> --output <file> set output file");
putchar(10);
exit(status);
}

original_code:
void printHelp(int exitStatus) {
    printf("The incredible, amazing, and stupendous cpslc written by William Hatch.\n");
    printf("Compiles CPSL programs into mips assembly suitable for spim or MARS\n");
    printf("I/O to/from stdout/stdin unless otherwise specified with these flags.\n");
    printf("Options:\n");
    printf("-v --verbose                print symbol table\n");
    printf("-h --help                   print this message\n");
    printf("-f <file> --file <file>     set input file\n");
    printf("-o <file> --output <file>   set output file\n");
    printf("\n");
    exit(exitStatus);
}

variable_types: exitStatus int


putIntervalArray

repo: willghatch/qiafph

decompiled_code:
__int64 __fastcall putIntervalArray(__int64 a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // rcx
__int64 v4; // rdx

result = (unsigned int)(nmeasures * sdivPerDiv * mdivision);
if ( (int)result > 1 )
{
v3 = (unsigned int)(result - 2);
result = 0LL;
do
{
*(_DWORD *)(a2 + 4 * result) = *(_DWORD *)(a1 + 8 * result + 8) - *(_DWORD *)(a1 + 8 * result);
v4 = result++;
}
while ( v4 != v3 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // rcx
__int64 v4; // rdx

result = (unsigned int)(nmeasures * sdivPerDiv * mdivision);
if ( (int)result > 1 )
{
v3 = (unsigned int)(result - 2);
result = 0LL;
do
{
*(_DWORD *)(a2 + 4 * result) = *(_DWORD *)(a1 + 8 * result + 8) - *(_DWORD *)(a1 + 8 * result);
v4 = result++;
}
while ( v4 != v3 );
}
return result;
}

original_code:
void putIntervalArray(Note* part, int* intervals) {
    int intervalLen = mdivision * sdivPerDiv * nmeasures - 1;
    for(int i = 0; i < intervalLen; ++i) {
        intervals[i] = part[i+1].pitch - part[i].pitch;
    }
}

canonical_original_code:
void putIntervalArray(struct notestruct *part, int *intervals) {
    int intervalLen = mdivision * sdivPerDiv * nmeasures - 1;
    for(int i = 0; i < intervalLen; ++i) {
        intervals[i] = part[i+1].pitch - part[i].pitch;
    }
}

variable_types: struct notestruct { int pitch; int flags; } *

variable_types:
intervals
int *

variable_types: intervalLen int

variable_types: i int


partsCp

decompiled_code:
void *__fastcall partsCp(__int64 a1, __int64 a2)
{
void *result; // rax
__int64 v5; // rbx
void *v6; // rdi
const void *v7; // rsi

result = (void *)nparts;
if ( nparts > 0 )
{
v5 = 0LL;
do
{
v6 = *(void **)(a2 + 8 * v5);
v7 = *(const void **)(a1 + 8 * v5++);
result = memcpy(v6, v7, 8LL * totalSubdivisions);
}
while ( nparts > (int)v5 );
}
return result;
}

canonical_decompiled_code:
void *__fastcall func1(__int64 a1, __int64 a2)
{
void *result; // rax
__int64 v5; // rbx
void *v6; // rdi
const void *v7; // rsi

result = (void *)nparts;
if ( nparts > 0 )
{
v5 = 0LL;
do
{
v6 = *(void **)(a2 + 8 * v5);
v7 = *(const void **)(a1 + 8 * v5++);
result = memcpy(v6, v7, 8LL * totalSubdivisions);
}
while ( nparts > (int)v5 );
}
return result;
}

original_code:
void partsCp(Note** srcParts, Note** dstParts) {
    for(int i = 0; i < nparts; ++i) {
        memcpy(dstParts[i], srcParts[i], sizeof(Note)*totalSubdivisions);
    }
}

canonical_original_code:
void partsCp(struct notestruct **srcParts, struct notestruct **dstParts) {
    for(int i = 0; i < nparts; ++i) {
        memcpy(dstParts[i], srcParts[i], sizeof(Note)*totalSubdivisions);
    }
}

variable_types: struct notestruct { int pitch; int flags; } **

variable_types:
dstParts
struct notestruct **


partsIntervalsCp

decompiled_code:
void *__fastcall partsIntervalsCp(__int64 a1, __int64 a2)
{
void *result; // rax
__int64 v5; // rbx
void *v6; // rdi
const void *v7; // rsi

result = (void *)nparts;
if ( nparts > 0 )
{
v5 = 0LL;
do
{
v6 = *(void **)(a2 + 8 * v5);
v7 = *(const void **)(a1 + 8 * v5++);
result = memcpy(v6, v7, 4LL * totalSubdivisions);
}
while ( nparts > (int)v5 );
}
return result;
}

canonical_decompiled_code:
void *__fastcall func2(__int64 a1, __int64 a2)
{
void *result; // rax
__int64 v5; // rbx
void *v6; // rdi
const void *v7; // rsi

result = (void *)nparts;
if ( nparts > 0 )
{
v5 = 0LL;
do
{
v6 = *(void **)(a2 + 8 * v5);
v7 = *(const void **)(a1 + 8 * v5++);
result = memcpy(v6, v7, 4LL * totalSubdivisions);
}
while ( nparts > (int)v5 );
}
return result;
}

original_code:
void partsIntervalsCp(int** src, int** dst) {
    for(int i = 0; i < nparts; ++i) {
        memcpy(dst[i], src[i], sizeof(int)*totalSubdivisions);
    }
}

canonical_original_code:
void partsIntervalsCp(int **src, int **dst) {
    for(int i = 0; i < nparts; ++i) {
        memcpy(dst[i], src[i], sizeof(int)*totalSubdivisions);
    }
}

variable_types:
src
int **

variable_types:
dst
int **


chordInfoCp

decompiled_code:
void *__fastcall chordInfoCp(void *src, void *dest)
{
return memcpy(dest, src, 32 * mdivision * (__int64)nmeasures);
}

canonical_decompiled_code:
void *__fastcall func3(void *src, void *dest)
{
return memcpy(dest, src, 32 * mdivision * (__int64)nmeasures);
}

original_code:
void chordInfoCp(ChordInfo* src, ChordInfo* dst) {
    memcpy(dst, src, sizeof(ChordInfo)*nmeasures*mdivision);
}

canonical_original_code:
void chordInfoCp(struct ChordInfoStruct *src, struct ChordInfoStruct *dst) {
    memcpy(dst, src, sizeof(ChordInfo)*nmeasures*mdivision);
}

variable_types: struct ChordInfoStruct { int rootNote; int inversion; enum ChordTypeEnum { ch_nochord=0, ch_maj=1, ch_min=2, ch_dim=3, ch_aug=4, ch_maj_7=5, ch_dom_7=6, ch_min_7=7, ch_halfdim_7=8, ch_fulldim_7=9, ch_aug_7=10 } type; int fullChordP; int doubledNote; int numNonChordSdivs; int numInPieceKey; int inNormalKeyChordsP; } *

variable_types:
dst
struct ChordInfoStruct *

user_defined_types: struct ChordInfoStruct { int rootNote; int inversion; enum ChordTypeEnum type; int fullChordP; int doubledNote; int numNonChordSdivs; int numInPieceKey; int inNormalKeyChordsP; }


printHelp

decompiled_code:
void __fastcall __noreturn printHelp(int status)
{
fwrite("qiafph -- qiafph is a four part harmonizer\n", 1uLL, 0x2BuLL, stderr);
fwrite("Written by William Hatch for CS 5600 at USU\n", 1uLL, 0x2CuLL, stderr);
fwrite("Generates four part harmony. Configured at the moment in source\n", 1uLL, 0x41uLL, stderr);
fwrite("in rulescores.h and globalvars.h\n", 1uLL, 0x21uLL, stderr);
fwrite("Options:\n", 1uLL, 9uLL, stderr);
fwrite("-m <file> --midge <file> Midge output file\n", 1uLL, 0x31uLL, stderr);
fwrite("-a <file> --analysis <file> Analysis info output file\n", 1uLL, 0x39uLL, stderr);
fwrite("-n <int> --nparts <int> Number of parts (default 4, must be > 2)\n", 1uLL, 0x48uLL, stderr);
fwrite("-v --verbose Print some extra info to stderr\n", 1uLL, 0x3FuLL, stderr);
fwrite("-h --help Print this message to stderr\n", 1uLL, 0x3CuLL, stderr);
fwrite("\nA music output format (midge or musedata) must be supplied\n", 1uLL, 0x3CuLL, stderr);
exit(status);
}

canonical_decompiled_code:
void __fastcall __noreturn func4(int status)
{
fwrite("qiafph -- qiafph is a four part harmonizer\n", 1uLL, 0x2BuLL, stderr);
fwrite("Written by William Hatch for CS 5600 at USU\n", 1uLL, 0x2CuLL, stderr);
fwrite("Generates four part harmony. Configured at the moment in source\n", 1uLL, 0x41uLL, stderr);
fwrite("in rulescores.h and globalvars.h\n", 1uLL, 0x21uLL, stderr);
fwrite("Options:\n", 1uLL, 9uLL, stderr);
fwrite("-m <file> --midge <file> Midge output file\n", 1uLL, 0x31uLL, stderr);
fwrite("-a <file> --analysis <file> Analysis info output file\n", 1uLL, 0x39uLL, stderr);
fwrite("-n <int> --nparts <int> Number of parts (default 4, must be > 2)\n", 1uLL, 0x48uLL, stderr);
fwrite("-v --verbose Print some extra info to stderr\n", 1uLL, 0x3FuLL, stderr);
fwrite("-h --help Print this message to stderr\n", 1uLL, 0x3CuLL, stderr);
fwrite("\nA music output format (midge or musedata) must be supplied\n", 1uLL, 0x3CuLL, stderr);
exit(status);
}

original_code:
void printHelp(int exitStatus) {
    fprintf(stderr, "qiafph -- qiafph is a four part harmonizer\n");
    fprintf(stderr, "Written by William Hatch for CS 5600 at USU\n");
    fprintf(stderr, "Generates four part harmony.  Configured at the moment in source\n");
    fprintf(stderr, "in rulescores.h and globalvars.h\n");
    fprintf(stderr, "Options:\n");
    fprintf(stderr, "-m <file>  --midge <file>      Midge output file\n");
    fprintf(stderr, "-a <file>  --analysis <file>   Analysis info output file\n");
    fprintf(stderr, "-n <int>   --nparts <int>      Number of parts (default 4, must be > 2)\n");
    fprintf(stderr, "-v         --verbose           Print some extra info to stderr\n");
    fprintf(stderr, "-h         --help              Print this message to stderr\n");
    fprintf(stderr, "\nA music output format (midge or musedata) must be supplied\n");
    exit(exitStatus);
}