callocTmpAlloc

decompiled_code:
char *__fastcall callocTmpAlloc(__int64 a1, __int64 a2)
{
unsigned __int64 v2; // rsi
char *v3; // rax
char *v4; // rbx

v2 = a1 * a2;
v3 = mallocTmpAlloc(v2);
v4 = v3;
if ( v3 )
memset(v3, 0, v2);
return v4;
}

canonical_decompiled_code:
char *__fastcall func3(__int64 a1, __int64 a2)
{
unsigned __int64 v2; // rsi
char *v3; // rax
char *v4; // rbx

v2 = a1 * a2;
v3 = func2(v2);
v4 = v3;
if ( v3 )
memset(v3, 0, v2);
return v4;
}

original_code:
static void * callocTmpAlloc( size_t in_qty, size_t in_size ) {
 in_size *= in_qty;
 void * ret = mallocTmpAlloc( in_size );
 if( ret ) {
  memset( ret, 0, in_size );
 }
 return ret;
}

canonical_original_code:
static void *callocTmpAlloc(unsigned long in_qty, unsigned long in_size) {
 in_size *= in_qty;
 void *ret = mallocTmpAlloc( in_size );
 if( ret ) {
  memset( ret, 0, in_size );
 }
 return ret;
}


tmpAllocRemaining

repo: AlexanderHaase/mprof

decompiled_code:
void *tmpAllocRemaining()
{
return tmpRemaining;
}

canonical_decompiled_code:
void *func4()
{
return tmpRemaining;
}

original_code: size_t tmpAllocRemaining( void ) { return tmpRemaining; }

canonical_original_code: unsigned long tmpAllocRemaining() { return tmpRemaining; }

return_type: unsigned long


repo: Alexanderbez/Multi-Merge-Sort

decompiled_code:
__int64 __fastcall int_cmp(_DWORD *a1, _DWORD *a2)
{
return (unsigned int)(*a1 - *a2);
}

canonical_decompiled_code:
__int64 __fastcall func0(_DWORD *a1, _DWORD *a2)
{
return (unsigned int)(*a1 - *a2);
}

original_code:
int int_cmp(const void *a, const void *b)
{
    int first = *(int *)a, second = *(int *)b;
    return first - second;
}

canonical_original_code:
int int_cmp(void *a, void *b)
{
    int first = *(int *)a; int second = *(int *)b;
    return first - second;
}

variable_types:
a
void *

variable_types:
b
void *

variable_types: first int

variable_types: second int

return_type: int


decompiled_code:
__int64 __fastcall tv_diff(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 result; // rax

result = a3 - a1;
if ( a4 - a2 < 0 )
--result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 result; // rax

result = a3 - a1;
if ( a4 - a2 < 0 )
--result;
return result;
}

original_code:
static struct timeval tv_diff(struct timeval start, struct timeval end)
{
    struct timeval delta = end;
    delta.tv_sec -= start.tv_sec;
    delta.tv_usec -= start.tv_usec;
    if (delta.tv_usec < 0) {
        delta.tv_usec += 1000000;
        delta.tv_sec--;
    }
    return delta;
}

variable_types:
start
struct timeval

variable_types:
end
struct timeval

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


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // er14
int v4; // ebp
size_t v5; // rbx
_DWORD *v6; // r15
_DWORD *v7; // r14
_DWORD *v8; // r13
_DWORD *v9; // r12
__int64 i; // rbx
int v11; // eax
__int64 v12; // rbx
__int64 v13; // rdx
__int64 v14; // rbp
__int64 v15; // rdx
__int64 v16; // r15
__int64 v17; // rdx
__int64 v18; // rbx
__int64 v19; // rdx
__int64 v20; // rbp
__int64 v21; // rdx
__int64 v22; // r15
__int64 v23; // rdx
__int64 v24; // r14
__int64 v25; // rbx
__int64 v26; // rdx
__int64 v27; // rbp
__int64 v28; // rdx
__int64 v29; // r15
__int64 v30; // rdx
__int64 v31; // r13
__int64 v32; // rbx
__int64 v33; // rdx
__int64 v34; // rbp
__int64 v35; // r13
__int64 v36; // rdx
__int64 v37; // r15
__int64 v38; // r12
__int64 v39; // rdx
__int64 v40; // r14
int v42; // [rsp+0h] [rbp-198h]
__int64 v43; // [rsp+0h] [rbp-198h]
__int64 v44; // [rsp+0h] [rbp-198h]
__int64 v45; // [rsp+0h] [rbp-198h]
int seed; // [rsp+8h] [rbp-190h]
__int64 seeda; // [rsp+8h] [rbp-190h]
__int64 seedb; // [rsp+8h] [rbp-190h]
__int64 seedc; // [rsp+8h] [rbp-190h]
__int64 v50; // [rsp+10h] [rbp-188h]
__int64 v51; // [rsp+18h] [rbp-180h]
struct timeval v52; // [rsp+20h] [rbp-178h] BYREF
struct timeval tv; // [rsp+30h] [rbp-168h] BYREF
struct rusage v54; // [rsp+40h] [rbp-158h] BYREF
struct rusage usage; // [rsp+D0h] [rbp-C8h] BYREF

v3 = atoi(argv[1]);
seed = atoi(argv[2]);
v4 = atoi(argv[3]);
v42 = v3;
v50 = v3;
v5 = 4LL * v3;
v6 = malloc(v5);
v7 = malloc(v5);
v8 = malloc(v5);
v9 = malloc(v5);
srand(seed);
if ( v42 > 0 )
{
for ( i = 0LL; i != v42; v9[i++] = v11 % v4 )
{
v11 = rand();
v6[i] = v11 % v4;
v7[i] = v11 % v4;
v8[i] = v11 % v4;
}
}
gettimeofday(&tv, 0LL);
getrusage(RUSAGE_SELF, &usage);
mergesort(v6, v50, 4LL, int_cmp);
gettimeofday(&v52, 0LL);
getrusage(RUSAGE_SELF, &v54);
v12 = tv_diff(tv.tv_sec, tv.tv_usec, v52.tv_sec, v52.tv_usec);
v14 = v13;
v43 = tv_diff(usage.ru_utime.tv_sec, usage.ru_utime.tv_usec, v54.ru_utime.tv_sec, v54.ru_utime.tv_usec);
v16 = v15;
seeda = tv_diff(usage.ru_stime.tv_sec, usage.ru_stime.tv_usec, v54.ru_stime.tv_sec, v54.ru_stime.tv_usec);
v51 = v17;
printf("0 threads: ");
printf("%d.%06ds wall; ", v12, v14);
printf("%d.%06ds user; ", v43, v16);
printf("%d.%06ds sys\n", seeda, v51);
gettimeofday(&tv, 0LL);
getrusage(RUSAGE_SELF, &usage);
mt_mergesort(v7, v50, 4LL, int_cmp, 1LL);
gettimeofday(&v52, 0LL);
getrusage(RUSAGE_SELF, &v54);
v18 = tv_diff(tv.tv_sec, tv.tv_usec, v52.tv_sec, v52.tv_usec);
v20 = v19;
v44 = tv_diff(usage.ru_utime.tv_sec, usage.ru_utime.tv_usec, v54.ru_utime.tv_sec, v54.ru_utime.tv_usec);
v22 = v21;
seedb = tv_diff(usage.ru_stime.tv_sec, usage.ru_stime.tv_usec, v54.ru_stime.tv_sec, v54.ru_stime.tv_usec);
v24 = v23;
printf("1 threads: ");
printf("%d.%06ds wall; ", v18, v20);
printf("%d.%06ds user; ", v44, v22);
printf("%d.%06ds sys\n", seedb, v24);
gettimeofday(&tv, 0LL);
getrusage(RUSAGE_SELF, &usage);
mt_mergesort(v8, v50, 4LL, int_cmp, 2LL);
gettimeofday(&v52, 0LL);
getrusage(RUSAGE_SELF, &v54);
v25 = tv_diff(tv.tv_sec, tv.tv_usec, v52.tv_sec, v52.tv_usec);
v27 = v26;
v45 = tv_diff(usage.ru_utime.tv_sec, usage.ru_utime.tv_usec, v54.ru_utime.tv_sec, v54.ru_utime.tv_usec);
v29 = v28;
seedc = tv_diff(usage.ru_stime.tv_sec, usage.ru_stime.tv_usec, v54.ru_stime.tv_sec, v54.ru_stime.tv_usec);
v31 = v30;
printf("2 threads: ");
printf("%d.%06ds wall; ", v25, v27);
printf("%d.%06ds user; ", v45, v29);
printf("%d.%06ds sys\n", seedc, v31);
gettimeofday(&tv, 0LL);
getrusage(RUSAGE_SELF, &usage);
mt_mergesort(v9, v50, 4LL, int_cmp, 4LL);
gettimeofday(&v52, 0LL);
getrusage(RUSAGE_SELF, &v54);
v32 = tv_diff(tv.tv_sec, tv.tv_usec, v52.tv_sec, v52.tv_usec);
v34 = v33;
v35 = tv_diff(usage.ru_utime.tv_sec, usage.ru_utime.tv_usec, v54.ru_utime.tv_sec, v54.ru_utime.tv_usec);
v37 = v36;
v38 = tv_diff(usage.ru_stime.tv_sec, usage.ru_stime.tv_usec, v54.ru_stime.tv_sec, v54.ru_stime.tv_usec);
v40 = v39;
printf("4 threads: ");
printf("%d.%06ds wall; ", v32, v34);
printf("%d.%06ds user; ", v35, v37);
printf("%d.%06ds sys\n", v38, v40);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // er14
int v4; // ebp
size_t v5; // rbx
_DWORD *v6; // r15
_DWORD *v7; // r14
_DWORD *v8; // r13
_DWORD *v9; // r12
__int64 i; // rbx
int v11; // eax
__int64 v12; // rbx
__int64 v13; // rdx
__int64 v14; // rbp
__int64 v15; // rdx
__int64 v16; // r15
__int64 v17; // rdx
__int64 v18; // rbx
__int64 v19; // rdx
__int64 v20; // rbp
__int64 v21; // rdx
__int64 v22; // r15
__int64 v23; // rdx
__int64 v24; // r14
__int64 v25; // rbx
__int64 v26; // rdx
__int64 v27; // rbp
__int64 v28; // rdx
__int64 v29; // r15
__int64 v30; // rdx
__int64 v31; // r13
__int64 v32; // rbx
__int64 v33; // rdx
__int64 v34; // rbp
__int64 v35; // r13
__int64 v36; // rdx
__int64 v37; // r15
__int64 v38; // r12
__int64 v39; // rdx
__int64 v40; // r14
int v42; // [rsp+0h] [rbp-198h]
__int64 v43; // [rsp+0h] [rbp-198h]
__int64 v44; // [rsp+0h] [rbp-198h]
__int64 v45; // [rsp+0h] [rbp-198h]
int seed; // [rsp+8h] [rbp-190h]
__int64 seeda; // [rsp+8h] [rbp-190h]
__int64 seedb; // [rsp+8h] [rbp-190h]
__int64 seedc; // [rsp+8h] [rbp-190h]
__int64 v50; // [rsp+10h] [rbp-188h]
__int64 v51; // [rsp+18h] [rbp-180h]
struct timeval v52; // [rsp+20h] [rbp-178h] BYREF
struct timeval tv; // [rsp+30h] [rbp-168h] BYREF
struct rusage v54; // [rsp+40h] [rbp-158h] BYREF
struct rusage usage; // [rsp+D0h] [rbp-C8h] BYREF

v3 = atoi(argv[1]);
seed = atoi(argv[2]);
v4 = atoi(argv[3]);
v42 = v3;
v50 = v3;
v5 = 4LL * v3;
v6 = malloc(v5);
v7 = malloc(v5);
v8 = malloc(v5);
v9 = malloc(v5);
srand(seed);
if ( v42 > 0 )
{
for ( i = 0LL; i != v42; v9[i++] = v11 % v4 )
{
v11 = rand();
v6[i] = v11 % v4;
v7[i] = v11 % v4;
v8[i] = v11 % v4;
}
}
gettimeofday(&tv, 0LL);
getrusage(RUSAGE_SELF, &usage);
mergesort(v6, v50, 4LL, int_cmp);
gettimeofday(&v52, 0LL);
getrusage(RUSAGE_SELF, &v54);
v12 = func1(tv.tv_sec, tv.tv_usec, v52.tv_sec, v52.tv_usec);
v14 = v13;
v43 = func1(usage.ru_utime.tv_sec, usage.ru_utime.tv_usec, v54.ru_utime.tv_sec, v54.ru_utime.tv_usec);
v16 = v15;
seeda = func1(usage.ru_stime.tv_sec, usage.ru_stime.tv_usec, v54.ru_stime.tv_sec, v54.ru_stime.tv_usec);
v51 = v17;
printf("0 threads: ");
printf("%d.%06ds wall; ", v12, v14);
printf("%d.%06ds user; ", v43, v16);
printf("%d.%06ds sys\n", seeda, v51);
gettimeofday(&tv, 0LL);
getrusage(RUSAGE_SELF, &usage);
mt_mergesort(v7, v50, 4LL, int_cmp, 1LL);
gettimeofday(&v52, 0LL);
getrusage(RUSAGE_SELF, &v54);
v18 = func1(tv.tv_sec, tv.tv_usec, v52.tv_sec, v52.tv_usec);
v20 = v19;
v44 = func1(usage.ru_utime.tv_sec, usage.ru_utime.tv_usec, v54.ru_utime.tv_sec, v54.ru_utime.tv_usec);
v22 = v21;
seedb = func1(usage.ru_stime.tv_sec, usage.ru_stime.tv_usec, v54.ru_stime.tv_sec, v54.ru_stime.tv_usec);
v24 = v23;
printf("1 threads: ");
printf("%d.%06ds wall; ", v18, v20);
printf("%d.%06ds user; ", v44, v22);
printf("%d.%06ds sys\n", seedb, v24);
gettimeofday(&tv, 0LL);
getrusage(RUSAGE_SELF, &usage);
mt_mergesort(v8, v50, 4LL, int_cmp, 2LL);
gettimeofday(&v52, 0LL);
getrusage(RUSAGE_SELF, &v54);
v25 = func1(tv.tv_sec, tv.tv_usec, v52.tv_sec, v52.tv_usec);
v27 = v26;
v45 = func1(usage.ru_utime.tv_sec, usage.ru_utime.tv_usec, v54.ru_utime.tv_sec, v54.ru_utime.tv_usec);
v29 = v28;
seedc = func1(usage.ru_stime.tv_sec, usage.ru_stime.tv_usec, v54.ru_stime.tv_sec, v54.ru_stime.tv_usec);
v31 = v30;
printf("2 threads: ");
printf("%d.%06ds wall; ", v25, v27);
printf("%d.%06ds user; ", v45, v29);
printf("%d.%06ds sys\n", seedc, v31);
gettimeofday(&tv, 0LL);
getrusage(RUSAGE_SELF, &usage);
mt_mergesort(v9, v50, 4LL, int_cmp, 4LL);
gettimeofday(&v52, 0LL);
getrusage(RUSAGE_SELF, &v54);
v32 = func1(tv.tv_sec, tv.tv_usec, v52.tv_sec, v52.tv_usec);
v34 = v33;
v35 = func1(usage.ru_utime.tv_sec, usage.ru_utime.tv_usec, v54.ru_utime.tv_sec, v54.ru_utime.tv_usec);
v37 = v36;
v38 = func1(usage.ru_stime.tv_sec, usage.ru_stime.tv_usec, v54.ru_stime.tv_sec, v54.ru_stime.tv_usec);
v40 = v39;
printf("4 threads: ");
printf("%d.%06ds wall; ", v32, v34);
printf("%d.%06ds user; ", v35, v37);
printf("%d.%06ds sys\n", v38, v40);
return 0;
}

