decompiled_code:
__int64 __fastcall generate_method(__int64 a1)
{
__int64 v1; // rbx
_WORD *v2; // rax

v1 = get_current_classfile();
v2 = (_WORD *)add_definition(v1 + 64, v1 + 56, *(_QWORD *)a1, *(_QWORD *)(a1 + 8));
if ( **(_DWORD **)(a1 + 24) == 2 )
*v2 = 1;
return add_attribute_code(v2 + 4, v2 + 3, a1, *(unsigned __int16 *)(v1 + 26));
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
__int64 v1; // rbx
_WORD *v2; // rax

v1 = get_current_classfile();
v2 = (_WORD *)add_definition(v1 + 64, v1 + 56, *(_QWORD *)a1, *(_QWORD *)(a1 + 8));
if ( **(_DWORD **)(a1 + 24) == 2 )
*v2 = 1;
return add_attribute_code(v2 + 4, v2 + 3, a1, *(unsigned __int16 *)(v1 + 26));
}

original_code:
static void generate_method(FunctionDefinition *fd){
    ClassFile *cf;
    Definition *dn;
    cf = get_current_classfile();
    dn = add_definition(&(cf->methods), &(cf->methods_count), fd->name, fd->descriptor);
    if(fd->statement->type == CONSTRUCTOR_STATEMENT)
        dn->access_flags = ACC_PUBLIC;
    add_attribute_code(&(dn->attributes), &(dn->attributes_count), fd, cf->this_class_index);
}

canonical_original_code:
static void generate_method(struct FunctionDefinition_tag *fd){
    struct ClassFile *cf;
    struct Definition_tag *dn;
    cf = get_current_classfile();
    dn = add_definition(&(cf->methods), &(cf->methods_count), fd->name, fd->descriptor);
    if(fd->statement->type == CONSTRUCTOR_STATEMENT)
        dn->access_flags = ACC_PUBLIC;
    add_attribute_code(&(dn->attributes), &(dn->attributes_count), fd, cf->this_class_index);
}

variable_types: struct ClassFile { unsigned int magic; unsigned short minor_version; unsigned short major_version; unsigned short constant_pool_count; struct ConstantInfo_tag { enum ConstantInfoTag { CONSTANT_Utf8=1, CONSTANT_Integer=3, CONSTANT_Float=4, CONSTANT_Long=5, CONSTANT_Double=6, CONSTANT_Class=7, CONSTANT_String=8, CONSTANT_Fieldref=9, CONSTANT_Methodref=10, CONSTANT_InterfaceMethodref=11, CONSTANT_NameAndType=12 } tag; union { unsigned short cp_index; struct ReferenceInfo { unsigned short class_index; unsigned short name_and_type_index; } reference_info; unsigned int bytes; struct LongBytes { unsigned int high_bytes; unsigned int low_bytes; } long_bytes; struct NameAndTypeInfo { unsigned short name_index; unsigned short descriptor_index; } name_and_type_info; struct Utf8Info { unsigned short length; char *value; } utf8_info; } u; struct ConstantInfo_tag *prev; struct ConstantInfo_tag *next; } *constant_pool; unsigned short access_flags; unsigned short this_class_index; unsigned short super_class_index; unsigned short interfaces_count; struct Definition_tag { unsigned short access_flags; unsigned short name_index; unsigned short descriptor_index; unsigned short attributes_count; struct AttributeInfo_tag { enum AttributeTag { ATTRIBUTE_ConstantValue=1, ATTRIBUTE_Code=2, ATTRIBUTE_Exceptions=3, ATTRIBUTE_InnerClasses=4, ATTRIBUTE_Synthetic=5, ATTRIBUTE_SourceFile=6, ATTRIBUTE_LineNumberTable=7, ATTRIBUTE_LocalVariableTable=8, ATTRIBUTE_Deprecated=9 } tag; unsigned short attribute_name_index; unsigned int attribute_length; union { unsigned short cp_index; struct CodeAttribute { unsigned short max_stack; unsigned short max_locals; unsigned int code_length; struct Code_tag { enum CodeTag { CODE_OPERATOR=0, CODE_OPERAND_BYTE=1, CODE_OPERAND_SHORT=2 } tag; union { struct OpcodeInfo { unsigned char byte; char *mnemonic; unsigned char operand_count; char *operands_type; unsigned short max_stack; unsigned short max_locals; } *opcode; unsigned char operand_byte; unsigned short operand_short; } u; struct Code_tag *prev; struct Code_tag *next; } *code; unsigned short exception_table_length; struct Exception_tag { unsigned short start_pc; unsigned short end_pc; unsigned short handler_pc; unsigned short catch_type; struct Exception_tag *prev; struct Exception_tag *next; } *exception_table; unsigned short attributes_count; struct AttributeInfo_tag *attributes; unsigned short this_class_index; char *parameter_name; } code_attribute; struct ExceptionsAttribute { unsigned short number_of_exceptions; struct ExceptionIndex_tag { unsigned short exception_index; struct ExceptionIndex_tag *prev; struct ExceptionIndex_tag *next; } *exception_index_table; } exceptions_attribute; struct InnerClassesAttribute { unsigned short number_of_classes; struct InnerClass_tag { unsigned short inner_class_info_index; unsigned short outer_class_info_index; unsigned short inner_name_index; unsigned short inner_class_access_flags; } *classes; } inner_classes_attribute; unsigned char dummy; struct LineNumberTableAttribute { unsigned short line_number_table_length; struct LineNumber_tag { unsigned short start_pc; unsigned short line_number; struct LineNumber_tag *prev; struct LineNumber_tag *next; } *line_number_table; } line_number_table_attribute; struct LocalVariableTableAttribute { unsigned short local_variable_table_length; struct LocalVariable_tag { unsigned short start_pc; unsigned short length; unsigned short name_index; unsigned short descriptor_index; unsigned short index; struct LocalVariable_tag *prev; struct LocalVariable_tag *next; } *local_variable_table; } local_variable_table_attribute; } u; struct AttributeInfo_tag *prev; struct AttributeInfo_tag *next; } *attributes; struct Definition_tag *prev; struct Definition_tag *next; } *interfaces; unsigned short fields_count; struct Definition_tag *fields; unsigned short methods_count; struct Definition_tag *methods; unsigned short attributes_count; struct AttributeInfo_tag *source_file; char *emit_file; struct Storage { struct MemoryPage_tag { int cell_num; int use_cell_num; struct MemoryPage_tag *next; union Cell { long l_dummy; double d_dummy; void *p_dummy; } cell[1]; } *page_list; int current_page_size; } *classfile_storage; } *

user_defined_types: struct ClassFile { unsigned int magic; unsigned short minor_version; unsigned short major_version; unsigned short constant_pool_count; struct ConstantInfo_tag *constant_pool; unsigned short access_flags; unsigned short this_class_index; unsigned short super_class_index; unsigned short interfaces_count; struct Definition_tag *interfaces; unsigned short fields_count; struct Definition_tag *fields; unsigned short methods_count; struct Definition_tag *methods; unsigned short attributes_count; struct AttributeInfo_tag *source_file; char *emit_file; struct Storage *classfile_storage; }

user_defined_types: struct Definition_tag { unsigned short access_flags; unsigned short name_index; unsigned short descriptor_index; unsigned short attributes_count; struct AttributeInfo_tag *attributes; struct Definition_tag *prev; struct Definition_tag *next; }

user_defined_types: struct FunctionPattern_tag { int pattern; struct Statement *statement; struct FunctionPattern_tag *prev; struct FunctionPattern_tag *next; }

user_defined_types: struct ConstantInfo_tag { enum ConstantInfoTag tag; union { unsigned short cp_index; struct ReferenceInfo reference_info; unsigned int bytes; struct LongBytes long_bytes; struct NameAndTypeInfo name_and_type_info; struct Utf8Info utf8_info; } u; struct ConstantInfo_tag *prev; struct ConstantInfo_tag *next; }

user_defined_types: struct Storage { struct MemoryPage_tag *page_list; int current_page_size; }

user_defined_types: enum StatementType { NONE_TYPE_STATEMENT=0, MAIN_STATEMENT=1, CONSTRUCTOR_STATEMENT=2, FUNCTION_STATEMENT=3, FUNCTION_PATTERN_STATEMENT=4 }

user_defined_types: struct MemoryPage_tag { int cell_num; int use_cell_num; struct MemoryPage_tag *next; union Cell cell[1]; }

user_defined_types: struct ExceptionsAttribute { unsigned short number_of_exceptions; struct ExceptionIndex_tag *exception_index_table; }

user_defined_types: struct InnerClassesAttribute { unsigned short number_of_classes; struct InnerClass_tag *classes; }

user_defined_types: struct LineNumberTableAttribute { unsigned short line_number_table_length; struct LineNumber_tag *line_number_table; }

user_defined_types: enum ExpressionKind { INT_EXPRESSION=0, IDENTIFIER_EXPRESSION=1, BINARY_EXPRESSION=2, MINUS_EXPRESSION=3, CALL_EXPRESSION=4 }

user_defined_types: struct CallExpression { char *identifier; struct Expression_tag *parameter_expression; }

user_defined_types: enum OperatorKind { ADD_OPERATOR=0, SUB_OPERATOR=1, MUL_OPERATOR=2, DIV_OPERATOR=3, MOD_OPERATOR=4 }


generate

repo: demmys/desk

decompiled_code:
__int64 __fastcall generate(__int64 a1)
{
__int64 v1; // r12

v1 = create_class_file();
generate_class_information_constprop_0(*(const char **)(a1 + 24));
generate_class_methods_isra_0(*(_QWORD *)(a1 + 8));
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
__int64 v1; // r12

v1 = create_class_file();
func2(*(const char **)(a1 + 24));
func3(*(_QWORD *)(a1 + 8));
return v1;
}

original_code:
ClassFile *generate(Compiler *compiler){
    ClassFile *cf;
    cf = create_class_file();
    generate_class_information(compiler->source_file, "java/lang/Object");
    generate_class_methods(compiler);
    return cf;
}

canonical_original_code:
struct ClassFile *generate(struct Compiler *compiler){
    struct ClassFile *cf;
    cf = create_class_file();
    generate_class_information(compiler->source_file, "java/lang/Object");
    generate_class_methods(compiler);
    return cf;
}

variable_types: struct Compiler { int function_count; struct FunctionDefinition_tag { char *name; char *descriptor; char *parameter_name; struct Statement { enum StatementType { NONE_TYPE_STATEMENT=0, MAIN_STATEMENT=1, CONSTRUCTOR_STATEMENT=2, FUNCTION_STATEMENT=3, FUNCTION_PATTERN_STATEMENT=4 } type; int line_number; struct Expression_tag { enum ExpressionKind { INT_EXPRESSION=0, IDENTIFIER_EXPRESSION=1, BINARY_EXPRESSION=2, MINUS_EXPRESSION=3, CALL_EXPRESSION=4 } kind; int line_number; union { int int_value; char *identifier; struct BinaryExpression { enum OperatorKind { ADD_OPERATOR=0, SUB_OPERATOR=1, MUL_OPERATOR=2, DIV_OPERATOR=3, MOD_OPERATOR=4 } kind; struct Expression_tag *left; struct Expression_tag *right; } binary_expression; struct Expression_tag *minus_expression; struct CallExpression { char *identifier; struct Expression_tag *parameter_expression; } call_expression; } u; } *expression; } *statement; struct FunctionPattern_tag { int pattern; struct Statement *statement; struct FunctionPattern_tag *prev; struct FunctionPattern_tag *next; } *pattern_list; struct FunctionDefinition_tag *prev; struct FunctionDefinition_tag *next; } *function_list; int current_line_number; char *source_file; struct Storage *compile_storage; } *

return_type: struct ClassFile { unsigned int magic; unsigned short minor_version; unsigned short major_version; unsigned short constant_pool_count; struct ConstantInfo_tag { enum ConstantInfoTag { CONSTANT_Utf8=1, CONSTANT_Integer=3, CONSTANT_Float=4, CONSTANT_Long=5, CONSTANT_Double=6, CONSTANT_Class=7, CONSTANT_String=8, CONSTANT_Fieldref=9, CONSTANT_Methodref=10, CONSTANT_InterfaceMethodref=11, CONSTANT_NameAndType=12 } tag; union { unsigned short cp_index; struct ReferenceInfo { unsigned short class_index; unsigned short name_and_type_index; } reference_info; unsigned int bytes; struct LongBytes { unsigned int high_bytes; unsigned int low_bytes; } long_bytes; struct NameAndTypeInfo { unsigned short name_index; unsigned short descriptor_index; } name_and_type_info; struct Utf8Info { unsigned short length; char *value; } utf8_info; } u; struct ConstantInfo_tag *prev; struct ConstantInfo_tag *next; } *constant_pool; unsigned short access_flags; unsigned short this_class_index; unsigned short super_class_index; unsigned short interfaces_count; struct Definition_tag { unsigned short access_flags; unsigned short name_index; unsigned short descriptor_index; unsigned short attributes_count; struct AttributeInfo_tag { enum AttributeTag { ATTRIBUTE_ConstantValue=1, ATTRIBUTE_Code=2, ATTRIBUTE_Exceptions=3, ATTRIBUTE_InnerClasses=4, ATTRIBUTE_Synthetic=5, ATTRIBUTE_SourceFile=6, ATTRIBUTE_LineNumberTable=7, ATTRIBUTE_LocalVariableTable=8, ATTRIBUTE_Deprecated=9 } tag; unsigned short attribute_name_index; unsigned int attribute_length; union { unsigned short cp_index; struct CodeAttribute { unsigned short max_stack; unsigned short max_locals; unsigned int code_length; struct Code_tag { enum CodeTag { CODE_OPERATOR=0, CODE_OPERAND_BYTE=1, CODE_OPERAND_SHORT=2 } tag; union { struct OpcodeInfo { unsigned char byte; char *mnemonic; unsigned char operand_count; char *operands_type; unsigned short max_stack; unsigned short max_locals; } *opcode; unsigned char operand_byte; unsigned short operand_short; } u; struct Code_tag *prev; struct Code_tag *next; } *code; unsigned short exception_table_length; struct Exception_tag { unsigned short start_pc; unsigned short end_pc; unsigned short handler_pc; unsigned short catch_type; struct Exception_tag *prev; struct Exception_tag *next; } *exception_table; unsigned short attributes_count; struct AttributeInfo_tag *attributes; unsigned short this_class_index; char *parameter_name; } code_attribute; struct ExceptionsAttribute { unsigned short number_of_exceptions; struct ExceptionIndex_tag { unsigned short exception_index; struct ExceptionIndex_tag *prev; struct ExceptionIndex_tag *next; } *exception_index_table; } exceptions_attribute; struct InnerClassesAttribute { unsigned short number_of_classes; struct InnerClass_tag { unsigned short inner_class_info_index; unsigned short outer_class_info_index; unsigned short inner_name_index; unsigned short inner_class_access_flags; } *classes; } inner_classes_attribute; unsigned char dummy; struct LineNumberTableAttribute { unsigned short line_number_table_length; struct LineNumber_tag { unsigned short start_pc; unsigned short line_number; struct LineNumber_tag *prev; struct LineNumber_tag *next; } *line_number_table; } line_number_table_attribute; struct LocalVariableTableAttribute { unsigned short local_variable_table_length; struct LocalVariable_tag { unsigned short start_pc; unsigned short length; unsigned short name_index; unsigned short descriptor_index; unsigned short index; struct LocalVariable_tag *prev; struct LocalVariable_tag *next; } *local_variable_table; } local_variable_table_attribute; } u; struct AttributeInfo_tag *prev; struct AttributeInfo_tag *next; } *attributes; struct Definition_tag *prev; struct Definition_tag *next; } *interfaces; unsigned short fields_count; struct Definition_tag *fields; unsigned short methods_count; struct Definition_tag *methods; unsigned short attributes_count; struct AttributeInfo_tag *source_file; char *emit_file; struct Storage { struct MemoryPage_tag { int cell_num; int use_cell_num; struct MemoryPage_tag *next; union Cell { long l_dummy; double d_dummy; void *p_dummy; } cell[1]; } *page_list; int current_page_size; } *classfile_storage; } *

