decompiled_code:
__int64 __fastcall symbol_table_put(char ***a1, const char *a2, __int16 a3)
{
char ***v4; // rbp
char **v5; // rdx
char *v6; // rax
char **v7; // rbx
char **v8; // rax
__int64 result; // rax
size_t v10; // rax
_QWORD *v11; // rbx
char *v12; // rbx
size_t v13; // rax

v4 = a1;
v5 = *a1;
if ( *a1 )
{
v6 = v5[2];
v7 = *a1;
if ( v6 )
{
while ( 1 )
{
v7 = (char **)v6;
v6 = (char *)*((_QWORD *)v6 + 2);
if ( !v6 )
break;
v5 = v7;
}
v4 = (char ***)(v5 + 2);
}
v7[2] = (char *)malloc(0x18uLL);
v4 = (char ***)(*v4 + 2);
if ( !*v4 )
{
perror("malloc'ing space for i->next");
return 1LL;
}
}
else
{
v8 = (char **)malloc(0x18uLL);
*a1 = v8;
if ( !v8 )
{
perror("Error malloc'ing in emptry table");
return 1LL;
}
}
v10 = strlen(a2);
v11 = *v4;
*v11 = malloc(v10);
v12 = **v4;
if ( v12 )
{
v13 = strlen(a2);
strncpy(v12, a2, v13);
*((_WORD *)*v4 + 4) = a3;
(*v4)[2] = 0LL;
result = 0LL;
}
else
{
perror("malloc'ing space for key");
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(char ***a1, const char *a2, __int16 a3)
{
char ***v4; // rbp
char **v5; // rdx
char *v6; // rax
char **v7; // rbx
char **v8; // rax
__int64 result; // rax
size_t v10; // rax
_QWORD *v11; // rbx
char *v12; // rbx
size_t v13; // rax

v4 = a1;
v5 = *a1;
if ( *a1 )
{
v6 = v5[2];
v7 = *a1;
if ( v6 )
{
while ( 1 )
{
v7 = (char **)v6;
v6 = (char *)*((_QWORD *)v6 + 2);
if ( !v6 )
break;
v5 = v7;
}
v4 = (char ***)(v5 + 2);
}
v7[2] = (char *)malloc(0x18uLL);
v4 = (char ***)(*v4 + 2);
if ( !*v4 )
{
perror("malloc'ing space for i->next");
return 1LL;
}
}
else
{
v8 = (char **)malloc(0x18uLL);
*a1 = v8;
if ( !v8 )
{
perror("Error malloc'ing in emptry table");
return 1LL;
}
}
v10 = strlen(a2);
v11 = *v4;
*v11 = malloc(v10);
v12 = **v4;
if ( v12 )
{
v13 = strlen(a2);
strncpy(v12, a2, v13);
*((_WORD *)*v4 + 4) = a3;
(*v4)[2] = 0LL;
result = 0LL;
}
else
{
perror("malloc'ing space for key");
result = 1LL;
}
return result;
}

original_code:
int symbol_table_put(Symbol_Table* table, Key key, Value value) {
 Symbol_Table_Entry **entry_ptr = &(table->head);
 if ((*entry_ptr) == ((void *)0) ) {
  (*entry_ptr) = malloc(sizeof(Symbol_Table_Entry));
  if ((*entry_ptr) == ((void *)0)) {
   perror("Error malloc'ing in emptry table");
   return 1;
  }
 } else {
  while((*entry_ptr)->next != ((void *)0)) {
    entry_ptr = &((*entry_ptr)->next);
  }
  (*entry_ptr)->next = malloc(sizeof(Symbol_Table_Entry));
  if ((*entry_ptr)->next == ((void *)0)) {
   perror("malloc'ing space for i->next");
   return 1;
  }
  entry_ptr = &((*entry_ptr)->next);
 }
 (*entry_ptr)->key = malloc(strlen(key));
 if ((*entry_ptr)->key == ((void *)0)) {
  perror("malloc'ing space for key");
  return 1;
 }
 strncpy((*entry_ptr)->key, key, strlen(key));
 (*entry_ptr)->value = value;
 (*entry_ptr)->next = ((void *)0);
 return 0;
}

canonical_original_code:
int symbol_table_put(struct Symbol_Table *table, char *key, unsigned short value) {
 struct Symbol_Table_Entry **entry_ptr = &(table->head);
 if ((*entry_ptr) == ((void *)0) ) {
  (*entry_ptr) = malloc(sizeof(Symbol_Table_Entry));
  if ((*entry_ptr) == ((void *)0)) {
   perror("Error malloc'ing in emptry table");
   return 1;
  }
 } else {
  while((*entry_ptr)->next != ((void *)0)) {
    entry_ptr = &((*entry_ptr)->next);
  }
  (*entry_ptr)->next = malloc(sizeof(Symbol_Table_Entry));
  if ((*entry_ptr)->next == ((void *)0)) {
   perror("malloc'ing space for i->next");
   return 1;
  }
  entry_ptr = &((*entry_ptr)->next);
 }
 (*entry_ptr)->key = malloc(strlen(key));
 if ((*entry_ptr)->key == ((void *)0)) {
  perror("malloc'ing space for key");
  return 1;
 }
 strncpy((*entry_ptr)->key, key, strlen(key));
 (*entry_ptr)->value = value;
 (*entry_ptr)->next = ((void *)0);
 return 0;
}

variable_types:
key
char *

variable_types:
value
unsigned short

user_defined_types: struct Symbol_Table_Entry { char *key; unsigned short value; struct Symbol_Table_Entry *next; }


repo: mtottenh/IMPS

decompiled_code:
char ***symbol_table_new()
{
char ***v0; // rbx

v0 = (char ***)malloc(8uLL);
symbol_table_put(v0, "halt", 0);
symbol_table_put(v0, "add", 1);
symbol_table_put(v0, "addi", 2);
symbol_table_put(v0, "sub", 3);
symbol_table_put(v0, "subi", 4);
symbol_table_put(v0, "mul", 5);
symbol_table_put(v0, "muli", 6);
symbol_table_put(v0, "lw", 7);
symbol_table_put(v0, "sw", 8);
symbol_table_put(v0, "beq", 9);
symbol_table_put(v0, "bne", 10);
symbol_table_put(v0, "blt", 11);
symbol_table_put(v0, "bgt", 12);
symbol_table_put(v0, "ble", 13);
symbol_table_put(v0, "bge", 14);
symbol_table_put(v0, "jmp", 15);
symbol_table_put(v0, "jr", 16);
symbol_table_put(v0, "jal", 17);
symbol_table_put(v0, "out", 18);
symbol_table_put(v0, ".fill", 19);
symbol_table_put(v0, ".skip", 20);
symbol_table_put(v0, "push", 21);
symbol_table_put(v0, "pop", 22);
symbol_table_put(v0, "call", 23);
symbol_table_put(v0, "ret", 24);
symbol_table_put(v0, "mov", 25);
symbol_table_put(v0, "inc", 26);
return v0;
}

original_code:
Symbol_Table* symbol_table_new(void) {
 Symbol_Table* s = malloc(sizeof(Symbol_Table));
 symbol_table_put(s, "halt", HALT);
 symbol_table_put(s, "add", ADD);
 symbol_table_put(s, "addi", ADDI);
 symbol_table_put(s, "sub", SUB);
 symbol_table_put(s, "subi", SUBI);
 symbol_table_put(s, "mul", MUL);
 symbol_table_put(s, "muli", MULI);
 symbol_table_put(s, "lw", LW);
 symbol_table_put(s, "sw", SW);
 symbol_table_put(s, "beq", BEQ);
 symbol_table_put(s, "bne", BNE);
 symbol_table_put(s, "blt", BLT);
 symbol_table_put(s, "bgt", BGT);
 symbol_table_put(s, "ble", BLE);
 symbol_table_put(s, "bge", BGE);
 symbol_table_put(s, "jmp", JMP);
 symbol_table_put(s, "jr", JR);
 symbol_table_put(s, "jal", JAL);
 symbol_table_put(s, "out", OUT);
 symbol_table_put(s, ".fill", FILL);
 symbol_table_put(s, ".skip", SKIP);
 symbol_table_put(s, "push", PUSH);
 symbol_table_put(s, "pop", POP);
 symbol_table_put(s, "call", CALL);
 symbol_table_put(s, "ret", RET);
 symbol_table_put(s, "mov", MOV);
 symbol_table_put(s, "inc", INC);
 return s;
}

canonical_original_code:
struct Symbol_Table *symbol_table_new() {
 struct Symbol_Table *s = malloc(sizeof(Symbol_Table));
 symbol_table_put(s, "halt", HALT);
 symbol_table_put(s, "add", ADD);
 symbol_table_put(s, "addi", ADDI);
 symbol_table_put(s, "sub", SUB);
 symbol_table_put(s, "subi", SUBI);
 symbol_table_put(s, "mul", MUL);
 symbol_table_put(s, "muli", MULI);
 symbol_table_put(s, "lw", LW);
 symbol_table_put(s, "sw", SW);
 symbol_table_put(s, "beq", BEQ);
 symbol_table_put(s, "bne", BNE);
 symbol_table_put(s, "blt", BLT);
 symbol_table_put(s, "bgt", BGT);
 symbol_table_put(s, "ble", BLE);
 symbol_table_put(s, "bge", BGE);
 symbol_table_put(s, "jmp", JMP);
 symbol_table_put(s, "jr", JR);
 symbol_table_put(s, "jal", JAL);
 symbol_table_put(s, "out", OUT);
 symbol_table_put(s, ".fill", FILL);
 symbol_table_put(s, ".skip", SKIP);
 symbol_table_put(s, "push", PUSH);
 symbol_table_put(s, "pop", POP);
 symbol_table_put(s, "call", CALL);
 symbol_table_put(s, "ret", RET);
 symbol_table_put(s, "mov", MOV);
 symbol_table_put(s, "inc", INC);
 return s;
}

variable_types: struct Symbol_Table { struct Symbol_Table_Entry { char *key; unsigned short value; struct Symbol_Table_Entry *next; } *head; } *

user_defined_types: struct Symbol_Table { struct Symbol_Table_Entry *head; }


decompiled_code:
int __fastcall symbol_table_contains(__int64 *a1, const char *a2)
{
__int64 i; // rbx
int result; // eax

for ( i = *a1; ; i = *(_QWORD *)(i + 16) )
{
result = strcmp(*(const char **)i, a2);
if ( !result )
break;
}
return result;
}

canonical_decompiled_code:
int __fastcall func6(__int64 *a1, const char *a2)
{
__int64 i; // rbx
int result; // eax

for ( i = *a1; ; i = *(_QWORD *)(i + 16) )
{
result = strcmp(*(const char **)i, a2);
if ( !result )
break;
}
return result;
}

original_code:
int symbol_table_contains(Symbol_Table* table, Key key) {
 Symbol_Table_Entry *s = table->head;
 while ((strcmp(s->key, key) != 0) && s != ((void *)0)) {
  s = s->next;
 }
 return s == ((void *)0) ? 1 : 0;
}

canonical_original_code:
int symbol_table_contains(struct Symbol_Table *table, char *key) {
 struct Symbol_Table_Entry *s = table->head;
 while ((strcmp(s->key, key) != 0) && s != ((void *)0)) {
  s = s->next;
 }
 return s == ((void *)0) ? 1 : 0;
}

variable_types: struct Symbol_Table_Entry { char *key; unsigned short value; struct Symbol_Table_Entry *next; } *

return_type: int


decompiled_code:
__int64 __fastcall symbol_table_get(__int64 *a1, const char *a2)
{
__int64 i; // rbx

for ( i = *a1; i; i = *(_QWORD *)(i + 16) )
{
if ( !strcmp(*(const char **)i, a2) )
break;
}
return i;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 *a1, const char *a2)
{
__int64 i; // rbx

for ( i = *a1; i; i = *(_QWORD *)(i + 16) )
{
if ( !strcmp(*(const char **)i, a2) )
break;
}
return i;
}

original_code:
Symbol_Table_Entry* symbol_table_get(Symbol_Table* table, Key key) {
 Symbol_Table_Entry *entry_ptr = table->head;
 while((entry_ptr != ((void *)0)) && (strcmp(entry_ptr->key, key) !=0)) {
  entry_ptr = entry_ptr->next;
 }
 return entry_ptr;
}

canonical_original_code:
struct Symbol_Table_Entry *symbol_table_get(struct Symbol_Table *table, char *key) {
 struct Symbol_Table_Entry *entry_ptr = table->head;
 while((entry_ptr != ((void *)0)) && (strcmp(entry_ptr->key, key) !=0)) {
  entry_ptr = entry_ptr->next;
 }
 return entry_ptr;
}

variable_types: struct Symbol_Table { struct Symbol_Table_Entry *head; } *

return_type: struct Symbol_Table_Entry { char *key; unsigned short value; struct Symbol_Table_Entry *next; } *


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

v2 = symbol_table_get(a1, a2);
v3 = symbol_table_getprev((const char ***)a1, a2);
if ( v3 )
v3[2] = *(const char **)(v2 + 16);
else
*a1 = *(_QWORD *)(v2 + 16);
free(*(void **)v2);
free((void *)v2);
return 0LL;
}

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

v2 = func7(a1, a2);
v3 = func1((const char ***)a1, a2);
if ( v3 )
v3[2] = *(const char **)(v2 + 16);
else
*a1 = *(_QWORD *)(v2 + 16);
free(*(void **)v2);
free((void *)v2);
return 0LL;
}

original_code:
int symbol_table_remove(Symbol_Table* table, Key key) {
 Symbol_Table_Entry *current = symbol_table_get(table,key);
 Symbol_Table_Entry *prev = symbol_table_getprev(table,key);
 if (prev == ((void *)0)) {
  table->head = current->next;
 } else {
  prev->next = current->next;
 }
 free(current->key);
 free(current);
 current = ((void *)0);
 return 0;
}

canonical_original_code:
int symbol_table_remove(struct Symbol_Table *table, char *key) {
 struct Symbol_Table_Entry *current = symbol_table_get(table,key);
 struct Symbol_Table_Entry *prev = symbol_table_getprev(table,key);
 if (prev == ((void *)0)) {
  table->head = current->next;
 } else {
  prev->next = current->next;
 }
 free(current->key);
 free(current);
 current = ((void *)0);
 return 0;
}


decompiled_code:
int __fastcall symbol_table_print(__int64 *a1)
{
__int64 i; // rbx
int result; // eax

if ( !a1 )
return fwrite("Erorr: Not a valid symbol table,please call symbol_table_new()\n", 1uLL, 0x3FuLL, stderr);
for ( i = *a1; i; i = *(_QWORD *)(i + 16) )
result = printf("Key: %s\t Value: %d\n", *(const char **)i, *(unsigned __int16 *)(i + 8));
return result;
}

canonical_decompiled_code:
int __fastcall func9(__int64 *a1)
{
__int64 i; // rbx
int result; // eax

if ( !a1 )
return fwrite("Erorr: Not a valid symbol table,please call symbol_table_new()\n", 1uLL, 0x3FuLL, stderr);
for ( i = *a1; i; i = *(_QWORD *)(i + 16) )
result = printf("Key: %s\t Value: %d\n", *(const char **)i, *(unsigned __int16 *)(i + 8));
return result;
}

