emitBeginWhile

decompiled_code:
void emitBeginWhile()
{
unsigned int v0; // eax
unsigned int v1; // eax

if ( doNotEmit )
{
doNotEmit = 1;
}
else
{
reserveLabels(loopLabelStack, 2LL);
v0 = peekLabelStackTop(loopLabelStack);
emitComment("Top of WHILE loop %s%d", "LOOP", v0);
v1 = peekLabelStackTop(loopLabelStack);
emitLabel(128LL, "%s%d", "LOOP", v1);
}
}

canonical_decompiled_code:
void func4()
{
unsigned int v0; // eax
unsigned int v1; // eax

if ( doNotEmit )
{
doNotEmit = 1;
}
else
{
reserveLabels(loopLabelStack, 2LL);
v0 = peekLabelStackTop(loopLabelStack);
emitComment("Top of WHILE loop %s%d", "LOOP", v0);
v1 = peekLabelStackTop(loopLabelStack);
emitLabel(128LL, "%s%d", "LOOP", v1);
}
}

original_code:
void emitBeginWhile() {
 do { if(!(1) || (doNotEmit)) { doNotEmit = 1; return; }} while (0);
 reserveLabels(loopLabelStack, 2);
 emitComment("Top of WHILE loop %s%d",
     "LOOP", peekLabelStackTop(loopLabelStack));
 emitLabel(128, "%s%d",
     "LOOP", peekLabelStackTop(loopLabelStack));
}


emitWhileLoopCondCheck

repo: a-krebs/YACC

decompiled_code:
void __fastcall emitWhileLoopCondCheck(__int64 a1)
{
int v1; // eax

if ( a1 )
{
if ( doNotEmit )
{
doNotEmit = 1;
}
else
{
if ( *(_DWORD *)(a1 + 8) || !(unsigned int)isConstResultSym(a1) )
emitPushSymbolValue(a1);
emitComment("If expr is false, skip loop body");
v1 = peekLabelStackTop(loopLabelStack);
emitStmt(128LL, "IFZ %s%d", "LOOP", (unsigned int)(v1 + 1));
}
}
else
{
doNotEmit = 1;
}
}

canonical_decompiled_code:
void __fastcall func5(__int64 a1)
{
int v1; // eax

if ( a1 )
{
if ( doNotEmit )
{
doNotEmit = 1;
}
else
{
if ( *(_DWORD *)(a1 + 8) || !(unsigned int)isConstResultSym(a1) )
emitPushSymbolValue(a1);
emitComment("If expr is false, skip loop body");
v1 = peekLabelStackTop(loopLabelStack);
emitStmt(128LL, "IFZ %s%d", "LOOP", (unsigned int)(v1 + 1));
}
}
else
{
doNotEmit = 1;
}
}

original_code:
void emitWhileLoopCondCheck(Symbol *s) {
 do { if(!(s) || (doNotEmit)) { doNotEmit = 1; return; }} while (0);
 if (! (s->kind == CONST_KIND && isConstResultSym(s))) {
  emitPushSymbolValue(s);
 }
 emitComment("If expr is false, skip loop body");
 emitStmt(128, "IFZ %s%d",
     "LOOP", peekLabelStackTop(loopLabelStack) + 1);
}

canonical_original_code:
void emitWhileLoopCondCheck(struct Symbol *s) {
 do { if(!(s) || (doNotEmit)) { doNotEmit = 1; return; }} while (0);
 if (! (s->kind == CONST_KIND && isConstResultSym(s))) {
  emitPushSymbolValue(s);
 }
 emitComment("If expr is false, skip loop body");
 emitStmt(128, "IFZ %s%d",
     "LOOP", peekLabelStackTop(loopLabelStack) + 1);
}

variable_types: struct Symbol { char *name; enum kind_t { CONST_KIND=0, FUNC_KIND=1, PARAM_KIND=2, PROC_KIND=3, TYPE_KIND=4, VAR_KIND=5 } kind; union kind_union { struct ConstantKind { int constResultFlag; struct Symbol *typeSym; union anonymous_constant_value { struct Boolean { int value; } Boolean; struct Char { unsigned char value; } Char; struct Integer { int value; } Integer; struct Real { double value; } Real; struct String { char *str; unsigned int strlen; } String; } value; } *ConstKind; struct FunctionKind { struct Symbol *typeSym; struct ElementArray { void **data; unsigned int len; unsigned int nElements; } *params; char *label; int invocationInstance; } *FuncKind; struct ParamKind { struct Symbol *typeSym; int byRef; } *ParamKind; struct ProcedureKind { struct ElementArray *params; char *label; } *ProcKind; struct TypeKind { union type_union { struct Array { struct Symbol *baseTypeSym; struct Symbol *indexTypeSym; } *Array; struct Function { struct ParamArray { struct Param { char *name; enum type_t { VOID_T=0, ARRAY_T=1, BOOLEAN_T=2, CHAR_T=3, INTEGER_T=4, REAL_T=5, RECORD_T=6, SCALARINT_T=7, SCALAR_T=8, STRING_T=9, SUBRANGE_T=10 } type; struct Symbol *typeSym; } **data; unsigned int len; unsigned int nElements; } *params; struct Symbol *returnTypeSym; char *label; } *Function; struct Procedure { struct ParamArray *params; char *label; } *Procedure; struct Record { struct hash { struct hashElement { char *key; struct Symbol *symbol; struct hashElement *prev; struct hashElement *next; } *elements[1000]; int offset[1024]; unsigned int (*hashFunction)(); int lexLevel; } *hash; } *Record; struct Scalar { struct ElementArray *consts; } *Scalar; struct StringType { unsigned int strlen; } *String; struct Subrange { int high; int low; struct Symbol *baseTypeSym; } *Subrange; } typePtr; enum type_t { VOID_T=0, ARRAY_T=1, BOOLEAN_T=2, CHAR_T=3, INTEGER_T=4, REAL_T=5, RECORD_T=6, SCALARINT_T=7, SCALAR_T=8, STRING_T=9, SUBRANGE_T=10 } type; } *TypeKind; struct VariableKind { struct Symbol *typeSym; int byRef; } *VarKind; } kindPtr; int lvl; int typeOriginator; int offset; int size; int isAddress; int isRecordHead; struct Symbol *next; } *

return_type: void

user_defined_types: struct Symbol { char *name; enum kind_t kind; union kind_union kindPtr; int lvl; int typeOriginator; int offset; int size; int isAddress; int isRecordHead; struct Symbol *next; }

user_defined_types: union kind_union { struct ConstantKind *ConstKind; struct FunctionKind *FuncKind; struct ParamKind *ParamKind; struct ProcedureKind *ProcKind; struct TypeKind *TypeKind; struct VariableKind *VarKind; }

user_defined_types: struct ConstantKind { int constResultFlag; struct Symbol *typeSym; union anonymous_constant_value value; }

user_defined_types: struct FunctionKind { struct Symbol *typeSym; struct ElementArray *params; char *label; int invocationInstance; }

user_defined_types: struct TypeKind { union type_union typePtr; enum type_t type; }

user_defined_types: union anonymous_constant_value { struct Boolean Boolean; struct Char Char; struct Integer Integer; struct Real Real; struct String String; }

user_defined_types: union type_union { struct Array *Array; struct Function *Function; struct Procedure *Procedure; struct Record *Record; struct Scalar *Scalar; struct StringType *String; struct Subrange *Subrange; }

user_defined_types: struct Function { struct ParamArray *params; struct Symbol *returnTypeSym; char *label; }

user_defined_types: struct ParamArray { struct Param **data; unsigned int len; unsigned int nElements; }

user_defined_types: struct hash { struct hashElement *elements[1000]; int offset[1024]; unsigned int (*hashFunction)(); int lexLevel; }

user_defined_types: struct Param { char *name; enum type_t type; struct Symbol *typeSym; }


emitGotoLoopTop

decompiled_code:
void emitGotoLoopTop()
{
unsigned int v0; // eax
unsigned int v1; // eax

if ( doNotEmit )
{
doNotEmit = 1;
}
else
{
v0 = peekLabelStackTop(loopLabelStack);
emitComment("Return to top of %s%d", "LOOP", v0);
v1 = peekLabelStackTop(loopLabelStack);
emitStmt(128LL, "GOTO %s%d", "LOOP", v1);
}
}

canonical_decompiled_code:
void func6()
{
unsigned int v0; // eax
unsigned int v1; // eax

if ( doNotEmit )
{
doNotEmit = 1;
}
else
{
v0 = peekLabelStackTop(loopLabelStack);
emitComment("Return to top of %s%d", "LOOP", v0);
v1 = peekLabelStackTop(loopLabelStack);
emitStmt(128LL, "GOTO %s%d", "LOOP", v1);
}
}

original_code:
void emitGotoLoopTop() {
 do { if(!(1) || (doNotEmit)) { doNotEmit = 1; return; }} while (0);
 emitComment("Return to top of %s%d",
     "LOOP", peekLabelStackTop(loopLabelStack));
 emitStmt(128, "GOTO %s%d",
     "LOOP", peekLabelStackTop(loopLabelStack));
}


emitEndWhile

decompiled_code:
void emitEndWhile()
{
unsigned int v0; // eax
int v1; // eax

if ( doNotEmit )
{
doNotEmit = 1;
}
else
{
v0 = peekLabelStackTop(loopLabelStack);
emitComment("End of WHILE loop %s%d", "LOOP", v0);
v1 = peekLabelStackTop(loopLabelStack);
emitLabel(128LL, "%s%d", "LOOP", (unsigned int)(v1 + 1));
popLabels(loopLabelStack);
}
}

canonical_decompiled_code:
void func7()
{
unsigned int v0; // eax
int v1; // eax

if ( doNotEmit )
{
doNotEmit = 1;
}
else
{
v0 = peekLabelStackTop(loopLabelStack);
emitComment("End of WHILE loop %s%d", "LOOP", v0);
v1 = peekLabelStackTop(loopLabelStack);
emitLabel(128LL, "%s%d", "LOOP", (unsigned int)(v1 + 1));
popLabels(loopLabelStack);
}
}

original_code:
void emitEndWhile() {
 do { if(!(1) || (doNotEmit)) { doNotEmit = 1; return; }} while (0);
 emitComment("End of WHILE loop %s%d",
     "LOOP", peekLabelStackTop(loopLabelStack));
 emitLabel(128, "%s%d",
     "LOOP", peekLabelStackTop(loopLabelStack) + 1);
 popLabels(loopLabelStack);
}


emitGotoLoopEnd

decompiled_code:
void emitGotoLoopEnd()
{
unsigned int v0; // eax
int v1; // eax

if ( doNotEmit )
{
doNotEmit = 1;
}
else
{
v0 = peekLabelStackTop(loopLabelStack);
emitComment("Go to end of %s%d", "LOOP", v0);
v1 = peekLabelStackTop(loopLabelStack);
emitStmt(128LL, "GOTO %s%d", "LOOP", (unsigned int)(v1 + 1));
}
}

canonical_decompiled_code:
void func8()
{
unsigned int v0; // eax
int v1; // eax

if ( doNotEmit )
{
doNotEmit = 1;
}
else
{
v0 = peekLabelStackTop(loopLabelStack);
emitComment("Go to end of %s%d", "LOOP", v0);
v1 = peekLabelStackTop(loopLabelStack);
emitStmt(128LL, "GOTO %s%d", "LOOP", (unsigned int)(v1 + 1));
}
}

original_code:
void emitGotoLoopEnd() {
 do { if(!(1) || (doNotEmit)) { doNotEmit = 1; return; }} while (0);
 emitComment("Go to end of %s%d",
     "LOOP", peekLabelStackTop(loopLabelStack));
 emitStmt(128, "GOTO %s%d",
     "LOOP", peekLabelStackTop(loopLabelStack) + 1);
}


allocationErrorCheck

decompiled_code:
void __fastcall allocationErrorCheck(__int64 a1)
{
if ( !a1 )
err(1, "Failed to allocate memory for kind ptr!");
}

canonical_decompiled_code:
void __fastcall func0(__int64 a1)
{
if ( !a1 )
err(1, "Failed to allocate memory for kind ptr!");
}

original_code:
void
allocationErrorCheck(void *p)
{
 if (!p) {
  err(1, "Failed to allocate memory for kind ptr!");
  exit(1);
 }
}

variable_types:
p
void *


allocateConstantKind

decompiled_code:
void *allocateConstantKind()
{
void *v0; // rbx

v0 = calloc(1uLL, 0x20uLL);
allocationErrorCheck((__int64)v0);
return v0;
}

canonical_decompiled_code:
void *func1()
{
void *v0; // rbx

v0 = calloc(1uLL, 0x20uLL);
func0((__int64)v0);
return v0;
}

original_code:
struct ConstantKind *
allocateConstantKind()
{
 struct ConstantKind *ck = calloc(1, sizeof(struct ConstantKind));
 allocationErrorCheck(ck);
 return ck;
}

canonical_original_code:
struct ConstantKind *allocateConstantKind()
{
 struct ConstantKind *ck = calloc(1, sizeof(struct ConstantKind));
 allocationErrorCheck(ck);
 return ck;
}

variable_types: struct ConstantKind { int constResultFlag; struct Symbol { char *name; enum kind_t { CONST_KIND=0, FUNC_KIND=1, PARAM_KIND=2, PROC_KIND=3, TYPE_KIND=4, VAR_KIND=5 } kind; union kind_union { struct ConstantKind *ConstKind; struct FunctionKind { struct Symbol *typeSym; struct ElementArray { void **data; unsigned int len; unsigned int nElements; } *params; char *label; int invocationInstance; } *FuncKind; struct ParamKind { struct Symbol *typeSym; int byRef; } *ParamKind; struct ProcedureKind { struct ElementArray *params; char *label; } *ProcKind; struct TypeKind { union type_union { struct Array { struct Symbol *baseTypeSym; struct Symbol *indexTypeSym; } *Array; struct Function { struct ParamArray { struct Param { char *name; enum type_t { VOID_T=0, ARRAY_T=1, BOOLEAN_T=2, CHAR_T=3, INTEGER_T=4, REAL_T=5, RECORD_T=6, SCALARINT_T=7, SCALAR_T=8, STRING_T=9, SUBRANGE_T=10 } type; struct Symbol *typeSym; } **data; unsigned int len; unsigned int nElements; } *params; struct Symbol *returnTypeSym; char *label; } *Function; struct Procedure { struct ParamArray *params; char *label; } *Procedure; struct Record { struct hash { struct hashElement { char *key; struct Symbol *symbol; struct hashElement *prev; struct hashElement *next; } *elements[1000]; int offset[1024]; unsigned int (*hashFunction)(); int lexLevel; } *hash; } *Record; struct Scalar { struct ElementArray *consts; } *Scalar; struct StringType { unsigned int strlen; } *String; struct Subrange { int high; int low; struct Symbol *baseTypeSym; } *Subrange; } typePtr; enum type_t { VOID_T=0, ARRAY_T=1, BOOLEAN_T=2, CHAR_T=3, INTEGER_T=4, REAL_T=5, RECORD_T=6, SCALARINT_T=7, SCALAR_T=8, STRING_T=9, SUBRANGE_T=10 } type; } *TypeKind; struct VariableKind { struct Symbol *typeSym; int byRef; } *VarKind; } kindPtr; int lvl; int typeOriginator; int offset; int size; int isAddress; int isRecordHead; struct Symbol *next; } *typeSym; union anonymous_constant_value { struct Boolean { int value; } Boolean; struct Char { unsigned char value; } Char; struct Integer { int value; } Integer; struct Real { double value; } Real; struct String { char *str; unsigned int strlen; } String; } value; } *


