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: 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 FunctionKind { struct Symbol *typeSym; struct ElementArray *params; char *label; int invocationInstance; }

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 ElementArray { void **data; unsigned int len; unsigned int nElements; }

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; }


emitInequalityOp

repo: a-krebs/YACC

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

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

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

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

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:
y
struct Symbol *

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 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; }


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: 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 Array { struct Symbol *baseTypeSym; struct Symbol *indexTypeSym; }

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; }


emitLTEOp

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

emitRelationalPrep(a1, a2, v5);
result = v5[0];
if ( v5[0] == 1 )
{
v3 = "GTR";
goto LABEL_6;
}
if ( v5[0] == 2 )
{
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");
v4 = getStrSymLen(a1);
emitStmt(128LL, "PUSH %d", v4);
emitStmt(128LL, "CALL 0, __do_str_gt_op");
emitComment("__do_str_gt_op overwrote our first param, so we");
emitComment("only adjust -2");
v3 = "ADJUST -2";
goto LABEL_6;
}
v3 = "GTI";
if ( !v5[0] )
{
LABEL_6:
emitStmt(128LL, v3);
result = emitStmt(128LL, "NOT");
}
return result;
}

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

func3(a1, a2, v5);
result = v5[0];
if ( v5[0] == 1 )
{
v3 = "GTR";
goto LABEL_6;
}
if ( v5[0] == 2 )
{
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");
v4 = getStrSymLen(a1);
emitStmt(128LL, "PUSH %d", v4);
emitStmt(128LL, "CALL 0, __do_str_gt_op");
emitComment("__do_str_gt_op overwrote our first param, so we");
emitComment("only adjust -2");
v3 = "ADJUST -2";
goto LABEL_6;
}
v3 = "GTI";
if ( !v5[0] )
{
LABEL_6:
emitStmt(128LL, v3);
result = emitStmt(128LL, "NOT");
}
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: 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 FunctionKind { struct Symbol *typeSym; struct ElementArray *params; char *label; int invocationInstance; }

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 ElementArray { void **data; unsigned int len; unsigned int nElements; }

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; }


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 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 ParamKind { struct Symbol *typeSym; int byRef; }

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

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

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

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


emitGTEOp

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

emitRelationalPrep(a1, a2, v5);
result = v5[0];
if ( v5[0] == 1 )
{
v3 = "LTR";
goto LABEL_6;
}
if ( v5[0] == 2 )
{
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");
v4 = getStrSymLen(a1);
emitStmt(128LL, "PUSH %d", v4);
emitStmt(128LL, "CALL 0, __do_str_lt_op");
emitComment("__do_str_lt_op overwrote our first param, so we");
emitComment("only adjust -2");
v3 = "ADJUST -2";
goto LABEL_6;
}
v3 = "LTI";
if ( !v5[0] )
{
LABEL_6:
emitStmt(128LL, v3);
result = emitStmt(128LL, "NOT");
}
return result;
}

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

func3(a1, a2, v5);
result = v5[0];
if ( v5[0] == 1 )
{
v3 = "LTR";
goto LABEL_6;
}
if ( v5[0] == 2 )
{
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");
v4 = getStrSymLen(a1);
emitStmt(128LL, "PUSH %d", v4);
emitStmt(128LL, "CALL 0, __do_str_lt_op");
emitComment("__do_str_lt_op overwrote our first param, so we");
emitComment("only adjust -2");
v3 = "ADJUST -2";
goto LABEL_6;
}
v3 = "LTI";
if ( !v5[0] )
{
LABEL_6:
emitStmt(128LL, v3);
result = emitStmt(128LL, "NOT");
}
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: 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 Array { struct Symbol *baseTypeSym; struct Symbol *indexTypeSym; }

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; }


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; // er12
__int64 result; // rax
__int64 v4; // rbp

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; // er12
__int64 result; // rax
__int64 v4; // rbp

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:
id
char *

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; } *

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 FunctionKind { struct Symbol *typeSym; struct ElementArray *params; char *label; int invocationInstance; }

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; }


exitTypeDeclPart

decompiled_code:
void exitTypeDeclPart()
{
;
}

canonical_decompiled_code:
void func4()
{
;
}

original_code:
void exitTypeDeclPart(void) {
}

canonical_original_code:
void exitTypeDeclPart() {
}


doTypeDecl

decompiled_code:
__int64 __fastcall doTypeDecl(const char *a1, __int64 a2)
{
__int64 v2; // rax
__int64 result; // rax

if ( getLocalSymbol(symbolTable, a1) )
{
v2 = customErrorString("The identifier %s is already defined at this scope.", a1);
result = recordError(v2, yylineno, colno, 2LL);
}
else
{
result = newTypeSymFromSym(a1, a2);
if ( result )
{
result = addToSymbolTable(symbolTable, result);
if ( (_DWORD)result )
err(1, "Could not insert symbol into symbol table");
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(const char *a1, __int64 a2)
{
__int64 v2; // rax
__int64 result; // rax

if ( getLocalSymbol(symbolTable, a1) )
{
v2 = customErrorString("The identifier %s is already defined at this scope.", a1);
result = recordError(v2, yylineno, colno, 2LL);
}
else
{
result = newTypeSymFromSym(a1, a2);
if ( result )
{
result = addToSymbolTable(symbolTable, result);
if ( (_DWORD)result )
err(1, "Could not insert symbol into symbol table");
}
}
return result;
}

original_code:
void doTypeDecl(char *id, Symbol *type) {
 Symbol * s = ((void *)0);
 s = getLocalSymbol(symbolTable, id);
 if (s != ((void *)0)) {
  errMsg = customErrorString("The identifier %s is already "
    "defined at this scope.", id);
  recordError(errMsg, yylineno, colno, SEMANTIC);
  return;
 }
 s = newTypeSymFromSym(id, type);
 if (s == ((void *)0)) {
  return;
 }
 if (addToSymbolTable(symbolTable, s) != 0) {
  err(1, "Could not insert symbol into symbol table");
 }
}

canonical_original_code:
void doTypeDecl(char *id, struct Symbol *type) {
 struct Symbol *s = ((void *)0);
 s = getLocalSymbol(symbolTable, id);
 if (s != ((void *)0)) {
  errMsg = customErrorString("The identifier %s is already "
    "defined at this scope.", id);
  recordError(errMsg, yylineno, colno, SEMANTIC);
  return;
 }
 s = newTypeSymFromSym(id, type);
 if (s == ((void *)0)) {
  return;
 }
 if (addToSymbolTable(symbolTable, s) != 0) {
  err(1, "Could not insert symbol into symbol table");
 }
}

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 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 TypeKind { union type_union typePtr; enum type_t type; }

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

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


exitVarDeclPart

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

reserveLabels(mainLabelStack, 1LL);
emitBlankLine();
emitComment("End of var decls, jump over any other proc or func decls");
v0 = peekLabelStackTop(mainLabelStack);
emitStmt(128LL, "GOTO %s_%d", "MAIN", v0);
return emitBlankLine();
}

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

reserveLabels(mainLabelStack, 1LL);
emitBlankLine();
emitComment("End of var decls, jump over any other proc or func decls");
v0 = peekLabelStackTop(mainLabelStack);
emitStmt(128LL, "GOTO %s_%d", "MAIN", v0);
return emitBlankLine();
}

original_code:
void exitVarDeclPart(void) {
 reserveLabels(mainLabelStack, 1);
 emitBlankLine();
 emitComment("End of var decls, jump over any other proc or func decls");
 emitStmt(128, "GOTO %s_%d",
     "MAIN", peekLabelStackTop(mainLabelStack));
 emitBlankLine();
}

canonical_original_code:
void exitVarDeclPart() {
 reserveLabels(mainLabelStack, 1);
 emitBlankLine();
 emitComment("End of var decls, jump over any other proc or func decls");
 emitStmt(128, "GOTO %s_%d",
     "MAIN", peekLabelStackTop(mainLabelStack));
 emitBlankLine();
}


doVarDecl

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

result = getLocalSymbol(symbolTable, a1);
if ( result )
{
alreadyDefinedError(a1);
result = 0LL;
}
else if ( a1 && a2 )
{
v3 = newVariableSym(a1, a2);
v4 = v3;
if ( v3 )
{
addToSymbolTable(symbolTable, v3);
setSymbolOffset(v4, symbolTable);
emitVarDecl(v4);
if ( (unsigned int)getType(a2) == 6 )
*(_DWORD *)(v4 + 44) = 1;
}
result = a2;
}
return result;
}

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

