constructArraylist

decompiled_code:
__int64 __fastcall constructArraylist(__int64 *a1, __int64 a2, __int64 a3)
{
__int64 v4; // rdi
_OWORD *v5; // rbp
void *v6; // rax
__int64 v7; // rdx
__int64 v8; // rcx
unsigned int v9; // er8
void *v11; // rdi
__int64 v12; // rdx
__int64 v13; // rcx
__int64 v14; // r8
void *v15; // rdi

v4 = a3;
*a1 = a3;
if ( (_DWORD)a2 != 1 )
{
LABEL_2:
a1[2] = 0LL;
*((_DWORD *)a1 + 6) = 8;
if ( v4 )
{
a2 = 64LL;
v5 = (_OWORD *)lpx_mempool_variable_alloc(v4, 64LL);
}
else
{
v5 = malloc(0x40uLL);
}
a1[4] = (__int64)v5;
if ( v5 )
{
*v5 = 0LL;
v5[1] = 0LL;
v5[2] = 0LL;
v5[3] = 0LL;
if ( *a1 )
{
a2 = 1024LL;
v6 = (void *)lpx_mempool_variable_alloc(*a1, 1024LL);
v5 = (_OWORD *)a1[4];
}
else
{
v6 = malloc(0x400uLL);
}
*(_QWORD *)v5 = v6;
v9 = 0;
if ( v6 )
return v9;
if ( *a1 )
lpx_mempool_variable_free(v5, a2, v7, v8, 0LL);
else
free(v5);
}
lpx_rwlock_destroy(a1[1]);
goto LABEL_17;
}
if ( a3 )
{
a2 = 96LL;
v11 = (void *)lpx_mempool_variable_alloc(a3, 96LL);
}
else
{
v11 = malloc(0x60uLL);
}
a1[1] = (__int64)v11;
if ( !v11 )
return (unsigned int)-1;
if ( !(unsigned int)lpx_rwlock_init() )
{
v4 = *a1;
goto LABEL_2;
}
LABEL_17:
v15 = (void *)a1[1];
if ( *a1 )
lpx_mempool_variable_free(v15, a2, v12, v13, v14);
else
free(v15);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 *a1, __int64 a2, __int64 a3)
{
__int64 v4; // rdi
_OWORD *v5; // rbp
void *v6; // rax
__int64 v7; // rdx
__int64 v8; // rcx
unsigned int v9; // er8
void *v11; // rdi
__int64 v12; // rdx
__int64 v13; // rcx
__int64 v14; // r8
void *v15; // rdi

v4 = a3;
*a1 = a3;
if ( (_DWORD)a2 != 1 )
{
LABEL_2:
a1[2] = 0LL;
*((_DWORD *)a1 + 6) = 8;
if ( v4 )
{
a2 = 64LL;
v5 = (_OWORD *)lpx_mempool_variable_alloc(v4, 64LL);
}
else
{
v5 = malloc(0x40uLL);
}
a1[4] = (__int64)v5;
if ( v5 )
{
*v5 = 0LL;
v5[1] = 0LL;
v5[2] = 0LL;
v5[3] = 0LL;
if ( *a1 )
{
a2 = 1024LL;
v6 = (void *)lpx_mempool_variable_alloc(*a1, 1024LL);
v5 = (_OWORD *)a1[4];
}
else
{
v6 = malloc(0x400uLL);
}
*(_QWORD *)v5 = v6;
v9 = 0;
if ( v6 )
return v9;
if ( *a1 )
lpx_mempool_variable_free(v5, a2, v7, v8, 0LL);
else
free(v5);
}
lpx_rwlock_destroy(a1[1]);
goto LABEL_17;
}
if ( a3 )
{
a2 = 96LL;
v11 = (void *)lpx_mempool_variable_alloc(a3, 96LL);
}
else
{
v11 = malloc(0x60uLL);
}
a1[1] = (__int64)v11;
if ( !v11 )
return (unsigned int)-1;
if ( !(unsigned int)lpx_rwlock_init() )
{
v4 = *a1;
goto LABEL_2;
}
LABEL_17:
v15 = (void *)a1[1];
if ( *a1 )
lpx_mempool_variable_free(v15, a2, v12, v13, v14);
else
free(v15);
return 0xFFFFFFFFLL;
}

original_code:
static int constructArraylist(lpx_arraylist_t *list, int isProtected, lpx_mempool_variable_t *pool)
{
    int i = 0;
    list->pool = pool;
    if (isProtected == 1) {
        list->rwlock = (((list->pool) == ((void *)0))? malloc((sizeof(lpx_rwlock_t))) : lpx_mempool_variable_alloc((list->pool), (sizeof(lpx_rwlock_t))));
 if (list->rwlock == ((void *)0)) {
     return -1;
 }
        if (0 != lpx_rwlock_init(list->rwlock)) {
     goto construct_error1;
 }
    }
    list->size = 0;
    list->numHeads = 8;
    list->heads = (((list->pool) == ((void *)0))? malloc((8 * sizeof(long *))) : lpx_mempool_variable_alloc((list->pool), (8 * sizeof(long *))));
    if (list->heads == ((void *)0)) {
        goto construct_error2;
    }
    for (i = 0; i < 8; i++) {
        list->heads[i] = ((void *)0);
    }
    list->heads[0] = (((list->pool) == ((void *)0))? malloc((sizeof(long) * 128)) : lpx_mempool_variable_alloc((list->pool), (sizeof(long) * 128)));
    if (list->heads[0] == ((void *)0)) {
        goto construct_error3;
    }
    return 0;
construct_error3: (((list->pool) == ((void *)0)) ? free((list->heads)) : lpx_mempool_variable_free((list->heads)));
construct_error2: lpx_rwlock_destroy(list->rwlock);
construct_error1: (((list->pool) == ((void *)0)) ? free((list->rwlock)) : lpx_mempool_variable_free((list->rwlock)));
    return -1;
}

canonical_original_code:
static int constructArraylist(struct __lpx_arraylist_t *list, int isProtected, struct __mempool_variable_t *pool)
{
    int i = 0;
    list->pool = pool;
    if (isProtected == 1) {
        list->rwlock = (((list->pool) == ((void *)0))? malloc((sizeof(lpx_rwlock_t))) : lpx_mempool_variable_alloc((list->pool), (sizeof(lpx_rwlock_t))));
 if (list->rwlock == ((void *)0)) {
     return -1;
 }
        if (0 != lpx_rwlock_init(list->rwlock)) {
     goto construct_error1;
 }
    }
    list->size = 0;
    list->numHeads = 8;
    list->heads = (((list->pool) == ((void *)0))? malloc((8 * sizeof(long *))) : lpx_mempool_variable_alloc((list->pool), (8 * sizeof(long *))));
    if (list->heads == ((void *)0)) {
        goto construct_error2;
    }
    for (i = 0; i < 8; i++) {
        list->heads[i] = ((void *)0);
    }
    list->heads[0] = (((list->pool) == ((void *)0))? malloc((sizeof(long) * 128)) : lpx_mempool_variable_alloc((list->pool), (sizeof(long) * 128)));
    if (list->heads[0] == ((void *)0)) {
        goto construct_error3;
    }
    return 0;
construct_error3: (((list->pool) == ((void *)0)) ? free((list->heads)) : lpx_mempool_variable_free((list->heads)));
construct_error2: lpx_rwlock_destroy(list->rwlock);
construct_error1: (((list->pool) == ((void *)0)) ? free((list->rwlock)) : lpx_mempool_variable_free((list->rwlock)));
    return -1;
}

variable_types: struct __lpx_arraylist_t { struct __mempool_variable_t { union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } *poolMutex; void *pool; long poolSize; void *freeList; int magic; } *pool; struct __lpx_rwlock_t { int value; union pthread_mutex_t rwlock_mutex; union pthread_cond_t { struct __pthread_cond_s { union { unsigned long long __wseq; struct { unsigned int __low; unsigned int __high; } __wseq32; }; union { unsigned long long __g1_start; struct { unsigned int __low; unsigned int __high; } __g1_start32; }; unsigned int __g_refs[2]; unsigned int __g_size[2]; unsigned int __g1_orig_size; unsigned int __wrefs; unsigned int __g_signals[2]; } __data; char __size[48]; long long __align; } rwlock_cvar; } *rwlock; long size; int numHeads; long **heads; } *

variable_types: isProtected int

variable_types:
pool
struct __mempool_variable_t *

variable_types: i int

user_defined_types: struct __lpx_arraylist_t { struct __mempool_variable_t *pool; struct __lpx_rwlock_t *rwlock; long size; int numHeads; long **heads; }


growList