allocateFunctionKind

decompiled_code:
void *allocateFunctionKind()
{
void *v0; // rbx

v0 = calloc(1uLL, 0x20uLL);
allocationErrorCheck((__int64)v0);
return v0;
}

canonical_decompiled_code:
void *func2()
{
void *v0; // rbx

v0 = calloc(1uLL, 0x20uLL);
func0((__int64)v0);
return v0;
}

original_code:
struct FunctionKind *
allocateFunctionKind()
{
 struct FunctionKind *fk = calloc(1, sizeof(struct FunctionKind));
 allocationErrorCheck(fk);
 return fk;
}

canonical_original_code:
struct FunctionKind *allocateFunctionKind()
{
 struct FunctionKind *fk = calloc(1, sizeof(struct FunctionKind));
 allocationErrorCheck(fk);
 return fk;
}

variable_types: struct FunctionKind { struct Symbol { char *name; enum kind_t { CONST_KIND=0, FUNC_KIND=1, PARAM_KIND=2, PROC_KIND=3, TYPE_KIND=4, VAR_KIND=5 } kind; union kind_union { struct ConstantKind { int constResultFlag; struct Symbol *typeSym; union anonymous_constant_value { struct Boolean { int value; } Boolean; struct Char { unsigned char value; } Char; struct Integer { int value; } Integer; struct Real { double value; } Real; struct String { char *str; unsigned int strlen; } String; } value; } *ConstKind; struct FunctionKind *FuncKind; struct ParamKind { struct Symbol *typeSym; int byRef; } *ParamKind; struct ProcedureKind { struct ElementArray { void **data; unsigned int len; unsigned int nElements; } *params; char *label; } *ProcKind; struct TypeKind { union type_union { struct Array { struct Symbol *baseTypeSym; struct Symbol *indexTypeSym; } *Array; struct Function { struct ParamArray { struct Param { char *name; enum type_t { VOID_T=0, ARRAY_T=1, BOOLEAN_T=2, CHAR_T=3, INTEGER_T=4, REAL_T=5, RECORD_T=6, SCALARINT_T=7, SCALAR_T=8, STRING_T=9, SUBRANGE_T=10 } type; struct Symbol *typeSym; } **data; unsigned int len; unsigned int nElements; } *params; struct Symbol *returnTypeSym; char *label; } *Function; struct Procedure { struct ParamArray *params; char *label; } *Procedure; struct Record { struct hash { struct hashElement { char *key; struct Symbol *symbol; struct hashElement *prev; struct hashElement *next; } *elements[1000]; int offset[1024]; unsigned int (*hashFunction)(); int lexLevel; } *hash; } *Record; struct Scalar { struct ElementArray *consts; } *Scalar; struct StringType { unsigned int strlen; } *String; struct Subrange { int high; int low; struct Symbol *baseTypeSym; } *Subrange; } typePtr; enum type_t { VOID_T=0, ARRAY_T=1, BOOLEAN_T=2, CHAR_T=3, INTEGER_T=4, REAL_T=5, RECORD_T=6, SCALARINT_T=7, SCALAR_T=8, STRING_T=9, SUBRANGE_T=10 } type; } *TypeKind; struct VariableKind { struct Symbol *typeSym; int byRef; } *VarKind; } kindPtr; int lvl; int typeOriginator; int offset; int size; int isAddress; int isRecordHead; struct Symbol *next; } *typeSym; struct ElementArray *params; char *label; int invocationInstance; } *

user_defined_types: struct ProcedureKind { struct ElementArray *params; char *label; }


allocateParamKind

decompiled_code:
void *allocateParamKind()
{
void *v0; // rbx

v0 = calloc(1uLL, 0x10uLL);
allocationErrorCheck((__int64)v0);
return v0;
}

canonical_decompiled_code:
void *func3()
{
void *v0; // rbx

v0 = calloc(1uLL, 0x10uLL);
func0((__int64)v0);
return v0;
}

original_code:
struct ParamKind *
allocateParamKind()
{
 struct ParamKind *pk = calloc(1, sizeof(struct ParamKind));
 allocationErrorCheck(pk);
 return pk;
}

canonical_original_code:
struct ParamKind *allocateParamKind()
{
 struct ParamKind *pk = calloc(1, sizeof(struct ParamKind));
 allocationErrorCheck(pk);
 return pk;
}

variable_types: struct ParamKind { struct Symbol { char *name; enum kind_t { CONST_KIND=0, FUNC_KIND=1, PARAM_KIND=2, PROC_KIND=3, TYPE_KIND=4, VAR_KIND=5 } kind; union kind_union { struct ConstantKind { int constResultFlag; struct Symbol *typeSym; union anonymous_constant_value { struct Boolean { int value; } Boolean; struct Char { unsigned char value; } Char; struct Integer { int value; } Integer; struct Real { double value; } Real; struct String { char *str; unsigned int strlen; } String; } value; } *ConstKind; struct FunctionKind { struct Symbol *typeSym; struct ElementArray { void **data; unsigned int len; unsigned int nElements; } *params; char *label; int invocationInstance; } *FuncKind; struct ParamKind *ParamKind; struct ProcedureKind { struct ElementArray *params; char *label; } *ProcKind; struct TypeKind { union type_union { struct Array { struct Symbol *baseTypeSym; struct Symbol *indexTypeSym; } *Array; struct Function { struct ParamArray { struct Param { char *name; enum type_t { VOID_T=0, ARRAY_T=1, BOOLEAN_T=2, CHAR_T=3, INTEGER_T=4, REAL_T=5, RECORD_T=6, SCALARINT_T=7, SCALAR_T=8, STRING_T=9, SUBRANGE_T=10 } type; struct Symbol *typeSym; } **data; unsigned int len; unsigned int nElements; } *params; struct Symbol *returnTypeSym; char *label; } *Function; struct Procedure { struct ParamArray *params; char *label; } *Procedure; struct Record { struct hash { struct hashElement { char *key; struct Symbol *symbol; struct hashElement *prev; struct hashElement *next; } *elements[1000]; int offset[1024]; unsigned int (*hashFunction)(); int lexLevel; } *hash; } *Record; struct Scalar { struct ElementArray *consts; } *Scalar; struct StringType { unsigned int strlen; } *String; struct Subrange { int high; int low; struct Symbol *baseTypeSym; } *Subrange; } typePtr; enum type_t { VOID_T=0, ARRAY_T=1, BOOLEAN_T=2, CHAR_T=3, INTEGER_T=4, REAL_T=5, RECORD_T=6, SCALARINT_T=7, SCALAR_T=8, STRING_T=9, SUBRANGE_T=10 } type; } *TypeKind; struct VariableKind { struct Symbol *typeSym; int byRef; } *VarKind; } kindPtr; int lvl; int typeOriginator; int offset; int size; int isAddress; int isRecordHead; struct Symbol *next; } *typeSym; int byRef; } *

user_defined_types: struct ParamKind { struct Symbol *typeSym; int byRef; }


allocateProcedureKind

decompiled_code:
void *allocateProcedureKind()
{
void *v0; // rbx

v0 = calloc(1uLL, 0x10uLL);
allocationErrorCheck((__int64)v0);
return v0;
}

canonical_decompiled_code:
void *func4()
{
void *v0; // rbx

v0 = calloc(1uLL, 0x10uLL);
func0((__int64)v0);
return v0;
}

original_code:
struct ProcedureKind *
allocateProcedureKind()
{
 struct ProcedureKind *pk = calloc(1, sizeof(struct ProcedureKind));
 allocationErrorCheck(pk);
 return pk;
}

canonical_original_code:
struct ProcedureKind *allocateProcedureKind()
{
 struct ProcedureKind *pk = calloc(1, sizeof(struct ProcedureKind));
 allocationErrorCheck(pk);
 return pk;
}

variable_types: struct ProcedureKind { struct ElementArray { void **data; unsigned int len; unsigned int nElements; } *params; char *label; } *


allocateTypeKind

decompiled_code:
void *allocateTypeKind()
{
void *v0; // rbx

v0 = calloc(1uLL, 0x10uLL);
allocationErrorCheck((__int64)v0);
return v0;
}

canonical_decompiled_code:
void *func5()
{
void *v0; // rbx

v0 = calloc(1uLL, 0x10uLL);
func0((__int64)v0);
return v0;
}

original_code:
struct TypeKind *
allocateTypeKind()
{
 struct TypeKind *tk = calloc(1, sizeof(struct TypeKind));
 allocationErrorCheck(tk);
 return tk;
}

canonical_original_code:
struct TypeKind *allocateTypeKind()
{
 struct TypeKind *tk = calloc(1, sizeof(struct TypeKind));
 allocationErrorCheck(tk);
 return tk;
}

variable_types: struct TypeKind { union type_union { struct Array { struct Symbol { char *name; enum kind_t { CONST_KIND=0, FUNC_KIND=1, PARAM_KIND=2, PROC_KIND=3, TYPE_KIND=4, VAR_KIND=5 } kind; union kind_union { struct ConstantKind { int constResultFlag; struct Symbol *typeSym; union anonymous_constant_value { struct Boolean { int value; } Boolean; struct Char { unsigned char value; } Char; struct Integer { int value; } Integer; struct Real { double value; } Real; struct String { char *str; unsigned int strlen; } String; } value; } *ConstKind; struct FunctionKind { struct Symbol *typeSym; struct ElementArray { void **data; unsigned int len; unsigned int nElements; } *params; char *label; int invocationInstance; } *FuncKind; struct ParamKind { struct Symbol *typeSym; int byRef; } *ParamKind; struct ProcedureKind { struct ElementArray *params; char *label; } *ProcKind; struct TypeKind *TypeKind; struct VariableKind { struct Symbol *typeSym; int byRef; } *VarKind; } kindPtr; int lvl; int typeOriginator; int offset; int size; int isAddress; int isRecordHead; struct Symbol *next; } *baseTypeSym; struct Symbol *indexTypeSym; } *Array; struct Function { struct ParamArray { struct Param { char *name; enum type_t { VOID_T=0, ARRAY_T=1, BOOLEAN_T=2, CHAR_T=3, INTEGER_T=4, REAL_T=5, RECORD_T=6, SCALARINT_T=7, SCALAR_T=8, STRING_T=9, SUBRANGE_T=10 } type; struct Symbol *typeSym; } **data; unsigned int len; unsigned int nElements; } *params; struct Symbol *returnTypeSym; char *label; } *Function; struct Procedure { struct ParamArray *params; char *label; } *Procedure; struct Record { struct hash { struct hashElement { char *key; struct Symbol *symbol; struct hashElement *prev; struct hashElement *next; } *elements[1000]; int offset[1024]; unsigned int (*hashFunction)(); int lexLevel; } *hash; } *Record; struct Scalar { struct ElementArray *consts; } *Scalar; struct StringType { unsigned int strlen; } *String; struct Subrange { int high; int low; struct Symbol *baseTypeSym; } *Subrange; } typePtr; enum type_t { VOID_T=0, ARRAY_T=1, BOOLEAN_T=2, CHAR_T=3, INTEGER_T=4, REAL_T=5, RECORD_T=6, SCALARINT_T=7, SCALAR_T=8, STRING_T=9, SUBRANGE_T=10 } type; } *

user_defined_types: struct Array { struct Symbol *baseTypeSym; struct Symbol *indexTypeSym; }


allocateVariableKind

decompiled_code:
void *allocateVariableKind()
{
void *v0; // rbx

v0 = calloc(1uLL, 0x10uLL);
allocationErrorCheck((__int64)v0);
return v0;
}

canonical_decompiled_code:
void *func6()
{
void *v0; // rbx

v0 = calloc(1uLL, 0x10uLL);
func0((__int64)v0);
return v0;
}

original_code:
struct VariableKind *
allocateVariableKind()
{
 struct VariableKind *vk = calloc(1, sizeof(struct VariableKind));
 allocationErrorCheck(vk);
 return vk;
}

canonical_original_code:
struct VariableKind *allocateVariableKind()
{
 struct VariableKind *vk = calloc(1, sizeof(struct VariableKind));
 allocationErrorCheck(vk);
 return vk;
}

variable_types: struct VariableKind { struct Symbol { char *name; enum kind_t { CONST_KIND=0, FUNC_KIND=1, PARAM_KIND=2, PROC_KIND=3, TYPE_KIND=4, VAR_KIND=5 } kind; union kind_union { struct ConstantKind { int constResultFlag; struct Symbol *typeSym; union anonymous_constant_value { struct Boolean { int value; } Boolean; struct Char { unsigned char value; } Char; struct Integer { int value; } Integer; struct Real { double value; } Real; struct String { char *str; unsigned int strlen; } String; } value; } *ConstKind; struct FunctionKind { struct Symbol *typeSym; struct ElementArray { void **data; unsigned int len; unsigned int nElements; } *params; char *label; int invocationInstance; } *FuncKind; struct ParamKind { struct Symbol *typeSym; int byRef; } *ParamKind; struct ProcedureKind { struct ElementArray *params; char *label; } *ProcKind; struct TypeKind { union type_union { struct Array { struct Symbol *baseTypeSym; struct Symbol *indexTypeSym; } *Array; struct Function { struct ParamArray { struct Param { char *name; enum type_t { VOID_T=0, ARRAY_T=1, BOOLEAN_T=2, CHAR_T=3, INTEGER_T=4, REAL_T=5, RECORD_T=6, SCALARINT_T=7, SCALAR_T=8, STRING_T=9, SUBRANGE_T=10 } type; struct Symbol *typeSym; } **data; unsigned int len; unsigned int nElements; } *params; struct Symbol *returnTypeSym; char *label; } *Function; struct Procedure { struct ParamArray *params; char *label; } *Procedure; struct Record { struct hash { struct hashElement { char *key; struct Symbol *symbol; struct hashElement *prev; struct hashElement *next; } *elements[1000]; int offset[1024]; unsigned int (*hashFunction)(); int lexLevel; } *hash; } *Record; struct Scalar { struct ElementArray *consts; } *Scalar; struct StringType { unsigned int strlen; } *String; struct Subrange { int high; int low; struct Symbol *baseTypeSym; } *Subrange; } typePtr; enum type_t { VOID_T=0, ARRAY_T=1, BOOLEAN_T=2, CHAR_T=3, INTEGER_T=4, REAL_T=5, RECORD_T=6, SCALARINT_T=7, SCALAR_T=8, STRING_T=9, SUBRANGE_T=10 } type; } *TypeKind; struct VariableKind *VarKind; } kindPtr; int lvl; int typeOriginator; int offset; int size; int isAddress; int isRecordHead; struct Symbol *next; } *typeSym; int byRef; } *