result = getLocalSymbol(symbolTable, a1);
if ( result )
{
alreadyDefinedError(a1);
result = 0LL;
}
else if ( a1 && a2 )
{
v3 = newVariableSym(a1, a2);
v4 = v3;
if ( v3 )
{
addToSymbolTable(symbolTable, v3);
setSymbolOffset(v4, symbolTable);
emitVarDecl(v4);
if ( (unsigned int)getType(a2) == 6 )
*(_DWORD *)(v4 + 44) = 1;
}
result = a2;
}
return result;
}

original_code:
Symbol *doVarDecl(char *id, Symbol *type) {
 Symbol *s = ((void *)0);
 s = getLocalSymbol(symbolTable, id);
 if (s) {
  alreadyDefinedError(id);
  return ((void *)0);
 }
 if ((!id) || !(type)) return ((void *)0);
 s = newVariableSym(id, type);
 if (s) {
  addToSymbolTable(symbolTable, s);
  setSymbolOffset(s, symbolTable);
  emitVarDecl(s);
  if (getType(type) == RECORD_T) s->isRecordHead = 1;
 }
 return type;
}

canonical_original_code:
struct Symbol *doVarDecl(char *id, struct Symbol *type) {
 struct Symbol *s = ((void *)0);
 s = getLocalSymbol(symbolTable, id);
 if (s) {
  alreadyDefinedError(id);
  return ((void *)0);
 }
 if ((!id) || !(type)) return ((void *)0);
 s = newVariableSym(id, type);
 if (s) {
  addToSymbolTable(symbolTable, s);
  setSymbolOffset(s, symbolTable);
  emitVarDecl(s);
  if (getType(type) == RECORD_T) s->isRecordHead = 1;
 }
 return type;
}

variable_types:
type
struct Symbol *

return_type: 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; } *

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


exitProcOrFuncDecl

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

if ( !a1 )
return popLexLevel(symbolTable);
v1 = *(_DWORD *)(a1 + 8);
if ( v1 != 3 )
{
if ( v1 == 1 )
emitEndFunc();
return popLexLevel(symbolTable);
}
emitEndProc();
return popLexLevel(symbolTable);
}

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

if ( !a1 )
return popLexLevel(symbolTable);
v1 = *(_DWORD *)(a1 + 8);
if ( v1 != 3 )
{
if ( v1 == 1 )
emitEndFunc();
return popLexLevel(symbolTable);
}
emitEndProc();
return popLexLevel(symbolTable);
}

original_code:
void exitProcOrFuncDecl(Symbol *symbol) {
 if (symbol != ((void *)0)) {
  if (symbol->kind == PROC_KIND) {
    emitEndProc(symbol);
  }
  else if (symbol->kind == FUNC_KIND) {
    emitEndFunc(symbol);
  }
 }
 popLexLevel(symbolTable);
}

canonical_original_code:
void exitProcOrFuncDecl(struct Symbol *symbol) {
 if (symbol != ((void *)0)) {
  if (symbol->kind == PROC_KIND) {
    emitEndProc(symbol);
  }
  else if (symbol->kind == FUNC_KIND) {
    emitEndFunc(symbol);
  }
 }
 popLexLevel(symbolTable);
}

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 Array { struct Symbol *baseTypeSym; struct Symbol *indexTypeSym; }

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; }


enterProcDecl

