emitVarDecl

repo: a-krebs/YACC

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

if ( a1 && (result = doNotEmit, !doNotEmit) )
{
emitComment("Make room on the stack for new var %s", *(const char **)a1);
result = emitStmt(128LL, "ADJUST %d", *(unsigned int *)(a1 + 36));
}
else
{
doNotEmit = 1;
}
return result;
}

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

if ( a1 && (result = doNotEmit, !doNotEmit) )
{
emitComment("Make room on the stack for new var %s", *(const char **)a1);
result = emitStmt(128LL, "ADJUST %d", *(unsigned int *)(a1 + 36));
}
else
{
doNotEmit = 1;
}
return result;
}

original_code:
void emitVarDecl(Symbol *s)
{
 do { if(!(s) || (doNotEmit)) { doNotEmit = 1; return; }} while (0);
 emitComment("Make room on the stack for new var %s", s->name);
 emitStmt(128, "ADJUST %d", s->size);
}

canonical_original_code:
void emitVarDecl(struct Symbol *s)
{
 do { if(!(s) || (doNotEmit)) { doNotEmit = 1; return; }} while (0);
 emitComment("Make room on the stack for new var %s", s->name);
 emitStmt(128, "ADJUST %d", s->size);
}

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: struct Symbol { char *name; enum kind_t kind; union kind_union kindPtr; int lvl; int typeOriginator; int offset; int size; int isAddress; int isRecordHead; struct Symbol *next; }

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

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

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

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

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

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

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

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

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

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


emitIntConstDecl

decompiled_code:
__int64 __fastcall emitIntConstDecl(__int64 a1, __int64 a2)
{
emitComment("Push const val = %d on stack, pop it into place.", a2);
emitStmt(128LL, "CONSTI %d", (unsigned int)a2);
return emitStmt(128LL, "POP %d[%d]", *(unsigned int *)(a1 + 32), *(unsigned int *)(a1 + 24));
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
emitComment("Push const val = %d on stack, pop it into place.", a2);
emitStmt(128LL, "CONSTI %d", (unsigned int)a2);
return emitStmt(128LL, "POP %d[%d]", *(unsigned int *)(a1 + 32), *(unsigned int *)(a1 + 24));
}

original_code:
void emitIntConstDecl(Symbol *s, int value)
{
 emitComment("Push const val = %d on stack, pop it into place.", value);
 emitStmt(128, "CONSTI %d", value);
 emitStmt(128, "POP %d[%d]", s->offset, s->lvl);
}

canonical_original_code:
void emitIntConstDecl(struct Symbol *s, int value)
{
 emitComment("Push const val = %d on stack, pop it into place.", value);
 emitStmt(128, "CONSTI %d", value);
 emitStmt(128, "POP %d[%d]", s->offset, s->lvl);
}

variable_types: value int

return_type: void

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

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


emitRealConstDecl

decompiled_code:
__int64 __fastcall emitRealConstDecl(__int64 a1, float a2)
{
emitComment("Push const val = %f on stack, pop it into place.", a2);
emitStmt(128LL, "CONSTR %f", a2);
return emitStmt(128LL, "POP %d[%d]", *(unsigned int *)(a1 + 32), *(unsigned int *)(a1 + 24));
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, float a2)
{
emitComment("Push const val = %f on stack, pop it into place.", a2);
emitStmt(128LL, "CONSTR %f", a2);
return emitStmt(128LL, "POP %d[%d]", *(unsigned int *)(a1 + 32), *(unsigned int *)(a1 + 24));
}

original_code:
void emitRealConstDecl(Symbol *s, float value)
{
 emitComment("Push const val = %f on stack, pop it into place.", value);
 emitStmt(128, "CONSTR %f", value);
 emitStmt(128, "POP %d[%d]", s->offset, s->lvl);
}

canonical_original_code:
void emitRealConstDecl(struct Symbol *s, float value)
{
 emitComment("Push const val = %f on stack, pop it into place.", value);
 emitStmt(128, "CONSTR %f", value);
 emitStmt(128, "POP %d[%d]", s->offset, s->lvl);
}

variable_types: value float

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

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

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

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

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

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

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

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


emitStringConstDecl