user_defined_types: struct VariableKind { struct Symbol *typeSym; int byRef; }


allocateKindPtr

decompiled_code:
void *__fastcall allocateKindPtr(__int64 a1)
{
void *result; // rax

*(_DWORD *)(a1 + 28) = 0;
result = (void *)*(unsigned int *)(a1 + 8);
switch ( *(_DWORD *)(a1 + 8) )
{
case 0:
result = allocateConstantKind();
*(_QWORD *)(a1 + 16) = result;
break;
case 1:
result = allocateFunctionKind();
*(_QWORD *)(a1 + 16) = result;
break;
case 2:
result = allocateParamKind();
*(_QWORD *)(a1 + 16) = result;
break;
case 3:
result = allocateProcedureKind();
*(_QWORD *)(a1 + 16) = result;
break;
case 4:
result = allocateTypeKind();
*(_QWORD *)(a1 + 16) = result;
*(_DWORD *)(a1 + 28) = 1;
break;
case 5:
result = allocateVariableKind();
*(_QWORD *)(a1 + 16) = result;
break;
default:
return result;
}
return result;
}

canonical_decompiled_code:
void *__fastcall func7(__int64 a1)
{
void *result; // rax

*(_DWORD *)(a1 + 28) = 0;
result = (void *)*(unsigned int *)(a1 + 8);
switch ( *(_DWORD *)(a1 + 8) )
{
case 0:
result = func1();
*(_QWORD *)(a1 + 16) = result;
break;
case 1:
result = func2();
*(_QWORD *)(a1 + 16) = result;
break;
case 2:
result = func3();
*(_QWORD *)(a1 + 16) = result;
break;
case 3:
result = func4();
*(_QWORD *)(a1 + 16) = result;
break;
case 4:
result = func5();
*(_QWORD *)(a1 + 16) = result;
*(_DWORD *)(a1 + 28) = 1;
break;
case 5:
result = func6();
*(_QWORD *)(a1 + 16) = result;
break;
default:
return result;
}
return result;
}

original_code:
void
allocateKindPtr(Symbol *s)
{
 s->typeOriginator = 0;
 if (!s) return;
 s->typeOriginator = 0;
 switch (s->kind) {
 case CONST_KIND:
  s->kindPtr.ConstKind = allocateConstantKind();
  break;
 case FUNC_KIND:
  s->kindPtr.FuncKind = allocateFunctionKind();
  break;
 case PARAM_KIND:
  s->kindPtr.ParamKind = allocateParamKind();
  break;
 case PROC_KIND:
  s->kindPtr.ProcKind = allocateProcedureKind();
  break;
 case TYPE_KIND:
  s->kindPtr.TypeKind = allocateTypeKind();
  s->typeOriginator = 1;
  break;
 case VAR_KIND:
  s->kindPtr.VarKind = allocateVariableKind();
  break;
 default:
  break;
 }
}

canonical_original_code:
void allocateKindPtr(struct Symbol *s)
{
 s->typeOriginator = 0;
 if (!s) return;
 s->typeOriginator = 0;
 switch (s->kind) {
 case CONST_KIND:
  s->kindPtr.ConstKind = allocateConstantKind();
  break;
 case FUNC_KIND:
  s->kindPtr.FuncKind = allocateFunctionKind();
  break;
 case PARAM_KIND:
  s->kindPtr.ParamKind = allocateParamKind();
  break;
 case PROC_KIND:
  s->kindPtr.ProcKind = allocateProcedureKind();
  break;
 case TYPE_KIND:
  s->kindPtr.TypeKind = allocateTypeKind();
  s->typeOriginator = 1;
  break;
 case VAR_KIND:
  s->kindPtr.VarKind = allocateVariableKind();
  break;
 default:
  break;
 }
}

user_defined_types: enum kind_t { CONST_KIND=0, FUNC_KIND=1, PARAM_KIND=2, PROC_KIND=3, TYPE_KIND=4, VAR_KIND=5 }

user_defined_types: enum type_t { VOID_T=0, ARRAY_T=1, BOOLEAN_T=2, CHAR_T=3, INTEGER_T=4, REAL_T=5, RECORD_T=6, SCALARINT_T=7, SCALAR_T=8, STRING_T=9, SUBRANGE_T=10 }

user_defined_types: struct String { char *str; unsigned int strlen; }

user_defined_types: struct ElementArray { void **data; unsigned int len; unsigned int nElements; }

user_defined_types: struct Procedure { struct ParamArray *params; char *label; }

user_defined_types: struct Scalar { struct ElementArray *consts; }

user_defined_types: struct StringType { unsigned int strlen; }

user_defined_types: struct Subrange { int high; int low; struct Symbol *baseTypeSym; }

user_defined_types: struct hashElement { char *key; struct Symbol *symbol; struct hashElement *prev; struct hashElement *next; }


getConstVal

decompiled_code:
__int64 __fastcall getConstVal(__int64 a1)
{
if ( !a1 )
err(1, "NULL argument passed to getConstVal");
return *(_QWORD *)(a1 + 16) + 16LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
if ( !a1 )
err(1, "NULL argument passed to getConstVal");
return *(_QWORD *)(a1 + 16) + 16LL;
}

original_code:
AnonConstVal *
getConstVal(Symbol *s)
{
 if (s == ((void *)0)) {
  err(1, "NULL argument passed to getConstVal");
 }
 return &(s->kindPtr.ConstKind->value);
}

canonical_original_code:
union anonymous_constant_value *getConstVal(struct Symbol *s)
{
 if (s == ((void *)0)) {
  err(1, "NULL argument passed to getConstVal");
 }
 return &(s->kindPtr.ConstKind->value);
}

variable_types: struct Symbol { char *name; enum kind_t { CONST_KIND=0, FUNC_KIND=1, PARAM_KIND=2, PROC_KIND=3, TYPE_KIND=4, VAR_KIND=5 } kind; union kind_union { struct ConstantKind { int constResultFlag; struct Symbol *typeSym; union anonymous_constant_value value; } *ConstKind; struct FunctionKind { struct Symbol *typeSym; struct ElementArray { void **data; unsigned int len; unsigned int nElements; } *params; char *label; int invocationInstance; } *FuncKind; struct ParamKind { struct Symbol *typeSym; int byRef; } *ParamKind; struct ProcedureKind { struct ElementArray *params; char *label; } *ProcKind; struct TypeKind { union type_union { struct Array { struct Symbol *baseTypeSym; struct Symbol *indexTypeSym; } *Array; struct Function { struct ParamArray { struct Param { char *name; enum type_t { VOID_T=0, ARRAY_T=1, BOOLEAN_T=2, CHAR_T=3, INTEGER_T=4, REAL_T=5, RECORD_T=6, SCALARINT_T=7, SCALAR_T=8, STRING_T=9, SUBRANGE_T=10 } type; struct Symbol *typeSym; } **data; unsigned int len; unsigned int nElements; } *params; struct Symbol *returnTypeSym; char *label; } *Function; struct Procedure { struct ParamArray *params; char *label; } *Procedure; struct Record { struct hash { struct hashElement { char *key; struct Symbol *symbol; struct hashElement *prev; struct hashElement *next; } *elements[1000]; int offset[1024]; unsigned int (*hashFunction)(); int lexLevel; } *hash; } *Record; struct Scalar { struct ElementArray *consts; } *Scalar; struct StringType { unsigned int strlen; } *String; struct Subrange { int high; int low; struct Symbol *baseTypeSym; } *Subrange; } typePtr; enum type_t { VOID_T=0, ARRAY_T=1, BOOLEAN_T=2, CHAR_T=3, INTEGER_T=4, REAL_T=5, RECORD_T=6, SCALARINT_T=7, SCALAR_T=8, STRING_T=9, SUBRANGE_T=10 } type; } *TypeKind; struct VariableKind { struct Symbol *typeSym; int byRef; } *VarKind; } kindPtr; int lvl; int typeOriginator; int offset; int size; int isAddress; int isRecordHead; struct Symbol *next; } *

return_type: union anonymous_constant_value { struct Boolean { int value; } Boolean; struct Char { unsigned char value; } Char; struct Integer { int value; } Integer; struct Real { double value; } Real; struct String { char *str; unsigned int strlen; } String; } *

user_defined_types: struct Symbol { char *name; enum kind_t kind; union kind_union kindPtr; int lvl; int typeOriginator; int offset; int size; int isAddress; int isRecordHead; struct Symbol *next; }

user_defined_types: union anonymous_constant_value { struct Boolean Boolean; struct Char Char; struct Integer Integer; struct Real Real; struct String String; }

user_defined_types: union kind_union { struct ConstantKind *ConstKind; struct FunctionKind *FuncKind; struct ParamKind *ParamKind; struct ProcedureKind *ProcKind; struct TypeKind *TypeKind; struct VariableKind *VarKind; }

user_defined_types: struct FunctionKind { struct Symbol *typeSym; struct ElementArray *params; char *label; int invocationInstance; }

user_defined_types: struct TypeKind { union type_union typePtr; enum type_t type; }

user_defined_types: union type_union { struct Array *Array; struct Function *Function; struct Procedure *Procedure; struct Record *Record; struct Scalar *Scalar; struct StringType *String; struct Subrange *Subrange; }

user_defined_types: struct Function { struct ParamArray *params; struct Symbol *returnTypeSym; char *label; }


getSimpleConstVal

decompiled_code:
void __fastcall getSimpleConstVal(__int64 a1)
{
if ( a1 )
{
switch ( (unsigned int)getType(0.0) )
{
case 2u:
case 3u:
case 4u:
case 5u:
case 7u:
getConstVal(a1);
break;
default:
return;
}
}
}

canonical_decompiled_code:
void __fastcall func9(__int64 a1)
{
if ( a1 )
{
switch ( (unsigned int)getType(0.0) )
{
case 2u:
case 3u:
case 4u:
case 5u:
case 7u:
func8(a1);
break;
default:
return;
}
}
}

original_code:
double
getSimpleConstVal(Symbol *s)
{
 if (!s) return 0;
 switch (getType(s)) {
 case BOOLEAN_T:
  return (double)(getConstVal(s)->Boolean.value);
 case CHAR_T:
  return (double)(getConstVal(s)->Char.value);
 case INTEGER_T:
  return (double)(getConstVal(s)->Integer.value);
 case SCALARINT_T:
  return (double)(getConstVal(s)->Integer.value);
 case REAL_T:
  return (double)(getConstVal(s)->Real.value);
 default:
 return 0;
 }
}

canonical_original_code:
double getSimpleConstVal(struct Symbol *s)
{
 if (!s) return 0;
 switch (getType(s)) {
 case BOOLEAN_T:
  return (double)(getConstVal(s)->Boolean.value);
 case CHAR_T:
  return (double)(getConstVal(s)->Char.value);
 case INTEGER_T:
  return (double)(getConstVal(s)->Integer.value);
 case SCALARINT_T:
  return (double)(getConstVal(s)->Integer.value);
 case REAL_T:
  return (double)(getConstVal(s)->Real.value);
 default:
 return 0;
 }
}

return_type: double

user_defined_types: struct ConstantKind { int constResultFlag; struct Symbol *typeSym; union anonymous_constant_value value; }

user_defined_types: struct ParamKind { struct Symbol *typeSym; int byRef; }

user_defined_types: struct ProcedureKind { struct ElementArray *params; char *label; }

user_defined_types: struct VariableKind { struct Symbol *typeSym; int byRef; }

user_defined_types: struct Array { struct Symbol *baseTypeSym; struct Symbol *indexTypeSym; }

user_defined_types: struct ParamArray { struct Param **data; unsigned int len; unsigned int nElements; }

user_defined_types: struct hash { struct hashElement *elements[1000]; int offset[1024]; unsigned int (*hashFunction)(); int lexLevel; }

user_defined_types: struct Param { char *name; enum type_t type; struct Symbol *typeSym; }


copyConstVal