decompiled_code:
__int64 __fastcall enterProcDecl(const char *a1, __int64 a2)
{
__int64 v3; // rdi
__int64 v4; // r12
__int64 v5; // r14
unsigned int v6; // ebx
__int64 v7; // rax
__int64 v8; // rax
_QWORD *v9; // rbp
__int64 v10; // rsi
__int64 v11; // rax
__int64 v13; // rax
__int64 v14; // rax

v3 = symbolTable;
if ( !a1 )
goto LABEL_15;
v4 = a2;
if ( getLocalSymbol(symbolTable, a1) )
{
v14 = customErrorString("Name %s is already defined.", a1);
recordError(v14, yylineno, colno, 2LL);
v3 = symbolTable;
LABEL_15:
incrementLexLevel(v3);
return 0LL;
}
if ( !a2 )
v4 = newElementArray();
if ( (unsigned int)hasDuplicateElement(v4) )
{
v13 = customErrorString("Procedure %s has duplicate argument names.", a1);
recordError(v13, yylineno, colno, 2LL);
}
v5 = newProcSym(a1, v4);
v6 = addToSymbolTable(symbolTable, v5);
if ( v6 )
err(1, "Could not add element to symbol table.");
incrementLexLevel(symbolTable);
if ( *(_DWORD *)(v4 + 12) )
{
do
{
while ( 1 )
{
v8 = getElementAt(v4, v6);
v9 = (_QWORD *)paramToVar(v8);
if ( !getLocalSymbol(symbolTable, *v9) )
break;
++v6;
v7 = customErrorString("Name %s is already defined.", a1);
recordError(v7, yylineno, colno, 2LL);
if ( *(_DWORD *)(v4 + 12) <= v6 )
goto LABEL_13;
}
addToSymbolTable(symbolTable, v9);
v10 = v6++;
v11 = getElementAt(v4, v10);
setSymbolSize(v11);
setSymbolSize(v9);
setParamOffset(v9, v4);
}
while ( *(_DWORD *)(v4 + 12) > v6 );
}
LABEL_13:
emitProcOrFuncDecl(v5, v4);
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func9(const char *a1, __int64 a2)
{
__int64 v3; // rdi
__int64 v4; // r12
__int64 v5; // r14
unsigned int v6; // ebx
__int64 v7; // rax
__int64 v8; // rax
_QWORD *v9; // rbp
__int64 v10; // rsi
__int64 v11; // rax
__int64 v13; // rax
__int64 v14; // rax

v3 = symbolTable;
if ( !a1 )
goto LABEL_15;
v4 = a2;
if ( getLocalSymbol(symbolTable, a1) )
{
v14 = customErrorString("Name %s is already defined.", a1);
recordError(v14, yylineno, colno, 2LL);
v3 = symbolTable;
LABEL_15:
incrementLexLevel(v3);
return 0LL;
}
if ( !a2 )
v4 = newElementArray();
if ( (unsigned int)hasDuplicateElement(v4) )
{
v13 = customErrorString("Procedure %s has duplicate argument names.", a1);
recordError(v13, yylineno, colno, 2LL);
}
v5 = newProcSym(a1, v4);
v6 = addToSymbolTable(symbolTable, v5);
if ( v6 )
err(1, "Could not add element to symbol table.");
incrementLexLevel(symbolTable);
if ( *(_DWORD *)(v4 + 12) )
{
do
{
while ( 1 )
{
v8 = getElementAt(v4, v6);
v9 = (_QWORD *)paramToVar(v8);
if ( !getLocalSymbol(symbolTable, *v9) )
break;
++v6;
v7 = customErrorString("Name %s is already defined.", a1);
recordError(v7, yylineno, colno, 2LL);
if ( *(_DWORD *)(v4 + 12) <= v6 )
goto LABEL_13;
}
addToSymbolTable(symbolTable, v9);
v10 = v6++;
v11 = getElementAt(v4, v10);
setSymbolSize(v11);
setSymbolSize(v9);
setParamOffset(v9, v4);
}
while ( *(_DWORD *)(v4 + 12) > v6 );
}
LABEL_13:
emitProcOrFuncDecl(v5, v4);
return v5;
}

original_code:
Symbol *enterProcDecl(char *id, struct ElementArray *ea) {
 Symbol *s = ((void *)0);
 Symbol *var = ((void *)0);
 if (!id) {
  incrementLexLevel(symbolTable);
  return ((void *)0);
 }
 s = getLocalSymbol(symbolTable, id);
 if (s) {
  errMsg = customErrorString("Name %s "
      "is already defined.",id);
  recordError(errMsg, yylineno, colno, SEMANTIC);
  incrementLexLevel(symbolTable);
  return ((void *)0);
 }
 if (!ea) {
  ea = newElementArray();
 }
 if (hasDuplicateElement(ea)) {
  errMsg = customErrorString("Procedure %s has duplicate "
     "argument names.", id);
  recordError(errMsg, yylineno, colno, SEMANTIC);
 }
 s = newProcSym(id, ea);
 if (addToSymbolTable(symbolTable, s) != 0) {
  err(1, "Could not add element to symbol table.");
  exit(1);
 }
 incrementLexLevel(symbolTable);
 for (int i = 0; i < ea->nElements; i++) {
  var = paramToVar(getElementAt(ea, i));
  if (!getLocalSymbol(symbolTable, var->name)) {
   addToSymbolTable(symbolTable, var);
   setSymbolSize(getElementAt(ea, i));
   setSymbolSize(var);
   setParamOffset(var, ea);
  }
  else {
   errMsg = customErrorString("Name %s "
        "is already defined.",id);
   recordError(errMsg, yylineno, colno, SEMANTIC);
  }
 }
 emitProcOrFuncDecl(s, ea);
 return s;
}

canonical_original_code:
struct Symbol *enterProcDecl(char *id, struct ElementArray *ea) {
 struct Symbol *s = ((void *)0);
 struct Symbol *var = ((void *)0);
 if (!id) {
  incrementLexLevel(symbolTable);
  return ((void *)0);
 }
 s = getLocalSymbol(symbolTable, id);
 if (s) {
  errMsg = customErrorString("Name %s "
      "is already defined.",id);
  recordError(errMsg, yylineno, colno, SEMANTIC);
  incrementLexLevel(symbolTable);
  return ((void *)0);
 }
 if (!ea) {
  ea = newElementArray();
 }
 if (hasDuplicateElement(ea)) {
  errMsg = customErrorString("Procedure %s has duplicate "
     "argument names.", id);
  recordError(errMsg, yylineno, colno, SEMANTIC);
 }
 s = newProcSym(id, ea);
 if (addToSymbolTable(symbolTable, s) != 0) {
  err(1, "Could not add element to symbol table.");
  exit(1);
 }
 incrementLexLevel(symbolTable);
 for (int i = 0; i < ea->nElements; i++) {
  var = paramToVar(getElementAt(ea, i));
  if (!getLocalSymbol(symbolTable, var->name)) {
   addToSymbolTable(symbolTable, var);
   setSymbolSize(getElementAt(ea, i));
   setSymbolSize(var);
   setParamOffset(var, ea);
  }
  else {
   errMsg = customErrorString("Name %s "
        "is already defined.",id);
   recordError(errMsg, yylineno, colno, SEMANTIC);
  }
 }
 emitProcOrFuncDecl(s, ea);
 return s;
}

variable_types:
ea
struct ElementArray *

variable_types: i 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: struct FunctionKind { struct Symbol *typeSym; struct ElementArray *params; char *label; int invocationInstance; }

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; }


enterFuncDecl

decompiled_code:
const char **__fastcall enterFuncDecl(const char *a1, __int64 a2, __int64 a3)
{
__int64 v4; // r12
unsigned int v5; // er14
const char **v6; // r13
int v7; // er14
unsigned int v8; // ebp
__int64 v9; // rax
const char **v10; // rbx
const char *v11; // r15
__int64 v12; // rax
__int64 v14; // rax
__int64 v15; // rax
__int64 v16; // rbp
__int64 v17; // rax
__int64 v18; // rax

v4 = a2;
v5 = getCurrentLexLevel(symbolTable);
if ( getLocalSymbol(symbolTable, a1) )
{
v6 = 0LL;
v17 = customErrorString("Function with name %s is already defined.", a1);
recordError(v17, yylineno, colno, 2LL);
return v6;
}
if ( a2 )
{
if ( a3 )
goto LABEL_4;
}
else
{
v4 = newElementArray();
if ( a3 )
goto LABEL_4;
}
v18 = customErrorString("Function with name %s has no return type, assuming INTEGER.", a1);
recordError(v18, yylineno, colno, 2LL);
a3 = getPreDefInt(preDefTypeSymbols);
LABEL_4:
if ( (unsigned int)hasDuplicateElement(v4) )
{
v15 = customErrorString("Procedure %s has duplicate argument names.", a1);
recordError(v15, yylineno, colno, 2LL);
}
v6 = (const char **)newFuncSym(v5, a1, a3, v4);
addToSymbolTable(symbolTable, v6);
incrementLexLevel(symbolTable);
if ( !*(_DWORD *)(v4 + 12) )
goto LABEL_16;
v7 = 0;
v8 = 0;
do
{
while ( 1 )
{
v9 = getElementAt(v4, v8);
v10 = (const char **)paramToVar(v9);
if ( !getLocalSymbol(symbolTable, *v10) )
{
addToSymbolTable(symbolTable, v10);
setSymbolSize(v10);
v14 = getElementAt(v4, v8);
setSymbolSize(v14);
setParamOffset(v10, v4);
}
v11 = *v6;
if ( !strcmp(*v10, *v6) )
break;
if ( *(_DWORD *)(v4 + 12) <= ++v8 )
goto LABEL_13;
}
v7 = 1;
++v8;
v12 = customErrorString("Function %s has parameter with same name as function.", v11);
recordError(v12, yylineno, colno, 2LL);
}
while ( *(_DWORD *)(v4 + 12) > v8 );
LABEL_13:
if ( !v7 )
{
LABEL_16:
v16 = paramToVar(v6);
addToSymbolTable(symbolTable, v16);
setParamOffset(v16, v4);
}
emitProcOrFuncDecl(v6, v4);
return v6;
}

