proxyRealLiteral

decompiled_code:
__int64 __fastcall proxyRealLiteral(double a1)
{
__int64 v1; // rax
double v3[2]; // [rsp+8h] [rbp-10h] BYREF

v3[0] = a1;
v1 = getPreDefReal(preDefTypeSymbols);
return newConstProxySym(0LL, v3, v1);
}

canonical_decompiled_code:
__int64 __fastcall func1(double a1)
{
__int64 v1; // rax
double v3[2]; // [rsp+8h] [rbp-10h] BYREF

v3[0] = a1;
v1 = getPreDefReal(preDefTypeSymbols);
return newConstProxySym(0LL, v3, v1);
}

original_code:
ProxySymbol *proxyRealLiteral(double value) {
 Symbol *realType = getPreDefReal(preDefTypeSymbols);
 Symbol *newConstProxy = ((void *)0);
 newConstProxy = newConstProxySym(((void *)0), &value, realType);
 return newConstProxy;
}

canonical_original_code:
struct Symbol *proxyRealLiteral(double value) {
 struct Symbol *realType = getPreDefReal(preDefTypeSymbols);
 struct Symbol *newConstProxy = ((void *)0);
 newConstProxy = newConstProxySym(((void *)0), &value, realType);
 return newConstProxy;
}

variable_types: value double

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

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

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

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

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

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

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

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


proxyCharLiteral

repo: a-krebs/YACC

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

v1 = getPreDefChar(preDefTypeSymbols);
return newConstProxySym(0LL, a1, v1);
}

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

v1 = getPreDefChar(preDefTypeSymbols);
return newConstProxySym(0LL, a1, v1);
}

original_code:
ProxySymbol *proxyCharLiteral(struct String s) {
 Symbol *charType = getPreDefChar(preDefTypeSymbols);
 Symbol *newConstProxy = ((void *)0);
 newConstProxy = newConstProxySym(((void *)0), s.str, charType);
 return newConstProxy;
}

canonical_original_code:
struct Symbol *proxyCharLiteral(struct String s) {
 struct Symbol *charType = getPreDefChar(preDefTypeSymbols);
 struct Symbol *newConstProxy = ((void *)0);
 newConstProxy = newConstProxySym(((void *)0), s.str, charType);
 return newConstProxy;
}

variable_types:
s
struct String

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

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


proxyStringLiteral

decompiled_code:
__int64 __fastcall proxyStringLiteral(__int64 a1, __int64 a2)
{
__int64 v2; // rbp
__int64 v3; // r12
__int64 v5[5]; // [rsp+0h] [rbp-28h] BYREF

v5[0] = a1;
v5[1] = a2;
v2 = newStringTypeSym((unsigned int)a2);
v3 = newConstProxySym(0LL, v5, v2);
addToSymbolTable(symbolTable, v2);
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2)
{
__int64 v2; // rbp
__int64 v3; // r12
__int64 v5[5]; // [rsp+0h] [rbp-28h] BYREF

v5[0] = a1;
v5[1] = a2;
v2 = newStringTypeSym((unsigned int)a2);
v3 = newConstProxySym(0LL, v5, v2);
addToSymbolTable(symbolTable, v2);
return v3;
}

original_code:
Symbol *proxyStringLiteral(struct String s) {
 Symbol *typeSym = ((void *)0);
 ProxySymbol *proxy = ((void *)0);
 typeSym = newStringTypeSym(s.strlen);
 proxy = newConstProxySym(((void *)0), &s, typeSym);
 addToSymbolTable(symbolTable, typeSym);
 return proxy;
}

canonical_original_code:
struct Symbol *proxyStringLiteral(struct String s) {
 struct Symbol *typeSym = ((void *)0);
 struct Symbol *proxy = ((void *)0);
 typeSym = newStringTypeSym(s.strlen);
 proxy = newConstProxySym(((void *)0), &s, typeSym);
 addToSymbolTable(symbolTable, typeSym);
 return proxy;
}

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


setSymbolName

decompiled_code:
void __fastcall setSymbolName(char **a1, const char *a2)
{
size_t v2; // r12
char *v3; // rax

if ( a2 )
{
v2 = strlen(a2);
v3 = (char *)calloc(1uLL, v2 + 1);
*a1 = v3;
if ( !v3 )
err(1, "Failed to allocate memory for symbol name!");
strncpy(v3, a2, v2);
}
else
{
*a1 = 0LL;
}
}

canonical_decompiled_code:
void __fastcall func0(char **a1, const char *a2)
{
size_t v2; // r12
char *v3; // rax

if ( a2 )
{
v2 = strlen(a2);
v3 = (char *)calloc(1uLL, v2 + 1);
*a1 = v3;
if ( !v3 )
err(1, "Failed to allocate memory for symbol name!");
strncpy(v3, a2, v2);
}
else
{
*a1 = 0LL;
}
}

original_code:
void setSymbolName(Symbol *s, char *id) {
 size_t len;
 if (id == ((void *)0)) {
  s->name = ((void *)0);
  return;
 }
 len = strlen(id) + 1;
 s->name = calloc(1, sizeof(char)*len);
 if (!s->name) {
  err(1, "Failed to allocate memory for symbol name!");
  exit(1);
 }
 strncpy(s->name, id, len - 1);
}

canonical_original_code:
void setSymbolName(struct Symbol *s, char *id) {
 unsigned long len;
 if (id == ((void *)0)) {
  s->name = ((void *)0);
  return;
 }
 len = strlen(id) + 1;
 s->name = calloc(1, sizeof(char)*len);
 if (!s->name) {
  err(1, "Failed to allocate memory for symbol name!");
  exit(1);
 }
 strncpy(s->name, id, len - 1);
}

variable_types:
id
char *

variable_types:
len
unsigned long

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


allocateSymbol

decompiled_code:
void *allocateSymbol()
{
void *result; // rax

result = calloc(1uLL, 0x38uLL);
if ( !result )
err(1, "Could not alloc memory for symbol.");
return result;
}

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

result = calloc(1uLL, 0x38uLL);
if ( !result )
err(1, "Could not alloc memory for symbol.");
return result;
}

original_code:
Symbol *allocateSymbol() {
 Symbol *symbol = ((void *)0);
 symbol = calloc(1, sizeof(Symbol));
 if ( symbol == ((void *)0) ) {
  err(1, "Could not alloc memory for symbol.");
  exit(1);
 }
 return symbol;
}

canonical_original_code:
struct Symbol *allocateSymbol() {
 struct Symbol *symbol = ((void *)0);
 symbol = calloc(1, sizeof(Symbol));
 if ( symbol == ((void *)0) ) {
  err(1, "Could not alloc memory for symbol.");
  exit(1);
 }
 return symbol;
}

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

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

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

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

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

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

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

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


createSymbol

decompiled_code:
char **__fastcall createSymbol(__int64 a1, const char *a2, int a3, int a4)
{
char **v6; // rax
char **v7; // r12
int v8; // eax
char **result; // rax

v6 = (char **)allocateSymbol();
if ( !v6 )
err(1, "Could not create new symbol.");
v7 = v6;
setSymbolName(v6, a2);
*((_DWORD *)v7 + 2) = a3;
allocateKindPtr(v7);
v8 = getCurrentLexLevel(a1);
*((_DWORD *)v7 + 7) = a4;
*((_DWORD *)v7 + 6) = v8;
result = v7;
*((_DWORD *)v7 + 11) = 0;
v7[6] = 0LL;
return result;
}

canonical_decompiled_code:
char **__fastcall func2(__int64 a1, const char *a2, int a3, int a4)
{
char **v6; // rax
char **v7; // r12
int v8; // eax
char **result; // rax

v6 = (char **)func1();
if ( !v6 )
err(1, "Could not create new symbol.");
v7 = v6;
func0(v6, a2);
*((_DWORD *)v7 + 2) = a3;
allocateKindPtr(v7);
v8 = getCurrentLexLevel(a1);
*((_DWORD *)v7 + 7) = a4;
*((_DWORD *)v7 + 6) = v8;
result = v7;
*((_DWORD *)v7 + 11) = 0;
v7[6] = 0LL;
return result;
}

original_code:
Symbol *createSymbol(
    struct hash *table, char *id, kind_t kind, int typeOriginator)
{
 Symbol *symbol = allocateSymbol();
 if (symbol == ((void *)0)) {
  err(1, "Could not create new symbol.");
  exit(1);
 }
 setSymbolName(symbol, id);
 symbol->kind = kind;
 allocateKindPtr(symbol);
 symbol->lvl = getCurrentLexLevel(table);
 symbol->typeOriginator = typeOriginator;
 symbol->isRecordHead = 0;
 symbol->next = ((void *)0);
 return symbol;
}

canonical_original_code:
struct Symbol *createSymbol(struct hash *table, char *id, enum kind_t kind, int typeOriginator)
{
 struct Symbol *symbol = allocateSymbol();
 if (symbol == ((void *)0)) {
  err(1, "Could not create new symbol.");
  exit(1);
 }
 setSymbolName(symbol, id);
 symbol->kind = kind;
 allocateKindPtr(symbol);
 symbol->lvl = getCurrentLexLevel(table);
 symbol->typeOriginator = typeOriginator;
 symbol->isRecordHead = 0;
 symbol->next = ((void *)0);
 return symbol;
}

variable_types:
table
struct hash *

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

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

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

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

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

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

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


setSymbolSize

decompiled_code:
void __fastcall setSymbolSize(__int64 a1)
{
if ( a1 && ((__int64 (*)(void))getTypeSym)() )
{
switch ( *(_DWORD *)(a1 + 8) )
{
case 0:
case 2:
case 5:
if ( (unsigned int)getType(a1) == 8 )
*(_DWORD *)(a1 + 36) = 1;
else
*(_DWORD *)(a1 + 36) = *(_DWORD *)(getTypeSym(a1) + 36);
break;
case 1:
case 3:
*(_DWORD *)(a1 + 36) = -1;
break;
case 4:
if ( (unsigned int)getType(a1) != 6 )
*(_DWORD *)(a1 + 36) = calculateSymbolSize(a1);
break;
default:
return;
}
}
}