decompiled_code:
__int64 __fastcall emitStringConstDecl(__int64 a1)
{
emitComment("Creating named string const decl %s", *(const char **)a1);
emitPushAnonConstValue(a1);
return emitStmt(128LL, "POP %d[%d]", *(unsigned int *)(a1 + 32), *(unsigned int *)(a1 + 24));
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
emitComment("Creating named string const decl %s", *(const char **)a1);
emitPushAnonConstValue(a1);
return emitStmt(128LL, "POP %d[%d]", *(unsigned int *)(a1 + 32), *(unsigned int *)(a1 + 24));
}

original_code:
void emitStringConstDecl(Symbol *s)
{
 emitComment("Creating named string const decl %s", s->name);
 emitPushAnonConstValue(s);
 emitStmt(128, "POP %d[%d]", s->offset, s->lvl);
}

canonical_original_code:
void emitStringConstDecl(struct Symbol *s)
{
 emitComment("Creating named string const decl %s", s->name);
 emitPushAnonConstValue(s);
 emitStmt(128, "POP %d[%d]", s->offset, s->lvl);
}

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


emitConstDecl

decompiled_code:
void __fastcall emitConstDecl(__int64 a1)
{
unsigned int *v1; // rax
unsigned __int8 *v2; // rax
float v3; // xmm0_4

if ( a1 && !doNotEmit )
{
emitComment("Make room on the stack for new const %s.", *(const char **)a1);
emitStmt(128LL, "ADJUST %d", *(unsigned int *)(a1 + 36));
switch ( (unsigned int)getType(a1) )
{
case 2u:
case 4u:
v1 = (unsigned int *)getConstVal(a1);
emitIntConstDecl(a1, *v1);
break;
case 3u:
v2 = (unsigned __int8 *)getConstVal(a1);
emitIntConstDecl(a1, *v2);
break;
case 5u:
v3 = *(double *)getConstVal(a1);
emitRealConstDecl(a1, v3);
break;
case 9u:
emitStringConstDecl(a1);
break;
default:
return;
}
}
else
{
doNotEmit = 1;
}
}

canonical_decompiled_code:
void __fastcall func4(__int64 a1)
{
unsigned int *v1; // rax
unsigned __int8 *v2; // rax
float v3; // xmm0_4

if ( a1 && !doNotEmit )
{
emitComment("Make room on the stack for new const %s.", *(const char **)a1);
emitStmt(128LL, "ADJUST %d", *(unsigned int *)(a1 + 36));
switch ( (unsigned int)getType(a1) )
{
case 2u:
case 4u:
v1 = (unsigned int *)getConstVal(a1);
func1(a1, *v1);
break;
case 3u:
v2 = (unsigned __int8 *)getConstVal(a1);
func1(a1, *v2);
break;
case 5u:
v3 = *(double *)getConstVal(a1);
func2(a1, v3);
break;
case 9u:
func3(a1);
break;
default:
return;
}
}
else
{
doNotEmit = 1;
}
}

original_code:
void emitConstDecl(Symbol *s)
{
 do { if(!(s) || (doNotEmit)) { doNotEmit = 1; return; }} while (0);
 emitComment("Make room on the stack for new const %s.", s->name);
 emitStmt(128, "ADJUST %d", s->size);
 switch (getType(s)) {
 case BOOLEAN_T:
  emitIntConstDecl(s, getConstVal(s)->Boolean.value);
  break;
 case CHAR_T:
  emitIntConstDecl(s, getConstVal(s)->Char.value);
  break;
 case INTEGER_T:
  emitIntConstDecl(s, getConstVal(s)->Integer.value);
  break;
 case REAL_T:
  emitRealConstDecl(s, getConstVal(s)->Real.value);
  break;
 case STRING_T:
  emitStringConstDecl(s);
  break;
 default:
  break;
 }
}

canonical_original_code:
void emitConstDecl(struct Symbol *s)
{
 do { if(!(s) || (doNotEmit)) { doNotEmit = 1; return; }} while (0);
 emitComment("Make room on the stack for new const %s.", s->name);
 emitStmt(128, "ADJUST %d", s->size);
 switch (getType(s)) {
 case BOOLEAN_T:
  emitIntConstDecl(s, getConstVal(s)->Boolean.value);
  break;
 case CHAR_T:
  emitIntConstDecl(s, getConstVal(s)->Char.value);
  break;
 case INTEGER_T:
  emitIntConstDecl(s, getConstVal(s)->Integer.value);
  break;
 case REAL_T:
  emitRealConstDecl(s, getConstVal(s)->Real.value);
  break;
 case STRING_T:
  emitStringConstDecl(s);
  break;
 default:
  break;
 }
}

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

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