canonical_decompiled_code:
const char **__fastcall func10(const char *a1, __int64 a2, __int64 a3)
{
__int64 v4; // r12
unsigned int v5; // er14
const char **v6; // r13
int v7; // er14
unsigned int v8; // ebp
__int64 v9; // rax
const char **v10; // rbx
const char *v11; // r15
__int64 v12; // rax
__int64 v14; // rax
__int64 v15; // rax
__int64 v16; // rbp
__int64 v17; // rax
__int64 v18; // rax

v4 = a2;
v5 = getCurrentLexLevel(symbolTable);
if ( getLocalSymbol(symbolTable, a1) )
{
v6 = 0LL;
v17 = customErrorString("Function with name %s is already defined.", a1);
recordError(v17, yylineno, colno, 2LL);
return v6;
}
if ( a2 )
{
if ( a3 )
goto LABEL_4;
}
else
{
v4 = newElementArray();
if ( a3 )
goto LABEL_4;
}
v18 = customErrorString("Function with name %s has no return type, assuming INTEGER.", a1);
recordError(v18, yylineno, colno, 2LL);
a3 = getPreDefInt(preDefTypeSymbols);
LABEL_4:
if ( (unsigned int)hasDuplicateElement(v4) )
{
v15 = customErrorString("Procedure %s has duplicate argument names.", a1);
recordError(v15, yylineno, colno, 2LL);
}
v6 = (const char **)newFuncSym(v5, a1, a3, v4);
addToSymbolTable(symbolTable, v6);
incrementLexLevel(symbolTable);
if ( !*(_DWORD *)(v4 + 12) )
goto LABEL_16;
v7 = 0;
v8 = 0;
do
{
while ( 1 )
{
v9 = getElementAt(v4, v8);
v10 = (const char **)paramToVar(v9);
if ( !getLocalSymbol(symbolTable, *v10) )
{
addToSymbolTable(symbolTable, v10);
setSymbolSize(v10);
v14 = getElementAt(v4, v8);
setSymbolSize(v14);
setParamOffset(v10, v4);
}
v11 = *v6;
if ( !strcmp(*v10, *v6) )
break;
if ( *(_DWORD *)(v4 + 12) <= ++v8 )
goto LABEL_13;
}
v7 = 1;
++v8;
v12 = customErrorString("Function %s has parameter with same name as function.", v11);
recordError(v12, yylineno, colno, 2LL);
}
while ( *(_DWORD *)(v4 + 12) > v8 );
LABEL_13:
if ( !v7 )
{
LABEL_16:
v16 = paramToVar(v6);
addToSymbolTable(symbolTable, v16);
setParamOffset(v16, v4);
}
emitProcOrFuncDecl(v6, v4);
return v6;
}

original_code:
Symbol *enterFuncDecl(char *id, struct ElementArray *ea, Symbol *typeSym) {
 Symbol *s = ((void *)0), *var = ((void *)0);
 int lvl = getCurrentLexLevel(symbolTable), i, badParamName = 0;
 s = getLocalSymbol(symbolTable, id);
 if (s) {
  errMsg = customErrorString("Function with name %s "
      "is already defined.",id);
  recordError(errMsg, yylineno, colno, SEMANTIC);
  return ((void *)0);
 }
 if (!ea) {
  ea = newElementArray();
 }
 if (!typeSym) {
  errMsg = customErrorString("Function with name %s "
      "has no return type, assuming INTEGER.",id);
  recordError(errMsg, yylineno, colno, SEMANTIC);
  typeSym = getPreDefInt(preDefTypeSymbols);
 }
 if (hasDuplicateElement(ea)) {
  errMsg = customErrorString("Procedure %s has duplicate "
     "argument names.", id);
  recordError(errMsg, yylineno, colno, SEMANTIC);
 }
 s = newFuncSym(lvl, id, typeSym, ea);
 if (addToSymbolTable(symbolTable, s) != 0) {
 }
 incrementLexLevel(symbolTable);
 for (i = 0; i < ea->nElements; i++) {
  var = paramToVar(getElementAt(ea, i));
  if (!getLocalSymbol(symbolTable, var->name)) {
   addToSymbolTable(symbolTable, var);
   setSymbolSize(var);
   setSymbolSize(getElementAt(ea, i));
   setParamOffset(var, ea);
  }
  if (var) {
   if (strcmp(var->name, s->name) == 0) {
    errMsg = customErrorString("Function %s has "
        "parameter with same name as function.",
        s->name);
    recordError(errMsg, yylineno, colno, SEMANTIC);
    badParamName = 1;
   }
  }
 }
 if (!badParamName) {
  var = paramToVar(s);
  addToSymbolTable(symbolTable, var);
  setParamOffset(var, ea);
 }
 emitProcOrFuncDecl(s, ea);
 return s;
}

canonical_original_code:
struct Symbol *enterFuncDecl(char *id, struct ElementArray *ea, struct Symbol *typeSym) {
 struct Symbol *s = ((void *)0); struct Symbol *var = ((void *)0);
 int lvl = getCurrentLexLevel(symbolTable); int i; int badParamName = 0;
 s = getLocalSymbol(symbolTable, id);
 if (s) {
  errMsg = customErrorString("Function with name %s "
      "is already defined.",id);
  recordError(errMsg, yylineno, colno, SEMANTIC);
  return ((void *)0);
 }
 if (!ea) {
  ea = newElementArray();
 }
 if (!typeSym) {
  errMsg = customErrorString("Function with name %s "
      "has no return type, assuming INTEGER.",id);
  recordError(errMsg, yylineno, colno, SEMANTIC);
  typeSym = getPreDefInt(preDefTypeSymbols);
 }
 if (hasDuplicateElement(ea)) {
  errMsg = customErrorString("Procedure %s has duplicate "
     "argument names.", id);
  recordError(errMsg, yylineno, colno, SEMANTIC);
 }
 s = newFuncSym(lvl, id, typeSym, ea);
 if (addToSymbolTable(symbolTable, s) != 0) {
 }
 incrementLexLevel(symbolTable);
 for (i = 0; i < ea->nElements; i++) {
  var = paramToVar(getElementAt(ea, i));
  if (!getLocalSymbol(symbolTable, var->name)) {
   addToSymbolTable(symbolTable, var);
   setSymbolSize(var);
   setSymbolSize(getElementAt(ea, i));
   setParamOffset(var, ea);
  }
  if (var) {
   if (strcmp(var->name, s->name) == 0) {
    errMsg = customErrorString("Function %s has "
        "parameter with same name as function.",
        s->name);
    recordError(errMsg, yylineno, colno, SEMANTIC);
    badParamName = 1;
   }
  }
 }
 if (!badParamName) {
  var = paramToVar(s);
  addToSymbolTable(symbolTable, var);
  setParamOffset(var, ea);
 }
 emitProcOrFuncDecl(s, ea);
 return s;
}

variable_types:
typeSym
struct Symbol *

variable_types: badParamName 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 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 TypeKind { union type_union typePtr; enum type_t type; }

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

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: struct ElementArray { void **data; unsigned int len; unsigned int nElements; }


createParmList

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

if ( !a1 )
return 0LL;
v1 = newElementArray();
growElementArray(v1);
appendElement(v1, a1);
return v1;
}

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

if ( !a1 )
return 0LL;
v1 = newElementArray();
growElementArray(v1);
appendElement(v1, a1);
return v1;
}

original_code:
struct ElementArray *createParmList(Symbol *parm) {
 struct ElementArray *ea = ((void *)0);
 if (!parm) return ((void *)0);
 ea = newElementArray();
 growElementArray(ea);
 appendElement(ea, parm);
 return ea;
}

