decompiled_code:
__int64 __fastcall vector_string_add(__int64 a1, const char *a2, int a3)
{
__int64 v3; // r12
__int64 v4; // rax
__int64 v7; // rbx
unsigned __int64 v8; // r13
__int64 v9; // rax
const char *v10; // rsi
char *v11; // rdi
__int64 result; // rax

v3 = a3;
if ( a3 >= 0 )
{
v4 = *(int *)(a1 + 16);
if ( (int)v4 + 1 >= *(_DWORD *)a1 )
{
vector_string_change_capacity((int *)a1, 2 * *(_DWORD *)a1);
v4 = *(int *)(a1 + 16);
if ( (int)v3 < (int)v4 )
{
LABEL_4:
v7 = 8LL * (int)v4 - 8;
v8 = 8 * ((int)v4 - (unsigned __int64)(unsigned int)(~(_DWORD)v3 + v4)) - 16;
do
{
v9 = *(_QWORD *)(a1 + 8);
v10 = *(const char **)(v9 + v7);
v11 = *(char **)(v9 + v7 + 8);
v7 -= 8LL;
strcpy(v11, v10);
}
while ( v8 != v7 );
strcpy(*(char **)(*(_QWORD *)(a1 + 8) + 8 * v3), a2);
goto LABEL_7;
}
}
else if ( a3 < (int)v4 )
{
goto LABEL_4;
}
strcpy(*(char **)(*(_QWORD *)(a1 + 8) + 8 * v4), a2);
LABEL_7:
result = (unsigned int)(*(_DWORD *)(a1 + 16) + 1);
*(_DWORD *)(a1 + 16) = result;
return result;
}
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, const char *a2, int a3)
{
__int64 v3; // r12
__int64 v4; // rax
__int64 v7; // rbx
unsigned __int64 v8; // r13
__int64 v9; // rax
const char *v10; // rsi
char *v11; // rdi
__int64 result; // rax

v3 = a3;
if ( a3 >= 0 )
{
v4 = *(int *)(a1 + 16);
if ( (int)v4 + 1 >= *(_DWORD *)a1 )
{
func7((int *)a1, 2 * *(_DWORD *)a1);
v4 = *(int *)(a1 + 16);
if ( (int)v3 < (int)v4 )
{
LABEL_4:
v7 = 8LL * (int)v4 - 8;
v8 = 8 * ((int)v4 - (unsigned __int64)(unsigned int)(~(_DWORD)v3 + v4)) - 16;
do
{
v9 = *(_QWORD *)(a1 + 8);
v10 = *(const char **)(v9 + v7);
v11 = *(char **)(v9 + v7 + 8);
v7 -= 8LL;
strcpy(v11, v10);
}
while ( v8 != v7 );
strcpy(*(char **)(*(_QWORD *)(a1 + 8) + 8 * v3), a2);
goto LABEL_7;
}
}
else if ( a3 < (int)v4 )
{
goto LABEL_4;
}
strcpy(*(char **)(*(_QWORD *)(a1 + 8) + 8 * v4), a2);
LABEL_7:
result = (unsigned int)(*(_DWORD *)(a1 + 16) + 1);
*(_DWORD *)(a1 + 16) = result;
return result;
}
return 0xFFFFFFFFLL;
}

original_code:
int
vector_string_add(
                  vector_string_t * vector,
                  char * string,
                  int index
                 )
{
    int i;
    if (index < 0)
    {
        return -1;
    }
    if (vector->size + 1 >= vector->capacity)
    {
        vector_string_change_capacity(vector, vector->capacity << 1);
    }
    if (index < vector->size)
    {
        for (i = vector->size; index < i; i--)
        {
            strcpy(vector->elements[i], vector->elements[i - 1]);
        }
        strcpy(vector->elements[index], string);
    }
    else
    {
        strcpy(vector->elements[vector->size], string);
    }
    return ++vector->size;
}

canonical_original_code:
int vector_string_add(struct vector_string *vector, char *string, int index)
{
    int i;
    if (index < 0)
    {
        return -1;
    }
    if (vector->size + 1 >= vector->capacity)
    {
        vector_string_change_capacity(vector, vector->capacity << 1);
    }
    if (index < vector->size)
    {
        for (i = vector->size; index < i; i--)
        {
            strcpy(vector->elements[i], vector->elements[i - 1]);
        }
        strcpy(vector->elements[index], string);
    }
    else
    {
        strcpy(vector->elements[vector->size], string);
    }
    return ++vector->size;
}


repo: kylelol/MIPS-Assembler-Final-Project

decompiled_code:
__int64 __fastcall vector_string_add_first(__int64 a1, const char *a2)
{
return vector_string_add(a1, a2, 0);
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, const char *a2)
{
return func8(a1, a2, 0);
}

original_code:
int
vector_string_add_first(
                        vector_string_t * vector,
                        char * string
                       )
{
    return vector_string_add(vector, string, 0);
}

canonical_original_code:
int vector_string_add_first(struct vector_string *vector, char *string)
{
    return vector_string_add(vector, string, 0);
}

variable_types: struct vector_string { int capacity; char **elements; int size; } *

variable_types:
string
char *

return_type: int


decompiled_code:
__int64 __fastcall vector_string_add_last(__int64 a1, const char *a2)
{
return vector_string_add(a1, a2, *(_DWORD *)(a1 + 16));
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, const char *a2)
{
return func8(a1, a2, *(_DWORD *)(a1 + 16));
}

original_code:
int
vector_string_add_last(
                       vector_string_t * vector,
                       char * string
                      )
{
    return vector_string_add(vector, string, vector->size);
}

canonical_original_code:
int vector_string_add_last(struct vector_string *vector, char *string)
{
    return vector_string_add(vector, string, vector->size);
}

user_defined_types: struct vector_string { int capacity; char **elements; int size; }


decompiled_code:
__int64 __fastcall vector_string_remove(__int64 a1, int a2)
{
int v3; // edx
__int64 result; // rax
int v5; // ebx
__int64 v6; // r12
__int64 v7; // rax
const char *v8; // rsi
char *v9; // rdi
int v10; // eax
int v11; // esi
int v12; // esi
int v13; // esi

if ( a2 < 0 )
return 0xFFFFFFFFLL;
v3 = *(_DWORD *)(a1 + 16);
if ( v3 <= a2 )
return 0xFFFFFFFFLL;
result = (unsigned int)(v3 - 1);
if ( v3 == 1 )
{
v13 = *(_DWORD *)a1;
*(_DWORD *)(a1 + 16) = 0;
if ( v13 <= 4 )
return 0LL;
v12 = v13 >> 1;
goto LABEL_15;
}
if ( a2 < (int)result )
{
v5 = a2 + 1;
v6 = 8LL * (a2 + 1);
while ( 1 )
{
v7 = *(_QWORD *)(a1 + 8);
v8 = *(const char **)(v7 + v6);
v9 = *(char **)(v7 + v6 - 8);
v6 += 8LL;
strcpy(v9, v8);
v10 = *(_DWORD *)(a1 + 16);
if ( v10 <= v5 )
break;
++v5;
}
result = (unsigned int)(v10 - 1);
}
v11 = *(_DWORD *)a1;
*(_DWORD *)(a1 + 16) = result;
if ( v11 > 4 )
{
v12 = v11 >> 1;
if ( v12 > (int)result )
{
LABEL_15:
vector_string_change_capacity((int *)a1, v12);
return *(unsigned int *)(a1 + 16);
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, int a2)
{
int v3; // edx
__int64 result; // rax
int v5; // ebx
__int64 v6; // r12
__int64 v7; // rax
const char *v8; // rsi
char *v9; // rdi
int v10; // eax
int v11; // esi
int v12; // esi
int v13; // esi

if ( a2 < 0 )
return 0xFFFFFFFFLL;
v3 = *(_DWORD *)(a1 + 16);
if ( v3 <= a2 )
return 0xFFFFFFFFLL;
result = (unsigned int)(v3 - 1);
if ( v3 == 1 )
{
v13 = *(_DWORD *)a1;
*(_DWORD *)(a1 + 16) = 0;
if ( v13 <= 4 )
return 0LL;
v12 = v13 >> 1;
goto LABEL_15;
}
if ( a2 < (int)result )
{
v5 = a2 + 1;
v6 = 8LL * (a2 + 1);
while ( 1 )
{
v7 = *(_QWORD *)(a1 + 8);
v8 = *(const char **)(v7 + v6);
v9 = *(char **)(v7 + v6 - 8);
v6 += 8LL;
strcpy(v9, v8);
v10 = *(_DWORD *)(a1 + 16);
if ( v10 <= v5 )
break;
++v5;
}
result = (unsigned int)(v10 - 1);
}
v11 = *(_DWORD *)a1;
*(_DWORD *)(a1 + 16) = result;
if ( v11 > 4 )
{
v12 = v11 >> 1;
if ( v12 > (int)result )
{
LABEL_15:
func7((int *)a1, v12);
return *(unsigned int *)(a1 + 16);
}
}
return result;
}

original_code:
int
vector_string_remove(
                     vector_string_t * vector,
                     int index
                    )
{
    int i;
    if (index < 0 || vector->size <= index)
    {
        return -1;
    }
    if (1 < vector->size && index < vector->size - 1)
    {
        for (i = index; i < vector->size; i++)
        {
            strcpy(vector->elements[i], vector->elements[i + 1]);
        }
    }
    vector->size--;
    if (4 < vector->capacity
            && vector->size < vector->capacity >> 1)
    {
       vector_string_change_capacity(vector, vector->capacity >> 1);
    }
    return vector->size;
}

canonical_original_code:
int vector_string_remove(struct vector_string *vector, int index)
{
    int i;
    if (index < 0 || vector->size <= index)
    {
        return -1;
    }
    if (1 < vector->size && index < vector->size - 1)
    {
        for (i = index; i < vector->size; i++)
        {
            strcpy(vector->elements[i], vector->elements[i + 1]);
        }
    }
    vector->size--;
    if (4 < vector->capacity
            && vector->size < vector->capacity >> 1)
    {
       vector_string_change_capacity(vector, vector->capacity >> 1);
    }
    return vector->size;
}

variable_types: index int

variable_types: i int


decompiled_code:
__int64 __fastcall vector_string_remove_first(__int64 a1)
{
return vector_string_remove(a1, 0);
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1)
{
return func11(a1, 0);
}

original_code:
int
vector_string_remove_first(vector_string_t * vector)
{
    return vector_string_remove(vector, 0);
}

canonical_original_code:
int vector_string_remove_first(struct vector_string *vector)
{
    return vector_string_remove(vector, 0);
}


decompiled_code:
__int64 __fastcall vector_string_remove_last(__int64 a1)
{
return vector_string_remove(a1, *(_DWORD *)(a1 + 16) - 1);
}

original_code:
int
vector_string_remove_last(vector_string_t * vector)
{
    return vector_string_remove(vector, vector->size - 1);
}

canonical_original_code:
int vector_string_remove_last(struct vector_string *vector)
{
    return vector_string_remove(vector, vector->size - 1);
}


decompiled_code:
_DWORD *vector_uint_create()
{
_DWORD *v0; // rax
_DWORD *v1; // r12
void *v2; // rax

v0 = malloc(0x18uLL);
if ( !v0 )
{
fwrite("*** malloc failed ***\n", 1uLL, 0x16uLL, stderr);
fwrite("vector_uint_create vector_uint_t\n", 1uLL, 0x21uLL, stderr);
exit(1);
}
*v0 = 4;
v1 = v0;
v2 = malloc(0x10uLL);
v1[4] = 0;
*((_QWORD *)v1 + 1) = v2;
if ( !v2 )
{
fwrite("*** malloc failed ***\n", 1uLL, 0x16uLL, stderr);
fwrite("vector_uint_create vector->elements\n", 1uLL, 0x24uLL, stderr);
exit(1);
}
return v1;
}

canonical_decompiled_code:
_DWORD *func14()
{
_DWORD *v0; // rax
_DWORD *v1; // r12
void *v2; // rax

v0 = malloc(0x18uLL);
if ( !v0 )
{
fwrite("*** malloc failed ***\n", 1uLL, 0x16uLL, stderr);
fwrite("vector_uint_create vector_uint_t\n", 1uLL, 0x21uLL, stderr);
exit(1);
}
*v0 = 4;
v1 = v0;
v2 = malloc(0x10uLL);
v1[4] = 0;
*((_QWORD *)v1 + 1) = v2;
if ( !v2 )
{
fwrite("*** malloc failed ***\n", 1uLL, 0x16uLL, stderr);
fwrite("vector_uint_create vector->elements\n", 1uLL, 0x24uLL, stderr);
exit(1);
}
return v1;
}

original_code:
vector_uint_t *
vector_uint_create()
{
    vector_uint_t * v;
    int i;
    if (!(v = malloc(sizeof(vector_uint_t))))
    {
        fprintf(stderr, "*** malloc failed ***\n");
        fprintf(stderr, "vector_uint_create vector_uint_t\n");
        exit(1);
    }
    v->capacity = 4;
    v->elements = malloc(4 * sizeof(unsigned int));
    v->size = 0;
    if (!v->elements)
    {
        fprintf(stderr, "*** malloc failed ***\n");
        fprintf(stderr, "vector_uint_create vector->elements\n");
        exit(1);
    }
    return v;
}

canonical_original_code:
struct vector_uint *vector_uint_create()
{
    struct vector_uint *v;
    int i;
    if (!(v = malloc(sizeof(vector_uint_t))))
    {
        fprintf(stderr, "*** malloc failed ***\n");
        fprintf(stderr, "vector_uint_create vector_uint_t\n");
        exit(1);
    }
    v->capacity = 4;
    v->elements = malloc(4 * sizeof(unsigned int));
    v->size = 0;
    if (!v->elements)
    {
        fprintf(stderr, "*** malloc failed ***\n");
        fprintf(stderr, "vector_uint_create vector->elements\n");
        exit(1);
    }
    return v;
}

variable_types: struct vector_uint { int capacity; unsigned int *elements; int size; } *


decompiled_code:
void __fastcall vector_uint_destroy(void *ptr)
{
void *v2; // rdi

v2 = (void *)*((_QWORD *)ptr + 1);
if ( v2 )
free(v2);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func15(void *ptr)
{
void *v2; // rdi

v2 = (void *)*((_QWORD *)ptr + 1);
if ( v2 )
free(v2);
free(ptr);
}

original_code:
void
vector_uint_destroy(vector_uint_t * vector)
{
    if (vector->elements)
    {
        free(vector->elements);
    }
    free(vector);
}

canonical_original_code:
void vector_uint_destroy(struct vector_uint *vector)
{
    if (vector->elements)
    {
        free(vector->elements);
    }
    free(vector);
}

return_type: void

user_defined_types: struct vector_uint { int capacity; unsigned int *elements; int size; }


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

result = 0LL;
if ( a3 >= 0 && *(_DWORD *)(a1 + 16) > a3 )
{
*(_DWORD *)(*(_QWORD *)(a1 + 8) + 4LL * a3) = a2;
result = *(unsigned int *)(a1 + 16);
}
return result;
}

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

result = 0LL;
if ( a3 >= 0 && *(_DWORD *)(a1 + 16) > a3 )
{
*(_DWORD *)(*(_QWORD *)(a1 + 8) + 4LL * a3) = a2;
result = *(unsigned int *)(a1 + 16);
}
return result;
}

original_code:
int
vector_uint_set(
                vector_uint_t * vector,
                unsigned int number,
                int index
               )
{
    if (index < 0 || vector->size <= index)
    {
        return 0;
    }
    vector->elements[index] = number;
    return vector->size;
}

canonical_original_code:
int vector_uint_set(struct vector_uint *vector, unsigned int number, int index)
{
    if (index < 0 || vector->size <= index)
    {
        return 0;
    }
    vector->elements[index] = number;
    return vector->size;
}

variable_types:
number
unsigned int


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

result = 0LL;
if ( a2 >= 0 && *(_DWORD *)(a1 + 16) > a2 )
result = *(unsigned int *)(*(_QWORD *)(a1 + 8) + 4LL * a2);
return result;
}

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

