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

if ( a1 && a4 )
{
switch ( a5 )
{
case 1:
arg = a1;
v15 = a3;
v14 = a2;
v16 = a4;
pthread_create(&newthread, 0LL, (void *(*)(void *))merge_th, &arg);
pthread_join(newthread, 0LL);
break;
case 2:
arg = a1;
v15 = a3;
v16 = a4;
v19 = a3;
v20 = a4;
v14 = a2 >> 1;
v17 = &a1[(a2 >> 1) * a3];
v18 = a2 - (a2 >> 1);
pthread_create(&newthread, 0LL, (void *(*)(void *))merge_th, &arg);
pthread_create(&th, 0LL, (void *(*)(void *))merge_th, &v17);
pthread_join(newthread, 0LL);
pthread_join(th, 0LL);
merge(a1, a2 >> 1, a2 - (a2 >> 1), a3, a4);
break;
case 4:
arg = a1;
v15 = a3;
v16 = a4;
v19 = a3;
v20 = a4;
v18 = (a2 >> 1) - (a2 >> 2);
v14 = a2 >> 2;
v17 = &a1[a3 * (a2 >> 2)];
pthread_create(&newthread, 0LL, (void *(*)(void *))merge_th, &arg);
pthread_create(&th, 0LL, (void *(*)(void *))merge_th, &v17);
pthread_join(newthread, 0LL);
pthread_join(th, 0LL);
merge(a1, a2 >> 2, (a2 >> 1) - (a2 >> 2), a3, a4);
v21[2] = a3;
v7 = (a2 - (a2 >> 1)) >> 1;
v21[0] = (__int64)&a1[a3 * (a2 >> 1)];
v21[1] = v7;
v8 = a2 - ((a2 >> 1) + v7);
v21[3] = (__int64)a4;
v22[2] = a3;
v22[1] = v8;
v22[0] = (__int64)&a1[a3 * ((a2 >> 1) + v7)];
v22[3] = (__int64)a4;
pthread_create(&v11, 0LL, (void *(*)(void *))merge_th, v21);
pthread_create(&v12, 0LL, (void *(*)(void *))merge_th, v22);
pthread_join(v11, 0LL);
pthread_join(v12, 0LL);
merge(&a1[a3 * (a2 >> 1)], (a2 - (a2 >> 1)) >> 1, v8, 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; // r9
__int64 v8; // r13
pthread_t newthread; // [rsp+10h] [rbp-D8h] BYREF
pthread_t th; // [rsp+18h] [rbp-D0h] BYREF
pthread_t v11; // [rsp+20h] [rbp-C8h] BYREF
pthread_t v12; // [rsp+28h] [rbp-C0h] BYREF
char *arg; // [rsp+30h] [rbp-B8h] BYREF
unsigned __int64 v14; // [rsp+38h] [rbp-B0h]
size_t v15; // [rsp+40h] [rbp-A8h]
int (__fastcall *v16)(char *, char *); // [rsp+48h] [rbp-A0h]
char *v17; // [rsp+50h] [rbp-98h] BYREF
unsigned __int64 v18; // [rsp+58h] [rbp-90h]
size_t v19; // [rsp+60h] [rbp-88h]
int (__fastcall *v20)(char *, char *); // [rsp+68h] [rbp-80h]
__int64 v21[4]; // [rsp+70h] [rbp-78h] BYREF
__int64 v22[11]; // [rsp+90h] [rbp-58h] BYREF

if ( a1 && a4 )
{
switch ( a5 )
{
case 1:
arg = a1;
v15 = a3;
v14 = a2;
v16 = a4;
pthread_create(&newthread, 0LL, (void *(*)(void *))merge_th, &arg);
pthread_join(newthread, 0LL);
break;
case 2:
arg = a1;
v15 = a3;
v16 = a4;
v19 = a3;
v20 = a4;
v14 = a2 >> 1;
v17 = &a1[(a2 >> 1) * a3];
v18 = a2 - (a2 >> 1);
pthread_create(&newthread, 0LL, (void *(*)(void *))merge_th, &arg);
pthread_create(&th, 0LL, (void *(*)(void *))merge_th, &v17);
pthread_join(newthread, 0LL);
pthread_join(th, 0LL);
func0(a1, a2 >> 1, a2 - (a2 >> 1), a3, a4);
break;
case 4:
arg = a1;
v15 = a3;
v16 = a4;
v19 = a3;
v20 = a4;
v18 = (a2 >> 1) - (a2 >> 2);
v14 = a2 >> 2;
v17 = &a1[a3 * (a2 >> 2)];
pthread_create(&newthread, 0LL, (void *(*)(void *))merge_th, &arg);
pthread_create(&th, 0LL, (void *(*)(void *))merge_th, &v17);
pthread_join(newthread, 0LL);
pthread_join(th, 0LL);
func0(a1, a2 >> 2, (a2 >> 1) - (a2 >> 2), a3, a4);
v21[2] = a3;
v7 = (a2 - (a2 >> 1)) >> 1;
v21[0] = (__int64)&a1[a3 * (a2 >> 1)];
v21[1] = v7;
v8 = a2 - ((a2 >> 1) + v7);
v21[3] = (__int64)a4;
v22[2] = a3;
v22[1] = v8;
v22[0] = (__int64)&a1[a3 * ((a2 >> 1) + v7)];
v22[3] = (__int64)a4;
pthread_create(&v11, 0LL, (void *(*)(void *))merge_th, v21);
pthread_create(&v12, 0LL, (void *(*)(void *))merge_th, v22);
pthread_join(v11, 0LL);
pthread_join(v12, 0LL);
func0(&a1[a3 * (a2 >> 1)], (a2 - (a2 >> 1)) >> 1, v8, 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)
{
int v1; // eax
__int64 v2; // rdx
unsigned int v3; // edi
__int64 result; // rax
__int64 v5; // rdx

v1 = _bswap_32(*(_DWORD *)(a1 + 2));
v3 = *(_DWORD *)(v2 + 6);
*(_DWORD *)(v2 + 2) = v1;
result = _bswap_32(v3);
*(_DWORD *)(v5 + 6) = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
int v1; // eax
__int64 v2; // rdx
unsigned int v3; // edi
__int64 result; // rax
__int64 v5; // rdx

v1 = func0(*(_DWORD *)(a1 + 2));
v3 = *(_DWORD *)(v2 + 6);
*(_DWORD *)(v2 + 2) = v1;
result = func0(v3);
*(_DWORD *)(v5 + 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; } *

return_type: void


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; // r8
__int64 v2; // rax
unsigned int v3; // er12

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

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

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

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; } *

return_type: int


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)
{
_QWORD *v2; // rax
__int64 result; // rax

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

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

if ( !a1 )
return 0LL;
v2 = createNode(a2);
if ( !v2 )
return 0LL;
if ( *(_QWORD *)a1 )
{
v2[1] = *(_QWORD *)a1;
*(_QWORD *)a1 = v2;
result = 1LL;
++*(_DWORD *)(a1 + 8);
}
else
{
*(_QWORD *)a1 = v2;
result = 1LL;
*(_DWORD *)(a1 + 8) = 1;
}
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

canonical_name: main

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

v3 = 0;
v4 = createStack(argc, argv, envp);
do
{
v5 = v3++;
push(v4, v5);
}
while ( v3 != 10 );
while ( (int)stackSize(v4) > 0 )
{
v6 = pop(v4);
printf("%i\n", v6);
}
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 *[]

variable_types: i int


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_11;
v4 = dlsym(*(void **)a1, "StartMatch");
*(_QWORD *)(a1 + 16) = v4;
if ( !v4 )
goto LABEL_11;
v5 = dlsym(*(void **)a1, "StartGame");
*(_QWORD *)(a1 + 24) = v5;
if ( !v5 )
goto LABEL_11;
v6 = dlsym(*(void **)a1, "EndGame");
*(_QWORD *)(a1 + 32) = v6;
if ( !v6 )
goto LABEL_11;
v7 = dlsym(*(void **)a1, "EndMatch");
*(_QWORD *)(a1 + 40) = v7;
if ( !v7 )
goto LABEL_11;
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_11:
v12 = dlerror();
fprintf(stderr, "Erreur de chargement de la fonction : %s\n", v12);
result = 0xFFFFFFFFLL;
}
}
else
{
v13 = dlerror();
fprintf(stderr, "Erreur de chargement de la lib : %s\n", v13);
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_11;
v4 = dlsym(*(void **)a1, "StartMatch");
*(_QWORD *)(a1 + 16) = v4;
if ( !v4 )
goto LABEL_11;
v5 = dlsym(*(void **)a1, "StartGame");
*(_QWORD *)(a1 + 24) = v5;
if ( !v5 )
goto LABEL_11;
v6 = dlsym(*(void **)a1, "EndGame");
*(_QWORD *)(a1 + 32) = v6;
if ( !v6 )
goto LABEL_11;
v7 = dlsym(*(void **)a1, "EndMatch");
*(_QWORD *)(a1 + 40) = v7;
if ( !v7 )
goto LABEL_11;
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_11:
v12 = dlerror();
fprintf(stderr, "Erreur de chargement de la fonction : %s\n", v12);
result = 0xFFFFFFFFLL;
}
}
else
{
v13 = dlerror();
fprintf(stderr, "Erreur de chargement de la lib : %s\n", v13);
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; // rax

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

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

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

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 honest_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 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);
}

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


decompiled_code:
// attributes: thunk
_BOOL8 __fastcall attacker_has_name(const char *a1, const char *a2)
{
return honest_has_name(a1, a2);
}

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

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);
}

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
__int128 v9[5]; // [rsp+0h] [rbp-58h] BYREF