user_defined_types: struct Compiler { int function_count; struct FunctionDefinition_tag *function_list; int current_line_number; char *source_file; struct Storage *compile_storage; }

user_defined_types: struct FunctionDefinition_tag { char *name; char *descriptor; char *parameter_name; struct Statement *statement; struct FunctionPattern_tag *pattern_list; struct FunctionDefinition_tag *prev; struct FunctionDefinition_tag *next; }

user_defined_types: struct Statement { enum StatementType type; int line_number; struct Expression_tag *expression; }

user_defined_types: struct AttributeInfo_tag { enum AttributeTag tag; unsigned short attribute_name_index; unsigned int attribute_length; union { unsigned short cp_index; struct CodeAttribute code_attribute; struct ExceptionsAttribute exceptions_attribute; struct InnerClassesAttribute inner_classes_attribute; unsigned char dummy; struct LineNumberTableAttribute line_number_table_attribute; struct LocalVariableTableAttribute local_variable_table_attribute; } u; struct AttributeInfo_tag *prev; struct AttributeInfo_tag *next; }

user_defined_types: struct Expression_tag { enum ExpressionKind kind; int line_number; union { int int_value; char *identifier; struct BinaryExpression binary_expression; struct Expression_tag *minus_expression; struct CallExpression call_expression; } u; }

user_defined_types: struct CodeAttribute { unsigned short max_stack; unsigned short max_locals; unsigned int code_length; struct Code_tag *code; unsigned short exception_table_length; struct Exception_tag *exception_table; unsigned short attributes_count; struct AttributeInfo_tag *attributes; unsigned short this_class_index; char *parameter_name; }

user_defined_types: struct LocalVariableTableAttribute { unsigned short local_variable_table_length; struct LocalVariable_tag *local_variable_table; }

user_defined_types: struct BinaryExpression { enum OperatorKind kind; struct Expression_tag *left; struct Expression_tag *right; }

user_defined_types: struct Code_tag { enum CodeTag tag; union { struct OpcodeInfo *opcode; unsigned char operand_byte; unsigned short operand_short; } u; struct Code_tag *prev; struct Code_tag *next; }


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

result = _byteswap_ulong(*a1);
*a1 = result;
return result;
}

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

result = _byteswap_ulong(*a1);
*a1 = result;
return result;
}

canonical_original_code:
static void swap32(unsigned int *value){
    unsigned int val = *value;
    *value = (val << 24) | ((val << 8) & 0xff0000) | ((val >> 8) & 0xff00) | ((val >> 24) & 0xff);
}

variable_types:
value
unsigned int *

variable_types:
val
unsigned int

return_type: void


decompiled_code:
size_t __fastcall emit_class_file(const void *a1, size_t a2)
{
return fwrite(a1, 1uLL, a2, fp);
}

canonical_decompiled_code:
size_t __fastcall func2(const void *a1, size_t a2)
{
return fwrite(a1, 1uLL, a2, fp);
}

original_code:
static void emit_class_file(void *p, size_t length){
    fwrite(p, sizeof(u1), length, fp);
}

canonical_original_code:
static void emit_class_file(void *p, unsigned long length){
    fwrite(p, sizeof(u1), length, fp);
}

variable_types:
p
void *

variable_types:
length
unsigned long


decompiled_code:
size_t __fastcall emit_prefixes(__int64 a1)
{
__int64 v1; // r8
const void *v2; // r8

swap32((unsigned int *)a1);
swap16((_WORD *)(a1 + 4));
swap16((_WORD *)(v1 + 6));
return emit_class_file(v2, 8uLL);
}

canonical_decompiled_code:
size_t __fastcall func3(__int64 a1)
{
__int64 v1; // r8
const void *v2; // r8

func1((unsigned int *)a1);
func0((_WORD *)(a1 + 4));
func0((_WORD *)(v1 + 6));
return func2(v2, 8uLL);
}

original_code:
static void emit_prefixes(ClassFile *cf){
    swap32(&(cf->magic));
    swap16(&(cf->minor_version));
    swap16(&(cf->major_version));
    emit_class_file(cf, 8);
}

canonical_original_code:
static void emit_prefixes(struct ClassFile *cf){
    swap32(&(cf->magic));
    swap16(&(cf->minor_version));
    swap16(&(cf->major_version));
    emit_class_file(cf, 8);
}

user_defined_types: struct ClassFile { unsigned int magic; unsigned short minor_version; unsigned short major_version; unsigned short constant_pool_count; struct ConstantInfo_tag *constant_pool; unsigned short access_flags; unsigned short this_class_index; unsigned short super_class_index; unsigned short interfaces_count; struct Definition_tag *interfaces; unsigned short fields_count; struct Definition_tag *fields; unsigned short methods_count; struct Definition_tag *methods; unsigned short attributes_count; struct AttributeInfo_tag *source_file; char *emit_file; struct Storage *classfile_storage; }

user_defined_types: struct ConstantInfo_tag { enum ConstantInfoTag tag; union { unsigned short cp_index; struct ReferenceInfo reference_info; unsigned int bytes; struct LongBytes long_bytes; struct NameAndTypeInfo name_and_type_info; struct Utf8Info utf8_info; } u; struct ConstantInfo_tag *prev; struct ConstantInfo_tag *next; }

user_defined_types: struct Definition_tag { unsigned short access_flags; unsigned short name_index; unsigned short descriptor_index; unsigned short attributes_count; struct AttributeInfo_tag *attributes; struct Definition_tag *prev; struct Definition_tag *next; }

user_defined_types: struct Storage { struct MemoryPage_tag *page_list; int current_page_size; }

user_defined_types: enum ConstantInfoTag { CONSTANT_Utf8=1, CONSTANT_Integer=3, CONSTANT_Float=4, CONSTANT_Long=5, CONSTANT_Double=6, CONSTANT_Class=7, CONSTANT_String=8, CONSTANT_Fieldref=9, CONSTANT_Methodref=10, CONSTANT_InterfaceMethodref=11, CONSTANT_NameAndType=12 }

user_defined_types: struct ReferenceInfo { unsigned short class_index; unsigned short name_and_type_index; }

user_defined_types: struct LongBytes { unsigned int high_bytes; unsigned int low_bytes; }

user_defined_types: struct NameAndTypeInfo { unsigned short name_index; unsigned short descriptor_index; }

user_defined_types: struct Utf8Info { unsigned short length; char *value; }

user_defined_types: enum AttributeTag { ATTRIBUTE_ConstantValue=1, ATTRIBUTE_Code=2, ATTRIBUTE_Exceptions=3, ATTRIBUTE_InnerClasses=4, ATTRIBUTE_Synthetic=5, ATTRIBUTE_SourceFile=6, ATTRIBUTE_LineNumberTable=7, ATTRIBUTE_LocalVariableTable=8, ATTRIBUTE_Deprecated=9 }

user_defined_types: union Cell { long l_dummy; double d_dummy; void *p_dummy; }

user_defined_types: struct Exception_tag { unsigned short start_pc; unsigned short end_pc; unsigned short handler_pc; unsigned short catch_type; struct Exception_tag *prev; struct Exception_tag *next; }

user_defined_types: struct ExceptionIndex_tag { unsigned short exception_index; struct ExceptionIndex_tag *prev; struct ExceptionIndex_tag *next; }

user_defined_types: struct InnerClass_tag { unsigned short inner_class_info_index; unsigned short outer_class_info_index; unsigned short inner_name_index; unsigned short inner_class_access_flags; }

user_defined_types: struct LineNumber_tag { unsigned short start_pc; unsigned short line_number; struct LineNumber_tag *prev; struct LineNumber_tag *next; }

user_defined_types: struct LocalVariable_tag { unsigned short start_pc; unsigned short length; unsigned short name_index; unsigned short descriptor_index; unsigned short index; struct LocalVariable_tag *prev; struct LocalVariable_tag *next; }

user_defined_types: enum CodeTag { CODE_OPERATOR=0, CODE_OPERAND_BYTE=1, CODE_OPERAND_SHORT=2 }

user_defined_types: struct OpcodeInfo { unsigned char byte; char *mnemonic; unsigned char operand_count; char *operands_type; unsigned short max_stack; unsigned short max_locals; }


decompiled_code:
size_t __fastcall emit_constant_pool(const void **a1, _WORD *a2)
{
const void **v2; // rbx
size_t result; // rax
const void *v4; // r8
unsigned __int16 v5; // bp

v2 = a1;
++*a2;
swap16(a2);
result = emit_class_file(a2, 2uLL);
if ( a1 )
{
do
{
while ( 1 )
{
emit_class_file(v2, 1uLL);
result = *(unsigned int *)v2;
if ( (unsigned int)result <= 0xC )
break;
LABEL_6:
v2 = (const void **)v2[4];
if ( !v2 )
return result;
}
if ( (unsigned int)result <= 8 )
{
if ( (_DWORD)result == 1 )
{
v5 = *((_WORD *)v2 + 4);
swap16((_WORD *)v2 + 4);
emit_class_file(v2 + 1, 2uLL);
result = emit_class_file(v2[2], v5);
}
else if ( (_DWORD)result == 7 )
{
swap16((_WORD *)v2 + 4);
result = emit_class_file(v2 + 1, 2uLL);
}
goto LABEL_6;
}
swap16((_WORD *)v2 + 4);
swap16((_WORD *)v2 + 5);
result = emit_class_file(v4, 4uLL);
v2 = (const void **)v2[4];
}
while ( v2 );
}
return result;
}

canonical_decompiled_code:
size_t __fastcall func4(const void **a1, _WORD *a2)
{
const void **v2; // rbx
size_t result; // rax
const void *v4; // r8
unsigned __int16 v5; // bp

v2 = a1;
++*a2;
func0(a2);
result = func2(a2, 2uLL);
if ( a1 )
{
do
{
while ( 1 )
{
func2(v2, 1uLL);
result = *(unsigned int *)v2;
if ( (unsigned int)result <= 0xC )
break;
LABEL_6:
v2 = (const void **)v2[4];
if ( !v2 )
return result;
}
if ( (unsigned int)result <= 8 )
{
if ( (_DWORD)result == 1 )
{
v5 = *((_WORD *)v2 + 4);
func0((_WORD *)v2 + 4);
func2(v2 + 1, 2uLL);
result = func2(v2[2], v5);
}
else if ( (_DWORD)result == 7 )
{
func0((_WORD *)v2 + 4);
result = func2(v2 + 1, 2uLL);
}
goto LABEL_6;
}
func0((_WORD *)v2 + 4);
func0((_WORD *)v2 + 5);
result = func2(v4, 4uLL);
v2 = (const void **)v2[4];
}
while ( v2 );
}
return result;
}

original_code:
static void emit_constant_pool(ConstantInfo *ci, u2 *count){
    u2 len;
    (*count)++;
    swap16(count);
    emit_class_file(count, 2);
    while(ci){
        emit_class_file(&(ci->tag), 1);
        switch(ci->tag){
            case CONSTANT_Class:
                swap16(&(ci->u.cp_index));
                emit_class_file(&(ci->u.cp_index), 2);
                break;
            case CONSTANT_Fieldref:
            case CONSTANT_Methodref:
            case CONSTANT_InterfaceMethodref:
                swap16(&(ci->u.reference_info.class_index));
                swap16(&(ci->u.reference_info.name_and_type_index));
                emit_class_file(&(ci->u.reference_info), 4);
                break;
            case CONSTANT_NameAndType:
                swap16(&(ci->u.name_and_type_info.name_index));
                swap16(&(ci->u.name_and_type_info.descriptor_index));
                emit_class_file(&(ci->u.name_and_type_info), 4);
                break;
            case CONSTANT_Utf8:
                len = ci->u.utf8_info.length;
                swap16(&(ci->u.utf8_info.length));
                emit_class_file(&(ci->u.utf8_info.length), 2);
                emit_class_file((void *)ci->u.utf8_info.value, len);
                break;
            case CONSTANT_String:
            case CONSTANT_Integer:
            case CONSTANT_Float:
            case CONSTANT_Long:
            case CONSTANT_Double:
            default:
                break;
        }
        ci = ci->next;
    }
}