result = 0LL;
if ( a2 >= 0 && *(_DWORD *)(a1 + 16) > a2 )
result = *(unsigned int *)(*(_QWORD *)(a1 + 8) + 4LL * a2);
return result;
}

original_code:
unsigned int
vector_uint_get(
                vector_uint_t * vector,
                int index
               )
{
    return (0 <= index && index < vector->size)
           ? vector->elements[index]
           : 0;
}

canonical_original_code:
unsigned int vector_uint_get(struct vector_uint *vector, int index)
{
    return (0 <= index && index < vector->size)
           ? vector->elements[index]
           : 0;
}

return_type: unsigned int


decompiled_code:
__int64 __fastcall vector_uint_size(__int64 a1)
{
return *(unsigned int *)(a1 + 16);
}

canonical_decompiled_code:
__int64 __fastcall func18(__int64 a1)
{
return *(unsigned int *)(a1 + 16);
}

original_code:
int
vector_uint_size(vector_uint_t * vector)
{
    return vector->size;
}

canonical_original_code:
int vector_uint_size(struct vector_uint *vector)
{
    return vector->size;
}


decompiled_code:
bool __fastcall vector_uint_is_empty(__int64 a1)
{
return *(_DWORD *)(a1 + 16) == 0;
}

canonical_decompiled_code:
bool __fastcall func20(__int64 a1)
{
return *(_DWORD *)(a1 + 16) == 0;
}

original_code:
char
vector_uint_is_empty(vector_uint_t * vector)
{
    return vector->size == 0;
}

canonical_original_code:
char vector_uint_is_empty(struct vector_uint *vector)
{
    return vector->size == 0;
}

return_type: char


decompiled_code:
void __fastcall vector_uint_change_capacity(int *a1, int a2)
{
__int64 v2; // rbx
_DWORD *v3; // rax
void *v4; // r15
_DWORD *v5; // r13
_DWORD *v6; // rax
_DWORD *v7; // rdx
int v8; // ecx
__int64 i; // rax

v2 = a1[4];
v3 = malloc(4 * v2);
v4 = (void *)*((_QWORD *)a1 + 1);
v5 = v3;
if ( (int)v2 > 0 )
memcpy(v3, *((const void **)a1 + 1), 4 * v2);
free(v4);
v6 = malloc(4LL * a2);
*((_QWORD *)a1 + 1) = v6;
v7 = v6;
if ( !v6 )
{
fwrite("*** malloc failed ***\n", 1uLL, 0x16uLL, stderr);
fprintf(stderr, "vector_uint_change_capacity from %i to %i\n", (unsigned int)*a1, (unsigned int)a2);
exit(1);
}
if ( a2 > 0 )
{
v8 = a1[4];
for ( i = 0LL; i != a2; ++i )
{
if ( v8 > (int)i )
v7[i] = v5[i];
}
}
free(v5);
*a1 = a2;
}

canonical_decompiled_code:
void __fastcall func21(int *a1, int a2)
{
__int64 v2; // rbx
_DWORD *v3; // rax
void *v4; // r15
_DWORD *v5; // r13
_DWORD *v6; // rax
_DWORD *v7; // rdx
int v8; // ecx
__int64 i; // rax

v2 = a1[4];
v3 = malloc(4 * v2);
v4 = (void *)*((_QWORD *)a1 + 1);
v5 = v3;
if ( (int)v2 > 0 )
memcpy(v3, *((const void **)a1 + 1), 4 * v2);
free(v4);
v6 = malloc(4LL * a2);
*((_QWORD *)a1 + 1) = v6;
v7 = v6;
if ( !v6 )
{
fwrite("*** malloc failed ***\n", 1uLL, 0x16uLL, stderr);
fprintf(stderr, "vector_uint_change_capacity from %i to %i\n", (unsigned int)*a1, (unsigned int)a2);
exit(1);
}
if ( a2 > 0 )
{
v8 = a1[4];
for ( i = 0LL; i != a2; ++i )
{
if ( v8 > (int)i )
v7[i] = v5[i];
}
}
free(v5);
*a1 = a2;
}

original_code:
void
vector_uint_change_capacity(
                            vector_uint_t * vector,
                            int new_capacity
                           )
{
    unsigned int * tmp;
    int tmp_size;
    int i;
    tmp = malloc(vector->size * sizeof(unsigned));
    for (i = 0; i < vector->size; i++)
    {
        tmp[i] = vector->elements[i];
    }
    free(vector->elements);
    vector->elements = malloc(new_capacity * sizeof(unsigned));
    if (!vector->elements)
    {
        fprintf(stderr, "*** malloc failed ***\n");
        fprintf(
                stderr,
                "vector_uint_change_capacity from %i to %i\n",
                vector->capacity,
                new_capacity
               );
        exit(1);
    }
    for (i = 0; i < new_capacity; i++)
    {
        if (i < vector->size)
        {
            vector->elements[i] = tmp[i];
        }
    }
    free(tmp);
    vector->capacity = new_capacity;
}

canonical_original_code:
void vector_uint_change_capacity(struct vector_uint *vector, int new_capacity)
{
    unsigned int *tmp;
    int tmp_size;
    int i;
    tmp = malloc(vector->size * sizeof(unsigned int));
    for (i = 0; i < vector->size; i++)
    {
        tmp[i] = vector->elements[i];
    }
    free(vector->elements);
    vector->elements = malloc(new_capacity * sizeof(unsigned int));
    if (!vector->elements)
    {
        fprintf(stderr, "*** malloc failed ***\n");
        fprintf(
                stderr,
                "vector_uint_change_capacity from %i to %i\n",
                vector->capacity,
                new_capacity
               );
        exit(1);
    }
    for (i = 0; i < new_capacity; i++)
    {
        if (i < vector->size)
        {
            vector->elements[i] = tmp[i];
        }
    }
    free(tmp);
    vector->capacity = new_capacity;
}

variable_types:
tmp
unsigned int *


decompiled_code:
__int64 __fastcall vector_uint_add(__int64 a1, int a2, int a3)
{
__int64 v3; // rbp
__int64 v4; // rax
__int64 v5; // r13
__int64 result; // rax

v3 = a3;
if ( a3 < 0 )
return 0xFFFFFFFFLL;
v4 = *(int *)(a1 + 16);
if ( (int)v4 + 1 >= *(_DWORD *)a1 )
{
vector_uint_change_capacity((int *)a1, 2 * *(_DWORD *)a1);
v4 = *(int *)(a1 + 16);
}
v5 = *(_QWORD *)(a1 + 8);
if ( (int)v3 < (int)v4 )
{
memmove(
(void *)(v5 + 4 * v4 - 4LL * (unsigned int)(v4 - v3 - 1)),
(const void *)(v5 + 4 * v4 - 4LL * (unsigned int)(v4 - v3 - 1) - 4),
4LL * (unsigned int)(v4 - v3 - 1) + 4);
*(_DWORD *)(v5 + 4 * v3) = a2;
}
else
{
*(_DWORD *)(v5 + 4 * v4) = a2;
}
result = (unsigned int)(*(_DWORD *)(a1 + 16) + 1);
*(_DWORD *)(a1 + 16) = result;
return result;
}

original_code:
int
vector_uint_add(
                vector_uint_t * vector,
                unsigned int number,
                int index
               )
{
    int i;
    if (index < 0)
    {
        return -1;
    }
    if (vector->size + 1 >= vector->capacity)
    {
        vector_uint_change_capacity(vector, vector->capacity << 1);
    }
    if (index < vector->size)
    {
        for (i = vector->size; index < i; i--)
        {
            vector->elements[i] = vector->elements[i - 1];
        }
        vector->elements[index] = number;
    }
    else
    {
        vector->elements[vector->size] = number;
    }
    return ++vector->size;
}

canonical_original_code:
int vector_uint_add(struct vector_uint *vector, unsigned int number, int index)
{
    int i;
    if (index < 0)
    {
        return -1;
    }
    if (vector->size + 1 >= vector->capacity)
    {
        vector_uint_change_capacity(vector, vector->capacity << 1);
    }
    if (index < vector->size)
    {
        for (i = vector->size; index < i; i--)
        {
            vector->elements[i] = vector->elements[i - 1];
        }
        vector->elements[index] = number;
    }
    else
    {
        vector->elements[vector->size] = number;
    }
    return ++vector->size;
}


decompiled_code:
__int64 __fastcall vector_uint_add_first(__int64 a1, int a2)
{
return vector_uint_add(a1, a2, 0);
}

canonical_decompiled_code:
__int64 __fastcall func23(__int64 a1, int a2)
{
return func22(a1, a2, 0);
}

original_code:
int
vector_uint_add_first(
                      vector_uint_t * vector,
                      unsigned int number
                     )
{
    return vector_uint_add(vector, number, 0);
}

canonical_original_code:
int vector_uint_add_first(struct vector_uint *vector, unsigned int number)
{
    return vector_uint_add(vector, number, 0);
}


decompiled_code:
__int64 __fastcall vector_uint_add_last(__int64 a1, int a2)
{
return vector_uint_add(a1, a2, *(_DWORD *)(a1 + 16));
}

canonical_decompiled_code:
__int64 __fastcall func24(__int64 a1, int a2)
{
return func22(a1, a2, *(_DWORD *)(a1 + 16));
}

original_code:
int
vector_uint_add_last(
                     vector_uint_t * vector,
                     unsigned int number
                    )
{
    return vector_uint_add(vector, number, vector->size);
}

canonical_original_code:
int vector_uint_add_last(struct vector_uint *vector, unsigned int number)
{
    return vector_uint_add(vector, number, vector->size);
}


