decompiled_code:
size_t __fastcall ocihandle_print(__int64 a1, unsigned int a2, unsigned int a3, unsigned int a4, unsigned int *a5)
{
size_t result; // rax

if ( !a5 )
return ((__int64 (*)(void))ocidump_pointer)();
ocidump_htype_short(*a5);
putc_unlocked(95, ocidump_logfp);
ocidump_ulong(a5[1]);
putc_unlocked(40, ocidump_logfp);
ocidump_pointer(a1);
putc_unlocked(41, ocidump_logfp);
result = *a5;
if ( (_DWORD)result != a2 && (_DWORD)result != a3 && (_DWORD)result != a4 )
{
fwrite("<<< This should be ", 1uLL, 0x13uLL, ocidump_logfp);
ocidump_htype_short(a2);
if ( !a3 || a4 )
{
fwrite(", ", 1uLL, 2uLL, ocidump_logfp);
ocidump_htype_short(a3);
fwrite(" or ", 1uLL, 4uLL, ocidump_logfp);
ocidump_htype_short(a4);
}
else
{
fwrite(" or ", 1uLL, 4uLL, ocidump_logfp);
ocidump_htype_short(a3);
}
result = fwrite(". >>>", 1uLL, 5uLL, ocidump_logfp);
}
return result;
}

canonical_decompiled_code:
size_t __fastcall func3(__int64 a1, unsigned int a2, unsigned int a3, unsigned int a4, unsigned int *a5)
{
size_t result; // rax

if ( !a5 )
return ((__int64 (*)(void))ocidump_pointer)();
ocidump_htype_short(*a5);
putc_unlocked(95, ocidump_logfp);
ocidump_ulong(a5[1]);
putc_unlocked(40, ocidump_logfp);
ocidump_pointer(a1);
putc_unlocked(41, ocidump_logfp);
result = *a5;
if ( (_DWORD)result != a2 && (_DWORD)result != a3 && (_DWORD)result != a4 )
{
fwrite("<<< This should be ", 1uLL, 0x13uLL, ocidump_logfp);
ocidump_htype_short(a2);
if ( !a3 || a4 )
{
fwrite(", ", 1uLL, 2uLL, ocidump_logfp);
ocidump_htype_short(a3);
fwrite(" or ", 1uLL, 4uLL, ocidump_logfp);
ocidump_htype_short(a4);
}
else
{
fwrite(" or ", 1uLL, 4uLL, ocidump_logfp);
ocidump_htype_short(a3);
}
result = fwrite(". >>>", 1uLL, 5uLL, ocidump_logfp);
}
return result;
}

original_code:
void ocihandle_print(const void *addr, ub4 type, ub4 type2, ub4 type3, const ocihandle_t *hndl)
{
    if (hndl != ((void *)0)) {
        ocidump_htype_short(hndl->type);
        putc_unlocked('_', ocidump_logfp);
        ocidump_ulong(hndl->id);
        putc_unlocked('(', ocidump_logfp);
        ocidump_pointer(addr);
        putc_unlocked(')', ocidump_logfp);
        if (type != hndl->type && type2 != hndl->type && type3 != hndl->type) {
            fputs("<<< This should be ", ocidump_logfp);
            ocidump_htype_short(type);
            if (type2 != 0 && type3 == 0) {
                fputs(" or ", ocidump_logfp);
                ocidump_htype_short(type2);
            } else {
                fputs(", ", ocidump_logfp);
                ocidump_htype_short(type2);
                fputs(" or ", ocidump_logfp);
                ocidump_htype_short(type3);
            }
            fputs(". >>>", ocidump_logfp);
        }
    } else {
        ocidump_pointer(addr);
    }
}

canonical_original_code:
void ocihandle_print(void *addr, unsigned int type, unsigned int type2, unsigned int type3, struct ocihandle *hndl)
{
    if (hndl != ((void *)0)) {
        ocidump_htype_short(hndl->type);
        putc_unlocked('_', ocidump_logfp);
        ocidump_ulong(hndl->id);
        putc_unlocked('(', ocidump_logfp);
        ocidump_pointer(addr);
        putc_unlocked(')', ocidump_logfp);
        if (type != hndl->type && type2 != hndl->type && type3 != hndl->type) {
            fputs("<<< This should be ", ocidump_logfp);
            ocidump_htype_short(type);
            if (type2 != 0 && type3 == 0) {
                fputs(" or ", ocidump_logfp);
                ocidump_htype_short(type2);
            } else {
                fputs(", ", ocidump_logfp);
                ocidump_htype_short(type2);
                fputs(" or ", ocidump_logfp);
                ocidump_htype_short(type3);
            }
            fputs(". >>>", ocidump_logfp);
        }
    } else {
        ocidump_pointer(addr);
    }
}

variable_types:
addr
void *

variable_types:
type
unsigned int

variable_types: struct ocihandle { unsigned int type; unsigned int id; } *


repo: kubo/ocidump

decompiled_code:
size_t __fastcall print_ht_entry(__int64 a1)
{
return ocihandle_print(*(_QWORD *)(a1 + 8), *(_DWORD *)(a1 + 48), 0, 0, (unsigned int *)(a1 + 48));
}

canonical_decompiled_code:
size_t __fastcall func4(__int64 a1)
{
return func3(*(_QWORD *)(a1 + 8), *(_DWORD *)(a1 + 48), 0, 0, (unsigned int *)(a1 + 48));
}

original_code:
static void print_ht_entry(ht_entry_t *entry)
{
    ocihandle_print(entry->addr, entry->handle.type, 0, 0, &entry->handle);
}

canonical_original_code:
static void print_ht_entry(struct ht_entry *entry)
{
    ocihandle_print(entry->addr, entry->handle.type, 0, 0, &entry->handle);
}

variable_types: struct ht_entry { struct ht_entry *next; void *addr; struct ht_entry *parent; struct ht_entry *children; struct ht_entry *prev_sibling; struct ht_entry *next_sibling; struct ocihandle { unsigned int type; unsigned int id; } handle; } *

return_type: void

user_defined_types: struct ht_entry { struct ht_entry *next; void *addr; struct ht_entry *parent; struct ht_entry *children; struct ht_entry *prev_sibling; struct ht_entry *next_sibling; struct ocihandle handle; }


decompiled_code:
__int64 ocidump_dump_hash_table()
{
__int64 result; // rax
unsigned __int64 v1; // r14
_QWORD *i; // rbp
__int64 v3; // rbx
__int64 v4; // rax
__int64 v5; // rbx

result = hash_table_size;
if ( hash_table_size )
{
v1 = 0LL;
do
{
for ( i = (_QWORD *)*((_QWORD *)hash_table + v1); i; i = (_QWORD *)*i )
{
print_ht_entry((__int64)i);
v3 = i[2];
if ( v3 )
{
fwrite(" parent = ", 1uLL, 0xAuLL, ocidump_logfp);
print_ht_entry(v3);
}
if ( i[3] )
{
fwrite(" children = [", 1uLL, 0xDuLL, ocidump_logfp);
print_ht_entry(i[3]);
v4 = i[3];
v5 = *(_QWORD *)(v4 + 40);
if ( v4 != v5 )
{
do
{
fwrite(", ", 1uLL, 2uLL, ocidump_logfp);
print_ht_entry(v5);
v5 = *(_QWORD *)(v5 + 40);
}
while ( i[3] != v5 );
}
fputc(93, ocidump_logfp);
}
fputc(10, ocidump_logfp);
}
result = hash_table_size;
++v1;
}
while ( hash_table_size > v1 );
}
return result;
}

canonical_decompiled_code:
__int64 func5()
{
__int64 result; // rax
unsigned __int64 v1; // r14
_QWORD *i; // rbp
__int64 v3; // rbx
__int64 v4; // rax
__int64 v5; // rbx

result = hash_table_size;
if ( hash_table_size )
{
v1 = 0LL;
do
{
for ( i = (_QWORD *)*((_QWORD *)hash_table + v1); i; i = (_QWORD *)*i )
{
func4((__int64)i);
v3 = i[2];
if ( v3 )
{
fwrite(" parent = ", 1uLL, 0xAuLL, ocidump_logfp);
func4(v3);
}
if ( i[3] )
{
fwrite(" children = [", 1uLL, 0xDuLL, ocidump_logfp);
func4(i[3]);
v4 = i[3];
v5 = *(_QWORD *)(v4 + 40);
if ( v4 != v5 )
{
do
{
fwrite(", ", 1uLL, 2uLL, ocidump_logfp);
func4(v5);
v5 = *(_QWORD *)(v5 + 40);
}
while ( i[3] != v5 );
}
fputc(93, ocidump_logfp);
}
fputc(10, ocidump_logfp);
}
result = hash_table_size;
++v1;
}
while ( hash_table_size > v1 );
}
return result;
}

original_code:
void ocidump_dump_hash_table(void)
{
    int i;
    for (i = 0; i < hash_table_size; i++) {
        ht_entry_t *entry;
        for (entry = hash_table[i]; entry != ((void *)0); entry = entry->next) {
            print_ht_entry(entry);
            if (entry->parent) {
                ht_entry_t *parent = entry->parent;
                fputs(" parent = ", ocidump_logfp);
                print_ht_entry(parent);
            }
            if (entry->children) {
                ht_entry_t *child;
                fputs(" children = [", ocidump_logfp);
                print_ht_entry(entry->children);
                for (child = entry->children->next_sibling; child != entry->children; child = child->next_sibling) {
                    fputs(", ", ocidump_logfp);
                    print_ht_entry(child);
                }
                fputc(']', ocidump_logfp);
            }
            fputc('\n', ocidump_logfp);
        }
    }
}

canonical_original_code:
void ocidump_dump_hash_table()
{
    int i;
    for (i = 0; i < hash_table_size; i++) {
        struct ht_entry *entry;
        for (entry = hash_table[i]; entry != ((void *)0); entry = entry->next) {
            print_ht_entry(entry);
            if (entry->parent) {
                struct ht_entry *parent = entry->parent;
                fputs(" parent = ", ocidump_logfp);
                print_ht_entry(parent);
            }
            if (entry->children) {
                struct ht_entry *child;
                fputs(" children = [", ocidump_logfp);
                print_ht_entry(entry->children);
                for (child = entry->children->next_sibling; child != entry->children; child = child->next_sibling) {
                    fputs(", ", ocidump_logfp);
                    print_ht_entry(child);
                }
                fputc(']', ocidump_logfp);
            }
            fputc('\n', ocidump_logfp);
        }
    }
}

variable_types: i int

user_defined_types: struct ocihandle { unsigned int type; unsigned int id; }


repo: kubo/plthook

decompiled_code:
double __fastcall strtod_cdecl(const char *a1, char **a2)
{
return strtod(a1, a2);
}

canonical_decompiled_code:
double __fastcall func6(const char *a1, char **a2)
{
return strtod(a1, a2);
}

original_code:
double strtod_cdecl(const char *str, char **endptr)
{
    return strtod(str, endptr);
}

canonical_original_code:
double strtod_cdecl(char *str, char **endptr)
{
    return strtod(str, endptr);
}

variable_types:
str
char *

variable_types:
endptr
char **

return_type: double


repo: kugland/libstruct