canonical_decompiled_code:
void __fastcall func3(__int64 a1)
{
if ( a1 && ((__int64 (*)(void))getTypeSym)() )
{
switch ( *(_DWORD *)(a1 + 8) )
{
case 0:
case 2:
case 5:
if ( (unsigned int)getType(a1) == 8 )
*(_DWORD *)(a1 + 36) = 1;
else
*(_DWORD *)(a1 + 36) = *(_DWORD *)(getTypeSym(a1) + 36);
break;
case 1:
case 3:
*(_DWORD *)(a1 + 36) = -1;
break;
case 4:
if ( (unsigned int)getType(a1) != 6 )
*(_DWORD *)(a1 + 36) = calculateSymbolSize(a1);
break;
default:
return;
}
}
}

original_code:
void setSymbolSize(Symbol *s)
{
 if (!s) return;
 if (!getTypeSym(s)) return;
 switch (s->kind) {
 case CONST_KIND:
  if (getType(s) == SCALAR_T) s->size = 1;
  else s->size = getTypeSym(s)->size;
  break;
 case PARAM_KIND:
 case VAR_KIND:
  if (getType(s) == SCALAR_T) s->size = 1;
  else s->size = getTypeSym(s)->size;
  break;
 case PROC_KIND:
 case FUNC_KIND:
  s->size = -1;
  break;
 case TYPE_KIND:
 {
  if (getType(s) != RECORD_T) s->size = calculateSymbolSize(s);
  break;
 }
 default:
  break;
 }
}

canonical_original_code:
void setSymbolSize(struct Symbol *s)
{
 if (!s) return;
 if (!getTypeSym(s)) return;
 switch (s->kind) {
 case CONST_KIND:
  if (getType(s) == SCALAR_T) s->size = 1;
  else s->size = getTypeSym(s)->size;
  break;
 case PARAM_KIND:
 case VAR_KIND:
  if (getType(s) == SCALAR_T) s->size = 1;
  else s->size = getTypeSym(s)->size;
  break;
 case PROC_KIND:
 case FUNC_KIND:
  s->size = -1;
  break;
 case TYPE_KIND:
 {
  if (getType(s) != RECORD_T) s->size = calculateSymbolSize(s);
  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 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; }


createArrayTypeSymbol

decompiled_code:
__int64 __fastcall createArrayTypeSymbol(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 v6; // r13
__int64 v7; // rax

if ( !a3 || !a4 )
err(1, "Trying to create array type with NULL index or base types. This should be caught further up in Symbols.c");
v6 = createTypeSymbol();
v7 = getKindPtrForTypeKind(v6);
*(_DWORD *)(v7 + 8) = 1;
*(_QWORD *)v7 = newArray(a3, a4);
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 v6; // r13
__int64 v7; // rax

if ( !a3 || !a4 )
err(1, "Trying to create array type with NULL index or base types. This should be caught further up in Symbols.c");
v6 = createTypeSymbol();
v7 = getKindPtrForTypeKind(v6);
*(_DWORD *)(v7 + 8) = 1;
*(_QWORD *)v7 = newArray(a3, a4);
return v6;
}

original_code:
Symbol *createArrayTypeSymbol(
   char *id, int typeOriginator, Symbol *base, Symbol *index)
{
 Symbol *symbol = ((void *)0);
 struct TypeKind *kindPtr = ((void *)0);
 if ((base == ((void *)0)) || (index == ((void *)0))) {
  err(1, "Trying to create array type with NULL "
      "index or base types. This should be caught further "
      "up in Symbols.c");
 }
 symbol = createTypeSymbol(id, typeOriginator);
 kindPtr = getKindPtrForTypeKind(symbol);
 kindPtr->type = ARRAY_T;
 kindPtr->typePtr.Array = newArray(base, index);
 return symbol;
}

canonical_original_code:
struct Symbol *createArrayTypeSymbol(char *id, int typeOriginator, struct Symbol *base, struct Symbol *index)
{
 struct Symbol *symbol = ((void *)0);
 struct TypeKind *kindPtr = ((void *)0);
 if ((base == ((void *)0)) || (index == ((void *)0))) {
  err(1, "Trying to create array type with NULL "
      "index or base types. This should be caught further "
      "up in Symbols.c");
 }
 symbol = createTypeSymbol(id, typeOriginator);
 kindPtr = getKindPtrForTypeKind(symbol);
 kindPtr->type = ARRAY_T;
 kindPtr->typePtr.Array = newArray(base, index);
 return symbol;
}

variable_types:
base
struct Symbol *

variable_types:
index
struct Symbol *

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

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 Function { struct ParamArray *params; struct Symbol *returnTypeSym; char *label; }

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


createScalarListTypeSymbol

decompiled_code:
__int64 __fastcall createScalarListTypeSymbol(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // r12
__int64 v5; // rax
unsigned int v6; // ebx
__int64 v7; // rdi

if ( !a3 )
err(1, "Trying to make a new scalar list type with empty list. This should be caught further up in Symbols.c");
v4 = createTypeSymbol();
v5 = getKindPtrForTypeKind(v4);
*(_DWORD *)(v5 + 8) = 8;
*(_QWORD *)v5 = newScalar(a3);
if ( *(_DWORD *)(a3 + 12) )
{
v6 = 0;
do
{
v7 = getElementAt(a3, v6);
if ( v7 )
setInnerTypeSymbol(v7, v4);
++v6;
}
while ( *(_DWORD *)(a3 + 12) > v6 );
}
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // r12
__int64 v5; // rax
unsigned int v6; // ebx
__int64 v7; // rdi

if ( !a3 )
err(1, "Trying to make a new scalar list type with empty list. This should be caught further up in Symbols.c");
v4 = createTypeSymbol();
v5 = getKindPtrForTypeKind(v4);
*(_DWORD *)(v5 + 8) = 8;
*(_QWORD *)v5 = newScalar(a3);
if ( *(_DWORD *)(a3 + 12) )
{
v6 = 0;
do
{
v7 = getElementAt(a3, v6);
if ( v7 )
setInnerTypeSymbol(v7, v4);
++v6;
}
while ( *(_DWORD *)(a3 + 12) > v6 );
}
return v4;
}

original_code:
Symbol *createScalarListTypeSymbol(
    char *id, int typeOriginator, struct ElementArray *scalars)
{
 int i = 0;
 Symbol *symbol = ((void *)0);
 Symbol *tmpConstSym = ((void *)0);
 struct TypeKind *kindPtr = ((void *)0);
 if (scalars == ((void *)0)) {
  err(1, "Trying to make a new scalar list type "
      "with empty list. This should be caught further up in "
      "Symbols.c");
 }
 symbol = createTypeSymbol(id, typeOriginator);
 kindPtr = getKindPtrForTypeKind(symbol);
 kindPtr->type = SCALAR_T;
 kindPtr->typePtr.Scalar = newScalar(scalars);
 for (i = 0; i < scalars->nElements; i++) {
  tmpConstSym = getElementAt(scalars, i);
  if (tmpConstSym == ((void *)0)) continue;
  setInnerTypeSymbol(tmpConstSym, symbol);
 }
 return symbol;
}

canonical_original_code:
struct Symbol *createScalarListTypeSymbol(char *id, int typeOriginator, struct ElementArray *scalars)
{
 int i = 0;
 struct Symbol *symbol = ((void *)0);
 struct Symbol *tmpConstSym = ((void *)0);
 struct TypeKind *kindPtr = ((void *)0);
 if (scalars == ((void *)0)) {
  err(1, "Trying to make a new scalar list type "
      "with empty list. This should be caught further up in "
      "Symbols.c");
 }
 symbol = createTypeSymbol(id, typeOriginator);
 kindPtr = getKindPtrForTypeKind(symbol);
 kindPtr->type = SCALAR_T;
 kindPtr->typePtr.Scalar = newScalar(scalars);
 for (i = 0; i < scalars->nElements; i++) {
  tmpConstSym = getElementAt(scalars, i);
  if (tmpConstSym == ((void *)0)) continue;
  setInnerTypeSymbol(tmpConstSym, symbol);
 }
 return symbol;
}

variable_types:
scalars
struct ElementArray *

variable_types: i int

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

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

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

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

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

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

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


newVariableSym

decompiled_code:
__int64 __fastcall newVariableSym(__int64 a1, __int64 a2)
{
__int64 v2; // r12

if ( !a2 || *(_DWORD *)(a2 + 8) != 4 || !a1 )
return 0LL;
v2 = createVarSymbol();
setInnerTypeSymbol(v2, a2);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
__int64 v2; // r12

if ( !a2 || *(_DWORD *)(a2 + 8) != 4 || !a1 )
return 0LL;
v2 = createVarSymbol();
setInnerTypeSymbol(v2, a2);
return v2;
}

original_code:
Symbol *newVariableSym(char *id, Symbol* typeSym) {
 Symbol *newVar = ((void *)0);
 if (typeSym == ((void *)0)) {
  return ((void *)0);
 }
 if (typeSym->kind != TYPE_KIND) {
  return ((void *)0);
 }
 if (id == ((void *)0)) {
  return ((void *)0);
 }
 newVar = createVarSymbol(id);
 setInnerTypeSymbol(newVar, typeSym);
 return newVar;
}

canonical_original_code:
struct Symbol *newVariableSym(char *id, struct Symbol *typeSym) {
 struct Symbol *newVar = ((void *)0);
 if (typeSym == ((void *)0)) {
  return ((void *)0);
 }
 if (typeSym->kind != TYPE_KIND) {
  return ((void *)0);
 }
 if (id == ((void *)0)) {
  return ((void *)0);
 }
 newVar = createVarSymbol(id);
 setInnerTypeSymbol(newVar, typeSym);
 return newVar;
}

variable_types:
typeSym
struct Symbol *

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

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

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

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

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


newParamSym

decompiled_code:
__int64 __fastcall newParamSym(__int64 a1, __int64 a2)
{
__int64 v2; // r12

if ( !a2 || !a1 )
return 0LL;
v2 = createParamSymbol();
setInnerTypeSymbol(v2, a2);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2)
{
__int64 v2; // r12

if ( !a2 || !a1 )
return 0LL;
v2 = createParamSymbol();
setInnerTypeSymbol(v2, a2);
return v2;
}

original_code:
Symbol *newParamSym(char *id, Symbol *typeSym) {
 Symbol *newParamSym = ((void *)0);
 if (!typeSym) {
  return ((void *)0);
 }
 if (!id) {
  return ((void *)0);
 }
 newParamSym = createParamSymbol(id);
 setInnerTypeSymbol(newParamSym, typeSym);
 return newParamSym;
}

canonical_original_code:
struct Symbol *newParamSym(char *id, struct Symbol *typeSym) {
 struct Symbol *newParamSym = ((void *)0);
 if (!typeSym) {
  return ((void *)0);
 }
 if (!id) {
  return ((void *)0);
 }
 newParamSym = createParamSymbol(id);
 setInnerTypeSymbol(newParamSym, typeSym);
 return newParamSym;
}

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

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

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

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

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

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

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


newProcSym

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

result = createProcSymbol();
**(_QWORD **)(result + 16) = a2;
return result;
}

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

result = createProcSymbol();
**(_QWORD **)(result + 16) = a2;
return result;
}