continueLoop

decompiled_code:
__int64 continueLoop()
{
__int64 v1; // rax

if ( !whileLoopDepth )
{
v1 = customErrorString("A continue statement is only allowed inside a while loop.");
recordError(v1, yylineno, colno, 2LL);
}
return emitGotoLoopTop();
}

canonical_decompiled_code:
__int64 func0()
{
__int64 v1; // rax

if ( !whileLoopDepth )
{
v1 = customErrorString("A continue statement is only allowed inside a while loop.");
recordError(v1, yylineno, colno, 2LL);
}
return emitGotoLoopTop();
}

original_code:
void continueLoop(void) {
 if (whileLoopDepth <= 0) {
  errMsg = customErrorString("A continue statement is only "
      "allowed inside a while loop.");
  recordError(errMsg, yylineno, colno, SEMANTIC);
 }
 emitGotoLoopTop();
}

canonical_original_code:
void continueLoop() {
 if (whileLoopDepth <= 0) {
  errMsg = customErrorString("A continue statement is only "
      "allowed inside a while loop.");
  recordError(errMsg, yylineno, colno, SEMANTIC);
 }
 emitGotoLoopTop();
}


exitLoop

decompiled_code:
__int64 exitLoop()
{
__int64 v1; // rax

if ( !whileLoopDepth )
{
v1 = customErrorString("An exit statement is only allowed inside a while loop.");
recordError(v1, yylineno, colno, 2LL);
}
return emitGotoLoopEnd();
}

canonical_decompiled_code:
__int64 func1()
{
__int64 v1; // rax

if ( !whileLoopDepth )
{
v1 = customErrorString("An exit statement is only allowed inside a while loop.");
recordError(v1, yylineno, colno, 2LL);
}
return emitGotoLoopEnd();
}

original_code:
void exitLoop(void) {
 if (whileLoopDepth <= 0) {
  errMsg = customErrorString("An exit statement is only "
      "allowed inside a while loop.");
  recordError(errMsg, yylineno, colno, SEMANTIC);
 }
 emitGotoLoopEnd();
}

canonical_original_code:
void exitLoop() {
 if (whileLoopDepth <= 0) {
  errMsg = customErrorString("An exit statement is only "
      "allowed inside a while loop.");
  recordError(errMsg, yylineno, colno, SEMANTIC);
 }
 emitGotoLoopEnd();
}


beginWhileLoop

decompiled_code:
__int64 beginWhileLoop()
{
++whileLoopDepth;
return emitBeginWhile();
}

canonical_decompiled_code:
__int64 func2()
{
++whileLoopDepth;
return emitBeginWhile();
}

original_code:
void beginWhileLoop(void) {
 whileLoopDepth++;
 emitBeginWhile();
}

canonical_original_code:
void beginWhileLoop() {
 whileLoopDepth++;
 emitBeginWhile();
}


whileLoopCondCheck

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

if ( !a1 || (unsigned int)getType() != 2 )
{
v1 = customErrorString("Loop conditions must be ");
recordError(v1, yylineno, colno, 2LL);
}
return emitWhileLoopCondCheck(a1);
}

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

if ( !a1 || (unsigned int)getType() != 2 )
{
v1 = customErrorString("Loop conditions must be ");
recordError(v1, yylineno, colno, 2LL);
}
return emitWhileLoopCondCheck(a1);
}

original_code:
void whileLoopCondCheck(ProxySymbol *expr) {
 if ((expr == ((void *)0)) || (getType(expr) != BOOLEAN_T)) {
  errMsg = customErrorString("Loop conditions must be ",
      "boolean type.");
  recordError(errMsg, yylineno, colno, SEMANTIC);
 }
 emitWhileLoopCondCheck(expr);
}