canonical_original_code:
static void emit_constant_pool(struct ConstantInfo_tag *ci, unsigned short *count){
    unsigned short len;
    (*count)++;
    swap16(count);
    emit_class_file(count, 2);
    while(ci){
        emit_class_file(&(ci->tag), 1);
        switch(ci->tag){
            case CONSTANT_Class:
                swap16(&(ci->u.cp_index));
                emit_class_file(&(ci->u.cp_index), 2);
                break;
            case CONSTANT_Fieldref:
            case CONSTANT_Methodref:
            case CONSTANT_InterfaceMethodref:
                swap16(&(ci->u.reference_info.class_index));
                swap16(&(ci->u.reference_info.name_and_type_index));
                emit_class_file(&(ci->u.reference_info), 4);
                break;
            case CONSTANT_NameAndType:
                swap16(&(ci->u.name_and_type_info.name_index));
                swap16(&(ci->u.name_and_type_info.descriptor_index));
                emit_class_file(&(ci->u.name_and_type_info), 4);
                break;
            case CONSTANT_Utf8:
                len = ci->u.utf8_info.length;
                swap16(&(ci->u.utf8_info.length));
                emit_class_file(&(ci->u.utf8_info.length), 2);
                emit_class_file((void *)ci->u.utf8_info.value, len);
                break;
            case CONSTANT_String:
            case CONSTANT_Integer:
            case CONSTANT_Float:
            case CONSTANT_Long:
            case CONSTANT_Double:
            default:
                break;
        }
        ci = ci->next;
    }
}

variable_types: struct ConstantInfo_tag { enum ConstantInfoTag { CONSTANT_Utf8=1, CONSTANT_Integer=3, CONSTANT_Float=4, CONSTANT_Long=5, CONSTANT_Double=6, CONSTANT_Class=7, CONSTANT_String=8, CONSTANT_Fieldref=9, CONSTANT_Methodref=10, CONSTANT_InterfaceMethodref=11, CONSTANT_NameAndType=12 } tag; union { unsigned short cp_index; struct ReferenceInfo { unsigned short class_index; unsigned short name_and_type_index; } reference_info; unsigned int bytes; struct LongBytes { unsigned int high_bytes; unsigned int low_bytes; } long_bytes; struct NameAndTypeInfo { unsigned short name_index; unsigned short descriptor_index; } name_and_type_info; struct Utf8Info { unsigned short length; char *value; } utf8_info; } u; struct ConstantInfo_tag *prev; struct ConstantInfo_tag *next; } *

variable_types:
count
unsigned short *

variable_types:
len
unsigned short

user_defined_types: struct ConstantInfo_tag { enum ConstantInfoTag tag; union { unsigned short cp_index; struct ReferenceInfo reference_info; unsigned int bytes; struct LongBytes long_bytes; struct NameAndTypeInfo name_and_type_info; struct Utf8Info utf8_info; } u; struct ConstantInfo_tag *prev; struct ConstantInfo_tag *next; }


decompiled_code:
size_t __fastcall emit_middles(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rax
const void *v3; // r8

swap16((_WORD *)(a1 + 24));
swap16((_WORD *)(v1 + 26));
swap16((_WORD *)(v2 + 28));
return emit_class_file(v3, 6uLL);
}

canonical_decompiled_code:
size_t __fastcall func5(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rax
const void *v3; // r8

func0((_WORD *)(a1 + 24));
func0((_WORD *)(v1 + 26));
func0((_WORD *)(v2 + 28));
return func2(v3, 6uLL);
}

original_code:
static void emit_middles(ClassFile *cf){
    swap16(&(cf->access_flags));
    swap16(&(cf->this_class_index));
    swap16(&(cf->super_class_index));
    emit_class_file(&(cf->access_flags), 6);
}

canonical_original_code:
static void emit_middles(struct ClassFile *cf){
    swap16(&(cf->access_flags));
    swap16(&(cf->this_class_index));
    swap16(&(cf->super_class_index));
    emit_class_file(&(cf->access_flags), 6);
}

user_defined_types: struct ClassFile { unsigned int magic; unsigned short minor_version; unsigned short major_version; unsigned short constant_pool_count; struct ConstantInfo_tag *constant_pool; unsigned short access_flags; unsigned short this_class_index; unsigned short super_class_index; unsigned short interfaces_count; struct Definition_tag *interfaces; unsigned short fields_count; struct Definition_tag *fields; unsigned short methods_count; struct Definition_tag *methods; unsigned short attributes_count; struct AttributeInfo_tag *source_file; char *emit_file; struct Storage *classfile_storage; }

user_defined_types: struct Definition_tag { unsigned short access_flags; unsigned short name_index; unsigned short descriptor_index; unsigned short attributes_count; struct AttributeInfo_tag *attributes; struct Definition_tag *prev; struct Definition_tag *next; }

user_defined_types: struct AttributeInfo_tag { enum AttributeTag tag; unsigned short attribute_name_index; unsigned int attribute_length; union { unsigned short cp_index; struct CodeAttribute code_attribute; struct ExceptionsAttribute exceptions_attribute; struct InnerClassesAttribute inner_classes_attribute; unsigned char dummy; struct LineNumberTableAttribute line_number_table_attribute; struct LocalVariableTableAttribute local_variable_table_attribute; } u; struct AttributeInfo_tag *prev; struct AttributeInfo_tag *next; }

user_defined_types: struct MemoryPage_tag { int cell_num; int use_cell_num; struct MemoryPage_tag *next; union Cell cell[1]; }

user_defined_types: struct CodeAttribute { unsigned short max_stack; unsigned short max_locals; unsigned int code_length; struct Code_tag *code; unsigned short exception_table_length; struct Exception_tag *exception_table; unsigned short attributes_count; struct AttributeInfo_tag *attributes; unsigned short this_class_index; char *parameter_name; }

user_defined_types: struct ExceptionsAttribute { unsigned short number_of_exceptions; struct ExceptionIndex_tag *exception_index_table; }

user_defined_types: struct InnerClassesAttribute { unsigned short number_of_classes; struct InnerClass_tag *classes; }

user_defined_types: struct LineNumberTableAttribute { unsigned short line_number_table_length; struct LineNumber_tag *line_number_table; }

user_defined_types: struct LocalVariableTableAttribute { unsigned short local_variable_table_length; struct LocalVariable_tag *local_variable_table; }

user_defined_types: struct Code_tag { enum CodeTag tag; union { struct OpcodeInfo *opcode; unsigned char operand_byte; unsigned short operand_short; } u; struct Code_tag *prev; struct Code_tag *next; }


decompiled_code:
void __fastcall emit_codes(int *a1)
{
int *v1; // rbx
int v2; // eax

if ( a1 )
{
v1 = a1;
do
{
while ( 1 )
{
v2 = *v1;
if ( *v1 != 1 )
break;
emit_class_file(v1 + 2, 1uLL);
LABEL_5:
v1 = (int *)*((_QWORD *)v1 + 3);
if ( !v1 )
return;
}
if ( v2 != 2 )
{
if ( !v2 )
emit_class_file(*((const void **)v1 + 1), 1uLL);
goto LABEL_5;
}
swap16((_WORD *)v1 + 4);
emit_class_file(v1 + 2, 2uLL);
v1 = (int *)*((_QWORD *)v1 + 3);
}
while ( v1 );
}
}

canonical_decompiled_code:
void __fastcall func6(int *a1)
{
int *v1; // rbx
int v2; // eax

if ( a1 )
{
v1 = a1;
do
{
while ( 1 )
{
v2 = *v1;
if ( *v1 != 1 )
break;
func2(v1 + 2, 1uLL);
LABEL_5:
v1 = (int *)*((_QWORD *)v1 + 3);
if ( !v1 )
return;
}
if ( v2 != 2 )
{
if ( !v2 )
func2(*((const void **)v1 + 1), 1uLL);
goto LABEL_5;
}
func0((_WORD *)v1 + 4);
func2(v1 + 2, 2uLL);
v1 = (int *)*((_QWORD *)v1 + 3);
}
while ( v1 );
}
}

original_code:
static void emit_codes(Code *c){
    while(c){
        switch(c->tag){
            case CODE_OPERAND_BYTE:
                emit_class_file(&(c->u.operand_byte), 1);
                break;
            case CODE_OPERAND_SHORT:
                swap16(&(c->u.operand_short));
                emit_class_file(&(c->u.operand_short), 2);
                break;
            case CODE_OPERATOR:
                emit_class_file(&(c->u.opcode->byte), 1);
        }
        c = c->next;
    }
}

canonical_original_code:
static void emit_codes(struct Code_tag *c){
    while(c){
        switch(c->tag){
            case CODE_OPERAND_BYTE:
                emit_class_file(&(c->u.operand_byte), 1);
                break;
            case CODE_OPERAND_SHORT:
                swap16(&(c->u.operand_short));
                emit_class_file(&(c->u.operand_short), 2);
                break;
            case CODE_OPERATOR:
                emit_class_file(&(c->u.opcode->byte), 1);
        }
        c = c->next;
    }
}

variable_types: struct Code_tag { enum CodeTag { CODE_OPERATOR=0, CODE_OPERAND_BYTE=1, CODE_OPERAND_SHORT=2 } tag; union { struct OpcodeInfo { unsigned char byte; char *mnemonic; unsigned char operand_count; char *operands_type; unsigned short max_stack; unsigned short max_locals; } *opcode; unsigned char operand_byte; unsigned short operand_short; } u; struct Code_tag *prev; struct Code_tag *next; } *


decompiled_code:
__int64 __fastcall emit_code_attribute(__int64 a1)
{
_WORD *v2; // rdi

swap16((_WORD *)a1);
swap16((_WORD *)(a1 + 2));
swap32((unsigned int *)(a1 + 4));
emit_class_file((const void *)a1, 8uLL);
emit_codes(*(int **)(a1 + 8));
v2 = (_WORD *)(a1 + 16);
swap16(v2);
emit_class_file(v2, 2uLL);
return emit_attributes(*(_QWORD *)(a1 + 40), a1 + 32);
}

original_code:
static void emit_code_attribute(CodeAttribute *ca){
    swap16(&(ca->max_stack));
    swap16(&(ca->max_locals));
    swap32(&(ca->code_length));
    emit_class_file(ca, 8);
    emit_codes(ca->code);
    swap16(&(ca->exception_table_length));
    emit_class_file(&(ca->exception_table_length), 2);
    emit_attributes(ca->attributes, &(ca->attributes_count));
}

canonical_original_code:
static void emit_code_attribute(struct CodeAttribute *ca){
    swap16(&(ca->max_stack));
    swap16(&(ca->max_locals));
    swap32(&(ca->code_length));
    emit_class_file(ca, 8);
    emit_codes(ca->code);
    swap16(&(ca->exception_table_length));
    emit_class_file(&(ca->exception_table_length), 2);
    emit_attributes(ca->attributes, &(ca->attributes_count));
}

variable_types: struct CodeAttribute { unsigned short max_stack; unsigned short max_locals; unsigned int code_length; struct Code_tag { enum CodeTag { CODE_OPERATOR=0, CODE_OPERAND_BYTE=1, CODE_OPERAND_SHORT=2 } tag; union { struct OpcodeInfo { unsigned char byte; char *mnemonic; unsigned char operand_count; char *operands_type; unsigned short max_stack; unsigned short max_locals; } *opcode; unsigned char operand_byte; unsigned short operand_short; } u; struct Code_tag *prev; struct Code_tag *next; } *code; unsigned short exception_table_length; struct Exception_tag { unsigned short start_pc; unsigned short end_pc; unsigned short handler_pc; unsigned short catch_type; struct Exception_tag *prev; struct Exception_tag *next; } *exception_table; unsigned short attributes_count; struct AttributeInfo_tag { enum AttributeTag { ATTRIBUTE_ConstantValue=1, ATTRIBUTE_Code=2, ATTRIBUTE_Exceptions=3, ATTRIBUTE_InnerClasses=4, ATTRIBUTE_Synthetic=5, ATTRIBUTE_SourceFile=6, ATTRIBUTE_LineNumberTable=7, ATTRIBUTE_LocalVariableTable=8, ATTRIBUTE_Deprecated=9 } tag; unsigned short attribute_name_index; unsigned int attribute_length; union { unsigned short cp_index; struct CodeAttribute code_attribute; struct ExceptionsAttribute { unsigned short number_of_exceptions; struct ExceptionIndex_tag { unsigned short exception_index; struct ExceptionIndex_tag *prev; struct ExceptionIndex_tag *next; } *exception_index_table; } exceptions_attribute; struct InnerClassesAttribute { unsigned short number_of_classes; struct InnerClass_tag { unsigned short inner_class_info_index; unsigned short outer_class_info_index; unsigned short inner_name_index; unsigned short inner_class_access_flags; } *classes; } inner_classes_attribute; unsigned char dummy; struct LineNumberTableAttribute { unsigned short line_number_table_length; struct LineNumber_tag { unsigned short start_pc; unsigned short line_number; struct LineNumber_tag *prev; struct LineNumber_tag *next; } *line_number_table; } line_number_table_attribute; struct LocalVariableTableAttribute { unsigned short local_variable_table_length; struct LocalVariable_tag { unsigned short start_pc; unsigned short length; unsigned short name_index; unsigned short descriptor_index; unsigned short index; struct LocalVariable_tag *prev; struct LocalVariable_tag *next; } *local_variable_table; } local_variable_table_attribute; } u; struct AttributeInfo_tag *prev; struct AttributeInfo_tag *next; } *attributes; unsigned short this_class_index; char *parameter_name; } *


decompiled_code:
size_t __fastcall emit_attributes(unsigned int *a1, _WORD *a2)
{
unsigned int *v2; // rbx
size_t result; // rax
const void *v4; // r8

v2 = a1;
swap16(a2);
result = emit_class_file(a2, 2uLL);
if ( a1 )
{
do
{
while ( 1 )
{
swap16((_WORD *)v2 + 2);
swap32(v2 + 2);
emit_class_file(v4, 2uLL);
emit_class_file(v2 + 2, 4uLL);
result = *v2;
if ( (_DWORD)result != 2 )
break;
result = emit_code_attribute((__int64)(v2 + 4));
v2 = (unsigned int *)*((_QWORD *)v2 + 11);
if ( !v2 )
return result;
}
if ( (_DWORD)result == 6 || (_DWORD)result == 1 )
{
swap16((_WORD *)v2 + 8);
result = emit_class_file(v2 + 4, 2uLL);
}
v2 = (unsigned int *)*((_QWORD *)v2 + 11);
}
while ( v2 );
}
return result;
}