canonical_original_code:
struct ElementArray *createParmList(struct Symbol *parm) {
 struct ElementArray *ea = ((void *)0);
 if (!parm) return ((void *)0);
 ea = newElementArray();
 growElementArray(ea);
 appendElement(ea, parm);
 return ea;
}

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 *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: struct ElementArray { void **data; unsigned int len; unsigned int nElements; } *


appendParmToParmList

decompiled_code:
__int64 __fastcall appendParmToParmList(__int64 a1, __int64 a2)
{
if ( !a1 || !a2 )
return 0LL;
appendElement(a1, a2);
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, __int64 a2)
{
if ( !a1 || !a2 )
return 0LL;
appendElement(a1, a2);
return a1;
}

original_code:
struct ElementArray *appendParmToParmList(
    struct ElementArray *ea, Symbol *parm) {
 if ( !(ea) || !(parm) ) return ((void *)0);
 appendElement(ea, parm);
 return ea;
}

canonical_original_code:
struct ElementArray *appendParmToParmList(struct ElementArray *ea, struct Symbol *parm) {
 if ( !(ea) || !(parm) ) return ((void *)0);
 appendElement(ea, parm);
 return ea;
}

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

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 Array { struct Symbol *baseTypeSym; struct Symbol *indexTypeSym; }

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; }


createNewParm

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

if ( a1 && a2 )
result = newParamSym();
else
result = 0LL;
return result;
}

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

if ( a1 && a2 )
result = newParamSym();
else
result = 0LL;
return result;
}

original_code:
Symbol *createNewParm(char *id, Symbol *type) {
 if ((!id) || (!type)) return ((void *)0);
 return newParamSym(id, type);
}

canonical_original_code:
struct Symbol *createNewParm(char *id, struct Symbol *type) {
 if ((!id) || (!type)) return ((void *)0);
 return newParamSym(id, type);
}

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: struct FunctionKind { struct Symbol *typeSym; struct ElementArray *params; char *label; int invocationInstance; }

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; }


createNewVarParm

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

result = createNewParm(a1, a2);
if ( result )
*(_DWORD *)(*(_QWORD *)(result + 16) + 8LL) = 1;
return result;
}

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

result = func13(a1, a2);
if ( result )
*(_DWORD *)(*(_QWORD *)(result + 16) + 8LL) = 1;
return result;
}

original_code:
Symbol *createNewVarParm(char *id, Symbol *type) {
 Symbol *s = createNewParm(id, type);
 if (s) s->kindPtr.ParamKind->byRef = 1;
 return s;
}

canonical_original_code:
struct Symbol *createNewVarParm(char *id, struct Symbol *type) {
 struct Symbol *s = createNewParm(id, type);
 if (s) s->kindPtr.ParamKind->byRef = 1;
 return s;
}

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 ParamKind { struct Symbol *typeSym; int byRef; }

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

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

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

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: struct ElementArray { void **data; unsigned int len; unsigned int nElements; }


getSizeOfParams

decompiled_code:
__int64 __fastcall getSizeOfParams(__int64 a1)
{
int v1; // eax
__int64 v2; // r12
unsigned int v3; // ebx
unsigned int v4; // er13
__int64 v5; // rbp
__int64 v6; // rbp
int v7; // eax

v1 = *(_DWORD *)(a1 + 8);
if ( v1 == 3 )
{
v2 = **(_QWORD **)(a1 + 16);
}
else
{
if ( v1 != 1 )
getSizeOfParams_cold();
v2 = *(_QWORD *)(*(_QWORD *)(a1 + 16) + 8LL);
}
if ( !*(_DWORD *)(v2 + 12) )
return 0;
v3 = 0;
v4 = 0;
do
{
while ( 1 )
{
v5 = getElementAt(v2, v3);
if ( !(unsigned int)isByReference(v5) )
{
if ( *(_DWORD *)(v5 + 8) )
{
v6 = getTypeSym(v5);
v7 = getType(v6);
if ( (unsigned int)(v7 - 1) > 4 && v7 != 7 )
break;
}
}
++v4;
if ( ++v3 >= *(_DWORD *)(v2 + 12) )
return v4;
}
if ( (unsigned int)(v7 - 8) <= 1 || v7 == 6 )
v4 += *(_DWORD *)(v6 + 36);
++v3;
}
while ( v3 < *(_DWORD *)(v2 + 12) );
return v4;
}

original_code:
int getSizeOfParams(Symbol *procOrFuncSymbol) {
 struct ElementArray *params = ((void *)0);
 Symbol *param = ((void *)0);
 int size = 0;
 type_t type;
 if (procOrFuncSymbol->kind == PROC_KIND) {
   params = procOrFuncSymbol->kindPtr.ProcKind->params;
 }
 else if (procOrFuncSymbol->kind == FUNC_KIND) {
  params = procOrFuncSymbol->kindPtr.FuncKind->params;
 }
 for (int i = 0; i < params->nElements; ++i) {
  param = getElementAt(params, i);
  if ( isByReference(param) ) {
   size++;
   continue;
  }
  if ( param->kind == CONST_KIND ) {
   size++;
   continue;
  }
  param = getTypeSym(param);
  type = getType(param);
  if ( type == BOOLEAN_T
   || type == CHAR_T
   || type == INTEGER_T
   || type == REAL_T
   || type == SCALARINT_T
   || type == ARRAY_T )
  {
   size++;
   continue;
  }
  if ( type == RECORD_T
   || type == SCALAR_T
   || type == STRING_T
   ) {
   size = size + param->size;
  }
 }
 return size;
}

canonical_original_code:
int getSizeOfParams(struct Symbol *procOrFuncSymbol) {
 struct ElementArray *params = ((void *)0);
 struct Symbol *param = ((void *)0);
 int size = 0;
 enum type_t type;
 if (procOrFuncSymbol->kind == PROC_KIND) {
   params = procOrFuncSymbol->kindPtr.ProcKind->params;
 }
 else if (procOrFuncSymbol->kind == FUNC_KIND) {
  params = procOrFuncSymbol->kindPtr.FuncKind->params;
 }
 for (int i = 0; i < params->nElements; ++i) {
  param = getElementAt(params, i);
  if ( isByReference(param) ) {
   size++;
   continue;
  }
  if ( param->kind == CONST_KIND ) {
   size++;
   continue;
  }
  param = getTypeSym(param);
  type = getType(param);
  if ( type == BOOLEAN_T
   || type == CHAR_T
   || type == INTEGER_T
   || type == REAL_T
   || type == SCALARINT_T
   || type == ARRAY_T )
  {
   size++;
   continue;
  }
  if ( type == RECORD_T
   || type == SCALAR_T
   || type == STRING_T
   ) {
   size = size + param->size;
  }
 }
 return size;
}

variable_types: size int

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 }

return_type: int

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

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

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; }


emitProcOrFuncEndCommon

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

result = doNotEmit;
if ( doNotEmit )
{
doNotEmit = 1;
}
else
{
v3 = getOffset(symbolTable);
v4 = *(_DWORD *)(a1 + 24) + 1;
emitStmt(128LL, "ADJUST %d", (unsigned int)-v3);
emitStmt(128LL, "RET %d", v4);
emitComment(a2);
emitStmt(128LL, (const char *)&unk_71A);
result = emitStmt(128LL, (const char *)&unk_71A);
}
return result;
}

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

result = doNotEmit;
if ( doNotEmit )
{
doNotEmit = 1;
}
else
{
v3 = getOffset(symbolTable);
v4 = *(_DWORD *)(a1 + 24) + 1;
emitStmt(128LL, "ADJUST %d", (unsigned int)-v3);
emitStmt(128LL, "RET %d", v4);
emitComment(a2);
emitStmt(128LL, (const char *)&unk_71A);
result = emitStmt(128LL, (const char *)&unk_71A);
}
return result;
}