decompiled_code:
__int64 __fastcall copyConstVal(_DWORD *a1, unsigned int *a2, int a3)
{
__int64 result; // rax

if ( a2 )
{
switch ( a3 )
{
case 2:
result = *a2;
*a1 = result;
break;
case 3:
result = *(unsigned __int8 *)a2;
*(_BYTE *)a1 = result;
break;
case 4:
result = *a2;
*a1 = result;
break;
case 5:
*(_QWORD *)a1 = *(_QWORD *)a2;
break;
case 9:
result = setStringStr(a1, *(_QWORD *)a2, a2[2]);
break;
default:
return result;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(_DWORD *a1, unsigned int *a2, int a3)
{
__int64 result; // rax

if ( a2 )
{
switch ( a3 )
{
case 2:
result = *a2;
*a1 = result;
break;
case 3:
result = *(unsigned __int8 *)a2;
*(_BYTE *)a1 = result;
break;
case 4:
result = *a2;
*a1 = result;
break;
case 5:
*(_QWORD *)a1 = *(_QWORD *)a2;
break;
case 9:
result = setStringStr(a1, *(_QWORD *)a2, a2[2]);
break;
default:
return result;
}
}
return result;
}

original_code:
void
copyConstVal(AnonConstVal *newacl, AnonConstVal * acl, type_t type)
{
 if (!acl) return;
 switch (type) {
 case BOOLEAN_T:
  newacl->Boolean.value = acl->Boolean.value;
  break;
 case CHAR_T:
  newacl->Char.value = acl->Char.value;
  break;
 case INTEGER_T:
  newacl->Integer.value = acl->Integer.value;
  break;
 case REAL_T:
  newacl->Real.value = acl->Real.value;
  break;
 case STRING_T:
  setStringStr(&newacl->String, acl->String.str, acl->String.strlen);
  break;
 default:
  break;
 }
}

canonical_original_code:
void copyConstVal(union anonymous_constant_value *newacl, union anonymous_constant_value *acl, enum type_t type)
{
 if (!acl) return;
 switch (type) {
 case BOOLEAN_T:
  newacl->Boolean.value = acl->Boolean.value;
  break;
 case CHAR_T:
  newacl->Char.value = acl->Char.value;
  break;
 case INTEGER_T:
  newacl->Integer.value = acl->Integer.value;
  break;
 case REAL_T:
  newacl->Real.value = acl->Real.value;
  break;
 case STRING_T:
  setStringStr(&newacl->String, acl->String.str, acl->String.strlen);
  break;
 default:
  break;
 }
}

variable_types: union anonymous_constant_value { struct Boolean { int value; } Boolean; struct Char { unsigned char value; } Char; struct Integer { int value; } Integer; struct Real { double value; } Real; struct String { char *str; unsigned int strlen; } String; } *

variable_types:
acl
union anonymous_constant_value *

variable_types: enum type_t { VOID_T=0, ARRAY_T=1, BOOLEAN_T=2, CHAR_T=3, INTEGER_T=4, REAL_T=5, RECORD_T=6, SCALARINT_T=7, SCALAR_T=8, STRING_T=9, SUBRANGE_T=10 }


isInvocInstance

decompiled_code:
__int64 __fastcall isInvocInstance(__int64 a1)
{
return *(unsigned int *)(*(_QWORD *)(a1 + 16) + 24LL);
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1)
{
return *(unsigned int *)(*(_QWORD *)(a1 + 16) + 24LL);
}

original_code:
int isInvocInstance(Symbol *sym){
 return sym->kindPtr.FuncKind->invocationInstance;
}

canonical_original_code:
int isInvocInstance(struct Symbol *sym){
 return sym->kindPtr.FuncKind->invocationInstance;
}

return_type: int

user_defined_types: enum kind_t { CONST_KIND=0, FUNC_KIND=1, PARAM_KIND=2, PROC_KIND=3, TYPE_KIND=4, VAR_KIND=5 }

user_defined_types: enum type_t { VOID_T=0, ARRAY_T=1, BOOLEAN_T=2, CHAR_T=3, INTEGER_T=4, REAL_T=5, RECORD_T=6, SCALARINT_T=7, SCALAR_T=8, STRING_T=9, SUBRANGE_T=10 }

user_defined_types: struct String { char *str; unsigned int strlen; }

user_defined_types: struct ElementArray { void **data; unsigned int len; unsigned int nElements; }

user_defined_types: struct Procedure { struct ParamArray *params; char *label; }

user_defined_types: struct Scalar { struct ElementArray *consts; }

user_defined_types: struct StringType { unsigned int strlen; }

user_defined_types: struct Subrange { int high; int low; struct Symbol *baseTypeSym; }


areKindAssignCompat

decompiled_code:
_BOOL8 __fastcall areKindAssignCompat(__int64 a1, __int64 a2)
{
int v2; // eax
_BOOL4 v3; // edx

v2 = *(_DWORD *)(a1 + 8);
if ( v2 == 5 )
{
v3 = 1;
if ( *(_DWORD *)(a2 + 8) == 1 )
v3 = isInvocInstance(a2) != 0;
}
else
{
v3 = 1;
if ( v2 == 4 )
v3 = *(_DWORD *)(a1 + 40) == 1;
}
return v3;
}

original_code:
int areKindAssignCompat(Symbol *x, Symbol *y){
 if ((x->kind == VAR_KIND) && (y->kind == FUNC_KIND)) {
  if (!isInvocInstance(y)){
   return 0;
  }
 }
 if ((x->kind == TYPE_KIND) && (x->isAddress != 1)) {
  return 0;
 }
 return 1;
}

canonical_original_code:
int areKindAssignCompat(struct Symbol *x, struct Symbol *y){
 if ((x->kind == VAR_KIND) && (y->kind == FUNC_KIND)) {
  if (!isInvocInstance(y)){
   return 0;
  }
 }
 if ((x->kind == TYPE_KIND) && (x->isAddress != 1)) {
  return 0;
 }
 return 1;
}

variable_types:
y
struct Symbol *

user_defined_types: struct Symbol { char *name; enum kind_t kind; union kind_union kindPtr; int lvl; int typeOriginator; int offset; int size; int isAddress; int isRecordHead; struct Symbol *next; }

user_defined_types: union kind_union { struct ConstantKind *ConstKind; struct FunctionKind *FuncKind; struct ParamKind *ParamKind; struct ProcedureKind *ProcKind; struct TypeKind *TypeKind; struct VariableKind *VarKind; }

user_defined_types: struct FunctionKind { struct Symbol *typeSym; struct ElementArray *params; char *label; int invocationInstance; }

user_defined_types: struct TypeKind { union type_union typePtr; enum type_t type; }

user_defined_types: union anonymous_constant_value { struct Boolean Boolean; struct Char Char; struct Integer Integer; struct Real Real; struct String String; }

user_defined_types: union type_union { struct Array *Array; struct Function *Function; struct Procedure *Procedure; struct Record *Record; struct Scalar *Scalar; struct StringType *String; struct Subrange *Subrange; }

user_defined_types: struct Function { struct ParamArray *params; struct Symbol *returnTypeSym; char *label; }

user_defined_types: struct hashElement { char *key; struct Symbol *symbol; struct hashElement *prev; struct hashElement *next; }


procInvok

decompiled_code:
__int64 __fastcall procInvok(__int64 a1, __int64 a2)
{
__int64 v2; // rbp
__int64 v3; // rax
__int64 v4; // rbx
__int64 result; // rax

v2 = a2;
v3 = getGlobalSymbol(symbolTable, a1);
if ( !v3 )
return notDefinedError(a1);
v4 = v3;
if ( !a2 )
v2 = newElementArray();
if ( (unsigned int)isIOProc(v4) )
{
isValidIOProcInvocation(v4, v2);
result = emitPreDefIO(v4, v2);
}
else
{
isValidProcInvocation(v4, v2);
result = emitProcInvok(v4, v2);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
__int64 v2; // rbp
__int64 v3; // rax
__int64 v4; // rbx
__int64 result; // rax

v2 = a2;
v3 = getGlobalSymbol(symbolTable, a1);
if ( !v3 )
return notDefinedError(a1);
v4 = v3;
if ( !a2 )
v2 = newElementArray();
if ( (unsigned int)isIOProc(v4) )
{
isValidIOProcInvocation(v4, v2);
result = emitPreDefIO(v4, v2);
}
else
{
isValidProcInvocation(v4, v2);
result = emitProcInvok(v4, v2);
}
return result;
}

original_code:
void procInvok(char *id, struct ElementArray *ea) {
 Symbol *s = ((void *)0);
 s = getGlobalSymbol(symbolTable, id);
 if (!s) {
  notDefinedError(id);
  return;
 }
 if (!ea) {
  ea = newElementArray();
 }
 if (isIOProc(s)) {
  isValidIOProcInvocation(s, ea);
  emitPreDefIO(s, ea);
 } else {
  isValidProcInvocation(s, ea);
  emitProcInvok(s, ea);
 }
}

canonical_original_code:
void procInvok(char *id, struct ElementArray *ea) {
 struct Symbol *s = ((void *)0);
 s = getGlobalSymbol(symbolTable, id);
 if (!s) {
  notDefinedError(id);
  return;
 }
 if (!ea) {
  ea = newElementArray();
 }
 if (isIOProc(s)) {
  isValidIOProcInvocation(s, ea);
  emitPreDefIO(s, ea);
 } else {
  isValidProcInvocation(s, ea);
  emitProcInvok(s, ea);
 }
}

variable_types:
id
char *

variable_types: struct ElementArray { void **data; unsigned int len; unsigned int nElements; } *

user_defined_types: struct ConstantKind { int constResultFlag; struct Symbol *typeSym; union anonymous_constant_value value; }

user_defined_types: struct ParamKind { struct Symbol *typeSym; int byRef; }

user_defined_types: struct ProcedureKind { struct ElementArray *params; char *label; }

user_defined_types: struct VariableKind { struct Symbol *typeSym; int byRef; }

user_defined_types: struct Array { struct Symbol *baseTypeSym; struct Symbol *indexTypeSym; }

user_defined_types: struct ParamArray { struct Param **data; unsigned int len; unsigned int nElements; }

user_defined_types: struct hash { struct hashElement *elements[1000]; int offset[1024]; unsigned int (*hashFunction)(); int lexLevel; }

user_defined_types: struct Param { char *name; enum type_t type; struct Symbol *typeSym; }


funcInvok

decompiled_code:
__int64 __fastcall funcInvok(__int64 a1, __int64 a2)
{
__int64 v2; // rbp
__int64 v3; // rax
_QWORD *v4; // rbx
__int64 v5; // rdx
__int64 v6; // rax
__int64 result; // rax
__int64 v8; // rax
__int64 v9; // rax

v2 = a2;
v3 = getGlobalSymbol(symbolTable, a1);
if ( !v3 )
{
notDefinedError(a1);
return createLeafNode(0LL);
}
v4 = (_QWORD *)v3;
if ( !a2 )
v2 = newElementArray();
if ( (unsigned int)isPreDefFunc(v4) )
{
v5 = isValidPreDefFuncInvocation(v4, v2);
if ( v5 )
{
v6 = newFuncSym(0LL, *v4, v5, v2);
*(_DWORD *)(v6 + 24) = 0;
*(_QWORD *)(*(_QWORD *)(v6 + 16) + 16LL) = *(_QWORD *)(v4[2] + 16LL);
*(_DWORD *)(*(_QWORD *)(v6 + 16) + 24LL) = 1;
result = createLeafNode(v6);
*(_DWORD *)(result + 8) = -4;
return result;
}
}
else if ( isValidFuncInvocation(v4, v2) )
{
v8 = getTypeSym(v4);
v9 = newFuncSym(*((unsigned int *)v4 + 6), *v4, v8, v2);
*(_QWORD *)(*(_QWORD *)(v9 + 16) + 16LL) = *(_QWORD *)(v4[2] + 16LL);
*(_DWORD *)(*(_QWORD *)(v9 + 16) + 24LL) = 1;
result = createLeafNode(v9);
*(_DWORD *)(result + 8) = -4;
return result;
}
return createLeafNode(0LL);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
__int64 v2; // rbp
__int64 v3; // rax
_QWORD *v4; // rbx
__int64 v5; // rdx
__int64 v6; // rax
__int64 result; // rax
__int64 v8; // rax
__int64 v9; // rax

v2 = a2;
v3 = getGlobalSymbol(symbolTable, a1);
if ( !v3 )
{
notDefinedError(a1);
return createLeafNode(0LL);
}
v4 = (_QWORD *)v3;
if ( !a2 )
v2 = newElementArray();
if ( (unsigned int)isPreDefFunc(v4) )
{
v5 = isValidPreDefFuncInvocation(v4, v2);
if ( v5 )
{
v6 = newFuncSym(0LL, *v4, v5, v2);
*(_DWORD *)(v6 + 24) = 0;
*(_QWORD *)(*(_QWORD *)(v6 + 16) + 16LL) = *(_QWORD *)(v4[2] + 16LL);
*(_DWORD *)(*(_QWORD *)(v6 + 16) + 24LL) = 1;
result = createLeafNode(v6);
*(_DWORD *)(result + 8) = -4;
return result;
}
}
else if ( isValidFuncInvocation(v4, v2) )
{
v8 = getTypeSym(v4);
v9 = newFuncSym(*((unsigned int *)v4 + 6), *v4, v8, v2);
*(_QWORD *)(*(_QWORD *)(v9 + 16) + 16LL) = *(_QWORD *)(v4[2] + 16LL);
*(_DWORD *)(*(_QWORD *)(v9 + 16) + 24LL) = 1;
result = createLeafNode(v9);
*(_DWORD *)(result + 8) = -4;
return result;
}
return createLeafNode(0LL);
}

original_code:
struct treeNode *funcInvok(char *id, struct ElementArray *argv) {
 struct treeNode *funcNode;
 Symbol *s = ((void *)0), *newNodeSym, *typeSym;
 s = getGlobalSymbol(symbolTable, id);
 if (!s) {
  notDefinedError(id);
  return createLeafNode(((void *)0));
 }
 if (!argv) {
  argv = newElementArray();
 }
 if (isPreDefFunc(s)) {
  typeSym = isValidPreDefFuncInvocation(s, argv);
  if (typeSym) {
   newNodeSym = newFuncSym(0, s->name, typeSym, argv);
   newNodeSym->lvl = 0;
   newNodeSym->kindPtr.FuncKind->label =
       s->kindPtr.FuncKind->label;
   newNodeSym->kindPtr.FuncKind->invocationInstance = 1;
   funcNode = createLeafNode(newNodeSym);
   funcNode->opToken = -4;
   return funcNode;
  }
  return createLeafNode(((void *)0));
 }
 if (isValidFuncInvocation(s, argv)) {
  newNodeSym = newFuncSym(s->lvl, s->name, getTypeSym(s), argv);
  newNodeSym->kindPtr.FuncKind->label =
      s->kindPtr.FuncKind->label;
  newNodeSym->kindPtr.FuncKind->invocationInstance = 1;
  funcNode = createLeafNode(newNodeSym);
  funcNode->opToken = -4;
  return funcNode;
 }
 return createLeafNode(((void *)0));
}

canonical_original_code:
struct treeNode *funcInvok(char *id, struct ElementArray *argv) {
 struct treeNode *funcNode;
 struct Symbol *s = ((void *)0); struct Symbol *newNodeSym; struct Symbol *typeSym;
 s = getGlobalSymbol(symbolTable, id);
 if (!s) {
  notDefinedError(id);
  return createLeafNode(((void *)0));
 }
 if (!argv) {
  argv = newElementArray();
 }
 if (isPreDefFunc(s)) {
  typeSym = isValidPreDefFuncInvocation(s, argv);
  if (typeSym) {
   newNodeSym = newFuncSym(0, s->name, typeSym, argv);
   newNodeSym->lvl = 0;
   newNodeSym->kindPtr.FuncKind->label =
       s->kindPtr.FuncKind->label;
   newNodeSym->kindPtr.FuncKind->invocationInstance = 1;
   funcNode = createLeafNode(newNodeSym);
   funcNode->opToken = -4;
   return funcNode;
  }
  return createLeafNode(((void *)0));
 }
 if (isValidFuncInvocation(s, argv)) {
  newNodeSym = newFuncSym(s->lvl, s->name, getTypeSym(s), argv);
  newNodeSym->kindPtr.FuncKind->label =
      s->kindPtr.FuncKind->label;
  newNodeSym->kindPtr.FuncKind->invocationInstance = 1;
  funcNode = createLeafNode(newNodeSym);
  funcNode->opToken = -4;
  return funcNode;
 }
 return createLeafNode(((void *)0));
}

variable_types:
argv
struct ElementArray *

variable_types: struct treeNode { struct Symbol { char *name; enum kind_t { CONST_KIND=0, FUNC_KIND=1, PARAM_KIND=2, PROC_KIND=3, TYPE_KIND=4, VAR_KIND=5 } kind; union kind_union { struct ConstantKind { int constResultFlag; struct Symbol *typeSym; union anonymous_constant_value { struct Boolean { int value; } Boolean; struct Char { unsigned char value; } Char; struct Integer { int value; } Integer; struct Real { double value; } Real; struct String { char *str; unsigned int strlen; } String; } value; } *ConstKind; struct FunctionKind { struct Symbol *typeSym; struct ElementArray { void **data; unsigned int len; unsigned int nElements; } *params; char *label; int invocationInstance; } *FuncKind; struct ParamKind { struct Symbol *typeSym; int byRef; } *ParamKind; struct ProcedureKind { struct ElementArray *params; char *label; } *ProcKind; struct TypeKind { union type_union { struct Array { struct Symbol *baseTypeSym; struct Symbol *indexTypeSym; } *Array; struct Function { struct ParamArray { struct Param { char *name; enum type_t { VOID_T=0, ARRAY_T=1, BOOLEAN_T=2, CHAR_T=3, INTEGER_T=4, REAL_T=5, RECORD_T=6, SCALARINT_T=7, SCALAR_T=8, STRING_T=9, SUBRANGE_T=10 } type; struct Symbol *typeSym; } **data; unsigned int len; unsigned int nElements; } *params; struct Symbol *returnTypeSym; char *label; } *Function; struct Procedure { struct ParamArray *params; char *label; } *Procedure; struct Record { struct hash { struct hashElement { char *key; struct Symbol *symbol; struct hashElement *prev; struct hashElement *next; } *elements[1000]; int offset[1024]; unsigned int (*hashFunction)(); int lexLevel; } *hash; } *Record; struct Scalar { struct ElementArray *consts; } *Scalar; struct StringType { unsigned int strlen; } *String; struct Subrange { int high; int low; struct Symbol *baseTypeSym; } *Subrange; } typePtr; enum type_t { VOID_T=0, ARRAY_T=1, BOOLEAN_T=2, CHAR_T=3, INTEGER_T=4, REAL_T=5, RECORD_T=6, SCALARINT_T=7, SCALAR_T=8, STRING_T=9, SUBRANGE_T=10 } type; } *TypeKind; struct VariableKind { struct Symbol *typeSym; int byRef; } *VarKind; } kindPtr; int lvl; int typeOriginator; int offset; int size; int isAddress; int isRecordHead; struct Symbol *next; } *symbol; int opToken; struct treeNode *parent; struct treeNode *left; struct treeNode *right; } *

user_defined_types: struct treeNode { struct Symbol *symbol; int opToken; struct treeNode *parent; struct treeNode *left; struct treeNode *right; }


createArgList

decompiled_code:
__int64 __fastcall createArgList(__int64 *a1)
{
__int64 v1; // rbx
int v2; // eax
__int64 v3; // rax

if ( !a1 )
return 0LL;
v1 = *a1;
if ( *a1 )
{
v2 = *(_DWORD *)(v1 + 8);
if ( v2 != 3 )
{
if ( v2 == 1 )
{
if ( *(_DWORD *)(*(_QWORD *)(v1 + 16) + 24LL) )
goto LABEL_7;
}
else if ( v2 != 2 )
{
LABEL_7:
v1 = newElementArray();
growElementArray(v1);
appendElement(v1, a1);
return v1;
}
}
v3 = customErrorString("Invalid argument type.");
recordError(v3, yylineno, colno, 2LL);
goto LABEL_7;
}
return v1;
}

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

if ( !a1 )
return 0LL;
v1 = *a1;
if ( *a1 )
{
v2 = *(_DWORD *)(v1 + 8);
if ( v2 != 3 )
{
if ( v2 == 1 )
{
if ( *(_DWORD *)(*(_QWORD *)(v1 + 16) + 24LL) )
goto LABEL_7;
}
else if ( v2 != 2 )
{
LABEL_7:
v1 = newElementArray();
growElementArray(v1);
appendElement(v1, a1);
return v1;
}
}
v3 = customErrorString("Invalid argument type.");
recordError(v3, yylineno, colno, 2LL);
goto LABEL_7;
}
return v1;
}

original_code:
struct ElementArray *createArgList(struct treeNode *arg) {
 struct ElementArray * ea = ((void *)0);
 if (!arg) {
  return ((void *)0);
 }
 if (!(arg->symbol)) return ((void *)0);
 if ( (arg->symbol->kind == PROC_KIND) ||
  ((arg->symbol->kind == FUNC_KIND) &&
   !(arg->symbol->kindPtr.FuncKind->invocationInstance)) ||
  (arg->symbol->kind == PARAM_KIND)
 ){
  errMsg = customErrorString("Invalid argument type.");
  recordError(errMsg, yylineno, colno, SEMANTIC);
 }
 ea = newElementArray();
 growElementArray(ea);
 appendElement(ea, arg);
 return ea;
}

canonical_original_code:
struct ElementArray *createArgList(struct treeNode *arg) {
 struct ElementArray *ea = ((void *)0);
 if (!arg) {
  return ((void *)0);
 }
 if (!(arg->symbol)) return ((void *)0);
 if ( (arg->symbol->kind == PROC_KIND) ||
  ((arg->symbol->kind == FUNC_KIND) &&
   !(arg->symbol->kindPtr.FuncKind->invocationInstance)) ||
  (arg->symbol->kind == PARAM_KIND)
 ){
  errMsg = customErrorString("Invalid argument type.");
  recordError(errMsg, yylineno, colno, SEMANTIC);
 }
 ea = newElementArray();
 growElementArray(ea);
 appendElement(ea, arg);
 return ea;
}

variable_types: struct treeNode { struct Symbol { char *name; enum kind_t { CONST_KIND=0, FUNC_KIND=1, PARAM_KIND=2, PROC_KIND=3, TYPE_KIND=4, VAR_KIND=5 } kind; union kind_union { struct ConstantKind { int constResultFlag; struct Symbol *typeSym; union anonymous_constant_value { struct Boolean { int value; } Boolean; struct Char { unsigned char value; } Char; struct Integer { int value; } Integer; struct Real { double value; } Real; struct String { char *str; unsigned int strlen; } String; } value; } *ConstKind; struct FunctionKind { struct Symbol *typeSym; struct ElementArray *params; char *label; int invocationInstance; } *FuncKind; struct ParamKind { struct Symbol *typeSym; int byRef; } *ParamKind; struct ProcedureKind { struct ElementArray *params; char *label; } *ProcKind; struct TypeKind { union type_union { struct Array { struct Symbol *baseTypeSym; struct Symbol *indexTypeSym; } *Array; struct Function { struct ParamArray { struct Param { char *name; enum type_t { VOID_T=0, ARRAY_T=1, BOOLEAN_T=2, CHAR_T=3, INTEGER_T=4, REAL_T=5, RECORD_T=6, SCALARINT_T=7, SCALAR_T=8, STRING_T=9, SUBRANGE_T=10 } type; struct Symbol *typeSym; } **data; unsigned int len; unsigned int nElements; } *params; struct Symbol *returnTypeSym; char *label; } *Function; struct Procedure { struct ParamArray *params; char *label; } *Procedure; struct Record { struct hash { struct hashElement { char *key; struct Symbol *symbol; struct hashElement *prev; struct hashElement *next; } *elements[1000]; int offset[1024]; unsigned int (*hashFunction)(); int lexLevel; } *hash; } *Record; struct Scalar { struct ElementArray *consts; } *Scalar; struct StringType { unsigned int strlen; } *String; struct Subrange { int high; int low; struct Symbol *baseTypeSym; } *Subrange; } typePtr; enum type_t { VOID_T=0, ARRAY_T=1, BOOLEAN_T=2, CHAR_T=3, INTEGER_T=4, REAL_T=5, RECORD_T=6, SCALARINT_T=7, SCALAR_T=8, STRING_T=9, SUBRANGE_T=10 } type; } *TypeKind; struct VariableKind { struct Symbol *typeSym; int byRef; } *VarKind; } kindPtr; int lvl; int typeOriginator; int offset; int size; int isAddress; int isRecordHead; struct Symbol *next; } *symbol; int opToken; struct treeNode *parent; struct treeNode *left; struct treeNode *right; } *

return_type: struct ElementArray { void **data; unsigned int len; unsigned int nElements; } *

user_defined_types: struct Symbol { char *name; enum kind_t kind; union kind_union kindPtr; int lvl; int typeOriginator; int offset; int size; int isAddress; int isRecordHead; struct Symbol *next; }


concatArgLists

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

result = *((_QWORD *)&a1 + 1) | a1;
if ( a1 != 0 )
{
if ( (_QWORD)a1 )
{
result = a1;
if ( *((_QWORD *)&a1 + 1) )
result = appendElementArray();
}
else
{
result = *((_QWORD *)&a1 + 1);
}
}
return result;
}

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

result = *((_QWORD *)&a1 + 1) | a1;
if ( a1 != 0 )
{
if ( (_QWORD)a1 )
{
result = a1;
if ( *((_QWORD *)&a1 + 1) )
result = appendElementArray();
}
else
{
result = *((_QWORD *)&a1 + 1);
}
}
return result;
}

original_code:
struct ElementArray *concatArgLists(
    struct ElementArray *arr1, struct ElementArray *arr2) {
 struct ElementArray *ea;
 if ((!arr1) && (!arr2)) return ((void *)0);
 if (!arr1) return arr2;
 if (!arr2) return arr1;
 ea = appendElementArray(arr1, arr2);
 return ea;
}

canonical_original_code:
struct ElementArray *concatArgLists(struct ElementArray *arr1, struct ElementArray *arr2) {
 struct ElementArray *ea;
 if ((!arr1) && (!arr2)) return ((void *)0);
 if (!arr1) return arr2;
 if (!arr2) return arr1;
 ea = appendElementArray(arr1, arr2);
 return ea;
}

user_defined_types: struct ElementArray { void **data; unsigned int len; unsigned int nElements; }


emitRelationalSimpleTypeConversion

decompiled_code:
__int64 __fastcall emitRelationalSimpleTypeConversion(const char **a1, const char **a2, _DWORD *a3)
{
__int64 result; // rax

if ( (unsigned int)((__int64 (*)(void))getType)() == 4 && (result = getType(a2), (_DWORD)result == 4) )
{
*a3 = 0;
}
else if ( (unsigned int)getType(a1) == 8 && (result = getType(a2), (_DWORD)result == 8) )
{
*a3 = 0;
}
else if ( (unsigned int)getType(a1) == 5 && (result = getType(a2), (_DWORD)result == 5) )
{
*a3 = 1;
}
else if ( (unsigned int)getType(a1) == 4 && (unsigned int)getType(a2) == 5 )
{
emitComment("Converting %s to a real value.", *a1);
emitStmt(128LL, "ADJUST -1");
emitStmt(128LL, "ITOR");
result = emitStmt(128LL, "ADJUST 1");
*a3 = 1;
}
else
{
result = getType(a1);
if ( (_DWORD)result == 5 )
{
result = getType(a2);
if ( (_DWORD)result == 4 )
{
emitComment("Converting %s to a real value.", *a2);
result = emitStmt(128LL, "ITOR");
*a3 = 1;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(const char **a1, const char **a2, _DWORD *a3)
{
__int64 result; // rax

if ( (unsigned int)((__int64 (*)(void))getType)() == 4 && (result = getType(a2), (_DWORD)result == 4) )
{
*a3 = 0;
}
else if ( (unsigned int)getType(a1) == 8 && (result = getType(a2), (_DWORD)result == 8) )
{
*a3 = 0;
}
else if ( (unsigned int)getType(a1) == 5 && (result = getType(a2), (_DWORD)result == 5) )
{
*a3 = 1;
}
else if ( (unsigned int)getType(a1) == 4 && (unsigned int)getType(a2) == 5 )
{
emitComment("Converting %s to a real value.", *a1);
emitStmt(128LL, "ADJUST -1");
emitStmt(128LL, "ITOR");
result = emitStmt(128LL, "ADJUST 1");
*a3 = 1;
}
else
{
result = getType(a1);
if ( (_DWORD)result == 5 )
{
result = getType(a2);
if ( (_DWORD)result == 4 )
{
emitComment("Converting %s to a real value.", *a2);
result = emitStmt(128LL, "ITOR");
*a3 = 1;
}
}
}
return result;
}

original_code:
static void emitRelationalSimpleTypeConversion(Symbol *x, Symbol *y,
    int *opType)
{
 if ( (getType(x) == INTEGER_T) && (getType(y) == INTEGER_T) ) {
  *opType = 0;
 } else if ((getType(x) == SCALAR_T) && (getType(y) == SCALAR_T)) {
  *opType = 0;
 } else if ( (getType(x) == REAL_T) && (getType(y) == REAL_T) ) {
  *opType = 1;
 } else if ( (getType(x) == INTEGER_T) && (getType(y) == REAL_T) ) {
  emitComment("Converting %s to a real value.", x->name);
  emitStmt(128, "ADJUST -1");
  emitStmt(128, "ITOR");
  emitStmt(128, "ADJUST 1");
  *opType = 1;
 } else if ( (getType(x) == REAL_T) && (getType(y) == INTEGER_T) ) {
  emitComment("Converting %s to a real value.", y->name);
  emitStmt(128, "ITOR");
  *opType = 1;
 }
}

canonical_original_code:
static void emitRelationalSimpleTypeConversion(struct Symbol *x, struct Symbol *y, int *opType)
{
 if ( (getType(x) == INTEGER_T) && (getType(y) == INTEGER_T) ) {
  *opType = 0;
 } else if ((getType(x) == SCALAR_T) && (getType(y) == SCALAR_T)) {
  *opType = 0;
 } else if ( (getType(x) == REAL_T) && (getType(y) == REAL_T) ) {
  *opType = 1;
 } else if ( (getType(x) == INTEGER_T) && (getType(y) == REAL_T) ) {
  emitComment("Converting %s to a real value.", x->name);
  emitStmt(128, "ADJUST -1");
  emitStmt(128, "ITOR");
  emitStmt(128, "ADJUST 1");
  *opType = 1;
 } else if ( (getType(x) == REAL_T) && (getType(y) == INTEGER_T) ) {
  emitComment("Converting %s to a real value.", y->name);
  emitStmt(128, "ITOR");
  *opType = 1;
 }
}

variable_types: struct Symbol { char *name; enum kind_t { CONST_KIND=0, FUNC_KIND=1, PARAM_KIND=2, PROC_KIND=3, TYPE_KIND=4, VAR_KIND=5 } kind; union kind_union { struct ConstantKind { int constResultFlag; struct Symbol *typeSym; union anonymous_constant_value { struct Boolean { int value; } Boolean; struct Char { unsigned char value; } Char; struct Integer { int value; } Integer; struct Real { double value; } Real; struct String { char *str; unsigned int strlen; } String; } value; } *ConstKind; struct FunctionKind { struct Symbol *typeSym; struct ElementArray { void **data; unsigned int len; unsigned int nElements; } *params; char *label; int invocationInstance; } *FuncKind; struct ParamKind { struct Symbol *typeSym; int byRef; } *ParamKind; struct ProcedureKind { struct ElementArray *params; char *label; } *ProcKind; struct TypeKind { union type_union { struct Array { struct Symbol *baseTypeSym; struct Symbol *indexTypeSym; } *Array; struct Function { struct ParamArray { struct Param { char *name; enum type_t { VOID_T=0, ARRAY_T=1, BOOLEAN_T=2, CHAR_T=3, INTEGER_T=4, REAL_T=5, RECORD_T=6, SCALARINT_T=7, SCALAR_T=8, STRING_T=9, SUBRANGE_T=10 } type; struct Symbol *typeSym; } **data; unsigned int len; unsigned int nElements; } *params; struct Symbol *returnTypeSym; char *label; } *Function; struct Procedure { struct ParamArray *params; char *label; } *Procedure; struct Record { struct hash { struct hashElement { char *key; struct Symbol *symbol; struct hashElement *prev; struct hashElement *next; } *elements[1000]; int offset[1024]; unsigned int (*hashFunction)(); int lexLevel; } *hash; } *Record; struct Scalar { struct ElementArray *consts; } *Scalar; struct StringType { unsigned int strlen; } *String; struct Subrange { int high; int low; struct Symbol *baseTypeSym; } *Subrange; } typePtr; enum type_t { VOID_T=0, ARRAY_T=1, BOOLEAN_T=2, CHAR_T=3, INTEGER_T=4, REAL_T=5, RECORD_T=6, SCALARINT_T=7, SCALAR_T=8, STRING_T=9, SUBRANGE_T=10 } type; } *TypeKind; struct VariableKind { struct Symbol *typeSym; int byRef; } *VarKind; } kindPtr; int lvl; int typeOriginator; int offset; int size; int isAddress; int isRecordHead; struct Symbol *next; } *

variable_types:
opType
int *

user_defined_types: union kind_union { struct ConstantKind *ConstKind; struct FunctionKind *FuncKind; struct ParamKind *ParamKind; struct ProcedureKind *ProcKind; struct TypeKind *TypeKind; struct VariableKind *VarKind; }

user_defined_types: struct FunctionKind { struct Symbol *typeSym; struct ElementArray *params; char *label; int invocationInstance; }


emitRelationalOperandValue

decompiled_code:
void __fastcall emitRelationalOperandValue(__int64 a1)
{
unsigned int v1; // eax

if ( *(_DWORD *)(a1 + 40) && (v1 = getType(a1), (unsigned int)isSimpleType(v1)) )
{
emitPushAddressValue(a1);
}
else if ( !*(_DWORD *)(a1 + 8) && !(unsigned int)isConstResultSym(a1) || *(_DWORD *)(a1 + 8) != 4 )
{
emitPushSymbolValue(a1);
}
}

canonical_decompiled_code:
void __fastcall func2(__int64 a1)
{
unsigned int v1; // eax

if ( *(_DWORD *)(a1 + 40) && (v1 = getType(a1), (unsigned int)isSimpleType(v1)) )
{
emitPushAddressValue(a1);
}
else if ( !*(_DWORD *)(a1 + 8) && !(unsigned int)isConstResultSym(a1) || *(_DWORD *)(a1 + 8) != 4 )
{
emitPushSymbolValue(a1);
}
}

original_code:
static void emitRelationalOperandValue(Symbol *x)
{
 if ( (x->isAddress) && (isSimpleType(getType(x))) ) {
  emitPushAddressValue(x);
 } else if (x->kind == CONST_KIND && !isConstResultSym(x) ) {
  emitPushSymbolValue(x);
 } else if (x->kind != TYPE_KIND) {
  emitPushSymbolValue(x);
 }
}

canonical_original_code:
static void emitRelationalOperandValue(struct Symbol *x)
{
 if ( (x->isAddress) && (isSimpleType(getType(x))) ) {
  emitPushAddressValue(x);
 } else if (x->kind == CONST_KIND && !isConstResultSym(x) ) {
  emitPushSymbolValue(x);
 } else if (x->kind != TYPE_KIND) {
  emitPushSymbolValue(x);
 }
}

user_defined_types: enum kind_t { CONST_KIND=0, FUNC_KIND=1, PARAM_KIND=2, PROC_KIND=3, TYPE_KIND=4, VAR_KIND=5 }

user_defined_types: struct TypeKind { union type_union typePtr; enum type_t type; }

user_defined_types: union anonymous_constant_value { struct Boolean Boolean; struct Char Char; struct Integer Integer; struct Real Real; struct String String; }

user_defined_types: enum type_t { VOID_T=0, ARRAY_T=1, BOOLEAN_T=2, CHAR_T=3, INTEGER_T=4, REAL_T=5, RECORD_T=6, SCALARINT_T=7, SCALAR_T=8, STRING_T=9, SUBRANGE_T=10 }

user_defined_types: struct String { char *str; unsigned int strlen; }

user_defined_types: struct Procedure { struct ParamArray *params; char *label; }

user_defined_types: struct Scalar { struct ElementArray *consts; }

user_defined_types: struct StringType { unsigned int strlen; }

user_defined_types: struct Subrange { int high; int low; struct Symbol *baseTypeSym; }


emitRelationalPrep

decompiled_code:
void __fastcall emitRelationalPrep(__int64 a1, __int64 a2, _DWORD *a3)
{
unsigned int v4; // eax
unsigned int v5; // eax

if ( a1 )
{
if ( doNotEmit )
{
doNotEmit = 1;
return;
}
if ( !a2 )
{
doNotEmit = 1;
return;
}
emitRelationalOperandValue(a1);
emitRelationalOperandValue(a2);
if ( *(_DWORD *)(a1 + 40) && *(_DWORD *)(a2 + 40) )
{
handleSpecialCase(a1, a2, a3);
v5 = getType(a1);
if ( !(unsigned int)isSimpleType(v5) )
goto LABEL_10;
}
else
{
if ( !*(_DWORD *)(a1 + 8)
&& (unsigned int)isConstResultSym(a1)
&& !*(_DWORD *)(a2 + 8)
&& (unsigned int)isConstResultSym(a2) )
{
*a3 = -1;
return;
}
v4 = getType(a1);
if ( !(unsigned int)isSimpleType(v4) )
{
LABEL_10:
*a3 = 2 * ((unsigned int)getType(a1) != 8);
return;
}
}
emitRelationalSimpleTypeConversion((const char **)a1, (const char **)a2, a3);
return;
}
doNotEmit = 1;
}

canonical_decompiled_code:
void __fastcall func3(__int64 a1, __int64 a2, _DWORD *a3)
{
unsigned int v4; // eax
unsigned int v5; // eax

if ( a1 )
{
if ( doNotEmit )
{
doNotEmit = 1;
return;
}
if ( !a2 )
{
doNotEmit = 1;
return;
}
func2(a1);
func2(a2);
if ( *(_DWORD *)(a1 + 40) && *(_DWORD *)(a2 + 40) )
{
func0(a1, a2, a3);
v5 = getType(a1);
if ( !(unsigned int)isSimpleType(v5) )
goto LABEL_10;
}
else
{
if ( !*(_DWORD *)(a1 + 8)
&& (unsigned int)isConstResultSym(a1)
&& !*(_DWORD *)(a2 + 8)
&& (unsigned int)isConstResultSym(a2) )
{
*a3 = -1;
return;
}
v4 = getType(a1);
if ( !(unsigned int)isSimpleType(v4) )
{
LABEL_10:
*a3 = 2 * ((unsigned int)getType(a1) != 8);
return;
}
}
func1((const char **)a1, (const char **)a2, a3);
return;
}
doNotEmit = 1;
}

original_code:
static void emitRelationalPrep(Symbol *x, Symbol *y, int *opType)
{
 do { if(!(x) || (doNotEmit)) { doNotEmit = 1; return; }} while (0);
 do { if(!(y) || (doNotEmit)) { doNotEmit = 1; return; }} while (0);
 emitRelationalOperandValue(x);
 emitRelationalOperandValue(y);
 if (x->isAddress && y->isAddress) {
  handleSpecialCase(x, y, opType);
  if (isSimpleType(getType(x))) {
   emitRelationalSimpleTypeConversion(x, y, opType);
   return;
  } else if (getType(x) == SCALAR_T) {
   *opType = 0;
  } else *opType = 2;
  return;
 }
 if ( ( x->kind == CONST_KIND && isConstResultSym(x) )
  && ( y->kind == CONST_KIND && isConstResultSym(y) ) ) {
  *opType = -1;
  return;
 }
 if (isSimpleType(getType(x))) {
      emitRelationalSimpleTypeConversion(x, y, opType);
  return;
 }
 if (getType(x) == SCALAR_T) {
  *opType = 0;
  return;
 } else *opType = 2;
}

canonical_original_code:
static void emitRelationalPrep(struct Symbol *x, struct Symbol *y, int *opType)
{
 do { if(!(x) || (doNotEmit)) { doNotEmit = 1; return; }} while (0);
 do { if(!(y) || (doNotEmit)) { doNotEmit = 1; return; }} while (0);
 emitRelationalOperandValue(x);
 emitRelationalOperandValue(y);
 if (x->isAddress && y->isAddress) {
  handleSpecialCase(x, y, opType);
  if (isSimpleType(getType(x))) {
   emitRelationalSimpleTypeConversion(x, y, opType);
   return;
  } else if (getType(x) == SCALAR_T) {
   *opType = 0;
  } else *opType = 2;
  return;
 }
 if ( ( x->kind == CONST_KIND && isConstResultSym(x) )
  && ( y->kind == CONST_KIND && isConstResultSym(y) ) ) {
  *opType = -1;
  return;
 }
 if (isSimpleType(getType(x))) {
      emitRelationalSimpleTypeConversion(x, y, opType);
  return;
 }
 if (getType(x) == SCALAR_T) {
  *opType = 0;
  return;
 } else *opType = 2;
}

user_defined_types: struct ConstantKind { int constResultFlag; struct Symbol *typeSym; union anonymous_constant_value value; }

user_defined_types: struct ParamKind { struct Symbol *typeSym; int byRef; }

user_defined_types: struct ProcedureKind { struct ElementArray *params; char *label; }

user_defined_types: struct VariableKind { struct Symbol *typeSym; int byRef; }

user_defined_types: union type_union { struct Array *Array; struct Function *Function; struct Procedure *Procedure; struct Record *Record; struct Scalar *Scalar; struct StringType *String; struct Subrange *Subrange; }

user_defined_types: struct Array { struct Symbol *baseTypeSym; struct Symbol *indexTypeSym; }

user_defined_types: struct Function { struct ParamArray *params; struct Symbol *returnTypeSym; char *label; }

user_defined_types: struct ParamArray { struct Param **data; unsigned int len; unsigned int nElements; }

user_defined_types: struct hashElement { char *key; struct Symbol *symbol; struct hashElement *prev; struct hashElement *next; }


emitEqualsOp

decompiled_code:
__int64 __fastcall emitEqualsOp(__int64 a1, __int64 a2)
{
__int64 result; // rax
unsigned int v3; // eax
unsigned int v4[3]; // [rsp+Ch] [rbp-Ch] BYREF

emitRelationalPrep(a1, a2, v4);
result = v4[0];
switch ( v4[0] )
{
case 1u:
return emitStmt(128LL, "EQR");
case 2u:
emitComment("We are performing 'eq' op on two structured types");
emitComment("We call a pre-defined function to do theoperation ");
v3 = getStrSymLen(a1);
emitStmt(128LL, "PUSH %d", v3);
emitStmt(128LL, "CALL 0, __do_str_eq_op");
emitComment("__do_str_eq_op overwrote our first param, so we");
emitComment("only adjust -2");
result = emitStmt(128LL, "ADJUST -2");
break;
case 0u:
result = emitStmt(128LL, "EQI");
break;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2)
{
__int64 result; // rax
unsigned int v3; // eax
unsigned int v4[3]; // [rsp+Ch] [rbp-Ch] BYREF

func3(a1, a2, v4);
result = v4[0];
switch ( v4[0] )
{
case 1u:
return emitStmt(128LL, "EQR");
case 2u:
emitComment("We are performing 'eq' op on two structured types");
emitComment("We call a pre-defined function to do theoperation ");
v3 = getStrSymLen(a1);
emitStmt(128LL, "PUSH %d", v3);
emitStmt(128LL, "CALL 0, __do_str_eq_op");
emitComment("__do_str_eq_op overwrote our first param, so we");
emitComment("only adjust -2");
result = emitStmt(128LL, "ADJUST -2");
break;
case 0u:
result = emitStmt(128LL, "EQI");
break;
}
return result;
}

original_code:
void emitEqualsOp(Symbol *x, Symbol *y)
{
 int opType;
 emitRelationalPrep(x, y, &opType);
 switch (opType) {
 case 0:
  emitStmt(128, "EQI");
  break;
 case 1:
  emitStmt(128, "EQR");
  break;
 case 2:
  emitComment("We are performing 'eq' op on two structured "
      "types");
  emitComment("We call a pre-defined function to do the"
      "operation ");
  emitStmt(128, "PUSH %d", getStrSymLen(x));
  emitStmt(128, "CALL 0, __do_str_eq_op");
  emitComment("__do_str_eq_op overwrote our first param, so we");
  emitComment("only adjust -2");
  emitStmt(128, "ADJUST -2");
  break;
 case -1:
  break;
 }
}

canonical_original_code:
void emitEqualsOp(struct Symbol *x, struct Symbol *y)
{
 int opType;
 emitRelationalPrep(x, y, &opType);
 switch (opType) {
 case 0:
  emitStmt(128, "EQI");
  break;
 case 1:
  emitStmt(128, "EQR");
  break;
 case 2:
  emitComment("We are performing 'eq' op on two structured "
      "types");
  emitComment("We call a pre-defined function to do the"
      "operation ");
  emitStmt(128, "PUSH %d", getStrSymLen(x));
  emitStmt(128, "CALL 0, __do_str_eq_op");
  emitComment("__do_str_eq_op overwrote our first param, so we");
  emitComment("only adjust -2");
  emitStmt(128, "ADJUST -2");
  break;
 case -1:
  break;
 }
}

variable_types: opType int

user_defined_types: struct Symbol { char *name; enum kind_t kind; union kind_union kindPtr; int lvl; int typeOriginator; int offset; int size; int isAddress; int isRecordHead; struct Symbol *next; }

user_defined_types: enum kind_t { CONST_KIND=0, FUNC_KIND=1, PARAM_KIND=2, PROC_KIND=3, TYPE_KIND=4, VAR_KIND=5 }

user_defined_types: union kind_union { struct ConstantKind *ConstKind; struct FunctionKind *FuncKind; struct ParamKind *ParamKind; struct ProcedureKind *ProcKind; struct TypeKind *TypeKind; struct VariableKind *VarKind; }

user_defined_types: struct FunctionKind { struct Symbol *typeSym; struct ElementArray *params; char *label; int invocationInstance; }

user_defined_types: struct TypeKind { union type_union typePtr; enum type_t type; }

user_defined_types: struct ElementArray { void **data; unsigned int len; unsigned int nElements; }

user_defined_types: struct hash { struct hashElement *elements[1000]; int offset[1024]; unsigned int (*hashFunction)(); int lexLevel; }

user_defined_types: struct Param { char *name; enum type_t type; struct Symbol *typeSym; }


emitInequalityOp

decompiled_code:
__int64 __fastcall emitInequalityOp(__int64 a1, __int64 a2)
{
__int64 result; // rax
unsigned int v3; // eax
unsigned int v4[3]; // [rsp+Ch] [rbp-Ch] BYREF

emitRelationalPrep(a1, a2, v4);
result = v4[0];
switch ( v4[0] )
{
case 1u:
emitStmt(128LL, "EQR");
result = emitStmt(128LL, "NOT");
break;
case 2u:
emitComment("We are performing 'eq' op on two structured types");
emitComment("We call a pre-defined function to do the operation");
v3 = getStrSymLen(a1);
emitStmt(128LL, "PUSH %d", v3);
emitStmt(128LL, "CALL 0, __do_str_eq_op");
emitComment("__do_str_lt_op overwrote our first param, so we");
emitComment("only adjust -2");
result = emitStmt(128LL, "ADJUST -2");
break;
case 0u:
emitStmt(128LL, "EQI");
result = emitStmt(128LL, "NOT");
break;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2)
{
__int64 result; // rax
unsigned int v3; // eax
unsigned int v4[3]; // [rsp+Ch] [rbp-Ch] BYREF

func3(a1, a2, v4);
result = v4[0];
switch ( v4[0] )
{
case 1u:
emitStmt(128LL, "EQR");
result = emitStmt(128LL, "NOT");
break;
case 2u:
emitComment("We are performing 'eq' op on two structured types");
emitComment("We call a pre-defined function to do the operation");
v3 = getStrSymLen(a1);
emitStmt(128LL, "PUSH %d", v3);
emitStmt(128LL, "CALL 0, __do_str_eq_op");
emitComment("__do_str_lt_op overwrote our first param, so we");
emitComment("only adjust -2");
result = emitStmt(128LL, "ADJUST -2");
break;
case 0u:
emitStmt(128LL, "EQI");
result = emitStmt(128LL, "NOT");
break;
}
return result;
}

original_code:
void emitInequalityOp(Symbol *x, Symbol *y)
{
 int opType;
 emitRelationalPrep(x, y, &opType);
 switch (opType) {
 case 0:
  emitStmt(128, "EQI");
  emitStmt(128, "NOT");
  break;
 case 1:
  emitStmt(128, "EQR");
  emitStmt(128, "NOT");
  break;
 case 2:
  emitComment("We are performing 'eq' op on two structured "
      "types");
  emitComment("We call a pre-defined function to do the "
      "operation");
  emitStmt(128, "PUSH %d", getStrSymLen(x));
  emitStmt(128, "CALL 0, __do_str_eq_op");
  emitComment("__do_str_lt_op overwrote our first param, so we");
  emitComment("only adjust -2");
  emitStmt(128, "ADJUST -2");
  break;
 case -1:
  break;
 }
}

canonical_original_code:
void emitInequalityOp(struct Symbol *x, struct Symbol *y)
{
 int opType;
 emitRelationalPrep(x, y, &opType);
 switch (opType) {
 case 0:
  emitStmt(128, "EQI");
  emitStmt(128, "NOT");
  break;
 case 1:
  emitStmt(128, "EQR");
  emitStmt(128, "NOT");
  break;
 case 2:
  emitComment("We are performing 'eq' op on two structured "
      "types");
  emitComment("We call a pre-defined function to do the "
      "operation");
  emitStmt(128, "PUSH %d", getStrSymLen(x));
  emitStmt(128, "CALL 0, __do_str_eq_op");
  emitComment("__do_str_lt_op overwrote our first param, so we");
  emitComment("only adjust -2");
  emitStmt(128, "ADJUST -2");
  break;
 case -1:
  break;
 }
}

user_defined_types: struct ConstantKind { int constResultFlag; struct Symbol *typeSym; union anonymous_constant_value value; }

user_defined_types: union anonymous_constant_value { struct Boolean Boolean; struct Char Char; struct Integer Integer; struct Real Real; struct String String; }

user_defined_types: enum type_t { VOID_T=0, ARRAY_T=1, BOOLEAN_T=2, CHAR_T=3, INTEGER_T=4, REAL_T=5, RECORD_T=6, SCALARINT_T=7, SCALAR_T=8, STRING_T=9, SUBRANGE_T=10 }

user_defined_types: struct String { char *str; unsigned int strlen; }

user_defined_types: struct Procedure { struct ParamArray *params; char *label; }

user_defined_types: struct Scalar { struct ElementArray *consts; }

user_defined_types: struct StringType { unsigned int strlen; }

user_defined_types: struct Subrange { int high; int low; struct Symbol *baseTypeSym; }


emitLTOp

decompiled_code:
__int64 __fastcall emitLTOp(__int64 a1, __int64 a2)
{
__int64 result; // rax
unsigned int v3; // eax
unsigned int v4[3]; // [rsp+Ch] [rbp-Ch] BYREF

emitRelationalPrep(a1, a2, v4);
result = v4[0];
switch ( v4[0] )
{
case 1u:
return emitStmt(128LL, "LTR");
case 2u:
emitComment("We are performing 'eq' op on two structured types");
emitComment("We call a pre-defined function to do theoperation ");
v3 = getStrSymLen(a1);
emitStmt(128LL, "PUSH %d", v3);
emitStmt(128LL, "CALL 0, __do_str_lt_op");
emitComment("__do_str_lt_op overwrote our first param, so we");
emitComment("only adjust -2");
result = emitStmt(128LL, "ADJUST -2");
break;
case 0u:
result = emitStmt(128LL, "LTI");
break;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 a2)
{
__int64 result; // rax
unsigned int v3; // eax
unsigned int v4[3]; // [rsp+Ch] [rbp-Ch] BYREF

func3(a1, a2, v4);
result = v4[0];
switch ( v4[0] )
{
case 1u:
return emitStmt(128LL, "LTR");
case 2u:
emitComment("We are performing 'eq' op on two structured types");
emitComment("We call a pre-defined function to do theoperation ");
v3 = getStrSymLen(a1);
emitStmt(128LL, "PUSH %d", v3);
emitStmt(128LL, "CALL 0, __do_str_lt_op");
emitComment("__do_str_lt_op overwrote our first param, so we");
emitComment("only adjust -2");
result = emitStmt(128LL, "ADJUST -2");
break;
case 0u:
result = emitStmt(128LL, "LTI");
break;
}
return result;
}

original_code:
void emitLTOp(Symbol *x, Symbol *y) {
 int opType;
 emitRelationalPrep(x, y, &opType);
 switch (opType) {
 case 0:
  emitStmt(128, "LTI");
  break;
 case 1:
  emitStmt(128, "LTR");
  break;
 case 2:
  emitComment("We are performing 'eq' op on two structured "
      "types");
  emitComment("We call a pre-defined function to do the"
      "operation ");
  emitStmt(128, "PUSH %d", getStrSymLen(x));
  emitStmt(128, "CALL 0, __do_str_lt_op");
  emitComment("__do_str_lt_op overwrote our first param, so we");
  emitComment("only adjust -2");
  emitStmt(128, "ADJUST -2");
  break;
 case -1:
  break;
 }
}

canonical_original_code:
void emitLTOp(struct Symbol *x, struct Symbol *y) {
 int opType;
 emitRelationalPrep(x, y, &opType);
 switch (opType) {
 case 0:
  emitStmt(128, "LTI");
  break;
 case 1:
  emitStmt(128, "LTR");
  break;
 case 2:
  emitComment("We are performing 'eq' op on two structured "
      "types");
  emitComment("We call a pre-defined function to do the"
      "operation ");
  emitStmt(128, "PUSH %d", getStrSymLen(x));
  emitStmt(128, "CALL 0, __do_str_lt_op");
  emitComment("__do_str_lt_op overwrote our first param, so we");
  emitComment("only adjust -2");
  emitStmt(128, "ADJUST -2");
  break;
 case -1:
  break;
 }
}

user_defined_types: struct ParamKind { struct Symbol *typeSym; int byRef; }

user_defined_types: struct ProcedureKind { struct ElementArray *params; char *label; }

user_defined_types: struct VariableKind { struct Symbol *typeSym; int byRef; }

user_defined_types: union type_union { struct Array *Array; struct Function *Function; struct Procedure *Procedure; struct Record *Record; struct Scalar *Scalar; struct StringType *String; struct Subrange *Subrange; }

user_defined_types: struct Array { struct Symbol *baseTypeSym; struct Symbol *indexTypeSym; }

user_defined_types: struct Function { struct ParamArray *params; struct Symbol *returnTypeSym; char *label; }

user_defined_types: struct ParamArray { struct Param **data; unsigned int len; unsigned int nElements; }

user_defined_types: struct hashElement { char *key; struct Symbol *symbol; struct hashElement *prev; struct hashElement *next; }


emitLTEOp

decompiled_code:
__int64 __fastcall emitLTEOp(__int64 a1, __int64 a2)
{
__int64 result; // rax
unsigned int v3; // eax
unsigned int v4[3]; // [rsp+Ch] [rbp-Ch] BYREF

emitRelationalPrep(a1, a2, v4);
result = v4[0];
switch ( v4[0] )
{
case 1u:
emitStmt(128LL, "GTR");
result = emitStmt(128LL, "NOT");
break;
case 2u:
emitComment("We are performing 'LTE' op on two structured types");
emitComment("We call a pre-defined function to do theoperation");
emitComment("We perform x > y operation, then negate the result");
v3 = getStrSymLen(a1);
emitStmt(128LL, "PUSH %d", v3);
emitStmt(128LL, "CALL 0, __do_str_gt_op");
emitComment("__do_str_gt_op overwrote our first param, so we");
emitComment("only adjust -2");
emitStmt(128LL, "ADJUST -2");
result = emitStmt(128LL, "NOT");
break;
case 0u:
emitStmt(128LL, "GTI");
result = emitStmt(128LL, "NOT");
break;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2)
{
__int64 result; // rax
unsigned int v3; // eax
unsigned int v4[3]; // [rsp+Ch] [rbp-Ch] BYREF

func3(a1, a2, v4);
result = v4[0];
switch ( v4[0] )
{
case 1u:
emitStmt(128LL, "GTR");
result = emitStmt(128LL, "NOT");
break;
case 2u:
emitComment("We are performing 'LTE' op on two structured types");
emitComment("We call a pre-defined function to do theoperation");
emitComment("We perform x > y operation, then negate the result");
v3 = getStrSymLen(a1);
emitStmt(128LL, "PUSH %d", v3);
emitStmt(128LL, "CALL 0, __do_str_gt_op");
emitComment("__do_str_gt_op overwrote our first param, so we");
emitComment("only adjust -2");
emitStmt(128LL, "ADJUST -2");
result = emitStmt(128LL, "NOT");
break;
case 0u:
emitStmt(128LL, "GTI");
result = emitStmt(128LL, "NOT");
break;
}
return result;
}

original_code:
void emitLTEOp(Symbol *x, Symbol *y)
{
 int opType;
 emitRelationalPrep(x, y, &opType);
 switch(opType) {
 case 0:
  emitStmt(128, "GTI");
  emitStmt(128, "NOT");
  break;
 case 1:
  emitStmt(128, "GTR");
  emitStmt(128, "NOT");
  break;
 case 2:
  emitComment("We are performing 'LTE' op on two structured "
      "types");
  emitComment("We call a pre-defined function to do the"
      "operation");
  emitComment("We perform x > y operation, then negate the "
      "result");
  emitStmt(128, "PUSH %d", getStrSymLen(x));
  emitStmt(128, "CALL 0, __do_str_gt_op");
  emitComment("__do_str_gt_op overwrote our first param, so we");
  emitComment("only adjust -2");
  emitStmt(128, "ADJUST -2");
  emitStmt(128, "NOT");
  break;
 case -1:
  break;
 }
}

canonical_original_code:
void emitLTEOp(struct Symbol *x, struct Symbol *y)
{
 int opType;
 emitRelationalPrep(x, y, &opType);
 switch(opType) {
 case 0:
  emitStmt(128, "GTI");
  emitStmt(128, "NOT");
  break;
 case 1:
  emitStmt(128, "GTR");
  emitStmt(128, "NOT");
  break;
 case 2:
  emitComment("We are performing 'LTE' op on two structured "
      "types");
  emitComment("We call a pre-defined function to do the"
      "operation");
  emitComment("We perform x > y operation, then negate the "
      "result");
  emitStmt(128, "PUSH %d", getStrSymLen(x));
  emitStmt(128, "CALL 0, __do_str_gt_op");
  emitComment("__do_str_gt_op overwrote our first param, so we");
  emitComment("only adjust -2");
  emitStmt(128, "ADJUST -2");
  emitStmt(128, "NOT");
  break;
 case -1:
  break;
 }
}

user_defined_types: struct Symbol { char *name; enum kind_t kind; union kind_union kindPtr; int lvl; int typeOriginator; int offset; int size; int isAddress; int isRecordHead; struct Symbol *next; }

user_defined_types: enum kind_t { CONST_KIND=0, FUNC_KIND=1, PARAM_KIND=2, PROC_KIND=3, TYPE_KIND=4, VAR_KIND=5 }

user_defined_types: union kind_union { struct ConstantKind *ConstKind; struct FunctionKind *FuncKind; struct ParamKind *ParamKind; struct ProcedureKind *ProcKind; struct TypeKind *TypeKind; struct VariableKind *VarKind; }

user_defined_types: struct FunctionKind { struct Symbol *typeSym; struct ElementArray *params; char *label; int invocationInstance; }

user_defined_types: struct TypeKind { union type_union typePtr; enum type_t type; }

user_defined_types: struct ElementArray { void **data; unsigned int len; unsigned int nElements; }

user_defined_types: struct hash { struct hashElement *elements[1000]; int offset[1024]; unsigned int (*hashFunction)(); int lexLevel; }

user_defined_types: struct Param { char *name; enum type_t type; struct Symbol *typeSym; }


emitGTOp

decompiled_code:
__int64 __fastcall emitGTOp(__int64 a1, __int64 a2)
{
__int64 result; // rax
unsigned int v3; // eax
unsigned int v4[3]; // [rsp+Ch] [rbp-Ch] BYREF

emitRelationalPrep(a1, a2, v4);
result = v4[0];
switch ( v4[0] )
{
case 1u:
return emitStmt(128LL, "GTR");
case 2u:
emitComment("We are performing 'gt' op on two structured types");
emitComment("We call a pre-defined function to do theoperation");
v3 = getStrSymLen(a1);
emitStmt(128LL, "PUSH %d", v3);
emitStmt(128LL, "CALL 0, __do_str_gt_op");
emitComment("__do_str_gt_op overwrote our first param, so we");
emitComment("only adjust -2");
result = emitStmt(128LL, "ADJUST -2");
break;
case 0u:
result = emitStmt(128LL, "GTI");
break;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, __int64 a2)
{
__int64 result; // rax
unsigned int v3; // eax
unsigned int v4[3]; // [rsp+Ch] [rbp-Ch] BYREF

func3(a1, a2, v4);
result = v4[0];
switch ( v4[0] )
{
case 1u:
return emitStmt(128LL, "GTR");
case 2u:
emitComment("We are performing 'gt' op on two structured types");
emitComment("We call a pre-defined function to do theoperation");
v3 = getStrSymLen(a1);
emitStmt(128LL, "PUSH %d", v3);
emitStmt(128LL, "CALL 0, __do_str_gt_op");
emitComment("__do_str_gt_op overwrote our first param, so we");
emitComment("only adjust -2");
result = emitStmt(128LL, "ADJUST -2");
break;
case 0u:
result = emitStmt(128LL, "GTI");
break;
}
return result;
}

original_code:
void emitGTOp(Symbol *x, Symbol *y) {
 int opType;
 emitRelationalPrep(x, y, &opType);
 switch (opType) {
 case 0:
  emitStmt(128, "GTI");
  break;
 case 1:
  emitStmt(128, "GTR");
  break;
 case 2:
  emitComment("We are performing 'gt' op on two structured "
      "types");
  emitComment("We call a pre-defined function to do the"
      "operation");
  emitStmt(128, "PUSH %d", getStrSymLen(x));
  emitStmt(128, "CALL 0, __do_str_gt_op");
  emitComment("__do_str_gt_op overwrote our first param, so we");
  emitComment("only adjust -2");
  emitStmt(128, "ADJUST -2");
break;
 case -1:
  break;
 }
}

canonical_original_code:
void emitGTOp(struct Symbol *x, struct Symbol *y) {
 int opType;
 emitRelationalPrep(x, y, &opType);
 switch (opType) {
 case 0:
  emitStmt(128, "GTI");
  break;
 case 1:
  emitStmt(128, "GTR");
  break;
 case 2:
  emitComment("We are performing 'gt' op on two structured "
      "types");
  emitComment("We call a pre-defined function to do the"
      "operation");
  emitStmt(128, "PUSH %d", getStrSymLen(x));
  emitStmt(128, "CALL 0, __do_str_gt_op");
  emitComment("__do_str_gt_op overwrote our first param, so we");
  emitComment("only adjust -2");
  emitStmt(128, "ADJUST -2");
break;
 case -1:
  break;
 }
}

user_defined_types: struct ConstantKind { int constResultFlag; struct Symbol *typeSym; union anonymous_constant_value value; }

user_defined_types: union anonymous_constant_value { struct Boolean Boolean; struct Char Char; struct Integer Integer; struct Real Real; struct String String; }

user_defined_types: enum type_t { VOID_T=0, ARRAY_T=1, BOOLEAN_T=2, CHAR_T=3, INTEGER_T=4, REAL_T=5, RECORD_T=6, SCALARINT_T=7, SCALAR_T=8, STRING_T=9, SUBRANGE_T=10 }

user_defined_types: struct String { char *str; unsigned int strlen; }

user_defined_types: struct Procedure { struct ParamArray *params; char *label; }

user_defined_types: struct Scalar { struct ElementArray *consts; }

user_defined_types: struct StringType { unsigned int strlen; }

user_defined_types: struct Subrange { int high; int low; struct Symbol *baseTypeSym; }


emitGTEOp

decompiled_code:
__int64 __fastcall emitGTEOp(__int64 a1, __int64 a2)
{
__int64 result; // rax
unsigned int v3; // eax
unsigned int v4[3]; // [rsp+Ch] [rbp-Ch] BYREF

emitRelationalPrep(a1, a2, v4);
result = v4[0];
switch ( v4[0] )
{
case 1u:
emitStmt(128LL, "LTR");
result = emitStmt(128LL, "NOT");
break;
case 2u:
emitComment("We are performing 'gte' op on two structured types");
emitComment("We call a pre-defined function to do theoperation");
emitComment("We perform x < y operation, then negate the result");
v3 = getStrSymLen(a1);
emitStmt(128LL, "PUSH %d", v3);
emitStmt(128LL, "CALL 0, __do_str_lt_op");
emitComment("__do_str_lt_op overwrote our first param, so we");
emitComment("only adjust -2");
emitStmt(128LL, "ADJUST -2");
result = emitStmt(128LL, "NOT");
break;
case 0u:
emitStmt(128LL, "LTI");
result = emitStmt(128LL, "NOT");
break;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, __int64 a2)
{
__int64 result; // rax
unsigned int v3; // eax
unsigned int v4[3]; // [rsp+Ch] [rbp-Ch] BYREF

func3(a1, a2, v4);
result = v4[0];
switch ( v4[0] )
{
case 1u:
emitStmt(128LL, "LTR");
result = emitStmt(128LL, "NOT");
break;
case 2u:
emitComment("We are performing 'gte' op on two structured types");
emitComment("We call a pre-defined function to do theoperation");
emitComment("We perform x < y operation, then negate the result");
v3 = getStrSymLen(a1);
emitStmt(128LL, "PUSH %d", v3);
emitStmt(128LL, "CALL 0, __do_str_lt_op");
emitComment("__do_str_lt_op overwrote our first param, so we");
emitComment("only adjust -2");
emitStmt(128LL, "ADJUST -2");
result = emitStmt(128LL, "NOT");
break;
case 0u:
emitStmt(128LL, "LTI");
result = emitStmt(128LL, "NOT");
break;
}
return result;
}

original_code:
void emitGTEOp(Symbol *x, Symbol *y)
{
 int opType;
 emitRelationalPrep(x, y, &opType);
 switch(opType) {
 case 0:
  emitStmt(128, "LTI");
  emitStmt(128, "NOT");
  break;
 case 1:
  emitStmt(128, "LTR");
  emitStmt(128, "NOT");
  break;
 case 2:
  emitComment("We are performing 'gte' op on two structured "
      "types");
  emitComment("We call a pre-defined function to do the"
      "operation");
  emitComment("We perform x < y operation, then negate the "
      "result");
  emitStmt(128, "PUSH %d", getStrSymLen(x));
  emitStmt(128, "CALL 0, __do_str_lt_op");
  emitComment("__do_str_lt_op overwrote our first param, so we");
  emitComment("only adjust -2");
  emitStmt(128, "ADJUST -2");
  emitStmt(128, "NOT");
  break;
 case -1:
  break;
 }
}

canonical_original_code:
void emitGTEOp(struct Symbol *x, struct Symbol *y)
{
 int opType;
 emitRelationalPrep(x, y, &opType);
 switch(opType) {
 case 0:
  emitStmt(128, "LTI");
  emitStmt(128, "NOT");
  break;
 case 1:
  emitStmt(128, "LTR");
  emitStmt(128, "NOT");
  break;
 case 2:
  emitComment("We are performing 'gte' op on two structured "
      "types");
  emitComment("We call a pre-defined function to do the"
      "operation");
  emitComment("We perform x < y operation, then negate the "
      "result");
  emitStmt(128, "PUSH %d", getStrSymLen(x));
  emitStmt(128, "CALL 0, __do_str_lt_op");
  emitComment("__do_str_lt_op overwrote our first param, so we");
  emitComment("only adjust -2");
  emitStmt(128, "ADJUST -2");
  emitStmt(128, "NOT");
  break;
 case -1:
  break;
 }
}

user_defined_types: struct ParamKind { struct Symbol *typeSym; int byRef; }

user_defined_types: struct ProcedureKind { struct ElementArray *params; char *label; }

user_defined_types: struct VariableKind { struct Symbol *typeSym; int byRef; }

user_defined_types: union type_union { struct Array *Array; struct Function *Function; struct Procedure *Procedure; struct Record *Record; struct Scalar *Scalar; struct StringType *String; struct Subrange *Subrange; }

user_defined_types: struct Array { struct Symbol *baseTypeSym; struct Symbol *indexTypeSym; }

user_defined_types: struct Function { struct ParamArray *params; struct Symbol *returnTypeSym; char *label; }

user_defined_types: struct ParamArray { struct Param **data; unsigned int len; unsigned int nElements; }

user_defined_types: struct hashElement { char *key; struct Symbol *symbol; struct hashElement *prev; struct hashElement *next; }


exitDeclPart

decompiled_code:
__int64 exitDeclPart()
{
unsigned int v0; // eax

emitBlankLine();
emitComment("Start of program, functions, or procedure:");
v0 = peekLabelStackTop(mainLabelStack);
emitLabel(128LL, "%s_%d", "MAIN", v0);
return popLabels(mainLabelStack);
}

canonical_decompiled_code:
__int64 func0()
{
unsigned int v0; // eax

emitBlankLine();
emitComment("Start of program, functions, or procedure:");
v0 = peekLabelStackTop(mainLabelStack);
emitLabel(128LL, "%s_%d", "MAIN", v0);
return popLabels(mainLabelStack);
}

original_code:
void exitDeclPart(void) {
 emitBlankLine();
 emitComment("Start of program, functions, or procedure:");
 emitLabel(128, "%s_%d",
     "MAIN", peekLabelStackTop(mainLabelStack));
 popLabels(mainLabelStack);
}

canonical_original_code:
void exitDeclPart() {
 emitBlankLine();
 emitComment("Start of program, functions, or procedure:");
 emitLabel(128, "%s_%d",
     "MAIN", peekLabelStackTop(mainLabelStack));
 popLabels(mainLabelStack);
}


doProgramDecl

decompiled_code:
__int64 doProgramDecl()
{
unsigned int v0; // eax
unsigned int v1; // eax

reserveLabels(mainLabelStack, 1LL);
emitBlankLine();
emitSepLine();
emitBlankLine();
emitComment("Start of user program");
emitBlankLine();
emitSepLine();
emitBlankLine();
emitComment("End of pre-def, call MAIN");
v0 = peekLabelStackTop(mainLabelStack);
emitStmt(128LL, "CALL 1, %s_%d", "MAIN", v0);
v1 = peekLabelStackTop(mainLabelStack);
emitLabel(128LL, "%s_%d", "MAIN", v1);
popLabels(mainLabelStack);
return incrementLexLevel(symbolTable);
}

canonical_decompiled_code:
__int64 func1()
{
unsigned int v0; // eax
unsigned int v1; // eax

reserveLabels(mainLabelStack, 1LL);
emitBlankLine();
emitSepLine();
emitBlankLine();
emitComment("Start of user program");
emitBlankLine();
emitSepLine();
emitBlankLine();
emitComment("End of pre-def, call MAIN");
v0 = peekLabelStackTop(mainLabelStack);
emitStmt(128LL, "CALL 1, %s_%d", "MAIN", v0);
v1 = peekLabelStackTop(mainLabelStack);
emitLabel(128LL, "%s_%d", "MAIN", v1);
popLabels(mainLabelStack);
return incrementLexLevel(symbolTable);
}

original_code:
void doProgramDecl(char *prog_name, char *in_name, char *out_name) {
 reserveLabels(mainLabelStack, 1);
 emitBlankLine();
 emitSepLine();
 emitBlankLine();
 emitComment("Start of user program");
 emitBlankLine();
 emitSepLine();
 emitBlankLine();
 emitComment("End of pre-def, call MAIN");
 emitStmt(128, "CALL 1, %s_%d",
     "MAIN", peekLabelStackTop(mainLabelStack));
 emitLabel(128, "%s_%d",
     "MAIN", peekLabelStackTop(mainLabelStack));
 popLabels(mainLabelStack);
 incrementLexLevel(symbolTable);
}


exitConstDeclPart

decompiled_code:
void exitConstDeclPart()
{
;
}

canonical_decompiled_code:
void func2()
{
;
}

original_code:
void exitConstDeclPart(void) {
}

canonical_original_code:
void exitConstDeclPart() {
}


doConstDecl

decompiled_code:
__int64 __fastcall doConstDecl(__int64 a1, _QWORD *a2)
{
unsigned int v2; // ebp
__int64 result; // rax
__int64 v4; // rbx

v2 = getCurrentLexLevel(symbolTable);
if ( getLocalSymbol(symbolTable, a1) )
return alreadyDefinedError(a1);
result = newConstSymFromProxy(v2, a1, *a2);
v4 = result;
if ( result )
{
addToSymbolTable(symbolTable, result);
setSymbolOffset(v4, symbolTable);
result = emitConstDecl(v4);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, _QWORD *a2)
{
unsigned int v2; // ebp
__int64 result; // rax
__int64 v4; // rbx

v2 = getCurrentLexLevel(symbolTable);
if ( getLocalSymbol(symbolTable, a1) )
return alreadyDefinedError(a1);
result = newConstSymFromProxy(v2, a1, *a2);
v4 = result;
if ( result )
{
addToSymbolTable(symbolTable, result);
setSymbolOffset(v4, symbolTable);
result = emitConstDecl(v4);
}
return result;
}

original_code:
void doConstDecl(char *id, struct treeNode *node) {
 Symbol *s = ((void *)0);
 int lvl = getCurrentLexLevel(symbolTable);
 s = getLocalSymbol(symbolTable, id);
 if (s) {
  alreadyDefinedError(id);
  return;
 }
 s = newConstSymFromProxy(lvl, id, node->symbol);
 if (s) {
  addToSymbolTable(symbolTable, s);
  setSymbolOffset(s, symbolTable);
  emitConstDecl(s);
 }
}

canonical_original_code:
void doConstDecl(char *id, struct treeNode *node) {
 struct Symbol *s = ((void *)0);
 int lvl = getCurrentLexLevel(symbolTable);
 s = getLocalSymbol(symbolTable, id);
 if (s) {
  alreadyDefinedError(id);
  return;
 }
 s = newConstSymFromProxy(lvl, id, node->symbol);
 if (s) {
  addToSymbolTable(symbolTable, s);
  setSymbolOffset(s, symbolTable);
  emitConstDecl(s);
 }
}

variable_types: lvl int

user_defined_types: struct treeNode { struct Symbol *symbol; int opToken; struct treeNode *parent; struct treeNode *left; struct treeNode *right; }

user_defined_types: struct Symbol { char *name; enum kind_t kind; union kind_union kindPtr; int lvl; int typeOriginator; int offset; int size; int isAddress; int isRecordHead; struct Symbol *next; }

user_defined_types: enum kind_t { CONST_KIND=0, FUNC_KIND=1, PARAM_KIND=2, PROC_KIND=3, TYPE_KIND=4, VAR_KIND=5 }

user_defined_types: union kind_union { struct ConstantKind *ConstKind; struct FunctionKind *FuncKind; struct ParamKind *ParamKind; struct ProcedureKind *ProcKind; struct TypeKind *TypeKind; struct VariableKind *VarKind; }

user_defined_types: struct FunctionKind { struct Symbol *typeSym; struct ElementArray *params; char *label; int invocationInstance; }

user_defined_types: struct TypeKind { union type_union typePtr; enum type_t type; }

user_defined_types: struct ElementArray { void **data; unsigned int len; unsigned int nElements; }

user_defined_types: struct hash { struct hashElement *elements[1000]; int offset[1024]; unsigned int (*hashFunction)(); int lexLevel; }

user_defined_types: struct Param { char *name; enum type_t type; struct Symbol *typeSym; }


exitTypeDeclPart

decompiled_code:
void exitTypeDeclPart()
{
;
}

canonical_decompiled_code:
void func4()
{
;
}

original_code:
void exitTypeDeclPart(void) {
}

canonical_original_code:
void exitTypeDeclPart() {
}