original_code:
int main(int argc, char *argv[])
{
 int *ARRAY, *ARRAY_2, *ARRAY_3, *ARRAY_4, i, k;
 int num = atoi(argv[1]), seed = atoi(argv[2]), m_bound = atoi(argv[3]);
 struct rusage start_ru, end_ru;
   struct timeval start_wall, end_wall, diff_wall, diff_usr, diff_sys;
    Compare_fn cmp = int_cmp;
 ARRAY = malloc(sizeof(int) * num);
    ARRAY_2 = malloc(sizeof(int) * num);
    ARRAY_3 = malloc(sizeof(int) * num);
    ARRAY_4 = malloc(sizeof(int) * num);
 srand(seed);
 for (i = 0; i < num ; i ++)
    {
        k = rand() % m_bound;
  ARRAY[i] = k;
        ARRAY_2[i] = k;
        ARRAY_3[i] = k;
        ARRAY_4[i] = k;
    }
 gettimeofday(&start_wall, ((void *)0));
 getrusage(RUSAGE_SELF, &start_ru);
 mergesort(ARRAY, num, sizeof(int), cmp);
 gettimeofday(&end_wall, ((void *)0));
 getrusage(RUSAGE_SELF,&end_ru);
    diff_wall = tv_diff(start_wall, end_wall);
    diff_usr = tv_diff(start_ru.ru_utime, end_ru.ru_utime);
    diff_sys = tv_diff(start_ru.ru_stime, end_ru.ru_stime);
    printf("0 threads:  ");
    printf("%d.%06ds wall;  ", diff_wall.tv_sec, diff_wall.tv_usec);
    printf("%d.%06ds user;  ", diff_usr.tv_sec, diff_usr.tv_usec);
    printf("%d.%06ds sys\n", diff_sys.tv_sec, diff_sys.tv_usec);
 gettimeofday(&start_wall, ((void *)0));
 getrusage(RUSAGE_SELF, &start_ru);
 mt_mergesort(ARRAY_2, num, sizeof(int), cmp, 1);
 gettimeofday(&end_wall, ((void *)0));
 getrusage(RUSAGE_SELF,&end_ru);
    diff_wall = tv_diff(start_wall, end_wall);
    diff_usr = tv_diff(start_ru.ru_utime, end_ru.ru_utime);
    diff_sys = tv_diff(start_ru.ru_stime, end_ru.ru_stime);
    printf("1 threads:  ");
    printf("%d.%06ds wall;  ", diff_wall.tv_sec, diff_wall.tv_usec);
    printf("%d.%06ds user;  ", diff_usr.tv_sec, diff_usr.tv_usec);
    printf("%d.%06ds sys\n", diff_sys.tv_sec, diff_sys.tv_usec);
    gettimeofday(&start_wall, ((void *)0));
 getrusage(RUSAGE_SELF, &start_ru);
 mt_mergesort(ARRAY_3, num, sizeof(int), cmp, 2);
 gettimeofday(&end_wall, ((void *)0));
 getrusage(RUSAGE_SELF,&end_ru);
    diff_wall = tv_diff(start_wall, end_wall);
    diff_usr = tv_diff(start_ru.ru_utime, end_ru.ru_utime);
    diff_sys = tv_diff(start_ru.ru_stime, end_ru.ru_stime);
    printf("2 threads:  ");
    printf("%d.%06ds wall;  ", diff_wall.tv_sec, diff_wall.tv_usec);
    printf("%d.%06ds user;  ", diff_usr.tv_sec, diff_usr.tv_usec);
    printf("%d.%06ds sys\n", diff_sys.tv_sec, diff_sys.tv_usec);
    gettimeofday(&start_wall, ((void *)0));
 getrusage(RUSAGE_SELF, &start_ru);
 mt_mergesort(ARRAY_4, num, sizeof(int), cmp, 4);
 gettimeofday(&end_wall, ((void *)0));
 getrusage(RUSAGE_SELF,&end_ru);
    diff_wall = tv_diff(start_wall, end_wall);
    diff_usr = tv_diff(start_ru.ru_utime, end_ru.ru_utime);
    diff_sys = tv_diff(start_ru.ru_stime, end_ru.ru_stime);
    printf("4 threads:  ");
    printf("%d.%06ds wall;  ", diff_wall.tv_sec, diff_wall.tv_usec);
    printf("%d.%06ds user;  ", diff_usr.tv_sec, diff_usr.tv_usec);
    printf("%d.%06ds sys\n", diff_sys.tv_sec, diff_sys.tv_usec);
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
 int *ARRAY; int *ARRAY_2; int *ARRAY_3; int *ARRAY_4; int i; int k;
 int num = atoi(argv[1]); int seed = atoi(argv[2]); int m_bound = atoi(argv[3]);
 struct rusage start_ru; struct rusage end_ru;
   struct timeval start_wall; struct timeval end_wall; struct timeval diff_wall; struct timeval diff_usr; struct timeval diff_sys;
    int (*cmp)(void *, void *) = int_cmp;
 ARRAY = malloc(sizeof(int) * num);
    ARRAY_2 = malloc(sizeof(int) * num);
    ARRAY_3 = malloc(sizeof(int) * num);
    ARRAY_4 = malloc(sizeof(int) * num);
 srand(seed);
 for (i = 0; i < num ; i ++)
    {
        k = rand() % m_bound;
  ARRAY[i] = k;
        ARRAY_2[i] = k;
        ARRAY_3[i] = k;
        ARRAY_4[i] = k;
    }
 gettimeofday(&start_wall, ((void *)0));
 getrusage(RUSAGE_SELF, &start_ru);
 mergesort(ARRAY, num, sizeof(int), cmp);
 gettimeofday(&end_wall, ((void *)0));
 getrusage(RUSAGE_SELF,&end_ru);
    diff_wall = tv_diff(start_wall, end_wall);
    diff_usr = tv_diff(start_ru.ru_utime, end_ru.ru_utime);
    diff_sys = tv_diff(start_ru.ru_stime, end_ru.ru_stime);
    printf("0 threads:  ");
    printf("%d.%06ds wall;  ", diff_wall.tv_sec, diff_wall.tv_usec);
    printf("%d.%06ds user;  ", diff_usr.tv_sec, diff_usr.tv_usec);
    printf("%d.%06ds sys\n", diff_sys.tv_sec, diff_sys.tv_usec);
 gettimeofday(&start_wall, ((void *)0));
 getrusage(RUSAGE_SELF, &start_ru);
 mt_mergesort(ARRAY_2, num, sizeof(int), cmp, 1);
 gettimeofday(&end_wall, ((void *)0));
 getrusage(RUSAGE_SELF,&end_ru);
    diff_wall = tv_diff(start_wall, end_wall);
    diff_usr = tv_diff(start_ru.ru_utime, end_ru.ru_utime);
    diff_sys = tv_diff(start_ru.ru_stime, end_ru.ru_stime);
    printf("1 threads:  ");
    printf("%d.%06ds wall;  ", diff_wall.tv_sec, diff_wall.tv_usec);
    printf("%d.%06ds user;  ", diff_usr.tv_sec, diff_usr.tv_usec);
    printf("%d.%06ds sys\n", diff_sys.tv_sec, diff_sys.tv_usec);
    gettimeofday(&start_wall, ((void *)0));
 getrusage(RUSAGE_SELF, &start_ru);
 mt_mergesort(ARRAY_3, num, sizeof(int), cmp, 2);
 gettimeofday(&end_wall, ((void *)0));
 getrusage(RUSAGE_SELF,&end_ru);
    diff_wall = tv_diff(start_wall, end_wall);
    diff_usr = tv_diff(start_ru.ru_utime, end_ru.ru_utime);
    diff_sys = tv_diff(start_ru.ru_stime, end_ru.ru_stime);
    printf("2 threads:  ");
    printf("%d.%06ds wall;  ", diff_wall.tv_sec, diff_wall.tv_usec);
    printf("%d.%06ds user;  ", diff_usr.tv_sec, diff_usr.tv_usec);
    printf("%d.%06ds sys\n", diff_sys.tv_sec, diff_sys.tv_usec);
    gettimeofday(&start_wall, ((void *)0));
 getrusage(RUSAGE_SELF, &start_ru);
 mt_mergesort(ARRAY_4, num, sizeof(int), cmp, 4);
 gettimeofday(&end_wall, ((void *)0));
 getrusage(RUSAGE_SELF,&end_ru);
    diff_wall = tv_diff(start_wall, end_wall);
    diff_usr = tv_diff(start_ru.ru_utime, end_ru.ru_utime);
    diff_sys = tv_diff(start_ru.ru_stime, end_ru.ru_stime);
    printf("4 threads:  ");
    printf("%d.%06ds wall;  ", diff_wall.tv_sec, diff_wall.tv_usec);
    printf("%d.%06ds user;  ", diff_usr.tv_sec, diff_usr.tv_usec);
    printf("%d.%06ds sys\n", diff_sys.tv_sec, diff_sys.tv_usec);
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types:
ARRAY
int *

variable_types: i int

variable_types: k int

variable_types: num int

variable_types: seed int

variable_types: struct rusage { struct timeval { long tv_sec; long tv_usec; } ru_utime; struct timeval ru_stime; union { long ru_maxrss; long __ru_maxrss_word; }; union { long ru_ixrss; long __ru_ixrss_word; }; union { long ru_idrss; long __ru_idrss_word; }; union { long ru_isrss; long __ru_isrss_word; }; union { long ru_minflt; long __ru_minflt_word; }; union { long ru_majflt; long __ru_majflt_word; }; union { long ru_nswap; long __ru_nswap_word; }; union { long ru_inblock; long __ru_inblock_word; }; union { long ru_oublock; long __ru_oublock_word; }; union { long ru_msgsnd; long __ru_msgsnd_word; }; union { long ru_msgrcv; long __ru_msgrcv_word; }; union { long ru_nsignals; long __ru_nsignals_word; }; union { long ru_nvcsw; long __ru_nvcsw_word; }; union { long ru_nivcsw; long __ru_nivcsw_word; }; }

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

user_defined_types: struct rusage { struct timeval ru_utime; struct timeval ru_stime; union { long ru_maxrss; long __ru_maxrss_word; }; union { long ru_ixrss; long __ru_ixrss_word; }; union { long ru_idrss; long __ru_idrss_word; }; union { long ru_isrss; long __ru_isrss_word; }; union { long ru_minflt; long __ru_minflt_word; }; union { long ru_majflt; long __ru_majflt_word; }; union { long ru_nswap; long __ru_nswap_word; }; union { long ru_inblock; long __ru_inblock_word; }; union { long ru_oublock; long __ru_oublock_word; }; union { long ru_msgsnd; long __ru_msgsnd_word; }; union { long ru_msgrcv; long __ru_msgrcv_word; }; union { long ru_nsignals; long __ru_nsignals_word; }; union { long ru_nvcsw; long __ru_nvcsw_word; }; union { long ru_nivcsw; long __ru_nivcsw_word; }; }


merge

decompiled_code:
void __fastcall merge(char *a1, __int64 a2, __int64 a3, size_t a4, int (__fastcall *a5)(char *, char *))
{
__int64 v5; // r13
__int64 v6; // r14
char *v8; // r15
char *v9; // r12
char *v10; // rbp
char *dest; // [rsp+10h] [rbp-48h]
size_t n; // [rsp+18h] [rbp-40h]

v5 = a2;
v6 = a3;
n = a4 * (a2 + a3);
dest = (char *)malloc(n);
if ( !dest )
err(71, "error allocating workspace");
v8 = a1;
v9 = &a1[a4 * a2];
if ( a2 && v6 )
{
v10 = dest;
do
{
if ( a5(v8, v9) < 0 )
{
memcpy(v10, v8, a4);
v8 += a4;
--v5;
}
else
{
memcpy(v10, v9, a4);
v9 += a4;
--v6;
}
v10 += a4;
}
while ( v5 && v6 );
}
else
{
v10 = dest;
v8 = a1;
}
memcpy(v10, v8, a4 * v5);
memcpy(v10, v9, v6 * a4);
memcpy(a1, dest, n);
free(dest);
}

canonical_decompiled_code:
void __fastcall func0(char *a1, __int64 a2, __int64 a3, size_t a4, int (__fastcall *a5)(char *, char *))
{
__int64 v5; // r13
__int64 v6; // r14
char *v8; // r15
char *v9; // r12
char *v10; // rbp
char *dest; // [rsp+10h] [rbp-48h]
size_t n; // [rsp+18h] [rbp-40h]

v5 = a2;
v6 = a3;
n = a4 * (a2 + a3);
dest = (char *)malloc(n);
if ( !dest )
err(71, "error allocating workspace");
v8 = a1;
v9 = &a1[a4 * a2];
if ( a2 && v6 )
{
v10 = dest;
do
{
if ( a5(v8, v9) < 0 )
{
memcpy(v10, v8, a4);
v8 += a4;
--v5;
}
else
{
memcpy(v10, v9, a4);
v9 += a4;
--v6;
}
v10 += a4;
}
while ( v5 && v6 );
}
else
{
v10 = dest;
v8 = a1;
}
memcpy(v10, v8, a4 * v5);
memcpy(v10, v9, v6 * a4);
memcpy(a1, dest, n);
free(dest);
}

original_code:
static void merge(void *arr, size_t num_elem_a, size_t num_elem_b,
                  size_t elem_size, Compare_fn cmp)
{
    char *i_ptr, *j_ptr, *work_ptr;
    char *workspace;
    size_t total_elem = num_elem_a + num_elem_b;
    workspace = malloc(total_elem * elem_size);
    if (workspace == ((void *)0))
        err(71, "error allocating workspace");
    i_ptr = arr;
    j_ptr = i_ptr + elem_size * num_elem_a;
    work_ptr = workspace;
    while (num_elem_a && num_elem_b) {
        if (cmp(i_ptr, j_ptr) < 0) {
            memmove(work_ptr, i_ptr, elem_size);
            i_ptr += elem_size;
            num_elem_a--;
        }
        else {
            memmove(work_ptr, j_ptr, elem_size);
            j_ptr += elem_size;
            num_elem_b--;
        }
        work_ptr += elem_size;
    }
    memmove(work_ptr, i_ptr, elem_size * num_elem_a);
    memmove(work_ptr, j_ptr, elem_size * num_elem_b);
    memmove(arr, workspace, elem_size * total_elem);
    free(workspace);
}

canonical_original_code:
static void merge(void *arr, unsigned long num_elem_a, unsigned long num_elem_b, unsigned long elem_size, int (*cmp)(void *, void *))
{
    char *i_ptr; char *j_ptr; char *work_ptr;
    char *workspace;
    unsigned long total_elem = num_elem_a + num_elem_b;
    workspace = malloc(total_elem * elem_size);
    if (workspace == ((void *)0))
        err(71, "error allocating workspace");
    i_ptr = arr;
    j_ptr = i_ptr + elem_size * num_elem_a;
    work_ptr = workspace;
    while (num_elem_a && num_elem_b) {
        if (cmp(i_ptr, j_ptr) < 0) {
            memmove(work_ptr, i_ptr, elem_size);
            i_ptr += elem_size;
            num_elem_a--;
        }
        else {
            memmove(work_ptr, j_ptr, elem_size);
            j_ptr += elem_size;
            num_elem_b--;
        }
        work_ptr += elem_size;
    }
    memmove(work_ptr, i_ptr, elem_size * num_elem_a);
    memmove(work_ptr, j_ptr, elem_size * num_elem_b);
    memmove(arr, workspace, elem_size * total_elem);
    free(workspace);
}

variable_types:
arr
void *

variable_types:
workspace
char *

return_type: void


mergesort

decompiled_code:
void __fastcall mergesort(char *a1, unsigned __int64 a2, size_t a3, int (__fastcall *a4)(char *, char *))
{
__int64 v6; // rbx

if ( a2 > 1 && a4 != 0LL )
{
if ( a1 )
{
v6 = a2 - (a2 >> 1);
mergesort(a1, a2 >> 1, a3);
mergesort(&a1[a3 * (a2 >> 1)], v6, a3);
merge(a1, a2 >> 1, v6, a3, a4);
}
}
}

original_code:
void mergesort(void *arr, size_t num_elem, size_t elem_size, Compare_fn cmp) {
    size_t first_half_count, second_half_count;
    char *second_half_arr = arr;
    if (arr == ((void *)0) || cmp == ((void *)0) || num_elem <= 1)
        return;
    first_half_count = num_elem / 2;
    second_half_count = num_elem - first_half_count;
    second_half_arr += first_half_count * elem_size;
    mergesort(arr, first_half_count, elem_size, cmp);
    mergesort(second_half_arr, second_half_count, elem_size, cmp);
    merge(arr, first_half_count, second_half_count, elem_size, cmp);
}

canonical_original_code:
void mergesort(void *arr, unsigned long num_elem, unsigned long elem_size, int (*cmp)(void *, void *)) {
    unsigned long first_half_count; unsigned long second_half_count;
    char *second_half_arr = arr;
    if (arr == ((void *)0) || cmp == ((void *)0) || num_elem <= 1)
        return;
    first_half_count = num_elem / 2;
    second_half_count = num_elem - first_half_count;
    second_half_arr += first_half_count * elem_size;
    mergesort(arr, first_half_count, elem_size, cmp);
    mergesort(second_half_arr, second_half_count, elem_size, cmp);
    merge(arr, first_half_count, second_half_count, elem_size, cmp);
}


decompiled_code:
void __fastcall merge_th(void *a1)
{
mergesort(*(char **)a1, *((_QWORD *)a1 + 1), *((_QWORD *)a1 + 2), *((int (__fastcall **)(char *, char *))a1 + 3));
}

canonical_decompiled_code:
void __fastcall func2(void *a1)
{
func1(*(char **)a1, *((_QWORD *)a1 + 1), *((_QWORD *)a1 + 2), *((int (__fastcall **)(char *, char *))a1 + 3));
}

original_code:
void *merge_th(void *merge_struct)
{
    Merge_mem *pars = (Merge_mem *) merge_struct;
    mergesort(pars->array, pars->num_elem, pars->elem_size, pars->cmp_f);
    return;
}

canonical_original_code:
void *merge_th(void *merge_struct)
{
    struct Merge_mem *pars = (Merge_mem *) merge_struct;
    mergesort(pars->array, pars->num_elem, pars->elem_size, pars->cmp_f);
    return;
}

variable_types: struct Merge_mem { void *array; unsigned long num_elem; unsigned long elem_size; int (*cmp_f)(void *, void *); } *

return_type: void *


decompiled_code:
void __fastcall mt_mergesort(char *a1, unsigned __int64 a2, size_t a3, int (__fastcall *a4)(char *, char *), int a5)
{
__int64 v7; // r15
char *arg; // [rsp+10h] [rbp-D8h] BYREF
unsigned __int64 v9; // [rsp+18h] [rbp-D0h]
size_t v10; // [rsp+20h] [rbp-C8h]
int (__fastcall *v11)(char *, char *); // [rsp+28h] [rbp-C0h]
char *v12; // [rsp+30h] [rbp-B8h] BYREF
unsigned __int64 v13; // [rsp+38h] [rbp-B0h]
size_t v14; // [rsp+40h] [rbp-A8h]
int (__fastcall *v15)(char *, char *); // [rsp+48h] [rbp-A0h]
__int64 v16[4]; // [rsp+50h] [rbp-98h] BYREF
__int64 v17[4]; // [rsp+70h] [rbp-78h] BYREF
pthread_t newthread; // [rsp+90h] [rbp-58h] BYREF
pthread_t th; // [rsp+98h] [rbp-50h] BYREF
pthread_t v20; // [rsp+A0h] [rbp-48h] BYREF
pthread_t v21[8]; // [rsp+A8h] [rbp-40h] BYREF

if ( a1 && a4 )
{
switch ( a5 )
{
case 1:
arg = a1;
v10 = a3;
v9 = a2;
v11 = a4;
pthread_create(&newthread, 0LL, (void *(*)(void *))merge_th, &arg);
pthread_join(newthread, 0LL);
break;
case 2:
arg = a1;
v10 = a3;
v9 = a2 >> 1;
v11 = a4;
v12 = &a1[(a2 >> 1) * a3];
v14 = a3;
v13 = a2 - (a2 >> 1);
v15 = a4;
pthread_create(&newthread, 0LL, (void *(*)(void *))merge_th, &arg);
pthread_create(&th, 0LL, (void *(*)(void *))merge_th, &v12);
pthread_join(newthread, 0LL);
pthread_join(th, 0LL);
merge(a1, a2 >> 1, a2 - (a2 >> 1), a3, a4);
break;
case 4:
arg = a1;
v10 = a3;
v9 = a2 >> 2;
v11 = a4;
v12 = &a1[a3 * (a2 >> 2)];
v14 = a3;
v13 = (a2 >> 1) - (a2 >> 2);
v15 = a4;
pthread_create(&newthread, 0LL, (void *(*)(void *))merge_th, &arg);
pthread_create(&th, 0LL, (void *(*)(void *))merge_th, &v12);
pthread_join(newthread, 0LL);
pthread_join(th, 0LL);
merge(a1, a2 >> 2, (a2 >> 1) - (a2 >> 2), a3, a4);
v7 = (a2 - (a2 >> 1)) >> 1;
v16[0] = (__int64)&a1[a3 * (a2 >> 1)];
v16[2] = a3;
v16[1] = v7;
v16[3] = (__int64)a4;
v17[0] = (__int64)&a1[a3 * ((a2 >> 1) + v7)];
v17[2] = a3;
v17[1] = a2 - ((a2 >> 1) + v7);
v17[3] = (__int64)a4;
pthread_create(&v20, 0LL, (void *(*)(void *))merge_th, v16);
pthread_create(v21, 0LL, (void *(*)(void *))merge_th, v17);
pthread_join(v20, 0LL);
pthread_join(v21[0], 0LL);
merge(&a1[a3 * (a2 >> 1)], v7, a2 - ((a2 >> 1) + v7), a3, a4);
merge(a1, a2 >> 1, a2 - (a2 >> 1), a3, a4);
break;
}
}
}

canonical_decompiled_code:
void __fastcall func3(char *a1, unsigned __int64 a2, size_t a3, int (__fastcall *a4)(char *, char *), int a5)
{
__int64 v7; // r15
char *arg; // [rsp+10h] [rbp-D8h] BYREF
unsigned __int64 v9; // [rsp+18h] [rbp-D0h]
size_t v10; // [rsp+20h] [rbp-C8h]
int (__fastcall *v11)(char *, char *); // [rsp+28h] [rbp-C0h]
char *v12; // [rsp+30h] [rbp-B8h] BYREF
unsigned __int64 v13; // [rsp+38h] [rbp-B0h]
size_t v14; // [rsp+40h] [rbp-A8h]
int (__fastcall *v15)(char *, char *); // [rsp+48h] [rbp-A0h]
__int64 v16[4]; // [rsp+50h] [rbp-98h] BYREF
__int64 v17[4]; // [rsp+70h] [rbp-78h] BYREF
pthread_t newthread; // [rsp+90h] [rbp-58h] BYREF
pthread_t th; // [rsp+98h] [rbp-50h] BYREF
pthread_t v20; // [rsp+A0h] [rbp-48h] BYREF
pthread_t v21[8]; // [rsp+A8h] [rbp-40h] BYREF

if ( a1 && a4 )
{
switch ( a5 )
{
case 1:
arg = a1;
v10 = a3;
v9 = a2;
v11 = a4;
pthread_create(&newthread, 0LL, (void *(*)(void *))merge_th, &arg);
pthread_join(newthread, 0LL);
break;
case 2:
arg = a1;
v10 = a3;
v9 = a2 >> 1;
v11 = a4;
v12 = &a1[(a2 >> 1) * a3];
v14 = a3;
v13 = a2 - (a2 >> 1);
v15 = a4;
pthread_create(&newthread, 0LL, (void *(*)(void *))merge_th, &arg);
pthread_create(&th, 0LL, (void *(*)(void *))merge_th, &v12);
pthread_join(newthread, 0LL);
pthread_join(th, 0LL);
func0(a1, a2 >> 1, a2 - (a2 >> 1), a3, a4);
break;
case 4:
arg = a1;
v10 = a3;
v9 = a2 >> 2;
v11 = a4;
v12 = &a1[a3 * (a2 >> 2)];
v14 = a3;
v13 = (a2 >> 1) - (a2 >> 2);
v15 = a4;
pthread_create(&newthread, 0LL, (void *(*)(void *))merge_th, &arg);
pthread_create(&th, 0LL, (void *(*)(void *))merge_th, &v12);
pthread_join(newthread, 0LL);
pthread_join(th, 0LL);
func0(a1, a2 >> 2, (a2 >> 1) - (a2 >> 2), a3, a4);
v7 = (a2 - (a2 >> 1)) >> 1;
v16[0] = (__int64)&a1[a3 * (a2 >> 1)];
v16[2] = a3;
v16[1] = v7;
v16[3] = (__int64)a4;
v17[0] = (__int64)&a1[a3 * ((a2 >> 1) + v7)];
v17[2] = a3;
v17[1] = a2 - ((a2 >> 1) + v7);
v17[3] = (__int64)a4;
pthread_create(&v20, 0LL, (void *(*)(void *))merge_th, v16);
pthread_create(v21, 0LL, (void *(*)(void *))merge_th, v17);
pthread_join(v20, 0LL);
pthread_join(v21[0], 0LL);
func0(&a1[a3 * (a2 >> 1)], v7, a2 - ((a2 >> 1) + v7), a3, a4);
func0(a1, a2 >> 1, a2 - (a2 >> 1), a3, a4);
break;
}
}
}

original_code:
void mt_mergesort(void *arr, size_t num_elem, size_t elem_size, Compare_fn cmp,
                  int num_threads)
{
    pthread_t tids[4];
    Merge_mem merge_ptr[4];
    size_t first_half_count, second_half_count, third_half_count,
    fourth_half_count;
    char *second_half_arr = arr, *third_half_arr = arr, *fourth_half_arr = arr;
 if (arr == ((void *)0) || cmp == ((void *)0))
  return;
 if (num_threads == 1)
 {
        merge_ptr[0].array = arr;
        merge_ptr[0].elem_size = elem_size;
        merge_ptr[0].num_elem = num_elem;
        merge_ptr[0].cmp_f = cmp;
  pthread_create(&tids[0], ((void *)0), merge_th, &merge_ptr[0]);
        pthread_join(tids[0], ((void *)0));
        return;
 }
    if (num_threads == 2)
    {
        first_half_count = num_elem / 2;
        second_half_count = num_elem - first_half_count;
        second_half_arr += first_half_count * elem_size;
        merge_ptr[0].array = arr;
        merge_ptr[0].elem_size = elem_size;
        merge_ptr[0].num_elem = first_half_count;
        merge_ptr[0].cmp_f = cmp;
        merge_ptr[1].array = second_half_arr;
        merge_ptr[1].elem_size = elem_size;
        merge_ptr[1].num_elem = second_half_count;
        merge_ptr[1].cmp_f = cmp;
        pthread_create(&tids[0], ((void *)0), merge_th, &merge_ptr[0]);
        pthread_create(&tids[1], ((void *)0), merge_th, &merge_ptr[1]);
        pthread_join(tids[0], ((void *)0));
        pthread_join(tids[1], ((void *)0));
        merge(arr, first_half_count, second_half_count, elem_size, cmp);
        return;
    }
    else
        if (num_threads == 4)
        {
            first_half_count = num_elem/4;
            second_half_count = (num_elem/2) - first_half_count;
            second_half_arr += first_half_count * elem_size;
            merge_ptr[0].array = arr;
            merge_ptr[0].elem_size = elem_size;
            merge_ptr[0].num_elem = first_half_count;
            merge_ptr[0].cmp_f = cmp;
            merge_ptr[1].array = second_half_arr;
            merge_ptr[1].elem_size = elem_size;
            merge_ptr[1].num_elem = second_half_count;
            merge_ptr[1].cmp_f = cmp;
            pthread_create(&tids[0], ((void *)0), merge_th, &merge_ptr[0]);
            pthread_create(&tids[1], ((void *)0), merge_th, &merge_ptr[1]);
            pthread_join(tids[0], ((void *)0));
            pthread_join(tids[1], ((void *)0));
            merge(arr, first_half_count, second_half_count, elem_size, cmp);
            third_half_count = (num_elem -
                                (first_half_count + second_half_count))/2;
            third_half_arr += (first_half_count + second_half_count)
                                * elem_size;
            fourth_half_count = num_elem - (first_half_count + second_half_count
                                            + third_half_count);
            fourth_half_arr += (first_half_count + second_half_count +
                                third_half_count) * elem_size;
            merge_ptr[2].array = third_half_arr;
            merge_ptr[2].elem_size = elem_size;
            merge_ptr[2].num_elem = third_half_count;
            merge_ptr[2].cmp_f = cmp;
            merge_ptr[3].array = fourth_half_arr;
            merge_ptr[3].elem_size = elem_size;
            merge_ptr[3].num_elem = fourth_half_count;
            merge_ptr[3].cmp_f = cmp;
            pthread_create(&tids[2], ((void *)0), merge_th, &merge_ptr[2]);
            pthread_create(&tids[3], ((void *)0), merge_th, &merge_ptr[3]);
            pthread_join(tids[2], ((void *)0));
            pthread_join(tids[3], ((void *)0));
            merge(third_half_arr, third_half_count, fourth_half_count,
                  elem_size, cmp);
            first_half_count = num_elem/2;
            second_half_count = num_elem - first_half_count;
            merge(arr, first_half_count, second_half_count, elem_size, cmp);
        }
}

canonical_original_code:
void mt_mergesort(void *arr, unsigned long num_elem, unsigned long elem_size, int (*cmp)(void *, void *), int num_threads)
{
    unsigned long tids[4];
    struct Merge_mem merge_ptr[4];
    unsigned long first_half_count; unsigned long second_half_count; unsigned long third_half_count; unsigned long fourth_half_count;
    char *second_half_arr = arr; char *third_half_arr = arr; char *fourth_half_arr = arr;
 if (arr == ((void *)0) || cmp == ((void *)0))
  return;
 if (num_threads == 1)
 {
        merge_ptr[0].array = arr;
        merge_ptr[0].elem_size = elem_size;
        merge_ptr[0].num_elem = num_elem;
        merge_ptr[0].cmp_f = cmp;
  pthread_create(&tids[0], ((void *)0), merge_th, &merge_ptr[0]);
        pthread_join(tids[0], ((void *)0));
        return;
 }
    if (num_threads == 2)
    {
        first_half_count = num_elem / 2;
        second_half_count = num_elem - first_half_count;
        second_half_arr += first_half_count * elem_size;
        merge_ptr[0].array = arr;
        merge_ptr[0].elem_size = elem_size;
        merge_ptr[0].num_elem = first_half_count;
        merge_ptr[0].cmp_f = cmp;
        merge_ptr[1].array = second_half_arr;
        merge_ptr[1].elem_size = elem_size;
        merge_ptr[1].num_elem = second_half_count;
        merge_ptr[1].cmp_f = cmp;
        pthread_create(&tids[0], ((void *)0), merge_th, &merge_ptr[0]);
        pthread_create(&tids[1], ((void *)0), merge_th, &merge_ptr[1]);
        pthread_join(tids[0], ((void *)0));
        pthread_join(tids[1], ((void *)0));
        merge(arr, first_half_count, second_half_count, elem_size, cmp);
        return;
    }
    else
        if (num_threads == 4)
        {
            first_half_count = num_elem/4;
            second_half_count = (num_elem/2) - first_half_count;
            second_half_arr += first_half_count * elem_size;
            merge_ptr[0].array = arr;
            merge_ptr[0].elem_size = elem_size;
            merge_ptr[0].num_elem = first_half_count;
            merge_ptr[0].cmp_f = cmp;
            merge_ptr[1].array = second_half_arr;
            merge_ptr[1].elem_size = elem_size;
            merge_ptr[1].num_elem = second_half_count;
            merge_ptr[1].cmp_f = cmp;
            pthread_create(&tids[0], ((void *)0), merge_th, &merge_ptr[0]);
            pthread_create(&tids[1], ((void *)0), merge_th, &merge_ptr[1]);
            pthread_join(tids[0], ((void *)0));
            pthread_join(tids[1], ((void *)0));
            merge(arr, first_half_count, second_half_count, elem_size, cmp);
            third_half_count = (num_elem -
                                (first_half_count + second_half_count))/2;
            third_half_arr += (first_half_count + second_half_count)
                                * elem_size;
            fourth_half_count = num_elem - (first_half_count + second_half_count
                                            + third_half_count);
            fourth_half_arr += (first_half_count + second_half_count +
                                third_half_count) * elem_size;
            merge_ptr[2].array = third_half_arr;
            merge_ptr[2].elem_size = elem_size;
            merge_ptr[2].num_elem = third_half_count;
            merge_ptr[2].cmp_f = cmp;
            merge_ptr[3].array = fourth_half_arr;
            merge_ptr[3].elem_size = elem_size;
            merge_ptr[3].num_elem = fourth_half_count;
            merge_ptr[3].cmp_f = cmp;
            pthread_create(&tids[2], ((void *)0), merge_th, &merge_ptr[2]);
            pthread_create(&tids[3], ((void *)0), merge_th, &merge_ptr[3]);
            pthread_join(tids[2], ((void *)0));
            pthread_join(tids[3], ((void *)0));
            merge(third_half_arr, third_half_count, fourth_half_count,
                  elem_size, cmp);
            first_half_count = num_elem/2;
            second_half_count = num_elem - first_half_count;
            merge(arr, first_half_count, second_half_count, elem_size, cmp);
        }
}

variable_types:
tids
unsigned long [4]

variable_types: struct Merge_mem { void *array; unsigned long num_elem; unsigned long elem_size; int (*cmp_f)(void *, void *); } [4]


repo: AlexandreZani/memengine

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

*(_DWORD *)(a1 + 2) = _bswap_32(*(_DWORD *)(a1 + 2));
result = _bswap_32(*(_DWORD *)(a1 + 6));
*(_DWORD *)(a1 + 6) = result;
return result;
}

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