original_code:
void emitProcOrFuncEndCommon(Symbol *symbol, char *msg) {
 do { if(!(1) || (doNotEmit)) { doNotEmit = 1; return; }} while (0);
 int adjustCount = 0;
 int lexLevel = 0;
 adjustCount = getOffset(symbolTable) * -1;
 lexLevel = symbol->lvl + 1;
 emitStmt(128, "ADJUST %d", adjustCount);
 emitStmt(128, "RET %d", lexLevel);
 emitComment(msg);
 emitStmt(128, "");
 emitStmt(128, "");
}

canonical_original_code:
void emitProcOrFuncEndCommon(struct Symbol *symbol, char *msg) {
 do { if(!(1) || (doNotEmit)) { doNotEmit = 1; return; }} while (0);
 int adjustCount = 0;
 int lexLevel = 0;
 adjustCount = getOffset(symbolTable) * -1;
 lexLevel = symbol->lvl + 1;
 emitStmt(128, "ADJUST %d", adjustCount);
 emitStmt(128, "RET %d", lexLevel);
 emitComment(msg);
 emitStmt(128, "");
 emitStmt(128, "");
}

variable_types:
msg
char *

variable_types: adjustCount int

variable_types: lexLevel 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: struct FunctionKind { struct Symbol *typeSym; struct ElementArray *params; char *label; int invocationInstance; }

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: 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 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; }


emitEndProc

decompiled_code:
__int64 __fastcall emitEndProc(__int64 a1)
{
return emitProcOrFuncEndCommon(a1, (__int64)"Procedure end.");
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
return func1(a1, (__int64)"Procedure end.");
}

original_code:
void emitEndProc(Symbol *symbol) {
 emitProcOrFuncEndCommon(symbol, "Procedure end.");
}

canonical_original_code:
void emitEndProc(struct Symbol *symbol) {
 emitProcOrFuncEndCommon(symbol, "Procedure end.");
}

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; } *

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 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: struct Param { char *name; enum type_t type; struct Symbol *typeSym; }


emitEndFunc

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

result = doNotEmit;
if ( !doNotEmit )
return emitProcOrFuncEndCommon(a1, (__int64)"Function end.");
doNotEmit = 1;
return result;
}

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

result = doNotEmit;
if ( !doNotEmit )
return func1(a1, (__int64)"Function end.");
doNotEmit = 1;
return result;
}

original_code:
void emitEndFunc(Symbol *symbol) {
 do { if(!(1) || (doNotEmit)) { doNotEmit = 1; return; }} while (0);
 emitProcOrFuncEndCommon(symbol, "Function end.");
}

canonical_original_code:
void emitEndFunc(struct Symbol *symbol) {
 do { if(!(1) || (doNotEmit)) { doNotEmit = 1; return; }} while (0);
 emitProcOrFuncEndCommon(symbol, "Function end.");
}

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 String { char *str; unsigned int strlen; }

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

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

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

user_defined_types: struct Scalar { struct ElementArray *consts; }


createProcOrFunctionLabel

decompiled_code:
char *__fastcall createProcOrFunctionLabel(const char **a1)
{
unsigned int v1; // er12
int v2; // eax
char *v3; // rbp
const char *v4; // r14
size_t v5; // r13
size_t v6; // rbx
char *v7; // r12

reserveLabels(procOrFuncStack, 1LL);
v1 = peekLabelStackTop(procOrFuncStack);
v2 = snprintf(0LL, 0LL, "%i", v1);
v3 = (char *)calloc(1uLL, v2 + 1);
sprintf(v3, "%i", v1);
v4 = *a1;
v5 = strlen(*a1);
v6 = strlen(v3);
v7 = (char *)calloc(1uLL, v5 + v6 + 2);
memcpy(v7, v4, v5);
v7[v5] = 95;
memcpy(&v7[v5 + 1], v3, v6 + 1);
free(v3);
return v7;
}

canonical_decompiled_code:
char *__fastcall func4(const char **a1)
{
unsigned int v1; // er12
int v2; // eax
char *v3; // rbp
const char *v4; // r14
size_t v5; // r13
size_t v6; // rbx
char *v7; // r12

reserveLabels(procOrFuncStack, 1LL);
v1 = peekLabelStackTop(procOrFuncStack);
v2 = snprintf(0LL, 0LL, "%i", v1);
v3 = (char *)calloc(1uLL, v2 + 1);
sprintf(v3, "%i", v1);
v4 = *a1;
v5 = strlen(*a1);
v6 = strlen(v3);
v7 = (char *)calloc(1uLL, v5 + v6 + 2);
memcpy(v7, v4, v5);
v7[v5] = 95;
memcpy(&v7[v5 + 1], v3, v6 + 1);
free(v3);
return v7;
}

original_code:
char *createProcOrFunctionLabel(Symbol *symbol) {
 char *tempName = ((void *)0);
 char *name = ((void *)0);
 int labelCount;
 int size;
 reserveLabels(procOrFuncStack, 1);
 labelCount = peekLabelStackTop(procOrFuncStack);
 size = snprintf(((void *)0), 0, "%i", labelCount);
        tempName = calloc(1, size + 1);
        sprintf(tempName, "%i", labelCount);
        name = calloc(1, (strlen(symbol->name) + 2 + strlen(tempName) ));
        strcat(name, symbol->name);
        strcat(name, "_");
        strcat(name, tempName);
        free(tempName);
        return name;
}

canonical_original_code:
char *createProcOrFunctionLabel(struct Symbol *symbol) {
 char *tempName = ((void *)0);
 char *name = ((void *)0);
 int labelCount;
 int size;
 reserveLabels(procOrFuncStack, 1);
 labelCount = peekLabelStackTop(procOrFuncStack);
 size = snprintf(((void *)0), 0, "%i", labelCount);
        tempName = calloc(1, size + 1);
        sprintf(tempName, "%i", labelCount);
        name = calloc(1, (strlen(symbol->name) + 2 + strlen(tempName) ));
        strcat(name, symbol->name);
        strcat(name, "_");
        strcat(name, tempName);
        free(tempName);
        return name;
}

variable_types:
tempName
char *

variable_types:
name
char *

variable_types: labelCount int

return_type: char *

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: struct FunctionKind { struct Symbol *typeSym; struct ElementArray *params; char *label; int invocationInstance; }

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: 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 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; }


emitProcOrFuncDecl

decompiled_code:
void __fastcall emitProcOrFuncDecl(__int64 a1)
{
char *v1; // rbp
int v2; // eax

if ( a1 && !doNotEmit )
{
emitStmt(128LL, (const char *)&unk_71A);
emitStmt(128LL, (const char *)&unk_71A);
v1 = createProcOrFunctionLabel((const char **)a1);
v2 = *(_DWORD *)(a1 + 8);
if ( v2 == 3 )
{
*(_QWORD *)(*(_QWORD *)(a1 + 16) + 8LL) = v1;
emitComment("Procedure start: %s", v1);
}
else if ( v2 == 1 )
{
*(_QWORD *)(*(_QWORD *)(a1 + 16) + 16LL) = v1;
emitComment("Function start: %s", v1);
}
emitLabel(128LL, v1);
}
else
{
doNotEmit = 1;
}
}

