decompiled_code:
struct __jmp_buf_tag __fastcall p_filesystem_clone[1](__int64 a1)
{
struct __jmp_buf_tag *__attribute__((__org_arrdim(0,1))) v1; // rbp
_BYTE v3[332]; // [rsp-150h] [rbp-168h] BYREF

if ( *(char **)(a1 + 16) == "filesystem" )
{
v1 = (struct __jmp_buf_tag *)p_object_clone();
v1->__saved_mask.__val[11] = (*(__int64 (__fastcall **)(_QWORD))(*(_QWORD *)(a1 + 160) + 128LL))(*(_QWORD *)(a1 + 160));
}
else
{
v1 = v_exception_hook;
if ( v_exception_hook )
{
qmemcpy(v3, &v_exception_kind, sizeof(v3));
p_exception_fill("object is not an instance of o_filesystem", "o_filesystem.c", "p_filesystem_clone", 113LL);
longjmp(v_exception_hook, v_exception_raised[82]);
}
}
return v1;
}

canonical_decompiled_code:
struct __jmp_buf_tag __fastcall func3[1](__int64 a1)
{
struct __jmp_buf_tag *__attribute__((__org_arrdim(0,1))) v1; // rbp
_BYTE v3[332]; // [rsp-150h] [rbp-168h] BYREF

if ( *(char **)(a1 + 16) == "filesystem" )
{
v1 = (struct __jmp_buf_tag *)p_object_clone();
v1->__saved_mask.__val[11] = (*(__int64 (__fastcall **)(_QWORD))(*(_QWORD *)(a1 + 160) + 128LL))(*(_QWORD *)(a1 + 160));
}
else
{
v1 = v_exception_hook;
if ( v_exception_hook )
{
qmemcpy(v3, &v_exception_kind, sizeof(v3));
p_exception_fill("object is not an instance of o_filesystem", "o_filesystem.c", "p_filesystem_clone", 113LL);
longjmp(v_exception_hook, v_exception_raised[82]);
}
}
return v1;
}

original_code:
struct o_object *p_filesystem_clone(struct o_object *object) {
  struct o_filesystem *result = ((void *)0), *local_object;
  if ((local_object = ((struct o_filesystem *)(((object)->kind==v_filesystem_kind)?(object):((void *)0))))) {
    result = (struct o_filesystem *)p_object_clone(object);
    result->files = (struct o_dictionary*)((struct o_object *)local_object->files)->s_delegate.m_clone((struct o_object *)local_object->files);
  } else
    do{ if(v_exception_hook){ p_exception_fill((v_exception_kind),("object is not an instance of o_filesystem"),"o_filesystem.c",__FUNCTION__,113); longjmp(*v_exception_hook,v_exception_raised.identificator); } }while(0);
  return (o_object *)result;
}

canonical_original_code:
struct o_object *p_filesystem_clone(struct o_object *object) {
  struct o_filesystem *result = ((void *)0); struct o_filesystem *local_object;
  if ((local_object = ((struct o_filesystem *)(((object)->kind==v_filesystem_kind)?(object):((void *)0))))) {
    result = (struct o_filesystem *)p_object_clone(object);
    result->files = (struct o_dictionary *)((struct o_object *)local_object->files)->s_delegate.m_clone((struct o_object *)local_object->files);
  } else
    do{ if(v_exception_hook){ p_exception_fill((v_exception_kind),("object is not an instance of o_filesystem"),"o_filesystem.c",__FUNCTION__,113); longjmp(*v_exception_hook,v_exception_raised.identificator); } }while(0);
  return (struct o_object *)result;
}

variable_types:
object
struct o_object *


repo: nardinan/serenity

decompiled_code:
__int64 __fastcall p_filesystem_store(__int64 a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // rbp
__int64 v4; // rbx
int v5; // eax
unsigned __int64 v6; // [rsp+0h] [rbp-138h]
__int64 v7; // [rsp+8h] [rbp-130h]
struct __jmp_buf_tag *v8; // [rsp+28h] [rbp-110h]
struct __jmp_buf_tag v9; // [rsp+30h] [rbp-108h] BYREF
char dest[8]; // [rsp+100h] [rbp-38h] BYREF
__int64 v11; // [rsp+108h] [rbp-30h]
__int64 v12[5]; // [rsp+110h] [rbp-28h] BYREF

result = (*(__int64 (__fastcall **)(_QWORD))(*(_QWORD *)(a1 + 160) + 200LL))(*(_QWORD *)(a1 + 160));
v7 = result;
v6 = 0LL;
if ( result )
{
while ( *(_QWORD *)(v7 + 176) > v6 )
{
v8 = v_exception_hook;
v_exception_hook = &v9;
if ( setjmp(&v9) )
{
v_exception_hook = v8;
v5 = v_exception_raised[81];
v_exception_raised[81] = v5 + 1;
if ( !v5 )
fprintf(
stderr,
"%s:%s() @ %d {%s} %s\n",
(const char *)&v_exception_raised[16],
(const char *)&v_exception_raised[32],
(unsigned int)v_exception_raised[80],
(const char *)v_exception_raised,
(const char *)&v_exception_raised[48]);
fprintf(stderr, "\t%s:%s() @ %d\n", "o_filesystem.c", "p_filesystem_store", 146LL);
if ( v_exception_hook )
longjmp(v_exception_hook, v_exception_raised[82]);
}
else
{
v3 = (*(__int64 (__fastcall **)(__int64, unsigned __int64))(v7 + 208))(v7, v6);
v4 = (*(__int64 (__fastcall **)(_QWORD, __int64))(*(_QWORD *)(a1 + 160) + 192LL))(*(_QWORD *)(a1 + 160), v3);
if ( v4 )
{
*(_QWORD *)dest = 0LL;
v11 = 0LL;
v12[0] = 0LL;
strncpy(dest, *(const char **)(v3 + 168), 0x10uLL);
v12[0] = (*(__int64 (__fastcall **)(__int64))(v4 + 232))(v4);
if ( !(unsigned int)f_endian_check() )
f_endian_swap(v12, 8LL);
(*(void (__fastcall **)(__int64, __int64, char *))(a2 + 184))(a2, 24LL, dest);
(*(void (__fastcall **)(__int64, __int64))(a2 + 200))(a2, v4);
}
}
v_exception_hook = v8;
++v6;
}
result = f_object_release(v7);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // rbp
__int64 v4; // rbx
int v5; // eax
unsigned __int64 v6; // [rsp+0h] [rbp-138h]
__int64 v7; // [rsp+8h] [rbp-130h]
struct __jmp_buf_tag *v8; // [rsp+28h] [rbp-110h]
struct __jmp_buf_tag v9; // [rsp+30h] [rbp-108h] BYREF
char dest[8]; // [rsp+100h] [rbp-38h] BYREF
__int64 v11; // [rsp+108h] [rbp-30h]
__int64 v12[5]; // [rsp+110h] [rbp-28h] BYREF

result = (*(__int64 (__fastcall **)(_QWORD))(*(_QWORD *)(a1 + 160) + 200LL))(*(_QWORD *)(a1 + 160));
v7 = result;
v6 = 0LL;
if ( result )
{
while ( *(_QWORD *)(v7 + 176) > v6 )
{
v8 = v_exception_hook;
v_exception_hook = &v9;
if ( setjmp(&v9) )
{
v_exception_hook = v8;
v5 = v_exception_raised[81];
v_exception_raised[81] = v5 + 1;
if ( !v5 )
fprintf(
stderr,
"%s:%s() @ %d {%s} %s\n",
(const char *)&v_exception_raised[16],
(const char *)&v_exception_raised[32],
(unsigned int)v_exception_raised[80],
(const char *)v_exception_raised,
(const char *)&v_exception_raised[48]);
fprintf(stderr, "\t%s:%s() @ %d\n", "o_filesystem.c", "p_filesystem_store", 146LL);
if ( v_exception_hook )
longjmp(v_exception_hook, v_exception_raised[82]);
}
else
{
v3 = (*(__int64 (__fastcall **)(__int64, unsigned __int64))(v7 + 208))(v7, v6);
v4 = (*(__int64 (__fastcall **)(_QWORD, __int64))(*(_QWORD *)(a1 + 160) + 192LL))(*(_QWORD *)(a1 + 160), v3);
if ( v4 )
{
*(_QWORD *)dest = 0LL;
v11 = 0LL;
v12[0] = 0LL;
strncpy(dest, *(const char **)(v3 + 168), 0x10uLL);
v12[0] = (*(__int64 (__fastcall **)(__int64))(v4 + 232))(v4);
if ( !(unsigned int)f_endian_check() )
f_endian_swap(v12, 8LL);
(*(void (__fastcall **)(__int64, __int64, char *))(a2 + 184))(a2, 24LL, dest);
(*(void (__fastcall **)(__int64, __int64))(a2 + 200))(a2, v4);
}
}
v_exception_hook = v8;
++v6;
}
result = f_object_release(v7);
}
return result;
}

original_code:
void p_filesystem_store(struct o_filesystem *object, struct o_stream *destination) {
  struct o_array *keys = ((void *)0);
  struct o_stream *stream;
  struct o_string *key;
  struct s_filesystem_header header;
  struct s_exception *exception = ((void *)0);
  size_t index;
  if ((keys = object->files->m_keys(object->files))) {
    for (index = 0; index < keys->filled; index++) {
      do{ jmp_buf _local_hook, *_last_hook=v_exception_hook; int _local_code; v_exception_hook=&_local_hook; if((_local_code = _setjmp (_local_hook))==0){ {
        key = (struct o_string *)keys->m_get(keys, index);
        if ((stream = (struct o_stream *) object->files->m_get(object->files, (struct o_object *)key))) {
          memset(&header, 0, sizeof(struct s_filesystem_header));
          strncpy(header.name, key->content, 16);
          header.bytes = stream->m_size(stream);
          if (f_endian_check() == 0)
            f_endian_swap(&(header.bytes), sizeof(header.bytes));
          destination->m_write(destination, sizeof(struct s_filesystem_header), &header);
          destination->m_write_stream(destination, stream);
        }
      } }else{ v_exception_hook=_last_hook; (exception)=&v_exception_raised; {
        do{ if(((exception)->level++)==0) fprintf((stderr),"%s:%s() @ %d {%s} %s\n",(exception)->file,exception->function,(exception)->line,(exception)->kind,(exception)->description); fprintf((stderr),"\t%s:%s() @ %d\n","o_filesystem.c",__FUNCTION__,146); }while(0);
        do{ if(v_exception_hook) longjmp(*v_exception_hook,v_exception_raised.identificator); }while(0);
      } } v_exception_hook=_last_hook; }while(0);
    }
    f_object_release((struct o_object *)keys);
  }
}

canonical_original_code:
void p_filesystem_store(struct o_filesystem *object, struct o_stream *destination) {
  struct o_array *keys = ((void *)0);
  struct o_stream *stream;
  struct o_string *key;
  struct s_filesystem_header header;
  struct s_exception *exception = ((void *)0);
  unsigned long index;
  if ((keys = object->files->m_keys(object->files))) {
    for (index = 0; index < keys->filled; index++) {
      do{ struct __jmp_buf_tag _local_hook[1]; struct __jmp_buf_tag (*_last_hook)[1] = v_exception_hook; int _local_code; v_exception_hook=&_local_hook; if((_local_code = _setjmp (_local_hook))==0){ {
        key = (struct o_string *)keys->m_get(keys, index);
        if ((stream = (struct o_stream *) object->files->m_get(object->files, (struct o_object *)key))) {
          memset(&header, 0, sizeof(struct s_filesystem_header));
          strncpy(header.name, key->content, 16);
          header.bytes = stream->m_size(stream);
          if (f_endian_check() == 0)
            f_endian_swap(&(header.bytes), sizeof(header.bytes));
          destination->m_write(destination, sizeof(struct s_filesystem_header), &header);
          destination->m_write_stream(destination, stream);
        }
      } }else{ v_exception_hook=_last_hook; (exception)=&v_exception_raised; {
        do{ if(((exception)->level++)==0) fprintf((stderr),"%s:%s() @ %d {%s} %s\n",(exception)->file,exception->function,(exception)->line,(exception)->kind,(exception)->description); fprintf((stderr),"\t%s:%s() @ %d\n","o_filesystem.c",__FUNCTION__,146); }while(0);
        do{ if(v_exception_hook) longjmp(*v_exception_hook,v_exception_raised.identificator); }while(0);
      } } v_exception_hook=_last_hook; }while(0);
    }
    f_object_release((struct o_object *)keys);
  }
}

variable_types: struct o_filesystem { struct o_object { struct s_list_node { struct s_list_node *next; } head; char *kind; unsigned long size; long long hash; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } mutex; struct { unsigned int supplied; } s_flags; struct { void (*m_delete)(struct o_object *); int (*m_compare)(struct o_object *, struct o_object *); long long (*m_hash)(struct o_object *); char *(*m_string)(struct o_object *, char *, unsigned long); struct o_object *(*m_clone)(struct o_object *); int (*m_trylock)(struct o_object *); void (*m_lock)(struct o_object *); void (*m_unlock)(struct o_object *); } s_delegate; } head; struct o_dictionary { struct o_object head; struct s_hash_table { long long mask; int (*compare)(void *left, void *right); long long (*calculate)(void *key); struct s_hash_bucket { long long hash; void *key; enum e_hash_kind { e_hash_kind_deleted=0, e_hash_kind_empty=1, e_hash_kind_fill=2 } kind; } *table; } *table; int (*m_load)(struct o_dictionary *, struct o_stream { struct o_object head; struct o_string { struct o_object head; struct { unsigned int constant; } s_flags; char *content; unsigned long size; void (*m_trim)(struct o_string *); void (*m_append)(struct o_string *, struct o_string *); unsigned long (*m_length)(struct o_string *); char (*m_character)(struct o_string *, unsigned long); struct o_string *(*m_substring)(struct o_string *, unsigned long, unsigned long); struct o_array { struct o_object head; struct o_object **content; unsigned long size; unsigned long (*m_insert)(struct o_array *, struct o_object *, unsigned long); int (*m_remove)(struct o_array *, unsigned long); struct o_object *(*m_get)(struct o_array *, unsigned long); } *(*m_split)(struct o_string *, char); void (*m_truncate)(struct o_string *, unsigned long); } *name; int descriptor; struct { unsigned int supplied; unsigned int opened; unsigned int temporary; } s_flags; long (*m_write)(struct o_stream *, unsigned long, void *); long (*m_write_string)(struct o_stream *, struct o_string *); long (*m_write_stream)(struct o_stream *, struct o_stream *); long (*m_read_raw)(struct o_stream *, unsigned char *, unsigned long); struct o_string *(*m_read_line)(struct o_stream *, struct o_string *, unsigned long); struct o_string *(*m_read)(struct o_stream *, struct o_string *, unsigned long); long (*m_size)(struct o_stream *); long (*m_seek)(struct o_stream *, long, enum e_stream_seek { e_stream_seek_begin=0, e_stream_seek_current=1, e_stream_seek_end=2 }); void (*m_blocking)(struct o_stream *, int); } *); int (*m_save)(struct o_dictionary *, struct o_stream *); int (*m_insert)(struct o_dictionary *, struct o_object *, struct o_object *); struct o_object *(*m_get)(struct o_dictionary *, struct o_object *); struct o_array *(*m_keys)(struct o_dictionary *); struct o_array *(*m_values)(struct o_dictionary *); } *files; int (*m_insert)(struct o_filesystem *, struct o_string *, struct o_stream *); struct o_stream *(*m_get)(struct o_filesystem *, struct o_string *); void (*m_store)(struct o_filesystem *, struct o_stream *); } *