canonical_original_code:
void whileLoopCondCheck(struct Symbol *expr) {
 if ((expr == ((void *)0)) || (getType(expr) != BOOLEAN_T)) {
  errMsg = customErrorString("Loop conditions must be ",
      "boolean type.");
  recordError(errMsg, yylineno, colno, SEMANTIC);
 }
 emitWhileLoopCondCheck(expr);
}

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

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

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

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

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

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

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

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


gotoLoopTop

decompiled_code:
__int64 gotoLoopTop()
{
return emitGotoLoopTop();
}

canonical_decompiled_code:
__int64 func4()
{
return emitGotoLoopTop();
}

original_code:
void gotoLoopTop() {
 emitGotoLoopTop();
}


endWhileLoop

decompiled_code:
__int64 endWhileLoop()
{
--whileLoopDepth;
return emitEndWhile();
}

canonical_decompiled_code:
__int64 func5()
{
--whileLoopDepth;
return emitEndWhile();
}

original_code:
void endWhileLoop(void) {
 whileLoopDepth--;
 emitEndWhile();
}

canonical_original_code:
void endWhileLoop() {
 whileLoopDepth--;
 emitEndWhile();
}


ifPart

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

if ( !a1 || (unsigned int)getType() != 2 )
{
v1 = customErrorString("If statement must be given ");
recordError(v1, yylineno, colno, 2LL);
}
return emitIfStat(a1);
}

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

if ( !a1 || (unsigned int)getType() != 2 )
{
v1 = customErrorString("If statement must be given ");
recordError(v1, yylineno, colno, 2LL);
}
return emitIfStat(a1);
}

original_code:
void ifPart(ProxySymbol *expr) {
 if ((expr == ((void *)0)) || (getType(expr) != BOOLEAN_T)) {
  errMsg = customErrorString("If statement must be given ",
      "boolean type expression.");
  recordError(errMsg, yylineno, colno, SEMANTIC);
 }
 emitIfStat(expr);
}

canonical_original_code:
void ifPart(struct Symbol *expr) {
 if ((expr == ((void *)0)) || (getType(expr) != BOOLEAN_T)) {
  errMsg = customErrorString("If statement must be given ",
      "boolean type expression.");
  recordError(errMsg, yylineno, colno, SEMANTIC);
 }
 emitIfStat(expr);
}

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


thenStatPart

decompiled_code:
__int64 thenStatPart()
{
return emitThenStat();
}

canonical_decompiled_code:
__int64 func7()
{
return emitThenStat();
}

original_code:
void thenStatPart() {
 emitThenStat();
}

canonical_original_code:
void thenStatPart() {
 emitThenStat();
}


thenMatchedStatPart

decompiled_code:
__int64 thenMatchedStatPart()
{
return emitThenMatchedStat();
}

canonical_decompiled_code:
__int64 func8()
{
return emitThenMatchedStat();
}

original_code:
void thenMatchedStatPart() {
 emitThenMatchedStat();
}


elseStatPart

decompiled_code:
__int64 elseStatPart()
{
return emitElseStat();
}

canonical_decompiled_code:
__int64 func9()
{
return emitElseStat();
}

original_code:
void elseStatPart() {
 emitElseStat();
}

canonical_original_code:
void elseStatPart() {
 emitElseStat();
}


emitIfStat

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

if ( a1 && !doNotEmit )
{
reserveLabels(labelStack, 2LL);
if ( *(_DWORD *)(a1 + 8) || !(unsigned int)isConstResultSym(a1) )
emitPushSymbolValue(a1);
v1 = peekLabelStackTop(labelStack);
emitComment("IF expr THEN. If 'expr' is false skip to %s%d", "LABEL", v1);
v2 = peekLabelStackTop(labelStack);
emitStmt(128LL, "IFZ %s%d", "LABEL", v2);
}
else
{
doNotEmit = 1;
}
}

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

if ( a1 && !doNotEmit )
{
reserveLabels(labelStack, 2LL);
if ( *(_DWORD *)(a1 + 8) || !(unsigned int)isConstResultSym(a1) )
emitPushSymbolValue(a1);
v1 = peekLabelStackTop(labelStack);
emitComment("IF expr THEN. If 'expr' is false skip to %s%d", "LABEL", v1);
v2 = peekLabelStackTop(labelStack);
emitStmt(128LL, "IFZ %s%d", "LABEL", v2);
}
else
{
doNotEmit = 1;
}
}

