decompiled_code:
void *__fastcall bz_minihash_get(__int64 a1, __int64 a2)
{
__int64 i; // rbx

for ( i = 0LL; i != 32; ++i )
{
if ( *(_QWORD *)(a1 + 8 * i + 8) && (unsigned int)bz_string_eq(a2) )
return *(void **)(a1 + 8LL * (int)i + 264);
}
return &bz_Empty_value;
}

canonical_decompiled_code:
void *__fastcall func6(__int64 a1, __int64 a2)
{
__int64 i; // rbx

for ( i = 0LL; i != 32; ++i )
{
if ( *(_QWORD *)(a1 + 8 * i + 8) && (unsigned int)bz_string_eq(a2) )
return *(void **)(a1 + 8LL * (int)i + 264);
}
return &bz_Empty_value;
}

original_code:
void* bz_minihash_get(bz_Minihash* m, bz_String* name)
{
  int i;
  for (i=0; i<32; i++)
    if(m->name[i])
      if(bz_string_eq(name,m->name[i]))
     return m->value[i];
  return ((void *)&bz_Empty_value);
}

canonical_original_code:
void *bz_minihash_get(struct bz_Minihash *m, struct bz_String *name)
{
  int i;
  for (i=0; i<32; i++)
    if(m->name[i])
      if(bz_string_eq(name,m->name[i]))
     return m->value[i];
  return ((void *)&bz_Empty_value);
}

variable_types:
name
struct bz_String *


repo: sambeau/burp

decompiled_code:
void *__fastcall bz_minihash_get_filename(__int64 a1, __int64 a2)
{
__int64 i; // rbx

for ( i = 0LL; i != 32; ++i )
{
if ( *(_QWORD *)(a1 + 8 * i + 8) && (unsigned int)bz_string_eq(a2) )
return *(void **)(a1 + 8LL * (int)i + 520);
}
return &bz_Empty_value;
}

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

for ( i = 0LL; i != 32; ++i )
{
if ( *(_QWORD *)(a1 + 8 * i + 8) && (unsigned int)bz_string_eq(a2) )
return *(void **)(a1 + 8LL * (int)i + 520);
}
return &bz_Empty_value;
}

original_code:
bz_String* bz_minihash_get_filename(bz_Minihash* m, bz_String* name)
{
  int i;
  for (i=0; i<32; i++)
    if(m->name[i])
      if(bz_string_eq(name,m->name[i]))
     return m->filename[i];
  return ((void *)&bz_Empty_value);
}

canonical_original_code:
struct bz_String *bz_minihash_get_filename(struct bz_Minihash *m, struct bz_String *name)
{
  int i;
  for (i=0; i<32; i++)
    if(m->name[i])
      if(bz_string_eq(name,m->name[i]))
     return m->filename[i];
  return ((void *)&bz_Empty_value);
}

variable_types: struct bz_Minihash { struct bz_Type *type; struct bz_String *name[32]; void *value[32]; struct bz_String *filename[32]; unsigned long line[32]; } *

variable_types: i int

return_type: struct bz_String { struct bz_Type { int *name; unsigned long size; void *(*new)(); void *(*clone)(); int (*length)(); int (*charsize)(); int (*compare)(); void *(*to_integer)(); void *(*to_real)(); void *(*to_string)(); void *(*to_list)(); void *(*to_wstr)(); void *(*show)(); } *type; unsigned long buffer_size; unsigned long length; int *string; } *

user_defined_types: struct bz_String { struct bz_Type *type; unsigned long buffer_size; unsigned long length; int *string; }


decompiled_code:
__int64 __fastcall bz_minihash_get_line(__int64 a1, __int64 a2)
{
__int64 i; // rbx

for ( i = 0LL; i != 32; ++i )
{
if ( *(_QWORD *)(a1 + 8 * i + 8) && (unsigned int)bz_string_eq(a2) )
return *(_QWORD *)(a1 + 8LL * (int)i + 776);
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, __int64 a2)
{
__int64 i; // rbx

for ( i = 0LL; i != 32; ++i )
{
if ( *(_QWORD *)(a1 + 8 * i + 8) && (unsigned int)bz_string_eq(a2) )
return *(_QWORD *)(a1 + 8LL * (int)i + 776);
}
return 0LL;
}

original_code:
size_t bz_minihash_get_line(bz_Minihash* m, bz_String* name)
{
  int i;
  for (i=0; i<32; i++)
    if(m->name[i])
      if(bz_string_eq(name,m->name[i]))
     return m->line[i];
  return 0;
}

canonical_original_code:
unsigned long bz_minihash_get_line(struct bz_Minihash *m, struct bz_String *name)
{
  int i;
  for (i=0; i<32; i++)
    if(m->name[i])
      if(bz_string_eq(name,m->name[i]))
     return m->line[i];
  return 0;
}

variable_types: struct bz_Minihash { struct bz_Type { int *name; unsigned long size; void *(*new)(); void *(*clone)(); int (*length)(); int (*charsize)(); int (*compare)(); void *(*to_integer)(); void *(*to_real)(); void *(*to_string)(); void *(*to_list)(); void *(*to_wstr)(); void *(*show)(); } *type; struct bz_String { struct bz_Type *type; unsigned long buffer_size; unsigned long length; int *string; } *name[32]; void *value[32]; struct bz_String *filename[32]; unsigned long line[32]; } *

return_type: unsigned long

user_defined_types: struct bz_Minihash { struct bz_Type *type; struct bz_String *name[32]; void *value[32]; struct bz_String *filename[32]; unsigned long line[32]; }


decompiled_code:
void __fastcall bz_minihash_delete(__int64 a1, __int64 a2)
{
__int64 v2; // rbx

v2 = 0LL;
while ( !*(_QWORD *)(a1 + 8 * v2 + 8) || !(unsigned int)bz_string_eq(a2) )
{
if ( ++v2 == 32 )
return;
}
*(_QWORD *)(a1 + 8LL * (int)v2 + 8) = 0LL;
}

canonical_decompiled_code:
void __fastcall func9(__int64 a1, __int64 a2)
{
__int64 v2; // rbx

v2 = 0LL;
while ( !*(_QWORD *)(a1 + 8 * v2 + 8) || !(unsigned int)bz_string_eq(a2) )
{
if ( ++v2 == 32 )
return;
}
*(_QWORD *)(a1 + 8LL * (int)v2 + 8) = 0LL;
}

original_code:
void bz_minihash_delete(bz_Minihash* m, bz_String* name)
{
  int i;
  for (i=0; i<32; i++)
    if(m->name[i])
      if(bz_string_eq(name,m->name[i])) {
     m->name[i]=((void *)0);
     return;
      }
}

canonical_original_code:
void bz_minihash_delete(struct bz_Minihash *m, struct bz_String *name)
{
  int i;
  for (i=0; i<32; i++)
    if(m->name[i])
      if(bz_string_eq(name,m->name[i])) {
     m->name[i]=((void *)0);
     return;
      }
}

return_type: void

user_defined_types: struct bz_Type { int *name; unsigned long size; void *(*new)(); void *(*clone)(); int (*length)(); int (*charsize)(); int (*compare)(); void *(*to_integer)(); void *(*to_real)(); void *(*to_string)(); void *(*to_list)(); void *(*to_wstr)(); void *(*show)(); }


decompiled_code:
void ***bz_empty_new()
{
return &bz_Empty_value;
}

canonical_decompiled_code:
void ***func0()
{
return &bz_Empty_value;
}

original_code:
const bz_Empty* bz_empty_new(bz_Empty* e)
{
  return ((void *)&bz_Empty_value);
}

canonical_original_code:
struct bz_Empty *bz_empty_new(struct bz_Empty *e)
{
  return ((void *)&bz_Empty_value);
}

variable_types:
e
struct bz_Empty *

return_type: struct bz_Empty { struct bz_Type { int *name; unsigned long size; void *(*new)(); void *(*clone)(); int (*length)(); int (*charsize)(); int (*compare)(); void *(*to_integer)(); void *(*to_real)(); void *(*to_string)(); void *(*to_list)(); void *(*to_wstr)(); void *(*show)(); } *type; } *

user_defined_types: struct bz_Empty { struct bz_Type *type; }


decompiled_code:
void ***bz_empty_clone()
{
return &bz_Empty_value;
}

canonical_decompiled_code:
void ***func1()
{
return &bz_Empty_value;
}

original_code:
const bz_Empty* bz_empty_clone(bz_Empty* e)
{
  return ((void *)&bz_Empty_value);
}

canonical_original_code:
struct bz_Empty *bz_empty_clone(struct bz_Empty *e)
{
  return ((void *)&bz_Empty_value);
}


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

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

original_code:
size_t bz_empty_length(bz_Empty* e)
{
  return 0;
}

canonical_original_code:
unsigned long bz_empty_length(struct bz_Empty *e)
{
  return 0;
}

variable_types: struct bz_Empty { struct bz_Type { int *name; unsigned long size; void *(*new)(); void *(*clone)(); int (*length)(); int (*charsize)(); int (*compare)(); void *(*to_integer)(); void *(*to_real)(); void *(*to_string)(); void *(*to_list)(); void *(*to_wstr)(); void *(*show)(); } *type; } *


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

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

original_code:
size_t bz_empty_charsize(bz_Empty* e)
{
  return 0;
}

canonical_original_code:
unsigned long bz_empty_charsize(struct bz_Empty *e)
{
  return 0;
}


decompiled_code:
__int64 __fastcall bz_empty_compare(void ***a1)
{
return (unsigned int)-(a1 != &bz_Empty_value);
}

canonical_decompiled_code:
__int64 __fastcall func4(void ***a1)
{
return (unsigned int)-(a1 != &bz_Empty_value);
}

original_code:
int bz_empty_compare(bz_Empty* e)
{
  return (e == ((void *)&bz_Empty_value) ? 0 : -1 );
}

canonical_original_code:
int bz_empty_compare(struct bz_Empty *e)
{
  return (e == ((void *)&bz_Empty_value) ? 0 : -1 );
}

return_type: int


decompiled_code:
void bz_empty_show()
{
;
}

canonical_decompiled_code:
void func5()
{
;
}

original_code:
void bz_empty_show(bz_Empty* e)
{
}

canonical_original_code:
void bz_empty_show(struct bz_Empty *e)
{
}


decompiled_code:
void *bz_list_new()
{
bz_barf_push_function("bz_list_new");
bz_barf_pop_function();
return &bz_Empty_value;
}

canonical_decompiled_code:
void *func0()
{
bz_barf_push_function("bz_list_new");
bz_barf_pop_function();
return &bz_Empty_value;
}

original_code:
bz_List* bz_list_new(void)
{
   {bz_barf_push_function(__PRETTY_FUNCTION__);;};
   {;bz_barf_pop_function();return (((void *)&bz_Empty_value));};
}

canonical_original_code:
struct bz_list_node *bz_list_new()
{
   {bz_barf_push_function(__PRETTY_FUNCTION__);;};
   {;bz_barf_pop_function();return (((void *)&bz_Empty_value));};
}

return_type: struct bz_list_node { struct bz_Type { int *name; unsigned long size; void *(*new)(); void *(*clone)(); int (*length)(); int (*charsize)(); int (*compare)(); void *(*to_integer)(); void *(*to_real)(); void *(*to_string)(); void *(*to_list)(); void *(*to_wstr)(); void *(*show)(); } *type; void *node; struct bz_list_node *next; } *

user_defined_types: struct bz_list_node { struct bz_Type *type; void *node; struct bz_list_node *next; }


decompiled_code:
__int64 __fastcall bz_list_charsize(__int64 a1)
{
int v1; // ebx

bz_barf_push_function("bz_list_charsize");
v1 = (*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 8) + 40LL))(*(_QWORD *)(a1 + 8));
bz_barf_pop_function();
return v1;
}

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

bz_barf_push_function("bz_list_charsize");
v1 = (*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 8) + 40LL))(*(_QWORD *)(a1 + 8));
bz_barf_pop_function();
return v1;
}

original_code:
size_t bz_list_charsize(bz_List* xs)
{
   int n = 0;
   {bz_barf_push_function(__PRETTY_FUNCTION__);;};
   n = ((bz_Type *)((bz_node *)xs->node)->type)->charsize(xs->node);
   {;bz_barf_pop_function();return (n);};
}

canonical_original_code:
unsigned long bz_list_charsize(struct bz_list_node *xs)
{
   int n = 0;
   {bz_barf_push_function(__PRETTY_FUNCTION__);;};
   n = ((struct bz_Type *)((struct bz_node *)xs->node)->type)->charsize(xs->node);
   {;bz_barf_pop_function();return (n);};
}

variable_types: struct bz_list_node { struct bz_Type { int *name; unsigned long size; void *(*new)(); void *(*clone)(); int (*length)(); int (*charsize)(); int (*compare)(); void *(*to_integer)(); void *(*to_real)(); void *(*to_string)(); void *(*to_list)(); void *(*to_wstr)(); void *(*show)(); } *type; void *node; struct bz_list_node *next; } *

variable_types: n int

user_defined_types: struct bz_node { struct bz_Type *type; }


cmp