variable_types:
destination
struct o_stream *

variable_types: struct o_array { struct o_object { struct s_list_node { struct s_list_node *next; } head; char *kind; unsigned long size; long long hash; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } mutex; struct { unsigned int supplied; } s_flags; struct { void (*m_delete)(struct o_object *); int (*m_compare)(struct o_object *, struct o_object *); long long (*m_hash)(struct o_object *); char *(*m_string)(struct o_object *, char *, unsigned long); struct o_object *(*m_clone)(struct o_object *); int (*m_trylock)(struct o_object *); void (*m_lock)(struct o_object *); void (*m_unlock)(struct o_object *); } s_delegate; } head; struct o_object **content; unsigned long size; unsigned long (*m_insert)(struct o_array *, struct o_object *, unsigned long); int (*m_remove)(struct o_array *, unsigned long); struct o_object *(*m_get)(struct o_array *, unsigned long); } *

variable_types: struct o_stream { struct o_object { struct s_list_node { struct s_list_node *next; } head; char *kind; unsigned long size; long long hash; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } mutex; struct { unsigned int supplied; } s_flags; struct { void (*m_delete)(struct o_object *); int (*m_compare)(struct o_object *, struct o_object *); long long (*m_hash)(struct o_object *); char *(*m_string)(struct o_object *, char *, unsigned long); struct o_object *(*m_clone)(struct o_object *); int (*m_trylock)(struct o_object *); void (*m_lock)(struct o_object *); void (*m_unlock)(struct o_object *); } s_delegate; } head; struct o_string { struct o_object head; struct { unsigned int constant; } s_flags; char *content; unsigned long size; void (*m_trim)(struct o_string *); void (*m_append)(struct o_string *, struct o_string *); unsigned long (*m_length)(struct o_string *); char (*m_character)(struct o_string *, unsigned long); struct o_string *(*m_substring)(struct o_string *, unsigned long, unsigned long); struct o_array { struct o_object head; struct o_object **content; unsigned long size; unsigned long (*m_insert)(struct o_array *, struct o_object *, unsigned long); int (*m_remove)(struct o_array *, unsigned long); struct o_object *(*m_get)(struct o_array *, unsigned long); } *(*m_split)(struct o_string *, char); void (*m_truncate)(struct o_string *, unsigned long); } *name; int descriptor; struct { unsigned int supplied; unsigned int opened; unsigned int temporary; } s_flags; long (*m_write)(struct o_stream *, unsigned long, void *); long (*m_write_string)(struct o_stream *, struct o_string *); long (*m_write_stream)(struct o_stream *, struct o_stream *); long (*m_read_raw)(struct o_stream *, unsigned char *, unsigned long); struct o_string *(*m_read_line)(struct o_stream *, struct o_string *, unsigned long); struct o_string *(*m_read)(struct o_stream *, struct o_string *, unsigned long); long (*m_size)(struct o_stream *); long (*m_seek)(struct o_stream *, long, enum e_stream_seek { e_stream_seek_begin=0, e_stream_seek_current=1, e_stream_seek_end=2 }); void (*m_blocking)(struct o_stream *, int); } *

variable_types: struct o_string { struct o_object { struct s_list_node { struct s_list_node *next; } head; char *kind; unsigned long size; long long hash; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } mutex; struct { unsigned int supplied; } s_flags; struct { void (*m_delete)(struct o_object *); int (*m_compare)(struct o_object *, struct o_object *); long long (*m_hash)(struct o_object *); char *(*m_string)(struct o_object *, char *, unsigned long); struct o_object *(*m_clone)(struct o_object *); int (*m_trylock)(struct o_object *); void (*m_lock)(struct o_object *); void (*m_unlock)(struct o_object *); } s_delegate; } head; struct { unsigned int constant; } s_flags; char *content; unsigned long size; void (*m_trim)(struct o_string *); void (*m_append)(struct o_string *, struct o_string *); unsigned long (*m_length)(struct o_string *); char (*m_character)(struct o_string *, unsigned long); struct o_string *(*m_substring)(struct o_string *, unsigned long, unsigned long); struct o_array { struct o_object head; struct o_object **content; unsigned long size; unsigned long (*m_insert)(struct o_array *, struct o_object *, unsigned long); int (*m_remove)(struct o_array *, unsigned long); struct o_object *(*m_get)(struct o_array *, unsigned long); } *(*m_split)(struct o_string *, char); void (*m_truncate)(struct o_string *, unsigned long); } *

variable_types: struct s_filesystem_header { char name[16]; long bytes; }

variable_types: struct s_exception { char kind[64]; unsigned int line; int identificator; } *

variable_types:
index
unsigned long

variable_types: struct __jmp_buf_tag { long __jmpbuf[8]; int __mask_was_saved; struct __sigset_t { unsigned long __val[-1]; } __saved_mask; } [1]

variable_types: struct __jmp_buf_tag { long __jmpbuf[8]; int __mask_was_saved; struct __sigset_t { unsigned long __val[-1]; } __saved_mask; } (*)[1]

return_type: void

user_defined_types: struct o_filesystem { struct o_object head; struct o_dictionary *files; int (*m_insert)(struct o_filesystem *, struct o_string *, struct o_stream *); struct o_stream *(*m_get)(struct o_filesystem *, struct o_string *); void (*m_store)(struct o_filesystem *, struct o_stream *); }

user_defined_types: struct o_stream { struct o_object head; struct o_string *name; int descriptor; struct { unsigned int supplied; unsigned int opened; unsigned int temporary; } s_flags; long (*m_write)(struct o_stream *, unsigned long, void *); long (*m_write_string)(struct o_stream *, struct o_string *); long (*m_write_stream)(struct o_stream *, struct o_stream *); long (*m_read_raw)(struct o_stream *, unsigned char *, unsigned long); struct o_string *(*m_read_line)(struct o_stream *, struct o_string *, unsigned long); struct o_string *(*m_read)(struct o_stream *, struct o_string *, unsigned long); long (*m_size)(struct o_stream *); long (*m_seek)(struct o_stream *, long, enum e_stream_seek); void (*m_blocking)(struct o_stream *, int); }

user_defined_types: struct o_string { struct o_object head; struct { unsigned int constant; } s_flags; char *content; unsigned long size; void (*m_trim)(struct o_string *); void (*m_append)(struct o_string *, struct o_string *); unsigned long (*m_length)(struct o_string *); char (*m_character)(struct o_string *, unsigned long); struct o_string *(*m_substring)(struct o_string *, unsigned long, unsigned long); struct o_array *(*m_split)(struct o_string *, char); void (*m_truncate)(struct o_string *, unsigned long); }

user_defined_types: struct __jmp_buf_tag { long __jmpbuf[8]; int __mask_was_saved; struct __sigset_t __saved_mask; }

user_defined_types: struct o_object { struct s_list_node head; char *kind; unsigned long size; long long hash; union pthread_mutex_t mutex; struct { unsigned int supplied; } s_flags; struct { void (*m_delete)(struct o_object *); int (*m_compare)(struct o_object *, struct o_object *); long long (*m_hash)(struct o_object *); char *(*m_string)(struct o_object *, char *, unsigned long); struct o_object *(*m_clone)(struct o_object *); int (*m_trylock)(struct o_object *); void (*m_lock)(struct o_object *); void (*m_unlock)(struct o_object *); } s_delegate; }

user_defined_types: union pthread_mutex_t { struct __pthread_mutex_s __data; char __size[40]; long __align; }

user_defined_types: struct o_dictionary { struct o_object head; struct s_hash_table *table; int (*m_load)(struct o_dictionary *, struct o_stream *); int (*m_save)(struct o_dictionary *, struct o_stream *); int (*m_insert)(struct o_dictionary *, struct o_object *, struct o_object *); struct o_object *(*m_get)(struct o_dictionary *, struct o_object *); struct o_array *(*m_keys)(struct o_dictionary *); struct o_array *(*m_values)(struct o_dictionary *); }

user_defined_types: struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list __list; }

user_defined_types: struct s_hash_table { long long mask; int (*compare)(void *left, void *right); long long (*calculate)(void *key); struct s_hash_bucket *table; }

user_defined_types: struct s_hash_bucket { long long hash; void *key; enum e_hash_kind kind; }


decompiled_code:
void __fastcall p_array_delete(__int64 a1)
{
unsigned __int64 v1; // rbp
_BYTE v2[332]; // [rsp-150h] [rbp-168h] BYREF

if ( *(char **)(a1 + 16) == "array" )
{
if ( *(_QWORD *)(a1 + 168) )
{
v1 = 0LL;
do
{
f_object_release(*(_QWORD *)(*(_QWORD *)(a1 + 160) + 8 * v1));
*(_QWORD *)(*(_QWORD *)(a1 + 160) + 8 * v1++) = 0LL;
}
while ( *(_QWORD *)(a1 + 168) > v1 );
}
p_memory_remove(*(_QWORD *)(a1 + 160), "o_array.c", "p_array_delete", 75LL, 0LL);
free(*(void **)(a1 + 160));
}
else if ( v_exception_hook )
{
qmemcpy(v2, &v_exception_kind, sizeof(v2));
p_exception_fill("object is not an instance of o_array", "o_array.c", "p_array_delete", 77LL);
longjmp(v_exception_hook, v_exception_raised[82]);
}
}

canonical_decompiled_code:
void __fastcall func0(__int64 a1)
{
unsigned __int64 v1; // rbp
_BYTE v2[332]; // [rsp-150h] [rbp-168h] BYREF

if ( *(char **)(a1 + 16) == "array" )
{
if ( *(_QWORD *)(a1 + 168) )
{
v1 = 0LL;
do
{
f_object_release(*(_QWORD *)(*(_QWORD *)(a1 + 160) + 8 * v1));
*(_QWORD *)(*(_QWORD *)(a1 + 160) + 8 * v1++) = 0LL;
}
while ( *(_QWORD *)(a1 + 168) > v1 );
}
p_memory_remove(*(_QWORD *)(a1 + 160), "o_array.c", "p_array_delete", 75LL, 0LL);
free(*(void **)(a1 + 160));
}
else if ( v_exception_hook )
{
qmemcpy(v2, &v_exception_kind, sizeof(v2));
p_exception_fill("object is not an instance of o_array", "o_array.c", "p_array_delete", 77LL);
longjmp(v_exception_hook, v_exception_raised[82]);
}
}

original_code:
void p_array_delete(struct o_object *object) {
  struct o_array *local_object;
  size_t index;
  if ((local_object = ((struct o_array *)(((object)->kind==v_array_kind)?(object):((void *)0))))) {
    for (index = 0; index < local_object->size; index++) {
      f_object_release((struct o_object *)local_object->content[index]);
      local_object->content[index] = ((void *)0);
    }
    do{ p_memory_remove((local_object->content),"o_array.c",__FUNCTION__,75,0); free(local_object->content); }while(0);
  } else
    do{ if(v_exception_hook){ p_exception_fill((v_exception_kind),("object is not an instance of o_array"),"o_array.c",__FUNCTION__,77); longjmp(*v_exception_hook,v_exception_raised.identificator); } }while(0);
}

canonical_original_code:
void p_array_delete(struct o_object *object) {
  struct o_array *local_object;
  unsigned long index;
  if ((local_object = ((struct o_array *)(((object)->kind==v_array_kind)?(object):((void *)0))))) {
    for (index = 0; index < local_object->size; index++) {
      f_object_release((struct o_object *)local_object->content[index]);
      local_object->content[index] = ((void *)0);
    }
    do{ p_memory_remove((local_object->content),"o_array.c",__FUNCTION__,75,0); free(local_object->content); }while(0);
  } else
    do{ if(v_exception_hook){ p_exception_fill((v_exception_kind),("object is not an instance of o_array"),"o_array.c",__FUNCTION__,77); longjmp(*v_exception_hook,v_exception_raised.identificator); } }while(0);
}

variable_types: struct o_object { struct s_list_node { struct s_list_node *next; } head; char *kind; unsigned long size; long long hash; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } mutex; struct { unsigned int supplied; } s_flags; struct { void (*m_delete)(struct o_object *); int (*m_compare)(struct o_object *, struct o_object *); long long (*m_hash)(struct o_object *); char *(*m_string)(struct o_object *, char *, unsigned long); struct o_object *(*m_clone)(struct o_object *); int (*m_trylock)(struct o_object *); void (*m_lock)(struct o_object *); void (*m_unlock)(struct o_object *); } s_delegate; } *

user_defined_types: struct o_array { struct o_object head; struct o_object **content; unsigned long size; unsigned long (*m_insert)(struct o_array *, struct o_object *, unsigned long); int (*m_remove)(struct o_array *, unsigned long); struct o_object *(*m_get)(struct o_array *, unsigned long); }