original_code:
void emitIfStat(Symbol *s) {
 do { if(!(s) || (doNotEmit)) { doNotEmit = 1; return; }} while (0);
 reserveLabels(labelStack, 2);
 if (! (s->kind == CONST_KIND && isConstResultSym(s))) {
  emitPushSymbolValue(s);
 }
 emitComment("IF expr THEN. If 'expr' is false skip to %s%d",
     "LABEL", peekLabelStackTop(labelStack));
 emitStmt(128, "IFZ %s%d",
     "LABEL", peekLabelStackTop(labelStack));
}

canonical_original_code:
void emitIfStat(struct Symbol *s) {
 do { if(!(s) || (doNotEmit)) { doNotEmit = 1; return; }} while (0);
 reserveLabels(labelStack, 2);
 if (! (s->kind == CONST_KIND && isConstResultSym(s))) {
  emitPushSymbolValue(s);
 }
 emitComment("IF expr THEN. If 'expr' is false skip to %s%d",
     "LABEL", peekLabelStackTop(labelStack));
 emitStmt(128, "IFZ %s%d",
     "LABEL", peekLabelStackTop(labelStack));
}

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

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


emitThenMatchedStat

decompiled_code:
__int64 emitThenMatchedStat()
{
__int64 result; // rax
unsigned int v1; // eax
int v2; // eax
unsigned int v3; // eax

result = doNotEmit;
if ( doNotEmit )
{
doNotEmit = 1;
}
else
{
emitComment("Bottom of an IF-THEN.");
emitComment("Either THEN was executed, so GOTO,");
v1 = peekLabelStackTop(labelStack);
emitComment("or land at %s%d if 'expr' was false", "LABEL", v1);
v2 = peekLabelStackTop(labelStack);
emitStmt(128LL, "GOTO %s%d", "LABEL", (unsigned int)(v2 + 1));
v3 = peekLabelStackTop(labelStack);
result = emitLabel(128LL, "%s%d", "LABEL", v3);
}
return result;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 result; // rax
unsigned int v1; // eax
int v2; // eax
unsigned int v3; // eax

result = doNotEmit;
if ( doNotEmit )
{
doNotEmit = 1;
}
else
{
emitComment("Bottom of an IF-THEN.");
emitComment("Either THEN was executed, so GOTO,");
v1 = peekLabelStackTop(labelStack);
emitComment("or land at %s%d if 'expr' was false", "LABEL", v1);
v2 = peekLabelStackTop(labelStack);
emitStmt(128LL, "GOTO %s%d", "LABEL", (unsigned int)(v2 + 1));
v3 = peekLabelStackTop(labelStack);
result = emitLabel(128LL, "%s%d", "LABEL", v3);
}
return result;
}

original_code:
void emitThenMatchedStat() {
 do { if(!(1) || (doNotEmit)) { doNotEmit = 1; return; }} while (0);
 emitComment("Bottom of an IF-THEN.");
 emitComment("Either THEN was executed, so GOTO,");
 emitComment("or land at %s%d if 'expr' was false",
     "LABEL", peekLabelStackTop(labelStack));
 emitStmt(128, "GOTO %s%d",
     "LABEL", peekLabelStackTop(labelStack) + 1);
 emitLabel(128, "%s%d",
     "LABEL", peekLabelStackTop(labelStack));
}


emitElseStat

decompiled_code:
__int64 emitElseStat()
{
__int64 result; // rax
int v1; // eax

result = doNotEmit;
if ( doNotEmit )
{
doNotEmit = 1;
}
else
{
emitComment("Bottom of ELSE stat");
v1 = peekLabelStackTop(labelStack);
emitLabel(128LL, "%s%d", "LABEL", (unsigned int)(v1 + 1));
result = popLabels(labelStack);
}
return result;
}

canonical_decompiled_code:
__int64 func2()
{
__int64 result; // rax
int v1; // eax

result = doNotEmit;
if ( doNotEmit )
{
doNotEmit = 1;
}
else
{
emitComment("Bottom of ELSE stat");
v1 = peekLabelStackTop(labelStack);
emitLabel(128LL, "%s%d", "LABEL", (unsigned int)(v1 + 1));
result = popLabels(labelStack);
}
return result;
}