v9[0] = 0LL;
v9[1] = 0LL;
v9[2] = 0LL;
v9[3] = 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
__int128 v9[5]; // [rsp+0h] [rbp-58h] BYREF

v9[0] = 0LL;
v9[1] = 0LL;
v9[2] = 0LL;
v9[3] = 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)
{
unsigned __int64 v1; // rsi
unsigned __int64 *v2; // r10
__int64 result; // rax
unsigned __int64 v4; // rbx
unsigned __int64 v5; // rcx

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

canonical_decompiled_code:
__int64 __fastcall func0(unsigned __int64 a1)
{
unsigned __int64 v1; // rsi
unsigned __int64 *v2; // r10
__int64 result; // rax
unsigned __int64 v4; // rbx
unsigned __int64 v5; // rcx

v1 = a1 + 8 * ((unsigned __int64)(*(_QWORD *)(a1 - 8) + 63LL) >> 6);
if ( a1 >= v1 )
return 0LL;
v2 = (unsigned __int64 *)(a1 + 8);
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)]);
if ( a1 + 8 < v1 )
{
if ( (((v1 + ~a1) >> 3) & 1) == 0
|| (result = (unsigned int)(set_bit_count[(unsigned __int8)*v2]
+ set_bit_count[BYTE1(*v2)]
+ set_bit_count[BYTE2(*v2)]
+ set_bit_count[BYTE3(*v2)]
+ set_bit_count[BYTE4(*v2)]
+ set_bit_count[HIBYTE(WORD2(*v2))]
+ set_bit_count[BYTE6(*v2)]
+ set_bit_count[HIBYTE(*v2)]
+ result),
v2 = (unsigned __int64 *)(a1 + 16),
a1 + 16 < v1) )
{
do
{
v4 = *v2;
v2 += 2;
v5 = *(v2 - 1);
result = (unsigned int)(result
+ set_bit_count[(unsigned __int8)v4]
+ set_bit_count[BYTE1(v4)]
+ set_bit_count[BYTE2(v4)]
+ set_bit_count[BYTE3(v4)]
+ set_bit_count[BYTE4(v4)]
+ set_bit_count[BYTE5(v4)]
+ set_bit_count[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)]);
}
while ( (unsigned __int64)v2 < 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:
int __fastcall read_options(int argc, char **argv)
{
int result; // eax
char *v3; // r12
int v4; // eax
char *v5; // rdx
int v6; // eax
size_t v7; // rdx
const char *v8; // rdi
FILE *v9; // rcx
int longind; // [rsp+4h] [rbp-24h] BYREF
char *endptr[4]; // [rsp+8h] [rbp-20h] BYREF

while ( 1 )
{
longind = 0;
result = getopt_long(argc, argv, "aswm:M:xur:1qh", &long_options_0, &longind);
if ( result == -1 )
break;
if ( result )
{
switch ( result )
{
case '0':
number1 = 0;
continue;
case '?':
goto LABEL_46;
case 'M':
v6 = strtol(optarg, endptr, 10);
v5 = optarg;
max_weight = v6;
if ( !*optarg || *endptr[0] || v6 < 0 )
goto LABEL_45;
if ( !v6 || min_weight )
goto LABEL_27;
if ( min_weight_set )
goto LABEL_52;
min_weight = 1;
LABEL_27:
max_weight_set = 1;
continue;
case 'a':
find_all = 1;
continue;
case 'h':
printhelp(*argv);
case 'm':
v4 = strtol(optarg, endptr, 10);
v5 = optarg;
min_weight = v4;
if ( !*optarg || *endptr[0] || v4 < 0 )
{
LABEL_45:
fprintf(stderr, "Bad argument: %s\n", v5);
goto LABEL_46;
}
if ( v4 || max_weight <= 0 )
goto LABEL_18;
if ( max_weight_set )
{
LABEL_52:
v7 = 45LL;
v8 = "Error: --max >0 is incompatible with --min 0\n";
v9 = stderr;
LABEL_51:
fwrite(v8, 1uLL, v7, v9);
LABEL_46:
fprintf(stderr, "Try `%s -h' for more information.\n", *argv);
exit(1);
}
max_weight = 0;
LABEL_18:
min_weight_set = 1;
break;
case 'q':
++quiet;
continue;
case 'r':
v3 = optarg;
if ( !strcasecmp(optarg, "none") )
{
reorder = 0LL;
}
else if ( !strcasecmp(v3, "reverse") )
{
reorder = &reorder_by_reverse;
}
else if ( !strcasecmp(v3, "default") )
{
reorder = &reorder_by_greedy_coloring;
}
else if ( !strcasecmp(v3, "unweighted-coloring") )
{
reorder = &reorder_by_unweighted_greedy_coloring;
}
else if ( !strcasecmp(v3, "weighted-coloring") )
{
reorder = &reorder_by_weighted_greedy_coloring;
}
else if ( !strcasecmp(v3, "degree") )
{
reorder = &reorder_by_degree;
}
else
{
if ( strcasecmp(v3, "random") )
{
fprintf(stderr, "Bad reordering type: %s\n", v3);
goto LABEL_46;
}
reorder = &reorder_by_random;
}
break;
case 's':
find_all = 0;
continue;
case 'u':
unweighted = 1;
continue;
case 'w':
only_weight = 1;
continue;
case 'x':
maximal = 1;
continue;
default:
fprintf(stderr, "Internal bug: line %d should never be reached!", 316LL);
exit(-1);
}
}
}
if ( optind >= argc )
{
v7 = 18LL;
v8 = "Missing filename.\n";
v9 = stderr;
goto LABEL_51;
}
if ( optind < argc - 1 )
{
fprintf(stderr, "Bad command line option: %s\n", argv[optind + 1]);
goto LABEL_46;
}
file = argv[optind];
return result;
}

canonical_decompiled_code:
int __fastcall func5(int argc, char **argv)
{
int result; // eax
char *v3; // r12
int v4; // eax
char *v5; // rdx
int v6; // eax
size_t v7; // rdx
const char *v8; // rdi
FILE *v9; // rcx
int longind; // [rsp+4h] [rbp-24h] BYREF
char *endptr[4]; // [rsp+8h] [rbp-20h] BYREF

while ( 1 )
{
longind = 0;
result = getopt_long(argc, argv, "aswm:M:xur:1qh", &long_options_0, &longind);
if ( result == -1 )
break;
if ( result )
{
switch ( result )
{
case '0':
number1 = 0;
continue;
case '?':
goto LABEL_46;
case 'M':
v6 = strtol(optarg, endptr, 10);
v5 = optarg;
max_weight = v6;
if ( !*optarg || *endptr[0] || v6 < 0 )
goto LABEL_45;
if ( !v6 || min_weight )
goto LABEL_27;
if ( min_weight_set )
goto LABEL_52;
min_weight = 1;
LABEL_27:
max_weight_set = 1;
continue;
case 'a':
find_all = 1;
continue;
case 'h':
func4(*argv);
case 'm':
v4 = strtol(optarg, endptr, 10);
v5 = optarg;
min_weight = v4;
if ( !*optarg || *endptr[0] || v4 < 0 )
{
LABEL_45:
fprintf(stderr, "Bad argument: %s\n", v5);
goto LABEL_46;
}
if ( v4 || max_weight <= 0 )
goto LABEL_18;
if ( max_weight_set )
{
LABEL_52:
v7 = 45LL;
v8 = "Error: --max >0 is incompatible with --min 0\n";
v9 = stderr;
LABEL_51:
fwrite(v8, 1uLL, v7, v9);
LABEL_46:
fprintf(stderr, "Try `%s -h' for more information.\n", *argv);
exit(1);
}
max_weight = 0;
LABEL_18:
min_weight_set = 1;
break;
case 'q':
++quiet;
continue;
case 'r':
v3 = optarg;
if ( !strcasecmp(optarg, "none") )
{
reorder = 0LL;
}
else if ( !strcasecmp(v3, "reverse") )
{
reorder = &reorder_by_reverse;
}
else if ( !strcasecmp(v3, "default") )
{
reorder = &reorder_by_greedy_coloring;
}
else if ( !strcasecmp(v3, "unweighted-coloring") )
{
reorder = &reorder_by_unweighted_greedy_coloring;
}
else if ( !strcasecmp(v3, "weighted-coloring") )
{
reorder = &reorder_by_weighted_greedy_coloring;
}
else if ( !strcasecmp(v3, "degree") )
{
reorder = &reorder_by_degree;
}
else
{
if ( strcasecmp(v3, "random") )
{
fprintf(stderr, "Bad reordering type: %s\n", v3);
goto LABEL_46;
}
reorder = &reorder_by_random;
}
break;
case 's':
find_all = 0;
continue;
case 'u':
unweighted = 1;
continue;
case 'w':
only_weight = 1;
continue;
case 'x':
maximal = 1;
continue;
default:
fprintf(stderr, "Internal bug: line %d should never be reached!", 316LL);
exit(-1);
}
}
}
if ( optind >= argc )
{
v7 = 18LL;
v8 = "Missing filename.\n";
v9 = stderr;
goto LABEL_51;
}
if ( optind < argc - 1 )
{
fprintf(stderr, "Bad command line option: %s\n", argv[optind + 1]);
goto LABEL_46;
}
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";
v2 = "s";
if ( !unweighted )
v1 = "weight";
if ( !find_all )
v2 = (const char *)&unk_D7B;
fprintf(stderr, "clique%s with %s ", v2, v1);
if ( max_weight )
{
if ( max_weight == min_weight )
fprintf(stderr, "exactly %d...", (unsigned int)max_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";
v5 = "size";
if ( !find_all )
v4 = (const char *)&unk_D7B;
if ( !unweighted )
v5 = "weight";
result = fprintf(stderr, "maximum %s clique%s...\n", v5, v4, &unk_D7B, "weight");
}
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";
v2 = "s";
if ( !unweighted )
v1 = "weight";
if ( !find_all )
v2 = (const char *)&unk_D7B;
fprintf(stderr, "clique%s with %s ", v2, v1);
if ( max_weight )
{
if ( max_weight == min_weight )
fprintf(stderr, "exactly %d...", (unsigned int)max_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";
v5 = "size";
if ( !find_all )
v4 = (const char *)&unk_D7B;
if ( !unweighted )
v5 = "weight";
result = fprintf(stderr, "maximum %s clique%s...\n", v5, v4, &unk_D7B, "weight");
}
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 __int64 v2; // rbx
unsigned int v3; // er12
unsigned int v4; // eax
__int64 v5; // rsi
unsigned __int64 v6; // rdx

v2 = 0LL;
v3 = graph_subgraph_weight(a2, a1);
v4 = set_size((unsigned __int64)a1);
printf("size=%d, weight=%d: ", v4, v3);
if ( *(a1 - 1) )
{
do
{
v5 = (unsigned int)(v2 + 1);
v6 = a1[(int)v2 >> 6];
if ( _bittest64((const __int64 *)&v6, v2) )
{
if ( !number1 )
v5 = (unsigned int)v2;
printf(" %d", v5);
}
++v2;
}
while ( *(a1 - 1) > v2 );
}
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func7(unsigned __int64 *a1, __int64 a2)
{
unsigned __int64 v2; // rbx
unsigned int v3; // er12
unsigned int v4; // eax
__int64 v5; // rsi
unsigned __int64 v6; // rdx

v2 = 0LL;
v3 = func1(a2, a1);
v4 = func0((unsigned __int64)a1);
printf("size=%d, weight=%d: ", v4, v3);
if ( *(a1 - 1) )
{
do
{
v5 = (unsigned int)(v2 + 1);
v6 = a1[(int)v2 >> 6];
if ( _bittest64((const __int64 *)&v6, v2) )
{
if ( !number1 )
v5 = (unsigned int)v2;
printf(" %d", v5);
}
++v2;
}
while ( *(a1 - 1) > v2 );
}
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)
{
char *v1; // r13
__int64 **i; // rbp
__int64 v3; // rbx
void *v4; // rax
void *v5; // rax

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

canonical_decompiled_code:
void __fastcall func2(void *ptr)
{
char *v1; // r13
__int64 **i; // rbp
__int64 v3; // rbx
void *v4; // rax
void *v5; // rax

if ( ptr )
{
v1 = (char *)ptr + 80;
for ( i = (__int64 **)*((_QWORD *)ptr + 10); i; i = (__int64 **)i[2] )
{
v3 = **i;
v4 = (void *)duallist_pick(v1, v3, edge_has_node);
free(v4);
v5 = (void *)duallist_pick(v3 + 80, ptr, edge_has_node);
free(v5);
}
duallist_destroy(v1, &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; }


decompiled_code:
__int64 __fastcall read_a_record(char *s, int a2, __int64 a3, __int64 a4)
{
unsigned int v6; // er12
const char *v7; // r13
char *v8; // rax
char *v9; // r14
const char *v10; // r14
char *v11; // rax
char *v12; // r13
const char *v13; // r13
char *v14; // rax
char *v15; // r14
char *v16; // rax
const char *v17; // r13
char *v18; // rax
char *v19; // r14
const char *v20; // r14
char *v21; // rax
char *v22; // r13
const char *v23; // r13
char *v24; // rax
char *v25; // r14
char *v26; // rax
const char *v27; // r13
char *v28; // rax
char *v29; // r14
const char *v30; // r14
char *v31; // rax
char *v32; // r13
const char *v33; // r13
char *v34; // rax
char *v35; // r14
const char *v36; // r14
char *v37; // rax
char *v38; // r13
const char *v39; // r13
char *v40; // rax
char *v41; // r14
const char *v42; // r14
char *v43; // rax
char *v44; // r13
const char *v45; // r13
char *v46; // rax
char *v47; // r14
const char *v48; // r14
char *v49; // rax
char *v50; // r13
const char *v51; // r13
char *v52; // rax
char *v53; // r14
char *v54; // rax
const char *v55; // r14
char *v56; // rax
char *v57; // r13
char *v58; // rax
char *v59; // rax
char *v60; // rax
char *v61; // rax
char *v62; // rax
__int64 i; // rax
const char *v65; // r13
char *v66; // rax
char *v67; // r14
const char *v68; // r14
char *v69; // rax
char *v70; // r13
const char *v71; // r13
char *v72; // rax
char *v73; // r14
const char *v74; // r14
char *v75; // rax
char *v76; // r13
const char *v77; // r13
char *v78; // rax
char *v79; // r14
const char *v80; // r14
char *v81; // r13
char *v82; // rdi
const char *v83; // r13
char *v84; // r14
char *v85; // rdi
const char *v86; // r13
char *v87; // rax

*(_QWORD *)a4 = 0LL;
*(_QWORD *)(a4 + 536) = 0LL;
memset(
(void *)((a4 + 8) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)a4 - (((_DWORD)a4 + 8) & 0xFFFFFFF8) + 544) >> 3));
if ( a2 == 1 )
{
v6 = 1;
v65 = strchr(s, 44) + 1;
v66 = strchr(v65, 44);
v67 = v66;
if ( v65 != v66 )
{
v6 = 0;
strncpy((char *)a4, v65, v66 - v65);
}
v68 = v67 + 1;
v69 = strchr(v68, 44);
v70 = v69;
if ( v68 == v69 )
{
*(_BYTE *)(a4 + 96) = 0;
v6 = 1;
}
else
{
strncpy((char *)(a4 + 96), v68, v69 - v68);
}
v71 = v70 + 1;
v72 = strchr(v71, 44);
v73 = v72;
if ( v71 == v72 )
{
*(_BYTE *)(a4 + 128) = 0;
v6 = 1;
}
else
{
strncpy((char *)(a4 + 128), v71, v72 - v71);
}
v74 = v73 + 1;
v75 = strchr(v74, 44);
v76 = v75;
if ( v74 == v75 )
{
*(_BYTE *)(a4 + 160) = 0;
v6 = 1;
}
else
{
strncpy((char *)(a4 + 160), v74, v75 - v74);
}
v77 = v76 + 1;
v78 = strchr(v77, 44);
v79 = v78;
if ( v77 == v78 )
{
*(_BYTE *)(a4 + 192) = 0;
v6 = 1;
}
else
{
strncpy((char *)(a4 + 192), v77, v78 - v77);
}
v80 = v79 + 1;
v81 = strchr(v80, 44);
v82 = strncpy((char *)(a4 + 256), v80, v81 - v80);
if ( v80 == v81 )
{
*(_BYTE *)(a4 + 256) = 0;
v6 = 1;
}
else
{
strncpy(v82, v80, v81 - v80);
}
v83 = v81 + 1;
v84 = strchr(v83, 44);
v85 = strncpy((char *)(a4 + 320), v83, v84 - v83);
if ( v83 == v84 )
{
*(_BYTE *)(a4 + 320) = 0;
v6 = 1;
}
else
{
strncpy(v85, v83, v84 - v83);
}
}
else
{
v6 = 1;
v7 = strchr(s, 44) + 1;
v8 = strchr(v7, 44);
v9 = v8;
if ( v7 != v8 )
{
v6 = 0;
strncpy((char *)(a4 + 32), v7, v8 - v7);
}
v10 = v9 + 1;
v11 = strchr(v10, 44);
v12 = v11;
if ( v10 == v11 )
v6 = 1;
else
strncpy((char *)a4, v10, v11 - v10);
v13 = v12 + 1;
v14 = strchr(v13, 44);
v15 = v14;
if ( v13 == v14 )
{
*(_BYTE *)(a4 + 64) = 0;
v6 = 1;
}
else
{
strncpy((char *)(a4 + 64), v13, v14 - v13);
}
v16 = strchr(v15 + 1, 44);
v17 = strchr(v16 + 1, 44) + 1;
v18 = strchr(v17, 44);
v19 = v18;
if ( v17 == v18 )
{
*(_BYTE *)(a4 + 96) = 0;
v6 = 1;
}
else
{
strncpy((char *)(a4 + 96), v17, v18 - v17);
}
v20 = v19 + 1;
v21 = strchr(v20, 44);
v22 = v21;
if ( v20 == v21 )
{
*(_BYTE *)(a4 + 128) = 0;
v6 = 1;
}
else
{
strncpy((char *)(a4 + 128), v20, v21 - v20);
}
v23 = v22 + 1;
v24 = strchr(v23, 44);
v25 = v24;
if ( v23 == v24 )
{
*(_BYTE *)(a4 + 160) = 0;
v6 = 1;
}
else
{
strncpy((char *)(a4 + 160), v23, v24 - v23);
}
v26 = strchr(v25 + 1, 44);
v27 = strchr(v26 + 1, 44) + 1;
v28 = strchr(v27, 44);
v29 = v28;
if ( v27 == v28 )
{
*(_BYTE *)(a4 + 224) = 0;
v6 = 1;
}
else
{
strncpy((char *)(a4 + 224), v27, v28 - v27);
}
v30 = v29 + 1;
v31 = strchr(v30, 44);
v32 = v31;
if ( v30 == v31 )
{
*(_BYTE *)(a4 + 256) = 0;
v6 = 1;
}
else
{
strncpy((char *)(a4 + 256), v30, v31 - v30);
}
v33 = v32 + 1;
v34 = strchr(v33, 44);
v35 = v34;
if ( v33 == v34 )
*(_BYTE *)(a4 + 288) = 0;
else
strncpy((char *)(a4 + 288), v33, v34 - v33);
v36 = v35 + 1;
v37 = strchr(v36, 44);
v38 = v37;
if ( v36 == v37 )
{
*(_BYTE *)(a4 + 320) = 0;
v6 = 1;
}
else
{
strncpy((char *)(a4 + 320), v36, v37 - v36);
}
v39 = v38 + 1;
v40 = strchr(v39, 44);
v41 = v40;
if ( v39 == v40 )
{
*(_BYTE *)(a4 + 352) = 0;
v6 = 1;
}
else
{
strncpy((char *)(a4 + 352), v39, v40 - v39);
}
v42 = v41 + 1;
v43 = strchr(v42, 44);
v44 = v43;
if ( v42 == v43 )
{
*(_BYTE *)(a4 + 384) = 0;
v6 = 1;
}
else
{
strncpy((char *)(a4 + 384), v42, v43 - v42);
}
v45 = v44 + 1;
v46 = strchr(v45, 44);
v47 = v46;
if ( v45 == v46 )
{
*(_BYTE *)(a4 + 416) = 0;
v6 = 1;
}
else
{
strncpy((char *)(a4 + 416), v45, v46 - v45);
}
v48 = v47 + 1;
v49 = strchr(v48, 44);
v50 = v49;
if ( v48 == v49 )
{
*(_BYTE *)(a4 + 448) = 0;
v6 = 1;
}
else
{
strncpy((char *)(a4 + 448), v48, v49 - v48);
}
v51 = v50 + 1;
v52 = strchr(v51, 44);
v53 = v52;
if ( v51 == v52 )
{
*(_BYTE *)(a4 + 480) = 0;
v6 = 1;
}
else
{
strncpy((char *)(a4 + 480), v51, v52 - v51);
}
v54 = strchr(v53 + 1, 44);
v55 = strchr(v54 + 1, 44) + 1;
v56 = strchr(v55, 44);
v57 = v56;
if ( v55 == v56 )
*(_BYTE *)(a4 + 512) = 0;
else
strncpy((char *)(a4 + 512), v55, v56 - v55);
v58 = strchr(v57 + 1, 44);
v59 = strchr(v58 + 1, 44);
v60 = strchr(v59 + 1, 44);
v61 = strchr(v60 + 1, 44);
v62 = strchr(v61 + 1, 44);
if ( v62[1] )
{
v86 = v62 + 1;
v87 = strchr(v62 + 1, 13);
strncpy((char *)(a4 + 192), v86, v87 - v86);
}
else
{
*(_BYTE *)(a4 + 192) = 0;
v6 = 1;
}
}
if ( a3 )
{
for ( i = 0LL; i != 10; ++i )
*(_BYTE *)(a4 + i + 256) = *(_BYTE *)(a3 + i);
}
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *s, int a2, __int64 a3, __int64 a4)
{
unsigned int v6; // er12
const char *v7; // r13
char *v8; // rax
char *v9; // r14
const char *v10; // r14
char *v11; // rax
char *v12; // r13
const char *v13; // r13
char *v14; // rax
char *v15; // r14
char *v16; // rax
const char *v17; // r13
char *v18; // rax
char *v19; // r14
const char *v20; // r14
char *v21; // rax
char *v22; // r13
const char *v23; // r13
char *v24; // rax
char *v25; // r14
char *v26; // rax
const char *v27; // r13
char *v28; // rax
char *v29; // r14
const char *v30; // r14
char *v31; // rax
char *v32; // r13
const char *v33; // r13
char *v34; // rax
char *v35; // r14
const char *v36; // r14
char *v37; // rax
char *v38; // r13
const char *v39; // r13
char *v40; // rax
char *v41; // r14
const char *v42; // r14
char *v43; // rax
char *v44; // r13
const char *v45; // r13
char *v46; // rax
char *v47; // r14
const char *v48; // r14
char *v49; // rax
char *v50; // r13
const char *v51; // r13
char *v52; // rax
char *v53; // r14
char *v54; // rax
const char *v55; // r14
char *v56; // rax
char *v57; // r13
char *v58; // rax
char *v59; // rax
char *v60; // rax
char *v61; // rax
char *v62; // rax
__int64 i; // rax
const char *v65; // r13
char *v66; // rax
char *v67; // r14
const char *v68; // r14
char *v69; // rax
char *v70; // r13
const char *v71; // r13
char *v72; // rax
char *v73; // r14
const char *v74; // r14
char *v75; // rax
char *v76; // r13
const char *v77; // r13
char *v78; // rax
char *v79; // r14
const char *v80; // r14
char *v81; // r13
char *v82; // rdi
const char *v83; // r13
char *v84; // r14
char *v85; // rdi
const char *v86; // r13
char *v87; // rax

*(_QWORD *)a4 = 0LL;
*(_QWORD *)(a4 + 536) = 0LL;
memset(
(void *)((a4 + 8) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)a4 - (((_DWORD)a4 + 8) & 0xFFFFFFF8) + 544) >> 3));
if ( a2 == 1 )
{
v6 = 1;
v65 = strchr(s, 44) + 1;
v66 = strchr(v65, 44);
v67 = v66;
if ( v65 != v66 )
{
v6 = 0;
strncpy((char *)a4, v65, v66 - v65);
}
v68 = v67 + 1;
v69 = strchr(v68, 44);
v70 = v69;
if ( v68 == v69 )
{
*(_BYTE *)(a4 + 96) = 0;
v6 = 1;
}
else
{
strncpy((char *)(a4 + 96), v68, v69 - v68);
}
v71 = v70 + 1;
v72 = strchr(v71, 44);
v73 = v72;
if ( v71 == v72 )
{
*(_BYTE *)(a4 + 128) = 0;
v6 = 1;
}
else
{
strncpy((char *)(a4 + 128), v71, v72 - v71);
}
v74 = v73 + 1;
v75 = strchr(v74, 44);
v76 = v75;
if ( v74 == v75 )
{
*(_BYTE *)(a4 + 160) = 0;
v6 = 1;
}
else
{
strncpy((char *)(a4 + 160), v74, v75 - v74);
}
v77 = v76 + 1;
v78 = strchr(v77, 44);
v79 = v78;
if ( v77 == v78 )
{
*(_BYTE *)(a4 + 192) = 0;
v6 = 1;
}
else
{
strncpy((char *)(a4 + 192), v77, v78 - v77);
}
v80 = v79 + 1;
v81 = strchr(v80, 44);
v82 = strncpy((char *)(a4 + 256), v80, v81 - v80);
if ( v80 == v81 )
{
*(_BYTE *)(a4 + 256) = 0;
v6 = 1;
}
else
{
strncpy(v82, v80, v81 - v80);
}
v83 = v81 + 1;
v84 = strchr(v83, 44);
v85 = strncpy((char *)(a4 + 320), v83, v84 - v83);
if ( v83 == v84 )
{
*(_BYTE *)(a4 + 320) = 0;
v6 = 1;
}
else
{
strncpy(v85, v83, v84 - v83);
}
}
else
{
v6 = 1;
v7 = strchr(s, 44) + 1;
v8 = strchr(v7, 44);
v9 = v8;
if ( v7 != v8 )
{
v6 = 0;
strncpy((char *)(a4 + 32), v7, v8 - v7);
}
v10 = v9 + 1;
v11 = strchr(v10, 44);
v12 = v11;
if ( v10 == v11 )
v6 = 1;
else
strncpy((char *)a4, v10, v11 - v10);
v13 = v12 + 1;
v14 = strchr(v13, 44);
v15 = v14;
if ( v13 == v14 )
{
*(_BYTE *)(a4 + 64) = 0;
v6 = 1;
}
else
{
strncpy((char *)(a4 + 64), v13, v14 - v13);
}
v16 = strchr(v15 + 1, 44);
v17 = strchr(v16 + 1, 44) + 1;
v18 = strchr(v17, 44);
v19 = v18;
if ( v17 == v18 )
{
*(_BYTE *)(a4 + 96) = 0;
v6 = 1;
}
else
{
strncpy((char *)(a4 + 96), v17, v18 - v17);
}
v20 = v19 + 1;
v21 = strchr(v20, 44);
v22 = v21;
if ( v20 == v21 )
{
*(_BYTE *)(a4 + 128) = 0;
v6 = 1;
}
else
{
strncpy((char *)(a4 + 128), v20, v21 - v20);
}
v23 = v22 + 1;
v24 = strchr(v23, 44);
v25 = v24;
if ( v23 == v24 )
{
*(_BYTE *)(a4 + 160) = 0;
v6 = 1;
}
else
{
strncpy((char *)(a4 + 160), v23, v24 - v23);
}
v26 = strchr(v25 + 1, 44);
v27 = strchr(v26 + 1, 44) + 1;
v28 = strchr(v27, 44);
v29 = v28;
if ( v27 == v28 )
{
*(_BYTE *)(a4 + 224) = 0;
v6 = 1;
}
else
{
strncpy((char *)(a4 + 224), v27, v28 - v27);
}
v30 = v29 + 1;
v31 = strchr(v30, 44);
v32 = v31;
if ( v30 == v31 )
{
*(_BYTE *)(a4 + 256) = 0;
v6 = 1;
}
else
{
strncpy((char *)(a4 + 256), v30, v31 - v30);
}
v33 = v32 + 1;
v34 = strchr(v33, 44);
v35 = v34;
if ( v33 == v34 )
*(_BYTE *)(a4 + 288) = 0;
else
strncpy((char *)(a4 + 288), v33, v34 - v33);
v36 = v35 + 1;
v37 = strchr(v36, 44);
v38 = v37;
if ( v36 == v37 )
{
*(_BYTE *)(a4 + 320) = 0;
v6 = 1;
}
else
{
strncpy((char *)(a4 + 320), v36, v37 - v36);
}
v39 = v38 + 1;
v40 = strchr(v39, 44);
v41 = v40;
if ( v39 == v40 )
{
*(_BYTE *)(a4 + 352) = 0;
v6 = 1;
}
else
{
strncpy((char *)(a4 + 352), v39, v40 - v39);
}
v42 = v41 + 1;
v43 = strchr(v42, 44);
v44 = v43;
if ( v42 == v43 )
{
*(_BYTE *)(a4 + 384) = 0;
v6 = 1;
}
else
{
strncpy((char *)(a4 + 384), v42, v43 - v42);
}
v45 = v44 + 1;
v46 = strchr(v45, 44);
v47 = v46;
if ( v45 == v46 )
{
*(_BYTE *)(a4 + 416) = 0;
v6 = 1;
}
else
{
strncpy((char *)(a4 + 416), v45, v46 - v45);
}
v48 = v47 + 1;
v49 = strchr(v48, 44);
v50 = v49;
if ( v48 == v49 )
{
*(_BYTE *)(a4 + 448) = 0;
v6 = 1;
}
else
{
strncpy((char *)(a4 + 448), v48, v49 - v48);
}
v51 = v50 + 1;
v52 = strchr(v51, 44);
v53 = v52;
if ( v51 == v52 )
{
*(_BYTE *)(a4 + 480) = 0;
v6 = 1;
}
else
{
strncpy((char *)(a4 + 480), v51, v52 - v51);
}
v54 = strchr(v53 + 1, 44);
v55 = strchr(v54 + 1, 44) + 1;
v56 = strchr(v55, 44);
v57 = v56;
if ( v55 == v56 )
*(_BYTE *)(a4 + 512) = 0;
else
strncpy((char *)(a4 + 512), v55, v56 - v55);
v58 = strchr(v57 + 1, 44);
v59 = strchr(v58 + 1, 44);
v60 = strchr(v59 + 1, 44);
v61 = strchr(v60 + 1, 44);
v62 = strchr(v61 + 1, 44);
if ( v62[1] )
{
v86 = v62 + 1;
v87 = strchr(v62 + 1, 13);
strncpy((char *)(a4 + 192), v86, v87 - v86);
}
else
{
*(_BYTE *)(a4 + 192) = 0;
v6 = 1;
}
}
if ( a3 )
{
for ( i = 0LL; i != 10; ++i )
*(_BYTE *)(a4 + i + 256) = *(_BYTE *)(a3 + i);
}
return v6;
}

original_code:
int read_a_record(char *buf, int vtype, char *change_to_date, struct Record *aRcd)
{
    char *p = buf, *q;
    int i, status = 0;
    memset(aRcd, '\0', 544);
    if(vtype == 1) {
 q = strchr(p, ',');
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->vId, p, q-p);
 else
  aRcd->vId[0] = '\0', status = 1;
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->longitude, p, q-p);
 else
  aRcd->longitude[0] = '\0', status = 1;
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->lattitude, p, q-p);
 else
  aRcd->lattitude[0] = '\0', status = 1;
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->speed, p, q-p);
 else
  aRcd->speed[0] = '\0', status = 1;
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->heading, p, q-p);
 else
  aRcd->heading[0] = '\0', status = 1;
 p = q+1;
 q = strchr(p, ',');
 strncpy(aRcd->timestamp, p, q-p);
 if(q!=p)
  strncpy(aRcd->timestamp, p, q-p);
 else
  aRcd->timestamp[0] = '\0', status = 1;
 p = q+1;
 q = strchr(p, ',');
 strncpy(aRcd->D7, p, q-p);
 if(q!=p)
  strncpy(aRcd->D7, p, q-p);
 else
  aRcd->D7[0] = '\0', status = 1;
    } else {
 q = strchr(p, ',');
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->msgType, p, q-p);
 else
  aRcd->msgType[0] = '\0', status = 1;
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->vId, p, q-p);
 else
  aRcd->vId[0] = '\0', status = 1;
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->routeId, p, q-p);
 else
  aRcd->routeId[0] = '\0', status = 1;
 p = q+1;
 q = strchr(p, ',');
 p = q+1;
 q = strchr(p, ',');
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->longitude, p, q-p);
 else
  aRcd->longitude[0] = '\0', status = 1;
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->lattitude, p, q-p);
 else
  aRcd->lattitude[0] = '\0', status = 1;
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->speed, p, q-p);
 else
  aRcd->speed[0] = '\0', status = 1;
 p = q+1;
 q = strchr(p, ',');
 p = q+1;
 q = strchr(p, ',');
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->routeLeng, p, q-p);
 else
  aRcd->routeLeng[0] = '\0', status = 1;
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->timestamp, p, q-p);
 else
  aRcd->timestamp[0] = '\0', status = 1;
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->gasVol, p, q-p);
 else
  aRcd->gasVol[0] = '\0';
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->D7, p, q-p);
 else
  aRcd->D7[0] = '\0', status = 1;
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->D6, p, q-p);
 else
  aRcd->D6[0] = '\0', status = 1;
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->D5, p, q-p);
 else
  aRcd->D5[0] = '\0', status = 1;
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->D4, p, q-p);
 else
  aRcd->D4[0] = '\0', status = 1;
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->D3, p, q-p);
 else
  aRcd->D3[0] = '\0', status = 1;
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->D2, p, q-p);
 else
  aRcd->D2[0] = '\0', status = 1;
 p = q+1;
 q = strchr(p, ',');
 p = q+1;
 q = strchr(p, ',');
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->errorInfo, p, q-p);
 else
  aRcd->errorInfo[0] = '\0';
 p = q+1;
 q = strchr(p, ',');
 p = q+1;
 q = strchr(p, ',');
 p = q+1;
 q = strchr(p, ',');
 p = q+1;
 q = strchr(p, ',');
 p = q+1;
 q = strchr(p, ',');
 p = q+1;
 q = strchr(p, '\r');
 if( p[0] != '\0')
  strncpy(aRcd->heading, p, q-p);
 else
  aRcd->heading[0] = '\0', status = 1;
    }
    if(change_to_date != ((void *)0)) {
 for(i=0;i<10;i++)
  aRcd->timestamp[i] = change_to_date[i];
    }
    return status;
}