decompiled_code:
__int64 __fastcall p_array_remove(_QWORD *a1, unsigned __int64 a2)
{
__int64 v3; // rdi
__int64 result; // rax
_BYTE v5[332]; // [rsp-150h] [rbp-168h] BYREF

if ( a1[21] <= a2 )
{
if ( v_exception_hook )
{
qmemcpy(v5, &v_exception_bound, sizeof(v5));
p_exception_fill("index is over the array's size", "o_array.c", "p_array_remove", 185LL);
longjmp(v_exception_hook, v_exception_raised[82]);
}
result = 0LL;
}
else
{
v3 = *(_QWORD *)(a1[20] + 8 * a2);
result = 0LL;
if ( v3 )
{
f_object_release(v3);
*(_QWORD *)(a1[20] + 8 * a2) = 0LL;
--a1[22];
result = 1LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(_QWORD *a1, unsigned __int64 a2)
{
__int64 v3; // rdi
__int64 result; // rax
_BYTE v5[332]; // [rsp-150h] [rbp-168h] BYREF

if ( a1[21] <= a2 )
{
if ( v_exception_hook )
{
qmemcpy(v5, &v_exception_bound, sizeof(v5));
p_exception_fill("index is over the array's size", "o_array.c", "p_array_remove", 185LL);
longjmp(v_exception_hook, v_exception_raised[82]);
}
result = 0LL;
}
else
{
v3 = *(_QWORD *)(a1[20] + 8 * a2);
result = 0LL;
if ( v3 )
{
f_object_release(v3);
*(_QWORD *)(a1[20] + 8 * a2) = 0LL;
--a1[22];
result = 1LL;
}
}
return result;
}

original_code:
int p_array_remove(struct o_array *object, size_t position) {
  int result = 0;
  if (position < object->size) {
    if (object->content[position]) {
      f_object_release((struct o_object *)object->content[position]);
      object->content[position] = ((void *)0);
      object->filled--;
      result = 1;
    }
  } else
    do{ if(v_exception_hook){ p_exception_fill((v_exception_bound),("index is over the array's size"),"o_array.c",__FUNCTION__,185); longjmp(*v_exception_hook,v_exception_raised.identificator); } }while(0);
  return result;
}

canonical_original_code:
int p_array_remove(struct o_array *object, unsigned long position) {
  int result = 0;
  if (position < object->size) {
    if (object->content[position]) {
      f_object_release((struct o_object *)object->content[position]);
      object->content[position] = ((void *)0);
      object->filled--;
      result = 1;
    }
  } else
    do{ if(v_exception_hook){ p_exception_fill((v_exception_bound),("index is over the array's size"),"o_array.c",__FUNCTION__,185); longjmp(*v_exception_hook,v_exception_raised.identificator); } }while(0);
  return result;
}

variable_types:
position
unsigned long

variable_types: result int

return_type: int

user_defined_types: struct s_list_node { struct s_list_node *next; }

user_defined_types: struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; }


decompiled_code:
struct __jmp_buf_tag __fastcall p_array_get[1](__int64 a1, unsigned __int64 a2)
{
struct __jmp_buf_tag *__attribute__((__org_arrdim(0,1))) result; // rax
_BYTE v3[332]; // [rsp-158h] [rbp-158h] BYREF

if ( *(_QWORD *)(a1 + 168) > a2 )
return *(struct __jmp_buf_tag **)(*(_QWORD *)(a1 + 160) + 8 * a2);
result = v_exception_hook;
if ( v_exception_hook )
{
qmemcpy(v3, &v_exception_bound, sizeof(v3));
p_exception_fill("index is over the array's size", "o_array.c", "p_array_get", 194LL);
longjmp(v_exception_hook, v_exception_raised[82]);
}
return result;
}

canonical_decompiled_code:
struct __jmp_buf_tag __fastcall func2[1](__int64 a1, unsigned __int64 a2)
{
struct __jmp_buf_tag *__attribute__((__org_arrdim(0,1))) result; // rax
_BYTE v3[332]; // [rsp-158h] [rbp-158h] BYREF

if ( *(_QWORD *)(a1 + 168) > a2 )
return *(struct __jmp_buf_tag **)(*(_QWORD *)(a1 + 160) + 8 * a2);
result = v_exception_hook;
if ( v_exception_hook )
{
qmemcpy(v3, &v_exception_bound, sizeof(v3));
p_exception_fill("index is over the array's size", "o_array.c", "p_array_get", 194LL);
longjmp(v_exception_hook, v_exception_raised[82]);
}
return result;
}

original_code:
struct o_object *p_array_get(struct o_array *object, size_t position) {
  struct o_object *result = ((void *)0);
  if (position < object->size)
    result = object->content[position];
  else
    do{ if(v_exception_hook){ p_exception_fill((v_exception_bound),("index is over the array's size"),"o_array.c",__FUNCTION__,194); longjmp(*v_exception_hook,v_exception_raised.identificator); } }while(0);
  return result;
}

canonical_original_code:
struct o_object *p_array_get(struct o_array *object, unsigned long position) {
  struct o_object *result = ((void *)0);
  if (position < object->size)
    result = object->content[position];
  else
    do{ if(v_exception_hook){ p_exception_fill((v_exception_bound),("index is over the array's size"),"o_array.c",__FUNCTION__,194); longjmp(*v_exception_hook,v_exception_raised.identificator); } }while(0);
  return result;
}

variable_types: struct o_array { struct o_object head; struct o_object **content; unsigned long size; unsigned long (*m_insert)(struct o_array *, struct o_object *, unsigned long); int (*m_remove)(struct o_array *, unsigned long); struct o_object *(*m_get)(struct o_array *, unsigned long); } *

return_type: struct o_object { struct s_list_node { struct s_list_node *next; } head; char *kind; unsigned long size; long long hash; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } mutex; struct { unsigned int supplied; } s_flags; struct { void (*m_delete)(struct o_object *); int (*m_compare)(struct o_object *, struct o_object *); long long (*m_hash)(struct o_object *); char *(*m_string)(struct o_object *, char *, unsigned long); struct o_object *(*m_clone)(struct o_object *); int (*m_trylock)(struct o_object *); void (*m_lock)(struct o_object *); void (*m_unlock)(struct o_object *); } s_delegate; } *


original_code:
int p_array_compare(struct o_object *object, struct o_object *other) {
  struct o_array *local_object, *local_other;
  int result = p_object_compare(object, other), index;
  if ((local_object = ((struct o_array *)(((object)->kind==v_array_kind)?(object):((void *)0)))) && (local_other = ((struct o_array *)(((other)->kind==v_array_kind)?(other):((void *)0))))) {
    result = (int)(local_object->filled-local_other->filled);
    for (index = 0; (result == 0)&&(index < local_object->size); index++)
      result = (((local_object->content[index])&&(local_other->content[index]))?((struct o_object *)local_object->content[index])->s_delegate.m_compare((struct o_object*)(local_object->content[index]),(struct o_object*)(local_other->content[index])):((long long)(local_object->content[index]))-((long long)(local_other->content[index])));
  }
  return result;
}

canonical_original_code:
int p_array_compare(struct o_object *object, struct o_object *other) {
  struct o_array *local_object; struct o_array *local_other;
  int result = p_object_compare(object, other); int index;
  if ((local_object = ((struct o_array *)(((object)->kind==v_array_kind)?(object):((void *)0)))) && (local_other = ((struct o_array *)(((other)->kind==v_array_kind)?(other):((void *)0))))) {
    result = (int)(local_object->filled-local_other->filled);
    for (index = 0; (result == 0)&&(index < local_object->size); index++)
      result = (((local_object->content[index])&&(local_other->content[index]))?((struct o_object *)local_object->content[index])->s_delegate.m_compare((struct o_object *)(local_object->content[index]),(struct o_object *)(local_other->content[index])):((long long)(local_object->content[index]))-((long long)(local_other->content[index])));
  }
  return result;
}

variable_types:
other
struct o_object *

variable_types: index int


decompiled_code:
unsigned __int64 __fastcall p_array_insert(__int64 a1, __int64 a2, unsigned __int64 a3)
{
unsigned __int64 v4; // rdx
__int64 v7; // rdi
__int64 v8; // r13
_QWORD *v9; // rsi
void *v10; // rax
__int64 v11; // rax
_QWORD *v12; // r13
void *v13; // rax
__int64 v14; // rax
_BYTE v16[332]; // [rsp-150h] [rbp-178h] BYREF

v4 = *(_QWORD *)(a1 + 168);
if ( v4 < a3 )
{
if ( v_exception_hook )
{
qmemcpy(v16, &v_exception_bound, sizeof(v16));
p_exception_fill("index is over the array's size", "o_array.c", "p_array_insert", 171LL);
longjmp(v_exception_hook, v_exception_raised[82]);
}
}
else
{
if ( v4 == a3 )
{
p_memory_remove(*(_QWORD *)(a1 + 160), "o_array.c", "p_array_insert", 147LL, 1LL);
v13 = realloc(*(void **)(a1 + 160), 8LL * (*(_QWORD *)(a1 + 168) + *(_QWORD *)(a1 + 184)));
v14 = p_memory_insert(v13, "o_array.c", "p_array_insert", 147LL, 1LL);
*(_QWORD *)(a1 + 160) = v14;
if ( !v14 )
{
p_log_write(stderr, 0LL, "o_array.c", "p_array_insert", 151LL, "out of memory! I'm dying: 'bleaaargh'");
exit(1);
}
memset((void *)(v14 + 8LL * *(_QWORD *)(a1 + 168)), 0, 8LL * *(_QWORD *)(a1 + 184));
*(_QWORD *)(a1 + 168) += *(_QWORD *)(a1 + 184);
}
else
{
v7 = *(_QWORD *)(a1 + 160);
v8 = 8 * a3;
v9 = (_QWORD *)(v7 + 8 * a3);
if ( *v9 )
{
if ( *(_QWORD *)(v7 + 8 * v4 - 8) )
{
p_memory_remove(v7, "o_array.c", "p_array_insert", 154LL, 1LL);
v10 = realloc(*(void **)(a1 + 160), 8LL * (*(_QWORD *)(a1 + 168) + *(_QWORD *)(a1 + 184)));
v11 = p_memory_insert(v10, "o_array.c", "p_array_insert", 154LL, 1LL);
*(_QWORD *)(a1 + 160) = v11;
if ( !v11 )
{
p_log_write(stderr, 0LL, "o_array.c", "p_array_insert", 161LL, "out of memory! I'm dying: 'bleaaargh'");
exit(1);
}
memset((void *)(v11 + 8LL * *(_QWORD *)(a1 + 168)), 0, 8LL * *(_QWORD *)(a1 + 184));
memmove(
(void *)(*(_QWORD *)(a1 + 160) + v8 + 8),
(const void *)(*(_QWORD *)(a1 + 160) + v8),
8 * (*(_QWORD *)(a1 + 168) - a3));
*(_QWORD *)(a1 + 168) += *(_QWORD *)(a1 + 184);
}
else
{
memmove((void *)(v7 + v8 + 8), v9, 8 * (~a3 + v4));
}
}
}
if ( a2 )
{
v12 = (_QWORD *)(*(_QWORD *)(a1 + 160) + 8 * a3);
*v12 = f_object_retain(a2);
++*(_QWORD *)(a1 + 176);
}
else
{
*(_QWORD *)(*(_QWORD *)(a1 + 160) + 8 * a3) = 0LL;
}
}
return a3;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func5(__int64 a1, __int64 a2, unsigned __int64 a3)
{
unsigned __int64 v4; // rdx
__int64 v7; // rdi
__int64 v8; // r13
_QWORD *v9; // rsi
void *v10; // rax
__int64 v11; // rax
_QWORD *v12; // r13
void *v13; // rax
__int64 v14; // rax
_BYTE v16[332]; // [rsp-150h] [rbp-178h] BYREF

v4 = *(_QWORD *)(a1 + 168);
if ( v4 < a3 )
{
if ( v_exception_hook )
{
qmemcpy(v16, &v_exception_bound, sizeof(v16));
p_exception_fill("index is over the array's size", "o_array.c", "p_array_insert", 171LL);
longjmp(v_exception_hook, v_exception_raised[82]);
}
}
else
{
if ( v4 == a3 )
{
p_memory_remove(*(_QWORD *)(a1 + 160), "o_array.c", "p_array_insert", 147LL, 1LL);
v13 = realloc(*(void **)(a1 + 160), 8LL * (*(_QWORD *)(a1 + 168) + *(_QWORD *)(a1 + 184)));
v14 = p_memory_insert(v13, "o_array.c", "p_array_insert", 147LL, 1LL);
*(_QWORD *)(a1 + 160) = v14;
if ( !v14 )
{
p_log_write(stderr, 0LL, "o_array.c", "p_array_insert", 151LL, "out of memory! I'm dying: 'bleaaargh'");
exit(1);
}
memset((void *)(v14 + 8LL * *(_QWORD *)(a1 + 168)), 0, 8LL * *(_QWORD *)(a1 + 184));
*(_QWORD *)(a1 + 168) += *(_QWORD *)(a1 + 184);
}
else
{
v7 = *(_QWORD *)(a1 + 160);
v8 = 8 * a3;
v9 = (_QWORD *)(v7 + 8 * a3);
if ( *v9 )
{
if ( *(_QWORD *)(v7 + 8 * v4 - 8) )
{
p_memory_remove(v7, "o_array.c", "p_array_insert", 154LL, 1LL);
v10 = realloc(*(void **)(a1 + 160), 8LL * (*(_QWORD *)(a1 + 168) + *(_QWORD *)(a1 + 184)));
v11 = p_memory_insert(v10, "o_array.c", "p_array_insert", 154LL, 1LL);
*(_QWORD *)(a1 + 160) = v11;
if ( !v11 )
{
p_log_write(stderr, 0LL, "o_array.c", "p_array_insert", 161LL, "out of memory! I'm dying: 'bleaaargh'");
exit(1);
}
memset((void *)(v11 + 8LL * *(_QWORD *)(a1 + 168)), 0, 8LL * *(_QWORD *)(a1 + 184));
memmove(
(void *)(*(_QWORD *)(a1 + 160) + v8 + 8),
(const void *)(*(_QWORD *)(a1 + 160) + v8),
8 * (*(_QWORD *)(a1 + 168) - a3));
*(_QWORD *)(a1 + 168) += *(_QWORD *)(a1 + 184);
}
else
{
memmove((void *)(v7 + v8 + 8), v9, 8 * (~a3 + v4));
}
}
}
if ( a2 )
{
v12 = (_QWORD *)(*(_QWORD *)(a1 + 160) + 8 * a3);
*v12 = f_object_retain(a2);
++*(_QWORD *)(a1 + 176);
}
else
{
*(_QWORD *)(*(_QWORD *)(a1 + 160) + 8 * a3) = 0LL;
}
}
return a3;
}

original_code:
size_t p_array_insert(struct o_array *object, struct o_object *value, size_t position) {
  if (position <= object->size) {
    if (position == object->size) {
      if ((object->content = (struct o_object **) (p_memory_remove((object->content),"o_array.c",__FUNCTION__,147,1), p_memory_insert(realloc((object->content),(((object->size+object->bucket)*sizeof(struct o_object *)))),"o_array.c",__FUNCTION__,147,1)))) {
        memset(&(object->content[object->size]), 0, (object->bucket*sizeof(struct o_object *)));
        object->size += object->bucket;
      } else
        do{ p_log_write(stderr,e_log_level_ever,"o_array.c",__FUNCTION__,151,"out of memory! I'm dying: 'bleaaargh'"); exit(1); }while(0);;
    } else if (object->content[position]) {
      if (object->content[object->size-1]) {
        if ((object->content = (struct o_object **) (p_memory_remove((object->content),"o_array.c",__FUNCTION__,154,1), p_memory_insert(realloc((object->content),(((object->size+object->bucket)*sizeof(struct o_object *)))),"o_array.c",__FUNCTION__,154,1)))) {
          memset(&(object->content[object->size]), 0, (object->bucket*sizeof(struct o_object *)));
          memmove(&(object->content[position+1]), &(object->content[position]),
              ((object->size-position)*sizeof(struct o_object *)));
          object->size += object->bucket;
        } else
          do{ p_log_write(stderr,e_log_level_ever,"o_array.c",__FUNCTION__,161,"out of memory! I'm dying: 'bleaaargh'"); exit(1); }while(0);;
      } else
        memmove(&(object->content[position+1]), &(object->content[position]), (object->size-position-1)*sizeof(struct o_object *));
    }
    if (value) {
      object->content[position] = (struct o_object*)f_object_retain((struct o_object *)value);
      object->filled++;
    } else
      object->content[position] = ((void *)0);
  } else
    do{ if(v_exception_hook){ p_exception_fill((v_exception_bound),("index is over the array's size"),"o_array.c",__FUNCTION__,171); longjmp(*v_exception_hook,v_exception_raised.identificator); } }while(0);
  return position;
}

canonical_original_code:
unsigned long p_array_insert(struct o_array *object, struct o_object *value, unsigned long position) {
  if (position <= object->size) {
    if (position == object->size) {
      if ((object->content = (struct o_object **) (p_memory_remove((object->content),"o_array.c",__FUNCTION__,147,1), p_memory_insert(realloc((object->content),(((object->size+object->bucket)*sizeof(struct o_object *)))),"o_array.c",__FUNCTION__,147,1)))) {
        memset(&(object->content[object->size]), 0, (object->bucket*sizeof(struct o_object *)));
        object->size += object->bucket;
      } else
        do{ p_log_write(stderr,e_log_level_ever,"o_array.c",__FUNCTION__,151,"out of memory! I'm dying: 'bleaaargh'"); exit(1); }while(0);;
    } else if (object->content[position]) {
      if (object->content[object->size-1]) {
        if ((object->content = (struct o_object **) (p_memory_remove((object->content),"o_array.c",__FUNCTION__,154,1), p_memory_insert(realloc((object->content),(((object->size+object->bucket)*sizeof(struct o_object *)))),"o_array.c",__FUNCTION__,154,1)))) {
          memset(&(object->content[object->size]), 0, (object->bucket*sizeof(struct o_object *)));
          memmove(&(object->content[position+1]), &(object->content[position]),
              ((object->size-position)*sizeof(struct o_object *)));
          object->size += object->bucket;
        } else
          do{ p_log_write(stderr,e_log_level_ever,"o_array.c",__FUNCTION__,161,"out of memory! I'm dying: 'bleaaargh'"); exit(1); }while(0);;
      } else
        memmove(&(object->content[position+1]), &(object->content[position]), (object->size-position-1)*sizeof(struct o_object *));
    }
    if (value) {
      object->content[position] = (struct o_object *)f_object_retain((struct o_object *)value);
      object->filled++;
    } else
      object->content[position] = ((void *)0);
  } else
    do{ if(v_exception_hook){ p_exception_fill((v_exception_bound),("index is over the array's size"),"o_array.c",__FUNCTION__,171); longjmp(*v_exception_hook,v_exception_raised.identificator); } }while(0);
  return position;
}

variable_types:
value
struct o_object *

return_type: unsigned long


decompiled_code:
__int64 __fastcall p_memory_insert(__int64 a1, const char *a2, const char *a3, int a4, int a5)
{
_QWORD *v7; // rax
char *v8; // rax
char *v9; // rbp
__int64 v10; // rax
char *v12; // rax
char *v13; // rax

if ( !a5 )
{
v12 = (char *)malloc(0x50uLL);
v9 = v12;
if ( !v12 )
return a1;
*(_QWORD *)(v12 + 60) = 0LL;
*(_QWORD *)(v12 + 68) = 0LL;
*((_DWORD *)v12 + 19) = 0;
*(_QWORD *)v12 = a1;
strncpy(v12 + 8, a2, 0x18uLL);
strncpy(v9 + 32, a3, 0x18uLL);
*((_DWORD *)v9 + 14) = a4;
v10 = v_memory_root;
if ( v_memory_root )
LABEL_7:
*(_QWORD *)(v10 + 72) = v9;
goto LABEL_8;
}
v7 = (_QWORD *)v_memory_root;
if ( !v_memory_root )
{
v13 = (char *)malloc(0x50uLL);
v9 = v13;
if ( !v13 )
return a1;
*(_QWORD *)(v13 + 60) = 0LL;
*(_QWORD *)(v13 + 68) = 0LL;
*((_DWORD *)v13 + 19) = 0;
*(_QWORD *)v13 = a1;
strncpy(v13 + 8, a2, 0x18uLL);
strncpy(v9 + 32, a3, 0x18uLL);
*((_DWORD *)v9 + 14) = a4;
v10 = v_memory_root;
LABEL_8:
*((_QWORD *)v9 + 8) = v10;
*((_QWORD *)v9 + 9) = 0LL;
v_memory_root = v9;
return a1;
}
while ( *v7 != a1 )
{
v7 = (_QWORD *)v7[8];
if ( !v7 )
{
v8 = (char *)malloc(0x50uLL);
v9 = v8;
if ( !v8 )
return a1;
*(_QWORD *)(v8 + 60) = 0LL;
*(_QWORD *)(v8 + 68) = 0LL;
*((_DWORD *)v8 + 19) = 0;
*(_QWORD *)v8 = a1;
strncpy(v8 + 8, a2, 0x18uLL);
strncpy(v9 + 32, a3, 0x18uLL);
*((_DWORD *)v9 + 14) = a4;
v10 = v_memory_root;
goto LABEL_7;
}
}
return a1;
}

original_code:
void *p_memory_insert(void *pointer, const char *file, const char *function, unsigned int line, int inside) {
  struct s_pointer *node;
  int founded = 0;
  if (inside) {
    node = v_memory_root;
    while (node) {
      if (node->pointer == pointer) {
        founded = 1;
        break;
      }
      node = node->next;
    }
  }
  if ((!founded) && (node = (struct s_pointer *) malloc(sizeof(struct s_pointer)))) {
    memset(node, 0, sizeof(struct s_pointer));
    node->pointer = pointer;
    strncpy(node->file, file, 24);
    strncpy(node->function, function, 24);
    node->line = line;
    if (v_memory_root)
      v_memory_root->back = node;
    node->next = v_memory_root;
    node->back = ((void *)0);
    v_memory_root = node;
  }
  return pointer;
}

canonical_original_code:
void *p_memory_insert(void *pointer, char *file, char *function, unsigned int line, int inside) {
  struct s_pointer *node;
  int founded = 0;
  if (inside) {
    node = v_memory_root;
    while (node) {
      if (node->pointer == pointer) {
        founded = 1;
        break;
      }
      node = node->next;
    }
  }
  if ((!founded) && (node = (struct s_pointer *) malloc(sizeof(struct s_pointer)))) {
    memset(node, 0, sizeof(struct s_pointer));
    node->pointer = pointer;
    strncpy(node->file, file, 24);
    strncpy(node->function, function, 24);
    node->line = line;
    if (v_memory_root)
      v_memory_root->back = node;
    node->next = v_memory_root;
    node->back = ((void *)0);
    v_memory_root = node;
  }
  return pointer;
}

variable_types:
pointer
void *

variable_types:
file
char *

variable_types:
function
char *

variable_types:
line
unsigned int

variable_types: inside int

variable_types: struct s_pointer { void *pointer; char file[24]; unsigned int line; struct s_pointer *next; } *

variable_types: founded int

return_type: void *


decompiled_code:
void __fastcall p_memory_remove(__int64 a1, const char *a2, const char *a3, __int64 a4, int a5)
{
_QWORD *v6; // rdi
__int64 v7; // rax
__int64 v8; // rax

v6 = (_QWORD *)v_memory_root;
if ( v_memory_root )
{
while ( *v6 != a1 )
{
v6 = (_QWORD *)v6[8];
if ( !v6 )
goto LABEL_4;
}
v7 = v6[8];
if ( v7 )
*(_QWORD *)(v7 + 72) = v6[9];
v8 = v6[9];
if ( v8 )
*(_QWORD *)(v8 + 64) = v6[8];
else
v_memory_root = v6[8];
free(v6);
}
else
{
LABEL_4:
if ( !a5 )
p_log_write(stdout, 0LL, "memory.c", "p_memory_remove", 66LL, "double free on %s:%s() (%d)", a2, a3, a4);
}
}

canonical_decompiled_code:
void __fastcall func1(__int64 a1, const char *a2, const char *a3, __int64 a4, int a5)
{
_QWORD *v6; // rdi
__int64 v7; // rax
__int64 v8; // rax

v6 = (_QWORD *)v_memory_root;
if ( v_memory_root )
{
while ( *v6 != a1 )
{
v6 = (_QWORD *)v6[8];
if ( !v6 )
goto LABEL_4;
}
v7 = v6[8];
if ( v7 )
*(_QWORD *)(v7 + 72) = v6[9];
v8 = v6[9];
if ( v8 )
*(_QWORD *)(v8 + 64) = v6[8];
else
v_memory_root = v6[8];
free(v6);
}
else
{
LABEL_4:
if ( !a5 )
p_log_write(stdout, 0LL, "memory.c", "p_memory_remove", 66LL, "double free on %s:%s() (%d)", a2, a3, a4);
}
}

original_code:
void p_memory_remove(void *pointer, const char *file, const char *function, unsigned int line, int suppress) {
  int result = 0;
  struct s_pointer *node = v_memory_root;
  while (node) {
    if (node->pointer == pointer) {
      if (node->next)
        node->next->back = node->back;
      if (node->back)
        node->back->next = node->next;
      else
        v_memory_root = node->next;
      free(node);
      result = 1;
      break;
    }
    node = node->next;
  }
  if ((result == 0) && (suppress == 0))
    p_log_write(stdout,e_log_level_ever,"memory.c",__FUNCTION__,66, "double free on %s:%s() (%d)", file, function, line);
}

canonical_original_code:
void p_memory_remove(void *pointer, char *file, char *function, unsigned int line, int suppress) {
  int result = 0;
  struct s_pointer *node = v_memory_root;
  while (node) {
    if (node->pointer == pointer) {
      if (node->next)
        node->next->back = node->back;
      if (node->back)
        node->back->next = node->next;
      else
        v_memory_root = node->next;
      free(node);
      result = 1;
      break;
    }
    node = node->next;
  }
  if ((result == 0) && (suppress == 0))
    p_log_write(stdout,e_log_level_ever,"memory.c",__FUNCTION__,66, "double free on %s:%s() (%d)", file, function, line);
}

variable_types: suppress int

user_defined_types: struct s_pointer { void *pointer; char file[24]; unsigned int line; struct s_pointer *next; }


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

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

original_code:
int f_endian_check(void) {
  static unsigned int value = 0xaabbccdd;
  return (*((unsigned char *)&value)==0xaa)?0:1;
}

canonical_original_code:
int f_endian_check() {
  static unsigned int value = 0xaabbccdd;
  return (*((unsigned char *)&value)==0xaa)?0:1;
}

variable_types:
value
unsigned int


original_code:
void f_endian_swap(void *data, size_t length) {
  unsigned char *pointer = (unsigned char *)data, byte;
  size_t tail, head;
  for (head = 0, tail = length-1; tail > head; head++, tail--) {
    byte = pointer[head];
    pointer[head] = pointer[tail];
    pointer[tail] = byte;
  }
}

canonical_original_code:
void f_endian_swap(void *data, unsigned long length) {
  unsigned char *pointer = (unsigned char *)data; unsigned char byte;
  unsigned long tail; unsigned long head;
  for (head = 0, tail = length-1; tail > head; head++, tail--) {
    byte = pointer[head];
    pointer[head] = pointer[tail];
    pointer[tail] = byte;
  }
}

variable_types:
data
void *

variable_types:
length
unsigned long

variable_types:
pointer
unsigned char *

variable_types:
byte
unsigned char

variable_types:
tail
unsigned long

variable_types:
head
unsigned long


decompiled_code:
int __fastcall p_exception_fill(const char *a1, const char *a2, const char *a3, unsigned int a4, __int64 a5, __int64 a6, __int64 a7, __int64 a8, __int64 a9, __int64 a10, __int64 a11, __int64 a12, __int64 a13, __int64 a14, __int64 a15, __int64 a16, __int64 a17, __int64 a18, __int64 a19, __int64 a20, __int64 a21, __int64 a22, __int64 a23, __int64 a24, __int64 a25, __int64 a26, __int64 a27, __int64 a28, __int64 a29, __int64 a30, __int64 a31, __int64 a32, __int64 a33, __int64 a34, __int64 a35, __int64 a36, __int64 a37, __int64 a38, __int64 a39, __int64 a40, __int64 a41, __int64 a42, __int64 a43, __int64 a44, __int64 a45, __int64 a46, __int128 a47)
{
int result; // eax

v_exception_raised = a7;
*(_QWORD *)((char *)&v_exception_raised + 324) = *(_QWORD *)((char *)&a47 + 4);
qmemcpy(
(void *)(((unsigned __int64)&v_exception_raised + 8) & 0xFFFFFFFFFFFFFFF8LL),
(const void *)((char *)&a7
- ((char *)&v_exception_raised
- (((unsigned __int64)&v_exception_raised + 8) & 0xFFFFFFFFFFFFFFF8LL))),
8LL
* (((unsigned int)((unsigned int)&v_exception_raised
- (((unsigned __int64)&v_exception_raised + 8) & 0xFFFFFFFFFFFFFFF8LL))
+ 332) >> 3));
snprintf((char *)&v_exception_raised + 192, 0x80uLL, "%s", a1);
snprintf((char *)&v_exception_raised + 64, 0x40uLL, "%s", a2);
result = snprintf((char *)&v_exception_raised + 128, 0x40uLL, "%s", a3);
*((_QWORD *)&v_exception_raised + 40) = a4;
return result;
}

canonical_decompiled_code:
int __fastcall func0(const char *a1, const char *a2, const char *a3, unsigned int a4, __int64 a5, __int64 a6, __int64 a7, __int64 a8, __int64 a9, __int64 a10, __int64 a11, __int64 a12, __int64 a13, __int64 a14, __int64 a15, __int64 a16, __int64 a17, __int64 a18, __int64 a19, __int64 a20, __int64 a21, __int64 a22, __int64 a23, __int64 a24, __int64 a25, __int64 a26, __int64 a27, __int64 a28, __int64 a29, __int64 a30, __int64 a31, __int64 a32, __int64 a33, __int64 a34, __int64 a35, __int64 a36, __int64 a37, __int64 a38, __int64 a39, __int64 a40, __int64 a41, __int64 a42, __int64 a43, __int64 a44, __int64 a45, __int64 a46, __int128 a47)
{
int result; // eax

v_exception_raised = a7;
*(_QWORD *)((char *)&v_exception_raised + 324) = *(_QWORD *)((char *)&a47 + 4);
qmemcpy(
(void *)(((unsigned __int64)&v_exception_raised + 8) & 0xFFFFFFFFFFFFFFF8LL),
(const void *)((char *)&a7
- ((char *)&v_exception_raised
- (((unsigned __int64)&v_exception_raised + 8) & 0xFFFFFFFFFFFFFFF8LL))),
8LL
* (((unsigned int)((unsigned int)&v_exception_raised
- (((unsigned __int64)&v_exception_raised + 8) & 0xFFFFFFFFFFFFFFF8LL))
+ 332) >> 3));
snprintf((char *)&v_exception_raised + 192, 0x80uLL, "%s", a1);
snprintf((char *)&v_exception_raised + 64, 0x40uLL, "%s", a2);
result = snprintf((char *)&v_exception_raised + 128, 0x40uLL, "%s", a3);
*((_QWORD *)&v_exception_raised + 40) = a4;
return result;
}

original_code:
void p_exception_fill(struct s_exception exception, const char *message, const char *file, const char *function, unsigned int line) {
  memcpy(&v_exception_raised, &exception, sizeof(struct s_exception));
  snprintf(v_exception_raised.description, 128, "%s", message);
  snprintf(v_exception_raised.file, 64, "%s", file);
  snprintf(v_exception_raised.function, 64, "%s", function);
  v_exception_raised.line = line;
  v_exception_raised.level = 0;
}

canonical_original_code:
void p_exception_fill(struct s_exception exception, char *message, char *file, char *function, unsigned int line) {
  memcpy(&v_exception_raised, &exception, sizeof(struct s_exception));
  snprintf(v_exception_raised.description, 128, "%s", message);
  snprintf(v_exception_raised.file, 64, "%s", file);
  snprintf(v_exception_raised.function, 64, "%s", function);
  v_exception_raised.line = line;
  v_exception_raised.level = 0;
}

variable_types: struct s_exception { char kind[64]; unsigned int line; int identificator; }

variable_types:
message
char *


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

v1 = calloc(1uLL, 0x20uLL);
result = p_memory_insert(v1, "list.c", "f_list_init", 20LL, 0LL);
*a1 = result;
if ( !result )
{
p_log_write(stderr, 0LL, "list.c", "f_list_init", 21LL, "out of memory! I'm dying: 'bleaaargh'");
exit(1);
}
return result;
}

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

v1 = calloc(1uLL, 0x20uLL);
result = p_memory_insert(v1, "list.c", "f_list_init", 20LL, 0LL);
*a1 = result;
if ( !result )
{
p_log_write(stderr, 0LL, "list.c", "f_list_init", 21LL, "out of memory! I'm dying: 'bleaaargh'");
exit(1);
}
return result;
}