original_code:
void emitElseStat() {
 do { if(!(1) || (doNotEmit)) { doNotEmit = 1; return; }} while (0);
 emitComment("Bottom of ELSE stat");
 emitLabel(128, "%s%d",
     "LABEL", peekLabelStackTop(labelStack) + 1);
 popLabels(labelStack);
}


emitThenStat

decompiled_code:
__int64 emitThenStat()
{
__int64 result; // rax
unsigned int v1; // eax

result = doNotEmit;
if ( doNotEmit )
{
doNotEmit = 1;
}
else
{
emitComment("Bottom of IF-THEN as part of IF-THEN");
v1 = peekLabelStackTop(labelStack);
emitLabel(128LL, "%s%d", "LABEL", v1);
result = popLabels(labelStack);
}
return result;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 result; // rax
unsigned int v1; // eax

result = doNotEmit;
if ( doNotEmit )
{
doNotEmit = 1;
}
else
{
emitComment("Bottom of IF-THEN as part of IF-THEN");
v1 = peekLabelStackTop(labelStack);
emitLabel(128LL, "%s%d", "LABEL", v1);
result = popLabels(labelStack);
}
return result;
}

original_code:
void emitThenStat() {
 do { if(!(1) || (doNotEmit)) { doNotEmit = 1; return; }} while (0);
 emitComment("Bottom of IF-THEN as part of IF-THEN");
 emitLabel(128, "%s%d",
     "LABEL", peekLabelStackTop(labelStack));
 popLabels(labelStack);
}


emitBeginWhile

