decompiled_code:
__int64 __fastcall parser_get_operand(char *s1, unsigned __int8 *a2)
{
int v2; // eax
__int64 result; // rax
int v4; // er12
size_t v5; // rax
unsigned __int8 v6; // al
char *v7; // r12
unsigned __int8 v8; // al
int v9; // ebx
int v10; // eax
int v11; // edx
unsigned __int8 v12; // al
size_t v13; // rax
int v14; // eax
char *endptr[4]; // [rsp+8h] [rbp-20h] BYREF

if ( *s1 == 35 )
{
v4 = strtol(s1 + 1, endptr, 10);
v5 = strlen(s1);
if ( endptr[0] == &s1[v5] )
{
v6 = *a2;
*(_DWORD *)&a2[4 * v6++ + 8] = v4;
*a2 = v6;
*(_DWORD *)&a2[4 * v6 + 24] = 1;
result = 0LL;
}
else
{
printf("Error! Invalid immediate value: %s\n", s1);
result = 4LL;
}
}
else
{
v2 = parser_string_to_register_type(s1);
if ( v2 != 8 )
{
a2[4] = a2[4] & 0xE3 | (4 * (v2 & 7));
return 3LL;
}
v7 = (char *)parser_get_index_from_label(s1);
if ( (unsigned int)parser_check_symbol_syntax(s1) )
{
v8 = *a2;
*(_DWORD *)&a2[4 * *a2 + 8] = 0;
*a2 = ++v8;
*(_DWORD *)&a2[4 * v8 + 24] = 2;
if ( s1 == v7 || !v7 )
{
result = 1LL;
}
else
{
v9 = strtol(v7, endptr, 10);
v10 = parser_string_to_register_type(v7);
if ( v10 != 8 )
{
v9 = v10;
v11 = 1;
goto LABEL_12;
}
v13 = strlen(v7);
if ( endptr[0] == &v7[v13] )
{
v11 = 1;
goto LABEL_12;
}
v14 = parser_check_symbol_syntax(v7);
v11 = 2;
if ( v14 )
{
LABEL_12:
v12 = *a2;
*(_DWORD *)&a2[4 * v12++ + 8] = v9;
*a2 = v12;
*(_DWORD *)&a2[4 * v12 + 24] = v11;
return 2LL;
}
printf("Error! Index %s has syntax errors.\n", v7);
result = 4LL;
}
}
else
{
printf("Error! Label %s has syntax errors.\n", s1);
result = 4LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(char *s1, unsigned __int8 *a2)
{
int v2; // eax
__int64 result; // rax
int v4; // er12
size_t v5; // rax
unsigned __int8 v6; // al
char *v7; // r12
unsigned __int8 v8; // al
int v9; // ebx
int v10; // eax
int v11; // edx
unsigned __int8 v12; // al
size_t v13; // rax
int v14; // eax
char *endptr[4]; // [rsp+8h] [rbp-20h] BYREF

if ( *s1 == 35 )
{
v4 = strtol(s1 + 1, endptr, 10);
v5 = strlen(s1);
if ( endptr[0] == &s1[v5] )
{
v6 = *a2;
*(_DWORD *)&a2[4 * v6++ + 8] = v4;
*a2 = v6;
*(_DWORD *)&a2[4 * v6 + 24] = 1;
result = 0LL;
}
else
{
printf("Error! Invalid immediate value: %s\n", s1);
result = 4LL;
}
}
else
{
v2 = func2(s1);
if ( v2 != 8 )
{
a2[4] = a2[4] & 0xE3 | (4 * (v2 & 7));
return 3LL;
}
v7 = (char *)func8(s1);
if ( (unsigned int)func3(s1) )
{
v8 = *a2;
*(_DWORD *)&a2[4 * *a2 + 8] = 0;
*a2 = ++v8;
*(_DWORD *)&a2[4 * v8 + 24] = 2;
if ( s1 == v7 || !v7 )
{
result = 1LL;
}
else
{
v9 = strtol(v7, endptr, 10);
v10 = func2(v7);
if ( v10 != 8 )
{
v9 = v10;
v11 = 1;
goto LABEL_12;
}
v13 = strlen(v7);
if ( endptr[0] == &v7[v13] )
{
v11 = 1;
goto LABEL_12;
}
v14 = func3(v7);
v11 = 2;
if ( v14 )
{
LABEL_12:
v12 = *a2;
*(_DWORD *)&a2[4 * v12++ + 8] = v9;
*a2 = v12;
*(_DWORD *)&a2[4 * v12 + 24] = v11;
return 2LL;
}
printf("Error! Index %s has syntax errors.\n", v7);
result = 4LL;
}
}
else
{
printf("Error! Label %s has syntax errors.\n", s1);
result = 4LL;
}
}
return result;
}

original_code:
operand_addressing_t parser_get_operand(char* szOperand,
          instruction_with_operands_t* pInstruction)
{
 machine_registers_t reg = parser_string_to_register_type(szOperand);
 if (szOperand[0] == '#')
 {
  char* pEnd;
  long int val;
  val = strtol(&szOperand[1], &pEnd, (10));
  if (pEnd == strchr(szOperand, '\0'))
  {
   pInstruction->extra_data[pInstruction->num_extra_data].val = val;
   pInstruction->num_extra_data++;
   pInstruction->localities[pInstruction->num_extra_data] = ADDR_ABSOLUTE;
   return OPERAND_ADDR_IMMEDIATE;
  }
  else
  {
   printf("Error! Invalid immediate value: %s\n", szOperand);
   return (OPERAND_ADDR_REGISTER+1);
  }
 }
 else if (reg != (R7+1))
 {
  pInstruction->instruction.dest_reg = reg;
  return OPERAND_ADDR_REGISTER;
 }
 else
 {
  const char* szIndexValue = parser_get_index_from_label(szOperand);
  if (parser_check_symbol_syntax(szOperand) == 0)
  {
   printf("Error! Label %s has syntax errors.\n",
     szOperand);
   return (OPERAND_ADDR_REGISTER+1);
  }
  pInstruction->extra_data[pInstruction->num_extra_data].val = 0;
  pInstruction->num_extra_data++;
  pInstruction->localities[pInstruction->num_extra_data] = ADDR_RELOCATABLE;
  if (szIndexValue != szOperand &&
   szIndexValue != ((void *)0))
  {
   long int index;
   char* pEnd;
   address_locality_t locality_for_index = ADDR_ABSOLUTE;
   index = strtol(szIndexValue, &pEnd, (10));
   reg = parser_string_to_register_type(szIndexValue);
   if (reg != (R7+1))
   {
    index = reg;
   }
   else if (pEnd != strchr(szIndexValue, '\0'))
   {
    if (parser_check_symbol_syntax(szIndexValue) == 0)
    {
     printf("Error! Index %s has syntax errors.\n",
       szIndexValue);
     return (OPERAND_ADDR_REGISTER+1);
    }
    locality_for_index = ADDR_RELOCATABLE;
   }
   pInstruction->extra_data[pInstruction->num_extra_data].val = index;
   pInstruction->num_extra_data++;
   pInstruction->localities[pInstruction->num_extra_data] = locality_for_index;
   return OPERAND_ADDR_INDEX;
  }
  else
  {
   return OPERAND_ADDR_DIRECT;
  }
 }
 return (OPERAND_ADDR_REGISTER+1);
}

canonical_original_code:
enum operand_addressing_t parser_get_operand(char *szOperand, struct instruction_with_operands_t *pInstruction)
{
 enum machine_registers_t reg = parser_string_to_register_type(szOperand);
 if (szOperand[0] == '#')
 {
  char *pEnd;
  long val;
  val = strtol(&szOperand[1], &pEnd, (10));
  if (pEnd == strchr(szOperand, '\0'))
  {
   pInstruction->extra_data[pInstruction->num_extra_data].val = val;
   pInstruction->num_extra_data++;
   pInstruction->localities[pInstruction->num_extra_data] = ADDR_ABSOLUTE;
   return OPERAND_ADDR_IMMEDIATE;
  }
  else
  {
   printf("Error! Invalid immediate value: %s\n", szOperand);
   return (OPERAND_ADDR_REGISTER+1);
  }
 }
 else if (reg != (R7+1))
 {
  pInstruction->instruction.dest_reg = reg;
  return OPERAND_ADDR_REGISTER;
 }
 else
 {
  char *szIndexValue = parser_get_index_from_label(szOperand);
  if (parser_check_symbol_syntax(szOperand) == 0)
  {
   printf("Error! Label %s has syntax errors.\n",
     szOperand);
   return (OPERAND_ADDR_REGISTER+1);
  }
  pInstruction->extra_data[pInstruction->num_extra_data].val = 0;
  pInstruction->num_extra_data++;
  pInstruction->localities[pInstruction->num_extra_data] = ADDR_RELOCATABLE;
  if (szIndexValue != szOperand &&
   szIndexValue != ((void *)0))
  {
   long index;
   char *pEnd;
   enum address_locality_t locality_for_index = ADDR_ABSOLUTE;
   index = strtol(szIndexValue, &pEnd, (10));
   reg = parser_string_to_register_type(szIndexValue);
   if (reg != (R7+1))
   {
    index = reg;
   }
   else if (pEnd != strchr(szIndexValue, '\0'))
   {
    if (parser_check_symbol_syntax(szIndexValue) == 0)
    {
     printf("Error! Index %s has syntax errors.\n",
       szIndexValue);
     return (OPERAND_ADDR_REGISTER+1);
    }
    locality_for_index = ADDR_RELOCATABLE;
   }
   pInstruction->extra_data[pInstruction->num_extra_data].val = index;
   pInstruction->num_extra_data++;
   pInstruction->localities[pInstruction->num_extra_data] = locality_for_index;
   return OPERAND_ADDR_INDEX;
  }
  else
  {
   return OPERAND_ADDR_DIRECT;
  }
 }
 return (OPERAND_ADDR_REGISTER+1);
}

variable_types:
szOperand
char *

variable_types: struct instruction_with_operands_t { unsigned char num_extra_data; struct instruction_t { enum instruction_comb_t { INST_COMB_MSB_MSB=0, INST_COMB_MSB_LSB=1, INST_COMB_LSB_MSB=2, INST_COMB_LSB_LSB=3 } comb; enum machine_registers_t { R0=0, R1=1, R2=2, R3=3, R4=4, R5=5, R6=6, R7=7 } dest_reg; enum operand_addressing_t { OPERAND_ADDR_IMMEDIATE=0, OPERAND_ADDR_DIRECT=1, OPERAND_ADDR_INDEX=2, OPERAND_ADDR_REGISTER=3 } dest_addressing; enum machine_registers_t { R0=0, R1=1, R2=2, R3=3, R4=4, R5=5, R6=6, R7=7 } src_reg; enum operand_addressing_t { OPERAND_ADDR_IMMEDIATE=0, OPERAND_ADDR_DIRECT=1, OPERAND_ADDR_INDEX=2, OPERAND_ADDR_REGISTER=3 } src_addressing; enum opcode_t { MOV=0, CMP=1, ADD=2, SUB=3, NOT=4, CLR=5, LEA=6, INC=7, DEC=8, JMP=9, BNE=10, RED=11, PRN=12, JSR=13, RTS=14, STOP=15 } opcode; enum instruction_type_t { INST_TYPE_20_BIT=0, INST_TYPE_10_BIT=1 } type; unsigned char rfu; unsigned int pad; } instruction; struct machine_cell_t { unsigned int val; } extra_data[-1]; enum address_locality_t { ADDR_INVALID=0, ADDR_ABSOLUTE=1, ADDR_RELOCATABLE=2, ADDR_EXTERNAL=3, ADDR_ENTRY=4 } localities[-1]; } *

variable_types: val long

variable_types:
szIndexValue
char *

variable_types: index long

user_defined_types: struct instruction_with_operands_t { unsigned char num_extra_data; struct instruction_t instruction; struct machine_cell_t extra_data[-1]; enum address_locality_t localities[-1]; }

user_defined_types: struct instruction_t { enum instruction_comb_t comb; enum machine_registers_t dest_reg; enum operand_addressing_t dest_addressing; enum machine_registers_t src_reg; enum operand_addressing_t src_addressing; enum opcode_t opcode; enum instruction_type_t type; unsigned char rfu; unsigned int pad; }


decompiled_code:
__int64 __fastcall parser_get_num_items_in_list(char *a1)
{
char v1; // si
char v2; // dl
int v3; // eax
unsigned int v4; // ebx
int v6; // er12

if ( !a1 )
return 0;
v1 = *a1;
if ( !*a1 )
return 0;
v2 = *a1;
v3 = 0;
v4 = 0;
do
{
v4 += v2 == 44;
v2 = a1[++v3];
}
while ( v2 );
if ( !v4 )
{
v6 = 0;
while ( strchr("\t \n\r", v1) )
{
v1 = a1[++v6];
if ( !v1 )
return v4;
}
}
++v4;
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func10(char *a1)
{
char v1; // si
char v2; // dl
int v3; // eax
unsigned int v4; // ebx
int v6; // er12

if ( !a1 )
return 0;
v1 = *a1;
if ( !*a1 )
return 0;
v2 = *a1;
v3 = 0;
v4 = 0;
do
{
v4 += v2 == 44;
v2 = a1[++v3];
}
while ( v2 );
if ( !v4 )
{
v6 = 0;
while ( strchr("\t \n\r", v1) )
{
v1 = a1[++v6];
if ( !v1 )
return v4;
}
}
++v4;
return v4;
}

original_code:
unsigned int parser_get_num_items_in_list(char* szList)
{
 unsigned int nDelimitersFound = 0;
 unsigned int i;
 if (szList == ((void *)0))
  return 0;
 for (i = 0; szList[i] != '\0'; ++i)
 {
  if (szList[i] == ',')
   nDelimitersFound++;
 }
 if (nDelimitersFound == 0)
 {
  unsigned char fEmpty = 1;
  for (i = 0; szList[i] != '\0'; ++i)
  {
   if (strchr("\t \n\r", szList[i]) == ((void *)0))
   {
    fEmpty = 0;
    break;
   }
  }
  if (fEmpty)
   return 0;
 }
 return nDelimitersFound + 1;
}

canonical_original_code:
unsigned int parser_get_num_items_in_list(char *szList)
{
 unsigned int nDelimitersFound = 0;
 unsigned int i;
 if (szList == ((void *)0))
  return 0;
 for (i = 0; szList[i] != '\0'; ++i)
 {
  if (szList[i] == ',')
   nDelimitersFound++;
 }
 if (nDelimitersFound == 0)
 {
  unsigned char fEmpty = 1;
  for (i = 0; szList[i] != '\0'; ++i)
  {
   if (strchr("\t \n\r", szList[i]) == ((void *)0))
   {
    fEmpty = 0;
    break;
   }
  }
  if (fEmpty)
   return 0;
 }
 return nDelimitersFound + 1;
}

variable_types:
szList
char *

variable_types:
nDelimitersFound
unsigned int

variable_types:
i
unsigned int

variable_types:
fEmpty
unsigned char

return_type: unsigned int


decompiled_code:
__int64 __fastcall parser_get_number(char *s, _DWORD *a2)
{
size_t v2; // rax
__int64 result; // rax
int *v4; // rdx
char *endptr; // [rsp+8h] [rbp-20h] BYREF

*a2 = strtol(s, &endptr, 10);
v2 = strlen(s);
if ( endptr != &s[v2] || (v4 = _errno_location(), result = 1LL, *v4 == 34) )
{
*_errno_location() = 0;
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(char *s, _DWORD *a2)
{
size_t v2; // rax
__int64 result; // rax
int *v4; // rdx
char *endptr; // [rsp+8h] [rbp-20h] BYREF

*a2 = strtol(s, &endptr, 10);
v2 = strlen(s);
if ( endptr != &s[v2] || (v4 = _errno_location(), result = 1LL, *v4 == 34) )
{
*_errno_location() = 0;
result = 0LL;
}
return result;
}

original_code:
unsigned char parser_get_number(const char* szNumber, unsigned int *o_pNum)
{
 char * pEnd;
 *o_pNum = strtol(szNumber, &pEnd, (10));
 if (pEnd != strchr(szNumber, '\0') ||
  (*__errno_location ()) == 34)
 {
  (*__errno_location ()) = 0;
  return 0;
 }
 return 1;
}

canonical_original_code:
unsigned char parser_get_number(char *szNumber, unsigned int *o_pNum)
{
 char *pEnd;
 *o_pNum = strtol(szNumber, &pEnd, (10));
 if (pEnd != strchr(szNumber, '\0') ||
  (*__errno_location ()) == 34)
 {
  (*__errno_location ()) = 0;
  return 0;
 }
 return 1;
}

variable_types:
szNumber
char *

variable_types:
pEnd
char *

return_type: unsigned char


decompiled_code:
_BOOL8 __fastcall is_addressing_valid_for_opcode(int a1, unsigned int a2, unsigned int a3)
{
__int64 v4; // rax
int v5; // ecx
_BOOL8 result; // rax
__int64 v7; // rdx

v4 = 0LL;
while ( 1 )
{
v5 = v4;
if ( g_arrInstructionSyntax[8 * v4] == a1 )
break;
if ( ++v4 == 16 )
return 0LL;
}
if ( a2 == 4
|| (v7 = 32LL * (unsigned int)v4, result = 0LL, *((_BYTE *)&g_arrInstructionSyntax[4] + a2 + v7 + 1) == 1) )
{
result = 1LL;
if ( a3 != 4 )
result = *((_BYTE *)&g_arrInstructionSyntax[8 * v5 + 5] + a3 + 1) == 1;
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(int a1, unsigned int a2, unsigned int a3)
{
__int64 v4; // rax
int v5; // ecx
_BOOL8 result; // rax
__int64 v7; // rdx

v4 = 0LL;
while ( 1 )
{
v5 = v4;
if ( g_arrInstructionSyntax[8 * v4] == a1 )
break;
if ( ++v4 == 16 )
return 0LL;
}
if ( a2 == 4
|| (v7 = 32LL * (unsigned int)v4, result = 0LL, *((_BYTE *)&g_arrInstructionSyntax[4] + a2 + v7 + 1) == 1) )
{
result = 1LL;
if ( a3 != 4 )
result = *((_BYTE *)&g_arrInstructionSyntax[8 * v5 + 5] + a3 + 1) == 1;
}
return result;
}

original_code:
unsigned int is_addressing_valid_for_opcode(opcode_t opcode,
           operand_addressing_t src,
           operand_addressing_t dest)
{
 unsigned int i;
 for (i = 0; i < (STOP+1); ++i)
 {
  if (g_arrInstructionSyntax[i].opcode == opcode)
  {
   if ((((OPERAND_ADDR_REGISTER+1) == src) ||
      (g_arrInstructionSyntax[i].src.types[src] == 1)) &&
     (((OPERAND_ADDR_REGISTER+1) == dest) ||
      (g_arrInstructionSyntax[i].dest.types[dest] == 1)))
   {
    return 1;
   }
   else
   {
    return 0;
   }
  }
 }
 return 0;
}

canonical_original_code:
unsigned int is_addressing_valid_for_opcode(enum opcode_t opcode, enum operand_addressing_t src, enum operand_addressing_t dest)
{
 unsigned int i;
 for (i = 0; i < (STOP+1); ++i)
 {
  if (g_arrInstructionSyntax[i].opcode == opcode)
  {
   if ((((OPERAND_ADDR_REGISTER+1) == src) ||
      (g_arrInstructionSyntax[i].src.types[src] == 1)) &&
     (((OPERAND_ADDR_REGISTER+1) == dest) ||
      (g_arrInstructionSyntax[i].dest.types[dest] == 1)))
   {
    return 1;
   }
   else
   {
    return 0;
   }
  }
 }
 return 0;
}

variable_types: enum opcode_t { MOV=0, CMP=1, ADD=2, SUB=3, NOT=4, CLR=5, LEA=6, INC=7, DEC=8, JMP=9, BNE=10, RED=11, PRN=12, JSR=13, RTS=14, STOP=15 }

variable_types: enum operand_addressing_t { OPERAND_ADDR_IMMEDIATE=0, OPERAND_ADDR_DIRECT=1, OPERAND_ADDR_INDEX=2, OPERAND_ADDR_REGISTER=3 }


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

v1 = 0LL;
while ( g_arrInstructionSyntax[8 * v1] != a1 )
{
if ( ++v1 == 16 )
return 0xFFFFFFFFLL;
}
return LOBYTE(g_arrInstructionSyntax[8 * (unsigned int)v1 + 4]);
}

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

v1 = 0LL;
while ( g_arrInstructionSyntax[8 * v1] != a1 )
{
if ( ++v1 == 16 )
return 0xFFFFFFFFLL;
}
return LOBYTE(g_arrInstructionSyntax[8 * (unsigned int)v1 + 4]);
}

original_code:
int get_num_operands_for_opcode(opcode_t opcode)
{
 unsigned int i;
 for (i = 0; i < (STOP+1); ++i)
 {
  if (g_arrInstructionSyntax[i].opcode == opcode)
  {
   return g_arrInstructionSyntax[i].numOperands;
  }
 }
 return -1;
}

canonical_original_code:
int get_num_operands_for_opcode(enum opcode_t opcode)
{
 unsigned int i;
 for (i = 0; i < (STOP+1); ++i)
 {
  if (g_arrInstructionSyntax[i].opcode == opcode)
  {
   return g_arrInstructionSyntax[i].numOperands;
  }
 }
 return -1;
}

return_type: int

user_defined_types: enum opcode_t { MOV=0, CMP=1, ADD=2, SUB=3, NOT=4, CLR=5, LEA=6, INC=7, DEC=8, JMP=9, BNE=10, RED=11, PRN=12, JSR=13, RTS=14, STOP=15 }


decompiled_code:
__int64 __fastcall retrieve_operands(__int64 a1, _QWORD *a2, int a3)
{
unsigned int v3; // ebp
unsigned int v4; // er12
__int64 result; // rax

if ( a3 == 2 )
{
v4 = parser_get_operand(*a2, a1);
*(_WORD *)(a1 + 4) = *(_WORD *)(a1 + 4) & 0xFC7F | (((*(_BYTE *)(a1 + 4) >> 2) & 7) << 7);
v3 = parser_get_operand(a2[1], a1);
}
else
{
v3 = 4;
v4 = 4;
if ( a3 == 1 )
v3 = parser_get_operand(*a2, a1);
}
if ( is_addressing_valid_for_opcode(*(_BYTE *)(a1 + 5) >> 4, v4, v3) )
{
*(_BYTE *)(a1 + 5) = *(_BYTE *)(a1 + 5) & 0xF3 | (4 * (v4 & 3));
*(_BYTE *)(a1 + 4) = *(_BYTE *)(a1 + 4) & 0x9F | (32 * (v3 & 3));
result = 0LL;
}
else
{
printf("Error! Operands addressing is invalid for instruction: ");
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, _QWORD *a2, int a3)
{
unsigned int v3; // ebp
unsigned int v4; // er12
__int64 result; // rax

if ( a3 == 2 )
{
v4 = parser_get_operand(*a2, a1);
*(_WORD *)(a1 + 4) = *(_WORD *)(a1 + 4) & 0xFC7F | (((*(_BYTE *)(a1 + 4) >> 2) & 7) << 7);
v3 = parser_get_operand(a2[1], a1);
}
else
{
v3 = 4;
v4 = 4;
if ( a3 == 1 )
v3 = parser_get_operand(*a2, a1);
}
if ( func0(*(_BYTE *)(a1 + 5) >> 4, v4, v3) )
{
*(_BYTE *)(a1 + 5) = *(_BYTE *)(a1 + 5) & 0xF3 | (4 * (v4 & 3));
*(_BYTE *)(a1 + 4) = *(_BYTE *)(a1 + 4) & 0x9F | (32 * (v3 & 3));
result = 0LL;
}
else
{
printf("Error! Operands addressing is invalid for instruction: ");
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int retrieve_operands(instruction_with_operands_t* pInstruction,
       char** arrOperands,
       unsigned int nOperands)
{
 operand_addressing_t addresingSrc, addressingDest;
 addresingSrc = addressingDest = (OPERAND_ADDR_REGISTER+1);
 if (nOperands == 2)
 {
  addresingSrc = parser_get_operand(arrOperands[0],
          pInstruction);
  pInstruction->instruction.src_reg = pInstruction->instruction.dest_reg;
  addressingDest = parser_get_operand(arrOperands[1],
        pInstruction);
 }
 else if(nOperands == 1)
 {
  addressingDest = parser_get_operand(arrOperands[0],
        pInstruction);
 }
 if (0 == is_addressing_valid_for_opcode(
          pInstruction->instruction.opcode,
          addresingSrc,
          addressingDest))
 {
  printf("Error! Operands addressing is invalid for instruction: ");
  return -1;
 }
 pInstruction->instruction.src_addressing = addresingSrc;
 pInstruction->instruction.dest_addressing = addressingDest;
 return 0;
}

canonical_original_code:
int retrieve_operands(struct instruction_with_operands_t *pInstruction, char **arrOperands, unsigned int nOperands)
{
 enum operand_addressing_t addresingSrc; enum operand_addressing_t addressingDest;
 addresingSrc = addressingDest = (OPERAND_ADDR_REGISTER+1);
 if (nOperands == 2)
 {
  addresingSrc = parser_get_operand(arrOperands[0],
          pInstruction);
  pInstruction->instruction.src_reg = pInstruction->instruction.dest_reg;
  addressingDest = parser_get_operand(arrOperands[1],
        pInstruction);
 }
 else if(nOperands == 1)
 {
  addressingDest = parser_get_operand(arrOperands[0],
        pInstruction);
 }
 if (0 == is_addressing_valid_for_opcode(
          pInstruction->instruction.opcode,
          addresingSrc,
          addressingDest))
 {
  printf("Error! Operands addressing is invalid for instruction: ");
  return -1;
 }
 pInstruction->instruction.src_addressing = addresingSrc;
 pInstruction->instruction.dest_addressing = addressingDest;
 return 0;
}

variable_types:
arrOperands
char **

variable_types:
nOperands
unsigned int

user_defined_types: enum operand_addressing_t { OPERAND_ADDR_IMMEDIATE=0, OPERAND_ADDR_DIRECT=1, OPERAND_ADDR_INDEX=2, OPERAND_ADDR_REGISTER=3 }

user_defined_types: enum instruction_comb_t { INST_COMB_MSB_MSB=0, INST_COMB_MSB_LSB=1, INST_COMB_LSB_MSB=2, INST_COMB_LSB_LSB=3 }

user_defined_types: enum instruction_type_t { INST_TYPE_20_BIT=0, INST_TYPE_10_BIT=1 }

user_defined_types: struct machine_cell_t { unsigned int val; }

user_defined_types: enum address_locality_t { ADDR_INVALID=0, ADDR_ABSOLUTE=1, ADDR_RELOCATABLE=2, ADDR_EXTERNAL=3, ADDR_ENTRY=4 }


decompiled_code:
__int64 __fastcall instruction_compile(__int64 a1, __int64 a2, __int64 a3)
{
int v6; // edi
int v7; // ebp
int v8; // eax
int v9; // er14
int v10; // eax
unsigned int v11; // ebp
const char *v12; // rsi
__int64 v13; // rax
unsigned int v14; // esi
unsigned __int8 v15; // dl
__int64 v16; // rax
_QWORD *v17; // rcx
_QWORD *v18; // rcx
int v20; // [rsp+0h] [rbp-98h] BYREF
char dest[36]; // [rsp+4h] [rbp-94h] BYREF
__int64 v22; // [rsp+28h] [rbp-70h]
char v23[4]; // [rsp+30h] [rbp-68h] BYREF
int v24; // [rsp+34h] [rbp-64h]
__int64 v25; // [rsp+38h] [rbp-60h] BYREF
__int128 v26; // [rsp+48h] [rbp-50h] BYREF
int v27; // [rsp+58h] [rbp-40h]
_QWORD v28[7]; // [rsp+60h] [rbp-38h] BYREF

if ( !a1 || !a2 )
return (unsigned int)-1;
v26 = 1uLL;
v27 = 0;
v6 = *(_DWORD *)(a1 + 16);
BYTE1(v24) = (16 * v6) | BYTE1(v24) & 0xF;
v7 = get_num_operands_for_opcode(v6 & 0xF);
if ( v7 < 0 )
return (unsigned int)-1;
v8 = parser_get_instruction_type(*(_QWORD *)(a1 + 24));
v9 = v8;
if ( v8 == 2 )
{
printf("Error! Invalid type: ");
v11 = -1;
}
else
{
BYTE2(v24) = v8 & 1 | BYTE2(v24) & 0xFE;
LOBYTE(v24) = v24 & 0xFC;
v10 = parser_get_instruction_comb(*(_QWORD *)(a1 + 24));
if ( v10 == 4 )
{
printf("Error! Invalid comb: ");
v11 = -1;
}
else
{
if ( v10 == 5 )
{
if ( v9 == 1 )
{
printf("Error! type is %d, there must comb set: ", 1LL);
return (unsigned int)-1;
}
}
else
{
if ( !v9 )
{
printf("Error! type is %d, there should be no comb: ", 0LL);
return (unsigned int)-1;
}
LOBYTE(v24) = v24 & 0xFC | v10 & 3;
}
if ( (unsigned int)parser_get_items_from_list(*(_QWORD *)(a1 + 32), v28, v7) )
{
printf("Error! Invalid number of operands: ");
v11 = -1;
}
else
{
v11 = retrieve_operands((__int64)v23, v28, v7);
if ( v11 )
{
v11 = -1;
}
else
{
v12 = *(const char **)(a1 + 8);
if ( v12
&& (v20 = 1,
v22 = *(unsigned int *)(a2 + 16000),
strncpy(dest, v12, 0x1FuLL),
(unsigned int)symbol_add_to_table(a3, &v20)) )
{
v11 = -1;
}
else
{
*(_DWORD *)(a2 + 4LL * *(unsigned int *)(a2 + 16000)) = v24;
v13 = *(unsigned int *)(a2 + 16000);
*(_DWORD *)(a2 + 4 * v13 + 8000) = v26;
v14 = v13 + 1;
*(_DWORD *)(a2 + 16000) = v13 + 1;
v15 = v23[0];
v16 = 4LL * (unsigned __int8)v23[0];
v17 = (_QWORD *)(a2 + 4LL * v14);
if ( (unsigned int)v16 >= 8 )
{
*v17 = v25;
*(_QWORD *)((char *)v17 + v16 - 8) = *(_QWORD *)&v23[v16];
qmemcpy(
(void *)((unsigned __int64)(v17 + 1) & 0xFFFFFFFFFFFFFFF8LL),
(const void *)((char *)&v25 - ((char *)v17 - ((unsigned __int64)(v17 + 1) & 0xFFFFFFFFFFFFFFF8LL))),
8LL * (((unsigned int)v16 + (_DWORD)v17 - (((_DWORD)v17 + 8) & 0xFFFFFFF8)) >> 3));
}
else if ( (v16 & 4) != 0 )
{
*(_DWORD *)v17 = v25;
*(_DWORD *)((char *)v17 + v16 - 4) = *(int *)((char *)&v24 + v16);
}
else if ( (_DWORD)v16 )
{
*(_BYTE *)v17 = v25;
}
v18 = (_QWORD *)(a2 + 4LL * *(unsigned int *)(a2 + 16000) + 8000);
if ( (unsigned int)v16 >= 8 )
{
*v18 = *(_QWORD *)((char *)&v26 + 4);
*(_QWORD *)((char *)v18 + v16 - 8) = *(_QWORD *)((char *)&v26 + v16 - 4);
qmemcpy(
(void *)((unsigned __int64)(v18 + 1) & 0xFFFFFFFFFFFFFFF8LL),
(const void *)((char *)&v26 + 4 - ((char *)v18 - ((unsigned __int64)(v18 + 1) & 0xFFFFFFFFFFFFFFF8LL))),
8LL * (((unsigned int)v16 + (_DWORD)v18 - (((_DWORD)v18 + 8) & 0xFFFFFFF8)) >> 3));
}
else if ( (v16 & 4) != 0 )
{
*(_DWORD *)v18 = DWORD1(v26);
*(_DWORD *)((char *)v18 + v16 - 4) = *(_DWORD *)((char *)&v26 + v16);
}
else if ( (_DWORD)v16 )
{
*(_BYTE *)v18 = BYTE4(v26);
}
*(_DWORD *)(a2 + 16000) += v15;
}
}
}
}
}
return v11;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2, __int64 a3)
{
int v6; // edi
int v7; // ebp
int v8; // eax
int v9; // er14
int v10; // eax
unsigned int v11; // ebp
const char *v12; // rsi
__int64 v13; // rax
unsigned int v14; // esi
unsigned __int8 v15; // dl
__int64 v16; // rax
_QWORD *v17; // rcx
_QWORD *v18; // rcx
int v20; // [rsp+0h] [rbp-98h] BYREF
char dest[36]; // [rsp+4h] [rbp-94h] BYREF
__int64 v22; // [rsp+28h] [rbp-70h]
char v23[4]; // [rsp+30h] [rbp-68h] BYREF
int v24; // [rsp+34h] [rbp-64h]
__int64 v25; // [rsp+38h] [rbp-60h] BYREF
__int128 v26; // [rsp+48h] [rbp-50h] BYREF
int v27; // [rsp+58h] [rbp-40h]
_QWORD v28[7]; // [rsp+60h] [rbp-38h] BYREF

if ( !a1 || !a2 )
return (unsigned int)-1;
v26 = 1uLL;
v27 = 0;
v6 = *(_DWORD *)(a1 + 16);
BYTE1(v24) = (16 * v6) | BYTE1(v24) & 0xF;
v7 = func1(v6 & 0xF);
if ( v7 < 0 )
return (unsigned int)-1;
v8 = parser_get_instruction_type(*(_QWORD *)(a1 + 24));
v9 = v8;
if ( v8 == 2 )
{
printf("Error! Invalid type: ");
v11 = -1;
}
else
{
BYTE2(v24) = v8 & 1 | BYTE2(v24) & 0xFE;
LOBYTE(v24) = v24 & 0xFC;
v10 = parser_get_instruction_comb(*(_QWORD *)(a1 + 24));
if ( v10 == 4 )
{
printf("Error! Invalid comb: ");
v11 = -1;
}
else
{
if ( v10 == 5 )
{
if ( v9 == 1 )
{
printf("Error! type is %d, there must comb set: ", 1LL);
return (unsigned int)-1;
}
}
else
{
if ( !v9 )
{
printf("Error! type is %d, there should be no comb: ", 0LL);
return (unsigned int)-1;
}
LOBYTE(v24) = v24 & 0xFC | v10 & 3;
}
if ( (unsigned int)parser_get_items_from_list(*(_QWORD *)(a1 + 32), v28, v7) )
{
printf("Error! Invalid number of operands: ");
v11 = -1;
}
else
{
v11 = func2((__int64)v23, v28, v7);
if ( v11 )
{
v11 = -1;
}
else
{
v12 = *(const char **)(a1 + 8);
if ( v12
&& (v20 = 1,
v22 = *(unsigned int *)(a2 + 16000),
strncpy(dest, v12, 0x1FuLL),
(unsigned int)symbol_add_to_table(a3, &v20)) )
{
v11 = -1;
}
else
{
*(_DWORD *)(a2 + 4LL * *(unsigned int *)(a2 + 16000)) = v24;
v13 = *(unsigned int *)(a2 + 16000);
*(_DWORD *)(a2 + 4 * v13 + 8000) = v26;
v14 = v13 + 1;
*(_DWORD *)(a2 + 16000) = v13 + 1;
v15 = v23[0];
v16 = 4LL * (unsigned __int8)v23[0];
v17 = (_QWORD *)(a2 + 4LL * v14);
if ( (unsigned int)v16 >= 8 )
{
*v17 = v25;
*(_QWORD *)((char *)v17 + v16 - 8) = *(_QWORD *)&v23[v16];
qmemcpy(
(void *)((unsigned __int64)(v17 + 1) & 0xFFFFFFFFFFFFFFF8LL),
(const void *)((char *)&v25 - ((char *)v17 - ((unsigned __int64)(v17 + 1) & 0xFFFFFFFFFFFFFFF8LL))),
8LL * (((unsigned int)v16 + (_DWORD)v17 - (((_DWORD)v17 + 8) & 0xFFFFFFF8)) >> 3));
}
else if ( (v16 & 4) != 0 )
{
*(_DWORD *)v17 = v25;
*(_DWORD *)((char *)v17 + v16 - 4) = *(int *)((char *)&v24 + v16);
}
else if ( (_DWORD)v16 )
{
*(_BYTE *)v17 = v25;
}
v18 = (_QWORD *)(a2 + 4LL * *(unsigned int *)(a2 + 16000) + 8000);
if ( (unsigned int)v16 >= 8 )
{
*v18 = *(_QWORD *)((char *)&v26 + 4);
*(_QWORD *)((char *)v18 + v16 - 8) = *(_QWORD *)((char *)&v26 + v16 - 4);
qmemcpy(
(void *)((unsigned __int64)(v18 + 1) & 0xFFFFFFFFFFFFFFF8LL),
(const void *)((char *)&v26 + 4 - ((char *)v18 - ((unsigned __int64)(v18 + 1) & 0xFFFFFFFFFFFFFFF8LL))),
8LL * (((unsigned int)v16 + (_DWORD)v18 - (((_DWORD)v18 + 8) & 0xFFFFFFF8)) >> 3));
}
else if ( (v16 & 4) != 0 )
{
*(_DWORD *)v18 = DWORD1(v26);
*(_DWORD *)((char *)v18 + v16 - 4) = *(_DWORD *)((char *)&v26 + v16);
}
else if ( (_DWORD)v16 )
{
*(_BYTE *)v18 = BYTE4(v26);
}
*(_DWORD *)(a2 + 16000) += v15;
}
}
}
}
}
return v11;
}

original_code:
int instruction_compile(const statement_t *pInstructionStatement,
      code_section_t* io_pCode,
      symbol_table_arr_t io_pSymbols)
{
 char* arrOperands[(2)];
 unsigned int type,comb;
 int nOperands;
 instruction_with_operands_t complete_instruction;
 instruction_t* pInst = &complete_instruction.instruction;
 if (pInstructionStatement == ((void *)0) ||
  io_pCode == ((void *)0))
  return -1;
 memset(complete_instruction.localities,
   0,
   sizeof(complete_instruction.localities));
 complete_instruction.localities[0] = ADDR_ABSOLUTE;
 pInst->opcode = pInstructionStatement->info.instruction.name;
 nOperands = get_num_operands_for_opcode(pInst->opcode);
 if (nOperands < 0)
  return -1;
 type = parser_get_instruction_type(pInstructionStatement->info.instruction.modifiers);
 if (type == (2))
 {
  printf("Error! Invalid type: ");
  return -1;
 }
 else
 {
  pInst->type = type;
 }
 pInst->comb = INST_COMB_MSB_MSB;
 comb = parser_get_instruction_comb(pInstructionStatement->info.instruction.modifiers);
 if (comb == (4))
 {
  printf("Error! Invalid comb: ");
  return -1;
 }
 else if (comb == (5))
 {
  if (type == INST_TYPE_10_BIT)
  {
   printf("Error! type is %d, there must comb set: ",
     type);
   return -1;
  }
 }
 else
 {
  if (type == INST_TYPE_20_BIT)
  {
   printf("Error! type is %d, there should be no comb: ",
     type);
   return -1;
  }
  pInst->comb = comb;
 }
 if (parser_get_items_from_list(
   pInstructionStatement->szOperationData,
      arrOperands,
      nOperands) != 0)
    {
  printf("Error! Invalid number of operands: ");
  return -1;
    }
 if (retrieve_operands(&complete_instruction,
        arrOperands,
        nOperands) != 0)
 {
  return -1;
 }
 if (pInstructionStatement->szLabel != ((void *)0))
 {
  symbol_t label;
  label.locality = ADDR_ABSOLUTE;
  label.address = io_pCode->IC;
  strncpy(label.name, pInstructionStatement->szLabel, sizeof(label.name));
  if (symbol_add_to_table(io_pSymbols, &label) != 0)
  {
   return -1;
  }
 }
 memcpy(&io_pCode->content[io_pCode->IC],
     pInst,
     sizeof(io_pCode->content[io_pCode->IC]));
 io_pCode->localities[io_pCode->IC] = complete_instruction.localities[0];
 io_pCode->IC++;
 memcpy(&io_pCode->content[io_pCode->IC],
     complete_instruction.extra_data,
     complete_instruction.num_extra_data *
     sizeof(io_pCode->content[io_pCode->IC]));
 memcpy(&io_pCode->localities[io_pCode->IC],
     &complete_instruction.localities[1],
     complete_instruction.num_extra_data *
     sizeof(io_pCode->localities[io_pCode->IC]));
 io_pCode->IC += complete_instruction.num_extra_data;
 return 0;
}

canonical_original_code:
int instruction_compile(struct statement_t *pInstructionStatement, struct code_section_t *io_pCode, struct symbol_t io_pSymbols[1000])
{
 char *arrOperands[-1];
 unsigned int type; unsigned int comb;
 int nOperands;
 struct instruction_with_operands_t complete_instruction;
 struct instruction_t *pInst = &complete_instruction.instruction;
 if (pInstructionStatement == ((void *)0) ||
  io_pCode == ((void *)0))
  return -1;
 memset(complete_instruction.localities,
   0,
   sizeof(complete_instruction.localities));
 complete_instruction.localities[0] = ADDR_ABSOLUTE;
 pInst->opcode = pInstructionStatement->info.instruction.name;
 nOperands = get_num_operands_for_opcode(pInst->opcode);
 if (nOperands < 0)
  return -1;
 type = parser_get_instruction_type(pInstructionStatement->info.instruction.modifiers);
 if (type == (2))
 {
  printf("Error! Invalid type: ");
  return -1;
 }
 else
 {
  pInst->type = type;
 }
 pInst->comb = INST_COMB_MSB_MSB;
 comb = parser_get_instruction_comb(pInstructionStatement->info.instruction.modifiers);
 if (comb == (4))
 {
  printf("Error! Invalid comb: ");
  return -1;
 }
 else if (comb == (5))
 {
  if (type == INST_TYPE_10_BIT)
  {
   printf("Error! type is %d, there must comb set: ",
     type);
   return -1;
  }
 }
 else
 {
  if (type == INST_TYPE_20_BIT)
  {
   printf("Error! type is %d, there should be no comb: ",
     type);
   return -1;
  }
  pInst->comb = comb;
 }
 if (parser_get_items_from_list(
   pInstructionStatement->szOperationData,
      arrOperands,
      nOperands) != 0)
    {
  printf("Error! Invalid number of operands: ");
  return -1;
    }
 if (retrieve_operands(&complete_instruction,
        arrOperands,
        nOperands) != 0)
 {
  return -1;
 }
 if (pInstructionStatement->szLabel != ((void *)0))
 {
  struct symbol_t label;
  label.locality = ADDR_ABSOLUTE;
  label.address = io_pCode->IC;
  strncpy(label.name, pInstructionStatement->szLabel, sizeof(label.name));
  if (symbol_add_to_table(io_pSymbols, &label) != 0)
  {
   return -1;
  }
 }
 memcpy(&io_pCode->content[io_pCode->IC],
     pInst,
     sizeof(io_pCode->content[io_pCode->IC]));
 io_pCode->localities[io_pCode->IC] = complete_instruction.localities[0];
 io_pCode->IC++;
 memcpy(&io_pCode->content[io_pCode->IC],
     complete_instruction.extra_data,
     complete_instruction.num_extra_data *
     sizeof(io_pCode->content[io_pCode->IC]));
 memcpy(&io_pCode->localities[io_pCode->IC],
     &complete_instruction.localities[1],
     complete_instruction.num_extra_data *
     sizeof(io_pCode->localities[io_pCode->IC]));
 io_pCode->IC += complete_instruction.num_extra_data;
 return 0;
}

variable_types: struct statement_t { enum statement_type_t { STATEMENT_TYPE_EMPTY=0, STATEMENT_TYPE_COMMENT=1, STATEMENT_TYPE_DIRECTIVE=2, STATEMENT_TYPE_INSTRUCTION=3, STATEMENT_TYPE_ERROR=4 } type; char *szLabel; union { struct directive_statement_t { int name; } directive; struct instruction_statement_t { int name; char *modifiers; } instruction; } info; char *szOperationData; char szContent[80]; } *

variable_types: struct code_section_t { struct machine_cell_t { unsigned int val; } content[2000]; enum address_locality_t { ADDR_INVALID=0, ADDR_ABSOLUTE=1, ADDR_RELOCATABLE=2, ADDR_EXTERNAL=3, ADDR_ENTRY=4 } localities[2000]; unsigned int IC; } *

variable_types: struct symbol_t { enum address_locality_t { ADDR_INVALID=0, ADDR_ABSOLUTE=1, ADDR_RELOCATABLE=2, ADDR_EXTERNAL=3, ADDR_ENTRY=4 } locality; char name[-1]; unsigned long address; } [1000]

variable_types:
arrOperands
char *[-1]

variable_types:
type
unsigned int

variable_types:
comb
unsigned int

variable_types: nOperands int

variable_types: struct instruction_with_operands_t { unsigned char num_extra_data; struct instruction_t { enum instruction_comb_t { INST_COMB_MSB_MSB=0, INST_COMB_MSB_LSB=1, INST_COMB_LSB_MSB=2, INST_COMB_LSB_LSB=3 } comb; enum machine_registers_t { R0=0, R1=1, R2=2, R3=3, R4=4, R5=5, R6=6, R7=7 } dest_reg; enum operand_addressing_t { OPERAND_ADDR_IMMEDIATE=0, OPERAND_ADDR_DIRECT=1, OPERAND_ADDR_INDEX=2, OPERAND_ADDR_REGISTER=3 } dest_addressing; enum machine_registers_t { R0=0, R1=1, R2=2, R3=3, R4=4, R5=5, R6=6, R7=7 } src_reg; enum operand_addressing_t { OPERAND_ADDR_IMMEDIATE=0, OPERAND_ADDR_DIRECT=1, OPERAND_ADDR_INDEX=2, OPERAND_ADDR_REGISTER=3 } src_addressing; enum opcode_t { MOV=0, CMP=1, ADD=2, SUB=3, NOT=4, CLR=5, LEA=6, INC=7, DEC=8, JMP=9, BNE=10, RED=11, PRN=12, JSR=13, RTS=14, STOP=15 } opcode; enum instruction_type_t { INST_TYPE_20_BIT=0, INST_TYPE_10_BIT=1 } type; unsigned char rfu; unsigned int pad; } instruction; struct machine_cell_t { unsigned int val; } extra_data[-1]; enum address_locality_t { ADDR_INVALID=0, ADDR_ABSOLUTE=1, ADDR_RELOCATABLE=2, ADDR_EXTERNAL=3, ADDR_ENTRY=4 } localities[-1]; }

variable_types: struct instruction_t { enum instruction_comb_t { INST_COMB_MSB_MSB=0, INST_COMB_MSB_LSB=1, INST_COMB_LSB_MSB=2, INST_COMB_LSB_LSB=3 } comb; enum machine_registers_t { R0=0, R1=1, R2=2, R3=3, R4=4, R5=5, R6=6, R7=7 } dest_reg; enum operand_addressing_t { OPERAND_ADDR_IMMEDIATE=0, OPERAND_ADDR_DIRECT=1, OPERAND_ADDR_INDEX=2, OPERAND_ADDR_REGISTER=3 } dest_addressing; enum machine_registers_t { R0=0, R1=1, R2=2, R3=3, R4=4, R5=5, R6=6, R7=7 } src_reg; enum operand_addressing_t { OPERAND_ADDR_IMMEDIATE=0, OPERAND_ADDR_DIRECT=1, OPERAND_ADDR_INDEX=2, OPERAND_ADDR_REGISTER=3 } src_addressing; enum opcode_t { MOV=0, CMP=1, ADD=2, SUB=3, NOT=4, CLR=5, LEA=6, INC=7, DEC=8, JMP=9, BNE=10, RED=11, PRN=12, JSR=13, RTS=14, STOP=15 } opcode; enum instruction_type_t { INST_TYPE_20_BIT=0, INST_TYPE_10_BIT=1 } type; unsigned char rfu; unsigned int pad; } *

user_defined_types: struct symbol_t { enum address_locality_t locality; char name[-1]; unsigned long address; }

user_defined_types: struct statement_t { enum statement_type_t type; char *szLabel; union { struct directive_statement_t directive; struct instruction_statement_t instruction; } info; char *szOperationData; char szContent[80]; }

user_defined_types: struct code_section_t { struct machine_cell_t content[2000]; enum address_locality_t localities[2000]; unsigned int IC; }


decompiled_code:
__int64 __fastcall directive_compile_extern(__int64 a1, __int64 a2)
{
int v3; // [rsp+0h] [rbp-48h] BYREF
char dest[36]; // [rsp+4h] [rbp-44h] BYREF
__int64 v5; // [rsp+28h] [rbp-20h]
char *src; // [rsp+38h] [rbp-10h] BYREF

v5 = 0LL;
v3 = 3;
if ( !a1 || !a2 )
return 0xFFFFFFFFLL;
if ( (unsigned int)parser_get_items_from_list(*(_QWORD *)(a1 + 32), &src, 1LL) )
return 4294967294LL;
strncpy(dest, src, 0x1FuLL);
return symbol_add_to_table(a2, &v3);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
int v3; // [rsp+0h] [rbp-48h] BYREF
char dest[36]; // [rsp+4h] [rbp-44h] BYREF
__int64 v5; // [rsp+28h] [rbp-20h]
char *src; // [rsp+38h] [rbp-10h] BYREF

v5 = 0LL;
v3 = 3;
if ( !a1 || !a2 )
return 0xFFFFFFFFLL;
if ( (unsigned int)parser_get_items_from_list(*(_QWORD *)(a1 + 32), &src, 1LL) )
return 4294967294LL;
strncpy(dest, src, 0x1FuLL);
return symbol_add_to_table(a2, &v3);
}

original_code:
int directive_compile_extern(const statement_t *pExtern,
        symbol_table_arr_t io_pSymbols)
{
 char *pName;
 symbol_t symbol;
 symbol.address = 0;
 symbol.locality = ADDR_EXTERNAL;
 if (pExtern == ((void *)0) ||
  io_pSymbols == ((void *)0))
  return -1;
 if (parser_get_items_from_list(pExtern->szOperationData,
           &pName,
           1) != 0)
  return -2;
 strncpy(symbol.name, pName, sizeof(symbol.name));
 return symbol_add_to_table(io_pSymbols, &symbol);
}

canonical_original_code:
int directive_compile_extern(struct statement_t *pExtern, struct symbol_t io_pSymbols[1000])
{
 char *pName;
 struct symbol_t symbol;
 symbol.address = 0;
 symbol.locality = ADDR_EXTERNAL;
 if (pExtern == ((void *)0) ||
  io_pSymbols == ((void *)0))
  return -1;
 if (parser_get_items_from_list(pExtern->szOperationData,
           &pName,
           1) != 0)
  return -2;
 strncpy(symbol.name, pName, sizeof(symbol.name));
 return symbol_add_to_table(io_pSymbols, &symbol);
}

variable_types:
pName
char *

variable_types: struct symbol_t { enum address_locality_t { ADDR_INVALID=0, ADDR_ABSOLUTE=1, ADDR_RELOCATABLE=2, ADDR_EXTERNAL=3, ADDR_ENTRY=4 } locality; char name[-1]; unsigned long address; }

user_defined_types: enum statement_type_t { STATEMENT_TYPE_EMPTY=0, STATEMENT_TYPE_COMMENT=1, STATEMENT_TYPE_DIRECTIVE=2, STATEMENT_TYPE_INSTRUCTION=3, STATEMENT_TYPE_ERROR=4 }

user_defined_types: struct directive_statement_t { int name; }

user_defined_types: struct instruction_statement_t { int name; char *modifiers; }


decompiled_code:
__int64 __fastcall directive_compile_entry(__int64 a1, __int64 a2)
{
unsigned int v2; // ebx
_DWORD *v3; // rax
const char *v5; // [rsp+8h] [rbp-20h] BYREF

v5 = 0LL;
if ( !a1 || !a2 )
return (unsigned int)-1;
v2 = parser_get_items_from_list(*(_QWORD *)(a1 + 32), &v5, 1LL);
if ( v2 )
return (unsigned int)-2;
v3 = (_DWORD *)symbol_get_from_table_by_name(a2, v5);
if ( v3 )
{
if ( *v3 == 4 )
{
printf("Error! %s is already an entry point!\n", v5);
v2 = -5;
}
else if ( *v3 == 3 )
{
printf("Error! cannot set %s as an entry point, it's an external symbol!\n", v5);
v2 = -5;
}
else
{
*v3 = 4;
}
}
else
{
printf("Error! cannot set %s as an entry point, symbol doesn't exist!\n", v5);
v2 = -4;
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
unsigned int v2; // ebx
_DWORD *v3; // rax
const char *v5; // [rsp+8h] [rbp-20h] BYREF

v5 = 0LL;
if ( !a1 || !a2 )
return (unsigned int)-1;
v2 = parser_get_items_from_list(*(_QWORD *)(a1 + 32), &v5, 1LL);
if ( v2 )
return (unsigned int)-2;
v3 = (_DWORD *)symbol_get_from_table_by_name(a2, v5);
if ( v3 )
{
if ( *v3 == 4 )
{
printf("Error! %s is already an entry point!\n", v5);
v2 = -5;
}
else if ( *v3 == 3 )
{
printf("Error! cannot set %s as an entry point, it's an external symbol!\n", v5);
v2 = -5;
}
else
{
*v3 = 4;
}
}
else
{
printf("Error! cannot set %s as an entry point, symbol doesn't exist!\n", v5);
v2 = -4;
}
return v2;
}

original_code:
int directive_compile_entry(const statement_t *pEntry,
       symbol_table_arr_t io_pSymbols)
{
 char *pName = ((void *)0);
 symbol_t *pSymbol = ((void *)0);
 if (pEntry == ((void *)0) ||
  io_pSymbols == ((void *)0))
  return -1;
 if (parser_get_items_from_list(pEntry->szOperationData,
           &pName,
           1) != 0)
  return -2;
 pSymbol = symbol_get_from_table_by_name(io_pSymbols, pName);
 if (pSymbol == ((void *)0))
 {
  printf("Error! cannot set %s as an entry point, symbol doesn't exist!\n",
    pName);
  return -4;
 }
 else if (pSymbol->locality == ADDR_ENTRY)
 {
  printf("Error! %s is already an entry point!\n",
    pName);
  return -5;
 }
 else if (pSymbol->locality == ADDR_EXTERNAL)
 {
  printf("Error! cannot set %s as an entry point, it's an external symbol!\n",
    pName);
  return -5;
 }
 else
 {
  pSymbol->locality = ADDR_ENTRY;
 }
 return 0;
}

canonical_original_code:
int directive_compile_entry(struct statement_t *pEntry, struct symbol_t io_pSymbols[1000])
{
 char *pName = ((void *)0);
 struct symbol_t *pSymbol = ((void *)0);
 if (pEntry == ((void *)0) ||
  io_pSymbols == ((void *)0))
  return -1;
 if (parser_get_items_from_list(pEntry->szOperationData,
           &pName,
           1) != 0)
  return -2;
 pSymbol = symbol_get_from_table_by_name(io_pSymbols, pName);
 if (pSymbol == ((void *)0))
 {
  printf("Error! cannot set %s as an entry point, symbol doesn't exist!\n",
    pName);
  return -4;
 }
 else if (pSymbol->locality == ADDR_ENTRY)
 {
  printf("Error! %s is already an entry point!\n",
    pName);
  return -5;
 }
 else if (pSymbol->locality == ADDR_EXTERNAL)
 {
  printf("Error! cannot set %s as an entry point, it's an external symbol!\n",
    pName);
  return -5;
 }
 else
 {
  pSymbol->locality = ADDR_ENTRY;
 }
 return 0;
}

variable_types: struct symbol_t { enum address_locality_t { ADDR_INVALID=0, ADDR_ABSOLUTE=1, ADDR_RELOCATABLE=2, ADDR_EXTERNAL=3, ADDR_ENTRY=4 } locality; char name[-1]; unsigned long address; } *


decompiled_code:
__int64 __fastcall retrieve_data_fields(__int64 a1, _QWORD *a2, int a3)
{
_QWORD *v3; // rbp
__int64 v4; // r12
unsigned int v5; // eax

if ( !a3 )
return 0LL;
v3 = a2;
v4 = (__int64)&a2[(unsigned int)(a3 - 1) + 1];
while ( 1 )
{
v5 = *(_DWORD *)(a1 + 8000);
if ( v5 > 0x7CF )
return 4294967294LL;
if ( !(unsigned __int8)parser_get_number(*v3, a1 + 4LL * v5) )
break;
++*(_DWORD *)(a1 + 8000);
if ( ++v3 == (_QWORD *)v4 )
return 0LL;
}
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, _QWORD *a2, int a3)
{
_QWORD *v3; // rbp
__int64 v4; // r12
unsigned int v5; // eax

if ( !a3 )
return 0LL;
v3 = a2;
v4 = (__int64)&a2[(unsigned int)(a3 - 1) + 1];
while ( 1 )
{
v5 = *(_DWORD *)(a1 + 8000);
if ( v5 > 0x7CF )
return 4294967294LL;
if ( !(unsigned __int8)parser_get_number(*v3, a1 + 4LL * v5) )
break;
++*(_DWORD *)(a1 + 8000);
if ( ++v3 == (_QWORD *)v4 )
return 0LL;
}
return 0xFFFFFFFFLL;
}

original_code:
int retrieve_data_fields(data_section_t* io_pData,
         char** arrFields,
         unsigned int nFields)
{
 unsigned i;
 for (i = 0; i < nFields; ++i)
 {
  if (io_pData->DC >= 2000)
  {
   return -2;
  }
  if (0 == parser_get_number(arrFields[i],
               &io_pData->content[io_pData->DC].val))
  {
   return -1;
  }
  io_pData->DC++;
 }
 return 0;
}

canonical_original_code:
int retrieve_data_fields(struct data_section_t *io_pData, char **arrFields, unsigned int nFields)
{
 unsigned int i;
 for (i = 0; i < nFields; ++i)
 {
  if (io_pData->DC >= 2000)
  {
   return -2;
  }
  if (0 == parser_get_number(arrFields[i],
               &io_pData->content[io_pData->DC].val))
  {
   return -1;
  }
  io_pData->DC++;
 }
 return 0;
}

variable_types: struct data_section_t { struct machine_cell_t { unsigned int val; } content[2000]; unsigned int DC; } *

variable_types:
arrFields
char **

variable_types:
nFields
unsigned int

variable_types:
i
unsigned int

user_defined_types: struct data_section_t { struct machine_cell_t content[2000]; unsigned int DC; }


decompiled_code:
__int64 __fastcall directive_compile_dummy_instruction(__int64 a1, __int64 a2, __int64 a3)
{
const char *v5; // rsi
unsigned int v6; // eax
int v7; // ebp
__int64 result; // rax
int v9; // [rsp+0h] [rbp-3EC8h] BYREF
char dest[36]; // [rsp+4h] [rbp-3EC4h] BYREF
__int64 v11; // [rsp+28h] [rbp-3EA0h]
_QWORD v12[2003]; // [rsp+30h] [rbp-3E98h] BYREF

if ( a2 == 0 || a3 == 0 || !a1 )
return 0xFFFFFFFFLL;
v5 = *(const char **)(a1 + 8);
if ( v5 )
{
v9 = 2;
v11 = *(unsigned int *)(a2 + 8000);
strncpy(dest, v5, 0x1FuLL);
if ( (unsigned int)symbol_add_to_table(a3, &v9) )
return 0xFFFFFFFFLL;
}
v6 = parser_get_num_items_in_list(*(_QWORD *)(a1 + 32));
v7 = v6;
if ( v6 )
{
if ( (unsigned int)parser_get_items_from_list(*(_QWORD *)(a1 + 32), v12, v6) )
{
result = 4294967294LL;
}
else
{
result = retrieve_data_fields(a2, v12, v7);
if ( (_DWORD)result )
result = 4294967293LL;
}
}
else
{
printf("Error! data directive must contain at least one element.");
result = 4294967294LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2, __int64 a3)
{
const char *v5; // rsi
unsigned int v6; // eax
int v7; // ebp
__int64 result; // rax
int v9; // [rsp+0h] [rbp-3EC8h] BYREF
char dest[36]; // [rsp+4h] [rbp-3EC4h] BYREF
__int64 v11; // [rsp+28h] [rbp-3EA0h]
_QWORD v12[2003]; // [rsp+30h] [rbp-3E98h] BYREF

if ( a2 == 0 || a3 == 0 || !a1 )
return 0xFFFFFFFFLL;
v5 = *(const char **)(a1 + 8);
if ( v5 )
{
v9 = 2;
v11 = *(unsigned int *)(a2 + 8000);
strncpy(dest, v5, 0x1FuLL);
if ( (unsigned int)symbol_add_to_table(a3, &v9) )
return 0xFFFFFFFFLL;
}
v6 = parser_get_num_items_in_list(*(_QWORD *)(a1 + 32));
v7 = v6;
if ( v6 )
{
if ( (unsigned int)parser_get_items_from_list(*(_QWORD *)(a1 + 32), v12, v6) )
{
result = 4294967294LL;
}
else
{
result = func2(a2, v12, v7);
if ( (_DWORD)result )
result = 4294967293LL;
}
}
else
{
printf("Error! data directive must contain at least one element.");
result = 4294967294LL;
}
return result;
}

original_code:
int directive_compile_dummy_instruction(const statement_t *pDummyInst,
             data_section_t* io_pData,
             symbol_table_arr_t io_pSymbols)
{
 char *arrDataFields[2000];
 unsigned int nNumDataFields = 0;
 if (pDummyInst == ((void *)0) ||
  io_pSymbols == ((void *)0) ||
  io_pData == ((void *)0))
  return -1;
 if (pDummyInst->szLabel != ((void *)0))
 {
  symbol_t label;
  label.locality = ADDR_RELOCATABLE;
  label.address = io_pData->DC;
  strncpy(label.name, pDummyInst->szLabel, sizeof(label.name));
  if (symbol_add_to_table(io_pSymbols, &label) != 0)
  {
   return -1;
  }
 }
 nNumDataFields = parser_get_num_items_in_list(pDummyInst->szOperationData);
 if (nNumDataFields == 0)
 {
  printf("Error! data directive must contain at least one element.");
  return -2;
 }
 if (parser_get_items_from_list(pDummyInst->szOperationData,
           arrDataFields,
           nNumDataFields) != 0)
  return -2;
 if (retrieve_data_fields(io_pData,
        arrDataFields,
        nNumDataFields) != 0)
  return -3;
 return 0;
}

canonical_original_code:
int directive_compile_dummy_instruction(struct statement_t *pDummyInst, struct data_section_t *io_pData, struct symbol_t io_pSymbols[1000])
{
 char *arrDataFields[2000];
 unsigned int nNumDataFields = 0;
 if (pDummyInst == ((void *)0) ||
  io_pSymbols == ((void *)0) ||
  io_pData == ((void *)0))
  return -1;
 if (pDummyInst->szLabel != ((void *)0))
 {
  struct symbol_t label;
  label.locality = ADDR_RELOCATABLE;
  label.address = io_pData->DC;
  strncpy(label.name, pDummyInst->szLabel, sizeof(label.name));
  if (symbol_add_to_table(io_pSymbols, &label) != 0)
  {
   return -1;
  }
 }
 nNumDataFields = parser_get_num_items_in_list(pDummyInst->szOperationData);
 if (nNumDataFields == 0)
 {
  printf("Error! data directive must contain at least one element.");
  return -2;
 }
 if (parser_get_items_from_list(pDummyInst->szOperationData,
           arrDataFields,
           nNumDataFields) != 0)
  return -2;
 if (retrieve_data_fields(io_pData,
        arrDataFields,
        nNumDataFields) != 0)
  return -3;
 return 0;
}

variable_types:
arrDataFields
char *[2000]

variable_types:
nNumDataFields
unsigned int


decompiled_code:
__int64 __fastcall symbol_get_from_table_by_name(__int64 a1, const char *a2)
{
__int64 v2; // rbx
__int64 v3; // r12

if ( !a1 || !a2 )
return 0LL;
v2 = a1;
while ( 1 )
{
v3 = v2;
if ( *(_DWORD *)v2 )
{
if ( !strcmp(a2, (const char *)(v2 + 4)) )
break;
}
v2 += 48LL;
if ( v2 == a1 + 384 )
return 0LL;
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, const char *a2)
{
__int64 v2; // rbx
__int64 v3; // r12

if ( !a1 || !a2 )
return 0LL;
v2 = a1;
while ( 1 )
{
v3 = v2;
if ( *(_DWORD *)v2 )
{
if ( !strcmp(a2, (const char *)(v2 + 4)) )
break;
}
v2 += 48LL;
if ( v2 == a1 + 384 )
return 0LL;
}
return v3;
}

original_code:
symbol_t* symbol_get_from_table_by_name(symbol_table_arr_t table,
          const char* szName)
{
 int i;
 if (table == ((void *)0) ||
  szName == ((void *)0))
  return ((void *)0);
 for (i = 0; i < sizeof(table); ++i)
 {
  if (table[i].locality != ADDR_INVALID)
  {
   if (strcmp(szName, table[i].name) == 0)
   {
    return &table[i];
   }
  }
 }
 return ((void *)0);
}

canonical_original_code:
struct symbol_t *symbol_get_from_table_by_name(struct symbol_t table[1000], char *szName)
{
 int i;
 if (table == ((void *)0) ||
  szName == ((void *)0))
  return ((void *)0);
 for (i = 0; i < sizeof(table); ++i)
 {
  if (table[i].locality != ADDR_INVALID)
  {
   if (strcmp(szName, table[i].name) == 0)
   {
    return &table[i];
   }
  }
 }
 return ((void *)0);
}

variable_types:
table
struct symbol_t [1000]

variable_types:
szName
char *

variable_types: i int

return_type: struct symbol_t { enum address_locality_t { ADDR_INVALID=0, ADDR_ABSOLUTE=1, ADDR_RELOCATABLE=2, ADDR_EXTERNAL=3, ADDR_ENTRY=4 } locality; char name[-1]; unsigned long address; } *


decompiled_code:
__int64 __fastcall symbol_add_to_table(__int64 a1, const __m128i *a2)
{
const char *v2; // rbp
__m128i *v3; // rax
__m128i *v4; // rdi
__int64 result; // rax

if ( !a1 )
return 4294967294LL;
if ( !a2 )
return 4294967294LL;
v2 = &a2->m128i_i8[4];
if ( symbol_get_from_table_by_name(a1, &a2->m128i_i8[4]) )
{
printf("Error! symbol %s already exists in symbol table.\n", v2);
result = 0xFFFFFFFFLL;
}
else if ( (unsigned int)parser_check_symbol_syntax(v2) )
{
v3 = (__m128i *)a1;
v4 = (__m128i *)(a1 + 384);
while ( v3->m128i_i32[0] )
{
v3 += 3;
if ( v3 == v4 )
return 4294967293LL;
}
*v3 = _mm_loadu_si128(a2);
v3[1] = _mm_loadu_si128(a2 + 1);
v3[2] = _mm_loadu_si128(a2 + 2);
result = 0LL;
}
else
{
result = 4294967293LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, const __m128i *a2)
{
const char *v2; // rbp
__m128i *v3; // rax
__m128i *v4; // rdi
__int64 result; // rax

if ( !a1 )
return 4294967294LL;
if ( !a2 )
return 4294967294LL;
v2 = &a2->m128i_i8[4];
if ( func0(a1, &a2->m128i_i8[4]) )
{
printf("Error! symbol %s already exists in symbol table.\n", v2);
result = 0xFFFFFFFFLL;
}
else if ( (unsigned int)parser_check_symbol_syntax(v2) )
{
v3 = (__m128i *)a1;
v4 = (__m128i *)(a1 + 384);
while ( v3->m128i_i32[0] )
{
v3 += 3;
if ( v3 == v4 )
return 4294967293LL;
}
*v3 = _mm_loadu_si128(a2);
v3[1] = _mm_loadu_si128(a2 + 1);
v3[2] = _mm_loadu_si128(a2 + 2);
result = 0LL;
}
else
{
result = 4294967293LL;
}
return result;
}

original_code:
int symbol_add_to_table(symbol_table_arr_t table,
      const symbol_t *symbol)
{
 int i;
 if (table == ((void *)0) ||
  symbol == ((void *)0))
  return -2;
 if (symbol_get_from_table_by_name(table, symbol->name) != ((void *)0))
 {
  printf("Error! symbol %s already exists in symbol table.\n", symbol->name);
  return -1;
 }
 if (parser_check_symbol_syntax(symbol->name) == 0)
  return -3;
 for (i = 0; i < sizeof(table); ++i)
 {
  if (table[i].locality == ADDR_INVALID)
  {
   memcpy(&table[i], symbol, sizeof(table[i]));
   return 0;
  }
 }
 return -3;
}

canonical_original_code:
int symbol_add_to_table(struct symbol_t table[1000], struct symbol_t *symbol)
{
 int i;
 if (table == ((void *)0) ||
  symbol == ((void *)0))
  return -2;
 if (symbol_get_from_table_by_name(table, symbol->name) != ((void *)0))
 {
  printf("Error! symbol %s already exists in symbol table.\n", symbol->name);
  return -1;
 }
 if (parser_check_symbol_syntax(symbol->name) == 0)
  return -3;
 for (i = 0; i < sizeof(table); ++i)
 {
  if (table[i].locality == ADDR_INVALID)
  {
   memcpy(&table[i], symbol, sizeof(table[i]));
   return 0;
  }
 }
 return -3;
}

variable_types: struct symbol_t { enum address_locality_t { ADDR_INVALID=0, ADDR_ABSOLUTE=1, ADDR_RELOCATABLE=2, ADDR_EXTERNAL=3, ADDR_ENTRY=4 } locality; char name[-1]; unsigned long address; } [1000]

variable_types:
symbol
struct symbol_t *


repo: organix/art

decompiled_code:
void *__fastcall empty_beh_kind(const void *a1, int *a2)
{
unsigned int v2; // eax
const void **v3; // rdx

fprintf(stderr, "%p(empty_beh_kind)\n", a1);
v2 = *a2;
if ( (unsigned int)*a2 > 0x2F )
{
v3 = (const void **)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v3 + 1;
}
else
{
v3 = (const void **)(*((_QWORD *)a2 + 2) + v2);
*a2 = v2 + 8;
}
fprintf(stderr, " %p: event=%p {actor:%p, msg:%p}\n", a1, *v3, *((const void **)*v3 + 1), *((const void **)*v3 + 2));
return &t_symbol;
}

canonical_decompiled_code:
void *__fastcall func0(const void *a1, int *a2)
{
unsigned int v2; // eax
const void **v3; // rdx

fprintf(stderr, "%p(empty_beh_kind)\n", a1);
v2 = *a2;
if ( (unsigned int)*a2 > 0x2F )
{
v3 = (const void **)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v3 + 1;
}
else
{
v3 = (const void **)(*((_QWORD *)a2 + 2) + v2);
*a2 = v2 + 8;
}
fprintf(stderr, " %p: event=%p {actor:%p, msg:%p}\n", a1, *v3, *((const void **)*v3 + 1), *((const void **)*v3 + 2));
return &t_symbol;
}

original_code:
static OOP empty_beh_kind(OOP self, va_list args)
{
    fprintf(stderr, "%p(empty_beh_kind)\n", self);
    OOP evt = __builtin_va_arg(args,OOP);
    OOP act = ((struct event *)(evt))->actor;
    OOP msg = ((struct event *)(evt))->msg;
    fprintf(stderr, "  %p: event=%p {actor:%p, msg:%p}\n", self, evt, act, msg);
    return ((OOP)&_t_symbol);
}

canonical_original_code:
static struct object *empty_beh_kind(struct object *self, __builtin_va_list args)
{
    fprintf(stderr, "%p(empty_beh_kind)\n", self);
    struct object *evt = __builtin_va_arg(args,OOP);
    struct object *act = ((struct event *)(evt))->actor;
    struct object *msg = ((struct event *)(evt))->msg;
    fprintf(stderr, "  %p: event=%p {actor:%p, msg:%p}\n", self, evt, act, msg);
    return ((OOP)&_t_symbol);
}

variable_types:
self
struct object *

variable_types: struct object { struct object *(*kind)(struct object *self, __builtin_va_list args); } *


decompiled_code:
void *__fastcall actor_kind(const void **a1, int *a2)
{
unsigned int v2; // eax
const void **v3; // rdx
void *v4; // r12
void *result; // rax
unsigned int v6; // eax
const void ***v7; // rdx

fprintf(stderr, "%p(actor_kind, %p)\n", a1, a1[1]);
v2 = *a2;
if ( (unsigned int)*a2 > 0x2F )
{
v3 = (const void **)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v3 + 1;
}
else
{
v3 = (const void **)(*((_QWORD *)a2 + 2) + v2);
*a2 = v2 + 8;
}
v4 = (void *)*v3;
fprintf(stderr, " %p: event=%p\n", a1, *v3);
if ( v4 != &eq_p_symbol )
return (void *)object_call(a1[1], v4);
v6 = *a2;
if ( (unsigned int)*a2 > 0x2F )
{
v7 = (const void ***)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v7 + 1;
}
else
{
v7 = (const void ***)(*((_QWORD *)a2 + 2) + v6);
*a2 = v6 + 8;
}
result = &t_symbol;
if ( a1 != *v7 )
result = &f_symbol;
return result;
}

canonical_decompiled_code:
void *__fastcall func1(const void **a1, int *a2)
{
unsigned int v2; // eax
const void **v3; // rdx
void *v4; // r12
void *result; // rax
unsigned int v6; // eax
const void ***v7; // rdx

fprintf(stderr, "%p(actor_kind, %p)\n", a1, a1[1]);
v2 = *a2;
if ( (unsigned int)*a2 > 0x2F )
{
v3 = (const void **)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v3 + 1;
}
else
{
v3 = (const void **)(*((_QWORD *)a2 + 2) + v2);
*a2 = v2 + 8;
}
v4 = (void *)*v3;
fprintf(stderr, " %p: event=%p\n", a1, *v3);
if ( v4 != &eq_p_symbol )
return (void *)object_call(a1[1], v4);
v6 = *a2;
if ( (unsigned int)*a2 > 0x2F )
{
v7 = (const void ***)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v7 + 1;
}
else
{
v7 = (const void ***)(*((_QWORD *)a2 + 2) + v6);
*a2 = v6 + 8;
}
result = &t_symbol;
if ( a1 != *v7 )
result = &f_symbol;
return result;
}

original_code:
OOP actor_kind(OOP self, va_list args)
{
    struct actor * this = ((struct actor *)(self));
    fprintf(stderr, "%p(actor_kind, %p)\n", this, this->beh);
    OOP event = __builtin_va_arg(args,OOP);
    fprintf(stderr, "  %p: event=%p\n", this, event);
    if (event == ((OOP)&eq_p_symbol)) {
        OOP other = __builtin_va_arg(args,OOP);
        if (other == self) {
            return ((OOP)&_t_symbol);
        }
        return ((OOP)&_f_symbol);
    }
    return object_call(this->beh, event);
}

canonical_original_code:
struct object *actor_kind(struct object *self, __builtin_va_list args)
{
    struct actor *this = ((struct actor *)(self));
    fprintf(stderr, "%p(actor_kind, %p)\n", this, this->beh);
    struct object *event = __builtin_va_arg(args,OOP);
    fprintf(stderr, "  %p: event=%p\n", this, event);
    if (event == ((OOP)&eq_p_symbol)) {
        struct object *other = __builtin_va_arg(args,OOP);
        if (other == self) {
            return ((OOP)&_t_symbol);
        }
        return ((OOP)&_f_symbol);
    }
    return object_call(this->beh, event);
}

variable_types: struct actor { struct object { struct object *(*kind)(struct object *self, __builtin_va_list args); } o; struct object *beh; } *

return_type: struct object { struct object *(*kind)(struct object *self, __builtin_va_list args); } *

user_defined_types: struct actor { struct object o; struct object *beh; }


decompiled_code:
void *__fastcall forward_beh_kind(const void **a1, int *a2)
{
unsigned int v2; // eax
const void **v3; // rdx
const void *v4; // rbp

fprintf(stderr, "%p forward_beh_kind {target:%p}\n", a1, a1[1]);
v2 = *a2;
if ( (unsigned int)*a2 > 0x2F )
{
v3 = (const void **)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v3 + 1;
}
else
{
v3 = (const void **)(*((_QWORD *)a2 + 2) + v2);
*a2 = v2 + 8;
}
v4 = *v3;
fprintf(stderr, " %p: event=%p {actor:%p, msg:%p}\n", a1, *v3, *((const void **)*v3 + 1), *((const void **)*v3 + 2));
object_call(v4, &send_x_symbol);
return &t_symbol;
}

canonical_decompiled_code:
void *__fastcall func2(const void **a1, int *a2)
{
unsigned int v2; // eax
const void **v3; // rdx
const void *v4; // rbp

fprintf(stderr, "%p forward_beh_kind {target:%p}\n", a1, a1[1]);
v2 = *a2;
if ( (unsigned int)*a2 > 0x2F )
{
v3 = (const void **)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v3 + 1;
}
else
{
v3 = (const void **)(*((_QWORD *)a2 + 2) + v2);
*a2 = v2 + 8;
}
v4 = *v3;
fprintf(stderr, " %p: event=%p {actor:%p, msg:%p}\n", a1, *v3, *((const void **)*v3 + 1), *((const void **)*v3 + 2));
object_call(v4, &send_x_symbol);
return &t_symbol;
}

original_code:
OOP forward_beh_kind(OOP self, va_list args)
{
    struct forward_beh * this = ((struct forward_beh *)(self));
    fprintf(stderr, "%p forward_beh_kind {target:%p}\n", this, this->target);
    OOP evt = __builtin_va_arg(args,OOP);
    OOP act = ((struct event *)(evt))->actor;
    OOP msg = ((struct event *)(evt))->msg;
    fprintf(stderr, "  %p: event=%p {actor:%p, msg:%p}\n", self, evt, act, msg);
    object_call(evt, ((OOP)&send_x_symbol), this->target, msg);
    return ((OOP)&_t_symbol);
}

canonical_original_code:
struct object *forward_beh_kind(struct object *self, __builtin_va_list args)
{
    struct forward_beh *this = ((struct forward_beh *)(self));
    fprintf(stderr, "%p forward_beh_kind {target:%p}\n", this, this->target);
    struct object *evt = __builtin_va_arg(args,OOP);
    struct object *act = ((struct event *)(evt))->actor;
    struct object *msg = ((struct event *)(evt))->msg;
    fprintf(stderr, "  %p: event=%p {actor:%p, msg:%p}\n", self, evt, act, msg);
    object_call(evt, ((OOP)&send_x_symbol), this->target, msg);
    return ((OOP)&_t_symbol);
}

variable_types: struct forward_beh { struct object { struct object *(*kind)(struct object *self, __builtin_va_list args); } o; struct object *target; } *

user_defined_types: struct forward_beh { struct object o; struct object *target; }


decompiled_code:
void *__fastcall one_shot_beh_kind(const void **a1, int *a2)
{
unsigned int v2; // eax
const void **v3; // rdx
const void *v4; // rbp

fprintf(stderr, "%p one_shot_beh_kind {target:%p}\n", a1, a1[1]);
v2 = *a2;
if ( (unsigned int)*a2 > 0x2F )
{
v3 = (const void **)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v3 + 1;
}
else
{
v3 = (const void **)(*((_QWORD *)a2 + 2) + v2);
*a2 = v2 + 8;
}
v4 = *v3;
fprintf(stderr, " %p: event=%p {actor:%p, msg:%p}\n", a1, *v3, *((const void **)*v3 + 1), *((const void **)*v3 + 2));
object_call(v4, &send_x_symbol);
object_call(v4, &become_x_symbol);
return &t_symbol;
}

canonical_decompiled_code:
void *__fastcall func3(const void **a1, int *a2)
{
unsigned int v2; // eax
const void **v3; // rdx
const void *v4; // rbp

fprintf(stderr, "%p one_shot_beh_kind {target:%p}\n", a1, a1[1]);
v2 = *a2;
if ( (unsigned int)*a2 > 0x2F )
{
v3 = (const void **)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v3 + 1;
}
else
{
v3 = (const void **)(*((_QWORD *)a2 + 2) + v2);
*a2 = v2 + 8;
}
v4 = *v3;
fprintf(stderr, " %p: event=%p {actor:%p, msg:%p}\n", a1, *v3, *((const void **)*v3 + 1), *((const void **)*v3 + 2));
object_call(v4, &send_x_symbol);
object_call(v4, &become_x_symbol);
return &t_symbol;
}

original_code:
OOP one_shot_beh_kind(OOP self, va_list args)
{
    struct forward_beh * this = ((struct forward_beh *)(self));
    fprintf(stderr, "%p one_shot_beh_kind {target:%p}\n", this, this->target);
    OOP evt = __builtin_va_arg(args,OOP);
    OOP act = ((struct event *)(evt))->actor;
    OOP msg = ((struct event *)(evt))->msg;
    fprintf(stderr, "  %p: event=%p {actor:%p, msg:%p}\n", self, evt, act, msg);
    object_call(evt, ((OOP)&send_x_symbol), this->target, msg);
    object_call(evt, ((OOP)&become_x_symbol), ((OOP)&empty_beh));
    return ((OOP)&_t_symbol);
}

canonical_original_code:
struct object *one_shot_beh_kind(struct object *self, __builtin_va_list args)
{
    struct forward_beh *this = ((struct forward_beh *)(self));
    fprintf(stderr, "%p one_shot_beh_kind {target:%p}\n", this, this->target);
    struct object *evt = __builtin_va_arg(args,OOP);
    struct object *act = ((struct event *)(evt))->actor;
    struct object *msg = ((struct event *)(evt))->msg;
    fprintf(stderr, "  %p: event=%p {actor:%p, msg:%p}\n", self, evt, act, msg);
    object_call(evt, ((OOP)&send_x_symbol), this->target, msg);
    object_call(evt, ((OOP)&become_x_symbol), ((OOP)&empty_beh));
    return ((OOP)&_t_symbol);
}

user_defined_types: struct object { struct object *(*kind)(struct object *self, __builtin_va_list args); }


decompiled_code:
void *__fastcall config_kind(_QWORD *a1, int *a2)
{
unsigned int v3; // eax
const void **v4; // rdx
void **v5; // r12
void *result; // rax
unsigned int v7; // eax
_QWORD *v8; // rdx
unsigned int v9; // eax
const void **v10; // rdx
__int64 v11; // rax
unsigned int v12; // eax
__int64 *v13; // rdx
__int64 v14; // r13
void *i; // rdi
__int64 v16; // rbp
const void *v17; // rcx
_QWORD *v18; // r12
__int64 v19; // rax
void *v20; // rbp

fprintf(stderr, "%p config_kind {remain:%d}\n", a1, *(unsigned int *)(a1[2] + 8LL));
v3 = *a2;
if ( (unsigned int)*a2 > 0x2F )
{
v4 = (const void **)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v4 + 1;
}
else
{
v4 = (const void **)(*((_QWORD *)a2 + 2) + v3);
*a2 = v3 + 8;
}
v5 = (void **)*v4;
fprintf(stderr, " %p: cmd=%p \"%s\"\n", a1, *v4, *((const char **)*v4 + 1));
if ( v5 == (void **)&eq_p_symbol )
{
v7 = *a2;
if ( (unsigned int)*a2 > 0x2F )
{
v8 = (_QWORD *)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v8 + 1;
}
else
{
v8 = (_QWORD *)(*((_QWORD *)a2 + 2) + v7);
*a2 = v7 + 8;
}
result = &t_symbol;
if ( a1 != (_QWORD *)*v8 )
result = &f_symbol;
}
else if ( v5 == (void **)&give_x_symbol )
{
v9 = *a2;
if ( (unsigned int)*a2 > 0x2F )
{
v10 = (const void **)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v10 + 1;
}
else
{
v10 = (const void **)(*((_QWORD *)a2 + 2) + v9);
*a2 = v9 + 8;
}
fprintf(stderr, " %p: give! {event:%p}\n", a1, *v10);
object_call(a1[1], &give_x_symbol);
v11 = object_call(a1[2], &add_symbol);
a1[2] = v11;
fprintf(stderr, " %p: remain=%d\n", a1, *(unsigned int *)(v11 + 8));
result = (void *)a1[2];
}
else
{
result = &undef_object;
if ( v5 == &dispatch_x_symbol )
{
v12 = *a2;
if ( (unsigned int)*a2 > 0x2F )
{
v13 = (__int64 *)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v13 + 1;
}
else
{
v13 = (__int64 *)(*((_QWORD *)a2 + 2) + v12);
*a2 = v12 + 8;
}
v14 = *v13;
fprintf(stderr, " %p: dispatch {count:%d}\n", a1, *(unsigned int *)(*v13 + 8));
while ( (_UNKNOWN *)object_call(v14, &eq_p_symbol) != &t_symbol
&& (_UNKNOWN *)object_call(a1[1], &empty_p_symbol) == &f_symbol )
{
v18 = (_QWORD *)object_call(a1[1], &take_x_symbol);
fprintf(stderr, " %p: event=%p\n", a1, v18);
v19 = object_call(a1[2], &add_symbol);
a1[2] = v19;
fprintf(stderr, " %p: remain=%d\n", a1, *(unsigned int *)(v19 + 8));
v20 = (void *)object_call(v18, &dispatch_x_symbol);
fprintf(stderr, " %p: result=%p\n", a1, v20);
if ( v20 == &t_symbol )
{
for ( i = (void *)v18[4]; i != &nil_object; i = *(void **)(v16 + 16) )
{
v16 = object_call(i, &pop_symbol);
fprintf(stderr, " %p: events=[%p]^%p\n", a1, *(const void **)(v16 + 8), *(const void **)(v16 + 16));
object_call(a1, &give_x_symbol);
}
v17 = (const void *)v18[5];
*(_QWORD *)(v18[1] + 8LL) = v17;
fprintf(stderr, " %p: beh=%p\n", a1, v17);
}
else
{
fprintf(stderr, " %p: event=%p ---ABORTED---", a1, v18);
}
v14 = object_call(v14, &add_symbol);
fprintf(stderr, " %p: count=%d\n", a1, *(unsigned int *)(v14 + 8));
}
result = (void *)a1[2];
}
}
return result;
}

canonical_decompiled_code:
void *__fastcall func4(_QWORD *a1, int *a2)
{
unsigned int v3; // eax
const void **v4; // rdx
void **v5; // r12
void *result; // rax
unsigned int v7; // eax
_QWORD *v8; // rdx
unsigned int v9; // eax
const void **v10; // rdx
__int64 v11; // rax
unsigned int v12; // eax
__int64 *v13; // rdx
__int64 v14; // r13
void *i; // rdi
__int64 v16; // rbp
const void *v17; // rcx
_QWORD *v18; // r12
__int64 v19; // rax
void *v20; // rbp

fprintf(stderr, "%p config_kind {remain:%d}\n", a1, *(unsigned int *)(a1[2] + 8LL));
v3 = *a2;
if ( (unsigned int)*a2 > 0x2F )
{
v4 = (const void **)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v4 + 1;
}
else
{
v4 = (const void **)(*((_QWORD *)a2 + 2) + v3);
*a2 = v3 + 8;
}
v5 = (void **)*v4;
fprintf(stderr, " %p: cmd=%p \"%s\"\n", a1, *v4, *((const char **)*v4 + 1));
if ( v5 == (void **)&eq_p_symbol )
{
v7 = *a2;
if ( (unsigned int)*a2 > 0x2F )
{
v8 = (_QWORD *)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v8 + 1;
}
else
{
v8 = (_QWORD *)(*((_QWORD *)a2 + 2) + v7);
*a2 = v7 + 8;
}
result = &t_symbol;
if ( a1 != (_QWORD *)*v8 )
result = &f_symbol;
}
else if ( v5 == (void **)&give_x_symbol )
{
v9 = *a2;
if ( (unsigned int)*a2 > 0x2F )
{
v10 = (const void **)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v10 + 1;
}
else
{
v10 = (const void **)(*((_QWORD *)a2 + 2) + v9);
*a2 = v9 + 8;
}
fprintf(stderr, " %p: give! {event:%p}\n", a1, *v10);
object_call(a1[1], &give_x_symbol);
v11 = object_call(a1[2], &add_symbol);
a1[2] = v11;
fprintf(stderr, " %p: remain=%d\n", a1, *(unsigned int *)(v11 + 8));
result = (void *)a1[2];
}
else
{
result = &undef_object;
if ( v5 == &dispatch_x_symbol )
{
v12 = *a2;
if ( (unsigned int)*a2 > 0x2F )
{
v13 = (__int64 *)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v13 + 1;
}
else
{
v13 = (__int64 *)(*((_QWORD *)a2 + 2) + v12);
*a2 = v12 + 8;
}
v14 = *v13;
fprintf(stderr, " %p: dispatch {count:%d}\n", a1, *(unsigned int *)(*v13 + 8));
while ( (_UNKNOWN *)object_call(v14, &eq_p_symbol) != &t_symbol
&& (_UNKNOWN *)object_call(a1[1], &empty_p_symbol) == &f_symbol )
{
v18 = (_QWORD *)object_call(a1[1], &take_x_symbol);
fprintf(stderr, " %p: event=%p\n", a1, v18);
v19 = object_call(a1[2], &add_symbol);
a1[2] = v19;
fprintf(stderr, " %p: remain=%d\n", a1, *(unsigned int *)(v19 + 8));
v20 = (void *)object_call(v18, &dispatch_x_symbol);
fprintf(stderr, " %p: result=%p\n", a1, v20);
if ( v20 == &t_symbol )
{
for ( i = (void *)v18[4]; i != &nil_object; i = *(void **)(v16 + 16) )
{
v16 = object_call(i, &pop_symbol);
fprintf(stderr, " %p: events=[%p]^%p\n", a1, *(const void **)(v16 + 8), *(const void **)(v16 + 16));
object_call(a1, &give_x_symbol);
}
v17 = (const void *)v18[5];
*(_QWORD *)(v18[1] + 8LL) = v17;
fprintf(stderr, " %p: beh=%p\n", a1, v17);
}
else
{
fprintf(stderr, " %p: event=%p ---ABORTED---", a1, v18);
}
v14 = object_call(v14, &add_symbol);
fprintf(stderr, " %p: count=%d\n", a1, *(unsigned int *)(v14 + 8));
}
result = (void *)a1[2];
}
}
return result;
}

original_code:
OOP config_kind(OOP self, va_list args)
{
    struct config * this = ((struct config *)(self));
    fprintf(stderr, "%p config_kind {remain:%d}\n", this, ((struct integer *)(this->remain))->n);
    OOP cmd = __builtin_va_arg(args,OOP);
    fprintf(stderr, "  %p: cmd=%p \"%s\"\n", this, cmd, ((struct symbol *)(cmd))->s);
    if (cmd == ((OOP)&eq_p_symbol)) {
        OOP other = __builtin_va_arg(args,OOP);
        if (other == self) {
            return ((OOP)&_t_symbol);
        }
        return ((OOP)&_f_symbol);
    } else if (cmd == ((OOP)&give_x_symbol)) {
        OOP evt = __builtin_va_arg(args,OOP);
        fprintf(stderr, "  %p: give! {event:%p}\n", this, evt);
        object_call(this->events, ((OOP)&give_x_symbol), evt);
        this->remain = object_call(this->remain, ((OOP)&add_symbol), ((OOP)&_1_integer));
        fprintf(stderr, "  %p: remain=%d\n", this, ((struct integer *)(this->remain))->n);
        return this->remain;
    } else if (cmd == ((OOP)&dispatch_x_symbol)) {
        OOP count = __builtin_va_arg(args,OOP);
        fprintf(stderr, "  %p: dispatch {count:%d}\n", this, ((struct integer *)(count))->n);
        while ((object_call(count, ((OOP)&eq_p_symbol), ((OOP)&_0_integer)) != ((OOP)&_t_symbol))
        && (object_call(this->events, ((OOP)&empty_p_symbol)) == ((OOP)&_f_symbol))) {
            OOP evt = object_call(this->events, ((OOP)&take_x_symbol));
            fprintf(stderr, "  %p: event=%p\n", this, evt);
            this->remain = object_call(this->remain, ((OOP)&add_symbol), ((OOP)&minus_1_integer));
            fprintf(stderr, "  %p: remain=%d\n", this, ((struct integer *)(this->remain))->n);
            OOP result = object_call(evt, ((OOP)&dispatch_x_symbol));
            fprintf(stderr, "  %p: result=%p\n", this, result);
            if (((OOP)&_t_symbol) == result) {
                struct event * ep = ((struct event *)(evt));
                OOP events = ep->events;
                while (((OOP)&nil_object) != events) {
                    struct pair * pp = ((struct pair *)(object_call(events, ((OOP)&pop_symbol))));
                    fprintf(stderr, "  %p: events=[%p]^%p\n", this, pp->h, pp->t);
                    object_call(self, ((OOP)&give_x_symbol), pp->h);
                    events = pp->t;
                }
                ((struct actor *)(ep->actor))->beh = ep->beh;
                fprintf(stderr, "  %p: beh=%p\n", this, ep->beh);
            } else {
                fprintf(stderr, "  %p: event=%p ---ABORTED---", this, evt);
            }
            count = object_call(count, ((OOP)&add_symbol), ((OOP)&minus_1_integer));
            fprintf(stderr, "  %p: count=%d\n", this, ((struct integer *)(count))->n);
        }
        return this->remain;
    }
    return ((OOP)&undef_object);
}

canonical_original_code:
struct object *config_kind(struct object *self, __builtin_va_list args)
{
    struct config *this = ((struct config *)(self));
    fprintf(stderr, "%p config_kind {remain:%d}\n", this, ((struct integer *)(this->remain))->n);
    struct object *cmd = __builtin_va_arg(args,OOP);
    fprintf(stderr, "  %p: cmd=%p \"%s\"\n", this, cmd, ((struct symbol *)(cmd))->s);
    if (cmd == ((OOP)&eq_p_symbol)) {
        struct object *other = __builtin_va_arg(args,OOP);
        if (other == self) {
            return ((OOP)&_t_symbol);
        }
        return ((OOP)&_f_symbol);
    } else if (cmd == ((OOP)&give_x_symbol)) {
        struct object *evt = __builtin_va_arg(args,OOP);
        fprintf(stderr, "  %p: give! {event:%p}\n", this, evt);
        object_call(this->events, ((OOP)&give_x_symbol), evt);
        this->remain = object_call(this->remain, ((OOP)&add_symbol), ((OOP)&_1_integer));
        fprintf(stderr, "  %p: remain=%d\n", this, ((struct integer *)(this->remain))->n);
        return this->remain;
    } else if (cmd == ((OOP)&dispatch_x_symbol)) {
        struct object *count = __builtin_va_arg(args,OOP);
        fprintf(stderr, "  %p: dispatch {count:%d}\n", this, ((struct integer *)(count))->n);
        while ((object_call(count, ((OOP)&eq_p_symbol), ((OOP)&_0_integer)) != ((OOP)&_t_symbol))
        && (object_call(this->events, ((OOP)&empty_p_symbol)) == ((OOP)&_f_symbol))) {
            struct object *evt = object_call(this->events, ((OOP)&take_x_symbol));
            fprintf(stderr, "  %p: event=%p\n", this, evt);
            this->remain = object_call(this->remain, ((OOP)&add_symbol), ((OOP)&minus_1_integer));
            fprintf(stderr, "  %p: remain=%d\n", this, ((struct integer *)(this->remain))->n);
            struct object *result = object_call(evt, ((OOP)&dispatch_x_symbol));
            fprintf(stderr, "  %p: result=%p\n", this, result);
            if (((OOP)&_t_symbol) == result) {
                struct event *ep = ((struct event *)(evt));
                struct object *events = ep->events;
                while (((OOP)&nil_object) != events) {
                    struct pair *pp = ((struct pair *)(object_call(events, ((OOP)&pop_symbol))));
                    fprintf(stderr, "  %p: events=[%p]^%p\n", this, pp->h, pp->t);
                    object_call(self, ((OOP)&give_x_symbol), pp->h);
                    events = pp->t;
                }
                ((struct actor *)(ep->actor))->beh = ep->beh;
                fprintf(stderr, "  %p: beh=%p\n", this, ep->beh);
            } else {
                fprintf(stderr, "  %p: event=%p ---ABORTED---", this, evt);
            }
            count = object_call(count, ((OOP)&add_symbol), ((OOP)&minus_1_integer));
            fprintf(stderr, "  %p: count=%d\n", this, ((struct integer *)(count))->n);
        }
        return this->remain;
    }
    return ((OOP)&undef_object);
}

variable_types: struct config { struct object { struct object *(*kind)(struct object *self, __builtin_va_list args); } o; struct object *events; struct object *remain; } *

variable_types: struct event { struct object { struct object *(*kind)(struct object *self, __builtin_va_list args); } o; struct object *actor; struct object *msg; struct object *actors; struct object *events; struct object *beh; } *

variable_types: struct pair { struct object { struct object *(*kind)(struct object *self, __builtin_va_list args); } o; struct object *h; struct object *t; } *

user_defined_types: struct config { struct object o; struct object *events; struct object *remain; }

user_defined_types: struct event { struct object o; struct object *actor; struct object *msg; struct object *actors; struct object *events; struct object *beh; }

user_defined_types: struct pair { struct object o; struct object *h; struct object *t; }

user_defined_types: struct integer { struct object o; int n; }

user_defined_types: struct symbol { struct object o; char *s; }


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

result = object_new(actor_kind, 16LL);
*(_QWORD *)(result + 8) = a1;
return result;
}

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

result = object_new(actor_kind, 16LL);
*(_QWORD *)(result + 8) = a1;
return result;
}

original_code:
OOP
actor_new(OOP beh)
{
    struct actor * this = ((struct actor *)object_new((actor_kind), sizeof(struct actor)));
    this->beh = beh;
    return (OOP)this;
}

canonical_original_code:
struct object *actor_new(struct object *beh)
{
    struct actor *this = ((struct actor *)object_new((actor_kind), sizeof(struct actor)));
    this->beh = beh;
    return (struct object *)this;
}

variable_types:
beh
struct object *


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

result = object_new(event_kind, 48LL);
*(_QWORD *)(result + 8) = a1;
*(_QWORD *)(result + 16) = a2;
return result;
}

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

result = object_new(event_kind, 48LL);
*(_QWORD *)(result + 8) = a1;
*(_QWORD *)(result + 16) = a2;
return result;
}

original_code:
OOP
event_new(OOP actor, OOP msg)
{
    struct event * this = ((struct event *)object_new((event_kind), sizeof(struct event)));
    this->actor = actor;
    this->msg = msg;
    return (OOP)this;
}

canonical_original_code:
struct object *event_new(struct object *actor, struct object *msg)
{
    struct event *this = ((struct event *)object_new((event_kind), sizeof(struct event)));
    this->actor = actor;
    this->msg = msg;
    return (struct object *)this;
}

variable_types:
actor
struct object *

variable_types:
msg
struct object *


decompiled_code:
__int64 __fastcall event_kind(__int64 a1, int *a2)
{
unsigned int v2; // eax
const void **v3; // rdx
void **v4; // r12
void *v5; // r13
unsigned int v7; // eax
_QWORD *v8; // rdx
const void *v9; // rbp
unsigned int v10; // eax
const void **v11; // rdx
__int64 v12; // rbp
unsigned int v13; // eax
__int64 v14; // rdx
const void *v15; // r12
const void **v16; // rdx
__int64 v17; // rbp
const void **v18; // rax
unsigned int v19; // eax
const void **v20; // rdx

fprintf(
stderr,
"%p event_kind {actor:%p, msg:%p}\n",
(const void *)a1,
*(const void **)(a1 + 8),
*(const void **)(a1 + 16));
v2 = *a2;
if ( (unsigned int)*a2 > 0x2F )
{
v3 = (const void **)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v3 + 1;
}
else
{
v3 = (const void **)(*((_QWORD *)a2 + 2) + v2);
*a2 = v2 + 8;
}
v4 = (void **)*v3;
fprintf(stderr, " %p: cmd=%p \"%s\"\n", (const void *)a1, *v3, *((const char **)*v3 + 1));
if ( v4 != (void **)&eq_p_symbol )
{
if ( v4 == &dispatch_x_symbol )
{
v9 = *(const void **)(*(_QWORD *)(a1 + 8) + 8LL);
fprintf(stderr, " %p: dispatch {beh:%p}\n", (const void *)a1, v9);
*(_QWORD *)(a1 + 24) = &nil_object;
*(_QWORD *)(a1 + 32) = &nil_object;
*(_QWORD *)(a1 + 40) = v9;
return object_call(v9, a1);
}
if ( v4 == &create_x_symbol )
{
v10 = *a2;
if ( (unsigned int)*a2 > 0x2F )
{
v11 = (const void **)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v11 + 1;
}
else
{
v11 = (const void **)(*((_QWORD *)a2 + 2) + v10);
*a2 = v10 + 8;
}
v12 = (__int64)*v11;
fprintf(stderr, " %p: create {beh:%p}\n", (const void *)a1, *v11);
v5 = (void *)actor_new(v12);
*(_QWORD *)(a1 + 24) = object_call(*(_QWORD *)(a1 + 24), &push_symbol);
return (__int64)v5;
}
if ( v4 != &send_x_symbol )
{
v5 = &undef_object;
if ( v4 == &become_x_symbol )
{
v19 = *a2;
if ( (unsigned int)*a2 > 0x2F )
{
v20 = (const void **)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v20 + 1;
}
else
{
v20 = (const void **)(*((_QWORD *)a2 + 2) + v19);
*a2 = v19 + 8;
}
v5 = (void *)*v20;
fprintf(stderr, " %p: become {beh:%p}\n", (const void *)a1, *v20);
*(_QWORD *)(a1 + 40) = v5;
}
return (__int64)v5;
}
v13 = *a2;
if ( (unsigned int)*a2 > 0x2F )
{
v18 = (const void **)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v18 + 1;
v15 = *v18;
}
else
{
v14 = *((_QWORD *)a2 + 2);
*a2 = v13 + 8;
v15 = *(const void **)(v14 + v13);
if ( v13 + 8 <= 0x2F )
{
v16 = (const void **)(v13 + 8 + v14);
*a2 = v13 + 16;
LABEL_24:
v17 = (__int64)*v16;
fprintf(stderr, " %p: send {actor:%p, msg:%p}\n", (const void *)a1, v15, *v16);
v5 = (void *)event_new((__int64)v15, v17);
*(_QWORD *)(a1 + 32) = object_call(*(_QWORD *)(a1 + 32), &push_symbol);
return (__int64)v5;
}
}
v16 = (const void **)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v16 + 1;
goto LABEL_24;
}
v7 = *a2;
if ( (unsigned int)*a2 > 0x2F )
{
v8 = (_QWORD *)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v8 + 1;
}
else
{
v8 = (_QWORD *)(*((_QWORD *)a2 + 2) + v7);
*a2 = v7 + 8;
}
v5 = &t_symbol;
if ( a1 != *v8 )
v5 = &f_symbol;
return (__int64)v5;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, int *a2)
{
unsigned int v2; // eax
const void **v3; // rdx
void **v4; // r12
void *v5; // r13
unsigned int v7; // eax
_QWORD *v8; // rdx
const void *v9; // rbp
unsigned int v10; // eax
const void **v11; // rdx
__int64 v12; // rbp
unsigned int v13; // eax
__int64 v14; // rdx
const void *v15; // r12
const void **v16; // rdx
__int64 v17; // rbp
const void **v18; // rax
unsigned int v19; // eax
const void **v20; // rdx

fprintf(
stderr,
"%p event_kind {actor:%p, msg:%p}\n",
(const void *)a1,
*(const void **)(a1 + 8),
*(const void **)(a1 + 16));
v2 = *a2;
if ( (unsigned int)*a2 > 0x2F )
{
v3 = (const void **)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v3 + 1;
}
else
{
v3 = (const void **)(*((_QWORD *)a2 + 2) + v2);
*a2 = v2 + 8;
}
v4 = (void **)*v3;
fprintf(stderr, " %p: cmd=%p \"%s\"\n", (const void *)a1, *v3, *((const char **)*v3 + 1));
if ( v4 != (void **)&eq_p_symbol )
{
if ( v4 == &dispatch_x_symbol )
{
v9 = *(const void **)(*(_QWORD *)(a1 + 8) + 8LL);
fprintf(stderr, " %p: dispatch {beh:%p}\n", (const void *)a1, v9);
*(_QWORD *)(a1 + 24) = &nil_object;
*(_QWORD *)(a1 + 32) = &nil_object;
*(_QWORD *)(a1 + 40) = v9;
return object_call(v9, a1);
}
if ( v4 == &create_x_symbol )
{
v10 = *a2;
if ( (unsigned int)*a2 > 0x2F )
{
v11 = (const void **)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v11 + 1;
}
else
{
v11 = (const void **)(*((_QWORD *)a2 + 2) + v10);
*a2 = v10 + 8;
}
v12 = (__int64)*v11;
fprintf(stderr, " %p: create {beh:%p}\n", (const void *)a1, *v11);
v5 = (void *)func5(v12);
*(_QWORD *)(a1 + 24) = object_call(*(_QWORD *)(a1 + 24), &push_symbol);
return (__int64)v5;
}
if ( v4 != &send_x_symbol )
{
v5 = &undef_object;
if ( v4 == &become_x_symbol )
{
v19 = *a2;
if ( (unsigned int)*a2 > 0x2F )
{
v20 = (const void **)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v20 + 1;
}
else
{
v20 = (const void **)(*((_QWORD *)a2 + 2) + v19);
*a2 = v19 + 8;
}
v5 = (void *)*v20;
fprintf(stderr, " %p: become {beh:%p}\n", (const void *)a1, *v20);
*(_QWORD *)(a1 + 40) = v5;
}
return (__int64)v5;
}
v13 = *a2;
if ( (unsigned int)*a2 > 0x2F )
{
v18 = (const void **)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v18 + 1;
v15 = *v18;
}
else
{
v14 = *((_QWORD *)a2 + 2);
*a2 = v13 + 8;
v15 = *(const void **)(v14 + v13);
if ( v13 + 8 <= 0x2F )
{
v16 = (const void **)(v13 + 8 + v14);
*a2 = v13 + 16;
LABEL_24:
v17 = (__int64)*v16;
fprintf(stderr, " %p: send {actor:%p, msg:%p}\n", (const void *)a1, v15, *v16);
v5 = (void *)func6((__int64)v15, v17);
*(_QWORD *)(a1 + 32) = object_call(*(_QWORD *)(a1 + 32), &push_symbol);
return (__int64)v5;
}
}
v16 = (const void **)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v16 + 1;
goto LABEL_24;
}
v7 = *a2;
if ( (unsigned int)*a2 > 0x2F )
{
v8 = (_QWORD *)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v8 + 1;
}
else
{
v8 = (_QWORD *)(*((_QWORD *)a2 + 2) + v7);
*a2 = v7 + 8;
}
v5 = &t_symbol;
if ( a1 != *v8 )
v5 = &f_symbol;
return (__int64)v5;
}

original_code:
OOP event_kind(OOP self, va_list args)
{
    struct event * this = ((struct event *)(self));
    fprintf(stderr, "%p event_kind {actor:%p, msg:%p}\n", this, this->actor, this->msg);
    OOP cmd = __builtin_va_arg(args,OOP);
    fprintf(stderr, "  %p: cmd=%p \"%s\"\n", this, cmd, ((struct symbol *)(cmd))->s);
    if (cmd == ((OOP)&eq_p_symbol)) {
        OOP other = __builtin_va_arg(args,OOP);
        if (other == self) {
            return ((OOP)&_t_symbol);
        }
        return ((OOP)&_f_symbol);
    } else if (cmd == ((OOP)&dispatch_x_symbol)) {
        OOP beh = ((struct actor *)(this->actor))->beh;
        fprintf(stderr, "  %p: dispatch {beh:%p}\n", this, beh);
        this->actors = ((OOP)&nil_object);
        this->events = ((OOP)&nil_object);
        this->beh = beh;
        return object_call(beh, this);
    } else if (cmd == ((OOP)&create_x_symbol)) {
        OOP beh = __builtin_va_arg(args,OOP);
        fprintf(stderr, "  %p: create {beh:%p}\n", this, beh);
        OOP actor = actor_new(beh);
        this->actors = object_call(this->actors, ((OOP)&push_symbol), actor);
        return actor;
    } else if (cmd == ((OOP)&send_x_symbol)) {
        OOP actor = __builtin_va_arg(args,OOP);
        OOP msg = __builtin_va_arg(args,OOP);
        fprintf(stderr, "  %p: send {actor:%p, msg:%p}\n", this, actor, msg);
        OOP event = event_new(actor, msg);
        this->events = object_call(this->events, ((OOP)&push_symbol), event);
        return event;
    } else if (cmd == ((OOP)&become_x_symbol)) {
        OOP beh = __builtin_va_arg(args,OOP);
        fprintf(stderr, "  %p: become {beh:%p}\n", this, beh);
        this->beh = beh;
        return beh;
    }
    return ((OOP)&undef_object);
}

canonical_original_code:
struct object *event_kind(struct object *self, __builtin_va_list args)
{
    struct event *this = ((struct event *)(self));
    fprintf(stderr, "%p event_kind {actor:%p, msg:%p}\n", this, this->actor, this->msg);
    struct object *cmd = __builtin_va_arg(args,OOP);
    fprintf(stderr, "  %p: cmd=%p \"%s\"\n", this, cmd, ((struct symbol *)(cmd))->s);
    if (cmd == ((OOP)&eq_p_symbol)) {
        struct object *other = __builtin_va_arg(args,OOP);
        if (other == self) {
            return ((OOP)&_t_symbol);
        }
        return ((OOP)&_f_symbol);
    } else if (cmd == ((OOP)&dispatch_x_symbol)) {
        struct object *beh = ((struct actor *)(this->actor))->beh;
        fprintf(stderr, "  %p: dispatch {beh:%p}\n", this, beh);
        this->actors = ((OOP)&nil_object);
        this->events = ((OOP)&nil_object);
        this->beh = beh;
        return object_call(beh, this);
    } else if (cmd == ((OOP)&create_x_symbol)) {
        struct object *beh = __builtin_va_arg(args,OOP);
        fprintf(stderr, "  %p: create {beh:%p}\n", this, beh);
        struct object *actor = actor_new(beh);
        this->actors = object_call(this->actors, ((OOP)&push_symbol), actor);
        return actor;
    } else if (cmd == ((OOP)&send_x_symbol)) {
        struct object *actor = __builtin_va_arg(args,OOP);
        struct object *msg = __builtin_va_arg(args,OOP);
        fprintf(stderr, "  %p: send {actor:%p, msg:%p}\n", this, actor, msg);
        struct object *event = event_new(actor, msg);
        this->events = object_call(this->events, ((OOP)&push_symbol), event);
        return event;
    } else if (cmd == ((OOP)&become_x_symbol)) {
        struct object *beh = __builtin_va_arg(args,OOP);
        fprintf(stderr, "  %p: become {beh:%p}\n", this, beh);
        this->beh = beh;
        return beh;
    }
    return ((OOP)&undef_object);
}


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

result = object_new(forward_beh_kind, 16LL);
*(_QWORD *)(result + 8) = a1;
return result;
}

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

result = object_new(forward_beh_kind, 16LL);
*(_QWORD *)(result + 8) = a1;
return result;
}

original_code:
OOP
forward_beh_new(OOP target)
{
    struct forward_beh * this = ((struct forward_beh *)object_new((forward_beh_kind), sizeof(struct forward_beh)));
    this->target = target;
    return (OOP)this;
}

canonical_original_code:
struct object *forward_beh_new(struct object *target)
{
    struct forward_beh *this = ((struct forward_beh *)object_new((forward_beh_kind), sizeof(struct forward_beh)));
    this->target = target;
    return (struct object *)this;
}

variable_types:
target
struct object *


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

result = object_new(one_shot_beh_kind, 16LL);
*(_QWORD *)(result + 8) = a1;
return result;
}

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

result = object_new(one_shot_beh_kind, 16LL);
*(_QWORD *)(result + 8) = a1;
return result;
}

original_code:
OOP
one_shot_beh_new(OOP target)
{
    struct forward_beh * this = ((struct forward_beh *)object_new((one_shot_beh_kind), sizeof(struct forward_beh)));
    this->target = target;
    return (OOP)this;
}

canonical_original_code:
struct object *one_shot_beh_new(struct object *target)
{
    struct forward_beh *this = ((struct forward_beh *)object_new((one_shot_beh_kind), sizeof(struct forward_beh)));
    this->target = target;
    return (struct object *)this;
}


decompiled_code:
__int64 config_new()
{
__int64 v0; // rbx

v0 = object_new(config_kind, 24LL);
*(_QWORD *)(v0 + 8) = queue_new();
*(_QWORD *)(v0 + 16) = &0_integer;
return v0;
}

canonical_decompiled_code:
__int64 func10()
{
__int64 v0; // rbx

v0 = object_new(config_kind, 24LL);
*(_QWORD *)(v0 + 8) = queue_new();
*(_QWORD *)(v0 + 16) = &0_integer;
return v0;
}

original_code:
OOP
config_new()
{
    struct config * this = ((struct config *)object_new((config_kind), sizeof(struct config)));
    this->events = queue_new();
    this->remain = ((OOP)&_0_integer);
    return (OOP)this;
}

canonical_original_code:
struct object *config_new()
{
    struct config *this = ((struct config *)object_new((config_kind), sizeof(struct config)));
    this->events = queue_new();
    this->remain = ((OOP)&_0_integer);
    return (struct object *)this;
}


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

result = object_new(pair_kind, 24LL);
*(_QWORD *)(result + 8) = a1;
*(_QWORD *)(result + 16) = a2;
return result;
}

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

result = object_new(pair_kind, 24LL);
*(_QWORD *)(result + 8) = a1;
*(_QWORD *)(result + 16) = a2;
return result;
}

original_code:
OOP
pair_new(OOP h, OOP t)
{
    struct pair * this = ((struct pair *)object_new((pair_kind), sizeof(struct pair)));
    this->h = h;
    this->t = t;
    return (OOP)this;
}

canonical_original_code:
struct object *pair_new(struct object *h, struct object *t)
{
    struct pair *this = ((struct pair *)object_new((pair_kind), sizeof(struct pair)));
    this->h = h;
    this->t = t;
    return (struct object *)this;
}

variable_types:
h
struct object *

variable_types:
t
struct object *


decompiled_code:
void *__fastcall nil_kind(__int64 a1, int *a2)
{
unsigned int v2; // eax
__int64 v3; // rcx
unsigned int v4; // er8
void **v5; // rdx
void *result; // rax
void ***v7; // rax
_QWORD *v8; // rcx
unsigned int v9; // eax
__int64 *v10; // rdx

v2 = *a2;
if ( (unsigned int)*a2 > 0x2F )
{
v7 = (void ***)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v7 + 1;
v5 = *v7;
if ( *v7 != (void **)&eq_p_symbol )
{
LABEL_3:
if ( v5 == &empty_p_symbol )
return &t_symbol;
result = &undef_object;
if ( v5 == &push_symbol )
{
v9 = *a2;
if ( (unsigned int)*a2 > 0x2F )
{
v10 = (__int64 *)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v10 + 1;
}
else
{
v10 = (__int64 *)(*((_QWORD *)a2 + 2) + v9);
*a2 = v9 + 8;
}
result = (void *)pair_new(*v10, a1);
}
return result;
}
goto LABEL_7;
}
v3 = *((_QWORD *)a2 + 2);
v4 = v2 + 8;
*a2 = v2 + 8;
v5 = *(void ***)(v3 + v2);
if ( v5 != (void **)&eq_p_symbol )
goto LABEL_3;
if ( v4 > 0x2F )
{
LABEL_7:
v8 = (_QWORD *)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v8 + 1;
goto LABEL_10;
}
v8 = (_QWORD *)(v4 + v3);
*a2 = v2 + 16;
LABEL_10:
result = &t_symbol;
if ( a1 != *v8 )
result = &f_symbol;
return result;
}

canonical_decompiled_code:
void *__fastcall func1(__int64 a1, int *a2)
{
unsigned int v2; // eax
__int64 v3; // rcx
unsigned int v4; // er8
void **v5; // rdx
void *result; // rax
void ***v7; // rax
_QWORD *v8; // rcx
unsigned int v9; // eax
__int64 *v10; // rdx

v2 = *a2;
if ( (unsigned int)*a2 > 0x2F )
{
v7 = (void ***)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v7 + 1;
v5 = *v7;
if ( *v7 != (void **)&eq_p_symbol )
{
LABEL_3:
if ( v5 == &empty_p_symbol )
return &t_symbol;
result = &undef_object;
if ( v5 == &push_symbol )
{
v9 = *a2;
if ( (unsigned int)*a2 > 0x2F )
{
v10 = (__int64 *)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v10 + 1;
}
else
{
v10 = (__int64 *)(*((_QWORD *)a2 + 2) + v9);
*a2 = v9 + 8;
}
result = (void *)func0(*v10, a1);
}
return result;
}
goto LABEL_7;
}
v3 = *((_QWORD *)a2 + 2);
v4 = v2 + 8;
*a2 = v2 + 8;
v5 = *(void ***)(v3 + v2);
if ( v5 != (void **)&eq_p_symbol )
goto LABEL_3;
if ( v4 > 0x2F )
{
LABEL_7:
v8 = (_QWORD *)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v8 + 1;
goto LABEL_10;
}
v8 = (_QWORD *)(v4 + v3);
*a2 = v2 + 16;
LABEL_10:
result = &t_symbol;
if ( a1 != *v8 )
result = &f_symbol;
return result;
}

original_code:
static OOP nil_kind(OOP self, va_list args)
{
    OOP cmd = __builtin_va_arg(args,OOP);
    if (cmd == ((OOP)&eq_p_symbol)) {
        OOP other = __builtin_va_arg(args,OOP);
        if (other == self) {
            return ((OOP)&_t_symbol);
        }
        return ((OOP)&_f_symbol);
    } else if (cmd == ((OOP)&empty_p_symbol)) {
        return ((OOP)&_t_symbol);
    } else if (cmd == ((OOP)&push_symbol)) {
        OOP x = __builtin_va_arg(args,OOP);
        return pair_new(x, self);
    }
    return ((OOP)&undef_object);
}

canonical_original_code:
static struct object *nil_kind(struct object *self, __builtin_va_list args)
{
    struct object *cmd = __builtin_va_arg(args,OOP);
    if (cmd == ((OOP)&eq_p_symbol)) {
        struct object *other = __builtin_va_arg(args,OOP);
        if (other == self) {
            return ((OOP)&_t_symbol);
        }
        return ((OOP)&_f_symbol);
    } else if (cmd == ((OOP)&empty_p_symbol)) {
        return ((OOP)&_t_symbol);
    } else if (cmd == ((OOP)&push_symbol)) {
        struct object *x = __builtin_va_arg(args,OOP);
        return pair_new(x, self);
    }
    return ((OOP)&undef_object);
}


decompiled_code:
void *__fastcall pair_kind(__int64 a1, int *a2)
{
unsigned int v2; // edx
__int64 v3; // rcx
unsigned int v4; // er8
void **v5; // rax
void *v6; // rdx
void **v8; // rax
_QWORD *v9; // rcx
unsigned int v10; // eax
__int64 *v11; // rdx

v2 = *a2;
if ( (unsigned int)*a2 <= 0x2F )
{
v3 = *((_QWORD *)a2 + 2);
v4 = v2 + 8;
*a2 = v2 + 8;
v5 = *(void ***)(v3 + v2);
if ( v5 != (void **)&eq_p_symbol )
goto LABEL_3;
if ( v4 <= 0x2F )
{
v9 = (_QWORD *)(v4 + v3);
*a2 = v2 + 16;
LABEL_11:
v6 = &t_symbol;
if ( a1 != *v9 )
v6 = &f_symbol;
return v6;
}
LABEL_8:
v9 = (_QWORD *)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v9 + 1;
goto LABEL_11;
}
v8 = (void **)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v8 + 1;
v5 = (void **)*v8;
if ( v5 == (void **)&eq_p_symbol )
goto LABEL_8;
LABEL_3:
if ( v5 == &empty_p_symbol )
return &f_symbol;
if ( v5 == &pop_symbol )
return (void *)a1;
v6 = &undef_object;
if ( v5 != &push_symbol )
return v6;
v10 = *a2;
if ( (unsigned int)*a2 > 0x2F )
{
v11 = (__int64 *)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v11 + 1;
}
else
{
v11 = (__int64 *)(*((_QWORD *)a2 + 2) + v10);
*a2 = v10 + 8;
}
return (void *)pair_new(*v11, a1);
}

canonical_decompiled_code:
void *__fastcall func2(__int64 a1, int *a2)
{
unsigned int v2; // edx
__int64 v3; // rcx
unsigned int v4; // er8
void **v5; // rax
void *v6; // rdx
void **v8; // rax
_QWORD *v9; // rcx
unsigned int v10; // eax
__int64 *v11; // rdx

v2 = *a2;
if ( (unsigned int)*a2 <= 0x2F )
{
v3 = *((_QWORD *)a2 + 2);
v4 = v2 + 8;
*a2 = v2 + 8;
v5 = *(void ***)(v3 + v2);
if ( v5 != (void **)&eq_p_symbol )
goto LABEL_3;
if ( v4 <= 0x2F )
{
v9 = (_QWORD *)(v4 + v3);
*a2 = v2 + 16;
LABEL_11:
v6 = &t_symbol;
if ( a1 != *v9 )
v6 = &f_symbol;
return v6;
}
LABEL_8:
v9 = (_QWORD *)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v9 + 1;
goto LABEL_11;
}
v8 = (void **)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v8 + 1;
v5 = (void **)*v8;
if ( v5 == (void **)&eq_p_symbol )
goto LABEL_8;
LABEL_3:
if ( v5 == &empty_p_symbol )
return &f_symbol;
if ( v5 == &pop_symbol )
return (void *)a1;
v6 = &undef_object;
if ( v5 != &push_symbol )
return v6;
v10 = *a2;
if ( (unsigned int)*a2 > 0x2F )
{
v11 = (__int64 *)*((_QWORD *)a2 + 1);
*((_QWORD *)a2 + 1) = v11 + 1;
}
else
{
v11 = (__int64 *)(*((_QWORD *)a2 + 2) + v10);
*a2 = v10 + 8;
}
return (void *)func0(*v11, a1);
}

original_code:
OOP pair_kind(OOP self, va_list args)
{
    OOP cmd = __builtin_va_arg(args,OOP);
    if (cmd == ((OOP)&eq_p_symbol)) {
        OOP other = __builtin_va_arg(args,OOP);
        if (other == self) {
            return ((OOP)&_t_symbol);
        }
        return ((OOP)&_f_symbol);
    } else if (cmd == ((OOP)&empty_p_symbol)) {
        return ((OOP)&_f_symbol);
    } else if (cmd == ((OOP)&pop_symbol)) {
        return self;
    } else if (cmd == ((OOP)&push_symbol)) {
        OOP x = __builtin_va_arg(args,OOP);
        return pair_new(x, self);
    }
    return ((OOP)&undef_object);
}

canonical_original_code:
struct object *pair_kind(struct object *self, __builtin_va_list args)
{
    struct object *cmd = __builtin_va_arg(args,OOP);
    if (cmd == ((OOP)&eq_p_symbol)) {
        struct object *other = __builtin_va_arg(args,OOP);
        if (other == self) {
            return ((OOP)&_t_symbol);
        }
        return ((OOP)&_f_symbol);
    } else if (cmd == ((OOP)&empty_p_symbol)) {
        return ((OOP)&_f_symbol);
    } else if (cmd == ((OOP)&pop_symbol)) {
        return self;
    } else if (cmd == ((OOP)&push_symbol)) {
        struct object *x = __builtin_va_arg(args,OOP);
        return pair_new(x, self);
    }
    return ((OOP)&undef_object);
}


original_code:
OOP queue_kind(OOP self, va_list args)
{
    struct pair * this = ((struct pair *)(self));
    OOP cmd = __builtin_va_arg(args,OOP);
    if (cmd == ((OOP)&eq_p_symbol)) {
        OOP other = __builtin_va_arg(args,OOP);
        if (other == self) {
            return ((OOP)&_t_symbol);
        }
        return ((OOP)&_f_symbol);
    } else if (cmd == ((OOP)&empty_p_symbol)) {
        if (this->h == ((OOP)&nil_object)) {
            return ((OOP)&_t_symbol);
        }
        return ((OOP)&_f_symbol);
    } else if (cmd == ((OOP)&take_x_symbol)) {
        if (this->h != ((OOP)&nil_object)) {
            struct pair * entry = ((struct pair *)(this->h));
            this->h = entry->t;
            OOP item = entry->h;
            return item;
        }
    } else if (cmd == ((OOP)&give_x_symbol)) {
        OOP item = __builtin_va_arg(args,OOP);
        OOP oop = pair_new(item, ((OOP)&nil_object));
        if (this->h == ((OOP)&nil_object)) {
            this->h = oop;
        } else {
            ((struct pair *)(this->t))->t = oop;
        }
        this->t = oop;
        return self;
    }
    return ((OOP)&undef_object);
}

canonical_original_code:
struct object *queue_kind(struct object *self, __builtin_va_list args)
{
    struct pair *this = ((struct pair *)(self));
    struct object *cmd = __builtin_va_arg(args,OOP);
    if (cmd == ((OOP)&eq_p_symbol)) {
        struct object *other = __builtin_va_arg(args,OOP);
        if (other == self) {
            return ((OOP)&_t_symbol);
        }
        return ((OOP)&_f_symbol);
    } else if (cmd == ((OOP)&empty_p_symbol)) {
        if (this->h == ((OOP)&nil_object)) {
            return ((OOP)&_t_symbol);
        }
        return ((OOP)&_f_symbol);
    } else if (cmd == ((OOP)&take_x_symbol)) {
        if (this->h != ((OOP)&nil_object)) {
            struct pair *entry = ((struct pair *)(this->h));
            this->h = entry->t;
            struct object *item = entry->h;
            return item;
        }
    } else if (cmd == ((OOP)&give_x_symbol)) {
        struct object *item = __builtin_va_arg(args,OOP);
        struct object *oop = pair_new(item, ((OOP)&nil_object));
        if (this->h == ((OOP)&nil_object)) {
            this->h = oop;
        } else {
            ((struct pair *)(this->t))->t = oop;
        }
        this->t = oop;
        return self;
    }
    return ((OOP)&undef_object);
}