original_code:
void f_list_init(struct s_list **list) {
  if (!(*list = (struct s_list *) p_memory_insert(calloc((1),(sizeof(struct s_list))),"list.c",__FUNCTION__,20,0)))
    do{ p_log_write(stderr,e_log_level_ever,"list.c",__FUNCTION__,21,"out of memory! I'm dying: 'bleaaargh'"); exit(1); }while(0);;
}

variable_types: struct s_list { struct s_list_node { struct s_list_node *next; } *head; unsigned long fill; } **

user_defined_types: struct s_list { struct s_list_node *head; unsigned long fill; }


decompiled_code:
void __fastcall f_list_destroy(void **a1)
{
void *v2; // rdi

v2 = *a1;
if ( v2 )
{
p_memory_remove(v2, "list.c", "f_list_destroy", 26LL, 0LL);
free(*a1);
}
*a1 = 0LL;
}

canonical_decompiled_code:
void __fastcall func1(void **a1)
{
void *v2; // rdi

v2 = *a1;
if ( v2 )
{
p_memory_remove(v2, "list.c", "f_list_destroy", 26LL, 0LL);
free(*a1);
}
*a1 = 0LL;
}

original_code:
void f_list_destroy(struct s_list **list) {
  if (*list)
    do{ p_memory_remove((*list),"list.c",__FUNCTION__,26,0); free(*list); }while(0);
  *list = ((void *)0);
}