*(_DWORD *)(a1 + 2) = func0(*(_DWORD *)(a1 + 2));
result = func0(*(_DWORD *)(a1 + 6));
*(_DWORD *)(a1 + 6) = result;
return result;
}

original_code:
void
message_header_ntoh(message_header_t *message_header) {
  message_header->key_size = ntohl(message_header->key_size);
  message_header->data_size = ntohl(message_header->data_size);
}

canonical_original_code:
void message_header_ntoh(struct message_header_t *message_header) {
  message_header->key_size = ntohl(message_header->key_size);
  message_header->data_size = ntohl(message_header->data_size);
}

variable_types: struct message_header_t { unsigned char protocol_version; unsigned char message_type; unsigned int key_size; unsigned int data_size; } *


createStack

decompiled_code:
void *createStack()
{
return calloc(1uLL, 0x10uLL);
}

canonical_decompiled_code:
void *func0()
{
return calloc(1uLL, 0x10uLL);
}

original_code:
Stack * createStack(void) {
Stack *new_stack;
new_stack = calloc(1,sizeof(Stack));
return new_stack;
}

canonical_original_code:
struct st_Stack *createStack() {
struct st_Stack *new_stack;
new_stack = calloc(1,sizeof(Stack));
return new_stack;
}

variable_types: struct st_Stack { struct st_Node { unsigned int value; struct st_Node *next; } *first; unsigned int count; } *