decompiled_code:
__int64 __fastcall growList(__int64 *a1)
{
__int64 v1; // rsi
__int64 result; // rax
size_t v3; // rsi
__int64 v5; // rdi
void *v6; // rbp
const void *v7; // rsi
__int64 v8; // rdx
__int64 v9; // rcx
__int64 v10; // r8
void *v11; // rdi

v1 = *((int *)a1 + 6);
result = 0LL;
if ( *(_QWORD *)(a1[4] + 8 * v1 - 8) )
{
v3 = 16 * v1;
v5 = *a1;
if ( v5 )
v6 = (void *)lpx_mempool_variable_alloc(v5, v3);
else
v6 = malloc(v3);
if ( v6 )
{
memset(v6, 0, 16LL * *((int *)a1 + 6));
v7 = (const void *)a1[4];
memcpy(v6, v7, 8LL * *((int *)a1 + 6));
v11 = (void *)a1[4];
if ( *a1 )
lpx_mempool_variable_free(v11, v7, v8, v9, v10);
else
free(v11);
a1[4] = (__int64)v6;
result = 0LL;
*((_DWORD *)a1 + 6) *= 2;
}
else
{
result = 0xFFFFFFFFLL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 *a1)
{
__int64 v1; // rsi
__int64 result; // rax
size_t v3; // rsi
__int64 v5; // rdi
void *v6; // rbp
const void *v7; // rsi
__int64 v8; // rdx
__int64 v9; // rcx
__int64 v10; // r8
void *v11; // rdi

v1 = *((int *)a1 + 6);
result = 0LL;
if ( *(_QWORD *)(a1[4] + 8 * v1 - 8) )
{
v3 = 16 * v1;
v5 = *a1;
if ( v5 )
v6 = (void *)lpx_mempool_variable_alloc(v5, v3);
else
v6 = malloc(v3);
if ( v6 )
{
memset(v6, 0, 16LL * *((int *)a1 + 6));
v7 = (const void *)a1[4];
memcpy(v6, v7, 8LL * *((int *)a1 + 6));
v11 = (void *)a1[4];
if ( *a1 )
lpx_mempool_variable_free(v11, v7, v8, v9, v10);
else
free(v11);
a1[4] = (__int64)v6;
result = 0LL;
*((_DWORD *)a1 + 6) *= 2;
}
else
{
result = 0xFFFFFFFFLL;
}
}
return result;
}

original_code:
static int growList(lpx_arraylist_t *list)
{
    long **newHeads = ((void *)0);
    if (list->heads[list->numHeads - 1] != ((void *)0)) {
        newHeads = (((list->pool) == ((void *)0))? malloc(((sizeof(long *) * list->numHeads * 2))) : lpx_mempool_variable_alloc((list->pool), ((sizeof(long *) * list->numHeads * 2))));
 if (newHeads == ((void *)0)) {
     return -1;
 }
 memset(newHeads, 0, sizeof(long *) * list->numHeads * 2);
 memcpy(newHeads, list->heads, sizeof(long *) * list->numHeads);
 (((list->pool) == ((void *)0)) ? free((list->heads)) : lpx_mempool_variable_free((list->heads)));
 list->heads = newHeads;
 list->numHeads *= 2;
    }
    return 0;
}

canonical_original_code:
static int growList(struct __lpx_arraylist_t *list)
{
    long **newHeads = ((void *)0);
    if (list->heads[list->numHeads - 1] != ((void *)0)) {
        newHeads = (((list->pool) == ((void *)0))? malloc(((sizeof(long *) * list->numHeads * 2))) : lpx_mempool_variable_alloc((list->pool), ((sizeof(long *) * list->numHeads * 2))));
 if (newHeads == ((void *)0)) {
     return -1;
 }
 memset(newHeads, 0, sizeof(long *) * list->numHeads * 2);
 memcpy(newHeads, list->heads, sizeof(long *) * list->numHeads);
 (((list->pool) == ((void *)0)) ? free((list->heads)) : lpx_mempool_variable_free((list->heads)));
 list->heads = newHeads;
 list->numHeads *= 2;
    }
    return 0;
}

variable_types:
newHeads
long **

return_type: int

user_defined_types: struct __mempool_variable_t { union pthread_mutex_t *poolMutex; void *pool; long poolSize; void *freeList; int magic; }

user_defined_types: struct __lpx_rwlock_t { int value; union pthread_mutex_t rwlock_mutex; union pthread_cond_t rwlock_cvar; }

user_defined_types: union pthread_cond_t { struct __pthread_cond_s __data; char __size[48]; long long __align; }

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

user_defined_types: struct __pthread_cond_s { union { unsigned long long __wseq; struct { unsigned int __low; unsigned int __high; } __wseq32; }; union { unsigned long long __g1_start; struct { unsigned int __low; unsigned int __high; } __g1_start32; }; unsigned int __g_refs[2]; unsigned int __g_size[2]; unsigned int __g1_orig_size; unsigned int __wrefs; unsigned int __g_signals[2]; }

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

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


decompiled_code:
__int64 __fastcall lpx_arraylist_init(__int64 *a1, __int64 a2)
{
__int64 result; // rax

if ( a1 )
result = constructArraylist(a1, a2, 0LL);
else
result = 0xFFFFFFFFLL;
return result;
}

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

if ( a1 )
result = func0(a1, a2, 0LL);
else
result = 0xFFFFFFFFLL;
return result;
}

original_code:
int lpx_arraylist_init(lpx_arraylist_t *list, int isProtected)
{
    if (list == ((void *)0)) {
        return -1;
    }
    return constructArraylist(list, isProtected, ((void *)0));
}

canonical_original_code:
int lpx_arraylist_init(struct __lpx_arraylist_t *list, int isProtected)
{
    if (list == ((void *)0)) {
        return -1;
    }
    return constructArraylist(list, isProtected, ((void *)0));
}


decompiled_code:
__int64 __fastcall lpx_arraylist_init_from_pool(__int64 *a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

if ( a1 && a3 )
result = constructArraylist(a1, a2, a3);
else
result = 0xFFFFFFFFLL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 *a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

if ( a1 && a3 )
result = func0(a1, a2, a3);
else
result = 0xFFFFFFFFLL;
return result;
}

original_code:
int lpx_arraylist_init_from_pool(lpx_arraylist_t *list, int isProtected, lpx_mempool_variable_t *pool)
{
    if (list == ((void *)0) || pool == ((void *)0)) {
        return -1;
    }
    return constructArraylist(list, isProtected, pool);
}

canonical_original_code:
int lpx_arraylist_init_from_pool(struct __lpx_arraylist_t *list, int isProtected, struct __mempool_variable_t *pool)
{
    if (list == ((void *)0) || pool == ((void *)0)) {
        return -1;
    }
    return constructArraylist(list, isProtected, pool);
}


decompiled_code:
__int64 __fastcall lpx_arraylist_destroy(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
_QWORD *v4; // r8
__int64 v6; // rbx
void *v7; // rdi
__int64 v8; // rdi
unsigned int v9; // er12
__int64 v10; // rdx
__int64 v11; // rcx
__int64 v12; // r8
void *v13; // rdi

if ( !a1 )
return (unsigned int)-1;
v4 = *(_QWORD **)(a1 + 32);
if ( *(int *)(a1 + 24) > 0 )
{
v6 = 0LL;
while ( 1 )
{
v7 = (void *)v4[v6];
if ( !v7 )
goto LABEL_5;
if ( *(_QWORD *)a1 )
{
lpx_mempool_variable_free(v7, a2, a3, a4, v4);
v4 = *(_QWORD **)(a1 + 32);
LABEL_5:
if ( *(_DWORD *)(a1 + 24) <= (int)++v6 )
break;
}
else
{
free(v7);
++v6;
v4 = *(_QWORD **)(a1 + 32);
if ( *(_DWORD *)(a1 + 24) <= (int)v6 )
break;
}
}
}
if ( *(_QWORD *)a1 )
lpx_mempool_variable_free(v4, a2, a3, a4, v4);
else
free(v4);
v8 = *(_QWORD *)(a1 + 8);
v9 = 0;
if ( !v8 )
return v9;
lpx_rwlock_destroy(v8);
v13 = *(void **)(a1 + 8);
if ( *(_QWORD *)a1 )
{
lpx_mempool_variable_free(v13, a2, v10, v11, v12);
return v9;
}
free(v13);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
_QWORD *v4; // r8
__int64 v6; // rbx
void *v7; // rdi
__int64 v8; // rdi
unsigned int v9; // er12
__int64 v10; // rdx
__int64 v11; // rcx
__int64 v12; // r8
void *v13; // rdi

if ( !a1 )
return (unsigned int)-1;
v4 = *(_QWORD **)(a1 + 32);
if ( *(int *)(a1 + 24) > 0 )
{
v6 = 0LL;
while ( 1 )
{
v7 = (void *)v4[v6];
if ( !v7 )
goto LABEL_5;
if ( *(_QWORD *)a1 )
{
lpx_mempool_variable_free(v7, a2, a3, a4, v4);
v4 = *(_QWORD **)(a1 + 32);
LABEL_5:
if ( *(_DWORD *)(a1 + 24) <= (int)++v6 )
break;
}
else
{
free(v7);
++v6;
v4 = *(_QWORD **)(a1 + 32);
if ( *(_DWORD *)(a1 + 24) <= (int)v6 )
break;
}
}
}
if ( *(_QWORD *)a1 )
lpx_mempool_variable_free(v4, a2, a3, a4, v4);
else
free(v4);
v8 = *(_QWORD *)(a1 + 8);
v9 = 0;
if ( !v8 )
return v9;
lpx_rwlock_destroy(v8);
v13 = *(void **)(a1 + 8);
if ( *(_QWORD *)a1 )
{
lpx_mempool_variable_free(v13, a2, v10, v11, v12);
return v9;
}
free(v13);
return 0LL;
}

original_code:
int lpx_arraylist_destroy(lpx_arraylist_t *list)
{
    int i = 0;
    if (list == ((void *)0)) {
        return -1;
    }
    for (i = 0; i < list->numHeads; i++) {
        if (((void *)0) != list->heads[i]) {
     (((list->pool) == ((void *)0)) ? free((list->heads[i])) : lpx_mempool_variable_free((list->heads[i])));
 }
    }
    (((list->pool) == ((void *)0)) ? free((list->heads)) : lpx_mempool_variable_free((list->heads)));
    if (list->rwlock != ((void *)0)) {
        lpx_rwlock_destroy(list->rwlock);
 (((list->pool) == ((void *)0)) ? free((list->rwlock)) : lpx_mempool_variable_free((list->rwlock)));
    }
    return 0;
}

canonical_original_code:
int lpx_arraylist_destroy(struct __lpx_arraylist_t *list)
{
    int i = 0;
    if (list == ((void *)0)) {
        return -1;
    }
    for (i = 0; i < list->numHeads; i++) {
        if (((void *)0) != list->heads[i]) {
     (((list->pool) == ((void *)0)) ? free((list->heads[i])) : lpx_mempool_variable_free((list->heads[i])));
 }
    }
    (((list->pool) == ((void *)0)) ? free((list->heads)) : lpx_mempool_variable_free((list->heads)));
    if (list->rwlock != ((void *)0)) {
        lpx_rwlock_destroy(list->rwlock);
 (((list->pool) == ((void *)0)) ? free((list->rwlock)) : lpx_mempool_variable_free((list->rwlock)));
    }
    return 0;
}


decompiled_code:
__int64 __fastcall lpx_arraylist_get(_QWORD *a1, __int64 a2, _QWORD *a3)
{
__int64 v4; // r8
unsigned int v5; // er13

if ( a2 < 0 || a3 == 0LL || !a1 )
return (unsigned int)-1;
if ( !a1[1] )
{
v5 = -2;
if ( a2 >= a1[2] )
return v5;
LABEL_10:
v5 = 0;
*a3 = *(_QWORD *)getElementAtIndex_isra_0(a1[4], a2);
goto LABEL_6;
}
if ( (unsigned int)lpx_rwlock_acquire_reader_lock(a1[1]) )
return (unsigned int)-1;
v4 = a1[1];
v5 = -2;
if ( a1[2] > a2 )
goto LABEL_10;
LABEL_6:
if ( v4 && (unsigned int)lpx_rwlock_release_reader_lock(v4) )
return (unsigned int)-1;
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func6(_QWORD *a1, __int64 a2, _QWORD *a3)
{
__int64 v4; // r8
unsigned int v5; // er13

if ( a2 < 0 || a3 == 0LL || !a1 )
return (unsigned int)-1;
if ( !a1[1] )
{
v5 = -2;
if ( a2 >= a1[2] )
return v5;
LABEL_10:
v5 = 0;
*a3 = *(_QWORD *)func2(a1[4], a2);
goto LABEL_6;
}
if ( (unsigned int)lpx_rwlock_acquire_reader_lock(a1[1]) )
return (unsigned int)-1;
v4 = a1[1];
v5 = -2;
if ( a1[2] > a2 )
goto LABEL_10;
LABEL_6:
if ( v4 && (unsigned int)lpx_rwlock_release_reader_lock(v4) )
return (unsigned int)-1;
return v5;
}

original_code:
int lpx_arraylist_get(lpx_arraylist_t *list, long index, long *value)
{
    int retval = 0;
    long *element = ((void *)0);
    if (list == ((void *)0) || value == ((void *)0) || index < 0) {
        return -1;
    }
    if (list->rwlock != ((void *)0) && lpx_rwlock_acquire_reader_lock(list->rwlock) != 0) {
        return -1;
    }
    if (index >= list->size) {
        retval = -2;
    } else {
        element = getElementAtIndex(list, index);
 *value = *element;
    }
    if (list->rwlock != ((void *)0) && lpx_rwlock_release_reader_lock(list->rwlock) != 0) {
        return -1;
    }
    return retval;
}

canonical_original_code:
int lpx_arraylist_get(struct __lpx_arraylist_t *list, long index, long *value)
{
    int retval = 0;
    long *element = ((void *)0);
    if (list == ((void *)0) || value == ((void *)0) || index < 0) {
        return -1;
    }
    if (list->rwlock != ((void *)0) && lpx_rwlock_acquire_reader_lock(list->rwlock) != 0) {
        return -1;
    }
    if (index >= list->size) {
        retval = -2;
    } else {
        element = getElementAtIndex(list, index);
 *value = *element;
    }
    if (list->rwlock != ((void *)0) && lpx_rwlock_release_reader_lock(list->rwlock) != 0) {
        return -1;
    }
    return retval;
}

variable_types: index long

variable_types:
value
long *

variable_types: retval int

variable_types:
element
long *


decompiled_code:
__int64 __fastcall lpx_arraylist_set(_QWORD *a1, __int64 a2, __int64 a3)
{
__int64 v4; // r8
unsigned int v5; // er12

if ( !a1 || a2 < 0 )
return (unsigned int)-1;
if ( !a1[1] )
{
v5 = -2;
if ( a2 >= a1[2] )
return v5;
LABEL_10:
v5 = 0;
*(_QWORD *)getElementAtIndex_isra_0(a1[4], a2) = a3;
goto LABEL_6;
}
if ( (unsigned int)lpx_rwlock_acquire_writer_lock(a1[1]) )
return (unsigned int)-1;
v4 = a1[1];
v5 = -2;
if ( a1[2] > a2 )
goto LABEL_10;
LABEL_6:
if ( v4 && (unsigned int)lpx_rwlock_release_writer_lock(v4) )
return (unsigned int)-1;
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func7(_QWORD *a1, __int64 a2, __int64 a3)
{
__int64 v4; // r8
unsigned int v5; // er12

if ( !a1 || a2 < 0 )
return (unsigned int)-1;
if ( !a1[1] )
{
v5 = -2;
if ( a2 >= a1[2] )
return v5;
LABEL_10:
v5 = 0;
*(_QWORD *)func2(a1[4], a2) = a3;
goto LABEL_6;
}
if ( (unsigned int)lpx_rwlock_acquire_writer_lock(a1[1]) )
return (unsigned int)-1;
v4 = a1[1];
v5 = -2;
if ( a1[2] > a2 )
goto LABEL_10;
LABEL_6:
if ( v4 && (unsigned int)lpx_rwlock_release_writer_lock(v4) )
return (unsigned int)-1;
return v5;
}

original_code:
int lpx_arraylist_set(lpx_arraylist_t *list, long index, long value)
{
    int retval = 0;
    long *element = ((void *)0);
    if (list == ((void *)0) || index < 0) {
        return -1;
    }
    if (list->rwlock != ((void *)0) && lpx_rwlock_acquire_writer_lock(list->rwlock) != 0) {
        return -1;
    }
    if (index >= list->size) {
        retval = -2;
    } else {
        element = getElementAtIndex(list, index);
 *element = value;
    }
    if (list->rwlock != ((void *)0) && lpx_rwlock_release_writer_lock(list->rwlock) != 0) {
        return -1;
    }
    return retval;
}

canonical_original_code:
int lpx_arraylist_set(struct __lpx_arraylist_t *list, long index, long value)
{
    int retval = 0;
    long *element = ((void *)0);
    if (list == ((void *)0) || index < 0) {
        return -1;
    }
    if (list->rwlock != ((void *)0) && lpx_rwlock_acquire_writer_lock(list->rwlock) != 0) {
        return -1;
    }
    if (index >= list->size) {
        retval = -2;
    } else {
        element = getElementAtIndex(list, index);
 *element = value;
    }
    if (list->rwlock != ((void *)0) && lpx_rwlock_release_writer_lock(list->rwlock) != 0) {
        return -1;
    }
    return retval;
}

variable_types: value long


decompiled_code:
__int64 __fastcall lpx_arraylist_append(__int64 *a1, __int64 a2)
{
__int64 v3; // rdi
__int64 v5; // rsi
__int64 v6; // rbp
__int64 v7; // r13
__int64 v8; // rbp
_QWORD *v9; // r14
unsigned int v10; // er12
__int64 v11; // rdi
void *v13; // rax

if ( !a1 )
return -1;
v3 = a1[1];
if ( v3 )
{
if ( (unsigned int)lpx_rwlock_acquire_writer_lock(v3) )
return -1;
}
v5 = a1[2];
if ( v5 == *((_DWORD *)a1 + 6) << 7 )
{
if ( (unsigned int)growList(a1) )
{
v10 = -1;
goto LABEL_9;
}
v5 = a1[2];
}
v6 = v5 + 127;
v7 = a1[4];
if ( v5 >= 0 )
v6 = v5;
v8 = 8 * (v6 >> 7);
v9 = (_QWORD *)(v7 + v8);
if ( !*(_QWORD *)(v7 + v8) )
{
if ( *a1 )
{
v13 = (void *)lpx_mempool_variable_alloc(*a1, 1024LL);
v7 = a1[4];
v9 = (_QWORD *)(v7 + v8);
}
else
{
v13 = malloc(0x400uLL);
}
*v9 = v13;
if ( !v13 )
return -1;
v5 = a1[2];
}
*(_QWORD *)getElementAtIndex_isra_0(v7, v5) = a2;
v10 = 0;
++a1[2];
LABEL_9:
v11 = a1[1];
if ( v11 && (unsigned int)lpx_rwlock_release_writer_lock(v11) )
return -1;
return v10;
}

original_code:
int lpx_arraylist_append(lpx_arraylist_t *list, long value)
{
    int retval = 0;
    long *element = ((void *)0);
    long newIndex = 0;
    if (list == ((void *)0)) {
        return -1;
    }
    if (list->rwlock != ((void *)0) && lpx_rwlock_acquire_writer_lock(list->rwlock) != 0) {
        return -1;
    }
    do {
        if (list->size == list->numHeads * 128) {
     if (growList(list) != 0) {
         retval = -1;
  break;
     }
 }
 newIndex = list->size / 128;
 if (list->heads[newIndex] == ((void *)0)) {
     list->heads[newIndex] = (((list->pool) == ((void *)0))? malloc((sizeof(long) * 128)) : lpx_mempool_variable_alloc((list->pool), (sizeof(long) * 128)));
     if (list->heads[newIndex] == ((void *)0)) {
         return -1;
     }
 }
 element = getElementAtIndex(list, list->size);
 *element = value;
        list->size++;
    } while (0);
    if (list->rwlock != ((void *)0) && lpx_rwlock_release_writer_lock(list->rwlock) != 0) {
        return -1;
    }
    return retval;
}

canonical_original_code:
int lpx_arraylist_append(struct __lpx_arraylist_t *list, long value)
{
    int retval = 0;
    long *element = ((void *)0);
    long newIndex = 0;
    if (list == ((void *)0)) {
        return -1;
    }
    if (list->rwlock != ((void *)0) && lpx_rwlock_acquire_writer_lock(list->rwlock) != 0) {
        return -1;
    }
    do {
        if (list->size == list->numHeads * 128) {
     if (growList(list) != 0) {
         retval = -1;
  break;
     }
 }
 newIndex = list->size / 128;
 if (list->heads[newIndex] == ((void *)0)) {
     list->heads[newIndex] = (((list->pool) == ((void *)0))? malloc((sizeof(long) * 128)) : lpx_mempool_variable_alloc((list->pool), (sizeof(long) * 128)));
     if (list->heads[newIndex] == ((void *)0)) {
         return -1;
     }
 }
 element = getElementAtIndex(list, list->size);
 *element = value;
        list->size++;
    } while (0);
    if (list->rwlock != ((void *)0) && lpx_rwlock_release_writer_lock(list->rwlock) != 0) {
        return -1;
    }
    return retval;
}

variable_types: newIndex long


decompiled_code:
__int64 __fastcall lpx_arraylist_remove(_QWORD *a1, __int64 a2)
{
__int64 v2; // r9
__int64 v4; // rax
unsigned int v5; // er12
__int64 v7; // rbx
__int64 v8; // rdi
__int64 v9; // rsi
_QWORD *v10; // rax
_QWORD *v11; // r8

if ( !a1 || a2 < 0 )
return (unsigned int)-1;
v2 = a1[1];
if ( !v2 )
{
v4 = a1[2];
v5 = -2;
if ( a2 >= v4 )
return v5;
LABEL_10:
v7 = a2 + 1;
if ( a2 + 1 < v4 )
{
v8 = a1[4];
do
{
getElementAtIndex_isra_0(v8, v7 - 1);
v9 = v7++;
v10 = (_QWORD *)getElementAtIndex_isra_0(v8, v9);
*v11 = *v10;
v4 = a1[2];
}
while ( v4 > v7 );
}
v5 = 0;
a1[2] = v4 - 1;
goto LABEL_6;
}
if ( (unsigned int)lpx_rwlock_acquire_writer_lock(a1[1]) )
return (unsigned int)-1;
v4 = a1[2];
v2 = a1[1];
v5 = -2;
if ( v4 > a2 )
goto LABEL_10;
LABEL_6:
if ( v2 && (unsigned int)lpx_rwlock_release_writer_lock(v2) )
return (unsigned int)-1;
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func9(_QWORD *a1, __int64 a2)
{
__int64 v2; // r9
__int64 v4; // rax
unsigned int v5; // er12
__int64 v7; // rbx
__int64 v8; // rdi
__int64 v9; // rsi
_QWORD *v10; // rax
_QWORD *v11; // r8

if ( !a1 || a2 < 0 )
return (unsigned int)-1;
v2 = a1[1];
if ( !v2 )
{
v4 = a1[2];
v5 = -2;
if ( a2 >= v4 )
return v5;
LABEL_10:
v7 = a2 + 1;
if ( a2 + 1 < v4 )
{
v8 = a1[4];
do
{
func2(v8, v7 - 1);
v9 = v7++;
v10 = (_QWORD *)func2(v8, v9);
*v11 = *v10;
v4 = a1[2];
}
while ( v4 > v7 );
}
v5 = 0;
a1[2] = v4 - 1;
goto LABEL_6;
}
if ( (unsigned int)lpx_rwlock_acquire_writer_lock(a1[1]) )
return (unsigned int)-1;
v4 = a1[2];
v2 = a1[1];
v5 = -2;
if ( v4 > a2 )
goto LABEL_10;
LABEL_6:
if ( v2 && (unsigned int)lpx_rwlock_release_writer_lock(v2) )
return (unsigned int)-1;
return v5;
}

original_code:
int lpx_arraylist_remove(lpx_arraylist_t *list, long index)
{
    int retval = 0;
    long *element = ((void *)0);
    long i = 0;
    if (list == ((void *)0) || index < 0) {
        return -1;
    }
    if (list->rwlock != ((void *)0) && lpx_rwlock_acquire_writer_lock(list->rwlock) != 0) {
        return -1;
    }
    if (index >= list->size) {
        retval = -2;
    } else {
        for (i = index + 1; i < list->size; i++) {
     element = getElementAtIndex(list, i - 1);
     *element = *(getElementAtIndex(list, i));
 }
 list->size--;
    }
    if (list->rwlock != ((void *)0) && lpx_rwlock_release_writer_lock(list->rwlock) != 0) {
        return -1;
    }
    return retval;
}

canonical_original_code:
int lpx_arraylist_remove(struct __lpx_arraylist_t *list, long index)
{
    int retval = 0;
    long *element = ((void *)0);
    long i = 0;
    if (list == ((void *)0) || index < 0) {
        return -1;
    }
    if (list->rwlock != ((void *)0) && lpx_rwlock_acquire_writer_lock(list->rwlock) != 0) {
        return -1;
    }
    if (index >= list->size) {
        retval = -2;
    } else {
        for (i = index + 1; i < list->size; i++) {
     element = getElementAtIndex(list, i - 1);
     *element = *(getElementAtIndex(list, i));
 }
 list->size--;
    }
    if (list->rwlock != ((void *)0) && lpx_rwlock_release_writer_lock(list->rwlock) != 0) {
        return -1;
    }
    return retval;
}

variable_types: i long


decompiled_code:
__int64 __fastcall lpx_arraylist_clear(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
__int64 v6; // rdi
__int64 v7; // rax
__int64 v8; // rbx
void *v9; // rdi
__int64 v10; // rdi
__int64 result; // rax

if ( !a1 )
return 0xFFFFFFFFLL;
v6 = *(_QWORD *)(a1 + 8);
if ( v6 && (unsigned int)lpx_rwlock_acquire_writer_lock(v6) )
return 0xFFFFFFFFLL;
if ( *(int *)(a1 + 24) > 1 )
{
v7 = *(_QWORD *)(a1 + 32);
v8 = 0LL;
do
{
++v8;
v9 = *(void **)(v7 + 8 * v8);
if ( v9 )
{
if ( *(_QWORD *)a1 )
lpx_mempool_variable_free(v9, a2, a3, a4, a5);
else
free(v9);
v7 = *(_QWORD *)(a1 + 32);
*(_QWORD *)(v7 + 8 * v8) = 0LL;
}
a3 = (unsigned int)(v8 + 1);
}
while ( *(_DWORD *)(a1 + 24) > (int)a3 );
}
v10 = *(_QWORD *)(a1 + 8);
*(_QWORD *)(a1 + 16) = 0LL;
result = 0LL;
if ( v10 )
result = (unsigned int)-((unsigned int)lpx_rwlock_release_writer_lock(v10) != 0);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
__int64 v6; // rdi
__int64 v7; // rax
__int64 v8; // rbx
void *v9; // rdi
__int64 v10; // rdi
__int64 result; // rax

if ( !a1 )
return 0xFFFFFFFFLL;
v6 = *(_QWORD *)(a1 + 8);
if ( v6 && (unsigned int)lpx_rwlock_acquire_writer_lock(v6) )
return 0xFFFFFFFFLL;
if ( *(int *)(a1 + 24) > 1 )
{
v7 = *(_QWORD *)(a1 + 32);
v8 = 0LL;
do
{
++v8;
v9 = *(void **)(v7 + 8 * v8);
if ( v9 )
{
if ( *(_QWORD *)a1 )
lpx_mempool_variable_free(v9, a2, a3, a4, a5);
else
free(v9);
v7 = *(_QWORD *)(a1 + 32);
*(_QWORD *)(v7 + 8 * v8) = 0LL;
}
a3 = (unsigned int)(v8 + 1);
}
while ( *(_DWORD *)(a1 + 24) > (int)a3 );
}
v10 = *(_QWORD *)(a1 + 8);
*(_QWORD *)(a1 + 16) = 0LL;
result = 0LL;
if ( v10 )
result = (unsigned int)-((unsigned int)lpx_rwlock_release_writer_lock(v10) != 0);
return result;
}

original_code:
int lpx_arraylist_clear(lpx_arraylist_t *list)
{
    int i = 0;
    if (list == ((void *)0)) {
        return -1;
    }
    if (list->rwlock != ((void *)0) && lpx_rwlock_acquire_writer_lock(list->rwlock) != 0) {
        return -1;
    }
    for (i = 1; i < list->numHeads; i++) {
        if (((void *)0) != list->heads[i]) {
     (((list->pool) == ((void *)0)) ? free((list->heads[i])) : lpx_mempool_variable_free((list->heads[i])));
     list->heads[i] = ((void *)0);
 }
    }
    list->size = 0;
    if (list->rwlock != ((void *)0) && lpx_rwlock_release_writer_lock(list->rwlock) != 0) {
        return -1;
    }
    return 0;
}

canonical_original_code:
int lpx_arraylist_clear(struct __lpx_arraylist_t *list)
{
    int i = 0;
    if (list == ((void *)0)) {
        return -1;
    }
    if (list->rwlock != ((void *)0) && lpx_rwlock_acquire_writer_lock(list->rwlock) != 0) {
        return -1;
    }
    for (i = 1; i < list->numHeads; i++) {
        if (((void *)0) != list->heads[i]) {
     (((list->pool) == ((void *)0)) ? free((list->heads[i])) : lpx_mempool_variable_free((list->heads[i])));
     list->heads[i] = ((void *)0);
 }
    }
    list->size = 0;
    if (list->rwlock != ((void *)0) && lpx_rwlock_release_writer_lock(list->rwlock) != 0) {
        return -1;
    }
    return 0;
}


decompiled_code:
void *__fastcall lpx_arraylist_to_array(_QWORD *a1)
{
__int64 v2; // rdi
__int64 v3; // rax
void *v4; // r12
__int64 v5; // rax
void *v6; // rcx
__int64 v7; // rbx
__int64 v8; // rbp
__int64 v9; // rdx
__int64 v10; // rax
int v11; // eax
char *v12; // rcx
__int64 v13; // rdi
void *result; // rax

if ( !a1 )
goto LABEL_15;
v2 = a1[1];
if ( v2 )
{
if ( (unsigned int)lpx_rwlock_acquire_reader_lock(v2) )
goto LABEL_15;
}
v3 = a1[2];
if ( *a1 )
v4 = (void *)lpx_mempool_variable_alloc(*a1, 8 * v3);
else
v4 = malloc(8 * v3);
if ( v4 )
{
v5 = a1[2];
if ( v5 > 0 )
{
v6 = v4;
v7 = 0LL;
v8 = 128LL;
do
{
v9 = v5 - v7;
v10 = (int)v5 - (int)v7;
if ( v9 < v8 )
v8 = v10;
v11 = v7;
v7 += 128LL;
v12 = (char *)memcpy(v6, *(const void **)(a1[4] + 8LL * (v11 >> 7)), 8 * v8);
v5 = a1[2];
v6 = v12 + 1024;
}
while ( v5 > v7 );
}
}
v13 = a1[1];
if ( v13 && (unsigned int)lpx_rwlock_release_reader_lock(v13) )
LABEL_15:
result = 0LL;
else
result = v4;
return result;
}

canonical_decompiled_code:
void *__fastcall func11(_QWORD *a1)
{
__int64 v2; // rdi
__int64 v3; // rax
void *v4; // r12
__int64 v5; // rax
void *v6; // rcx
__int64 v7; // rbx
__int64 v8; // rbp
__int64 v9; // rdx
__int64 v10; // rax
int v11; // eax
char *v12; // rcx
__int64 v13; // rdi
void *result; // rax

if ( !a1 )
goto LABEL_15;
v2 = a1[1];
if ( v2 )
{
if ( (unsigned int)lpx_rwlock_acquire_reader_lock(v2) )
goto LABEL_15;
}
v3 = a1[2];
if ( *a1 )
v4 = (void *)lpx_mempool_variable_alloc(*a1, 8 * v3);
else
v4 = malloc(8 * v3);
if ( v4 )
{
v5 = a1[2];
if ( v5 > 0 )
{
v6 = v4;
v7 = 0LL;
v8 = 128LL;
do
{
v9 = v5 - v7;
v10 = (int)v5 - (int)v7;
if ( v9 < v8 )
v8 = v10;
v11 = v7;
v7 += 128LL;
v12 = (char *)memcpy(v6, *(const void **)(a1[4] + 8LL * (v11 >> 7)), 8 * v8);
v5 = a1[2];
v6 = v12 + 1024;
}
while ( v5 > v7 );
}
}
v13 = a1[1];
if ( v13 && (unsigned int)lpx_rwlock_release_reader_lock(v13) )
LABEL_15:
result = 0LL;
else
result = v4;
return result;
}

original_code:
long *lpx_arraylist_to_array(lpx_arraylist_t *list)
{
    int i = 0;
    long *array = ((void *)0);
    int elementsToCopy = 128;
    if (list == ((void *)0)) {
        return ((void *)0);
    }
    if (list->rwlock != ((void *)0) && lpx_rwlock_acquire_reader_lock(list->rwlock) != 0) {
        return ((void *)0);
    }
    array = (((list->pool) == ((void *)0))? malloc((list->size * sizeof(long))) : lpx_mempool_variable_alloc((list->pool), (list->size * sizeof(long))));
    if (array != ((void *)0)) {
        for (i = 0; i < list->size; i += 128) {
     if ((list->size - i) < elementsToCopy) {
         elementsToCopy = list->size - i;
     }
     memcpy(array + i, list->heads[i / 128], elementsToCopy * sizeof(long));
 }
    }
    if (list->rwlock != ((void *)0) && lpx_rwlock_release_reader_lock(list->rwlock) != 0) {
        return ((void *)0);
    }
    return array;
}

canonical_original_code:
long *lpx_arraylist_to_array(struct __lpx_arraylist_t *list)
{
    int i = 0;
    long *array = ((void *)0);
    int elementsToCopy = 128;
    if (list == ((void *)0)) {
        return ((void *)0);
    }
    if (list->rwlock != ((void *)0) && lpx_rwlock_acquire_reader_lock(list->rwlock) != 0) {
        return ((void *)0);
    }
    array = (((list->pool) == ((void *)0))? malloc((list->size * sizeof(long))) : lpx_mempool_variable_alloc((list->pool), (list->size * sizeof(long))));
    if (array != ((void *)0)) {
        for (i = 0; i < list->size; i += 128) {
     if ((list->size - i) < elementsToCopy) {
         elementsToCopy = list->size - i;
     }
     memcpy(array + i, list->heads[i / 128], elementsToCopy * sizeof(long));
 }
    }
    if (list->rwlock != ((void *)0) && lpx_rwlock_release_reader_lock(list->rwlock) != 0) {
        return ((void *)0);
    }
    return array;
}

variable_types:
array
long *

variable_types: elementsToCopy int

return_type: long *


decompiled_code:
__int64 __fastcall lpx_arraylist_size(__int64 a1)
{
__int64 v2; // rdi
__int64 v3; // rdi
__int64 v4; // r12

if ( !a1 )
return -1LL;
v2 = *(_QWORD *)(a1 + 8);
if ( v2 )
{
if ( !(unsigned int)lpx_rwlock_acquire_reader_lock(v2) )
{
v3 = *(_QWORD *)(a1 + 8);
v4 = *(_QWORD *)(a1 + 16);
if ( !v3 || !(unsigned int)lpx_rwlock_release_reader_lock(v3) )
return v4;
}
return -1LL;
}
return *(_QWORD *)(a1 + 16);
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1)
{
__int64 v2; // rdi
__int64 v3; // rdi
__int64 v4; // r12

if ( !a1 )
return -1LL;
v2 = *(_QWORD *)(a1 + 8);
if ( v2 )
{
if ( !(unsigned int)lpx_rwlock_acquire_reader_lock(v2) )
{
v3 = *(_QWORD *)(a1 + 8);
v4 = *(_QWORD *)(a1 + 16);
if ( !v3 || !(unsigned int)lpx_rwlock_release_reader_lock(v3) )
return v4;
}
return -1LL;
}
return *(_QWORD *)(a1 + 16);
}

original_code:
long lpx_arraylist_size(lpx_arraylist_t *list)
{
    long retval = -1;
    if (list == ((void *)0)) {
        return -1;
    }
    if (list->rwlock != ((void *)0) && lpx_rwlock_acquire_reader_lock(list->rwlock) != 0) {
        return -1;
    }
    retval = list->size;
    if (list->rwlock != ((void *)0) && lpx_rwlock_release_reader_lock(list->rwlock) != 0) {
        return -1;
    }
    return retval;
}

canonical_original_code:
long lpx_arraylist_size(struct __lpx_arraylist_t *list)
{
    long retval = -1;
    if (list == ((void *)0)) {
        return -1;
    }
    if (list->rwlock != ((void *)0) && lpx_rwlock_acquire_reader_lock(list->rwlock) != 0) {
        return -1;
    }
    retval = list->size;
    if (list->rwlock != ((void *)0) && lpx_rwlock_release_reader_lock(list->rwlock) != 0) {
        return -1;
    }
    return retval;
}

variable_types: retval long

return_type: long


decompiled_code:
__int64 __fastcall lpx_arraylist_get_index(__int64 a1, __int64 a2)
{
__int64 v2; // r9
__int64 v5; // rdi
__int64 i; // rsi
__int64 v7; // rcx
__int64 j; // rax
__int64 v9; // r12

if ( !a1 )
return -1LL;
v2 = *(_QWORD *)(a1 + 8);
if ( v2 )
{
if ( !(unsigned int)lpx_rwlock_acquire_reader_lock(*(_QWORD *)(a1 + 8)) )
{
v5 = *(int *)(a1 + 24);
v2 = *(_QWORD *)(a1 + 8);
if ( v5 <= 0 )
goto LABEL_15;
goto LABEL_5;
}
return -1LL;
}
v5 = *(int *)(a1 + 24);
if ( v5 <= 0 )
return -1LL;
LABEL_5:
for ( i = 0LL; i < v5; ++i )
{
v7 = *(_QWORD *)(*(_QWORD *)(a1 + 32) + 8 * i);
if ( !v7 )
break;
for ( j = 0LL; j != 128; ++j )
{
if ( *(_QWORD *)(v7 + 8 * j) == a2 )
{
v9 = (i << 7) + (int)j;
goto LABEL_11;
}
}
}
LABEL_15:
v9 = -1LL;
LABEL_11:
if ( v2 && (unsigned int)lpx_rwlock_release_reader_lock(v2) )
return -1LL;
return v9;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, __int64 a2)
{
__int64 v2; // r9
__int64 v5; // rdi
__int64 i; // rsi
__int64 v7; // rcx
__int64 j; // rax
__int64 v9; // r12

if ( !a1 )
return -1LL;
v2 = *(_QWORD *)(a1 + 8);
if ( v2 )
{
if ( !(unsigned int)lpx_rwlock_acquire_reader_lock(*(_QWORD *)(a1 + 8)) )
{
v5 = *(int *)(a1 + 24);
v2 = *(_QWORD *)(a1 + 8);
if ( v5 <= 0 )
goto LABEL_15;
goto LABEL_5;
}
return -1LL;
}
v5 = *(int *)(a1 + 24);
if ( v5 <= 0 )
return -1LL;
LABEL_5:
for ( i = 0LL; i < v5; ++i )
{
v7 = *(_QWORD *)(*(_QWORD *)(a1 + 32) + 8 * i);
if ( !v7 )
break;
for ( j = 0LL; j != 128; ++j )
{
if ( *(_QWORD *)(v7 + 8 * j) == a2 )
{
v9 = (i << 7) + (int)j;
goto LABEL_11;
}
}
}
LABEL_15:
v9 = -1LL;
LABEL_11:
if ( v2 && (unsigned int)lpx_rwlock_release_reader_lock(v2) )
return -1LL;
return v9;
}

original_code:
long lpx_arraylist_get_index(lpx_arraylist_t *list, long key)
{
    long i = 0;
    int j = 0;
    long index = -1;
    long *row = ((void *)0);
    if (list == ((void *)0)) {
        return -1;
    }
    if (list->rwlock != ((void *)0) && lpx_rwlock_acquire_reader_lock(list->rwlock) != 0) {
        return -1;
    }
    for (i = 0; i < list->numHeads; i++) {
        if (list->heads[i] == ((void *)0)) {
     break;
 }
        row = list->heads[i];
 for (j = 0; j < 128; j++) {
     if (row[j] == key) {
         index = i * 128 + j;
  break;
     }
 }
 if (index != -1) {
     break;
 }
    }
    if (list->rwlock != ((void *)0) && lpx_rwlock_release_reader_lock(list->rwlock) != 0) {
        return -1;
    }
    return index;
}

canonical_original_code:
long lpx_arraylist_get_index(struct __lpx_arraylist_t *list, long key)
{
    long i = 0;
    int j = 0;
    long index = -1;
    long *row = ((void *)0);
    if (list == ((void *)0)) {
        return -1;
    }
    if (list->rwlock != ((void *)0) && lpx_rwlock_acquire_reader_lock(list->rwlock) != 0) {
        return -1;
    }
    for (i = 0; i < list->numHeads; i++) {
        if (list->heads[i] == ((void *)0)) {
     break;
 }
        row = list->heads[i];
 for (j = 0; j < 128; j++) {
     if (row[j] == key) {
         index = i * 128 + j;
  break;
     }
 }
 if (index != -1) {
     break;
 }
    }
    if (list->rwlock != ((void *)0) && lpx_rwlock_release_reader_lock(list->rwlock) != 0) {
        return -1;
    }
    return index;
}

variable_types: key long

variable_types: j int

variable_types:
row
long *


enqueue

decompiled_code:
__int64 __fastcall enqueue(__int64 a1, __int64 a2)
{
_QWORD *v2; // rax
_QWORD *v3; // rbp
__int64 v4; // rax
__int64 result; // rax

v2 = (_QWORD *)lpx_mempool_fixed_alloc(a1 + 8);
if ( !v2 )
return 0xFFFFFFFFLL;
*v2 = a2;
v3 = v2;
v2[1] = 0LL;
if ( pthread_mutex_lock((pthread_mutex_t *)(a1 + 248)) )
{
lpx_mempool_fixed_free(v3);
result = 0xFFFFFFFFLL;
}
else
{
v4 = *(_QWORD *)(a1 + 296);
v3[2] = v4;
if ( v4 )
*(_QWORD *)(v4 + 8) = v3;
else
*(_QWORD *)(a1 + 288) = v3;
*(_QWORD *)(a1 + 296) = v3;
result = (unsigned int)-(pthread_mutex_unlock((pthread_mutex_t *)(a1 + 248)) != 0);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
_QWORD *v2; // rax
_QWORD *v3; // rbp
__int64 v4; // rax
__int64 result; // rax

v2 = (_QWORD *)lpx_mempool_fixed_alloc(a1 + 8);
if ( !v2 )
return 0xFFFFFFFFLL;
*v2 = a2;
v3 = v2;
v2[1] = 0LL;
if ( pthread_mutex_lock((pthread_mutex_t *)(a1 + 248)) )
{
lpx_mempool_fixed_free(v3);
result = 0xFFFFFFFFLL;
}
else
{
v4 = *(_QWORD *)(a1 + 296);
v3[2] = v4;
if ( v4 )
*(_QWORD *)(v4 + 8) = v3;
else
*(_QWORD *)(a1 + 288) = v3;
*(_QWORD *)(a1 + 296) = v3;
result = (unsigned int)-(pthread_mutex_unlock((pthread_mutex_t *)(a1 + 248)) != 0);
}
return result;
}

original_code:
static int enqueue(lpx_pcq_t *queue, void *value)
{
    lpx_pcq_node_t *node = lpx_mempool_fixed_alloc(&queue->pool);
    if (node == ((void *)0)) {
        return -1;
    }
    node->data = value;
    node->next = ((void *)0);
    if (0 != pthread_mutex_lock(&queue->qMutex)) {
        lpx_mempool_fixed_free(node);
        return -1;
    }
    node->prev = queue->tail;
    if (queue->tail != ((void *)0)) {
        queue->tail->next = node;
        queue->tail = node;
    } else {
        queue->head = node;
        queue->tail = node;
    }
    if (0 != pthread_mutex_unlock(&queue->qMutex)) {
       return -1;
    }
    return 0;
}

canonical_original_code:
static int enqueue(struct __lpx_pcq_t *queue, void *value)
{
    struct __lpx_pcq_node_t *node = lpx_mempool_fixed_alloc(&queue->pool);
    if (node == ((void *)0)) {
        return -1;
    }
    node->data = value;
    node->next = ((void *)0);
    if (0 != pthread_mutex_lock(&queue->qMutex)) {
        lpx_mempool_fixed_free(node);
        return -1;
    }
    node->prev = queue->tail;
    if (queue->tail != ((void *)0)) {
        queue->tail->next = node;
        queue->tail = node;
    } else {
        queue->head = node;
        queue->tail = node;
    }
    if (0 != pthread_mutex_unlock(&queue->qMutex)) {
       return -1;
    }
    return 0;
}

variable_types: struct __lpx_pcq_t { int maxSize; struct __mempool_fixed_t { union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } *poolMutex; void *pool; void *freeList; long poolSize; long storedObjectSize; int magic; } pool; struct __semaphore_t { unsigned int initialized; int value; union pthread_mutex_t sem_mutex; union pthread_cond_t { struct __pthread_cond_s { union { unsigned long long __wseq; struct { unsigned int __low; unsigned int __high; } __wseq32; }; union { unsigned long long __g1_start; struct { unsigned int __low; unsigned int __high; } __g1_start32; }; unsigned int __g_refs[2]; unsigned int __g_size[2]; unsigned int __g1_orig_size; unsigned int __wrefs; unsigned int __g_signals[2]; } __data; char __size[48]; long long __align; } sem_cvar; } dqSem; struct __semaphore_t nqSem; union pthread_mutex_t qMutex; struct __lpx_pcq_node_t { void *data; struct __lpx_pcq_node_t *next; struct __lpx_pcq_node_t *prev; } *head; struct __lpx_pcq_node_t *tail; } *

variable_types:
value
void *

user_defined_types: struct __lpx_pcq_t { int maxSize; struct __mempool_fixed_t pool; struct __semaphore_t dqSem; struct __semaphore_t nqSem; union pthread_mutex_t qMutex; struct __lpx_pcq_node_t *head; struct __lpx_pcq_node_t *tail; }

user_defined_types: struct __mempool_fixed_t { union pthread_mutex_t *poolMutex; void *pool; void *freeList; long poolSize; long storedObjectSize; int magic; }

user_defined_types: struct __semaphore_t { unsigned int initialized; int value; union pthread_mutex_t sem_mutex; union pthread_cond_t sem_cvar; }


dequeue

decompiled_code:
__int64 __fastcall dequeue(__int64 a1, _QWORD *a2)
{
pthread_mutex_t *v2; // r12
_QWORD *v3; // rbp
__int64 v4; // rax
unsigned int v5; // er12

v2 = (pthread_mutex_t *)(a1 + 248);
if ( pthread_mutex_lock((pthread_mutex_t *)(a1 + 248)) )
return (unsigned int)-1;
v3 = *(_QWORD **)(a1 + 288);
if ( !v3 )
{
pthread_mutex_unlock(v2);
return (unsigned int)-1;
}
v4 = v3[1];
*(_QWORD *)(a1 + 288) = v4;
if ( v4 )
*(_QWORD *)(v4 + 16) = 0LL;
v5 = pthread_mutex_unlock(v2);
if ( v5 )
return (unsigned int)-1;
*a2 = *v3;
lpx_mempool_fixed_free(v3);
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, _QWORD *a2)
{
pthread_mutex_t *v2; // r12
_QWORD *v3; // rbp
__int64 v4; // rax
unsigned int v5; // er12

v2 = (pthread_mutex_t *)(a1 + 248);
if ( pthread_mutex_lock((pthread_mutex_t *)(a1 + 248)) )
return (unsigned int)-1;
v3 = *(_QWORD **)(a1 + 288);
if ( !v3 )
{
pthread_mutex_unlock(v2);
return (unsigned int)-1;
}
v4 = v3[1];
*(_QWORD *)(a1 + 288) = v4;
if ( v4 )
*(_QWORD *)(v4 + 16) = 0LL;
v5 = pthread_mutex_unlock(v2);
if ( v5 )
return (unsigned int)-1;
*a2 = *v3;
lpx_mempool_fixed_free(v3);
return v5;
}

original_code:
static int dequeue(lpx_pcq_t *queue, void **value)
{
    lpx_pcq_node_t *node = ((void *)0);
    if (0 != pthread_mutex_lock(&queue->qMutex)) {
        return -1;
    }
    if (queue->head == ((void *)0)) {
        pthread_mutex_unlock(&queue->qMutex);
        return -1;
    }
    node = queue->head;
    queue->head = queue->head->next;
    if (queue->head != ((void *)0)) {
        queue->head->prev = ((void *)0);
    }
    if (0 != pthread_mutex_unlock(&queue->qMutex)) {
        return -1;
    }
    *value = node->data;
    lpx_mempool_fixed_free(node);
    return 0;
}

canonical_original_code:
static int dequeue(struct __lpx_pcq_t *queue, void **value)
{
    struct __lpx_pcq_node_t *node = ((void *)0);
    if (0 != pthread_mutex_lock(&queue->qMutex)) {
        return -1;
    }
    if (queue->head == ((void *)0)) {
        pthread_mutex_unlock(&queue->qMutex);
        return -1;
    }
    node = queue->head;
    queue->head = queue->head->next;
    if (queue->head != ((void *)0)) {
        queue->head->prev = ((void *)0);
    }
    if (0 != pthread_mutex_unlock(&queue->qMutex)) {
        return -1;
    }
    *value = node->data;
    lpx_mempool_fixed_free(node);
    return 0;
}

variable_types:
value
void **

variable_types: struct __lpx_pcq_node_t { void *data; struct __lpx_pcq_node_t *next; struct __lpx_pcq_node_t *prev; } *


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

if ( !a1 )
return 0xFFFFFFFFLL;
if ( a2 > 0 )
{
*(_DWORD *)a1 = a2;
if ( !(unsigned int)lpx_sem_init(a1 + 152) )
{
if ( !(unsigned int)lpx_sem_init(a1 + 56) )
{
if ( !(unsigned int)lpx_sem_down_multiple(a1 + 56, (unsigned int)a2)
&& !pthread_mutex_init((pthread_mutex_t *)(a1 + 248), 0LL) )
{
result = lpx_mempool_create_fixed_pool(a1 + 8, 24LL, (unsigned int)a2, 2LL);
if ( !(_DWORD)result )
{
*(_QWORD *)(a1 + 288) = 0LL;
*(_QWORD *)(a1 + 296) = 0LL;
return result;
}
pthread_mutex_destroy((pthread_mutex_t *)(a1 + 248));
}
lpx_sem_destroy(a1 + 56);
}
lpx_sem_destroy(a1 + 152);
}
}
return 0xFFFFFFFFLL;
}

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

if ( !a1 )
return 0xFFFFFFFFLL;
if ( a2 > 0 )
{
*(_DWORD *)a1 = a2;
if ( !(unsigned int)lpx_sem_init(a1 + 152) )
{
if ( !(unsigned int)lpx_sem_init(a1 + 56) )
{
if ( !(unsigned int)lpx_sem_down_multiple(a1 + 56, (unsigned int)a2)
&& !pthread_mutex_init((pthread_mutex_t *)(a1 + 248), 0LL) )
{
result = lpx_mempool_create_fixed_pool(a1 + 8, 24LL, (unsigned int)a2, 2LL);
if ( !(_DWORD)result )
{
*(_QWORD *)(a1 + 288) = 0LL;
*(_QWORD *)(a1 + 296) = 0LL;
return result;
}
pthread_mutex_destroy((pthread_mutex_t *)(a1 + 248));
}
lpx_sem_destroy(a1 + 56);
}
lpx_sem_destroy(a1 + 152);
}
}
return 0xFFFFFFFFLL;
}

original_code:
int lpx_pcq_init(lpx_pcq_t *queue, int queueDepth)
{
    if (queue == ((void *)0) || queueDepth < 1) {
        return -1;
    }
    queue->maxSize = queueDepth;
    if (0 != lpx_sem_init(&queue->nqSem, queueDepth)) {
        return -1;
    }
    if (0 != lpx_sem_init(&queue->dqSem, queueDepth)) {
        goto pcq_destroy1;
    }
    if (0 != lpx_sem_down_multiple(&queue->dqSem, queueDepth)) {
        goto pcq_destroy2;
    }
    if (0 != pthread_mutex_init(&queue->qMutex, ((void *)0))) {
        goto pcq_destroy2;
    }
    if (0 != lpx_mempool_create_fixed_pool(&queue->pool, sizeof(lpx_pcq_node_t),
                                           queueDepth, 2)) {
        goto pcq_destroy3;
    }
    queue->head = ((void *)0);
    queue->tail = ((void *)0);
    return 0;
pcq_destroy3: pthread_mutex_destroy(&queue->qMutex);
pcq_destroy2: lpx_sem_destroy(&queue->dqSem);
pcq_destroy1: lpx_sem_destroy(&queue->nqSem);
    return -1;
}

canonical_original_code:
int lpx_pcq_init(struct __lpx_pcq_t *queue, int queueDepth)
{
    if (queue == ((void *)0) || queueDepth < 1) {
        return -1;
    }
    queue->maxSize = queueDepth;
    if (0 != lpx_sem_init(&queue->nqSem, queueDepth)) {
        return -1;
    }
    if (0 != lpx_sem_init(&queue->dqSem, queueDepth)) {
        goto pcq_destroy1;
    }
    if (0 != lpx_sem_down_multiple(&queue->dqSem, queueDepth)) {
        goto pcq_destroy2;
    }
    if (0 != pthread_mutex_init(&queue->qMutex, ((void *)0))) {
        goto pcq_destroy2;
    }
    if (0 != lpx_mempool_create_fixed_pool(&queue->pool, sizeof(lpx_pcq_node_t),
                                           queueDepth, 2)) {
        goto pcq_destroy3;
    }
    queue->head = ((void *)0);
    queue->tail = ((void *)0);
    return 0;
pcq_destroy3: pthread_mutex_destroy(&queue->qMutex);
pcq_destroy2: lpx_sem_destroy(&queue->dqSem);
pcq_destroy1: lpx_sem_destroy(&queue->nqSem);
    return -1;
}

variable_types: queueDepth int

user_defined_types: struct __lpx_pcq_node_t { void *data; struct __lpx_pcq_node_t *next; struct __lpx_pcq_node_t *prev; }


decompiled_code:
__int64 __fastcall lpx_pcq_enqueue(__int64 a1, __int64 a2)
{
if ( !a1 )
return 0xFFFFFFFFLL;
if ( (unsigned int)lpx_sem_down(a1 + 152) )
return 0xFFFFFFFFLL;
if ( (unsigned int)enqueue(a1, a2) )
{
lpx_sem_up(a1 + 152);
return 0xFFFFFFFFLL;
}
return (unsigned int)-((unsigned int)lpx_sem_up(a1 + 56) != 0);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2)
{
if ( !a1 )
return 0xFFFFFFFFLL;
if ( (unsigned int)lpx_sem_down(a1 + 152) )
return 0xFFFFFFFFLL;
if ( (unsigned int)func0(a1, a2) )
{
lpx_sem_up(a1 + 152);
return 0xFFFFFFFFLL;
}
return (unsigned int)-((unsigned int)lpx_sem_up(a1 + 56) != 0);
}

original_code:
int lpx_pcq_enqueue(lpx_pcq_t *queue, void *data)
{
    if (queue == ((void *)0)) {
        return -1;
    }
    if (0 != lpx_sem_down(&queue->nqSem)) {
        return -1;
    }
    if (0 != enqueue(queue, data)) {
        lpx_sem_up(&queue->nqSem);
 return -1;
    }
    if (0 != lpx_sem_up(&queue->dqSem)) {
        return -1;
    }
    return 0;
}

canonical_original_code:
int lpx_pcq_enqueue(struct __lpx_pcq_t *queue, void *data)
{
    if (queue == ((void *)0)) {
        return -1;
    }
    if (0 != lpx_sem_down(&queue->nqSem)) {
        return -1;
    }
    if (0 != enqueue(queue, data)) {
        lpx_sem_up(&queue->nqSem);
 return -1;
    }
    if (0 != lpx_sem_up(&queue->dqSem)) {
        return -1;
    }
    return 0;
}

variable_types:
data
void *


decompiled_code:
__int64 __fastcall lpx_pcq_dequeue(__int64 a1, _QWORD *a2)
{
if ( !a1 )
return 0xFFFFFFFFLL;
if ( !a2 || (unsigned int)lpx_sem_down(a1 + 56) )
return 0xFFFFFFFFLL;
if ( (unsigned int)dequeue(a1, a2) )
{
lpx_sem_up(a1 + 56);
return 0xFFFFFFFFLL;
}
return (unsigned int)-((unsigned int)lpx_sem_up(a1 + 152) != 0);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, _QWORD *a2)
{
if ( !a1 )
return 0xFFFFFFFFLL;
if ( !a2 || (unsigned int)lpx_sem_down(a1 + 56) )
return 0xFFFFFFFFLL;
if ( (unsigned int)func1(a1, a2) )
{
lpx_sem_up(a1 + 56);
return 0xFFFFFFFFLL;
}
return (unsigned int)-((unsigned int)lpx_sem_up(a1 + 152) != 0);
}

original_code:
int lpx_pcq_dequeue(lpx_pcq_t *queue, void **data)
{
    if (queue == ((void *)0) || data == ((void *)0)) {
        return -1;
    }
    if (0 != lpx_sem_down(&queue->dqSem)) {
        return -1;
    }
    if (0 != dequeue(queue, data)) {
        lpx_sem_up(&queue->dqSem);
 return -1;
    }
    if (0 != lpx_sem_up(&queue->nqSem)) {
        return -1;
    }
    return 0;
}

canonical_original_code:
int lpx_pcq_dequeue(struct __lpx_pcq_t *queue, void **data)
{
    if (queue == ((void *)0) || data == ((void *)0)) {
        return -1;
    }
    if (0 != lpx_sem_down(&queue->dqSem)) {
        return -1;
    }
    if (0 != dequeue(queue, data)) {
        lpx_sem_up(&queue->dqSem);
 return -1;
    }
    if (0 != lpx_sem_up(&queue->nqSem)) {
        return -1;
    }
    return 0;
}

variable_types:
data
void **


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

if ( !a1 )
return 0xFFFFFFFFLL;
result = lpx_sem_timed_down(a1 + 152, 1LL);
if ( (_DWORD)result )
{
if ( (_DWORD)result == -2 )
return result;
}
else
{
if ( !(unsigned int)enqueue(a1, a2) )
return (unsigned int)-((unsigned int)lpx_sem_up(a1 + 56) != 0);
lpx_sem_up(a1 + 152);
}
return 0xFFFFFFFFLL;
}

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

if ( !a1 )
return 0xFFFFFFFFLL;
result = lpx_sem_timed_down(a1 + 152, 1LL);
if ( (_DWORD)result )
{
if ( (_DWORD)result == -2 )
return result;
}
else
{
if ( !(unsigned int)func0(a1, a2) )
return (unsigned int)-((unsigned int)lpx_sem_up(a1 + 56) != 0);
lpx_sem_up(a1 + 152);
}
return 0xFFFFFFFFLL;
}