decompiled_code:
void __fastcall list_node_destroy(void *ptr)
{
__int64 v1; // rax
__int64 v2; // rdx
__int64 v3; // rax

if ( !ptr )
_assert_fail("node != NULL", "list/node_destroy.c", 0xAu, "list_node_destroy");
v1 = *((_QWORD *)ptr + 3);
if ( !v1 )
_assert_fail("node->owner != NULL", "list/node_destroy.c", 0xBu, "list_node_destroy");
v2 = *((_QWORD *)ptr + 1);
if ( v2 )
{
if ( *(void **)(v1 + 8) == ptr )
_assert_fail("node->owner->last != node", "list/node_destroy.c", 0xEu, "list_node_destroy");
*(_QWORD *)(v2 + 16) = *((_QWORD *)ptr + 2);
}
else
{
*(_QWORD *)(v1 + 8) = *((_QWORD *)ptr + 2);
}
v3 = *((_QWORD *)ptr + 2);
if ( v3 )
{
if ( **((void ***)ptr + 3) == ptr )
_assert_fail("node->owner->first != node", "list/node_destroy.c", 0x14u, "list_node_destroy");
*(_QWORD *)(v3 + 8) = *((_QWORD *)ptr + 1);
}
else
{
**((_QWORD **)ptr + 3) = *((_QWORD *)ptr + 1);
}
--*(_QWORD *)(*((_QWORD *)ptr + 3) + 16LL);
if ( *(_DWORD *)(*((_QWORD *)ptr + 3) + 24LL) )
free(*(void **)ptr);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func0(void *ptr)
{
__int64 v1; // rax
__int64 v2; // rdx
__int64 v3; // rax

if ( !ptr )
_assert_fail("node != NULL", "list/node_destroy.c", 0xAu, "list_node_destroy");
v1 = *((_QWORD *)ptr + 3);
if ( !v1 )
_assert_fail("node->owner != NULL", "list/node_destroy.c", 0xBu, "list_node_destroy");
v2 = *((_QWORD *)ptr + 1);
if ( v2 )
{
if ( *(void **)(v1 + 8) == ptr )
_assert_fail("node->owner->last != node", "list/node_destroy.c", 0xEu, "list_node_destroy");
*(_QWORD *)(v2 + 16) = *((_QWORD *)ptr + 2);
}
else
{
*(_QWORD *)(v1 + 8) = *((_QWORD *)ptr + 2);
}
v3 = *((_QWORD *)ptr + 2);
if ( v3 )
{
if ( **((void ***)ptr + 3) == ptr )
_assert_fail("node->owner->first != node", "list/node_destroy.c", 0x14u, "list_node_destroy");
*(_QWORD *)(v3 + 8) = *((_QWORD *)ptr + 1);
}
else
{
**((_QWORD **)ptr + 3) = *((_QWORD *)ptr + 1);
}
--*(_QWORD *)(*((_QWORD *)ptr + 3) + 16LL);
if ( *(_DWORD *)(*((_QWORD *)ptr + 3) + 24LL) )
free(*(void **)ptr);
free(ptr);
}

original_code:
void list_node_destroy(list_node_t* node)
{
 ((void) sizeof ((node != ((void *)0)) ? 1 : 0), __extension__ ({ if (node != ((void *)0)) ; else __assert_fail ("node != NULL", "list/node_destroy.c", 10, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((node->owner != ((void *)0)) ? 1 : 0), __extension__ ({ if (node->owner != ((void *)0)) ; else __assert_fail ("node->owner != NULL", "list/node_destroy.c", 11, __extension__ __PRETTY_FUNCTION__); }));
 if (node->next != ((void *)0)) {
  ((void) sizeof ((node->owner->last != node) ? 1 : 0), __extension__ ({ if (node->owner->last != node) ; else __assert_fail ("node->owner->last != node", "list/node_destroy.c", 14, __extension__ __PRETTY_FUNCTION__); }));
  node->next->prev = node->prev;
 } else
  node->owner->last = node->prev;
 if (node->prev != ((void *)0)) {
  ((void) sizeof ((node->owner->first != node) ? 1 : 0), __extension__ ({ if (node->owner->first != node) ; else __assert_fail ("node->owner->first != node", "list/node_destroy.c", 20, __extension__ __PRETTY_FUNCTION__); }));
  node->prev->next = node->next;
 } else
  node->owner->first = node->next;
 node->owner->len--;
 if (node->owner->free_data)
  free(node->data);
 free(node);
}

canonical_original_code:
void list_node_destroy(struct list_node_t *node)
{
 ((void) sizeof ((node != ((void *)0)) ? 1 : 0), __extension__ ({ if (node != ((void *)0)) ; else __assert_fail ("node != NULL", "list/node_destroy.c", 10, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((node->owner != ((void *)0)) ? 1 : 0), __extension__ ({ if (node->owner != ((void *)0)) ; else __assert_fail ("node->owner != NULL", "list/node_destroy.c", 11, __extension__ __PRETTY_FUNCTION__); }));
 if (node->next != ((void *)0)) {
  ((void) sizeof ((node->owner->last != node) ? 1 : 0), __extension__ ({ if (node->owner->last != node) ; else __assert_fail ("node->owner->last != node", "list/node_destroy.c", 14, __extension__ __PRETTY_FUNCTION__); }));
  node->next->prev = node->prev;
 } else
  node->owner->last = node->prev;
 if (node->prev != ((void *)0)) {
  ((void) sizeof ((node->owner->first != node) ? 1 : 0), __extension__ ({ if (node->owner->first != node) ; else __assert_fail ("node->owner->first != node", "list/node_destroy.c", 20, __extension__ __PRETTY_FUNCTION__); }));
  node->prev->next = node->next;
 } else
  node->owner->first = node->next;
 node->owner->len--;
 if (node->owner->free_data)
  free(node->data);
 free(node);
}

variable_types: struct list_node_t { void *data; struct list_node_t *next; struct list_node_t *prev; struct list_t { struct list_node_t *first; struct list_node_t *last; unsigned long len; int free_data; } *owner; } *

user_defined_types: struct list_node_t { void *data; struct list_node_t *next; struct list_node_t *prev; struct list_t *owner; }


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

result = malloc(0x20uLL);
if ( !result )
_assert_fail("list != NULL", "list/create.c", 0xEu, "list_create");
*result = 0LL;
result[1] = 0LL;
result[2] = 0LL;
*((_DWORD *)result + 6) = 0;
return result;
}

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

result = malloc(0x20uLL);
if ( !result )
_assert_fail("list != NULL", "list/create.c", 0xEu, "list_create");
*result = 0LL;
result[1] = 0LL;
result[2] = 0LL;
*((_DWORD *)result + 6) = 0;
return result;
}

original_code:
list_t* list_create(void)
{
 list_t* list;
 list = (list_t*) malloc(sizeof(list_t));
 ((void) sizeof ((list != ((void *)0)) ? 1 : 0), __extension__ ({ if (list != ((void *)0)) ; else __assert_fail ("list != NULL", "list/create.c", 14, __extension__ __PRETTY_FUNCTION__); }));
 list->first = ((void *)0);
 list->last = ((void *)0);
 list->len = 0;
 list->free_data = 0;
 return list;
}

canonical_original_code:
struct list_t *list_create()
{
 struct list_t *list;
 list = (struct list_t *) malloc(sizeof(list_t));
 ((void) sizeof ((list != ((void *)0)) ? 1 : 0), __extension__ ({ if (list != ((void *)0)) ; else __assert_fail ("list != NULL", "list/create.c", 14, __extension__ __PRETTY_FUNCTION__); }));
 list->first = ((void *)0);
 list->last = ((void *)0);
 list->len = 0;
 list->free_data = 0;
 return list;
}

variable_types: struct list_t { struct list_node_t { void *data; struct list_node_t *next; struct list_node_t *prev; struct list_t *owner; } *first; struct list_node_t *last; unsigned long len; int free_data; } *

user_defined_types: struct list_t { struct list_node_t *first; struct list_node_t *last; unsigned long len; int free_data; }


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

if ( !a1 )
_assert_fail("list != NULL", "list/join.c", 0xCu, "list_join");
if ( !a2 )
_assert_fail("list2 != NULL", "list/join.c", 0xDu, "list_join");
v2 = (_QWORD *)*a2;
if ( *a2 )
{
do
{
list_append(a1, *v2);
v2 = (_QWORD *)v2[1];
}
while ( v2 );
}
return a1;
}

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

if ( !a1 )
_assert_fail("list != NULL", "list/join.c", 0xCu, "list_join");
if ( !a2 )
_assert_fail("list2 != NULL", "list/join.c", 0xDu, "list_join");
v2 = (_QWORD *)*a2;
if ( *a2 )
{
do
{
list_append(a1, *v2);
v2 = (_QWORD *)v2[1];
}
while ( v2 );
}
return a1;
}

original_code:
list_t* list_join(list_t* list, list_t* list2)
{
 list_node_t* node;
 ((void) sizeof ((list != ((void *)0)) ? 1 : 0), __extension__ ({ if (list != ((void *)0)) ; else __assert_fail ("list != NULL", "list/join.c", 12, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((list2 != ((void *)0)) ? 1 : 0), __extension__ ({ if (list2 != ((void *)0)) ; else __assert_fail ("list2 != NULL", "list/join.c", 13, __extension__ __PRETTY_FUNCTION__); }));
 for (node = list2->first; node != ((void *)0); node = node->next)
  list_append(list, node->data);
 return list;
}

canonical_original_code:
struct list_t *list_join(struct list_t *list, struct list_t *list2)
{
 struct list_node_t *node;
 ((void) sizeof ((list != ((void *)0)) ? 1 : 0), __extension__ ({ if (list != ((void *)0)) ; else __assert_fail ("list != NULL", "list/join.c", 12, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((list2 != ((void *)0)) ? 1 : 0), __extension__ ({ if (list2 != ((void *)0)) ; else __assert_fail ("list2 != NULL", "list/join.c", 13, __extension__ __PRETTY_FUNCTION__); }));
 for (node = list2->first; node != ((void *)0); node = node->next)
  list_append(list, node->data);
 return list;
}

variable_types:
list
struct list_t *

return_type: struct list_t { struct list_node_t { void *data; struct list_node_t *next; struct list_node_t *prev; struct list_t *owner; } *first; struct list_node_t *last; unsigned long len; int free_data; } *


decompiled_code:
__int64 __fastcall list_from_array(__int64 a1, unsigned __int64 a2)
{
__int64 v2; // rbp
unsigned int v3; // ebx
__int64 v4; // rax

v2 = list_create();
if ( a2 )
{
v3 = 0;
v4 = 0LL;
do
{
list_append(v2, *(_QWORD *)(a1 + 8 * v4));
v4 = ++v3;
}
while ( v3 < a2 );
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, unsigned __int64 a2)
{
__int64 v2; // rbp
unsigned int v3; // ebx
__int64 v4; // rax

v2 = list_create();
if ( a2 )
{
v3 = 0;
v4 = 0LL;
do
{
list_append(v2, *(_QWORD *)(a1 + 8 * v4));
v4 = ++v3;
}
while ( v3 < a2 );
}
return v2;
}

original_code:
list_t* list_from_array(void** ptr, size_t len)
{
    unsigned i;
    list_t* list;
    list = list_create();
    for (i = 0; i < len; i++)
        list_append(list, ptr[i]);
    return list;
}

canonical_original_code:
struct list_t *list_from_array(void **ptr, unsigned long len)
{
    unsigned int i;
    struct list_t *list;
    list = list_create();
    for (i = 0; i < len; i++)
        list_append(list, ptr[i]);
    return list;
}

variable_types:
ptr
void **

variable_types:
len
unsigned long

variable_types:
i
unsigned int


decompiled_code:
__int64 __fastcall list_sort(__int64 a1, int (__fastcall *a2)(_QWORD, _QWORD))
{
unsigned __int64 v3; // rsi

v3 = *(_QWORD *)(a1 + 16);
if ( v3 > 1 )
merge_sort(*(_QWORD **)a1, v3, a2, 0);
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, int (__fastcall *a2)(_QWORD, _QWORD))
{
unsigned __int64 v3; // rsi

v3 = *(_QWORD *)(a1 + 16);
if ( v3 > 1 )
func0(*(_QWORD **)a1, v3, a2, 0);
return a1;
}

original_code:
list_t* list_sort(list_t* list, int (*cmp)(const void *, const void *))
{
 if (__builtin_expect((list->len > 1),1))
  merge_sort(list->first, list->len, cmp, 0);
 return list;
}

canonical_original_code:
struct list_t *list_sort(struct list_t *list, int (*cmp)(void *, void *))
{
 if (__builtin_expect((list->len > 1),1))
  merge_sort(list->first, list->len, cmp, 0);
 return list;
}

variable_types:
cmp
int (*)(void *, void *)


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

if ( !a1 )
_assert_fail("list != NULL", "list/copy.c", 0xAu, "list_copy");
v1 = list_create();
return list_join(v1, a1);
}

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

if ( !a1 )
_assert_fail("list != NULL", "list/copy.c", 0xAu, "list_copy");
v1 = list_create();
return list_join(v1, a1);
}

original_code:
list_t* list_copy(list_t* list)
{
 ((void) sizeof ((list != ((void *)0)) ? 1 : 0), __extension__ ({ if (list != ((void *)0)) ; else __assert_fail ("list != NULL", "list/copy.c", 10, __extension__ __PRETTY_FUNCTION__); }));
 return list_join(list_create(), list);
}

canonical_original_code:
struct list_t *list_copy(struct list_t *list)
{
 ((void) sizeof ((list != ((void *)0)) ? 1 : 0), __extension__ ({ if (list != ((void *)0)) ; else __assert_fail ("list != NULL", "list/copy.c", 10, __extension__ __PRETTY_FUNCTION__); }));
 return list_join(list_create(), list);
}


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

if ( !a1 )
_assert_fail("list != NULL", "list/destroy.c", 0xAu, "list_destroy");
v1 = (void *)list_clear();
free(v1);
}

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

if ( !a1 )
_assert_fail("list != NULL", "list/destroy.c", 0xAu, "list_destroy");
v1 = (void *)list_clear();
free(v1);
}

original_code:
void list_destroy(list_t* list)
{
 ((void) sizeof ((list != ((void *)0)) ? 1 : 0), __extension__ ({ if (list != ((void *)0)) ; else __assert_fail ("list != NULL", "list/destroy.c", 10, __extension__ __PRETTY_FUNCTION__); }));
 free(list_clear(list));
}

canonical_original_code:
void list_destroy(struct list_t *list)
{
 ((void) sizeof ((list != ((void *)0)) ? 1 : 0), __extension__ ({ if (list != ((void *)0)) ; else __assert_fail ("list != NULL", "list/destroy.c", 10, __extension__ __PRETTY_FUNCTION__); }));
 free(list_clear(list));
}


main

canonical_name: main

repo: kumkee/lylunarlib

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v3; // rcx
unsigned int v5; // [rsp+0h] [rbp-28h] BYREF
unsigned int v6; // [rsp+4h] [rbp-24h]
unsigned int v7; // [rsp+8h] [rbp-20h]
unsigned int v8; // [rsp+Ch] [rbp-1Ch]
int v9; // [rsp+14h] [rbp-14h]

v5 = 2012;
v6 = 6;
v7 = 4;
v8 = 12;
Solar2Lunar(&v5, argv, envp);
printf("Solar : %d.%d.%d.%d\t\n", 2012LL, 6LL, 4LL, 12LL);
v3 = "Leap";
if ( !v9 )
v3 = "Solar : %d.%d.%d.%d\t\n" + 21;
printf("Lunar : %d.%d%s.%d.%d\n", v5, v6, v3, v7, v8);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v3; // rcx
unsigned int v5; // [rsp+0h] [rbp-28h] BYREF
unsigned int v6; // [rsp+4h] [rbp-24h]
unsigned int v7; // [rsp+8h] [rbp-20h]
unsigned int v8; // [rsp+Ch] [rbp-1Ch]
int v9; // [rsp+14h] [rbp-14h]

v5 = 2012;
v6 = 6;
v7 = 4;
v8 = 12;
func14(&v5, argv, envp);
printf("Solar : %d.%d.%d.%d\t\n", 2012LL, 6LL, 4LL, 12LL);
v3 = "Leap";
if ( !v9 )
v3 = "Solar : %d.%d.%d.%d\t\n" + 21;
printf("Lunar : %d.%d%s.%d.%d\n", v5, v6, v3, v7, v8);
return 0;
}

original_code:
int main()
{
    int year, month, day, hour;
    year = 2012;
    month = 6;
    day = 4;
    hour = 12;
    Date myday;
    myday.year = year;
    myday.month = month;
    myday.day = day;
    myday.hour = hour;
    Solar2Lunar(&myday);
    printf("Solar : %d.%d.%d.%d\t\n", year, month, day, hour);
    printf("Lunar : %d.%d%s.%d.%d\n",
    myday.year, myday.month, (myday.leap?"Leap":""), myday.day, myday.hour);
    return 0;
}

canonical_original_code:
int main()
{
    int year; int month; int day; int hour;
    year = 2012;
    month = 6;
    day = 4;
    hour = 12;
    struct Date myday;
    myday.year = year;
    myday.month = month;
    myday.day = day;
    myday.hour = hour;
    Solar2Lunar(&myday);
    printf("Solar : %d.%d.%d.%d\t\n", year, month, day, hour);
    printf("Lunar : %d.%d%s.%d.%d\n",
    myday.year, myday.month, (myday.leap?"Leap":""), myday.day, myday.hour);
    return 0;
}

variable_types: year int

variable_types: month int

variable_types: day int

variable_types: hour int

variable_types:
myday
struct Date { int year; int leap; }

return_type: int


original_code:
int make_yday()
{
    int year, i, leap;
    long code;
    for (year = 0; year < 150; year++)
    {
 code = yearInfo[year];
 leap = code & 0xf;
 yday[year] = 0;
 if (leap != 0)
 {
     i = (code >> 16) & 0x1;
     yday[year] += moon[i];
 }
 code >>= 4;
 for (i = 0; i < 13 -1; i++)
 {
     yday[year] += moon[code&0x1];
     code >>= 1;
 }
 ymonth[year] = 12;
 if (leap != 0) ymonth[year]++;
    }
    return 150;
}

canonical_original_code:
int make_yday()
{
    int year; int i; int leap;
    long code;
    for (year = 0; year < 150; year++)
    {
 code = yearInfo[year];
 leap = code & 0xf;
 yday[year] = 0;
 if (leap != 0)
 {
     i = (code >> 16) & 0x1;
     yday[year] += moon[i];
 }
 code >>= 4;
 for (i = 0; i < 13 -1; i++)
 {
     yday[year] += moon[code&0x1];
     code >>= 1;
 }
 ymonth[year] = 12;
 if (leap != 0) ymonth[year]++;
    }
    return 150;
}

variable_types: leap int

variable_types: code long


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

v1 = Solar2Day(a1);
return Day2Lunar(v1 + (dword_40462C == 23), a1);
}

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

v1 = func9(a1);
return func13(v1 + (dword_40462C == 23), a1);
}

original_code:
void Solar2Lunar(Date *d)
{
    long offset;
    offset = Solar2Day(d);
    if (solar.hour == 23)
 offset++;
    Day2Lunar(offset, d);
}

canonical_original_code:
void Solar2Lunar(struct Date *d)
{
    long offset;
    offset = Solar2Day(d);
    if (solar.hour == 23)
 offset++;
    Day2Lunar(offset, d);
}

variable_types:
d
struct Date { int year; int leap; } *

variable_types: offset long


decompiled_code:
__int64 __fastcall is_empty(_BYTE *a1, __int64 a2)
{
_BYTE *v2; // rax
_BYTE *v3; // rsi

if ( !a2 )
return 1LL;
v2 = a1;
v3 = &a1[a2];
while ( *v2 == 0xFD )
{
if ( ++v2 == v3 )
return 1LL;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(_BYTE *a1, __int64 a2)
{
_BYTE *v2; // rax
_BYTE *v3; // rsi

if ( !a2 )
return 1LL;
v2 = a1;
v3 = &a1[a2];
while ( *v2 == 0xFD )
{
if ( ++v2 == v3 )
return 1LL;
}
return 0LL;
}

original_code:
bool is_empty(void *data, unsigned long size)
{
 register unsigned long i;
 for (i=0; i<size; i++)
 {
  if (((unsigned char *)data)[i] != 0xfd)
            return 0;
 }
 return 1;
}

canonical_original_code:
unsigned char is_empty(void *data, unsigned long size)
{
 register unsigned long i;
 for (i=0; i<size; i++)
 {
  if (((unsigned char *)data)[i] != 0xfd)
            return 0;
 }
 return 1;
}

variable_types:
data
void *

variable_types:
size
unsigned long

variable_types:
i
unsigned long

return_type: unsigned char


decompiled_code:
__int64 __fastcall is_deleted(_BYTE *a1, __int64 a2)
{
_BYTE *v2; // rax
_BYTE *v3; // rsi

if ( !a2 )
return 1LL;
v2 = a1;
v3 = &a1[a2];
while ( *v2 == 0xFE )
{
if ( ++v2 == v3 )
return 1LL;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(_BYTE *a1, __int64 a2)
{
_BYTE *v2; // rax
_BYTE *v3; // rsi

if ( !a2 )
return 1LL;
v2 = a1;
v3 = &a1[a2];
while ( *v2 == 0xFE )
{
if ( ++v2 == v3 )
return 1LL;
}
return 0LL;
}

original_code:
bool is_deleted(void *data, unsigned long size)
{
 register unsigned long i;
 for (i=0; i<size; i++)
 {
  if (((unsigned char *) data)[i] != 0xfe)
   return 0;
 }
 return 1;
}

canonical_original_code:
unsigned char is_deleted(void *data, unsigned long size)
{
 register unsigned long i;
 for (i=0; i<size; i++)
 {
  if (((unsigned char *) data)[i] != 0xfe)
   return 0;
 }
 return 1;
}


decompiled_code:
__int64 __fastcall is_reserved(_BYTE *a1, __int64 a2)
{
__int64 result; // rax
_BYTE *v3; // rax
_BYTE *v4; // rsi

result = 0LL;
if ( (unsigned __int8)(*a1 + 3) <= 1u )
{
if ( a2 )
{
v3 = a1 + 1;
v4 = &a1[a2];
while ( v3 != v4 )
{
if ( *a1 != *v3++ )
return 0LL;
}
result = 1LL;
}
else
{
result = 1LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(_BYTE *a1, __int64 a2)
{
__int64 result; // rax
_BYTE *v3; // rax
_BYTE *v4; // rsi

result = 0LL;
if ( (unsigned __int8)(*a1 + 3) <= 1u )
{
if ( a2 )
{
v3 = a1 + 1;
v4 = &a1[a2];
while ( v3 != v4 )
{
if ( *a1 != *v3++ )
return 0LL;
}
result = 1LL;
}
else
{
result = 1LL;
}
}
return result;
}

original_code:
bool is_reserved(void *data, unsigned long size)
{
 register unsigned long i;
 if (((unsigned char *) data)[0] != 0xfd &&
   ((unsigned char *) data)[0] != 0xfe)
  return 0;
 for (i=0; i<size; i++)
 {
  if (((unsigned char *) data)[i] != ((unsigned char *) data)[0])
   return 0;
 }
 return 1;
}

canonical_original_code:
unsigned char is_reserved(void *data, unsigned long size)
{
 register unsigned long i;
 if (((unsigned char *) data)[0] != 0xfd &&
   ((unsigned char *) data)[0] != 0xfe)
  return 0;
 for (i=0; i<size; i++)
 {
  if (((unsigned char *) data)[i] != ((unsigned char *) data)[0])
   return 0;
 }
 return 1;
}


decompiled_code:
void __fastcall hmap_free(void *ptr)
{
free(*((void **)ptr + 3));
free(*((void **)ptr + 4));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func3(void *ptr)
{
free(*((void **)ptr + 3));
free(*((void **)ptr + 4));
free(ptr);
}

original_code:
void hmap_free(struct hmap *map)
{
 free(map->keys);
 free(map->data);
 free(map);
}

variable_types: struct hmap { unsigned long map_size; unsigned long data_size; unsigned long key_size; void *keys; void *data; unsigned long (*hash)(void *); } *


decompiled_code:
__int64 __fastcall hmap_insert(unsigned __int64 *a1, _BYTE *a2, const void *a3)
{
unsigned __int64 v3; // rax
unsigned __int64 v4; // r12
unsigned __int64 v5; // r14
unsigned __int64 v6; // rbp
size_t v7; // r13
__int64 v8; // r14
_BYTE *v9; // rbx
unsigned __int64 v11; // r12
unsigned __int64 v12; // [rsp+8h] [rbp-50h]

v3 = ((__int64 (__fastcall *)(_BYTE *))a1[5])(a2);
v4 = *a1;
v5 = v3 % *a1;
v6 = v5;
v12 = a1[3];
v7 = a1[2];
if ( (unsigned __int8)is_reserved(a2, v7) )
return 0xFFFFFFFFLL;
v8 = v4 + v5;
while ( 1 )
{
v9 = (_BYTE *)(v12 + v7 * (v6 % v4));
if ( (unsigned __int8)is_reserved(v9, v7) )
break;
if ( v6 == v8 )
return 0xFFFFFFFFLL;
++v6;
}
v11 = a1[4];
memcpy(v9, a2, v7);
memcpy((void *)(v11 + a1[1] * (v6 % *a1)), a3, a1[1]);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned __int64 *a1, _BYTE *a2, const void *a3)
{
unsigned __int64 v3; // rax
unsigned __int64 v4; // r12
unsigned __int64 v5; // r14
unsigned __int64 v6; // rbp
size_t v7; // r13
__int64 v8; // r14
_BYTE *v9; // rbx
unsigned __int64 v11; // r12
unsigned __int64 v12; // [rsp+8h] [rbp-50h]

v3 = ((__int64 (__fastcall *)(_BYTE *))a1[5])(a2);
v4 = *a1;
v5 = v3 % *a1;
v6 = v5;
v12 = a1[3];
v7 = a1[2];
if ( (unsigned __int8)func2(a2, v7) )
return 0xFFFFFFFFLL;
v8 = v4 + v5;
while ( 1 )
{
v9 = (_BYTE *)(v12 + v7 * (v6 % v4));
if ( (unsigned __int8)func2(v9, v7) )
break;
if ( v6 == v8 )
return 0xFFFFFFFFLL;
++v6;
}
v11 = a1[4];
memcpy(v9, a2, v7);
memcpy((void *)(v11 + a1[1] * (v6 % *a1)), a3, a1[1]);
return 0LL;
}

original_code:
int hmap_insert(struct hmap *map, void *key, void *data)
{
 unsigned long i=0, index=map->hash(key)%map->map_size;
 char *aux_key=map->keys, *aux_data=map->data;
 if (is_reserved(key, map->key_size))
        return -1;
 while (!is_reserved(aux_key+((index+i)%map->map_size)*(map->key_size),
   map->key_size))
 {
  if (i==map->map_size)
   return -1;
  i++;
 }
 memcpy(aux_key+((index+i)%map->map_size)*(map->key_size), key,
   map->key_size);
 memcpy(aux_data+((index+i)%map->map_size)*(map->data_size), data,
    map->data_size);
 return 0;
}

canonical_original_code:
int hmap_insert(struct hmap *map, void *key, void *data)
{
 unsigned long i = 0; unsigned long index = map->hash(key)%map->map_size;
 char *aux_key = map->keys; char *aux_data = map->data;
 if (is_reserved(key, map->key_size))
        return -1;
 while (!is_reserved(aux_key+((index+i)%map->map_size)*(map->key_size),
   map->key_size))
 {
  if (i==map->map_size)
   return -1;
  i++;
 }
 memcpy(aux_key+((index+i)%map->map_size)*(map->key_size), key,
   map->key_size);
 memcpy(aux_data+((index+i)%map->map_size)*(map->data_size), data,
    map->data_size);
 return 0;
}

variable_types:
key
void *

variable_types:
index
unsigned long

user_defined_types: struct hmap { unsigned long map_size; unsigned long data_size; unsigned long key_size; void *keys; void *data; unsigned long (*hash)(void *); }


decompiled_code:
__int64 __fastcall hmap_remove(unsigned __int64 *a1, const char *a2, void *a3)
{
unsigned __int64 v3; // rax
unsigned __int64 v4; // r12
size_t v5; // r14
__int64 i; // rbp
unsigned __int64 v7; // r15
char v8; // al
unsigned int v9; // ebx
unsigned __int64 v11; // [rsp+8h] [rbp-60h]
unsigned __int64 v12; // [rsp+10h] [rbp-58h]

v3 = ((__int64 (__fastcall *)(const char *))a1[5])(a2);
v4 = *a1;
v12 = v3 % *a1;
v11 = a1[3];
v5 = a1[2];
for ( i = 0LL; ; ++i )
{
v7 = (i + v12) % v4;
v8 = is_empty((_BYTE *)(v11 + v7 * v5), v5);
if ( v4 == i || v8 )
break;
v9 = strncmp((const char *)(v11 + v7 * v5), a2, v5);
if ( !v9 )
{
memcpy(a3, (const void *)(a1[4] + a1[1] * v7), a1[1]);
memset((void *)(a1[2] * ((i + v12) % *a1) + v11), 255, a1[2]);
return v9;
}
}
return (unsigned int)-1;
}

canonical_decompiled_code:
__int64 __fastcall func5(unsigned __int64 *a1, const char *a2, void *a3)
{
unsigned __int64 v3; // rax
unsigned __int64 v4; // r12
size_t v5; // r14
__int64 i; // rbp
unsigned __int64 v7; // r15
char v8; // al
unsigned int v9; // ebx
unsigned __int64 v11; // [rsp+8h] [rbp-60h]
unsigned __int64 v12; // [rsp+10h] [rbp-58h]

v3 = ((__int64 (__fastcall *)(const char *))a1[5])(a2);
v4 = *a1;
v12 = v3 % *a1;
v11 = a1[3];
v5 = a1[2];
for ( i = 0LL; ; ++i )
{
v7 = (i + v12) % v4;
v8 = func0((_BYTE *)(v11 + v7 * v5), v5);
if ( v4 == i || v8 )
break;
v9 = strncmp((const char *)(v11 + v7 * v5), a2, v5);
if ( !v9 )
{
memcpy(a3, (const void *)(a1[4] + a1[1] * v7), a1[1]);
memset((void *)(a1[2] * ((i + v12) % *a1) + v11), 255, a1[2]);
return v9;
}
}
return (unsigned int)-1;
}

original_code:
int hmap_remove(struct hmap *map, void *key, void *data)
{
 unsigned long i=0, index=map->hash(key)%map->map_size;
 char *aux_key=map->keys, *aux_data=map->data;
 while (!is_empty(aux_key+((index+i)%map->map_size)*(map->key_size),
    map->key_size)&&i!=map->map_size)
 {
  if (strncmp(aux_key+((index+i)%map->map_size)*(map->key_size),
    key, map->key_size) == 0)
  {
   memcpy(data, aux_data+((index+i)%map->map_size)*
     (map->data_size), map->data_size);
   memset(aux_key+((index+i)%map->map_size)*(map->key_size)
     , 0xff, map->key_size);
   return 0;
  }
  i++;
 }
 return -1;
}

canonical_original_code:
int hmap_remove(struct hmap *map, void *key, void *data)
{
 unsigned long i = 0; unsigned long index = map->hash(key)%map->map_size;
 char *aux_key = map->keys; char *aux_data = map->data;
 while (!is_empty(aux_key+((index+i)%map->map_size)*(map->key_size),
    map->key_size)&&i!=map->map_size)
 {
  if (strncmp(aux_key+((index+i)%map->map_size)*(map->key_size),
    key, map->key_size) == 0)
  {
   memcpy(data, aux_data+((index+i)%map->map_size)*
     (map->data_size), map->data_size);
   memset(aux_key+((index+i)%map->map_size)*(map->key_size)
     , 0xff, map->key_size);
   return 0;
  }
  i++;
 }
 return -1;
}


decompiled_code:
__int64 __fastcall hmap_search(unsigned __int64 *a1, const char *a2, void *a3)
{
size_t v3; // r13
unsigned __int64 v4; // r12
__int64 i; // rbp
unsigned __int64 v6; // r14
char v7; // al
unsigned int v8; // ebx
__int64 v10; // [rsp+0h] [rbp-58h]
unsigned __int64 v11; // [rsp+8h] [rbp-50h]

v10 = ((__int64 (__fastcall *)(const char *))a1[5])(a2);
v11 = a1[3];
v3 = a1[2];
v4 = *a1;
for ( i = 0LL; ; ++i )
{
v6 = (i + v10) % v4;
v7 = is_empty((_BYTE *)(v11 + v6 * v3), v3);
if ( v4 == i || v7 )
break;
v8 = strncmp((const char *)(v11 + v6 * v3), a2, v3);
if ( !v8 )
{
memcpy(a3, (const void *)(a1[4] + a1[1] * v6), a1[1]);
return v8;
}
}
return (unsigned int)-1;
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned __int64 *a1, const char *a2, void *a3)
{
size_t v3; // r13
unsigned __int64 v4; // r12
__int64 i; // rbp
unsigned __int64 v6; // r14
char v7; // al
unsigned int v8; // ebx
__int64 v10; // [rsp+0h] [rbp-58h]
unsigned __int64 v11; // [rsp+8h] [rbp-50h]

v10 = ((__int64 (__fastcall *)(const char *))a1[5])(a2);
v11 = a1[3];
v3 = a1[2];
v4 = *a1;
for ( i = 0LL; ; ++i )
{
v6 = (i + v10) % v4;
v7 = func0((_BYTE *)(v11 + v6 * v3), v3);
if ( v4 == i || v7 )
break;
v8 = strncmp((const char *)(v11 + v6 * v3), a2, v3);
if ( !v8 )
{
memcpy(a3, (const void *)(a1[4] + a1[1] * v6), a1[1]);
return v8;
}
}
return (unsigned int)-1;
}

original_code:
int hmap_search(struct hmap *map, void *key, void *data)
{
 unsigned long i=0, index=map->hash(key);
 char *aux_key=map->keys, *aux_data=map->data;
 while (!is_empty(aux_key+((index+i)%map->map_size)*(map->key_size),
    map->key_size)&&i!=map->map_size)
 {
  if (strncmp(aux_key+((index+i)%map->map_size)*(map->key_size),
    key, map->key_size) == 0)
  {
   memcpy(data, aux_data+((index+i)%map->map_size)*
     (map->data_size), map->data_size);
   return 0;
  }
  i++;
 }
 return -1;
}

canonical_original_code:
int hmap_search(struct hmap *map, void *key, void *data)
{
 unsigned long i = 0; unsigned long index = map->hash(key);
 char *aux_key = map->keys; char *aux_data = map->data;
 while (!is_empty(aux_key+((index+i)%map->map_size)*(map->key_size),
    map->key_size)&&i!=map->map_size)
 {
  if (strncmp(aux_key+((index+i)%map->map_size)*(map->key_size),
    key, map->key_size) == 0)
  {
   memcpy(data, aux_data+((index+i)%map->map_size)*
     (map->data_size), map->data_size);
   return 0;
  }
  i++;
 }
 return -1;
}


decompiled_code:
__int64 __fastcall hmap_update(unsigned __int64 *a1, const void *a2, const void *a3)
{
unsigned __int64 v3; // rax
unsigned __int64 v4; // r12
size_t v5; // r13
__int64 i; // rbp
unsigned __int64 v7; // r14
char v8; // al
unsigned int v9; // ebx
unsigned __int64 v11; // [rsp+0h] [rbp-58h]
unsigned __int64 v12; // [rsp+8h] [rbp-50h]

v3 = ((__int64 (__fastcall *)(const void *))a1[5])(a2);
v4 = *a1;
v12 = v3 % *a1;
v11 = a1[3];
v5 = a1[2];
for ( i = 0LL; ; ++i )
{
v7 = (i + v12) % v4;
v8 = is_empty((_BYTE *)(v11 + v7 * v5), v5);
if ( v4 == i || v8 )
break;
v9 = memcmp((const void *)(v11 + v7 * v5), a2, v5);
if ( !v9 )
{
memcpy((void *)(a1[4] + a1[1] * v7), a3, a1[1]);
return v9;
}
}
return (unsigned int)-1;
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned __int64 *a1, const void *a2, const void *a3)
{
unsigned __int64 v3; // rax
unsigned __int64 v4; // r12
size_t v5; // r13
__int64 i; // rbp
unsigned __int64 v7; // r14
char v8; // al
unsigned int v9; // ebx
unsigned __int64 v11; // [rsp+0h] [rbp-58h]
unsigned __int64 v12; // [rsp+8h] [rbp-50h]

v3 = ((__int64 (__fastcall *)(const void *))a1[5])(a2);
v4 = *a1;
v12 = v3 % *a1;
v11 = a1[3];
v5 = a1[2];
for ( i = 0LL; ; ++i )
{
v7 = (i + v12) % v4;
v8 = func0((_BYTE *)(v11 + v7 * v5), v5);
if ( v4 == i || v8 )
break;
v9 = memcmp((const void *)(v11 + v7 * v5), a2, v5);
if ( !v9 )
{
memcpy((void *)(a1[4] + a1[1] * v7), a3, a1[1]);
return v9;
}
}
return (unsigned int)-1;
}

original_code:
int hmap_update(struct hmap *map, void *key, void *data)
{
 unsigned long i=0, index=map->hash(key)%map->map_size;
 unsigned char *aux_key=map->keys, *aux_data=map->data;
 while (!is_empty(aux_key+((index+i)%map->map_size)*(map->key_size),
    map->key_size)&&i!=map->map_size)
 {
  if (memcmp(aux_key+((index+i)%map->map_size)*(map->key_size),
    key, map->key_size) == 0)
  {
   memcpy(aux_data+((index+i)%map->map_size)*
     (map->data_size), data, map->data_size);
   return 0;
  }
  i++;
 }
 return -1;
}

canonical_original_code:
int hmap_update(struct hmap *map, void *key, void *data)
{
 unsigned long i = 0; unsigned long index = map->hash(key)%map->map_size;
 unsigned char *aux_key = map->keys; unsigned char *aux_data = map->data;
 while (!is_empty(aux_key+((index+i)%map->map_size)*(map->key_size),
    map->key_size)&&i!=map->map_size)
 {
  if (memcmp(aux_key+((index+i)%map->map_size)*(map->key_size),
    key, map->key_size) == 0)
  {
   memcpy(aux_data+((index+i)%map->map_size)*
     (map->data_size), data, map->data_size);
   return 0;
  }
  i++;
 }
 return -1;
}


decompiled_code:
int __fastcall hmap_print(unsigned __int64 *a1)
{
unsigned __int64 v1; // r13
unsigned __int64 v2; // r14
int result; // eax
unsigned __int64 v4; // rbx
__int64 v5; // r15
unsigned __int64 v6; // rax
unsigned __int64 i; // r12
unsigned __int64 v8; // r12

v1 = a1[3];
v2 = a1[4];
printf("Struct hmap at %p\n", a1);
result = printf("map_size=%lu key_size=%lu data_size=%lu\n", *a1, a1[2], a1[1]);
if ( *a1 )
{
v4 = 0LL;
do
{
v5 = a1[2];
if ( (unsigned __int8)is_empty((_BYTE *)(v1 + v4 * v5), v5) )
{
result = printf("Block %lu: empty\n", v4);
}
else if ( (unsigned __int8)is_deleted((_BYTE *)(v1 + v4 * v5), v5) )
{
result = printf("Block %lu: deleted\n", v4);
}
else
{
printf("Block %lu: key = ", v4);
v6 = a1[2];
if ( v6 )
{
for ( i = 0LL; i < v6; ++i )
{
printf("%u ", (unsigned int)*(char *)(v1 + i + v4 * v6));
v6 = a1[2];
}
}
printf("data = ");
if ( a1[2] )
{
v8 = 0LL;
do
printf("%u ", (unsigned int)*(char *)(v2 + v8++ + a1[1] * v4));
while ( a1[2] > v8 );
}
result = putchar(10);
}
++v4;
}
while ( *a1 > v4 );
}
return result;
}

canonical_decompiled_code:
int __fastcall func8(unsigned __int64 *a1)
{
unsigned __int64 v1; // r13
unsigned __int64 v2; // r14
int result; // eax
unsigned __int64 v4; // rbx
__int64 v5; // r15
unsigned __int64 v6; // rax
unsigned __int64 i; // r12
unsigned __int64 v8; // r12

v1 = a1[3];
v2 = a1[4];
printf("Struct hmap at %p\n", a1);
result = printf("map_size=%lu key_size=%lu data_size=%lu\n", *a1, a1[2], a1[1]);
if ( *a1 )
{
v4 = 0LL;
do
{
v5 = a1[2];
if ( (unsigned __int8)func0((_BYTE *)(v1 + v4 * v5), v5) )
{
result = printf("Block %lu: empty\n", v4);
}
else if ( (unsigned __int8)func1((_BYTE *)(v1 + v4 * v5), v5) )
{
result = printf("Block %lu: deleted\n", v4);
}
else
{
printf("Block %lu: key = ", v4);
v6 = a1[2];
if ( v6 )
{
for ( i = 0LL; i < v6; ++i )
{
printf("%u ", (unsigned int)*(char *)(v1 + i + v4 * v6));
v6 = a1[2];
}
}
printf("data = ");
if ( a1[2] )
{
v8 = 0LL;
do
printf("%u ", (unsigned int)*(char *)(v2 + v8++ + a1[1] * v4));
while ( a1[2] > v8 );
}
result = putchar(10);
}
++v4;
}
while ( *a1 > v4 );
}
return result;
}

original_code:
void hmap_print(struct hmap *map)
{
  unsigned long i, j;
 char *aux_key=map->keys, *aux_data=map->data;
  printf("Struct hmap at %p\n", (void *) map);
  printf("map_size=%lu    key_size=%lu    data_size=%lu\n", map->map_size,
        map->key_size, map->data_size);
 for (i=0; i<map->map_size; i++)
 {
  if (is_empty(aux_key+i*map->key_size,map->key_size))
   printf("Block %lu: empty\n", i);
  else if (is_deleted(aux_key+i*map->key_size,
    map->key_size))
   printf("Block %lu: deleted\n", i);
  else
  {
   printf("Block %lu: key = ", i);
   for (j=0; j<map->key_size; j++)
    printf("%u ", aux_key[i*map->key_size+j]);
   printf("data = ");
   for (j=0; j<map->key_size; j++)
    printf("%u ", aux_data[i*map->data_size+j]);
   printf("\n");
  }
 }
}

canonical_original_code:
void hmap_print(struct hmap *map)
{
  unsigned long i; unsigned long j;
 char *aux_key = map->keys; char *aux_data = map->data;
  printf("Struct hmap at %p\n", (void *) map);
  printf("map_size=%lu    key_size=%lu    data_size=%lu\n", map->map_size,
        map->key_size, map->data_size);
 for (i=0; i<map->map_size; i++)
 {
  if (is_empty(aux_key+i*map->key_size,map->key_size))
   printf("Block %lu: empty\n", i);
  else if (is_deleted(aux_key+i*map->key_size,
    map->key_size))
   printf("Block %lu: deleted\n", i);
  else
  {
   printf("Block %lu: key = ", i);
   for (j=0; j<map->key_size; j++)
    printf("%u ", aux_key[i*map->key_size+j]);
   printf("data = ");
   for (j=0; j<map->key_size; j++)
    printf("%u ", aux_data[i*map->data_size+j]);
   printf("\n");
  }
 }
}

variable_types:
j
unsigned long


calcula

decompiled_code:
void __fastcall __noreturn calcula(void *a1)
{
__int64 v1; // rax
int v2; // ebx
__int64 v3; // rbp
int v4; // eax
int v5; // eax
double v6; // [rsp+8h] [rbp-20h]

v1 = *(int *)a1;
dentroCircunferenciaParcial[v1] = 0LL;
TOTALParcial[v1] = 0LL;
v2 = 200000000;
v3 = v1;
while ( 1 )
{
++TOTALParcial[v3];
drand48();
v6 = (double)v4;
drand48();
if ( (double)v5 * (double)v5 + v6 * v6 <= 1.0 )
++dentroCircunferenciaParcial[v3];
if ( !--v2 )
pthread_exit(0LL);
}
}

canonical_decompiled_code:
void __fastcall __noreturn func7(void *a1)
{
__int64 v1; // rax
int v2; // ebx
__int64 v3; // rbp
int v4; // eax
int v5; // eax
double v6; // [rsp+8h] [rbp-20h]

v1 = *(int *)a1;
dentroCircunferenciaParcial[v1] = 0LL;
TOTALParcial[v1] = 0LL;
v2 = 200000000;
v3 = v1;
while ( 1 )
{
++TOTALParcial[v3];
drand48();
v6 = (double)v4;
drand48();
if ( (double)v5 * (double)v5 + v6 * v6 <= 1.0 )
++dentroCircunferenciaParcial[v3];
if ( !--v2 )
pthread_exit(0LL);
}
}

original_code:
void *calcula (void *param) {
 int i=0;
 int thrNum = *((int *)param);
 double x,y;
 dentroCircunferenciaParcial[thrNum] = 0;
 TOTALParcial[thrNum] = 0;
 for (i = 0; i<200000000; i++){
  TOTALParcial[thrNum]++;
  x = drand48();
  y = drand48();
  if((pow(x, 2) + pow(y,2)) <= 1.0)
   dentroCircunferenciaParcial[thrNum]++;
 }
 pthread_exit(0);
}

canonical_original_code:
void *calcula(void *param) {
 int i = 0;
 int thrNum = *((int *)param);
 double x; double y;
 dentroCircunferenciaParcial[thrNum] = 0;
 TOTALParcial[thrNum] = 0;
 for (i = 0; i<200000000; i++){
  TOTALParcial[thrNum]++;
  x = drand48();
  y = drand48();
  if((pow(x, 2) + pow(y,2)) <= 1.0)
   dentroCircunferenciaParcial[thrNum]++;
 }
 pthread_exit(0);
}

variable_types:
param
void *

variable_types: i int

variable_types: thrNum int

variable_types: x double

variable_types: y double

return_type: void *


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rax
char *v4; // r12
__int64 i; // rbp
pthread_t *v6; // rbx
__int64 j; // rbx
_QWORD v9[5]; // [rsp+0h] [rbp-C8h] BYREF
__int64 v10; // [rsp+28h] [rbp-A0h] BYREF
char arg; // [rsp+90h] [rbp-38h] BYREF

__gmpf_set_default_prec();
__gmpf_init();
__gmpf_init_set_d();
__gmpf_init_set_d();
v3 = time(0LL);
srand48(v3);
v4 = &arg;
for ( i = 0LL; i != 5; ++i )
{
*(_DWORD *)v4 = i;
v6 = v9;
pthread_create(&v9[i], 0LL, (void *(*)(void *))calcula, v4);
v4 += 4;
}
do
pthread_join(*v6++, 0LL);
while ( v6 != (pthread_t *)&v10 );
for ( j = 0LL; j != 40; j += 8LL )
{
__gmpf_add_ui();
__gmpf_add_ui();
}
__gmpf_div();
__gmpf_mul_ui();
__gmpf_out_str();
putchar(10);
__gmpf_clear();
__gmpf_clear();
__gmpf_clear();
return 0;
}

original_code:
int main(void){
 int cont, numThread[5];
 __gmpf_set_default_prec((long)(DIGITS*BITS_PER_DIGIT+16));
 mpf_t PI, dentroCircunferencia, TOTAL;
 pthread_t tID[5];
 __gmpf_init(PI);
 __gmpf_init_set_d(dentroCircunferencia, 0.0);
 __gmpf_init_set_d(TOTAL, 0.0);
 srand48(time(((void *)0)));
 for (cont = 0; cont< 5 ; cont++){
  numThread[cont] = cont;
  pthread_create (&tID[cont], ((void *)0), calcula, &numThread[cont]);
 }
 for (cont = 0; cont< 5 ; cont++)
  pthread_join (tID[cont], ((void *)0));
    for (cont = 0; cont< 5 ; cont++){
          __gmpf_add_ui(TOTAL, TOTAL, TOTALParcial[cont]);
          __gmpf_add_ui(dentroCircunferencia, dentroCircunferencia, dentroCircunferenciaParcial[cont]);
 }
 __gmpf_div (PI, dentroCircunferencia, TOTAL);
 __gmpf_mul_ui (PI, PI, 4);
 __gmpf_out_str(stdout, 10, DIGITS, PI);
 printf("\n");
 __gmpf_clear (PI);
 __gmpf_clear (TOTAL);
 __gmpf_clear (dentroCircunferencia);
 return 0;
}

canonical_original_code:
int main(){
 int cont; int numThread[5];
 __gmpf_set_default_prec((long)(DIGITS*BITS_PER_DIGIT+16));
 struct __mpf_struct PI[1]; struct __mpf_struct dentroCircunferencia[1]; struct __mpf_struct TOTAL[1];
 unsigned long tID[5];
 __gmpf_init(PI);
 __gmpf_init_set_d(dentroCircunferencia, 0.0);
 __gmpf_init_set_d(TOTAL, 0.0);
 srand48(time(((void *)0)));
 for (cont = 0; cont< 5 ; cont++){
  numThread[cont] = cont;
  pthread_create (&tID[cont], ((void *)0), calcula, &numThread[cont]);
 }
 for (cont = 0; cont< 5 ; cont++)
  pthread_join (tID[cont], ((void *)0));
    for (cont = 0; cont< 5 ; cont++){
          __gmpf_add_ui(TOTAL, TOTAL, TOTALParcial[cont]);
          __gmpf_add_ui(dentroCircunferencia, dentroCircunferencia, dentroCircunferenciaParcial[cont]);
 }
 __gmpf_div (PI, dentroCircunferencia, TOTAL);
 __gmpf_mul_ui (PI, PI, 4);
 __gmpf_out_str(stdout, 10, DIGITS, PI);
 printf("\n");
 __gmpf_clear (PI);
 __gmpf_clear (TOTAL);
 __gmpf_clear (dentroCircunferencia);
 return 0;
}

variable_types: cont int

variable_types:
numThread
int [5]

variable_types: struct __mpf_struct { int _mp_prec; int _mp_size; long _mp_exp; unsigned long *_mp_d; } [1]

variable_types:
tID
unsigned long [5]


qrand

decompiled_code:
__int64 qrand()
{
unsigned int v0; // edx
__int64 result; // rax

v0 = (qrand_x << 16) ^ qrand_x ^ (((qrand_x << 16) ^ (unsigned int)qrand_x) >> 5);
qrand_x = qrand_y;
qrand_y = qrand_z;
result = (2 * v0) ^ v0 ^ qrand_z ^ qrand_x;
qrand_z ^= (2 * v0) ^ v0 ^ qrand_x;
return result;
}

canonical_decompiled_code:
__int64 func0()
{
unsigned int v0; // edx
__int64 result; // rax

v0 = (qrand_x << 16) ^ qrand_x ^ (((qrand_x << 16) ^ (unsigned int)qrand_x) >> 5);
qrand_x = qrand_y;
qrand_y = qrand_z;
result = (2 * v0) ^ v0 ^ qrand_z ^ qrand_x;
qrand_z ^= (2 * v0) ^ v0 ^ qrand_x;
return result;
}

original_code:
static inline unsigned qrand(void)
{
 unsigned t;
 qrand_x ^= qrand_x<<16;
 qrand_x ^= qrand_x>>5;
 qrand_x ^= qrand_x<<1;
 t = qrand_x;
 qrand_x = qrand_y;
 qrand_y = qrand_z;
 qrand_z = t^qrand_x^qrand_y;
 return qrand_z; }

canonical_original_code:
static inline unsigned int qrand()
{
 unsigned int t;
 qrand_x ^= qrand_x<<16;
 qrand_x ^= qrand_x>>5;
 qrand_x ^= qrand_x<<1;
 t = qrand_x;
 qrand_x = qrand_y;
 qrand_y = qrand_z;
 qrand_z = t^qrand_x^qrand_y;
 return qrand_z; }

variable_types:
t
unsigned int

return_type: unsigned int


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

qrand_x ^= a1;
result = (unsigned int)(8 * a1);
qrand_y ^= result;
qrand_z ^= a1 << 7;
return result;
}

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

qrand_x ^= a1;
result = (unsigned int)(8 * a1);
qrand_y ^= result;
qrand_z ^= a1 << 7;
return result;
}

original_code:
void qrand_seed(unsigned seed)
{
 qrand_x ^= seed;
 qrand_y ^= seed<<3;
 qrand_z ^= seed<<7;
}

canonical_original_code:
void qrand_seed(unsigned int seed)
{
 qrand_x ^= seed;
 qrand_y ^= seed<<3;
 qrand_z ^= seed<<7;
}

variable_types:
seed
unsigned int


decompiled_code:
void __fastcall qrand_test(unsigned int a1, __int64 a2)
{
_DWORD *v2; // rbp
__int64 i; // rbx
__int64 v4; // rdx
__int64 j; // rbx

v2 = malloc(4LL * a1);
if ( a2 )
{
for ( i = 0LL; i != a2; ++i )
{
v4 = (unsigned int)qrand() % a1;
++v2[v4];
}
}
if ( a1 )
{
for ( j = 0LL; j != a1; ++j )
printf("At position %llu: %u.\n", j, (unsigned int)v2[j]);
}
free(v2);
}

canonical_decompiled_code:
void __fastcall func2(unsigned int a1, __int64 a2)
{
_DWORD *v2; // rbp
__int64 i; // rbx
__int64 v4; // rdx
__int64 j; // rbx

v2 = malloc(4LL * a1);
if ( a2 )
{
for ( i = 0LL; i != a2; ++i )
{
v4 = (unsigned int)func0() % a1;
++v2[v4];
}
}
if ( a1 )
{
for ( j = 0LL; j != a1; ++j )
printf("At position %llu: %u.\n", j, (unsigned int)v2[j]);
}
free(v2);
}

original_code:
void qrand_test(unsigned n, unsigned long long iterations)
{
 register unsigned long long i;
 unsigned *array;
 array = malloc(n*sizeof(unsigned));
 for (i=0; i<iterations; ++i)
  array[qrand()%n]+=1;
 for (i=0; i<n; i++)
 {
  printf("At position %llu: %u.\n", i, array[i]);
 }
 free(array);
}

canonical_original_code:
void qrand_test(unsigned int n, unsigned long long iterations)
{
 register unsigned long long i;
 unsigned int *array;
 array = malloc(n*sizeof(unsigned int));
 for (i=0; i<iterations; ++i)
  array[qrand()%n]+=1;
 for (i=0; i<n; i++)
 {
  printf("At position %llu: %u.\n", i, array[i]);
 }
 free(array);
}

variable_types:
n
unsigned int

variable_types:
iterations
unsigned long long

variable_types:
i
unsigned long long

variable_types:
array
unsigned int *


decompiled_code:
__int64 __fastcall qrand_word(_BYTE *a1)
{
unsigned int v2; // eax
unsigned int v3; // ecx
__int64 v4; // rdi
_BYTE *v5; // rsi
__int64 v6; // rdx
unsigned int v7; // eax
_BYTE *v8; // rbx
_BYTE *v9; // rbp
unsigned int v10; // eax
__int64 result; // rax

v2 = (unsigned int)((__int64 (*)(void))qrand)() % 0xBC8C10;
v3 = 5;
if ( v2 <= 0x74076 )
{
v3 = 4;
if ( v2 <= 0x4766 )
{
v3 = 3;
if ( v2 <= 0x2BE )
v3 = (v2 > 0x1A) + 1;
}
}
v4 = v3;
v5 = &a1[v3];
v6 = 6 - v3;
if ( v3 != 6 )
{
v7 = 0;
do
v5[v7++] = 0;
while ( v7 < (unsigned int)v6 );
}
v8 = a1;
v9 = &a1[v3];
do
{
v10 = qrand(v4, v5, v6);
v6 = 26 * (v10 / 0x1A);
result = v10 % 0x1A + 97;
*v8++ = result;
}
while ( v8 != v9 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(_BYTE *a1)
{
unsigned int v2; // eax
unsigned int v3; // ecx
__int64 v4; // rdi
_BYTE *v5; // rsi
__int64 v6; // rdx
unsigned int v7; // eax
_BYTE *v8; // rbx
_BYTE *v9; // rbp
unsigned int v10; // eax
__int64 result; // rax

v2 = (unsigned int)((__int64 (*)(void))qrand)() % 0xBC8C10;
v3 = 5;
if ( v2 <= 0x74076 )
{
v3 = 4;
if ( v2 <= 0x4766 )
{
v3 = 3;
if ( v2 <= 0x2BE )
v3 = (v2 > 0x1A) + 1;
}
}
v4 = v3;
v5 = &a1[v3];
v6 = 6 - v3;
if ( v3 != 6 )
{
v7 = 0;
do
v5[v7++] = 0;
while ( v7 < (unsigned int)v6 );
}
v8 = a1;
v9 = &a1[v3];
do
{
v10 = func0(v4, v5, v6);
v6 = 26 * (v10 / 0x1A);
result = v10 % 0x1A + 97;
*v8++ = result;
}
while ( v8 != v9 );
return result;
}

original_code:
void qrand_word(char *s)
{
 unsigned i, lenght;
 lenght = qrand()%12356624;
 if (lenght > 475254)
  lenght = 5;
 else if (lenght > 18278)
  lenght = 4;
 else if (lenght > 702)
  lenght = 3;
 else if (lenght > 26)
  lenght = 2;
 else
  lenght = 1;
 memset(s+lenght, '\0', 6-lenght);
 for (i=0; i<lenght; ++i)
 {
  s[i]='a'+(qrand())%26;
 }
 return;
}

canonical_original_code:
void qrand_word(char *s)
{
 unsigned int i; unsigned int lenght;
 lenght = qrand()%12356624;
 if (lenght > 475254)
  lenght = 5;
 else if (lenght > 18278)
  lenght = 4;
 else if (lenght > 702)
  lenght = 3;
 else if (lenght > 26)
  lenght = 2;
 else
  lenght = 1;
 memset(s+lenght, '\0', 6-lenght);
 for (i=0; i<lenght; ++i)
 {
  s[i]='a'+(qrand())%26;
 }
 return;
}

variable_types:
s
char *

variable_types:
i
unsigned int

variable_types:
lenght
unsigned int


calculatePI

decompiled_code:
void *__fastcall calculatePI(void *a1)
{
__gmpf_add();
__gmpf_pow_ui();
__gmpf_div();
__gmpf_div_ui();
return 0LL;
}

canonical_decompiled_code:
void *__fastcall func7(void *a1)
{
__gmpf_add();
__gmpf_pow_ui();
__gmpf_div();
__gmpf_div_ui();
return 0LL;
}

original_code:
void* calculatePI(void *gl)
{
    GaussLegendre *gauss = (GaussLegendre*)gl;
    __gmpf_add(gauss->PI.curValue, gauss->a.prevValue, gauss->b.prevValue);
    __gmpf_pow_ui(gauss->PI.curValue, gauss->PI.curValue, 2);
    __gmpf_div(gauss->PI.curValue, gauss->PI.curValue, gauss->t.prevValue);
    __gmpf_div_ui(gauss->PI.curValue, gauss->PI.curValue, 4);
    return (void*)0;
}

canonical_original_code:
void *calculatePI(void *gl)
{
    struct GaussLegendre *gauss = (GaussLegendre*)gl;
    __gmpf_add(gauss->PI.curValue, gauss->a.prevValue, gauss->b.prevValue);
    __gmpf_pow_ui(gauss->PI.curValue, gauss->PI.curValue, 2);
    __gmpf_div(gauss->PI.curValue, gauss->PI.curValue, gauss->t.prevValue);
    __gmpf_div_ui(gauss->PI.curValue, gauss->PI.curValue, 4);
    return (void *)0;
}

variable_types:
gl
void *

variable_types: struct GaussLegendre { struct BigNumber { struct __mpf_struct { int _mp_prec; int _mp_size; long _mp_exp; unsigned long *_mp_d; } prevValue[1]; struct __mpf_struct curValue[1]; } a; struct BigNumber b; struct BigNumber t; struct BigNumber p; struct BigNumber PI; } *

user_defined_types: struct GaussLegendre { struct BigNumber a; struct BigNumber b; struct BigNumber t; struct BigNumber p; struct BigNumber PI; }

user_defined_types: struct BigNumber { struct __mpf_struct prevValue[1]; struct __mpf_struct curValue[1]; }


updateA

decompiled_code:
void *__fastcall updateA(void *a1)
{
__gmpf_add();
__gmpf_div_ui();
return 0LL;
}

canonical_decompiled_code:
void *__fastcall func8(void *a1)
{
__gmpf_add();
__gmpf_div_ui();
return 0LL;
}

original_code:
void* updateA(void *gl)
{
    GaussLegendre *gauss = (GaussLegendre*)gl;
    __gmpf_add(gauss->a.curValue, gauss->a.prevValue, gauss->b.prevValue);
    __gmpf_div_ui(gauss->a.curValue, gauss->a.curValue, 2);
    return (void*)0;
}

canonical_original_code:
void *updateA(void *gl)
{
    struct GaussLegendre *gauss = (GaussLegendre*)gl;
    __gmpf_add(gauss->a.curValue, gauss->a.prevValue, gauss->b.prevValue);
    __gmpf_div_ui(gauss->a.curValue, gauss->a.curValue, 2);
    return (void *)0;
}

user_defined_types: struct __mpf_struct { int _mp_prec; int _mp_size; long _mp_exp; unsigned long *_mp_d; }


updateB

decompiled_code:
void *__fastcall updateB(void *a1)
{
__gmpf_mul();
__gmpf_sqrt();
return 0LL;
}

canonical_decompiled_code:
void *__fastcall func9(void *a1)
{
__gmpf_mul();
__gmpf_sqrt();
return 0LL;
}

original_code:
void* updateB(void *gl)
{
    GaussLegendre *gauss = (GaussLegendre*)gl;
    __gmpf_mul(gauss->b.curValue, gauss->b.prevValue, gauss->a.prevValue);
    __gmpf_sqrt(gauss->b.curValue, gauss->b.curValue);
    return (void*)0;
}

canonical_original_code:
void *updateB(void *gl)
{
    struct GaussLegendre *gauss = (GaussLegendre*)gl;
    __gmpf_mul(gauss->b.curValue, gauss->b.prevValue, gauss->a.prevValue);
    __gmpf_sqrt(gauss->b.curValue, gauss->b.curValue);
    return (void *)0;
}


updateP

decompiled_code:
void *__fastcall updateP(void *a1)
{
__gmpf_mul_ui();
return 0LL;
}

canonical_decompiled_code:
void *__fastcall func10(void *a1)
{
__gmpf_mul_ui();
return 0LL;
}

original_code:
void* updateP(void *gl)
{
    GaussLegendre *gauss = (GaussLegendre*)gl;
    __gmpf_mul_ui(gauss->p.curValue, gauss->p.prevValue, 2);
    return (void*)0;
}

canonical_original_code:
void *updateP(void *gl)
{
    struct GaussLegendre *gauss = (GaussLegendre*)gl;
    __gmpf_mul_ui(gauss->p.curValue, gauss->p.prevValue, 2);
    return (void *)0;
}


updateT

decompiled_code:
void *__fastcall updateT(void *a1)
{
__gmpf_sub();
__gmpf_pow_ui();
__gmpf_mul();
__gmpf_sub();
return 0LL;
}

canonical_decompiled_code:
void *__fastcall func11(void *a1)
{
__gmpf_sub();
__gmpf_pow_ui();
__gmpf_mul();
__gmpf_sub();
return 0LL;
}

original_code:
void* updateT(void *gl)
{
    GaussLegendre *gauss = (GaussLegendre*)gl;
    __gmpf_sub(gauss->t.curValue, gauss->a.prevValue, gauss->a.curValue);
    __gmpf_pow_ui(gauss->t.curValue, gauss->t.curValue, 2);
    __gmpf_mul(gauss->t.curValue, gauss->t.curValue, gauss->p.prevValue);
    __gmpf_sub(gauss->t.curValue, gauss->t.prevValue, gauss->t.curValue);
    return (void*)0;
}

canonical_original_code:
void *updateT(void *gl)
{
    struct GaussLegendre *gauss = (GaussLegendre*)gl;
    __gmpf_sub(gauss->t.curValue, gauss->a.prevValue, gauss->a.curValue);
    __gmpf_pow_ui(gauss->t.curValue, gauss->t.curValue, 2);
    __gmpf_mul(gauss->t.curValue, gauss->t.curValue, gauss->p.prevValue);
    __gmpf_sub(gauss->t.curValue, gauss->t.prevValue, gauss->t.curValue);
    return (void *)0;
}


initBigNumber

decompiled_code:
__int64 initBigNumber()
{
__gmpf_init();
return __gmpf_init();
}

canonical_decompiled_code:
__int64 func12()
{
__gmpf_init();
return __gmpf_init();
}

original_code:
void initBigNumber(BigNumber *bn)
{
    __gmpf_init(bn->prevValue);
    __gmpf_init(bn->curValue);
}

canonical_original_code:
void initBigNumber(struct BigNumber *bn)
{
    __gmpf_init(bn->prevValue);
    __gmpf_init(bn->curValue);
}

variable_types: struct BigNumber { struct __mpf_struct { int _mp_prec; int _mp_size; long _mp_exp; unsigned long *_mp_d; } prevValue[1]; struct __mpf_struct curValue[1]; } *


repo: kurt-gehlen/Testcode

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

if ( a2 <= a1[4] )
result = *(_QWORD *)&a1[2 * (a2 >> a1[1]) + 6] + a1[3] * (a2 & *a1);
else
result = 0LL;
return result;
}

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

if ( a2 <= a1[4] )
result = *(_QWORD *)&a1[2 * (a2 >> a1[1]) + 6] + a1[3] * (a2 & *a1);
else
result = 0LL;
return result;
}

original_code:
static inline void * SA_atIndex( SegArray * sa, unsigned int index )
{
 if( index > sa->numObjects )
  return 0;
 return (unsigned char *)sa->segments[index >> sa->shift] + (sa->objectSize * (index & sa->mask));
}

canonical_original_code:
static inline void *SA_atIndex(struct SegArray *sa, unsigned int index)
{
 if( index > sa->numObjects )
  return 0;
 return (unsigned char *)sa->segments[index >> sa->shift] + (sa->objectSize * (index & sa->mask));
}

variable_types: struct SegArray { unsigned int mask; unsigned int shift; int numSegments; int objectSize; unsigned int numObjects; void *segments[16]; } *

variable_types:
index
unsigned int


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

LOBYTE(result) = a1 && (a1 & (a1 - 1)) == 0;
return (unsigned __int8)result;
}

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

LOBYTE(result) = a1 && (a1 & (a1 - 1)) == 0;
return (unsigned __int8)result;
}

original_code:
static inline int isPowerOf2( unsigned int v )
{
 return v && !(v & (v - 1));
}

canonical_original_code:
static inline int isPowerOf2(unsigned int v)
{
 return v && !(v & (v - 1));
}

variable_types:
v
unsigned int


decompiled_code:
__int64 __fastcall logBase2(unsigned int a1)
{
unsigned int i; // [rsp+10h] [rbp-4h]

for ( i = 0; ; ++i )
{
a1 >>= 1;
if ( !a1 )
break;
}
return i;
}

canonical_decompiled_code:
__int64 __fastcall func9(unsigned int a1)
{
unsigned int i; // [rsp+10h] [rbp-4h]

for ( i = 0; ; ++i )
{
a1 >>= 1;
if ( !a1 )
break;
}
return i;
}

original_code:
static inline int logBase2( unsigned int v )
{
 int r = 0;
 while ( v >>= 1 )
  r++;
 return r;
}

canonical_original_code:
static inline int logBase2(unsigned int v)
{
 int r = 0;
 while ( v >>= 1 )
  r++;
 return r;
}

variable_types: r int


decompiled_code:
__int64 __fastcall SA_init(unsigned int *a1, int a2, int a3, unsigned int a4)
{
__int64 result; // rax
int v8; // [rsp+28h] [rbp-8h]
int i; // [rsp+2Ch] [rbp-4h]
int j; // [rsp+2Ch] [rbp-4h]

if ( !(unsigned int)isPowerOf2(a3) || !(unsigned int)isPowerOf2(a2) )
return 0xFFFFFFFFLL;
v8 = a2 / a3;
for ( i = 0; i < a3; ++i )
{
*(_QWORD *)&a1[2 * i + 6] = malloc((int)(a4 * (a2 / a3)));
if ( !*(_QWORD *)&a1[2 * i + 6] )
break;
}
if ( i == a3 )
{
a1[3] = a4;
a1[2] = a3;
a1[4] = a3 * v8;
*a1 = v8 - 1;
a1[1] = logBase2(*a1) + 1;
result = 0LL;
}
else
{
for ( j = i - 1; j >= 0; --j )
free(*(void **)&a1[2 * j + 6]);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(unsigned int *a1, int a2, int a3, unsigned int a4)
{
__int64 result; // rax
int v8; // [rsp+28h] [rbp-8h]
int i; // [rsp+2Ch] [rbp-4h]
int j; // [rsp+2Ch] [rbp-4h]

if ( !(unsigned int)func8(a3) || !(unsigned int)func8(a2) )
return 0xFFFFFFFFLL;
v8 = a2 / a3;
for ( i = 0; i < a3; ++i )
{
*(_QWORD *)&a1[2 * i + 6] = malloc((int)(a4 * (a2 / a3)));
if ( !*(_QWORD *)&a1[2 * i + 6] )
break;
}
if ( i == a3 )
{
a1[3] = a4;
a1[2] = a3;
a1[4] = a3 * v8;
*a1 = v8 - 1;
a1[1] = func9(*a1) + 1;
result = 0LL;
}
else
{
for ( j = i - 1; j >= 0; --j )
free(*(void **)&a1[2 * j + 6]);
result = 0LL;
}
return result;
}

original_code:
static inline int
SA_init( SegArray * sa, int numObjects, int numSegments, int objectSize )
{
 if ( !isPowerOf2(numSegments) || !isPowerOf2(numObjects) )
  return -1;
 int perSegment = (numObjects / numSegments);
 int segmentSize = perSegment * objectSize;
 int i;
 for ( i = 0; i < numSegments; ++i )
 {
  if ( !(sa->segments[i] = malloc( segmentSize )) )
   break;
 }
 if ( i == numSegments )
 {
  sa->objectSize = objectSize;
  sa->numSegments = numSegments;
  sa->numObjects = perSegment * numSegments;
  sa->mask = perSegment - 1;
  sa->shift = logBase2( sa->mask ) + 1;
  return 0;
 }
 for ( --i; i >= 0; --i )
  free( sa->segments[i] );
 return 0;
}

canonical_original_code:
static inline int SA_init(struct SegArray *sa, int numObjects, int numSegments, int objectSize)
{
 if ( !isPowerOf2(numSegments) || !isPowerOf2(numObjects) )
  return -1;
 int perSegment = (numObjects / numSegments);
 int segmentSize = perSegment * objectSize;
 int i;
 for ( i = 0; i < numSegments; ++i )
 {
  if ( !(sa->segments[i] = malloc( segmentSize )) )
   break;
 }
 if ( i == numSegments )
 {
  sa->objectSize = objectSize;
  sa->numSegments = numSegments;
  sa->numObjects = perSegment * numSegments;
  sa->mask = perSegment - 1;
  sa->shift = logBase2( sa->mask ) + 1;
  return 0;
 }
 for ( --i; i >= 0; --i )
  free( sa->segments[i] );
 return 0;
}

variable_types: numObjects int

variable_types: numSegments int

variable_types: objectSize int

variable_types: perSegment int

variable_types: segmentSize int

variable_types: i int

user_defined_types: struct SegArray { unsigned int mask; unsigned int shift; int numSegments; int objectSize; unsigned int numObjects; void *segments[16]; }


original_code:
int
SAL_init( SegArrayList * sal, SegArray * sa, int head, int offset )
{
 memset( sal, sizeof(sal), 0 );
 sal->array = sa;
 sal->head = head;
 sal->offset = offset;
 sal->headPtr = sal_fromIndex( sal, head );
 sal->headPtr->next = sal->headPtr->prev = head;
 sal->count = 0;
 return 0;
}

canonical_original_code:
int SAL_init(struct SegArrayList *sal, struct SegArray *sa, int head, int offset)
{
 memset( sal, sizeof(sal), 0 );
 sal->array = sa;
 sal->head = head;
 sal->offset = offset;
 sal->headPtr = sal_fromIndex( sal, head );
 sal->headPtr->next = sal->headPtr->prev = head;
 sal->count = 0;
 return 0;
}

variable_types: struct SegArrayList { struct SegArray { unsigned int mask; unsigned int shift; int numSegments; int objectSize; unsigned int numObjects; void *segments[16]; } *array; int count; int offset; int head; struct SAL_Node { int prev; int next; } *headPtr; } *

variable_types:
sa
struct SegArray *

variable_types: head int

variable_types: offset int

user_defined_types: struct SegArrayList { struct SegArray *array; int count; int offset; int head; struct SAL_Node *headPtr; }


decompiled_code:
__int64 __fastcall SAL_insert(__int64 a1, unsigned int a2, unsigned int a3)
{
__int64 v4; // r13
__int64 v5; // rbp
unsigned int v6; // er15
_DWORD *v7; // rax

v4 = sal_fromIndex(a1, a2);
v5 = sal_fromIndex(a1, a3);
if ( !(v5 | v4) )
return 0xFFFFFFFFLL;
v6 = *(_DWORD *)(v5 + 4);
v7 = (_DWORD *)sal_fromIndex(a1, v6);
if ( !v7 )
return 0xFFFFFFFFLL;
*(_DWORD *)(v4 + 4) = v6;
*(_DWORD *)v4 = a3;
*v7 = a2;
*(_DWORD *)(v5 + 4) = a2;
++*(_DWORD *)(a1 + 8);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func16(__int64 a1, unsigned int a2, unsigned int a3)
{
__int64 v4; // r13
__int64 v5; // rbp
unsigned int v6; // er15
_DWORD *v7; // rax

v4 = func14(a1, a2);
v5 = func14(a1, a3);
if ( !(v5 | v4) )
return 0xFFFFFFFFLL;
v6 = *(_DWORD *)(v5 + 4);
v7 = (_DWORD *)func14(a1, v6);
if ( !v7 )
return 0xFFFFFFFFLL;
*(_DWORD *)(v4 + 4) = v6;
*(_DWORD *)v4 = a3;
*v7 = a2;
*(_DWORD *)(v5 + 4) = a2;
++*(_DWORD *)(a1 + 8);
return 0LL;
}

original_code:
int
SAL_insert( SegArrayList * sal, int toInsert, int toInsertAfter )
{
 SAL_Node * newNode = sal_fromIndex( sal, toInsert );
 SAL_Node * oldNode = sal_fromIndex( sal, toInsertAfter );
 if ( !newNode && !oldNode )
  return -1;
 SAL_Node * oldNext = sal_fromIndex( sal, oldNode->next );
 if ( !oldNext )
  return -1;
 newNode->next = oldNode->next;
 newNode->prev = toInsertAfter;
 oldNext->prev = toInsert;
 oldNode->next = toInsert;
 sal->count++;
 return 0;
}

canonical_original_code:
int SAL_insert(struct SegArrayList *sal, int toInsert, int toInsertAfter)
{
 struct SAL_Node *newNode = sal_fromIndex( sal, toInsert );
 struct SAL_Node *oldNode = sal_fromIndex( sal, toInsertAfter );
 if ( !newNode && !oldNode )
  return -1;
 struct SAL_Node *oldNext = sal_fromIndex( sal, oldNode->next );
 if ( !oldNext )
  return -1;
 newNode->next = oldNode->next;
 newNode->prev = toInsertAfter;
 oldNext->prev = toInsert;
 oldNode->next = toInsert;
 sal->count++;
 return 0;
}

variable_types: toInsert int

variable_types: toInsertAfter int

variable_types: struct SAL_Node { int prev; int next; } *


decompiled_code:
__int64 __fastcall SAL_insertHead(__int64 a1, unsigned int a2)
{
return SAL_insert(a1, a2, *(_DWORD *)(a1 + 16));
}

canonical_decompiled_code:
__int64 __fastcall func17(__int64 a1, unsigned int a2)
{
return func16(a1, a2, *(_DWORD *)(a1 + 16));
}

original_code:
int
SAL_insertHead( SegArrayList * sal, int index )
{
 return SAL_insert( sal, index, sal->head );
}

canonical_original_code:
int SAL_insertHead(struct SegArrayList *sal, int index)
{
 return SAL_insert( sal, index, sal->head );
}

variable_types: index int


decompiled_code:
__int64 __fastcall SAL_insertTail(__int64 a1, unsigned int a2)
{
return SAL_insert(a1, a2, **(_DWORD **)(a1 + 24));
}

canonical_decompiled_code:
__int64 __fastcall func18(__int64 a1, unsigned int a2)
{
return func16(a1, a2, **(_DWORD **)(a1 + 24));
}

original_code:
int
SAL_insertTail( SegArrayList * sal, int index )
{
 return SAL_insert( sal, index, sal->headPtr->prev );
}

canonical_original_code:
int SAL_insertTail(struct SegArrayList *sal, int index)
{
 return SAL_insert( sal, index, sal->headPtr->prev );
}


decompiled_code:
unsigned int *__fastcall SAL_remove(__int64 a1, unsigned int a2)
{
unsigned int *v2; // rax
unsigned int *v3; // rbx
__int64 v4; // r12
unsigned int v5; // er13
_DWORD *v6; // rax

if ( !*(_DWORD *)(a1 + 8) )
return 0LL;
v2 = (unsigned int *)sal_fromIndex(a1, a2);
v3 = v2;
if ( v2 )
{
v4 = sal_fromIndex(a1, *v2);
v5 = v3[1];
v6 = (_DWORD *)sal_fromIndex(a1, v5);
if ( v4 && v6 )
{
*(_DWORD *)(v4 + 4) = v5;
*v6 = *v3;
--*(_DWORD *)(a1 + 8);
*v3 = -1;
v3[1] = -1;
v3 = (unsigned int *)((char *)v3 - *(int *)(a1 + 12));
}
else
{
v3 = 0LL;
}
}
return v3;
}

canonical_decompiled_code:
unsigned int *__fastcall func19(__int64 a1, unsigned int a2)
{
unsigned int *v2; // rax
unsigned int *v3; // rbx
__int64 v4; // r12
unsigned int v5; // er13
_DWORD *v6; // rax

if ( !*(_DWORD *)(a1 + 8) )
return 0LL;
v2 = (unsigned int *)func14(a1, a2);
v3 = v2;
if ( v2 )
{
v4 = func14(a1, *v2);
v5 = v3[1];
v6 = (_DWORD *)func14(a1, v5);
if ( v4 && v6 )
{
*(_DWORD *)(v4 + 4) = v5;
*v6 = *v3;
--*(_DWORD *)(a1 + 8);
*v3 = -1;
v3[1] = -1;
v3 = (unsigned int *)((char *)v3 - *(int *)(a1 + 12));
}
else
{
v3 = 0LL;
}
}
return v3;
}

original_code:
void *
SAL_remove( SegArrayList * sal, int index )
{
 if ( sal->count == 0 )
  return 0;
 SAL_Node * node = sal_fromIndex( sal, index );
 if ( !node )
  return 0;
 SAL_Node * prev = sal_fromIndex( sal, node->prev );
 SAL_Node * next = sal_fromIndex( sal, node->next );
 if ( !(prev && next ) )
  return 0;
 prev->next = node->next;
 next->prev = node->prev;
 sal->count--;
 node->next = node->prev = -1;
 return (void*)node - sal->offset;
}

canonical_original_code:
void *SAL_remove(struct SegArrayList *sal, int index)
{
 if ( sal->count == 0 )
  return 0;
 struct SAL_Node *node = sal_fromIndex( sal, index );
 if ( !node )
  return 0;
 struct SAL_Node *prev = sal_fromIndex( sal, node->prev );
 struct SAL_Node *next = sal_fromIndex( sal, node->next );
 if ( !(prev && next ) )
  return 0;
 prev->next = node->next;
 next->prev = node->prev;
 sal->count--;
 node->next = node->prev = -1;
 return (void *)node - sal->offset;
}


decompiled_code:
unsigned int *__fastcall SAL_removeNode(__int64 a1, unsigned int *a2)
{
__int64 v2; // rax

v2 = sal_fromIndex(a1, *a2);
return SAL_remove(a1, *(_DWORD *)(v2 + 4));
}

canonical_decompiled_code:
unsigned int *__fastcall func20(__int64 a1, unsigned int *a2)
{
__int64 v2; // rax

v2 = func14(a1, *a2);
return func19(a1, *(_DWORD *)(v2 + 4));
}

original_code:
void *
SAL_removeNode( SegArrayList * sal, SAL_Node * node, int * index )
{
 SAL_Node * prev = sal_fromIndex( sal, node->prev );
 return SAL_remove( sal, prev->next );
}

canonical_original_code:
void *SAL_removeNode(struct SegArrayList *sal, struct SAL_Node *node, int *index)
{
 struct SAL_Node *prev = sal_fromIndex( sal, node->prev );
 return SAL_remove( sal, prev->next );
}

variable_types:
node
struct SAL_Node *

variable_types:
index
int *


decompiled_code:
unsigned int *__fastcall SAL_removeHead(__int64 a1, _DWORD *a2)
{
if ( a2 )
*a2 = *(_DWORD *)(*(_QWORD *)(a1 + 24) + 4LL);
return SAL_remove(a1, *(_DWORD *)(*(_QWORD *)(a1 + 24) + 4LL));
}

canonical_decompiled_code:
unsigned int *__fastcall func21(__int64 a1, _DWORD *a2)
{
if ( a2 )
*a2 = *(_DWORD *)(*(_QWORD *)(a1 + 24) + 4LL);
return func19(a1, *(_DWORD *)(*(_QWORD *)(a1 + 24) + 4LL));
}

original_code:
void *
SAL_removeHead( SegArrayList * sal, int * index )
{
 if ( index )
  *index = sal->headPtr->next;
 return SAL_remove( sal, sal->headPtr->next );
}

canonical_original_code:
void *SAL_removeHead(struct SegArrayList *sal, int *index)
{
 if ( index )
  *index = sal->headPtr->next;
 return SAL_remove( sal, sal->headPtr->next );
}


decompiled_code:
unsigned int *__fastcall SAL_removeTail(__int64 a1, _DWORD *a2)
{
if ( a2 )
*a2 = **(_DWORD **)(a1 + 24);
return SAL_remove(a1, **(_DWORD **)(a1 + 24));
}

canonical_decompiled_code:
unsigned int *__fastcall func22(__int64 a1, _DWORD *a2)
{
if ( a2 )
*a2 = **(_DWORD **)(a1 + 24);
return func19(a1, **(_DWORD **)(a1 + 24));
}

original_code:
void *
SAL_removeTail( SegArrayList * sal, int * index )
{
 if ( index )
  *index = sal->headPtr->prev;
 return SAL_remove( sal, sal->headPtr->prev );
}

canonical_original_code:
void *SAL_removeTail(struct SegArrayList *sal, int *index)
{
 if ( index )
  *index = sal->headPtr->prev;
 return SAL_remove( sal, sal->headPtr->prev );
}


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

if ( a1[4] < a2 )
result = 0LL;
else
result = *(_QWORD *)&a1[2 * (a2 >> a1[1]) + 6] + a1[3] * (*a1 & a2);
return result;
}

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

if ( a1[4] < a2 )
result = 0LL;
else
result = *(_QWORD *)&a1[2 * (a2 >> a1[1]) + 6] + a1[3] * (*a1 & a2);
return result;
}

variable_types: struct SegArray { unsigned int mask; unsigned int shift; int numSegments; int objectSize; unsigned int numObjects; void *segments[16]; } *

variable_types:
index
unsigned int


original_code:
int
SCH_init( SC_Hashtable * ht, int tablesize, int objectsize, SegArray * array, HASHFUNC hash, COMPFUNC comp, ALLOCFUNC alloc, FREEFUNC dealloc, DELFUNC del )
{
 if ( (ht->table = (int *)malloc( tablesize * sizeof(int *) )) )
 {
  ht->tablesize = tablesize;
  ht->array = array;
  ht->objsize = objectsize;
  ht->count = 0;
  ht->maxdepth = 0;
  ht->hash = hash;
  ht->comp = comp;
  ht->del = del;
  ht->alloc = alloc;
  ht->dealloc = dealloc;
  int i;
  for ( i = 0; i < tablesize; ++i )
   ht->table[i] = -1;
  return 0;
 }
 return -1;
}

canonical_original_code:
int SCH_init(struct SC_Hashtable *ht, int tablesize, int objectsize, struct SegArray *array, unsigned long (*hash)(void *), int (*comp)(void *, void *), int (*alloc)(), void (*dealloc)(int), void (*del)(void *))
{
 if ( (ht->table = (int *)malloc( tablesize * sizeof(int *) )) )
 {
  ht->tablesize = tablesize;
  ht->array = array;
  ht->objsize = objectsize;
  ht->count = 0;
  ht->maxdepth = 0;
  ht->hash = hash;
  ht->comp = comp;
  ht->del = del;
  ht->alloc = alloc;
  ht->dealloc = dealloc;
  int i;
  for ( i = 0; i < tablesize; ++i )
   ht->table[i] = -1;
  return 0;
 }
 return -1;
}

variable_types: struct SC_Hashtable { int tablesize; int objsize; int count; int *table; struct SegArray { unsigned int mask; unsigned int shift; int numSegments; int objectSize; unsigned int numObjects; void *segments[16]; } *array; int maxdepth; unsigned long (*hash)(void *); int (*comp)(void *, void *); void (*del)(void *); int (*alloc)(); void (*dealloc)(int); } *

variable_types: tablesize int

variable_types: objectsize int

variable_types:
array
struct SegArray *

variable_types:
hash
unsigned long (*)(void *)

variable_types:
comp
int (*)(void *, void *)

variable_types:
alloc
int (*)()

variable_types:
dealloc
void (*)(int)

variable_types:
del
void (*)(void *)

user_defined_types: struct SC_Hashtable { int tablesize; int objsize; int count; int *table; struct SegArray *array; int maxdepth; unsigned long (*hash)(void *); int (*comp)(void *, void *); void (*del)(void *); int (*alloc)(); void (*dealloc)(int); }


decompiled_code:
void __fastcall SCH_delete(__int64 a1)
{
__int64 v1; // r12
unsigned int v2; // esi
unsigned int *v3; // rbx
void (__fastcall *v4)(unsigned int *); // rax
void *v5; // rdi

if ( *(int *)a1 > 0 )
{
v1 = 0LL;
do
{
v2 = *(_DWORD *)(*(_QWORD *)(a1 + 16) + 4 * v1);
if ( v2 != -1 )
{
do
{
v3 = (unsigned int *)SA_atIndex(*(_DWORD **)(a1 + 24), v2);
v4 = *(void (__fastcall **)(unsigned int *))(a1 + 56);
if ( v4 )
v4(v3 + 1);
v2 = *v3;
}
while ( *v3 != -1 );
}
++v1;
}
while ( *(_DWORD *)a1 > (int)v1 );
}
v5 = *(void **)(a1 + 16);
if ( v5 )
free(v5);
}

canonical_decompiled_code:
void __fastcall func2(__int64 a1)
{
__int64 v1; // r12
unsigned int v2; // esi
unsigned int *v3; // rbx
void (__fastcall *v4)(unsigned int *); // rax
void *v5; // rdi

if ( *(int *)a1 > 0 )
{
v1 = 0LL;
do
{
v2 = *(_DWORD *)(*(_QWORD *)(a1 + 16) + 4 * v1);
if ( v2 != -1 )
{
do
{
v3 = (unsigned int *)func0(*(_DWORD **)(a1 + 24), v2);
v4 = *(void (__fastcall **)(unsigned int *))(a1 + 56);
if ( v4 )
v4(v3 + 1);
v2 = *v3;
}
while ( *v3 != -1 );
}
++v1;
}
while ( *(_DWORD *)a1 > (int)v1 );
}
v5 = *(void **)(a1 + 16);
if ( v5 )
free(v5);
}

original_code:
void
SCH_delete( SC_Hashtable * ht )
{
 int i;
 for ( i = 0; i < ht->tablesize; ++i )
 {
  int index = ht->table[i];
  while ( index != -1 )
  {
   int * object = SA_atIndex( ht->array, index );
   if( ht->del )
    ht->del( object + 1 );
   index = *object;
  }
 }
 if ( ht->table )
  free(ht->table);
}

canonical_original_code:
void SCH_delete(struct SC_Hashtable *ht)
{
 int i;
 for ( i = 0; i < ht->tablesize; ++i )
 {
  int index = ht->table[i];
  while ( index != -1 )
  {
   int *object = SA_atIndex( ht->array, index );
   if( ht->del )
    ht->del( object + 1 );
   index = *object;
  }
 }
 if ( ht->table )
  free(ht->table);
}

variable_types: i int

variable_types:
object
int *


decompiled_code:
unsigned int *__fastcall SCH_find(int *a1, __int64 a2)
{
unsigned __int64 v2; // rax
unsigned int *v3; // rbx
unsigned int *v4; // r13
int v5; // eax

v2 = (*((__int64 (__fastcall **)(__int64))a1 + 5))(a2);
v3 = (unsigned int *)SA_atIndex(*((_DWORD **)a1 + 3), *(_DWORD *)(*((_QWORD *)a1 + 2) + 4 * (v2 % *a1)));
if ( !v3 )
return 0LL;
while ( 1 )
{
v4 = v3 + 1;
v5 = (*((__int64 (__fastcall **)(__int64, unsigned int *))a1 + 6))(a2, v3 + 1);
if ( v5 >= 0 )
break;
v3 = (unsigned int *)SA_atIndex(*((_DWORD **)a1 + 3), *v3);
if ( !v3 )
return 0LL;
}
if ( v5 )
v4 = 0LL;
return v4;
}

canonical_decompiled_code:
unsigned int *__fastcall func3(int *a1, __int64 a2)
{
unsigned __int64 v2; // rax
unsigned int *v3; // rbx
unsigned int *v4; // r13
int v5; // eax

v2 = (*((__int64 (__fastcall **)(__int64))a1 + 5))(a2);
v3 = (unsigned int *)func0(*((_DWORD **)a1 + 3), *(_DWORD *)(*((_QWORD *)a1 + 2) + 4 * (v2 % *a1)));
if ( !v3 )
return 0LL;
while ( 1 )
{
v4 = v3 + 1;
v5 = (*((__int64 (__fastcall **)(__int64, unsigned int *))a1 + 6))(a2, v3 + 1);
if ( v5 >= 0 )
break;
v3 = (unsigned int *)func0(*((_DWORD **)a1 + 3), *v3);
if ( !v3 )
return 0LL;
}
if ( v5 )
v4 = 0LL;
return v4;
}

original_code:
void *
SCH_find( SC_Hashtable * ht, void * item )
{
 unsigned long hash_value = ht->hash( item );
 hash_value %= ht->tablesize;
 int * node;
 int v;
 for ( node = SA_atIndex(ht->array,ht->table[hash_value]); node && (v = ht->comp(item,node + 1)) < 0; node = SA_atIndex(ht->array,*node) )
  ;
 if ( node && v == 0 )
  return node + 1;
 return 0;
}

canonical_original_code:
void *SCH_find(struct SC_Hashtable *ht, void *item)
{
 unsigned long hash_value = ht->hash( item );
 hash_value %= ht->tablesize;
 int *node;
 int v;
 for ( node = SA_atIndex(ht->array,ht->table[hash_value]); node && (v = ht->comp(item,node + 1)) < 0; node = SA_atIndex(ht->array,*node) )
  ;
 if ( node && v == 0 )
  return node + 1;
 return 0;
}

variable_types:
item
void *

variable_types:
node
int *

variable_types: v int


decompiled_code:
__int64 __fastcall SCH_remove(int *a1, __int64 a2, void *a3)
{
unsigned int *v4; // r14
unsigned int *v5; // rbx
int v6; // eax
__int64 v7; // rax
void (__fastcall *v8)(unsigned int *); // rax
unsigned int v9; // er12

v4 = (unsigned int *)(*((_QWORD *)a1 + 2)
+ 4 * ((*((__int64 (__fastcall **)(__int64))a1 + 5))(a2) % (unsigned __int64)*a1));
v5 = (unsigned int *)SA_atIndex(*((_DWORD **)a1 + 3), *v4);
if ( !v5 )
return 0LL;
while ( 1 )
{
v6 = (*((__int64 (__fastcall **)(__int64, unsigned int *))a1 + 6))(a2, v5 + 1);
if ( v6 >= 0 )
break;
v7 = SA_atIndex(*((_DWORD **)a1 + 3), *v5);
v4 = v5;
if ( !v7 )
return 0LL;
v5 = (unsigned int *)v7;
}
if ( v6 )
return 0LL;
if ( a3 )
memcpy(a3, v5 + 1, a1[1]);
v8 = (void (__fastcall *)(unsigned int *))*((_QWORD *)a1 + 7);
if ( v8 )
v8(v5 + 1);
v9 = *v5;
*v5 = -1;
(*((void (__fastcall **)(_QWORD))a1 + 9))(*v4);
*v4 = v9;
--a1[2];
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(int *a1, __int64 a2, void *a3)
{
unsigned int *v4; // r14
unsigned int *v5; // rbx
int v6; // eax
__int64 v7; // rax
void (__fastcall *v8)(unsigned int *); // rax
unsigned int v9; // er12

v4 = (unsigned int *)(*((_QWORD *)a1 + 2)
+ 4 * ((*((__int64 (__fastcall **)(__int64))a1 + 5))(a2) % (unsigned __int64)*a1));
v5 = (unsigned int *)func0(*((_DWORD **)a1 + 3), *v4);
if ( !v5 )
return 0LL;
while ( 1 )
{
v6 = (*((__int64 (__fastcall **)(__int64, unsigned int *))a1 + 6))(a2, v5 + 1);
if ( v6 >= 0 )
break;
v7 = func0(*((_DWORD **)a1 + 3), *v5);
v4 = v5;
if ( !v7 )
return 0LL;
v5 = (unsigned int *)v7;
}
if ( v6 )
return 0LL;
if ( a3 )
memcpy(a3, v5 + 1, a1[1]);
v8 = (void (__fastcall *)(unsigned int *))*((_QWORD *)a1 + 7);
if ( v8 )
v8(v5 + 1);
v9 = *v5;
*v5 = -1;
(*((void (__fastcall **)(_QWORD))a1 + 9))(*v4);
*v4 = v9;
--a1[2];
return 1LL;
}

original_code:
int
SCH_remove( SC_Hashtable * ht, void * item, void * copy )
{
 unsigned long hash_value = ht->hash( item );
 hash_value %= ht->tablesize;
 int v;
 int * prev = &ht->table[hash_value];
 int * node;
 for ( node = SA_atIndex(ht->array,ht->table[hash_value]); node && (v = ht->comp(item,node + 1)) < 0; node = SA_atIndex(ht->array,*node) )
  prev = node;
 if ( !node || v != 0 )
  return 0;
 if ( copy )
  memcpy( copy, node + 1, ht->objsize );
 if ( ht->del )
  ht->del( node + 1 );
 int next = *node;
 *node = -1;
 ht->dealloc( *prev );
 *prev = next;
 ht->count--;
 return 1;
}

canonical_original_code:
int SCH_remove(struct SC_Hashtable *ht, void *item, void *copy)
{
 unsigned long hash_value = ht->hash( item );
 hash_value %= ht->tablesize;
 int v;
 int *prev = &ht->table[hash_value];
 int *node;
 for ( node = SA_atIndex(ht->array,ht->table[hash_value]); node && (v = ht->comp(item,node + 1)) < 0; node = SA_atIndex(ht->array,*node) )
  prev = node;
 if ( !node || v != 0 )
  return 0;
 if ( copy )
  memcpy( copy, node + 1, ht->objsize );
 if ( ht->del )
  ht->del( node + 1 );
 int next = *node;
 *node = -1;
 ht->dealloc( *prev );
 *prev = next;
 ht->count--;
 return 1;
}

variable_types:
copy
void *

variable_types:
prev
int *

variable_types: next int


decompiled_code:
int __fastcall SCH_iterate(__int64 a1, void (__fastcall *a2)(unsigned int *, _QWORD))
{
__int64 v2; // rax
__int64 v3; // r15
unsigned int v4; // ebp
unsigned int *v5; // rbx
__int64 v7; // [rsp+0h] [rbp-40h]

LODWORD(v2) = *(_DWORD *)a1;
if ( *(int *)a1 > 0 )
{
v7 = (unsigned int)v2;
v3 = 0LL;
do
{
v2 = SA_atIndex(*(_DWORD **)(a1 + 24), *(_DWORD *)(*(_QWORD *)(a1 + 16) + 4 * v3));
v5 = (unsigned int *)v2;
if ( v2 )
{
v4 = 0;
do
{
++v4;
a2(v5 + 1, (unsigned int)v3);
v2 = SA_atIndex(*(_DWORD **)(a1 + 24), *v5);
v5 = (unsigned int *)v2;
}
while ( v2 );
}
else
{
v4 = 0;
}
if ( *(_DWORD *)(a1 + 32) < (signed int)v4 )
LODWORD(v2) = printf("bad cnt %d at %d\n", v4, (unsigned int)v3);
++v3;
}
while ( v3 != v7 );
}
return v2;
}

canonical_decompiled_code:
int __fastcall func5(__int64 a1, void (__fastcall *a2)(unsigned int *, _QWORD))
{
__int64 v2; // rax
__int64 v3; // r15
unsigned int v4; // ebp
unsigned int *v5; // rbx
__int64 v7; // [rsp+0h] [rbp-40h]

LODWORD(v2) = *(_DWORD *)a1;
if ( *(int *)a1 > 0 )
{
v7 = (unsigned int)v2;
v3 = 0LL;
do
{
v2 = func0(*(_DWORD **)(a1 + 24), *(_DWORD *)(*(_QWORD *)(a1 + 16) + 4 * v3));
v5 = (unsigned int *)v2;
if ( v2 )
{
v4 = 0;
do
{
++v4;
a2(v5 + 1, (unsigned int)v3);
v2 = func0(*(_DWORD **)(a1 + 24), *v5);
v5 = (unsigned int *)v2;
}
while ( v2 );
}
else
{
v4 = 0;
}
if ( *(_DWORD *)(a1 + 32) < (signed int)v4 )
LODWORD(v2) = printf("bad cnt %d at %d\n", v4, (unsigned int)v3);
++v3;
}
while ( v3 != v7 );
}
return v2;
}

original_code:
void
SCH_iterate( SC_Hashtable * ht, OPFUNC op )
{
 int i, size = ht->tablesize;
 for ( i = 0; i < size; ++i )
 {
  int * node;
  int cnt = 0;
  for ( node = SA_atIndex(ht->array,ht->table[i]); node; node = SA_atIndex(ht->array,*node) )
  {
   cnt++;
   op( node + 1, i );
  }
  if ( cnt > ht->maxdepth )
   printf("bad cnt %d at %d\n",cnt,i);
 }
}

canonical_original_code:
void SCH_iterate(struct SC_Hashtable *ht, int (*op)(void *, int))
{
 int i; int size = ht->tablesize;
 for ( i = 0; i < size; ++i )
 {
  int *node;
  int cnt = 0;
  for ( node = SA_atIndex(ht->array,ht->table[i]); node; node = SA_atIndex(ht->array,*node) )
  {
   cnt++;
   op( node + 1, i );
  }
  if ( cnt > ht->maxdepth )
   printf("bad cnt %d at %d\n",cnt,i);
 }
}

variable_types: struct SC_Hashtable { int tablesize; int objsize; int count; int *table; struct SegArray { unsigned int mask; unsigned int shift; int numSegments; int objectSize; unsigned int numObjects; void *segments[16]; } *array; int maxdepth; unsigned long (*hash)(void *); int (*comp)(void *, void *); void (*del)(void *); int (*alloc)(); void (*dealloc)(int); } *

variable_types:
op
int (*)(void *, int)

variable_types: size int

variable_types: cnt int


decompiled_code:
__int64 __fastcall SCH_first(__int64 a1, int *a2)
{
unsigned int *v2; // rbx
int v3; // er12
_DWORD *v4; // r13
int v5; // ebp
__int64 v6; // rax
__int64 result; // rax

v2 = *(unsigned int **)(a1 + 16);
v3 = *(_DWORD *)a1;
if ( *(int *)a1 <= 0 )
{
v3 = 0;
LABEL_5:
*a2 = v3;
result = 0LL;
}
else
{
v4 = *(_DWORD **)(a1 + 24);
v5 = 0;
while ( 1 )
{
v6 = SA_atIndex(v4, *v2);
if ( v6 )
break;
++v5;
++v2;
if ( v3 == v5 )
goto LABEL_5;
}
*a2 = v5;
result = v6 + 4;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, int *a2)
{
unsigned int *v2; // rbx
int v3; // er12
_DWORD *v4; // r13
int v5; // ebp
__int64 v6; // rax
__int64 result; // rax

v2 = *(unsigned int **)(a1 + 16);
v3 = *(_DWORD *)a1;
if ( *(int *)a1 <= 0 )
{
v3 = 0;
LABEL_5:
*a2 = v3;
result = 0LL;
}
else
{
v4 = *(_DWORD **)(a1 + 24);
v5 = 0;
while ( 1 )
{
v6 = func0(v4, *v2);
if ( v6 )
break;
++v5;
++v2;
if ( v3 == v5 )
goto LABEL_5;
}
*a2 = v5;
result = v6 + 4;
}
return result;
}

original_code:
void *
SCH_first( SC_Hashtable * ht, int * last )
{
 int * ret = 0;
 int * table = ht->table;
 int i, size = ht->tablesize;
 for ( i = 0; i < size; ++i )
  if ( (ret = SA_atIndex(ht->array,table[i])) )
   break;
 *last = i;
 return ret ? ret + 1 : 0;
}

canonical_original_code:
void *SCH_first(struct SC_Hashtable *ht, int *last)
{
 int *ret = 0;
 int *table = ht->table;
 int i; int size = ht->tablesize;
 for ( i = 0; i < size; ++i )
  if ( (ret = SA_atIndex(ht->array,table[i])) )
   break;
 *last = i;
 return ret ? ret + 1 : 0;
}

variable_types:
last
int *

variable_types:
ret
int *

variable_types:
table
int *


decompiled_code:
__int64 __fastcall SCH_next(__int64 a1, __int64 a2, _DWORD *a3)
{
_DWORD *v4; // rbp
__int64 result; // rax
int v6; // er12
__int64 v7; // rbx
__int64 v8; // r13

v4 = *(_DWORD **)(a1 + 24);
result = SA_atIndex(v4, *(_DWORD *)(a2 - 4));
if ( result )
{
result += 4LL;
}
else
{
v6 = *(_DWORD *)a1;
LODWORD(v7) = *a3 + 1;
if ( *(_DWORD *)a1 > (int)v7 )
{
v8 = *(_QWORD *)(a1 + 16);
v7 = (int)v7;
while ( 1 )
{
result = SA_atIndex(v4, *(_DWORD *)(v8 + 4 * v7));
if ( result )
break;
if ( v6 <= (int)++v7 )
return result;
}
*a3 = v7;
result += 4LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2, _DWORD *a3)
{
_DWORD *v4; // rbp
__int64 result; // rax
int v6; // er12
__int64 v7; // rbx
__int64 v8; // r13

v4 = *(_DWORD **)(a1 + 24);
result = func0(v4, *(_DWORD *)(a2 - 4));
if ( result )
{
result += 4LL;
}
else
{
v6 = *(_DWORD *)a1;
LODWORD(v7) = *a3 + 1;
if ( *(_DWORD *)a1 > (int)v7 )
{
v8 = *(_QWORD *)(a1 + 16);
v7 = (int)v7;
while ( 1 )
{
result = func0(v4, *(_DWORD *)(v8 + 4 * v7));
if ( result )
break;
if ( v6 <= (int)++v7 )
return result;
}
*a3 = v7;
result += 4LL;
}
}
return result;
}

original_code:
void *
SCH_next( SC_Hashtable * ht, void * cur, int * last )
{
 int * ret = 0;
 int * table = ht->table;
 int * node = (int *)cur - 1;
 int * next = SA_atIndex(ht->array,*node);
 if ( next )
  return next + 1;
 int i, size = ht->tablesize;
 for ( i = *last + 1; i < size; ++i )
  if ( (ret = SA_atIndex(ht->array,table[i])) )
   break;
 if ( ret )
  *last = i;
 return ret ? ret + 1 : 0;
}

canonical_original_code:
void *SCH_next(struct SC_Hashtable *ht, void *cur, int *last)
{
 int *ret = 0;
 int *table = ht->table;
 int *node = (int *)cur - 1;
 int *next = SA_atIndex(ht->array,*node);
 if ( next )
  return next + 1;
 int i; int size = ht->tablesize;
 for ( i = *last + 1; i < size; ++i )
  if ( (ret = SA_atIndex(ht->array,table[i])) )
   break;
 if ( ret )
  *last = i;
 return ret ? ret + 1 : 0;
}

variable_types:
cur
void *

variable_types:
next
int *


original_code:
int cauchy_n_ones(int n, int w)
{
  int no;
  int cno;
  int nones;
  int i, j;
  int highbit;
  highbit = (1 << (w-1));
  if (PPs[w] == -1) {
    nones = 0;
    PPs[w] = galois_single_multiply(highbit, 2, w);
    for (i = 0; i < w; i++) {
      if (PPs[w] & (1 << i)) {
        ONEs[w][nones] = (1 << i);
        nones++;
      }
    }
    NOs[w] = nones;
  }
  no = 0;
  for (i = 0; i < w; i++) if (n & (1 << i)) no++;
  cno = no;
  for (i = 1; i < w; i++) {
    if (n & highbit) {
      n ^= highbit;
      n <<= 1;
      n ^= PPs[w];
      cno--;
      for (j = 0; j < NOs[w]; j++) {
        cno += (n & ONEs[w][j]) ? 1 : -1;
      }
    } else {
      n <<= 1;
    }
    no += cno;
  }
  return no;
}

canonical_original_code:
int cauchy_n_ones(int n, int w)
{
  int no;
  int cno;
  int nones;
  int i; int j;
  int highbit;
  highbit = (1 << (w-1));
  if (PPs[w] == -1) {
    nones = 0;
    PPs[w] = galois_single_multiply(highbit, 2, w);
    for (i = 0; i < w; i++) {
      if (PPs[w] & (1 << i)) {
        ONEs[w][nones] = (1 << i);
        nones++;
      }
    }
    NOs[w] = nones;
  }
  no = 0;
  for (i = 0; i < w; i++) if (n & (1 << i)) no++;
  cno = no;
  for (i = 1; i < w; i++) {
    if (n & highbit) {
      n ^= highbit;
      n <<= 1;
      n ^= PPs[w];
      cno--;
      for (j = 0; j < NOs[w]; j++) {
        cno += (n & ONEs[w][j]) ? 1 : -1;
      }
    } else {
      n <<= 1;
    }
    no += cno;
  }
  return no;
}

variable_types: n int

variable_types: w int

variable_types: no int

variable_types: cno int

variable_types: nones int

variable_types: i int

variable_types: j int

variable_types: highbit int


original_code:
void cauchy_improve_coding_matrix(int k, int m, int w, int *matrix)
{
  int index, i, j, x;
  int tmp;
  int bno, tno, bno_index;
  for (j = 0; j < k; j++) {
    if (matrix[j] != 1) {
      tmp = galois_single_divide(1, matrix[j], w);
      index = j;
      for (i = 0; i < m; i++) {
        matrix[index] = galois_single_multiply(matrix[index], tmp, w);
        index += k;
      }
    }
  }
  for (i = 1; i < m; i++) {
    bno = 0;
    index = i*k;
    for (j = 0; j < k; j++) bno += cauchy_n_ones(matrix[index+j], w);
    bno_index = -1;
    for (j = 0; j < k; j++) {
      if (matrix[index+j] != 1) {
        tmp = galois_single_divide(1, matrix[index+j], w);
        tno = 0;
        for (x = 0; x < k; x++) {
          tno += cauchy_n_ones(galois_single_multiply(matrix[index+x], tmp, w), w);
        }
        if (tno < bno) {
          bno = tno;
          bno_index = j;
        }
      }
    }
    if (bno_index != -1) {
      tmp = galois_single_divide(1, matrix[index+bno_index], w);
      for (j = 0; j < k; j++) {
        matrix[index+j] = galois_single_multiply(matrix[index+j], tmp, w);
      }
    }
  }
}

canonical_original_code:
void cauchy_improve_coding_matrix(int k, int m, int w, int *matrix)
{
  int index; int i; int j; int x;
  int tmp;
  int bno; int tno; int bno_index;
  for (j = 0; j < k; j++) {
    if (matrix[j] != 1) {
      tmp = galois_single_divide(1, matrix[j], w);
      index = j;
      for (i = 0; i < m; i++) {
        matrix[index] = galois_single_multiply(matrix[index], tmp, w);
        index += k;
      }
    }
  }
  for (i = 1; i < m; i++) {
    bno = 0;
    index = i*k;
    for (j = 0; j < k; j++) bno += cauchy_n_ones(matrix[index+j], w);
    bno_index = -1;
    for (j = 0; j < k; j++) {
      if (matrix[index+j] != 1) {
        tmp = galois_single_divide(1, matrix[index+j], w);
        tno = 0;
        for (x = 0; x < k; x++) {
          tno += cauchy_n_ones(galois_single_multiply(matrix[index+x], tmp, w), w);
        }
        if (tno < bno) {
          bno = tno;
          bno_index = j;
        }
      }
    }
    if (bno_index != -1) {
      tmp = galois_single_divide(1, matrix[index+bno_index], w);
      for (j = 0; j < k; j++) {
        matrix[index+j] = galois_single_multiply(matrix[index+j], tmp, w);
      }
    }
  }
}

variable_types: k int

variable_types: m int

variable_types:
matrix
int *

variable_types: index int

variable_types: x int

variable_types: tmp int

variable_types: bno int

variable_types: tno int


mkpath

original_code:
static void mkpath(const char *dir) {
        char tmp[256];
        char *p = ((void *)0);
        size_t len;
        snprintf(tmp, sizeof(tmp),"%s",dir);
        len = strlen(tmp);
        if(tmp[len - 1] == '/')
                tmp[len - 1] = 0;
        for(p = tmp + 1; *p; p++)
                if(*p == '/') {
                        *p = 0;
                        mkdir(tmp, (0400|0200|0100));
                        *p = '/';
                }
        mkdir(tmp, (0400|0200|0100));
}

canonical_original_code:
static void mkpath(char *dir) {
        char tmp[256];
        char *p = ((void *)0);
        unsigned long len;
        snprintf(tmp, sizeof(tmp),"%s",dir);
        len = strlen(tmp);
        if(tmp[len - 1] == '/')
                tmp[len - 1] = 0;
        for(p = tmp + 1; *p; p++)
                if(*p == '/') {
                        *p = 0;
                        mkdir(tmp, (0400|0200|0100));
                        *p = '/';
                }
        mkdir(tmp, (0400|0200|0100));
}

variable_types:
dir
char *

variable_types:
tmp
char [256]

variable_types:
p
char *

variable_types:
len
unsigned long


repo: kusha/iterations-counting

decompiled_code:
__int64 print_help()
{
printf("%s", HELPMSG);
return 1LL;
}

canonical_decompiled_code:
__int64 func7()
{
printf("%s", HELPMSG);
return 1LL;
}

original_code:
int print_help() {
 printf("%s", HELPMSG);
 return 1;
}


decompiled_code:
__m128d __fastcall f_abs(__m128d result)
{
if ( result.m128d_f64[0] < 0.0 )
result = _mm_xor_pd(result, (__m128d)xmmword_402360);
return result;
}

canonical_decompiled_code:
__m128d __fastcall func8(__m128d result)
{
if ( result.m128d_f64[0] < 0.0 )
result = _mm_xor_pd(result, (__m128d)xmmword_402360);
return result;
}

original_code:
double f_abs (double x) {
 if (x<0) {
  return -x;
 } else {
  return x;
 }
}

canonical_original_code:
double f_abs(double x) {
 if (x<0) {
  return -x;
 } else {
  return x;
 }
}

variable_types: x double


sqr

original_code:
double sqr (double x, double eps) {
 if (x<0) {
  return 0.0/0.0;
 }
 else if (x==0) {
  return 0;
 }
 double c = 1;
 if (x<1) {
  c = x;
  x = 1/x;
 }
 double aprx=1;
 double previous=0;
 double q;
 do {
  q = x/aprx;
  previous = aprx;
  aprx=(q+aprx)/2;
 } while (f_abs(previous-aprx)>eps);
 return c*aprx;
}

canonical_original_code:
double sqr(double x, double eps) {
 if (x<0) {
  return 0.0/0.0;
 }
 else if (x==0) {
  return 0;
 }
 double c = 1;
 if (x<1) {
  c = x;
  x = 1/x;
 }
 double aprx = 1;
 double previous = 0;
 double q;
 do {
  q = x/aprx;
  previous = aprx;
  aprx=(q+aprx)/2;
 } while (f_abs(previous-aprx)>eps);
 return c*aprx;
}

variable_types: eps double

variable_types: c double

variable_types: aprx double

variable_types: previous double

variable_types: q double


ln

original_code:
double ln (double x, double eps) {
 if (x<0) {
  return 0.0/0.0;
 }
 else if (x==0) {
  return -1.0/0.0;
 }
 else if (x==1) {
  return 0.0;
 }
 int div_c=0;
 int mul_c=0;
 if (x>=1) {
  while (x>=1) {
   x = x / CONST_E;
   ++div_c;
  }
 } else {
  while ((x * CONST_E)<1) {
   x = x * CONST_E;
   ++mul_c;
  }
 }
 --x;
 double sum = 0;
 double previous = 0;
 double next = x;
 double xpow = x;
 int i = 2;
 do {
  sum = sum + next;
  previous = next;
  xpow = xpow * x * -1;
  next = xpow/i;
  ++i;
 } while (f_abs(previous-next)>eps);
 if (div_c) {sum += div_c;}
 if (mul_c) {sum -= mul_c;}
 return sum;
}

canonical_original_code:
double ln(double x, double eps) {
 if (x<0) {
  return 0.0/0.0;
 }
 else if (x==0) {
  return -1.0/0.0;
 }
 else if (x==1) {
  return 0.0;
 }
 int div_c = 0;
 int mul_c = 0;
 if (x>=1) {
  while (x>=1) {
   x = x / CONST_E;
   ++div_c;
  }
 } else {
  while ((x * CONST_E)<1) {
   x = x * CONST_E;
   ++mul_c;
  }
 }
 --x;
 double sum = 0;
 double previous = 0;
 double next = x;
 double xpow = x;
 int i = 2;
 do {
  sum = sum + next;
  previous = next;
  xpow = xpow * x * -1;
  next = xpow/i;
  ++i;
 } while (f_abs(previous-next)>eps);
 if (div_c) {sum += div_c;}
 if (mul_c) {sum -= mul_c;}
 return sum;
}

variable_types: sum double

variable_types: next double

variable_types: xpow double

variable_types: i int


arctg

original_code:
double arctg (double x, double eps) {
 double c=1;
 if(x<0){
  x = -x;
  c= -1;
 }
 if (x==1) {return CONST_PI_4;}
 _Bool Pi_flag = 0;
 if (x>1) {x = 1/x; Pi_flag =1;}
 double sum = 0;
 double previous = 0;
 double next = x;
 double xpow = x;
 double x2 = x*x;
 int i = 3;
 do {
  sum = sum + next;
  previous = next;
  xpow = xpow * x2 * -1;
  next = xpow/i;
  i += 2;
 } while (f_abs(next-previous)>=eps);
 if (Pi_flag) {
  sum = (CONST_PI_2 - sum);
 }
 return c*sum;
}

canonical_original_code:
double arctg(double x, double eps) {
 double c = 1;
 if(x<0){
  x = -x;
  c= -1;
 }
 if (x==1) {return CONST_PI_4;}
 _Bool Pi_flag = 0;
 if (x>1) {x = 1/x; Pi_flag =1;}
 double sum = 0;
 double previous = 0;
 double next = x;
 double xpow = x;
 double x2 = x*x;
 int i = 3;
 do {
  sum = sum + next;
  previous = next;
  xpow = xpow * x2 * -1;
  next = xpow/i;
  i += 2;
 } while (f_abs(next-previous)>=eps);
 if (Pi_flag) {
  sum = (CONST_PI_2 - sum);
 }
 return c*sum;
}