original_code:
void symbol_table_print(Symbol_Table* table) {
 if (table == ((void *)0)) {
  fprintf(stderr,"Erorr: Not a valid symbol table,"
    "please call symbol_table_new()\n");
  return;
 }
 Symbol_Table_Entry *entry_ptr = table->head;
 for ( ; entry_ptr != ((void *)0); entry_ptr = entry_ptr->next) {
  printf("Key: %s\t Value: %d\n",
   entry_ptr->key, entry_ptr->value);
 }
}

canonical_original_code:
void symbol_table_print(struct Symbol_Table *table) {
 if (table == ((void *)0)) {
  fprintf(stderr,"Erorr: Not a valid symbol table,"
    "please call symbol_table_new()\n");
  return;
 }
 struct Symbol_Table_Entry *entry_ptr = table->head;
 for ( ; entry_ptr != ((void *)0); entry_ptr = entry_ptr->next) {
  printf("Key: %s\t Value: %d\n",
   entry_ptr->key, entry_ptr->value);
 }
}

return_type: void


decompiled_code:
__int64 assemble_halt()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func0()
{
return 0LL;
}

original_code:
uint32_t assemble_halt(Instruction instruction) {
 return 0;
}

canonical_original_code:
unsigned int assemble_halt(struct Instruction instruction) {
 return 0;
}

variable_types: struct Instruction { unsigned int opcode; char *operand1; char *operand2; char *operand3; struct Symbol_Table { struct Symbol_Table_Entry { char *key; unsigned short value; struct Symbol_Table_Entry *next; } *head; } *table; unsigned short *address; }

return_type: unsigned int

user_defined_types: struct Instruction { unsigned int opcode; char *operand1; char *operand2; char *operand3; struct Symbol_Table *table; unsigned short *address; }


decompiled_code:
int __fastcall assemble_fill(int a1, int a2, int a3, int a4, int a5, int a6, int a7, char *nptr)
{
return atoi(nptr);
}

canonical_decompiled_code:
int __fastcall func1(int a1, int a2, int a3, int a4, int a5, int a6, int a7, char *nptr)
{
return atoi(nptr);
}

original_code:
uint32_t assemble_fill(Instruction instruction) {
 return (uint32_t) atoi(instruction.operand1);
}

canonical_original_code:
unsigned int assemble_fill(struct Instruction instruction) {
 return (unsigned int) atoi(instruction.operand1);
}


decompiled_code:
__int64 __fastcall assemble_skip(int a1, int a2, int a3, int a4, int a5, int a6, int a7, char *nptr, int a9, int a10, int a11, __int64 a12)
{
int v12; // eax
int v13; // edx
int i; // eax
__int16 v15; // si

v12 = atoi(nptr);
if ( v12 > 0 )
{
v13 = v12;
for ( i = 0; i != v13; ++i )
v15 = *(_WORD *)a12 + 1 + i;
*(_WORD *)a12 = v15;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1, int a2, int a3, int a4, int a5, int a6, int a7, char *nptr, int a9, int a10, int a11, __int64 a12)
{
int v12; // eax
int v13; // edx
int i; // eax
__int16 v15; // si

v12 = atoi(nptr);
if ( v12 > 0 )
{
v13 = v12;
for ( i = 0; i != v13; ++i )
v15 = *(_WORD *)a12 + 1 + i;
*(_WORD *)a12 = v15;
}
return 0LL;
}

original_code:
uint32_t assemble_skip(Instruction instruction) {
 int num_reserve = atoi(instruction.operand1);
 for(int i = 0; i < num_reserve; i++) {
  *(instruction.address) += 1;
 }
 return 0;
}

canonical_original_code:
unsigned int assemble_skip(struct Instruction instruction) {
 int num_reserve = atoi(instruction.operand1);
 for(int i = 0; i < num_reserve; i++) {
  *(instruction.address) += 1;
 }
 return 0;
}

variable_types: i int


decompiled_code:
__int64 __fastcall eval_immediate(char *nptr, __int64 a2)
{
__int64 result; // rax

result = 0LL;
if ( nptr )
{
result = symbol_table_get(a2, nptr);
if ( result )
LOWORD(result) = *(_WORD *)(result + 8);
else
LOWORD(result) = strtol(nptr, 0LL, 0);
result = (unsigned __int16)result;
}
return result;
}

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

result = 0LL;
if ( nptr )
{
result = symbol_table_get(a2, nptr);
if ( result )
LOWORD(result) = *(_WORD *)(result + 8);
else
LOWORD(result) = strtol(nptr, 0LL, 0);
result = (unsigned __int16)result;
}
return result;
}

original_code:
uint32_t eval_immediate(char* immediate, Symbol_Table* table) {
 uint32_t result = 0;
 if (immediate == ((void *)0)) {
  return result;
 }
 Symbol_Table_Entry* label_entry = symbol_table_get(table, immediate);
 if (label_entry != ((void *)0)) {
  result = (uint32_t) label_entry->value;
 } else {
  result = (uint32_t) strtol(immediate, ((void *)0), 0);
 }
 result &= 0xFFFF;
 return result;
}

canonical_original_code:
unsigned int eval_immediate(char *immediate, struct Symbol_Table *table) {
 unsigned int result = 0;
 if (immediate == ((void *)0)) {
  return result;
 }
 struct Symbol_Table_Entry *label_entry = symbol_table_get(table, immediate);
 if (label_entry != ((void *)0)) {
  result = (unsigned int) label_entry->value;
 } else {
  result = (unsigned int) strtol(immediate, ((void *)0), 0);
 }
 result &= 0xFFFF;
 return result;
}

variable_types:
immediate
char *

variable_types:
result
unsigned int


decompiled_code:
__int64 __fastcall assemble_jtype(int a1, int a2, int a3, int a4, int a5, int a6, int a7, char *nptr, int a9, int a10, __int64 a11)
{
return (a7 << 26) | (unsigned int)eval_immediate(nptr, a11);
}

canonical_decompiled_code:
__int64 __fastcall func6(int a1, int a2, int a3, int a4, int a5, int a6, int a7, char *nptr, int a9, int a10, __int64 a11)
{
return (a7 << 26) | (unsigned int)func5(nptr, a11);
}

original_code:
uint32_t assemble_jtype(Instruction instruction) {
 uint32_t result = instruction.opcode << (32 - 6);
 result |= eval_immediate(instruction.operand1, instruction.table);
 return result;
}

canonical_original_code:
unsigned int assemble_jtype(struct Instruction instruction) {
 unsigned int result = instruction.opcode << (32 - 6);
 result |= eval_immediate(instruction.operand1, instruction.table);
 return result;
}


decompiled_code:
int __fastcall eval_register(__int64 a1)
{
return atoi((const char *)(a1 + 1));
}

canonical_decompiled_code:
int __fastcall func7(__int64 a1)
{
return atoi((const char *)(a1 + 1));
}

original_code:
uint32_t eval_register(char* regstring) {
 regstring++;
  return (uint32_t) atoi(regstring);
}

canonical_original_code:
unsigned int eval_register(char *regstring) {
 regstring++;
  return (unsigned int) atoi(regstring);
}

variable_types:
regstring
char *


original_code:
uint32_t assemble_rtype(Instruction instruction) {
 int shift = 32;
 uint32_t result = instruction.opcode << (shift -= 6);
 if (instruction.operand1 != ((void *)0)) {
  result |= (eval_register(instruction.operand1)
    << (shift -= 5));
 }
 if (instruction.operand2 != ((void *)0)) {
  result |= (eval_register(instruction.operand2)
    << (shift -= 5));
 }
 if (instruction.operand3 != ((void *)0)) {
  result |= (eval_register(instruction.operand3)
    << (shift -= 5));
 }
 return result;
}

canonical_original_code:
unsigned int assemble_rtype(struct Instruction instruction) {
 int shift = 32;
 unsigned int result = instruction.opcode << (shift -= 6);
 if (instruction.operand1 != ((void *)0)) {
  result |= (eval_register(instruction.operand1)
    << (shift -= 5));
 }
 if (instruction.operand2 != ((void *)0)) {
  result |= (eval_register(instruction.operand2)
    << (shift -= 5));
 }
 if (instruction.operand3 != ((void *)0)) {
  result |= (eval_register(instruction.operand3)
    << (shift -= 5));
 }
 return result;
}

variable_types: shift int


decompiled_code:
int __fastcall eval_stype(__int64 a1, char *a2, _DWORD *a3)
{
if ( !a2 )
return 0;
if ( *a2 == 36 )
return eval_register((__int64)a2);
*a3 |= 1u;
return eval_immediate(a2, a1);
}

canonical_decompiled_code:
int __fastcall func9(__int64 a1, char *a2, _DWORD *a3)
{
if ( !a2 )
return 0;
if ( *a2 == 36 )
return func7((__int64)a2);
*a3 |= 1u;
return func5(a2, a1);
}

original_code:
uint32_t eval_stype(Symbol_Table* table, char* operand, uint32_t* flags) {
 if (operand == ((void *)0)) {
  return 0;
 }
 else if (operand[0] == '$') {
  return eval_register(operand);
 }
 else {
  *flags |= 0x1;
  return eval_immediate(operand, table);
 }
}

canonical_original_code:
unsigned int eval_stype(struct Symbol_Table *table, char *operand, unsigned int *flags) {
 if (operand == ((void *)0)) {
  return 0;
 }
 else if (operand[0] == '$') {
  return eval_register(operand);
 }
 else {
  *flags |= 0x1;
  return eval_immediate(operand, table);
 }
}

variable_types:
operand
char *

variable_types:
flags
unsigned int *