original_code:
int lpx_pcq_timed_enqueue(lpx_pcq_t *queue, void *data, long timeout)
{
    int retval = 0;
    if (queue == ((void *)0)) {
        return -1;
    }
    if ((retval = lpx_sem_timed_down(&queue->nqSem, 1, timeout)) != 0) {
        if (retval == -2) {
     return -2;
 } else {
     return -1;
 }
    }
    if (0 != enqueue(queue, data)) {
        lpx_sem_up(&queue->nqSem);
 return -1;
    }
    if (0 != lpx_sem_up(&queue->dqSem)) {
        return -1;
    }
    return 0;
}

canonical_original_code:
int lpx_pcq_timed_enqueue(struct __lpx_pcq_t *queue, void *data, long timeout)
{
    int retval = 0;
    if (queue == ((void *)0)) {
        return -1;
    }
    if ((retval = lpx_sem_timed_down(&queue->nqSem, 1, timeout)) != 0) {
        if (retval == -2) {
     return -2;
 } else {
     return -1;
 }
    }
    if (0 != enqueue(queue, data)) {
        lpx_sem_up(&queue->nqSem);
 return -1;
    }
    if (0 != lpx_sem_up(&queue->dqSem)) {
        return -1;
    }
    return 0;
}

variable_types: timeout long