decompiled_code:
__int64 emitBeginWhile()
{
__int64 result; // rax
unsigned int v1; // eax
unsigned int v2; // eax

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

canonical_decompiled_code:
__int64 func4()
{
__int64 result; // rax
unsigned int v1; // eax
unsigned int v2; // eax

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

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


emitWhileLoopCondCheck

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

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

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

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

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

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

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

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

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

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

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

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

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

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


emitGotoLoopTop

decompiled_code:
__int64 emitGotoLoopTop()
{
__int64 result; // rax
unsigned int v1; // eax
unsigned int v2; // eax

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

canonical_decompiled_code:
__int64 func6()
{
__int64 result; // rax
unsigned int v1; // eax
unsigned int v2; // eax

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

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


emitEndWhile

decompiled_code:
__int64 emitEndWhile()
{
__int64 result; // rax
unsigned int v1; // eax
int v2; // eax

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

canonical_decompiled_code:
__int64 func7()
{
__int64 result; // rax
unsigned int v1; // eax
int v2; // eax

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

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


emitGotoLoopEnd

decompiled_code:
__int64 emitGotoLoopEnd()
{
__int64 result; // rax
unsigned int v1; // eax
int v2; // eax

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

canonical_decompiled_code:
__int64 func8()
{
__int64 result; // rax
unsigned int v1; // eax
int v2; // eax

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

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


allocationErrorCheck

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

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

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

variable_types:
p
void *


allocateConstantKind

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

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

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

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

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

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

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

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


allocateFunctionKind

decompiled_code:
void *allocateFunctionKind()
{
return allocateConstantKind();
}

canonical_decompiled_code:
void *func2()
{
return func1();
}

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

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

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

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


allocateProcedureKind

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

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

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

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

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

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

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


allocateTypeKind

decompiled_code:
void *allocateTypeKind()
{
return allocateProcedureKind();
}

canonical_decompiled_code:
void *func4()
{
return func3();
}

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

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

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

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


allocateVariableKind

decompiled_code:
void *allocateVariableKind()
{
return allocateProcedureKind();
}

canonical_decompiled_code:
void *func5()
{
return func3();
}

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

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

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

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


allocateKindPtr

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

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

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

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

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

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

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

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

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

user_defined_types: struct Scalar { struct ElementArray *consts; }

user_defined_types: struct StringType { unsigned int strlen; }


allocateParamKind

decompiled_code:
void *allocateParamKind()
{
return allocateProcedureKind();
}

canonical_decompiled_code:
void *func7()
{
return func3();
}

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

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

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

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

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

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

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

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

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


getConstVal

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

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

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

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

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

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

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


getSimpleConstVal

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

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

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

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

return_type: double

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

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


copyConstVal

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

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

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

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

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

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

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

variable_types:
acl
union anonymous_constant_value *

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


isInvocInstance

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

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

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

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

return_type: int

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

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

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

user_defined_types: struct Scalar { struct ElementArray *consts; }

user_defined_types: struct StringType { unsigned int strlen; }


areKindAssignCompat

decompiled_code:
__int64 __fastcall areKindAssignCompat(__int64 a1, __int64 a2)
{
int v2; // eax
__int64 result; // rax
unsigned int v4; // er8

v2 = *(_DWORD *)(a1 + 8);
if ( v2 == 5 )
{
if ( *(_DWORD *)(a2 + 8) != 1 )
return 1LL;
LOBYTE(v4) = (unsigned int)isInvocInstance(a2) != 0;
result = v4;
}
else
{
if ( v2 != 4 )
return 1LL;
result = *(_DWORD *)(a1 + 40) == 1;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, __int64 a2)
{
int v2; // eax
__int64 result; // rax
unsigned int v4; // er8

v2 = *(_DWORD *)(a1 + 8);
if ( v2 == 5 )
{
if ( *(_DWORD *)(a2 + 8) != 1 )
return 1LL;
LOBYTE(v4) = (unsigned int)func11(a2) != 0;
result = v4;
}
else
{
if ( v2 != 4 )
return 1LL;
result = *(_DWORD *)(a1 + 40) == 1;
}
return result;
}

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

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

variable_types:
y
struct Symbol *

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

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

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

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

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

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

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

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


procInvok

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

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

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

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

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

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

variable_types:
id
char *

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

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

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


funcInvok

decompiled_code:
__int64 __fastcall funcInvok(__int64 a1, __int64 a2)
{
__int64 v3; // rsi
__int64 v4; // rax
_QWORD *v5; // rbx
__int64 v6; // rdx
__int64 v7; // rax
__int64 v8; // rsi
__int64 v9; // rdi
__int64 v10; // rax
__int64 v11; // rdx
__int64 result; // rax
__int64 v13; // rax

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

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
__int64 v3; // rsi
__int64 v4; // rax
_QWORD *v5; // rbx
__int64 v6; // rdx
__int64 v7; // rax
__int64 v8; // rsi
__int64 v9; // rdi
__int64 v10; // rax
__int64 v11; // rdx
__int64 result; // rax
__int64 v13; // rax

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

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

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

variable_types:
argv
struct ElementArray *

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

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

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


createArgList

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

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

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

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

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

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

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

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

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

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

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


concatArgLists

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

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

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

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

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

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

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


emitRelationalSimpleTypeConversion

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

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

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

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

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

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

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

variable_types:
opType
int *

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

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


emitRelationalOperandValue

decompiled_code:
__int64 __fastcall emitRelationalOperandValue(__int64 a1)
{
__int64 result; // rax
unsigned int v2; // eax

if ( *(_DWORD *)(a1 + 40) )
{
v2 = getType(a1);
if ( (unsigned int)isSimpleType(v2) )
return emitPushAddressValue(a1);
}
result = *(unsigned int *)(a1 + 8);
if ( !(_DWORD)result )
{
if ( !(unsigned int)isConstResultSym(a1) )
return emitPushSymbolValue(a1);
result = *(unsigned int *)(a1 + 8);
}
if ( (_DWORD)result != 4 )
return emitPushSymbolValue(a1);
return result;
}

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

if ( *(_DWORD *)(a1 + 40) )
{
v2 = getType(a1);
if ( (unsigned int)isSimpleType(v2) )
return emitPushAddressValue(a1);
}
result = *(unsigned int *)(a1 + 8);
if ( !(_DWORD)result )
{
if ( !(unsigned int)isConstResultSym(a1) )
return emitPushSymbolValue(a1);
result = *(unsigned int *)(a1 + 8);
}
if ( (_DWORD)result != 4 )
return emitPushSymbolValue(a1);
return result;
}

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

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

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

user_defined_types: struct 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 Procedure { struct ParamArray *params; char *label; }

user_defined_types: struct Scalar { struct ElementArray *consts; }

user_defined_types: struct StringType { unsigned int strlen; }


emitRelationalPrep

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

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

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

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

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

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

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

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

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