user_defined_types: struct st_Stack { struct st_Node *first; unsigned int count; }


pop

decompiled_code:
__int64 __fastcall pop(__int64 a1)
{
_QWORD *v1; // rax
unsigned int v2; // ebx

if ( !a1 )
return (unsigned int)-1;
v1 = *(_QWORD **)a1;
if ( !*(_QWORD *)a1 )
return (unsigned int)-1;
*(_QWORD *)a1 = v1[1];
--*(_DWORD *)(a1 + 8);
v2 = *(_DWORD *)v1;
free(v1);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
_QWORD *v1; // rax
unsigned int v2; // ebx

if ( !a1 )
return (unsigned int)-1;
v1 = *(_QWORD **)a1;
if ( !*(_QWORD *)a1 )
return (unsigned int)-1;
*(_QWORD *)a1 = v1[1];
--*(_DWORD *)(a1 + 8);
v2 = *(_DWORD *)v1;
free(v1);
return v2;
}

original_code:
int pop(Stack *stack) {
int value;
Node *nodo;
if(stack == ((void *)0)) return -1;
if(stack->first == ((void *)0)) return -1;
nodo = stack->first;
stack->first = nodo->next;
stack->count--;
value = nodo->value;
free(nodo);
return value;
}

canonical_original_code:
int pop(struct st_Stack *stack) {
int value;
struct st_Node *nodo;
if(stack == ((void *)0)) return -1;
if(stack->first == ((void *)0)) return -1;
nodo = stack->first;
stack->first = nodo->next;
stack->count--;
value = nodo->value;
free(nodo);
return value;
}

variable_types: value int

variable_types: struct st_Node { unsigned int value; struct st_Node *next; } *


stackSize

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

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

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

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

original_code:
int stackSize(Stack *stack) {
return (stack == ((void *)0)) ? -1 : stack->count;
}

canonical_original_code:
int stackSize(struct st_Stack *stack) {
return (stack == ((void *)0)) ? -1 : stack->count;
}

user_defined_types: struct st_Node { unsigned int value; struct st_Node *next; }


destroyStack

decompiled_code:
void __fastcall destroyStack(void *ptr)
{
if ( ptr )
{
while ( *((_DWORD *)ptr + 2) )
pop((__int64)ptr);
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func3(void *ptr)
{
if ( ptr )
{
while ( *((_DWORD *)ptr + 2) )
func1((__int64)ptr);
free(ptr);
}
}

original_code:
void destroyStack(Stack *stack) {
if(stack == ((void *)0)) return;
while(stack->count > 0) {
pop(stack);
}
free(stack);
}

canonical_original_code:
void destroyStack(struct st_Stack *stack) {
if(stack == ((void *)0)) return;
while(stack->count > 0) {
pop(stack);
}
free(stack);
}


push

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

result = 0LL;
if ( a1 )
{
v3 = createNode(a2);
if ( v3 )
{
if ( *(_QWORD *)a1 )
{
v3[1] = *(_QWORD *)a1;
*(_QWORD *)a1 = v3;
++*(_DWORD *)(a1 + 8);
}
else
{
*(_QWORD *)a1 = v3;
*(_DWORD *)(a1 + 8) = 1;
}
result = 1LL;
}
else
{
result = 0LL;
}
}
return result;
}

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

result = 0LL;
if ( a1 )
{
v3 = createNode(a2);
if ( v3 )
{
if ( *(_QWORD *)a1 )
{
v3[1] = *(_QWORD *)a1;
*(_QWORD *)a1 = v3;
++*(_DWORD *)(a1 + 8);
}
else
{
*(_QWORD *)a1 = v3;
*(_DWORD *)(a1 + 8) = 1;
}
result = 1LL;
}
else
{
result = 0LL;
}
}
return result;
}

original_code:
int push(Stack *stack, int value) {
Node *nodo;
if(stack == ((void *)0)) return 0;
nodo = createNode(value);
if(nodo == ((void *)0)) return 0;
if(stack->first == ((void *)0)) {
stack->first = nodo;
stack->count = 1;
return 1;
}
nodo->next = stack->first;
stack->first = nodo;
stack->count++;
return 1;
}

canonical_original_code:
int push(struct st_Stack *stack, int value) {
struct st_Node *nodo;
if(stack == ((void *)0)) return 0;
nodo = createNode(value);
if(nodo == ((void *)0)) return 0;
if(stack->first == ((void *)0)) {
stack->first = nodo;
stack->count = 1;
return 1;
}
nodo->next = stack->first;
stack->first = nodo;
stack->count++;
return 1;
}


main

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

v3 = createStack(argc, argv, envp);
for ( i = 0; i != 10; ++i )
push(v3, i);
while ( (int)stackSize(v3) > 0 )
{
v5 = pop(v3);
printf("%i\n", v5);
}
return 0;
}

original_code:
int main(int argc, char *args[]) {
Stack *stack;
int i = 0;
stack = createStack();
for(i=0; i<10; i++) {
push(stack,i);
}
while(stackSize(stack)>0) {
printf("%i\n",pop(stack));
}
}

canonical_original_code:
int main(int argc, char *args[]) {
struct st_Stack *stack;
int i = 0;
stack = createStack();
for(i=0; i<10; i++) {
push(stack,i);
}
while(stackSize(stack)>0) {
printf("%i\n",pop(stack));
}
}

variable_types: argc int

variable_types:
args
char *[]


LoadLib