canonical_decompiled_code:
size_t __fastcall func8(unsigned int *a1, _WORD *a2)
{
unsigned int *v2; // rbx
size_t result; // rax
const void *v4; // r8

v2 = a1;
func0(a2);
result = func2(a2, 2uLL);
if ( a1 )
{
do
{
while ( 1 )
{
func0((_WORD *)v2 + 2);
func1(v2 + 2);
func2(v4, 2uLL);
func2(v2 + 2, 4uLL);
result = *v2;
if ( (_DWORD)result != 2 )
break;
result = func7((__int64)(v2 + 4));
v2 = (unsigned int *)*((_QWORD *)v2 + 11);
if ( !v2 )
return result;
}
if ( (_DWORD)result == 6 || (_DWORD)result == 1 )
{
func0((_WORD *)v2 + 8);
result = func2(v2 + 4, 2uLL);
}
v2 = (unsigned int *)*((_QWORD *)v2 + 11);
}
while ( v2 );
}
return result;
}

original_code:
static void emit_attributes(AttributeInfo *ai, u2 *count){
    swap16(count);
    emit_class_file(count, 2);
    while(ai){
        swap16(&(ai->attribute_name_index));
        swap32(&(ai->attribute_length));
        emit_class_file(&(ai->attribute_name_index), 2);
        emit_class_file(&(ai->attribute_length), 4);
        switch(ai->tag){
            case ATTRIBUTE_Code:
                emit_code_attribute(&(ai->u.code_attribute));
                break;
            case ATTRIBUTE_ConstantValue:
            case ATTRIBUTE_SourceFile:
                swap16(&(ai->u.cp_index));
                emit_class_file(&(ai->u.cp_index), 2);
                break;
            default:
                break;
        }
        ai = ai->next;
    }
}

canonical_original_code:
static void emit_attributes(struct AttributeInfo_tag *ai, unsigned short *count){
    swap16(count);
    emit_class_file(count, 2);
    while(ai){
        swap16(&(ai->attribute_name_index));
        swap32(&(ai->attribute_length));
        emit_class_file(&(ai->attribute_name_index), 2);
        emit_class_file(&(ai->attribute_length), 4);
        switch(ai->tag){
            case ATTRIBUTE_Code:
                emit_code_attribute(&(ai->u.code_attribute));
                break;
            case ATTRIBUTE_ConstantValue:
            case ATTRIBUTE_SourceFile:
                swap16(&(ai->u.cp_index));
                emit_class_file(&(ai->u.cp_index), 2);
                break;
            default:
                break;
        }
        ai = ai->next;
    }
}

variable_types: struct AttributeInfo_tag { enum AttributeTag { ATTRIBUTE_ConstantValue=1, ATTRIBUTE_Code=2, ATTRIBUTE_Exceptions=3, ATTRIBUTE_InnerClasses=4, ATTRIBUTE_Synthetic=5, ATTRIBUTE_SourceFile=6, ATTRIBUTE_LineNumberTable=7, ATTRIBUTE_LocalVariableTable=8, ATTRIBUTE_Deprecated=9 } tag; unsigned short attribute_name_index; unsigned int attribute_length; union { unsigned short cp_index; struct CodeAttribute { unsigned short max_stack; unsigned short max_locals; unsigned int code_length; struct Code_tag { enum CodeTag { CODE_OPERATOR=0, CODE_OPERAND_BYTE=1, CODE_OPERAND_SHORT=2 } tag; union { struct OpcodeInfo { unsigned char byte; char *mnemonic; unsigned char operand_count; char *operands_type; unsigned short max_stack; unsigned short max_locals; } *opcode; unsigned char operand_byte; unsigned short operand_short; } u; struct Code_tag *prev; struct Code_tag *next; } *code; unsigned short exception_table_length; struct Exception_tag { unsigned short start_pc; unsigned short end_pc; unsigned short handler_pc; unsigned short catch_type; struct Exception_tag *prev; struct Exception_tag *next; } *exception_table; unsigned short attributes_count; struct AttributeInfo_tag *attributes; unsigned short this_class_index; char *parameter_name; } code_attribute; struct ExceptionsAttribute { unsigned short number_of_exceptions; struct ExceptionIndex_tag { unsigned short exception_index; struct ExceptionIndex_tag *prev; struct ExceptionIndex_tag *next; } *exception_index_table; } exceptions_attribute; struct InnerClassesAttribute { unsigned short number_of_classes; struct InnerClass_tag { unsigned short inner_class_info_index; unsigned short outer_class_info_index; unsigned short inner_name_index; unsigned short inner_class_access_flags; } *classes; } inner_classes_attribute; unsigned char dummy; struct LineNumberTableAttribute { unsigned short line_number_table_length; struct LineNumber_tag { unsigned short start_pc; unsigned short line_number; struct LineNumber_tag *prev; struct LineNumber_tag *next; } *line_number_table; } line_number_table_attribute; struct LocalVariableTableAttribute { unsigned short local_variable_table_length; struct LocalVariable_tag { unsigned short start_pc; unsigned short length; unsigned short name_index; unsigned short descriptor_index; unsigned short index; struct LocalVariable_tag *prev; struct LocalVariable_tag *next; } *local_variable_table; } local_variable_table_attribute; } u; struct AttributeInfo_tag *prev; struct AttributeInfo_tag *next; } *


decompiled_code:
size_t __fastcall emit_definitions(__int64 a1, _WORD *a2)
{
__int64 v2; // rbx
size_t result; // rax

v2 = a1;
swap16(a2);
result = emit_class_file(a2, 2uLL);
if ( a1 )
{
do
{
swap16((_WORD *)v2);
swap16((_WORD *)(v2 + 2));
swap16((_WORD *)(v2 + 4));
emit_class_file((const void *)v2, 6uLL);
result = emit_attributes(*(unsigned int **)(v2 + 8), (_WORD *)(v2 + 6));
v2 = *(_QWORD *)(v2 + 24);
}
while ( v2 );
}
return result;
}

canonical_decompiled_code:
size_t __fastcall func9(__int64 a1, _WORD *a2)
{
__int64 v2; // rbx
size_t result; // rax

v2 = a1;
func0(a2);
result = func2(a2, 2uLL);
if ( a1 )
{
do
{
func0((_WORD *)v2);
func0((_WORD *)(v2 + 2));
func0((_WORD *)(v2 + 4));
func2((const void *)v2, 6uLL);
result = func8(*(unsigned int **)(v2 + 8), (_WORD *)(v2 + 6));
v2 = *(_QWORD *)(v2 + 24);
}
while ( v2 );
}
return result;
}

original_code:
static void emit_definitions(Definition *mi, u2 *count){
    swap16(count);
    emit_class_file(count, 2);
    while(mi){
        swap16(&(mi->access_flags));
        swap16(&(mi->name_index));
        swap16(&(mi->descriptor_index));
        emit_class_file(mi, 6);
        emit_attributes(mi->attributes, &(mi->attributes_count));
        mi = mi->next;
    }
}

canonical_original_code:
static void emit_definitions(struct Definition_tag *mi, unsigned short *count){
    swap16(count);
    emit_class_file(count, 2);
    while(mi){
        swap16(&(mi->access_flags));
        swap16(&(mi->name_index));
        swap16(&(mi->descriptor_index));
        emit_class_file(mi, 6);
        emit_attributes(mi->attributes, &(mi->attributes_count));
        mi = mi->next;
    }
}

variable_types: struct Definition_tag { unsigned short access_flags; unsigned short name_index; unsigned short descriptor_index; unsigned short attributes_count; struct AttributeInfo_tag { enum AttributeTag { ATTRIBUTE_ConstantValue=1, ATTRIBUTE_Code=2, ATTRIBUTE_Exceptions=3, ATTRIBUTE_InnerClasses=4, ATTRIBUTE_Synthetic=5, ATTRIBUTE_SourceFile=6, ATTRIBUTE_LineNumberTable=7, ATTRIBUTE_LocalVariableTable=8, ATTRIBUTE_Deprecated=9 } tag; unsigned short attribute_name_index; unsigned int attribute_length; union { unsigned short cp_index; struct CodeAttribute { unsigned short max_stack; unsigned short max_locals; unsigned int code_length; struct Code_tag { enum CodeTag { CODE_OPERATOR=0, CODE_OPERAND_BYTE=1, CODE_OPERAND_SHORT=2 } tag; union { struct OpcodeInfo { unsigned char byte; char *mnemonic; unsigned char operand_count; char *operands_type; unsigned short max_stack; unsigned short max_locals; } *opcode; unsigned char operand_byte; unsigned short operand_short; } u; struct Code_tag *prev; struct Code_tag *next; } *code; unsigned short exception_table_length; struct Exception_tag { unsigned short start_pc; unsigned short end_pc; unsigned short handler_pc; unsigned short catch_type; struct Exception_tag *prev; struct Exception_tag *next; } *exception_table; unsigned short attributes_count; struct AttributeInfo_tag *attributes; unsigned short this_class_index; char *parameter_name; } code_attribute; struct ExceptionsAttribute { unsigned short number_of_exceptions; struct ExceptionIndex_tag { unsigned short exception_index; struct ExceptionIndex_tag *prev; struct ExceptionIndex_tag *next; } *exception_index_table; } exceptions_attribute; struct InnerClassesAttribute { unsigned short number_of_classes; struct InnerClass_tag { unsigned short inner_class_info_index; unsigned short outer_class_info_index; unsigned short inner_name_index; unsigned short inner_class_access_flags; } *classes; } inner_classes_attribute; unsigned char dummy; struct LineNumberTableAttribute { unsigned short line_number_table_length; struct LineNumber_tag { unsigned short start_pc; unsigned short line_number; struct LineNumber_tag *prev; struct LineNumber_tag *next; } *line_number_table; } line_number_table_attribute; struct LocalVariableTableAttribute { unsigned short local_variable_table_length; struct LocalVariable_tag { unsigned short start_pc; unsigned short length; unsigned short name_index; unsigned short descriptor_index; unsigned short index; struct LocalVariable_tag *prev; struct LocalVariable_tag *next; } *local_variable_table; } local_variable_table_attribute; } u; struct AttributeInfo_tag *prev; struct AttributeInfo_tag *next; } *attributes; struct Definition_tag *prev; struct Definition_tag *next; } *


emit

decompiled_code:
int __fastcall emit(__int64 a1)
{
fp = fopen(*(const char **)(a1 + 88), "wb");
if ( !fp )
{
fprintf(stderr, "system error!\n%d: class file \"%s\" could not create\n", 0LL, *(const char **)(a1 + 88));
exit(1);
}
emit_prefixes(a1);
emit_constant_pool(*(const void ***)(a1 + 16), (_WORD *)(a1 + 8));
emit_middles(a1);
emit_definitions(*(_QWORD *)(a1 + 32), (_WORD *)(a1 + 30));
emit_definitions(*(_QWORD *)(a1 + 48), (_WORD *)(a1 + 40));
emit_definitions(*(_QWORD *)(a1 + 64), (_WORD *)(a1 + 56));
emit_attributes(*(unsigned int **)(a1 + 80), (_WORD *)(a1 + 72));
fclose(fp);
return printf("generated %s\n", *(const char **)(a1 + 88));
}

canonical_decompiled_code:
int __fastcall func10(__int64 a1)
{
fp = fopen(*(const char **)(a1 + 88), "wb");
if ( !fp )
{
fprintf(stderr, "system error!\n%d: class file \"%s\" could not create\n", 0LL, *(const char **)(a1 + 88));
exit(1);
}
func3(a1);
func4(*(const void ***)(a1 + 16), (_WORD *)(a1 + 8));
func5(a1);
func9(*(_QWORD *)(a1 + 32), (_WORD *)(a1 + 30));
func9(*(_QWORD *)(a1 + 48), (_WORD *)(a1 + 40));
func9(*(_QWORD *)(a1 + 64), (_WORD *)(a1 + 56));
func8(*(unsigned int **)(a1 + 80), (_WORD *)(a1 + 72));
fclose(fp);
return printf("generated %s\n", *(const char **)(a1 + 88));
}

original_code:
void emit(ClassFile *cf){
    if(!(fp = fopen(cf->emit_file, "wb"))){
        fprintf(stderr, "system error!\n%d: class file \"%s\" could not create\n", 0, cf->emit_file);
        exit(1);
    }
    emit_prefixes(cf);
    emit_constant_pool(cf->constant_pool, &(cf->constant_pool_count));
    emit_middles(cf);
    emit_definitions(cf->interfaces, &(cf->interfaces_count));
    emit_definitions(cf->fields, &(cf->fields_count));
    emit_definitions(cf->methods, &(cf->methods_count));
    emit_attributes(cf->source_file, &(cf->attributes_count));
    fclose(fp);
    printf("generated %s\n", cf->emit_file);
}

canonical_original_code:
void emit(struct ClassFile *cf){
    if(!(fp = fopen(cf->emit_file, "wb"))){
        fprintf(stderr, "system error!\n%d: class file \"%s\" could not create\n", 0, cf->emit_file);
        exit(1);
    }
    emit_prefixes(cf);
    emit_constant_pool(cf->constant_pool, &(cf->constant_pool_count));
    emit_middles(cf);
    emit_definitions(cf->interfaces, &(cf->interfaces_count));
    emit_definitions(cf->fields, &(cf->fields_count));
    emit_definitions(cf->methods, &(cf->methods_count));
    emit_attributes(cf->source_file, &(cf->attributes_count));
    fclose(fp);
    printf("generated %s\n", cf->emit_file);
}

user_defined_types: struct Storage { struct MemoryPage_tag *page_list; int current_page_size; }

user_defined_types: enum ConstantInfoTag { CONSTANT_Utf8=1, CONSTANT_Integer=3, CONSTANT_Float=4, CONSTANT_Long=5, CONSTANT_Double=6, CONSTANT_Class=7, CONSTANT_String=8, CONSTANT_Fieldref=9, CONSTANT_Methodref=10, CONSTANT_InterfaceMethodref=11, CONSTANT_NameAndType=12 }

user_defined_types: struct ReferenceInfo { unsigned short class_index; unsigned short name_and_type_index; }