canonical_decompiled_code:
void __fastcall func5(__int64 a1)
{
char *v1; // rbp
int v2; // eax

if ( a1 && !doNotEmit )
{
emitStmt(128LL, (const char *)&unk_71A);
emitStmt(128LL, (const char *)&unk_71A);
v1 = func4((const char **)a1);
v2 = *(_DWORD *)(a1 + 8);
if ( v2 == 3 )
{
*(_QWORD *)(*(_QWORD *)(a1 + 16) + 8LL) = v1;
emitComment("Procedure start: %s", v1);
}
else if ( v2 == 1 )
{
*(_QWORD *)(*(_QWORD *)(a1 + 16) + 16LL) = v1;
emitComment("Function start: %s", v1);
}
emitLabel(128LL, v1);
}
else
{
doNotEmit = 1;
}
}

original_code:
void emitProcOrFuncDecl(Symbol *symbol, struct ElementArray *ea) {
  do { if(!(symbol) || (doNotEmit)) { doNotEmit = 1; return; }} while (0);
  emitStmt(128, "");
  emitStmt(128, "");
  char *label = createProcOrFunctionLabel(symbol);
  if (symbol->kind == PROC_KIND) {
   symbol->kindPtr.ProcKind->label = label;
  emitComment("Procedure start: %s", label);
 }
 else if (symbol->kind == FUNC_KIND) {
  symbol->kindPtr.FuncKind->label = label;
   emitComment("Function start: %s", label);
 }
  emitLabel(128, label);
}

canonical_original_code:
void emitProcOrFuncDecl(struct Symbol *symbol, struct ElementArray *ea) {
  do { if(!(symbol) || (doNotEmit)) { doNotEmit = 1; return; }} while (0);
  emitStmt(128, "");
  emitStmt(128, "");
  char *label = createProcOrFunctionLabel(symbol);
  if (symbol->kind == PROC_KIND) {
   symbol->kindPtr.ProcKind->label = label;
  emitComment("Procedure start: %s", label);
 }
 else if (symbol->kind == FUNC_KIND) {
  symbol->kindPtr.FuncKind->label = label;
   emitComment("Function start: %s", label);
 }
  emitLabel(128, label);
}

variable_types:
label
char *

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 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: 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; }


emitStructuredType

decompiled_code:
__int64 __fastcall emitStructuredType(unsigned int *a1, __int64 a2)
{
signed int v2; // ebx
__int64 result; // rax
__int64 v4; // rdx

if ( (unsigned int)isByReference(a2) )
{
emitStmt(128LL, "PUSH %d[%d]", *(unsigned int *)(a2 + 32), *(unsigned int *)(a2 + 24));
result = emitStmt(128LL, "PUSHI");
}
else
{
v2 = 0;
result = a1[9];
if ( (int)result > 0 )
{
do
{
v4 = v2 + a1[8];
++v2;
result = emitStmt(128LL, "PUSH %d[%d]", v4, a1[6]);
}
while ( (int)a1[9] > v2 );
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned int *a1, __int64 a2)
{
signed int v2; // ebx
__int64 result; // rax
__int64 v4; // rdx

if ( (unsigned int)isByReference(a2) )
{
emitStmt(128LL, "PUSH %d[%d]", *(unsigned int *)(a2 + 32), *(unsigned int *)(a2 + 24));
result = emitStmt(128LL, "PUSHI");
}
else
{
v2 = 0;
result = a1[9];
if ( (int)result > 0 )
{
do
{
v4 = v2 + a1[8];
++v2;
result = emitStmt(128LL, "PUSH %d[%d]", v4, a1[6]);
}
while ( (int)a1[9] > v2 );
}
}
return result;
}

original_code:
void emitStructuredType(Symbol *arg, Symbol *param) {
 int offset = arg->offset;
 if ( isByReference(param) ) {
   emitStmt(128, "PUSH %d[%d]", param->offset, param->lvl);
   emitStmt(128, "PUSHI");
   return;
 }
 for (int i = 0; i < arg->size; ++i){
  offset = arg->offset + i;
  emitStmt(128, "PUSH %d[%d]", offset, arg->lvl);
 }
}

canonical_original_code:
void emitStructuredType(struct Symbol *arg, struct Symbol *param) {
 int offset = arg->offset;
 if ( isByReference(param) ) {
   emitStmt(128, "PUSH %d[%d]", param->offset, param->lvl);
   emitStmt(128, "PUSHI");
   return;
 }
 for (int i = 0; i < arg->size; ++i){
  offset = arg->offset + i;
  emitStmt(128, "PUSH %d[%d]", offset, arg->lvl);
 }
}

variable_types:
param
struct Symbol *

variable_types: offset int

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 String { char *str; unsigned int strlen; }

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

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

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

user_defined_types: struct Scalar { struct ElementArray *consts; }


getProcOrFuncParams

original_code:
struct ElementArray *getProcOrFuncParams(Symbol *procOrFuncSymbol) {
 struct ElementArray *params = ((void *)0);
 if (procOrFuncSymbol->kind == PROC_KIND) {
   params = procOrFuncSymbol->kindPtr.ProcKind->params;
 }
 else if (procOrFuncSymbol->kind == FUNC_KIND) {
  params = procOrFuncSymbol->kindPtr.FuncKind->params;
 }
 return params;
}

canonical_original_code:
struct ElementArray *getProcOrFuncParams(struct Symbol *procOrFuncSymbol) {
 struct ElementArray *params = ((void *)0);
 if (procOrFuncSymbol->kind == PROC_KIND) {
   params = procOrFuncSymbol->kindPtr.ProcKind->params;
 }
 else if (procOrFuncSymbol->kind == FUNC_KIND) {
  params = procOrFuncSymbol->kindPtr.FuncKind->params;
 }
 return params;
}

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: struct FunctionKind { struct Symbol *typeSym; struct ElementArray *params; char *label; int invocationInstance; }

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: 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 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; }


emitPushParamValue

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

result = *(unsigned int *)(a1 + 8);
if ( !a2 )
{
if ( (_DWORD)result )
{
if ( (_DWORD)result != 5 )
{
if ( *(_DWORD *)(a1 + 40) || (unsigned int)getType(a1) == 1 || (result = getType(a1), (_DWORD)result == 6) )
result = emitPushAddressValue(a1);
return result;
}
if ( (unsigned int)getType(a1) == 1 || (unsigned int)getType(a1) == 6 )
return emitPushStructuredVarValue(a1);
}
else
{
result = isConstResultSym();
if ( (_DWORD)result )
return result;
}
return emitPushSymbolValue(a1);
}
if ( (_DWORD)result == 5 )
{
result = *(unsigned int *)(a1 + 40);
if ( !(_DWORD)result )
result = emitPushVarAddress();
}
return result;
}

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

result = *(unsigned int *)(a1 + 8);
if ( !a2 )
{
if ( (_DWORD)result )
{
if ( (_DWORD)result != 5 )
{
if ( *(_DWORD *)(a1 + 40) || (unsigned int)getType(a1) == 1 || (result = getType(a1), (_DWORD)result == 6) )
result = emitPushAddressValue(a1);
return result;
}
if ( (unsigned int)getType(a1) == 1 || (unsigned int)getType(a1) == 6 )
return emitPushStructuredVarValue(a1);
}
else
{
result = isConstResultSym();
if ( (_DWORD)result )
return result;
}
return emitPushSymbolValue(a1);
}
if ( (_DWORD)result == 5 )
{
result = *(unsigned int *)(a1 + 40);
if ( !(_DWORD)result )
result = emitPushVarAddress();
}
return result;
}