variable_types: retval int


decompiled_code:
__int64 __fastcall lpx_pcq_timed_dequeue(__int64 a1, _QWORD *a2)
{
__int64 result; // rax

if ( !a1 )
return 0xFFFFFFFFLL;
if ( a2 )
{
result = lpx_sem_timed_down(a1 + 56, 1LL);
if ( (_DWORD)result )
{
if ( (_DWORD)result == -2 )
return result;
}
else
{
if ( !(unsigned int)dequeue(a1, a2) )
return (unsigned int)-((unsigned int)lpx_sem_up(a1 + 152) != 0);
lpx_sem_up(a1 + 56);
}
}
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, _QWORD *a2)
{
__int64 result; // rax

if ( !a1 )
return 0xFFFFFFFFLL;
if ( a2 )
{
result = lpx_sem_timed_down(a1 + 56, 1LL);
if ( (_DWORD)result )
{
if ( (_DWORD)result == -2 )
return result;
}
else
{
if ( !(unsigned int)func1(a1, a2) )
return (unsigned int)-((unsigned int)lpx_sem_up(a1 + 152) != 0);
lpx_sem_up(a1 + 56);
}
}
return 0xFFFFFFFFLL;
}

original_code:
int lpx_pcq_timed_dequeue(lpx_pcq_t *queue, void **data, long timeout)
{
    int retval = 0;
    if (queue == ((void *)0) || data == ((void *)0)) {
        return -1;
    }
    if ((retval = lpx_sem_timed_down(&queue->dqSem, 1, timeout)) != 0) {
        if (retval == -2) {
     return -2;
 } else {
     return -1;
 }
    }
    if (0 != dequeue(queue, data)) {
        lpx_sem_up(&queue->dqSem);
 return -1;
    }
    if (0 != lpx_sem_up(&queue->nqSem)) {
        return -1;
    }
    return 0;
}