user_defined_types: struct LongBytes { unsigned int high_bytes; unsigned int low_bytes; }

user_defined_types: struct NameAndTypeInfo { unsigned short name_index; unsigned short descriptor_index; }

user_defined_types: struct Utf8Info { unsigned short length; char *value; }

user_defined_types: enum AttributeTag { ATTRIBUTE_ConstantValue=1, ATTRIBUTE_Code=2, ATTRIBUTE_Exceptions=3, ATTRIBUTE_InnerClasses=4, ATTRIBUTE_Synthetic=5, ATTRIBUTE_SourceFile=6, ATTRIBUTE_LineNumberTable=7, ATTRIBUTE_LocalVariableTable=8, ATTRIBUTE_Deprecated=9 }

user_defined_types: union Cell { long l_dummy; double d_dummy; void *p_dummy; }

user_defined_types: struct Exception_tag { unsigned short start_pc; unsigned short end_pc; unsigned short handler_pc; unsigned short catch_type; struct Exception_tag *prev; struct Exception_tag *next; }

user_defined_types: struct ExceptionIndex_tag { unsigned short exception_index; struct ExceptionIndex_tag *prev; struct ExceptionIndex_tag *next; }


decompiled_code:
int __fastcall yy_stack_print(__int16 *a1, unsigned __int64 a2)
{
__int16 *v2; // rbx
__int64 v3; // rdx

v2 = a1;
fwrite("Stack now", 1uLL, 9uLL, stderr);
if ( (unsigned __int64)a1 <= a2 )
{
do
{
v3 = (unsigned int)*v2++;
fprintf(stderr, " %d", v3);
}
while ( a2 >= (unsigned __int64)v2 );
}
return fputc(10, stderr);
}

canonical_decompiled_code:
int __fastcall func0(__int16 *a1, unsigned __int64 a2)
{
__int16 *v2; // rbx
__int64 v3; // rdx

v2 = a1;
fwrite("Stack now", 1uLL, 9uLL, stderr);
if ( (unsigned __int64)a1 <= a2 )
{
do
{
v3 = (unsigned int)*v2++;
fprintf(stderr, " %d", v3);
}
while ( a2 >= (unsigned __int64)v2 );
}
return fputc(10, stderr);
}

original_code:
static void
yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
{
  fprintf (stderr, "Stack now");
  for (; yybottom <= yytop; yybottom++)
    {
      int yybot = *yybottom;
      fprintf (stderr, " %d", yybot);
    }
  fprintf (stderr, "\n");
}

canonical_original_code:
static void yy_stack_print(short *yybottom, short *yytop)
{
  fprintf (stderr, "Stack now");
  for (; yybottom <= yytop; yybottom++)
    {
      int yybot = *yybottom;
      fprintf (stderr, " %d", yybot);
    }
  fprintf (stderr, "\n");
}

variable_types:
yybottom
short *

variable_types:
yytop
short *

variable_types: yybot int


yyparse

original_code:
int
yyparse (void)
{
    int yystate;
    int yyerrstatus;
    yytype_int16 yyssa[200];
    yytype_int16 *yyss;
    yytype_int16 *yyssp;
    YYSTYPE yyvsa[200];
    YYSTYPE *yyvs;
    YYSTYPE *yyvsp;
    long unsigned int yystacksize;
  int yyn;
  int yyresult;
  int yytoken = 0;
  YYSTYPE yyval;
  int yylen = 0;
  yyssp = yyss = yyssa;
  yyvsp = yyvs = yyvsa;
  yystacksize = 200;
  do { if (yydebug) fprintf (stderr, "Starting parse\n"); } while (0);
  yystate = 0;
  yyerrstatus = 0;
  yynerrs = 0;
  yychar = (-2);
  goto yysetstate;
yynewstate:
  yyssp++;
yysetstate:
  *yyssp = (yytype_int16) yystate;
  if (yyss + yystacksize - 1 <= yyssp)
    {
      long unsigned int yysize = (long unsigned int) (yyssp - yyss + 1);
      if (10000 <= yystacksize)
        goto yyexhaustedlab;
      yystacksize *= 2;
      if (10000 < yystacksize)
        yystacksize = 10000;
      {
        yytype_int16 *yyss1 = yyss;
        union yyalloc *yyptr =
          (union yyalloc *) malloc (((yystacksize) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) + (sizeof (union yyalloc) - 1)));
        if (! yyptr)
          goto yyexhaustedlab;
        do { long unsigned int yynewbytes; __builtin_memcpy (&yyptr->yyss_alloc, yyss, (yysize) * sizeof (*(yyss))); yyss = &yyptr->yyss_alloc; yynewbytes = yystacksize * sizeof (*yyss) + (sizeof (union yyalloc) - 1); yyptr += yynewbytes / sizeof (*yyptr); } while (0);
        do { long unsigned int yynewbytes; __builtin_memcpy (&yyptr->yyvs_alloc, yyvs, (yysize) * sizeof (*(yyvs))); yyvs = &yyptr->yyvs_alloc; yynewbytes = yystacksize * sizeof (*yyvs) + (sizeof (union yyalloc) - 1); yyptr += yynewbytes / sizeof (*yyptr); } while (0);
        if (yyss1 != yyssa)
          free (yyss1);
      }
      yyssp = yyss + yysize - 1;
      yyvsp = yyvs + yysize - 1;
      do { if (yydebug) fprintf (stderr, "Stack size increased to %lu\n", (unsigned long) yystacksize); } while (0);
      if (yyss + yystacksize - 1 <= yyssp)
        goto yyabortlab;
    }
  do { if (yydebug) fprintf (stderr, "Entering state %d\n", yystate); } while (0);
  if (yystate == 11)
    goto yyacceptlab;
  goto yybackup;
yybackup:
  yyn = yypact[yystate];
  if ((!!((yyn) == (-16))))
    goto yydefault;
  if (yychar == (-2))
    {
      do { if (yydebug) fprintf (stderr, "Reading a token: "); } while (0);
      yychar = yylex ();
    }
  if (yychar <= 0)
    {
      yychar = yytoken = 0;
      do { if (yydebug) fprintf (stderr, "Now at end of input.\n"); } while (0);
    }
  else
    {
      yytoken = ((unsigned) (yychar) <= 269 ? yytranslate[yychar] : 2);
      do { if (yydebug) { fprintf (stderr, "%s ", "Next token is"); yy_symbol_print (stderr, yytoken, &yylval); fprintf (stderr, "\n"); } } while (0);
    }
  yyn += yytoken;
  if (yyn < 0 || 59 < yyn || yycheck[yyn] != yytoken)
    goto yydefault;
  yyn = yytable[yyn];
  if (yyn <= 0)
    {
      if (0)
        goto yyerrlab;
      yyn = -yyn;
      goto yyreduce;
    }
  if (yyerrstatus)
    yyerrstatus--;
  do { if (yydebug) { fprintf (stderr, "%s ", "Shifting"); yy_symbol_print (stderr, yytoken, &yylval); fprintf (stderr, "\n"); } } while (0);
  yychar = (-2);
  yystate = yyn;

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yyvsp = yylval;

#pragma GCC diagnostic pop

  goto yynewstate;
yydefault:
  yyn = yydefact[yystate];
  if (yyn == 0)
    goto yyerrlab;
  goto yyreduce;
yyreduce:
  yylen = yyr2[yyn];
  yyval = yyvsp[1-yylen];
  do { if (yydebug) yy_reduce_print (yyssp, yyvsp, yyn); } while (0);
  switch (yyn)
    {
        case 6:
    {
        main_define((yyvsp[-3].identifier), (yyvsp[0].statement));
    }
    break;
  case 7:
    {
        main_pattern_define((yyvsp[-3].expression), (yyvsp[0].statement));
    }
    break;
  case 8:
    {
        main_define(((void *)0), (yyvsp[0].statement));
    }
    break;
  case 9:
    {
        main_define(((void *)0), (yyvsp[0].statement));
    }
    break;
  case 10:
    {
        function_define((yyvsp[-5].identifier), "(I)I", (yyvsp[-3].identifier), (yyvsp[0].statement));
    }
    break;
  case 11:
    {
        function_pattern_define((yyvsp[-5].identifier), (yyvsp[-3].expression), (yyvsp[0].statement));
    }
    break;
  case 12:
    {
        function_define((yyvsp[-4].identifier), "()I", ((void *)0), (yyvsp[0].statement));
    }
    break;
  case 13:
    {
        function_define((yyvsp[-2].identifier), "()I", ((void *)0), (yyvsp[0].statement));
    }
    break;
  case 14:
    {
        (yyval.statement) = create_expression_statement((yyvsp[-1].expression));
    }
    break;
  case 17:
    {
        (yyval.expression) = create_binary_expression(ADD_OPERATOR, (yyvsp[-2].expression), (yyvsp[0].expression));
    }
    break;
  case 18:
    {
        (yyval.expression) = create_binary_expression(SUB_OPERATOR, (yyvsp[-2].expression), (yyvsp[0].expression));
    }
    break;
  case 20:
    {
        (yyval.expression) = create_binary_expression(MUL_OPERATOR, (yyvsp[-2].expression), (yyvsp[0].expression));
    }
    break;
  case 21:
    {
        (yyval.expression) = create_binary_expression(DIV_OPERATOR, (yyvsp[-2].expression), (yyvsp[0].expression));
    }
    break;
  case 22:
    {
        (yyval.expression) = create_binary_expression(MOD_OPERATOR, (yyvsp[-2].expression), (yyvsp[0].expression));
    }
    break;
  case 24:
    {
        (yyval.expression) = create_minus_expression((yyvsp[0].expression));
    }
    break;
  case 26:
    {
        (yyval.expression) = create_call_expression((yyvsp[-2].identifier), ((void *)0));
    }
    break;
  case 27:
    {
        (yyval.expression) = create_call_expression((yyvsp[-3].identifier), (yyvsp[-1].expression));
    }
    break;
  case 28:
    {
        (yyval.expression) = (yyvsp[-1].expression);
    }
    break;
  case 30:
    {
        (yyval.expression) = create_identifier_expression((yyvsp[0].identifier));
    }
    break;
      default: break;
    }
  do { if (yydebug) { fprintf (stderr, "%s ", "-> $$ ="); yy_symbol_print (stderr, yyr1[yyn], &yyval); fprintf (stderr, "\n"); } } while (0);
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  do { if (yydebug) yy_stack_print ((yyss), (yyssp)); } while (0);
  *++yyvsp = yyval;
  {
    const int yylhs = yyr1[yyn] - 15;
    const int yyi = yypgoto[yylhs] + *yyssp;
    yystate = (0 <= yyi && yyi <= 59 && yycheck[yyi] == *yyssp
               ? yytable[yyi]
               : yydefgoto[yylhs]);
  }
  goto yynewstate;
yyerrlab:
  yytoken = yychar == (-2) ? (-2) : ((unsigned) (yychar) <= 269 ? yytranslate[yychar] : 2);
  if (!yyerrstatus)
    {
      ++yynerrs;
      yyerror ("syntax error");
    }
  if (yyerrstatus == 3)
    {
      if (yychar <= 0)
        {
          if (yychar == 0)
            goto yyabortlab;
        }
      else
        {
          yydestruct ("Error: discarding",
                      yytoken, &yylval);
          yychar = (-2);
        }
    }
  goto yyerrlab1;
yyerrorlab:
  if (0)
    goto yyerrorlab;
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  do { if (yydebug) yy_stack_print ((yyss), (yyssp)); } while (0);
  yystate = *yyssp;
  goto yyerrlab1;
yyerrlab1:
  yyerrstatus = 3;
  for (;;)
    {
      yyn = yypact[yystate];
      if (!(!!((yyn) == (-16))))
        {
          yyn += 1;
          if (0 <= yyn && yyn <= 59 && yycheck[yyn] == 1)
            {
              yyn = yytable[yyn];
              if (0 < yyn)
                break;
            }
        }
      if (yyssp == yyss)
        goto yyabortlab;
      yydestruct ("Error: popping",
                  yystos[yystate], yyvsp);
      (yyvsp -= (1), yyssp -= (1));
      yystate = *yyssp;
      do { if (yydebug) yy_stack_print ((yyss), (yyssp)); } while (0);
    }

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yyvsp = yylval;

#pragma GCC diagnostic pop

  do { if (yydebug) { fprintf (stderr, "%s ", "Shifting"); yy_symbol_print (stderr, yystos[yyn], yyvsp); fprintf (stderr, "\n"); } } while (0);
  yystate = yyn;
  goto yynewstate;
yyacceptlab:
  yyresult = 0;
  goto yyreturn;
yyabortlab:
  yyresult = 1;
  goto yyreturn;
yyexhaustedlab:
  yyerror ("memory exhausted");
  yyresult = 2;
yyreturn:
  if (yychar != (-2))
    {
      yytoken = ((unsigned) (yychar) <= 269 ? yytranslate[yychar] : 2);
      yydestruct ("Cleanup: discarding lookahead",
                  yytoken, &yylval);
    }
  (yyvsp -= (yylen), yyssp -= (yylen));
  do { if (yydebug) yy_stack_print ((yyss), (yyssp)); } while (0);
  while (yyssp != yyss)
    {
      yydestruct ("Cleanup: popping",
                  yystos[*yyssp], yyvsp);
      (yyvsp -= (1), yyssp -= (1));
    }
  if (yyss != yyssa)
    free (yyss);
  return yyresult;
}