decompiled_code:
__int64 __fastcall vector_uint_remove(__int64 a1, __int64 a2)
{
int v2; // edx
__int64 result; // rax
__int64 v4; // rdx
int v5; // eax
int v6; // esi
int v7; // esi
int v8; // esi

if ( (int)a2 < 0 )
return 0xFFFFFFFFLL;
v2 = *(_DWORD *)(a1 + 16);
if ( v2 <= (int)a2 )
return 0xFFFFFFFFLL;
result = (unsigned int)(v2 - 1);
if ( v2 == 1 )
{
v8 = *(_DWORD *)a1;
*(_DWORD *)(a1 + 16) = 0;
if ( v8 <= 4 )
return 0LL;
v7 = v8 >> 1;
goto LABEL_14;
}
if ( (int)a2 < (int)result )
{
v4 = *(_QWORD *)(a1 + 8);
a2 = (int)a2;
do
{
*(_DWORD *)(v4 + 4 * a2) = *(_DWORD *)(v4 + 4 * a2 + 4);
v5 = *(_DWORD *)(a1 + 16);
++a2;
}
while ( v5 > (int)a2 );
result = (unsigned int)(v5 - 1);
}
v6 = *(_DWORD *)a1;
*(_DWORD *)(a1 + 16) = result;
if ( v6 > 4 )
{
v7 = v6 >> 1;
if ( v7 > (int)result )
{
LABEL_14:
vector_uint_change_capacity((int *)a1, v7);
return *(unsigned int *)(a1 + 16);
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func25(__int64 a1, __int64 a2)
{
int v2; // edx
__int64 result; // rax
__int64 v4; // rdx
int v5; // eax
int v6; // esi
int v7; // esi
int v8; // esi

if ( (int)a2 < 0 )
return 0xFFFFFFFFLL;
v2 = *(_DWORD *)(a1 + 16);
if ( v2 <= (int)a2 )
return 0xFFFFFFFFLL;
result = (unsigned int)(v2 - 1);
if ( v2 == 1 )
{
v8 = *(_DWORD *)a1;
*(_DWORD *)(a1 + 16) = 0;
if ( v8 <= 4 )
return 0LL;
v7 = v8 >> 1;
goto LABEL_14;
}
if ( (int)a2 < (int)result )
{
v4 = *(_QWORD *)(a1 + 8);
a2 = (int)a2;
do
{
*(_DWORD *)(v4 + 4 * a2) = *(_DWORD *)(v4 + 4 * a2 + 4);
v5 = *(_DWORD *)(a1 + 16);
++a2;
}
while ( v5 > (int)a2 );
result = (unsigned int)(v5 - 1);
}
v6 = *(_DWORD *)a1;
*(_DWORD *)(a1 + 16) = result;
if ( v6 > 4 )
{
v7 = v6 >> 1;
if ( v7 > (int)result )
{
LABEL_14:
func21((int *)a1, v7);
return *(unsigned int *)(a1 + 16);
}
}
return result;
}

original_code:
int
vector_uint_remove(
                   vector_uint_t * vector,
                   int index
                  )
{
    int i;
    if (index < 0 || vector->size <= index)
    {
        return -1;
    }
    if (1 < vector->size && index < vector->size - 1)
    {
        for (i = index; i < vector->size; i++)
        {
            vector->elements[i] = vector->elements[i + 1];
        }
    }
    vector->size--;
    if (4 < vector->capacity
            && vector->size < vector->capacity >> 1)
    {
       vector_uint_change_capacity(vector, vector->capacity >> 1);
    }
    return vector->size;
}

canonical_original_code:
int vector_uint_remove(struct vector_uint *vector, int index)
{
    int i;
    if (index < 0 || vector->size <= index)
    {
        return -1;
    }
    if (1 < vector->size && index < vector->size - 1)
    {
        for (i = index; i < vector->size; i++)
        {
            vector->elements[i] = vector->elements[i + 1];
        }
    }
    vector->size--;
    if (4 < vector->capacity
            && vector->size < vector->capacity >> 1)
    {
       vector_uint_change_capacity(vector, vector->capacity >> 1);
    }
    return vector->size;
}


decompiled_code:
__int64 __fastcall vector_uint_remove_first(__int64 a1)
{
return vector_uint_remove(a1, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func26(__int64 a1)
{
return func25(a1, 0LL);
}

original_code:
int
vector_uint_remove_first(vector_uint_t * vector)
{
    return vector_uint_remove(vector, 0);
}

canonical_original_code:
int vector_uint_remove_first(struct vector_uint *vector)
{
    return vector_uint_remove(vector, 0);
}


decompiled_code:
__int64 __fastcall vector_uint_remove_last(__int64 a1)
{
return vector_uint_remove(a1, (unsigned int)(*(_DWORD *)(a1 + 16) - 1));
}

canonical_decompiled_code:
__int64 __fastcall func27(__int64 a1)
{
return func25(a1, (unsigned int)(*(_DWORD *)(a1 + 16) - 1));
}

original_code:
int
vector_uint_remove_last(vector_uint_t * vector)
{
    return vector_uint_remove(vector, vector->size - 1);
}

canonical_original_code:
int vector_uint_remove_last(struct vector_uint *vector)
{
    return vector_uint_remove(vector, vector->size - 1);
}


decompiled_code:
char *__fastcall string_trim(char *s)
{
__int64 v1; // rax
char v2; // dl
__int64 v3; // rbx
int v4; // edx
char *v5; // rax
int v6; // edx
char *v7; // rax
char v8; // cl
char *result; // rax

if ( *s <= 32 && *s )
{
v1 = 1LL;
do
{
v2 = s[v1];
v3 = (int)v1++;
}
while ( v2 <= 32 && v2 );
}
else
{
v3 = 0LL;
}
v4 = strlen(s) - 1;
v5 = &s[v4];
if ( v4 > 0 )
{
do
{
if ( *v5 > 32 )
break;
--v5;
--v4;
}
while ( v4 );
}
if ( (int)v3 > v4 )
{
result = s;
*s = 0;
}
else
{
v6 = v4 - v3;
v7 = s;
do
{
v8 = v7[v3];
*v7++ = v8;
}
while ( &s[v6 + 1] != v7 );
result = s;
s[v6 + 1] = 0;
}
return result;
}

canonical_decompiled_code:
char *__fastcall func1(char *s)
{
__int64 v1; // rax
char v2; // dl
__int64 v3; // rbx
int v4; // edx
char *v5; // rax
int v6; // edx
char *v7; // rax
char v8; // cl
char *result; // rax

if ( *s <= 32 && *s )
{
v1 = 1LL;
do
{
v2 = s[v1];
v3 = (int)v1++;
}
while ( v2 <= 32 && v2 );
}
else
{
v3 = 0LL;
}
v4 = strlen(s) - 1;
v5 = &s[v4];
if ( v4 > 0 )
{
do
{
if ( *v5 > 32 )
break;
--v5;
--v4;
}
while ( v4 );
}
if ( (int)v3 > v4 )
{
result = s;
*s = 0;
}
else
{
v6 = v4 - v3;
v7 = s;
do
{
v8 = v7[v3];
*v7++ = v8;
}
while ( &s[v6 + 1] != v7 );
result = s;
s[v6 + 1] = 0;
}
return result;
}

original_code:
char *
string_trim(char * string)
{
    int i, j, k, l;
    i = 0;
    while (string[i] <= ' ' && string[i] != '\0')
    {
        i++;
    }
    j = strlen(string) - 1;
    while (0 < j && string[j] <= ' ')
    {
        j--;
    }
    for (k = 0, l = i; l <= j; k++, l++)
    {
        string[k] = string[l];
    }
    string[k] = '\0';
    return string;
}

canonical_original_code:
char *string_trim(char *string)
{
    int i; int j; int k; int l;
    i = 0;
    while (string[i] <= ' ' && string[i] != '\0')
    {
        i++;
    }
    j = strlen(string) - 1;
    while (0 < j && string[j] <= ' ')
    {
        j--;
    }
    for (k = 0, l = i; l <= j; k++, l++)
    {
        string[k] = string[l];
    }
    string[k] = '\0';
    return string;
}

variable_types: j int

variable_types: k int

variable_types: l int

return_type: char *


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // eax
int v4; // ebp
size_t v5; // r15
double *v6; // r12
double *v7; // r13
double *v8; // r14
double *v9; // r15
__int64 v10; // rbx
double v11; // xmm0_8
double v12; // xmm1_8
__int64 v13; // rbx
double v14; // xmm0_8
double v15; // xmm1_8

if ( argc == 2 )
{
v3 = atoi(argv[1]);
v4 = v3;
if ( !v3 )
{
puts("Error in command line argument, should be a single nonzero integer.");
exit(1);
}
v5 = v3;
v6 = (double *)calloc(v3, 8uLL);
v7 = (double *)calloc(v5, 8uLL);
v8 = (double *)calloc(v5, 8uLL);
v9 = (double *)calloc(v5, 8uLL);
nullsub_1((unsigned int)v4, v6, v7, v8, v9);
printf(
"Type (%i, %i) best rational function approximant to matrix exponential.\n",
(unsigned int)v4,
(unsigned int)v4);
puts("poles: ");
if ( v4 <= 0 )
{
putchar(10);
puts("residuals: ");
goto LABEL_8;
}
}
else
{
v4 = 10;
v6 = (double *)calloc(0xAuLL, 8uLL);
v7 = (double *)calloc(0xAuLL, 8uLL);
v8 = (double *)calloc(0xAuLL, 8uLL);
v9 = (double *)calloc(0xAuLL, 8uLL);
nullsub_1(10LL, v6, v7, v8, v9);
printf("Type (%i, %i) best rational function approximant to matrix exponential.\n", 10LL, 10LL);
puts("poles: ");
}
v10 = 0LL;
do
{
v11 = v6[v10];
v12 = v7[v10++];
printf("%.15e + %.15e i\n", v11, v12);
}
while ( v4 > (int)v10 );
v13 = 0LL;
putchar(10);
puts("residuals: ");
do
{
v14 = v8[v13];
v15 = v9[v13++];
printf("%.15e + %.15e i\n", v14, v15);
}
while ( v4 > (int)v13 );
LABEL_8:
putchar(10);
free(v6);
free(v7);
free(v8);
free(v9);
return 0;
}

original_code:
int main (int argc, char *argv[]) {
 int n = 10;
 if (argc == 2) {
  n = atoi (argv[1]);
  if (n == 0) {
   printf ("Error in command line argument, should be a single nonzero integer.\n");
   exit (1);
  }
 }
 double *poles_r = (double*) calloc (n, sizeof(double));
 double *poles_i = (double*) calloc (n, sizeof(double));
 double *res_r = (double*) calloc (n, sizeof(double));
 double *res_i = (double*) calloc (n, sizeof(double));
 cf ( n, poles_r, poles_i, res_r, res_i );
 printf("Type (%i, %i) best rational function approximant to matrix exponential.\n", n, n);
 printf("poles: \n");
 for (int i = 0; i < n; ++i) {
  printf("%.15e + %.15e i\n", poles_r[i], poles_i[i]);
 }
 printf("\n");
 printf("residuals: \n");
 for (int i = 0; i < n; ++i) {
  printf("%.15e + %.15e i\n", res_r[i], res_i[i]);
 }
 printf("\n");
 free (poles_r);
 free (poles_i);
 free (res_r);
 free (res_i);
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[]) {
 int n = 10;
 if (argc == 2) {
  n = atoi (argv[1]);
  if (n == 0) {
   printf ("Error in command line argument, should be a single nonzero integer.\n");
   exit (1);
  }
 }
 double *poles_r = (double*) calloc (n, sizeof(double));
 double *poles_i = (double*) calloc (n, sizeof(double));
 double *res_r = (double*) calloc (n, sizeof(double));
 double *res_i = (double*) calloc (n, sizeof(double));
 cf ( n, poles_r, poles_i, res_r, res_i );
 printf("Type (%i, %i) best rational function approximant to matrix exponential.\n", n, n);
 printf("poles: \n");
 for (int i = 0; i < n; ++i) {
  printf("%.15e + %.15e i\n", poles_r[i], poles_i[i]);
 }
 printf("\n");
 printf("residuals: \n");
 for (int i = 0; i < n; ++i) {
  printf("%.15e + %.15e i\n", res_r[i], res_i[i]);
 }
 printf("\n");
 free (poles_r);
 free (poles_i);
 free (res_r);
 free (res_i);
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: n int


SetSeed

decompiled_code:
// attributes: thunk
void SetSeed(unsigned int seed)
{
srand(seed);
}

canonical_decompiled_code:
void func0(unsigned int seed)
{
srand(seed);
}

original_code:
void SetSeed (int seed)
{
 srand(seed);
}

canonical_original_code:
void SetSeed(int seed)
{
 srand(seed);
}

variable_types: seed int


RandomNumber

decompiled_code:
__int64 __fastcall RandomNumber(int a1, int a2)
{
return (unsigned int)(rand() % (a2 - a1 + 1) + a1);
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1, int a2)
{
return (unsigned int)(rand() % (a2 - a1 + 1) + a1);
}

original_code:
int RandomNumber (int min, int max)
{
 return min + (rand() % ((max - min) + 1));
}

canonical_original_code:
int RandomNumber(int min, int max)
{
 return min + (rand() % ((max - min) + 1));
}

variable_types: min int

variable_types: max int


NURand

decompiled_code:
__int64 __fastcall NURand(unsigned int a1, int a2, int a3)
{
int v3; // er13
int v4; // er14
int v5; // er15
int v7; // ebp
int v9; // eax

if ( first_3 )
{
v5 = RandomNumber(0, 255);
v4 = RandomNumber(0, 1023);
v9 = RandomNumber(0, 0x1FFF);
first_3 = 0;
v3 = v9;
}
if ( a1 == 1023 )
{
v3 = v4;
}
else if ( a1 != 0x1FFF )
{
if ( a1 != 255 )
{
fprintf(stderr, "NURand: unexpected value (%d) of A used\n", a1);
abort();
}
v3 = v5;
}
v7 = RandomNumber(0, a1);
return (v3 + (v7 | (unsigned int)RandomNumber(a2, a3))) % (a3 - a2 + 1) + a2;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1, int a2, int a3)
{
int v3; // er13
int v4; // er14
int v5; // er15
int v7; // ebp
int v9; // eax

if ( first_3 )
{
v5 = func1(0, 255);
v4 = func1(0, 1023);
v9 = func1(0, 0x1FFF);
first_3 = 0;
v3 = v9;
}
if ( a1 == 1023 )
{
v3 = v4;
}
else if ( a1 != 0x1FFF )
{
if ( a1 != 255 )
{
fprintf(stderr, "NURand: unexpected value (%d) of A used\n", a1);
abort();
}
v3 = v5;
}
v7 = func1(0, a1);
return (v3 + (v7 | (unsigned int)func1(a2, a3))) % (a3 - a2 + 1) + a2;
}

original_code:
int NURand (unsigned A, unsigned x, unsigned y)
{
 static int first = 1;
 unsigned C, C_255, C_1023, C_8191;
 if (first) {
  C_255 = RandomNumber(0, 255);
  C_1023 = RandomNumber(0, 1023);
  C_8191 = RandomNumber(0, 8191);
  first = 0;
 }
 switch (A) {
 case 255: C = C_255; break;
 case 1023: C = C_1023; break;
 case 8191: C = C_8191; break;
 default:
  fprintf(stderr,
   "NURand: unexpected value (%d) of A used\n",
   A);
  abort();
 }
 return (int)
        (((RandomNumber(0, A) | RandomNumber(x, y)) + C) % (y-x+1)) + x;
}

canonical_original_code:
int NURand(unsigned int A, unsigned int x, unsigned int y)
{
 static int first = 1;
 unsigned int C; unsigned int C_255; unsigned int C_1023; unsigned int C_8191;
 if (first) {
  C_255 = RandomNumber(0, 255);
  C_1023 = RandomNumber(0, 1023);
  C_8191 = RandomNumber(0, 8191);
  first = 0;
 }
 switch (A) {
 case 255: C = C_255; break;
 case 1023: C = C_1023; break;
 case 8191: C = C_8191; break;
 default:
  fprintf(stderr,
   "NURand: unexpected value (%d) of A used\n",
   A);
  abort();
 }
 return (int)
        (((RandomNumber(0, A) | RandomNumber(x, y)) + C) % (y-x+1)) + x;
}

variable_types:
A
unsigned int

variable_types:
x
unsigned int

variable_types:
y
unsigned int

variable_types: first int

variable_types:
C
unsigned int


MakeAlphaString

decompiled_code:
__int64 __fastcall MakeAlphaString(int a1, int a2, _BYTE *a3)
{
int v4; // eax
unsigned int v5; // er12
__int64 v6; // rbp

v4 = RandomNumber(a1, a2);
v5 = v4;
if ( v4 > 0 )
{
v6 = (__int64)&a3[v4 - 1 + 1];
do
*a3++ = byte_32B0[(int)RandomNumber(0, 61)];
while ( a3 != (_BYTE *)v6 );
}
return v5;
}

original_code:
int MakeAlphaString (int x, int y, char str[])
{
 static char *alphanum = "0123456789"
           "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
           "abcdefghijklmnopqrstuvwxyz";
 int arrmax = 61;
 register int i, len;
 len = RandomNumber(x, y);
 for (i = 0; i < len; i++)
  str[i] = alphanum[RandomNumber(0, arrmax)];
 return len;
}

canonical_original_code:
int MakeAlphaString(int x, int y, char str[])
{
 static char *alphanum = "0123456789"
           "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
           "abcdefghijklmnopqrstuvwxyz";
 int arrmax = 61;
 register int i; register int len;
 len = RandomNumber(x, y);
 for (i = 0; i < len; i++)
  str[i] = alphanum[RandomNumber(0, arrmax)];
 return len;
}

variable_types: x int

variable_types: y int

variable_types:
str
char []

variable_types:
alphanum
char *

variable_types: arrmax int

variable_types: i int

variable_types: len int


MakeNumberString

decompiled_code:
__int64 __fastcall MakeNumberString(int a1, int a2, _BYTE *a3)
{
int v4; // eax
unsigned int v5; // er12
__int64 v6; // rbp

v4 = RandomNumber(a1, a2);
v5 = v4;
if ( v4 > 0 )
{
v6 = (__int64)&a3[v4 - 1 + 1];
do
*a3++ = byte_333B[(int)RandomNumber(0, 9)];
while ( a3 != (_BYTE *)v6 );
}
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func4(int a1, int a2, _BYTE *a3)
{
int v4; // eax
unsigned int v5; // er12
__int64 v6; // rbp

v4 = func1(a1, a2);
v5 = v4;
if ( v4 > 0 )
{
v6 = (__int64)&a3[v4 - 1 + 1];
do
*a3++ = byte_333B[(int)func1(0, 9)];
while ( a3 != (_BYTE *)v6 );
}
return v5;
}

original_code:
int MakeNumberString (int x, int y, char str[])
{
 static char *numeric = "0123456789";
 int arrmax = 9;
 register int i, len;
 len = RandomNumber(x, y);
 for (i = 0; i < len; i++)
  str[i] = numeric[RandomNumber(0, arrmax)];
 return len;
}

canonical_original_code:
int MakeNumberString(int x, int y, char str[])
{
 static char *numeric = "0123456789";
 int arrmax = 9;
 register int i; register int len;
 len = RandomNumber(x, y);
 for (i = 0; i < len; i++)
  str[i] = numeric[RandomNumber(0, arrmax)];
 return len;
}

variable_types:
numeric
char *


gettimestamp

decompiled_code:
size_t __fastcall gettimestamp(char *s, char *format, size_t maxsize)
{
struct tm *v4; // rax
size_t result; // rax
time_t timer; // [rsp+8h] [rbp-20h] BYREF

timer = time(0LL);
v4 = localtime(&timer);
result = strftime(s, maxsize, format, v4);
if ( !result )
{
fwrite("error writing timestamp to string\n", 1uLL, 0x22uLL, stderr);
abort();
}
return result;
}

canonical_decompiled_code:
size_t __fastcall func5(char *s, char *format, size_t maxsize)
{
struct tm *v4; // rax
size_t result; // rax
time_t timer; // [rsp+8h] [rbp-20h] BYREF

timer = time(0LL);
v4 = localtime(&timer);
result = strftime(s, maxsize, format, v4);
if ( !result )
{
fwrite("error writing timestamp to string\n", 1uLL, 0x22uLL, stderr);
abort();
}
return result;
}

original_code:
void gettimestamp (char str[], char *format, size_t len)
{
 time_t t;
 struct tm *datetime;
 t = time(((void *)0));
 datetime = localtime(&t);
 if ( !strftime(str, len, format, datetime) ) {
  fprintf(stderr, "error writing timestamp to string\n");
  abort();
 }
}

canonical_original_code:
void gettimestamp(char str[], char *format, unsigned long len)
{
 long t;
 struct tm *datetime;
 t = time(((void *)0));
 datetime = localtime(&t);
 if ( !strftime(str, len, format, datetime) ) {
  fprintf(stderr, "error writing timestamp to string\n");
  abort();
 }
}

variable_types:
format
char *

variable_types:
len
unsigned long

variable_types: t long

variable_types: struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long tm_gmtoff; char *tm_zone; } *


InitPermutation

decompiled_code:
__int64 InitPermutation()
{
__int64 v0; // rax
__int64 i; // rbx
int v2; // edx
__int64 result; // rax

v0 = 0LL;
perm_count = 0;
do
{
nums[v0] = v0 + 1;
++v0;
}
while ( v0 != 3000 );
for ( i = 1LL; i != 3000; ++i )
{
LODWORD(result) = RandomNumber(i, 2999);
v2 = dword_39C[i];
result = (int)result;
dword_39C[i] = nums[(int)result];
nums[(int)result] = v2;
}
return result;
}

canonical_decompiled_code:
__int64 func6()
{
__int64 v0; // rax
__int64 i; // rbx
int v2; // edx
__int64 result; // rax

v0 = 0LL;
perm_count = 0;
do
{
nums[v0] = v0 + 1;
++v0;
}
while ( v0 != 3000 );
for ( i = 1LL; i != 3000; ++i )
{
LODWORD(result) = func1(i, 2999);
v2 = dword_39C[i];
result = (int)result;
dword_39C[i] = nums[(int)result];
nums[(int)result] = v2;
}
return result;
}

original_code:
void InitPermutation (void)
{
 int *cur;
 int i,j;
 perm_count = 0;
 for (i = 0, cur = nums; i < 3000; i++, cur++) {
  *cur = i + 1;
 }
 for (i = 0; i < 3000 -1; i++) {
  j = (int)RandomNumber(i+1, 3000 -1);
  {int tmp; tmp=nums[i]; nums[i]=nums[j]; nums[j]=tmp;};
 }
}

canonical_original_code:
void InitPermutation()
{
 int *cur;
 int i; int j;
 perm_count = 0;
 for (i = 0, cur = nums; i < 3000; i++, cur++) {
  *cur = i + 1;
 }
 for (i = 0; i < 3000 -1; i++) {
  j = (int)RandomNumber(i+1, 3000 -1);
  {int tmp; tmp=nums[i]; nums[i]=nums[j]; nums[j]=tmp;};
 }
}

variable_types:
cur
int *

variable_types: j int

variable_types: tmp int


GetPermutation

decompiled_code:
__int64 GetPermutation()
{
if ( perm_count > 2999 )
{
fwrite("GetPermutation: past end of list!\n", 1uLL, 0x22uLL, stderr);
abort();
}
return (unsigned int)nums[perm_count++];
}

canonical_decompiled_code:
__int64 func7()
{
if ( perm_count > 2999 )
{
fwrite("GetPermutation: past end of list!\n", 1uLL, 0x22uLL, stderr);
abort();
}
return (unsigned int)nums[perm_count++];
}

original_code:
int GetPermutation (void)
{
 if ( perm_count >= 3000 ) {
  fprintf(stderr, "GetPermutation: past end of list!\n");
  abort();
 }
 return nums[perm_count++];
}

canonical_original_code:
int GetPermutation()
{
 if ( perm_count >= 3000 ) {
  fprintf(stderr, "GetPermutation: past end of list!\n");
  abort();
 }
 return nums[perm_count++];
}


decompiled_code:
void *hist_init()
{
memset(&cur_hist, 0, (size_t)&unk_61A80);
return memset(&total_hist, 0, (size_t)&unk_61A80);
}

canonical_decompiled_code:
void *func0()
{
memset(&cur_hist, 0, (size_t)&unk_61A80);
return memset(&total_hist, 0, (size_t)&unk_61A80);
}


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

LODWORD(result) = (int)(1000.0 * a2);
if ( (int)result > 19999 )
LODWORD(result) = 19999;
if ( a2 > *((double *)&cur_max_rt + a1) )
*((double *)&cur_max_rt + a1) = a2;
result = (int)result;
++cur_hist[20000 * a1 + (int)result];
return result;
}

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

LODWORD(result) = (int)(1000.0 * a2);
if ( (int)result > 19999 )
LODWORD(result) = 19999;
if ( a2 > *((double *)&cur_max_rt + a1) )
*((double *)&cur_max_rt + a1) = a2;
result = (int)result;
++cur_hist[20000 * a1 + (int)result];
return result;
}

original_code:
void hist_inc( int transaction, double rtclk )
{
  int i;
  i = ( rtclk * (double)1000 );
  if(i >= (20 * 1000)){
    i = (20 * 1000) - 1;
  }
  if (rtclk > cur_max_rt[transaction]) cur_max_rt[transaction] = rtclk;
  ++cur_hist[transaction][i];
}

canonical_original_code:
void hist_inc(int transaction, double rtclk)
{
  int i;
  i = ( rtclk * (double)1000 );
  if(i >= (20 * 1000)){
    i = (20 * 1000) - 1;
  }
  if (rtclk > cur_max_rt[transaction]) cur_max_rt[transaction] = rtclk;
  ++cur_hist[transaction][i];
}

variable_types: transaction int

variable_types: rtclk double


original_code:
double hist_ckp( int transaction )
{
  int i;
  int total,tmp,line,line_set;
  total = tmp = line_set = 0;
  line = 20 * 1000;
  for( i=0; i<(20 * 1000); i++){
    total += cur_hist[transaction][i];
  }
  for( i=0; i<(20 * 1000); i++){
    tmp += cur_hist[transaction][i];
    total_hist[transaction][i] += cur_hist[transaction][i];
    cur_hist[transaction][i] = 0;
    if (( tmp >= (total*99/100) ) && (line_set ==0)){
      line = i;
      line_set=1;
    }
  }
  return ( (double)(line)/(double)(1000) );
}

canonical_original_code:
double hist_ckp(int transaction)
{
  int i;
  int total; int tmp; int line; int line_set;
  total = tmp = line_set = 0;
  line = 20 * 1000;
  for( i=0; i<(20 * 1000); i++){
    total += cur_hist[transaction][i];
  }
  for( i=0; i<(20 * 1000); i++){
    tmp += cur_hist[transaction][i];
    total_hist[transaction][i] += cur_hist[transaction][i];
    cur_hist[transaction][i] = 0;
    if (( tmp >= (total*99/100) ) && (line_set ==0)){
      line = i;
      line_set=1;
    }
  }
  return ( (double)(line)/(double)(1000) );
}

variable_types: total int

variable_types: line int

return_type: double


original_code:
void hist_report()
{
  int i,j;
  int total[5],tmp[5],line[5];
  for( j=0; j<5; j++){
    total[j] = tmp[j] = 0;
    line[j] = 20 * 1000;
    for( i=0; i<(20 * 1000); i++){
      total[j] += total_hist[j][i];
    }
    for( i=(20 * 1000)-1; i >= 0 ; i--){
      tmp[j] += total_hist[j][i];
      if( (tmp[j] * 10) <= total[j] ){
 line[j] = i;
      }
    }
  }
  printf("\n<RT Histogram>\n");
  for( j=0; j<5; j++){
    switch(j){
    case 0:
      printf("\n1.New-Order\n\n");
      break;
    case 1:
      printf("\n2.Payment\n\n");
      break;
    case 2:
      printf("\n3.Order-Status\n\n");
      break;
    case 3:
      printf("\n4.Delivery\n\n");
      break;
    case 4:
      printf("\n5.Stock-Level\n\n");
    }
    for( i=0; (i<(20 * 1000))&&(i <= line[j]*4); i++){
      printf("%3.2f, %6d\n",(double)(i+1)/(double)(1000),total_hist[j][i]);
    }
    printf("\n");
  }
  printf("\n<90th Percentile RT (MaxRT)>\n");
  for( j=0; j<5; j++){
    switch(j){
    case 0:
      printf("   New-Order : ");
      break;
    case 1:
      printf("     Payment : ");
      break;
    case 2:
      printf("Order-Status : ");
      break;
    case 3:
      printf("    Delivery : ");
      break;
    case 4:
      printf(" Stock-Level : ");
    }
    printf("%3.2f  (%.2f)\n",(double)(line[j])/(double)(1000),max_rt[j]);
  }
}

canonical_original_code:
void hist_report()
{
  int i; int j;
  int total[5]; int tmp[5]; int line[5];
  for( j=0; j<5; j++){
    total[j] = tmp[j] = 0;
    line[j] = 20 * 1000;
    for( i=0; i<(20 * 1000); i++){
      total[j] += total_hist[j][i];
    }
    for( i=(20 * 1000)-1; i >= 0 ; i--){
      tmp[j] += total_hist[j][i];
      if( (tmp[j] * 10) <= total[j] ){
 line[j] = i;
      }
    }
  }
  printf("\n<RT Histogram>\n");
  for( j=0; j<5; j++){
    switch(j){
    case 0:
      printf("\n1.New-Order\n\n");
      break;
    case 1:
      printf("\n2.Payment\n\n");
      break;
    case 2:
      printf("\n3.Order-Status\n\n");
      break;
    case 3:
      printf("\n4.Delivery\n\n");
      break;
    case 4:
      printf("\n5.Stock-Level\n\n");
    }
    for( i=0; (i<(20 * 1000))&&(i <= line[j]*4); i++){
      printf("%3.2f, %6d\n",(double)(i+1)/(double)(1000),total_hist[j][i]);
    }
    printf("\n");
  }
  printf("\n<90th Percentile RT (MaxRT)>\n");
  for( j=0; j<5; j++){
    switch(j){
    case 0:
      printf("   New-Order : ");
      break;
    case 1:
      printf("     Payment : ");
      break;
    case 2:
      printf("Order-Status : ");
      break;
    case 3:
      printf("    Delivery : ");
      break;
    case 4:
      printf(" Stock-Level : ");
    }
    printf("%3.2f  (%.2f)\n",(double)(line[j])/(double)(1000),max_rt[j]);
  }
}

variable_types:
total
int [5]

variable_types:
tmp
int [5]

variable_types:
line
int [5]


shuffle

canonical_original_code:
static void shuffle()
{
  int i; int j; int rnd; int tmp;
  for( i=0, j=0; i < no ; i++, j++ ){
    seq[j]=0;
  }
  for( i=0; i < py ; i++, j++){
    seq[j]=1;
  }
  for( i=0; i < os ; i++, j++){
    seq[j]=2;
  }
  for( i=0; i < dl ; i++, j++){
    seq[j]=3;
  }
  for( i=0; i < sl ; i++, j++){
    seq[j]=4;
  }
  for( i=0, j = total - 1; j>0; i++, j--){
    rnd = rand()%(j+1);
    tmp = seq[rnd+i];
    seq[rnd+i] = seq[i];
    seq[i] = tmp;
  }
}

variable_types: i int

variable_types: rnd int


decompiled_code:
void __fastcall seq_init(int a1, int a2, int a3, int a4, int a5)
{
pthread_mutex_init(&mutex, 0LL);
no = a1;
py = a2;
os = a3;
dword_2B0 = a4;
total = a5 + a4 + a3 + a1 + a2;
sl = a5;
seq = malloc(4LL * total);
shuffle();
next_num = 0;
}

canonical_decompiled_code:
void __fastcall func1(int a1, int a2, int a3, int a4, int a5)
{
pthread_mutex_init(&mutex, 0LL);
no = a1;
py = a2;
os = a3;
dword_2B0 = a4;
total = a5 + a4 + a3 + a1 + a2;
sl = a5;
seq = malloc(4LL * total);
func0();
next_num = 0;
}

original_code:
void seq_init( int n, int p, int o, int d, int s )
{
  pthread_mutex_init( &mutex, ((void *)0) );
  no = n;
  py = p;
  os = o;
  dl = d;
  sl = s;
  total = n + p + o + d + s;
  seq = malloc( sizeof(int) * total );
  shuffle();
  next_num = 0;
}

canonical_original_code:
void seq_init(int n, int p, int o, int d, int s)
{
  pthread_mutex_init( &mutex, ((void *)0) );
  no = n;
  py = p;
  os = o;
  dl = d;
  sl = s;
  total = n + p + o + d + s;
  seq = malloc( sizeof(int) * total );
  shuffle();
  next_num = 0;
}

variable_types: n int

variable_types: p int

variable_types: o int

variable_types: d int

variable_types: s int


decompiled_code:
__int64 seq_get()
{
int v0; // eax
__int64 v1; // rdx
unsigned int v2; // er12

pthread_mutex_lock(&mutex);
if ( next_num >= total )
{
shuffle();
v0 = 1;
v1 = 0LL;
}
else
{
v0 = next_num + 1;
v1 = 4LL * next_num;
}
next_num = v0;
v2 = *(_DWORD *)((char *)seq + v1);
pthread_mutex_unlock(&mutex);
return v2;
}

canonical_decompiled_code:
__int64 func2()
{
int v0; // eax
__int64 v1; // rdx
unsigned int v2; // er12

pthread_mutex_lock(&mutex);
if ( next_num >= total )
{
func0();
v0 = 1;
v1 = 0LL;
}
else
{
v0 = next_num + 1;
v1 = 4LL * next_num;
}
next_num = v0;
v2 = *(_DWORD *)((char *)seq + v1);
pthread_mutex_unlock(&mutex);
return v2;
}

original_code:
int seq_get()
{
  int retval;
  pthread_mutex_lock( &mutex );
  if(next_num >= total){
    shuffle();
    next_num = 0;
  }
  retval = seq[next_num];
  ++next_num;
  pthread_mutex_unlock( &mutex );
  return(retval);
}

variable_types: retval int


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

result = a1;
if ( num_ware != 1 )
{
do
result = RandomNumber(1LL);
while ( (_DWORD)result == a1 );
}
return result;
}

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

result = a1;
if ( num_ware != 1 )
{
do
result = RandomNumber(1LL);
while ( (_DWORD)result == a1 );
}
return result;
}

original_code:
static int other_ware (int home_ware)
{
    int tmp;
    if (num_ware == 1) return home_ware;
    while ((tmp = RandomNumber(1, num_ware)) == home_ware);
    return tmp;
}

canonical_original_code:
static int other_ware(int home_ware)
{
    int tmp;
    if (num_ware == 1) return home_ware;
    while ((tmp = RandomNumber(1, num_ware)) == home_ware);
    return tmp;
}


driver

decompiled_code:
__int64 __fastcall driver(unsigned int a1)
{
if ( !activate_transaction )
return 0LL;
do
{
switch ( (unsigned int)seq_get() )
{
case 0u:
do_neword_isra_0(a1);
break;
case 1u:
do_payment_isra_0(a1);
break;
case 2u:
do_ordstat_isra_0(a1);
break;
case 3u:
do_delivery_isra_0(a1);
break;
case 4u:
do_slev_isra_0(a1);
break;
default:
puts("Error - Unknown sequence.");
break;
}
}
while ( activate_transaction );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned int a1)
{
if ( !activate_transaction )
return 0LL;
do
{
switch ( (unsigned int)seq_get() )
{
case 0u:
func5(a1);
break;
case 1u:
func4(a1);
break;
case 2u:
func3(a1);
break;
case 3u:
func2(a1);
break;
case 4u:
func1(a1);
break;
default:
puts("Error - Unknown sequence.");
break;
}
}
while ( activate_transaction );
return 0LL;
}

original_code:
int driver (int t_num)
{
    int i, j;
    while( activate_transaction ){
      switch(seq_get()){
      case 0:
 do_neword(t_num);
 break;
      case 1:
 do_payment(t_num);
 break;
      case 2:
 do_ordstat(t_num);
 break;
      case 3:
 do_delivery(t_num);
 break;
      case 4:
 do_slev(t_num);
 break;
      default:
 printf("Error - Unknown sequence.\n");
      }
    }
    return(0);
}

canonical_original_code:
int driver(int t_num)
{
    int i; int j;
    while( activate_transaction ){
      switch(seq_get()){
      case 0:
 do_neword(t_num);
 break;
      case 1:
 do_payment(t_num);
 break;
      case 2:
 do_ordstat(t_num);
 break;
      case 3:
 do_delivery(t_num);
 break;
      case 4:
 do_slev(t_num);
 break;
      default:
 printf("Error - Unknown sequence.\n");
      }
    }
    return(0);
}

variable_types: j int


main

repo: kyoto/sendkeys

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
bool v3; // cf
bool v4; // zf
int v7; // er15
__int64 v8; // rcx
const char *v9; // rdi
__int64 v10; // rdx
const char *v11; // rsi
char v12; // al
bool v13; // cf
bool v14; // zf
__int64 v15; // rcx
char v16; // al
bool v17; // cf
bool v18; // zf
int v19; // er15
const char *v20; // rdi
Display *v21; // rax
int v22; // ebx
__int64 v24; // rcx
char *i; // rbp
int v26; // eax
char *v27; // rax
int v28; // [rsp+8h] [rbp-50h]
int v29[15]; // [rsp+1Ch] [rbp-3Ch] BYREF

progname = (__int64)*argv;
v3 = argc == 0;
v4 = argc == 1;
if ( argc > 1 )
{
v28 = 1;
v7 = 1;
while ( 1 )
{
v8 = 9LL;
v9 = "-display";
v10 = v7;
v11 = argv[v10];
do
{
if ( !v8 )
break;
v3 = *v11 < (unsigned int)*v9;
v4 = *v11++ == *v9++;
--v8;
}
while ( v4 );
v12 = (!v3 && !v4) - v3;
v13 = 0;
v14 = v12 == 0;
if ( !v12 )
break;
v9 = "-count";
v15 = 7LL;
v11 = argv[v7];
do
{
if ( !v15 )
break;
v13 = *v11 < (unsigned int)*v9;
v14 = *v11++ == *v9++;
--v15;
}
while ( v14 );
v16 = (!v13 && !v14) - v13;
v17 = 0;
v18 = v16 == 0;
if ( v16 )
{
v9 = "-window";
v24 = 8LL;
v11 = argv[v7];
do
{
if ( !v24 )
break;
v17 = *v11 < (unsigned int)*v9;
v18 = *v11++ == *v9++;
--v24;
}
while ( v18 );
if ( (!v17 && !v18) == v17 )
{
if ( argc == ++v7 )
goto LABEL_51;
if ( !strcmp(argv[v10 + 1], "root") )
window = -1LL;
else
window = strtoul(argv[v10 + 1], 0LL, 0);
}
else
{
if ( *argv[v7] == 45 )
{
v11 = "%s: bad option `%s'.\n";
v9 = (const char *)stderr;
fprintf(stderr, "%s: bad option `%s'.\n", (const char *)progname, argv[v7]);
LABEL_51:
usage(v9, v11, v10 * 8);
}
strncpy(&keyname, argv[v7], 0x3FFuLL);
keysym = 0;
shift = 0;
for ( i = strtok(&keyname, "+"); i; i = strtok(0LL, "+") )
{
if ( !strcmp(i, "Alt") )
{
LABEL_36:
shift |= 8u;
}
else if ( !strcmp(i, "Control") )
{
LABEL_40:
shift |= 4u;
}
else if ( !strcmp(i, "Shift") )
{
LABEL_42:
shift |= 1u;
}
else
{
v26 = XStringToKeysym(i);
if ( !v26 )
{
fprintf(stderr, "unknown: %s\n", i);
((void (*)(void))usage)();
}
switch ( v26 )
{
case 65505:
case 65506:
goto LABEL_42;
case 65507:
case 65508:
goto LABEL_40;
case 65509:
case 65510:
shift |= 2u;
break;
case 65511:
case 65512:
case 65513:
case 65514:
goto LABEL_36;
case 65515:
case 65516:
case 65517:
case 65518:
continue;
default:
keysym = v26;
break;
}
}
}
}
LABEL_5:
v3 = argc < (unsigned int)++v7;
v4 = argc == v7;
if ( argc <= v7 )
goto LABEL_16;
}
else
{
v19 = v7 + 1;
if ( argc == v19 )
goto LABEL_51;
v7 = v19 + 1;
v28 = strtoul(argv[v10 + 1], 0LL, 0);
v3 = argc < (unsigned int)v7;
v4 = argc == v7;
if ( argc <= v7 )
goto LABEL_16;
}
}
if ( argc == ++v7 )
goto LABEL_51;
displayname = (char *)argv[v10 + 1];
goto LABEL_5;
}
v28 = 1;
LABEL_16:
if ( !keyname )
{
fprintf(stderr, "%s: you must specify a keyname.\n", (const char *)progname);
exit(1);
}
v20 = displayname;
if ( !displayname )
{
v27 = getenv("DISPLAY");
v20 = v27;
if ( v27 )
{
displayname = v27;
}
else
{
displayname = ":0.0";
v20 = ":0.0";
}
}
v21 = XOpenDisplay(v20);
display = v21;
if ( !v21 )
{
fprintf(stderr, "%s: can't open display `%s'.\n", (const char *)progname, displayname);
exit(1);
}
if ( !window )
XGetInputFocus(v21, &window, v29);
if ( window == -1LL )
window = display->screens->root;
v22 = 0;
if ( v28 > 0 )
{
do
{
++v22;
SendKeyPressedEvent(keysym);
}
while ( v22 != v28 );
}
XCloseDisplay(display);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
bool v3; // cf
bool v4; // zf
int v7; // er15
__int64 v8; // rcx
const char *v9; // rdi
__int64 v10; // rdx
const char *v11; // rsi
char v12; // al
bool v13; // cf
bool v14; // zf
__int64 v15; // rcx
char v16; // al
bool v17; // cf
bool v18; // zf
int v19; // er15
const char *v20; // rdi
Display *v21; // rax
int v22; // ebx
__int64 v24; // rcx
char *i; // rbp
int v26; // eax
char *v27; // rax
int v28; // [rsp+8h] [rbp-50h]
int v29[15]; // [rsp+1Ch] [rbp-3Ch] BYREF

progname = (__int64)*argv;
v3 = argc == 0;
v4 = argc == 1;
if ( argc > 1 )
{
v28 = 1;
v7 = 1;
while ( 1 )
{
v8 = 9LL;
v9 = "-display";
v10 = v7;
v11 = argv[v10];
do
{
if ( !v8 )
break;
v3 = *v11 < (unsigned int)*v9;
v4 = *v11++ == *v9++;
--v8;
}
while ( v4 );
v12 = (!v3 && !v4) - v3;
v13 = 0;
v14 = v12 == 0;
if ( !v12 )
break;
v9 = "-count";
v15 = 7LL;
v11 = argv[v7];
do
{
if ( !v15 )
break;
v13 = *v11 < (unsigned int)*v9;
v14 = *v11++ == *v9++;
--v15;
}
while ( v14 );
v16 = (!v13 && !v14) - v13;
v17 = 0;
v18 = v16 == 0;
if ( v16 )
{
v9 = "-window";
v24 = 8LL;
v11 = argv[v7];
do
{
if ( !v24 )
break;
v17 = *v11 < (unsigned int)*v9;
v18 = *v11++ == *v9++;
--v24;
}
while ( v18 );
if ( (!v17 && !v18) == v17 )
{
if ( argc == ++v7 )
goto LABEL_51;
if ( !strcmp(argv[v10 + 1], "root") )
window = -1LL;
else
window = strtoul(argv[v10 + 1], 0LL, 0);
}
else
{
if ( *argv[v7] == 45 )
{
v11 = "%s: bad option `%s'.\n";
v9 = (const char *)stderr;
fprintf(stderr, "%s: bad option `%s'.\n", (const char *)progname, argv[v7]);
LABEL_51:
func10(v9, v11, v10 * 8);
}
strncpy(&keyname, argv[v7], 0x3FFuLL);
keysym = 0;
shift = 0;
for ( i = strtok(&keyname, "+"); i; i = strtok(0LL, "+") )
{
if ( !strcmp(i, "Alt") )
{
LABEL_36:
shift |= 8u;
}
else if ( !strcmp(i, "Control") )
{
LABEL_40:
shift |= 4u;
}
else if ( !strcmp(i, "Shift") )
{
LABEL_42:
shift |= 1u;
}
else
{
v26 = XStringToKeysym(i);
if ( !v26 )
{
fprintf(stderr, "unknown: %s\n", i);
((void (*)(void))usage)();
}
switch ( v26 )
{
case 65505:
case 65506:
goto LABEL_42;
case 65507:
case 65508:
goto LABEL_40;
case 65509:
case 65510:
shift |= 2u;
break;
case 65511:
case 65512:
case 65513:
case 65514:
goto LABEL_36;
case 65515:
case 65516:
case 65517:
case 65518:
continue;
default:
keysym = v26;
break;
}
}
}
}
LABEL_5:
v3 = argc < (unsigned int)++v7;
v4 = argc == v7;
if ( argc <= v7 )
goto LABEL_16;
}
else
{
v19 = v7 + 1;
if ( argc == v19 )
goto LABEL_51;
v7 = v19 + 1;
v28 = strtoul(argv[v10 + 1], 0LL, 0);
v3 = argc < (unsigned int)v7;
v4 = argc == v7;
if ( argc <= v7 )
goto LABEL_16;
}
}
if ( argc == ++v7 )
goto LABEL_51;
displayname = (char *)argv[v10 + 1];
goto LABEL_5;
}
v28 = 1;
LABEL_16:
if ( !keyname )
{
fprintf(stderr, "%s: you must specify a keyname.\n", (const char *)progname);
exit(1);
}
v20 = displayname;
if ( !displayname )
{
v27 = getenv("DISPLAY");
v20 = v27;
if ( v27 )
{
displayname = v27;
}
else
{
displayname = ":0.0";
v20 = ":0.0";
}
}
v21 = XOpenDisplay(v20);
display = v21;
if ( !v21 )
{
fprintf(stderr, "%s: can't open display `%s'.\n", (const char *)progname, displayname);
exit(1);
}
if ( !window )
XGetInputFocus(v21, &window, v29);
if ( window == -1LL )
window = display->screens->root;
v22 = 0;
if ( v28 > 0 )
{
do
{
++v22;
func9(keysym);
}
while ( v22 != v28 );
}
XCloseDisplay(display);
return 0;
}