canonical_original_code:
int read_a_record(char *buf, int vtype, char *change_to_date, struct Record *aRcd)
{
    char *p = buf; char *q;
    int i; int status = 0;
    memset(aRcd, '\0', 544);
    if(vtype == 1) {
 q = strchr(p, ',');
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->vId, p, q-p);
 else
  aRcd->vId[0] = '\0', status = 1;
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->longitude, p, q-p);
 else
  aRcd->longitude[0] = '\0', status = 1;
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->lattitude, p, q-p);
 else
  aRcd->lattitude[0] = '\0', status = 1;
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->speed, p, q-p);
 else
  aRcd->speed[0] = '\0', status = 1;
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->heading, p, q-p);
 else
  aRcd->heading[0] = '\0', status = 1;
 p = q+1;
 q = strchr(p, ',');
 strncpy(aRcd->timestamp, p, q-p);
 if(q!=p)
  strncpy(aRcd->timestamp, p, q-p);
 else
  aRcd->timestamp[0] = '\0', status = 1;
 p = q+1;
 q = strchr(p, ',');
 strncpy(aRcd->D7, p, q-p);
 if(q!=p)
  strncpy(aRcd->D7, p, q-p);
 else
  aRcd->D7[0] = '\0', status = 1;
    } else {
 q = strchr(p, ',');
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->msgType, p, q-p);
 else
  aRcd->msgType[0] = '\0', status = 1;
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->vId, p, q-p);
 else
  aRcd->vId[0] = '\0', status = 1;
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->routeId, p, q-p);
 else
  aRcd->routeId[0] = '\0', status = 1;
 p = q+1;
 q = strchr(p, ',');
 p = q+1;
 q = strchr(p, ',');
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->longitude, p, q-p);
 else
  aRcd->longitude[0] = '\0', status = 1;
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->lattitude, p, q-p);
 else
  aRcd->lattitude[0] = '\0', status = 1;
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->speed, p, q-p);
 else
  aRcd->speed[0] = '\0', status = 1;
 p = q+1;
 q = strchr(p, ',');
 p = q+1;
 q = strchr(p, ',');
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->routeLeng, p, q-p);
 else
  aRcd->routeLeng[0] = '\0', status = 1;
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->timestamp, p, q-p);
 else
  aRcd->timestamp[0] = '\0', status = 1;
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->gasVol, p, q-p);
 else
  aRcd->gasVol[0] = '\0';
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->D7, p, q-p);
 else
  aRcd->D7[0] = '\0', status = 1;
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->D6, p, q-p);
 else
  aRcd->D6[0] = '\0', status = 1;
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->D5, p, q-p);
 else
  aRcd->D5[0] = '\0', status = 1;
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->D4, p, q-p);
 else
  aRcd->D4[0] = '\0', status = 1;
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->D3, p, q-p);
 else
  aRcd->D3[0] = '\0', status = 1;
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->D2, p, q-p);
 else
  aRcd->D2[0] = '\0', status = 1;
 p = q+1;
 q = strchr(p, ',');
 p = q+1;
 q = strchr(p, ',');
 p = q+1;
 q = strchr(p, ',');
 if(q!=p)
  strncpy(aRcd->errorInfo, p, q-p);
 else
  aRcd->errorInfo[0] = '\0';
 p = q+1;
 q = strchr(p, ',');
 p = q+1;
 q = strchr(p, ',');
 p = q+1;
 q = strchr(p, ',');
 p = q+1;
 q = strchr(p, ',');
 p = q+1;
 q = strchr(p, ',');
 p = q+1;
 q = strchr(p, '\r');
 if( p[0] != '\0')
  strncpy(aRcd->heading, p, q-p);
 else
  aRcd->heading[0] = '\0', status = 1;
    }
    if(change_to_date != ((void *)0)) {
 for(i=0;i<10;i++)
  aRcd->timestamp[i] = change_to_date[i];
    }
    return status;
}