original_code:
Symbol *newProcSym(char *id, struct ElementArray *ea) {
 Symbol *s = createProcSymbol(id);
 s->kindPtr.ProcKind->params = ea;
 return s;
}

canonical_original_code:
struct Symbol *newProcSym(char *id, struct ElementArray *ea) {
 struct Symbol *s = createProcSymbol(id);
 s->kindPtr.ProcKind->params = ea;
 return s;
}

variable_types:
ea
struct ElementArray *

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

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

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

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

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

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

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


newFuncSym

decompiled_code:
__int64 __fastcall newFuncSym(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 v6; // r12

v6 = createFuncSymbol(a2);
*(_QWORD *)(*(_QWORD *)(v6 + 16) + 8LL) = a4;
setInnerTypeSymbol(v6, a3);
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 v6; // r12

v6 = createFuncSymbol(a2);
*(_QWORD *)(*(_QWORD *)(v6 + 16) + 8LL) = a4;
setInnerTypeSymbol(v6, a3);
return v6;
}

original_code:
Symbol *newFuncSym(
    int lvl, char *id, Symbol *typeSym, struct ElementArray *ea)
{
 Symbol *s = createFuncSymbol(id);
 s->kindPtr.FuncKind->params = ea;
 setInnerTypeSymbol(s, typeSym);
 return s;
}

canonical_original_code:
struct Symbol *newFuncSym(int lvl, char *id, struct Symbol *typeSym, struct ElementArray *ea)
{
 struct Symbol *s = createFuncSymbol(id);
 s->kindPtr.FuncKind->params = ea;
 setInnerTypeSymbol(s, typeSym);
 return s;
}

variable_types: lvl int

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

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

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

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

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


newRecordTypeSym

decompiled_code:
__int64 __fastcall newRecordTypeSym(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rbx
__int64 v3; // r12

v1 = createTypeSymbol(a1, 1LL);
v2 = *(_QWORD *)(v1 + 16);
v3 = v1;
*(_DWORD *)(v2 + 8) = 6;
*(_QWORD *)v2 = newRecord();
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rbx
__int64 v3; // r12

v1 = createTypeSymbol(a1, 1LL);
v2 = *(_QWORD *)(v1 + 16);
v3 = v1;
*(_DWORD *)(v2 + 8) = 6;
*(_QWORD *)v2 = newRecord();
return v3;
}

original_code:
Symbol *newRecordTypeSym(char *id) {
 Symbol *newRecType = createTypeSymbol(id, 1);
 newRecType->kindPtr.TypeKind->type = RECORD_T;
 newRecType->kindPtr.TypeKind->typePtr.Record = newRecord();
 return newRecType;
}

canonical_original_code:
struct Symbol *newRecordTypeSym(char *id) {
 struct Symbol *newRecType = createTypeSymbol(id, 1);
 newRecType->kindPtr.TypeKind->type = RECORD_T;
 newRecType->kindPtr.TypeKind->typePtr.Record = newRecord();
 return newRecType;
}

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

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

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

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

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

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

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


newSubrangeSym

decompiled_code:
__int64 __fastcall newSubrangeSym(__int64 a1, __int64 a2)
{
int v2; // er12
unsigned int v3; // eax
unsigned int v4; // eax
unsigned __int8 v5; // bl
__int64 v6; // rax
__int64 v7; // rbx
__int64 v8; // r12
int v10; // ebx

if ( !a1 )
return 0LL;
if ( !a2 )
return 0LL;
if ( *(_DWORD *)(a1 + 8) )
return 0LL;
if ( *(_DWORD *)(a2 + 8) )
return 0LL;
v2 = ((__int64 (*)(void))getType)();
if ( v2 != (unsigned int)getType(a2) )
return 0LL;
v3 = getType(a1);
if ( !(unsigned int)isOrdinal(v3) )
return 0LL;
v4 = getType(a1);
if ( v4 == 4 )
goto LABEL_14;
if ( v4 > 4 )
{
if ( v4 != 8 )
goto LABEL_12;
goto LABEL_14;
}
if ( v4 == 2 )
{
LABEL_14:
v10 = *(_DWORD *)getConstVal(a1);
if ( v10 > *(_DWORD *)getConstVal(a2) )
return 0LL;
LABEL_12:
v6 = createTypeSymbol(0LL, 1LL);
v7 = *(_QWORD *)(v6 + 16);
v8 = v6;
*(_DWORD *)(v7 + 8) = 10;
*(_QWORD *)v7 = newSubrange(a1, a2);
return v8;
}
if ( v4 != 3 )
goto LABEL_12;
v5 = *(_BYTE *)getConstVal(a1);
if ( v5 <= *(_BYTE *)getConstVal(a2) )
goto LABEL_12;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2)
{
int v2; // er12
unsigned int v3; // eax
unsigned int v4; // eax
unsigned __int8 v5; // bl
__int64 v6; // rax
__int64 v7; // rbx
__int64 v8; // r12
int v10; // ebx

if ( !a1 )
return 0LL;
if ( !a2 )
return 0LL;
if ( *(_DWORD *)(a1 + 8) )
return 0LL;
if ( *(_DWORD *)(a2 + 8) )
return 0LL;
v2 = ((__int64 (*)(void))getType)();
if ( v2 != (unsigned int)getType(a2) )
return 0LL;
v3 = getType(a1);
if ( !(unsigned int)isOrdinal(v3) )
return 0LL;
v4 = getType(a1);
if ( v4 == 4 )
goto LABEL_14;
if ( v4 > 4 )
{
if ( v4 != 8 )
goto LABEL_12;
goto LABEL_14;
}
if ( v4 == 2 )
{
LABEL_14:
v10 = *(_DWORD *)getConstVal(a1);
if ( v10 > *(_DWORD *)getConstVal(a2) )
return 0LL;
LABEL_12:
v6 = createTypeSymbol(0LL, 1LL);
v7 = *(_QWORD *)(v6 + 16);
v8 = v6;
*(_DWORD *)(v7 + 8) = 10;
*(_QWORD *)v7 = newSubrange(a1, a2);
return v8;
}
if ( v4 != 3 )
goto LABEL_12;
v5 = *(_BYTE *)getConstVal(a1);
if ( v5 <= *(_BYTE *)getConstVal(a2) )
goto LABEL_12;
return 0LL;
}

original_code:
Symbol *newSubrangeSym(ProxySymbol *constSymLow, ProxySymbol *constSymHigh) {
 Symbol *newSubrangeSym = ((void *)0);
 if ((!constSymLow) || (!constSymHigh)) {
  return ((void *)0);
 }
 if ((constSymLow->kind != CONST_KIND) ||
     (constSymHigh->kind != CONST_KIND)) {
  return ((void *)0);
 }
 if (getType(constSymLow) != getType(constSymHigh)) {
  return ((void *)0);
 }
 if (!isOrdinal(getType(constSymLow))) {
  return ((void *)0);
 }
 switch(getType(constSymLow)) {
 case SCALAR_T:
  if (getConstVal(constSymLow)->Integer.value >
      getConstVal(constSymHigh)->Integer.value) return ((void *)0);
  break;
 case INTEGER_T:
  if (getConstVal(constSymLow)->Integer.value >
      getConstVal(constSymHigh)->Integer.value) return ((void *)0);
  break;
 case BOOLEAN_T:
  if (getConstVal(constSymLow)->Boolean.value >
      getConstVal(constSymHigh)->Boolean.value) return ((void *)0);
  break;
 case CHAR_T:
  if (getConstVal(constSymLow)->Char.value >
      getConstVal(constSymHigh)->Char.value) return ((void *)0);
  break;
 default:
  break;
 }
 newSubrangeSym = createTypeSymbol(((void *)0), 1);
 newSubrangeSym->kindPtr.TypeKind->type = SUBRANGE_T;
 newSubrangeSym->kindPtr.TypeKind->typePtr.Subrange = newSubrange(
          constSymLow,
          constSymHigh);
 return newSubrangeSym;
}