original_code:
int main(int argc, char **argv)
{
    int ii, Junk;
    int c;
    char *temp;
    unsigned long count = 1;
    progname = argv[0];
    for(ii=1; ii<argc; ii++) {
        if(strcmp(argv[ii], "-display") == 0) {
            if(++ii == argc)
                usage();
            displayname = argv[ii];
        }
        else if(strcmp(argv[ii], "-count") == 0) {
            if(++ii == argc)
                usage();
            count = strtoul(argv[ii],((void *)0),0);
        }
        else if(strcmp(argv[ii], "-window") == 0) {
            if(++ii == argc)
                usage();
            if(strcmp(argv[ii], "root") == 0)
                window = (Window)-1;
            else
                window = (Window)strtoul(argv[ii], ((void *)0), 0);
        }
        else if(argv[ii][0] == '-') {
            fprintf(stderr, "%s: bad option `%s'.\n",
                progname, argv[ii]);
            usage();
        }
        else {
            strncpy(keyname, argv[ii], 1023);
            keysym = 0;
            shift = 0;
            temp = strtok((char *)keyname, "+");
            while (temp != ((void *)0)) {
                if (strcmp(temp, "Alt") == 0)
                    c = 0xffe9;
                else if (strcmp(temp, "Control") == 0)
                    c = 0xffe3;
                else if (strcmp(temp, "Shift") == 0)
                    c = 0xffe1;
                else
                    c = XStringToKeysym(temp);
                if (c == 0) {
                    fprintf(stderr, "unknown: %s\n", temp);
                    usage();
                }
                switch (c) {
                    case 0xffe1:
                    case 0xffe2:
                        shift |= (1<<0);
                        break;
                    case 0xffe3:
                    case 0xffe4:
                        shift |= (1<<2);
                        break;
                    case 0xffe5:
                    case 0xffe6:
                        shift |= (1<<1);
                        break;
                    case 0xffe7:
                    case 0xffe8:
                    case 0xffe9:
                    case 0xffea:
                        shift |= (1<<3);
                        break;
                    case 0xffeb:
                    case 0xffec:
                    case 0xffed:
                    case 0xffee:
                        break;
                    default:
                        keysym = c;
                }
                temp = strtok(((void *)0), "+");
            }
        }
    }
    if (keyname[0] == 0) {
        fprintf(stderr, "%s: you must specify a keyname.\n", progname);
        exit(1);
    }
    if(displayname == ((void *)0))
 displayname = getenv("DISPLAY");
    if(displayname == ((void *)0))
 displayname = ":0.0";
    display = XOpenDisplay(displayname);
    if(display == ((void *)0))
    {
 fprintf(stderr, "%s: can't open display `%s'.\n",
  progname, displayname);
 exit(1);
    }
    if(window == 0)
        XGetInputFocus(display, &window, &Junk);
    if(window == (Window)-1)
    {
        window = ((&((_XPrivDisplay)(display))->screens[0])->root);
    }
    for (ii=0;ii<(int)count;ii++)
      SendKeyPressedEvent(keysym, shift);
    XCloseDisplay(display);
    return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
    int ii; int Junk;
    int c;
    char *temp;
    unsigned long count = 1;
    progname = argv[0];
    for(ii=1; ii<argc; ii++) {
        if(strcmp(argv[ii], "-display") == 0) {
            if(++ii == argc)
                usage();
            displayname = argv[ii];
        }
        else if(strcmp(argv[ii], "-count") == 0) {
            if(++ii == argc)
                usage();
            count = strtoul(argv[ii],((void *)0),0);
        }
        else if(strcmp(argv[ii], "-window") == 0) {
            if(++ii == argc)
                usage();
            if(strcmp(argv[ii], "root") == 0)
                window = (Window)-1;
            else
                window = (unsigned long)strtoul(argv[ii], ((void *)0), 0);
        }
        else if(argv[ii][0] == '-') {
            fprintf(stderr, "%s: bad option `%s'.\n",
                progname, argv[ii]);
            usage();
        }
        else {
            strncpy(keyname, argv[ii], 1023);
            keysym = 0;
            shift = 0;
            temp = strtok((char *)keyname, "+");
            while (temp != ((void *)0)) {
                if (strcmp(temp, "Alt") == 0)
                    c = 0xffe9;
                else if (strcmp(temp, "Control") == 0)
                    c = 0xffe3;
                else if (strcmp(temp, "Shift") == 0)
                    c = 0xffe1;
                else
                    c = XStringToKeysym(temp);
                if (c == 0) {
                    fprintf(stderr, "unknown: %s\n", temp);
                    usage();
                }
                switch (c) {
                    case 0xffe1:
                    case 0xffe2:
                        shift |= (1<<0);
                        break;
                    case 0xffe3:
                    case 0xffe4:
                        shift |= (1<<2);
                        break;
                    case 0xffe5:
                    case 0xffe6:
                        shift |= (1<<1);
                        break;
                    case 0xffe7:
                    case 0xffe8:
                    case 0xffe9:
                    case 0xffea:
                        shift |= (1<<3);
                        break;
                    case 0xffeb:
                    case 0xffec:
                    case 0xffed:
                    case 0xffee:
                        break;
                    default:
                        keysym = c;
                }
                temp = strtok(((void *)0), "+");
            }
        }
    }
    if (keyname[0] == 0) {
        fprintf(stderr, "%s: you must specify a keyname.\n", progname);
        exit(1);
    }
    if(displayname == ((void *)0))
 displayname = getenv("DISPLAY");
    if(displayname == ((void *)0))
 displayname = ":0.0";
    display = XOpenDisplay(displayname);
    if(display == ((void *)0))
    {
 fprintf(stderr, "%s: can't open display `%s'.\n",
  progname, displayname);
 exit(1);
    }
    if(window == 0)
        XGetInputFocus(display, &window, &Junk);
    if(window == (Window)-1)
    {
        window = ((&((_XPrivDisplay)(display))->screens[0])->root);
    }
    for (ii=0;ii<(int)count;ii++)
      SendKeyPressedEvent(keysym, shift);
    XCloseDisplay(display);
    return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: ii int

variable_types: Junk int

variable_types: c int

variable_types:
temp
char *

variable_types:
count
unsigned long


usage

decompiled_code:
void __noreturn usage()
{
fprintf(
stderr,
"usage: %s [-window <id>|root]\n"
" [-count <count>]\n"
" [-display <name>] [Modifier+[Modifier+]]Key\n"
"(looks up keysyms in <X11/keysymdef.h>)\n"
"'Alt', 'Control', 'Shift' are replaced by\n"
"'Alt_L', 'Control_L', 'Shift_L'...\n"
" example:\n"
" %s Control+Alt+Right\n",
(const char *)progname,
(const char *)progname);
exit(1);
}

canonical_decompiled_code:
void __noreturn func10()
{
fprintf(
stderr,
"usage: %s [-window <id>|root]\n"
" [-count <count>]\n"
" [-display <name>] [Modifier+[Modifier+]]Key\n"
"(looks up keysyms in <X11/keysymdef.h>)\n"
"'Alt', 'Control', 'Shift' are replaced by\n"
"'Alt_L', 'Control_L', 'Shift_L'...\n"
" example:\n"
" %s Control+Alt+Right\n",
(const char *)progname,
(const char *)progname);
exit(1);
}

original_code:
void usage()
{
    fprintf(stderr,
        "usage: %s [-window <id>|root]\n"
        "            [-count <count>]\n"
        "            [-display <name>] [Modifier+[Modifier+]]Key\n"
        "(looks up keysyms in <X11/keysymdef.h>)\n"
        "'Alt',   'Control',   'Shift' are replaced by\n"
        "'Alt_L', 'Control_L', 'Shift_L'...\n"
        "  example:\n"
        "     %s Control+Alt+Right\n", progname, progname);
    exit(1);
}


repo: kyuba/curie

original_code:
sexpr sx_set_add (sexpr set, sexpr item)
{
    sexpr c = set;
    while ((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)c))->type == sxt_cons)))
    {
        if (((sexpr)(equalp (((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)c))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)c))->car) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5))), item)) == ((sexpr)((((int_pointer)(3)) << 3) | 0x5))))
        {
            return set;
        }
        c = ((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)c))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)c))->cdr) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
    }
    return cons (item, set);
}