canonical_original_code:
int yyparse()
{
    int yystate;
    int yyerrstatus;
    short yyssa[200];
    short *yyss;
    short *yyssp;
    union YYSTYPE yyvsa[200];
    union YYSTYPE *yyvs;
    union YYSTYPE *yyvsp;
    unsigned long yystacksize;
  int yyn;
  int yyresult;
  int yytoken = 0;
  union YYSTYPE yyval;
  int yylen = 0;
  yyssp = yyss = yyssa;
  yyvsp = yyvs = yyvsa;
  yystacksize = 200;
  do { if (yydebug) fprintf (stderr, "Starting parse\n"); } while (0);
  yystate = 0;
  yyerrstatus = 0;
  yynerrs = 0;
  yychar = (-2);
  goto yysetstate;
yynewstate:
  yyssp++;
yysetstate:
  *yyssp = (short) yystate;
  if (yyss + yystacksize - 1 <= yyssp)
    {
      unsigned long yysize = (long unsigned int) (yyssp - yyss + 1);
      if (10000 <= yystacksize)
        goto yyexhaustedlab;
      yystacksize *= 2;
      if (10000 < yystacksize)
        yystacksize = 10000;
      {
        short *yyss1 = yyss;
        union yyalloc *yyptr = (union yyalloc *) malloc (((yystacksize) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) + (sizeof (union yyalloc) - 1)));
        if (! yyptr)
          goto yyexhaustedlab;
        do { unsigned long yynewbytes; __builtin_memcpy (&yyptr->yyss_alloc, yyss, (yysize) * sizeof (*(yyss))); yyss = &yyptr->yyss_alloc; yynewbytes = yystacksize * sizeof (*yyss) + (sizeof (union yyalloc) - 1); yyptr += yynewbytes / sizeof (*yyptr); } while (0);
        do { unsigned long yynewbytes; __builtin_memcpy (&yyptr->yyvs_alloc, yyvs, (yysize) * sizeof (*(yyvs))); yyvs = &yyptr->yyvs_alloc; yynewbytes = yystacksize * sizeof (*yyvs) + (sizeof (union yyalloc) - 1); yyptr += yynewbytes / sizeof (*yyptr); } while (0);
        if (yyss1 != yyssa)
          free (yyss1);
      }
      yyssp = yyss + yysize - 1;
      yyvsp = yyvs + yysize - 1;
      do { if (yydebug) fprintf (stderr, "Stack size increased to %lu\n", (unsigned long) yystacksize); } while (0);
      if (yyss + yystacksize - 1 <= yyssp)
        goto yyabortlab;
    }
  do { if (yydebug) fprintf (stderr, "Entering state %d\n", yystate); } while (0);
  if (yystate == 11)
    goto yyacceptlab;
  goto yybackup;
yybackup:
  yyn = yypact[yystate];
  if ((!!((yyn) == (-16))))
    goto yydefault;
  if (yychar == (-2))
    {
      do { if (yydebug) fprintf (stderr, "Reading a token: "); } while (0);
      yychar = yylex ();
    }
  if (yychar <= 0)
    {
      yychar = yytoken = 0;
      do { if (yydebug) fprintf (stderr, "Now at end of input.\n"); } while (0);
    }
  else
    {
      yytoken = ((unsigned int) (yychar) <= 269 ? yytranslate[yychar] : 2);
      do { if (yydebug) { fprintf (stderr, "%s ", "Next token is"); yy_symbol_print (stderr, yytoken, &yylval); fprintf (stderr, "\n"); } } while (0);
    }
  yyn += yytoken;
  if (yyn < 0 || 59 < yyn || yycheck[yyn] != yytoken)
    goto yydefault;
  yyn = yytable[yyn];
  if (yyn <= 0)
    {
      if (0)
        goto yyerrlab;
      yyn = -yyn;
      goto yyreduce;
    }
  if (yyerrstatus)
    yyerrstatus--;
  do { if (yydebug) { fprintf (stderr, "%s ", "Shifting"); yy_symbol_print (stderr, yytoken, &yylval); fprintf (stderr, "\n"); } } while (0);
  yychar = (-2);
  yystate = yyn;

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yyvsp = yylval;

#pragma GCC diagnostic pop

  goto yynewstate;
yydefault:
  yyn = yydefact[yystate];
  if (yyn == 0)
    goto yyerrlab;
  goto yyreduce;
yyreduce:
  yylen = yyr2[yyn];
  yyval = yyvsp[1-yylen];
  do { if (yydebug) yy_reduce_print (yyssp, yyvsp, yyn); } while (0);
  switch (yyn)
    {
        case 6:
    {
        main_define((yyvsp[-3].identifier), (yyvsp[0].statement));
    }
    break;
  case 7:
    {
        main_pattern_define((yyvsp[-3].expression), (yyvsp[0].statement));
    }
    break;
  case 8:
    {
        main_define(((void *)0), (yyvsp[0].statement));
    }
    break;
  case 9:
    {
        main_define(((void *)0), (yyvsp[0].statement));
    }
    break;
  case 10:
    {
        function_define((yyvsp[-5].identifier), "(I)I", (yyvsp[-3].identifier), (yyvsp[0].statement));
    }
    break;
  case 11:
    {
        function_pattern_define((yyvsp[-5].identifier), (yyvsp[-3].expression), (yyvsp[0].statement));
    }
    break;
  case 12:
    {
        function_define((yyvsp[-4].identifier), "()I", ((void *)0), (yyvsp[0].statement));
    }
    break;
  case 13:
    {
        function_define((yyvsp[-2].identifier), "()I", ((void *)0), (yyvsp[0].statement));
    }
    break;
  case 14:
    {
        (yyval.statement) = create_expression_statement((yyvsp[-1].expression));
    }
    break;
  case 17:
    {
        (yyval.expression) = create_binary_expression(ADD_OPERATOR, (yyvsp[-2].expression), (yyvsp[0].expression));
    }
    break;
  case 18:
    {
        (yyval.expression) = create_binary_expression(SUB_OPERATOR, (yyvsp[-2].expression), (yyvsp[0].expression));
    }
    break;
  case 20:
    {
        (yyval.expression) = create_binary_expression(MUL_OPERATOR, (yyvsp[-2].expression), (yyvsp[0].expression));
    }
    break;
  case 21:
    {
        (yyval.expression) = create_binary_expression(DIV_OPERATOR, (yyvsp[-2].expression), (yyvsp[0].expression));
    }
    break;
  case 22:
    {
        (yyval.expression) = create_binary_expression(MOD_OPERATOR, (yyvsp[-2].expression), (yyvsp[0].expression));
    }
    break;
  case 24:
    {
        (yyval.expression) = create_minus_expression((yyvsp[0].expression));
    }
    break;
  case 26:
    {
        (yyval.expression) = create_call_expression((yyvsp[-2].identifier), ((void *)0));
    }
    break;
  case 27:
    {
        (yyval.expression) = create_call_expression((yyvsp[-3].identifier), (yyvsp[-1].expression));
    }
    break;
  case 28:
    {
        (yyval.expression) = (yyvsp[-1].expression);
    }
    break;
  case 30:
    {
        (yyval.expression) = create_identifier_expression((yyvsp[0].identifier));
    }
    break;
      default: break;
    }
  do { if (yydebug) { fprintf (stderr, "%s ", "-> $$ ="); yy_symbol_print (stderr, yyr1[yyn], &yyval); fprintf (stderr, "\n"); } } while (0);
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  do { if (yydebug) yy_stack_print ((yyss), (yyssp)); } while (0);
  *++yyvsp = yyval;
  {
    int yylhs = yyr1[yyn] - 15;
    int yyi = yypgoto[yylhs] + *yyssp;
    yystate = (0 <= yyi && yyi <= 59 && yycheck[yyi] == *yyssp
               ? yytable[yyi]
               : yydefgoto[yylhs]);
  }
  goto yynewstate;
yyerrlab:
  yytoken = yychar == (-2) ? (-2) : ((unsigned int) (yychar) <= 269 ? yytranslate[yychar] : 2);
  if (!yyerrstatus)
    {
      ++yynerrs;
      yyerror ("syntax error");
    }
  if (yyerrstatus == 3)
    {
      if (yychar <= 0)
        {
          if (yychar == 0)
            goto yyabortlab;
        }
      else
        {
          yydestruct ("Error: discarding",
                      yytoken, &yylval);
          yychar = (-2);
        }
    }
  goto yyerrlab1;
yyerrorlab:
  if (0)
    goto yyerrorlab;
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  do { if (yydebug) yy_stack_print ((yyss), (yyssp)); } while (0);
  yystate = *yyssp;
  goto yyerrlab1;
yyerrlab1:
  yyerrstatus = 3;
  for (;;)
    {
      yyn = yypact[yystate];
      if (!(!!((yyn) == (-16))))
        {
          yyn += 1;
          if (0 <= yyn && yyn <= 59 && yycheck[yyn] == 1)
            {
              yyn = yytable[yyn];
              if (0 < yyn)
                break;
            }
        }
      if (yyssp == yyss)
        goto yyabortlab;
      yydestruct ("Error: popping",
                  yystos[yystate], yyvsp);
      (yyvsp -= (1), yyssp -= (1));
      yystate = *yyssp;
      do { if (yydebug) yy_stack_print ((yyss), (yyssp)); } while (0);
    }

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yyvsp = yylval;

#pragma GCC diagnostic pop

  do { if (yydebug) { fprintf (stderr, "%s ", "Shifting"); yy_symbol_print (stderr, yystos[yyn], yyvsp); fprintf (stderr, "\n"); } } while (0);
  yystate = yyn;
  goto yynewstate;
yyacceptlab:
  yyresult = 0;
  goto yyreturn;
yyabortlab:
  yyresult = 1;
  goto yyreturn;
yyexhaustedlab:
  yyerror ("memory exhausted");
  yyresult = 2;
yyreturn:
  if (yychar != (-2))
    {
      yytoken = ((unsigned int) (yychar) <= 269 ? yytranslate[yychar] : 2);
      yydestruct ("Cleanup: discarding lookahead",
                  yytoken, &yylval);
    }
  (yyvsp -= (yylen), yyssp -= (yylen));
  do { if (yydebug) yy_stack_print ((yyss), (yyssp)); } while (0);
  while (yyssp != yyss)
    {
      yydestruct ("Cleanup: popping",
                  yystos[*yyssp], yyvsp);
      (yyvsp -= (1), yyssp -= (1));
    }
  if (yyss != yyssa)
    free (yyss);
  return yyresult;
}

variable_types: yystate int

variable_types: yyerrstatus int

variable_types:
yyssa
short [200]

variable_types:
yyss
short *

variable_types:
yyssp
short *

variable_types: union YYSTYPE { char *identifier; struct Expression_tag { enum ExpressionKind { INT_EXPRESSION=0, IDENTIFIER_EXPRESSION=1, BINARY_EXPRESSION=2, MINUS_EXPRESSION=3, CALL_EXPRESSION=4 } kind; int line_number; union { int int_value; char *identifier; struct BinaryExpression { enum OperatorKind { ADD_OPERATOR=0, SUB_OPERATOR=1, MUL_OPERATOR=2, DIV_OPERATOR=3, MOD_OPERATOR=4 } kind; struct Expression_tag *left; struct Expression_tag *right; } binary_expression; struct Expression_tag *minus_expression; struct CallExpression { char *identifier; struct Expression_tag *parameter_expression; } call_expression; } u; } *expression; struct Statement { enum StatementType { NONE_TYPE_STATEMENT=0, MAIN_STATEMENT=1, CONSTRUCTOR_STATEMENT=2, FUNCTION_STATEMENT=3, FUNCTION_PATTERN_STATEMENT=4 } type; int line_number; struct Expression_tag *expression; } *statement; } [200]

variable_types: union YYSTYPE { char *identifier; struct Expression_tag { enum ExpressionKind { INT_EXPRESSION=0, IDENTIFIER_EXPRESSION=1, BINARY_EXPRESSION=2, MINUS_EXPRESSION=3, CALL_EXPRESSION=4 } kind; int line_number; union { int int_value; char *identifier; struct BinaryExpression { enum OperatorKind { ADD_OPERATOR=0, SUB_OPERATOR=1, MUL_OPERATOR=2, DIV_OPERATOR=3, MOD_OPERATOR=4 } kind; struct Expression_tag *left; struct Expression_tag *right; } binary_expression; struct Expression_tag *minus_expression; struct CallExpression { char *identifier; struct Expression_tag *parameter_expression; } call_expression; } u; } *expression; struct Statement { enum StatementType { NONE_TYPE_STATEMENT=0, MAIN_STATEMENT=1, CONSTRUCTOR_STATEMENT=2, FUNCTION_STATEMENT=3, FUNCTION_PATTERN_STATEMENT=4 } type; int line_number; struct Expression_tag *expression; } *statement; } *

variable_types:
yystacksize
unsigned long

variable_types: yyn int

variable_types: yyresult int

variable_types: yytoken int

variable_types: yylen int

variable_types:
yysize
unsigned long

variable_types: union yyalloc { short yyss_alloc; union YYSTYPE { char *identifier; struct Expression_tag { enum ExpressionKind { INT_EXPRESSION=0, IDENTIFIER_EXPRESSION=1, BINARY_EXPRESSION=2, MINUS_EXPRESSION=3, CALL_EXPRESSION=4 } kind; int line_number; union { int int_value; char *identifier; struct BinaryExpression { enum OperatorKind { ADD_OPERATOR=0, SUB_OPERATOR=1, MUL_OPERATOR=2, DIV_OPERATOR=3, MOD_OPERATOR=4 } kind; struct Expression_tag *left; struct Expression_tag *right; } binary_expression; struct Expression_tag *minus_expression; struct CallExpression { char *identifier; struct Expression_tag *parameter_expression; } call_expression; } u; } *expression; struct Statement { enum StatementType { NONE_TYPE_STATEMENT=0, MAIN_STATEMENT=1, CONSTRUCTOR_STATEMENT=2, FUNCTION_STATEMENT=3, FUNCTION_PATTERN_STATEMENT=4 } type; int line_number; struct Expression_tag *expression; } *statement; } yyvs_alloc; } *

variable_types:
yynewbytes
unsigned long

variable_types: yylhs int

variable_types: yyi int

return_type: int

user_defined_types: union YYSTYPE { char *identifier; struct Expression_tag *expression; struct Statement *statement; }

user_defined_types: union yyalloc { short yyss_alloc; union YYSTYPE yyvs_alloc; }

user_defined_types: struct Expression_tag { enum ExpressionKind kind; int line_number; union { int int_value; char *identifier; struct BinaryExpression binary_expression; struct Expression_tag *minus_expression; struct CallExpression call_expression; } u; }

user_defined_types: struct Statement { enum StatementType type; int line_number; struct Expression_tag *expression; }

user_defined_types: struct BinaryExpression { enum OperatorKind kind; struct Expression_tag *left; struct Expression_tag *right; }


yyerror

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

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

original_code:
int yyerror(char const *str){
    return 0;
}

canonical_original_code:
int yyerror(char *str){
    return 0;
}