original_code:
void f_list_append(struct s_list *list, struct s_list_node *node, enum e_list_insert_kind kind) {
  switch (kind) {
    case e_list_insert_head:
      if (list->head)
        list->head->back = node;
      node->next = list->head;
      list->head = node;
      break;
    case e_list_insert_tail:
      if (list->tail)
        list->tail->next = node;
      node->back = list->tail;
      list->tail = node;
      break;
  }
  list->fill++;
}

variable_types: struct s_list { struct s_list_node { struct s_list_node *next; } *head; unsigned long fill; } *

variable_types:
node
struct s_list_node *

variable_types: enum e_list_insert_kind { e_list_insert_head=0, e_list_insert_tail=1 }


original_code:
void f_list_insert(struct s_list *list, struct s_list_node *node, struct s_list_node *left) {
  if (left) {
    if (left->next) {
      node->next = left->next;
      node->next->back = node;
      node->back = left;
      left->next = node;
    } else
      f_list_append(list, node, e_list_insert_tail);
  } else
    f_list_append(list, node, e_list_insert_head);
  list->fill++;
}

variable_types:
left
struct s_list_node *


original_code:
enum bstate check_winner(char board[3][3])
{
    int user_num = 3 * 'X', comp_num = 3 * 'o';
    int s1, s2;
    for (int i = 0; i < 3; ++i) {
  s1 = s2 = 0;
 for (int j = 0; j < 3; j++) {
     s1 += board[i][j];
     s2 += board[j][i];
 }
 if (s1 == user_num || s2 == user_num)
     return USERW;
 else if (s1 == comp_num || s2 == comp_num)
     return COMPW;
    }
    s1 = board[0][0] + board[1][1] + board[2][2];
    s2 = board[0][2] + board[1][1] + board[2][0];
    if (s1 == user_num || s2 == user_num)
  return USERW;
    else if (s1 == comp_num || s2 == comp_num)
  return COMPW;
    for (int i = 0; i < 9; ++i)
  if (board[i / 3][i % 3] == ' ')
      return INCOM;
    return NONE;
}

canonical_original_code:
enum bstate check_winner(char board[3][3])
{
    int user_num = 3 * 'X'; int comp_num = 3 * 'o';
    int s1; int s2;
    for (int i = 0; i < 3; ++i) {
  s1 = s2 = 0;
 for (int j = 0; j < 3; j++) {
     s1 += board[i][j];
     s2 += board[j][i];
 }
 if (s1 == user_num || s2 == user_num)
     return USERW;
 else if (s1 == comp_num || s2 == comp_num)
     return COMPW;
    }
    s1 = board[0][0] + board[1][1] + board[2][2];
    s2 = board[0][2] + board[1][1] + board[2][0];
    if (s1 == user_num || s2 == user_num)
  return USERW;
    else if (s1 == comp_num || s2 == comp_num)
  return COMPW;
    for (int i = 0; i < 9; ++i)
  if (board[i / 3][i % 3] == ' ')
      return INCOM;
    return NONE;
}

variable_types:
board
char [3][3]

variable_types: i int

variable_types: j int

return_type: enum bstate { USERW=0, NONE=1, INCOM=2, COMPW=3 }


original_code:
int get_score(char board[3][3], enum player p)
{
    if (check_winner(board) != INCOM)
  return check_winner(board);
    int score = -1;
    for (int i = 0; i < 9; ++i) {
  if (board[i / 3][i % 3] == ' ') {
      if (p == USR) {
    board[i / 3][i % 3] = 'X';
    if (score == -1)
        score = get_score(board, COMP);
    else
        score = ((score<get_score(board, COMP))?score:get_score(board, COMP));
      } else if (p == COMP) {
    board[i / 3][i % 3] = 'o';
    score = ((score>get_score(board, USR))?score:get_score(board, USR));
     }
     board[i / 3][i % 3] = ' ';
 }
    }
    return score;
}

variable_types:
p
enum player { USR=0, COMP=1 }

variable_types: score int


original_code:
void comp_move(char board[3][3])
{
    int best_move, move_score = -1;
    for (int i = 0; i < 9; ++i) {
  if (board[i / 3][i % 3] == ' ') {
   board[i / 3][i % 3] = 'o';
   if (get_score(board, USR) > move_score) {
    move_score = get_score(board, USR);
    best_move = i;
   }
   board[i / 3][i % 3] = ' ';
  }
    }
    board[best_move / 3][best_move % 3] = 'o';
    return;
}

canonical_original_code:
void comp_move(char board[3][3])
{
    int best_move; int move_score = -1;
    for (int i = 0; i < 9; ++i) {
  if (board[i / 3][i % 3] == ' ') {
   board[i / 3][i % 3] = 'o';
   if (get_score(board, USR) > move_score) {
    move_score = get_score(board, USR);
    best_move = i;
   }
   board[i / 3][i % 3] = ' ';
  }
    }
    board[best_move / 3][best_move % 3] = 'o';
    return;
}


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *v3; // rcx
int v4; // eax
signed int v6; // [rsp+0h] [rbp-18h]
char v7[17]; // [rsp+7h] [rbp-11h] BYREF

qmemcpy(v7, " ", 9);
draw_board((__int64)v7);
do
{
while ( 1 )
{
printf("Your Move : ");
__isoc99_scanf();
if ( (unsigned int)v6 <= 8 )
{
v3 = &v7[3 * (v6 / 3) + 9];
if ( v3[v6 % 3 - 9] == 32 )
break;
}
puts("Invalid Move!!!");
}
v3[v6 % 3 - 9] = 88;
draw_board((__int64)v7);
if ( (unsigned int)check_winner(v7) != 2 )
break;
comp_move(v7);
draw_board((__int64)v7);
}
while ( (unsigned int)check_winner(v7) == 2 );
v4 = check_winner(v7);
if ( v4 == 3 )
{
puts("Computer wins the Game. Better luck next time\n");
}
else if ( v4 )
{
puts("Damn! It's a draw.\n");
}
else
{
puts("You have won the game! \n");
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *v3; // rcx
int v4; // eax
signed int v6; // [rsp+0h] [rbp-18h]
char v7[17]; // [rsp+7h] [rbp-11h] BYREF

qmemcpy(v7, " ", 9);
func7((__int64)v7);
do
{
while ( 1 )
{
printf("Your Move : ");
__isoc99_scanf();
if ( (unsigned int)v6 <= 8 )
{
v3 = &v7[3 * (v6 / 3) + 9];
if ( v3[v6 % 3 - 9] == 32 )
break;
}
puts("Invalid Move!!!");
}
v3[v6 % 3 - 9] = 88;
func7((__int64)v7);
if ( (unsigned int)func8(v7) != 2 )
break;
func10(v7);
func7((__int64)v7);
}
while ( (unsigned int)func8(v7) == 2 );
v4 = func8(v7);
if ( v4 == 3 )
{
puts("Computer wins the Game. Better luck next time\n");
}
else if ( v4 )
{
puts("Damn! It's a draw.\n");
}
else
{
puts("You have won the game! \n");
}
return 0;
}

original_code:
int main()
{
    char board[3][3];
    int move;
    for (int i = 0; i < 3; ++i)
  for (int j = 0; j < 3; ++j)
      board[i][j] = ' ';
    draw_board(board);
    do {
  printf("Your Move : ");
  scanf("%d", &move);
  if (move >= 0 && move <= 8 && board[move / 3][move % 3] == ' ') {
   board[move / 3][move % 3] = 'X';
   draw_board(board);
  } else {
   printf("Invalid Move!!!\n");
   continue;
  }
  if (check_winner(board) != INCOM)
   break;
  comp_move(board);
  draw_board(board);
  if (check_winner(board) != INCOM)
   break;
    }
    while (1);
    if (check_winner(board) == COMPW)
  printf("Computer wins the Game. Better luck next time\n\n");
    else if (check_winner(board) == USERW)
  printf("You have won the game! \n\n");
    else
  printf("Damn! It's a draw.\n\n");
    return 0;
}

variable_types: move int


repo: narshlob/botfly

decompiled_code:
__int64 __fastcall irc_pong(__int64 a1, const char *a2)
{
return sck_sendf(a1, "PONG :%s\r\n", a2);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, const char *a2)
{
return sck_sendf(a1, "PONG :%s\r\n", a2);
}

original_code:
int irc_pong(int s, const char *data){
  return sck_sendf(s, "PONG :%s\r\n", data);
}

canonical_original_code:
int irc_pong(int s, char *data){
  return sck_sendf(s, "PONG :%s\r\n", data);
}

variable_types: s int

variable_types:
data
char *


decompiled_code:
__int64 __fastcall irc_reg(__int64 a1, const char *a2, const char *a3, const char *a4)
{
return sck_sendf(a1, "NICK %s\r\nUSER %s localhost 0 :%s\r\n", a2, a3, a4);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, const char *a2, const char *a3, const char *a4)
{
return sck_sendf(a1, "NICK %s\r\nUSER %s localhost 0 :%s\r\n", a2, a3, a4);
}

original_code:
int irc_reg(int s, const char *nick, const char *username, const char *fullname){
  return sck_sendf(s, "NICK %s\r\nUSER %s localhost 0 :%s\r\n", nick, username, fullname);
}

canonical_original_code:
int irc_reg(int s, char *nick, char *username, char *fullname){
  return sck_sendf(s, "NICK %s\r\nUSER %s localhost 0 :%s\r\n", nick, username, fullname);
}