canonical_original_code:
unsigned long sx_set_add(unsigned long set, unsigned long item)
{
    unsigned long c = set;
    while ((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)c))->type == sxt_cons)))
    {
        if (((sexpr)(equalp (((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)c))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)c))->car) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5))), item)) == ((sexpr)((((int_pointer)(3)) << 3) | 0x5))))
        {
            return set;
        }
        c = ((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)c))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)c))->cdr) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
    }
    return cons (item, set);
}

variable_types:
set
unsigned long

variable_types:
item
unsigned long

variable_types:
c
unsigned long

return_type: unsigned long

user_defined_types: struct sexpr_cons { enum sx_type type; unsigned long car; unsigned long cdr; }

user_defined_types: enum sx_type { sxt_string=4, sxt_symbol=5, sxt_cons=6, sxt_rational=20 }


original_code:
sexpr sx_set_remove (sexpr set, sexpr item)
{
    sexpr rv = ((sexpr)((((int_pointer)(5)) << 3) | 0x5)), c = set, t;
    while ((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)c))->type == sxt_cons)))
    {
        t = ((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)c))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)c))->car) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
        if (((sexpr)(equalp (t, item)) == ((sexpr)((((int_pointer)(2)) << 3) | 0x5))))
        {
            rv = cons (t, rv);
        }
        c = ((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)c))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)c))->cdr) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
    }
    return rv;
}