canonical_original_code:
int lpx_pcq_timed_dequeue(struct __lpx_pcq_t *queue, void **data, long timeout)
{
    int retval = 0;
    if (queue == ((void *)0) || data == ((void *)0)) {
        return -1;
    }
    if ((retval = lpx_sem_timed_down(&queue->dqSem, 1, timeout)) != 0) {
        if (retval == -2) {
     return -2;
 } else {
     return -1;
 }
    }
    if (0 != dequeue(queue, data)) {
        lpx_sem_up(&queue->dqSem);
 return -1;
    }
    if (0 != lpx_sem_up(&queue->nqSem)) {
        return -1;
    }
    return 0;
}


decompiled_code:
__int64 __fastcall lpx_pcq_destroy(__int64 a1)
{
lpx_mempool_destroy_fixed_pool(a1 + 8);
lpx_sem_destroy(a1 + 152);
lpx_sem_destroy(a1 + 56);
pthread_mutex_destroy((pthread_mutex_t *)(a1 + 248));
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
lpx_mempool_destroy_fixed_pool(a1 + 8);
lpx_sem_destroy(a1 + 152);
lpx_sem_destroy(a1 + 56);
pthread_mutex_destroy((pthread_mutex_t *)(a1 + 248));
return 0LL;
}

original_code:
int lpx_pcq_destroy(lpx_pcq_t *queue)
{
    lpx_mempool_destroy_fixed_pool(&queue->pool);
    lpx_sem_destroy(&queue->nqSem);
    lpx_sem_destroy(&queue->dqSem);
    pthread_mutex_destroy(&queue->qMutex);
    return 0;
}

canonical_original_code:
int lpx_pcq_destroy(struct __lpx_pcq_t *queue)
{
    lpx_mempool_destroy_fixed_pool(&queue->pool);
    lpx_sem_destroy(&queue->nqSem);
    lpx_sem_destroy(&queue->dqSem);
    pthread_mutex_destroy(&queue->qMutex);
    return 0;
}


main

canonical_name: main

repo: razlock/sizeof

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
printf("/%-8s\t/%-6s\t/%s\n\n", "type", "bytes", "desc");
printf("%-8s\t%-6lu\t%s\n", "size_t", 8LL, "integral data type");
putchar(10);
printf("%-8s\t%-6lu\t%s\n", "char", 1LL, "one character");
putchar(10);
printf("%-8s\t%-6lu\t%s\n", "int8_t", 1LL, "standard int 8");
printf("%-8s\t%-6lu\t%s\n", "int16_t", 2LL, "standard int 16");
printf("%-8s\t%-6lu\t%s\n", "int32_t", 4LL, "standard int 32");
printf("%-8s\t%-6lu\t%s\n", "int64_t", 8LL, "standard int 64");
putchar(10);
printf("%-8s\t%-6lu\t%s\n", "short", 2LL, "small integer");
printf("%-8s\t%-6lu\t%s\n", "int", 4LL, "integer");
printf("%-8s\t%-6lu\t%s\n", "long", 8LL, "big integer");
putchar(10);
printf("%-8s\t%-6lu\t%s\n", "float", 4LL, "floating-point number");
printf("%-8s\t%-6lu\t%s\n", "double", 8LL, "double-precision floating-point number");
printf("%-8s\t%-6lu\t%s\n", "long double", 16LL, "double-double-precision floating-point number");
return 0;
}