decompiled_code:
__int64 __fastcall assemble_stype(int a1, int a2, int a3, int a4, int a5, int a6, int a7, char *s, int a9, int a10, __int64 a11)
{
char *v11; // rbx
int v12; // eax
int v14[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v14[0] = 0;
v11 = s;
if ( s && *s == 91 && s[strlen(s) - 1] == 93 )
{
v14[0] = 2;
s[strlen(s + 1)] = 0;
v11 = s + 1;
}
v12 = eval_stype(a11, v11, v14);
return v12 | (unsigned int)(a7 << 26) | (v14[0] << 24);
}

original_code:
uint32_t assemble_stype(Instruction instruction) {
 int shift = 32;
 uint32_t result = instruction.opcode << (shift -= 6);
 uint32_t flags = 0x0;
 char* operand1 = instruction.operand1;
 if (operand1 != ((void *)0) && operand1[0] == '['
   && operand1[strlen(operand1) - 1] == ']') {
  flags |= 0x2;
  operand1++;
  operand1[strlen(operand1) - 1] = '\0';
 }
 uint32_t operand_value = eval_stype(instruction.table, operand1,
       &flags);
 result |= flags << (shift -= 2);
 result |= operand_value;
 return result;
}

canonical_original_code:
unsigned int assemble_stype(struct Instruction instruction) {
 int shift = 32;
 unsigned int result = instruction.opcode << (shift -= 6);
 unsigned int flags = 0x0;
 char *operand1 = instruction.operand1;
 if (operand1 != ((void *)0) && operand1[0] == '['
   && operand1[strlen(operand1) - 1] == ']') {
  flags |= 0x2;
  operand1++;
  operand1[strlen(operand1) - 1] = '\0';
 }
 unsigned int operand_value = eval_stype(instruction.table, operand1,
       &flags);
 result |= flags << (shift -= 2);
 result |= operand_value;
 return result;
}

variable_types:
flags
unsigned int


decompiled_code:
__int64 __fastcall assemble_branch(int a1, int a2, int a3, int a4, int a5, int a6, int a7, __int64 a8, __int64 a9, char *nptr, __int64 a11, __int64 a12)
{
int v12; // ebp
int v13; // ebx

v12 = eval_register(a8);
v13 = (eval_register(a9) << 16) | (v12 << 21) | (a7 << 26);
return v13 | (unsigned int)(unsigned __int16)((int)eval_immediate(nptr, a11) / 4 - *(_WORD *)a12);
}

canonical_decompiled_code:
__int64 __fastcall func11(int a1, int a2, int a3, int a4, int a5, int a6, int a7, __int64 a8, __int64 a9, char *nptr, __int64 a11, __int64 a12)
{
int v12; // ebp
int v13; // ebx

v12 = func7(a8);
v13 = (func7(a9) << 16) | (v12 << 21) | (a7 << 26);
return v13 | (unsigned int)(unsigned __int16)((int)func5(nptr, a11) / 4 - *(_WORD *)a12);
}

original_code:
uint32_t assemble_branch(Instruction instruction) {
 int shift = 32;
 uint32_t result = instruction.opcode << (shift -= 6);
 result |= (eval_register(instruction.operand1) << (shift -= 5));
 result |= (eval_register(instruction.operand2) << (shift -= 5));
 int32_t offset = eval_immediate(instruction.operand3,
     instruction.table);
 offset /= 32 / 8;
 offset -= *(instruction.address);
 offset &= 0xFFFF;
 result |= offset;
 return result;
}

canonical_original_code:
unsigned int assemble_branch(struct Instruction instruction) {
 int shift = 32;
 unsigned int result = instruction.opcode << (shift -= 6);
 result |= (eval_register(instruction.operand1) << (shift -= 5));
 result |= (eval_register(instruction.operand2) << (shift -= 5));
 int offset = eval_immediate(instruction.operand3,
     instruction.table);
 offset /= 32 / 8;
 offset -= *(instruction.address);
 offset &= 0xFFFF;
 result |= offset;
 return result;
}

variable_types: offset int


decompiled_code:
__int64 __fastcall assemble_itype(int a1, int a2, int a3, int a4, int a5, int a6, int a7, __int64 a8, __int64 a9, char *nptr, __int64 a11, __int64 a12)
{
int v12; // er12
int v13; // ebp

if ( (unsigned int)(a7 - 9) <= 5 )
return assemble_branch(a1, a2, a3, a4, a5, a6, a7, a8, a9, nptr, a11, a12);
v12 = eval_register(a8);
v13 = eval_register(a9);
return (v12 << 21) | (unsigned int)eval_immediate(nptr, a11) | (a7 << 26) | (v13 << 16);
}

canonical_decompiled_code:
__int64 __fastcall func12(int a1, int a2, int a3, int a4, int a5, int a6, int a7, __int64 a8, __int64 a9, char *nptr, __int64 a11, __int64 a12)
{
int v12; // er12
int v13; // ebp

if ( (unsigned int)(a7 - 9) <= 5 )
return func11(a1, a2, a3, a4, a5, a6, a7, a8, a9, nptr, a11, a12);
v12 = func7(a8);
v13 = func7(a9);
return (v12 << 21) | (unsigned int)func5(nptr, a11) | (a7 << 26) | (v13 << 16);
}

original_code:
uint32_t assemble_itype(Instruction instruction) {
 if (instruction.opcode >= 9
  && instruction.opcode <= 14) {
  return assemble_branch(instruction);
 }
 int shift = 32;
 uint32_t result = instruction.opcode << (shift -= 6);
 result |= (eval_register(instruction.operand1) << (shift -= 5));
 result |= (eval_register(instruction.operand2) << (shift -= 5));
 result |= eval_immediate(instruction.operand3, instruction.table);
 return result;
}

canonical_original_code:
unsigned int assemble_itype(struct Instruction instruction) {
 if (instruction.opcode >= 9
  && instruction.opcode <= 14) {
  return assemble_branch(instruction);
 }
 int shift = 32;
 unsigned int result = instruction.opcode << (shift -= 6);
 result |= (eval_register(instruction.operand1) << (shift -= 5));
 result |= (eval_register(instruction.operand2) << (shift -= 5));
 result |= eval_immediate(instruction.operand3, instruction.table);
 return result;
}


decompiled_code:
_BOOL8 __fastcall is_valid_opcode(unsigned __int8 a1)
{
return a1 <= 0x1Au;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(unsigned __int8 a1)
{
return a1 <= 0x1Au;
}

original_code:
int is_valid_opcode(uint8_t opcode) {
 return opcode < 27;
}

canonical_original_code:
int is_valid_opcode(unsigned char opcode) {
 return opcode < 27;
}

variable_types:
opcode
unsigned char


decompiled_code:
__int64 __fastcall check_mem_access(unsigned int a1)
{
__int64 result; // rax

result = 0LL;
if ( a1 > 0xFFFC )
{
fprintf(stderr, "*** Cannot access memory location '%d'.\n", a1);
result = 1LL;
}
return result;
}

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

result = 0LL;
if ( a1 > 0xFFFC )
{
fprintf(stderr, "*** Cannot access memory location '%d'.\n", a1);
result = 1LL;
}
return result;
}

original_code:
int check_mem_access(int location) {
 if (location < 0 || location > 65536 - 4) {
  fprintf(stderr, "*** Cannot access memory "
   "location '%d'.\n", location);
  return 1;
 }
 return 0;
}

variable_types: location int


decompiled_code:
__int64 __fastcall check_address(unsigned int a1)
{
__int64 result; // rax

result = 0LL;
if ( a1 > 0x7FFFF )
{
fprintf(stderr, "*** Cannot access memory address '%u'. \n", a1);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1)
{
__int64 result; // rax

result = 0LL;
if ( a1 > 0x7FFFF )
{
fprintf(stderr, "*** Cannot access memory address '%u'. \n", a1);
result = 1LL;
}
return result;
}

original_code:
int check_address(uint32_t address) {
 if(address >= (8 * 65536)) {
  fprintf(stderr, "*** Cannot access memory "
   "address '%u'. \n", address);
  return 1;
 }
 return 0;
}

canonical_original_code:
int check_address(unsigned int address) {
 if(address >= (8 * 65536)) {
  fprintf(stderr, "*** Cannot access memory "
   "address '%u'. \n", address);
  return 1;
 }
 return 0;
}

variable_types:
address
unsigned int


extract

decompiled_code:
__int64 __fastcall extract(int a1, char a2, char a3)
{
int v3; // ecx
int v4; // eax
int v5; // esi
unsigned int v6; // eax

v3 = (unsigned __int8)(31 - a3);
v4 = (unsigned __int8)(31 - a2);
if ( v3 > v4 )
{
v6 = 0;
}
else
{
v5 = v4 + 1;
v6 = 0;
do
v6 += 1 << v3++;
while ( v3 != v5 );
}
return (a1 & v6) >> (31 - a3);
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1, char a2, char a3)
{
int v3; // ecx
int v4; // eax
int v5; // esi
unsigned int v6; // eax

v3 = (unsigned __int8)(31 - a3);
v4 = (unsigned __int8)(31 - a2);
if ( v3 > v4 )
{
v6 = 0;
}
else
{
v5 = v4 + 1;
v6 = 0;
do
v6 += 1 << v3++;
while ( v3 != v5 );
}
return (a1 & v6) >> (31 - a3);
}

original_code:
uint32_t extract(uint32_t instruction, uint8_t start, uint8_t end) {
 uint32_t mask = 0;
 start = 31 - start;
 end = 31 - end;
 for (int i = end; i <= start; i++) {
  mask += (1 << i);
 }
 return (mask & instruction) >> end;
}

canonical_original_code:
unsigned int extract(unsigned int instruction, unsigned char start, unsigned char end) {
 unsigned int mask = 0;
 start = 31 - start;
 end = 31 - end;
 for (int i = end; i <= start; i++) {
  mask += (1 << i);
 }
 return (mask & instruction) >> end;
}

variable_types:
instruction
unsigned int

variable_types:
start
unsigned char

variable_types:
end
unsigned char

variable_types:
mask
unsigned int


decompiled_code:
__int64 __fastcall extract_opcode(int a1)
{
return extract(a1, 0, 5);
}

canonical_decompiled_code:
__int64 __fastcall func4(int a1)
{
return func3(a1, 0, 5);
}

original_code:
uint8_t extract_opcode(uint32_t instruction) {
 uint8_t opcode = (uint8_t)extract(instruction, START_OPCODE, END_OPCODE);
 return opcode;
}

canonical_original_code:
unsigned char extract_opcode(unsigned int instruction) {
 unsigned char opcode = (uint8_t)extract(instruction, START_OPCODE, END_OPCODE);
 return opcode;
}

return_type: unsigned char


decompiled_code:
__int64 __fastcall extract_address(int a1)
{
return extract(a1, 6, 31);
}

canonical_decompiled_code:
__int64 __fastcall func5(int a1)
{
return func3(a1, 6, 31);
}

original_code:
uint32_t extract_address(uint32_t instruction) {
 return extract(instruction, (END_OPCODE + 1), 31);
}

canonical_original_code:
unsigned int extract_address(unsigned int instruction) {
 return extract(instruction, (END_OPCODE + 1), 31);
}


decompiled_code:
unsigned __int64 __fastcall extract_r(int a1)
{
unsigned __int16 v2; // [rsp+Dh] [rbp-1Bh]

LOBYTE(v2) = extract(a1, 6, 10);
HIBYTE(v2) = extract(a1, 11, 15);
return v2 | ((unsigned __int64)(unsigned __int8)extract(a1, 16, 20) << 16);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func6(int a1)
{
unsigned __int16 v2; // [rsp+Dh] [rbp-1Bh]

LOBYTE(v2) = func3(a1, 6, 10);
HIBYTE(v2) = func3(a1, 11, 15);
return v2 | ((unsigned __int64)(unsigned __int8)func3(a1, 16, 20) << 16);
}

original_code:
OperandsR extract_r(uint32_t instruction) {
 OperandsR operands;
 uint8_t r1_start = END_OPCODE + 1;
 uint8_t r2_start = r1_start + REG_WIDTH;
 uint8_t r3_start = r2_start + REG_WIDTH;
 operands.r1 = extract(instruction, r1_start, r2_start - 1);
 operands.r2 = extract(instruction, r2_start, r3_start - 1);
 operands.r3 = extract(instruction, r3_start, r3_start + REG_WIDTH - 1);
 return operands;
}

canonical_original_code:
struct OperandsR extract_r(unsigned int instruction) {
 struct OperandsR operands;
 unsigned char r1_start = END_OPCODE + 1;
 unsigned char r2_start = r1_start + REG_WIDTH;
 unsigned char r3_start = r2_start + REG_WIDTH;
 operands.r1 = extract(instruction, r1_start, r2_start - 1);
 operands.r2 = extract(instruction, r2_start, r3_start - 1);
 operands.r3 = extract(instruction, r3_start, r3_start + REG_WIDTH - 1);
 return operands;
}

variable_types: struct OperandsR { unsigned char r1; unsigned char r2; unsigned char r3; }


decompiled_code:
__int64 __fastcall extract_i(int a1)
{
char v1; // r12
char v2; // bp
int v3; // edx
unsigned __int16 v4; // ax

v1 = extract(a1, 6, 10);
v2 = extract(a1, 11, 15);
v3 = extract(a1, 16, 31);
LOBYTE(v4) = v1;
HIBYTE(v4) = v2;
return (v3 << 16) | (unsigned int)v4;
}

canonical_decompiled_code:
__int64 __fastcall func7(int a1)
{
char v1; // r12
char v2; // bp
int v3; // edx
unsigned __int16 v4; // ax

v1 = func3(a1, 6, 10);
v2 = func3(a1, 11, 15);
v3 = func3(a1, 16, 31);
LOBYTE(v4) = v1;
HIBYTE(v4) = v2;
return (v3 << 16) | (unsigned int)v4;
}

original_code:
OperandsI extract_i(uint32_t instruction) {
 OperandsI operands;
 uint8_t r1_start = END_OPCODE + 1;
 uint8_t r2_start = r1_start + REG_WIDTH;
 uint8_t immediate_start = r2_start + REG_WIDTH;
 operands.r1 = extract(instruction, r1_start, r2_start - 1);
 operands.r2 = extract(instruction, r2_start, immediate_start - 1 );
 operands.immediate = (int16_t)extract(instruction, immediate_start,
   31);
 return operands;
}

canonical_original_code:
struct OperandsI extract_i(unsigned int instruction) {
 struct OperandsI operands;
 unsigned char r1_start = END_OPCODE + 1;
 unsigned char r2_start = r1_start + REG_WIDTH;
 unsigned char immediate_start = r2_start + REG_WIDTH;
 operands.r1 = extract(instruction, r1_start, r2_start - 1);
 operands.r2 = extract(instruction, r2_start, immediate_start - 1 );
 operands.immediate = (short)extract(instruction, immediate_start,
   31);
 return operands;
}

variable_types: struct OperandsI { unsigned char r1; unsigned char r2; short immediate; }


decompiled_code:
__int64 __fastcall stack_dump(__int64 a1)
{
unsigned int v1; // ebx
__int64 result; // rax

if ( *(_WORD *)(a1 + 2) != 0xFFFF )
{
v1 = 0xFFFF;
do
{
fprintf(stderr, "Stack Address [%d] : %d\t", v1 - 0x10000, *(unsigned int *)(a1 + v1 + 8));
v1 -= 4;
result = *(unsigned __int16 *)(a1 + 2);
}
while ( (unsigned int)result < v1 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
unsigned int v1; // ebx
__int64 result; // rax

if ( *(_WORD *)(a1 + 2) != 0xFFFF )
{
v1 = 0xFFFF;
do
{
fprintf(stderr, "Stack Address [%d] : %d\t", v1 - 0x10000, *(unsigned int *)(a1 + v1 + 8));
v1 -= 4;
result = *(unsigned __int16 *)(a1 + 2);
}
while ( (unsigned int)result < v1 );
}
return result;
}

original_code:
static void stack_dump(State* machine_state) {
 for (uint32_t i = 65536 - 1; i > machine_state->sp; i -= 4) {
  uint32_t *stackelem = (uint32_t *)&machine_state->mem[i];
  fprintf(stderr, "Stack Address [%d] : %d\t",
     (i - 65536), *stackelem);
  if (i % 2 == 0) {
   fprintf(stderr,"\n");
  }
 }
}

canonical_original_code:
static void stack_dump(struct State *machine_state) {
 for (unsigned int i = 65536 - 1; i > machine_state->sp; i -= 4) {
  unsigned int *stackelem = (uint32_t *)&machine_state->mem[i];
  fprintf(stderr, "Stack Address [%d] : %d\t",
     (i - 65536), *stackelem);
  if (i % 2 == 0) {
   fprintf(stderr,"\n");
  }
 }
}

variable_types: struct State { unsigned short pc; unsigned short sp; unsigned short stack_size; unsigned short stack_boundary; unsigned char mem[65536]; unsigned int reg[32]; } *

variable_types:
i
unsigned int

variable_types:
stackelem
unsigned int *


decompiled_code:
int __fastcall halt_instruction(__int64 a1, unsigned __int16 *a2)
{
__int64 v2; // rbx
int v3; // ebp

fprintf(stderr, " PC: 0x%x\t", *a2);
v2 = 0LL;
v3 = 1;
do
{
fprintf(stderr, "R%02d: 0x%x", (unsigned int)v2, *(unsigned int *)&a2[2 * v2 + 32772]);
if ( (unsigned __int8)++v3 <= 3u )
{
fputc(9, stderr);
}
else
{
fputc(10, stderr);
v3 = 0;
}
++v2;
}
while ( v2 != 32 );
return fputc(10, stderr);
}

canonical_decompiled_code:
int __fastcall func2(__int64 a1, unsigned __int16 *a2)
{
__int64 v2; // rbx
int v3; // ebp

fprintf(stderr, " PC: 0x%x\t", *a2);
v2 = 0LL;
v3 = 1;
do
{
fprintf(stderr, "R%02d: 0x%x", (unsigned int)v2, *(unsigned int *)&a2[2 * v2 + 32772]);
if ( (unsigned __int8)++v3 <= 3u )
{
fputc(9, stderr);
}
else
{
fputc(10, stderr);
v3 = 0;
}
++v2;
}
while ( v2 != 32 );
return fputc(10, stderr);
}

original_code:
void halt_instruction(uint32_t instruction, State *machine_state) {
        fprintf(stderr, " PC: 0x%x\t", machine_state->pc);
 uint8_t num_cols = 1;
        for(int i = 0; i < 32; i++) {
                fprintf(stderr, "R%02d: 0x%x", i, machine_state->reg[i]);
  num_cols++;
  if (num_cols >= 4) {
   fprintf(stderr, "\n");
   num_cols = 0;
  }
  else {
   fprintf(stderr, "\t");
  }
        }
 fprintf(stderr, "\n");
}

canonical_original_code:
void halt_instruction(unsigned int instruction, struct State *machine_state) {
        fprintf(stderr, " PC: 0x%x\t", machine_state->pc);
 unsigned char num_cols = 1;
        for(int i = 0; i < 32; i++) {
                fprintf(stderr, "R%02d: 0x%x", i, machine_state->reg[i]);
  num_cols++;
  if (num_cols >= 4) {
   fprintf(stderr, "\n");
   num_cols = 0;
  }
  else {
   fprintf(stderr, "\t");
  }
        }
 fprintf(stderr, "\n");
}

variable_types: i int

user_defined_types: struct State { unsigned short pc; unsigned short sp; unsigned short stack_size; unsigned short stack_boundary; unsigned char mem[65536]; unsigned int reg[32]; }


decompiled_code:
__int64 __fastcall jal_instruction(__int64 a1, unsigned __int16 *a2)
{
unsigned int v2; // eax
unsigned __int16 v3; // bp
__int64 result; // rax

v2 = extract_address();
v3 = v2;
if ( (unsigned int)check_address(v2) )
{
fwrite("*** Terminating...\n", 1uLL, 0x13uLL, stdout);
exit(1);
}
result = (unsigned int)*a2 + 4;
*((_DWORD *)a2 + 16417) = result;
*a2 = v3;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func19(__int64 a1, unsigned __int16 *a2)
{
unsigned int v2; // eax
unsigned __int16 v3; // bp
__int64 result; // rax

v2 = extract_address();
v3 = v2;
if ( (unsigned int)check_address(v2) )
{
fwrite("*** Terminating...\n", 1uLL, 0x13uLL, stdout);
exit(1);
}
result = (unsigned int)*a2 + 4;
*((_DWORD *)a2 + 16417) = result;
*a2 = v3;
return result;
}

original_code:
void jal_instruction(uint32_t instruction, State *machine_state) {
        uint32_t address = extract_address(instruction);
 if(check_address(address)) {
  fprintf(stdout, "*** Terminating...\n");
  exit(1);
 }
        machine_state->reg[31] = (machine_state->pc + 4);
        machine_state->pc = address;
}

canonical_original_code:
void jal_instruction(unsigned int instruction, struct State *machine_state) {
        unsigned int address = extract_address(instruction);
 if(check_address(address)) {
  fprintf(stdout, "*** Terminating...\n");
  exit(1);
 }
        machine_state->reg[31] = (machine_state->pc + 4);
        machine_state->pc = address;
}


decompiled_code:
__int64 __fastcall call_instruction(unsigned int a1, unsigned __int16 *a2)
{
unsigned __int16 v2; // dx
int v3; // eax
__int64 result; // rax

increment_pc(a2, 1);
v2 = extract(a1, 8LL, 31LL);
v3 = a2[1];
*(_DWORD *)((char *)a2 + (unsigned __int16)v3 + 8) = *a2;
result = (unsigned int)(v3 - 4);
a2[1] = result;
*a2 = v2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func23(unsigned int a1, unsigned __int16 *a2)
{
unsigned __int16 v2; // dx
int v3; // eax
__int64 result; // rax

func1(a2, 1);
v2 = extract(a1, 8LL, 31LL);
v3 = a2[1];
*(_DWORD *)((char *)a2 + (unsigned __int16)v3 + 8) = *a2;
result = (unsigned int)(v3 - 4);
a2[1] = result;
*a2 = v2;
return result;
}

original_code:
void call_instruction(uint32_t instruction, State *machine_state) {
 increment_pc(machine_state, 1);
 uint32_t value = (uint32_t) extract(instruction,8,31);
 uint32_t *pointer = (uint32_t *)&machine_state->mem[machine_state->sp];
 *pointer = (uint32_t) machine_state->pc;
 machine_state->sp -= 4;
 machine_state->pc = value;
}

canonical_original_code:
void call_instruction(unsigned int instruction, struct State *machine_state) {
 increment_pc(machine_state, 1);
 unsigned int value = (uint32_t) extract(instruction,8,31);
 unsigned int *pointer = (uint32_t *)&machine_state->mem[machine_state->sp];
 *pointer = (unsigned int) machine_state->pc;
 machine_state->sp -= 4;
 machine_state->pc = value;
}

variable_types:
value
unsigned int

variable_types:
pointer
unsigned int *


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

if ( a2 )
{
v2 = strlen(a2);
v3 = (const char *)realloc(*a1, v2);
v4 = (char *)v3;
*a1 = (void *)v3;
if ( !v3 )
{
perror("Couldn't reallocate memory for *dest");
exit(1);
}
v5 = strlen(v3);
memset(v4, 0, v5);
v6 = strlen(a2);
strncpy((char *)*a1, a2, v6);
}
else
{
*a1 = 0LL;
}
}

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

if ( a2 )
{
v2 = strlen(a2);
v3 = (const char *)realloc(*a1, v2);
v4 = (char *)v3;
*a1 = (void *)v3;
if ( !v3 )
{
perror("Couldn't reallocate memory for *dest");
exit(1);
}
v5 = strlen(v3);
memset(v4, 0, v5);
v6 = strlen(a2);
strncpy((char *)*a1, a2, v6);
}
else
{
*a1 = 0LL;
}
}

original_code:
void copy_token(char **dest, const void *src) {
 if (src == ((void *)0)) {
  *dest = ((void *)0);
 } else {
  *dest = realloc(*dest, strlen(src));
  if (*dest == ((void *)0)) {
   perror("Couldn't reallocate memory for *dest");
   exit(1);
  }
  memset(*dest, '\0',strlen(*dest));
  strncpy(*dest, src, strlen(src));
 }
}

canonical_original_code:
void copy_token(char **dest, void *src) {
 if (src == ((void *)0)) {
  *dest = ((void *)0);
 } else {
  *dest = realloc(*dest, strlen(src));
  if (*dest == ((void *)0)) {
   perror("Couldn't reallocate memory for *dest");
   exit(1);
  }
  memset(*dest, '\0',strlen(*dest));
  strncpy(*dest, src, strlen(src));
 }
}

variable_types:
dest
char **

variable_types:
src
void *


init

original_code:
int init(State *machine_state) {
 machine_state->pc = 0;
 machine_state->sp = 65536 - 5;
 machine_state->stack_size = 1024;
 machine_state->stack_boundary = machine_state->sp - machine_state->stack_size;
 memset(machine_state->mem, 0, sizeof(uint8_t) * 65536);
 memset(machine_state->reg, 0, sizeof(uint32_t) * 32);
 return 0;
}

canonical_original_code:
int init(struct State *machine_state) {
 machine_state->pc = 0;
 machine_state->sp = 65536 - 5;
 machine_state->stack_size = 1024;
 machine_state->stack_boundary = machine_state->sp - machine_state->stack_size;
 memset(machine_state->mem, 0, sizeof(unsigned char) * 65536);
 memset(machine_state->reg, 0, sizeof(unsigned int) * 32);
 return 0;
}


repo: mtoyoda/sl

decompiled_code:
int __fastcall my_mvaddstr(int a1, int a2, char *a3)
{
int v3; // ebx
char *v4; // rbp
int v5; // ebx
int result; // eax

v3 = a2;
if ( a2 >= 0 )
{
LABEL_4:
if ( *a3 )
{
v4 = a3;
v5 = v3 - (_DWORD)a3;
while ( 1 )
{
result = wmove(stdscr__NCURSES6_TINFO_5_0_19991023, a1, v5 + (_DWORD)v4);
if ( result == -1 )
break;
result = waddch(stdscr__NCURSES6_TINFO_5_0_19991023, (unsigned int)*v4);
if ( result == -1 )
break;
if ( !*++v4 )
return 0;
}
}
else
{
result = 0;
}
}
else
{
while ( *a3 )
{
++a3;
if ( !++v3 )
goto LABEL_4;
}
result = -1;
}
return result;
}

canonical_decompiled_code:
int __fastcall func7(int a1, int a2, char *a3)
{
int v3; // ebx
char *v4; // rbp
int v5; // ebx
int result; // eax

v3 = a2;
if ( a2 >= 0 )
{
LABEL_4:
if ( *a3 )
{
v4 = a3;
v5 = v3 - (_DWORD)a3;
while ( 1 )
{
result = wmove(stdscr__NCURSES6_TINFO_5_0_19991023, a1, v5 + (_DWORD)v4);
if ( result == -1 )
break;
result = waddch(stdscr__NCURSES6_TINFO_5_0_19991023, (unsigned int)*v4);
if ( result == -1 )
break;
if ( !*++v4 )
return 0;
}
}
else
{
result = 0;
}
}
else
{
while ( *a3 )
{
++a3;
if ( !++v3 )
goto LABEL_4;
}
result = -1;
}
return result;
}

variable_types: y int

variable_types: x int

variable_types:
str
char *


option

decompiled_code:
__int64 __fastcall option(unsigned __int8 *a1)
{
__int64 result; // rax

for ( result = *a1; (_BYTE)result; result = *a1 )
{
++a1;
if ( (_BYTE)result == 99 )
{
C51 = 1;
}
else if ( (char)result > 99 )
{
if ( (_BYTE)result == 108 )
LOGO = 1;
}
else if ( (_BYTE)result == 70 )
{
FLY = 1;
}
else if ( (_BYTE)result == 97 )
{
ACCIDENT = 1;
}
}
return result;
}

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

for ( result = *a1; (_BYTE)result; result = *a1 )
{
++a1;
if ( (_BYTE)result == 99 )
{
C51 = 1;
}
else if ( (char)result > 99 )
{
if ( (_BYTE)result == 108 )
LOGO = 1;
}
else if ( (_BYTE)result == 70 )
{
FLY = 1;
}
else if ( (_BYTE)result == 97 )
{
ACCIDENT = 1;
}
}
return result;
}

original_code:
void option(char *str)
{
    extern int ACCIDENT, LOGO, FLY, C51;
    while (*str != '\0') {
        switch (*str++) {
            case 'a': ACCIDENT = 1; break;
            case 'F': FLY = 1; break;
            case 'l': LOGO = 1; break;
            case 'c': C51 = 1; break;
            default: break;
        }
    }
}

canonical_original_code:
void option(char *str)
{
    extern int ACCIDENT; extern int LOGO; extern int FLY; extern int C51;
    while (*str != '\0') {
        switch (*str++) {
            case 'a': ACCIDENT = 1; break;
            case 'F': FLY = 1; break;
            case 'l': LOGO = 1; break;
            case 'c': C51 = 1; break;
            default: break;
        }
    }
}

variable_types: ACCIDENT int

variable_types: LOGO int

variable_types: FLY int


decompiled_code:
int __fastcall add_man(int a1, int a2)
{
char **v2; // r12

v2 = (char **)(&man_6 + 2 * ((a2 + 84) / 12 % 2));
my_mvaddstr(a1, a2, *v2);
return my_mvaddstr(a1 + 1, a2, v2[1]);
}

variable_types:
man
char *[2][2]


variable_types: struct smokes { int y; int ptrn; } [1000]

variable_types: sum int

variable_types:
Smoke
char *[2][16]

variable_types:
Eraser
char *[16]

variable_types:
dy
int [16]

variable_types:
dx
int [16]


variable_types:
coal
char *[-1]

variable_types:
car
char *[-1]

variable_types: i int


variable_types: dy int


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char **v3; // rbx
int i; // ebx

if ( argc > 1 )
{
v3 = argv + 1;
do
{
if ( **v3 == 45 )
option((unsigned __int8 *)*v3 + 1);
++v3;
}
while ( v3 != &argv[(unsigned int)(argc - 2) + 2] );
}
initscr();
signal(2, (__sighandler_t)1);
noecho();
curs_set(0);
nodelay(stdscr__NCURSES6_TINFO_5_0_19991023, 1);
leaveok(stdscr__NCURSES6_TINFO_5_0_19991023, 1);
scrollok(stdscr__NCURSES6_TINFO_5_0_19991023, 0);
for ( i = COLS__NCURSES6_TINFO_5_0_19991023 - 1; ; --i )
{
if ( LOGO == 1 )
{
if ( (unsigned int)add_sl(i) == -1 )
goto LABEL_14;
goto LABEL_10;
}
if ( C51 != 1 )
break;
if ( (unsigned int)add_C51(i) == -1 )
goto LABEL_14;
LABEL_10:
wgetch(stdscr__NCURSES6_TINFO_5_0_19991023);
wrefresh(stdscr__NCURSES6_TINFO_5_0_19991023);
usleep(0x9C40u);
}
if ( (unsigned int)add_D51(i) != -1 )
goto LABEL_10;
LABEL_14:
mvcur(0, COLS__NCURSES6_TINFO_5_0_19991023 - 1, LINES__NCURSES6_TINFO_5_0_19991023 - 1, 0);
endwin();
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char **v3; // rbx
int i; // ebx

if ( argc > 1 )
{
v3 = argv + 1;
do
{
if ( **v3 == 45 )
func8((unsigned __int8 *)*v3 + 1);
++v3;
}
while ( v3 != &argv[(unsigned int)(argc - 2) + 2] );
}
initscr();
signal(2, (__sighandler_t)1);
noecho();
curs_set(0);
nodelay(stdscr__NCURSES6_TINFO_5_0_19991023, 1);
leaveok(stdscr__NCURSES6_TINFO_5_0_19991023, 1);
scrollok(stdscr__NCURSES6_TINFO_5_0_19991023, 0);
for ( i = COLS__NCURSES6_TINFO_5_0_19991023 - 1; ; --i )
{
if ( LOGO == 1 )
{
if ( (unsigned int)func11(i) == -1 )
goto LABEL_14;
goto LABEL_10;
}
if ( C51 != 1 )
break;
if ( (unsigned int)func13(i) == -1 )
goto LABEL_14;
LABEL_10:
wgetch(stdscr__NCURSES6_TINFO_5_0_19991023);
wrefresh(stdscr__NCURSES6_TINFO_5_0_19991023);
usleep(0x9C40u);
}
if ( (unsigned int)func12(i) != -1 )
goto LABEL_10;
LABEL_14:
mvcur(0, COLS__NCURSES6_TINFO_5_0_19991023 - 1, LINES__NCURSES6_TINFO_5_0_19991023 - 1, 0);
endwin();
return 0;
}

original_code:
int main(int argc, char *argv[])
{
    int x, i;
    for (i = 1; i < argc; ++i) {
        if (*argv[i] == '-') {
            option(argv[i] + 1);
        }
    }
    initscr();
    signal(2, ((__sighandler_t) 1));
    noecho();
    curs_set(0);
    nodelay(stdscr, 1);
    leaveok(stdscr, 1);
    scrollok(stdscr, 0);
    for (x = COLS - 1; ; --x) {
        if (LOGO == 1) {
            if (add_sl(x) == (-1)) break;
        }
        else if (C51 == 1) {
            if (add_C51(x) == (-1)) break;
        }
        else {
            if (add_D51(x) == (-1)) break;
        }
        wgetch(stdscr);
        wrefresh(stdscr);
        usleep(40000);
    }
    mvcur(0, COLS - 1, LINES - 1, 0);
    endwin();
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
    int x; int i;
    for (i = 1; i < argc; ++i) {
        if (*argv[i] == '-') {
            option(argv[i] + 1);
        }
    }
    initscr();
    signal(2, ((void (*)(int)) 1));
    noecho();
    curs_set(0);
    nodelay(stdscr, 1);
    leaveok(stdscr, 1);
    scrollok(stdscr, 0);
    for (x = COLS - 1; ; --x) {
        if (LOGO == 1) {
            if (add_sl(x) == (-1)) break;
        }
        else if (C51 == 1) {
            if (add_C51(x) == (-1)) break;
        }
        else {
            if (add_D51(x) == (-1)) break;
        }
        wgetch(stdscr);
        wrefresh(stdscr);
        usleep(40000);
    }
    mvcur(0, COLS - 1, LINES - 1, 0);
    endwin();
    return 0;
}

variable_types: argc int

variable_types:
argv
char *[]


slurp

repo: mugit/effprog

decompiled_code:
void *__fastcall slurp(const char *a1)
{
int v1; // eax
int v2; // ebx
void *result; // rax
struct stat v4; // [rsp+0h] [rbp-A8h] BYREF

v1 = open(a1, 0);
if ( v1 == -1 )
err(1, "%s", a1);
v2 = v1;
if ( (unsigned int)fstat(v1, &v4) == -1 )
err(1, "%s", a1);
result = mmap(0LL, v4.st_size + 7, 3, 2, v2, 0LL);
if ( result == (void *)-1LL )
err(1, "%s", a1);
return result;
}

canonical_decompiled_code:
void *__fastcall func7(const char *a1)
{
int v1; // eax
int v2; // ebx
void *result; // rax
struct stat v4; // [rsp+0h] [rbp-A8h] BYREF

v1 = open(a1, 0);
if ( v1 == -1 )
err(1, "%s", a1);
v2 = v1;
if ( (unsigned int)func12(v1, &v4) == -1 )
err(1, "%s", a1);
result = mmap(0LL, v4.st_size + 7, 3, 2, v2, 0LL);
if ( result == (void *)-1LL )
err(1, "%s", a1);
return result;
}

original_code:
struct block slurp(char *filename) {
    int fd=open(filename,00);
    char *s;
    struct stat statbuf;
    struct block r;
    if (fd==-1)
        err(1, "%s", filename);
    if (fstat(fd, &statbuf)==-1)
        err(1, "%s", filename);
    s = mmap(((void *)0),statbuf.st_size+7, 0x1|0x2,0|0x02,fd, 0);
    if (s==((void *) -1))
        err(1, "%s", filename);
    r.addr = s;
    r.len = statbuf.st_size;
    return r;
}

canonical_original_code:
struct block slurp(char *filename) {
    int fd = open(filename,00);
    char *s;
    struct stat statbuf;
    struct block r;
    if (fd==-1)
        err(1, "%s", filename);
    if (fstat(fd, &statbuf)==-1)
        err(1, "%s", filename);
    s = mmap(((void *)0),statbuf.st_size+7, 0x1|0x2,0|0x02,fd, 0);
    if (s==((void *) -1))
        err(1, "%s", filename);
    r.addr = s;
    r.len = statbuf.st_size;
    return r;
}

variable_types:
filename
char *

variable_types: fd int

variable_types:
s
char *

variable_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec { long tv_sec; long tv_nsec; } st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }

variable_types: struct block { char *addr; unsigned long len; }

user_defined_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }


hash

original_code:
unsigned long hash(char *addr, size_t len) {
    uint128_t x = 0, w;
    size_t i, shift;
    for (i = 0; i + 7 < len; i += 8) {
        w = *(unsigned long *)(addr+i);
        x = (x + w)*13493690561280548289ULL;
    }
    if (i < len) {
        shift = ((i - len) << 3) + 64;
        w = (*(unsigned long *)(addr + i)) << shift;
        x = (x + w)*13493690561280548289ULL;
    }
    return x+(x>>64);
}

canonical_original_code:
unsigned long hash(char *addr, unsigned long len) {
    unsigned int x = 0; unsigned int w;
    unsigned long i; unsigned long shift;
    for (i = 0; i + 7 < len; i += 8) {
        w = *(unsigned long *)(addr+i);
        x = (x + w)*13493690561280548289ULL;
    }
    if (i < len) {
        shift = ((i - len) << 3) + 64;
        w = (*(unsigned long *)(addr + i)) << shift;
        x = (x + w)*13493690561280548289ULL;
    }
    return x+(x>>64);
}

variable_types:
addr
char *

variable_types:
len
unsigned long

variable_types:
x
unsigned int

variable_types:
w
unsigned int

variable_types:
i
unsigned long

variable_types:
shift
unsigned long

return_type: unsigned long


lookup

decompiled_code:
__int64 __fastcall lookup(void *s1, size_t n)
{
__int64 v2; // rbx

v2 = ht[hash((unsigned __int64 *)s1, n) & 0xFFFFF];
if ( !v2 )
return 0xFFFFFFFFLL;
do
{
if ( *(_QWORD *)(v2 + 16) == n && !memcmp(s1, *(const void **)(v2 + 8), n) )
return *(unsigned int *)(v2 + 24);
v2 = *(_QWORD *)v2;
}
while ( v2 );
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func9(void *s1, size_t n)
{
__int64 v2; // rbx

v2 = ht[func8((unsigned __int64 *)s1, n) & 0xFFFFF];
if ( !v2 )
return 0xFFFFFFFFLL;
do
{
if ( *(_QWORD *)(v2 + 16) == n && !memcmp(s1, *(const void **)(v2 + 8), n) )
return *(unsigned int *)(v2 + 24);
v2 = *(_QWORD *)v2;
}
while ( v2 );
return 0xFFFFFFFFLL;
}

original_code:
int lookup(char *keyaddr, size_t keylen) {
    struct hashnode *l = ht[hash(keyaddr, keylen) & ((1<<20)-1)];
    while (l!=((void *)0)) {
        if (keylen == l->keylen && memcmp(keyaddr, l->keyaddr, keylen) == 0)
            return l->value;
        l = l->next;
    }
    return -1;
}

canonical_original_code:
int lookup(char *keyaddr, unsigned long keylen) {
    struct hashnode *l = ht[hash(keyaddr, keylen) & ((1<<20)-1)];
    while (l!=((void *)0)) {
        if (keylen == l->keylen && memcmp(keyaddr, l->keyaddr, keylen) == 0)
            return l->value;
        l = l->next;
    }
    return -1;
}

variable_types:
keyaddr
char *

variable_types:
keylen
unsigned long

variable_types: struct hashnode { struct hashnode *next; char *keyaddr; unsigned long keylen; int value; } *


main

original_code:
int main(int argc, char *argv[]) {
    struct block input1, input2;
    char *p, *nextp, *endp;
    unsigned int i;
    unsigned long r = 0;
    int currentLookup;
    int *cache;
    int cacheSize = (1<<20);
    int cacheCounter;
    if (argc!=3) {
        fprintf(stderr, "usage: %s <dict-file> <lookup-file>\n", argv[0]);
        exit(1);
    }
    input1 = slurp(argv[1]);
    input2 = slurp(argv[2]);
    for (p=input1.addr, endp=input1.addr+input1.len, i=0; p<endp; i++) {
        nextp=memchr(p, '\n', endp-p);
        if (nextp == ((void *)0))
            break;
        insert(p, nextp-p, i);
        p = nextp+1;
    }
    cache = calloc((1<<20), sizeof(int));
    for (i = 0; i < 10; i++) {
        for (p = input2.addr, endp = input2.addr + input2.len, cacheCounter = 0; p < endp; cacheCounter++) {
            nextp = memchr(p, '\n', endp-p);
            if (nextp == ((void *)0)) {
                break;
            }
            if (i == 0) {
                currentLookup = lookup(p, nextp - p);
                if (cacheCounter >= cacheSize) {
                    cache = realloc(cache, 96 * sizeof(int));
                    cacheSize += 96;
                }
                cache[cacheCounter] = currentLookup;
            } else {
                currentLookup = cache[cacheCounter];
            }
            r = ((unsigned long)r) * 2654435761L + currentLookup;
            r = r + (r>>32);
            p = nextp+1;
        }
    }
    printf("%ld\n",r);
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[]) {
    struct block input1; struct block input2;
    char *p; char *nextp; char *endp;
    unsigned int i;
    unsigned long r = 0;
    int currentLookup;
    int *cache;
    int cacheSize = (1<<20);
    int cacheCounter;
    if (argc!=3) {
        fprintf(stderr, "usage: %s <dict-file> <lookup-file>\n", argv[0]);
        exit(1);
    }
    input1 = slurp(argv[1]);
    input2 = slurp(argv[2]);
    for (p=input1.addr, endp=input1.addr+input1.len, i=0; p<endp; i++) {
        nextp=memchr(p, '\n', endp-p);
        if (nextp == ((void *)0))
            break;
        insert(p, nextp-p, i);
        p = nextp+1;
    }
    cache = calloc((1<<20), sizeof(int));
    for (i = 0; i < 10; i++) {
        for (p = input2.addr, endp = input2.addr + input2.len, cacheCounter = 0; p < endp; cacheCounter++) {
            nextp = memchr(p, '\n', endp-p);
            if (nextp == ((void *)0)) {
                break;
            }
            if (i == 0) {
                currentLookup = lookup(p, nextp - p);
                if (cacheCounter >= cacheSize) {
                    cache = realloc(cache, 96 * sizeof(int));
                    cacheSize += 96;
                }
                cache[cacheCounter] = currentLookup;
            } else {
                currentLookup = cache[cacheCounter];
            }
            r = ((unsigned long)r) * 2654435761L + currentLookup;
            r = r + (r>>32);
            p = nextp+1;
        }
    }
    printf("%ld\n",r);
    return 0;
}

variable_types:
p
char *

variable_types:
nextp
char *

variable_types:
endp
char *

variable_types:
i
unsigned int

variable_types:
r
unsigned long

variable_types: currentLookup int

variable_types:
cache
int *

variable_types: cacheSize int

variable_types: cacheCounter int

user_defined_types: struct block { char *addr; unsigned long len; }


decompiled_code:
_BOOL8 find_hid_device()
{
devh = libusb_open_device_with_vid_pid();
return devh == 0;
}

canonical_decompiled_code:
_BOOL8 func7()
{
devh = libusb_open_device_with_vid_pid();
return devh == 0;
}

original_code:
int find_hid_device(void){
    devh = libusb_open_device_with_vid_pid(((void *)0), HID_VENDOR, HID_PRODUCT);
    return devh ? 0 : 1;
}

canonical_original_code:
int find_hid_device(){
    devh = libusb_open_device_with_vid_pid(((void *)0), HID_VENDOR, HID_PRODUCT);
    return devh ? 0 : 1;
}


decompiled_code:
int __fastcall send_key(unsigned int a1)
{
XKeysymToKeycode(display, a1);
XTestFakeKeyEvent();
XTestFakeKeyEvent();
return XFlush(display);
}

canonical_decompiled_code:
int __fastcall func8(unsigned int a1)
{
XKeysymToKeycode(display, a1);
XTestFakeKeyEvent();
XTestFakeKeyEvent();
return XFlush(display);
}

original_code:
void send_key(unsigned int key){
    unsigned int keycode;
    keycode = XKeysymToKeycode(display, key);
    XTestFakeKeyEvent(display, keycode, 1, 0);
    XTestFakeKeyEvent(display, keycode, 0, 0);
    XFlush(display);
}

variable_types:
key
unsigned int

variable_types:
keycode
unsigned int


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // eax
int v4; // ebp
int v5; // ebx

v3 = libusb_init();
if ( v3 < 0 )
{
v4 = v3;
fwrite("Error initializing libusb. \n", 1uLL, 0x1CuLL, stderr);
}
else if ( find_hid_device() )
{
fwrite("Device not found. \n", 1uLL, 0x13uLL, stderr);
v4 = -1;
}
else
{
libusb_detach_kernel_driver();
libusb_set_configuration();
v4 = libusb_claim_interface();
if ( v4 )
{
fwrite("Failed to claim interface. \n", 1uLL, 0x1CuLL, stderr);
}
else
{
display = XOpenDisplay(0LL);
do
v5 = libusb_bulk_transfer();
while ( v5 != -4 );
libusb_release_interface();
libusb_close();
}
}
return v4;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // eax
int v4; // ebp
int v5; // ebx

v3 = libusb_init();
if ( v3 < 0 )
{
v4 = v3;
fwrite("Error initializing libusb. \n", 1uLL, 0x1CuLL, stderr);
}
else if ( func7() )
{
fwrite("Device not found. \n", 1uLL, 0x13uLL, stderr);
v4 = -1;
}
else
{
libusb_detach_kernel_driver();
libusb_set_configuration();
v4 = libusb_claim_interface();
if ( v4 )
{
fwrite("Failed to claim interface. \n", 1uLL, 0x1CuLL, stderr);
}
else
{
display = XOpenDisplay(0LL);
do
v5 = libusb_bulk_transfer();
while ( v5 != -4 );
libusb_release_interface();
libusb_close();
}
}
return v4;
}

original_code:
int main(){
    int r = 1;
    r = libusb_init(((void *)0));
    if (r < 0) {
        fprintf(stderr, "Error initializing libusb. \n");
        return r;
    }
    if (find_hid_device()) {
        fprintf(stderr, "Device not found. \n");
        return -1;
    }
    libusb_detach_kernel_driver(devh, 0);
    r = libusb_set_configuration(devh, 1);
    r = libusb_claim_interface(devh, 0);
    if (r) {
        fprintf(stderr, "Failed to claim interface. \n");
        return r;
    }
    unsigned char data[10];
    int actual = 0;
    display = XOpenDisplay(((void *)0));
    do{
        memset(data, 0, sizeof(data));
        r = libusb_bulk_transfer(devh, ENDPOINT_UP, data, 8, &actual, 0);
        switch(data[2]){
            case 78:
                fprintf(stderr, "PgUp\n");
                send_key(0xff55);
                break;
            case 75:
                fprintf(stderr, "PgDn\n");
                send_key(0xff56);
                break;
        }
    } while (r != LIBUSB_ERROR_NO_DEVICE);
    r = libusb_release_interface(devh, 0);
    libusb_close(devh);
    return 0;
}

variable_types: r int

variable_types:
data
unsigned char [10]

variable_types: actual int


decompiled_code:
void cairo_image_view_destroy()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
static void
cairo_image_view_destroy (gpointer instance __attribute__((__unused__)))
{
}

canonical_original_code:
static void cairo_image_view_destroy(void *instance)
{
}

variable_types:
instance
void *


decompiled_code:
__int64 __fastcall cairo_image_view_destroy_surface(__int64 a1, __int64 a2)
{
return cairo_surface_destroy(a2);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2)
{
return cairo_surface_destroy(a2);
}

original_code:
static void
cairo_image_view_destroy_surface (gpointer instance,
      gpointer surface)
{
  cairo_surface_destroy (surface);
}

canonical_original_code:
static void cairo_image_view_destroy_surface(void *instance, void *surface)
{
  cairo_surface_destroy (surface);
}

variable_types:
surface
void *


decompiled_code:
__int64 __fastcall cairo_vector_view_destroy_surface(__int64 a1, __int64 a2)
{
return cairo_surface_destroy(a2);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2)
{
return cairo_surface_destroy(a2);
}

original_code:
static void
cairo_vector_view_destroy_surface (gpointer instance,
       gpointer surface)
{
  cairo_surface_destroy (surface);
}

canonical_original_code:
static void cairo_vector_view_destroy_surface(void *instance, void *surface)
{
  cairo_surface_destroy (surface);
}


decompiled_code:
__int64 __fastcall pangoft2_view_destroy_surface(__int64 a1, __int64 a2)
{
g_free(*(_QWORD *)(a2 + 16));
return g_slice_free1(40LL, a2);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2)
{
g_free(*(_QWORD *)(a2 + 16));
return g_slice_free1(40LL, a2);
}

original_code:
static void
pangoft2_view_destroy_surface (gpointer instance __attribute__((__unused__)),
          gpointer surface)
{
  FT_Bitmap *bitmap = (FT_Bitmap *) surface;
  g_free (bitmap->buffer);
  do { if (1) g_slice_free1 (sizeof (FT_Bitmap), (bitmap)); else (void) ((FT_Bitmap*) 0 == (bitmap)); } while (0);
}

canonical_original_code:
static void pangoft2_view_destroy_surface(void *instance, void *surface)
{
  struct FT_Bitmap_ *bitmap = (FT_Bitmap *) surface;
  g_free (bitmap->buffer);
  do { if (1) g_slice_free1 (sizeof (FT_Bitmap), (bitmap)); else (void) ((struct FT_Bitmap_ *) 0 == (bitmap)); } while (0);
}

variable_types: struct FT_Bitmap_ { unsigned int rows; unsigned int width; int pitch; unsigned char *buffer; unsigned short num_grays; unsigned char pixel_mode; unsigned char palette_mode; void *palette; } *


decompiled_code:
__int64 pangoft2_view_destroy()
{
return g_object_unref();
}

canonical_decompiled_code:
__int64 func6()
{
return g_object_unref();
}

original_code:
static void
pangoft2_view_destroy (gpointer instance)
{
  g_object_unref (instance);
}

canonical_original_code:
static void pangoft2_view_destroy(void *instance)
{
  g_object_unref (instance);
}


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
glob = 0;
gtk_init();
gtk_window_new();
gtk_drawing_area_new();
gtk_widget_set_size_request();
gtk_container_get_type();
g_type_check_instance_cast();
gtk_container_add();
gtk_widget_add_events();
g_type_check_instance_cast();
g_signal_connect_data();
g_signal_connect_data();
g_signal_connect_data();
gtk_window_get_type();
g_type_check_instance_cast();
gtk_window_set_position();
g_type_check_instance_cast();
gtk_window_set_default_size();
g_type_check_instance_cast();
gtk_window_set_title();
gtk_widget_show_all();
gtk_main();
return 0;
}