variable_types:
str
char *


original_code:
Definition *add_definition(Definition **dn_list, u2 *list_length, char *name, char *type){
    Definition *dn;
    if(*dn_list){
        dn = classfile_storage_malloc(sizeof(Definition));
        dn->next = ((void *)0);
        dn->prev = (*dn_list)->prev;
        dn->prev->next = dn;
        (*dn_list)->prev = dn;
    } else{
        *dn_list = classfile_storage_malloc(sizeof(Definition));
        (*dn_list)->next = ((void *)0);
        (*dn_list)->prev = *dn_list;
        dn = *dn_list;
    }
    (*list_length)++;
    dn->access_flags = ACC_PUBLIC | ACC_STATIC;
    dn->name_index = add_constant_utf8_info(name);
    dn->descriptor_index = add_constant_utf8_info(type);
    dn->attributes_count = 0;
    dn->attributes = ((void *)0);
    return dn;
}

canonical_original_code:
struct Definition_tag *add_definition(struct Definition_tag **dn_list, unsigned short *list_length, char *name, char *type){
    struct Definition_tag *dn;
    if(*dn_list){
        dn = classfile_storage_malloc(sizeof(Definition));
        dn->next = ((void *)0);
        dn->prev = (*dn_list)->prev;
        dn->prev->next = dn;
        (*dn_list)->prev = dn;
    } else{
        *dn_list = classfile_storage_malloc(sizeof(Definition));
        (*dn_list)->next = ((void *)0);
        (*dn_list)->prev = *dn_list;
        dn = *dn_list;
    }
    (*list_length)++;
    dn->access_flags = ACC_PUBLIC | ACC_STATIC;
    dn->name_index = add_constant_utf8_info(name);
    dn->descriptor_index = add_constant_utf8_info(type);
    dn->attributes_count = 0;
    dn->attributes = ((void *)0);
    return dn;
}

variable_types:
name
char *

variable_types:
type
char *

variable_types: struct Definition_tag { unsigned short access_flags; unsigned short name_index; unsigned short descriptor_index; unsigned short attributes_count; struct AttributeInfo_tag { enum AttributeTag { ATTRIBUTE_ConstantValue=1, ATTRIBUTE_Code=2, ATTRIBUTE_Exceptions=3, ATTRIBUTE_InnerClasses=4, ATTRIBUTE_Synthetic=5, ATTRIBUTE_SourceFile=6, ATTRIBUTE_LineNumberTable=7, ATTRIBUTE_LocalVariableTable=8, ATTRIBUTE_Deprecated=9 } tag; unsigned short attribute_name_index; unsigned int attribute_length; union { unsigned short cp_index; struct CodeAttribute { unsigned short max_stack; unsigned short max_locals; unsigned int code_length; struct Code_tag { enum CodeTag { CODE_OPERATOR=0, CODE_OPERAND_BYTE=1, CODE_OPERAND_SHORT=2 } tag; union { struct OpcodeInfo { unsigned char byte; char *mnemonic; unsigned char operand_count; char *operands_type; unsigned short max_stack; unsigned short max_locals; } *opcode; unsigned char operand_byte; unsigned short operand_short; } u; struct Code_tag *prev; struct Code_tag *next; } *code; unsigned short exception_table_length; struct Exception_tag { unsigned short start_pc; unsigned short end_pc; unsigned short handler_pc; unsigned short catch_type; struct Exception_tag *prev; struct Exception_tag *next; } *exception_table; unsigned short attributes_count; struct AttributeInfo_tag *attributes; unsigned short this_class_index; char *parameter_name; } code_attribute; struct ExceptionsAttribute { unsigned short number_of_exceptions; struct ExceptionIndex_tag { unsigned short exception_index; struct ExceptionIndex_tag *prev; struct ExceptionIndex_tag *next; } *exception_index_table; } exceptions_attribute; struct InnerClassesAttribute { unsigned short number_of_classes; struct InnerClass_tag { unsigned short inner_class_info_index; unsigned short outer_class_info_index; unsigned short inner_name_index; unsigned short inner_class_access_flags; } *classes; } inner_classes_attribute; unsigned char dummy; struct LineNumberTableAttribute { unsigned short line_number_table_length; struct LineNumber_tag { unsigned short start_pc; unsigned short line_number; struct LineNumber_tag *prev; struct LineNumber_tag *next; } *line_number_table; } line_number_table_attribute; struct LocalVariableTableAttribute { unsigned short local_variable_table_length; struct LocalVariable_tag { unsigned short start_pc; unsigned short length; unsigned short name_index; unsigned short descriptor_index; unsigned short index; struct LocalVariable_tag *prev; struct LocalVariable_tag *next; } *local_variable_table; } local_variable_table_attribute; } u; struct AttributeInfo_tag *prev; struct AttributeInfo_tag *next; } *attributes; struct Definition_tag *prev; struct Definition_tag *next; } *

user_defined_types: struct Definition_tag { unsigned short access_flags; unsigned short name_index; unsigned short descriptor_index; unsigned short attributes_count; struct AttributeInfo_tag *attributes; struct Definition_tag *prev; struct Definition_tag *next; }

user_defined_types: struct AttributeInfo_tag { enum AttributeTag tag; unsigned short attribute_name_index; unsigned int attribute_length; union { unsigned short cp_index; struct CodeAttribute code_attribute; struct ExceptionsAttribute exceptions_attribute; struct InnerClassesAttribute inner_classes_attribute; unsigned char dummy; struct LineNumberTableAttribute line_number_table_attribute; struct LocalVariableTableAttribute local_variable_table_attribute; } u; struct AttributeInfo_tag *prev; struct AttributeInfo_tag *next; }

user_defined_types: struct CodeAttribute { unsigned short max_stack; unsigned short max_locals; unsigned int code_length; struct Code_tag *code; unsigned short exception_table_length; struct Exception_tag *exception_table; unsigned short attributes_count; struct AttributeInfo_tag *attributes; unsigned short this_class_index; char *parameter_name; }

user_defined_types: struct ExceptionsAttribute { unsigned short number_of_exceptions; struct ExceptionIndex_tag *exception_index_table; }

user_defined_types: struct InnerClassesAttribute { unsigned short number_of_classes; struct InnerClass_tag *classes; }

user_defined_types: struct LineNumberTableAttribute { unsigned short line_number_table_length; struct LineNumber_tag *line_number_table; }

user_defined_types: struct LocalVariableTableAttribute { unsigned short local_variable_table_length; struct LocalVariable_tag *local_variable_table; }


decompiled_code:
_DWORD *alloc_statement()
{
_DWORD *v0; // rax
_DWORD *v1; // r12
int v2; // eax

v0 = (_DWORD *)compiler_storage_malloc(16LL);
*v0 = 0;
v1 = v0;
v2 = *(_DWORD *)(get_current_compiler() + 16);
*((_QWORD *)v1 + 1) = 0LL;
v1[1] = v2;
return v1;
}

canonical_decompiled_code:
_DWORD *func0()
{
_DWORD *v0; // rax
_DWORD *v1; // r12
int v2; // eax

v0 = (_DWORD *)compiler_storage_malloc(16LL);
*v0 = 0;
v1 = v0;
v2 = *(_DWORD *)(get_current_compiler() + 16);
*((_QWORD *)v1 + 1) = 0LL;
v1[1] = v2;
return v1;
}

original_code:
static Statement* alloc_statement(){
    Statement *st;
    st = compiler_storage_malloc(sizeof(Statement));
    st->type = NONE_TYPE_STATEMENT;
    st->line_number = get_current_compiler()->current_line_number;
    st->expression = ((void *)0);
    return st;
}

canonical_original_code:
static struct Statement *alloc_statement(){
    struct Statement *st;
    st = compiler_storage_malloc(sizeof(Statement));
    st->type = NONE_TYPE_STATEMENT;
    st->line_number = get_current_compiler()->current_line_number;
    st->expression = ((void *)0);
    return st;
}

variable_types: struct Statement { enum StatementType { NONE_TYPE_STATEMENT=0, MAIN_STATEMENT=1, CONSTRUCTOR_STATEMENT=2, FUNCTION_STATEMENT=3, FUNCTION_PATTERN_STATEMENT=4 } type; int line_number; struct Expression_tag { enum ExpressionKind { INT_EXPRESSION=0, IDENTIFIER_EXPRESSION=1, BINARY_EXPRESSION=2, MINUS_EXPRESSION=3, CALL_EXPRESSION=4 } kind; int line_number; union { int int_value; char *identifier; struct BinaryExpression { enum OperatorKind { ADD_OPERATOR=0, SUB_OPERATOR=1, MUL_OPERATOR=2, DIV_OPERATOR=3, MOD_OPERATOR=4 } kind; struct Expression_tag *left; struct Expression_tag *right; } binary_expression; struct Expression_tag *minus_expression; struct CallExpression { char *identifier; struct Expression_tag *parameter_expression; } call_expression; } u; } *expression; } *


decompiled_code:
__int64 __fastcall search_function(char *s2)
{
__int64 i; // r12

for ( i = *(_QWORD *)(get_current_compiler() + 8); i; i = *(_QWORD *)(i + 48) )
{
if ( !strcmp(*(const char **)i, s2) )
break;
}
return i;
}

canonical_decompiled_code:
__int64 __fastcall func1(char *s2)
{
__int64 i; // r12

for ( i = *(_QWORD *)(get_current_compiler() + 8); i; i = *(_QWORD *)(i + 48) )
{
if ( !strcmp(*(const char **)i, s2) )
break;
}
return i;
}

original_code:
static FunctionDefinition *search_function(char *identifier){
    Compiler *compiler;
    FunctionDefinition *fd;
    compiler = get_current_compiler();
    for(fd = compiler->function_list; fd; fd = fd->next){
        if(!strcmp(fd->name, identifier)){
            return fd;
        }
    }
    return ((void *)0);
}

canonical_original_code:
static struct FunctionDefinition_tag *search_function(char *identifier){
    struct Compiler *compiler;
    struct FunctionDefinition_tag *fd;
    compiler = get_current_compiler();
    for(fd = compiler->function_list; fd; fd = fd->next){
        if(!strcmp(fd->name, identifier)){
            return fd;
        }
    }
    return ((void *)0);
}

variable_types:
identifier
char *

variable_types: struct Compiler { int function_count; struct FunctionDefinition_tag { char *name; char *descriptor; char *parameter_name; struct Statement { enum StatementType { NONE_TYPE_STATEMENT=0, MAIN_STATEMENT=1, CONSTRUCTOR_STATEMENT=2, FUNCTION_STATEMENT=3, FUNCTION_PATTERN_STATEMENT=4 } type; int line_number; struct Expression_tag { enum ExpressionKind { INT_EXPRESSION=0, IDENTIFIER_EXPRESSION=1, BINARY_EXPRESSION=2, MINUS_EXPRESSION=3, CALL_EXPRESSION=4 } kind; int line_number; union { int int_value; char *identifier; struct BinaryExpression { enum OperatorKind { ADD_OPERATOR=0, SUB_OPERATOR=1, MUL_OPERATOR=2, DIV_OPERATOR=3, MOD_OPERATOR=4 } kind; struct Expression_tag *left; struct Expression_tag *right; } binary_expression; struct Expression_tag *minus_expression; struct CallExpression { char *identifier; struct Expression_tag *parameter_expression; } call_expression; } u; } *expression; } *statement; struct FunctionPattern_tag { int pattern; struct Statement *statement; struct FunctionPattern_tag *prev; struct FunctionPattern_tag *next; } *pattern_list; struct FunctionDefinition_tag *prev; struct FunctionDefinition_tag *next; } *function_list; int current_line_number; char *source_file; struct Storage { struct MemoryPage_tag { int cell_num; int use_cell_num; struct MemoryPage_tag *next; union Cell { long l_dummy; double d_dummy; void *p_dummy; } cell[1]; } *page_list; int current_page_size; } *compile_storage; } *

user_defined_types: struct Compiler { int function_count; struct FunctionDefinition_tag *function_list; int current_line_number; char *source_file; struct Storage *compile_storage; }

user_defined_types: struct FunctionDefinition_tag { char *name; char *descriptor; char *parameter_name; struct Statement *statement; struct FunctionPattern_tag *pattern_list; struct FunctionDefinition_tag *prev; struct FunctionDefinition_tag *next; }

user_defined_types: struct Storage { struct MemoryPage_tag *page_list; int current_page_size; }

user_defined_types: struct MemoryPage_tag { int cell_num; int use_cell_num; struct MemoryPage_tag *next; union Cell cell[1]; }


decompiled_code:
char **__fastcall function_define(char *a1, char *a2, char *a3, char *a4)
{
__int64 v6; // r14
char **result; // rax
__int64 v8; // rdx
__int64 v9; // rcx

if ( search_function(a1) )
compile_error(6LL, *((unsigned int *)a4 + 1), a1, a3);
v6 = get_current_compiler();
if ( *(_QWORD *)(v6 + 8) )
{
result = (char **)compiler_storage_malloc(56LL);
v8 = *(_QWORD *)(v6 + 8);
result[6] = 0LL;
v9 = *(_QWORD *)(v8 + 40);
result[5] = (char *)v9;
*(_QWORD *)(v9 + 48) = result;
*(_QWORD *)(v8 + 40) = result;
}
else
{
result = (char **)compiler_storage_malloc(56LL);
*(_QWORD *)(v6 + 8) = result;
result[6] = 0LL;
result[5] = (char *)result;
}
++*(_DWORD *)v6;
*result = a1;
result[1] = a2;
result[2] = a3;
*(_DWORD *)a4 = 3;
result[3] = a4;
result[4] = 0LL;
return result;
}

canonical_decompiled_code:
char **__fastcall func3(char *a1, char *a2, char *a3, char *a4)
{
__int64 v6; // r14
char **result; // rax
__int64 v8; // rdx
__int64 v9; // rcx

if ( func1(a1) )
compile_error(6LL, *((unsigned int *)a4 + 1), a1, a3);
v6 = get_current_compiler();
if ( *(_QWORD *)(v6 + 8) )
{
result = (char **)compiler_storage_malloc(56LL);
v8 = *(_QWORD *)(v6 + 8);
result[6] = 0LL;
v9 = *(_QWORD *)(v8 + 40);
result[5] = (char *)v9;
*(_QWORD *)(v9 + 48) = result;
*(_QWORD *)(v8 + 40) = result;
}
else
{
result = (char **)compiler_storage_malloc(56LL);
*(_QWORD *)(v6 + 8) = result;
result[6] = 0LL;
result[5] = (char *)result;
}
++*(_DWORD *)v6;
*result = a1;
result[1] = a2;
result[2] = a3;
*(_DWORD *)a4 = 3;
result[3] = a4;
result[4] = 0LL;
return result;
}