original_code:
int main(void)
{
    printf("/%-8s\t/%-6s\t/%s\n\n", "type", "bytes", "desc");
    printf("%-8s\t%-6lu\t%s\n", "size_t", (unsigned long)sizeof(size_t), "integral data type");
    printf("\n");
    printf("%-8s\t%-6lu\t%s\n", "char", (unsigned long)sizeof(char), "one character");
    printf("\n");
    printf("%-8s\t%-6lu\t%s\n", "int8_t", (unsigned long)sizeof(int8_t), "standard int 8");
    printf("%-8s\t%-6lu\t%s\n", "int16_t", (unsigned long)sizeof(int16_t), "standard int 16");
    printf("%-8s\t%-6lu\t%s\n", "int32_t", (unsigned long)sizeof(int32_t), "standard int 32");
    printf("%-8s\t%-6lu\t%s\n", "int64_t", (unsigned long)sizeof(int64_t), "standard int 64");
    printf("\n");
    printf("%-8s\t%-6lu\t%s\n", "short", (unsigned long)sizeof(short), "small integer");
    printf("%-8s\t%-6lu\t%s\n", "int", (unsigned long)sizeof(int), "integer");
    printf("%-8s\t%-6lu\t%s\n", "long", (unsigned long)sizeof(long), "big integer");
    printf("\n");
    printf("%-8s\t%-6lu\t%s\n", "float", (unsigned long)sizeof(float), "floating-point number");
    printf("%-8s\t%-6lu\t%s\n", "double", (unsigned long)sizeof(double), "double-precision floating-point number");
    printf("%-8s\t%-6lu\t%s\n", "long double", (unsigned long)sizeof(long double), "double-double-precision floating-point number");
    return 0;
}

canonical_original_code:
int main()
{
    printf("/%-8s\t/%-6s\t/%s\n\n", "type", "bytes", "desc");
    printf("%-8s\t%-6lu\t%s\n", "size_t", (unsigned long)sizeof(unsigned long), "integral data type");
    printf("\n");
    printf("%-8s\t%-6lu\t%s\n", "char", (unsigned long)sizeof(char), "one character");
    printf("\n");
    printf("%-8s\t%-6lu\t%s\n", "int8_t", (unsigned long)sizeof(char), "standard int 8");
    printf("%-8s\t%-6lu\t%s\n", "int16_t", (unsigned long)sizeof(short), "standard int 16");
    printf("%-8s\t%-6lu\t%s\n", "int32_t", (unsigned long)sizeof(int), "standard int 32");
    printf("%-8s\t%-6lu\t%s\n", "int64_t", (unsigned long)sizeof(long), "standard int 64");
    printf("\n");
    printf("%-8s\t%-6lu\t%s\n", "short", (unsigned long)sizeof(short), "small integer");
    printf("%-8s\t%-6lu\t%s\n", "int", (unsigned long)sizeof(int), "integer");
    printf("%-8s\t%-6lu\t%s\n", "long", (unsigned long)sizeof(long), "big integer");
    printf("\n");
    printf("%-8s\t%-6lu\t%s\n", "float", (unsigned long)sizeof(float), "floating-point number");
    printf("%-8s\t%-6lu\t%s\n", "double", (unsigned long)sizeof(double), "double-precision floating-point number");
    printf("%-8s\t%-6lu\t%s\n", "long double", (unsigned long)sizeof(long double), "double-double-precision floating-point number");
    return 0;
}


repo: razpeitia/data-structures

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

result = malloc(0x18uLL);
if ( result )
{
*result = 0LL;
result[1] = 0LL;
*((_DWORD *)result + 4) = 0;
}
return result;
}

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

result = malloc(0x18uLL);
if ( result )
{
*result = 0LL;
result[1] = 0LL;
*((_DWORD *)result + 4) = 0;
}
return result;
}

original_code:
QUEUE* create_queue(){
    QUEUE *q = (QUEUE*) malloc(sizeof(QUEUE));
    if(q == ((void *)0))
        return q;
    q->back = ((void *)0);
    q->front = ((void *)0);
    q->size = 0;
    return q;
}

canonical_original_code:
struct queue *create_queue(){
    struct queue *q = (QUEUE*) malloc(sizeof(QUEUE));
    if(q == ((void *)0))
        return q;
    q->back = ((void *)0);
    q->front = ((void *)0);
    q->size = 0;
    return q;
}

variable_types: struct queue { struct node { struct node *next; int data; } *back; struct node *front; int size; } *

user_defined_types: struct queue { struct node *back; struct node *front; int size; }


enqueue

original_code:
void enqueue(QUEUE *q, int data){
    if(q == ((void *)0))
        return;
    NODE *pnew = (NODE*) malloc(sizeof(NODE));
    if(pnew == ((void *)0))
        return;
    pnew->data = data;
    pnew->next = ((void *)0);
    if(q->back == ((void *)0))
        q->front = pnew;
    else
        q->back->next = pnew;
    q->back = pnew;
    q->size++;
}

canonical_original_code:
void enqueue(struct queue *q, int data){
    if(q == ((void *)0))
        return;
    struct node *pnew = (NODE*) malloc(sizeof(NODE));
    if(pnew == ((void *)0))
        return;
    pnew->data = data;
    pnew->next = ((void *)0);
    if(q->back == ((void *)0))
        q->front = pnew;
    else
        q->back->next = pnew;
    q->back = pnew;
    q->size++;
}

variable_types: data int

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

return_type: void


dequeue

original_code:
void dequeue(QUEUE *q){
    if(q == ((void *)0) || q->front == ((void *)0))
        return;
    NODE *p = q->front;
    q->front = q->front->next;
    if(q->front == ((void *)0))
        q->back = ((void *)0);
    free(p);
    q->size--;
}

canonical_original_code:
void dequeue(struct queue *q){
    if(q == ((void *)0) || q->front == ((void *)0))
        return;
    struct node *p = q->front;
    q->front = q->front->next;
    if(q->front == ((void *)0))
        q->back = ((void *)0);
    free(p);
    q->size--;
}

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


decompiled_code:
int __fastcall print_queue(__int64 a1)
{
__int64 v1; // rax
__int64 **i; // rbx

if ( !a1 )
return puts("NULL");
v1 = *(_QWORD *)(a1 + 8);
if ( !v1 )
return puts("[]");
printf("[%d", *(unsigned int *)(v1 + 8));
for ( i = **(__int64 ****)(a1 + 8); i; i = (__int64 **)*i )
printf(" %d", *((unsigned int *)i + 2));
return puts("]");
}

original_code:
void print_queue(QUEUE *q){
    if(q == ((void *)0)){
        printf("NULL\n");
        return;
    }
    NODE *p;
    if(q->front == ((void *)0))
        printf("[]\n");
    else{
        printf("[%d", q->front->data);
        for(p = q->front->next; p != ((void *)0); p = p->next)
            printf(" %d", p->data);
        printf("]\n");
    }
}

canonical_original_code:
void print_queue(struct queue *q){
    if(q == ((void *)0)){
        printf("NULL\n");
        return;
    }
    struct node *p;
    if(q->front == ((void *)0))
        printf("[]\n");
    else{
        printf("[%d", q->front->data);
        for(p = q->front->next; p != ((void *)0); p = p->next)
            printf(" %d", p->data);
        printf("]\n");
    }
}


front

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

if ( a1 && (v1 = *(_QWORD *)(a1 + 8)) != 0 )
result = *(unsigned int *)(v1 + 8);
else
result = 0LL;
return result;
}

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

if ( a1 && (v1 = *(_QWORD *)(a1 + 8)) != 0 )
result = *(unsigned int *)(v1 + 8);
else
result = 0LL;
return result;
}

original_code:
int front(QUEUE *q){
    if(q == ((void *)0) || q->front == ((void *)0))
        return 0;
    return q->front->data;
}

canonical_original_code:
int front(struct queue *q){
    if(q == ((void *)0) || q->front == ((void *)0))
        return 0;
    return q->front->data;
}


back

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

if ( a1 && *(_QWORD *)a1 )
result = *(unsigned int *)(*(_QWORD *)a1 + 8LL);
else
result = 0LL;
return result;
}

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

if ( a1 && *(_QWORD *)a1 )
result = *(unsigned int *)(*(_QWORD *)a1 + 8LL);
else
result = 0LL;
return result;
}

original_code:
int back(QUEUE *q){
    if(q == ((void *)0) || q->back == ((void *)0))
        return 0;
    return q->back->data;
}

canonical_original_code:
int back(struct queue *q){
    if(q == ((void *)0) || q->back == ((void *)0))
        return 0;
    return q->back->data;
}


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

if ( a1 )
{
v2 = *a1;
if ( v2 )
{
while ( !empty((__int64)v2) )
{
dequeue((__int64)v2);
v2 = *a1;
}
free(v2);
*a1 = 0LL;
}
}
}

original_code:
void destroy_queue(QUEUE **q){
    if( q == ((void *)0) || *q == ((void *)0) )
        return;
    while( !empty(*q) )
        dequeue(*q);
    free(*q);
    *q = ((void *)0);
}

canonical_original_code:
void destroy_queue(struct queue **q){
    if( q == ((void *)0) || *q == ((void *)0) )
        return;
    while( !empty(*q) )
        dequeue(*q);
    free(*q);
    *q = ((void *)0);
}

variable_types: struct queue { struct node { struct node *next; int data; } *back; struct node *front; int size; } **


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // ebx
__int64 v4; // rsi
__int64 v6; // [rsp+8h] [rbp-10h] BYREF

v3 = 0;
v6 = create_queue(argc, argv, envp);
puts("ENQUEUE");
do
{
print_queue(v6);
v4 = v3++;
enqueue(v6, v4);
}
while ( v3 != 10 );
puts("DEQUEUE");
while ( !(unsigned int)empty(v6) )
{
print_queue(v6);
dequeue(v6);
}
print_queue(v6);
destroy_queue(&v6);
print_queue(v6);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // ebx
__int64 v4; // rsi
__int64 v6; // [rsp+8h] [rbp-10h] BYREF

v3 = 0;
v6 = func7(argc, argv, envp);
puts("ENQUEUE");
do
{
func11(v6);
v4 = v3++;
func9(v6, v4);
}
while ( v3 != 10 );
puts("DEQUEUE");
while ( !(unsigned int)func8(v6) )
{
func11(v6);
func10(v6);
}
func11(v6);
func14(&v6);
func11(v6);
return 0;
}

original_code:
int main(){
    QUEUE *q = create_queue();
    int i;
    printf("ENQUEUE\n");
    for(i = 0; i < 10; i++){
        print_queue(q);
        enqueue(q, i);
    }
    printf("DEQUEUE\n");
    while(!empty(q)){
        print_queue(q);
        dequeue(q);
    }
    print_queue(q);
    destroy_queue(&q);
    print_queue(q);
    return 0;
}

canonical_original_code:
int main(){
    struct queue *q = create_queue();
    int i;
    printf("ENQUEUE\n");
    for(i = 0; i < 10; i++){
        print_queue(q);
        enqueue(q, i);
    }
    printf("DEQUEUE\n");
    while(!empty(q)){
        print_queue(q);
        dequeue(q);
    }
    print_queue(q);
    destroy_queue(&q);
    print_queue(q);
    return 0;
}

variable_types: i int


empty

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

if ( a1 )
result = *(_QWORD *)(a1 + 8) == 0LL;
else
result = 1LL;
return result;
}

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

if ( a1 )
result = *(_QWORD *)(a1 + 8) == 0LL;
else
result = 1LL;
return result;
}

original_code:
int empty(QUEUE *q){
    if(q == ((void *)0) || q->front == ((void *)0))
        return 1;
    return 0;
}

canonical_original_code:
int empty(struct queue *q){
    if(q == ((void *)0) || q->front == ((void *)0))
        return 1;
    return 0;
}


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

result = malloc(0x10uLL);
if ( result )
{
*(_DWORD *)result = 0;
result[1] = 0LL;
}
return result;
}

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

result = malloc(0x10uLL);
if ( result )
{
*(_DWORD *)result = 0;
result[1] = 0LL;
}
return result;
}

original_code:
STACK* create_stack(){
    STACK *s = (STACK*) malloc(sizeof(STACK));
    if(s == ((void *)0))
        return s;
    s->size = 0;
    s->top = ((void *)0);
    return s;
}

canonical_original_code:
struct stack *create_stack(){
    struct stack *s = (STACK*) malloc(sizeof(STACK));
    if(s == ((void *)0))
        return s;
    s->size = 0;
    s->top = ((void *)0);
    return s;
}

variable_types: struct stack { int size; struct node { struct node *next; int data; } *top; } *

user_defined_types: struct stack { int size; struct node *top; }


push

original_code:
void push(STACK *s, int data){
    if(s == ((void *)0))
        return;
    NODE *p = (NODE*)malloc(sizeof(NODE));
    if(p == ((void *)0))
        return;
    p->data = data;
    p->next = s->top;
    s->top = p;
}

canonical_original_code:
void push(struct stack *s, int data){
    if(s == ((void *)0))
        return;
    struct node *p = (NODE*)malloc(sizeof(NODE));
    if(p == ((void *)0))
        return;
    p->data = data;
    p->next = s->top;
    s->top = p;
}


top

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

result = empty(a1);
if ( (_DWORD)result )
result = *(unsigned int *)(*(_QWORD *)(a1 + 8) + 8LL);
return result;
}

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

result = func8(a1);
if ( (_DWORD)result )
result = *(unsigned int *)(*(_QWORD *)(a1 + 8) + 8LL);
return result;
}

original_code:
int top(STACK *s){
    if(!empty(s))
        return 0;
    return s->top->data;
}

canonical_original_code:
int top(struct stack *s){
    if(!empty(s))
        return 0;
    return s->top->data;
}


decompiled_code:
int __fastcall print_stack(__int64 a1)
{
__int64 **i; // rbx

if ( !a1 )
return puts("NULL");
if ( empty(a1) )
return puts("[]");
printf("[%d", *(unsigned int *)(*(_QWORD *)(a1 + 8) + 8LL));
for ( i = **(__int64 ****)(a1 + 8); i; i = (__int64 **)*i )
printf(" %d", *((unsigned int *)i + 2));
return puts("]");
}

canonical_decompiled_code:
int __fastcall func12(__int64 a1)
{
__int64 **i; // rbx

if ( !a1 )
return puts("NULL");
if ( func8(a1) )
return puts("[]");
printf("[%d", *(unsigned int *)(*(_QWORD *)(a1 + 8) + 8LL));
for ( i = **(__int64 ****)(a1 + 8); i; i = (__int64 **)*i )
printf(" %d", *((unsigned int *)i + 2));
return puts("]");
}