original_code:
int main (int argc, char ** argv)
{
    list_fonts ();
    return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
    list_fonts ();
    return 0;
}

variable_types: argc int

variable_types:
argv
char **


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
list_fonts(argc, argv, envp);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
func7(argc, argv, envp);
return 0;
}


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v3; // r8
__int64 v4; // rbp
int result; // eax
__int64 v6; // rbp

if ( argc == 3 )
{
v3 = argv[1];
if ( !strcmp("1_1", v3) )
{
cairo_svg_surface_create();
cairo_svg_surface_restrict_to_version();
v6 = cairo_create();
cairo_set_source_rgb();
cairo_select_font_face();
cairo_set_font_size();
gen_page_1(v6, "Sans", 40.0, 0.0);
goto LABEL_5;
}
if ( !strcmp("1_2", v3) )
{
cairo_svg_surface_create();
cairo_svg_surface_restrict_to_version();
v4 = cairo_create();
cairo_set_source_rgb();
cairo_select_font_face();
cairo_set_font_size();
gen_page_1(v4, "Sans", 40.0, 0.0);
gen_page_2(v4);
LABEL_5:
cairo_surface_destroy();
cairo_destroy();
return 0;
}
fwrite("ERROR: SVG version must be 1_1 or 1_2!\n", 1uLL, 0x27uLL, stderr);
result = -1;
}
else
{
fprintf(stderr, "%s [svg_version] [output file]\n", *argv);
fwrite("\tsvg version = 1_1 or 1_2\n", 1uLL, 0x1AuLL, stderr);
result = -1;
}
return result;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v3; // r8
__int64 v4; // rbp
int result; // eax
__int64 v6; // rbp