canonical_original_code:
unsigned long sx_set_remove(unsigned long set, unsigned long item)
{
    unsigned long rv = ((sexpr)((((int_pointer)(5)) << 3) | 0x5)); unsigned long c = set; unsigned long t;
    while ((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)c))->type == sxt_cons)))
    {
        t = ((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)c))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)c))->car) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
        if (((sexpr)(equalp (t, item)) == ((sexpr)((((int_pointer)(2)) << 3) | 0x5))))
        {
            rv = cons (t, rv);
        }
        c = ((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)c))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)c))->cdr) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
    }
    return rv;
}

variable_types:
rv
unsigned long

variable_types:
t
unsigned long


original_code:
sexpr sx_set_merge (sexpr a, sexpr b)
{
    sexpr c, t;
    while ((((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)b))->type == sxt_cons)))
    {
        t = ((((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)b))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)b))->car) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
        c = a;
        while ((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)c))->type == sxt_cons)))
        {
            if (((sexpr)(equalp (((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)c))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)c))->car) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5))), t)) == ((sexpr)((((int_pointer)(3)) << 3) | 0x5))))
            {
                goto next;
            }
            c = ((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)c))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)c))->cdr) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
        }
        a = cons (t, a);
      next:
        b = ((((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)b))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)b))->cdr) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
    }
    return a;
}