original_code:
void print_stack(STACK *s){
    NODE *p;
    if(s == ((void *)0)){
        printf("NULL\n");
        return;
    }
    if(empty(s)){
        printf("[]\n");
        return;
    }
    else{
        printf("[%d", s->top->data);
        for(p = s->top->next; p != ((void *)0); p = p->next)
            printf(" %d", p->data);
        printf("]\n");
    }
}

canonical_original_code:
void print_stack(struct stack *s){
    struct node *p;
    if(s == ((void *)0)){
        printf("NULL\n");
        return;
    }
    if(empty(s)){
        printf("[]\n");
        return;
    }
    else{
        printf("[%d", s->top->data);
        for(p = s->top->next; p != ((void *)0); p = p->next)
            printf(" %d", p->data);
        printf("]\n");
    }
}


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

if ( a1 )
{
v2 = *a1;
if ( v2 )
{
while ( !empty((__int64)v2) )
{
pop((__int64)v2);
v2 = *a1;
}
free(v2);
*a1 = 0LL;
}
}
}

original_code:
void destroy_stack(STACK **s){
    if(s == ((void *)0) || *s == ((void *)0))
        return;
    while(!empty(*s))
        pop(*s);
    free(*s);
    *s = ((void *)0);
}

canonical_original_code:
void destroy_stack(struct stack **s){
    if(s == ((void *)0) || *s == ((void *)0))
        return;
    while(!empty(*s))
        pop(*s);
    free(*s);
    *s = ((void *)0);
}

variable_types: struct stack { int size; struct node { struct node *next; int data; } *top; } **


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // ebx
__int64 v4; // rsi
__int64 v6; // [rsp+8h] [rbp-10h] BYREF

v3 = 0;
v6 = create_stack(argc, argv, envp);
puts("PUSH TIME");
do
{
print_stack(v6);
v4 = v3++;
push(v6, v4);
}
while ( v3 != 10 );
puts("POP TIME");
while ( !(unsigned int)empty(v6) )
{
print_stack(v6);
pop(v6);
}
print_stack(v6);
destroy_stack(&v6);
print_stack(v6);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // ebx
__int64 v4; // rsi
__int64 v6; // [rsp+8h] [rbp-10h] BYREF

v3 = 0;
v6 = func7(argc, argv, envp);
puts("PUSH TIME");
do
{
func12(v6);
v4 = v3++;
func9(v6, v4);
}
while ( v3 != 10 );
puts("POP TIME");
while ( !(unsigned int)func8(v6) )
{
func12(v6);
func10(v6);
}
func12(v6);
func13(&v6);
func12(v6);
return 0;
}

original_code:
int main(){
    STACK *s = create_stack();
    int i;
    printf("PUSH TIME\n");
    for(i = 0; i < 10; i++){
        print_stack(s);
        push(s, i);
    }
    printf("POP TIME\n");
    while( !empty(s) ){
        print_stack(s);
        pop(s);
    }
    print_stack(s);
    destroy_stack(&s);
    print_stack(s);
    return 0;
}

canonical_original_code:
int main(){
    struct stack *s = create_stack();
    int i;
    printf("PUSH TIME\n");
    for(i = 0; i < 10; i++){
        print_stack(s);
        push(s, i);
    }
    printf("POP TIME\n");
    while( !empty(s) ){
        print_stack(s);
        pop(s);
    }
    print_stack(s);
    destroy_stack(&s);
    print_stack(s);
    return 0;
}


empty

original_code:
int empty(STACK *s){
    if(s == ((void *)0) || s->top == ((void *)0))
        return 1;
    return 0;
}

canonical_original_code:
int empty(struct stack *s){
    if(s == ((void *)0) || s->top == ((void *)0))
        return 1;
    return 0;
}


pop

original_code:
void pop(STACK *s){
    if(s == ((void *)0))
        return;
    if(!empty(s)){
        NODE *p;
        p = s->top;
        s->top = p->next;
        free(p);
    }
}

canonical_original_code:
void pop(struct stack *s){
    if(s == ((void *)0))
        return;
    if(!empty(s)){
        struct node *p;
        p = s->top;
        s->top = p->next;
        free(p);
    }
}


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

result = malloc(8uLL);
if ( result )
*result = 0LL;
return result;
}

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

result = malloc(8uLL);
if ( result )
*result = 0LL;
return result;
}

original_code:
TREE* create_tree(){
    TREE *t = (TREE*) malloc(sizeof(TREE));
    if(t == ((void *)0))
        return t;
    t->root = ((void *)0);
    return t;
}

canonical_original_code:
struct tree *create_tree(){
    struct tree *t = (TREE*) malloc(sizeof(TREE));
    if(t == ((void *)0))
        return t;
    t->root = ((void *)0);
    return t;
}

variable_types: struct tree { struct node { struct node *left; struct node *right; int data; } *root; } *


add

original_code:
void add(NODE *root, NODE *p){
    if(root->data > p->data){
        if(root->left == ((void *)0))
            root->left = p;
        else
            add(root->left, p);
    }
    else if(root->data < p->data){
        if(root->right == ((void *)0))
            root->right = p;
        else
            add(root->right, p);
    }
}

canonical_original_code:
void add(struct node *root, struct node *p){
    if(root->data > p->data){
        if(root->left == ((void *)0))
            root->left = p;
        else
            add(root->left, p);
    }
    else if(root->data < p->data){
        if(root->right == ((void *)0))
            root->right = p;
        else
            add(root->right, p);
    }
}

variable_types: struct node { struct node *left; struct node *right; int data; } *

variable_types:
p
struct node *


original_code:
void add_node(TREE *t, int value){
    if(t == ((void *)0))
        return;
    NODE *p = (NODE*)malloc(sizeof(NODE));
    if(p == ((void *)0))
        return;
    p->left = p->right = ((void *)0);
    p->data = value;
    if(t->root == ((void *)0))
        t->root = p;
    else
        add(t->root, p);
}

canonical_original_code:
void add_node(struct tree *t, int value){
    if(t == ((void *)0))
        return;
    struct node *p = (NODE*)malloc(sizeof(NODE));
    if(p == ((void *)0))
        return;
    p->left = p->right = ((void *)0);
    p->data = value;
    if(t->root == ((void *)0))
        t->root = p;
    else
        add(t->root, p);
}

variable_types: value int

user_defined_types: struct node { struct node *left; struct node *right; int data; }


pre

decompiled_code:
__int64 __fastcall pre(__int64 a1)
{
__int64 v1; // rbx
__int64 result; // rax

if ( a1 )
{
v1 = a1;
do
{
printf("%d ", *(unsigned int *)(v1 + 16));
result = pre(*(_QWORD *)v1);
v1 = *(_QWORD *)(v1 + 8);
}
while ( v1 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1)
{
__int64 v1; // rbx
__int64 result; // rax

if ( a1 )
{
v1 = a1;
do
{
printf("%d ", *(unsigned int *)(v1 + 16));
result = func10(*(_QWORD *)v1);
v1 = *(_QWORD *)(v1 + 8);
}
while ( v1 );
}
return result;
}

original_code:
void pre(NODE *root){
    if(root != ((void *)0)){
        printf("%d ", root->data);
        pre(root->left);
        pre(root->right);
    }
}

canonical_original_code:
void pre(struct node *root){
    if(root != ((void *)0)){
        printf("%d ", root->data);
        pre(root->left);
        pre(root->right);
    }
}


decompiled_code:
int __fastcall pre_orden(__int64 *a1)
{
if ( !a1 )
return puts("NULL");
putchar(123);
pre(*a1);
putchar(125);
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func11(__int64 *a1)
{
if ( !a1 )
return puts("NULL");
putchar(123);
func10(*a1);
putchar(125);
return putchar(10);
}

original_code:
void pre_orden(TREE *t){
    if(t == ((void *)0)){
        printf("NULL\n");
        return;
    }
    printf("{");
    pre(t->root);
    printf("}");
    printf("\n");
}

canonical_original_code:
void pre_orden(struct tree *t){
    if(t == ((void *)0)){
        printf("NULL\n");
        return;
    }
    printf("{");
    pre(t->root);
    printf("}");
    printf("\n");
}


in

decompiled_code:
int __fastcall in(__int64 a1)
{
__int64 v1; // rbx
int result; // eax

if ( a1 )
{
v1 = a1;
do
{
in(*(_QWORD *)v1);
result = printf("%d ", *(unsigned int *)(v1 + 16));
v1 = *(_QWORD *)(v1 + 8);
}
while ( v1 );
}
return result;
}

canonical_decompiled_code:
int __fastcall func12(__int64 a1)
{
__int64 v1; // rbx
int result; // eax

if ( a1 )
{
v1 = a1;
do
{
func12(*(_QWORD *)v1);
result = printf("%d ", *(unsigned int *)(v1 + 16));
v1 = *(_QWORD *)(v1 + 8);
}
while ( v1 );
}
return result;
}

original_code:
void in(NODE *root){
    if(root != ((void *)0)){
        in(root->left);
        printf("%d ", root->data);
        in(root->right);
    }
}

canonical_original_code:
void in(struct node *root){
    if(root != ((void *)0)){
        in(root->left);
        printf("%d ", root->data);
        in(root->right);
    }
}


decompiled_code:
int __fastcall in_orden(__int64 *a1)
{
if ( !a1 )
return puts("NULL");
putchar(123);
in(*a1);
putchar(125);
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func13(__int64 *a1)
{
if ( !a1 )
return puts("NULL");
putchar(123);
func12(*a1);
putchar(125);
return putchar(10);
}

original_code:
void in_orden(TREE *t){
    if(t == ((void *)0)){
        printf("NULL\n");
        return;
    }
    printf("{");
    in(t->root);
    printf("}");
    printf("\n");
}

canonical_original_code:
void in_orden(struct tree *t){
    if(t == ((void *)0)){
        printf("NULL\n");
        return;
    }
    printf("{");
    in(t->root);
    printf("}");
    printf("\n");
}


post

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

if ( a1 )
{
post(*(_QWORD *)a1);
post(*(_QWORD *)(a1 + 8));
result = printf("%d ", *(unsigned int *)(a1 + 16));
}
return result;
}

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

if ( a1 )
{
func14(*(_QWORD *)a1);
func14(*(_QWORD *)(a1 + 8));
result = printf("%d ", *(unsigned int *)(a1 + 16));
}
return result;
}

original_code:
void post(NODE *root){
    if(root != ((void *)0)){
        post(root->left);
        post(root->right);
        printf("%d ",root->data);
    }
}

canonical_original_code:
void post(struct node *root){
    if(root != ((void *)0)){
        post(root->left);
        post(root->right);
        printf("%d ",root->data);
    }
}


decompiled_code:
int __fastcall post_orden(__int64 *a1)
{
if ( !a1 )
return puts("NULL");
putchar(123);
post(*a1);
putchar(125);
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func15(__int64 *a1)
{
if ( !a1 )
return puts("NULL");
putchar(123);
func14(*a1);
putchar(125);
return putchar(10);
}

original_code:
void post_orden(TREE *t){
    if(t == ((void *)0)){
        printf("NULL\n");
        return;
    }
    printf("{");
    post(t->root);
    printf("}");
    printf("\n");
}

canonical_original_code:
void post_orden(struct tree *t){
    if(t == ((void *)0)){
        printf("NULL\n");
        return;
    }
    printf("{");
    post(t->root);
    printf("}");
    printf("\n");
}


min

decompiled_code:
int __fastcall min(__int64 **a1)
{
while ( 1 )
{
if ( !a1 )
return puts("Empty");
if ( !*a1 )
break;
a1 = (__int64 **)*a1;
}
return printf("Min = %d\n", *((unsigned int *)a1 + 4));
}

canonical_decompiled_code:
int __fastcall func16(__int64 **a1)
{
while ( 1 )
{
if ( !a1 )
return puts("Empty");
if ( !*a1 )
break;
a1 = (__int64 **)*a1;
}
return printf("Min = %d\n", *((unsigned int *)a1 + 4));
}

original_code:
void min(NODE *root){
    if(root == ((void *)0)){
        printf("Empty\n");
        return;
    }
    if(root->left == ((void *)0))
       printf("Min = %d\n", root->data);
    else
        min(root->left);
}

canonical_original_code:
void min(struct node *root){
    if(root == ((void *)0)){
        printf("Empty\n");
        return;
    }
    if(root->left == ((void *)0))
       printf("Min = %d\n", root->data);
    else
        min(root->left);
}


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

if ( a1 )
result = min(*a1);
else
result = puts("NULL");
return result;
}

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

if ( a1 )
result = func16(*a1);
else
result = puts("NULL");
return result;
}

original_code:
void min_value(TREE *t){
    if(t == ((void *)0)){
        printf("NULL\n");
        return;
    }
    min(t->root);
}

canonical_original_code:
void min_value(struct tree *t){
    if(t == ((void *)0)){
        printf("NULL\n");
        return;
    }
    min(t->root);
}


max

decompiled_code:
int __fastcall max(__int64 a1)
{
while ( 1 )
{
if ( !a1 )
return puts("Empty");
if ( !*(_QWORD *)(a1 + 8) )
break;
a1 = *(_QWORD *)(a1 + 8);
}
return printf("Max = %d\n", *(unsigned int *)(a1 + 16));
}

canonical_decompiled_code:
int __fastcall func18(__int64 a1)
{
while ( 1 )
{
if ( !a1 )
return puts("Empty");
if ( !*(_QWORD *)(a1 + 8) )
break;
a1 = *(_QWORD *)(a1 + 8);
}
return printf("Max = %d\n", *(unsigned int *)(a1 + 16));
}

original_code:
void max(NODE *root){
    if(root == ((void *)0)){
        printf("Empty\n");
        return;
    }
    if(root->right == ((void *)0))
        printf("Max = %d\n", root->data);
    else
        max(root->right);
}

canonical_original_code:
void max(struct node *root){
    if(root == ((void *)0)){
        printf("Empty\n");
        return;
    }
    if(root->right == ((void *)0))
        printf("Max = %d\n", root->data);
    else
        max(root->right);
}


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

if ( a1 )
result = max(*a1);
else
result = puts("NULL");
return result;
}

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

if ( a1 )
result = func18(*a1);
else
result = puts("NULL");
return result;
}

original_code:
void max_value(TREE *t){
    if(t == ((void *)0)){
        printf("NULL\n");
        return;
    }
    max(t->root);
}

canonical_original_code:
void max_value(struct tree *t){
    if(t == ((void *)0)){
        printf("NULL\n");
        return;
    }
    max(t->root);
}


destroy