if ( argc == 3 )
{
v3 = argv[1];
if ( !strcmp("1_1", v3) )
{
cairo_svg_surface_create();
cairo_svg_surface_restrict_to_version();
v6 = cairo_create();
cairo_set_source_rgb();
cairo_select_font_face();
cairo_set_font_size();
func7(v6, "Sans", 40.0, 0.0);
goto LABEL_5;
}
if ( !strcmp("1_2", v3) )
{
cairo_svg_surface_create();
cairo_svg_surface_restrict_to_version();
v4 = cairo_create();
cairo_set_source_rgb();
cairo_select_font_face();
cairo_set_font_size();
func7(v4, "Sans", 40.0, 0.0);
func8(v4);
LABEL_5:
cairo_surface_destroy();
cairo_destroy();
return 0;
}
fwrite("ERROR: SVG version must be 1_1 or 1_2!\n", 1uLL, 0x27uLL, stderr);
result = -1;
}
else
{
fprintf(stderr, "%s [svg_version] [output file]\n", *argv);
fwrite("\tsvg version = 1_1 or 1_2\n", 1uLL, 0x1AuLL, stderr);
result = -1;
}
return result;
}


testReallocateFn

repo: munificent/wren

decompiled_code:
void *__fastcall testReallocateFn(void *ptr, size_t size, const char *a3)
{
if ( strcmp(a3, "my user data") )
return 0LL;
if ( size )
return realloc(ptr, size);
free(ptr);
return 0LL;
}