canonical_original_code:
unsigned long sx_set_merge(unsigned long a, unsigned long b)
{
    unsigned long c; unsigned long t;
    while ((((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)b))->type == sxt_cons)))
    {
        t = ((((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)b))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)b))->car) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
        c = a;
        while ((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)c))->type == sxt_cons)))
        {
            if (((sexpr)(equalp (((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)c))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)c))->car) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5))), t)) == ((sexpr)((((int_pointer)(3)) << 3) | 0x5))))
            {
                goto next;
            }
            c = ((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)c))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)c))->cdr) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
        }
        a = cons (t, a);
      next:
        b = ((((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)b))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)b))->cdr) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
    }
    return a;
}

variable_types:
a
unsigned long

variable_types:
b
unsigned long


original_code:
sexpr sx_set_intersect (sexpr a, sexpr b)
{
    sexpr rv = ((sexpr)((((int_pointer)(5)) << 3) | 0x5)), c, t;
    while ((((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)b))->type == sxt_cons)))
    {
        t = ((((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)b))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)b))->car) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
        c = a;
        while ((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)c))->type == sxt_cons)))
        {
            if (((sexpr)(equalp (((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)c))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)c))->car) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5))), t)) == ((sexpr)((((int_pointer)(3)) << 3) | 0x5))))
            {
                rv = cons (t, rv);
                goto next;
            }
            c = ((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)c))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)c))->cdr) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
        }
      next:
        b = ((((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)b))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)b))->cdr) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
    }
    return rv;
}

canonical_original_code:
unsigned long sx_set_intersect(unsigned long a, unsigned long b)
{
    unsigned long rv = ((sexpr)((((int_pointer)(5)) << 3) | 0x5)); unsigned long c; unsigned long t;
    while ((((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)b))->type == sxt_cons)))
    {
        t = ((((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)b))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)b))->car) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
        c = a;
        while ((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)c))->type == sxt_cons)))
        {
            if (((sexpr)(equalp (((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)c))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)c))->car) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5))), t)) == ((sexpr)((((int_pointer)(3)) << 3) | 0x5))))
            {
                rv = cons (t, rv);
                goto next;
            }
            c = ((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)c))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)c))->cdr) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
        }
      next:
        b = ((((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)b))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)b))->cdr) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
    }
    return rv;
}


original_code:
sexpr sx_set_difference (sexpr a, sexpr b)
{
    sexpr rv = ((sexpr)((((int_pointer)(5)) << 3) | 0x5)), c, t, ob = b;
    while ((((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)b))->type == sxt_cons)))
    {
        t = ((((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)b))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)b))->car) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
        c = a;
        while ((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)c))->type == sxt_cons)))
        {
            if (((sexpr)(equalp (((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)c))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)c))->car) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5))), t)) == ((sexpr)((((int_pointer)(3)) << 3) | 0x5))))
            {
                goto next_a;
            }
            c = ((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)c))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)c))->cdr) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
        }
        rv = cons (t, rv);
      next_a:
        b = ((((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)b))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)b))->cdr) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
    }
    while ((((((int_pointer)(a)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)a))->type == sxt_cons)))
    {
        t = ((((((int_pointer)(a)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)a))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)a))->car) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
        c = ob;
        while ((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)c))->type == sxt_cons)))
        {
            if (((sexpr)(equalp (((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)c))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)c))->car) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5))), t)) == ((sexpr)((((int_pointer)(3)) << 3) | 0x5))))
            {
                goto next_b;
            }
            c = ((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)c))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)c))->cdr) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
        }
        rv = cons (t, rv);
      next_b:
        a = ((((((int_pointer)(a)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)a))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)a))->cdr) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
    }
    return rv;
}

canonical_original_code:
unsigned long sx_set_difference(unsigned long a, unsigned long b)
{
    unsigned long rv = ((sexpr)((((int_pointer)(5)) << 3) | 0x5)); unsigned long c; unsigned long t; unsigned long ob = b;
    while ((((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)b))->type == sxt_cons)))
    {
        t = ((((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)b))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)b))->car) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
        c = a;
        while ((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)c))->type == sxt_cons)))
        {
            if (((sexpr)(equalp (((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)c))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)c))->car) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5))), t)) == ((sexpr)((((int_pointer)(3)) << 3) | 0x5))))
            {
                goto next_a;
            }
            c = ((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)c))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)c))->cdr) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
        }
        rv = cons (t, rv);
      next_a:
        b = ((((((int_pointer)(b)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)b))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)b))->cdr) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
    }
    while ((((((int_pointer)(a)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)a))->type == sxt_cons)))
    {
        t = ((((((int_pointer)(a)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)a))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)a))->car) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
        c = ob;
        while ((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)c))->type == sxt_cons)))
        {
            if (((sexpr)(equalp (((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)c))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)c))->car) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5))), t)) == ((sexpr)((((int_pointer)(3)) << 3) | 0x5))))
            {
                goto next_b;
            }
            c = ((((((int_pointer)(c)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)c))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)c))->cdr) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
        }
        rv = cons (t, rv);
      next_b:
        a = ((((((int_pointer)(a)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)a))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)a))->cdr) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
    }
    return rv;
}

variable_types:
ob
unsigned long


decompiled_code:
__int64 __fastcall sx_set_memberp(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
__int64 result; // rax

if ( (a1 & 1) != 0 )
return 21LL;
v2 = a1;
do
{
if ( *(_DWORD *)v2 != 6 )
break;
result = equalp(*(_QWORD *)(v2 + 8), a2);
if ( result == 29 )
return result;
if ( *(_DWORD *)v2 != 6 )
break;
v2 = *(_QWORD *)(v2 + 16);
}
while ( (v2 & 1) == 0 );
return 21LL;
}

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

if ( (a1 & 1) != 0 )
return 21LL;
v2 = a1;
do
{
if ( *(_DWORD *)v2 != 6 )
break;
result = equalp(*(_QWORD *)(v2 + 8), a2);
if ( result == 29 )
return result;
if ( *(_DWORD *)v2 != 6 )
break;
v2 = *(_QWORD *)(v2 + 16);
}
while ( (v2 & 1) == 0 );
return 21LL;
}

original_code:
sexpr sx_set_memberp (sexpr set, sexpr item)
{
    while ((((((int_pointer)(set)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)set))->type == sxt_cons)))
    {
        if (((sexpr)(equalp (((((((int_pointer)(set)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)set))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)set))->car) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5))), item)) == ((sexpr)((((int_pointer)(3)) << 3) | 0x5))))
        {
            return ((sexpr)((((int_pointer)(3)) << 3) | 0x5));
        }
        set = ((((((int_pointer)(set)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)set))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)set))->cdr) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
    }
    return ((sexpr)((((int_pointer)(2)) << 3) | 0x5));
}

canonical_original_code:
unsigned long sx_set_memberp(unsigned long set, unsigned long item)
{
    while ((((((int_pointer)(set)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)set))->type == sxt_cons)))
    {
        if (((sexpr)(equalp (((((((int_pointer)(set)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)set))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)set))->car) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5))), item)) == ((sexpr)((((int_pointer)(3)) << 3) | 0x5))))
        {
            return ((sexpr)((((int_pointer)(3)) << 3) | 0x5));
        }
        set = ((((((int_pointer)(set)) & 0x1) == 0x0) && (((struct sexpr_cons *)((void *)set))->type == sxt_cons)) ? (((struct sexpr_cons *)((void *)set))->cdr) : ((sexpr)((((int_pointer)(8)) << 3) | 0x5)));
    }
    return ((sexpr)((((int_pointer)(2)) << 3) | 0x5));
}


decompiled_code:
__int64 __fastcall sx_list1(__int64 a1)
{
return cons(a1, 45LL);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
return cons(a1, 45LL);
}

original_code:
sexpr sx_list1
    (sexpr alpha)
{
    return cons (alpha, ((sexpr)((((int_pointer)(5)) << 3) | 0x5)));
}

canonical_original_code:
unsigned long sx_list1(unsigned long alpha)
{
    return cons (alpha, ((sexpr)((((int_pointer)(5)) << 3) | 0x5)));
}

variable_types:
alpha
unsigned long


decompiled_code:
__int64 __fastcall sx_list2(__int64 a1, __int64 a2)
{
__int64 v2; // rax

v2 = sx_list1(a2);
return cons(a1, v2);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
__int64 v2; // rax

v2 = func0(a2);
return cons(a1, v2);
}

original_code:
sexpr sx_list2
    (sexpr alpha, sexpr beta)
{
    return cons (alpha,
                 sx_list1 (beta));
}

canonical_original_code:
unsigned long sx_list2(unsigned long alpha, unsigned long beta)
{
    return cons (alpha,
                 sx_list1 (beta));
}

variable_types:
beta
unsigned long


decompiled_code:
__int64 __fastcall sx_list3(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v3; // rax

v3 = sx_list2(a2, a3);
return cons(a1, v3);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v3; // rax

v3 = func1(a2, a3);
return cons(a1, v3);
}

original_code:
sexpr sx_list3
    (sexpr alpha, sexpr beta, sexpr gamma)
{
    return cons (alpha,
                 sx_list2 (beta, gamma));
}

canonical_original_code:
unsigned long sx_list3(unsigned long alpha, unsigned long beta, unsigned long gamma)
{
    return cons (alpha,
                 sx_list2 (beta, gamma));
}

