decompiled_code:
void intern_free()
{
char *v0; // rdi
char **v1; // rbx

v0 = pstringz;
if ( pstringz )
{
v1 = &pstringz;
do
{
free(v0);
v0 = *++v1;
}
while ( *v1 );
}
}

canonical_decompiled_code:
void func1()
{
char *v0; // rdi
char **v1; // rbx

v0 = pstringz;
if ( pstringz )
{
v1 = &pstringz;
do
{
free(v0);
v0 = *++v1;
}
while ( *v1 );
}
}

original_code:
void
intern_free(void)
{
  const char **ptr;
  for (ptr = pstringz; *ptr != ((void *)0); ptr++) {
    if (*ptr != ((void *)0)) {
      free((void *) *ptr);
    }
  }
}

canonical_original_code:
void intern_free()
{
  char **ptr;
  for (ptr = pstringz; *ptr != ((void *)0); ptr++) {
    if (*ptr != ((void *)0)) {
      free((void *) *ptr);
    }
  }
}


repo: tmishra/lispkit

decompiled_code:
const char *__fastcall type_str(int a1)
{
const char *result; // rax

switch ( a1 )
{
case 1:
result = "symbol";
break;
case 2:
result = "number";
break;
case 3:
result = "dot";
break;
case 4:
result = "left paren";
break;
case 5:
result = "right paren";
break;
case 6:
result = "EOF";
break;
default:
result = "unknown";
break;
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func0(int a1)
{
const char *result; // rax

switch ( a1 )
{
case 1:
result = "symbol";
break;
case 2:
result = "number";
break;
case 3:
result = "dot";
break;
case 4:
result = "left paren";
break;
case 5:
result = "right paren";
break;
case 6:
result = "EOF";
break;
default:
result = "unknown";
break;
}
return result;
}

original_code:
char *type_str(int type) {
  switch(type) {
    case T_SYMBOL: return "symbol";
    case T_NUMBER: return "number";
    case T_DOT: return "dot";
    case T_LEFTPAREN: return "left paren";
    case T_RIGHTPAREN: return "right paren";
    case T_END: return "EOF";
  }
  return "unknown";
}

variable_types: type int

return_type: char *


decompiled_code:
__int64 token_type()
{
char *v0; // rax
char v1; // dl
__int64 result; // rax

v0 = (char *)token[1];
if ( !v0 )
return 6LL;
v1 = *v0;
if ( *v0 == 46 )
return 3LL;
if ( v1 > 46 )
return (unsigned int)((unsigned __int8)(v1 - 48) < 0xAu) + 1;
result = 4LL;
if ( v1 != 40 )
result = 4 * (unsigned int)(v1 == 41) + 1;
return result;
}

canonical_decompiled_code:
__int64 func1()
{
char *v0; // rax
char v1; // dl
__int64 result; // rax

v0 = (char *)token[1];
if ( !v0 )
return 6LL;
v1 = *v0;
if ( *v0 == 46 )
return 3LL;
if ( v1 > 46 )
return (unsigned int)((unsigned __int8)(v1 - 48) < 0xAu) + 1;
result = 4LL;
if ( v1 != 40 )
result = 4 * (unsigned int)(v1 == 41) + 1;
return result;
}

original_code:
int token_type(void) {
  if (token.token == ((void *)0)) return T_END;
  switch(token.token[0]) {
    case '.': return T_DOT;
    case '(': return T_LEFTPAREN;
    case ')': return T_RIGHTPAREN;
    case '0':
    case '1':
    case '2':
    case '3':
    case '4':
    case '5':
    case '6':
    case '7':
    case '8':
    case '9': return T_NUMBER;
    default: return T_SYMBOL;
  }
}

canonical_original_code:
int token_type() {
  if (token.token == ((void *)0)) return T_END;
  switch(token.token[0]) {
    case '.': return T_DOT;
    case '(': return T_LEFTPAREN;
    case ')': return T_RIGHTPAREN;
    case '0':
    case '1':
    case '2':
    case '3':
    case '4':
    case '5':
    case '6':
    case '7':
    case '8':
    case '9': return T_NUMBER;
    default: return T_SYMBOL;
  }
}

return_type: int


match

decompiled_code:
__int64 __fastcall match(unsigned int a1)
{
const char *v2; // rax

if ( (unsigned int)token_type() != a1 )
{
v2 = type_str(a1);
printf("Error - expected %d %s , got '%s'\n", a1, v2, (const char *)token[1]);
printf("Line %d, word %d\n", LODWORD(token[2]), HIDWORD(token[2]));
exit(-1);
}
return ((__int64 (*)(void))scanner)();
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1)
{
const char *v2; // rax

if ( (unsigned int)func1() != a1 )
{
v2 = func0(a1);
printf("Error - expected %d %s , got '%s'\n", a1, v2, (const char *)token[1]);
printf("Line %d, word %d\n", LODWORD(token[2]), HIDWORD(token[2]));
exit(-1);
}
return ((__int64 (*)(void))scanner)();
}

original_code:
void match(int type) {
  if (type != token_type()) {
    printf("Error - expected %d %s , got '%s'\n",
        type, type_str(type), token.token);
    printf("Line %d, word %d\n", token.line, token.word);
    exit(-1);
  }
  scanner();
}

return_type: void


decompiled_code:
__int64 s_exp_list()
{
__int64 v0; // rbx
__int64 v1; // rax
__int64 v2; // rbx
int v3; // eax

v0 = nil;
v1 = s_exp();
v2 = cons(v1, v0);
v3 = token_type();
if ( v3 == 3 )
{
match(3u);
*(_QWORD *)(v2 + 8) = s_exp();
}
else if ( (unsigned int)(v3 - 5) > 1 )
{
*(_QWORD *)(v2 + 8) = s_exp_list();
}
return v2;
}

original_code:
Object * s_exp_list(void) {
  Object *cell = _nil;
  cell = cons(s_exp(), _nil);
  switch(token_type()) {
    case T_RIGHTPAREN:
      break;
    case T_DOT:
      match(T_DOT);
      cell->Cons.cdr = s_exp();
      break;
    case T_END:
      break;
    default:
      cell->Cons.cdr = s_exp_list();
      break;
  }
  return cell;
}

canonical_original_code:
union Object *s_exp_list() {
  union Object *cell = _nil;
  cell = cons(s_exp(), _nil);
  switch(token_type()) {
    case T_RIGHTPAREN:
      break;
    case T_DOT:
      match(T_DOT);
      cell->Cons.cdr = s_exp();
      break;
    case T_END:
      break;
    default:
      cell->Cons.cdr = s_exp_list();
      break;
  }
  return cell;
}

variable_types: union Object { struct Number { long number; } Number; struct Symbol { char *symbol; } Symbol; struct Cons { union Object *car; union Object *cdr; } Cons; } *

user_defined_types: union Object { struct Number Number; struct Symbol Symbol; struct Cons Cons; }


decompiled_code:
__int64 s_exp()
{
int v0; // eax
unsigned int v1; // ebx
unsigned int v2; // eax
__int64 v3; // rbx
const char *v5; // rax

v0 = token_type();
if ( v0 == 4 )
{
match(4u);
v3 = s_exp_list();
match(5u);
return v3;
}
v1 = v0;
if ( v0 > 4 )
{
if ( v0 == 6 )
return nil;
LABEL_11:
v5 = type_str(v0);
printf("%s:%d error, did not expect type %d %s\n", "parser.c", 107LL, v1, v5);
exit(-1);
}
if ( v0 == 1 )
{
v3 = symbol(token[1]);
match(1u);
return v3;
}
if ( v0 != 2 )
goto LABEL_11;
v2 = atoi((const char *)token[1]);
v3 = number(v2);
match(2u);
return v3;
}

canonical_decompiled_code:
__int64 func4()
{
int v0; // eax
unsigned int v1; // ebx
unsigned int v2; // eax
__int64 v3; // rbx
const char *v5; // rax

v0 = func1();
if ( v0 == 4 )
{
func2(4u);
v3 = func3();
func2(5u);
return v3;
}
v1 = v0;
if ( v0 > 4 )
{
if ( v0 == 6 )
return nil;
LABEL_11:
v5 = func0(v0);
printf("%s:%d error, did not expect type %d %s\n", "parser.c", 107LL, v1, v5);
exit(-1);
}
if ( v0 == 1 )
{
v3 = symbol(token[1]);
func2(1u);
return v3;
}
if ( v0 != 2 )
goto LABEL_11;
v2 = atoi((const char *)token[1]);
v3 = number(v2);
func2(2u);
return v3;
}

original_code:
Object * s_exp(void) {
  Object *cell = _nil;
  switch(token_type()) {
    case T_NUMBER:
      cell = number(atoi(token.token));
      match(T_NUMBER);
      break;
    case T_SYMBOL:
      cell = symbol(token.token);
      match(T_SYMBOL);
      break;
    case T_LEFTPAREN:
      match(T_LEFTPAREN);
      cell = s_exp_list();
      match(T_RIGHTPAREN);
      break;
    case T_END:
      break;
    default:
      printf("%s:%d error, did not expect type %d %s\n",
          "parser.c", 107, token_type(), type_str(token_type()));
      exit(-1);
  }
  return cell;
}

canonical_original_code:
union Object *s_exp() {
  union Object *cell = _nil;
  switch(token_type()) {
    case T_NUMBER:
      cell = number(atoi(token.token));
      match(T_NUMBER);
      break;
    case T_SYMBOL:
      cell = symbol(token.token);
      match(T_SYMBOL);
      break;
    case T_LEFTPAREN:
      match(T_LEFTPAREN);
      cell = s_exp_list();
      match(T_RIGHTPAREN);
      break;
    case T_END:
      break;
    default:
      printf("%s:%d error, did not expect type %d %s\n",
          "parser.c", 107, token_type(), type_str(token_type()));
      exit(-1);
  }
  return cell;
}

return_type: union Object { struct Number { long number; } Number; struct Symbol { char *symbol; } Symbol; struct Cons { union Object *car; union Object *cdr; } Cons; } *


car

decompiled_code:
__int64 car()
{
__int64 v0; // rbx
__int64 v1; // rax
__int64 v2; // rax
__int64 result; // rax

v0 = cdr(stack);
v1 = car(stack);
v2 = car(v1);
stack = cons(v2, v0);
result = cdr(control);
control = result;
return result;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 v0; // rbx
__int64 v1; // rax
__int64 v2; // rax
__int64 result; // rax

v0 = func4(stack);
v1 = func3(stack);
v2 = func3(v1);
stack = func5(v2, v0);
result = func4(control);
control = result;
return result;
}

original_code:
Object * car(Object *obj) {
  if (((struct GCHeader *)obj - 1)->type != CONS) {
    printf("car error\n");
    exit(-1);
  }
  return obj->Cons.car;
}

canonical_original_code:
union Object *car(union Object *obj) {
  if (((struct GCHeader *)obj - 1)->type != CONS) {
    printf("car error\n");
    exit(-1);
  }
  return obj->Cons.car;
}

variable_types:
obj
union Object *

user_defined_types: struct GCHeader { int size; int type; int marked; int id; }

user_defined_types: struct Cons { union Object *car; union Object *cdr; }


cdr

decompiled_code:
__int64 cdr()
{
__int64 v0; // rbx
__int64 v1; // rax
__int64 v2; // rax
__int64 result; // rax

v0 = cdr(stack);
v1 = car(stack);
v2 = cdr(v1);
stack = cons(v2, v0);
result = cdr(control);
control = result;
return result;
}

canonical_decompiled_code:
__int64 func4()
{
__int64 v0; // rbx
__int64 v1; // rax
__int64 v2; // rax
__int64 result; // rax

v0 = func4(stack);
v1 = func3(stack);
v2 = func4(v1);
stack = func5(v2, v0);
result = func4(control);
control = result;
return result;
}

original_code:
Object * cdr(Object *obj) {
  if (((struct GCHeader *)obj - 1)->type != CONS) {
    printf("cdr error\n");
    exit(-1);
  }
  return obj->Cons.cdr;
}

canonical_original_code:
union Object *cdr(union Object *obj) {
  if (((struct GCHeader *)obj - 1)->type != CONS) {
    printf("cdr error\n");
    exit(-1);
  }
  return obj->Cons.cdr;
}


cons

decompiled_code:
__int64 cons()
{
__int64 v0; // rax
__int64 v1; // rbx
__int64 v2; // rax
__int64 v3; // rbp
__int64 v4; // rax
__int64 v5; // rax
__int64 result; // rax

v0 = cdr(stack);
v1 = cdr(v0);
v2 = cdr(stack);
v3 = car(v2);
v4 = car(stack);
v5 = cons(v4, v3);
stack = cons(v5, v1);
result = cdr(control);
control = result;
return result;
}

canonical_decompiled_code:
__int64 func5()
{
__int64 v0; // rax
__int64 v1; // rbx
__int64 v2; // rax
__int64 v3; // rbp
__int64 v4; // rax
__int64 v5; // rax
__int64 result; // rax

v0 = func4(stack);
v1 = func4(v0);
v2 = func4(stack);
v3 = func3(v2);
v4 = func3(stack);
v5 = func5(v4, v3);
stack = func5(v5, v1);
result = func4(control);
control = result;
return result;
}

original_code:
Object * cons(Object *_car, Object *_cdr) {
  Object *obj = object_alloc();
  ((struct GCHeader *)obj - 1)->type = CONS;
  obj->Cons.car = _car;
  obj->Cons.cdr = _cdr;
  return obj;
}

canonical_original_code:
union Object *cons(union Object *_car, union Object *_cdr) {
  union Object *obj = object_alloc();
  ((struct GCHeader *)obj - 1)->type = CONS;
  obj->Cons.car = _car;
  obj->Cons.cdr = _cdr;
  return obj;
}


execute

decompiled_code:
__int64 __fastcall execute(__int64 a1, __int64 a2)
{
__int64 v2; // rdi
int v3; // eax

stack = cons(a2, nil);
environ = (char **)nil;
control = a1;
dump = nil;
stopped = 0;
do
{
v2 = car(control);
v3 = number_value(v2);
((void (*)(void))op_code[v3])();
}
while ( !stopped );
return stack;
}

canonical_decompiled_code:
__int64 __fastcall func21(__int64 a1, __int64 a2)
{
__int64 v2; // rdi
int v3; // eax

stack = func5(a2, nil);
environ = (char **)nil;
control = a1;
dump = nil;
stopped = 0;
do
{
v2 = func3(control);
v3 = number_value(v2);
((void (*)(void))op_code[v3])();
}
while ( !stopped );
return stack;
}

original_code:
Object * execute(Object *fn, Object *args) {
  _stack = cons(args, _nil);
  _environ = _nil;
  _control = fn;
  _dump = _nil;
  stopped = 0;
  for ( ; stopped == 0; ) {
    op_code[number_value(car(_control))]();
  }
  return _stack;
}

canonical_original_code:
union Object *execute(union Object *fn, union Object *args) {
  _stack = cons(args, _nil);
  _environ = _nil;
  _control = fn;
  _dump = _nil;
  stopped = 0;
  for ( ; stopped == 0; ) {
    op_code[number_value(car(_control))]();
  }
  return _stack;
}

variable_types:
fn
union Object *

variable_types:
args
union Object *


init

decompiled_code:
char **init()
{
char **result; // rax

gc_init();
true = symbol(&unk_D14);
false = symbol(&unk_D16);
result = (char **)symbol(&unk_D18);
nil = (__int64)result;
stack = (__int64)result;
control = (__int64)result;
environ = result;
dump = (__int64)result;
work = (__int64)result;
return result;
}

canonical_decompiled_code:
char **func22()
{
char **result; // rax

gc_init();
true = symbol(&unk_D14);
false = symbol(&unk_D16);
result = (char **)symbol(&unk_D18);
nil = (__int64)result;
stack = (__int64)result;
control = (__int64)result;
environ = result;
dump = (__int64)result;
work = (__int64)result;
return result;
}

original_code:
void init() {
  gc_init();
  _true = symbol("T");
  _false = symbol("F");
  _nil = symbol("NIL");
  _stack = _nil;
  _control = _nil;
  _environ = _nil;
  _dump = _nil;
  _work = _nil;
}


decompiled_code:
void __fastcall gc_mark(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rax

if ( !*(_DWORD *)(a1 - 8) )
{
*(_DWORD *)(a1 - 8) = 1;
if ( !(unsigned int)is_atom() )
{
v1 = car(a1);
gc_mark(v1);
v2 = cdr(a1);
gc_mark(v2);
}
}
}

original_code:
void
gc_mark(Object * object)
{
  if (((struct GCHeader *)object - 1)->marked == 0) {
    ((struct GCHeader *)object - 1)->marked = 1;
    if (is_atom(object) == 0) {
      gc_mark(car(object));
      gc_mark(cdr(object));
    }
  }
}

canonical_original_code:
void gc_mark(union Object *object)
{
  if (((struct GCHeader *)object - 1)->marked == 0) {
    ((struct GCHeader *)object - 1)->marked = 1;
    if (is_atom(object) == 0) {
      gc_mark(car(object));
      gc_mark(cdr(object));
    }
  }
}


decompiled_code:
void *gc_init()
{
char *v0; // rax
unsigned int v1; // ebp
char *v2; // rbx
void *result; // rax
char *v4; // rdx
char *v5; // rcx

if ( getenv("LISPKIT_MEMORY") )
{
v0 = getenv("LISPKIT_MEMORY");
v1 = atoi(v0);
v2 = (char *)calloc(v1, 0x20uLL);
mem = v2;
result = calloc(v1, 8uLL);
cells = result;
alloc_counter = 0;
collect_counter = 0;
ff = 0LL;
if ( !v1 )
return result;
}
else
{
v2 = (char *)calloc(0x4000uLL, 0x20uLL);
mem = v2;
cells = calloc(0x4000uLL, 8uLL);
alloc_counter = 0;
collect_counter = 0;
ff = 0LL;
v1 = 0x4000;
}
v4 = v2 + 16;
result = 0LL;
do
{
*((_QWORD *)cells + (_QWORD)result) = v4;
v5 = (char *)cells + 8 * (_QWORD)result;
*(_QWORD *)(*(_QWORD *)v5 + 8LL) = ff;
ff = *(_QWORD *)v5;
result = (char *)result + 1;
v4 += 32;
}
while ( v1 > (unsigned int)result );
return result;
}

canonical_decompiled_code:
void *func1()
{
char *v0; // rax
unsigned int v1; // ebp
char *v2; // rbx
void *result; // rax
char *v4; // rdx
char *v5; // rcx

if ( getenv("LISPKIT_MEMORY") )
{
v0 = getenv("LISPKIT_MEMORY");
v1 = atoi(v0);
v2 = (char *)calloc(v1, 0x20uLL);
mem = v2;
result = calloc(v1, 8uLL);
cells = result;
alloc_counter = 0;
collect_counter = 0;
ff = 0LL;
if ( !v1 )
return result;
}
else
{
v2 = (char *)calloc(0x4000uLL, 0x20uLL);
mem = v2;
cells = calloc(0x4000uLL, 8uLL);
alloc_counter = 0;
collect_counter = 0;
ff = 0LL;
v1 = 0x4000;
}
v4 = v2 + 16;
result = 0LL;
do
{
*((_QWORD *)cells + (_QWORD)result) = v4;
v5 = (char *)cells + 8 * (_QWORD)result;
*(_QWORD *)(*(_QWORD *)v5 + 8LL) = ff;
ff = *(_QWORD *)v5;
result = (char *)result + 1;
v4 += 32;
}
while ( v1 > (unsigned int)result );
return result;
}

original_code:
void
gc_init()
{
  const unsigned cell_size = sizeof(struct GCHeader) + sizeof(Object);
  unsigned char *ptr;
  unsigned num_cells;
  int i;
  num_cells = getenv("LISPKIT_MEMORY") ?
    atoi(getenv("LISPKIT_MEMORY")) : 16384;
  mem = calloc(num_cells, cell_size);
  cells = calloc(num_cells, sizeof(Object *));
  alloc_counter = 0;
  collect_counter = 0;
  ff = ((void *)0);
  for (i = 0, ptr = mem; i < num_cells; i++, ptr += cell_size) {
    cells[i] = (Object *) ((struct GCHeader *) ptr + 1);
    cells[i]->Cons.cdr = ff;
    ff = cells[i];
  }
}

canonical_original_code:
void gc_init()
{
  unsigned int cell_size = sizeof(struct GCHeader) + sizeof(Object);
  unsigned char *ptr;
  unsigned int num_cells;
  int i;
  num_cells = getenv("LISPKIT_MEMORY") ?
    atoi(getenv("LISPKIT_MEMORY")) : 16384;
  mem = calloc(num_cells, cell_size);
  cells = calloc(num_cells, sizeof(union Object *));
  alloc_counter = 0;
  collect_counter = 0;
  ff = ((void *)0);
  for (i = 0, ptr = mem; i < num_cells; i++, ptr += cell_size) {
    cells[i] = (union Object *) ((struct GCHeader *) ptr + 1);
    cells[i]->Cons.cdr = ff;
    ff = cells[i];
  }
}

variable_types:
ptr
unsigned char *

variable_types: i int


decompiled_code:
void gc_exit()
{
free(mem);
free(cells);
}

canonical_decompiled_code:
void func2()
{
free(mem);
free(cells);
}


decompiled_code:
char *gc_collect()
{
char *result; // rax
char *v1; // rcx

result = (char *)cells;
v1 = (char *)cells + 0x20000;
do
{
if ( !*(_DWORD *)(*(_QWORD *)result - 8LL) )
{
*(_QWORD *)(*(_QWORD *)result + 8LL) = ff;
ff = *(_QWORD *)result;
++collect_counter;
}
result += 8;
}
while ( result != v1 );
return result;
}

canonical_decompiled_code:
char *func3()
{
char *result; // rax
char *v1; // rcx

result = (char *)cells;
v1 = (char *)cells + 0x20000;
do
{
if ( !*(_DWORD *)(*(_QWORD *)result - 8LL) )
{
*(_QWORD *)(*(_QWORD *)result + 8LL) = ff;
ff = *(_QWORD *)result;
++collect_counter;
}
result += 8;
}
while ( result != v1 );
return result;
}

original_code:
void
gc_collect()
{
  int i;
  for (i = 0; i < 16384; i++) {
    if (((struct GCHeader *)cells[i] - 1)->marked == 0) {
      cells[i]->Cons.cdr = ff;
      ff = cells[i];
      collect_counter++;
    }
  }
}


decompiled_code:
char *gc_collect_garbage()
{
__int64 i; // rax
char *result; // rax

for ( i = 0LL; i != 0x20000; i += 8LL )
*(_DWORD *)(*(_QWORD *)((char *)cells + i) - 8LL) = 0;
gc_mark(stack);
gc_mark((__int64)environ);
gc_mark(control);
gc_mark(dump);
gc_mark(work);
gc_mark(true);
gc_mark(false);
gc_mark(nil);
result = gc_collect();
if ( !ff )
{
printf("out of memory: %s", "gc_collect_garbage");
exit(-1);
}
return result;
}

canonical_decompiled_code:
char *func4()
{
__int64 i; // rax
char *result; // rax

for ( i = 0LL; i != 0x20000; i += 8LL )
*(_DWORD *)(*(_QWORD *)((char *)cells + i) - 8LL) = 0;
func0(stack);
func0((__int64)environ);
func0(control);
func0(dump);
func0(work);
func0(true);
func0(false);
func0(nil);
result = func3();
if ( !ff )
{
printf("out of memory: %s", "gc_collect_garbage");
exit(-1);
}
return result;
}

original_code:
void
gc_collect_garbage()
{
  int i;
  for (i = 0; i < 16384; i++) {
    ((struct GCHeader *)cells[i] - 1)->marked = 0;
  }
  gc_mark(_stack);
  gc_mark(_environ);
  gc_mark(_control);
  gc_mark(_dump);
  gc_mark(_work);
  gc_mark(_true);
  gc_mark(_false);
  gc_mark(_nil);
  gc_collect();
  if (ff == ((void *)0)) {
    printf("out of memory: %s", __func__);
    exit(-1);
  }
}


decompiled_code:
__int64 gc_alloc()
{
__int64 result; // rax

if ( !ff )
gc_collect_garbage();
result = ff;
ff = *(_QWORD *)(ff + 8);
*(_DWORD *)(result - 12) = 0;
*(_DWORD *)(result - 4) = 0;
++alloc_counter;
return result;
}

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

if ( !ff )
func4();
result = ff;
ff = *(_QWORD *)(ff + 8);
*(_DWORD *)(result - 12) = 0;
*(_DWORD *)(result - 4) = 0;
++alloc_counter;
return result;
}

original_code:
Object *
gc_alloc()
{
  Object *object;
  static unsigned _id = 0;
  if (ff == ((void *)0)) {
    gc_collect_garbage();
  }
  object = ff;
  ff = ff->Cons.cdr;
  ((struct GCHeader *)object - 1)->type = 0;
  ((struct GCHeader *)object - 1)->id = _id;
  alloc_counter++;
  return object;
}

canonical_original_code:
union Object *gc_alloc()
{
  union Object *object;
  static unsigned int _id = 0;
  if (ff == ((void *)0)) {
    gc_collect_garbage();
  }
  object = ff;
  ff = ff->Cons.cdr;
  ((struct GCHeader *)object - 1)->type = 0;
  ((struct GCHeader *)object - 1)->id = _id;
  alloc_counter++;
  return object;
}


decompiled_code:
int gc_stats()
{
printf("cells allocated: %u\n", (unsigned int)alloc_counter);
return printf("cells collected: %u\n", (unsigned int)collect_counter);
}

canonical_decompiled_code:
int func6()
{
printf("cells allocated: %u\n", (unsigned int)alloc_counter);
return printf("cells collected: %u\n", (unsigned int)collect_counter);
}

original_code:
void
gc_stats()
{
  printf("cells allocated: %u\n", alloc_counter);
  printf("cells collected: %u\n", collect_counter);
}


decompiled_code:
_BOOL8 __fastcall is_null(__int64 a1)
{
_BOOL8 result; // rax
const char *v2; // rbp
const char *v3; // rax

result = 0LL;
if ( *(_DWORD *)(a1 - 12) == 2 )
{
v2 = (const char *)string_value(nil);
v3 = (const char *)string_value(a1);
result = strcmp(v3, v2) == 0;
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(__int64 a1)
{
_BOOL8 result; // rax
const char *v2; // rbp
const char *v3; // rax

result = 0LL;
if ( *(_DWORD *)(a1 - 12) == 2 )
{
v2 = (const char *)string_value(nil);
v3 = (const char *)string_value(a1);
result = strcmp(v3, v2) == 0;
}
return result;
}

original_code:
int is_null(Object *obj)
{
  return
      ( (((struct GCHeader *)obj - 1)->type == SYMBOL)
       && (strcmp(string_value(obj), string_value(_nil)) == 0) );
}

canonical_original_code:
int is_null(union Object *obj)
{
  return
      ( (((struct GCHeader *)obj - 1)->type == SYMBOL)
       && (strcmp(string_value(obj), string_value(_nil)) == 0) );
}


print

decompiled_code:
void __fastcall print(const char **a1)
{
__int64 v1; // rsi
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax

if ( a1 && (const char **)nil != a1 )
{
v1 = *((unsigned int *)a1 - 3);
switch ( (_DWORD)v1 )
{
case 1:
printf("%ld ", *a1);
break;
case 2:
printf("%s ", *a1);
break;
case 3:
if ( *(_DWORD *)(((__int64 (*)(void))car)() - 12) == 3
|| *(_DWORD *)(cdr(a1) - 12) == 3
|| (v4 = cdr(a1), is_null(v4)) )
{
if ( *(_DWORD *)(car(a1) - 12) == 3 )
printf("( ");
v2 = car(a1);
print(v2);
if ( *(_DWORD *)(car(a1) - 12) == 3 )
printf(") ");
v3 = cdr(a1);
if ( !is_null(v3) )
{
v7 = cdr(a1);
print(v7);
}
}
else
{
v5 = car(a1);
print(v5);
printf(". ");
v6 = cdr(a1);
print(v6);
}
break;
default:
printf("Unknown type: %d\n", v1);
exit(-1);
}
}
}

canonical_decompiled_code:
void __fastcall func1(const char **a1)
{
__int64 v1; // rsi
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax

if ( a1 && (const char **)nil != a1 )
{
v1 = *((unsigned int *)a1 - 3);
switch ( (_DWORD)v1 )
{
case 1:
printf("%ld ", *a1);
break;
case 2:
printf("%s ", *a1);
break;
case 3:
if ( *(_DWORD *)(((__int64 (*)(void))car)() - 12) == 3
|| *(_DWORD *)(cdr(a1) - 12) == 3
|| (v4 = cdr(a1), func0(v4)) )
{
if ( *(_DWORD *)(car(a1) - 12) == 3 )
printf("( ");
v2 = car(a1);
func1(v2);
if ( *(_DWORD *)(car(a1) - 12) == 3 )
printf(") ");
v3 = cdr(a1);
if ( !func0(v3) )
{
v7 = cdr(a1);
func1(v7);
}
}
else
{
v5 = car(a1);
func1(v5);
printf(". ");
v6 = cdr(a1);
func1(v6);
}
break;
default:
printf("Unknown type: %d\n", v1);
exit(-1);
}
}
}

original_code:
void
print(Object * obj)
{
  if (!obj || obj == _nil )
    return;
  if (((struct GCHeader *)obj - 1)->type == NUMBER) {
    printf("%ld ", obj->Number.number);
  } else if (((struct GCHeader *)obj - 1)->type == SYMBOL) {
    printf("%s ", obj->Symbol.symbol);
  } else if (((struct GCHeader *)obj - 1)->type == CONS) {
    if (((struct GCHeader *)car(obj) - 1)->type != CONS
        && ((struct GCHeader *)cdr(obj) - 1)->type != CONS
        && !is_null(cdr(obj))
 ) {
      print(car(obj));
      printf(". ");
      print(cdr(obj));
    } else {
      if (((struct GCHeader *)car(obj) - 1)->type == CONS)
 printf("( ");
      print(car(obj));
      if (((struct GCHeader *)car(obj) - 1)->type == CONS)
 printf(") ");
      if (!is_null(cdr(obj))) {
      print(cdr(obj));
      }
    }
  } else {
    printf("Unknown type: %d\n", ((struct GCHeader *)obj - 1)->type);
    exit(-1);
  }
}

canonical_original_code:
void print(union Object *obj)
{
  if (!obj || obj == _nil )
    return;
  if (((struct GCHeader *)obj - 1)->type == NUMBER) {
    printf("%ld ", obj->Number.number);
  } else if (((struct GCHeader *)obj - 1)->type == SYMBOL) {
    printf("%s ", obj->Symbol.symbol);
  } else if (((struct GCHeader *)obj - 1)->type == CONS) {
    if (((struct GCHeader *)car(obj) - 1)->type != CONS
        && ((struct GCHeader *)cdr(obj) - 1)->type != CONS
        && !is_null(cdr(obj))
 ) {
      print(car(obj));
      printf(". ");
      print(cdr(obj));
    } else {
      if (((struct GCHeader *)car(obj) - 1)->type == CONS)
 printf("( ");
      print(car(obj));
      if (((struct GCHeader *)car(obj) - 1)->type == CONS)
 printf(") ");
      if (!is_null(cdr(obj))) {
      print(cdr(obj));
      }
    }
  } else {
    printf("Unknown type: %d\n", ((struct GCHeader *)obj - 1)->type);
    exit(-1);
  }
}


decompiled_code:
__int64 object_alloc()
{
return gc_alloc();
}

canonical_decompiled_code:
__int64 func0()
{
return gc_alloc();
}

original_code:
Object * object_alloc() {
  return gc_alloc();
}

canonical_original_code:
union Object *object_alloc() {
  return gc_alloc();
}


car

decompiled_code:
__int64 __fastcall car(__int64 a1)
{
if ( *(_DWORD *)(a1 - 12) != 3 )
{
puts("car error");
exit(-1);
}
return *(_QWORD *)a1;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
if ( *(_DWORD *)(a1 - 12) != 3 )
{
puts("car error");
exit(-1);
}
return *(_QWORD *)a1;
}


cdr

decompiled_code:
__int64 __fastcall cdr(__int64 a1)
{
if ( *(_DWORD *)(a1 - 12) != 3 )
{
puts("cdr error");
exit(-1);
}
return *(_QWORD *)(a1 + 8);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
if ( *(_DWORD *)(a1 - 12) != 3 )
{
puts("cdr error");
exit(-1);
}
return *(_QWORD *)(a1 + 8);
}


decompiled_code:
_BOOL8 __fastcall is_symbol(__int64 a1)
{
return *(_DWORD *)(a1 - 12) == 2;
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(__int64 a1)
{
return *(_DWORD *)(a1 - 12) == 2;
}

original_code:
int is_symbol(Object *obj) {
  return ((struct GCHeader *)obj - 1)->type == SYMBOL;
}

canonical_original_code:
int is_symbol(union Object *obj) {
  return ((struct GCHeader *)obj - 1)->type == SYMBOL;
}


decompiled_code:
_BOOL8 __fastcall is_number(__int64 a1)
{
return *(_DWORD *)(a1 - 12) == 1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func4(__int64 a1)
{
return *(_DWORD *)(a1 - 12) == 1;
}

original_code:
int is_number(Object *obj) {
  return ((struct GCHeader *)obj - 1)->type == NUMBER;
}

canonical_original_code:
int is_number(union Object *obj) {
  return ((struct GCHeader *)obj - 1)->type == NUMBER;
}


decompiled_code:
_BOOL8 __fastcall is_atom(__int64 a1)
{
_BOOL4 v1; // edx
_BOOL8 result; // rax

v1 = is_symbol(a1);
result = 1LL;
if ( !v1 )
result = is_number(a1);
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func5(__int64 a1)
{
_BOOL4 v1; // edx
_BOOL8 result; // rax

v1 = func3(a1);
result = 1LL;
if ( !v1 )
result = func4(a1);
return result;
}

original_code:
int is_atom(Object *obj) {
  return is_symbol(obj) || is_number(obj);
}

canonical_original_code:
int is_atom(union Object *obj) {
  return is_symbol(obj) || is_number(obj);
}


decompiled_code:
_BOOL8 __fastcall is_cons(__int64 a1)
{
return *(_DWORD *)(a1 - 12) == 3;
}

canonical_decompiled_code:
_BOOL8 __fastcall func6(__int64 a1)
{
return *(_DWORD *)(a1 - 12) == 3;
}

original_code:
int is_cons(Object *obj) {
  return ((struct GCHeader *)obj - 1)->type == CONS;
}

canonical_original_code:
int is_cons(union Object *obj) {
  return ((struct GCHeader *)obj - 1)->type == CONS;
}


decompiled_code:
__int64 __fastcall string_value(__int64 a1)
{
if ( *(_DWORD *)(a1 - 12) != 2 )
{
puts("object is not a symbol");
exit(-1);
}
return *(_QWORD *)a1;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
if ( *(_DWORD *)(a1 - 12) != 2 )
{
puts("object is not a symbol");
exit(-1);
}
return *(_QWORD *)a1;
}

original_code:
const char * string_value(Object *obj) {
  if (((struct GCHeader *)obj - 1)->type != SYMBOL) {
    printf("object is not a symbol\n");
    exit(-1);
  }
  return obj->Symbol.symbol;
}

canonical_original_code:
char *string_value(union Object *obj) {
  if (((struct GCHeader *)obj - 1)->type != SYMBOL) {
    printf("object is not a symbol\n");
    exit(-1);
  }
  return obj->Symbol.symbol;
}


decompiled_code:
__int64 __fastcall number_value(__int64 a1)
{
if ( *(_DWORD *)(a1 - 12) != 1 )
{
puts("object is not a number");
exit(-1);
}
return *(_QWORD *)a1;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
if ( *(_DWORD *)(a1 - 12) != 1 )
{
puts("object is not a number");
exit(-1);
}
return *(_QWORD *)a1;
}

original_code:
int number_value(Object *obj) {
  if (((struct GCHeader *)obj - 1)->type != NUMBER) {
    printf("object is not a number\n");
    exit(-1);
  }
  return obj->Number.number;
}

canonical_original_code:
int number_value(union Object *obj) {
  if (((struct GCHeader *)obj - 1)->type != NUMBER) {
    printf("object is not a number\n");
    exit(-1);
  }
  return obj->Number.number;
}


scanner

decompiled_code:
__int64 scanner()
{
int v0; // eax
__int64 v1; // rsi
__int64 result; // rax

v0 = cur_tok++;
v1 = (unsigned int)cur_tok;
result = token_stack[v0];
token[1] = result;
if ( (int)v1 > 0x3FFF )
{
printf("scanner is out of tokens %d/%d)\n", v1, 0x4000LL);
exit(-1);
}
return result;
}

canonical_decompiled_code:
__int64 func0()
{
int v0; // eax
__int64 v1; // rsi
__int64 result; // rax

v0 = cur_tok++;
v1 = (unsigned int)cur_tok;
result = token_stack[v0];
token[1] = result;
if ( (int)v1 > 0x3FFF )
{
printf("scanner is out of tokens %d/%d)\n", v1, 0x4000LL);
exit(-1);
}
return result;
}

original_code:
void scanner(void) {
  token.token = token_stack[cur_tok++];
  if (cur_tok >= 16384) {
    printf("scanner is out of tokens %d/%d)\n", cur_tok, 16384);
    exit(-1);
  }
}

canonical_original_code:
void scanner() {
  token.token = token_stack[cur_tok++];
  if (cur_tok >= 16384) {
    printf("scanner is out of tokens %d/%d)\n", cur_tok, 16384);
    exit(-1);
  }
}


decompiled_code:
void tokenizer_free()
{
void **v0; // rbx

v0 = (void **)token_stack;
do
{
if ( *v0 )
free(*v0);
*v0++ = 0LL;
}
while ( v0 != (void **)(unsigned int)((_DWORD)token_stack + 0x20000) );
}

canonical_decompiled_code:
void func2()
{
void **v0; // rbx

v0 = (void **)token_stack;
do
{
if ( *v0 )
free(*v0);
*v0++ = 0LL;
}
while ( v0 != (void **)(unsigned int)((_DWORD)token_stack + 0x20000) );
}

original_code:
void tokenizer_free(void) {
  int i = 0;
  for (i = 0; i < 16384; i++) {
    if (token_stack[i] != ((void *)0)) {
      free(token_stack[i]);
    }
    token_stack[i] = ((void *)0);
  }
}

canonical_original_code:
void tokenizer_free() {
  int i = 0;
  for (i = 0; i < 16384; i++) {
    if (token_stack[i] != ((void *)0)) {
      free(token_stack[i]);
    }
    token_stack[i] = ((void *)0);
  }
}


decompiled_code:
void __fastcall free_list(void *ptr)
{
free(*((void **)ptr + 2));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func7(void *ptr)
{
free(*((void **)ptr + 2));
free(ptr);
}

original_code:
void free_list(plist list) {
  free(list->array);
  free(list);
  list = ((void *)0);
}

canonical_original_code:
void free_list(struct python_list *list) {
  free(list->array);
  free(list);
  list = ((void *)0);
}

variable_types: struct python_list { int capacity; int size; int type_size; unsigned char *array; } *


size

decompiled_code:
__int64 __fastcall size(__int64 a1)
{
return *(unsigned int *)(a1 + 4);
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
return *(unsigned int *)(a1 + 4);
}

original_code:
int size(plist list) {
  return list->size;
}

canonical_original_code:
int size(struct python_list *list) {
  return list->size;
}

user_defined_types: struct python_list { int capacity; int size; int type_size; unsigned char *array; }


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

v1 = realloc(*(void **)(a1 + 16), *(_DWORD *)(a1 + 8) * *(_DWORD *)a1 + 20);
*(_QWORD *)(a1 + 16) = v1;
if ( !v1 )
{
printf("realloc failed");
exit(1);
}
result = (unsigned int)((*(_DWORD *)a1 * *(_DWORD *)(a1 + 8) + 20) / *(_DWORD *)(a1 + 8));
*(_DWORD *)a1 = result;
return result;
}

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

v1 = realloc(*(void **)(a1 + 16), *(_DWORD *)(a1 + 8) * *(_DWORD *)a1 + 20);
*(_QWORD *)(a1 + 16) = v1;
if ( !v1 )
{
printf("realloc failed");
exit(1);
}
result = (unsigned int)((*(_DWORD *)a1 * *(_DWORD *)(a1 + 8) + 20) / *(_DWORD *)(a1 + 8));
*(_DWORD *)a1 = result;
return result;
}

original_code:
void expand_capacity(plist list) {
  if (!(list->array = realloc(list->array,
          (list->capacity*list->type_size)+20))){
    printf("realloc failed");
    exit(1);
  }else{
   list->capacity = ((list->capacity*list->type_size) + 20)/list->type_size;
  }
}

canonical_original_code:
void expand_capacity(struct python_list *list) {
  if (!(list->array = realloc(list->array,
          (list->capacity*list->type_size)+20))){
    printf("realloc failed");
    exit(1);
  }else{
   list->capacity = ((list->capacity*list->type_size) + 20)/list->type_size;
  }
}


append

decompiled_code:
__int64 __fastcall append(__int64 a1, __int64 a2)
{
int v2; // eax
__int64 result; // rax
__int64 src; // [rsp+8h] [rbp-10h] BYREF

src = a2;
memcpy((void *)(*(_QWORD *)(a1 + 16) + *(_DWORD *)(a1 + 4) * *(_DWORD *)(a1 + 8)), &src, *(int *)(a1 + 8));
v2 = *(_DWORD *)(a1 + 4);
*(_DWORD *)(a1 + 4) = v2 + 1;
result = (unsigned int)(v2 + 2);
if ( (int)result >= *(_DWORD *)a1 )
result = expand_capacity(a1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, __int64 a2)
{
int v2; // eax
__int64 result; // rax
__int64 src; // [rsp+8h] [rbp-10h] BYREF

src = a2;
memcpy((void *)(*(_QWORD *)(a1 + 16) + *(_DWORD *)(a1 + 4) * *(_DWORD *)(a1 + 8)), &src, *(int *)(a1 + 8));
v2 = *(_DWORD *)(a1 + 4);
*(_DWORD *)(a1 + 4) = v2 + 1;
result = (unsigned int)(v2 + 2);
if ( (int)result >= *(_DWORD *)a1 )
result = func9(a1);
return result;
}

original_code:
void append(plist list, void *value) {
  int shift = list->size * list->type_size;
  memcpy(list->array+shift, &value, list->type_size);
  list->size++;
  if (list->size+1 >= list->capacity) {
    expand_capacity(list);
  }
}

canonical_original_code:
void append(struct python_list *list, void *value) {
  int shift = list->size * list->type_size;
  memcpy(list->array+shift, &value, list->type_size);
  list->size++;
  if (list->size+1 >= list->capacity) {
    expand_capacity(list);
  }
}

variable_types:
value
void *

variable_types: shift int


set

decompiled_code:
void *__fastcall set(__int64 a1, __int64 a2, __int64 a3)
{
__int64 src; // [rsp+8h] [rbp-10h] BYREF

src = a3;
if ( (int)a2 < 0 && *(_DWORD *)(a1 + 4) <= (int)a2 )
{
printf("Index %d out of range.\n", a2);
exit(1);
}
return memcpy((void *)(*(_QWORD *)(a1 + 16) + *(_DWORD *)(a1 + 8) * (int)a2), &src, *(int *)(a1 + 8));
}

canonical_decompiled_code:
void *__fastcall func11(__int64 a1, __int64 a2, __int64 a3)
{
__int64 src; // [rsp+8h] [rbp-10h] BYREF

src = a3;
if ( (int)a2 < 0 && *(_DWORD *)(a1 + 4) <= (int)a2 )
{
printf("Index %d out of range.\n", a2);
exit(1);
}
return memcpy((void *)(*(_QWORD *)(a1 + 16) + *(_DWORD *)(a1 + 8) * (int)a2), &src, *(int *)(a1 + 8));
}

original_code:
void set(plist list, int index, void *value){
  if(!(0<=index || index<list->size)){
   printf("Index %d out of range.\n",index);
   exit(1);
 }
  int shift = index * list->type_size;
  memcpy(list->array+shift, &value, list->type_size);
}

canonical_original_code:
void set(struct python_list *list, int index, void *value){
  if(!(0<=index || index<list->size)){
   printf("Index %d out of range.\n",index);
   exit(1);
 }
  int shift = index * list->type_size;
  memcpy(list->array+shift, &value, list->type_size);
}

variable_types: index int


get

decompiled_code:
__int64 __fastcall get(__int64 a1, __int64 a2)
{
if ( (int)a2 < 0 && *(_DWORD *)(a1 + 4) <= (int)a2 )
{
printf("Index %d out of range.\n", a2);
exit(1);
}
return *(unsigned __int8 *)(*(_QWORD *)(a1 + 16) + *(_DWORD *)(a1 + 8) * (int)a2);
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, __int64 a2)
{
if ( (int)a2 < 0 && *(_DWORD *)(a1 + 4) <= (int)a2 )
{
printf("Index %d out of range.\n", a2);
exit(1);
}
return *(unsigned __int8 *)(*(_QWORD *)(a1 + 16) + *(_DWORD *)(a1 + 8) * (int)a2);
}

original_code:
void *get(plist list, int index){
  if(!(0<=index || index<list->size)){
   printf("Index %d out of range.\n",index);
   exit(1);
 }
  int real_index = index * list->type_size;
  return (void *)list->array[real_index];
}

canonical_original_code:
void *get(struct python_list *list, int index){
  if(!(0<=index || index<list->size)){
   printf("Index %d out of range.\n",index);
   exit(1);
 }
  int real_index = index * list->type_size;
  return (void *)list->array[real_index];
}

return_type: void *


repo: tobbik/parcle

decompiled_code:
_QWORD *populate_used()
{
__int64 i; // rbx
__int64 v1; // rdi
_QWORD *result; // rax

for ( i = frees; i; result = add_to_useds((_QWORD *)v1) )
{
v1 = i;
i = *(_QWORD *)(i + 8);
if ( *(int *)(v1 + 24) <= 3 )
break;
frees = i;
}
return result;
}

canonical_decompiled_code:
_QWORD *func7()
{
__int64 i; // rbx
__int64 v1; // rdi
_QWORD *result; // rax

for ( i = frees; i; result = add_to_useds((_QWORD *)v1) )
{
v1 = i;
i = *(_QWORD *)(i + 8);
if ( *(int *)(v1 + 24) <= 3 )
break;
frees = i;
}
return result;
}

original_code:
static void populate_used ()
{
 struct node *tmp, *tmp1;
 tmp = _frees;
 while (((void *)0) != tmp) {
  tmp1 = tmp->next;
  if (tmp->data>3) {
   _frees = tmp1;
   add_to_useds (tmp);
  }
  else
   break;
  tmp=tmp1;
 }
}

canonical_original_code:
static void populate_used()
{
 struct node *tmp; struct node *tmp1;
 tmp = _frees;
 while (((void *)0) != tmp) {
  tmp1 = tmp->next;
  if (tmp->data>3) {
   _frees = tmp1;
   add_to_useds (tmp);
  }
  else
   break;
  tmp=tmp1;
 }
}

variable_types: struct node { struct node *prev; struct node *next; struct node *queue; int data; } *


original_code:
static void remove_from_useds (struct node *nd)
{
 if (((void *)0) == _useds) {
  return;
 }
 else if (((void *)0) == nd->prev) {
  if (((void *)0) == nd->next) {
   _useds = ((void *)0);
  }
  else {
   nd->next->prev = ((void *)0);
   _useds = nd->next;
  }
 }
 else if (((void *)0) == nd->next) {
  nd->prev->next = ((void *)0);
  nd->prev = ((void *)0);
 }
 else {
  nd->prev->next = nd->next;
  nd->next->prev = nd->prev;
 }
 nd->next = _frees;
 nd->prev = ((void *)0);
 _frees = nd;
}

canonical_original_code:
static void remove_from_useds(struct node *nd)
{
 if (((void *)0) == _useds) {
  return;
 }
 else if (((void *)0) == nd->prev) {
  if (((void *)0) == nd->next) {
   _useds = ((void *)0);
  }
  else {
   nd->next->prev = ((void *)0);
   _useds = nd->next;
  }
 }
 else if (((void *)0) == nd->next) {
  nd->prev->next = ((void *)0);
  nd->prev = ((void *)0);
 }
 else {
  nd->prev->next = nd->next;
  nd->next->prev = nd->prev;
 }
 nd->next = _frees;
 nd->prev = ((void *)0);
 _frees = nd;
}

user_defined_types: struct node { struct node *prev; struct node *next; struct node *queue; int data; }


decompiled_code:
void from_useds_to_frees()
{
__int64 v0; // rbx
__int64 v1; // rdi

v0 = useds;
while ( v0 )
{
printf("%d ", *(unsigned int *)(v0 + 24));
v1 = v0;
v0 = *(_QWORD *)(v0 + 8);
if ( (*(_BYTE *)(v1 + 24) & 1) != 0 )
remove_from_useds((__int64 *)v1);
}
}

original_code:
static void from_useds_to_frees ()
{
 struct node *tmp,*tmp1;
 tmp = _useds;
 while (((void *)0) != tmp) {
  printf("%d  ", tmp->data);
  tmp1=tmp->next;
  if (tmp->data%2)
   remove_from_useds (tmp);
  tmp=tmp1;
 }
}

canonical_original_code:
static void from_useds_to_frees()
{
 struct node *tmp; struct node *tmp1;
 tmp = _useds;
 while (((void *)0) != tmp) {
  printf("%d  ", tmp->data);
  tmp1=tmp->next;
  if (tmp->data%2)
   remove_from_useds (tmp);
  tmp=tmp1;
 }
}


decompiled_code:
int __fastcall list_list(__int64 *a1)
{
__int64 *v1; // rbx
int result; // eax
__int64 *v3; // rbp
__int64 v4; // rax

v1 = a1;
result = puts("prev\tdata\tnext");
if ( a1 )
{
while ( 1 )
{
v3 = (__int64 *)v1[1];
v4 = *v1;
if ( v3 && *v1 )
{
printf("%d\t%d\t%d\n", *(unsigned int *)(v4 + 24), *((unsigned int *)v1 + 6), *((unsigned int *)v3 + 6));
}
else if ( !v4 && v3 )
{
printf(" \t%d\t%d\n", *((unsigned int *)v1 + 6), *((unsigned int *)v3 + 6));
}
else
{
if ( !v3 && *v1 )
return printf("%d\t%d\t \n", *(unsigned int *)(v4 + 24), *((unsigned int *)v1 + 6));
result = printf(" \t%d\t \n", *((unsigned int *)v1 + 6));
if ( !v3 )
return result;
}
v1 = v3;
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func10(__int64 *a1)
{
__int64 *v1; // rbx
int result; // eax
__int64 *v3; // rbp
__int64 v4; // rax

v1 = a1;
result = puts("prev\tdata\tnext");
if ( a1 )
{
while ( 1 )
{
v3 = (__int64 *)v1[1];
v4 = *v1;
if ( v3 && *v1 )
{
printf("%d\t%d\t%d\n", *(unsigned int *)(v4 + 24), *((unsigned int *)v1 + 6), *((unsigned int *)v3 + 6));
}
else if ( !v4 && v3 )
{
printf(" \t%d\t%d\n", *((unsigned int *)v1 + 6), *((unsigned int *)v3 + 6));
}
else
{
if ( !v3 && *v1 )
return printf("%d\t%d\t \n", *(unsigned int *)(v4 + 24), *((unsigned int *)v1 + 6));
result = printf(" \t%d\t \n", *((unsigned int *)v1 + 6));
if ( !v3 )
return result;
}
v1 = v3;
}
}
return result;
}

original_code:
static void list_list (struct node *nd)
{
 struct node *tmp, *tmp1;
 tmp=nd;
 printf("prev\tdata\tnext\n" );
 while (((void *)0) != tmp) {
  tmp1 = tmp->next;
  if (((void *)0) != tmp->prev && ((void *)0) != tmp->next)
   printf("%d\t%d\t%d\n", tmp->prev->data, tmp->data, tmp->next->data );
  else if (((void *)0) == tmp->prev && ((void *)0) != tmp->next)
   printf("  \t%d\t%d\n", tmp->data, tmp->next->data );
  else if (((void *)0) != tmp->prev && ((void *)0) == tmp->next)
   printf("%d\t%d\t  \n", tmp->prev->data, tmp->data);
  else
   printf("  \t%d\t  \n", tmp->data);
  tmp=tmp1;
 }
}

canonical_original_code:
static void list_list(struct node *nd)
{
 struct node *tmp; struct node *tmp1;
 tmp=nd;
 printf("prev\tdata\tnext\n" );
 while (((void *)0) != tmp) {
  tmp1 = tmp->next;
  if (((void *)0) != tmp->prev && ((void *)0) != tmp->next)
   printf("%d\t%d\t%d\n", tmp->prev->data, tmp->data, tmp->next->data );
  else if (((void *)0) == tmp->prev && ((void *)0) != tmp->next)
   printf("  \t%d\t%d\n", tmp->data, tmp->next->data );
  else if (((void *)0) != tmp->prev && ((void *)0) == tmp->next)
   printf("%d\t%d\t  \n", tmp->prev->data, tmp->data);
  else
   printf("  \t%d\t  \n", tmp->data);
  tmp=tmp1;
 }
}


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int i; // ebx
__int64 v4; // rbp
_QWORD *v5; // rax

for ( i = 0; i != 10; ++i )
{
v4 = frees;
v5 = calloc(1uLL, 0x20uLL);
frees = (__int64)v5;
v5[1] = v4;
*v5 = 0LL;
v5[2] = 0LL;
*((_DWORD *)v5 + 6) = i;
}
list_list(v5);
populate_used();
list_list((__int64 *)frees);
list_list((__int64 *)useds);
from_useds_to_frees();
list_list((__int64 *)frees);
list_list((__int64 *)useds);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int i; // ebx
__int64 v4; // rbp
_QWORD *v5; // rax

for ( i = 0; i != 10; ++i )
{
v4 = frees;
v5 = calloc(1uLL, 0x20uLL);
frees = (__int64)v5;
v5[1] = v4;
*v5 = 0LL;
v5[2] = 0LL;
*((_DWORD *)v5 + 6) = i;
}
func10(v5);
func7();
func10((__int64 *)frees);
func10((__int64 *)useds);
func9();
func10((__int64 *)frees);
func10((__int64 *)useds);
return 0;
}

original_code:
int main ()
{
 int i;
 struct node *tmp;
 for (i=0; i<10; i++) {
  tmp = _frees;
  _frees = (struct node *) calloc (1, sizeof(struct node));
  _frees->next = tmp;
  _frees->prev = ((void *)0);
  _frees->queue = ((void *)0);
  _frees->data = i;
 }
 list_list(_frees);
 populate_used();
 list_list(_frees);
 list_list(_useds);
 from_useds_to_frees();
 list_list(_frees);
 list_list(_useds);
 return 0;
}

canonical_original_code:
int main()
{
 int i;
 struct node *tmp;
 for (i=0; i<10; i++) {
  tmp = _frees;
  _frees = (struct node *) calloc (1, sizeof(struct node));
  _frees->next = tmp;
  _frees->prev = ((void *)0);
  _frees->queue = ((void *)0);
  _frees->data = i;
 }
 list_list(_frees);
 populate_used();
 list_list(_frees);
 list_list(_useds);
 from_useds_to_frees();
 list_list(_frees);
 list_list(_useds);
 return 0;
}


decompiled_code:
void check_sockets()
{
_QWORD *v0; // rax

v0 = Busy_conns;
if ( Busy_conns )
{
do
v0 = (_QWORD *)*v0;
while ( v0 );
}
}

canonical_decompiled_code:
void func0()
{
_QWORD *v0; // rax

v0 = Busy_conns;
if ( Busy_conns )
{
do
v0 = (_QWORD *)*v0;
while ( v0 );
}
}

original_code:
static void
check_sockets (int sig)
{
 struct cn_strct *tmp1, *tmp2;
 tmp1 = _Busy_conns;
 while (((void *)0) != tmp1) {
  tmp2 = tmp1->c_next;
  tmp1 = tmp2;
 }
}

canonical_original_code:
static void check_sockets(int sig)
{
 struct cn_strct *tmp1; struct cn_strct *tmp2;
 tmp1 = _Busy_conns;
 while (((void *)0) != tmp1) {
  tmp2 = tmp1->c_next;
  tmp1 = tmp2;
 }
}

variable_types: sig int

variable_types: struct cn_strct { struct cn_strct *c_next; struct cn_strct *c_prev; struct cn_strct *q_prev; enum req_states { REQSTATE_READ_HEAD=0, REQSTATE_SEND_HEAD=1, REQSTATE_BUFF_HEAD=2, REQSTATE_SEND_FILE=3 } req_state; int net_socket; char *data_buf_head; char *data_buf; int processed_bytes; char *url; enum bool { false=0, true=1 } is_static; int identifier; } *

user_defined_types: struct cn_strct { struct cn_strct *c_next; struct cn_strct *c_prev; struct cn_strct *q_prev; enum req_states req_state; int net_socket; char *data_buf_head; char *data_buf; int processed_bytes; char *url; enum bool is_static; int identifier; }


decompiled_code:
int __fastcall write_head(__int64 a1)
{
time_t v1; // rax
struct tm *v3; // rax

v1 = time(0LL);
if ( v1 - Last_loop > 0 )
{
Last_loop = v1;
v3 = gmtime(&Last_loop);
strftime(Master_date, 0x1EuLL, "%a, %d %b %Y %H:%M:%S %Z", v3);
}
pthread_mutex_lock(&pull_job_mutex);
if ( Queue_tail )
{
*(_QWORD *)(Queue_tail + 16) = a1;
Queue_tail = a1;
++Queue_count;
}
else
{
Queue_head = a1;
Queue_tail = a1;
Queue_count = 1;
}
pthread_mutex_unlock(&pull_job_mutex);
*(_DWORD *)(a1 + 24) = 2;
return pthread_cond_signal(&wake_worker_cond);
}

canonical_decompiled_code:
int __fastcall func1(__int64 a1)
{
time_t v1; // rax
struct tm *v3; // rax

v1 = time(0LL);
if ( v1 - Last_loop > 0 )
{
Last_loop = v1;
v3 = gmtime(&Last_loop);
strftime(Master_date, 0x1EuLL, "%a, %d %b %Y %H:%M:%S %Z", v3);
}
pthread_mutex_lock(&pull_job_mutex);
if ( Queue_tail )
{
*(_QWORD *)(Queue_tail + 16) = a1;
Queue_tail = a1;
++Queue_count;
}
else
{
Queue_head = a1;
Queue_tail = a1;
Queue_count = 1;
}
pthread_mutex_unlock(&pull_job_mutex);
*(_DWORD *)(a1 + 24) = 2;
return pthread_cond_signal(&wake_worker_cond);
}

original_code:
void
write_head (struct cn_strct *cn)
{
 time_t now = time(((void *)0));
 struct tm *tm_struct;
 if (now-_Last_loop>0) {
  _Last_loop = now;
  tm_struct = gmtime(&_Last_loop);
  strftime( _Master_date, 30, "%a, %d %b %Y %H:%M:%S %Z", tm_struct);
 }
 pthread_mutex_lock( &pull_job_mutex );
 if (((void *)0) == _Queue_tail) {
  _Queue_tail = _Queue_head = cn;
  _Queue_count = 1;
 }
 else {
  _Queue_tail->q_prev = cn;
  _Queue_tail = cn;
  _Queue_count++;
 }
 pthread_mutex_unlock( &pull_job_mutex );
 cn->req_state = REQSTATE_BUFF_HEAD;
 pthread_cond_signal (&wake_worker_cond);
}

canonical_original_code:
void write_head(struct cn_strct *cn)
{
 long now = time(((void *)0));
 struct tm *tm_struct;
 if (now-_Last_loop>0) {
  _Last_loop = now;
  tm_struct = gmtime(&_Last_loop);
  strftime( _Master_date, 30, "%a, %d %b %Y %H:%M:%S %Z", tm_struct);
 }
 pthread_mutex_lock( &pull_job_mutex );
 if (((void *)0) == _Queue_tail) {
  _Queue_tail = _Queue_head = cn;
  _Queue_count = 1;
 }
 else {
  _Queue_tail->q_prev = cn;
  _Queue_tail = cn;
  _Queue_count++;
 }
 pthread_mutex_unlock( &pull_job_mutex );
 cn->req_state = REQSTATE_BUFF_HEAD;
 pthread_cond_signal (&wake_worker_cond);
}

variable_types: now long

variable_types: struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long tm_gmtoff; char *tm_zone; } *

user_defined_types: enum req_states { REQSTATE_READ_HEAD=0, REQSTATE_SEND_HEAD=1, REQSTATE_BUFF_HEAD=2, REQSTATE_SEND_FILE=3 }


decompiled_code:
int __fastcall c_response(__int64 a1)
{
int result; // eax

result = snprintf(
*(char **)(a1 + 32),
0x2004uLL,
"HTTP/1.1 200 OK\r\n"
"Server: %s\r\n"
"Content-Type: text/html\r\n"
"Content-Length: %Zd\r\n"
"Date: %s\r\n"
"Last-Modified: %s\r\n"
"\r\n"
"%s",
"testserver/poc",
7176LL,
Master_date,
Master_date,
aDoctypeHtmlPub);
*(_DWORD *)(a1 + 48) = result;
return result;
}

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

result = snprintf(
*(char **)(a1 + 32),
0x2004uLL,
"HTTP/1.1 200 OK\r\n"
"Server: %s\r\n"
"Content-Type: text/html\r\n"
"Content-Length: %Zd\r\n"
"Date: %s\r\n"
"Last-Modified: %s\r\n"
"\r\n"
"%s",
"testserver/poc",
7176LL,
Master_date,
Master_date,
aDoctypeHtmlPub);
*(_DWORD *)(a1 + 48) = result;
return result;
}

original_code:
static void
c_response ( struct cn_strct *cn)
{
 char *page = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n  \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\" >\n\n\n  <title>I'm the Favicon substitute</title>\n  <meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />\n\n\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n\n\n";
 cn->processed_bytes = snprintf(
  cn->data_buf_head, 8196,
  "HTTP/1.1"" 200 OK\r\n"
  "Server: %s\r\n"
  "Content-Type: text/html\r\n"
  "Content-Length: %Zd\r\n"
  "Date: %s\r\n"
  "Last-Modified: %s\r\n\r\n%s"
  , _Server_version, strlen(page),
  _Master_date, _Master_date, page
 );
}

canonical_original_code:
static void c_response(struct cn_strct *cn)
{
 char *page = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n  \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\" >\n\n\n  <title>I'm the Favicon substitute</title>\n  <meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />\n\n\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n  I am a line: Amazing isn't it totally blowing your mind! ?!
\n\n\n";
 cn->processed_bytes = snprintf(
  cn->data_buf_head, 8196,
  "HTTP/1.1"" 200 OK\r\n"
  "Server: %s\r\n"
  "Content-Type: text/html\r\n"
  "Content-Length: %Zd\r\n"
  "Date: %s\r\n"
  "Last-Modified: %s\r\n\r\n%s"
  , _Server_version, strlen(page),
  _Master_date, _Master_date, page
 );
}

variable_types:
page
char *


decompiled_code:
void __fastcall __noreturn run_app_thread(void *a1)
{
__int64 v1; // rbx

while ( 1 )
{
pthread_mutex_lock(&wake_worker_mutex);
while ( !Queue_head )
pthread_cond_wait(&wake_worker_cond, &wake_worker_mutex);
pthread_mutex_unlock(&wake_worker_mutex);
pthread_mutex_lock(&pull_job_mutex);
v1 = Queue_head;
if ( Queue_head )
{
--Queue_count;
if ( *(_QWORD *)(Queue_head + 16) )
{
Queue_head = *(_QWORD *)(Queue_head + 16);
*(_QWORD *)(v1 + 16) = 0LL;
}
else
{
Queue_head = 0LL;
Queue_tail = 0LL;
}
pthread_mutex_unlock(&pull_job_mutex);
c_response(v1);
*(_QWORD *)(v1 + 40) = *(_QWORD *)(v1 + 32);
send(*(_DWORD *)(v1 + 28), &unk_EEF, 0LL, 0);
*(_DWORD *)(v1 + 24) = 3;
pthread_cond_signal(&wake_worker_cond);
}
else
{
puts("QUEUE MISSED!!");
pthread_mutex_unlock(&pull_job_mutex);
}
}
}

canonical_decompiled_code:
void __fastcall __noreturn func3(void *a1)
{
__int64 v1; // rbx

while ( 1 )
{
pthread_mutex_lock(&wake_worker_mutex);
while ( !Queue_head )
pthread_cond_wait(&wake_worker_cond, &wake_worker_mutex);
pthread_mutex_unlock(&wake_worker_mutex);
pthread_mutex_lock(&pull_job_mutex);
v1 = Queue_head;
if ( Queue_head )
{
--Queue_count;
if ( *(_QWORD *)(Queue_head + 16) )
{
Queue_head = *(_QWORD *)(Queue_head + 16);
*(_QWORD *)(v1 + 16) = 0LL;
}
else
{
Queue_head = 0LL;
Queue_tail = 0LL;
}
pthread_mutex_unlock(&pull_job_mutex);
func2(v1);
*(_QWORD *)(v1 + 40) = *(_QWORD *)(v1 + 32);
send(*(_DWORD *)(v1 + 28), &unk_EEF, 0LL, 0);
*(_DWORD *)(v1 + 24) = 3;
pthread_cond_signal(&wake_worker_cond);
}
else
{
puts("QUEUE MISSED!!");
pthread_mutex_unlock(&pull_job_mutex);
}
}
}

original_code:
void
*run_app_thread (void *tid)
{
 struct cn_strct *cn;
 int id = *((int*) tid);
 int sent;
 while(1) {
  pthread_mutex_lock( &wake_worker_mutex );
  while (((void *)0) == _Queue_head) {
   pthread_cond_wait( &wake_worker_cond, &wake_worker_mutex );
  }
  pthread_mutex_unlock( &wake_worker_mutex );
  pthread_mutex_lock ( &pull_job_mutex );
  if (((void *)0) == _Queue_head) {
   printf("QUEUE MISSED!!\n");
   pthread_mutex_unlock ( &pull_job_mutex );
   continue;
  }
  else {
   cn = _Queue_head;
   _Queue_count--;
   if (((void *)0) == _Queue_head->q_prev) {
    _Queue_head = ((void *)0);
    _Queue_tail = ((void *)0);
   }
   else {
    _Queue_head = cn->q_prev;
    cn->q_prev = ((void *)0);
   }
  }
  pthread_mutex_unlock ( &pull_job_mutex );
  c_response(cn);
  cn->data_buf = cn->data_buf_head;
  sent = send (cn->net_socket, "", 0, 0);
  cn->req_state = REQSTATE_SEND_FILE;
  if (REQSTATE_SEND_FILE != cn->req_state) {
   printf("DAMMIT!\n");
   sent = send (cn->net_socket, "", 0, 0);
   cn->req_state = REQSTATE_SEND_FILE;
  }
  if (REQSTATE_SEND_FILE != cn->req_state)
   printf("FUCK IT!\n");
  pthread_cond_signal (&wake_worker_cond);
 }
}

canonical_original_code:
void *run_app_thread(void *tid)
{
 struct cn_strct *cn;
 int id = *((int*) tid);
 int sent;
 while(1) {
  pthread_mutex_lock( &wake_worker_mutex );
  while (((void *)0) == _Queue_head) {
   pthread_cond_wait( &wake_worker_cond, &wake_worker_mutex );
  }
  pthread_mutex_unlock( &wake_worker_mutex );
  pthread_mutex_lock ( &pull_job_mutex );
  if (((void *)0) == _Queue_head) {
   printf("QUEUE MISSED!!\n");
   pthread_mutex_unlock ( &pull_job_mutex );
   continue;
  }
  else {
   cn = _Queue_head;
   _Queue_count--;
   if (((void *)0) == _Queue_head->q_prev) {
    _Queue_head = ((void *)0);
    _Queue_tail = ((void *)0);
   }
   else {
    _Queue_head = cn->q_prev;
    cn->q_prev = ((void *)0);
   }
  }
  pthread_mutex_unlock ( &pull_job_mutex );
  c_response(cn);
  cn->data_buf = cn->data_buf_head;
  sent = send (cn->net_socket, "", 0, 0);
  cn->req_state = REQSTATE_SEND_FILE;
  if (REQSTATE_SEND_FILE != cn->req_state) {
   printf("DAMMIT!\n");
   sent = send (cn->net_socket, "", 0, 0);
   cn->req_state = REQSTATE_SEND_FILE;
  }
  if (REQSTATE_SEND_FILE != cn->req_state)
   printf("FUCK IT!\n");
  pthread_cond_signal (&wake_worker_cond);
 }
}

variable_types:
tid
void *

variable_types: id int

variable_types: sent int


decompiled_code:
void __fastcall remove_conn_from_list(int *a1)
{
_QWORD *v1; // rax
__int64 v2; // rdx
int v3; // edi

if ( a1 )
{
v1 = (_QWORD *)*((_QWORD *)a1 + 1);
if ( v1 )
{
v2 = *(_QWORD *)a1;
if ( *(_QWORD *)a1 )
{
*v1 = v2;
*(_QWORD *)(v2 + 8) = *((_QWORD *)a1 + 1);
}
else
{
*v1 = 0LL;
--Busy_count;
}
}
else
{
if ( *(_QWORD *)a1 )
{
*(_QWORD *)(*(_QWORD *)a1 + 8LL) = 0LL;
Busy_conns = *(void **)a1;
}
else
{
Busy_conns = 0LL;
}
--Busy_count;
}
*(_QWORD *)a1 = Free_conns;
*((_QWORD *)a1 + 1) = 0LL;
Free_conns = a1;
++Free_count;
v3 = a1[7];
if ( v3 != -1 )
close(v3);
}
}

canonical_decompiled_code:
void __fastcall func4(int *a1)
{
_QWORD *v1; // rax
__int64 v2; // rdx
int v3; // edi

if ( a1 )
{
v1 = (_QWORD *)*((_QWORD *)a1 + 1);
if ( v1 )
{
v2 = *(_QWORD *)a1;
if ( *(_QWORD *)a1 )
{
*v1 = v2;
*(_QWORD *)(v2 + 8) = *((_QWORD *)a1 + 1);
}
else
{
*v1 = 0LL;
--Busy_count;
}
}
else
{
if ( *(_QWORD *)a1 )
{
*(_QWORD *)(*(_QWORD *)a1 + 8LL) = 0LL;
Busy_conns = *(void **)a1;
}
else
{
Busy_conns = 0LL;
}
--Busy_count;
}
*(_QWORD *)a1 = Free_conns;
*((_QWORD *)a1 + 1) = 0LL;
Free_conns = a1;
++Free_count;
v3 = a1[7];
if ( v3 != -1 )
close(v3);
}
}

original_code:
void
remove_conn_from_list( struct cn_strct *cn )
{
 struct cn_strct *tp;
 tp = cn;
 if (tp == ((void *)0) || cn == ((void *)0))
  return;
 if (((void *)0) == tp->c_prev) {
  if (((void *)0) == tp->c_next) {
   _Busy_conns = ((void *)0);
  }
  else {
   tp->c_next->c_prev = ((void *)0);
   _Busy_conns = tp->c_next;
  }
  _Busy_count--;
 }
 else if (((void *)0) == tp->c_next) {
  tp->c_prev->c_next = ((void *)0);
  tp->c_prev = ((void *)0);
  _Busy_count--;
 }
 else {
  tp->c_prev->c_next = tp->c_next;
  tp->c_next->c_prev = tp->c_prev;
 }
 cn->c_next = _Free_conns;
 cn->c_prev = ((void *)0);
 _Free_conns = cn;
 _Free_count++;
 if (cn->net_socket != -1) {
  close(cn->net_socket);
 }
}

canonical_original_code:
void remove_conn_from_list(struct cn_strct *cn)
{
 struct cn_strct *tp;
 tp = cn;
 if (tp == ((void *)0) || cn == ((void *)0))
  return;
 if (((void *)0) == tp->c_prev) {
  if (((void *)0) == tp->c_next) {
   _Busy_conns = ((void *)0);
  }
  else {
   tp->c_next->c_prev = ((void *)0);
   _Busy_conns = tp->c_next;
  }
  _Busy_count--;
 }
 else if (((void *)0) == tp->c_next) {
  tp->c_prev->c_next = ((void *)0);
  tp->c_prev = ((void *)0);
  _Busy_count--;
 }
 else {
  tp->c_prev->c_next = tp->c_next;
  tp->c_next->c_prev = tp->c_prev;
 }
 cn->c_next = _Free_conns;
 cn->c_prev = ((void *)0);
 _Free_conns = cn;
 _Free_count++;
 if (cn->net_socket != -1) {
  close(cn->net_socket);
 }
}


original_code:
void
send_file (struct cn_strct *cn)
{
 int sent = send (cn->net_socket, cn->data_buf,
  cn->processed_bytes, 0);
 if (0 > sent) {
  remove_conn_from_list(cn);
 }
 else if (cn->processed_bytes == sent) {
  remove_conn_from_list(cn);
 }
 else if (0 == sent) {
 }
 else {
  cn->data_buf = cn->data_buf + sent;
  cn->processed_bytes -= sent;
 }
}

canonical_original_code:
void send_file(struct cn_strct *cn)
{
 int sent = send (cn->net_socket, cn->data_buf,
  cn->processed_bytes, 0);
 if (0 > sent) {
  remove_conn_from_list(cn);
 }
 else if (cn->processed_bytes == sent) {
  remove_conn_from_list(cn);
 }
 else if (0 == sent) {
 }
 else {
  cn->data_buf = cn->data_buf + sent;
  cn->processed_bytes -= sent;
 }
}


decompiled_code:
int __fastcall list_queue(__int64 a1, unsigned int a2)
{
int result; // eax
__int64 v3; // rbx
int v4; // ebp
__int64 v5; // rax

result = puts("q_prev\tdata\tq_next");
v3 = a1;
v4 = 0;
if ( a1 )
{
while ( 1 )
{
v5 = v3;
v3 = *(_QWORD *)(v3 + 16);
if ( !v3 )
break;
printf("%d\t%d\t \t%d\n", *(unsigned int *)(v3 + 68), *(unsigned int *)(v5 + 68), a2);
++v4;
if ( a1 == v3 && v4 > 0 )
return puts("DETECTED LOOP ");
}
result = printf(" \t%d\t \t%d\n", *(unsigned int *)(v5 + 68), a2);
}
return result;
}

canonical_decompiled_code:
int __fastcall func6(__int64 a1, unsigned int a2)
{
int result; // eax
__int64 v3; // rbx
int v4; // ebp
__int64 v5; // rax

result = puts("q_prev\tdata\tq_next");
v3 = a1;
v4 = 0;
if ( a1 )
{
while ( 1 )
{
v5 = v3;
v3 = *(_QWORD *)(v3 + 16);
if ( !v3 )
break;
printf("%d\t%d\t \t%d\n", *(unsigned int *)(v3 + 68), *(unsigned int *)(v5 + 68), a2);
++v4;
if ( a1 == v3 && v4 > 0 )
return puts("DETECTED LOOP ");
}
result = printf(" \t%d\t \t%d\n", *(unsigned int *)(v5 + 68), a2);
}
return result;
}

original_code:
static void
list_queue (struct cn_strct *nd, int count)
{
 struct cn_strct *tmp, *tmp1;
 int cnt = 0;
 tmp=nd;
 printf( "q_prev\tdata\tq_next\n" );
 while (((void *)0) != tmp) {
  if (tmp == nd && 0 < cnt) {
   printf("DETECTED LOOP \n");
   break;
  }
  tmp1 = tmp->q_prev;
  if (((void *)0) == tmp->q_prev)
   printf("  \t%d\t  \t%d\n", tmp->identifier, count);
  else
   printf("%d\t%d\t  \t%d\n", tmp->q_prev->identifier, tmp->identifier, count);
  tmp=tmp1;
  cnt++;
 }
}

canonical_original_code:
static void list_queue(struct cn_strct *nd, int count)
{
 struct cn_strct *tmp; struct cn_strct *tmp1;
 int cnt = 0;
 tmp=nd;
 printf( "q_prev\tdata\tq_next\n" );
 while (((void *)0) != tmp) {
  if (tmp == nd && 0 < cnt) {
   printf("DETECTED LOOP \n");
   break;
  }
  tmp1 = tmp->q_prev;
  if (((void *)0) == tmp->q_prev)
   printf("  \t%d\t  \t%d\n", tmp->identifier, count);
  else
   printf("%d\t%d\t  \t%d\n", tmp->q_prev->identifier, tmp->identifier, count);
  tmp=tmp1;
  cnt++;
 }
}

variable_types: count int

variable_types: cnt int


die

decompiled_code:
void __fastcall __noreturn die(unsigned int a1)
{
printf("Server stopped, caught signal: %d\n", a1);
exit(0);
}

canonical_decompiled_code:
void __fastcall __noreturn func9(unsigned int a1)
{
printf("Server stopped, caught signal: %d\n", a1);
exit(0);
}

original_code:
static void
die(int sig)
{
 printf("Server stopped, caught signal: %d\n", sig);
 exit(0);
}


decompiled_code:
void __fastcall __noreturn clean_on_quit(unsigned int a1)
{
_QWORD *v2; // rbx
_QWORD *v3; // rax
_QWORD *v4; // rbx
__int64 v5; // rdi

puts("\n\n\n\n\nPRINTING QUEUE: ");
list_queue(Queue_head, Queue_count);
puts("PRINTING QUEUE_LIST: ");
list_list((__int64 **)Queue_tail);
puts("PRINTING FREEs: ");
list_list((__int64 **)Free_conns);
puts("PRINTING BUSYs: ");
list_list((__int64 **)Busy_conns);
v2 = Free_conns;
if ( Free_conns )
{
do
{
v3 = v2;
v2 = (_QWORD *)*v2;
free((void *)v3[4]);
free(Free_conns);
Free_conns = v2;
}
while ( v2 );
}
v4 = Busy_conns;
if ( Busy_conns )
{
do
{
v5 = (__int64)v4;
v4 = (_QWORD *)*v4;
show_cn(v5);
free(*((void **)Busy_conns + 4));
close(*((_DWORD *)Busy_conns + 7));
free(Busy_conns);
Busy_conns = v4;
}
while ( v4 );
}
close(Master_sock);
Master_sock = -1;
printf("Graceful exit done after signal: %d\n", a1);
pthread_cancel(Workers);
pthread_cancel(*(&Workers + 1));
exit(0);
}

canonical_decompiled_code:
void __fastcall __noreturn func10(unsigned int a1)
{
_QWORD *v2; // rbx
_QWORD *v3; // rax
_QWORD *v4; // rbx
__int64 v5; // rdi

puts("\n\n\n\n\nPRINTING QUEUE: ");
func6(Queue_head, Queue_count);
puts("PRINTING QUEUE_LIST: ");
func7((__int64 **)Queue_tail);
puts("PRINTING FREEs: ");
func7((__int64 **)Free_conns);
puts("PRINTING BUSYs: ");
func7((__int64 **)Busy_conns);
v2 = Free_conns;
if ( Free_conns )
{
do
{
v3 = v2;
v2 = (_QWORD *)*v2;
free((void *)v3[4]);
free(Free_conns);
Free_conns = v2;
}
while ( v2 );
}
v4 = Busy_conns;
if ( Busy_conns )
{
do
{
v5 = (__int64)v4;
v4 = (_QWORD *)*v4;
func8(v5);
free(*((void **)Busy_conns + 4));
close(*((_DWORD *)Busy_conns + 7));
free(Busy_conns);
Busy_conns = v4;
}
while ( v4 );
}
close(Master_sock);
Master_sock = -1;
printf("Graceful exit done after signal: %d\n", a1);
pthread_cancel(Workers);
pthread_cancel(*(&Workers + 1));
exit(0);
}

original_code:
static void
clean_on_quit(int sig)
{
 struct cn_strct *tp;
 int i;
 printf("\n\n\n\n\nPRINTING QUEUE: \n");
 list_queue(_Queue_head, _Queue_count);
 printf("PRINTING QUEUE_LIST: \n");
 list_list(_Queue_tail);
 printf("PRINTING FREEs: \n");
 list_list(_Free_conns);
 printf("PRINTING BUSYs: \n");
 list_list(_Busy_conns);
 while (((void *)0) != _Free_conns) {
  tp = _Free_conns->c_next;
  free(_Free_conns->data_buf_head);
  free(_Free_conns);
  _Free_conns = tp;
 }
 while (((void *)0) != _Busy_conns) {
  tp = _Busy_conns->c_next;
  show_cn(_Busy_conns);
  free(_Busy_conns->data_buf_head);
  close(_Busy_conns->net_socket);
  free(_Busy_conns);
  _Busy_conns = tp;
 }
 close(_Master_sock);
 _Master_sock = -1;
 printf("Graceful exit done after signal: %d\n", sig);
 for (i = 0; i < 2; i++) {
  pthread_cancel(_Workers[i]);
 }
 exit(0);
}


decompiled_code:
__int64 __fastcall pow2(char a1)
{
u_0 = 0x40000000;
HIWORD(u_0) = (unsigned __int8)(a1 + 127) << 7;
return (unsigned int)(int)*(float *)&u_0;
}

canonical_decompiled_code:
__int64 __fastcall func0(char a1)
{
u_0 = 0x40000000;
HIWORD(u_0) = (unsigned __int8)(a1 + 127) << 7;
return (unsigned int)(int)*(float *)&u_0;
}

original_code:
int pow2( char exponent )
{
 static union IeeeFloatUnion u;
 u.f = 2.0;
 u.brokenOut.exponent += (exponent - 1);
 return (int) (u.f);
}

canonical_original_code:
int pow2(char exponent)
{
 static union IeeeFloatUnion u;
 u.f = 2.0;
 u.brokenOut.exponent += (exponent - 1);
 return (int) (u.f);
}

variable_types: exponent char

variable_types: union IeeeFloatUnion { struct IeeeFloat { unsigned int base; unsigned int exponent; unsigned int signBit; } brokenOut; float f; }

user_defined_types: union IeeeFloatUnion { struct IeeeFloat brokenOut; float f; }


repo: tobyjaffey/libzpu

decompiled_code:
void *__fastcall zpuvm_read(__int64 a1, unsigned int a2, void *a3, unsigned int a4)
{
return memcpy(a3, (const void *)(a2 + 4210816LL), a4);
}

canonical_decompiled_code:
void *__fastcall func7(__int64 a1, unsigned int a2, void *a3, unsigned int a4)
{
return memcpy(a3, (const void *)(a2 + 4210816LL), a4);
}

original_code:
void zpuvm_read(zpuvm_t *vm, uint32_t addr, uint8_t *buf, uint32_t len)
{
    memcpy(buf, ram + addr, len);
}

canonical_original_code:
void zpuvm_read(struct zpuvm_t *vm, unsigned int addr, unsigned char *buf, unsigned int len)
{
    memcpy(buf, ram + addr, len);
}

variable_types: struct zpuvm_t { unsigned int pc; unsigned int sp; unsigned int ram_len; _Bool idim; _Bool error; void *userdata; unsigned int interrupt_status; unsigned int interrupt_config; unsigned int syscontrol; unsigned char uart_in; } *

variable_types:
addr
unsigned int

variable_types:
buf
unsigned char *

variable_types:
len
unsigned int


decompiled_code:
void *__fastcall zpuvm_write(__int64 a1, unsigned int a2, const void *a3, unsigned int a4)
{
return memcpy((void *)(a2 + 4210816LL), a3, a4);
}

canonical_decompiled_code:
void *__fastcall func8(__int64 a1, unsigned int a2, const void *a3, unsigned int a4)
{
return memcpy((void *)(a2 + 4210816LL), a3, a4);
}

original_code:
void zpuvm_write(zpuvm_t *vm, uint32_t addr, uint8_t *buf, uint32_t len)
{
    memcpy(ram + addr, buf, len);
}

canonical_original_code:
void zpuvm_write(struct zpuvm_t *vm, unsigned int addr, unsigned char *buf, unsigned int len)
{
    memcpy(ram + addr, buf, len);
}

user_defined_types: struct zpuvm_t { unsigned int pc; unsigned int sp; unsigned int ram_len; _Bool idim; _Bool error; void *userdata; unsigned int interrupt_status; unsigned int interrupt_config; unsigned int syscontrol; unsigned char uart_in; }


decompiled_code:
int __fastcall zpuvm_write_io32(__int64 a1, int a2, char a3)
{
int result; // eax

if ( a2 == -2147483392 )
result = putchar(a3);
return result;
}

canonical_decompiled_code:
int __fastcall func9(__int64 a1, int a2, char a3)
{
int result; // eax

if ( a2 == -2147483392 )
result = putchar(a3);
return result;
}

original_code:
void zpuvm_write_io32(zpuvm_t *vm, uint32_t addr, uint32_t val)
{
    if (addr == ((0x80000000 + 0x00000100)+0))
        putchar((char)val);
}

canonical_original_code:
void zpuvm_write_io32(struct zpuvm_t *vm, unsigned int addr, unsigned int val)
{
    if (addr == ((0x80000000 + 0x00000100)+0))
        putchar((char)val);
}

variable_types:
val
unsigned int


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

result = 0LL;
if ( a2 == -2147483392 )
result = *(unsigned __int8 *)(a1 + 36);
return result;
}

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

result = 0LL;
if ( a2 == -2147483392 )
result = *(unsigned __int8 *)(a1 + 36);
return result;
}

original_code:
uint32_t zpuvm_read_io32(zpuvm_t *vm, uint32_t addr)
{
    if (addr == ((0x80000000 + 0x00000100)+0))
        return vm->uart_in;
    return 0;
}

canonical_original_code:
unsigned int zpuvm_read_io32(struct zpuvm_t *vm, unsigned int addr)
{
    if (addr == ((0x80000000 + 0x00000100)+0))
        return vm->uart_in;
    return 0;
}

return_type: unsigned int


main

original_code:
int main(int argc, char *argv[])
{
    zpuvm_t vm;
    memcpy(ram, image, sizeof(image));
    zpuvm_init(&vm, sizeof(ram), ((void *)0));
    while(0 == zpuvm_exec(&vm))
    {
    }
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
    struct zpuvm_t vm;
    memcpy(ram, image, sizeof(image));
    zpuvm_init(&vm, sizeof(ram), ((void *)0));
    while(0 == zpuvm_exec(&vm))
    {
    }
    return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: struct zpuvm_t { unsigned int pc; unsigned int sp; unsigned int ram_len; _Bool idim; _Bool error; void *userdata; unsigned int interrupt_status; unsigned int interrupt_config; unsigned int syscontrol; unsigned char uart_in; }


original_code:
void zpuvm_init(zpuvm_t *vm, uint32_t ram_len, void *userdata)
{
    vm->pc = 0;
    vm->idim = 0;
    vm->ram_len = ram_len;
    vm->sp = ram_len;
    vm->interrupt_status = 0;
    vm->error = 0;
    vm->userdata = userdata;
}

canonical_original_code:
void zpuvm_init(struct zpuvm_t *vm, unsigned int ram_len, void *userdata)
{
    vm->pc = 0;
    vm->idim = 0;
    vm->ram_len = ram_len;
    vm->sp = ram_len;
    vm->interrupt_status = 0;
    vm->error = 0;
    vm->userdata = userdata;
}

variable_types:
userdata
void *


decompiled_code:
__int64 __fastcall zpuvm_read32(__int64 a1, int a2)
{
__int64 result; // rax
unsigned int v3[3]; // [rsp+Ch] [rbp-Ch] BYREF

if ( a2 < 0 )
{
switch ( a2 )
{
case -2147483644:
result = *(unsigned int *)(a1 + 28);
break;
case -2147483640:
result = *(unsigned int *)(a1 + 32);
break;
case -2147483648:
result = *(unsigned int *)(a1 + 24);
break;
default:
result = zpuvm_read_io32(a1, a2);
break;
}
}
else if ( *(_DWORD *)(a1 + 8) - 4 < (unsigned int)a2 )
{
fprintf(stderr, "MEMFAULT! addr=%08X\n", (unsigned int)a2);
*(_BYTE *)(a1 + 13) = 1;
result = 3735928559LL;
}
else
{
zpuvm_read(a1, a2, v3, 4u);
result = _byteswap_ulong(v3[0]);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, int a2)
{
__int64 result; // rax
unsigned int v3[3]; // [rsp+Ch] [rbp-Ch] BYREF

if ( a2 < 0 )
{
switch ( a2 )
{
case -2147483644:
result = *(unsigned int *)(a1 + 28);
break;
case -2147483640:
result = *(unsigned int *)(a1 + 32);
break;
case -2147483648:
result = *(unsigned int *)(a1 + 24);
break;
default:
result = func10(a1, a2);
break;
}
}
else if ( *(_DWORD *)(a1 + 8) - 4 < (unsigned int)a2 )
{
fprintf(stderr, "MEMFAULT! addr=%08X\n", (unsigned int)a2);
*(_BYTE *)(a1 + 13) = 1;
result = 3735928559LL;
}
else
{
func7(a1, a2, v3, 4u);
result = _byteswap_ulong(v3[0]);
}
return result;
}

original_code:
int32_t zpuvm_read32(zpuvm_t *vm, uint32_t addr)
{
    int32_t val;
    uint8_t buf[4];
    if (addr >= 0x80000000)
    {
        switch(addr)
        {
            case (0x80000000 +0):
                val = vm->interrupt_status;
            break;
            case (0x80000000 +4):
                val = vm->interrupt_config;
            break;
            case (0x80000000 +8):
                val = vm->syscontrol;
            break;
            default:
                val = (int32_t)zpuvm_read_io32(vm, addr);
        }
    }
    else
    {
        if (addr > vm->ram_len-4)
        {
            fprintf(stderr, "MEMFAULT! addr=%08X\n", addr);
            vm->error = 1;
            return 0xDEADBEEF;
        }
        zpuvm_read(vm, addr, buf, 4);
        val = (buf[0] << 24) |
              (buf[1] << 16) |
              (buf[2] << 8) |
              (buf[3]);
    }
    return val;
}

canonical_original_code:
int zpuvm_read32(struct zpuvm_t *vm, unsigned int addr)
{
    int val;
    unsigned char buf[4];
    if (addr >= 0x80000000)
    {
        switch(addr)
        {
            case (0x80000000 +0):
                val = vm->interrupt_status;
            break;
            case (0x80000000 +4):
                val = vm->interrupt_config;
            break;
            case (0x80000000 +8):
                val = vm->syscontrol;
            break;
            default:
                val = (int)zpuvm_read_io32(vm, addr);
        }
    }
    else
    {
        if (addr > vm->ram_len-4)
        {
            fprintf(stderr, "MEMFAULT! addr=%08X\n", addr);
            vm->error = 1;
            return 0xDEADBEEF;
        }
        zpuvm_read(vm, addr, buf, 4);
        val = (buf[0] << 24) |
              (buf[1] << 16) |
              (buf[2] << 8) |
              (buf[3]);
    }
    return val;
}

variable_types: val int

variable_types:
buf
unsigned char [4]


decompiled_code:
int __fastcall zpuvm_write32(__int64 a1, int a2, int a3)
{
int result; // eax
char v4[12]; // [rsp+Ch] [rbp-Ch] BYREF

v4[0] = HIBYTE(a3);
v4[1] = BYTE2(a3);
result = BYTE1(a3);
v4[2] = BYTE1(a3);
v4[3] = a3;
if ( a2 < 0 )
{
switch ( a2 )
{
case -2147483644:
*(_DWORD *)(a1 + 28) = a3;
break;
case -2147483640:
*(_DWORD *)(a1 + 32) = a3;
break;
case -2147483648:
*(_DWORD *)(a1 + 24) = a3;
break;
default:
result = zpuvm_write_io32(a1, a2, a3);
break;
}
}
else if ( *(_DWORD *)(a1 + 8) - 4 >= (unsigned int)a2 )
{
result = (unsigned int)zpuvm_write(a1, a2, v4, 4u);
}
else
{
result = fprintf(stderr, "MEMFAULT! addr=%08X\n", (unsigned int)a2);
*(_BYTE *)(a1 + 13) = 1;
}
return result;
}

canonical_decompiled_code:
int __fastcall func13(__int64 a1, int a2, int a3)
{
int result; // eax
char v4[12]; // [rsp+Ch] [rbp-Ch] BYREF

v4[0] = HIBYTE(a3);
v4[1] = BYTE2(a3);
result = BYTE1(a3);
v4[2] = BYTE1(a3);
v4[3] = a3;
if ( a2 < 0 )
{
switch ( a2 )
{
case -2147483644:
*(_DWORD *)(a1 + 28) = a3;
break;
case -2147483640:
*(_DWORD *)(a1 + 32) = a3;
break;
case -2147483648:
*(_DWORD *)(a1 + 24) = a3;
break;
default:
result = func9(a1, a2, a3);
break;
}
}
else if ( *(_DWORD *)(a1 + 8) - 4 >= (unsigned int)a2 )
{
result = (unsigned int)func8(a1, a2, v4, 4u);
}
else
{
result = fprintf(stderr, "MEMFAULT! addr=%08X\n", (unsigned int)a2);
*(_BYTE *)(a1 + 13) = 1;
}
return result;
}

original_code:
void zpuvm_write32(zpuvm_t *vm, uint32_t addr, int32_t val)
{
    uint8_t buf[4];
    buf[0] = val >> 24;
    buf[1] = val >> 16;
    buf[2] = val >> 8;
    buf[3] = val;
    if (addr >= 0x80000000)
    {
        switch(addr)
        {
            case (0x80000000 +0):
                vm->interrupt_status = val;
            break;
            case (0x80000000 +4):
                vm->interrupt_config = val;
            break;
            case (0x80000000 +8):
                vm->syscontrol = val;
            break;
            default:
                zpuvm_write_io32(vm, addr, (uint32_t)val);
        }
    }
    else
    {
        if (addr > vm->ram_len-4)
        {
            fprintf(stderr, "MEMFAULT! addr=%08X\n", addr);
            vm->error = 1;
        }
        else
        {
            zpuvm_write(vm, addr, buf, 4);
        }
    }
}

canonical_original_code:
void zpuvm_write32(struct zpuvm_t *vm, unsigned int addr, int val)
{
    unsigned char buf[4];
    buf[0] = val >> 24;
    buf[1] = val >> 16;
    buf[2] = val >> 8;
    buf[3] = val;
    if (addr >= 0x80000000)
    {
        switch(addr)
        {
            case (0x80000000 +0):
                vm->interrupt_status = val;
            break;
            case (0x80000000 +4):
                vm->interrupt_config = val;
            break;
            case (0x80000000 +8):
                vm->syscontrol = val;
            break;
            default:
                zpuvm_write_io32(vm, addr, (unsigned int)val);
        }
    }
    else
    {
        if (addr > vm->ram_len-4)
        {
            fprintf(stderr, "MEMFAULT! addr=%08X\n", addr);
            vm->error = 1;
        }
        else
        {
            zpuvm_write(vm, addr, buf, 4);
        }
    }
}


decompiled_code:
__int64 __fastcall zpuvm_pop(__int64 a1)
{
int v1; // esi
__int64 result; // rax

v1 = *(_DWORD *)(a1 + 4);
if ( (unsigned int)(v1 + 4) > *(_DWORD *)(a1 + 8) )
{
fwrite("\nStack underflow!\n", 1uLL, 0x12uLL, stderr);
*(_BYTE *)(a1 + 13) = 1;
result = 3735928559LL;
}
else
{
result = zpuvm_read32(a1, v1);
*(_DWORD *)(a1 + 4) += 4;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1)
{
int v1; // esi
__int64 result; // rax

v1 = *(_DWORD *)(a1 + 4);
if ( (unsigned int)(v1 + 4) > *(_DWORD *)(a1 + 8) )
{
fwrite("\nStack underflow!\n", 1uLL, 0x12uLL, stderr);
*(_BYTE *)(a1 + 13) = 1;
result = 3735928559LL;
}
else
{
result = func12(a1, v1);
*(_DWORD *)(a1 + 4) += 4;
}
return result;
}

original_code:
int32_t zpuvm_pop(zpuvm_t *vm)
{
    int32_t val;
    if (vm->sp + 4 > vm->ram_len)
    {
        fprintf(stderr, "\nStack underflow!\n");
        vm->error = 1;
        return 0xDEADBEEF;
    }
    val = zpuvm_read32(vm, vm->sp);
    vm->sp += 4;
    return val;
}

canonical_original_code:
int zpuvm_pop(struct zpuvm_t *vm)
{
    int val;
    if (vm->sp + 4 > vm->ram_len)
    {
        fprintf(stderr, "\nStack underflow!\n");
        vm->error = 1;
        return 0xDEADBEEF;
    }
    val = zpuvm_read32(vm, vm->sp);
    vm->sp += 4;
    return val;
}


decompiled_code:
int __fastcall zpuvm_push(__int64 a1, int a2)
{
unsigned int v3; // esi
int v4; // esi
int result; // eax

v3 = *(_DWORD *)(a1 + 4);
if ( v3 <= 3 )
{
result = fwrite("\nStack overflow!\n", 1uLL, 0x11uLL, stderr);
*(_BYTE *)(a1 + 13) = 1;
}
else
{
v4 = v3 - 4;
*(_DWORD *)(a1 + 4) = v4;
result = zpuvm_write32(a1, v4, a2);
}
return result;
}

canonical_decompiled_code:
int __fastcall func15(__int64 a1, int a2)
{
unsigned int v3; // esi
int v4; // esi
int result; // eax

v3 = *(_DWORD *)(a1 + 4);
if ( v3 <= 3 )
{
result = fwrite("\nStack overflow!\n", 1uLL, 0x11uLL, stderr);
*(_BYTE *)(a1 + 13) = 1;
}
else
{
v4 = v3 - 4;
*(_DWORD *)(a1 + 4) = v4;
result = func13(a1, v4, a2);
}
return result;
}

original_code:
void zpuvm_push(zpuvm_t *vm, int32_t val)
{
    if (vm->sp < 4)
    {
        fprintf(stderr, "\nStack overflow!\n");
        vm->error = 1;
        return;
    }
    vm->sp -= 4;
    zpuvm_write32(vm, vm->sp, val);
}

canonical_original_code:
void zpuvm_push(struct zpuvm_t *vm, int val)
{
    if (vm->sp < 4)
    {
        fprintf(stderr, "\nStack overflow!\n");
        vm->error = 1;
        return;
    }
    vm->sp -= 4;
    zpuvm_write32(vm, vm->sp, val);
}


decompiled_code:
int __fastcall zpuvm_print_stack(__int64 a1)
{
unsigned int v1; // er12
unsigned int v2; // ebx
unsigned int v3; // er12
int v5[7]; // [rsp+Ch] [rbp-1Ch] BYREF

fputc(91, stderr);
v1 = *(_DWORD *)(a1 + 4);
if ( v1 < *(_DWORD *)(a1 + 8) )
{
v2 = *(_DWORD *)(a1 + 4);
zpuvm_read(a1, v1, v5, 4u);
fprintf(stderr, " %08X", (unsigned int)v5[0]);
v3 = v1 + 28;
while ( 1 )
{
v2 += 4;
if ( *(_DWORD *)(a1 + 8) <= v2 )
break;
zpuvm_read(a1, v2, v5, 4u);
fprintf(stderr, " %08X", (unsigned int)v5[0]);
if ( v3 == v2 )
{
fwrite("...", 1uLL, 3uLL, stderr);
return fprintf(stderr, " ] (sp=0x%08X)\n", *(unsigned int *)(a1 + 4));
}
}
}
return fprintf(stderr, " ] (sp=0x%08X)\n", *(unsigned int *)(a1 + 4));
}

canonical_decompiled_code:
int __fastcall func16(__int64 a1)
{
unsigned int v1; // er12
unsigned int v2; // ebx
unsigned int v3; // er12
int v5[7]; // [rsp+Ch] [rbp-1Ch] BYREF

fputc(91, stderr);
v1 = *(_DWORD *)(a1 + 4);
if ( v1 < *(_DWORD *)(a1 + 8) )
{
v2 = *(_DWORD *)(a1 + 4);
func7(a1, v1, v5, 4u);
fprintf(stderr, " %08X", (unsigned int)v5[0]);
v3 = v1 + 28;
while ( 1 )
{
v2 += 4;
if ( *(_DWORD *)(a1 + 8) <= v2 )
break;
func7(a1, v2, v5, 4u);
fprintf(stderr, " %08X", (unsigned int)v5[0]);
if ( v3 == v2 )
{
fwrite("...", 1uLL, 3uLL, stderr);
return fprintf(stderr, " ] (sp=0x%08X)\n", *(unsigned int *)(a1 + 4));
}
}
}
return fprintf(stderr, " ] (sp=0x%08X)\n", *(unsigned int *)(a1 + 4));
}

original_code:
void zpuvm_print_stack(zpuvm_t *vm)
{
    int32_t i;
    int n = 8;
    fprintf(stderr, "[");
    for (i=vm->sp;i<vm->ram_len;i+=4)
    {
        int32_t val;
        zpuvm_read(vm, i, (uint8_t *)&val, 4);
        fprintf(stderr, " %08X", val);
        n--;
        if (n == 0)
        {
            fprintf(stderr, "...");
            break;
        }
    }
    fprintf(stderr, " ] (sp=0x%08X)\n", vm->sp);
}

canonical_original_code:
void zpuvm_print_stack(struct zpuvm_t *vm)
{
    int i;
    int n = 8;
    fprintf(stderr, "[");
    for (i=vm->sp;i<vm->ram_len;i+=4)
    {
        int val;
        zpuvm_read(vm, i, (unsigned char *)&val, 4);
        fprintf(stderr, " %08X", val);
        n--;
        if (n == 0)
        {
            fprintf(stderr, "...");
            break;
        }
    }
    fprintf(stderr, " ] (sp=0x%08X)\n", vm->sp);
}

variable_types: i int

variable_types: n int


decompiled_code:
int __fastcall zpuvm_interrupt(int *a1, int a2)
{
int result; // eax

a1[6] |= a2;
result = zpuvm_push((__int64)a1, *a1);
*a1 = 32;
return result;
}

canonical_decompiled_code:
int __fastcall func17(int *a1, int a2)
{
int result; // eax

a1[6] |= a2;
result = func15((__int64)a1, *a1);
*a1 = 32;
return result;
}

original_code:
void zpuvm_interrupt(zpuvm_t *vm, uint32_t mask)
{
    vm->interrupt_status |= mask;
    zpuvm_push(vm, vm->pc);
    vm->pc = 0x00000020;
}

canonical_original_code:
void zpuvm_interrupt(struct zpuvm_t *vm, unsigned int mask)
{
    vm->interrupt_status |= mask;
    zpuvm_push(vm, vm->pc);
    vm->pc = 0x00000020;
}

variable_types:
mask
unsigned int


test

decompiled_code:
int __fastcall test(unsigned int a1, const char *a2, const char *a3)
{
int result; // eax

binary_decode(&input_3, a2, a1);
encoded_2[(int)zbase32_encode(encoded_2, &input_3, a1)] = 0;
if ( strcmp(encoded_2, a3) )
{
fprintf(_bss_start, "%s: Bad encode (%s)", a3, encoded_2);
exit(1);
}
if ( (int)zbase32_decode(&decoded_1, encoded_2, a1) < 0 )
{
fprintf(_bss_start, "%s: Decode failed\n", a3);
exit(1);
}
binary_encode(decoded_binary_0, &decoded_1, a1);
decoded_binary_0[a1] = 0;
result = strcmp(decoded_binary_0, a2);
if ( result )
{
fprintf(_bss_start, "%s: %s != %s\n", a3, decoded_binary_0, a2);
exit(1);
}
return result;
}

canonical_decompiled_code:
int __fastcall func7(unsigned int a1, const char *a2, const char *a3)
{
int result; // eax

func10(&input_3, a2, a1);
encoded_2[(int)zbase32_encode(encoded_2, &input_3, a1)] = 0;
if ( strcmp(encoded_2, a3) )
{
fprintf(_bss_start, "%s: Bad encode (%s)", a3, encoded_2);
exit(1);
}
if ( (int)zbase32_decode(&decoded_1, encoded_2, a1) < 0 )
{
fprintf(_bss_start, "%s: Decode failed\n", a3);
exit(1);
}
func11(decoded_binary_0, &decoded_1, a1);
decoded_binary_0[a1] = 0;
result = strcmp(decoded_binary_0, a2);
if ( result )
{
fprintf(_bss_start, "%s: %s != %s\n", a3, decoded_binary_0, a2);
exit(1);
}
return result;
}

original_code:
void test(const unsigned int bits,
          const char *input_binary,
          const char *expected_encoded) {
  static unsigned char decoded[512],
                       decoded_binary[512],
                       encoded[512],
                       input[512];
  int encoded_length;
  binary_decode(input,(unsigned char *)input_binary,bits);
  encoded_length = zbase32_encode(encoded,input,bits);
  encoded[encoded_length] = '\0';
  if (strcmp((char *)encoded,expected_encoded) != 0) {
    fprintf(stderr,"%s: Bad encode (%s)",expected_encoded,encoded);
    exit(1);
  }
  if (zbase32_decode(decoded,encoded,bits) < 0) {
    fprintf(stderr,"%s: Decode failed\n",expected_encoded);
    exit(1);
  }
  binary_encode(decoded_binary,decoded,bits);
  decoded_binary[bits] = '\0';
  if (strcmp((char *)decoded_binary,input_binary) != 0) {
    fprintf(stderr,"%s: %s != %s\n",
      expected_encoded,
      decoded_binary,
      input_binary
    );
    exit(1);
  }
}

canonical_original_code:
void test(unsigned int bits, char *input_binary, char *expected_encoded) {
  static unsigned char decoded[512]; static unsigned char decoded_binary[512]; static unsigned char encoded[512]; static unsigned char input[512];
  int encoded_length;
  binary_decode(input,(unsigned char *)input_binary,bits);
  encoded_length = zbase32_encode(encoded,input,bits);
  encoded[encoded_length] = '\0';
  if (strcmp((char *)encoded,expected_encoded) != 0) {
    fprintf(stderr,"%s: Bad encode (%s)",expected_encoded,encoded);
    exit(1);
  }
  if (zbase32_decode(decoded,encoded,bits) < 0) {
    fprintf(stderr,"%s: Decode failed\n",expected_encoded);
    exit(1);
  }
  binary_encode(decoded_binary,decoded,bits);
  decoded_binary[bits] = '\0';
  if (strcmp((char *)decoded_binary,input_binary) != 0) {
    fprintf(stderr,"%s: %s != %s\n",
      expected_encoded,
      decoded_binary,
      input_binary
    );
    exit(1);
  }
}

variable_types:
bits
unsigned int

variable_types:
decoded
unsigned char [512]

variable_types:
encoded
unsigned char [512]

variable_types:
input
unsigned char [512]


repo: todashuta/libpenis

decompiled_code:
void __fastcall set_balls(int a1)
{
B = a1;
}

canonical_decompiled_code:
void __fastcall func0(int a1)
{
B = a1;
}

original_code:
void set_balls(int balls)
{
 B = balls;
}

variable_types: balls int


decompiled_code:
void __fastcall set_dick_head(int a1)
{
D = a1;
}

canonical_decompiled_code:
void __fastcall func1(int a1)
{
D = a1;
}

original_code:
void set_dick_head(int dick_head)
{
 D = dick_head;
}


repo: toelke/etar

decompiled_code:
__int64 __fastcall tar_new_file_callback(__int64 a1, const char *a2, __int64 a3)
{
printf("New file: %s; size: %d\n", a2, a3);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, const char *a2, __int64 a3)
{
printf("New file: %s; size: %d\n", a2, a3);
return 1LL;
}

original_code:
int tar_new_file_callback(void *cls, const char* filename, unsigned int filesize) {
 printf("New file: %s; size: %d\n", filename, filesize);
 return 1;
}

canonical_original_code:
int tar_new_file_callback(void *cls, char *filename, unsigned int filesize) {
 printf("New file: %s; size: %d\n", filename, filesize);
 return 1;
}

variable_types:
cls
void *

variable_types:
filename
char *

variable_types:
filesize
unsigned int


decompiled_code:
__int64 __fastcall tar_new_data_callback(__int64 a1, __int64 a2, unsigned int a3)
{
printf("New data; size: %d\n", a3);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, __int64 a2, unsigned int a3)
{
printf("New data; size: %d\n", a3);
return 1LL;
}

original_code:
int tar_new_data_callback(void *cls, const char *data, unsigned int len) {
 printf("New data; size: %d\n", len);
 return 1;
}

canonical_original_code:
int tar_new_data_callback(void *cls, char *data, unsigned int len) {
 printf("New data; size: %d\n", len);
 return 1;
}

variable_types:
data
char *

variable_types:
len
unsigned int