decompiled_code:
void __fastcall destroy(void *ptr)
{
if ( ptr )
{
destroy(*(void **)ptr);
destroy(*((void **)ptr + 1));
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func20(void *ptr)
{
if ( ptr )
{
func20(*(void **)ptr);
func20(*((void **)ptr + 1));
free(ptr);
}
}

original_code:
void destroy(NODE *root){
    if(root != ((void *)0)){
        destroy(root->left);
        destroy(root->right);
        free(root);
    }
}

canonical_original_code:
void destroy(struct node *root){
    if(root != ((void *)0)){
        destroy(root->left);
        destroy(root->right);
        free(root);
    }
}


decompiled_code:
void __fastcall destroy_tree(void *ptr)
{
if ( ptr )
{
destroy(*(void **)ptr);
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func21(void *ptr)
{
if ( ptr )
{
func20(*(void **)ptr);
free(ptr);
}
}

original_code:
void destroy_tree(TREE* t){
    if(t == ((void *)0))
        return;
    destroy(t->root);
    free(t);
}

canonical_original_code:
void destroy_tree(struct tree *t){
    if(t == ((void *)0))
        return;
    destroy(t->root);
    free(t);
}


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
void *v3; // rbp

v3 = (void *)create_tree(argc, argv, envp);
add_node(v3, 4LL);
add_node(v3, 3LL);
add_node(v3, 9LL);
add_node(v3, 5LL);
add_node(v3, 8LL);
add_node(v3, 2LL);
add_node(v3, 0LL);
add_node(v3, 6LL);
add_node(v3, 7LL);
add_node(v3, 1LL);
puts("PREORDEN");
pre_orden(v3);
puts("INORDEN");
in_orden(v3);
puts("POSTORDEN");
post_orden(v3);
min_value(v3);
max_value(v3);
destroy_tree(v3);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
void *v3; // rbp

v3 = (void *)func7(argc, argv, envp);
func9(v3, 4LL);
func9(v3, 3LL);
func9(v3, 9LL);
func9(v3, 5LL);
func9(v3, 8LL);
func9(v3, 2LL);
func9(v3, 0LL);
func9(v3, 6LL);
func9(v3, 7LL);
func9(v3, 1LL);
puts("PREORDEN");
func11(v3);
puts("INORDEN");
func13(v3);
puts("POSTORDEN");
func15(v3);
func17(v3);
func19(v3);
func21(v3);
return 0;
}

original_code:
int main(){
    TREE *t;
    t = create_tree();
    add_node(t, 4);
    add_node(t, 3);
    add_node(t, 9);
    add_node(t, 5);
    add_node(t, 8);
    add_node(t, 2);
    add_node(t, 0);
    add_node(t, 6);
    add_node(t, 7);
    add_node(t, 1);
    printf("PREORDEN\n");
    pre_orden(t);
    printf("INORDEN\n");
    in_orden(t);
    printf("POSTORDEN\n");
    post_orden(t);
    min_value(t);
    max_value(t);
    destroy_tree(t);
    return 0;
}

canonical_original_code:
int main(){
    struct tree *t;
    t = create_tree();
    add_node(t, 4);
    add_node(t, 3);
    add_node(t, 9);
    add_node(t, 5);
    add_node(t, 8);
    add_node(t, 2);
    add_node(t, 0);
    add_node(t, 6);
    add_node(t, 7);
    add_node(t, 1);
    printf("PREORDEN\n");
    pre_orden(t);
    printf("INORDEN\n");
    in_orden(t);
    printf("POSTORDEN\n");
    post_orden(t);
    min_value(t);
    max_value(t);
    destroy_tree(t);
    return 0;
}


insert

decompiled_code:
void insert()
{
;
}

canonical_decompiled_code:
void func8()
{
;
}

original_code:
void insert(LIST *l, int index){
}

canonical_original_code:
void insert(struct list *l, int index){
}

variable_types: struct list { struct node { struct node *next; int data; } *next; long long size; short empty; } *

variable_types: index int

user_defined_types: struct list { struct node *next; long long size; short empty; }


decompiled_code:
int __fastcall print_list(__int64 ***a1)
{
__int64 **v1; // rbx

if ( !a1 )
return puts("NULL");
v1 = *a1;
putchar(91);
if ( v1 )
{
printf("%d", *((unsigned int *)v1 + 2));
while ( 1 )
{
v1 = (__int64 **)*v1;
if ( !v1 )
break;
printf(", %d", *((unsigned int *)v1 + 2));
}
}
return puts("]\n");
}

canonical_decompiled_code:
int __fastcall func11(__int64 ***a1)
{
__int64 **v1; // rbx

if ( !a1 )
return puts("NULL");
v1 = *a1;
putchar(91);
if ( v1 )
{
printf("%d", *((unsigned int *)v1 + 2));
while ( 1 )
{
v1 = (__int64 **)*v1;
if ( !v1 )
break;
printf(", %d", *((unsigned int *)v1 + 2));
}
}
return puts("]\n");
}

original_code:
void print_list(LIST *l){
    NODE *p;
    if(l == ((void *)0)){
        printf("NULL\n");
        return;
    }
    p = l->next;
    printf("[");
    if(p != ((void *)0)){
        printf("%d", p->data);
        p = p->next;
    }
    while(p != ((void *)0)){
        printf(", %d", p->data);
        p = p->next;
    }
    printf("]\n\n");
}

canonical_original_code:
void print_list(struct list *l){
    struct node *p;
    if(l == ((void *)0)){
        printf("NULL\n");
        return;
    }
    p = l->next;
    printf("[");
    if(p != ((void *)0)){
        printf("%d", p->data);
        p = p->next;
    }
    while(p != ((void *)0)){
        printf(", %d", p->data);
        p = p->next;
    }
    printf("]\n\n");
}


decompiled_code:
int __fastcall print_pointers(const void **a1)
{
const void **v1; // rbx

v1 = a1;
puts(" LIST ");
if ( !a1 )
puts("NULL");
while ( 1 )
{
v1 = (const void **)*v1;
if ( !v1 )
break;
printf("%p -> %p\n", v1, *v1);
}
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func12(const void **a1)
{
const void **v1; // rbx

v1 = a1;
puts(" LIST ");
if ( !a1 )
puts("NULL");
while ( 1 )
{
v1 = (const void **)*v1;
if ( !v1 )
break;
printf("%p -> %p\n", v1, *v1);
}
return putchar(10);
}

original_code:
void print_pointers(LIST *l){
    NODE *p;
    printf("       LIST        \n");
    if(l == ((void *)0))
        printf("NULL\n");
    p = l->next;
    while(p != ((void *)0)){
        printf("%p -> %p\n", p, p->next);
        p = p->next;
    }
    printf("\n");
}

canonical_original_code:
void print_pointers(struct list *l){
    struct node *p;
    printf("       LIST        \n");
    if(l == ((void *)0))
        printf("NULL\n");
    p = l->next;
    while(p != ((void *)0)){
        printf("%p -> %p\n", p, p->next);
        p = p->next;
    }
    printf("\n");
}


main

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

v3 = create_list(argc, argv, envp);
if ( v3 )
{
v4 = (void *)v3;
print_list(v3);
append(v4, 1LL);
print_list(v4);
append(v4, 2LL);
print_list(v4);
append(v4, 3LL);
print_list(v4);
v5 = search(v4, 1LL);
if ( v5 )
*(_DWORD *)(v5 + 8) = 4;
print_list(v4);
delete(v4);
print_list(v4);
delete(v4);
print_list(v4);
delete(v4);
print_list(v4);
destroy_list(v4);
result = 0;
}
else
{
puts("Run out of memory x_x");
result = 1;
}
return result;
}

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

v3 = func7(argc, argv, envp);
if ( v3 )
{
v4 = (void *)v3;
func11(v3);
append(v4, 1LL);
func11(v4);
append(v4, 2LL);
func11(v4);
append(v4, 3LL);
func11(v4);
v5 = search(v4, 1LL);
if ( v5 )
*(_DWORD *)(v5 + 8) = 4;
func11(v4);
func9(v4);
func11(v4);
func9(v4);
func11(v4);
func9(v4);
func11(v4);
func10(v4);
result = 0;
}
else
{
puts("Run out of memory x_x");
result = 1;
}
return result;
}

original_code:
int main(){
    LIST *l = create_list();
    NODE *p;
    if(l == ((void *)0)){
        printf("Run out of memory x_x\n");
        return 1;
    }
    print_list(l);
    append(l, 1);
    print_list(l);
    append(l, 2);
    print_list(l);
    append(l, 3);
    print_list(l);
    p = search(l, 1);
    if( p != ((void *)0) )
        p->data = 4;
    print_list(l);
    delete(l);
    print_list(l);
    delete(l);
    print_list(l);
    delete(l);
    print_list(l);
    destroy_list(l);
    return 0;
}

canonical_original_code:
int main(){
    struct list *l = create_list();
    struct node *p;
    if(l == ((void *)0)){
        printf("Run out of memory x_x\n");
        return 1;
    }
    print_list(l);
    append(l, 1);
    print_list(l);
    append(l, 2);
    print_list(l);
    append(l, 3);
    print_list(l);
    p = search(l, 1);
    if( p != ((void *)0) )
        p->data = 4;
    print_list(l);
    delete(l);
    print_list(l);
    delete(l);
    print_list(l);
    delete(l);
    print_list(l);
    destroy_list(l);
    return 0;
}


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

result = malloc(0x18uLL);
if ( result )
{
*result = 0LL;
result[1] = 0LL;
*((_WORD *)result + 8) = 1;
}
return result;
}

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

result = malloc(0x18uLL);
if ( result )
{
*result = 0LL;
result[1] = 0LL;
*((_WORD *)result + 8) = 1;
}
return result;
}

original_code:
LIST* create_list(){
    LIST *l = malloc(sizeof(LIST));
    if(l == ((void *)0))
        return l;
    l->next = ((void *)0);
    l->size = 0;
    l->empty = 1;
    return l;
}

canonical_original_code:
struct list *create_list(){
    struct list *l = malloc(sizeof(LIST));
    if(l == ((void *)0))
        return l;
    l->next = ((void *)0);
    l->size = 0;
    l->empty = 1;
    return l;
}

return_type: struct list { struct node { struct node *next; int data; } *next; long long size; short empty; } *


decompiled_code:
void __fastcall destroy_list(void *ptr)
{
_QWORD *v2; // rbx
void *v3; // rdi

if ( ptr )
{
v2 = *(_QWORD **)ptr;
if ( *(_QWORD *)ptr )
{
do
{
v3 = v2;
v2 = (_QWORD *)*v2;
free(v3);
}
while ( v2 );
}
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func10(void *ptr)
{
_QWORD *v2; // rbx
void *v3; // rdi

if ( ptr )
{
v2 = *(_QWORD **)ptr;
if ( *(_QWORD *)ptr )
{
do
{
v3 = v2;
v2 = (_QWORD *)*v2;
free(v3);
}
while ( v2 );
}
free(ptr);
}
}

original_code:
void destroy_list(LIST* l){
    NODE *p, *aux;
    if(l == ((void *)0))
        return;
    p = l->next;
    while(p != ((void *)0)){
        aux = p->next;
        free(p);
        p = aux;
    }
    free(l);
}

canonical_original_code:
void destroy_list(struct list *l){
    struct node *p; struct node *aux;
    if(l == ((void *)0))
        return;
    p = l->next;
    while(p != ((void *)0)){
        aux = p->next;
        free(p);
        p = aux;
    }
    free(l);
}


fordward

decompiled_code:
int __fastcall fordward(__int64 **a1)
{
__int64 *v1; // rbx

if ( !a1 )
return puts("NULL");
v1 = *a1;
if ( !*a1 )
return puts("Empty");
do
{
printf("%d ", *((unsigned int *)v1 + 4));
v1 = (__int64 *)*v1;
}
while ( *a1 != v1 );
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func10(__int64 **a1)
{
__int64 *v1; // rbx

if ( !a1 )
return puts("NULL");
v1 = *a1;
if ( !*a1 )
return puts("Empty");
do
{
printf("%d ", *((unsigned int *)v1 + 4));
v1 = (__int64 *)*v1;
}
while ( *a1 != v1 );
return putchar(10);
}

original_code:
void fordward(LIST *l){
    if(l == ((void *)0)){
        printf("NULL\n");
        return;
    }
    if(l->first == ((void *)0)){
        printf("Empty\n");
        return;
    }
    else{
        NODE *p = l->first;
        do{
            printf("%d ", p->data);
            p = p->next;
        }while(p != l->first);
        printf("\n");
    }
}

canonical_original_code:
void fordward(struct list *l){
    if(l == ((void *)0)){
        printf("NULL\n");
        return;
    }
    if(l->first == ((void *)0)){
        printf("Empty\n");
        return;
    }
    else{
        struct node *p = l->first;
        do{
            printf("%d ", p->data);
            p = p->next;
        }while(p != l->first);
        printf("\n");
    }
}

variable_types: struct list { struct node { struct node *next; struct node *prev; int data; } *first; struct node *last; unsigned long long size; } *

user_defined_types: struct list { struct node *first; struct node *last; unsigned long long size; }


backward

decompiled_code:
int __fastcall backward(__int64 a1)
{
__int64 v1; // rbx

if ( !a1 )
return puts("NULL");
v1 = *(_QWORD *)(a1 + 8);
if ( !v1 )
return puts("Empty");
do
{
printf("%d ", *(unsigned int *)(v1 + 16));
v1 = *(_QWORD *)(v1 + 8);
}
while ( *(_QWORD *)(a1 + 8) != v1 );
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func11(__int64 a1)
{
__int64 v1; // rbx

if ( !a1 )
return puts("NULL");
v1 = *(_QWORD *)(a1 + 8);
if ( !v1 )
return puts("Empty");
do
{
printf("%d ", *(unsigned int *)(v1 + 16));
v1 = *(_QWORD *)(v1 + 8);
}
while ( *(_QWORD *)(a1 + 8) != v1 );
return putchar(10);
}

original_code:
void backward(LIST *l){
    if(l == ((void *)0)){
        printf("NULL\n");
        return;
    }
    if(l->last == ((void *)0)){
        printf("Empty\n");
        return;
    }
    else{
        NODE *p = l->last;
        do{
            printf("%d ", p->data);
            p = p->prev;
        }while(p != l->last);
        printf("\n");
    }
}

canonical_original_code:
void backward(struct list *l){
    if(l == ((void *)0)){
        printf("NULL\n");
        return;
    }
    if(l->last == ((void *)0)){
        printf("Empty\n");
        return;
    }
    else{
        struct node *p = l->last;
        do{
            printf("%d ", p->data);
            p = p->prev;
        }while(p != l->last);
        printf("\n");
    }
}

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


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // ebx
void *v4; // rbp
__int64 v5; // rsi

v3 = 0;
v4 = (void *)create_list(argc, argv, envp);
do
{
v5 = v3++;
append(v4, v5);
fordward(v4);
}
while ( v3 != 5 );
destroy_list(v4);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // ebx
void *v4; // rbp
__int64 v5; // rsi

v3 = 0;
v4 = (void *)func7(argc, argv, envp);
do
{
v5 = v3++;
func8(v4, v5);
func10(v4);
}
while ( v3 != 5 );
func12(v4);
return 0;
}

original_code:
int main(){
    int i;
    LIST *l = create_list();
    for(i = 0; i < 5; i++){
        append(l, i);
        fordward(l);
    }
    destroy_list(l);
    return 0;
}

canonical_original_code:
int main(){
    int i;
    struct list *l = create_list();
    for(i = 0; i < 5; i++){
        append(l, i);
        fordward(l);
    }
    destroy_list(l);
    return 0;
}

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