canonical_original_code:
struct Symbol *newSubrangeSym(struct Symbol *constSymLow, struct Symbol *constSymHigh) {
 struct Symbol *newSubrangeSym = ((void *)0);
 if ((!constSymLow) || (!constSymHigh)) {
  return ((void *)0);
 }
 if ((constSymLow->kind != CONST_KIND) ||
     (constSymHigh->kind != CONST_KIND)) {
  return ((void *)0);
 }
 if (getType(constSymLow) != getType(constSymHigh)) {
  return ((void *)0);
 }
 if (!isOrdinal(getType(constSymLow))) {
  return ((void *)0);
 }
 switch(getType(constSymLow)) {
 case SCALAR_T:
  if (getConstVal(constSymLow)->Integer.value >
      getConstVal(constSymHigh)->Integer.value) return ((void *)0);
  break;
 case INTEGER_T:
  if (getConstVal(constSymLow)->Integer.value >
      getConstVal(constSymHigh)->Integer.value) return ((void *)0);
  break;
 case BOOLEAN_T:
  if (getConstVal(constSymLow)->Boolean.value >
      getConstVal(constSymHigh)->Boolean.value) return ((void *)0);
  break;
 case CHAR_T:
  if (getConstVal(constSymLow)->Char.value >
      getConstVal(constSymHigh)->Char.value) return ((void *)0);
  break;
 default:
  break;
 }
 newSubrangeSym = createTypeSymbol(((void *)0), 1);
 newSubrangeSym->kindPtr.TypeKind->type = SUBRANGE_T;
 newSubrangeSym->kindPtr.TypeKind->typePtr.Subrange = newSubrange(
          constSymLow,
          constSymHigh);
 return newSubrangeSym;
}

variable_types:
constSymLow
struct Symbol *

variable_types:
constSymHigh
struct Symbol *

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

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

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

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

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

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

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

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


newTypeSymFromSym

decompiled_code:
__int64 __fastcall newTypeSymFromSym(__int64 a1, __int64 a2)
{
__int64 v2; // r12
__int64 v4; // rax

if ( !a2 )
return 0LL;
if ( *(_DWORD *)(a2 + 8) == 4 )
{
if ( !a1 )
err(1, "Trying to create named type symbol but name is NULL.");
v2 = createTypeSymbol(a1, 0LL);
*(_QWORD *)(v2 + 16) = *(_QWORD *)(a2 + 16);
if ( (unsigned int)getType(v2) == 6 )
*(_DWORD *)(v2 + 36) = *(_DWORD *)(a2 + 36);
return v2;
}
v4 = customErrorString("Identifier %s is not a type.", *(const char **)a2);
recordError(v4, yylineno, colno, 2LL);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, __int64 a2)
{
__int64 v2; // r12
__int64 v4; // rax

if ( !a2 )
return 0LL;
if ( *(_DWORD *)(a2 + 8) == 4 )
{
if ( !a1 )
err(1, "Trying to create named type symbol but name is NULL.");
v2 = createTypeSymbol(a1, 0LL);
*(_QWORD *)(v2 + 16) = *(_QWORD *)(a2 + 16);
if ( (unsigned int)getType(v2) == 6 )
*(_DWORD *)(v2 + 36) = *(_DWORD *)(a2 + 36);
return v2;
}
v4 = customErrorString("Identifier %s is not a type.", *(const char **)a2);
recordError(v4, yylineno, colno, 2LL);
return 0LL;
}

original_code:
Symbol *newTypeSymFromSym(char *id, Symbol *typeSym) {
 Symbol *newTypeSym = ((void *)0);
 if (!typeSym) {
  return ((void *)0);
 }
 if (typeSym->kind != TYPE_KIND) {
  errMsg = customErrorString("Identifier %s is not a type.",
      typeSym->name);
  recordError(errMsg, yylineno, colno, SEMANTIC);
  return ((void *)0);
 }
 if (!id) {
  err(1, "Trying to create named type symbol "
      "but name is NULL.");
 }
 newTypeSym = createTypeSymbol(id, 0);
 newTypeSym->kindPtr = typeSym->kindPtr;
 if (getType(newTypeSym) == RECORD_T) {
  newTypeSym->size = typeSym->size;
 }
 return newTypeSym;
}

canonical_original_code:
struct Symbol *newTypeSymFromSym(char *id, struct Symbol *typeSym) {
 struct Symbol *newTypeSym = ((void *)0);
 if (!typeSym) {
  return ((void *)0);
 }
 if (typeSym->kind != TYPE_KIND) {
  errMsg = customErrorString("Identifier %s is not a type.",
      typeSym->name);
  recordError(errMsg, yylineno, colno, SEMANTIC);
  return ((void *)0);
 }
 if (!id) {
  err(1, "Trying to create named type symbol "
      "but name is NULL.");
 }
 newTypeSym = createTypeSymbol(id, 0);
 newTypeSym->kindPtr = typeSym->kindPtr;
 if (getType(newTypeSym) == RECORD_T) {
  newTypeSym->size = typeSym->size;
 }
 return newTypeSym;
}

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

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

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

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

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


makeArrayIndexSym