canonical_decompiled_code:
void *__fastcall func0(void *ptr, size_t size, const char *a3)
{
if ( strcmp(a3, "my user data") )
return 0LL;
if ( size )
return realloc(ptr, size);
free(ptr);
return 0LL;
}

original_code:
void* testReallocateFn(void* ptr, size_t newSize, void* userData) {
  if (strcmp(userData, data) != 0) return ((void *)0);
  if (newSize == 0)
  {
    free(ptr);
    return ((void *)0);
  }
  return realloc(ptr, newSize);
}

canonical_original_code:
void *testReallocateFn(void *ptr, unsigned long newSize, void *userData) {
  if (strcmp(userData, data) != 0) return ((void *)0);
  if (newSize == 0)
  {
    free(ptr);
    return ((void *)0);
  }
  return realloc(ptr, newSize);
}

variable_types:
ptr
void *

variable_types:
newSize
unsigned long

variable_types:
userData
void *

return_type: void *


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebx
const char *v5; // r13
char v6; // bp
int v7; // er12

v3 = handle_args(argc, argv, envp);
if ( !v3 )
{
v5 = argv[1];
v6 = isModuleAnAPITest(v5);
vm = initVM(v6);
v7 = runFile(vm, v5);
if ( v6 )
v3 = APITest_Run(vm, v5);
if ( v7 == 1 )
{
v3 = 65;
}
else if ( v7 == 2 )
{
v3 = 70;
}
else
{
wrenFreeVM(vm);
}
}
return v3;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebx
const char *v5; // r13
char v6; // bp
int v7; // er12

v3 = handle_args(argc, argv, envp);
if ( !v3 )
{
v5 = argv[1];
v6 = isModuleAnAPITest(v5);
vm = func0(v6);
v7 = runFile(vm, v5);
if ( v6 )
v3 = APITest_Run(vm, v5);
if ( v7 == 1 )
{
v3 = 65;
}
else if ( v7 == 2 )
{
v3 = 70;
}
else
{
wrenFreeVM(vm);
}
}
return v3;
}

original_code:
int main(int argc, const char* argv[]) {
  int handled = handle_args(argc, argv);
  if(handled != 0) return handled;
  int exitCode = 0;
  const char* testName = argv[1];
  _Bool isAPITest = isModuleAnAPITest(testName);
  vm = initVM(isAPITest);
  WrenInterpretResult result = runFile(vm, testName);
  if(isAPITest) {
    exitCode = APITest_Run(vm, testName);
  }
  if (result == WREN_RESULT_COMPILE_ERROR) return 65;
  if (result == WREN_RESULT_RUNTIME_ERROR) return 70;
  wrenFreeVM(vm);
  return exitCode;
}

canonical_original_code:
int main(int argc, char *argv[]) {
  int handled = handle_args(argc, argv);
  if(handled != 0) return handled;
  int exitCode = 0;
  char *testName = argv[1];
  _Bool isAPITest = isModuleAnAPITest(testName);
  vm = initVM(isAPITest);
  enum WrenInterpretResult result = runFile(vm, testName);
  if(isAPITest) {
    exitCode = APITest_Run(vm, testName);
  }
  if (result == WREN_RESULT_COMPILE_ERROR) return 65;
  if (result == WREN_RESULT_RUNTIME_ERROR) return 70;
  wrenFreeVM(vm);
  return exitCode;
}

variable_types:
argv
char *[]

variable_types: handled int

variable_types: exitCode int

variable_types:
testName
char *

variable_types: enum WrenInterpretResult { WREN_RESULT_SUCCESS=0, WREN_RESULT_COMPILE_ERROR=1, WREN_RESULT_RUNTIME_ERROR=2 }


wrenStringEqualsCString