variable_types:
nick
char *

variable_types:
username
char *

variable_types:
fullname
char *


decompiled_code:
__int64 __fastcall irc_join(__int64 a1, const char *a2)
{
return sck_sendf(a1, "JOIN %s\r\n", a2);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, const char *a2)
{
return sck_sendf(a1, "JOIN %s\r\n", a2);
}

original_code:
int irc_join(int s, const char *data){
  return sck_sendf(s, "JOIN %s\r\n", data);
}

canonical_original_code:
int irc_join(int s, char *data){
  return sck_sendf(s, "JOIN %s\r\n", data);
}


decompiled_code:
__int64 __fastcall irc_part(__int64 a1, const char *a2)
{
return sck_sendf(a1, "PART %s\r\n", a2);
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, const char *a2)
{
return sck_sendf(a1, "PART %s\r\n", a2);
}

original_code:
int irc_part(int s, const char *data){
  return sck_sendf(s, "PART %s\r\n", data);
}

canonical_original_code:
int irc_part(int s, char *data){
  return sck_sendf(s, "PART %s\r\n", data);
}


decompiled_code:
__int64 __fastcall irc_nick(__int64 a1, const char *a2)
{
return sck_sendf(a1, "NICK %s\r\n", a2);
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, const char *a2)
{
return sck_sendf(a1, "NICK %s\r\n", a2);
}

original_code:
int irc_nick(int s, const char *data){
  return sck_sendf(s, "NICK %s\r\n", data);
}

canonical_original_code:
int irc_nick(int s, char *data){
  return sck_sendf(s, "NICK %s\r\n", data);
}


decompiled_code:
__int64 __fastcall irc_quit(__int64 a1, const char *a2)
{
return sck_sendf(a1, "QUIT :%s\r\n", a2);
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, const char *a2)
{
return sck_sendf(a1, "QUIT :%s\r\n", a2);
}

original_code:
int irc_quit(int s, const char *data){
  return sck_sendf(s, "QUIT :%s\r\n", data);
}

canonical_original_code:
int irc_quit(int s, char *data){
  return sck_sendf(s, "QUIT :%s\r\n", data);
}