decompiled_code:
__int64 __fastcall cmp(__int64 a1, __int64 a2)
{
bz_barf_push_function("cmp");
bz_barf_pop_function();
return (*(__int64 (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 48LL))(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
bz_barf_push_function("cmp");
bz_barf_pop_function();
return (*(__int64 (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 48LL))(a1, a2);
}

original_code:
static inline int cmp(void* x, void* y) {
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  {;bz_barf_pop_function();return (((bz_Type *)((bz_node *)x)->type)->compare(x,y));};
}

canonical_original_code:
static inline int cmp(void *x, void *y) {
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  {;bz_barf_pop_function();return (((struct bz_Type *)((struct bz_node *)x)->type)->compare(x,y));};
}

variable_types:
x
void *

variable_types:
y
void *


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

bz_barf_push_function("bz_list_length");
if ( !a1 )
_assert_fail("xs", "src/list.c", 0x85u, "bz_list_length");
if ( (_UNKNOWN *)a1 == &bz_Empty_value )
{
bz_barf_pop_function();
result = 0LL;
}
else
{
if ( !*(_QWORD *)(a1 + 16) )
_assert_fail("xs->next", "src/list.c", 0x8Au, "bz_list_length");
bz_barf_pop_function();
result = bz_list_length(*(_QWORD *)(a1 + 16)) + 1;
}
return result;
}

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

bz_barf_push_function("bz_list_length");
if ( !a1 )
_assert_fail("xs", "src/list.c", 0x85u, "bz_list_length");
if ( (_UNKNOWN *)a1 == &bz_Empty_value )
{
bz_barf_pop_function();
result = 0LL;
}
else
{
if ( !*(_QWORD *)(a1 + 16) )
_assert_fail("xs->next", "src/list.c", 0x8Au, "bz_list_length");
bz_barf_pop_function();
result = func3(*(_QWORD *)(a1 + 16)) + 1;
}
return result;
}

original_code:
size_t bz_list_length(bz_List* xs)
{
   {bz_barf_push_function(__PRETTY_FUNCTION__);;};
   ((void) sizeof ((xs) ? 1 : 0), __extension__ ({ if (xs) ; else __assert_fail ("xs", "src/list.c", 133, __extension__ __PRETTY_FUNCTION__); }));
   if (xs == ((void *)&bz_Empty_value)) {
      {;bz_barf_pop_function();return (0);};
   }
   ((void) sizeof ((xs->next) ? 1 : 0), __extension__ ({ if (xs->next) ; else __assert_fail ("xs->next", "src/list.c", 138, __extension__ __PRETTY_FUNCTION__); }));
   {;bz_barf_pop_function();return (1 + bz_list_length(xs->next));};
}

canonical_original_code:
unsigned long bz_list_length(struct bz_list_node *xs)
{
   {bz_barf_push_function(__PRETTY_FUNCTION__);;};
   ((void) sizeof ((xs) ? 1 : 0), __extension__ ({ if (xs) ; else __assert_fail ("xs", "src/list.c", 133, __extension__ __PRETTY_FUNCTION__); }));
   if (xs == ((void *)&bz_Empty_value)) {
      {;bz_barf_pop_function();return (0);};
   }
   ((void) sizeof ((xs->next) ? 1 : 0), __extension__ ({ if (xs->next) ; else __assert_fail ("xs->next", "src/list.c", 138, __extension__ __PRETTY_FUNCTION__); }));
   {;bz_barf_pop_function();return (1 + bz_list_length(xs->next));};
}


decompiled_code:
__int64 __fastcall bz_list_show(void ***a1)
{
void ***v1; // rbx
void **v2; // rdi

v1 = a1;
bz_barf_push_function("bz_list_show");
if ( !a1 )
_assert_fail("xs", "src/list.c", 0x114u, "bz_list_show");
if ( *a1 != &bz_List_type && a1 != (void ***)&bz_Empty_value )
_assert_fail("(xs->type == bz_LIST) || (xs == bz_EMPTY)", "src/list.c", 0x116u, "bz_list_show");
while ( v1 != (void ***)&bz_Empty_value )
{
v2 = v1[1];
if ( !v2 )
_assert_fail("xs->node", "src/list.c", 0x11Au, "bz_list_show");
if ( !*v2 )
_assert_fail("((bz_List* )xs->node)->type", "src/list.c", 0x11Bu, "bz_list_show");
(*((void (__fastcall **)(void **))*v2 + 12))(v2);
v1 = (void ***)v1[2];
if ( !v1 )
_assert_fail("xs->next", "src/list.c", 0x126u, "bz_list_show");
}
return bz_barf_pop_function();
}

canonical_decompiled_code:
__int64 __fastcall func4(void ***a1)
{
void ***v1; // rbx
void **v2; // rdi

v1 = a1;
bz_barf_push_function("bz_list_show");
if ( !a1 )
_assert_fail("xs", "src/list.c", 0x114u, "bz_list_show");
if ( *a1 != &bz_List_type && a1 != (void ***)&bz_Empty_value )
_assert_fail("(xs->type == bz_LIST) || (xs == bz_EMPTY)", "src/list.c", 0x116u, "bz_list_show");
while ( v1 != (void ***)&bz_Empty_value )
{
v2 = v1[1];
if ( !v2 )
_assert_fail("xs->node", "src/list.c", 0x11Au, "bz_list_show");
if ( !*v2 )
_assert_fail("((bz_List* )xs->node)->type", "src/list.c", 0x11Bu, "bz_list_show");
(*((void (__fastcall **)(void **))*v2 + 12))(v2);
v1 = (void ***)v1[2];
if ( !v1 )
_assert_fail("xs->next", "src/list.c", 0x126u, "bz_list_show");
}
return bz_barf_pop_function();
}

original_code:
void bz_list_show(bz_List* xs)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  ((void) sizeof ((xs) ? 1 : 0), __extension__ ({ if (xs) ; else __assert_fail ("xs", "src/list.c", 276, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof (((xs->type == &bz_List_type) || (xs == ((void *)&bz_Empty_value))) ? 1 : 0), __extension__ ({ if ((xs->type == &bz_List_type) || (xs == ((void *)&bz_Empty_value))) ; else __assert_fail ("(xs->type == bz_LIST) || (xs == bz_EMPTY)", "src/list.c", 278, __extension__ __PRETTY_FUNCTION__); }));
  while (xs != ((void *)&bz_Empty_value)) {
    ((void) sizeof ((xs->node) ? 1 : 0), __extension__ ({ if (xs->node) ; else __assert_fail ("xs->node", "src/list.c", 282, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((((bz_List* )xs->node)->type) ? 1 : 0), __extension__ ({ if (((bz_List* )xs->node)->type) ; else __assert_fail ("((bz_List* )xs->node)->type", "src/list.c", 283, __extension__ __PRETTY_FUNCTION__); }));
      ((bz_Type *)((bz_node *)xs->node)->type)->show(xs->node);;
    ((void) sizeof ((xs->next) ? 1 : 0), __extension__ ({ if (xs->next) ; else __assert_fail ("xs->next", "src/list.c", 294, __extension__ __PRETTY_FUNCTION__); }));
    xs = xs->next;
    ((void) sizeof ((xs) ? 1 : 0), __extension__ ({ if (xs) ; else __assert_fail ("xs", "src/list.c", 297, __extension__ __PRETTY_FUNCTION__); }));
  }
  {;bz_barf_pop_function();};
}

canonical_original_code:
void bz_list_show(struct bz_list_node *xs)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  ((void) sizeof ((xs) ? 1 : 0), __extension__ ({ if (xs) ; else __assert_fail ("xs", "src/list.c", 276, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof (((xs->type == &bz_List_type) || (xs == ((void *)&bz_Empty_value))) ? 1 : 0), __extension__ ({ if ((xs->type == &bz_List_type) || (xs == ((void *)&bz_Empty_value))) ; else __assert_fail ("(xs->type == bz_LIST) || (xs == bz_EMPTY)", "src/list.c", 278, __extension__ __PRETTY_FUNCTION__); }));
  while (xs != ((void *)&bz_Empty_value)) {
    ((void) sizeof ((xs->node) ? 1 : 0), __extension__ ({ if (xs->node) ; else __assert_fail ("xs->node", "src/list.c", 282, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((((struct bz_list_node * )xs->node)->type) ? 1 : 0), __extension__ ({ if (((struct bz_list_node * )xs->node)->type) ; else __assert_fail ("((bz_List* )xs->node)->type", "src/list.c", 283, __extension__ __PRETTY_FUNCTION__); }));
      ((struct bz_Type *)((struct bz_node *)xs->node)->type)->show(xs->node);;
    ((void) sizeof ((xs->next) ? 1 : 0), __extension__ ({ if (xs->next) ; else __assert_fail ("xs->next", "src/list.c", 294, __extension__ __PRETTY_FUNCTION__); }));
    xs = xs->next;
    ((void) sizeof ((xs) ? 1 : 0), __extension__ ({ if (xs) ; else __assert_fail ("xs", "src/list.c", 297, __extension__ __PRETTY_FUNCTION__); }));
  }
  {;bz_barf_pop_function();};
}


decompiled_code:
__int64 type_default()
{
return bz_barf("Missing method");
}

canonical_decompiled_code:
__int64 func5()
{
return bz_barf("Missing method");
}

original_code:
void type_default(void)
{
  bz_barf("Missing method");
}

canonical_original_code:
void type_default()
{
  bz_barf("Missing method");
}


splitAt

decompiled_code:
__int64 __fastcall splitAt(int a1, __int64 a2, _QWORD *a3, _QWORD *a4)
{
int v4; // ebx
_QWORD *v7; // rax

v4 = a1;
bz_barf_push_function("splitAt");
v7 = bz_list_copy(a2);
*a3 = v7;
if ( v7 != (_QWORD *)&bz_Empty_value && a1 )
{
do
{
v7 = (_QWORD *)v7[2];
--v4;
}
while ( v7 != (_QWORD *)&bz_Empty_value && v4 );
}
if ( v7 != (_QWORD *)&bz_Empty_value )
{
*a4 = v7[2];
v7[2] = &bz_Empty_value;
}
return bz_barf_pop_function();
}

canonical_decompiled_code:
__int64 __fastcall func6(int a1, __int64 a2, _QWORD *a3, _QWORD *a4)
{
int v4; // ebx
_QWORD *v7; // rax

v4 = a1;
bz_barf_push_function("splitAt");
v7 = bz_list_copy(a2);
*a3 = v7;
if ( v7 != (_QWORD *)&bz_Empty_value && a1 )
{
do
{
v7 = (_QWORD *)v7[2];
--v4;
}
while ( v7 != (_QWORD *)&bz_Empty_value && v4 );
}
if ( v7 != (_QWORD *)&bz_Empty_value )
{
*a4 = v7[2];
v7[2] = &bz_Empty_value;
}
return bz_barf_pop_function();
}

original_code:
static inline void splitAt(int n, bz_List* xs, bz_List** as, bz_List** bs)
{
  bz_List* aas;
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  *as = bz_list_copy(xs);
  aas = *as;
  while (n && (aas != ((void *)&bz_Empty_value))) {
    aas = aas->next;
    n--;
  }
  if (aas != ((void *)&bz_Empty_value)) {
    *bs = aas->next;
    aas->next = ((void *)&bz_Empty_value);
  }
  {;bz_barf_pop_function();};
}

canonical_original_code:
static inline void splitAt(int n, struct bz_list_node *xs, struct bz_list_node **as, struct bz_list_node **bs)
{
  struct bz_list_node *aas;
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  *as = bz_list_copy(xs);
  aas = *as;
  while (n && (aas != ((void *)&bz_Empty_value))) {
    aas = aas->next;
    n--;
  }
  if (aas != ((void *)&bz_Empty_value)) {
    *bs = aas->next;
    aas->next = ((void *)&bz_Empty_value);
  }
  {;bz_barf_pop_function();};
}

variable_types:
as
struct bz_list_node **

variable_types:
bs
struct bz_list_node **


decompiled_code:
__int64 __fastcall bz_list_debug_show(_QWORD **a1)
{
_QWORD **v1; // rbx
__int64 v2; // rax
_QWORD *v3; // rdx
_QWORD *v4; // rax

v1 = a1;
bz_barf_push_function("bz_list_debug_show");
if ( !a1 )
_assert_fail("xs", "src/list.c", 0x134u, "bz_list_debug_show");
v2 = bz_list_length((__int64)a1);
wprintf(U"[%ls:%i]", **a1, v2);
fflush(0LL);
if ( *a1 != &bz_List_type && a1 != (_QWORD **)&bz_Empty_value )
_assert_fail("(xs->type == bz_LIST) || (xs == bz_EMPTY)", "src/list.c", 0x136u, "bz_list_debug_show");
while ( v1 != (_QWORD **)&bz_Empty_value )
{
v3 = v1[1];
if ( !v3 )
_assert_fail("xs->node", "src/list.c", 0x139u, "bz_list_debug_show");
v4 = (_QWORD *)*v3;
if ( (_UNKNOWN *)*v3 == &bz_String_type )
{
wprintf(U"-->[%ls:%ls]", 0LL, v3[3]);
fflush(0LL);
}
else
{
if ( v4 == (_QWORD *)&bz_Integer_type )
wprintf(U"-->[%ls:%ld]", 0LL, v3[1]);
else
wprintf(U"-->[%ls]", *v4);
fflush(0LL);
}
v1 = (_QWORD **)v1[2];
if ( !v1 )
_assert_fail("xs", "src/list.c", 0x144u, "bz_list_debug_show");
}
wprintf(U"-->[/]");
fflush(0LL);
return bz_barf_pop_function();
}

canonical_decompiled_code:
__int64 __fastcall func7(_QWORD **a1)
{
_QWORD **v1; // rbx
__int64 v2; // rax
_QWORD *v3; // rdx
_QWORD *v4; // rax

v1 = a1;
bz_barf_push_function("bz_list_debug_show");
if ( !a1 )
_assert_fail("xs", "src/list.c", 0x134u, "bz_list_debug_show");
v2 = func3((__int64)a1);
wprintf(U"[%ls:%i]", **a1, v2);
fflush(0LL);
if ( *a1 != &bz_List_type && a1 != (_QWORD **)&bz_Empty_value )
_assert_fail("(xs->type == bz_LIST) || (xs == bz_EMPTY)", "src/list.c", 0x136u, "bz_list_debug_show");
while ( v1 != (_QWORD **)&bz_Empty_value )
{
v3 = v1[1];
if ( !v3 )
_assert_fail("xs->node", "src/list.c", 0x139u, "bz_list_debug_show");
v4 = (_QWORD *)*v3;
if ( (_UNKNOWN *)*v3 == &bz_String_type )
{
wprintf(U"-->[%ls:%ls]", 0LL, v3[3]);
fflush(0LL);
}
else
{
if ( v4 == (_QWORD *)&bz_Integer_type )
wprintf(U"-->[%ls:%ld]", 0LL, v3[1]);
else
wprintf(U"-->[%ls]", *v4);
fflush(0LL);
}
v1 = (_QWORD **)v1[2];
if ( !v1 )
_assert_fail("xs", "src/list.c", 0x144u, "bz_list_debug_show");
}
wprintf(U"-->[/]");
fflush(0LL);
return bz_barf_pop_function();
}

original_code:
void bz_list_debug_show(bz_List* xs)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  ((void) sizeof ((xs) ? 1 : 0), __extension__ ({ if (xs) ; else __assert_fail ("xs", "src/list.c", 308, __extension__ __PRETTY_FUNCTION__); }));
  wprintf(L"[%ls:%i]",xs->type->name,bz_list_length(xs));fflush(0);
  ((void) sizeof (((xs->type == &bz_List_type) || (xs == ((void *)&bz_Empty_value))) ? 1 : 0), __extension__ ({ if ((xs->type == &bz_List_type) || (xs == ((void *)&bz_Empty_value))) ; else __assert_fail ("(xs->type == bz_LIST) || (xs == bz_EMPTY)", "src/list.c", 310, __extension__ __PRETTY_FUNCTION__); }));
  while ( xs != ((void *)&bz_Empty_value) ) {
    ((void) sizeof ((xs->node) ? 1 : 0), __extension__ ({ if (xs->node) ; else __assert_fail ("xs->node", "src/list.c", 313, __extension__ __PRETTY_FUNCTION__); }));
    if (((bz_String*)xs->node)->type == &bz_String_type) {
      wprintf(L"-->[%ls:%ls]",((bz_String*)xs->node)->type->name,((bz_String*)xs->node)->string);fflush(0);
    } else if (((bz_String*)xs->node)->type == &bz_Integer_type) {
      wprintf(L"-->[%ls:%ld]",((bz_String*)xs->node)->type->name,((bz_Integer*)xs->node)->value);fflush(0);
    } else {
      wprintf(L"-->[%ls]",((bz_String*)xs->node)->type->name,xs->node);fflush(0);
    }
    xs = xs->next;
    ((void) sizeof ((xs) ? 1 : 0), __extension__ ({ if (xs) ; else __assert_fail ("xs", "src/list.c", 324, __extension__ __PRETTY_FUNCTION__); }));
  }
    wprintf(L"-->[/]");fflush(0);
  {;bz_barf_pop_function();};
}

canonical_original_code:
void bz_list_debug_show(struct bz_list_node *xs)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  ((void) sizeof ((xs) ? 1 : 0), __extension__ ({ if (xs) ; else __assert_fail ("xs", "src/list.c", 308, __extension__ __PRETTY_FUNCTION__); }));
  wprintf(L"[%ls:%i]",xs->type->name,bz_list_length(xs));fflush(0);
  ((void) sizeof (((xs->type == &bz_List_type) || (xs == ((void *)&bz_Empty_value))) ? 1 : 0), __extension__ ({ if ((xs->type == &bz_List_type) || (xs == ((void *)&bz_Empty_value))) ; else __assert_fail ("(xs->type == bz_LIST) || (xs == bz_EMPTY)", "src/list.c", 310, __extension__ __PRETTY_FUNCTION__); }));
  while ( xs != ((void *)&bz_Empty_value) ) {
    ((void) sizeof ((xs->node) ? 1 : 0), __extension__ ({ if (xs->node) ; else __assert_fail ("xs->node", "src/list.c", 313, __extension__ __PRETTY_FUNCTION__); }));
    if (((struct bz_String *)xs->node)->type == &bz_String_type) {
      wprintf(L"-->[%ls:%ls]",((struct bz_String *)xs->node)->type->name,((struct bz_String *)xs->node)->string);fflush(0);
    } else if (((struct bz_String *)xs->node)->type == &bz_Integer_type) {
      wprintf(L"-->[%ls:%ld]",((struct bz_String *)xs->node)->type->name,((struct bz_Integer *)xs->node)->value);fflush(0);
    } else {
      wprintf(L"-->[%ls]",((struct bz_String *)xs->node)->type->name,xs->node);fflush(0);
    }
    xs = xs->next;
    ((void) sizeof ((xs) ? 1 : 0), __extension__ ({ if (xs) ; else __assert_fail ("xs", "src/list.c", 324, __extension__ __PRETTY_FUNCTION__); }));
  }
    wprintf(L"-->[/]");fflush(0);
  {;bz_barf_pop_function();};
}

user_defined_types: struct bz_Integer { struct bz_Type *type; long long value; }


decompiled_code:
__int64 __fastcall bz_list_compare(void *a1, void *a2)
{
_QWORD *v2; // rbx
_QWORD *v3; // rbp
unsigned int v4; // er12

bz_barf_push_function("bz_list_compare");
if ( a1 == &bz_Empty_value )
{
bz_barf_pop_function();
if ( a2 == &bz_Empty_value )
v4 = 0;
else
v4 = -1;
}
else
{
if ( a2 == &bz_Empty_value )
goto LABEL_6;
v2 = bz_list_flatten((__int64)a1);
v3 = bz_list_flatten((__int64)a2);
if ( *(_QWORD *)v2[1] != *(_QWORD *)v3[1] )
_assert_fail(
"((bz_String*)xxs->node)->type == ((bz_String*)yys->node)->type",
"src/list.c",
0x1B3u,
"bz_list_compare");
if ( v2 == (_QWORD *)&bz_Empty_value )
{
LABEL_13:
bz_barf_pop_function();
if ( v3 == (_QWORD *)&bz_Empty_value )
v4 = 0;
else
v4 = -1;
}
else
{
if ( v3 == (_QWORD *)&bz_Empty_value )
{
LABEL_6:
bz_barf_pop_function();
return 1;
}
while ( 1 )
{
v4 = (*(__int64 (__fastcall **)(_QWORD, _QWORD))(*(_QWORD *)v2[1] + 48LL))(v2[1], v3[1]);
if ( v4 )
break;
v2 = (_QWORD *)v2[2];
v3 = (_QWORD *)v3[2];
if ( !v2 || !v3 )
break;
if ( v2 == (_QWORD *)&bz_Empty_value )
goto LABEL_13;
if ( v3 == (_QWORD *)&bz_Empty_value )
goto LABEL_6;
if ( *(_QWORD *)v2[1] != *(_QWORD *)v3[1] )
bz_barf("comparing different things");
}
bz_barf_pop_function();
}
}
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func9(void *a1, void *a2)
{
_QWORD *v2; // rbx
_QWORD *v3; // rbp
unsigned int v4; // er12

bz_barf_push_function("bz_list_compare");
if ( a1 == &bz_Empty_value )
{
bz_barf_pop_function();
if ( a2 == &bz_Empty_value )
v4 = 0;
else
v4 = -1;
}
else
{
if ( a2 == &bz_Empty_value )
goto LABEL_6;
v2 = bz_list_flatten((__int64)a1);
v3 = bz_list_flatten((__int64)a2);
if ( *(_QWORD *)v2[1] != *(_QWORD *)v3[1] )
_assert_fail(
"((bz_String*)xxs->node)->type == ((bz_String*)yys->node)->type",
"src/list.c",
0x1B3u,
"bz_list_compare");
if ( v2 == (_QWORD *)&bz_Empty_value )
{
LABEL_13:
bz_barf_pop_function();
if ( v3 == (_QWORD *)&bz_Empty_value )
v4 = 0;
else
v4 = -1;
}
else
{
if ( v3 == (_QWORD *)&bz_Empty_value )
{
LABEL_6:
bz_barf_pop_function();
return 1;
}
while ( 1 )
{
v4 = (*(__int64 (__fastcall **)(_QWORD, _QWORD))(*(_QWORD *)v2[1] + 48LL))(v2[1], v3[1]);
if ( v4 )
break;
v2 = (_QWORD *)v2[2];
v3 = (_QWORD *)v3[2];
if ( !v2 || !v3 )
break;
if ( v2 == (_QWORD *)&bz_Empty_value )
goto LABEL_13;
if ( v3 == (_QWORD *)&bz_Empty_value )
goto LABEL_6;
if ( *(_QWORD *)v2[1] != *(_QWORD *)v3[1] )
bz_barf("comparing different things");
}
bz_barf_pop_function();
}
}
return v4;
}

original_code:
int bz_list_compare(bz_List* xs, bz_List* ys)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  if(xs == ((void *)&bz_Empty_value)) {
    if(ys == ((void *)&bz_Empty_value))
      {;bz_barf_pop_function();return (0);};
    {;bz_barf_pop_function();return (-1);};
  }
  if(ys == ((void *)&bz_Empty_value))
    {;bz_barf_pop_function();return (1);};
  bz_List* xxs = bz_list_flatten(xs);
  bz_List* yys = bz_list_flatten(ys);
  int cmp=0;
  ((void) sizeof ((((bz_String*)xxs->node)->type == ((bz_String*)yys->node)->type) ? 1 : 0), __extension__ ({ if (((bz_String*)xxs->node)->type == ((bz_String*)yys->node)->type) ; else __assert_fail ("((bz_String*)xxs->node)->type == ((bz_String*)yys->node)->type", "src/list.c", 435, __extension__ __PRETTY_FUNCTION__); }));
  while ( xxs && yys ) {
    if(xxs == ((void *)&bz_Empty_value)) {
      if(yys == ((void *)&bz_Empty_value))
 {;bz_barf_pop_function();return (0);};
      {;bz_barf_pop_function();return (-1);};
    }
    if(yys == ((void *)&bz_Empty_value))
      {;bz_barf_pop_function();return (1);};
    if(((bz_String*)xxs->node)->type != ((bz_String*)yys->node)->type)
      bz_barf("comparing different things");
    cmp = ((bz_Type *)((bz_node *)xxs->node)->type)->compare(xxs->node,yys->node);
    if (cmp != 0) {;bz_barf_pop_function();return (cmp);};
    xxs = xxs->next;
    yys = yys->next;
  }
  {;bz_barf_pop_function();return (cmp);};
}

canonical_original_code:
int bz_list_compare(struct bz_list_node *xs, struct bz_list_node *ys)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  if(xs == ((void *)&bz_Empty_value)) {
    if(ys == ((void *)&bz_Empty_value))
      {;bz_barf_pop_function();return (0);};
    {;bz_barf_pop_function();return (-1);};
  }
  if(ys == ((void *)&bz_Empty_value))
    {;bz_barf_pop_function();return (1);};
  struct bz_list_node *xxs = bz_list_flatten(xs);
  struct bz_list_node *yys = bz_list_flatten(ys);
  int cmp = 0;
  ((void) sizeof ((((struct bz_String *)xxs->node)->type == ((struct bz_String *)yys->node)->type) ? 1 : 0), __extension__ ({ if (((struct bz_String *)xxs->node)->type == ((struct bz_String *)yys->node)->type) ; else __assert_fail ("((bz_String*)xxs->node)->type == ((bz_String*)yys->node)->type", "src/list.c", 435, __extension__ __PRETTY_FUNCTION__); }));
  while ( xxs && yys ) {
    if(xxs == ((void *)&bz_Empty_value)) {
      if(yys == ((void *)&bz_Empty_value))
 {;bz_barf_pop_function();return (0);};
      {;bz_barf_pop_function();return (-1);};
    }
    if(yys == ((void *)&bz_Empty_value))
      {;bz_barf_pop_function();return (1);};
    if(((struct bz_String *)xxs->node)->type != ((struct bz_String *)yys->node)->type)
      bz_barf("comparing different things");
    cmp = ((struct bz_Type *)((struct bz_node *)xxs->node)->type)->compare(xxs->node,yys->node);
    if (cmp != 0) {;bz_barf_pop_function();return (cmp);};
    xxs = xxs->next;
    yys = yys->next;
  }
  {;bz_barf_pop_function();return (cmp);};
}

variable_types:
ys
struct bz_list_node *

variable_types: cmp int


decompiled_code:
__int64 __fastcall bz_trie_find(__int64 a1, const wchar_t *a2, size_t a3)
{
const wchar_t *v4; // r12
const wchar_t *v6; // rdi
size_t v7; // rax
__int64 v8; // rcx
__int64 v9; // rdx
__int64 v10; // r8
wchar_t v11; // esi
__int64 v12; // rbx
__int64 v13; // rax
__int64 v14; // r14
size_t v16; // rbp

v4 = a2;
bz_barf_push_function("bz_trie_find");
if ( !a2 )
_assert_fail("key != NULL", "src/trie.c", 0x4Fu, "bz_trie_find");
v6 = a2;
v7 = wcslen(a2);
if ( v7 < a3 )
_assert_fail("key_index <= wcslen(key)", "src/trie.c", 0x50u, "bz_trie_find");
if ( !v7 )
_assert_fail("wcslen(key) > 0", "src/trie.c", 0x51u, "bz_trie_find");
v8 = *(_QWORD *)(a1 + 8);
if ( v8 )
{
v9 = *(_QWORD *)(a1 + 16);
v10 = a3;
v11 = a2[a3];
v12 = 0LL;
v13 = 0LL;
while ( 1 )
{
v6 = (const wchar_t *)(v9 + v12);
if ( *(_DWORD *)(v9 + v12) == v11 )
break;
++v13;
v12 += 24LL;
if ( v13 == v8 )
goto LABEL_8;
}
v16 = a3 + 1;
if ( v4[v10 + 1] )
{
v14 = *((_QWORD *)v6 + 2);
bz_barf_pop_function(v6);
if ( v14 )
v14 = bz_trie_find(*(_QWORD *)(*(_QWORD *)(a1 + 16) + v12 + 16), v4, v16);
}
else
{
bz_barf_pop_function(v6);
v14 = *(_QWORD *)(*(_QWORD *)(a1 + 16) + v12 + 8);
}
}
else
{
LABEL_8:
bz_barf_pop_function(v6);
v14 = 0LL;
}
return v14;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, const wchar_t *a2, size_t a3)
{
const wchar_t *v4; // r12
const wchar_t *v6; // rdi
size_t v7; // rax
__int64 v8; // rcx
__int64 v9; // rdx
__int64 v10; // r8
wchar_t v11; // esi
__int64 v12; // rbx
__int64 v13; // rax
__int64 v14; // r14
size_t v16; // rbp

v4 = a2;
bz_barf_push_function("bz_trie_find");
if ( !a2 )
_assert_fail("key != NULL", "src/trie.c", 0x4Fu, "bz_trie_find");
v6 = a2;
v7 = wcslen(a2);
if ( v7 < a3 )
_assert_fail("key_index <= wcslen(key)", "src/trie.c", 0x50u, "bz_trie_find");
if ( !v7 )
_assert_fail("wcslen(key) > 0", "src/trie.c", 0x51u, "bz_trie_find");
v8 = *(_QWORD *)(a1 + 8);
if ( v8 )
{
v9 = *(_QWORD *)(a1 + 16);
v10 = a3;
v11 = a2[a3];
v12 = 0LL;
v13 = 0LL;
while ( 1 )
{
v6 = (const wchar_t *)(v9 + v12);
if ( *(_DWORD *)(v9 + v12) == v11 )
break;
++v13;
v12 += 24LL;
if ( v13 == v8 )
goto LABEL_8;
}
v16 = a3 + 1;
if ( v4[v10 + 1] )
{
v14 = *((_QWORD *)v6 + 2);
bz_barf_pop_function(v6);
if ( v14 )
v14 = func0(*(_QWORD *)(*(_QWORD *)(a1 + 16) + v12 + 16), v4, v16);
}
else
{
bz_barf_pop_function(v6);
v14 = *(_QWORD *)(*(_QWORD *)(a1 + 16) + v12 + 8);
}
}
else
{
LABEL_8:
bz_barf_pop_function(v6);
v14 = 0LL;
}
return v14;
}

original_code:
void* bz_trie_find(bz_trie* T, wchar_t* key, size_t key_index)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  size_t i;
  ((void) sizeof ((key != ((void *)0)) ? 1 : 0), __extension__ ({ if (key != ((void *)0)) ; else __assert_fail ("key != NULL", "src/trie.c", 79, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((key_index <= wcslen(key)) ? 1 : 0), __extension__ ({ if (key_index <= wcslen(key)) ; else __assert_fail ("key_index <= wcslen(key)", "src/trie.c", 80, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((wcslen(key) > 0) ? 1 : 0), __extension__ ({ if (wcslen(key) > 0) ; else __assert_fail ("wcslen(key) > 0", "src/trie.c", 81, __extension__ __PRETTY_FUNCTION__); }));
  for (i=0; i < T->length; i++) {
    if (T->nodes[i].c == key[key_index]) {
      if (key[key_index + 1] == L'\0')
 {;bz_barf_pop_function();return (T->nodes[i].data);};
      if (!T->nodes[i].next)
 {;bz_barf_pop_function();return (((void *)0));};
      {;bz_barf_pop_function();return (bz_trie_find(T->nodes[i].next, key, key_index + 1));};
    }
  }
  {;bz_barf_pop_function();return (((void *)0));};
}

canonical_original_code:
void *bz_trie_find(struct bz_trie *T, int *key, unsigned long key_index)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  unsigned long i;
  ((void) sizeof ((key != ((void *)0)) ? 1 : 0), __extension__ ({ if (key != ((void *)0)) ; else __assert_fail ("key != NULL", "src/trie.c", 79, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((key_index <= wcslen(key)) ? 1 : 0), __extension__ ({ if (key_index <= wcslen(key)) ; else __assert_fail ("key_index <= wcslen(key)", "src/trie.c", 80, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((wcslen(key) > 0) ? 1 : 0), __extension__ ({ if (wcslen(key) > 0) ; else __assert_fail ("wcslen(key) > 0", "src/trie.c", 81, __extension__ __PRETTY_FUNCTION__); }));
  for (i=0; i < T->length; i++) {
    if (T->nodes[i].c == key[key_index]) {
      if (key[key_index + 1] == L'\0')
 {;bz_barf_pop_function();return (T->nodes[i].data);};
      if (!T->nodes[i].next)
 {;bz_barf_pop_function();return (((void *)0));};
      {;bz_barf_pop_function();return (bz_trie_find(T->nodes[i].next, key, key_index + 1));};
    }
  }
  {;bz_barf_pop_function();return (((void *)0));};
}

variable_types: struct bz_trie { unsigned long node_array_size; unsigned long length; struct bz_trie_node { int c; void *data; void *next; } *nodes; } *

variable_types:
key
int *

variable_types:
i
unsigned long

return_type: void *

user_defined_types: struct bz_trie { unsigned long node_array_size; unsigned long length; struct bz_trie_node *nodes; }


decompiled_code:
__int64 __fastcall bz_trie_find_top(__int64 a1, const wchar_t *a2, size_t a3)
{
const wchar_t *v4; // r13
const wchar_t *v6; // rdi
size_t v7; // rax
__int64 v8; // rcx
__int64 v9; // rdx
__int64 v10; // r8
wchar_t v11; // esi
__int64 v12; // rbx
__int64 v13; // rax
size_t v14; // r12
__int64 result; // rax

v4 = a2;
bz_barf_push_function("bz_trie_find_top");
if ( !a2 )
_assert_fail("key != NULL", "src/trie.c", 0x6Au, "bz_trie_find_top");
v6 = a2;
v7 = wcslen(a2);
if ( v7 < a3 )
_assert_fail("key_index <= wcslen(key)", "src/trie.c", 0x6Bu, "bz_trie_find_top");
if ( !v7 )
_assert_fail("wcslen(key) > 0", "src/trie.c", 0x6Cu, "bz_trie_find_top");
v8 = *(_QWORD *)(a1 + 8);
if ( !v8 )
goto LABEL_15;
v9 = *(_QWORD *)(a1 + 16);
v10 = a3;
v11 = a2[a3];
v12 = 0LL;
v13 = 0LL;
while ( 1 )
{
v6 = (const wchar_t *)(v9 + v12);
if ( *(_DWORD *)(v9 + v12) == v11 )
break;
++v13;
v12 += 24LL;
if ( v13 == v8 )
goto LABEL_15;
}
v14 = a3 + 1;
if ( v4[v10 + 1] && *((_QWORD *)v6 + 2) )
{
bz_barf_pop_function(v6);
result = bz_trie_find_top(*(_QWORD *)(*(_QWORD *)(a1 + 16) + v12 + 16), v4, v14);
}
else
{
LABEL_15:
bz_barf_pop_function(v6);
result = a1;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, const wchar_t *a2, size_t a3)
{
const wchar_t *v4; // r13
const wchar_t *v6; // rdi
size_t v7; // rax
__int64 v8; // rcx
__int64 v9; // rdx
__int64 v10; // r8
wchar_t v11; // esi
__int64 v12; // rbx
__int64 v13; // rax
size_t v14; // r12
__int64 result; // rax

v4 = a2;
bz_barf_push_function("bz_trie_find_top");
if ( !a2 )
_assert_fail("key != NULL", "src/trie.c", 0x6Au, "bz_trie_find_top");
v6 = a2;
v7 = wcslen(a2);
if ( v7 < a3 )
_assert_fail("key_index <= wcslen(key)", "src/trie.c", 0x6Bu, "bz_trie_find_top");
if ( !v7 )
_assert_fail("wcslen(key) > 0", "src/trie.c", 0x6Cu, "bz_trie_find_top");
v8 = *(_QWORD *)(a1 + 8);
if ( !v8 )
goto LABEL_15;
v9 = *(_QWORD *)(a1 + 16);
v10 = a3;
v11 = a2[a3];
v12 = 0LL;
v13 = 0LL;
while ( 1 )
{
v6 = (const wchar_t *)(v9 + v12);
if ( *(_DWORD *)(v9 + v12) == v11 )
break;
++v13;
v12 += 24LL;
if ( v13 == v8 )
goto LABEL_15;
}
v14 = a3 + 1;
if ( v4[v10 + 1] && *((_QWORD *)v6 + 2) )
{
bz_barf_pop_function(v6);
result = func1(*(_QWORD *)(*(_QWORD *)(a1 + 16) + v12 + 16), v4, v14);
}
else
{
LABEL_15:
bz_barf_pop_function(v6);
result = a1;
}
return result;
}

original_code:
bz_trie* bz_trie_find_top(bz_trie* T, wchar_t* key, size_t key_index)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  size_t i;
  ((void) sizeof ((key != ((void *)0)) ? 1 : 0), __extension__ ({ if (key != ((void *)0)) ; else __assert_fail ("key != NULL", "src/trie.c", 106, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((key_index <= wcslen(key)) ? 1 : 0), __extension__ ({ if (key_index <= wcslen(key)) ; else __assert_fail ("key_index <= wcslen(key)", "src/trie.c", 107, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((wcslen(key) > 0) ? 1 : 0), __extension__ ({ if (wcslen(key) > 0) ; else __assert_fail ("wcslen(key) > 0", "src/trie.c", 108, __extension__ __PRETTY_FUNCTION__); }));
  for (i=0; i < T->length; i++) {
    if (T->nodes[i].c == key[key_index]) {
      if (key[key_index + 1] == L'\0')
 {;bz_barf_pop_function();return (T);};
      if (!T->nodes[i].next)
 {;bz_barf_pop_function();return (T);};
      {;bz_barf_pop_function();return (bz_trie_find_top(T->nodes[i].next, key, key_index + 1));};
    }
  }
  {;bz_barf_pop_function();return (T);};
}

canonical_original_code:
struct bz_trie *bz_trie_find_top(struct bz_trie *T, int *key, unsigned long key_index)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  unsigned long i;
  ((void) sizeof ((key != ((void *)0)) ? 1 : 0), __extension__ ({ if (key != ((void *)0)) ; else __assert_fail ("key != NULL", "src/trie.c", 106, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((key_index <= wcslen(key)) ? 1 : 0), __extension__ ({ if (key_index <= wcslen(key)) ; else __assert_fail ("key_index <= wcslen(key)", "src/trie.c", 107, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((wcslen(key) > 0) ? 1 : 0), __extension__ ({ if (wcslen(key) > 0) ; else __assert_fail ("wcslen(key) > 0", "src/trie.c", 108, __extension__ __PRETTY_FUNCTION__); }));
  for (i=0; i < T->length; i++) {
    if (T->nodes[i].c == key[key_index]) {
      if (key[key_index + 1] == L'\0')
 {;bz_barf_pop_function();return (T);};
      if (!T->nodes[i].next)
 {;bz_barf_pop_function();return (T);};
      {;bz_barf_pop_function();return (bz_trie_find_top(T->nodes[i].next, key, key_index + 1));};
    }
  }
  {;bz_barf_pop_function();return (T);};
}

variable_types:
T
struct bz_trie *

return_type: struct bz_trie { unsigned long node_array_size; unsigned long length; struct bz_trie_node { int c; void *data; void *next; } *nodes; } *


decompiled_code:
__int64 __fastcall bz_trie_graft(__int64 *a1, const wchar_t *a2, __int64 a3, __int64 a4)
{
unsigned __int64 v7; // rdx
size_t v8; // rsi
__int64 v9; // r12
void *v11; // rax

bz_barf_push_function("bz_trie_graft");
if ( !a2 )
_assert_fail("key != NULL", "src/trie.c", 0x86u, "bz_trie_graft");
if ( !wcslen(a2) )
_assert_fail("wcslen(key) > 0", "src/trie.c", 0x87u, "bz_trie_graft");
v7 = *a1;
if ( a1[1] + 1 > (unsigned __int64)*a1 )
{
*a1 = 2 * v7;
v11 = realloc((void *)a1[2], 48 * v7);
a1[2] = (__int64)v11;
if ( !v11 )
bz_barf("Out of memory");
}
*(_DWORD *)(a1[2] + 24 * a1[1]) = a2[a3];
v8 = a3 + 1;
if ( a2[a3 + 1] )
*(_QWORD *)(a1[2] + 24 * a1[1] + 8) = 0LL;
else
*(_QWORD *)(a1[2] + 24 * a1[1] + 8) = a4;
v9 = a1[2] + 24 * a1[1];
*(_QWORD *)(v9 + 16) = bz_trie_make(a2, v8, 2uLL, a4);
++a1[1];
return bz_barf_pop_function(a2);
}

original_code:
void bz_trie_graft(bz_trie* T, wchar_t* key, size_t key_index, void* data)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  ((void) sizeof ((key != ((void *)0)) ? 1 : 0), __extension__ ({ if (key != ((void *)0)) ; else __assert_fail ("key != NULL", "src/trie.c", 134, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((wcslen(key) > 0) ? 1 : 0), __extension__ ({ if (wcslen(key) > 0) ; else __assert_fail ("wcslen(key) > 0", "src/trie.c", 135, __extension__ __PRETTY_FUNCTION__); }));
  if ((T->length + 1) > (T->node_array_size)) {
    T->node_array_size <<= 1;
    T->nodes = realloc( T->nodes, sizeof(bz_trie_node[T->node_array_size]));
    if (T->nodes == ((void *)0))
      bz_barf("Out of memory");
  }
  T->nodes[T->length].c = key[key_index];
  if(key[key_index + 1] == L'\0')
    T->nodes[T->length].data = data;
  else
    T->nodes[T->length].data = ((void *)0);
  T->nodes[T->length].next = bz_trie_make(key, key_index + 1, 2, data);
  T->length++;
  {;bz_barf_pop_function();};
}

canonical_original_code:
void bz_trie_graft(struct bz_trie *T, int *key, unsigned long key_index, void *data)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  ((void) sizeof ((key != ((void *)0)) ? 1 : 0), __extension__ ({ if (key != ((void *)0)) ; else __assert_fail ("key != NULL", "src/trie.c", 134, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((wcslen(key) > 0) ? 1 : 0), __extension__ ({ if (wcslen(key) > 0) ; else __assert_fail ("wcslen(key) > 0", "src/trie.c", 135, __extension__ __PRETTY_FUNCTION__); }));
  if ((T->length + 1) > (T->node_array_size)) {
    T->node_array_size <<= 1;
    T->nodes = realloc( T->nodes, sizeof(bz_trie_node[T->node_array_size]));
    if (T->nodes == ((void *)0))
      bz_barf("Out of memory");
  }
  T->nodes[T->length].c = key[key_index];
  if(key[key_index + 1] == L'\0')
    T->nodes[T->length].data = data;
  else
    T->nodes[T->length].data = ((void *)0);
  T->nodes[T->length].next = bz_trie_make(key, key_index + 1, 2, data);
  T->length++;
  {;bz_barf_pop_function();};
}

variable_types:
data
void *

user_defined_types: struct bz_trie_node { int c; void *data; void *next; }


decompiled_code:
__int64 __fastcall bz_trie_find_and_graft(__int64 *a1, const wchar_t *a2, unsigned __int64 a3, __int64 a4)
{
size_t v8; // rax
__int64 v9; // rax
__int64 v10; // rcx
__int64 v11; // rdi
wchar_t v12; // esi
__int64 v13; // rdx
__int64 result; // rax
__int64 v15; // rdi

bz_barf_push_function("bz_trie_find_and_graft");
if ( !a1 )
_assert_fail("T != NULL", "src/trie.c", 0xA4u, "bz_trie_find_and_graft");
if ( !a2 )
_assert_fail("key != NULL", "src/trie.c", 0xA5u, "bz_trie_find_and_graft");
v8 = wcslen(a2);
if ( v8 < a3 )
_assert_fail("key_index <= wcslen(key)", "src/trie.c", 0xA6u, "bz_trie_find_and_graft");
if ( !v8 )
_assert_fail("wcslen(key) > 0", "src/trie.c", 0xA7u, "bz_trie_find_and_graft");
v9 = a1[2];
if ( !v9 )
_assert_fail("T->nodes != NULL", "src/trie.c", 0xA8u, "bz_trie_find_and_graft");
v10 = a1[1];
if ( v10 )
{
v11 = a3;
v12 = a2[a3];
v13 = 0LL;
while ( *(_DWORD *)v9 != v12 )
{
++v13;
v9 += 24LL;
if ( v13 == v10 )
goto LABEL_10;
}
if ( a2[v11 + 1] )
{
v15 = *(_QWORD *)(v9 + 16);
if ( v15 )
{
bz_trie_find_and_graft(v15, a2, a3 + 1, a4);
result = bz_barf_pop_function(v15);
}
else
{
*(_QWORD *)(v9 + 16) = bz_trie_make(a2, a3 + 1, 2uLL, a4);
result = bz_barf_pop_function(a2);
}
}
else
{
*(_QWORD *)(v9 + 8) = a4;
result = bz_barf_pop_function(v11 * 4);
}
}
else
{
LABEL_10:
bz_trie_graft(a1, a2, a3, a4);
result = bz_barf_pop_function(a1);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 *a1, const wchar_t *a2, unsigned __int64 a3, __int64 a4)
{
size_t v8; // rax
__int64 v9; // rax
__int64 v10; // rcx
__int64 v11; // rdi
wchar_t v12; // esi
__int64 v13; // rdx
__int64 result; // rax
__int64 v15; // rdi

bz_barf_push_function("bz_trie_find_and_graft");
if ( !a1 )
_assert_fail("T != NULL", "src/trie.c", 0xA4u, "bz_trie_find_and_graft");
if ( !a2 )
_assert_fail("key != NULL", "src/trie.c", 0xA5u, "bz_trie_find_and_graft");
v8 = wcslen(a2);
if ( v8 < a3 )
_assert_fail("key_index <= wcslen(key)", "src/trie.c", 0xA6u, "bz_trie_find_and_graft");
if ( !v8 )
_assert_fail("wcslen(key) > 0", "src/trie.c", 0xA7u, "bz_trie_find_and_graft");
v9 = a1[2];
if ( !v9 )
_assert_fail("T->nodes != NULL", "src/trie.c", 0xA8u, "bz_trie_find_and_graft");
v10 = a1[1];
if ( v10 )
{
v11 = a3;
v12 = a2[a3];
v13 = 0LL;
while ( *(_DWORD *)v9 != v12 )
{
++v13;
v9 += 24LL;
if ( v13 == v10 )
goto LABEL_10;
}
if ( a2[v11 + 1] )
{
v15 = *(_QWORD *)(v9 + 16);
if ( v15 )
{
func3(v15, a2, a3 + 1, a4);
result = bz_barf_pop_function(v15);
}
else
{
*(_QWORD *)(v9 + 16) = bz_trie_make(a2, a3 + 1, 2uLL, a4);
result = bz_barf_pop_function(a2);
}
}
else
{
*(_QWORD *)(v9 + 8) = a4;
result = bz_barf_pop_function(v11 * 4);
}
}
else
{
LABEL_10:
func2(a1, a2, a3, a4);
result = bz_barf_pop_function(a1);
}
return result;
}

original_code:
void bz_trie_find_and_graft(bz_trie* T, wchar_t* key, size_t key_index, void* data)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  size_t i;
  ((void) sizeof ((T != ((void *)0)) ? 1 : 0), __extension__ ({ if (T != ((void *)0)) ; else __assert_fail ("T != NULL", "src/trie.c", 164, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((key != ((void *)0)) ? 1 : 0), __extension__ ({ if (key != ((void *)0)) ; else __assert_fail ("key != NULL", "src/trie.c", 165, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((key_index <= wcslen(key)) ? 1 : 0), __extension__ ({ if (key_index <= wcslen(key)) ; else __assert_fail ("key_index <= wcslen(key)", "src/trie.c", 166, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((wcslen(key) > 0) ? 1 : 0), __extension__ ({ if (wcslen(key) > 0) ; else __assert_fail ("wcslen(key) > 0", "src/trie.c", 167, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((T->nodes != ((void *)0)) ? 1 : 0), __extension__ ({ if (T->nodes != ((void *)0)) ; else __assert_fail ("T->nodes != NULL", "src/trie.c", 168, __extension__ __PRETTY_FUNCTION__); }));
  for (i=0; i < T->length; i++) {
    if (T->nodes[i].c == key[key_index]) {
      if (key[key_index + 1] == L'\0') {
 T->nodes[i].data = data;
 {;bz_barf_pop_function();return;};
      }
      if (T->nodes[i].next == ((void *)0)) {
 T->nodes[i].next = bz_trie_make(key, key_index+1, 2, data);
 {;bz_barf_pop_function();return;};
      }
      bz_trie_find_and_graft(T->nodes[i].next, key, key_index + 1, data);
      {;bz_barf_pop_function();return;};
    }
  }
  bz_trie_graft( T, key, key_index, data);
  {;bz_barf_pop_function();};
}

canonical_original_code:
void bz_trie_find_and_graft(struct bz_trie *T, int *key, unsigned long key_index, void *data)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  unsigned long i;
  ((void) sizeof ((T != ((void *)0)) ? 1 : 0), __extension__ ({ if (T != ((void *)0)) ; else __assert_fail ("T != NULL", "src/trie.c", 164, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((key != ((void *)0)) ? 1 : 0), __extension__ ({ if (key != ((void *)0)) ; else __assert_fail ("key != NULL", "src/trie.c", 165, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((key_index <= wcslen(key)) ? 1 : 0), __extension__ ({ if (key_index <= wcslen(key)) ; else __assert_fail ("key_index <= wcslen(key)", "src/trie.c", 166, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((wcslen(key) > 0) ? 1 : 0), __extension__ ({ if (wcslen(key) > 0) ; else __assert_fail ("wcslen(key) > 0", "src/trie.c", 167, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((T->nodes != ((void *)0)) ? 1 : 0), __extension__ ({ if (T->nodes != ((void *)0)) ; else __assert_fail ("T->nodes != NULL", "src/trie.c", 168, __extension__ __PRETTY_FUNCTION__); }));
  for (i=0; i < T->length; i++) {
    if (T->nodes[i].c == key[key_index]) {
      if (key[key_index + 1] == L'\0') {
 T->nodes[i].data = data;
 {;bz_barf_pop_function();return;};
      }
      if (T->nodes[i].next == ((void *)0)) {
 T->nodes[i].next = bz_trie_make(key, key_index+1, 2, data);
 {;bz_barf_pop_function();return;};
      }
      bz_trie_find_and_graft(T->nodes[i].next, key, key_index + 1, data);
      {;bz_barf_pop_function();return;};
    }
  }
  bz_trie_graft( T, key, key_index, data);
  {;bz_barf_pop_function();};
}


decompiled_code:
__int64 __fastcall bz_trie_show(__int64 a1, int a2)
{
const char *v3; // rdi
unsigned __int64 i; // r13
__int64 v6; // r14
int j; // ebx

v3 = "bz_trie_show";
bz_barf_push_function("bz_trie_show");
if ( !a1 )
_assert_fail("T", "src/trie.c", 0xCAu, "bz_trie_show");
for ( i = 0LL; *(_QWORD *)(a1 + 8) > i; ++i )
{
if ( !*(_QWORD *)(a1 + 16) )
_assert_fail("T->nodes", "src/trie.c", 0xCEu, "bz_trie_show");
v6 = 24 * i;
if ( a2 > 0 )
{
for ( j = 0; j != a2; ++j )
wprintf(U" ");
}
wprintf(U"%lc", *(unsigned int *)(*(_QWORD *)(a1 + 16) + 24 * i));
if ( *(_QWORD *)(*(_QWORD *)(a1 + 16) + v6 + 8) )
wprintf(U"-->*");
wprintf(asc_C98);
v3 = *(const char **)(*(_QWORD *)(a1 + 16) + v6 + 16);
if ( v3 )
bz_trie_show(v3, (unsigned int)(a2 + 1));
}
return bz_barf_pop_function(v3);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, int a2)
{
const char *v3; // rdi
unsigned __int64 i; // r13
__int64 v6; // r14
int j; // ebx

v3 = "bz_trie_show";
bz_barf_push_function("bz_trie_show");
if ( !a1 )
_assert_fail("T", "src/trie.c", 0xCAu, "bz_trie_show");
for ( i = 0LL; *(_QWORD *)(a1 + 8) > i; ++i )
{
if ( !*(_QWORD *)(a1 + 16) )
_assert_fail("T->nodes", "src/trie.c", 0xCEu, "bz_trie_show");
v6 = 24 * i;
if ( a2 > 0 )
{
for ( j = 0; j != a2; ++j )
wprintf(U" ");
}
wprintf(U"%lc", *(unsigned int *)(*(_QWORD *)(a1 + 16) + 24 * i));
if ( *(_QWORD *)(*(_QWORD *)(a1 + 16) + v6 + 8) )
wprintf(U"-->*");
wprintf(asc_C98);
v3 = *(const char **)(*(_QWORD *)(a1 + 16) + v6 + 16);
if ( v3 )
func4(v3, (unsigned int)(a2 + 1));
}
return bz_barf_pop_function(v3);
}

original_code:
void bz_trie_show(bz_trie* T, int n)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  int i;
  ((void) sizeof ((T) ? 1 : 0), __extension__ ({ if (T) ; else __assert_fail ("T", "src/trie.c", 202, __extension__ __PRETTY_FUNCTION__); }));
  for(i=0;i<T->length;i++) {
    ((void) sizeof ((T->nodes) ? 1 : 0), __extension__ ({ if (T->nodes) ; else __assert_fail ("T->nodes", "src/trie.c", 206, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((&T->nodes[i]) ? 1 : 0), __extension__ ({ if (&T->nodes[i]) ; else __assert_fail ("&T->nodes[i]", "src/trie.c", 207, __extension__ __PRETTY_FUNCTION__); }));
    {int j;for(j=0;j<n;j++){wprintf(L"  ");};};
    wprintf(L"%lc",T->nodes[i].c);
    if (T->nodes[i].data)
      wprintf(L"-->*");
    wprintf(L"\n");
    if (T->nodes[i].next)
      bz_trie_show(T->nodes[i].next,n+1);
  }
  {;bz_barf_pop_function();};
}

canonical_original_code:
void bz_trie_show(struct bz_trie *T, int n)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  int i;
  ((void) sizeof ((T) ? 1 : 0), __extension__ ({ if (T) ; else __assert_fail ("T", "src/trie.c", 202, __extension__ __PRETTY_FUNCTION__); }));
  for(i=0;i<T->length;i++) {
    ((void) sizeof ((T->nodes) ? 1 : 0), __extension__ ({ if (T->nodes) ; else __assert_fail ("T->nodes", "src/trie.c", 206, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((&T->nodes[i]) ? 1 : 0), __extension__ ({ if (&T->nodes[i]) ; else __assert_fail ("&T->nodes[i]", "src/trie.c", 207, __extension__ __PRETTY_FUNCTION__); }));
    {int j;for(j=0;j<n;j++){wprintf(L"  ");};};
    wprintf(L"%lc",T->nodes[i].c);
    if (T->nodes[i].data)
      wprintf(L"-->*");
    wprintf(L"\n");
    if (T->nodes[i].next)
      bz_trie_show(T->nodes[i].next,n+1);
  }
  {;bz_barf_pop_function();};
}

variable_types: i int

variable_types: j int


original_code:
bz_trie* bz_trie_prune(bz_trie* T)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  if(T == ((void *)0))
    {;bz_barf_pop_function();return (((void *)0));};
  if(T->length == 0)
    {;bz_barf_pop_function();return (((void *)0));};
  size_t kept = 0;
  size_t i;
  for (i=0;i<T->length;i++) {
    if (T->nodes[i].data) {
      T->nodes[kept].c = T->nodes[i].c;
      T->nodes[kept].data = T->nodes[i].data;
      T->nodes[kept].next = bz_trie_prune(T->nodes[i].next);
      kept++;
      continue;
    }
    if (T->nodes[i].next) {
      bz_trie* next = bz_trie_prune(T->nodes[i].next);
      if( next != ((void *)0) ) {
 T->nodes[kept].c = T->nodes[i].c;
 T->nodes[kept].data = ((void *)0);
 T->nodes[kept].next = next;
 kept++;
      }
    }
  }
  if(kept == 0)
    {;bz_barf_pop_function();return (((void *)0));};
  T->length = kept;
  if((T->length > 2) && (T->length < T->node_array_size))
    T->nodes = realloc(T->nodes,sizeof(bz_trie_node) * T->length);
  {;bz_barf_pop_function();return (T);};
}

canonical_original_code:
struct bz_trie *bz_trie_prune(struct bz_trie *T)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  if(T == ((void *)0))
    {;bz_barf_pop_function();return (((void *)0));};
  if(T->length == 0)
    {;bz_barf_pop_function();return (((void *)0));};
  unsigned long kept = 0;
  unsigned long i;
  for (i=0;i<T->length;i++) {
    if (T->nodes[i].data) {
      T->nodes[kept].c = T->nodes[i].c;
      T->nodes[kept].data = T->nodes[i].data;
      T->nodes[kept].next = bz_trie_prune(T->nodes[i].next);
      kept++;
      continue;
    }
    if (T->nodes[i].next) {
      struct bz_trie *next = bz_trie_prune(T->nodes[i].next);
      if( next != ((void *)0) ) {
 T->nodes[kept].c = T->nodes[i].c;
 T->nodes[kept].data = ((void *)0);
 T->nodes[kept].next = next;
 kept++;
      }
    }
  }
  if(kept == 0)
    {;bz_barf_pop_function();return (((void *)0));};
  T->length = kept;
  if((T->length > 2) && (T->length < T->node_array_size))
    T->nodes = realloc(T->nodes,sizeof(bz_trie_node) * T->length);
  {;bz_barf_pop_function();return (T);};
}

variable_types:
kept
unsigned long


decompiled_code:
__int64 __fastcall bz_trie_find_and_delete(__int64 a1, const wchar_t *a2, size_t a3)
{
const wchar_t *v4; // r12
const wchar_t *v6; // rdi
size_t v7; // rax
__int64 v8; // rcx
__int64 v9; // rdx
__int64 v10; // rbx
__int64 v11; // rax
__int64 v12; // rsi
__int64 v13; // r14

v4 = a2;
bz_barf_push_function("bz_trie_find_and_delete");
if ( !a2 )
_assert_fail("key != NULL", "src/trie.c", 0x117u, "bz_trie_find_and_delete");
v6 = a2;
v7 = wcslen(a2);
if ( v7 < a3 )
_assert_fail("key_index <= wcslen(key)", "src/trie.c", 0x118u, "bz_trie_find_and_delete");
if ( !v7 )
_assert_fail("wcslen(key) > 0", "src/trie.c", 0x119u, "bz_trie_find_and_delete");
v8 = *(_QWORD *)(a1 + 8);
if ( v8 )
{
v9 = *(_QWORD *)(a1 + 16);
v6 = (const wchar_t *)(unsigned int)a2[a3];
v10 = 0LL;
v11 = 0LL;
while ( 1 )
{
v12 = v9 + v10;
if ( *(_DWORD *)(v9 + v10) == (_DWORD)v6 )
break;
++v11;
v10 += 24LL;
if ( v11 == v8 )
goto LABEL_8;
}
if ( *(_QWORD *)(v12 + 8) && !v4[a3 + 1] )
{
*(_QWORD *)(v12 + 8) = 0LL;
bz_barf_pop_function(v6);
v13 = a1;
}
else
{
v13 = *(_QWORD *)(v12 + 16);
bz_barf_pop_function(v6);
if ( v13 )
v13 = bz_trie_find_and_delete(*(_QWORD *)(*(_QWORD *)(a1 + 16) + v10 + 16), v4, a3 + 1);
}
}
else
{
LABEL_8:
bz_barf_pop_function(v6);
v13 = 0LL;
}
return v13;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, const wchar_t *a2, size_t a3)
{
const wchar_t *v4; // r12
const wchar_t *v6; // rdi
size_t v7; // rax
__int64 v8; // rcx
__int64 v9; // rdx
__int64 v10; // rbx
__int64 v11; // rax
__int64 v12; // rsi
__int64 v13; // r14

v4 = a2;
bz_barf_push_function("bz_trie_find_and_delete");
if ( !a2 )
_assert_fail("key != NULL", "src/trie.c", 0x117u, "bz_trie_find_and_delete");
v6 = a2;
v7 = wcslen(a2);
if ( v7 < a3 )
_assert_fail("key_index <= wcslen(key)", "src/trie.c", 0x118u, "bz_trie_find_and_delete");
if ( !v7 )
_assert_fail("wcslen(key) > 0", "src/trie.c", 0x119u, "bz_trie_find_and_delete");
v8 = *(_QWORD *)(a1 + 8);
if ( v8 )
{
v9 = *(_QWORD *)(a1 + 16);
v6 = (const wchar_t *)(unsigned int)a2[a3];
v10 = 0LL;
v11 = 0LL;
while ( 1 )
{
v12 = v9 + v10;
if ( *(_DWORD *)(v9 + v10) == (_DWORD)v6 )
break;
++v11;
v10 += 24LL;
if ( v11 == v8 )
goto LABEL_8;
}
if ( *(_QWORD *)(v12 + 8) && !v4[a3 + 1] )
{
*(_QWORD *)(v12 + 8) = 0LL;
bz_barf_pop_function(v6);
v13 = a1;
}
else
{
v13 = *(_QWORD *)(v12 + 16);
bz_barf_pop_function(v6);
if ( v13 )
v13 = func6(*(_QWORD *)(*(_QWORD *)(a1 + 16) + v10 + 16), v4, a3 + 1);
}
}
else
{
LABEL_8:
bz_barf_pop_function(v6);
v13 = 0LL;
}
return v13;
}

original_code:
void* bz_trie_find_and_delete(bz_trie* T, wchar_t* key, size_t key_index)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  size_t i;
  ((void) sizeof ((key != ((void *)0)) ? 1 : 0), __extension__ ({ if (key != ((void *)0)) ; else __assert_fail ("key != NULL", "src/trie.c", 279, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((key_index <= wcslen(key)) ? 1 : 0), __extension__ ({ if (key_index <= wcslen(key)) ; else __assert_fail ("key_index <= wcslen(key)", "src/trie.c", 280, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((wcslen(key) > 0) ? 1 : 0), __extension__ ({ if (wcslen(key) > 0) ; else __assert_fail ("wcslen(key) > 0", "src/trie.c", 281, __extension__ __PRETTY_FUNCTION__); }));
  for (i=0; i < T->length; i++) {
    if (T->nodes[i].c == key[key_index]) {
      if (T->nodes[i].data)
      if (key[key_index + 1] == L'\0') {
 T->nodes[i].data = ((void *)0);
 {;bz_barf_pop_function();return (T);};
      }
      if (!T->nodes[i].next)
 {;bz_barf_pop_function();return (((void *)0));};
      {;bz_barf_pop_function();return (bz_trie_find_and_delete(T->nodes[i].next, key, key_index + 1));};
    }
  }
  {;bz_barf_pop_function();return (((void *)0));};
}

canonical_original_code:
void *bz_trie_find_and_delete(struct bz_trie *T, int *key, unsigned long key_index)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  unsigned long i;
  ((void) sizeof ((key != ((void *)0)) ? 1 : 0), __extension__ ({ if (key != ((void *)0)) ; else __assert_fail ("key != NULL", "src/trie.c", 279, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((key_index <= wcslen(key)) ? 1 : 0), __extension__ ({ if (key_index <= wcslen(key)) ; else __assert_fail ("key_index <= wcslen(key)", "src/trie.c", 280, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((wcslen(key) > 0) ? 1 : 0), __extension__ ({ if (wcslen(key) > 0) ; else __assert_fail ("wcslen(key) > 0", "src/trie.c", 281, __extension__ __PRETTY_FUNCTION__); }));
  for (i=0; i < T->length; i++) {
    if (T->nodes[i].c == key[key_index]) {
      if (T->nodes[i].data)
      if (key[key_index + 1] == L'\0') {
 T->nodes[i].data = ((void *)0);
 {;bz_barf_pop_function();return (T);};
      }
      if (!T->nodes[i].next)
 {;bz_barf_pop_function();return (((void *)0));};
      {;bz_barf_pop_function();return (bz_trie_find_and_delete(T->nodes[i].next, key, key_index + 1));};
    }
  }
  {;bz_barf_pop_function();return (((void *)0));};
}


decompiled_code:
__int64 __fastcall bz_trie_delete(unsigned __int64 *a1, const wchar_t *a2)
{
bz_barf_push_function("bz_trie_delete");
if ( !a1 )
_assert_fail("T", "src/trie.c", 0x134u, "bz_trie_delete");
if ( !a2 )
_assert_fail("key", "src/trie.c", 0x135u, "bz_trie_delete");
if ( !a1[1] )
_assert_fail("T->length > 0", "src/trie.c", 0x136u, "bz_trie_delete");
if ( !wcslen(a2) )
_assert_fail("wcslen(key) > 0", "src/trie.c", 0x137u, "bz_trie_delete");
bz_trie_find_and_delete((__int64)a1, a2, 0LL);
bz_trie_prune(a1);
return bz_barf_pop_function(a1);
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned __int64 *a1, const wchar_t *a2)
{
bz_barf_push_function("bz_trie_delete");
if ( !a1 )
_assert_fail("T", "src/trie.c", 0x134u, "bz_trie_delete");
if ( !a2 )
_assert_fail("key", "src/trie.c", 0x135u, "bz_trie_delete");
if ( !a1[1] )
_assert_fail("T->length > 0", "src/trie.c", 0x136u, "bz_trie_delete");
if ( !wcslen(a2) )
_assert_fail("wcslen(key) > 0", "src/trie.c", 0x137u, "bz_trie_delete");
func6((__int64)a1, a2, 0LL);
func5(a1);
return bz_barf_pop_function(a1);
}

original_code:
void bz_trie_delete(bz_trie* T, wchar_t* key)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  ((void) sizeof ((T) ? 1 : 0), __extension__ ({ if (T) ; else __assert_fail ("T", "src/trie.c", 308, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((key) ? 1 : 0), __extension__ ({ if (key) ; else __assert_fail ("key", "src/trie.c", 309, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((T->length > 0) ? 1 : 0), __extension__ ({ if (T->length > 0) ; else __assert_fail ("T->length > 0", "src/trie.c", 310, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((wcslen(key) > 0) ? 1 : 0), __extension__ ({ if (wcslen(key) > 0) ; else __assert_fail ("wcslen(key) > 0", "src/trie.c", 311, __extension__ __PRETTY_FUNCTION__); }));
  bz_trie_find_and_delete(T, key, 0);
  T = bz_trie_prune(T);
  {;bz_barf_pop_function();};
}

canonical_original_code:
void bz_trie_delete(struct bz_trie *T, int *key)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  ((void) sizeof ((T) ? 1 : 0), __extension__ ({ if (T) ; else __assert_fail ("T", "src/trie.c", 308, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((key) ? 1 : 0), __extension__ ({ if (key) ; else __assert_fail ("key", "src/trie.c", 309, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((T->length > 0) ? 1 : 0), __extension__ ({ if (T->length > 0) ; else __assert_fail ("T->length > 0", "src/trie.c", 310, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((wcslen(key) > 0) ? 1 : 0), __extension__ ({ if (wcslen(key) > 0) ; else __assert_fail ("wcslen(key) > 0", "src/trie.c", 311, __extension__ __PRETTY_FUNCTION__); }));
  bz_trie_find_and_delete(T, key, 0);
  T = bz_trie_prune(T);
  {;bz_barf_pop_function();};
}


decompiled_code:
const char *__fastcall bz_trie_flatten(__int64 a1, __int64 a2)
{
const char *v3; // rdi
unsigned __int64 v4; // rbp
const char *i; // r12
__int64 v6; // r13
__int64 v7; // rax

v3 = "bz_trie_flatten";
bz_barf_push_function("bz_trie_flatten");
if ( a1 )
{
v4 = 0LL;
for ( i = (const char *)&bz_Empty_value; *(_QWORD *)(a1 + 8) > v4; ++v4 )
{
v6 = bz_string_copy(a2);
bz_string_cat_wchar(v6, *(unsigned int *)(*(_QWORD *)(a1 + 16) + 24 * v4));
if ( *(_QWORD *)(*(_QWORD *)(a1 + 16) + 24 * v4 + 8) )
i = (const char *)bz_list_cons(i, v6);
v3 = *(const char **)(*(_QWORD *)(a1 + 16) + 24 * v4 + 16);
if ( v3 )
{
v7 = bz_trie_flatten(v3, v6);
v3 = i;
i = (const char *)bz_list_concat(i, v7);
}
}
bz_barf_pop_function(v3);
}
else
{
bz_barf_pop_function("bz_trie_flatten");
i = (const char *)&bz_Empty_value;
}
return i;
}

canonical_decompiled_code:
const char *__fastcall func8(__int64 a1, __int64 a2)
{
const char *v3; // rdi
unsigned __int64 v4; // rbp
const char *i; // r12
__int64 v6; // r13
__int64 v7; // rax

v3 = "bz_trie_flatten";
bz_barf_push_function("bz_trie_flatten");
if ( a1 )
{
v4 = 0LL;
for ( i = (const char *)&bz_Empty_value; *(_QWORD *)(a1 + 8) > v4; ++v4 )
{
v6 = bz_string_copy(a2);
bz_string_cat_wchar(v6, *(unsigned int *)(*(_QWORD *)(a1 + 16) + 24 * v4));
if ( *(_QWORD *)(*(_QWORD *)(a1 + 16) + 24 * v4 + 8) )
i = (const char *)bz_list_cons(i, v6);
v3 = *(const char **)(*(_QWORD *)(a1 + 16) + 24 * v4 + 16);
if ( v3 )
{
v7 = func8(v3, v6);
v3 = i;
i = (const char *)bz_list_concat(i, v7);
}
}
bz_barf_pop_function(v3);
}
else
{
bz_barf_pop_function("bz_trie_flatten");
i = (const char *)&bz_Empty_value;
}
return i;
}

original_code:
bz_List* bz_trie_flatten(bz_trie* T, bz_String* s)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  if (T == ((void *)0))
    {;bz_barf_pop_function();return (((void *)&bz_Empty_value));};
  if (T->length == 0)
    {;bz_barf_pop_function();return (((void *)&bz_Empty_value));};
  bz_List* L = ((void *)&bz_Empty_value);
  int i;
  for (i=0; i < T->length ;i++) {
    bz_String* name = bz_string_copy(s);
    bz_string_cat_wchar(name,T->nodes[i].c);
    if (T->nodes[i].data) {
      L = bz_list_cons(L,name);
    }
    if (T->nodes[i].next) {
      L = bz_list_concat(L,bz_trie_flatten(T->nodes[i].next,name));
    }
  }
  {;bz_barf_pop_function();return (L);};
}

canonical_original_code:
struct bz_list_node *bz_trie_flatten(struct bz_trie *T, struct bz_String *s)
{
  {bz_barf_push_function(__PRETTY_FUNCTION__);;};
  if (T == ((void *)0))
    {;bz_barf_pop_function();return (((void *)&bz_Empty_value));};
  if (T->length == 0)
    {;bz_barf_pop_function();return (((void *)&bz_Empty_value));};
  struct bz_list_node *L = ((void *)&bz_Empty_value);
  int i;
  for (i=0; i < T->length ;i++) {
    struct bz_String *name = bz_string_copy(s);
    bz_string_cat_wchar(name,T->nodes[i].c);
    if (T->nodes[i].data) {
      L = bz_list_cons(L,name);
    }
    if (T->nodes[i].next) {
      L = bz_list_concat(L,bz_trie_flatten(T->nodes[i].next,name));
    }
  }
  {;bz_barf_pop_function();return (L);};
}

variable_types: struct bz_String { struct bz_Type *type; unsigned long buffer_size; unsigned long length; int *string; } *

variable_types: struct bz_String { struct bz_Type { int *name; unsigned long size; void *(*new)(); void *(*clone)(); int (*length)(); int (*charsize)(); int (*compare)(); void *(*to_integer)(); void *(*to_real)(); void *(*to_string)(); void *(*to_list)(); void *(*to_wstr)(); void *(*show)(); } *type; unsigned long buffer_size; unsigned long length; int *string; } *


decompiled_code:
__int64 __fastcall bz_lazy_new(__int64 (__fastcall *a1)(__int64), __int64 a2)
{
bz_barf_push_function("bz_lazy_new");
bz_barf_pop_function();
return a1(a2);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 (__fastcall *a1)(__int64), __int64 a2)
{
bz_barf_push_function("bz_lazy_new");
bz_barf_pop_function();
return a1(a2);
}

original_code:
bz_Lazy* bz_lazy_new(const bz_Lazy* (*next)(),void* arg)
{
   {bz_barf_push_function(__PRETTY_FUNCTION__);;};
   {;bz_barf_pop_function();return ((bz_Lazy* )next(arg));};
}

canonical_original_code:
struct bz_lazy_node *bz_lazy_new(struct bz_lazy_node *(*next)(), void *arg)
{
   {bz_barf_push_function(__PRETTY_FUNCTION__);;};
   {;bz_barf_pop_function();return ((struct bz_lazy_node * )next(arg));};
}

variable_types:
next
struct bz_lazy_node *(*)()

variable_types:
arg
void *

return_type: struct bz_lazy_node { struct bz_Type { int *name; unsigned long size; void *(*new)(); void *(*clone)(); int (*length)(); int (*charsize)(); int (*compare)(); void *(*to_integer)(); void *(*to_real)(); void *(*to_string)(); void *(*to_list)(); void *(*to_wstr)(); void *(*show)(); } *type; void *node; void *(*next)(); void *arg; } *

user_defined_types: struct bz_lazy_node { struct bz_Type *type; void *node; void *(*next)(); void *arg; }


decompiled_code:
__int64 __fastcall bz_lazy_length(void *a1)
{
__int64 v1; // rbx
int v2; // ebp
__int64 (__fastcall *v3)(_QWORD); // rdx

v1 = (__int64)a1;
bz_barf_push_function("bz_lazy_length");
v2 = 0;
if ( a1 != &bz_Empty_value )
{
do
{
v3 = *(__int64 (__fastcall **)(_QWORD))(v1 + 16);
if ( (char *)v3 == (char *)&bz_Empty_value )
break;
++v2;
v1 = v3(*(_QWORD *)(v1 + 24));
}
while ( (_UNKNOWN *)v1 != &bz_Empty_value );
}
bz_barf_pop_function();
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func1(void *a1)
{
__int64 v1; // rbx
int v2; // ebp
__int64 (__fastcall *v3)(_QWORD); // rdx

v1 = (__int64)a1;
bz_barf_push_function("bz_lazy_length");
v2 = 0;
if ( a1 != &bz_Empty_value )
{
do
{
v3 = *(__int64 (__fastcall **)(_QWORD))(v1 + 16);
if ( (char *)v3 == (char *)&bz_Empty_value )
break;
++v2;
v1 = v3(*(_QWORD *)(v1 + 24));
}
while ( (_UNKNOWN *)v1 != &bz_Empty_value );
}
bz_barf_pop_function();
return v2;
}

original_code:
size_t bz_lazy_length(bz_Lazy* xs)
{
   int n = 0;
   {bz_barf_push_function(__PRETTY_FUNCTION__);;};
   while((xs != ((void *)&bz_Empty_value)) && (xs->next != ((void *)&bz_Empty_value))) {
      n++;
      xs = xs->next(xs->arg);
   }
   {;bz_barf_pop_function();return (n);};
}

canonical_original_code:
unsigned long bz_lazy_length(struct bz_lazy_node *xs)
{
   int n = 0;
   {bz_barf_push_function(__PRETTY_FUNCTION__);;};
   while((xs != ((void *)&bz_Empty_value)) && (xs->next != ((void *)&bz_Empty_value))) {
      n++;
      xs = xs->next(xs->arg);
   }
   {;bz_barf_pop_function();return (n);};
}

variable_types: struct bz_lazy_node { struct bz_Type { int *name; unsigned long size; void *(*new)(); void *(*clone)(); int (*length)(); int (*charsize)(); int (*compare)(); void *(*to_integer)(); void *(*to_real)(); void *(*to_string)(); void *(*to_list)(); void *(*to_wstr)(); void *(*show)(); } *type; void *node; void *(*next)(); void *arg; } *

variable_types: n int


decompiled_code:
__int64 __fastcall bz_lazy_charsize(__int64 a1)
{
int v1; // ebx

bz_barf_push_function("bz_lazy_charsize");
v1 = (*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 8) + 40LL))(*(_QWORD *)(a1 + 8));
bz_barf_pop_function();
return v1;
}

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

bz_barf_push_function("bz_lazy_charsize");
v1 = (*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 8) + 40LL))(*(_QWORD *)(a1 + 8));
bz_barf_pop_function();
return v1;
}

original_code:
size_t bz_lazy_charsize(bz_Lazy* xs)
{
   int n = 0;
   {bz_barf_push_function(__PRETTY_FUNCTION__);;};
   n = ((bz_Type *)((bz_node *)xs->node)->type)->charsize(xs->node);
   {;bz_barf_pop_function();return (n);};
}

canonical_original_code:
unsigned long bz_lazy_charsize(struct bz_lazy_node *xs)
{
   int n = 0;
   {bz_barf_push_function(__PRETTY_FUNCTION__);;};
   n = ((struct bz_Type *)((struct bz_node *)xs->node)->type)->charsize(xs->node);
   {;bz_barf_pop_function();return (n);};
}


decompiled_code:
void *bz_lazy_copy()
{
bz_barf_push_function("bz_lazy_copy");
bz_barf_pop_function();
return &bz_Empty_value;
}

canonical_decompiled_code:
void *func3()
{
bz_barf_push_function("bz_lazy_copy");
bz_barf_pop_function();
return &bz_Empty_value;
}

original_code:
bz_Lazy* bz_lazy_copy(bz_Lazy* xs)
{
   {bz_barf_push_function(__PRETTY_FUNCTION__);;};
   {;bz_barf_pop_function();return (((void *)&bz_Empty_value));};
}

canonical_original_code:
struct bz_lazy_node *bz_lazy_copy(struct bz_lazy_node *xs)
{
   {bz_barf_push_function(__PRETTY_FUNCTION__);;};
   {;bz_barf_pop_function();return (((void *)&bz_Empty_value));};
}

variable_types:
xs
struct bz_lazy_node *


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

if ( (_UNKNOWN *)a1 != &bz_Empty_value )
{
wprintf("%", *(unsigned int *)(a1 + 8));
v1 = (*(__int64 (__fastcall **)(_QWORD))(a1 + 16))(*(_QWORD *)(a1 + 24));
bz_lazy_show(v1);
}
}

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

if ( (_UNKNOWN *)a1 != &bz_Empty_value )
{
wprintf("%", *(unsigned int *)(a1 + 8));
v1 = (*(__int64 (__fastcall **)(_QWORD))(a1 + 16))(*(_QWORD *)(a1 + 24));
func5(v1);
}
}

original_code:
void bz_lazy_show(bz_Lazy* xs)
{
   if(xs != ((void *)&bz_Empty_value)) {
      wprintf(L"%i",(int)xs->node);
      bz_lazy_show(xs->next(xs->arg));
   }
}

canonical_original_code:
void bz_lazy_show(struct bz_lazy_node *xs)
{
   if(xs != ((void *)&bz_Empty_value)) {
      wprintf(L"%i",(int)xs->node);
      bz_lazy_show(xs->next(xs->arg));
   }
}


decompiled_code:
void __fastcall bz_lazy_filter(__int64 a1, __int64 a2)
{
_QWORD *v2; // rbx

v2 = malloc(8uLL);
if ( !v2 )
bz_barf("Out of memory");
*v2 = a1;
v2[1] = a2;
filter();
}

canonical_decompiled_code:
void __fastcall func6(__int64 a1, __int64 a2)
{
_QWORD *v2; // rbx

v2 = malloc(8uLL);
if ( !v2 )
bz_barf("Out of memory");
*v2 = a1;
v2[1] = a2;
func4();
}

original_code:
bz_Lazy* bz_lazy_filter(void* f, bz_Lazy* xs)
{
   filter_arg* arg = malloc(sizeof(arg));
   if(!arg) bz_barf("Out of memory");
   arg->f = f;
   arg->xs = xs;
   return _filter(arg);
}

canonical_original_code:
struct bz_lazy_node *bz_lazy_filter(void *f, struct bz_lazy_node *xs)
{
   struct filter_arg *arg = malloc(sizeof(arg));
   if(!arg) bz_barf("Out of memory");
   arg->f = f;
   arg->xs = xs;
   return _filter(arg);
}

variable_types:
f
void *

variable_types: struct filter_arg { void *(*f)(); void *xs; } *


decompiled_code:
__int64 bz_integer_length()
{
return 1LL;
}

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

original_code:
size_t bz_integer_length(bz_Integer* I)
{
  return 1;
}

canonical_original_code:
unsigned long bz_integer_length(struct bz_Integer *I)
{
  return 1;
}

variable_types: struct bz_Integer { struct bz_Type { int *name; unsigned long size; void *(*new)(); void *(*clone)(); int (*length)(); int (*charsize)(); int (*compare)(); void *(*to_integer)(); void *(*to_real)(); void *(*to_string)(); void *(*to_list)(); void *(*to_wstr)(); void *(*show)(); } *type; long long value; } *


decompiled_code:
__int64 __fastcall bz_integer_compare(__int64 a1, __int64 a2)
{
return (unsigned int)*(_QWORD *)(a1 + 8) - *(_DWORD *)(a2 + 8);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
return (unsigned int)*(_QWORD *)(a1 + 8) - *(_DWORD *)(a2 + 8);
}

original_code:
int bz_integer_compare(bz_Integer* x, bz_Integer* y)
{
  return x->value - y->value;
}

canonical_original_code:
int bz_integer_compare(struct bz_Integer *x, struct bz_Integer *y)
{
  return x->value - y->value;
}

variable_types:
y
struct bz_Integer *


original_code:
size_t bz_integer_charsize(bz_Integer* I)
{
  return ( (I->value == 0) ? 1 : (floor( log10( abs(I->value) ) ) + 1 + (I->value < 0 ? 1 : 0)) );
}

canonical_original_code:
unsigned long bz_integer_charsize(struct bz_Integer *I)
{
  return ( (I->value == 0) ? 1 : (floor( log10( abs(I->value) ) ) + 1 + (I->value < 0 ? 1 : 0)) );
}


decompiled_code:
int bz_integer_show()
{
struct _IO_FILE *v0; // rbx
const wchar_t *v1; // rax

v0 = stdout;
v1 = (const wchar_t *)bz_integer_to_wstr();
return fputws(v1, v0);
}

canonical_decompiled_code:
int func3()
{
struct _IO_FILE *v0; // rbx
const wchar_t *v1; // rax

v0 = stdout;
v1 = (const wchar_t *)bz_integer_to_wstr();
return fputws(v1, v0);
}

original_code:
void bz_integer_show(bz_Integer* I)
{
  fputws(bz_integer_to_wstr(I),stdout);
}

canonical_original_code:
void bz_integer_show(struct bz_Integer *I)
{
  fputws(bz_integer_to_wstr(I),stdout);
}


decompiled_code:
__int64 bz_nvp_length()
{
return 1LL;
}

original_code:
size_t bz_nvp_length(bz_Nvp* xs)
{
  return 1;
}

canonical_original_code:
unsigned long bz_nvp_length(struct bz_Nvp *xs)
{
  return 1;
}

variable_types: struct bz_Nvp { struct bz_Type { int *name; unsigned long size; void *(*new)(); void *(*clone)(); int (*length)(); int (*charsize)(); int (*compare)(); void *(*to_integer)(); void *(*to_real)(); void *(*to_string)(); void *(*to_list)(); void *(*to_wstr)(); void *(*show)(); } *type; struct bz_String { struct bz_Type *type; unsigned long buffer_size; unsigned long length; int *string; } *name; void *value; struct bz_String *filename; int line; } *

user_defined_types: struct bz_Nvp { struct bz_Type *type; struct bz_String *name; void *value; struct bz_String *filename; int line; }


decompiled_code:
__int64 __fastcall bz_nvp_charsize(__int64 a1)
{
return bz_string_length(*(_QWORD *)(a1 + 8));
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
return bz_string_length(*(_QWORD *)(a1 + 8));
}

original_code:
size_t bz_nvp_charsize(bz_Nvp* n)
{
  return bz_string_length(n->name);
}

canonical_original_code:
unsigned long bz_nvp_charsize(struct bz_Nvp *n)
{
  return bz_string_length(n->name);
}


decompiled_code:
__int64 __fastcall bz_nvp_show(__int64 a1)
{
return bz_string_show(*(_QWORD *)(a1 + 8));
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
return bz_string_show(*(_QWORD *)(a1 + 8));
}

original_code:
void bz_nvp_show(bz_Nvp* n)
{
  bz_string_show(n->name);
}

canonical_original_code:
void bz_nvp_show(struct bz_Nvp *n)
{
  bz_string_show(n->name);
}


decompiled_code:
int bz_trace_cleanup()
{
return fclose(bz_trace_log_file);
}

canonical_decompiled_code:
int func0()
{
return fclose(bz_trace_log_file);
}

original_code:
void bz_trace_cleanup(void)
{
  fclose(bz_trace_log_file);
}

canonical_original_code:
void bz_trace_cleanup()
{
  fclose(bz_trace_log_file);
}


decompiled_code:
int __fastcall bz_trace_log(const char *a1, const char *a2, __int64 a3, __int64 a4)
{
return fprintf(bz_trace_log_file, "%s\t\t%s\t\t%12li\t\t%12li\n", a1, a2, a3, a4);
}

canonical_decompiled_code:
int __fastcall func1(const char *a1, const char *a2, __int64 a3, __int64 a4)
{
return fprintf(bz_trace_log_file, "%s\t\t%s\t\t%12li\t\t%12li\n", a1, a2, a3, a4);
}

original_code:
void bz_trace_log(const char* file, const char* function,long time1,long time2)
{
  fprintf(bz_trace_log_file,"%s\t\t%s\t\t%12li\t\t%12li\n",file,function,time1,time2);
}

canonical_original_code:
void bz_trace_log(char *file, char *function, long time1, long time2)
{
  fprintf(bz_trace_log_file,"%s\t\t%s\t\t%12li\t\t%12li\n",file,function,time1,time2);
}

variable_types:
file
char *

variable_types:
function
char *


decompiled_code:
int __fastcall bz_trace_push(__time_t a1, __suseconds_t a2)
{
struct timeval *v2; // rax

v2 = (struct timeval *)GC_malloc(72LL);
if ( !v2 )
{
fprintf(stderr, "[!] %s: Error in trace.c '%s'\n", (const char *)prog_name, "Out of memory");
exit(0);
}
v2->tv_sec = a1;
v2->tv_usec = a2;
v2[3].tv_usec = 0LL;
v2[4].tv_sec = tstack;
tstack = (__int64)v2;
return gettimeofday(v2 + 1, &tz);
}

canonical_decompiled_code:
int __fastcall func2(__time_t a1, __suseconds_t a2)
{
struct timeval *v2; // rax

v2 = (struct timeval *)GC_malloc(72LL);
if ( !v2 )
{
fprintf(stderr, "[!] %s: Error in trace.c '%s'\n", (const char *)prog_name, "Out of memory");
exit(0);
}
v2->tv_sec = a1;
v2->tv_usec = a2;
v2[3].tv_usec = 0LL;
v2[4].tv_sec = tstack;
tstack = (__int64)v2;
return gettimeofday(v2 + 1, &tz);
}

original_code:
void bz_trace_push(const char *file, const char* function)
{
  bz_trace_stack *ts;
  ts = GC_malloc(sizeof(bz_trace_stack));
  if (!ts) {fprintf(stderr,"[!] %s: Error in trace.c '%s'\n",prog_name,"Out of memory");exit(0);};
  ts->file = file;
  ts->function = function;
  ts->tot_child_time = 0;
  ts->prev = tstack;
  tstack = ts;
  gettimeofday(&ts->start,&tz);
}

canonical_original_code:
void bz_trace_push(char *file, char *function)
{
  struct bz_trace_rec *ts;
  ts = GC_malloc(sizeof(bz_trace_stack));
  if (!ts) {fprintf(stderr,"[!] %s: Error in trace.c '%s'\n",prog_name,"Out of memory");exit(0);};
  ts->file = file;
  ts->function = function;
  ts->tot_child_time = 0;
  ts->prev = tstack;
  tstack = ts;
  gettimeofday(&ts->start,&tz);
}

variable_types: struct bz_trace_rec { char *file; char *function; struct timeval { long tv_sec; long tv_usec; } start; struct timeval stop; long tot_time; long tot_child_time; struct bz_trace_rec *prev; } *

user_defined_types: struct bz_trace_rec { char *file; char *function; struct timeval start; struct timeval stop; long tot_time; long tot_child_time; struct bz_trace_rec *prev; }


decompiled_code:
__int64 bz_trace_pop()
{
__int64 v0; // rbx
__int64 v1; // rdx
__int64 result; // rax

v0 = tstack;
if ( !tstack )
{
fprintf(stderr, "[!] %s: Error in trace.c '%s'\n", (const char *)prog_name, "Tried to pop an empty trace stack");
exit(0);
}
gettimeofday((struct timeval *)(tstack + 32), &tz);
v1 = *(_QWORD *)(v0 + 40)
+ 1000000LL * *(_QWORD *)(v0 + 32)
- (*(_QWORD *)(v0 + 24)
+ 1000000LL * *(_QWORD *)(v0 + 16));
*(_QWORD *)(v0 + 48) = v1;
bz_trace_log(*(const char **)v0, *(const char **)(v0 + 8), v1, v1 - *(_QWORD *)(v0 + 56));
result = *(_QWORD *)(v0 + 64);
tstack = result;
if ( result )
*(_QWORD *)(result + 56) += *(_QWORD *)(v0 + 48);
return result;
}

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

v0 = tstack;
if ( !tstack )
{
fprintf(stderr, "[!] %s: Error in trace.c '%s'\n", (const char *)prog_name, "Tried to pop an empty trace stack");
exit(0);
}
gettimeofday((struct timeval *)(tstack + 32), &tz);
v1 = *(_QWORD *)(v0 + 40)
+ 1000000LL * *(_QWORD *)(v0 + 32)
- (*(_QWORD *)(v0 + 24)
+ 1000000LL * *(_QWORD *)(v0 + 16));
*(_QWORD *)(v0 + 48) = v1;
func1(*(const char **)v0, *(const char **)(v0 + 8), v1, v1 - *(_QWORD *)(v0 + 56));
result = *(_QWORD *)(v0 + 64);
tstack = result;
if ( result )
*(_QWORD *)(result + 56) += *(_QWORD *)(v0 + 48);
return result;
}

original_code:
void bz_trace_pop(void)
{
  bz_trace_stack *ts;
  ts = tstack;
   if (ts) {
      gettimeofday(&ts->stop,&tz);
      ts->tot_time =
         ((long)ts->stop.tv_sec*1000000 + (long)ts->stop.tv_usec)
            - ((long)ts->start.tv_sec * 1000000 + (long)ts->start.tv_usec);
      bz_trace_log(ts->file, ts->function, ts->tot_time, ts->tot_time - ts->tot_child_time);
      tstack = ts->prev;
      if (tstack) {
         tstack->tot_child_time += ts->tot_time;
      }
   } else {
     {fprintf(stderr,"[!] %s: Error in trace.c '%s'\n",prog_name,"Tried to pop an empty trace stack");exit(0);};
   }
}

canonical_original_code:
void bz_trace_pop()
{
  struct bz_trace_rec *ts;
  ts = tstack;
   if (ts) {
      gettimeofday(&ts->stop,&tz);
      ts->tot_time =
         ((long)ts->stop.tv_sec*1000000 + (long)ts->stop.tv_usec)
            - ((long)ts->start.tv_sec * 1000000 + (long)ts->start.tv_usec);
      bz_trace_log(ts->file, ts->function, ts->tot_time, ts->tot_time - ts->tot_child_time);
      tstack = ts->prev;
      if (tstack) {
         tstack->tot_child_time += ts->tot_time;
      }
   } else {
     {fprintf(stderr,"[!] %s: Error in trace.c '%s'\n",prog_name,"Tried to pop an empty trace stack");exit(0);};
   }
}

user_defined_types: struct timeval { long tv_sec; long tv_usec; }


decompiled_code:
_QWORD *bz_barf_stack_new()
{
_QWORD *result; // rax

result = (_QWORD *)GC_malloc(16LL);
if ( !result )
{
fprintf(stderr, "[!] %s: Error in barf.c '%s'\n", (const char *)prog_name, "Out of memory");
exit(0);
}
*result = 0LL;
result[1] = 0LL;
return result;
}

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

result = (_QWORD *)GC_malloc(16LL);
if ( !result )
{
fprintf(stderr, "[!] %s: Error in barf.c '%s'\n", (const char *)prog_name, "Out of memory");
exit(0);
}
*result = 0LL;
result[1] = 0LL;
return result;
}

original_code:
static inline bz_barf_stack* bz_barf_stack_new()
{
   bz_barf_stack* new;
   new = GC_malloc(sizeof(bz_barf_stack));
   if(new==((void *)0))
      {fprintf(stderr,"[!] %s: Error in barf.c '%s'\n",prog_name,"Out of memory");exit(0);};
   new->barf_data = ((void *)0);
   new->next = ((void *)0);
   return new;
}

canonical_original_code:
static inline struct bz_barf_stack_node *bz_barf_stack_new()
{
   struct bz_barf_stack_node *new;
   new = GC_malloc(sizeof(bz_barf_stack));
   if(new==((void *)0))
      {fprintf(stderr,"[!] %s: Error in barf.c '%s'\n",prog_name,"Out of memory");exit(0);};
   new->barf_data = ((void *)0);
   new->next = ((void *)0);
   return new;
}

variable_types: struct bz_barf_stack_node { void *barf_data; struct bz_barf_stack_node *next; } *


decompiled_code:
__sighandler_t set_signals()
{
signal(4, signal_handler);
signal(8, signal_handler);
signal(7, signal_handler);
signal(11, signal_handler);
signal(15, signal_handler);
return signal(2, signal_handler);
}

canonical_decompiled_code:
__sighandler_t func3()
{
signal(4, signal_handler);
signal(8, signal_handler);
signal(7, signal_handler);
signal(11, signal_handler);
signal(15, signal_handler);
return signal(2, signal_handler);
}

original_code:
static void set_signals(void)
{
   signal(4, signal_handler);
   signal(8, signal_handler);
   signal(7, signal_handler);
   signal(11, signal_handler);
   signal(15, signal_handler);
   signal(2, signal_handler);
}

canonical_original_code:
static void set_signals()
{
   signal(4, signal_handler);
   signal(8, signal_handler);
   signal(7, signal_handler);
   signal(11, signal_handler);
   signal(15, signal_handler);
   signal(2, signal_handler);
}


decompiled_code:
__int64 bz_barf_prog_name()
{
return prog_name;
}

canonical_decompiled_code:
__int64 func4()
{
return prog_name;
}

original_code:
inline const char* bz_barf_prog_name(void)
{
   return prog_name;
}

canonical_original_code:
inline char *bz_barf_prog_name()
{
   return prog_name;
}

return_type: char *


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

result = bz_barf_stack_pop(pfs);
pfs = result;
return result;
}

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

result = func2(pfs);
pfs = result;
return result;
}

original_code:
inline void bz_barf_pop_function()
{
   pfs = (bz_barf_stack*) bz_barf_stack_pop(pfs);
}

canonical_original_code:
inline void bz_barf_pop_function()
{
   pfs = (struct bz_barf_stack_node *) bz_barf_stack_pop(pfs);
}

user_defined_types: struct bz_barf_stack_node { void *barf_data; struct bz_barf_stack_node *next; }


decompiled_code:
void __fastcall __noreturn bz_barf(const char *a1)
{
const char *v1; // rax
const char *v2; // rax

already_barfing = 1;
fwrite("\n**ERROR****************************************************************\n", 1uLL, 0x49uLL, stderr);
fprintf(stderr, "Program: %s\n", (const char *)prog_name);
fprintf(stderr, "Error: %s\n", a1);
v1 = (const char *)bz_barf_stack_top(pfs);
fprintf(stderr, "In: %s()\n", v1);
v2 = bz_barf_stack_show(pfs, "<-");
fprintf(stderr, "Trace: error%s\n", v2);
fwrite("***********************************************************************\n", 1uLL, 0x48uLL, stderr);
exit(0);
}

canonical_decompiled_code:
void __fastcall __noreturn func6(const char *a1)
{
const char *v1; // rax
const char *v2; // rax

already_barfing = 1;
fwrite("\n**ERROR****************************************************************\n", 1uLL, 0x49uLL, stderr);
fprintf(stderr, "Program: %s\n", (const char *)prog_name);
fprintf(stderr, "Error: %s\n", a1);
v1 = (const char *)func0(pfs);
fprintf(stderr, "In: %s()\n", v1);
v2 = bz_barf_stack_show(pfs, "<-");
fprintf(stderr, "Trace: error%s\n", v2);
fwrite("***********************************************************************\n", 1uLL, 0x48uLL, stderr);
exit(0);
}


decompiled_code:
void __fastcall signal_handler(int a1)
{
if ( already_barfing )
exit(1);
switch ( a1 )
{
case 2:
exit(1);
case 4:
bz_barf("Illegal instruction");
case 7:
bz_barf("Bus error");
case 8:
bz_barf("Floating point exception");
case 11:
bz_barf("Segmentation violation");
case 15:
bz_barf("Terminated");
default:
return;
}
}

canonical_decompiled_code:
void __fastcall func7(int a1)
{
if ( already_barfing )
exit(1);
switch ( a1 )
{
case 2:
exit(1);
case 4:
func6("Illegal instruction");
case 7:
func6("Bus error");
case 8:
func6("Floating point exception");
case 11:
func6("Segmentation violation");
case 15:
func6("Terminated");
default:
return;
}
}

original_code:
static void signal_handler(int sig)
{
   if(already_barfing) {
      exit(1);
   }
   switch (sig)
   {
   case 15:
      bz_barf("Terminated");
      break;
   case 2:
      exit(1);
      break;
   case 7:
      bz_barf("Bus error");
      break;
   case 11:
      bz_barf("Segmentation violation");
      break;
   case 4:
      bz_barf("Illegal instruction");
      break;
   case 8:
      bz_barf("Floating point exception");
      break;
   }
}

variable_types: sig int


main

canonical_name: main

repo: sameenjalal/Linux-File-System

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
format_fs("ssjfs_disk", 800LL, envp);
open_fs("ssjfs_disk");
test_fs();
close_fs("ssjfs_disk");
return 0;
}

original_code:
int main(){
 format_fs("ssjfs_disk", 800);
 open_fs("ssjfs_disk");
 test_fs();
 close_fs("ssjfs_disk");
 return 0;
}


decompiled_code:
__int64 __fastcall file_open(char *src)
{
__int64 v1; // rbx
_DWORD *v2; // rbp
char *v3; // rbp

v1 = (unsigned int)path_to_inumber();
printf("path_to_inumber returned %d\n", v1);
if ( (int)v1 <= 0 )
return 4294967293LL;
v2 = (_DWORD *)get_inode((unsigned int)v1);
printf("get_inode returned %p\n", v2);
if ( v2[3] )
return 4294967291LL;
v3 = (char *)malloc(0x6CuLL);
strcpy(v3, src);
*((_DWORD *)v3 + 25) = v1;
*((_DWORD *)v3 + 26) = 0;
return arraylist_add(v3, open_files);
}

canonical_decompiled_code:
__int64 __fastcall func0(char *src)
{
__int64 v1; // rbx
_DWORD *v2; // rbp
char *v3; // rbp

v1 = (unsigned int)path_to_inumber();
printf("path_to_inumber returned %d\n", v1);
if ( (int)v1 <= 0 )
return 4294967293LL;
v2 = (_DWORD *)get_inode((unsigned int)v1);
printf("get_inode returned %p\n", v2);
if ( v2[3] )
return 4294967291LL;
v3 = (char *)malloc(0x6CuLL);
strcpy(v3, src);
*((_DWORD *)v3 + 25) = v1;
*((_DWORD *)v3 + 26) = 0;
return arraylist_add(v3, open_files);
}

original_code:
int
file_open(char *path)
{
 int file_num;
    int inumber = path_to_inumber(path);
 printf("path_to_inumber returned %d\n", inumber);
 if ( inumber <= 0 )
        return -3;
 inode *in = get_inode(inumber);
 printf("get_inode returned %p\n", in);
 if ( in->directory_flag )
  return -5;
 file_info *new_file = (file_info *) malloc(sizeof(file_info));
 strcpy(new_file->filepath, path);
 new_file->inumber = inumber;
 new_file->cursor = 0;
 file_num = arraylist_add(new_file,open_files);
 return file_num;
}

canonical_original_code:
int file_open(char *path)
{
 int file_num;
    int inumber = path_to_inumber(path);
 printf("path_to_inumber returned %d\n", inumber);
 if ( inumber <= 0 )
        return -3;
 struct inode *in = get_inode(inumber);
 printf("get_inode returned %p\n", in);
 if ( in->directory_flag )
  return -5;
 struct file_info *new_file = (file_info *) malloc(sizeof(file_info));
 strcpy(new_file->filepath, path);
 new_file->inumber = inumber;
 new_file->cursor = 0;
 file_num = arraylist_add(new_file,open_files);
 return file_num;
}

variable_types:
path
char *

variable_types: inumber int

variable_types: struct inode { int next_free; int prev_free; int filesize; int directory_flag; int block_pointers[10]; int indirect_pointer; int double_indirect_pointer; } *

variable_types: struct file_info { char filepath[100]; int inumber; int cursor; } *


decompiled_code:
__int64 __fastcall file_close(__int64 a1)
{
return arraylist_delete(a1, open_files);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
return arraylist_delete(a1, open_files);
}

original_code:
void
file_close(int file_number)
{
 if ( !arraylist_delete(file_number, open_files) )
  return;
}


decompiled_code:
__int64 __fastcall file_mkdir(__int64 a1)
{
return file_create_generic(a1, 1LL);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
return file_create_generic(a1, 1LL);
}

original_code:
int file_mkdir(char *path)
{
 return file_create_generic(path, 1);
}


decompiled_code:
__int64 __fastcall file_rmdir(__int64 a1)
{
return file_delete_generic(a1, 1LL);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
return file_delete_generic(a1, 1LL);
}

original_code:
int file_rmdir(char *path)
{
 return file_delete_generic(path, 1);
}


decompiled_code:
int file_printdir()
{
const char **v0; // rax
const char *v1; // rdx
const char **v2; // rbx

v0 = (const char **)file_listdir();
v1 = *v0;
if ( *v0 )
{
v2 = v0 + 1;
do
{
LODWORD(v0) = fprintf(stdout, "%s\n", v1);
v1 = *v2++;
}
while ( v1 );
}
return (int)v0;
}

canonical_decompiled_code:
int func3()
{
const char **v0; // rax
const char *v1; // rdx
const char **v2; // rbx

v0 = (const char **)func2();
v1 = *v0;
if ( *v0 )
{
v2 = v0 + 1;
do
{
LODWORD(v0) = fprintf(stdout, "%s\n", v1);
v1 = *v2++;
}
while ( v1 );
}
return (int)v0;
}

original_code:
void file_printdir(char *path)
{
 char **names;
 char *ptr;
 int i;
 names = file_listdir(path);
 for (i = 0; names[i] != ((void *)0); i++){
  fprintf(stdout, "%s\n", names[i]);
 }
}

variable_types:
names
char **

variable_types:
ptr
char *

variable_types: i int


original_code:
int arraylist_add(void * new_value, arraylist *list){
 void * *data_array;
 int size = list->size;
 int index;
 if (size == list->capacity){
  data_array = (void * *)malloc(sizeof(void *) * (size * 2));
  for (index = 0; index < size; index++){
   data_array[index] = list->data[index];
  }
  free(list->data);
  list->data = data_array;
  list->capacity = size * 2;
 }
 else{
  data_array = list->data;
 }
 data_array[size] = new_value;
 list->size++;
 return size;
}

canonical_original_code:
int arraylist_add(void *new_value, struct arraylist *list){
 void **data_array;
 int size = list->size;
 int index;
 if (size == list->capacity){
  data_array = (void **)malloc(sizeof(void *) * (size * 2));
  for (index = 0; index < size; index++){
   data_array[index] = list->data[index];
  }
  free(list->data);
  list->data = data_array;
  list->capacity = size * 2;
 }
 else{
  data_array = list->data;
 }
 data_array[size] = new_value;
 list->size++;
 return size;
}

variable_types: struct arraylist { void **data; int size; int capacity; } *

variable_types: size int

variable_types: index int


decompiled_code:
__int64 __fastcall arraylist_set(int a1, __int64 a2, __int64 a3)
{
if ( *(_DWORD *)(a3 + 8) <= a1 || a1 < 0 )
return 1LL;
*(_QWORD *)(*(_QWORD *)a3 + 8LL * a1) = a2;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1, __int64 a2, __int64 a3)
{
if ( *(_DWORD *)(a3 + 8) <= a1 || a1 < 0 )
return 1LL;
*(_QWORD *)(*(_QWORD *)a3 + 8LL * a1) = a2;
return 0LL;
}

original_code:
int arraylist_set(int index, void * data, arraylist *list){
 if (index >= list->size || index < 0){
  return 1;
 }
 list->data[index] = data;
 return 0;
}

canonical_original_code:
int arraylist_set(int index, void *data, struct arraylist *list){
 if (index >= list->size || index < 0){
  return 1;
 }
 list->data[index] = data;
 return 0;
}

variable_types:
data
void *

user_defined_types: struct arraylist { void **data; int size; int capacity; }


original_code:
int arraylist_delete(int index, arraylist *list){
 int i;
 if (index < 0 || index >= list->size){
  return 1;
 }
 for (i = index; i < list->size - 1; i++){
  list->data[i] = list->data[i + 1];
 }
 list->size--;
 return 0;
}

canonical_original_code:
int arraylist_delete(int index, struct arraylist *list){
 int i;
 if (index < 0 || index >= list->size){
  return 1;
 }
 for (i = index; i < list->size - 1; i++){
  list->data[i] = list->data[i + 1];
 }
 list->size--;
 return 0;
}


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

if ( *(_DWORD *)(a2 + 8) <= a1 || a1 < 0 )
result = 0LL;
else
result = *(_QWORD *)(*(_QWORD *)a2 + 8LL * a1);
return result;
}

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

if ( *(_DWORD *)(a2 + 8) <= a1 || a1 < 0 )
result = 0LL;
else
result = *(_QWORD *)(*(_QWORD *)a2 + 8LL * a1);
return result;
}

original_code:
void * arraylist_get(int index, arraylist *list){
 void * ret;
 if (index >= list->size || index < 0){
  return ((void *)0);
 }
 ret = list->data[index];
 return ret;
}

canonical_original_code:
void *arraylist_get(int index, struct arraylist *list){
 void *ret;
 if (index >= list->size || index < 0){
  return ((void *)0);
 }
 ret = list->data[index];
 return ret;
}

variable_types:
ret
void *


decompiled_code:
__int64 __fastcall arraylist_size(__int64 a1)
{
return *(unsigned int *)(a1 + 8);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
return *(unsigned int *)(a1 + 8);
}

original_code:
int arraylist_size(arraylist *list){
 return list->size;
}

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


decompiled_code:
__int64 __fastcall arraylist_capacity(__int64 a1)
{
return *(unsigned int *)(a1 + 12);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
return *(unsigned int *)(a1 + 12);
}

original_code:
int arraylist_capacity(arraylist *list){
 return list->capacity;
}

canonical_original_code:
int arraylist_capacity(struct arraylist *list){
 return list->capacity;
}


decompiled_code:
void __fastcall arraylist_destroy(void *ptr)
{
free(*(void **)ptr);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func6(void *ptr)
{
free(*(void **)ptr);
free(ptr);
}

original_code:
void arraylist_destroy(arraylist *list){
 free(list->data);
 free(list);
}

canonical_original_code:
void arraylist_destroy(struct arraylist *list){
 free(list->data);
 free(list);
}


decompiled_code:
__int64 __fastcall file_create(__int64 a1)
{
return file_create_generic(a1, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
return file_create_generic(a1, 0LL);
}

original_code:
int file_create(char *path)
{
 int st = file_create_generic(path, 0);
 return st;
}

variable_types: st int


decompiled_code:
__int64 __fastcall file_delete(__int64 a1)
{
return file_delete_generic(a1, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
return file_delete_generic(a1, 0LL);
}

original_code:
int file_delete(char *path){
 return file_delete_generic(path, 0);
}