decompiled_code:
__int64 __fastcall makeArrayIndexSym(__int64 a1)
{
__int64 v1; // r12
int v2; // eax
__int64 v3; // rax
__int64 v4; // rax
__int64 v5; // rbp
__int64 v6; // rax
__int64 v7; // r12
__int64 result; // rax
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // rbp
__int64 v12; // rax
__int64 v13; // rax
int v14; // [rsp+8h] [rbp-20h] BYREF
int v15[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v1 = a1;
v2 = getType(a1);
if ( v2 == 2 )
{
v14 = 0;
v9 = getTypeSym(a1);
v10 = newConstProxySym(0LL, &v14, v9);
v15[0] = 1;
v11 = v10;
v12 = getTypeSym(a1);
v13 = newConstProxySym(0LL, v15, v12);
result = newSubrangeSym(v11, v13);
}
else
{
if ( v2 == 3 )
{
v14 = 0;
v3 = getTypeSym(a1);
v4 = newConstProxySym(0LL, &v14, v3);
v15[0] = 255;
v5 = v4;
v6 = getTypeSym(a1);
v7 = newConstProxySym(0LL, v15, v6);
*(_BYTE *)getConstVal(v7) = -1;
v1 = newSubrangeSym(v5, v7);
}
result = v1;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
__int64 v1; // r12
int v2; // eax
__int64 v3; // rax
__int64 v4; // rax
__int64 v5; // rbp
__int64 v6; // rax
__int64 v7; // r12
__int64 result; // rax
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // rbp
__int64 v12; // rax
__int64 v13; // rax
int v14; // [rsp+8h] [rbp-20h] BYREF
int v15[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v1 = a1;
v2 = getType(a1);
if ( v2 == 2 )
{
v14 = 0;
v9 = getTypeSym(a1);
v10 = newConstProxySym(0LL, &v14, v9);
v15[0] = 1;
v11 = v10;
v12 = getTypeSym(a1);
v13 = newConstProxySym(0LL, v15, v12);
result = func7(v11, v13);
}
else
{
if ( v2 == 3 )
{
v14 = 0;
v3 = getTypeSym(a1);
v4 = newConstProxySym(0LL, &v14, v3);
v15[0] = 255;
v5 = v4;
v6 = getTypeSym(a1);
v7 = newConstProxySym(0LL, v15, v6);
*(_BYTE *)getConstVal(v7) = -1;
v1 = func7(v5, v7);
}
result = v1;
}
return result;
}

original_code:
Symbol *makeArrayIndexSym(Symbol *indexTypeSym)
{
 Symbol *lowSym, *highSym;
 int low, high;
 switch (getType(indexTypeSym)) {
 case BOOLEAN_T:
  low = 0;
  lowSym = newConstProxySym(((void *)0), &low,
      getTypeSym(indexTypeSym));
  high = 1;
  highSym = newConstProxySym(((void *)0), &high,
      getTypeSym(indexTypeSym));
  return newSubrangeSym(lowSym, highSym);
 case CHAR_T:
  low = 0;
  lowSym = newConstProxySym(((void *)0), &low,
      getTypeSym(indexTypeSym));
  high = 255;
  highSym = newConstProxySym(((void *)0), &high,
      getTypeSym(indexTypeSym));
  getConstVal(highSym)->Char.value = '\xff';
  return newSubrangeSym(lowSym, highSym);
 default:
  return indexTypeSym;
 }
 return ((void *)0);
}

canonical_original_code:
struct Symbol *makeArrayIndexSym(struct Symbol *indexTypeSym)
{
 struct Symbol *lowSym; struct Symbol *highSym;
 int low; int high;
 switch (getType(indexTypeSym)) {
 case BOOLEAN_T:
  low = 0;
  lowSym = newConstProxySym(((void *)0), &low,
      getTypeSym(indexTypeSym));
  high = 1;
  highSym = newConstProxySym(((void *)0), &high,
      getTypeSym(indexTypeSym));
  return newSubrangeSym(lowSym, highSym);
 case CHAR_T:
  low = 0;
  lowSym = newConstProxySym(((void *)0), &low,
      getTypeSym(indexTypeSym));
  high = 255;
  highSym = newConstProxySym(((void *)0), &high,
      getTypeSym(indexTypeSym));
  getConstVal(highSym)->Char.value = '\xff';
  return newSubrangeSym(lowSym, highSym);
 default:
  return indexTypeSym;
 }
 return ((void *)0);
}

variable_types:
indexTypeSym
struct Symbol *

variable_types: low int

variable_types: high int

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

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

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

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

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

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

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


newAnonArraySym

decompiled_code:
__int64 __fastcall newAnonArraySym(__int64 a1, __int64 a2)
{
__int64 v2; // rax
__int64 result; // rax
__int64 v4; // rax
unsigned int v5; // eax
const char *v6; // rax

if ( !a1 || !a2 )
{
v4 = customErrorString("Cannot define array. Base type or index type incorrect or undefined.");
goto LABEL_10;
}
if ( *(_DWORD *)(a1 + 8) != 4 )
{
v4 = customErrorString("Cannot create array with given base type");
LABEL_10:
recordError(v4, yylineno, colno, 2LL);
return 0LL;
}
if ( (unsigned int)getType(a2) != 8
&& (unsigned int)getType(a2) != 10
&& (unsigned int)getType(a2) != 2
&& (unsigned int)getType(a2) != 3 )
{
v5 = getType(a2);
v6 = (const char *)typeToString(v5);
v4 = customErrorString("Trying to index array using non-index type %s", v6);
goto LABEL_10;
}
v2 = makeArrayIndexSym(a2);
result = createArrayTypeSymbol(0LL, 1LL, a1, v2);
if ( !result )
err(1, "Failed to allocate memory for new array!");
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, __int64 a2)
{
__int64 v2; // rax
__int64 result; // rax
__int64 v4; // rax
unsigned int v5; // eax
const char *v6; // rax

if ( !a1 || !a2 )
{
v4 = customErrorString("Cannot define array. Base type or index type incorrect or undefined.");
goto LABEL_10;
}
if ( *(_DWORD *)(a1 + 8) != 4 )
{
v4 = customErrorString("Cannot create array with given base type");
LABEL_10:
recordError(v4, yylineno, colno, 2LL);
return 0LL;
}
if ( (unsigned int)getType(a2) != 8
&& (unsigned int)getType(a2) != 10
&& (unsigned int)getType(a2) != 2
&& (unsigned int)getType(a2) != 3 )
{
v5 = getType(a2);
v6 = (const char *)typeToString(v5);
v4 = customErrorString("Trying to index array using non-index type %s", v6);
goto LABEL_10;
}
v2 = func9(a2);
result = func0(0LL, 1LL, a1, v2);
if ( !result )
err(1, "Failed to allocate memory for new array!");
return result;
}

original_code:
Symbol *newAnonArraySym(Symbol *baseTypeSym, Symbol *indexTypeSym) {
 Symbol *newArraySym = ((void *)0), *index;
 if ((!baseTypeSym) || (!indexTypeSym)) {
  errMsg = customErrorString("Cannot define array. "
      "Base type or index type incorrect or undefined.");
  recordError(errMsg, yylineno, colno, SEMANTIC);
  return ((void *)0);
 }
 if ((baseTypeSym->kind != TYPE_KIND) ||
     (baseTypeSym->kind != TYPE_KIND)) {
  errMsg = customErrorString("Cannot create array with given "
      "base type");
  recordError(errMsg, yylineno, colno, SEMANTIC);
  return ((void *)0);
 }
 if (((getType(indexTypeSym)) != SCALAR_T) &&
     ((getType(indexTypeSym)) != SUBRANGE_T) &&
     ((getType(indexTypeSym))!= BOOLEAN_T) &&
     ((getType(indexTypeSym)) != CHAR_T)) {
  errMsg = customErrorString("Trying to index array using non-"
      "index type %s", typeToString(getType(indexTypeSym)));
  recordError(errMsg, yylineno, colno, SEMANTIC);
  return ((void *)0);
 }
 index = makeArrayIndexSym(indexTypeSym);
 newArraySym = createArrayTypeSymbol(
      ((void *)0), 1, baseTypeSym, index);
 if (!newArraySym) {
  err(1, "Failed to allocate memory for new array!");
 }
 return newArraySym;
}

canonical_original_code:
struct Symbol *newAnonArraySym(struct Symbol *baseTypeSym, struct Symbol *indexTypeSym) {
 struct Symbol *newArraySym = ((void *)0); struct Symbol *index;
 if ((!baseTypeSym) || (!indexTypeSym)) {
  errMsg = customErrorString("Cannot define array. "
      "Base type or index type incorrect or undefined.");
  recordError(errMsg, yylineno, colno, SEMANTIC);
  return ((void *)0);
 }
 if ((baseTypeSym->kind != TYPE_KIND) ||
     (baseTypeSym->kind != TYPE_KIND)) {
  errMsg = customErrorString("Cannot create array with given "
      "base type");
  recordError(errMsg, yylineno, colno, SEMANTIC);
  return ((void *)0);
 }
 if (((getType(indexTypeSym)) != SCALAR_T) &&
     ((getType(indexTypeSym)) != SUBRANGE_T) &&
     ((getType(indexTypeSym))!= BOOLEAN_T) &&
     ((getType(indexTypeSym)) != CHAR_T)) {
  errMsg = customErrorString("Trying to index array using non-"
      "index type %s", typeToString(getType(indexTypeSym)));
  recordError(errMsg, yylineno, colno, SEMANTIC);
  return ((void *)0);
 }
 index = makeArrayIndexSym(indexTypeSym);
 newArraySym = createArrayTypeSymbol(
      ((void *)0), 1, baseTypeSym, index);
 if (!newArraySym) {
  err(1, "Failed to allocate memory for new array!");
 }
 return newArraySym;
}

variable_types:
baseTypeSym
struct Symbol *

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

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

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


newAnonScalarListTypeSym

decompiled_code:
__int64 __fastcall newAnonScalarListTypeSym(__int64 a1)
{
if ( !a1 )
err(1, "Trying to create anon scalar list with NULL list of scalars.");
return createScalarListTypeSymbol(0LL, 1LL, a1);
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1)
{
if ( !a1 )
err(1, "Trying to create anon scalar list with NULL list of scalars.");
return func1(0LL, 1LL, a1);
}

original_code:
Symbol *newAnonScalarListTypeSym(struct ElementArray *ea) {
 Symbol *newAnonScalarList = ((void *)0);
 if (ea == ((void *)0)) {
  err(1, "Trying to create anon scalar list with "
      "NULL list of scalars.");
 }
 newAnonScalarList = createScalarListTypeSymbol(
     ((void *)0), 1, ea);
 return newAnonScalarList;
}

canonical_original_code:
struct Symbol *newAnonScalarListTypeSym(struct ElementArray *ea) {
 struct Symbol *newAnonScalarList = ((void *)0);
 if (ea == ((void *)0)) {
  err(1, "Trying to create anon scalar list with "
      "NULL list of scalars.");
 }
 newAnonScalarList = createScalarListTypeSymbol(
     ((void *)0), 1, ea);
 return newAnonScalarList;
}

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 hashElement { char *key; struct Symbol *symbol; struct hashElement *prev; struct hashElement *next; }


newStringTypeSym

decompiled_code:
__int64 __fastcall newStringTypeSym(unsigned int a1)
{
__int64 v1; // r12
__int64 v2; // rax

v1 = createTypeSymbol(0LL, 1LL);
v2 = getKindPtrForTypeKind(v1);
*(_DWORD *)(v2 + 8) = 9;
*(_QWORD *)v2 = newStringType(a1);
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func12(unsigned int a1)
{
__int64 v1; // r12
__int64 v2; // rax

v1 = createTypeSymbol(0LL, 1LL);
v2 = getKindPtrForTypeKind(v1);
*(_DWORD *)(v2 + 8) = 9;
*(_QWORD *)v2 = newStringType(a1);
return v1;
}

original_code:
Symbol *newStringTypeSym(int strlen) {
 Symbol *newStringSym = createTypeSymbol(((void *)0), 1);
 struct TypeKind *kindPtr = getKindPtrForTypeKind(newStringSym);
 kindPtr->type = STRING_T;
 kindPtr->typePtr.String = newStringType(strlen);
 return newStringSym;
}

canonical_original_code:
struct Symbol *newStringTypeSym(int strlen) {
 struct Symbol *newStringSym = createTypeSymbol(((void *)0), 1);
 struct TypeKind *kindPtr = getKindPtrForTypeKind(newStringSym);
 kindPtr->type = STRING_T;
 kindPtr->typePtr.String = newStringType(strlen);
 return newStringSym;
}

variable_types: strlen int

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

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 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: union anonymous_constant_value { struct Boolean Boolean; struct Char Char; struct Integer Integer; struct Real Real; struct String String; }


isConstInScalar

decompiled_code:
_BOOL8 __fastcall isConstInScalar(__int64 a1, __int64 a2)
{
_BOOL8 result; // rax
__int64 v3; // rax
__int64 v4; // rbx

if ( !a1 )
return 0LL;
result = 0LL;
if ( a2 )
{
v3 = getTypeSym(a1);
v4 = getTypePtr(v3);
result = v4 == getTypePtr(a2);
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func13(__int64 a1, __int64 a2)
{
_BOOL8 result; // rax
__int64 v3; // rax
__int64 v4; // rbx

if ( !a1 )
return 0LL;
result = 0LL;
if ( a2 )
{
v3 = getTypeSym(a1);
v4 = getTypePtr(v3);
result = v4 == getTypePtr(a2);
}
return result;
}

original_code:
int
isConstInScalar(Symbol *constSym, Symbol *scalarSymType)
{
 if (!(constSym) || !(scalarSymType)) return 0;
 if (getTypePtr(getTypeSym(constSym)) != getTypePtr(scalarSymType)) {
  return 0;
 }
 return 1;
}

canonical_original_code:
int isConstInScalar(struct Symbol *constSym, struct Symbol *scalarSymType)
{
 if (!(constSym) || !(scalarSymType)) return 0;
 if (getTypePtr(getTypeSym(constSym)) != getTypePtr(scalarSymType)) {
  return 0;
 }
 return 1;
}

variable_types:
scalarSymType
struct Symbol *

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

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

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

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

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


setSymbolOffset

decompiled_code:
void __fastcall setSymbolOffset(__int64 a1, __int64 a2)
{
int v3; // eax
__int64 v4; // rsi

if ( a1 )
{
v3 = getOffset(a2);
v4 = *(unsigned int *)(a1 + 36);
*(_DWORD *)(a1 + 32) = v3;
addToOffset(a2, v4);
}
}

canonical_decompiled_code:
void __fastcall func14(__int64 a1, __int64 a2)
{
int v3; // eax
__int64 v4; // rsi

if ( a1 )
{
v3 = getOffset(a2);
v4 = *(unsigned int *)(a1 + 36);
*(_DWORD *)(a1 + 32) = v3;
addToOffset(a2, v4);
}
}

original_code:
void setSymbolOffset(Symbol *s, struct hash *table)
{
 if (!s) return;
 s->offset = getOffset(table);
 addToOffset(table, s->size);
}

canonical_original_code:
void setSymbolOffset(struct Symbol *s, struct hash *table)
{
 if (!s) return;
 s->offset = getOffset(table);
 addToOffset(table, s->size);
}

variable_types:
table
struct hash *

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 hashElement { char *key; struct Symbol *symbol; struct hashElement *prev; struct hashElement *next; }


setParamOffset

decompiled_code:
__int64 __fastcall setParamOffset(__int64 a1, __int64 a2)
{
unsigned int v2; // ebp
int v3; // er13
__int64 v4; // rbx
__int64 result; // rax

if ( !*(_DWORD *)(a2 + 12) )
{
result = 4294967294LL;
goto LABEL_8;
}
v2 = 0;
v3 = 0;
do
{
v4 = getElementAt(a2, v2);
if ( (unsigned int)isByReference(v4) )
{
++v3;
if ( !strcmp(*(const char **)v4, *(const char **)a1) )
break;
goto LABEL_4;
}
v3 += *(_DWORD *)(v4 + 36);
if ( !strcmp(*(const char **)v4, *(const char **)a1) )
break;
LABEL_4:
++v2;
}
while ( *(_DWORD *)(a2 + 12) > v2 );
result = (unsigned int)(-2 - v3);
LABEL_8:
*(_DWORD *)(a1 + 32) = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func15(__int64 a1, __int64 a2)
{
unsigned int v2; // ebp
int v3; // er13
__int64 v4; // rbx
__int64 result; // rax

if ( !*(_DWORD *)(a2 + 12) )
{
result = 4294967294LL;
goto LABEL_8;
}
v2 = 0;
v3 = 0;
do
{
v4 = getElementAt(a2, v2);
if ( (unsigned int)isByReference(v4) )
{
++v3;
if ( !strcmp(*(const char **)v4, *(const char **)a1) )
break;
goto LABEL_4;
}
v3 += *(_DWORD *)(v4 + 36);
if ( !strcmp(*(const char **)v4, *(const char **)a1) )
break;
LABEL_4:
++v2;
}
while ( *(_DWORD *)(a2 + 12) > v2 );
result = (unsigned int)(-2 - v3);
LABEL_8:
*(_DWORD *)(a1 + 32) = result;
return result;
}

original_code:
void setParamOffset(Symbol *s, struct ElementArray *params)
{
 Symbol *param = ((void *)0);
 int offset = 0, i;
 for (i = 0; i < params->nElements; i++) {
  param = getElementAt(params, i);
  if (isByReference(param)) offset += 1;
  else offset += param->size;
  if (strcmp(param->name, s->name) == 0) {
   break;
  }
 }
 offset += 2;
 offset *= -1;
 s->offset = offset;
}

canonical_original_code:
void setParamOffset(struct Symbol *s, struct ElementArray *params)
{
 struct Symbol *param = ((void *)0);
 int offset = 0; int i;
 for (i = 0; i < params->nElements; i++) {
  param = getElementAt(params, i);
  if (isByReference(param)) offset += 1;
  else offset += param->size;
  if (strcmp(param->name, s->name) == 0) {
   break;
  }
 }
 offset += 2;
 offset *= -1;
 s->offset = offset;
}

variable_types:
params
struct ElementArray *

variable_types: offset int

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

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

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

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

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


emitArithmeticPrep

decompiled_code:
void __fastcall emitArithmeticPrep(const char **a1, __int64 a2, _DWORD *a3, int a4)
{
if ( !a1 || doNotEmit )
{
doNotEmit = 1;
return;
}
if ( !a2 )
{
doNotEmit = 1;
return;
}
if ( *((_DWORD *)a1 + 10) )
{
((void (*)(void))emitPushAddressValue)();
LABEL_6:
if ( !*(_DWORD *)(a2 + 40) )
goto LABEL_7;
LABEL_19:
emitPushAddressValue(a2);
LABEL_8:
if ( (unsigned int)getType(a1) != 4 )
goto LABEL_9;
goto LABEL_15;
}
if ( *((_DWORD *)a1 + 2) == 4 )
goto LABEL_6;
((void (*)(void))emitPushSymbolValue)();
if ( *(_DWORD *)(a2 + 40) )
goto LABEL_19;
LABEL_7:
if ( *(_DWORD *)(a2 + 8) == 4 )
goto LABEL_8;
emitPushSymbolValue(a2);
if ( (unsigned int)getType(a1) != 4 )
goto LABEL_9;
LABEL_15:
if ( (unsigned int)getType(a2) == 4 )
{
if ( a4 != 298 )
{
*a3 = 0;
return;
}
emitComment("Converting %s to a real value.", *a1);
emitStmt(128LL, "ADJUST -1");
emitStmt(128LL, "ITOR");
emitStmt(128LL, "ADJUST 1");
goto LABEL_27;
}
LABEL_9:
if ( (unsigned int)getType(a1) == 5 && (unsigned int)getType(a2) == 5 )
goto LABEL_23;
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");
emitStmt(128LL, "ADJUST 1");
*a3 = 1;
return;
}
if ( (unsigned int)getType(a1) == 5 && (unsigned int)getType(a2) == 4 )
{
LABEL_27:
emitComment("Converting %s to a real value.", *(const char **)a2);
emitStmt(128LL, "ITOR");
LABEL_23:
*a3 = 1;
}
}

canonical_decompiled_code:
void __fastcall func0(const char **a1, __int64 a2, _DWORD *a3, int a4)
{
if ( !a1 || doNotEmit )
{
doNotEmit = 1;
return;
}
if ( !a2 )
{
doNotEmit = 1;
return;
}
if ( *((_DWORD *)a1 + 10) )
{
((void (*)(void))emitPushAddressValue)();
LABEL_6:
if ( !*(_DWORD *)(a2 + 40) )
goto LABEL_7;
LABEL_19:
emitPushAddressValue(a2);
LABEL_8:
if ( (unsigned int)getType(a1) != 4 )
goto LABEL_9;
goto LABEL_15;
}
if ( *((_DWORD *)a1 + 2) == 4 )
goto LABEL_6;
((void (*)(void))emitPushSymbolValue)();
if ( *(_DWORD *)(a2 + 40) )
goto LABEL_19;
LABEL_7:
if ( *(_DWORD *)(a2 + 8) == 4 )
goto LABEL_8;
emitPushSymbolValue(a2);
if ( (unsigned int)getType(a1) != 4 )
goto LABEL_9;
LABEL_15:
if ( (unsigned int)getType(a2) == 4 )
{
if ( a4 != 298 )
{
*a3 = 0;
return;
}
emitComment("Converting %s to a real value.", *a1);
emitStmt(128LL, "ADJUST -1");
emitStmt(128LL, "ITOR");
emitStmt(128LL, "ADJUST 1");
goto LABEL_27;
}
LABEL_9:
if ( (unsigned int)getType(a1) == 5 && (unsigned int)getType(a2) == 5 )
goto LABEL_23;
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");
emitStmt(128LL, "ADJUST 1");
*a3 = 1;
return;
}
if ( (unsigned int)getType(a1) == 5 && (unsigned int)getType(a2) == 4 )
{
LABEL_27:
emitComment("Converting %s to a real value.", *(const char **)a2);
emitStmt(128LL, "ITOR");
LABEL_23:
*a3 = 1;
}
}

original_code:
static void emitArithmeticPrep(Symbol *x, Symbol *y, int *result, int opToken)
{
 do { if(!(x) || (doNotEmit)) { doNotEmit = 1; return; }} while (0);
 do { if(!(y) || (doNotEmit)) { doNotEmit = 1; return; }} while (0);
 if (x->isAddress) {
  emitPushAddressValue(x);
 } else if (x->kind != TYPE_KIND){
  emitPushSymbolValue(x);
 }
 if (y->isAddress) {
  emitPushAddressValue(y);
 } else if (y->kind != TYPE_KIND){
  emitPushSymbolValue(y);
 }
 if ((getType(x) == INTEGER_T) && (getType(y) == INTEGER_T)) {
  if ( opToken == 298 ) {
   emitComment("Converting %s to a real value.", x->name);
   emitStmt(128, "ADJUST -1");
   emitStmt(128, "ITOR");
   emitStmt(128, "ADJUST 1");
   emitComment("Converting %s to a real value.", y->name);
   emitStmt(128, "ITOR");
   *result = 1;
   return;
  }
  *result = 0;
 } else if ((getType(x) == REAL_T) && (getType(y) == REAL_T)) {
  *result = 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");
  *result = 1;
 } else if ((getType(x) == REAL_T) && (getType(y) == INTEGER_T)) {
  emitComment("Converting %s to a real value.", y->name);
  emitStmt(128, "ITOR");
  *result = 1;
 }
}

canonical_original_code:
static void emitArithmeticPrep(struct Symbol *x, struct Symbol *y, int *result, int opToken)
{
 do { if(!(x) || (doNotEmit)) { doNotEmit = 1; return; }} while (0);
 do { if(!(y) || (doNotEmit)) { doNotEmit = 1; return; }} while (0);
 if (x->isAddress) {
  emitPushAddressValue(x);
 } else if (x->kind != TYPE_KIND){
  emitPushSymbolValue(x);
 }
 if (y->isAddress) {
  emitPushAddressValue(y);
 } else if (y->kind != TYPE_KIND){
  emitPushSymbolValue(y);
 }
 if ((getType(x) == INTEGER_T) && (getType(y) == INTEGER_T)) {
  if ( opToken == 298 ) {
   emitComment("Converting %s to a real value.", x->name);
   emitStmt(128, "ADJUST -1");
   emitStmt(128, "ITOR");
   emitStmt(128, "ADJUST 1");
   emitComment("Converting %s to a real value.", y->name);
   emitStmt(128, "ITOR");
   *result = 1;
   return;
  }
  *result = 0;
 } else if ((getType(x) == REAL_T) && (getType(y) == REAL_T)) {
  *result = 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");
  *result = 1;
 } else if ((getType(x) == REAL_T) && (getType(y) == INTEGER_T)) {
  emitComment("Converting %s to a real value.", y->name);
  emitStmt(128, "ITOR");
  *result = 1;
 }
}

variable_types:
y
struct Symbol *

variable_types:
result
int *

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

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

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

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

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


emitITOR

decompiled_code:
void __fastcall emitITOR(const char **a1)
{
const char *v1; // r12
unsigned int v2; // eax
const char *v3; // rax
const char *v4; // rcx
const char *v5; // r8

if ( a1 && !doNotEmit )
{
v1 = *a1;
v2 = getType(a1);
v3 = (const char *)typeToString(v2);
emitComment("Perform ITOR of %s %s and %s %s", v3, v1, v4, v5);
if ( (unsigned int)getType(a1) == 4 )
{
emitPushVarValue(a1);
emitStmt(128LL, "ITOR");
}
}
else
{
doNotEmit = 1;
}
}

canonical_decompiled_code:
void __fastcall func1(const char **a1)
{
const char *v1; // r12
unsigned int v2; // eax
const char *v3; // rax
const char *v4; // rcx
const char *v5; // r8

if ( a1 && !doNotEmit )
{
v1 = *a1;
v2 = getType(a1);
v3 = (const char *)typeToString(v2);
emitComment("Perform ITOR of %s %s and %s %s", v3, v1, v4, v5);
if ( (unsigned int)getType(a1) == 4 )
{
emitPushVarValue(a1);
emitStmt(128LL, "ITOR");
}
}
else
{
doNotEmit = 1;
}
}

original_code:
void emitITOR(Symbol *x) {
 do { if(!(x) || (doNotEmit)) { doNotEmit = 1; return; }} while (0);
 emitComment("Perform ITOR of %s %s and %s %s",
      typeToString(getType(x)), x->name);
 if ( getType(x) == INTEGER_T) {
  emitPushVarValue(x);
  emitStmt(128, "ITOR");
 }
}

canonical_original_code:
void emitITOR(struct Symbol *x) {
 do { if(!(x) || (doNotEmit)) { doNotEmit = 1; return; }} while (0);
 emitComment("Perform ITOR of %s %s and %s %s",
      typeToString(getType(x)), x->name);
 if ( getType(x) == INTEGER_T) {
  emitPushVarValue(x);
  emitStmt(128, "ITOR");
 }
}

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 hashElement { char *key; struct Symbol *symbol; struct hashElement *prev; struct hashElement *next; }


emitRTOI

decompiled_code:
void __fastcall emitRTOI(const char **a1)
{
const char *v1; // r12
unsigned int v2; // eax
const char *v3; // rax
const char *v4; // rcx
const char *v5; // r8

if ( a1 && !doNotEmit )
{
v1 = *a1;
v2 = getType(a1);
v3 = (const char *)typeToString(v2);
emitComment("Perform RTOI of %s %s and %s %s", v3, v1, v4, v5);
if ( (unsigned int)getType(a1) == 5 )
{
emitPushVarValue(a1);
emitStmt(128LL, "RTOI");
}
}
else
{
doNotEmit = 1;
}
}

canonical_decompiled_code:
void __fastcall func2(const char **a1)
{
const char *v1; // r12
unsigned int v2; // eax
const char *v3; // rax
const char *v4; // rcx
const char *v5; // r8

if ( a1 && !doNotEmit )
{
v1 = *a1;
v2 = getType(a1);
v3 = (const char *)typeToString(v2);
emitComment("Perform RTOI of %s %s and %s %s", v3, v1, v4, v5);
if ( (unsigned int)getType(a1) == 5 )
{
emitPushVarValue(a1);
emitStmt(128LL, "RTOI");
}
}
else
{
doNotEmit = 1;
}
}

original_code:
void emitRTOI(Symbol *x) {
 do { if(!(x) || (doNotEmit)) { doNotEmit = 1; return; }} while (0);
 emitComment("Perform RTOI of %s %s and %s %s",
      typeToString(getType(x)), x->name);
 if ( getType(x) == REAL_T) {
  emitPushVarValue(x);
  emitStmt(128, "RTOI");
 }
}

canonical_original_code:
void emitRTOI(struct Symbol *x) {
 do { if(!(x) || (doNotEmit)) { doNotEmit = 1; return; }} while (0);
 emitComment("Perform RTOI of %s %s and %s %s",
      typeToString(getType(x)), x->name);
 if ( getType(x) == REAL_T) {
  emitPushVarValue(x);
  emitStmt(128, "RTOI");
 }
}

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

user_defined_types: struct Scalar { struct ElementArray *consts; }

user_defined_types: struct StringType { unsigned int strlen; }


emitArithmCheckAndComment

decompiled_code:
void __fastcall emitArithmCheckAndComment(const char **a1, const char **a2, const char *a3)
{
const char *v4; // r14
unsigned int v5; // eax
__int64 v6; // rax
const char *v7; // r13
const char *v8; // rbx
unsigned int v9; // eax
const char *v10; // rax

if ( a1 && !doNotEmit && a2 )
{
v4 = *a2;
v5 = getType(a2);
v6 = typeToString(v5);
v7 = *a1;
v8 = (const char *)v6;
v9 = getType(a1);
v10 = (const char *)typeToString(v9);
emitComment("Perform %s of %s %s and %s %s", a3, v10, v7, v8, v4);
}
else
{
doNotEmit = 1;
}
}

canonical_decompiled_code:
void __fastcall func3(const char **a1, const char **a2, const char *a3)
{
const char *v4; // r14
unsigned int v5; // eax
__int64 v6; // rax
const char *v7; // r13
const char *v8; // rbx
unsigned int v9; // eax
const char *v10; // rax

if ( a1 && !doNotEmit && a2 )
{
v4 = *a2;
v5 = getType(a2);
v6 = typeToString(v5);
v7 = *a1;
v8 = (const char *)v6;
v9 = getType(a1);
v10 = (const char *)typeToString(v9);
emitComment("Perform %s of %s %s and %s %s", a3, v10, v7, v8, v4);
}
else
{
doNotEmit = 1;
}
}

original_code:
void emitArithmCheckAndComment(Symbol *x, Symbol *y, char *opName) {
 do { if(!(x) || (doNotEmit)) { doNotEmit = 1; return; }} while (0);
 do { if(!(y) || (doNotEmit)) { doNotEmit = 1; return; }} while (0);
 emitComment("Perform %s of %s %s and %s %s",
  opName,
      typeToString(getType(x)), x->name,
      typeToString(getType(y)), y->name);
}

canonical_original_code:
void emitArithmCheckAndComment(struct Symbol *x, struct Symbol *y, char *opName) {
 do { if(!(x) || (doNotEmit)) { doNotEmit = 1; return; }} while (0);
 do { if(!(y) || (doNotEmit)) { doNotEmit = 1; return; }} while (0);
 emitComment("Perform %s of %s %s and %s %s",
  opName,
      typeToString(getType(x)), x->name,
      typeToString(getType(y)), y->name);
}

variable_types:
opName
char *

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

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

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

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

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

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


emitMod

decompiled_code:
__int64 __fastcall emitMod(const char **a1, const char **a2)
{
int v3[7]; // [rsp+Ch] [rbp-1Ch] BYREF

emitArithmCheckAndComment(a1, a2, "mod");
emitArithmeticPrep(a1, (__int64)a2, v3, -1);
return emitStmt(128LL, "MOD");
}

canonical_decompiled_code:
__int64 __fastcall func4(const char **a1, const char **a2)
{
int v3[7]; // [rsp+Ch] [rbp-1Ch] BYREF

func3(a1, a2, "mod");
func0(a1, (__int64)a2, v3, -1);
return emitStmt(128LL, "MOD");
}

original_code:
void emitMod(Symbol *x, Symbol *y) {
 int result;
 emitArithmCheckAndComment(x, y, "mod");
 emitArithmeticPrep(x, y, &result, -1);
 emitStmt(128, "MOD");
}

canonical_original_code:
void emitMod(struct Symbol *x, struct Symbol *y) {
 int result;
 emitArithmCheckAndComment(x, y, "mod");
 emitArithmeticPrep(x, y, &result, -1);
 emitStmt(128, "MOD");
}

variable_types: result int

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

user_defined_types: struct 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 hashElement { char *key; struct Symbol *symbol; struct hashElement *prev; struct hashElement *next; }


genericArithConstruct

decompiled_code:
__int64 __fastcall genericArithConstruct(const char **a1, const char **a2, const char *a3, __int64 a4, __int64 a5, int a6)
{
__int64 result; // rax
unsigned int v10[11]; // [rsp+Ch] [rbp-2Ch] BYREF

emitArithmCheckAndComment(a1, a2, a3);
emitArithmeticPrep(a1, (__int64)a2, v10, a6);
result = v10[0];
if ( !v10[0] )
return emitStmt(128LL, a4);
if ( v10[0] == 1 )
result = emitStmt(128LL, a5);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(const char **a1, const char **a2, const char *a3, __int64 a4, __int64 a5, int a6)
{
__int64 result; // rax
unsigned int v10[11]; // [rsp+Ch] [rbp-2Ch] BYREF

func3(a1, a2, a3);
func0(a1, (__int64)a2, v10, a6);
result = v10[0];
if ( !v10[0] )
return emitStmt(128LL, a4);
if ( v10[0] == 1 )
result = emitStmt(128LL, a5);
return result;
}

original_code:
void genericArithConstruct(Symbol *x, Symbol *y, char *opName,
 char *ascIntName, char *ascRealName, int opToken)
{
 int result;
 emitArithmCheckAndComment(x, y, opName);
 emitArithmeticPrep(x, y, &result, opToken);
 if ( result == 0) {
  emitStmt(128, ascIntName);
 }
 else if (result == 1) {
  emitStmt(128, ascRealName);
 } else {
 }
}

canonical_original_code:
void genericArithConstruct(struct Symbol *x, struct Symbol *y, char *opName, char *ascIntName, char *ascRealName, int opToken)
{
 int result;
 emitArithmCheckAndComment(x, y, opName);
 emitArithmeticPrep(x, y, &result, opToken);
 if ( result == 0) {
  emitStmt(128, ascIntName);
 }
 else if (result == 1) {
  emitStmt(128, ascRealName);
 } else {
 }
}

variable_types:
ascIntName
char *

variable_types:
ascRealName
char *

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

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

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

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

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


emitAddition

decompiled_code:
__int64 __fastcall emitAddition(const char **a1, const char **a2)
{
return genericArithConstruct(a1, a2, "addition", (__int64)"ADDI", (__int64)"ADDR", -1);
}

canonical_decompiled_code:
__int64 __fastcall func6(const char **a1, const char **a2)
{
return func5(a1, a2, "addition", (__int64)"ADDI", (__int64)"ADDR", -1);
}

original_code:
void emitAddition(Symbol *x, Symbol *y) {
 genericArithConstruct(x, y, "addition", "ADDI", "ADDR", -1);
}

canonical_original_code:
void emitAddition(struct Symbol *x, struct Symbol *y) {
 genericArithConstruct(x, y, "addition", "ADDI", "ADDR", -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: struct FunctionKind { struct Symbol *typeSym; struct ElementArray *params; char *label; int invocationInstance; }

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

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

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

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


emitSubtraction

decompiled_code:
__int64 __fastcall emitSubtraction(const char **a1, const char **a2)
{
return genericArithConstruct(a1, a2, "subtraction", (__int64)"SUBI", (__int64)"SUBR", -1);
}

canonical_decompiled_code:
__int64 __fastcall func7(const char **a1, const char **a2)
{
return func5(a1, a2, "subtraction", (__int64)"SUBI", (__int64)"SUBR", -1);
}

original_code:
void emitSubtraction(Symbol *x, Symbol *y) {
 genericArithConstruct(x, y, "subtraction", "SUBI", "SUBR", -1);
}

canonical_original_code:
void emitSubtraction(struct Symbol *x, struct Symbol *y) {
 genericArithConstruct(x, y, "subtraction", "SUBI", "SUBR", -1);
}

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 hashElement { char *key; struct Symbol *symbol; struct hashElement *prev; struct hashElement *next; }


emitMultiplication

decompiled_code:
__int64 __fastcall emitMultiplication(const char **a1, const char **a2)
{
return genericArithConstruct(a1, a2, "mulitplication", (__int64)"MULI", (__int64)"MULR", -1);
}

canonical_decompiled_code:
__int64 __fastcall func8(const char **a1, const char **a2)
{
return func5(a1, a2, "mulitplication", (__int64)"MULI", (__int64)"MULR", -1);
}

original_code:
void emitMultiplication(Symbol *x, Symbol *y) {
 genericArithConstruct(x, y, "mulitplication", "MULI", "MULR", -1);
}

canonical_original_code:
void emitMultiplication(struct Symbol *x, struct Symbol *y) {
 genericArithConstruct(x, y, "mulitplication", "MULI", "MULR", -1);
}

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

user_defined_types: struct Scalar { struct ElementArray *consts; }

user_defined_types: struct StringType { unsigned int strlen; }


emitDivision

decompiled_code:
__int64 __fastcall emitDivision(const char **a1, const char **a2, int a3)
{
return genericArithConstruct(a1, a2, "division", (__int64)"DIVI", (__int64)"DIVR", a3);
}

canonical_decompiled_code:
__int64 __fastcall func9(const char **a1, const char **a2, int a3)
{
return func5(a1, a2, "division", (__int64)"DIVI", (__int64)"DIVR", a3);
}

original_code:
void emitDivision(Symbol *x, Symbol *y, int opToken) {
 genericArithConstruct(x, y, "division", "DIVI", "DIVR", opToken);
}

canonical_original_code:
void emitDivision(struct Symbol *x, struct Symbol *y, int opToken) {
 genericArithConstruct(x, y, "division", "DIVI", "DIVR", opToken);
}

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

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

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

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

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


getAscFileName

decompiled_code:
char *__fastcall getAscFileName(char *src)
{
int v1; // eax
char *v2; // r8
int v3; // ebx
char *v4; // rax
char *v5; // rax

v1 = strlen(src);
v2 = 0LL;
v3 = v1 + 1;
if ( v1 + 1 > 4 )
{
v4 = (char *)calloc(v3, 1uLL);
v5 = strncpy(v4, src, v3);
*(_DWORD *)&v5[v3 - 5] = 1668505902;
v2 = v5;
}
return v2;
}

canonical_decompiled_code:
char *__fastcall func0(char *src)
{
int v1; // eax
char *v2; // r8
int v3; // ebx
char *v4; // rax
char *v5; // rax

v1 = strlen(src);
v2 = 0LL;
v3 = v1 + 1;
if ( v1 + 1 > 4 )
{
v4 = (char *)calloc(v3, 1uLL);
v5 = strncpy(v4, src, v3);
*(_DWORD *)&v5[v3 - 5] = 1668505902;
v2 = v5;
}
return v2;
}

original_code:
char *getAscFileName(char *palFileName)
{
  int len = 0;
  char *ascFileName = ((void *)0);
  len = strlen(palFileName) + 1;
  if (len < 5) return ((void *)0);
  ascFileName = calloc(len, sizeof(char));
  strncpy(ascFileName, palFileName, len);
  strncpy(ascFileName + len - 5, ".asc", 4);
  return ascFileName;
}

variable_types:
palFileName
char *

variable_types: len int

variable_types:
ascFileName
char *

return_type: char *


emitStr

decompiled_code:
__int64 __fastcall emitStr(__int64 a1, const char *a2, const char *a3, const char *a4)
{
int v6; // ebx
int v7; // ebp
int v8; // er12
char *v9; // rax
__int64 v10; // rdx
__int64 v11; // rcx
__int64 v12; // r8
char *v13; // r15

v6 = strlen(a2);
v7 = strlen(a3);
v8 = strlen(a4);
v9 = (char *)calloc(v7 + v6 + v8 + 1, 1uLL);
if ( !v9 )
err(1, "Failed to allocate memory for asc statement.", v10, v11, v12, a2);
v13 = v9;
strncpy(v9, a2, v6);
strncpy(&v13[v6], a3, v7);
strncpy(&v13[v6 + (__int64)v7], a4, v8);
return appendStmt(a1, v13);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, const char *a2, const char *a3, const char *a4)
{
int v6; // ebx
int v7; // ebp
int v8; // er12
char *v9; // rax
__int64 v10; // rdx
__int64 v11; // rcx
__int64 v12; // r8
char *v13; // r15

v6 = strlen(a2);
v7 = strlen(a3);
v8 = strlen(a4);
v9 = (char *)calloc(v7 + v6 + v8 + 1, 1uLL);
if ( !v9 )
err(1, "Failed to allocate memory for asc statement.", v10, v11, v12, a2);
v13 = v9;
strncpy(v9, a2, v6);
strncpy(&v13[v6], a3, v7);
strncpy(&v13[v6 + (__int64)v7], a4, v8);
return appendStmt(a1, v13);
}

original_code:
void emitStr(StmtLL **ll, char *prefix, char *s, char *suffix) {
 char *stmt = ((void *)0);
 int prefixLen = 0;
 int sLen = 0;
 int suffixLen = 0;
 int stmtLen = 0;
 prefixLen = strlen(prefix);
 sLen = strlen(s);
 suffixLen = strlen(suffix);
 stmtLen = prefixLen + sLen + suffixLen;
 stmt = calloc(stmtLen + 1, sizeof(char));
 if (!(stmt)) err(1,
     "Failed to allocate memory for asc statement.");
 strncpy(stmt, prefix, prefixLen);
 strncpy(stmt + prefixLen, s, sLen);
 strncpy(stmt + prefixLen + sLen, suffix, suffixLen);
 appendStmt(ll, stmt);
}

canonical_original_code:
void emitStr(struct stmtll **ll, char *prefix, char *s, char *suffix) {
 char *stmt = ((void *)0);
 int prefixLen = 0;
 int sLen = 0;
 int suffixLen = 0;
 int stmtLen = 0;
 prefixLen = strlen(prefix);
 sLen = strlen(s);
 suffixLen = strlen(suffix);
 stmtLen = prefixLen + sLen + suffixLen;
 stmt = calloc(stmtLen + 1, sizeof(char));
 if (!(stmt)) err(1,
     "Failed to allocate memory for asc statement.");
 strncpy(stmt, prefix, prefixLen);
 strncpy(stmt + prefixLen, s, sLen);
 strncpy(stmt + prefixLen + sLen, suffix, suffixLen);
 appendStmt(ll, stmt);
}

variable_types: struct stmtll { char *stmt; struct stmtll *next; } **

variable_types:
prefix
char *

variable_types:
s
char *

variable_types:
suffix
char *

variable_types:
stmt
char *

variable_types: prefixLen int

variable_types: sLen int

variable_types: suffixLen int

variable_types: stmtLen int


emitComment

decompiled_code:
__int64 emitComment(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
memset(cmt_0, 0, 0x400uLL);
vsnprintf(cmt_0, 0x3FFuLL, format, arg);
return emitStr((__int64)&stmts, "\t\t# ", cmt_0, "\n");
}

canonical_decompiled_code:
__int64 func2(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
memset(cmt_0, 0, 0x400uLL);
vsnprintf(cmt_0, 0x3FFuLL, format, arg);
return func1((__int64)&stmts, "\t\t# ", cmt_0, "\n");
}

original_code:
void emitComment(char *s, ...)
{
 static char cmt[1024];
 va_list args;
 memset(cmt, 0, 1024);
 __builtin_va_start(args,s);
 vsnprintf(cmt, 1024 - 1, s, args);
 __builtin_va_end(args);
 emitStr(&stmts, "\t\t# ", cmt, "\n");
}

canonical_original_code:
void emitComment(char *s, ...)
{
 static char cmt[1024];
 __builtin_va_list args;
 memset(cmt, 0, 1024);
 __builtin_va_start(args,s);
 vsnprintf(cmt, 1024 - 1, s, args);
 __builtin_va_end(args);
 emitStr(&stmts, "\t\t# ", cmt, "\n");
}

variable_types:
cmt
char [1024]