variable_types:
buf
char *

variable_types: vtype int

variable_types: struct Record { char vId[32]; char msgType[32]; char routeId[32]; char longitude[32]; char lattitude[32]; char speed[32]; char heading[32]; char routeLeng[32]; char timestamp[32]; char gasVol[32]; char D7[32]; char D6[32]; char D5[32]; char D4[32]; char D3[32]; char D2[32]; char errorInfo[32]; } *

variable_types:
p
char *

variable_types:
q
char *

variable_types: status int


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

if ( 2 * a1 > 90 )
result = (unsigned int)(2 * (225 - a1));
else
result = (unsigned int)(2 * (45 - a1));
return result;
}

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

if ( 2 * a1 > 90 )
result = (unsigned int)(2 * (225 - a1));
else
result = (unsigned int)(2 * (45 - a1));
return result;
}

original_code:
int normal_angle_taxi(int repAngle)
{
 int rtAngle;
 if (90 >= 2*repAngle)
  rtAngle = 90-2*repAngle;
 else
  rtAngle = 450-2*repAngle;
 return rtAngle;
}

variable_types: repAngle int

variable_types: rtAngle int


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

if ( a1 > 90 )
result = (unsigned int)(450 - a1);
else
result = (unsigned int)(90 - a1);
return result;
}

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

if ( a1 > 90 )
result = (unsigned int)(450 - a1);
else
result = (unsigned int)(90 - a1);
return result;
}

original_code:
int normal_angle_bus(int repAngle)
{
 int rtAngle;
 if (90 >= repAngle)
  rtAngle = 90-repAngle;
 else
  rtAngle = 450-repAngle;
 return rtAngle;
}


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

if ( a1 > 90 )
result = (unsigned int)((450 - a1) / 2);
else
result = (unsigned int)((90 - a1) >> 1);
return result;
}

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

if ( a1 > 90 )
result = (unsigned int)((450 - a1) / 2);
else
result = (unsigned int)((90 - a1) >> 1);
return result;
}

original_code:
int report_angle(int norAngle)
{
 int rtAngle;
 if(norAngle <= 90)
  rtAngle = (90-norAngle)/2;
 else
  rtAngle = (450-norAngle)/2;
 return rtAngle;
}

variable_types: norAngle int