original_code:
void emitPushParamValue(Symbol *s, int byRef)
{
 if (!byRef) {
  if (s->kind == CONST_KIND) {
   if (!isConstResultSym(s)) {
    emitPushSymbolValue(s);
   }
   return;
  }
  if (s->kind == VAR_KIND) {
   if ( (getType(s) == ARRAY_T) || (getType(s) ==
       RECORD_T) ) {
   emitPushStructuredVarValue(s);
   } else {
    emitPushSymbolValue(s);
   }
   return;
  }
  if ( (s->isAddress) || getType(s) == ARRAY_T || getType(s) ==
      (RECORD_T) ) {
   emitPushAddressValue(s);
  }
 } else {
  if (s->kind == CONST_KIND) {
  }
  if (s->kind == VAR_KIND) {
   if (!s->isAddress) emitPushVarAddress(s);
  }
 }
}

canonical_original_code:
void emitPushParamValue(struct Symbol *s, int byRef)
{
 if (!byRef) {
  if (s->kind == CONST_KIND) {
   if (!isConstResultSym(s)) {
    emitPushSymbolValue(s);
   }
   return;
  }
  if (s->kind == VAR_KIND) {
   if ( (getType(s) == ARRAY_T) || (getType(s) ==
       RECORD_T) ) {
   emitPushStructuredVarValue(s);
   } else {
    emitPushSymbolValue(s);
   }
   return;
  }
  if ( (s->isAddress) || getType(s) == ARRAY_T || getType(s) ==
      (RECORD_T) ) {
   emitPushAddressValue(s);
  }
 } else {
  if (s->kind == CONST_KIND) {
  }
  if (s->kind == VAR_KIND) {
   if (!s->isAddress) emitPushVarAddress(s);
  }
 }
}

variable_types: byRef 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 ConstantKind { int constResultFlag; struct Symbol *typeSym; union anonymous_constant_value value; }

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: 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; }


emitFuncInvok

decompiled_code:
void __fastcall emitFuncInvok(__int64 a1, __int64 a2)
{
const char *v2; // r13

if ( a1 && !doNotEmit )
{
emitStmt(128LL, (const char *)&unk_71A);
emitComment("Start function invocation '%s':", *(const char **)a1);
if ( (unsigned int)isPreDefFunc(a1) )
{
emitPreDefFunc(a1, a2);
}
else
{
v2 = *(const char **)(*(_QWORD *)(a1 + 16) + 16LL);
emitComment("Make room for return value.");
emitStmt(128LL, "CONSTI 0");
emitProcOrFuncInvokCommon(a1, a2, v2);
}
}
else
{
doNotEmit = 1;
}
}

canonical_decompiled_code:
void __fastcall func9(__int64 a1, __int64 a2)
{
const char *v2; // r13

if ( a1 && !doNotEmit )
{
emitStmt(128LL, (const char *)&unk_71A);
emitComment("Start function invocation '%s':", *(const char **)a1);
if ( (unsigned int)isPreDefFunc(a1) )
{
emitPreDefFunc(a1, a2);
}
else
{
v2 = *(const char **)(*(_QWORD *)(a1 + 16) + 16LL);
emitComment("Make room for return value.");
emitStmt(128LL, "CONSTI 0");
emitProcOrFuncInvokCommon(a1, a2, v2);
}
}
else
{
doNotEmit = 1;
}
}

original_code:
void emitFuncInvok(Symbol *symbol, struct ElementArray *params) {
 char *label;
 do { if(!(symbol) || (doNotEmit)) { doNotEmit = 1; return; }} while (0);
  emitStmt(128, "");
  emitComment("Start function invocation '%s':", symbol->name);
 if (isPreDefFunc(symbol)) {
  emitPreDefFunc(symbol, params);
  return;
 }
 label = symbol->kindPtr.FuncKind->label;
 emitComment("Make room for return value.");
 emitStmt(128, "CONSTI 0");
  emitProcOrFuncInvokCommon(symbol, params, label);
}

canonical_original_code:
void emitFuncInvok(struct Symbol *symbol, struct ElementArray *params) {
 char *label;
 do { if(!(symbol) || (doNotEmit)) { doNotEmit = 1; return; }} while (0);
  emitStmt(128, "");
  emitComment("Start function invocation '%s':", symbol->name);
 if (isPreDefFunc(symbol)) {
  emitPreDefFunc(symbol, params);
  return;
 }
 label = symbol->kindPtr.FuncKind->label;
 emitComment("Make room for return value.");
 emitStmt(128, "CONSTI 0");
  emitProcOrFuncInvokCommon(symbol, params, label);
}

variable_types:
params
struct ElementArray *

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 String { char *str; unsigned int strlen; }

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

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

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

user_defined_types: struct Scalar { struct ElementArray *consts; }


proxyIntLiteral

decompiled_code:
__int64 __fastcall proxyIntLiteral(__int64 a1)
{
__int64 v1; // rax
__int64 v3; // rax
int v4[3]; // [rsp+Ch] [rbp-Ch] BYREF

v4[0] = 0;
if ( (unsigned __int64)(a1 + 0x7FFFFFFF) > 0xFFFFFFFE )
{
v3 = customErrorString("%ld is larger than maxint, which is: %d", a1, 0x7FFFFFFFLL);
recordError(v3, yylineno, colno, 2LL);
}
v4[0] = a1;
v1 = getPreDefInt(preDefTypeSymbols);
return newConstProxySym(0LL, v4, v1);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
__int64 v1; // rax
__int64 v3; // rax
int v4[3]; // [rsp+Ch] [rbp-Ch] BYREF

v4[0] = 0;
if ( (unsigned __int64)(a1 + 0x7FFFFFFF) > 0xFFFFFFFE )
{
v3 = customErrorString("%ld is larger than maxint, which is: %d", a1, 0x7FFFFFFFLL);
recordError(v3, yylineno, colno, 2LL);
}
v4[0] = a1;
v1 = getPreDefInt(preDefTypeSymbols);
return newConstProxySym(0LL, v4, v1);
}

original_code:
ProxySymbol *proxyIntLiteral(long int value) {
 Symbol *newConstProxy = ((void *)0);
 int intValue = 0;
 if (value > 2147483647 || value < -2147483647) {
  errMsg = customErrorString("%ld is larger than maxint, "
      "which is: %d", value, 2147483647);
  recordError(errMsg, yylineno, colno, SEMANTIC);
 }
 intValue = value;
 Symbol *integerType = getPreDefInt(preDefTypeSymbols);
 newConstProxy = newConstProxySym(((void *)0), &intValue, integerType);
 return newConstProxy;
}

canonical_original_code:
struct Symbol *proxyIntLiteral(long value) {
 struct Symbol *newConstProxy = ((void *)0);
 int intValue = 0;
 if (value > 2147483647 || value < -2147483647) {
  errMsg = customErrorString("%ld is larger than maxint, "
      "which is: %d", value, 2147483647);
  recordError(errMsg, yylineno, colno, SEMANTIC);
 }
 intValue = value;
 struct Symbol *integerType = getPreDefInt(preDefTypeSymbols);
 newConstProxy = newConstProxySym(((void *)0), &intValue, integerType);
 return newConstProxy;
}

variable_types: value long

variable_types: intValue 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: struct FunctionKind { struct Symbol *typeSym; struct ElementArray *params; char *label; int invocationInstance; }

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: 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 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; }