decompiled_code:
_BOOL8 __fastcall wrenStringEqualsCString(__int64 a1, const void *a2, size_t a3)
{
_BOOL8 result; // rax

if ( *(_DWORD *)(a1 + 24) == a3 )
result = memcmp((const void *)(a1 + 32), a2, a3) == 0;
else
result = 0LL;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(__int64 a1, const void *a2, size_t a3)
{
_BOOL8 result; // rax

if ( *(_DWORD *)(a1 + 24) == a3 )
result = memcmp((const void *)(a1 + 32), a2, a3) == 0;
else
result = 0LL;
return result;
}

original_code:
static inline _Bool wrenStringEqualsCString(const ObjString* a,
                                           const char* b, size_t length)
{
  return a->length == length && memcmp(a->value, b, length) == 0;
}

canonical_original_code:
static inline _Bool wrenStringEqualsCString(struct sObjString *a, char *b, unsigned long length)
{
  return a->length == length && memcmp(a->value, b, length) == 0;
}

variable_types: struct sObjString { struct sObj { enum ObjType { OBJ_CLASS=0, OBJ_CLOSURE=1, OBJ_FIBER=2, OBJ_FN=3, OBJ_FOREIGN=4, OBJ_INSTANCE=5, OBJ_LIST=6, OBJ_MAP=7, OBJ_MODULE=8, OBJ_RANGE=9, OBJ_STRING=10, OBJ_UPVALUE=11 } type; _Bool isDark; struct sObjClass { struct sObj obj; struct sObjClass *superclass; int numFields; struct MethodBuffer { struct Method { enum MethodType { METHOD_PRIMITIVE=0, METHOD_FUNCTION_CALL=1, METHOD_FOREIGN=2, METHOD_BLOCK=3, METHOD_NONE=4 } type; union { _Bool (*primitive)(struct WrenVM { struct sObjClass *boolClass; struct sObjClass *classClass; struct sObjClass *fiberClass; struct sObjClass *fnClass; struct sObjClass *listClass; struct sObjClass *mapClass; struct sObjClass *nullClass; struct sObjClass *numClass; struct sObjClass *objectClass; struct sObjClass *rangeClass; struct sObjClass *stringClass; struct sObjFiber { struct sObj obj; unsigned long *stack; unsigned long *stackTop; int stackCapacity; struct CallFrame { unsigned char *ip; struct ObjClosure { struct sObj obj; struct ObjFn { struct sObj obj; struct ByteBuffer { unsigned char *data; int count; int capacity; } code; struct ValueBuffer { unsigned long *data; int count; int capacity; } constants; struct ObjModule { struct sObj obj; struct ValueBuffer variables; struct StringBuffer { struct sObjString **data; int count; int capacity; } variableNames; struct sObjString *name; } *module; int maxSlots; int numUpvalues; int arity; struct FnDebug { char *name; struct IntBuffer { int *data; int count; int capacity; } sourceLines; } *debug; } *fn; struct sObjUpvalue { struct sObj obj; unsigned long *value; unsigned long closed; struct sObjUpvalue *next; } *upvalues[]; } *closure; unsigned long *stackStart; } *frames; int numFrames; int frameCapacity; struct sObjUpvalue *openUpvalues; struct sObjFiber *caller; unsigned long error; enum FiberState { FIBER_TRY=0, FIBER_ROOT=1, FIBER_OTHER=2 } state; } *fiber; struct ObjMap { struct sObj obj; unsigned int capacity; unsigned int count; struct MapEntry { unsigned long key; unsigned long value; } *entries; } *modules; struct ObjModule *lastModule; unsigned long bytesAllocated; unsigned long nextGC; struct sObj *first; struct sObj **gray; int grayCount; int grayCapacity; struct sObj *tempRoots[8]; int numTempRoots; struct WrenHandle { unsigned long value; struct WrenHandle *prev; struct WrenHandle *next; } *handles; unsigned long *apiStack; struct WrenConfiguration { void *(*reallocateFn)(void *memory, unsigned long newSize, void *userData); char *(*resolveModuleFn)(struct WrenVM *vm, char *importer, char *name); struct WrenLoadModuleResult { char *source; void (*onComplete)(struct WrenVM *vm, char *name, struct WrenLoadModuleResult result); void *userData; } (*loadModuleFn)(struct WrenVM *vm, char *name); void (*(*bindForeignMethodFn)(struct WrenVM *vm, char *module, char *className, _Bool isStatic, char *signature))(struct WrenVM *vm); struct WrenForeignClassMethods { void (*allocate)(struct WrenVM *vm); void (*finalize)(void *data); } (*bindForeignClassFn)(struct WrenVM *vm, char *module, char *className); void (*writeFn)(struct WrenVM *vm, char *text); void (*errorFn)(struct WrenVM *vm, enum WrenErrorType { WREN_ERROR_COMPILE=0, WREN_ERROR_RUNTIME=1, WREN_ERROR_STACK_TRACE=2 } type, char *module, int line, char *message); unsigned long initialHeapSize; unsigned long minHeapSize; int heapGrowthPercent; void *userData; } config; struct sCompiler { struct Parser { struct WrenVM *vm; struct ObjModule *module; char *source; char *tokenStart; char *currentChar; int currentLine; struct Token { enum TokenType { TOKEN_LEFT_PAREN=0, TOKEN_RIGHT_PAREN=1, TOKEN_LEFT_BRACKET=2, TOKEN_RIGHT_BRACKET=3, TOKEN_LEFT_BRACE=4, TOKEN_RIGHT_BRACE=5, TOKEN_COLON=6, TOKEN_DOT=7, TOKEN_DOTDOT=8, TOKEN_DOTDOTDOT=9, TOKEN_COMMA=10, TOKEN_STAR=11, TOKEN_SLASH=12, TOKEN_PERCENT=13, TOKEN_HASH=14, TOKEN_PLUS=15, TOKEN_MINUS=16, TOKEN_LTLT=17, TOKEN_GTGT=18, TOKEN_PIPE=19, TOKEN_PIPEPIPE=20, TOKEN_CARET=21, TOKEN_AMP=22, TOKEN_AMPAMP=23, TOKEN_BANG=24, TOKEN_TILDE=25, TOKEN_QUESTION=26, TOKEN_EQ=27, TOKEN_LT=28, TOKEN_GT=29, TOKEN_LTEQ=30, TOKEN_GTEQ=31, TOKEN_EQEQ=32, TOKEN_BANGEQ=33, TOKEN_BREAK=34, TOKEN_CONTINUE=35, TOKEN_CLASS=36, TOKEN_CONSTRUCT=37, TOKEN_ELSE=38, TOKEN_FALSE=39, TOKEN_FOR=40, TOKEN_FOREIGN=41, TOKEN_IF=42, TOKEN_IMPORT=43, TOKEN_AS=44, TOKEN_IN=45, TOKEN_IS=46, TOKEN_NULL=47, TOKEN_RETURN=48, TOKEN_STATIC=49, TOKEN_SUPER=50, TOKEN_THIS=51, TOKEN_TRUE=52, TOKEN_VAR=53, TOKEN_WHILE=54, TOKEN_FIELD=55, TOKEN_STATIC_FIELD=56, TOKEN_NAME=57, TOKEN_NUMBER=58, TOKEN_STRING=59, TOKEN_INTERPOLATION=60, TOKEN_LINE=61, TOKEN_ERROR=62, TOKEN_EOF=63 } type; char *start; int length; int line; unsigned long value; } next; struct Token current; struct Token previous; int parens[8]; int numParens; _Bool printErrors; _Bool hasError; } *parser; struct sCompiler *parent; struct Local { char *name; int length; int depth; _Bool isUpvalue; } locals[256]; int numLocals; struct CompilerUpvalue { _Bool isLocal; int index; } upvalues[256]; int scopeDepth; int numSlots; struct sLoop { int start; int exitJump; int body; int scopeDepth; struct sLoop *enclosing; } *loop; struct ClassInfo { struct sObjString *name; struct ObjMap *classAttributes; struct ObjMap *methodAttributes; struct StringBuffer fields; struct IntBuffer methods; struct IntBuffer staticMethods; _Bool isForeign; _Bool inStatic; struct Signature { char *name; int length; enum SignatureType { SIG_METHOD=0, SIG_GETTER=1, SIG_SETTER=2, SIG_SUBSCRIPT=3, SIG_SUBSCRIPT_SETTER=4, SIG_INITIALIZER=5 } type; int arity; } *signature; } *enclosingClass; struct ObjFn *fn; struct ObjMap *constants; _Bool isInitializer; int numAttributes; struct ObjMap *attributes; } *compiler; struct StringBuffer methodNames; } *vm, unsigned long *args); void (*foreign)(struct WrenVM *vm); struct ObjClosure *closure; } as; } *data; int count; int capacity; } methods; struct sObjString *name; unsigned long attributes; } *classObj; struct sObj *next; } obj; unsigned int length; unsigned int hash; char value[]; } *

variable_types:
b
char *

variable_types:
length
unsigned long

user_defined_types: struct sObjString { struct sObj obj; unsigned int length; unsigned int hash; char value[]; }

user_defined_types: struct sObj { enum ObjType type; _Bool isDark; struct sObjClass *classObj; struct sObj *next; }

user_defined_types: struct sObjClass { struct sObj obj; struct sObjClass *superclass; int numFields; struct MethodBuffer methods; struct sObjString *name; unsigned long attributes; }

user_defined_types: struct MethodBuffer { struct Method *data; int count; int capacity; }

user_defined_types: struct Method { enum MethodType type; union { _Bool (*primitive)(struct WrenVM *vm, unsigned long *args); void (*foreign)(struct WrenVM *vm); struct ObjClosure *closure; } as; }

user_defined_types: struct WrenVM { struct sObjClass *boolClass; struct sObjClass *classClass; struct sObjClass *fiberClass; struct sObjClass *fnClass; struct sObjClass *listClass; struct sObjClass *mapClass; struct sObjClass *nullClass; struct sObjClass *numClass; struct sObjClass *objectClass; struct sObjClass *rangeClass; struct sObjClass *stringClass; struct sObjFiber *fiber; struct ObjMap *modules; struct ObjModule *lastModule; unsigned long bytesAllocated; unsigned long nextGC; struct sObj *first; struct sObj **gray; int grayCount; int grayCapacity; struct sObj *tempRoots[8]; int numTempRoots; struct WrenHandle *handles; unsigned long *apiStack; struct WrenConfiguration config; struct sCompiler *compiler; struct StringBuffer methodNames; }

user_defined_types: struct WrenConfiguration { void *(*reallocateFn)(void *memory, unsigned long newSize, void *userData); char *(*resolveModuleFn)(struct WrenVM *vm, char *importer, char *name); struct WrenLoadModuleResult (*loadModuleFn)(struct WrenVM *vm, char *name); void (*(*bindForeignMethodFn)(struct WrenVM *vm, char *module, char *className, _Bool isStatic, char *signature))(struct WrenVM *vm); struct WrenForeignClassMethods (*bindForeignClassFn)(struct WrenVM *vm, char *module, char *className); void (*writeFn)(struct WrenVM *vm, char *text); void (*errorFn)(struct WrenVM *vm, enum WrenErrorType type, char *module, int line, char *message); unsigned long initialHeapSize; unsigned long minHeapSize; int heapGrowthPercent; void *userData; }

user_defined_types: struct sObjFiber { struct sObj obj; unsigned long *stack; unsigned long *stackTop; int stackCapacity; struct CallFrame *frames; int numFrames; int frameCapacity; struct sObjUpvalue *openUpvalues; struct sObjFiber *caller; unsigned long error; enum FiberState state; }

user_defined_types: struct ObjMap { struct sObj obj; unsigned int capacity; unsigned int count; struct MapEntry *entries; }

user_defined_types: struct sCompiler { struct Parser *parser; struct sCompiler *parent; struct Local locals[256]; int numLocals; struct CompilerUpvalue upvalues[256]; int scopeDepth; int numSlots; struct sLoop *loop; struct ClassInfo *enclosingClass; struct ObjFn *fn; struct ObjMap *constants; _Bool isInitializer; int numAttributes; struct ObjMap *attributes; }

user_defined_types: struct CallFrame { unsigned char *ip; struct ObjClosure *closure; unsigned long *stackStart; }

user_defined_types: struct Parser { struct WrenVM *vm; struct ObjModule *module; char *source; char *tokenStart; char *currentChar; int currentLine; struct Token next; struct Token current; struct Token previous; int parens[8]; int numParens; _Bool printErrors; _Bool hasError; }

user_defined_types: struct ClassInfo { struct sObjString *name; struct ObjMap *classAttributes; struct ObjMap *methodAttributes; struct StringBuffer fields; struct IntBuffer methods; struct IntBuffer staticMethods; _Bool isForeign; _Bool inStatic; struct Signature *signature; }

user_defined_types: struct Token { enum TokenType type; char *start; int length; int line; unsigned long value; }

user_defined_types: struct ObjClosure { struct sObj obj; struct ObjFn *fn; struct sObjUpvalue *upvalues[]; }

user_defined_types: struct Signature { char *name; int length; enum SignatureType type; int arity; }

user_defined_types: struct ObjFn { struct sObj obj; struct ByteBuffer code; struct ValueBuffer constants; struct ObjModule *module; int maxSlots; int numUpvalues; int arity; struct FnDebug *debug; }

user_defined_types: struct ObjModule { struct sObj obj; struct ValueBuffer variables; struct StringBuffer variableNames; struct sObjString *name; }

user_defined_types: struct FnDebug { char *name; struct IntBuffer sourceLines; }


wrenByteBufferInit

decompiled_code:
void __fastcall wrenByteBufferInit(__int64 a1)
{
*(_QWORD *)a1 = 0LL;
*(_DWORD *)(a1 + 12) = 0;
*(_DWORD *)(a1 + 8) = 0;
}

original_code: void wrenByteBufferInit(ByteBuffer* buffer) { buffer->data = ((void *)0); buffer->capacity = 0; buffer->count = 0; }

canonical_original_code: void wrenByteBufferInit(struct ByteBuffer *buffer) { buffer->data = ((void *)0); buffer->capacity = 0; buffer->count = 0; }

variable_types: struct ByteBuffer { unsigned char *data; int count; int capacity; } *


wrenIntBufferInit

decompiled_code:
void __fastcall wrenIntBufferInit(__int64 a1)
{
*(_QWORD *)a1 = 0LL;
*(_DWORD *)(a1 + 12) = 0;
*(_DWORD *)(a1 + 8) = 0;
}

original_code: void wrenIntBufferInit(IntBuffer* buffer) { buffer->data = ((void *)0); buffer->capacity = 0; buffer->count = 0; }

canonical_original_code: void wrenIntBufferInit(struct IntBuffer *buffer) { buffer->data = ((void *)0); buffer->capacity = 0; buffer->count = 0; }

variable_types: struct IntBuffer { int *data; int count; int capacity; } *


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

result = 1LL;
if ( a1 > 127 )
{
result = 2LL;
if ( a1 > 2047 )
{
result = 3LL;
if ( a1 > 0xFFFF )
result = 4 * (unsigned int)(a1 < 1114112);
}
}
return result;
}

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

result = 1LL;
if ( a1 > 127 )
{
result = 2LL;
if ( a1 > 2047 )
{
result = 3LL;
if ( a1 > 0xFFFF )
result = 4 * (unsigned int)(a1 < 1114112);
}
}
return result;
}

original_code:
int wrenUtf8EncodeNumBytes(int value)
{
  do { } while (0);
  if (value <= 0x7f) return 1;
  if (value <= 0x7ff) return 2;
  if (value <= 0xffff) return 3;
  if (value <= 0x10ffff) return 4;
  return 0;
}

variable_types: value int


original_code:
int wrenUtf8Encode(int value, uint8_t* bytes)
{
  if (value <= 0x7f)
  {
    *bytes = value & 0x7f;
    return 1;
  }
  else if (value <= 0x7ff)
  {
    *bytes = 0xc0 | ((value & 0x7c0) >> 6);
    bytes++;
    *bytes = 0x80 | (value & 0x3f);
    return 2;
  }
  else if (value <= 0xffff)
  {
    *bytes = 0xe0 | ((value & 0xf000) >> 12);
    bytes++;
    *bytes = 0x80 | ((value & 0xfc0) >> 6);
    bytes++;
    *bytes = 0x80 | (value & 0x3f);
    return 3;
  }
  else if (value <= 0x10ffff)
  {
    *bytes = 0xf0 | ((value & 0x1c0000) >> 18);
    bytes++;
    *bytes = 0x80 | ((value & 0x3f000) >> 12);
    bytes++;
    *bytes = 0x80 | ((value & 0xfc0) >> 6);
    bytes++;
    *bytes = 0x80 | (value & 0x3f);
    return 4;
  }
  __builtin_unreachable();
  return 0;
}

canonical_original_code:
int wrenUtf8Encode(int value, unsigned char *bytes)
{
  if (value <= 0x7f)
  {
    *bytes = value & 0x7f;
    return 1;
  }
  else if (value <= 0x7ff)
  {
    *bytes = 0xc0 | ((value & 0x7c0) >> 6);
    bytes++;
    *bytes = 0x80 | (value & 0x3f);
    return 2;
  }
  else if (value <= 0xffff)
  {
    *bytes = 0xe0 | ((value & 0xf000) >> 12);
    bytes++;
    *bytes = 0x80 | ((value & 0xfc0) >> 6);
    bytes++;
    *bytes = 0x80 | (value & 0x3f);
    return 3;
  }
  else if (value <= 0x10ffff)
  {
    *bytes = 0xf0 | ((value & 0x1c0000) >> 18);
    bytes++;
    *bytes = 0x80 | ((value & 0x3f000) >> 12);
    bytes++;
    *bytes = 0x80 | ((value & 0xfc0) >> 6);
    bytes++;
    *bytes = 0x80 | (value & 0x3f);
    return 4;
  }
  __builtin_unreachable();
  return 0;
}

variable_types:
bytes
unsigned char *


decompiled_code:
__int64 __fastcall wrenUtf8Decode(_BYTE *a1, int a2)
{
__int64 result; // rax
unsigned int v4; // esi
_BYTE *v5; // rsi

LOBYTE(result) = *a1;
if ( (char)*a1 >= 0 )
return (unsigned __int8)result;
if ( (result & 0xE0) == 0xC0 )
{
LODWORD(result) = result & 0x1F;
v4 = 1;
}
else if ( (result & 0xF0) == 0xE0 )
{
LODWORD(result) = result & 0xF;
v4 = 2;
}
else
{
if ( (result & 0xF8) != 0xF0 )
return 0xFFFFFFFFLL;
LODWORD(result) = result & 7;
v4 = 3;
}
if ( a2 - 1 < v4 )
return 0xFFFFFFFFLL;
v5 = &a1[v4];
while ( (*++a1 & 0xC0) == 0x80 )
{
result = *a1 & 0x3Fu | ((_DWORD)result << 6);
if ( v5 == a1 )
return result;
}
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func13(_BYTE *a1, int a2)
{
__int64 result; // rax
unsigned int v4; // esi
_BYTE *v5; // rsi

LOBYTE(result) = *a1;
if ( (char)*a1 >= 0 )
return (unsigned __int8)result;
if ( (result & 0xE0) == 0xC0 )
{
LODWORD(result) = result & 0x1F;
v4 = 1;
}
else if ( (result & 0xF0) == 0xE0 )
{
LODWORD(result) = result & 0xF;
v4 = 2;
}
else
{
if ( (result & 0xF8) != 0xF0 )
return 0xFFFFFFFFLL;
LODWORD(result) = result & 7;
v4 = 3;
}
if ( a2 - 1 < v4 )
return 0xFFFFFFFFLL;
v5 = &a1[v4];
while ( (*++a1 & 0xC0) == 0x80 )
{
result = *a1 & 0x3Fu | ((_DWORD)result << 6);
if ( v5 == a1 )
return result;
}
return 0xFFFFFFFFLL;
}

original_code:
int wrenUtf8Decode(const uint8_t* bytes, uint32_t length)
{
  if (*bytes <= 0x7f) return *bytes;
  int value;
  uint32_t remainingBytes;
  if ((*bytes & 0xe0) == 0xc0)
  {
    value = *bytes & 0x1f;
    remainingBytes = 1;
  }
  else if ((*bytes & 0xf0) == 0xe0)
  {
    value = *bytes & 0x0f;
    remainingBytes = 2;
  }
  else if ((*bytes & 0xf8) == 0xf0)
  {
    value = *bytes & 0x07;
    remainingBytes = 3;
  }
  else
  {
    return -1;
  }
  if (remainingBytes > length - 1) return -1;
  while (remainingBytes > 0)
  {
    bytes++;
    remainingBytes--;
    if ((*bytes & 0xc0) != 0x80) return -1;
    value = value << 6 | (*bytes & 0x3f);
  }
  return value;
}

canonical_original_code:
int wrenUtf8Decode(unsigned char *bytes, unsigned int length)
{
  if (*bytes <= 0x7f) return *bytes;
  int value;
  unsigned int remainingBytes;
  if ((*bytes & 0xe0) == 0xc0)
  {
    value = *bytes & 0x1f;
    remainingBytes = 1;
  }
  else if ((*bytes & 0xf0) == 0xe0)
  {
    value = *bytes & 0x0f;
    remainingBytes = 2;
  }
  else if ((*bytes & 0xf8) == 0xf0)
  {
    value = *bytes & 0x07;
    remainingBytes = 3;
  }
  else
  {
    return -1;
  }
  if (remainingBytes > length - 1) return -1;
  while (remainingBytes > 0)
  {
    bytes++;
    remainingBytes--;
    if ((*bytes & 0xc0) != 0x80) return -1;
    value = value << 6 | (*bytes & 0x3f);
  }
  return value;
}

variable_types:
length
unsigned int

variable_types:
remainingBytes
unsigned int


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

result = 0LL;
if ( (a1 & 0xC0) != 0x80 )
{
if ( (a1 & 0xF8) == 0xF0 )
{
result = 4LL;
}
else if ( (a1 & 0xF0) == 0xE0 )
{
result = 3LL;
}
else
{
result = (unsigned int)((a1 & 0xE0) == 0xC0) + 1;
}
}
return result;
}

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