original_code:
void function_define(char *identifier, char *descriptor, char *parameter, Statement *statement){
    Compiler *compiler;
    FunctionDefinition *fd;
    if(search_function(identifier))
        compile_error(ERROR_FUNCTION_ALREADY_DEFINED, statement->line_number, identifier, parameter);
    compiler = get_current_compiler();
    if(compiler->function_list){
        fd = compiler_storage_malloc(sizeof(FunctionDefinition));
        fd->next = ((void *)0);
        fd->prev = compiler->function_list->prev;
        fd->prev->next = fd;
        compiler->function_list->prev = fd;
    }
    else{
        compiler->function_list = compiler_storage_malloc(sizeof(FunctionDefinition));
        compiler->function_list->next = ((void *)0);
        compiler->function_list->prev = compiler->function_list;
        fd = compiler->function_list;
    }
    (compiler->function_count)++;
    fd->name = identifier;
    fd->descriptor = descriptor;
    fd->parameter_name = parameter;
    statement->type = FUNCTION_STATEMENT;
    fd->statement = statement;
    fd->pattern_list = ((void *)0);
}

canonical_original_code:
void function_define(char *identifier, char *descriptor, char *parameter, struct Statement *statement){
    struct Compiler *compiler;
    struct FunctionDefinition_tag *fd;
    if(search_function(identifier))
        compile_error(ERROR_FUNCTION_ALREADY_DEFINED, statement->line_number, identifier, parameter);
    compiler = get_current_compiler();
    if(compiler->function_list){
        fd = compiler_storage_malloc(sizeof(FunctionDefinition));
        fd->next = ((void *)0);
        fd->prev = compiler->function_list->prev;
        fd->prev->next = fd;
        compiler->function_list->prev = fd;
    }
    else{
        compiler->function_list = compiler_storage_malloc(sizeof(FunctionDefinition));
        compiler->function_list->next = ((void *)0);
        compiler->function_list->prev = compiler->function_list;
        fd = compiler->function_list;
    }
    (compiler->function_count)++;
    fd->name = identifier;
    fd->descriptor = descriptor;
    fd->parameter_name = parameter;
    statement->type = FUNCTION_STATEMENT;
    fd->statement = statement;
    fd->pattern_list = ((void *)0);
}

variable_types:
descriptor
char *

variable_types:
parameter
char *

variable_types: struct FunctionDefinition_tag { char *name; char *descriptor; char *parameter_name; struct Statement { enum StatementType { NONE_TYPE_STATEMENT=0, MAIN_STATEMENT=1, CONSTRUCTOR_STATEMENT=2, FUNCTION_STATEMENT=3, FUNCTION_PATTERN_STATEMENT=4 } type; int line_number; struct Expression_tag { enum ExpressionKind { INT_EXPRESSION=0, IDENTIFIER_EXPRESSION=1, BINARY_EXPRESSION=2, MINUS_EXPRESSION=3, CALL_EXPRESSION=4 } kind; int line_number; union { int int_value; char *identifier; struct BinaryExpression { enum OperatorKind { ADD_OPERATOR=0, SUB_OPERATOR=1, MUL_OPERATOR=2, DIV_OPERATOR=3, MOD_OPERATOR=4 } kind; struct Expression_tag *left; struct Expression_tag *right; } binary_expression; struct Expression_tag *minus_expression; struct CallExpression { char *identifier; struct Expression_tag *parameter_expression; } call_expression; } u; } *expression; } *statement; struct FunctionPattern_tag { int pattern; struct Statement *statement; struct FunctionPattern_tag *prev; struct FunctionPattern_tag *next; } *pattern_list; struct FunctionDefinition_tag *prev; struct FunctionDefinition_tag *next; } *

user_defined_types: union Cell { long l_dummy; double d_dummy; void *p_dummy; }


decompiled_code:
char **constructor_define()
{
char *v0; // rbx
char **result; // rax

get_current_compiler();
v0 = (char *)alloc_statement();
result = function_define("<init>", "()V", 0LL, v0);
*(_DWORD *)v0 = 2;
return result;
}

canonical_decompiled_code:
char **func4()
{
char *v0; // rbx
char **result; // rax

get_current_compiler();
v0 = (char *)func0();
result = func3("<init>", "()V", 0LL, v0);
*(_DWORD *)v0 = 2;
return result;
}

original_code:
void constructor_define(){
    Compiler *compiler;
    Statement *statement;
    compiler = get_current_compiler();
    statement = alloc_statement();
    function_define("<init>", "()V", ((void *)0), statement);
    statement->type = CONSTRUCTOR_STATEMENT;
}

canonical_original_code:
void constructor_define(){
    struct Compiler *compiler;
    struct Statement *statement;
    compiler = get_current_compiler();
    statement = alloc_statement();
    function_define("<init>", "()V", ((void *)0), statement);
    statement->type = CONSTRUCTOR_STATEMENT;
}

user_defined_types: enum StatementType { NONE_TYPE_STATEMENT=0, MAIN_STATEMENT=1, CONSTRUCTOR_STATEMENT=2, FUNCTION_STATEMENT=3, FUNCTION_PATTERN_STATEMENT=4 }

user_defined_types: enum ExpressionKind { INT_EXPRESSION=0, IDENTIFIER_EXPRESSION=1, BINARY_EXPRESSION=2, MINUS_EXPRESSION=3, CALL_EXPRESSION=4 }

user_defined_types: struct FunctionPattern_tag { int pattern; struct Statement *statement; struct FunctionPattern_tag *prev; struct FunctionPattern_tag *next; }

user_defined_types: struct CallExpression { char *identifier; struct Expression_tag *parameter_expression; }

user_defined_types: enum OperatorKind { ADD_OPERATOR=0, SUB_OPERATOR=1, MUL_OPERATOR=2, DIV_OPERATOR=3, MOD_OPERATOR=4 }


decompiled_code:
__int64 __fastcall function_pattern_define(char *a1, __int64 a2, _DWORD *a3)
{
unsigned int v4; // er12
__int64 v5; // rbx
__int64 v6; // rdx
__int64 result; // rax
__int64 v8; // rdx
__int64 v9; // rcx

v4 = *(_DWORD *)(a2 + 8);
v5 = search_function(a1);
if ( !v5 )
compile_error(7LL, (unsigned int)a3[1], a1, v4);
if ( !*(_QWORD *)(v5 + 16) )
compile_error(10LL, (unsigned int)a3[1], a1, v4);
if ( (unsigned int)search_function_pattern_isra_0(*(_QWORD *)(v5 + 32), v4) )
{
compile_error(8LL, (unsigned int)a3[1], a1, v4);
if ( *(_QWORD *)(v5 + 32) )
goto LABEL_7;
LABEL_10:
result = compiler_storage_malloc(32LL);
*(_QWORD *)(v5 + 32) = result;
*(_QWORD *)(result + 24) = 0LL;
*(_QWORD *)(result + 16) = result;
goto LABEL_8;
}
if ( !v6 )
goto LABEL_10;
LABEL_7:
result = compiler_storage_malloc(32LL);
v8 = *(_QWORD *)(v5 + 32);
*(_QWORD *)(result + 24) = 0LL;
v9 = *(_QWORD *)(v8 + 16);
*(_QWORD *)(result + 16) = v9;
*(_QWORD *)(v9 + 24) = result;
*(_QWORD *)(v8 + 16) = result;
LABEL_8:
*(_DWORD *)result = v4;
*a3 = 4;
*(_QWORD *)(result + 8) = a3;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(char *a1, __int64 a2, _DWORD *a3)
{
unsigned int v4; // er12
__int64 v5; // rbx
__int64 v6; // rdx
__int64 result; // rax
__int64 v8; // rdx
__int64 v9; // rcx

v4 = *(_DWORD *)(a2 + 8);
v5 = func1(a1);
if ( !v5 )
compile_error(7LL, (unsigned int)a3[1], a1, v4);
if ( !*(_QWORD *)(v5 + 16) )
compile_error(10LL, (unsigned int)a3[1], a1, v4);
if ( (unsigned int)func2(*(_QWORD *)(v5 + 32), v4) )
{
compile_error(8LL, (unsigned int)a3[1], a1, v4);
if ( *(_QWORD *)(v5 + 32) )
goto LABEL_7;
LABEL_10:
result = compiler_storage_malloc(32LL);
*(_QWORD *)(v5 + 32) = result;
*(_QWORD *)(result + 24) = 0LL;
*(_QWORD *)(result + 16) = result;
goto LABEL_8;
}
if ( !v6 )
goto LABEL_10;
LABEL_7:
result = compiler_storage_malloc(32LL);
v8 = *(_QWORD *)(v5 + 32);
*(_QWORD *)(result + 24) = 0LL;
v9 = *(_QWORD *)(v8 + 16);
*(_QWORD *)(result + 16) = v9;
*(_QWORD *)(v9 + 24) = result;
*(_QWORD *)(v8 + 16) = result;
LABEL_8:
*(_DWORD *)result = v4;
*a3 = 4;
*(_QWORD *)(result + 8) = a3;
return result;
}

original_code:
void function_pattern_define(char *identifier, Expression *pattern, Statement *statement){
    FunctionDefinition *fd;
    FunctionPattern *fp;
    int pattern_value;
    pattern_value = pattern->u.int_value;
    fd = search_function(identifier);
    if(!fd)
        compile_error(ERROR_FUNCTION_NOT_DEFINED, statement->line_number, identifier, pattern_value);
    if(!fd->parameter_name)
        compile_error(ERROR_FUNCTION_WITH_ARG_NOT_DEFINED, statement->line_number, identifier, pattern_value);
    if(search_function_pattern(fd, pattern_value))
        compile_error(ERROR_FUNCTION_PATTERN_ALREADY_DEFINED, statement->line_number, identifier, pattern_value);
    if(fd->pattern_list){
        fp = compiler_storage_malloc(sizeof(FunctionPattern));
        fp->next = ((void *)0);
        fp->prev = fd->pattern_list->prev;
        fp->prev->next = fp;
        fd->pattern_list->prev = fp;
    }
    else{
        fd->pattern_list = compiler_storage_malloc(sizeof(FunctionPattern));
        fd->pattern_list->next = ((void *)0);
        fd->pattern_list->prev = fd->pattern_list;
        fp = fd->pattern_list;
    }
    fp->pattern = pattern_value;
    statement->type = FUNCTION_PATTERN_STATEMENT;
    fp->statement = statement;
}

canonical_original_code:
void function_pattern_define(char *identifier, struct Expression_tag *pattern, struct Statement *statement){
    struct FunctionDefinition_tag *fd;
    struct FunctionPattern_tag *fp;
    int pattern_value;
    pattern_value = pattern->u.int_value;
    fd = search_function(identifier);
    if(!fd)
        compile_error(ERROR_FUNCTION_NOT_DEFINED, statement->line_number, identifier, pattern_value);
    if(!fd->parameter_name)
        compile_error(ERROR_FUNCTION_WITH_ARG_NOT_DEFINED, statement->line_number, identifier, pattern_value);
    if(search_function_pattern(fd, pattern_value))
        compile_error(ERROR_FUNCTION_PATTERN_ALREADY_DEFINED, statement->line_number, identifier, pattern_value);
    if(fd->pattern_list){
        fp = compiler_storage_malloc(sizeof(FunctionPattern));
        fp->next = ((void *)0);
        fp->prev = fd->pattern_list->prev;
        fp->prev->next = fp;
        fd->pattern_list->prev = fp;
    }
    else{
        fd->pattern_list = compiler_storage_malloc(sizeof(FunctionPattern));
        fd->pattern_list->next = ((void *)0);
        fd->pattern_list->prev = fd->pattern_list;
        fp = fd->pattern_list;
    }
    fp->pattern = pattern_value;
    statement->type = FUNCTION_PATTERN_STATEMENT;
    fp->statement = statement;
}

variable_types: struct Statement { enum StatementType { NONE_TYPE_STATEMENT=0, MAIN_STATEMENT=1, CONSTRUCTOR_STATEMENT=2, FUNCTION_STATEMENT=3, FUNCTION_PATTERN_STATEMENT=4 } type; int line_number; struct Expression_tag *expression; } *

variable_types: struct FunctionPattern_tag { int pattern; struct Statement { enum StatementType { NONE_TYPE_STATEMENT=0, MAIN_STATEMENT=1, CONSTRUCTOR_STATEMENT=2, FUNCTION_STATEMENT=3, FUNCTION_PATTERN_STATEMENT=4 } type; int line_number; struct Expression_tag { enum ExpressionKind { INT_EXPRESSION=0, IDENTIFIER_EXPRESSION=1, BINARY_EXPRESSION=2, MINUS_EXPRESSION=3, CALL_EXPRESSION=4 } kind; int line_number; union { int int_value; char *identifier; struct BinaryExpression { enum OperatorKind { ADD_OPERATOR=0, SUB_OPERATOR=1, MUL_OPERATOR=2, DIV_OPERATOR=3, MOD_OPERATOR=4 } kind; struct Expression_tag *left; struct Expression_tag *right; } binary_expression; struct Expression_tag *minus_expression; struct CallExpression { char *identifier; struct Expression_tag *parameter_expression; } call_expression; } u; } *expression; } *statement; struct FunctionPattern_tag *prev; struct FunctionPattern_tag *next; } *

user_defined_types: struct Expression_tag { enum ExpressionKind kind; int line_number; union { int int_value; char *identifier; struct BinaryExpression binary_expression; struct Expression_tag *minus_expression; struct CallExpression call_expression; } u; }

user_defined_types: struct Statement { enum StatementType type; int line_number; struct Expression_tag *expression; }

user_defined_types: struct BinaryExpression { enum OperatorKind kind; struct Expression_tag *left; struct Expression_tag *right; }