decompiled_code:
__int64 __fastcall LoadLib(__int64 a1, const char *a2)
{
void *v2; // rax
void *v3; // rax
void *v4; // rax
void *v5; // rax
void *v6; // rax
void *v7; // rax
void *v8; // rax
void *v9; // rax
void *v10; // rax
__int64 result; // rax
char *v12; // rax
char *v13; // rax

v2 = dlopen(a2, 1);
*(_QWORD *)a1 = v2;
if ( v2 )
{
v3 = dlsym(v2, "InitLibrary");
*(_QWORD *)(a1 + 8) = v3;
if ( !v3 )
goto LABEL_12;
v4 = dlsym(*(void **)a1, "StartMatch");
*(_QWORD *)(a1 + 16) = v4;
if ( !v4 )
goto LABEL_12;
v5 = dlsym(*(void **)a1, "StartGame");
*(_QWORD *)(a1 + 24) = v5;
if ( !v5 )
goto LABEL_12;
v6 = dlsym(*(void **)a1, "EndGame");
*(_QWORD *)(a1 + 32) = v6;
if ( !v6 )
goto LABEL_12;
v7 = dlsym(*(void **)a1, "EndMatch");
*(_QWORD *)(a1 + 40) = v7;
if ( !v7 )
goto LABEL_12;
v8 = dlsym(*(void **)a1, "NextMove");
*(_QWORD *)(a1 + 48) = v8;
if ( v8
&& (v9 = dlsym(*(void **)a1, "AttackResult"), (*(_QWORD *)(a1 + 56) = v9) != 0LL)
&& (v10 = dlsym(*(void **)a1, "Penalty"), (*(_QWORD *)(a1 + 64) = v10) != 0LL) )
{
result = 0LL;
}
else
{
LABEL_12:
v13 = dlerror();
fprintf(stderr, "Erreur de chargement de la fonction : %s\n", v13);
result = 0xFFFFFFFFLL;
}
}
else
{
v12 = dlerror();
fprintf(stderr, "Erreur de chargement de la lib : %s\n", v12);
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, const char *a2)
{
void *v2; // rax
void *v3; // rax
void *v4; // rax
void *v5; // rax
void *v6; // rax
void *v7; // rax
void *v8; // rax
void *v9; // rax
void *v10; // rax
__int64 result; // rax
char *v12; // rax
char *v13; // rax

v2 = dlopen(a2, 1);
*(_QWORD *)a1 = v2;
if ( v2 )
{
v3 = dlsym(v2, "InitLibrary");
*(_QWORD *)(a1 + 8) = v3;
if ( !v3 )
goto LABEL_12;
v4 = dlsym(*(void **)a1, "StartMatch");
*(_QWORD *)(a1 + 16) = v4;
if ( !v4 )
goto LABEL_12;
v5 = dlsym(*(void **)a1, "StartGame");
*(_QWORD *)(a1 + 24) = v5;
if ( !v5 )
goto LABEL_12;
v6 = dlsym(*(void **)a1, "EndGame");
*(_QWORD *)(a1 + 32) = v6;
if ( !v6 )
goto LABEL_12;
v7 = dlsym(*(void **)a1, "EndMatch");
*(_QWORD *)(a1 + 40) = v7;
if ( !v7 )
goto LABEL_12;
v8 = dlsym(*(void **)a1, "NextMove");
*(_QWORD *)(a1 + 48) = v8;
if ( v8
&& (v9 = dlsym(*(void **)a1, "AttackResult"), (*(_QWORD *)(a1 + 56) = v9) != 0LL)
&& (v10 = dlsym(*(void **)a1, "Penalty"), (*(_QWORD *)(a1 + 64) = v10) != 0LL) )
{
result = 0LL;
}
else
{
LABEL_12:
v13 = dlerror();
fprintf(stderr, "Erreur de chargement de la fonction : %s\n", v13);
result = 0xFFFFFFFFLL;
}
}
else
{
v12 = dlerror();
fprintf(stderr, "Erreur de chargement de la lib : %s\n", v12);
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int LoadLib(AI *ai, char* file)
{
    if ((ai->lib = dlopen(file, 0x00001)) == ((void *)0))
    {
        fprintf(stderr, "Erreur de chargement de la lib : %s\n", dlerror());
        return -1;
    }
    if ((ai->InitLibrary = (pfInitLibrary) dlsym(ai->lib, "InitLibrary")) == ((void *)0))
    {
        fprintf(stderr, "Erreur de chargement de la fonction : %s\n", dlerror());
        return -1;
    }
    if ((ai->StartMatch = (pfStartMatch) dlsym(ai->lib, "StartMatch")) == ((void *)0))
    {
        fprintf(stderr, "Erreur de chargement de la fonction : %s\n", dlerror());
        return -1;
    }
    if ((ai->StartGame = (pfStartGame) dlsym(ai->lib, "StartGame")) == ((void *)0))
    {
        fprintf(stderr, "Erreur de chargement de la fonction : %s\n", dlerror());
        return -1;
    }
    if ((ai->EndGame = (pfEndGame) dlsym(ai->lib, "EndGame")) == ((void *)0))
    {
        fprintf(stderr, "Erreur de chargement de la fonction : %s\n", dlerror());
        return -1;
    }
    if ((ai->EndMatch = (pfEndMatch) dlsym(ai->lib, "EndMatch")) == ((void *)0))
    {
        fprintf(stderr, "Erreur de chargement de la fonction : %s\n", dlerror());
        return -1;
    }
    if ((ai->NextMove = (pfNextMove) dlsym(ai->lib, "NextMove")) == ((void *)0))
    {
        fprintf(stderr, "Erreur de chargement de la fonction : %s\n", dlerror());
        return -1;
    }
    if ((ai->AttackResult = (pfAttackResult) dlsym(ai->lib, "AttackResult")) == ((void *)0))
    {
        fprintf(stderr, "Erreur de chargement de la fonction : %s\n", dlerror());
        return -1;
    }
    if ((ai->Penalty = (pfPenalty) dlsym(ai->lib, "Penalty")) == ((void *)0))
    {
        fprintf(stderr, "Erreur de chargement de la fonction : %s\n", dlerror());
        return -1;
    }
    return 0;
}

canonical_original_code:
int LoadLib(struct AI *ai, char *file)
{
    if ((ai->lib = dlopen(file, 0x00001)) == ((void *)0))
    {
        fprintf(stderr, "Erreur de chargement de la lib : %s\n", dlerror());
        return -1;
    }
    if ((ai->InitLibrary = (void (*)(char [50])) dlsym(ai->lib, "InitLibrary")) == ((void *)0))
    {
        fprintf(stderr, "Erreur de chargement de la fonction : %s\n", dlerror());
        return -1;
    }
    if ((ai->StartMatch = (void (*)()) dlsym(ai->lib, "StartMatch")) == ((void *)0))
    {
        fprintf(stderr, "Erreur de chargement de la fonction : %s\n", dlerror());
        return -1;
    }
    if ((ai->StartGame = (void (*)(enum EColor, enum EPiece [4][10])) dlsym(ai->lib, "StartGame")) == ((void *)0))
    {
        fprintf(stderr, "Erreur de chargement de la fonction : %s\n", dlerror());
        return -1;
    }
    if ((ai->EndGame = (void (*)()) dlsym(ai->lib, "EndGame")) == ((void *)0))
    {
        fprintf(stderr, "Erreur de chargement de la fonction : %s\n", dlerror());
        return -1;
    }
    if ((ai->EndMatch = (void (*)()) dlsym(ai->lib, "EndMatch")) == ((void *)0))
    {
        fprintf(stderr, "Erreur de chargement de la fonction : %s\n", dlerror());
        return -1;
    }
    if ((ai->NextMove = (struct SMove (*)(struct SGameState *)) dlsym(ai->lib, "NextMove")) == ((void *)0))
    {
        fprintf(stderr, "Erreur de chargement de la fonction : %s\n", dlerror());
        return -1;
    }
    if ((ai->AttackResult = (void (*)(struct SPos, enum EPiece, struct SPos, enum EPiece)) dlsym(ai->lib, "AttackResult")) == ((void *)0))
    {
        fprintf(stderr, "Erreur de chargement de la fonction : %s\n", dlerror());
        return -1;
    }
    if ((ai->Penalty = (void (*)()) dlsym(ai->lib, "Penalty")) == ((void *)0))
    {
        fprintf(stderr, "Erreur de chargement de la fonction : %s\n", dlerror());
        return -1;
    }
    return 0;
}

variable_types: struct AI { void *lib; void (*InitLibrary)(char [50]); void (*StartMatch)(); void (*StartGame)(enum EColor { ECnone=0, EClake=1, ECred=2, ECblue=3 }, enum EPiece { EPbomb=0, EPspy=1, EPscout=2, EPminer=3, EPsergeant=4, EPlieutenant=5, EPcaptain=6, EPmajor=7, EPcolonel=8, EPgeneral=9, EPmarshal=10, EPflag=11, EPnone=12 } [4][10]); void (*EndGame)(); void (*EndMatch)(); struct SMove { struct SPos { int line; int col; } start; struct SPos end; } (*NextMove)(struct SGameState { struct SBox { enum EColor { ECnone=0, EClake=1, ECred=2, ECblue=3 } content; enum EPiece { EPbomb=0, EPspy=1, EPscout=2, EPminer=3, EPsergeant=4, EPlieutenant=5, EPcaptain=6, EPmajor=7, EPcolonel=8, EPgeneral=9, EPmarshal=10, EPflag=11, EPnone=12 } piece; } board[10][10]; unsigned int redOut[11]; unsigned int blueOut[11]; } *); void (*AttackResult)(struct SPos, enum EPiece { EPbomb=0, EPspy=1, EPscout=2, EPminer=3, EPsergeant=4, EPlieutenant=5, EPcaptain=6, EPmajor=7, EPcolonel=8, EPgeneral=9, EPmarshal=10, EPflag=11, EPnone=12 }, struct SPos, enum EPiece { EPbomb=0, EPspy=1, EPscout=2, EPminer=3, EPsergeant=4, EPlieutenant=5, EPcaptain=6, EPmajor=7, EPcolonel=8, EPgeneral=9, EPmarshal=10, EPflag=11, EPnone=12 }); void (*Penalty)(); } *

variable_types:
file
char *

user_defined_types: struct AI { void *lib; void (*InitLibrary)(char [50]); void (*StartMatch)(); void (*StartGame)(enum EColor, enum EPiece [4][10]); void (*EndGame)(); void (*EndMatch)(); struct SMove (*NextMove)(struct SGameState *); void (*AttackResult)(struct SPos, enum EPiece, struct SPos, enum EPiece); void (*Penalty)(); }

user_defined_types: struct SMove { struct SPos start; struct SPos end; }

user_defined_types: struct SGameState { struct SBox board[10][10]; unsigned int redOut[11]; unsigned int blueOut[11]; }

user_defined_types: struct SBox { enum EColor content; enum EPiece piece; }


repo: AltraVita/vanetcsim

decompiled_code:
char *__fastcall address_copy_func(char *src)
{
char *v1; // rbp

v1 = 0LL;
if ( src )
{
v1 = (char *)malloc(0x20uLL);
strncpy(v1, src, 0x20uLL);
}
return v1;
}

canonical_decompiled_code:
char *__fastcall func0(char *src)
{
char *v1; // rbp

v1 = 0LL;
if ( src )
{
v1 = (char *)malloc(0x20uLL);
strncpy(v1, src, 0x20uLL);
}
return v1;
}

original_code:
char* address_copy_func(char * addr)
{
 char *rtAddr;
 if(addr) {
  rtAddr = (char*)malloc(sizeof(char)*32);
  strncpy(rtAddr, addr, 32);
 }
 return rtAddr;
}

canonical_original_code:
char *address_copy_func(char *addr)
{
 char *rtAddr;
 if(addr) {
  rtAddr = (char *)malloc(sizeof(char)*32);
  strncpy(rtAddr, addr, 32);
 }
 return rtAddr;
}

variable_types:
addr
char *

variable_types:
rtAddr
char *

return_type: char *


original_code:
void pkg_init_func(struct Pkg *aPkg, unsigned id, char* src, char* dst, time_t startAt, unsigned int size, int ttl, double value)
{
 if(aPkg == ((void *)0))
  return;
 aPkg->id = id;
 strncpy(aPkg->src, src, strlen(src)+1);
 strncpy(aPkg->dst, dst, strlen(dst)+1);
 aPkg->startAt = startAt;
 aPkg->endAt = 0;
 aPkg->size = size;
 aPkg->ttl = ttl;
 aPkg->value = value;
 duallist_init(&aPkg->routingRecord);
}

canonical_original_code:
void pkg_init_func(struct Pkg *aPkg, unsigned int id, char *src, char *dst, long startAt, unsigned int size, int ttl, double value)
{
 if(aPkg == ((void *)0))
  return;
 aPkg->id = id;
 strncpy(aPkg->src, src, strlen(src)+1);
 strncpy(aPkg->dst, dst, strlen(dst)+1);
 aPkg->startAt = startAt;
 aPkg->endAt = 0;
 aPkg->size = size;
 aPkg->ttl = ttl;
 aPkg->value = value;
 duallist_init(&aPkg->routingRecord);
}

variable_types: struct Pkg { unsigned int id; char src[-1]; char dst[-1]; long startAt; long endAt; unsigned int size; int ttl; double value; struct Duallist { struct Item { void *datap; struct Item *prev; struct Item *next; } *head; unsigned long nItems; } routingRecord; } *

variable_types:
id
unsigned int

variable_types:
src
char *

variable_types:
dst
char *

variable_types: startAt long

variable_types:
size
unsigned int

variable_types: ttl int

variable_types: value double

user_defined_types: struct Pkg { unsigned int id; char src[-1]; char dst[-1]; long startAt; long endAt; unsigned int size; int ttl; double value; struct Duallist routingRecord; }

user_defined_types: struct Duallist { struct Item *head; unsigned long nItems; }


original_code:
struct Pkg *pkg_copy_func(struct Pkg *aPkg)
{
 struct Pkg *newPkg;
 if(aPkg == ((void *)0))
  return ((void *)0);
 newPkg = (struct Pkg*)malloc(sizeof(struct Pkg));
 newPkg->id = aPkg->id;
 strncpy(newPkg->src, aPkg->src, 32);
 strncpy(newPkg->dst, aPkg->dst, 32);
 newPkg->startAt = aPkg->startAt;
 newPkg->endAt = aPkg->endAt;
 newPkg->size = aPkg->size;
 newPkg->ttl = aPkg->ttl;
 newPkg->value = aPkg->value;
 duallist_copy(&newPkg->routingRecord, &aPkg->routingRecord,(void*(*)(void*))address_copy_func);
 return newPkg;
}

canonical_original_code:
struct Pkg *pkg_copy_func(struct Pkg *aPkg)
{
 struct Pkg *newPkg;
 if(aPkg == ((void *)0))
  return ((void *)0);
 newPkg = (struct Pkg *)malloc(sizeof(struct Pkg));
 newPkg->id = aPkg->id;
 strncpy(newPkg->src, aPkg->src, 32);
 strncpy(newPkg->dst, aPkg->dst, 32);
 newPkg->startAt = aPkg->startAt;
 newPkg->endAt = aPkg->endAt;
 newPkg->size = aPkg->size;
 newPkg->ttl = aPkg->ttl;
 newPkg->value = aPkg->value;
 duallist_copy(&newPkg->routingRecord, &aPkg->routingRecord,(void *(*)(void *))address_copy_func);
 return newPkg;
}

variable_types:
aPkg
struct Pkg *

return_type: struct Pkg { unsigned int id; char src[-1]; char dst[-1]; long startAt; long endAt; unsigned int size; int ttl; double value; struct Duallist { struct Item { void *datap; struct Item *prev; struct Item *next; } *head; unsigned long nItems; } routingRecord; } *


decompiled_code:
void __fastcall pkg_free_func(void *ptr)
{
if ( ptr )
{
duallist_destroy((char *)ptr + 168, &free);
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func3(void *ptr)
{
if ( ptr )
{
duallist_destroy((char *)ptr + 168, &free);
free(ptr);
}
}

original_code:
void pkg_free_func(struct Pkg *aPkg)
{
 if(aPkg) {
  duallist_destroy(&aPkg->routingRecord, free);
  free(aPkg);
 }
}

user_defined_types: struct Item { void *datap; struct Item *prev; struct Item *next; }


decompiled_code:
_BOOL8 __fastcall pkg_has_id(_DWORD *a1, _DWORD *a2)
{
return *a1 == *a2;
}

canonical_decompiled_code:
_BOOL8 __fastcall func4(_DWORD *a1, _DWORD *a2)
{
return *a1 == *a2;
}

original_code:
int pkg_has_id(int *id, struct Pkg *aPkg)
{
 return *id==aPkg->id;
}

variable_types:
id
int *


decompiled_code:
_BOOL8 __fastcall pkg_has_earlier_startAt_than(__int64 a1, __int64 a2)
{
return *(_QWORD *)(a1 + 136) < *(_QWORD *)(a2 + 136);
}

original_code:
int pkg_has_earlier_startAt_than(struct Pkg *aPkg, struct Pkg *bPkg)
{
 return aPkg->startAt < bPkg->startAt;
}

variable_types:
bPkg
struct Pkg *


decompiled_code:
_BOOL8 __fastcall count_has_id(char *s1, char *s2)
{
size_t v2; // rax

v2 = strlen(s1);
return strncmp(s1, s2, v2) == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(char *s1, char *s2)
{
size_t v2; // rax

v2 = strlen(s1);
return strncmp(s1, s2, v2) == 0;
}

original_code:
int count_has_id(char *name, struct VidCount *aVid)
{
 return !strncmp(name, aVid->id, strlen(name));
}

variable_types:
name
char *

variable_types: struct VidCount { char id[256]; int count; } *


basename

decompiled_code:
const char *__fastcall basename(const char *a1)
{
char *v2; // rax
char *v3; // rdi
bool v4; // zf
const char *result; // rax

v2 = strrchr(a1, 47);
v3 = v2 + 1;
v4 = v2 == 0LL;
result = a1;
if ( !v4 )
result = v3;
return result;
}

canonical_decompiled_code:
const char *__fastcall func1(const char *a1)
{
char *v2; // rax
char *v3; // rdi
bool v4; // zf
const char *result; // rax

v2 = strrchr(a1, 47);
v3 = v2 + 1;
v4 = v2 == 0LL;
result = a1;
if ( !v4 )
result = v3;
return result;
}

original_code:
char* basename (char* path)
{
    char *ptr = strrchr (path, '/');
    return ptr ? ptr + 1 : (char*)path;
}

canonical_original_code:
char *basename(char *path)
{
    char *ptr = strrchr (path, '/');
    return ptr ? ptr + 1 : (char *)path;
}

variable_types:
path
char *

variable_types:
ptr
char *


decompiled_code:
_BOOL8 __fastcall value_is_smaller_than(double *a1, double *a2)
{
return *a2 > *a1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(double *a1, double *a2)
{
return *a2 > *a1;
}

original_code:
int value_is_smaller_than(double *aValue, double *bValue)
{
 return *aValue < *bValue;
}

variable_types:
aValue
double *

variable_types:
bValue
double *


decompiled_code:
_BOOL8 __fastcall taxi_has_name(const char *a1, const char *a2)
{
return strcmp(a1, a2) == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(const char *a1, const char *a2)
{
return strcmp(a1, a2) == 0;
}

original_code:
int taxi_has_name(char *name, struct TaxiReps* ataxi)
{
 return !strcmp(name, ataxi->vname);
}

canonical_original_code:
int taxi_has_name(char *name, struct TaxiReps *ataxi)
{
 return !strcmp(name, ataxi->vname);
}

variable_types: struct TaxiReps { char vname[32]; double maxvalue; double minvalue; double avgvalue; struct Duallist { struct Item { void *datap; struct Item *prev; struct Item *next; } *head; unsigned long nItems; } reps; } *

user_defined_types: struct TaxiReps { char vname[32]; double maxvalue; double minvalue; double avgvalue; struct Duallist reps; }


decompiled_code:
void __fastcall taxi_free_func(void *ptr)
{
if ( ptr )
{
duallist_destroy((char *)ptr + 56, &free);
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func2(void *ptr)
{
if ( ptr )
{
duallist_destroy((char *)ptr + 56, &free);
free(ptr);
}
}

original_code:
void taxi_free_func(struct TaxiReps *ataxi)
{
 if(ataxi==((void *)0))
  return;
 duallist_destroy(&ataxi->reps, free);
 free(ataxi);
}


original_code:
void compute_a_taxi(struct TaxiReps *ataxi)
{
 struct Item *aItem;
 double sum = 0;
 if(ataxi == ((void *)0)) return;
 aItem = ataxi->reps.head->next;
 while(aItem != ((void *)0)) {
  sum += *((double*)aItem->datap);
  aItem = aItem->next;
 }
 if(ataxi->reps.nItems - 1 > 0)
  ataxi->avgvalue = sum/(ataxi->reps.nItems - 1);
 else
  ataxi->avgvalue = -1;
}

canonical_original_code:
void compute_a_taxi(struct TaxiReps *ataxi)
{
 struct Item *aItem;
 double sum = 0;
 if(ataxi == ((void *)0)) return;
 aItem = ataxi->reps.head->next;
 while(aItem != ((void *)0)) {
  sum += *((double *)aItem->datap);
  aItem = aItem->next;
 }
 if(ataxi->reps.nItems - 1 > 0)
  ataxi->avgvalue = sum/(ataxi->reps.nItems - 1);
 else
  ataxi->avgvalue = -1;
}

variable_types: struct Item { void *datap; struct Item *prev; struct Item *next; } *

variable_types: sum double


decompiled_code:
_BOOL8 __fastcall pairName_has_names(char *s1, const char *a2)
{
char v3[136]; // [rsp+0h] [rbp-88h] BYREF

sprintf(v3, "%s,%s", a2, a2 + 32);
return strcmp(s1, v3) == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(char *s1, const char *a2)
{
char v3[136]; // [rsp+0h] [rbp-88h] BYREF

sprintf(v3, "%s,%s", a2, a2 + 32);
return strcmp(s1, v3) == 0;
}

original_code:
int pairName_has_names(char *names, struct PairName *aPairName)
{
 char buf[128];
 sprintf(buf, "%s,%s", aPairName->vName1, aPairName->vName2);
 return !strcmp(names, buf);
}

variable_types:
names
char *

variable_types: struct PairName { char vName1[32]; char vName2[32]; } *

variable_types:
buf
char [128]


decompiled_code:
_BOOL8 __fastcall attacker_has_name(const char *a1, const char *a2)
{
return strcmp(a1, a2) == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(const char *a1, const char *a2)
{
return strcmp(a1, a2) == 0;
}

original_code:
int attacker_has_name(char *name, struct Honest* aHonest)
{
 return !strcmp(name, aHonest->name);
}

canonical_original_code:
int attacker_has_name(char *name, struct Honest *aHonest)
{
 return !strcmp(name, aHonest->name);
}

variable_types: struct Honest { char name[64]; int state; } *


decompiled_code:
_BOOL8 __fastcall honest_has_name(const char *a1, const char *a2)
{
return strcmp(a1, a2) == 0;
}

original_code:
int honest_has_name(char *name, struct Honest* aHonest)
{
 return !strcmp(name, aHonest->name);
}

canonical_original_code:
int honest_has_name(char *name, struct Honest *aHonest)
{
 return !strcmp(name, aHonest->name);
}

user_defined_types: struct Honest { char name[64]; int state; }


decompiled_code:
_BOOL8 __fastcall is_name_honest(char *src)
{
size_t v1; // rax
char v3[72]; // [rsp+0h] [rbp-48h] BYREF

v1 = strlen(src);
strncpy(v3, src, v1 + 1);
strtok(v3, "_");
strtok(0LL, "_");
strtok(0LL, "_");
return strtok(0LL, "_") == 0LL;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(char *src)
{
size_t v1; // rax
char v3[72]; // [rsp+0h] [rbp-48h] BYREF

v1 = strlen(src);
strncpy(v3, src, v1 + 1);
strtok(v3, "_");
strtok(0LL, "_");
strtok(0LL, "_");
return strtok(0LL, "_") == 0LL;
}

original_code:
int is_name_honest(char *name)
{
 char buf[64], *p;
 strncpy(buf, name, strlen(name)+1);
 p = strtok(buf, "_");
 p = strtok(((void *)0), "_");
 p = strtok(((void *)0), "_");
 p = strtok(((void *)0), "_");
 if(p) return 0;
 return 1;
}

canonical_original_code:
int is_name_honest(char *name)
{
 char buf[64]; char *p;
 strncpy(buf, name, strlen(name)+1);
 p = strtok(buf, "_");
 p = strtok(((void *)0), "_");
 p = strtok(((void *)0), "_");
 p = strtok(((void *)0), "_");
 if(p) return 0;
 return 1;
}

variable_types:
buf
char [64]

variable_types:
p
char *


decompiled_code:
char *__fastcall get_attacker_name(char *dest)
{
char *v1; // rbp
size_t v2; // rax
char *v3; // rbp
size_t v4; // rax
char *v5; // rbp
size_t v6; // rax
size_t v7; // rax
__int64 v9[11]; // [rsp+0h] [rbp-58h] BYREF

v9[0] = 0LL;
v9[1] = 0LL;
v9[2] = 0LL;
v9[3] = 0LL;
v9[4] = 0LL;
v9[5] = 0LL;
v9[6] = 0LL;
v9[7] = 0LL;
v1 = strtok(dest, "_");
v2 = strlen(v1);
strncat((char *)v9, v1, v2);
*(_WORD *)((char *)v9 + strlen((const char *)v9)) = 95;
v3 = strtok(0LL, "_");
v4 = strlen(v3);
strncat((char *)v9, v3, v4);
*(_WORD *)((char *)v9 + strlen((const char *)v9)) = 95;
v5 = strtok(0LL, "_");
v6 = strlen(v5);
strncat((char *)v9, v5, v6);
v7 = strlen((const char *)v9);
return strncpy(dest, (const char *)v9, v7 + 1);
}

canonical_decompiled_code:
char *__fastcall func3(char *dest)
{
char *v1; // rbp
size_t v2; // rax
char *v3; // rbp
size_t v4; // rax
char *v5; // rbp
size_t v6; // rax
size_t v7; // rax
__int64 v9[11]; // [rsp+0h] [rbp-58h] BYREF

v9[0] = 0LL;
v9[1] = 0LL;
v9[2] = 0LL;
v9[3] = 0LL;
v9[4] = 0LL;
v9[5] = 0LL;
v9[6] = 0LL;
v9[7] = 0LL;
v1 = strtok(dest, "_");
v2 = strlen(v1);
strncat((char *)v9, v1, v2);
*(_WORD *)((char *)v9 + strlen((const char *)v9)) = 95;
v3 = strtok(0LL, "_");
v4 = strlen(v3);
strncat((char *)v9, v3, v4);
*(_WORD *)((char *)v9 + strlen((const char *)v9)) = 95;
v5 = strtok(0LL, "_");
v6 = strlen(v5);
strncat((char *)v9, v5, v6);
v7 = strlen((const char *)v9);
return strncpy(dest, (const char *)v9, v7 + 1);
}

original_code:
char * get_attacker_name(char *name)
{
 char buf[64], *p;
 memset(buf, 0, 64);
 p = strtok(name, "_");
 strncat(buf, p, strlen(p));
 strncat(buf, "_", 1);
 p = strtok(((void *)0), "_");
 strncat(buf, p, strlen(p));
 strncat(buf, "_", 1);
 p = strtok(((void *)0), "_");
 strncat(buf, p, strlen(p));
 strncpy(name, buf, strlen(buf)+1);
 return name;
}

canonical_original_code:
char *get_attacker_name(char *name)
{
 char buf[64]; char *p;
 memset(buf, 0, 64);
 p = strtok(name, "_");
 strncat(buf, p, strlen(p));
 strncat(buf, "_", 1);
 p = strtok(((void *)0), "_");
 strncat(buf, p, strlen(p));
 strncat(buf, "_", 1);
 p = strtok(((void *)0), "_");
 strncat(buf, p, strlen(p));
 strncpy(name, buf, strlen(buf)+1);
 return name;
}


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

if ( a1 )
{
result = duallist_init();
*(_QWORD *)(a1 + 16) = a2;
*(_QWORD *)(a1 + 24) = 0LL;
}
return result;
}

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

if ( a1 )
{
result = duallist_init();
*(_QWORD *)(a1 + 16) = a2;
*(_QWORD *)(a1 + 24) = 0LL;
}
return result;
}

original_code:
void storage_init_func(struct Storage *storage, unsigned long size)
{
 if(storage) {
  duallist_init(&storage->pkgs);
  storage->size = size;
  storage->usage = 0;
 }
}

variable_types: struct Storage { struct Duallist { struct Item { void *datap; struct Item *prev; struct Item *next; } *head; unsigned long nItems; } pkgs; unsigned long size; unsigned long usage; } *

variable_types:
size
unsigned long

user_defined_types: struct Storage { struct Duallist pkgs; unsigned long size; unsigned long usage; }


decompiled_code:
__int64 __fastcall storage_add_pkg(__int64 a1, __int64 a2)
{
__int64 result; // rax
unsigned __int64 v3; // rdx

if ( !a1 )
return 2LL;
result = 2LL;
if ( a2 )
{
v3 = *(_QWORD *)(a1 + 16);
if ( v3 == -1LL || v3 >= *(_QWORD *)(a1 + 24) + (unsigned __int64)*(unsigned int *)(a2 + 152) )
{
duallist_add_in_sequence_from_tail(a1, a2, &pkg_has_earlier_startAt_than);
*(_QWORD *)(a1 + 24) += *(unsigned int *)(a2 + 152);
result = 0LL;
}
else
{
pkg_free_func(a2);
result = 1LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
__int64 result; // rax
unsigned __int64 v3; // rdx

if ( !a1 )
return 2LL;
result = 2LL;
if ( a2 )
{
v3 = *(_QWORD *)(a1 + 16);
if ( v3 == -1LL || v3 >= *(_QWORD *)(a1 + 24) + (unsigned __int64)*(unsigned int *)(a2 + 152) )
{
duallist_add_in_sequence_from_tail(a1, a2, &pkg_has_earlier_startAt_than);
*(_QWORD *)(a1 + 24) += *(unsigned int *)(a2 + 152);
result = 0LL;
}
else
{
pkg_free_func(a2);
result = 1LL;
}
}
return result;
}

original_code:
int storage_add_pkg(struct Storage *storage, struct Pkg *aPkg)
{
 if(storage && aPkg) {
  if(storage->size == -1 || storage->usage + aPkg->size <= storage->size) {
   duallist_add_in_sequence_from_tail(&storage->pkgs, aPkg, (int(*)(void*,void*))pkg_has_earlier_startAt_than);
   storage->usage += aPkg->size;
   return 0;
  } else {
   pkg_free_func(aPkg);
   return 1;;
  }
 }
 return 2;;
}

canonical_original_code:
int storage_add_pkg(struct Storage *storage, struct Pkg *aPkg)
{
 if(storage && aPkg) {
  if(storage->size == -1 || storage->usage + aPkg->size <= storage->size) {
   duallist_add_in_sequence_from_tail(&storage->pkgs, aPkg, (int (*)(void *, void *))pkg_has_earlier_startAt_than);
   storage->usage += aPkg->size;
   return 0;
  } else {
   pkg_free_func(aPkg);
   return 1;;
  }
 }
 return 2;;
}

variable_types: struct Pkg { unsigned int id; char src[-1]; char dst[-1]; long startAt; long endAt; unsigned int size; int ttl; double value; struct Duallist routingRecord; } *


decompiled_code:
void __fastcall storage_remove_pkg(__int64 a1, int a2)
{
__int64 v2; // rax
__int64 v3; // rax
int v4[3]; // [rsp+Ch] [rbp-Ch] BYREF

v4[0] = a2;
if ( a1 )
{
v2 = duallist_find(a1, v4, &pkg_has_id);
if ( v2 )
{
*(_QWORD *)(a1 + 24) -= *(unsigned int *)(*(_QWORD *)v2 + 152LL);
v3 = duallist_pick_item(a1, v2);
pkg_free_func(v3);
}
}
}

canonical_decompiled_code:
void __fastcall func2(__int64 a1, int a2)
{
__int64 v2; // rax
__int64 v3; // rax
int v4[3]; // [rsp+Ch] [rbp-Ch] BYREF

v4[0] = a2;
if ( a1 )
{
v2 = duallist_find(a1, v4, &pkg_has_id);
if ( v2 )
{
*(_QWORD *)(a1 + 24) -= *(unsigned int *)(*(_QWORD *)v2 + 152LL);
v3 = duallist_pick_item(a1, v2);
pkg_free_func(v3);
}
}
}

original_code:
void storage_remove_pkg(struct Storage *storage, int pkgId)
{
 struct Item *aItem;
 if(storage){
  aItem = duallist_find(&storage->pkgs, &pkgId,(int(*)(void*,void*))pkg_has_id);
  if(aItem) {
   storage->usage -= ((struct Pkg*)aItem->datap)->size;
   pkg_free_func( (struct Pkg*)duallist_pick_item(&storage->pkgs, aItem));
  }
 }
}

canonical_original_code:
void storage_remove_pkg(struct Storage *storage, int pkgId)
{
 struct Item *aItem;
 if(storage){
  aItem = duallist_find(&storage->pkgs, &pkgId,(int (*)(void *, void *))pkg_has_id);
  if(aItem) {
   storage->usage -= ((struct Pkg *)aItem->datap)->size;
   pkg_free_func( (struct Pkg *)duallist_pick_item(&storage->pkgs, aItem));
  }
 }
}

variable_types: pkgId int


decompiled_code:
void __fastcall storage_free_func(void *ptr)
{
__int64 v1; // rax

if ( ptr )
{
while ( *(_QWORD *)ptr )
{
v1 = duallist_pick_head(ptr);
pkg_free_func(v1);
}
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func3(void *ptr)
{
__int64 v1; // rax

if ( ptr )
{
while ( *(_QWORD *)ptr )
{
v1 = duallist_pick_head(ptr);
pkg_free_func(v1);
}
free(ptr);
}
}

original_code:
void storage_free_func(struct Storage *storage)
{
 if(storage) {
  while(storage->pkgs.head) {
   pkg_free_func((struct Pkg*)duallist_pick_head(&storage->pkgs));
  }
  free(storage);
 }
}

canonical_original_code:
void storage_free_func(struct Storage *storage)
{
 if(storage) {
  while(storage->pkgs.head) {
   pkg_free_func((struct Pkg *)duallist_pick_head(&storage->pkgs));
  }
  free(storage);
 }
}


decompiled_code:
_BOOL8 __fastcall trace_has_less_mobility_than(__int64 a1, __int64 a2)
{
return *(_QWORD *)(a1 + 80) < *(_QWORD *)(a2 + 80);
}

original_code:
int trace_has_less_mobility_than(struct Trace_mobility *aTraceMobility, struct Trace_mobility *bTraceMobility)
{
 return aTraceMobility->count < bTraceMobility->count;
}

variable_types: struct Trace_mobility { char vName[32]; struct Hashtable { struct Item { void *datap; struct Item *prev; struct Item *next; } **head; unsigned long size; unsigned long entries; unsigned long count; unsigned long (*hash_func)(void *); int (*equal_func)(void *, void *); } cells; unsigned long count; } *

variable_types:
bTraceMobility
struct Trace_mobility *

user_defined_types: struct Trace_mobility { char vName[32]; struct Hashtable cells; unsigned long count; }

user_defined_types: struct Hashtable { struct Item **head; unsigned long size; unsigned long entries; unsigned long count; unsigned long (*hash_func)(void *); int (*equal_func)(void *, void *); }


decompiled_code:
void __fastcall trace_mobility_free_func(void *ptr)
{
if ( ptr )
{
hashtable_destroy((char *)ptr + 32, 0LL);
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func1(void *ptr)
{
if ( ptr )
{
hashtable_destroy((char *)ptr + 32, 0LL);
free(ptr);
}
}

original_code:
void trace_mobility_free_func(struct Trace_mobility *aTraceMobility)
{
 if(aTraceMobility == ((void *)0))
  return;
 hashtable_destroy(&aTraceMobility->cells, ((void *)0));
 free(aTraceMobility);
}


decompiled_code:
_BOOL8 __fastcall trace_mobility_has_name(const char *a1, const char *a2)
{
_BOOL8 result; // rax

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

canonical_decompiled_code:
_BOOL8 __fastcall func2(const char *a1, const char *a2)
{
_BOOL8 result; // rax

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

original_code:
int trace_mobility_has_name(char *name, struct Trace_mobility* aTraceMobility)
{
 if(aTraceMobility == ((void *)0))
  return 0;
 return !strcmp(name, aTraceMobility->vName);
}

canonical_original_code:
int trace_mobility_has_name(char *name, struct Trace_mobility *aTraceMobility)
{
 if(aTraceMobility == ((void *)0))
  return 0;
 return !strcmp(name, aTraceMobility->vName);
}

variable_types:
name
char *


decompiled_code:
__int64 __fastcall set_size(unsigned __int64 a1)
{
_QWORD *v1; // rcx
__int64 v2; // rbp
__int64 result; // rax
_QWORD *v4; // rdi
unsigned __int64 v5; // rdx

v1 = (_QWORD *)(a1 + 8 * ((unsigned __int64)(*(_QWORD *)(a1 - 8) + 63LL) >> 6));
if ( a1 >= (unsigned __int64)v1 )
return 0LL;
v2 = (((unsigned __int64)v1 + ~a1) >> 3) & 1;
result = (unsigned int)(set_bit_count[(unsigned __int8)*(_QWORD *)a1]
+ set_bit_count[(unsigned __int8)BYTE1(*(_QWORD *)a1)]
+ set_bit_count[(unsigned __int8)BYTE2(*(_QWORD *)a1)]
+ set_bit_count[BYTE3(*(_QWORD *)a1)]
+ set_bit_count[(unsigned __int8)BYTE4(*(_QWORD *)a1)]
+ set_bit_count[(unsigned __int8)((unsigned __int16)WORD2(*(_QWORD *)a1) >> 8)]
+ set_bit_count[(unsigned __int8)BYTE6(*(_QWORD *)a1)]
+ set_bit_count[HIBYTE(*(_QWORD *)a1)]);
v4 = (_QWORD *)(a1 + 8);
if ( v4 < v1 )
{
if ( !v2
|| (result = (unsigned int)(set_bit_count[(unsigned __int8)*v4]
+ set_bit_count[(unsigned __int8)BYTE1(*v4)]
+ set_bit_count[(unsigned __int8)BYTE2(*v4)]
+ set_bit_count[BYTE3(*v4)]
+ set_bit_count[(unsigned __int8)BYTE4(*v4)]
+ set_bit_count[(unsigned __int8)((unsigned __int16)WORD2(*v4) >> 8)]
+ set_bit_count[(unsigned __int8)BYTE6(*v4)]
+ set_bit_count[HIBYTE(*v4)]
+ result),
++v4,
v4 < v1) )
{
do
{
v5 = v4[1];
result = (unsigned int)(result
+ set_bit_count[(unsigned __int8)*v4]
+ set_bit_count[(unsigned __int8)BYTE1(*v4)]
+ set_bit_count[(unsigned __int8)BYTE2(*v4)]
+ set_bit_count[BYTE3(*v4)]
+ set_bit_count[(unsigned __int8)BYTE4(*v4)]
+ set_bit_count[(unsigned __int8)((unsigned __int16)WORD2(*v4) >> 8)]
+ set_bit_count[(unsigned __int8)BYTE6(*v4)]
+ set_bit_count[HIBYTE(*v4)]
+ set_bit_count[(unsigned __int8)v5]
+ set_bit_count[BYTE1(v5)]
+ set_bit_count[BYTE2(v5)]
+ set_bit_count[BYTE3(v5)]
+ set_bit_count[BYTE4(v5)]
+ set_bit_count[BYTE5(v5)]
+ set_bit_count[BYTE6(v5)]
+ set_bit_count[HIBYTE(v5)]);
v4 += 2;
}
while ( v4 < v1 );
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned __int64 a1)
{
_QWORD *v1; // rcx
__int64 v2; // rbp
__int64 result; // rax
_QWORD *v4; // rdi
unsigned __int64 v5; // rdx

v1 = (_QWORD *)(a1 + 8 * ((unsigned __int64)(*(_QWORD *)(a1 - 8) + 63LL) >> 6));
if ( a1 >= (unsigned __int64)v1 )
return 0LL;
v2 = (((unsigned __int64)v1 + ~a1) >> 3) & 1;
result = (unsigned int)(set_bit_count[(unsigned __int8)*(_QWORD *)a1]
+ set_bit_count[(unsigned __int8)BYTE1(*(_QWORD *)a1)]
+ set_bit_count[(unsigned __int8)BYTE2(*(_QWORD *)a1)]
+ set_bit_count[BYTE3(*(_QWORD *)a1)]
+ set_bit_count[(unsigned __int8)BYTE4(*(_QWORD *)a1)]
+ set_bit_count[(unsigned __int8)((unsigned __int16)WORD2(*(_QWORD *)a1) >> 8)]
+ set_bit_count[(unsigned __int8)BYTE6(*(_QWORD *)a1)]
+ set_bit_count[HIBYTE(*(_QWORD *)a1)]);
v4 = (_QWORD *)(a1 + 8);
if ( v4 < v1 )
{
if ( !v2
|| (result = (unsigned int)(set_bit_count[(unsigned __int8)*v4]
+ set_bit_count[(unsigned __int8)BYTE1(*v4)]
+ set_bit_count[(unsigned __int8)BYTE2(*v4)]
+ set_bit_count[BYTE3(*v4)]
+ set_bit_count[(unsigned __int8)BYTE4(*v4)]
+ set_bit_count[(unsigned __int8)((unsigned __int16)WORD2(*v4) >> 8)]
+ set_bit_count[(unsigned __int8)BYTE6(*v4)]
+ set_bit_count[HIBYTE(*v4)]
+ result),
++v4,
v4 < v1) )
{
do
{
v5 = v4[1];
result = (unsigned int)(result
+ set_bit_count[(unsigned __int8)*v4]
+ set_bit_count[(unsigned __int8)BYTE1(*v4)]
+ set_bit_count[(unsigned __int8)BYTE2(*v4)]
+ set_bit_count[BYTE3(*v4)]
+ set_bit_count[(unsigned __int8)BYTE4(*v4)]
+ set_bit_count[(unsigned __int8)((unsigned __int16)WORD2(*v4) >> 8)]
+ set_bit_count[(unsigned __int8)BYTE6(*v4)]
+ set_bit_count[HIBYTE(*v4)]
+ set_bit_count[(unsigned __int8)v5]
+ set_bit_count[BYTE1(v5)]
+ set_bit_count[BYTE2(v5)]
+ set_bit_count[BYTE3(v5)]
+ set_bit_count[BYTE4(v5)]
+ set_bit_count[BYTE5(v5)]
+ set_bit_count[BYTE6(v5)]
+ set_bit_count[HIBYTE(v5)]);
v4 += 2;
}
while ( v4 < v1 );
}
}
return result;
}

original_code:
__attribute__((unused)) inline
static int set_size(set_t s) {
 int count=0;
 setelement *c;
 for (c=s; c < s+(((s)[-1]+64 -1)/64); c++)
  count+=(set_bit_count[(*c)>>56] + set_bit_count[((*c)>>48)&0xFF] + set_bit_count[((*c)>>40)&0xFF] + set_bit_count[((*c)>>32)&0xFF] + set_bit_count[((*c)>>24)&0xFF] + set_bit_count[((*c)>>16)&0xFF] + set_bit_count[((*c)>>8)&0xFF] + set_bit_count[(*c)&0xFF]);
 return count;
}

canonical_original_code:
inline static int set_size(unsigned long *s) {
 int count = 0;
 unsigned long *c;
 for (c=s; c < s+(((s)[-1]+64 -1)/64); c++)
  count+=(set_bit_count[(*c)>>56] + set_bit_count[((*c)>>48)&0xFF] + set_bit_count[((*c)>>40)&0xFF] + set_bit_count[((*c)>>32)&0xFF] + set_bit_count[((*c)>>24)&0xFF] + set_bit_count[((*c)>>16)&0xFF] + set_bit_count[((*c)>>8)&0xFF] + set_bit_count[(*c)&0xFF]);
 return count;
}

variable_types:
s
unsigned long *

variable_types: count int

variable_types:
c
unsigned long *


original_code:
__attribute__((unused)) inline
static int graph_subgraph_weight(graph_t *g,set_t s) {
 int i,j;
 int count=0;
 setelement e;
 for (i=0; i<(((s)[-1]+64 -1)/64); i++) {
  if (s[i]) {
   e=s[i];
   for (j=0; j<64; j++) {
    if (e&1)
     count+=g->weights[i*64 +j];
    e = e>>1;
   }
  }
 }
 return count;
}

canonical_original_code:
inline static int graph_subgraph_weight(struct _graph_t *g, unsigned long *s) {
 int i; int j;
 int count = 0;
 unsigned long e;
 for (i=0; i<(((s)[-1]+64 -1)/64); i++) {
  if (s[i]) {
   e=s[i];
   for (j=0; j<64; j++) {
    if (e&1)
     count+=g->weights[i*64 +j];
    e = e>>1;
   }
  }
 }
 return count;
}

variable_types: struct _graph_t { int n; unsigned long **edges; int *weights; } *

variable_types: i int

variable_types: j int

variable_types:
e
unsigned long


printhelp

decompiled_code:
void __fastcall __noreturn printhelp(const char *a1)
{
printf(
"Usage: %s [options] <dimacs-file>\n"
"\n"
"<dimacs-file> is the ASCII or binary DIMACS-format file from which to read\n"
"the graph. Options are the following:\n"
"\n"
" -h --help This help text.\n"
" -a --all Find all cliques.\n"
" -s --single Find only one clique (default).\n"
" -w --weight Tell only maximum weight (no faster than -s).\n"
" -m N --min N Search for cliques with weight at least N. If N=0,\n"
" searches for maximum weight clique (default).\n"
" -M N --max N Search for cliques with weight at most N. If N=0,\n"
" no limit is imposed (default). N being positive is\n"
" incompatible with \"--min 0\" (\"--min 1\" is assumed).\n"
" -x --maximal Require cliques to be maximal.\n"
" -u --unweighted Assume weight 1 for all vertices.\n"
" -0 --from-0 Number vertices 0 to n-1 instead of 1 to n when writing.\n"
" -r F --reorder F Reorder with function F. See below for details.\n"
" -q --quiet Suppresses progress output. Specifying -q twice\n"
" suppresses all output except the actual result.\n"
"\n"
"Available reordering functions are the following:\n"
"\n"
" none No ordering (same order as in the file).\n"
" reverse Reverse order as in the file.\n"
" default One of the two below, depending on weightedness.\n"
" unweighted-coloring Coloring method efficient for unweighted graphs.\n"
" weighted-coloring Coloring method efficient for weighted graphs.\n"
" degree Order by ascending degree.\n"
" random Random order.\n"
"\n",
a1);
exit(0);
}

canonical_decompiled_code:
void __fastcall __noreturn func4(const char *a1)
{
printf(
"Usage: %s [options] <dimacs-file>\n"
"\n"
"<dimacs-file> is the ASCII or binary DIMACS-format file from which to read\n"
"the graph. Options are the following:\n"
"\n"
" -h --help This help text.\n"
" -a --all Find all cliques.\n"
" -s --single Find only one clique (default).\n"
" -w --weight Tell only maximum weight (no faster than -s).\n"
" -m N --min N Search for cliques with weight at least N. If N=0,\n"
" searches for maximum weight clique (default).\n"
" -M N --max N Search for cliques with weight at most N. If N=0,\n"
" no limit is imposed (default). N being positive is\n"
" incompatible with \"--min 0\" (\"--min 1\" is assumed).\n"
" -x --maximal Require cliques to be maximal.\n"
" -u --unweighted Assume weight 1 for all vertices.\n"
" -0 --from-0 Number vertices 0 to n-1 instead of 1 to n when writing.\n"
" -r F --reorder F Reorder with function F. See below for details.\n"
" -q --quiet Suppresses progress output. Specifying -q twice\n"
" suppresses all output except the actual result.\n"
"\n"
"Available reordering functions are the following:\n"
"\n"
" none No ordering (same order as in the file).\n"
" reverse Reverse order as in the file.\n"
" default One of the two below, depending on weightedness.\n"
" unweighted-coloring Coloring method efficient for unweighted graphs.\n"
" weighted-coloring Coloring method efficient for weighted graphs.\n"
" degree Order by ascending degree.\n"
" random Random order.\n"
"\n",
a1);
exit(0);
}

original_code:
void printhelp(char *prog) {
 printf("Usage:  %s [options] <dimacs-file>\n"
        "\n"
        "<dimacs-file> is the ASCII or binary DIMACS-format file from which to read\n"
        "the graph.  Options are the following:\n"
        "\n"
        " -h    --help         This help text.\n"
        " -a    --all          Find all cliques.\n"
        " -s    --single       Find only one clique (default).\n"
        " -w    --weight       Tell only maximum weight (no faster than -s).\n"
        " -m N  --min N        Search for cliques with weight at least N.  If N=0,\n"
        "                      searches for maximum weight clique (default).\n"
        " -M N  --max N        Search for cliques with weight at most N.  If N=0,\n"
        "                      no limit is imposed (default).  N being positive is\n"
        "                      incompatible with \"--min 0\" (\"--min 1\" is assumed).\n"
        " -x    --maximal      Require cliques to be maximal.\n"
        " -u    --unweighted   Assume weight 1 for all vertices.\n"
        " -0    --from-0       Number vertices 0 to n-1 instead of 1 to n when writing.\n"
        " -r F  --reorder F    Reorder with function F.  See below for details.\n"
        " -q    --quiet        Suppresses progress output.  Specifying -q twice\n"
        "                      suppresses all output except the actual result.\n"
        "\n"
        "Available reordering functions are the following:\n"
        "\n"
        "      none        No ordering (same order as in the file).\n"
        "      reverse     Reverse order as in the file.\n"
        "      default     One of the two below, depending on weightedness.\n"
        "      unweighted-coloring   Coloring method efficient for unweighted graphs.\n"
        "      weighted-coloring     Coloring method efficient for weighted graphs.\n"
        "      degree      Order by ascending degree.\n"
        "      random      Random order.\n"
        "\n",
        prog);
 exit(0);
}

variable_types:
prog
char *


decompiled_code:
__int64 __fastcall read_options(int argc, char **argv)
{
int v2; // eax
__int64 result; // rax
int longind; // [rsp+4h] [rbp-24h] BYREF

while ( 1 )
{
longind = 0;
v2 = getopt_long(argc, argv, "aswm:M:xur:1qh", &long_options_0, &longind);
if ( v2 == -1 )
break;
if ( v2 )
{
fprintf(stderr, "Internal bug: line %d should never be reached!", 316LL);
exit(-1);
}
}
if ( optind >= argc )
{
fwrite("Missing filename.\n", 1uLL, 0x12uLL, stderr);
fprintf(stderr, "Try `%s -h' for more information.\n", *argv);
exit(1);
}
if ( optind < argc - 1 )
{
fprintf(stderr, "Bad command line option: %s\n", argv[optind + 1]);
fprintf(stderr, "Try `%s -h' for more information.\n", *argv);
exit(1);
}
result = optind;
file = argv[optind];
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(int argc, char **argv)
{
int v2; // eax
__int64 result; // rax
int longind; // [rsp+4h] [rbp-24h] BYREF

while ( 1 )
{
longind = 0;
v2 = getopt_long(argc, argv, "aswm:M:xur:1qh", &long_options_0, &longind);
if ( v2 == -1 )
break;
if ( v2 )
{
fprintf(stderr, "Internal bug: line %d should never be reached!", 316LL);
exit(-1);
}
}
if ( optind >= argc )
{
fwrite("Missing filename.\n", 1uLL, 0x12uLL, stderr);
fprintf(stderr, "Try `%s -h' for more information.\n", *argv);
exit(1);
}
if ( optind < argc - 1 )
{
fprintf(stderr, "Bad command line option: %s\n", argv[optind + 1]);
fprintf(stderr, "Try `%s -h' for more information.\n", *argv);
exit(1);
}
result = optind;
file = argv[optind];
return result;
}

original_code:
void read_options(int argc, char **argv) {
 int c;
 char *ptr;
 while ((!(0))) {
  int option_index = 0;
  static struct option long_options[] = {
   { "all", 0, ((void *)0), 'a' },
   { "single", 0, ((void *)0), 's' },
   { "weight", 0, ((void *)0), 'w' },
   { "min", 1, ((void *)0), 'm' },
   { "max", 1, ((void *)0), 'M' },
   { "maximal", 0, ((void *)0), 'x' },
   { "unweighted", 0, ((void *)0), 'u' },
   { "reorder", 1, ((void *)0), 'r' },
   { "from-0", 0, ((void *)0), '0' },
   { "quiet", 0, ((void *)0), 'q' },
   { "help", 0, ((void *)0), 'h' },
   { 0,0,0,0 }
  };
  c=getopt_long(argc,argv,"aswm:M:xur:1qh",
         long_options,&option_index);
  if (c==-1)
   break;
  switch (c) {
  case 0:
   break;
  case 'a':
   find_all=(!(0));
   break;
  case 's':
   find_all=(0);
   break;
  case 'w':
   only_weight=(!(0));
   break;
  case 'm':
   min_weight=strtol(optarg,&ptr,10);
   if ((*optarg == 0) || (*ptr != 0) || (min_weight<0)) {
    fprintf(stderr,"Bad argument: %s\n",optarg);
    fprintf(stderr,"Try `%s -h' for more information.\n",argv[0]);
    exit(1);
   }
   if (min_weight==0 && max_weight>0) {
    if (max_weight_set) {
     fprintf(stderr,"Error: --max >0 is "
      "incompatible with --min 0\n");
     fprintf(stderr,"Try `%s -h' for more information.\n",argv[0]);
     exit(1);
    }
    max_weight=0;
   }
   min_weight_set=(!(0));
   break;
  case 'M':
   max_weight=strtol(optarg,&ptr,10);
   if ((*optarg == 0) || (*ptr != 0) || (max_weight<0)) {
    fprintf(stderr,"Bad argument: %s\n",optarg);
    fprintf(stderr,"Try `%s -h' for more information.\n",argv[0]);
    exit(1);
   }
   if (max_weight>0 && min_weight==0) {
    if (min_weight_set) {
     fprintf(stderr,"Error: --max >0 is "
      "incompatible with --min 0\n");
     fprintf(stderr,"Try `%s -h' for more information.\n",argv[0]);
     exit(1);
    }
    min_weight=1;
   }
   max_weight_set=(!(0));
   break;
  case 'x':
   maximal=(!(0));
   break;
  case 'u':
   unweighted=(!(0));
   break;
  case 'r':
   if (strcasecmp(optarg,"none")==0)
    reorder=((void *)0);
   else if (strcasecmp(optarg,"reverse")==0)
    reorder=reorder_by_reverse;
   else if (strcasecmp(optarg,"default")==0)
    reorder=reorder_by_greedy_coloring;
   else if (strcasecmp(optarg,"unweighted-coloring")==0)
    reorder=reorder_by_unweighted_greedy_coloring;
   else if (strcasecmp(optarg,"weighted-coloring")==0)
    reorder=reorder_by_weighted_greedy_coloring;
   else if (strcasecmp(optarg,"degree")==0)
    reorder=reorder_by_degree;
   else if (strcasecmp(optarg,"random")==0)
    reorder=reorder_by_random;
   else {
    fprintf(stderr,"Bad reordering type: %s\n",
     optarg);
    fprintf(stderr,"Try `%s -h' for more information.\n",argv[0]);
    exit(1);
   }
   break;
  case '0':
   number1=(0);
   break;
  case 'q':
   quiet++;
   break;
  case 'h':
   printhelp(argv[0]);
   break;
  case '?':
   fprintf(stderr,"Try `%s -h' for more information.\n",argv[0]);
   exit(1);
  default:
   fprintf(stderr,"Internal bug: line %d should never "
    "be reached!",316);
   exit(-1);
  }
 }
 if (optind >= argc) {
  fprintf(stderr,"Missing filename.\n");
  fprintf(stderr,"Try `%s -h' for more information.\n",argv[0]);
  exit(1);
 }
 if (optind < argc-1) {
  fprintf(stderr,"Bad command line option: %s\n",argv[optind+1]);
  fprintf(stderr,"Try `%s -h' for more information.\n",argv[0]);
  exit(1);
 }
 file=argv[optind];
 return;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: c int

variable_types:
ptr
char *

variable_types: struct option { char *name; int has_arg; int *flag; int val; } []


decompiled_code:
int print_search()
{
const char *v0; // rdx
const char *v1; // rcx
const char *v2; // rdx
int result; // eax
const char *v4; // rcx
const char *v5; // rdx

v0 = "all";
if ( !find_all )
v0 = "a single";
fprintf(stderr, "Searching for %s ", v0);
if ( min_weight )
{
if ( min_weight > 0 && maximal )
fwrite("maximal ", 1uLL, 8uLL, stderr);
v1 = "size";
if ( !unweighted )
v1 = "weight";
v2 = "s";
if ( !find_all )
v2 = (const char *)&unk_129B;
fprintf(stderr, "clique%s with %s ", v2, v1);
if ( max_weight )
{
if ( max_weight == min_weight )
fprintf(stderr, "exactly %d...", (unsigned int)min_weight);
else
fprintf(stderr, "within range %d-%d...", (unsigned int)min_weight, (unsigned int)max_weight);
}
else
{
fprintf(stderr, "at least %d...", (unsigned int)min_weight);
}
result = fputc(10, stderr);
}
else
{
v4 = "s";
if ( !find_all )
v4 = (const char *)&unk_129B;
v5 = "size";
if ( !unweighted )
v5 = "weight";
result = fprintf(stderr, "maximum %s clique%s...\n", v5, v4);
}
return result;
}

canonical_decompiled_code:
int func6()
{
const char *v0; // rdx
const char *v1; // rcx
const char *v2; // rdx
int result; // eax
const char *v4; // rcx
const char *v5; // rdx

v0 = "all";
if ( !find_all )
v0 = "a single";
fprintf(stderr, "Searching for %s ", v0);
if ( min_weight )
{
if ( min_weight > 0 && maximal )
fwrite("maximal ", 1uLL, 8uLL, stderr);
v1 = "size";
if ( !unweighted )
v1 = "weight";
v2 = "s";
if ( !find_all )
v2 = (const char *)&unk_129B;
fprintf(stderr, "clique%s with %s ", v2, v1);
if ( max_weight )
{
if ( max_weight == min_weight )
fprintf(stderr, "exactly %d...", (unsigned int)min_weight);
else
fprintf(stderr, "within range %d-%d...", (unsigned int)min_weight, (unsigned int)max_weight);
}
else
{
fprintf(stderr, "at least %d...", (unsigned int)min_weight);
}
result = fputc(10, stderr);
}
else
{
v4 = "s";
if ( !find_all )
v4 = (const char *)&unk_129B;
v5 = "size";
if ( !unweighted )
v5 = "weight";
result = fprintf(stderr, "maximum %s clique%s...\n", v5, v4);
}
return result;
}

original_code:
void print_search(graph_t *g) {
 fprintf(stderr,"Searching for %s ",find_all?"all":"a single");
 if (min_weight==0) {
  fprintf(stderr,"maximum %s clique%s...\n",
   unweighted?"size":"weight",find_all?"s":"");
  return;
 }
 if (min_weight>0 && maximal)
  fprintf(stderr,"maximal ");
 fprintf(stderr,"clique%s with %s ",find_all?"s":"",
  unweighted?"size":"weight");
 if (max_weight==0) {
  fprintf(stderr,"at least %d...",min_weight);
 } else if (min_weight==max_weight) {
  fprintf(stderr,"exactly %d...",min_weight);
 } else {
  fprintf(stderr,"within range %d-%d...",min_weight,max_weight);
 }
 fprintf(stderr,"\n");
 return;
}

canonical_original_code:
void print_search(struct _graph_t *g) {
 fprintf(stderr,"Searching for %s ",find_all?"all":"a single");
 if (min_weight==0) {
  fprintf(stderr,"maximum %s clique%s...\n",
   unweighted?"size":"weight",find_all?"s":"");
  return;
 }
 if (min_weight>0 && maximal)
  fprintf(stderr,"maximal ");
 fprintf(stderr,"clique%s with %s ",find_all?"s":"",
  unweighted?"size":"weight");
 if (max_weight==0) {
  fprintf(stderr,"at least %d...",min_weight);
 } else if (min_weight==max_weight) {
  fprintf(stderr,"exactly %d...",min_weight);
 } else {
  fprintf(stderr,"within range %d-%d...",min_weight,max_weight);
 }
 fprintf(stderr,"\n");
 return;
}

user_defined_types: struct _graph_t { int n; unsigned long **edges; int *weights; }


decompiled_code:
int __fastcall print_clique(unsigned __int64 a1, __int64 a2)
{
unsigned int v2; // ebx
unsigned int v3; // eax
unsigned __int64 v4; // rbx
__int64 v5; // r8

v2 = graph_subgraph_weight(a2, a1);
v3 = set_size(a1);
printf("size=%d, weight=%d: ", v3, v2);
if ( *(_QWORD *)(a1 - 8) )
{
v4 = 0LL;
do
{
v5 = *(_QWORD *)(a1 + 8LL * ((int)v4 / 64));
if ( _bittest64(&v5, (unsigned int)((int)v4 % 64)) )
{
if ( number1 )
printf(" %d", (unsigned int)(v4 + 1));
else
printf(" %d", (unsigned int)v4);
}
++v4;
}
while ( *(_QWORD *)(a1 - 8) > v4 );
}
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func7(unsigned __int64 a1, __int64 a2)
{
unsigned int v2; // ebx
unsigned int v3; // eax
unsigned __int64 v4; // rbx
__int64 v5; // r8

v2 = func1(a2, a1);
v3 = func0(a1);
printf("size=%d, weight=%d: ", v3, v2);
if ( *(_QWORD *)(a1 - 8) )
{
v4 = 0LL;
do
{
v5 = *(_QWORD *)(a1 + 8LL * ((int)v4 / 64));
if ( _bittest64(&v5, (unsigned int)((int)v4 % 64)) )
{
if ( number1 )
printf(" %d", (unsigned int)(v4 + 1));
else
printf(" %d", (unsigned int)v4);
}
++v4;
}
while ( *(_QWORD *)(a1 - 8) > v4 );
}
return putchar(10);
}

original_code:
void print_clique(set_t s,graph_t *g) {
 int i;
 printf("size=%d, weight=%d:  ",set_size(s),graph_subgraph_weight(g,s));
 for (i=0; i<((s)[-1]); i++) {
  if ((((i)<((s)[-1]))?((((s)[(i)/64])&((setelement)1<<((i)%64)))):(0))) {
   if (number1)
    printf(" %d",i+1);
   else
    printf(" %d",i);
  }
 }
 printf("\n");
 return;
}

canonical_original_code:
void print_clique(unsigned long *s, struct _graph_t *g) {
 int i;
 printf("size=%d, weight=%d:  ",set_size(s),graph_subgraph_weight(g,s));
 for (i=0; i<((s)[-1]); i++) {
  if ((((i)<((s)[-1]))?((((s)[(i)/64])&((unsigned long)1<<((i)%64)))):(0))) {
   if (number1)
    printf(" %d",i+1);
   else
    printf(" %d",i);
  }
 }
 printf("\n");
 return;
}


decompiled_code:
_BOOL8 __fastcall edge_has_node(__int64 a1, _QWORD *a2)
{
return *a2 == a1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(__int64 a1, _QWORD *a2)
{
return *a2 == a1;
}

original_code:
int edge_has_node(struct Node *aNode, struct Edge* anEdge)
{
 return aNode == anEdge->aNode;
}

canonical_original_code:
int edge_has_node(struct Node *aNode, struct Edge *anEdge)
{
 return aNode == anEdge->aNode;
}

variable_types: struct Node { char name[64]; int id; int nParts; int visited; struct Duallist { struct Item { void *datap; struct Item *prev; struct Item *next; } *head; unsigned long nItems; } edges; } *

variable_types: struct Edge { struct Node *aNode; double similarity; } *

user_defined_types: struct Node { char name[64]; int id; int nParts; int visited; struct Duallist edges; }


decompiled_code:
_BOOL8 __fastcall node_has_name(const char *a1, const char *a2)
{
return strcmp(a1, a2) == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(const char *a1, const char *a2)
{
return strcmp(a1, a2) == 0;
}

original_code:
int node_has_name(char *name, struct Node* aNode)
{
 return !strcmp(name, aNode->name);
}

canonical_original_code:
int node_has_name(char *name, struct Node *aNode)
{
 return !strcmp(name, aNode->name);
}


decompiled_code:
void __fastcall node_free_func(void *ptr)
{
__int64 **i; // rbp
__int64 v2; // rbx
void *v3; // rax
void *v4; // rax

if ( ptr )
{
for ( i = (__int64 **)*((_QWORD *)ptr + 10); i; i = (__int64 **)i[2] )
{
v2 = **i;
v3 = (void *)duallist_pick((char *)ptr + 80, v2, edge_has_node);
free(v3);
v4 = (void *)duallist_pick(v2 + 80, ptr, edge_has_node);
free(v4);
}
duallist_destroy((char *)ptr + 80, &free);
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func2(void *ptr)
{
__int64 **i; // rbp
__int64 v2; // rbx
void *v3; // rax
void *v4; // rax

if ( ptr )
{
for ( i = (__int64 **)*((_QWORD *)ptr + 10); i; i = (__int64 **)i[2] )
{
v2 = **i;
v3 = (void *)duallist_pick((char *)ptr + 80, v2, edge_has_node);
free(v3);
v4 = (void *)duallist_pick(v2 + 80, ptr, edge_has_node);
free(v4);
}
duallist_destroy((char *)ptr + 80, &free);
free(ptr);
}
}

original_code:
void node_free_func(struct Node* aNode)
{
 struct Item *anEdgeItem;
 struct Edge *anEdge;
 struct Node *bNode;
 if(aNode) {
  anEdgeItem = aNode->edges.head;
  while(anEdgeItem) {
   anEdge = (struct Edge*)anEdgeItem->datap;
   bNode = anEdge->aNode;
   free(duallist_pick(&aNode->edges, bNode, (int(*)(void*,void*))edge_has_node));
   free(duallist_pick(&bNode->edges, aNode, (int(*)(void*,void*))edge_has_node));
   anEdgeItem = anEdgeItem->next;
  }
  duallist_destroy(&aNode->edges, free);
  free(aNode);
 }
}

canonical_original_code:
void node_free_func(struct Node *aNode)
{
 struct Item *anEdgeItem;
 struct Edge *anEdge;
 struct Node *bNode;
 if(aNode) {
  anEdgeItem = aNode->edges.head;
  while(anEdgeItem) {
   anEdge = (struct Edge *)anEdgeItem->datap;
   bNode = anEdge->aNode;
   free(duallist_pick(&aNode->edges, bNode, (int (*)(void *, void *))edge_has_node));
   free(duallist_pick(&bNode->edges, aNode, (int (*)(void *, void *))edge_has_node));
   anEdgeItem = anEdgeItem->next;
  }
  duallist_destroy(&aNode->edges, free);
  free(aNode);
 }
}

variable_types: struct Edge { struct Node { char name[64]; int id; int nParts; int visited; struct Duallist { struct Item { void *datap; struct Item *prev; struct Item *next; } *head; unsigned long nItems; } edges; } *aNode; double similarity; } *

user_defined_types: struct Edge { struct Node *aNode; double similarity; }