decompiled_code:
__int64 __fastcall irc_topic(__int64 a1, const char *a2, const char *a3)
{
return sck_sendf(a1, "TOPIC %s :%s\r\n", a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, const char *a2, const char *a3)
{
return sck_sendf(a1, "TOPIC %s :%s\r\n", a2, a3);
}

original_code:
int irc_topic(int s, const char *channel, const char *data){
  return sck_sendf(s, "TOPIC %s :%s\r\n", channel, data);
}

canonical_original_code:
int irc_topic(int s, char *channel, char *data){
  return sck_sendf(s, "TOPIC %s :%s\r\n", channel, data);
}

variable_types:
channel
char *


decompiled_code:
__int64 __fastcall irc_action(__int64 a1, __int64 a2, __int64 a3)
{
return sck_sendf(a1, aPrivmsgS, a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1, __int64 a2, __int64 a3)
{
return sck_sendf(a1, aPrivmsgS, a2, a3);
}

original_code:
int irc_action(int s, const char *channel, const char *data){
  return sck_sendf(s, "PRIVMSG %s :\001ACTION %s\001\r\n", channel, data);
}

canonical_original_code:
int irc_action(int s, char *channel, char *data){
  return sck_sendf(s, "PRIVMSG %s :\001ACTION %s\001\r\n", channel, data);
}


decompiled_code:
__int64 __fastcall irc_msg(__int64 a1, const char *a2, const char *a3)
{
return sck_sendf(a1, "PRIVMSG %s :%s\r\n", a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func15(__int64 a1, const char *a2, const char *a3)
{
return sck_sendf(a1, "PRIVMSG %s :%s\r\n", a2, a3);
}

original_code:
int irc_msg(int s, const char *channel, const char *data){
  return sck_sendf(s, "PRIVMSG %s :%s\r\n", channel, data);
}

canonical_original_code:
int irc_msg(int s, char *channel, char *data){
  return sck_sendf(s, "PRIVMSG %s :%s\r\n", channel, data);
}


decompiled_code:
__int64 __fastcall get_socket(const char *a1, const char *a2)
{
int v2; // eax
int v3; // ebx
const char *v5; // rax
struct addrinfo *pai; // [rsp+8h] [rbp-40h] BYREF
struct addrinfo req; // [rsp+10h] [rbp-38h] BYREF

*(_QWORD *)&req.ai_flags = 1LL;
*(_QWORD *)&req.ai_socktype = 1LL;
*(_QWORD *)&req.ai_addrlen = 0LL;
req.ai_addr = 0LL;
req.ai_canonname = 0LL;
req.ai_next = 0LL;
v2 = getaddrinfo(a1, a2, &req, &pai);
if ( v2 < 0 )
{
v5 = gai_strerror(v2);
fprintf(stderr, "getaddrinfo error: %s\n", v5);
return (unsigned int)-1;
}
v3 = socket(pai->ai_family, pai->ai_socktype, pai->ai_protocol);
if ( v3 < 0 )
{
fwrite("Couldn't get socket.\n", 1uLL, 0x15uLL, stderr);
LABEL_8:
freeaddrinfo(pai);
return (unsigned int)-1;
}
if ( connect(v3, pai->ai_addr, pai->ai_addrlen) < 0 )
{
fwrite("Couldn't connect.\n", 1uLL, 0x12uLL, stderr);
goto LABEL_8;
}
freeaddrinfo(pai);
return (unsigned int)v3;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1, const char *a2)
{
int v2; // eax
int v3; // ebx
const char *v5; // rax
struct addrinfo *pai; // [rsp+8h] [rbp-40h] BYREF
struct addrinfo req; // [rsp+10h] [rbp-38h] BYREF

*(_QWORD *)&req.ai_flags = 1LL;
*(_QWORD *)&req.ai_socktype = 1LL;
*(_QWORD *)&req.ai_addrlen = 0LL;
req.ai_addr = 0LL;
req.ai_canonname = 0LL;
req.ai_next = 0LL;
v2 = getaddrinfo(a1, a2, &req, &pai);
if ( v2 < 0 )
{
v5 = gai_strerror(v2);
fprintf(stderr, "getaddrinfo error: %s\n", v5);
return (unsigned int)-1;
}
v3 = socket(pai->ai_family, pai->ai_socktype, pai->ai_protocol);
if ( v3 < 0 )
{
fwrite("Couldn't get socket.\n", 1uLL, 0x15uLL, stderr);
LABEL_8:
freeaddrinfo(pai);
return (unsigned int)-1;
}
if ( connect(v3, pai->ai_addr, pai->ai_addrlen) < 0 )
{
fwrite("Couldn't connect.\n", 1uLL, 0x12uLL, stderr);
goto LABEL_8;
}
freeaddrinfo(pai);
return (unsigned int)v3;
}

original_code:
int get_socket(const char* host, const char* port){
  int rc;
  int s;
  struct addrinfo hints, *res;
  memset(&hints, 0, sizeof(hints));
  hints.ai_family = 0;
  hints.ai_socktype = SOCK_STREAM;
  hints.ai_flags = 0x0001;
  if((rc = getaddrinfo(host, port, &hints, &res)) < 0){
    fprintf(stderr, "getaddrinfo error: %s\n", gai_strerror(rc));
    return -1;
  }
  s = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
  if(s < 0){
    fprintf(stderr, "Couldn't get socket.\n");
    goto error;
  }
  if(connect(s, res->ai_addr, res->ai_addrlen) < 0){
    fprintf(stderr, "Couldn't connect.\n");
    goto error;
  }
  freeaddrinfo(res);
  return s;
error:
  freeaddrinfo(res);
  return -1;
}

canonical_original_code:
int get_socket(char *host, char *port){
  int rc;
  int s;
  struct addrinfo hints; struct addrinfo *res;
  memset(&hints, 0, sizeof(hints));
  hints.ai_family = 0;
  hints.ai_socktype = SOCK_STREAM;
  hints.ai_flags = 0x0001;
  if((rc = getaddrinfo(host, port, &hints, &res)) < 0){
    fprintf(stderr, "getaddrinfo error: %s\n", gai_strerror(rc));
    return -1;
  }
  s = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
  if(s < 0){
    fprintf(stderr, "Couldn't get socket.\n");
    goto error;
  }
  if(connect(s, res->ai_addr, res->ai_addrlen) < 0){
    fprintf(stderr, "Couldn't connect.\n");
    goto error;
  }
  freeaddrinfo(res);
  return s;
error:
  freeaddrinfo(res);
  return -1;
}

variable_types:
host
char *

variable_types:
port
char *

variable_types: rc int

variable_types: struct addrinfo { int ai_flags; int ai_family; int ai_socktype; int ai_protocol; unsigned int ai_addrlen; struct sockaddr { unsigned short sa_family; char sa_data[14]; } *ai_addr; char *ai_canonname; struct addrinfo *ai_next; } *

user_defined_types: struct addrinfo { int ai_flags; int ai_family; int ai_socktype; int ai_protocol; unsigned int ai_addrlen; struct sockaddr *ai_addr; char *ai_canonname; struct addrinfo *ai_next; }


decompiled_code:
__int64 __fastcall sck_send(int fd, __int64 a2, unsigned __int64 a3)
{
unsigned __int64 v4; // rbx
int v5; // eax
__int64 result; // rax

if ( a3 )
{
v4 = 0LL;
while ( 1 )
{
v5 = send(fd, (const void *)(a2 + v4), a3 - v4, 0);
if ( v5 <= 0 )
break;
v4 += v5;
if ( a3 <= v4 )
goto LABEL_5;
}
result = 0xFFFFFFFFLL;
}
else
{
LODWORD(v4) = 0;
LABEL_5:
result = (unsigned int)v4;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(int fd, __int64 a2, unsigned __int64 a3)
{
unsigned __int64 v4; // rbx
int v5; // eax
__int64 result; // rax

if ( a3 )
{
v4 = 0LL;
while ( 1 )
{
v5 = send(fd, (const void *)(a2 + v4), a3 - v4, 0);
if ( v5 <= 0 )
break;
v4 += v5;
if ( a3 <= v4 )
goto LABEL_5;
}
result = 0xFFFFFFFFLL;
}
else
{
LODWORD(v4) = 0;
LABEL_5:
result = (unsigned int)v4;
}
return result;
}

original_code:
int sck_send(int s, const char* data, size_t size){
  size_t written = 0;
  int rc;
  while(written < size){
    rc = send(s, data + written, size - written, 0);
    if(rc <= 0)
      return -1;
    written += rc;
  }
  return written;
}

canonical_original_code:
int sck_send(int s, char *data, unsigned long size){
  unsigned long written = 0;
  int rc;
  while(written < size){
    rc = send(s, data + written, size - written, 0);
    if(rc <= 0)
      return -1;
    written += rc;
  }
  return written;
}

variable_types:
size
unsigned long

variable_types:
written
unsigned long


decompiled_code:
__int64 sck_sendf(int fd, char *format, ...)
{
int v2; // ebx
int v4; // eax
gcc_va_list arg; // [rsp+8h] [rbp-2E0h] BYREF
char s[512]; // [rsp+20h] [rbp-2C8h] BYREF

v2 = 0;
if ( *format )
{
va_start(arg, format);
v4 = vsnprintf(s, 0x200uLL, format, arg);
v2 = 512;
if ( v4 <= 512 )
v2 = v4;
if ( (int)sck_send(fd, (__int64)s, v2) <= 0 )
v2 = -1;
}
return (unsigned int)v2;
}

canonical_decompiled_code:
__int64 func2(int fd, char *format, ...)
{
int v2; // ebx
int v4; // eax
gcc_va_list arg; // [rsp+8h] [rbp-2E0h] BYREF
char s[512]; // [rsp+20h] [rbp-2C8h] BYREF

v2 = 0;
if ( *format )
{
va_start(arg, format);
v4 = vsnprintf(s, 0x200uLL, format, arg);
v2 = 512;
if ( v4 <= 512 )
v2 = v4;
if ( (int)func1(fd, (__int64)s, v2) <= 0 )
v2 = -1;
}
return (unsigned int)v2;
}

original_code:
int sck_sendf(int s, const char *fmt, ...){
  char send_buf[512];
  int send_len;
  va_list args;
  if(strlen(fmt) != 0){
    __builtin_va_start(args,fmt);
    send_len = vsnprintf(send_buf, sizeof (send_buf), fmt, args);
    __builtin_va_end(args);
    if(send_len > 512)
      send_len = 512;
    if(sck_send( s, send_buf, send_len ) <= 0)
      return -1;
    return send_len;
  }
  return 0;
}

canonical_original_code:
int sck_sendf(int s, char *fmt, ...){
  char send_buf[512];
  int send_len;
  __builtin_va_list args;
  if(strlen(fmt) != 0){
    __builtin_va_start(args,fmt);
    send_len = vsnprintf(send_buf, sizeof (send_buf), fmt, args);
    __builtin_va_end(args);
    if(send_len > 512)
      send_len = 512;
    if(sck_send( s, send_buf, send_len ) <= 0)
      return -1;
    return send_len;
  }
  return 0;
}

variable_types:
fmt
char *


decompiled_code:
ssize_t __fastcall sck_recv(int a1, void *a2, size_t a3)
{
ssize_t result; // rax

result = recv(a1, a2, a3, 0);
if ( (int)result <= 0 )
result = 0xFFFFFFFFLL;
return result;
}

canonical_decompiled_code:
ssize_t __fastcall func3(int a1, void *a2, size_t a3)
{
ssize_t result; // rax

result = recv(a1, a2, a3, 0);
if ( (int)result <= 0 )
result = 0xFFFFFFFFLL;
return result;
}

original_code:
int sck_recv(int s, char* buffer, size_t size){
  int rc;
  rc = recv(s, buffer, size, 0);
  if(rc <= 0)
    return -1;
  return rc;
}

canonical_original_code:
int sck_recv(int s, char *buffer, unsigned long size){
  int rc;
  rc = recv(s, buffer, size, 0);
  if(rc <= 0)
    return -1;
  return rc;
}

variable_types:
buffer
char *


decompiled_code:
__int64 __fastcall sck_done(int a1)
{
close(a1);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(int a1)
{
close(a1);
return 0LL;
}

original_code:
int sck_done(int s){
  close(s);
  return 0;
}


usage

decompiled_code:
void __noreturn usage()
{
puts("botfly <server> <chan> -p [port] -n <nick> -i <identity> -f <output file>");
exit(1);
}

canonical_decompiled_code:
void __noreturn func0()
{
puts("botfly <server> <chan> -p [port] -n <nick> -i <identity> -f <output file>");
exit(1);
}

original_code:
void usage(){
  puts("botfly <server> <chan> -p [port] -n <nick> -i <identity> -f <output file>");
  exit(1);
}


smack

decompiled_code:
__int64 __fastcall smack(char *s1, char *s, char *s2, int a4, const char *a5)
{
unsigned int v8; // eax
int v9; // eax
int v10; // ebp
int v11; // eax
int v12; // eax

v8 = time(0LL);
srand(v8);
v9 = rand();
if ( s2 && (v10 = v9, *s2) )
{
if ( !strcmp(s1, s2) )
{
v12 = rand();
snprintf(s, a4, "scoffs then smacks %s with a rusty pipe for %d damage!", a5, (unsigned int)(v12 % 20 + 41));
}
else
{
v11 = rand();
if ( (unsigned int)(v10 % 10 + 7) <= 0xE )
snprintf(s, a4, "smacks %s, for %d damage.", s2, (unsigned int)(v11 % 20 + 1));
else
snprintf(s, a4, "smacks %s, for %d damage (it's super effective).", s2, (unsigned int)(v11 % 20 + 21));
}
s[a4] = 0;
}
else
{
snprintf(s, a4, "Smacking thin air..");
s[a4] = 0;
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(char *s1, char *s, char *s2, int a4, const char *a5)
{
unsigned int v8; // eax
int v9; // eax
int v10; // ebp
int v11; // eax
int v12; // eax

v8 = time(0LL);
srand(v8);
v9 = rand();
if ( s2 && (v10 = v9, *s2) )
{
if ( !strcmp(s1, s2) )
{
v12 = rand();
snprintf(s, a4, "scoffs then smacks %s with a rusty pipe for %d damage!", a5, (unsigned int)(v12 % 20 + 41));
}
else
{
v11 = rand();
if ( (unsigned int)(v10 % 10 + 7) <= 0xE )
snprintf(s, a4, "smacks %s, for %d damage.", s2, (unsigned int)(v11 % 20 + 1));
else
snprintf(s, a4, "smacks %s, for %d damage (it's super effective).", s2, (unsigned int)(v11 % 20 + 21));
}
s[a4] = 0;
}
else
{
snprintf(s, a4, "Smacking thin air..");
s[a4] = 0;
}
return 1LL;
}

original_code:
int smack(char *botnick, char *mesg, char *arg, int bufsize, char *irc_nick){
  srand(time(((void *)0)));
  int critical;
  critical = (rand()%10)/8;
  if(arg != ((void *)0) && strlen(arg) > 0){
    if(strcmp(botnick, arg) == 0){
      snprintf(mesg, bufsize, "scoffs then smacks %s with a rusty pipe for %d damage!", irc_nick, rand()%20 + 41);
    }else if(critical)
      snprintf(mesg, bufsize, "smacks %s, for %d damage (it's super effective).", arg, rand()%20 + 21);
    else
      snprintf(mesg, bufsize, "smacks %s, for %d damage.", arg, rand()%20 + 1);
    mesg[bufsize] = '\0';
  } else {
     snprintf(mesg, bufsize, "Smacking thin air..");
     mesg[bufsize] = '\0';
  }
  return 1;
}

variable_types:
botnick
char *

variable_types:
mesg
char *

variable_types:
arg
char *

variable_types: bufsize int

variable_types: critical int


google

original_code:
int google(char *mesg, char *arg, int bufsize){
  char t_nick[128];
  char t_link[256];
  char link[256] = {0};
  char *t_arg = strtok(arg, " ");
  if ( t_arg ){
    strncpy(t_nick, t_arg, 127);
    t_nick[127] = '\0';
  }
  else
     return 0;
  t_arg = strtok(((void *)0), "");
  if ( t_arg ){
    while ( *t_arg == ' ' )
      t_arg++;
    strncpy(t_link, t_arg, 255);
    t_link[255] = '\0';
  }
  else
    return 0;
  t_arg = strtok(t_link, " ");
  while ( t_arg ){
    strncpy(&link[strlen(link)], t_arg, 254 - strlen(link));
    t_arg = strtok(((void *)0), " ");
    if ( !t_arg )
      break;
    strncpy(&link[strlen(link)], "%20", 254 - strlen(link));
  }
  snprintf(mesg, 511, "%s: http://lmgtfy.com/?q=%s", t_nick, link);
  mesg[bufsize - 1] = '\0';
  return 0;
}

variable_types:
link
char [256]


repo: nasrallahmounir/Posix

decompiled_code:
int affiche2()
{
return puts("Je suis la fonction 2");
}

canonical_decompiled_code:
int func0()
{
return puts("Je suis la fonction 2");
}

original_code:
void affiche2() {
  printf("Je suis la fonction 2\n");
}


decompiled_code:
__int64 init_queue()
{
void *v0; // rax
__int64 result; // rax

v0 = malloc(0x10uLL);
fifo = (__int64)v0;
if ( v0 )
{
init_list(v0);
result = 0LL;
}
else
{
fprintf(stderr, "Malloc error -- line : %d, file %s ", 12LL, "src/fifo_list.c");
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 func7()
{
void *v0; // rax
__int64 result; // rax

v0 = malloc(0x10uLL);
fifo = (__int64)v0;
if ( v0 )
{
func11(v0);
result = 0LL;
}
else
{
fprintf(stderr, "Malloc error -- line : %d, file %s ", 12LL, "src/fifo_list.c");
result = 1LL;
}
return result;
}

original_code:
int init_queue(){
  fifo = (struct list_type*)malloc(sizeof(struct list_type));
  if(fifo==((void *)0)){
    fprintf(stderr,"Malloc error -- line : %d, file %s ",12,"src/fifo_list.c");
    return 1;
  }
  else{
    init_list(fifo);
    return 0;
  }
}

canonical_original_code:
int init_queue(){
  fifo = (struct list_type *)malloc(sizeof(struct list_type));
  if(fifo==((void *)0)){
    fprintf(stderr,"Malloc error -- line : %d, file %s ",12,"src/fifo_list.c");
    return 1;
  }
  else{
    init_list(fifo);
    return 0;
  }
}

user_defined_types: struct list_type { struct cell_type *head; struct cell_type *tail; }

user_defined_types: struct cell_type { struct cell_type *previous; struct cell_type *next; void *content; }


queue

decompiled_code:
__int64 __fastcall queue(__int64 a1)
{
insert_head(fifo, a1);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
insert_head(fifo, a1);
return 0LL;
}

original_code:
int queue(void* element){
  insert_head(fifo, element);
  return 0;
}

canonical_original_code:
int queue(void *element){
  insert_head(fifo, element);
  return 0;
}

variable_types:
element
void *


dequeue

decompiled_code:
__int64 dequeue()
{
return extract_tail(fifo);
}

canonical_decompiled_code:
__int64 func9()
{
return extract_tail(fifo);
}

original_code:
void* dequeue(){
  return extract_tail(fifo);
}

canonical_original_code:
void *dequeue(){
  return extract_tail(fifo);
}


decompiled_code:
void *__fastcall extract_head(void **a1)
{
_QWORD *v1; // rax
void *v2; // rbx
_QWORD *v3; // rdx

if ( !a1 )
return 0LL;
v1 = *a1;
if ( !*a1 )
return 0LL;
v2 = a1[1];
if ( v2 )
{
v2 = (void *)v1[2];
v3 = (_QWORD *)v1[1];
if ( v3 )
{
*v3 = 0LL;
*a1 = (void *)*((_QWORD *)*a1 + 1);
free(v1);
}
else
{
free(*a1);
}
}
return v2;
}

canonical_decompiled_code:
void *__fastcall func12(void **a1)
{
_QWORD *v1; // rax
void *v2; // rbx
_QWORD *v3; // rdx

if ( !a1 )
return 0LL;
v1 = *a1;
if ( !*a1 )
return 0LL;
v2 = a1[1];
if ( v2 )
{
v2 = (void *)v1[2];
v3 = (_QWORD *)v1[1];
if ( v3 )
{
*v3 = 0LL;
*a1 = (void *)*((_QWORD *)*a1 + 1);
free(v1);
}
else
{
free(*a1);
}
}
return v2;
}

original_code:
void* extract_head(struct list_type *l) {
  if(l!=((void *)0) && l->head!=((void *)0) && l->tail!=((void *)0)){
    cell* old_head;
    old_head = l->head;
    void* content;
    content = old_head->content;
    if(l->head->next!=((void *)0)){
      l->head->next->previous = ((void *)0);
      l->head = l->head->next;
      free(old_head);
    }
    else{
       free(l->head);
    }
    return content;
  }
  return ((void *)0);
}

canonical_original_code:
void *extract_head(struct list_type *l) {
  if(l!=((void *)0) && l->head!=((void *)0) && l->tail!=((void *)0)){
    struct cell_type *old_head;
    old_head = l->head;
    void *content;
    content = old_head->content;
    if(l->head->next!=((void *)0)){
      l->head->next->previous = ((void *)0);
      l->head = l->head->next;
      free(old_head);
    }
    else{
       free(l->head);
    }
    return content;
  }
  return ((void *)0);
}

variable_types: struct list_type { struct cell_type { struct cell_type *previous; struct cell_type *next; void *content; } *head; struct cell_type *tail; } *

variable_types:
content
void *


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

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

original_code:
int list_size(struct list_type *l){
  cell* current;
  int size;
  size = 0;
  while(current!=((void *)0)){
    size++;
    current=current->next;
  }
  return size;
}

canonical_original_code:
int list_size(struct list_type *l){
  struct cell_type *current;
  int size;
  size = 0;
  while(current!=((void *)0)){
    size++;
    current=current->next;
  }
  return size;
}

variable_types: struct cell_type { struct cell_type *previous; struct cell_type *next; void *content; } *

variable_types: size int


size

decompiled_code:
__int64 size()
{
return list_size(fifo);
}

canonical_decompiled_code:
__int64 func10()
{
return func13(fifo);
}

original_code:
int size(){
  return list_size(fifo);
}

canonical_original_code:
int size(){
  return list_size(fifo);
}


convertfrom

decompiled_code:
double __fastcall convertfrom(const char *a1, double result)
{
if ( !strcmp(a1, "GBP") )
return result / 0.8796;
if ( !strcmp(a1, "USD") )
return result / 1.3605;
if ( !strcmp(a1, "JPY") )
return result / 124.25;
if ( !strcmp(a1, "CNY") )
return result / 6.8264;
if ( strcmp(a1, "EUR") )
{
perror("Unknown currency");
exit(1);
}
return result;
}

canonical_decompiled_code:
double __fastcall func7(const char *a1, double result)
{
if ( !strcmp(a1, "GBP") )
return result / 0.8796;
if ( !strcmp(a1, "USD") )
return result / 1.3605;
if ( !strcmp(a1, "JPY") )
return result / 124.25;
if ( !strcmp(a1, "CNY") )
return result / 6.8264;
if ( strcmp(a1, "EUR") )
{
perror("Unknown currency");
exit(1);
}
return result;
}

original_code:
double convertfrom(char* input_currency, double input_amount) {
 if (strcmp(input_currency, "GBP") == 0)
  return (input_amount / 0.8796);
 else if (strcmp(input_currency, "USD") == 0)
  return (input_amount / 1.3605);
 else if (strcmp(input_currency, "JPY") == 0)
  return (input_amount / 124.25);
 else if (strcmp(input_currency, "CNY") == 0)
  return (input_amount / 6.8264);
 else if (strcmp(input_currency, "EUR") == 0)
  return input_amount;
 else {
  perror("Unknown currency");
  exit(1);
 }
}

canonical_original_code:
double convertfrom(char *input_currency, double input_amount) {
 if (strcmp(input_currency, "GBP") == 0)
  return (input_amount / 0.8796);
 else if (strcmp(input_currency, "USD") == 0)
  return (input_amount / 1.3605);
 else if (strcmp(input_currency, "JPY") == 0)
  return (input_amount / 124.25);
 else if (strcmp(input_currency, "CNY") == 0)
  return (input_amount / 6.8264);
 else if (strcmp(input_currency, "EUR") == 0)
  return input_amount;
 else {
  perror("Unknown currency");
  exit(1);
 }
}

return_type: double


convertto

decompiled_code:
double __fastcall convertto(const char *a1, double result)
{
if ( !strcmp(a1, "GBP") )
return result * 0.8796;
if ( !strcmp(a1, "USD") )
return result * 1.3605;
if ( !strcmp(a1, "JPY") )
return result * 124.25;
if ( !strcmp(a1, "CNY") )
return result * 6.8264;
if ( strcmp(a1, "EUR") )
{
perror("Unknown currency");
exit(1);
}
return result;
}

canonical_decompiled_code:
double __fastcall func8(const char *a1, double result)
{
if ( !strcmp(a1, "GBP") )
return result * 0.8796;
if ( !strcmp(a1, "USD") )
return result * 1.3605;
if ( !strcmp(a1, "JPY") )
return result * 124.25;
if ( !strcmp(a1, "CNY") )
return result * 6.8264;
if ( strcmp(a1, "EUR") )
{
perror("Unknown currency");
exit(1);
}
return result;
}

original_code:
double convertto(char* target_currency, double input_amount) {
 if (strcmp(target_currency, "GBP") == 0)
  return (input_amount * 0.8796);
 else if (strcmp(target_currency, "USD") == 0)
  return (input_amount * 1.3605);
 else if (strcmp(target_currency, "JPY") == 0)
  return (input_amount * 124.25);
 else if (strcmp(target_currency, "CNY") == 0)
  return (input_amount * 6.8264);
 else if (strcmp(target_currency, "EUR") == 0)
  return input_amount;
 else {
  perror("Unknown currency");
  exit(1);
 }
}

canonical_original_code:
double convertto(char *target_currency, double input_amount) {
 if (strcmp(target_currency, "GBP") == 0)
  return (input_amount * 0.8796);
 else if (strcmp(target_currency, "USD") == 0)
  return (input_amount * 1.3605);
 else if (strcmp(target_currency, "JPY") == 0)
  return (input_amount * 124.25);
 else if (strcmp(target_currency, "CNY") == 0)
  return (input_amount * 6.8264);
 else if (strcmp(target_currency, "EUR") == 0)
  return input_amount;
 else {
  perror("Unknown currency");
  exit(1);
 }
}


convert

decompiled_code:
double __fastcall convert(const char *a1, const char *a2, double a3)
{
double v3; // xmm0_8

v3 = convertfrom(a1, a3);
return convertto(a2, v3);
}

canonical_decompiled_code:
double __fastcall func9(const char *a1, const char *a2, double a3)
{
double v3; // xmm0_8

v3 = func7(a1, a3);
return func8(a2, v3);
}

original_code:
double convert(char* input_currency, char* target_currency, double input_amount) {
 return convertto(target_currency, convertfrom(input_currency, input_amount));
}

canonical_original_code:
double convert(char *input_currency, char *target_currency, double input_amount) {
 return convertto(target_currency, convertfrom(input_currency, input_amount));
}


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

switch ( a1 )
{
case 0:
result = "EUR";
break;
case 1:
result = "GBP";
break;
case 2:
result = "USD";
break;
case 3:
result = "JPY";
break;
case 4:
result = "CNY";
break;
default:
perror("Unknown currency");
exit(1);
}
return result;
}

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

switch ( a1 )
{
case 0:
result = "EUR";
break;
case 1:
result = "GBP";
break;
case 2:
result = "USD";
break;
case 3:
result = "JPY";
break;
case 4:
result = "CNY";
break;
default:
perror("Unknown currency");
exit(1);
}
return result;
}

original_code:
char* determine_currency(int curr_nb) {
 switch(curr_nb) {
  case 0: return "EUR";
  case 1: return "GBP";
  case 2: return "USD";
  case 3: return "JPY";
  case 4: return "CNY";
  default: perror("Unknown currency"); exit(1);
 }
}

canonical_original_code:
char *determine_currency(int curr_nb) {
 switch(curr_nb) {
  case 0: return "EUR";
  case 1: return "GBP";
  case 2: return "USD";
  case 3: return "JPY";
  case 4: return "CNY";
  default: perror("Unknown currency"); exit(1);
 }
}

return_type: char *


decompiled_code:
__int64 init_stack()
{
void *v0; // rax
__int64 result; // rax

v0 = malloc(0x10uLL);
stack = (__int64)v0;
if ( v0 )
{
init_list(v0);
result = 0LL;
}
else
{
fprintf(stderr, "Malloc error -- line : %d, file : %s \n", 14LL, "src/stack_list.c");
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 func7()
{
void *v0; // rax
__int64 result; // rax

v0 = malloc(0x10uLL);
stack = (__int64)v0;
if ( v0 )
{
func11(v0);
result = 0LL;
}
else
{
fprintf(stderr, "Malloc error -- line : %d, file : %s \n", 14LL, "src/stack_list.c");
result = 1LL;
}
return result;
}

original_code:
int init_stack(){
  stack = (struct list_type*)malloc(sizeof(struct list_type));
  if(stack==((void *)0)){
    fprintf(stderr,"Malloc error -- line : %d, file : %s \n",14,"src/stack_list.c");
    return 1;
  }
  else{
    init_list(stack);
    return 0;
    }
}

canonical_original_code:
int init_stack(){
  stack = (struct list_type *)malloc(sizeof(struct list_type));
  if(stack==((void *)0)){
    fprintf(stderr,"Malloc error -- line : %d, file : %s \n",14,"src/stack_list.c");
    return 1;
  }
  else{
    init_list(stack);
    return 0;
    }
}


push

decompiled_code:
__int64 __fastcall push(__int64 a1)
{
insert_head(stack, a1);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
insert_head(stack, a1);
return 0LL;
}

original_code:
int push(void* element){
  insert_head(stack, element);
  return 0;
}

canonical_original_code:
int push(void *element){
  insert_head(stack, element);
  return 0;
}


pop

decompiled_code:
__int64 pop()
{
return extract_head(stack);
}

canonical_decompiled_code:
__int64 func9()
{
return func12(stack);
}

original_code:
void* pop(){
  return extract_head(stack);
}

canonical_original_code:
void *pop(){
  return extract_head(stack);
}


size

decompiled_code:
__int64 size()
{
return list_size(stack);
}

canonical_decompiled_code:
__int64 func10()
{
return func13(stack);
}

original_code:
int size(){
  return list_size(stack);
}

canonical_original_code:
int size(){
  return list_size(stack);
}


decompiled_code:
void __noreturn exo_I_a()
{
int v0; // ebx
__pid_t v1; // eax
unsigned int v2; // ebx
unsigned int v3; // eax

v0 = 7;
while ( 1 )
{
v1 = fork();
if ( v1 == -1 )
break;
if ( !v1 )
{
v2 = getppid();
v3 = getpid();
printf(format, v3, v2);
exit(0);
}
if ( !--v0 )
exit(0);
}
fwrite(&unk_402008, 1uLL, 0x1EuLL, stderr);
exit(1);
}

canonical_decompiled_code:
void __noreturn func7()
{
int v0; // ebx
__pid_t v1; // eax
unsigned int v2; // ebx
unsigned int v3; // eax

v0 = 7;
while ( 1 )
{
v1 = fork();
if ( v1 == -1 )
break;
if ( !v1 )
{
v2 = getppid();
v3 = getpid();
printf(format, v3, v2);
exit(0);
}
if ( !--v0 )
exit(0);
}
fwrite(&unk_402008, 1uLL, 0x1EuLL, stderr);
exit(1);
}

original_code:
void exo_I_a(){
  int i;
  pid_t pid;
  for(i=0;i<7;i++){
    pid=fork();
    switch(pid){
    case -1:
      fprintf(stderr,"Erreur lors de l'appel à fork");
      exit(1);
    case 0:
      printf("Je suis un processus fils, mon pid est le %d, mon père est %d \n",getpid(),getppid());
      exit(0);
    default:;
    }
  }
  exit(0);
}

canonical_original_code:
void exo_I_a(){
  int i;
  int pid;
  for(i=0;i<7;i++){
    pid=fork();
    switch(pid){
    case -1:
      fprintf(stderr,"Erreur lors de l'appel à fork");
      exit(1);
    case 0:
      printf("Je suis un processus fils, mon pid est le %d, mon père est %d \n",getpid(),getppid());
      exit(0);
    default:;
    }
  }
  exit(0);
}

variable_types: i int

variable_types: pid int


decompiled_code:
void __fastcall __noreturn exo_I_b(int *a1)
{
__pid_t v1; // eax
unsigned int v2; // ebx
unsigned int v3; // eax

if ( *a1 <= 6 )
{
v1 = fork();
++*a1;
if ( v1 != -1 )
{
if ( v1 )
exo_I_b(a1);
v2 = getppid();
v3 = getpid();
printf(format, v3, v2);
exit(0);
}
fwrite(&unk_402070, 1uLL, 0x23uLL, stderr);
exit(1);
}
exit(0);
}

canonical_decompiled_code:
void __fastcall __noreturn func8(int *a1)
{
__pid_t v1; // eax
unsigned int v2; // ebx
unsigned int v3; // eax

if ( *a1 <= 6 )
{
v1 = fork();
++*a1;
if ( v1 != -1 )
{
if ( v1 )
func8(a1);
v2 = getppid();
v3 = getpid();
printf(format, v3, v2);
exit(0);
}
fwrite(&unk_402070, 1uLL, 0x23uLL, stderr);
exit(1);
}
exit(0);
}

original_code:
void exo_I_b(int* i){
  if(*i<7){
    pid_t pid;
    pid=fork();
    *i = *i + 1;
    switch(pid){
    case -1: fprintf(stderr,"Erreur lors de la création du fils");
      exit(1);
    case 0:
      printf("Je suis un processus fils, mon pid est le %d, mon père est %d \n",getpid(),getppid());
      exit(0);
    default:
      exo_I_b(i);
    }
  }
  exit(0);
}

canonical_original_code:
void exo_I_b(int *i){
  if(*i<7){
    int pid;
    pid=fork();
    *i = *i + 1;
    switch(pid){
    case -1: fprintf(stderr,"Erreur lors de la création du fils");
      exit(1);
    case 0:
      printf("Je suis un processus fils, mon pid est le %d, mon père est %d \n",getpid(),getppid());
      exit(0);
    default:
      exo_I_b(i);
    }
  }
  exit(0);
}

variable_types:
i
int *


decompiled_code:
void __noreturn exo_II_1()
{
int v0; // ebx
__pid_t v1; // eax
unsigned int v2; // ebx
unsigned int v3; // eax

v0 = 7;
while ( 1 )
{
v1 = fork();
if ( v1 == -1 )
break;
if ( !v1 )
{
v2 = getppid();
v3 = getpid();
printf(format, v3, v2);
exit(0);
}
if ( !--v0 )
{
wait(0LL);
exit(0);
}
}
fwrite(&unk_402008, 1uLL, 0x1EuLL, stderr);
exit(1);
}

canonical_decompiled_code:
void __noreturn func9()
{
int v0; // ebx
__pid_t v1; // eax
unsigned int v2; // ebx
unsigned int v3; // eax

v0 = 7;
while ( 1 )
{
v1 = fork();
if ( v1 == -1 )
break;
if ( !v1 )
{
v2 = getppid();
v3 = getpid();
printf(format, v3, v2);
exit(0);
}
if ( !--v0 )
{
wait(0LL);
exit(0);
}
}
fwrite(&unk_402008, 1uLL, 0x1EuLL, stderr);
exit(1);
}

original_code:
void exo_II_1(){
  int i;
  pid_t pid;
  for(i=0;i<7;i++){
    pid=fork();
    switch(pid){
    case -1:
      fprintf(stderr,"Erreur lors de l'appel à fork");
      exit(1);
    case 0:
      printf("Je suis un processus fils, mon pid est le %d, mon père est %d \n",getpid(),getppid());
      exit(0);
    default:;}
  }
  wait(((void *)0));
  exit(0);
}

canonical_original_code:
void exo_II_1(){
  int i;
  int pid;
  for(i=0;i<7;i++){
    pid=fork();
    switch(pid){
    case -1:
      fprintf(stderr,"Erreur lors de l'appel à fork");
      exit(1);
    case 0:
      printf("Je suis un processus fils, mon pid est le %d, mon père est %d \n",getpid(),getppid());
      exit(0);
    default:;}
  }
  wait(((void *)0));
  exit(0);
}


decompiled_code:
void __noreturn exo_II_2()
{
int v0; // ebx
__pid_t v1; // eax
unsigned int v2; // ebx
unsigned int v3; // eax

v0 = 7;
while ( 1 )
{
v1 = fork();
if ( v1 == -1 )
break;
if ( !v1 )
{
v2 = getppid();
v3 = getpid();
printf(format, v3, v2);
exit(0);
}
wait(0LL);
if ( !--v0 )
exit(0);
}
fwrite(&unk_402008, 1uLL, 0x1EuLL, stderr);
exit(1);
}

canonical_decompiled_code:
void __noreturn func10()
{
int v0; // ebx
__pid_t v1; // eax
unsigned int v2; // ebx
unsigned int v3; // eax

v0 = 7;
while ( 1 )
{
v1 = fork();
if ( v1 == -1 )
break;
if ( !v1 )
{
v2 = getppid();
v3 = getpid();
printf(format, v3, v2);
exit(0);
}
wait(0LL);
if ( !--v0 )
exit(0);
}
fwrite(&unk_402008, 1uLL, 0x1EuLL, stderr);
exit(1);
}

original_code:
void exo_II_2(){
  int i;
  pid_t pid;
  for(i=0;i<7;i++){
    pid=fork();
    switch(pid){
    case -1:
      fprintf(stderr,"Erreur lors de l'appel à fork");
      exit(1);
    case 0:
      printf("Je suis un processus fils, mon pid est le %d, mon père est %d \n",getpid(),getppid());
      exit(0);
    default:
      wait(((void *)0));
    }
  }
  exit(0);
}

canonical_original_code:
void exo_II_2(){
  int i;
  int pid;
  for(i=0;i<7;i++){
    pid=fork();
    switch(pid){
    case -1:
      fprintf(stderr,"Erreur lors de l'appel à fork");
      exit(1);
    case 0:
      printf("Je suis un processus fils, mon pid est le %d, mon père est %d \n",getpid(),getppid());
      exit(0);
    default:
      wait(((void *)0));
    }
  }
  exit(0);
}


decompiled_code:
void __noreturn exo_II_3()
{
int i; // ebx
__pid_t v1; // eax
unsigned int v2; // ebx
unsigned int v3; // eax
int stat_loc[3]; // [rsp+Ch] [rbp-Ch] BYREF

for ( i = 7; ; --i )
{
v1 = fork();
if ( v1 == -1 )
break;
if ( !v1 )
{
v2 = getppid();
v3 = getpid();
printf(format, v3, v2);
exit(0);
}
if ( i == 1 )
{
waitpid(v1, stat_loc, 0);
exit(0);
}
}
fwrite(&unk_402008, 1uLL, 0x1EuLL, stderr);
exit(1);
}

canonical_decompiled_code:
void __noreturn func11()
{
int i; // ebx
__pid_t v1; // eax
unsigned int v2; // ebx
unsigned int v3; // eax
int stat_loc[3]; // [rsp+Ch] [rbp-Ch] BYREF

for ( i = 7; ; --i )
{
v1 = fork();
if ( v1 == -1 )
break;
if ( !v1 )
{
v2 = getppid();
v3 = getpid();
printf(format, v3, v2);
exit(0);
}
if ( i == 1 )
{
waitpid(v1, stat_loc, 0);
exit(0);
}
}
fwrite(&unk_402008, 1uLL, 0x1EuLL, stderr);
exit(1);
}

original_code:
void exo_II_3(){
  int i,status;
  pid_t pid;
  for(i=0;i<7;i++){
    pid=fork();
    switch(pid){
    case -1:
      fprintf(stderr,"Erreur lors de l'appel à fork");
      exit(1);
    case 0:
      printf("Je suis un processus fils, mon pid est le %d, mon père est %d \n",getpid(),getppid());
      exit(0);
    default:
      if(i==7 -1){
        waitpid(pid,&status,0);
      }
    }
  }
  exit(0);
}

canonical_original_code:
void exo_II_3(){
  int i; int status;
  int pid;
  for(i=0;i<7;i++){
    pid=fork();
    switch(pid){
    case -1:
      fprintf(stderr,"Erreur lors de l'appel à fork");
      exit(1);
    case 0:
      printf("Je suis un processus fils, mon pid est le %d, mon père est %d \n",getpid(),getppid());
      exit(0);
    default:
      if(i==7 -1){
        waitpid(pid,&status,0);
      }
    }
  }
  exit(0);
}

variable_types: status int