variable_types:
gamma
unsigned long


decompiled_code:
__int64 __fastcall sx_list4(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 v4; // rax

v4 = sx_list3(a2, a3, a4);
return cons(a1, v4);
}

original_code:
sexpr sx_list4
    (sexpr alpha, sexpr beta, sexpr gamma, sexpr delta)
{
    return cons (alpha,
                 sx_list3 (beta, gamma, delta));
}

canonical_original_code:
unsigned long sx_list4(unsigned long alpha, unsigned long beta, unsigned long gamma, unsigned long delta)
{
    return cons (alpha,
                 sx_list3 (beta, gamma, delta));
}

variable_types:
delta
unsigned long


original_code:
sexpr sx_list5
    (sexpr alpha, sexpr beta, sexpr gamma, sexpr delta, sexpr epsilon)
{
    return cons (alpha,
                 sx_list4 (beta, gamma, delta, epsilon));
}

canonical_original_code:
unsigned long sx_list5(unsigned long alpha, unsigned long beta, unsigned long gamma, unsigned long delta, unsigned long epsilon)
{
    return cons (alpha,
                 sx_list4 (beta, gamma, delta, epsilon));
}

variable_types:
epsilon
unsigned long


original_code:
sexpr sx_list6
    (sexpr alpha, sexpr beta, sexpr gamma, sexpr delta, sexpr epsilon,
     sexpr zeta)
{
    return cons (alpha,
                 sx_list5 (beta, gamma, delta, epsilon, zeta));
}

canonical_original_code:
unsigned long sx_list6(unsigned long alpha, unsigned long beta, unsigned long gamma, unsigned long delta, unsigned long epsilon, unsigned long zeta)
{
    return cons (alpha,
                 sx_list5 (beta, gamma, delta, epsilon, zeta));
}

variable_types:
zeta
unsigned long


decompiled_code:
__int64 __fastcall multiplex_add_tail(int a1, __int64 a2, __int64 a3)
{
__int64 result; // rax
__int64 v5; // rdx

result = get_pool_mem(&pool_3);
v5 = list;
*(_DWORD *)result = a1;
*(_QWORD *)(result + 8) = a2;
*(_QWORD *)(result + 16) = a3;
*(_QWORD *)(result + 24) = v5;
list = result;
return result;
}

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

result = get_pool_mem(&pool_3);
v5 = list;
*(_DWORD *)result = a1;
*(_QWORD *)(result + 8) = a2;
*(_QWORD *)(result + 16) = a3;
*(_QWORD *)(result + 24) = v5;
list = result;
return result;
}

original_code:
static void multiplex_add_tail
        (int fd, void (*on_connect)(struct io *, struct io *, void *),
         void *aux)
{
    static struct memory_pool pool
            = { mpft_static_header, ((((unsigned long)sizeof (struct net_socket_listener)) & ~(((unsigned short)8) - 1)) + (((((unsigned long)sizeof (struct net_socket_listener)) & ~(((unsigned short)8) - 1)) != ((unsigned long)sizeof (struct net_socket_listener))) ? ((unsigned short)8) : 0)) };
    struct net_socket_listener *l = get_pool_mem (&pool);
    l->socket = fd;
    l->on_connect = on_connect;
    l->data = aux;
    l->next = list;
    list = l;
}

canonical_original_code:
static void multiplex_add_tail(int fd, void (*on_connect)(struct io *, struct io *, void *), void *aux)
{
    static struct memory_pool pool = { mpft_static_header, ((((unsigned long)sizeof (struct net_socket_listener)) & ~(((unsigned short)8) - 1)) + (((((unsigned long)sizeof (struct net_socket_listener)) & ~(((unsigned short)8) - 1)) != ((unsigned long)sizeof (struct net_socket_listener))) ? ((unsigned short)8) : 0)) };
    struct net_socket_listener *l = get_pool_mem (&pool);
    l->socket = fd;
    l->on_connect = on_connect;
    l->data = aux;
    l->next = list;
    list = l;
}

variable_types: fd int

variable_types: void (*)(struct io { int fd; char *buffer; enum io_type { iot_undefined=0, iot_read=1, iot_write=2, iot_special_read=3, iot_special_write=4, iot_buffer=5 } type; enum io_result { io_undefined=0, io_end_of_file=1, io_changes=2, io_unrecoverable_error=3, io_no_change=4, io_complete=5, io_incomplete=6, io_finalising=7 } status; unsigned int length; unsigned int position; unsigned int buffersize; } *, struct io *, void *)

variable_types:
aux
void *

variable_types: struct memory_pool { enum memory_pool_frame_type { mpft_static_header=0, mpft_frame=1 } type; unsigned int entitysize; }

variable_types: struct net_socket_listener { int socket; void (*on_connect)(struct io { int fd; char *buffer; enum io_type { iot_undefined=0, iot_read=1, iot_write=2, iot_special_read=3, iot_special_write=4, iot_buffer=5 } type; enum io_result { io_undefined=0, io_end_of_file=1, io_changes=2, io_unrecoverable_error=3, io_no_change=4, io_complete=5, io_incomplete=6, io_finalising=7 } status; unsigned int length; unsigned int position; unsigned int buffersize; } *, struct io *, void *); void *data; struct net_socket_listener *next; } *

user_defined_types: struct memory_pool { enum memory_pool_frame_type type; unsigned int entitysize; }

user_defined_types: struct net_socket_listener { int socket; void (*on_connect)(struct io *, struct io *, void *); void *data; struct net_socket_listener *next; }

user_defined_types: struct io { int fd; char *buffer; enum io_type type; enum io_result status; unsigned int length; unsigned int position; unsigned int buffersize; }


decompiled_code:
__int64 multiplex_network()
{
__int64 result; // rax

if ( !installed_5 )
{
result = multiplex_add(mx_functions_4);
installed_5 = 1;
}
return result;
}

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

if ( !installed_5 )
{
result = multiplex_add(mx_functions_4);
installed_5 = 1;
}
return result;
}

original_code:
void multiplex_network() {
    static struct multiplex_functions mx_functions =
    {
        .count = mx_f_count,
        .augment = mx_f_augment,
        .callback = mx_f_callback,
        .next = (struct multiplex_functions *)0
    };
    static char installed = (char)0;
    if (installed == (char)0) {
        multiplex_add (&mx_functions);
        installed = (char)1;
    }
}

variable_types: struct multiplex_functions { enum multiplex_result { mx_ok=0, mx_nothing_to_do=1, mx_immediate_action=2 } (*count)(int *, int *); void (*augment)(int *, int *, int *, int *); void (*callback)(int *, int, int *, int); struct multiplex_functions *next; }

variable_types: installed char

user_defined_types: struct multiplex_functions { enum multiplex_result (*count)(int *, int *); void (*augment)(int *, int *, int *, int *); void (*callback)(int *, int, int *, int); struct multiplex_functions *next; }


decompiled_code:
__int64 __fastcall multiplex_add_socket(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax
int v5[7]; // [rsp+Ch] [rbp-1Ch] BYREF

result = a_open_listen_socket(v5, a1);
if ( (_DWORD)result == 5 )
result = multiplex_add_tail(v5[0], a2, a3);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax
int v5[7]; // [rsp+Ch] [rbp-1Ch] BYREF

result = a_open_listen_socket(v5, a1);
if ( (_DWORD)result == 5 )
result = func4(v5[0], a2, a3);
return result;
}

original_code:
void multiplex_add_socket
        (const char *path, void (*on_connect)(struct io *, struct io *, void *),
         void *aux)
{
    int fd;
    if (a_open_listen_socket (&fd, path) == io_complete)
    {
        multiplex_add_tail (fd, on_connect, aux);
    }
}

canonical_original_code:
void multiplex_add_socket(char *path, void (*on_connect)(struct io *, struct io *, void *), void *aux)
{
    int fd;
    if (a_open_listen_socket (&fd, path) == io_complete)
    {
        multiplex_add_tail (fd, on_connect, aux);
    }
}

variable_types:
path
char *

user_defined_types: enum io_type { iot_undefined=0, iot_read=1, iot_write=2, iot_special_read=3, iot_special_write=4, iot_buffer=5 }

user_defined_types: enum io_result { io_undefined=0, io_end_of_file=1, io_changes=2, io_unrecoverable_error=3, io_no_change=4, io_complete=5, io_incomplete=6, io_finalising=7 }


decompiled_code:
__int64 __fastcall multiplex_add_ip4(unsigned int a1, unsigned __int16 a2, __int64 a3, __int64 a4)
{
__int64 result; // rax
int v7[7]; // [rsp+Ch] [rbp-1Ch] BYREF

result = a_open_listen_ip4(v7, a1, a2);
if ( (_DWORD)result == 5 )
result = multiplex_add_tail(v7[0], a3, a4);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(unsigned int a1, unsigned __int16 a2, __int64 a3, __int64 a4)
{
__int64 result; // rax
int v7[7]; // [rsp+Ch] [rbp-1Ch] BYREF

result = a_open_listen_ip4(v7, a1, a2);
if ( (_DWORD)result == 5 )
result = func4(v7[0], a3, a4);
return result;
}

original_code:
void multiplex_add_ip4
        (int_32 addr, int_16 port,
         void (*on_connect)(struct io *, struct io *, void *), void *aux)
{
    int fd;
    if (a_open_listen_ip4 (&fd, addr, port) == io_complete)
    {
        multiplex_add_tail (fd, on_connect, aux);
    }
}

canonical_original_code:
void multiplex_add_ip4(unsigned int addr, unsigned short port, void (*on_connect)(struct io *, struct io *, void *), void *aux)
{
    int fd;
    if (a_open_listen_ip4 (&fd, addr, port) == io_complete)
    {
        multiplex_add_tail (fd, on_connect, aux);
    }
}

variable_types:
addr
unsigned int

variable_types:
port
unsigned short


decompiled_code:
__int64 __fastcall multiplex_add_ip6(__int64 a1, unsigned __int16 a2, __int64 a3, __int64 a4)
{
__int64 result; // rax
int v7[7]; // [rsp+Ch] [rbp-1Ch] BYREF

result = a_open_listen_ip6(v7, a1, a2);
if ( (_DWORD)result == 5 )
result = multiplex_add_tail(v7[0], a3, a4);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1, unsigned __int16 a2, __int64 a3, __int64 a4)
{
__int64 result; // rax
int v7[7]; // [rsp+Ch] [rbp-1Ch] BYREF

result = a_open_listen_ip6(v7, a1, a2);
if ( (_DWORD)result == 5 )
result = func4(v7[0], a3, a4);
return result;
}

original_code:
void multiplex_add_ip6
        (int_8 addr[16], int_16 port,
         void (*on_connect)(struct io *, struct io *, void *), void *aux)
{
    int fd;
    if (a_open_listen_ip6 (&fd, addr, port) == io_complete)
    {
        multiplex_add_tail (fd, on_connect, aux);
    }
}

canonical_original_code:
void multiplex_add_ip6(unsigned char addr[16], unsigned short port, void (*on_connect)(struct io *, struct io *, void *), void *aux)
{
    int fd;
    if (a_open_listen_ip6 (&fd, addr, port) == io_complete)
    {
        multiplex_add_tail (fd, on_connect, aux);
    }
}

variable_types:
addr
unsigned char [16]


decompiled_code:
__int64 __fastcall mx_f_count(_DWORD *a1)
{
__int64 i; // rax

for ( i = list; i; i = *(_QWORD *)(i + 24) )
{
if ( *(int *)i >= 0 )
++*a1;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(_DWORD *a1)
{
__int64 i; // rax

for ( i = list; i; i = *(_QWORD *)(i + 24) )
{
if ( *(int *)i >= 0 )
++*a1;
}
return 0LL;
}

original_code:
static enum multiplex_result mx_f_count(int *r, int *w) {
    struct net_socket_listener *l = list;
    while (l != (struct net_socket_listener *)0)
    {
        if (l->socket >= 0)
        {
            (*r) += 1;
        }
        l = l->next;
    }
    return mx_ok;
}

variable_types:
r
int *

variable_types:
w
int *

return_type: enum multiplex_result { mx_ok=0, mx_nothing_to_do=1, mx_immediate_action=2 }


original_code:
static void mx_f_augment(int *rs, int *r, int *ws, int *w)
{
    struct net_socket_listener *l = list;
    while (l != (struct net_socket_listener *)0)
    {
        if (l->socket >= 0)
        {
            int i, j = (*r);
            for (i = 0; i < j; i++)
            {
                if (rs[i] == l->socket)
                {
                    goto next;
                }
            }
            rs[i] = l->socket;
            (*r) += 1;
        }
        next:
        l = l->next;
    }
}

canonical_original_code:
static void mx_f_augment(int *rs, int *r, int *ws, int *w)
{
    struct net_socket_listener *l = list;
    while (l != (struct net_socket_listener *)0)
    {
        if (l->socket >= 0)
        {
            int i; int j = (*r);
            for (i = 0; i < j; i++)
            {
                if (rs[i] == l->socket)
                {
                    goto next;
                }
            }
            rs[i] = l->socket;
            (*r) += 1;
        }
        next:
        l = l->next;
    }
}

variable_types:
rs
int *

variable_types:
ws
int *

variable_types: i int

variable_types: j int