result = 0LL;
if ( (a1 & 0xC0) != 0x80 )
{
if ( (a1 & 0xF8) == 0xF0 )
{
result = 4LL;
}
else if ( (a1 & 0xF0) == 0xE0 )
{
result = 3LL;
}
else
{
result = (unsigned int)((a1 & 0xE0) == 0xC0) + 1;
}
}
return result;
}

original_code:
int wrenUtf8DecodeNumBytes(uint8_t byte)
{
  if ((byte & 0xc0) == 0x80) return 0;
  if ((byte & 0xf8) == 0xf0) return 4;
  if ((byte & 0xf0) == 0xe0) return 3;
  if ((byte & 0xe0) == 0xc0) return 2;
  return 1;
}

canonical_original_code:
int wrenUtf8DecodeNumBytes(unsigned char byte)
{
  if ((byte & 0xc0) == 0x80) return 0;
  if ((byte & 0xf8) == 0xf0) return 4;
  if ((byte & 0xf0) == 0xe0) return 3;
  if ((byte & 0xe0) == 0xc0) return 2;
  return 1;
}

variable_types:
byte
unsigned char


wrenValidateIndex

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

if ( a2 >= 0 || (result = 0xFFFFFFFFLL, a2 += a1, a2 >= 0) )
{
result = 0xFFFFFFFFLL;
if ( a1 > a2 )
result = (unsigned int)a2;
}
return result;
}

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

if ( a2 >= 0 || (result = 0xFFFFFFFFLL, a2 += a1, a2 >= 0) )
{
result = 0xFFFFFFFFLL;
if ( a1 > a2 )
result = (unsigned int)a2;
}
return result;
}

original_code:
uint32_t wrenValidateIndex(uint32_t count, int64_t value)
{
  if (value < 0) value = count + value;
  if (value >= 0 && value < count) return (uint32_t)value;
  return (4294967295U);
}

canonical_original_code:
unsigned int wrenValidateIndex(unsigned int count, long value)
{
  if (value < 0) value = count + value;
  if (value >= 0 && value < count) return (unsigned int)value;
  return (4294967295U);
}

variable_types:
count
unsigned int

variable_types: value long


call

decompiled_code:
__int64 __fastcall call(__int64 a1, double a2, double a3, double a4, double a5)
{
int v5; // er14
__int64 v6; // rbx
__int64 v7; // r12
__int64 v8; // r13
int v9; // ebp
int v10; // ebp
double v11; // xmm0_8
__int64 result; // rax
double v13; // [rsp+0h] [rbp-A8h]
int v14; // [rsp+8h] [rbp-A0h]
char v15[152]; // [rsp+10h] [rbp-98h] BYREF

v5 = (int)wrenGetSlotDouble(a1, 1LL);
wrenInitConfiguration(v15);
v6 = wrenNewVM(v15);
wrenInterpret(v6, "main", testScript);
v7 = wrenMakeCallHandle(v6, "method(_,_,_,_)");
wrenEnsureSlots(v6, 1LL);
wrenGetVariable(v6, "main", "Test", 0LL);
v8 = wrenGetSlotHandle(v6, 0LL);
v14 = clock();
if ( v5 <= 0 )
{
v13 = 0.0;
}
else
{
v9 = 0;
v13 = 0.0;
do
{
wrenEnsureSlots(v6, 5LL);
wrenSetSlotHandle(v6, 0LL, v8);
wrenSetSlotDouble(v6, 1LL, 1.0);
wrenSetSlotDouble(v6, 2LL, 2.0);
wrenSetSlotDouble(v6, 3LL, 3.0);
wrenSetSlotDouble(v6, 4LL, 4.0);
wrenCall(v6, v7);
v13 = wrenGetSlotDouble(v6, 0LL) + v13;
++v9;
}
while ( v5 != v9 );
}
v10 = clock();
wrenReleaseHandle(v6, v8);
wrenReleaseHandle(v6, v7);
wrenFreeVM(v6);
v11 = (double)v5 * 10.0;
if ( v11 == v13 )
result = wrenSetSlotDouble(a1, 0LL, (double)v10 / 1000000.0 - (double)v14 / 1000000.0);
else
result = wrenSetSlotBool(a1, 0LL, 0LL, v11, a3, a4, a5, v13);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, double a2, double a3, double a4, double a5)
{
int v5; // er14
__int64 v6; // rbx
__int64 v7; // r12
__int64 v8; // r13
int v9; // ebp
int v10; // ebp
double v11; // xmm0_8
__int64 result; // rax
double v13; // [rsp+0h] [rbp-A8h]
int v14; // [rsp+8h] [rbp-A0h]
char v15[152]; // [rsp+10h] [rbp-98h] BYREF

v5 = (int)wrenGetSlotDouble(a1, 1LL);
wrenInitConfiguration(v15);
v6 = wrenNewVM(v15);
wrenInterpret(v6, "main", testScript);
v7 = wrenMakeCallHandle(v6, "method(_,_,_,_)");
wrenEnsureSlots(v6, 1LL);
wrenGetVariable(v6, "main", "Test", 0LL);
v8 = wrenGetSlotHandle(v6, 0LL);
v14 = clock();
if ( v5 <= 0 )
{
v13 = 0.0;
}
else
{
v9 = 0;
v13 = 0.0;
do
{
wrenEnsureSlots(v6, 5LL);
wrenSetSlotHandle(v6, 0LL, v8);
wrenSetSlotDouble(v6, 1LL, 1.0);
wrenSetSlotDouble(v6, 2LL, 2.0);
wrenSetSlotDouble(v6, 3LL, 3.0);
wrenSetSlotDouble(v6, 4LL, 4.0);
wrenCall(v6, v7);
v13 = wrenGetSlotDouble(v6, 0LL) + v13;
++v9;
}
while ( v5 != v9 );
}
v10 = clock();
wrenReleaseHandle(v6, v8);
wrenReleaseHandle(v6, v7);
wrenFreeVM(v6);
v11 = (double)v5 * 10.0;
if ( v11 == v13 )
result = wrenSetSlotDouble(a1, 0LL, (double)v10 / 1000000.0 - (double)v14 / 1000000.0);
else
result = wrenSetSlotBool(a1, 0LL, 0LL, v11, a3, a4, a5, v13);
return result;
}

original_code:
static void call(Compiler* compiler, _Bool canAssign)
{
  ignoreNewlines(compiler);
  consume(compiler, TOKEN_NAME, "Expect method name after '.'.");
  namedCall(compiler, canAssign, CODE_CALL_0);
}

canonical_original_code:
static void call(struct sCompiler *compiler, _Bool canAssign)
{
  ignoreNewlines(compiler);
  consume(compiler, TOKEN_NAME, "Expect method name after '.'.");
  namedCall(compiler, canAssign, CODE_CALL_0);
}

variable_types: struct sCompiler { struct Parser { struct WrenVM { struct sObjClass { struct sObj { enum ObjType { OBJ_CLASS=0, OBJ_CLOSURE=1, OBJ_FIBER=2, OBJ_FN=3, OBJ_FOREIGN=4, OBJ_INSTANCE=5, OBJ_LIST=6, OBJ_MAP=7, OBJ_MODULE=8, OBJ_RANGE=9, OBJ_STRING=10, OBJ_UPVALUE=11 } type; _Bool isDark; struct sObjClass *classObj; struct sObj *next; } obj; struct sObjClass *superclass; int numFields; struct MethodBuffer { struct Method { enum MethodType { METHOD_PRIMITIVE=0, METHOD_FUNCTION_CALL=1, METHOD_FOREIGN=2, METHOD_BLOCK=3, METHOD_NONE=4 } type; union { _Bool (*primitive)(struct WrenVM *vm, unsigned long *args); void (*foreign)(struct WrenVM *vm); struct ObjClosure { struct sObj obj; struct ObjFn { struct sObj obj; struct ByteBuffer { unsigned char *data; int count; int capacity; } code; struct ValueBuffer { unsigned long *data; int count; int capacity; } constants; struct ObjModule { struct sObj obj; struct ValueBuffer variables; struct StringBuffer { struct sObjString { struct sObj obj; unsigned int length; unsigned int hash; char value[]; } **data; int count; int capacity; } variableNames; struct sObjString *name; } *module; int maxSlots; int numUpvalues; int arity; struct FnDebug { char *name; struct IntBuffer { int *data; int count; int capacity; } sourceLines; } *debug; } *fn; struct sObjUpvalue { struct sObj obj; unsigned long *value; unsigned long closed; struct sObjUpvalue *next; } *upvalues[]; } *closure; } as; } *data; int count; int capacity; } methods; struct sObjString *name; unsigned long attributes; } *boolClass; struct sObjClass *classClass; struct sObjClass *fiberClass; struct sObjClass *fnClass; struct sObjClass *listClass; struct sObjClass *mapClass; struct sObjClass *nullClass; struct sObjClass *numClass; struct sObjClass *objectClass; struct sObjClass *rangeClass; struct sObjClass *stringClass; struct sObjFiber { struct sObj obj; unsigned long *stack; unsigned long *stackTop; int stackCapacity; struct CallFrame { unsigned char *ip; struct ObjClosure *closure; unsigned long *stackStart; } *frames; int numFrames; int frameCapacity; struct sObjUpvalue *openUpvalues; struct sObjFiber *caller; unsigned long error; enum FiberState { FIBER_TRY=0, FIBER_ROOT=1, FIBER_OTHER=2 } state; } *fiber; struct ObjMap { struct sObj obj; unsigned int capacity; unsigned int count; struct MapEntry { unsigned long key; unsigned long value; } *entries; } *modules; struct ObjModule *lastModule; unsigned long bytesAllocated; unsigned long nextGC; struct sObj *first; struct sObj **gray; int grayCount; int grayCapacity; struct sObj *tempRoots[8]; int numTempRoots; struct WrenHandle { unsigned long value; struct WrenHandle *prev; struct WrenHandle *next; } *handles; unsigned long *apiStack; struct WrenConfiguration { void *(*reallocateFn)(void *memory, unsigned long newSize, void *userData); char *(*resolveModuleFn)(struct WrenVM *vm, char *importer, char *name); struct WrenLoadModuleResult { char *source; void (*onComplete)(struct WrenVM *vm, char *name, struct WrenLoadModuleResult result); void *userData; } (*loadModuleFn)(struct WrenVM *vm, char *name); void (*(*bindForeignMethodFn)(struct WrenVM *vm, char *module, char *className, _Bool isStatic, char *signature))(struct WrenVM *vm); struct WrenForeignClassMethods { void (*allocate)(struct WrenVM *vm); void (*finalize)(void *data); } (*bindForeignClassFn)(struct WrenVM *vm, char *module, char *className); void (*writeFn)(struct WrenVM *vm, char *text); void (*errorFn)(struct WrenVM *vm, enum WrenErrorType { WREN_ERROR_COMPILE=0, WREN_ERROR_RUNTIME=1, WREN_ERROR_STACK_TRACE=2 } type, char *module, int line, char *message); unsigned long initialHeapSize; unsigned long minHeapSize; int heapGrowthPercent; void *userData; } config; struct sCompiler *compiler; struct StringBuffer methodNames; } *vm; struct ObjModule *module; char *source; char *tokenStart; char *currentChar; int currentLine; struct Token { enum TokenType { TOKEN_LEFT_PAREN=0, TOKEN_RIGHT_PAREN=1, TOKEN_LEFT_BRACKET=2, TOKEN_RIGHT_BRACKET=3, TOKEN_LEFT_BRACE=4, TOKEN_RIGHT_BRACE=5, TOKEN_COLON=6, TOKEN_DOT=7, TOKEN_DOTDOT=8, TOKEN_DOTDOTDOT=9, TOKEN_COMMA=10, TOKEN_STAR=11, TOKEN_SLASH=12, TOKEN_PERCENT=13, TOKEN_HASH=14, TOKEN_PLUS=15, TOKEN_MINUS=16, TOKEN_LTLT=17, TOKEN_GTGT=18, TOKEN_PIPE=19, TOKEN_PIPEPIPE=20, TOKEN_CARET=21, TOKEN_AMP=22, TOKEN_AMPAMP=23, TOKEN_BANG=24, TOKEN_TILDE=25, TOKEN_QUESTION=26, TOKEN_EQ=27, TOKEN_LT=28, TOKEN_GT=29, TOKEN_LTEQ=30, TOKEN_GTEQ=31, TOKEN_EQEQ=32, TOKEN_BANGEQ=33, TOKEN_BREAK=34, TOKEN_CONTINUE=35, TOKEN_CLASS=36, TOKEN_CONSTRUCT=37, TOKEN_ELSE=38, TOKEN_FALSE=39, TOKEN_FOR=40, TOKEN_FOREIGN=41, TOKEN_IF=42, TOKEN_IMPORT=43, TOKEN_AS=44, TOKEN_IN=45, TOKEN_IS=46, TOKEN_NULL=47, TOKEN_RETURN=48, TOKEN_STATIC=49, TOKEN_SUPER=50, TOKEN_THIS=51, TOKEN_TRUE=52, TOKEN_VAR=53, TOKEN_WHILE=54, TOKEN_FIELD=55, TOKEN_STATIC_FIELD=56, TOKEN_NAME=57, TOKEN_NUMBER=58, TOKEN_STRING=59, TOKEN_INTERPOLATION=60, TOKEN_LINE=61, TOKEN_ERROR=62, TOKEN_EOF=63 } type; char *start; int length; int line; unsigned long value; } next; struct Token current; struct Token previous; int parens[8]; int numParens; _Bool printErrors; _Bool hasError; } *parser; struct sCompiler *parent; struct Local { char *name; int length; int depth; _Bool isUpvalue; } locals[256]; int numLocals; struct CompilerUpvalue { _Bool isLocal; int index; } upvalues[256]; int scopeDepth; int numSlots; struct sLoop { int start; int exitJump; int body; int scopeDepth; struct sLoop *enclosing; } *loop; struct ClassInfo { struct sObjString *name; struct ObjMap *classAttributes; struct ObjMap *methodAttributes; struct StringBuffer fields; struct IntBuffer methods; struct IntBuffer staticMethods; _Bool isForeign; _Bool inStatic; struct Signature { char *name; int length; enum SignatureType { SIG_METHOD=0, SIG_GETTER=1, SIG_SETTER=2, SIG_SUBSCRIPT=3, SIG_SUBSCRIPT_SETTER=4, SIG_INITIALIZER=5 } type; int arity; } *signature; } *enclosingClass; struct ObjFn *fn; struct ObjMap *constants; _Bool isInitializer; int numAttributes; struct ObjMap *attributes; } *

user_defined_types: struct sObjClass { struct sObj obj; struct sObjClass *superclass; int numFields; struct MethodBuffer methods; struct sObjString *name; unsigned long attributes; }

user_defined_types: struct sObj { enum ObjType type; _Bool isDark; struct sObjClass *classObj; struct sObj *next; }

user_defined_types: struct StringBuffer { struct sObjString **data; int count; int capacity; }


isSeparator

decompiled_code:
bool __fastcall isSeparator(char a1)
{
return a1 == 47;
}

canonical_decompiled_code:
bool __fastcall func0(char a1)
{
return a1 == 47;
}

original_code:
inline static _Bool isSeparator(char c)
  {
    if (c == '/') return 1;
    return 0;
  }

variable_types: c char