decompiled_code:
__int64 init_tests_utils()
{
__int64 v0; // rax
__int64 v1; // rbp

v0 = CU_add_suite("utils", 0LL, 0LL);
if ( !v0
|| (v1 = v0, !CU_add_test(v0, "Get/put uint16", test_getput2byte))
|| !CU_add_test(v1, "Get/put uint32", test_getput4byte)
|| !CU_add_test(v1, "Get/put varint32", test_varint32) )
{
CU_cleanup_registry();
}
return CU_get_error();
}

canonical_decompiled_code:
__int64 func3()
{
__int64 v0; // rax
__int64 v1; // rbp

v0 = CU_add_suite("utils", 0LL, 0LL);
if ( !v0
|| (v1 = v0, !CU_add_test(v0, "Get/put uint16", test_getput2byte))
|| !CU_add_test(v1, "Get/put uint32", test_getput4byte)
|| !CU_add_test(v1, "Get/put varint32", test_varint32) )
{
CU_cleanup_registry();
}
return CU_get_error();
}

original_code:
int init_tests_utils()
{
 CU_pSuite utilsTests = ((void *)0);
 utilsTests = CU_add_suite("utils", ((void *)0), ((void *)0));
 if (((void *)0) == utilsTests)
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 if (
  (((void *)0) == CU_add_test(utilsTests, "Get/put uint16", test_getput2byte)) ||
  (((void *)0) == CU_add_test(utilsTests, "Get/put uint32", test_getput4byte)) ||
  (((void *)0) == CU_add_test(utilsTests, "Get/put varint32", test_varint32))
    )
    {
      CU_cleanup_registry();
      return CU_get_error();
   }
 return CU_get_error();
}

canonical_original_code:
int init_tests_utils()
{
 struct CU_Suite *utilsTests = ((void *)0);
 utilsTests = CU_add_suite("utils", ((void *)0), ((void *)0));
 if (((void *)0) == utilsTests)
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 if (
  (((void *)0) == CU_add_test(utilsTests, "Get/put uint16", test_getput2byte)) ||
  (((void *)0) == CU_add_test(utilsTests, "Get/put uint32", test_getput4byte)) ||
  (((void *)0) == CU_add_test(utilsTests, "Get/put varint32", test_varint32))
    )
    {
      CU_cleanup_registry();
      return CU_get_error();
   }
 return CU_get_error();
}

user_defined_types: struct __sigset_t { unsigned long __val[-1]; }


repo: SeanHogan/webscale-db

decompiled_code:
__int64 init_tests_pager()
{
__int64 v0; // rax
__int64 v1; // rbp

v0 = CU_add_suite("pager", 0LL, 0LL);
if ( !v0
|| (v1 = v0, !CU_add_test(v0, "Opening an existing file", test_open))
|| !CU_add_test(v1, "Reading pages", test_read)
|| !CU_add_test(v1, "Allocating/writing/reading a page", test_readwrite) )
{
CU_cleanup_registry();
}
return CU_get_error();
}

canonical_decompiled_code:
__int64 func3()
{
__int64 v0; // rax
__int64 v1; // rbp

v0 = CU_add_suite("pager", 0LL, 0LL);
if ( !v0
|| (v1 = v0, !CU_add_test(v0, "Opening an existing file", test_open))
|| !CU_add_test(v1, "Reading pages", test_read)
|| !CU_add_test(v1, "Allocating/writing/reading a page", test_readwrite) )
{
CU_cleanup_registry();
}
return CU_get_error();
}

original_code:
int init_tests_pager()
{
 CU_pSuite pagerTests = ((void *)0);
 pagerTests = CU_add_suite("pager", ((void *)0), ((void *)0));
 if (((void *)0) == pagerTests)
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 if (
  (((void *)0) == CU_add_test(pagerTests, "Opening an existing file", test_open)) ||
  (((void *)0) == CU_add_test(pagerTests, "Reading pages", test_read)) ||
  (((void *)0) == CU_add_test(pagerTests, "Allocating/writing/reading a page", test_readwrite))
    )
    {
      CU_cleanup_registry();
      return CU_get_error();
   }
 return CU_get_error();
}

canonical_original_code:
int init_tests_pager()
{
 struct CU_Suite *pagerTests = ((void *)0);
 pagerTests = CU_add_suite("pager", ((void *)0), ((void *)0));
 if (((void *)0) == pagerTests)
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 if (
  (((void *)0) == CU_add_test(pagerTests, "Opening an existing file", test_open)) ||
  (((void *)0) == CU_add_test(pagerTests, "Reading pages", test_read)) ||
  (((void *)0) == CU_add_test(pagerTests, "Allocating/writing/reading a page", test_readwrite))
    )
    {
      CU_cleanup_registry();
      return CU_get_error();
   }
 return CU_get_error();
}

variable_types: struct CU_Suite { char *pName; int fActive; struct CU_Test { char *pName; int fActive; void (*pTestFunc)(); struct __jmp_buf_tag { long __jmpbuf[8]; int __mask_was_saved; struct __sigset_t { unsigned long __val[-1]; } __saved_mask; } (*pJumpBuf)[1]; struct CU_Test *pNext; struct CU_Test *pPrev; } *pTest; int (*pInitializeFunc)(); int (*pCleanupFunc)(); void (*pSetUpFunc)(); void (*pTearDownFunc)(); unsigned int uiNumberOfTests; struct CU_Suite *pNext; struct CU_Suite *pPrev; unsigned int uiNumberOfTestsFailed; unsigned int uiNumberOfTestsSuccess; } *

return_type: int

user_defined_types: struct CU_Suite { char *pName; int fActive; struct CU_Test *pTest; int (*pInitializeFunc)(); int (*pCleanupFunc)(); void (*pSetUpFunc)(); void (*pTearDownFunc)(); unsigned int uiNumberOfTests; struct CU_Suite *pNext; struct CU_Suite *pPrev; unsigned int uiNumberOfTestsFailed; unsigned int uiNumberOfTestsSuccess; }

user_defined_types: struct CU_Test { char *pName; int fActive; void (*pTestFunc)(); struct __jmp_buf_tag (*pJumpBuf)[1]; struct CU_Test *pNext; struct CU_Test *pPrev; }

user_defined_types: struct __jmp_buf_tag { long __jmpbuf[8]; int __mask_was_saved; struct __sigset_t __saved_mask; }


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
pthread_t newthread[2]; // [rsp+8h] [rbp-10h] BYREF

newthread[0] = 0LL;
pthread_create(newthread, 0LL, UninDomainSocketServer, 0LL);
sleep(0x493E0u);
return 0;
}

original_code:
int main(int argc,char **argv)
{
 RemoteCtrlServiceOpen(1);
 return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
 RemoteCtrlServiceOpen(1);
 return 0;
}

variable_types: argc int

variable_types:
argv
char **


siphash

repo: Senscape/Dagon

variable_types:
out
unsigned char *

variable_types:
in
unsigned char *

variable_types:
inlen
unsigned long

variable_types:
k
unsigned char *

variable_types:
b
unsigned long

variable_types:
m
unsigned long

variable_types: i int

variable_types:
end
unsigned char *

variable_types: left int


repo: SerhoLiu/gakio

original_code:
static void value_pool_resize(valuepool *vpool)
{
    unsigned long newsize, oldsize, olduse, i;
    void **newvalues, **oldvalues;
    oldsize = vpool->size;
    newsize = oldsize << 1;
    olduse = vpool->use;
    oldvalues = vpool->values;
    newvalues = malloc(newsize * sizeof(void*));
    if (newvalues == ((void *)0)) {
        return;
    }
    for (i = 0; i < olduse; i++) {
        newvalues[i] = oldvalues[i];
    }
    vpool->values = newvalues;
    vpool->size = newsize;
    free(oldvalues);
}

canonical_original_code:
static void value_pool_resize(struct valuepool *vpool)
{
    unsigned long newsize; unsigned long oldsize; unsigned long olduse; unsigned long i;
    void **newvalues; void **oldvalues;
    oldsize = vpool->size;
    newsize = oldsize << 1;
    olduse = vpool->use;
    oldvalues = vpool->values;
    newvalues = malloc(newsize * sizeof(void *));
    if (newvalues == ((void *)0)) {
        return;
    }
    for (i = 0; i < olduse; i++) {
        newvalues[i] = oldvalues[i];
    }
    vpool->values = newvalues;
    vpool->size = newsize;
    free(oldvalues);
}

variable_types: struct valuepool { unsigned long size; unsigned long use; void **values; } *

variable_types:
newsize
unsigned long

variable_types:
oldsize
unsigned long

variable_types:
olduse
unsigned long

variable_types:
i
unsigned long

variable_types:
newvalues
void **

variable_types:
oldvalues
void **

return_type: void


decompiled_code:
// attributes: thunk
_QWORD *value_pool_new()
{
return value_pool_new_constprop_0();
}

canonical_decompiled_code:
_QWORD *func2()
{
return func1();
}

canonical_original_code:
struct valuepool *value_pool_new()
{
    return _value_pool_new((1 << 9));
}

return_type: struct valuepool { unsigned long size; unsigned long use; void **values; } *


decompiled_code:
void __fastcall value_pool_delete(void *ptr)
{
__int64 v2; // rax
void **v3; // rdi
void **v4; // rbx
void **v5; // rbp
unsigned __int64 v6; // rdi

v2 = *((_QWORD *)ptr + 1);
v3 = (void **)*((_QWORD *)ptr + 2);
if ( v2 )
{
v4 = v3;
v5 = &v3[v2];
do
{
while ( 1 )
{
v6 = (unsigned __int64)*v4;
if ( ((unsigned __int8)*v4 & 1) == 0 )
break;
++v4;
free((void *)(v6 & 0xFFFFFFFFFFFFFFFELL));
if ( v4 == v5 )
goto LABEL_6;
}
free((void *)v6);
++v4;
}
while ( v4 != v5 );
LABEL_6:
v3 = (void **)*((_QWORD *)ptr + 2);
}
free(v3);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func3(void *ptr)
{
__int64 v2; // rax
void **v3; // rdi
void **v4; // rbx
void **v5; // rbp
unsigned __int64 v6; // rdi

v2 = *((_QWORD *)ptr + 1);
v3 = (void **)*((_QWORD *)ptr + 2);
if ( v2 )
{
v4 = v3;
v5 = &v3[v2];
do
{
while ( 1 )
{
v6 = (unsigned __int64)*v4;
if ( ((unsigned __int8)*v4 & 1) == 0 )
break;
++v4;
free((void *)(v6 & 0xFFFFFFFFFFFFFFFELL));
if ( v4 == v5 )
goto LABEL_6;
}
free((void *)v6);
++v4;
}
while ( v4 != v5 );
LABEL_6:
v3 = (void **)*((_QWORD *)ptr + 2);
}
free(v3);
free(ptr);
}

original_code:
void value_pool_delete(valuepool *vpool)
{
    unsigned long use, i;
    use = vpool->use;
    void **values = vpool->values;
    for (i = 0; i < use; i++) {
        if ((((unsigned long) (values[i]) & 0x1) != 0)) {
            free((void *)(((unsigned long) (values[i]) & ~0x1)));
        } else {
            free(values[i]);
        }
    }
    free(vpool->values);
    free(vpool);
}

canonical_original_code:
void value_pool_delete(struct valuepool *vpool)
{
    unsigned long use; unsigned long i;
    use = vpool->use;
    void **values = vpool->values;
    for (i = 0; i < use; i++) {
        if ((((unsigned long) (values[i]) & 0x1) != 0)) {
            free((void *)(((unsigned long) (values[i]) & ~0x1)));
        } else {
            free(values[i]);
        }
    }
    free(vpool->values);
    free(vpool);
}

variable_types:
use
unsigned long

variable_types:
values
void **

user_defined_types: struct valuepool { unsigned long size; unsigned long use; void **values; }


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

if ( !a1 )
return 0LL;
v2 = a1[1];
if ( v2 + 4 > (unsigned __int64)*a1 )
{
value_pool_resize(a1);
v2 = a1[1];
}
*(_QWORD *)(a1[2] + 8 * v2) = a2;
a1[1] = v2 + 1;
return 1LL;
}

original_code:
int value_pool_append(valuepool *vpool, void *value)
{
    if (vpool == ((void *)0)) {
        return 0;
    }
    if (vpool->use + (1 << 2) > vpool->size) {
        value_pool_resize(vpool);
    }
    vpool->values[vpool->use] = value;
    vpool->use++;
    return 1;
}

canonical_original_code:
int value_pool_append(struct valuepool *vpool, void *value)
{
    if (vpool == ((void *)0)) {
        return 0;
    }
    if (vpool->use + (1 << 2) > vpool->size) {
        value_pool_resize(vpool);
    }
    vpool->values[vpool->use] = value;
    vpool->use++;
    return 1;
}

variable_types:
value
void *


decompiled_code:
const char *__fastcall value_pool_find(__int64 a1, const char *a2)
{
__int64 v2; // rbp
__int64 v3; // r15
__int64 v4; // rbx
const char *v5; // r12

v2 = *(_QWORD *)(a1 + 8);
v3 = *(_QWORD *)(a1 + 16);
if ( !v2 )
return 0LL;
v4 = 0LL;
while ( 1 )
{
if ( ((unsigned __int8)a2 & 1) == 0 )
{
v5 = *(const char **)(v3 + 8 * v4);
if ( !strcmp(v5, a2) )
break;
}
if ( v2 == ++v4 )
return 0LL;
}
return v5;
}

canonical_decompiled_code:
const char *__fastcall func5(__int64 a1, const char *a2)
{
__int64 v2; // rbp
__int64 v3; // r15
__int64 v4; // rbx
const char *v5; // r12

v2 = *(_QWORD *)(a1 + 8);
v3 = *(_QWORD *)(a1 + 16);
if ( !v2 )
return 0LL;
v4 = 0LL;
while ( 1 )
{
if ( ((unsigned __int8)a2 & 1) == 0 )
{
v5 = *(const char **)(v3 + 8 * v4);
if ( !strcmp(v5, a2) )
break;
}
if ( v2 == ++v4 )
return 0LL;
}
return v5;
}

original_code:
void *value_pool_find(valuepool *vpool, const void *value)
{
    unsigned long use, i;
    use = vpool->use;
    void **values = vpool->values;
    for (i = 0; i < use; i++) {
        if (!(((unsigned long) (value) & 0x1) != 0)) {
            if (!strcmp((char *)values[i], (char *)value)) {
                return values[i];
            }
        }
    }
    return ((void *)0);
}

canonical_original_code:
void *value_pool_find(struct valuepool *vpool, void *value)
{
    unsigned long use; unsigned long i;
    use = vpool->use;
    void **values = vpool->values;
    for (i = 0; i < use; i++) {
        if (!(((unsigned long) (value) & 0x1) != 0)) {
            if (!strcmp((char *)values[i], (char *)value)) {
                return values[i];
            }
        }
    }
    return ((void *)0);
}

return_type: void *


decompiled_code:
__int64 __fastcall ch_in_str(char a1, char *a2)
{
char v2; // al

v2 = *a2;
do
{
if ( a1 == v2 )
return 1LL;
v2 = *++a2;
}
while ( v2 );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(char a1, char *a2)
{
char v2; // al

v2 = *a2;
do
{
if ( a1 == v2 )
return 1LL;
v2 = *++a2;
}
while ( v2 );
return 0LL;
}

original_code:
static int ch_in_str(const char ch, const char *str)
{
    do {
        if (ch == *str)
            return 1;
    } while (str++ && (*str != '\0'));
    return 0;
}

canonical_original_code:
static int ch_in_str(char ch, char *str)
{
    do {
        if (ch == *str)
            return 1;
    } while (str++ && (*str != '\0'));
    return 0;
}

variable_types: ch char

variable_types:
str
char *


original_code:
static int get_next_op(const char str[], char *value, int index)
{
    int i = 0, ch;
    ch = str[index];
    if (((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short int) _ISalpha) || ch == '_') {
        value[i] = ch;
        while ((ch = str[++index]) && (((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short int) _ISalpha) || ((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short int) _ISdigit)
                || (ch == '_') || (ch == '.'))) {
            value[++i] = ch;
            if (i > 128 - 2) {
                value[i-2] = '.';
                value[i-1] = '.';
                value[i] = '.';
                value[++i] = '\0';
                return 720;
            }
        }
        value[++i] = '\0';
        if (ch_in_str('.', value)) {
            return 717;
        } else {
            return index;
        }
    }
    if (((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short int) _ISdigit)) {
        value[i] = ch;
        while((ch = str[++index]) && (!ch_in_str(ch, OPT_STR))
               && !(((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short int) _ISspace))) {
            if (!((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short int) _ISdigit) && (!ch_in_str(ch, OPT_STR) && (ch != '.'))) {
                value[++i] = ch;
                value[++i] = '\0';
                return 717;
            }
            else if (((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short int) _ISdigit) || ch == '.') {
                value[++i] = ch;
            }
            if (i > 128 - 2) {
                value[i-2] = '.';
                value[i-1] = '.';
                value[i] = '.';
                value[++i] = '\0';
                return 720;
            }
        }
        value[++i] = '\0';
        return index;
    }
    if (ch == '?') {
        if (index != 0) {
            value[i] = ch;
            value[++i] = '\0';
            return 719;
        }
    }
    switch (ch) {
        case '+': {value[i] = '+'; value[++i] = '\0'; break;}
        case '-': {value[i] = '-'; value[++i] = '\0'; break;}
        case '*': {value[i] = '*'; value[++i] = '\0'; break;}
        case '/': {value[i] = '/'; value[++i] = '\0'; break;}
        case '(': {value[i] = '('; value[++i] = '\0'; break;}
        case ')': {value[i] = ')'; value[++i] = '\0'; break;}
        case '?': {value[i] = '?'; value[++i] = '\0'; break;}
        case '=': {value[i] = '='; value[++i] = '\0'; break;}
        default: {value[i] = ch; value[++i] = '\0'; return 718;}
    }
    index++;
    return index;
}

canonical_original_code:
static int get_next_op(char str[], char *value, int index)
{
    int i = 0; int ch;
    ch = str[index];
    if (((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short) _ISalpha) || ch == '_') {
        value[i] = ch;
        while ((ch = str[++index]) && (((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short) _ISalpha) || ((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short) _ISdigit)
                || (ch == '_') || (ch == '.'))) {
            value[++i] = ch;
            if (i > 128 - 2) {
                value[i-2] = '.';
                value[i-1] = '.';
                value[i] = '.';
                value[++i] = '\0';
                return 720;
            }
        }
        value[++i] = '\0';
        if (ch_in_str('.', value)) {
            return 717;
        } else {
            return index;
        }
    }
    if (((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short) _ISdigit)) {
        value[i] = ch;
        while((ch = str[++index]) && (!ch_in_str(ch, OPT_STR))
               && !(((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short) _ISspace))) {
            if (!((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short) _ISdigit) && (!ch_in_str(ch, OPT_STR) && (ch != '.'))) {
                value[++i] = ch;
                value[++i] = '\0';
                return 717;
            }
            else if (((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short) _ISdigit) || ch == '.') {
                value[++i] = ch;
            }
            if (i > 128 - 2) {
                value[i-2] = '.';
                value[i-1] = '.';
                value[i] = '.';
                value[++i] = '\0';
                return 720;
            }
        }
        value[++i] = '\0';
        return index;
    }
    if (ch == '?') {
        if (index != 0) {
            value[i] = ch;
            value[++i] = '\0';
            return 719;
        }
    }
    switch (ch) {
        case '+': {value[i] = '+'; value[++i] = '\0'; break;}
        case '-': {value[i] = '-'; value[++i] = '\0'; break;}
        case '*': {value[i] = '*'; value[++i] = '\0'; break;}
        case '/': {value[i] = '/'; value[++i] = '\0'; break;}
        case '(': {value[i] = '('; value[++i] = '\0'; break;}
        case ')': {value[i] = ')'; value[++i] = '\0'; break;}
        case '?': {value[i] = '?'; value[++i] = '\0'; break;}
        case '=': {value[i] = '='; value[++i] = '\0'; break;}
        default: {value[i] = ch; value[++i] = '\0'; return 718;}
    }
    index++;
    return index;
}

variable_types:
str
char []

variable_types:
value
char *

variable_types: index int

variable_types: ch int


decompiled_code:
void __fastcall create_tokens_array(__int64 a1, __int64 a2, const char *a3)
{
char v4; // bl
unsigned __int16 v5; // ax
const char *v6; // rax
void *v7; // rbx
__int64 v8; // rbx
size_t v9; // r14
double v10; // [rsp+0h] [rbp-40h]
int v11; // [rsp+8h] [rbp-38h] BYREF
__int64 v12; // [rsp+10h] [rbp-30h]

if ( a1 )
{
v4 = *a3;
v5 = (*_ctype_b_loc())[v4];
if ( (v5 & 0x800) != 0 )
{
v11 = 8;
v10 = atof(a3);
v8 = (__int64)malloc(8uLL);
*(double *)v8 = v10;
value_pool_append(a2, v8 | 1);
v12 = v8;
}
else
{
if ( (v5 & 0x400) == 0 && v4 != 95 )
{
switch ( v4 )
{
case '(':
v11 = 5;
goto LABEL_14;
case ')':
v11 = 6;
goto LABEL_14;
case '*':
v11 = 3;
goto LABEL_14;
case '+':
v11 = 1;
goto LABEL_14;
case '-':
v11 = 2;
goto LABEL_14;
case '/':
v11 = 4;
goto LABEL_14;
case '=':
v11 = 10;
goto LABEL_14;
case '?':
v11 = 9;
LABEL_14:
v12 = 0LL;
goto LABEL_9;
default:
return;
}
}
v11 = 7;
v6 = (const char *)value_pool_find(a2, a3);
v7 = (void *)v6;
if ( !v6 || strcmp(v6, a3) )
{
v9 = strlen(a3) + 1;
v7 = malloc(v9);
memcpy(v7, a3, v9);
value_pool_append(a2, v7);
}
v12 = (__int64)v7;
}
LABEL_9:
token_adt_append(a1, &v11);
}
}

canonical_decompiled_code:
void __fastcall func2(__int64 a1, __int64 a2, const char *a3)
{
char v4; // bl
unsigned __int16 v5; // ax
const char *v6; // rax
void *v7; // rbx
__int64 v8; // rbx
size_t v9; // r14
double v10; // [rsp+0h] [rbp-40h]
int v11; // [rsp+8h] [rbp-38h] BYREF
__int64 v12; // [rsp+10h] [rbp-30h]

if ( a1 )
{
v4 = *a3;
v5 = (*_ctype_b_loc())[v4];
if ( (v5 & 0x800) != 0 )
{
v11 = 8;
v10 = atof(a3);
v8 = (__int64)malloc(8uLL);
*(double *)v8 = v10;
value_pool_append(a2, v8 | 1);
v12 = v8;
}
else
{
if ( (v5 & 0x400) == 0 && v4 != 95 )
{
switch ( v4 )
{
case '(':
v11 = 5;
goto LABEL_14;
case ')':
v11 = 6;
goto LABEL_14;
case '*':
v11 = 3;
goto LABEL_14;
case '+':
v11 = 1;
goto LABEL_14;
case '-':
v11 = 2;
goto LABEL_14;
case '/':
v11 = 4;
goto LABEL_14;
case '=':
v11 = 10;
goto LABEL_14;
case '?':
v11 = 9;
LABEL_14:
v12 = 0LL;
goto LABEL_9;
default:
return;
}
}
v11 = 7;
v6 = (const char *)value_pool_find(a2, a3);
v7 = (void *)v6;
if ( !v6 || strcmp(v6, a3) )
{
v9 = strlen(a3) + 1;
v7 = malloc(v9);
memcpy(v7, a3, v9);
value_pool_append(a2, v7);
}
v12 = (__int64)v7;
}
LABEL_9:
token_adt_append(a1, &v11);
}
}

original_code:
static void create_tokens_array(tokenadt *tokens, valuepool *vpool, const char *value)
{
    char ch;
    token t;
    if (tokens == ((void *)0)) {
        return;
    }
    ch = value[0];
    if (((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short int) _ISdigit)) {
        t.code = T_CONST;
        double *gnum, num;
        num = atof(value);
        gnum = (double *)malloc(sizeof(double));
        *gnum = num;
        value_pool_append(vpool, ((void *)((unsigned long) (gnum) | 0x1)));
        t.value = gnum;
    } else if (((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short int) _ISalpha) || ch == '_') {
        t.code = T_VAR;
        void *vchar = value_pool_find(vpool, value);
        if ((vchar != ((void *)0)) && !(strcmp((char *)vchar, value))) {
            t.value = vchar;
        } else {
            char *str = (char *)malloc((strlen(value) + 1) * sizeof(char));
            strcpy(str, value);
            value_pool_append(vpool, str);
            t.value = str;
        }
    } else {
        switch (ch) {
            case '+': {t.code = T_PLUS; break;}
            case '-': {t.code = T_MINUS; break;}
            case '*': {t.code = T_MULTI; break;}
            case '/': {t.code = T_DIVI; break;}
            case '(': {t.code = T_BRACES_L; break;}
            case ')': {t.code = T_BRACES_R; break;}
            case '?': {t.code = T_PRINT; break;}
            case '=': {t.code = T_ASSING; break;}
            default: {return;}
        }
        t.value = ((void *)0);
    }
    token_adt_append(tokens, &t);
}

canonical_original_code:
static void create_tokens_array(struct tokenadt *tokens, struct valuepool *vpool, char *value)
{
    char ch;
    struct token t;
    if (tokens == ((void *)0)) {
        return;
    }
    ch = value[0];
    if (((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short) _ISdigit)) {
        t.code = T_CONST;
        double *gnum; double num;
        num = atof(value);
        gnum = (double *)malloc(sizeof(double));
        *gnum = num;
        value_pool_append(vpool, ((void *)((unsigned long) (gnum) | 0x1)));
        t.value = gnum;
    } else if (((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short) _ISalpha) || ch == '_') {
        t.code = T_VAR;
        void *vchar = value_pool_find(vpool, value);
        if ((vchar != ((void *)0)) && !(strcmp((char *)vchar, value))) {
            t.value = vchar;
        } else {
            char *str = (char *)malloc((strlen(value) + 1) * sizeof(char));
            strcpy(str, value);
            value_pool_append(vpool, str);
            t.value = str;
        }
    } else {
        switch (ch) {
            case '+': {t.code = T_PLUS; break;}
            case '-': {t.code = T_MINUS; break;}
            case '*': {t.code = T_MULTI; break;}
            case '/': {t.code = T_DIVI; break;}
            case '(': {t.code = T_BRACES_L; break;}
            case ')': {t.code = T_BRACES_R; break;}
            case '?': {t.code = T_PRINT; break;}
            case '=': {t.code = T_ASSING; break;}
            default: {return;}
        }
        t.value = ((void *)0);
    }
    token_adt_append(tokens, &t);
}

variable_types: struct tokenadt { unsigned long size; unsigned long use; struct token { int code; void *value; } *items; } *

variable_types:
t
struct token { int code; void *value; }

variable_types:
gnum
double *

variable_types: num double

variable_types:
vchar
void *

user_defined_types: struct tokenadt { unsigned long size; unsigned long use; struct token *items; }


decompiled_code:
__int64 __fastcall akio_lex(__int64 a1, __int64 a2, const char *a3)
{
int v4; // er15
const unsigned __int16 **v5; // rbx
__int64 v6; // rax
__int64 v7; // rdx
int v8; // er10
int v9; // eax
__int64 result; // rax
int v11; // [rsp+Ch] [rbp-CCh]
int v12; // [rsp+10h] [rbp-C8h] BYREF
__int64 v13; // [rsp+18h] [rbp-C0h]
char v14[184]; // [rsp+20h] [rbp-B8h] BYREF

v11 = strlen(a3);
if ( v11 <= 0 )
{
LABEL_10:
v12 = 11;
v13 = 0LL;
token_adt_append(a1, &v12);
result = 0LL;
}
else
{
v4 = 0;
v5 = _ctype_b_loc();
while ( 1 )
{
v6 = v4;
do
{
v7 = a3[v6];
v8 = v6++;
}
while ( ((*v5)[v7] & 0x2000) != 0 );
memset(v14, 0, 0x80uLL);
v9 = get_next_op((__int64)a3, (__int64)v14, v8);
v4 = v9;
switch ( v9 )
{
case 717:
printf("SyntaxError: invalid syntax \"%s\"\n", v14);
return 1LL;
case 718:
printf("SyntaxError: invalid token \"%s\"\n", v14);
return 1LL;
case 719:
printf("SyntaxError: ? must a first \"%s\"\n", v14);
return 1LL;
}
if ( v9 == 720 )
break;
create_tokens_array(a1, a2, v14);
if ( v11 <= v4 )
goto LABEL_10;
}
printf("TokenError: token '%s' too long\n", v14);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2, const char *a3)
{
int v4; // er15
const unsigned __int16 **v5; // rbx
__int64 v6; // rax
__int64 v7; // rdx
int v8; // er10
int v9; // eax
__int64 result; // rax
int v11; // [rsp+Ch] [rbp-CCh]
int v12; // [rsp+10h] [rbp-C8h] BYREF
__int64 v13; // [rsp+18h] [rbp-C0h]
char v14[184]; // [rsp+20h] [rbp-B8h] BYREF

v11 = strlen(a3);
if ( v11 <= 0 )
{
LABEL_10:
v12 = 11;
v13 = 0LL;
token_adt_append(a1, &v12);
result = 0LL;
}
else
{
v4 = 0;
v5 = _ctype_b_loc();
while ( 1 )
{
v6 = v4;
do
{
v7 = a3[v6];
v8 = v6++;
}
while ( ((*v5)[v7] & 0x2000) != 0 );
memset(v14, 0, 0x80uLL);
v9 = func1((__int64)a3, (__int64)v14, v8);
v4 = v9;
switch ( v9 )
{
case 717:
printf("SyntaxError: invalid syntax \"%s\"\n", v14);
return 1LL;
case 718:
printf("SyntaxError: invalid token \"%s\"\n", v14);
return 1LL;
case 719:
printf("SyntaxError: ? must a first \"%s\"\n", v14);
return 1LL;
}
if ( v9 == 720 )
break;
func2(a1, a2, v14);
if ( v11 <= v4 )
goto LABEL_10;
}
printf("TokenError: token '%s' too long\n", v14);
result = 1LL;
}
return result;
}

original_code:
int akio_lex(tokenadt *tokens, valuepool *vpool, char *codes)
{
    int index = 0, len_str;
    char value[128];
    len_str = strlen(codes);
    while (index < len_str) {
        while (((*__ctype_b_loc ())[(int) ((codes[index]))] & (unsigned short int) _ISspace)) {
            index++;
        }
        memset(value, 0, 128);
        index = get_next_op(codes, value, index);
        if (index == 717) {
            printf("SyntaxError: invalid syntax \"%s\"\n", value);
            return 1;
        }
        else if (index == 718) {
            printf("SyntaxError: invalid token \"%s\"\n", value);
            return 1;
        }
        else if (index == 719) {
            printf("SyntaxError: ? must a first \"%s\"\n", value);
            return 1;
        }
        else if (index == 720) {
            printf("TokenError: token '%s' too long\n", value);
            return 1;
        } else {
            create_tokens_array(tokens, vpool, value);
        }
    }
    token t;
    t.code = T_BOUND;
    t.value = ((void *)0);
    token_adt_append(tokens, &t);
    return 0;
}

canonical_original_code:
int akio_lex(struct tokenadt *tokens, struct valuepool *vpool, char *codes)
{
    int index = 0; int len_str;
    char value[128];
    len_str = strlen(codes);
    while (index < len_str) {
        while (((*__ctype_b_loc ())[(int) ((codes[index]))] & (unsigned short) _ISspace)) {
            index++;
        }
        memset(value, 0, 128);
        index = get_next_op(codes, value, index);
        if (index == 717) {
            printf("SyntaxError: invalid syntax \"%s\"\n", value);
            return 1;
        }
        else if (index == 718) {
            printf("SyntaxError: invalid token \"%s\"\n", value);
            return 1;
        }
        else if (index == 719) {
            printf("SyntaxError: ? must a first \"%s\"\n", value);
            return 1;
        }
        else if (index == 720) {
            printf("TokenError: token '%s' too long\n", value);
            return 1;
        } else {
            create_tokens_array(tokens, vpool, value);
        }
    }
    struct token t;
    t.code = T_BOUND;
    t.value = ((void *)0);
    token_adt_append(tokens, &t);
    return 0;
}

variable_types: struct valuepool { unsigned long size; unsigned long use; void **values; } *

variable_types:
codes
char *

variable_types:
value
char [128]


original_code:
static unsigned long string_hash(const char *str) {
    unsigned long x;
    unsigned long len = 0;
    x = *str << 7;
    while (*str) {
        x = (1000003 * x) ^ *str++;
        len++;
    }
    x ^= len;
    return x;
}

canonical_original_code:
static unsigned long string_hash(char *str) {
    unsigned long x;
    unsigned long len = 0;
    x = *str << 7;
    while (*str) {
        x = (1000003 * x) ^ *str++;
        len++;
    }
    x ^= len;
    return x;
}

variable_types:
x
unsigned long

variable_types:
len
unsigned long

return_type: unsigned long


decompiled_code:
_QWORD *numdict_new()
{
return numdict_new(512LL);
}

canonical_decompiled_code:
_QWORD *func1()
{
return func1(512LL);
}

canonical_original_code:
struct numdict *numdict_new()
{
    return _numdict_new((1 << 9));
}

return_type: struct numdict { unsigned long size; unsigned long use; struct dictitem { char *key; void *value; } *items; } *

user_defined_types: struct numdict { unsigned long size; unsigned long use; struct dictitem *items; }


decompiled_code:
void __fastcall numdict_delete(void *ptr)
{
if ( ptr )
{
free(*((void **)ptr + 2));
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func2(void *ptr)
{
if ( ptr )
{
free(*((void **)ptr + 2));
free(ptr);
}
}

original_code:
void numdict_delete(numdict *dict)
{
    if (dict == ((void *)0)) {
        return;
    }
    free(dict->items);
    free(dict);
}

canonical_original_code:
void numdict_delete(struct numdict *dict)
{
    if (dict == ((void *)0)) {
        return;
    }
    free(dict->items);
    free(dict);
}

variable_types: struct numdict { unsigned long size; unsigned long use; struct dictitem { char *key; void *value; } *items; } *


original_code:
int numdict_put(numdict *dict, char *key, void * const value)
{
    dictitem *item;
    if (dict == ((void *)0)) {
        return 0;
    }
    if (key == ((void *)0) || value == ((void *)0)) {
        return 0;
    }
    if (dict->use * 3 >= dict->size * 2) {
        numdict_resize(dict);
    }
    unsigned long hash = string_hash(key);
    unsigned long index = hash;
    unsigned long perturb = hash;
    while (1) {
        index = index & (dict->size - 1);
        item = &(dict->items[index]);
        if ((item->key != ((void *)0)) && (!strcmp(item->key, key))) {
            item->value = value;
            return 1;
        }
        if (item->key == ((void *)0)) {
            item->key = key;
            item->value = value;
            dict->use++;
            return 1;
        }
        perturb >>= 5;
        index = (index << 2) + index + perturb + 1;
    }
}

canonical_original_code:
int numdict_put(struct numdict *dict, char *key, void *value)
{
    struct dictitem *item;
    if (dict == ((void *)0)) {
        return 0;
    }
    if (key == ((void *)0) || value == ((void *)0)) {
        return 0;
    }
    if (dict->use * 3 >= dict->size * 2) {
        numdict_resize(dict);
    }
    unsigned long hash = string_hash(key);
    unsigned long index = hash;
    unsigned long perturb = hash;
    while (1) {
        index = index & (dict->size - 1);
        item = &(dict->items[index]);
        if ((item->key != ((void *)0)) && (!strcmp(item->key, key))) {
            item->value = value;
            return 1;
        }
        if (item->key == ((void *)0)) {
            item->key = key;
            item->value = value;
            dict->use++;
            return 1;
        }
        perturb >>= 5;
        index = (index << 2) + index + perturb + 1;
    }
}

variable_types:
key
char *

variable_types:
value
void *

variable_types: struct dictitem { char *key; void *value; } *

variable_types:
hash
unsigned long

variable_types:
index
unsigned long

variable_types:
perturb
unsigned long


original_code:
static void numdict_resize(numdict *dict)
{
    unsigned long oldsize, newsize, olduse, i;
    dictitem *item, *temp;
    numdict *newdict;
    oldsize = dict->size;
    olduse = dict->use;
    newsize = oldsize << 1;
    newdict = _numdict_new(newsize);
    if (newdict == ((void *)0)) {
        return;
    }
    for (i = 0; (olduse > 0) && (i < oldsize); i++) {
        item = &(dict->items[i]);
        if (item->key) {
            if (numdict_put(newdict, item->key, item->value)) {
                olduse--;
            }
        }
    }
    if (!olduse) {
        temp = dict->items;
        dict->items = newdict->items;
        dict->size = newsize;
        newdict->items = temp;
        newdict->size = oldsize;
    }
    numdict_delete(newdict);
}

canonical_original_code:
static void numdict_resize(struct numdict *dict)
{
    unsigned long oldsize; unsigned long newsize; unsigned long olduse; unsigned long i;
    struct dictitem *item; struct dictitem *temp;
    struct numdict *newdict;
    oldsize = dict->size;
    olduse = dict->use;
    newsize = oldsize << 1;
    newdict = _numdict_new(newsize);
    if (newdict == ((void *)0)) {
        return;
    }
    for (i = 0; (olduse > 0) && (i < oldsize); i++) {
        item = &(dict->items[i]);
        if (item->key) {
            if (numdict_put(newdict, item->key, item->value)) {
                olduse--;
            }
        }
    }
    if (!olduse) {
        temp = dict->items;
        dict->items = newdict->items;
        dict->size = newsize;
        newdict->items = temp;
        newdict->size = oldsize;
    }
    numdict_delete(newdict);
}

variable_types:
oldsize
unsigned long

variable_types:
newsize
unsigned long

variable_types:
olduse
unsigned long

variable_types:
i
unsigned long

user_defined_types: struct dictitem { char *key; void *value; }


decompiled_code:
const char *__fastcall numdict_get(__int64 a1, char *a2)
{
__int64 v2; // rax
_QWORD *v3; // rcx
__int64 v4; // r14
unsigned __int64 v5; // r15
__int64 v6; // r13
__int64 i; // rbx
__int64 v8; // rbp
const char *v9; // rdi

if ( !a2 || !a1 )
return 0LL;
v2 = string_hash(a2);
v4 = v3[2];
v5 = v2;
v6 = *v3 - 1LL;
for ( i = v6 & v2; ; i = v6 & (i + v5 + 1 + 4 * i) )
{
v8 = v4 + 16 * i;
v9 = *(const char **)v8;
if ( !*(_QWORD *)v8 )
break;
if ( !strcmp(v9, a2) )
return *(const char **)(v8 + 8);
v5 >>= 5;
}
return v9;
}

canonical_decompiled_code:
const char *__fastcall func5(__int64 a1, char *a2)
{
__int64 v2; // rax
_QWORD *v3; // rcx
__int64 v4; // r14
unsigned __int64 v5; // r15
__int64 v6; // r13
__int64 i; // rbx
__int64 v8; // rbp
const char *v9; // rdi

if ( !a2 || !a1 )
return 0LL;
v2 = func0(a2);
v4 = v3[2];
v5 = v2;
v6 = *v3 - 1LL;
for ( i = v6 & v2; ; i = v6 & (i + v5 + 1 + 4 * i) )
{
v8 = v4 + 16 * i;
v9 = *(const char **)v8;
if ( !*(_QWORD *)v8 )
break;
if ( !strcmp(v9, a2) )
return *(const char **)(v8 + 8);
v5 >>= 5;
}
return v9;
}

original_code:
void *numdict_get(const numdict *dict, const char *key)
{
    dictitem *item;
    if (dict == ((void *)0)) {
        return ((void *)0);
    }
    if (key == ((void *)0)) {
        return ((void *)0);
    }
    unsigned long hash = string_hash(key);
    unsigned long index = hash;
    unsigned long perturb = hash;
    while (1) {
        index = index & (dict->size - 1);
        item = &(dict->items[index]);
        if (item->key == ((void *)0)) {
            return ((void *)0);
        }
        if ((item->key != ((void *)0)) && (!strcmp(item->key, key))) {
            return item->value;
        }
        perturb >>= 5;
        index = (index << 2) + index + perturb + 1;
    }
}

canonical_original_code:
void *numdict_get(struct numdict *dict, char *key)
{
    struct dictitem *item;
    if (dict == ((void *)0)) {
        return ((void *)0);
    }
    if (key == ((void *)0)) {
        return ((void *)0);
    }
    unsigned long hash = string_hash(key);
    unsigned long index = hash;
    unsigned long perturb = hash;
    while (1) {
        index = index & (dict->size - 1);
        item = &(dict->items[index]);
        if (item->key == ((void *)0)) {
            return ((void *)0);
        }
        if ((item->key != ((void *)0)) && (!strcmp(item->key, key))) {
            return item->value;
        }
        perturb >>= 5;
        index = (index << 2) + index + perturb + 1;
    }
}


decompiled_code:
void __fastcall token_adt_reset(__int64 a1)
{
if ( a1 )
*(_QWORD *)(a1 + 8) = 0LL;
}

canonical_decompiled_code:
void __fastcall func0(__int64 a1)
{
if ( a1 )
*(_QWORD *)(a1 + 8) = 0LL;
}

original_code:
void token_adt_reset(tokenadt *tokens)
{
    if (tokens == ((void *)0)) {
        return;
    }
    tokens->use = 0;
}

canonical_original_code:
void token_adt_reset(struct tokenadt *tokens)
{
    if (tokens == ((void *)0)) {
        return;
    }
    tokens->use = 0;
}

variable_types: struct tokenadt { unsigned long size; unsigned long use; struct token { int code; void *value; } *items; } *


decompiled_code:
void __fastcall token_adt_delete(void *ptr)
{
if ( ptr )
{
free(*((void **)ptr + 2));
free(ptr);
}
}

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

original_code:
void token_adt_delete(tokenadt *tokens)
{
    if (tokens == ((void *)0)) {
        return;
    }
    free(tokens->items);
    free(tokens);
}

canonical_original_code:
void token_adt_delete(struct tokenadt *tokens)
{
    if (tokens == ((void *)0)) {
        return;
    }
    free(tokens->items);
    free(tokens);
}


decompiled_code:
__int64 __fastcall token_adt_append(_QWORD *a1, __int64 a2)
{
__int64 v2; // rdx
__int64 result; // rax
__int64 v4; // rax

if ( !a1 )
return 0LL;
v2 = a1[1];
result = 0LL;
if ( *a1 != v2 )
{
v4 = a1[2] + 16LL * (int)v2;
*(_DWORD *)v4 = *(_DWORD *)a2;
*(_QWORD *)(v4 + 8) = *(_QWORD *)(a2 + 8);
result = 1LL;
a1[1] = v2 + 1;
}
return result;
}

original_code:
int token_adt_append(tokenadt *tokens, token *item)
{
    int i = 0;
    token *t;
    if (tokens == ((void *)0)) {
        return 0;
    }
    if (tokens->size == tokens->use) {
        return 0;
    }
    i = tokens->use;
    t = &(tokens->items[i]);
    t->code = item->code;
    t->value = item->value;
    tokens->use++;
    return 1;
}

canonical_original_code:
int token_adt_append(struct tokenadt *tokens, struct token *item)
{
    int i = 0;
    struct token *t;
    if (tokens == ((void *)0)) {
        return 0;
    }
    if (tokens->size == tokens->use) {
        return 0;
    }
    i = tokens->use;
    t = &(tokens->items[i]);
    t->code = item->code;
    t->value = item->value;
    tokens->use++;
    return 1;
}

variable_types:
item
struct token *

variable_types: i int

variable_types: struct token { int code; void *value; } *


decompiled_code:
__int64 __fastcall arith_reduction(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 result; // rax
double v7; // xmm0_8
unsigned __int64 v8; // rbx
unsigned __int64 v9; // r12
int v10; // eax
double v11; // xmm0_8
double v12; // [rsp+0h] [rbp-38h]
double v13; // [rsp+8h] [rbp-30h]

result = 752LL;
if ( *(_DWORD *)a2 == 12 )
{
if ( *(_DWORD *)a1 != 12 )
{
if ( *(_DWORD *)a3 == 2 )
{
v7 = 0.0 - **(double **)(a2 + 8);
v8 = (unsigned __int64)malloc(8uLL);
*(double *)v8 = v7;
value_pool_append(a4, v8 | 1);
*(_QWORD *)(a3 + 8) = v8;
result = 1LL;
*(_DWORD *)a3 = 12;
}
return result;
}
v13 = **(double **)(a1 + 8);
v12 = **(double **)(a2 + 8);
v9 = (unsigned __int64)malloc(8uLL);
v10 = *(_DWORD *)a3;
if ( *(_DWORD *)a3 == 3 )
{
v11 = v13 * v12;
goto LABEL_10;
}
if ( v10 <= 3 )
{
if ( v10 == 1 )
{
v11 = v13 + v12;
goto LABEL_10;
}
if ( v10 == 2 )
{
v11 = v13 - v12;
goto LABEL_10;
}
}
else if ( v10 == 4 )
{
result = 753LL;
if ( v12 == 0.0 )
return result;
v11 = v13 / v12;
LABEL_10:
*(double *)v9 = v11;
value_pool_append(a4, v9 | 1);
*(_DWORD *)a1 = 12;
result = 0LL;
*(_QWORD *)(a1 + 8) = v9;
return result;
}
free((void *)v9);
result = 751LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 result; // rax
double v7; // xmm0_8
unsigned __int64 v8; // rbx
unsigned __int64 v9; // r12
int v10; // eax
double v11; // xmm0_8
double v12; // [rsp+0h] [rbp-38h]
double v13; // [rsp+8h] [rbp-30h]

result = 752LL;
if ( *(_DWORD *)a2 == 12 )
{
if ( *(_DWORD *)a1 != 12 )
{
if ( *(_DWORD *)a3 == 2 )
{
v7 = 0.0 - **(double **)(a2 + 8);
v8 = (unsigned __int64)malloc(8uLL);
*(double *)v8 = v7;
value_pool_append(a4, v8 | 1);
*(_QWORD *)(a3 + 8) = v8;
result = 1LL;
*(_DWORD *)a3 = 12;
}
return result;
}
v13 = **(double **)(a1 + 8);
v12 = **(double **)(a2 + 8);
v9 = (unsigned __int64)malloc(8uLL);
v10 = *(_DWORD *)a3;
if ( *(_DWORD *)a3 == 3 )
{
v11 = v13 * v12;
goto LABEL_10;
}
if ( v10 <= 3 )
{
if ( v10 == 1 )
{
v11 = v13 + v12;
goto LABEL_10;
}
if ( v10 == 2 )
{
v11 = v13 - v12;
goto LABEL_10;
}
}
else if ( v10 == 4 )
{
result = 753LL;
if ( v12 == 0.0 )
return result;
v11 = v13 / v12;
LABEL_10:
*(double *)v9 = v11;
value_pool_append(a4, v9 | 1);
*(_DWORD *)a1 = 12;
result = 0LL;
*(_QWORD *)(a1 + 8) = v9;
return result;
}
free((void *)v9);
result = 751LL;
}
return result;
}

original_code:
static int arith_reduction(token *l, token *r, token *op, valuepool *vpool)
{
    int isneg = 0;
    double left, right, *result = ((void *)0);
    left = right = 0;
    if (r->code != 12) {
        return 752;
    }
    if (l->code != T_N) {
        if (op->code == T_MINUS) {
            left = 0;
            isneg = 1;
        } else {
            return 752;
        }
    } else {
        left = *(double *)(l->value);
    }
    right = *(double *)(r->value);
    result = (double *)malloc(sizeof(double));
    switch (op->code) {
        case T_PLUS: {
            *result = left + right;
            break;
        }
        case T_MINUS: {
            *result = left - right;
            break;
        }
        case T_MULTI: {
            *result = left * right;
            break;
        }
        case T_DIVI: {
            if (right == 0) {
                return 753;
            }
            *result = left / right;
            break;
        }
        default: {
            free(result);
            return 751;
        }
    }
    value_pool_append(vpool, ((void *)((unsigned long) (result) | 0x1)));
    if (isneg) {
        op->code = T_N;
        op->value = result;
    } else {
        l->code = T_N;
        l->value = result;
    }
    return isneg;
}

canonical_original_code:
static int arith_reduction(struct token *l, struct token *r, struct token *op, struct valuepool *vpool)
{
    int isneg = 0;
    double left; double right; double *result = ((void *)0);
    left = right = 0;
    if (r->code != 12) {
        return 752;
    }
    if (l->code != T_N) {
        if (op->code == T_MINUS) {
            left = 0;
            isneg = 1;
        } else {
            return 752;
        }
    } else {
        left = *(double *)(l->value);
    }
    right = *(double *)(r->value);
    result = (double *)malloc(sizeof(double));
    switch (op->code) {
        case T_PLUS: {
            *result = left + right;
            break;
        }
        case T_MINUS: {
            *result = left - right;
            break;
        }
        case T_MULTI: {
            *result = left * right;
            break;
        }
        case T_DIVI: {
            if (right == 0) {
                return 753;
            }
            *result = left / right;
            break;
        }
        default: {
            free(result);
            return 751;
        }
    }
    value_pool_append(vpool, ((void *)((unsigned long) (result) | 0x1)));
    if (isneg) {
        op->code = T_N;
        op->value = result;
    } else {
        l->code = T_N;
        l->value = result;
    }
    return isneg;
}

variable_types:
r
struct token *

variable_types:
op
struct token *

variable_types: struct valuepool { unsigned long size; unsigned long use; void **values; } *

variable_types: isneg int

variable_types: left double

variable_types: right double

variable_types:
result
double *


repo: Shakadak/C-Experiment

decompiled_code:
__int64 __fastcall check_vertical(__int64 a1, int a2, int a3)
{
__int64 v3; // r10
__int64 v4; // rcx
int v5; // er9
__int64 v7; // r11
char v8; // si
_QWORD *v9; // rdx
int v10; // er9
__int64 result; // rax
_QWORD *v12; // rdx
int v13; // er8

v3 = *(_QWORD *)(a1 + 8);
v4 = a3;
v5 = *(_DWORD *)(a1 + 4);
v7 = 8LL * a2;
v8 = *(_BYTE *)(*(_QWORD *)(v3 + v7) + a3);
if ( a2 + 1 >= v5 )
{
result = 1LL;
}
else
{
v9 = (_QWORD *)(v3 + v7 + 8);
v10 = v5 - a2;
result = 1LL;
do
{
if ( *(_BYTE *)(*v9 + v4) != v8 )
break;
result = (unsigned int)(result + 1);
++v9;
}
while ( (_DWORD)result != v10 );
}
if ( a2 > 0 )
{
v12 = (_QWORD *)(v3 + v7 - 8);
v13 = result + a2;
do
{
if ( *(_BYTE *)(*v12 + v4) != v8 )
break;
result = (unsigned int)(result + 1);
--v12;
}
while ( v13 != (_DWORD)result );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, int a2, int a3)
{
__int64 v3; // r10
__int64 v4; // rcx
int v5; // er9
__int64 v7; // r11
char v8; // si
_QWORD *v9; // rdx
int v10; // er9
__int64 result; // rax
_QWORD *v12; // rdx
int v13; // er8

v3 = *(_QWORD *)(a1 + 8);
v4 = a3;
v5 = *(_DWORD *)(a1 + 4);
v7 = 8LL * a2;
v8 = *(_BYTE *)(*(_QWORD *)(v3 + v7) + a3);
if ( a2 + 1 >= v5 )
{
result = 1LL;
}
else
{
v9 = (_QWORD *)(v3 + v7 + 8);
v10 = v5 - a2;
result = 1LL;
do
{
if ( *(_BYTE *)(*v9 + v4) != v8 )
break;
result = (unsigned int)(result + 1);
++v9;
}
while ( (_DWORD)result != v10 );
}
if ( a2 > 0 )
{
v12 = (_QWORD *)(v3 + v7 - 8);
v13 = result + a2;
do
{
if ( *(_BYTE *)(*v12 + v4) != v8 )
break;
result = (unsigned int)(result + 1);
--v12;
}
while ( v13 != (_DWORD)result );
}
return result;
}

original_code:
int check_vertical(t_grid *grid, int row, int col)
{
 char origin;
 int i;
 int size;
 size = 1;
 i = row;
 origin = grid->grid[row][col];
 while (++i < grid->y && grid->grid[i][col] == origin)
  size++;
 i = row;
 while (--i >= 0 && grid->grid[i][col] == origin)
  size++;
 return (size);
}

canonical_original_code:
int check_vertical(struct s_grid *grid, int row, int col)
{
 char origin;
 int i;
 int size;
 size = 1;
 i = row;
 origin = grid->grid[row][col];
 while (++i < grid->y && grid->grid[i][col] == origin)
  size++;
 i = row;
 while (--i >= 0 && grid->grid[i][col] == origin)
  size++;
 return (size);
}

variable_types: struct s_grid { int x; int y; char **grid; } *

variable_types: row int

variable_types: col int

variable_types: origin char

variable_types: size int


decompiled_code:
__int64 __fastcall check_horizontal(__int64 a1, int a2, int a3)
{
__int64 v5; // rcx
char v6; // si
int v7; // edx
int v8; // er8
__int64 result; // rax
_BYTE *v10; // rdx
_BYTE *v11; // rdx
int v12; // ecx

v5 = *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL * a2);
v6 = *(_BYTE *)(v5 + a3);
v7 = a3 + 1;
if ( v7 >= *(_DWORD *)a1 )
{
result = 1LL;
}
else
{
v8 = *(_DWORD *)a1 - a3;
result = 1LL;
v10 = (_BYTE *)(v5 + v7);
do
{
if ( *v10 != v6 )
break;
result = (unsigned int)(result + 1);
++v10;
}
while ( (_DWORD)result != v8 );
}
if ( a3 - 1 >= 0 )
{
v11 = (_BYTE *)(v5 + a3 - 1);
v12 = result + a3;
do
{
if ( *v11 != v6 )
break;
result = (unsigned int)(result + 1);
--v11;
}
while ( (_DWORD)result != v12 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, int a2, int a3)
{
__int64 v5; // rcx
char v6; // si
int v7; // edx
int v8; // er8
__int64 result; // rax
_BYTE *v10; // rdx
_BYTE *v11; // rdx
int v12; // ecx

v5 = *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL * a2);
v6 = *(_BYTE *)(v5 + a3);
v7 = a3 + 1;
if ( v7 >= *(_DWORD *)a1 )
{
result = 1LL;
}
else
{
v8 = *(_DWORD *)a1 - a3;
result = 1LL;
v10 = (_BYTE *)(v5 + v7);
do
{
if ( *v10 != v6 )
break;
result = (unsigned int)(result + 1);
++v10;
}
while ( (_DWORD)result != v8 );
}
if ( a3 - 1 >= 0 )
{
v11 = (_BYTE *)(v5 + a3 - 1);
v12 = result + a3;
do
{
if ( *v11 != v6 )
break;
result = (unsigned int)(result + 1);
--v11;
}
while ( (_DWORD)result != v12 );
}
return result;
}

original_code:
int check_horizontal(t_grid *grid, int row, int col)
{
 char origin;
 int j;
 int size;
 size = 1;
 j = col;
 origin = grid->grid[row][col];
 while (++j < grid->x && grid->grid[row][j] == origin)
  size++;
 j = col;
 while (--j >= 0 && grid->grid[row][j] == origin)
  size++;
 return (size);
}

canonical_original_code:
int check_horizontal(struct s_grid *grid, int row, int col)
{
 char origin;
 int j;
 int size;
 size = 1;
 j = col;
 origin = grid->grid[row][col];
 while (++j < grid->x && grid->grid[row][j] == origin)
  size++;
 j = col;
 while (--j >= 0 && grid->grid[row][j] == origin)
  size++;
 return (size);
}

variable_types: j int

user_defined_types: struct s_grid { int x; int y; char **grid; }


decompiled_code:
__int64 __fastcall check_diagonal_up(__int64 a1, int a2, int a3)
{
__int64 v3; // r11
__int64 v5; // rbp
__int64 v7; // rbx
int v8; // er9
char v9; // si
__int64 v10; // rdx
int v11; // er9
__int64 result; // rax
__int64 v13; // rdx
int v14; // ecx
int v15; // er8
__int64 v16; // rbx

v3 = a3;
v5 = 8LL * a2;
v7 = *(_QWORD *)(a1 + 8);
v8 = *(_DWORD *)(a1 + 4);
v9 = *(_BYTE *)(*(_QWORD *)(v7 + v5) + a3);
if ( a2 + 1 >= v8 )
{
result = 1LL;
}
else
{
v10 = a3 + 1LL;
v11 = v8 - a2;
result = 1LL;
do
{
if ( *(_DWORD *)a1 <= a3 + (int)result )
break;
if ( *(_BYTE *)(*(_QWORD *)(v7 + v5 - 8 * v3 + 8 * v10) + v10) != v9 )
break;
result = (unsigned int)(result + 1);
++v10;
}
while ( (_DWORD)result != v11 );
}
if ( a2 > 0 )
{
LODWORD(v13) = a3 - 1;
if ( a3 - 1 >= 0 )
{
v13 = (int)v13;
v14 = result + a3;
v15 = result + a2;
v16 = v5 - 8 * v3 + v7;
do
{
if ( *(_BYTE *)(*(_QWORD *)(v16 + 8 * v13) + v13) != v9 )
break;
result = (unsigned int)(result + 1);
if ( (_DWORD)result == v15 )
break;
--v13;
}
while ( (_DWORD)result != v14 );
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, int a2, int a3)
{
__int64 v3; // r11
__int64 v5; // rbp
__int64 v7; // rbx
int v8; // er9
char v9; // si
__int64 v10; // rdx
int v11; // er9
__int64 result; // rax
__int64 v13; // rdx
int v14; // ecx
int v15; // er8
__int64 v16; // rbx

v3 = a3;
v5 = 8LL * a2;
v7 = *(_QWORD *)(a1 + 8);
v8 = *(_DWORD *)(a1 + 4);
v9 = *(_BYTE *)(*(_QWORD *)(v7 + v5) + a3);
if ( a2 + 1 >= v8 )
{
result = 1LL;
}
else
{
v10 = a3 + 1LL;
v11 = v8 - a2;
result = 1LL;
do
{
if ( *(_DWORD *)a1 <= a3 + (int)result )
break;
if ( *(_BYTE *)(*(_QWORD *)(v7 + v5 - 8 * v3 + 8 * v10) + v10) != v9 )
break;
result = (unsigned int)(result + 1);
++v10;
}
while ( (_DWORD)result != v11 );
}
if ( a2 > 0 )
{
LODWORD(v13) = a3 - 1;
if ( a3 - 1 >= 0 )
{
v13 = (int)v13;
v14 = result + a3;
v15 = result + a2;
v16 = v5 - 8 * v3 + v7;
do
{
if ( *(_BYTE *)(*(_QWORD *)(v16 + 8 * v13) + v13) != v9 )
break;
result = (unsigned int)(result + 1);
if ( (_DWORD)result == v15 )
break;
--v13;
}
while ( (_DWORD)result != v14 );
}
}
return result;
}

original_code:
int check_diagonal_up(t_grid *g, int row, int col)
{
 char origin;
 int i;
 int j;
 int size;
 size = 1;
 i = row;
 j = col;
 origin = g->grid[row][col];
 while (++i < g->y && ++j < g->x && g->grid[i][j] == origin)
  size++;
 i = row;
 j = col;
 while (--i >= 0 && --j >= 0 && g->grid[i][j] == origin)
  size++;
 return (size);
}

canonical_original_code:
int check_diagonal_up(struct s_grid *g, int row, int col)
{
 char origin;
 int i;
 int j;
 int size;
 size = 1;
 i = row;
 j = col;
 origin = g->grid[row][col];
 while (++i < g->y && ++j < g->x && g->grid[i][j] == origin)
  size++;
 i = row;
 j = col;
 while (--i >= 0 && --j >= 0 && g->grid[i][j] == origin)
  size++;
 return (size);
}


decompiled_code:
__int64 __fastcall check_diagonal_down(int *a1, int a2, int a3)
{
__int64 v3; // r10
__int64 v4; // rbp
__int64 v5; // rdx
__int64 v7; // rdi
int v8; // er12
char v9; // r8
int v10; // er12
__int64 result; // rax
int v12; // esi
int v13; // ebx
__int64 v14; // rdx
__int64 v15; // r10
int v16; // ecx

v3 = a2;
v4 = a3;
LODWORD(v5) = a2 + 1;
v7 = *((_QWORD *)a1 + 1);
v8 = a1[1];
v9 = *(_BYTE *)(*(_QWORD *)(v7 + 8LL * a2) + v4);
if ( a2 + 1 >= v8 || (int)v4 <= 0 )
{
result = 1LL;
}
else
{
v5 = (int)v5;
v10 = v8 - a2;
result = 1LL;
do
{
if ( *(_BYTE *)(*(_QWORD *)(v7 + 8 * v5) + a2 + v4 - v5) != v9 )
break;
result = (unsigned int)(result + 1);
if ( (_DWORD)result == v10 )
break;
++v5;
}
while ( (_DWORD)result != (_DWORD)v4 + 1 );
}
v12 = a2 - 1;
if ( v12 >= 0 )
{
v13 = *a1;
v14 = v12;
v15 = v4 + v3;
v16 = v4 + 1 - result;
do
{
if ( v16 + (int)result >= v13 )
break;
if ( *(_BYTE *)(*(_QWORD *)(v7 + 8 * v14) + v15 - v14) != v9 )
break;
--v14;
result = (unsigned int)(result + 1);
}
while ( (int)v14 >= 0 );
}
return result;
}

original_code:
int check_diagonal_down(t_grid *grid, int row, int col)
{
 char origin;
 int i;
 int j;
 int size;
 size = 1;
 i = row;
 j = col;
 origin = grid->grid[row][col];
 while (++i < grid->y && --j >= 0 && grid->grid[i][j] == origin)
  size++;
 i = row;
 j = col;
 while (--i >= 0 && ++j < grid->x && grid->grid[i][j] == origin)
  size++;
 return (size);
}

canonical_original_code:
int check_diagonal_down(struct s_grid *grid, int row, int col)
{
 char origin;
 int i;
 int j;
 int size;
 size = 1;
 i = row;
 j = col;
 origin = grid->grid[row][col];
 while (++i < grid->y && --j >= 0 && grid->grid[i][j] == origin)
  size++;
 i = row;
 j = col;
 while (--i >= 0 && ++j < grid->x && grid->grid[i][j] == origin)
  size++;
 return (size);
}


decompiled_code:
__int64 __fastcall check_four(__int64 a1, int a2, int a3)
{
__int64 v3; // rbx
int v4; // er8
__int64 result; // rax

v3 = a3;
if ( (int)check_vertical(a1, a2, a3) > 3
|| (int)check_horizontal(a1, a2, v3) > 3
|| (int)check_diagonal_up(a1, a2, v3) > 3
|| (v4 = check_diagonal_down((int *)a1, a2, v3), result = 0LL, v4 > 3) )
{
result = (unsigned int)*(char *)(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL * a2) + v3);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, int a2, int a3)
{
__int64 v3; // rbx
int v4; // er8
__int64 result; // rax

v3 = a3;
if ( (int)func0(a1, a2, a3) > 3
|| (int)func1(a1, a2, v3) > 3
|| (int)func2(a1, a2, v3) > 3
|| (v4 = func3((int *)a1, a2, v3), result = 0LL, v4 > 3) )
{
result = (unsigned int)*(char *)(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL * a2) + v3);
}
return result;
}

original_code:
int check_four(t_grid *grid, int row, int col)
{
 if (check_vertical(grid, row, col) > 3)
  return ((int)grid->grid[row][col]);
 if (check_horizontal(grid, row, col) > 3)
  return ((int)grid->grid[row][col]);
 if (check_diagonal_up(grid, row, col) > 3)
  return ((int)grid->grid[row][col]);
 if (check_diagonal_down(grid, row, col) > 3)
  return ((int)grid->grid[row][col]);
 return (0);
}

canonical_original_code:
int check_four(struct s_grid *grid, int row, int col)
{
 if (check_vertical(grid, row, col) > 3)
  return ((int)grid->grid[row][col]);
 if (check_horizontal(grid, row, col) > 3)
  return ((int)grid->grid[row][col]);
 if (check_diagonal_up(grid, row, col) > 3)
  return ((int)grid->grid[row][col]);
 if (check_diagonal_down(grid, row, col) > 3)
  return ((int)grid->grid[row][col]);
 return (0);
}


original_code:
int put_coin(t_grid *grid, int col, char player)
{
 int row;
 row = grid->y - 1;
 while (grid->grid[row][col])
  row--;
 grid->grid[row][col] = player;
 return (check_four(grid, row, col));
}

canonical_original_code:
int put_coin(struct s_grid *grid, int col, char player)
{
 int row;
 row = grid->y - 1;
 while (grid->grid[row][col])
  row--;
 grid->grid[row][col] = player;
 return (check_four(grid, row, col));
}

variable_types: player char


original_code:
void free_grid(t_grid *grid)
{
 int i;
 i = 0;
 while (i < grid->y)
  free(grid->grid[i++]);
 free(grid->grid);
 grid->grid = ((void *)0);
}

canonical_original_code:
void free_grid(struct s_grid *grid)
{
 int i;
 i = 0;
 while (i < grid->y)
  free(grid->grid[i++]);
 free(grid->grid);
 grid->grid = ((void *)0);
}


decompiled_code:
char *__fastcall ft_strchr(char *a1, int a2)
{
int v2; // eax
unsigned int v3; // edx
char *result; // rax

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

canonical_decompiled_code:
char *__fastcall func0(char *a1, int a2)
{
int v2; // eax
unsigned int v3; // edx
char *result; // rax

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

original_code:
char *ft_strchr(const char *src, int c)
{
 int i;
 int l;
 i = 0;
 l = ft_strlen(src);
 if (c == 0)
  return ((char *)&src[l]);
 while (i < l)
 {
  if (src[i] == c)
   return ((char *)&src[i]);
  i++;
 }
 return (((void *)0));
}

canonical_original_code:
char *ft_strchr(char *src, int c)
{
 int i;
 int l;
 i = 0;
 l = ft_strlen(src);
 if (c == 0)
  return ((char *)&src[l]);
 while (i < l)
 {
  if (src[i] == c)
   return ((char *)&src[i]);
  i++;
 }
 return (((void *)0));
}

variable_types:
src
char *

variable_types: c int

variable_types: l int

return_type: char *


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

if ( a1 )
result = ft_memdel();
return result;
}

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

if ( a1 )
result = ft_memdel();
return result;
}

original_code:
void ft_strdel(char **as)
{
 if (as)
  ft_memdel((void **)as);
}

variable_types:
as
char **


main

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

if ( argc == 1 )
{
ft_putendl("Pliss, gimme some list.", argv, envp);
result = -1;
}
else
{
v5 = 0LL;
v3 = ft_get_param(&v5, argv, (unsigned int)argc);
ft_select(v5, v3);
result = 0;
}
return result;
}

original_code:
int main(int argc, char **argv)
{
 t_alst *data;
 int width;
 if (argc == 1)
 {
  ft_putendl("Pliss, gimme some list.");
  return (-1);
 }
 data = ((void *)0);
 width = ft_get_param(&data, argv, argc);
 ft_select(data, width);
 return (0);
}

canonical_original_code:
int main(int argc, char **argv)
{
 struct s_alst *data;
 int width;
 if (argc == 1)
 {
  ft_putendl("Pliss, gimme some list.");
  return (-1);
 }
 data = ((void *)0);
 width = ft_get_param(&data, argv, argc);
 ft_select(data, width);
 return (0);
}

variable_types: argc int

variable_types:
argv
char **

variable_types: struct s_alst { char *param; int size; int select; int i; struct s_alst *next; struct s_alst *prev; } *

variable_types: width int


decompiled_code:
__int64 ft_putendl()
{
ft_putstr();
return ft_putchar(10LL);
}

canonical_decompiled_code:
__int64 func0()
{
ft_putstr();
return ft_putchar(10LL);
}

original_code:
void ft_putendl(const char *str)
{
 ft_putstr(str);
 ft_putchar('\n');
}

canonical_original_code:
void ft_putendl(char *str)
{
 ft_putstr(str);
 ft_putchar('\n');
}

variable_types:
str
char *


decompiled_code:
__int64 __fastcall ft_putendl_fd(__int64 a1, unsigned int a2)
{
ft_putstr_fd();
return ft_putchar_fd(10LL, a2);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, unsigned int a2)
{
ft_putstr_fd();
return ft_putchar_fd(10LL, a2);
}

original_code:
void ft_putendl_fd(const char *s, int fd)
{
 ft_putstr_fd(s, fd);
 ft_putchar_fd('\n', fd);
}

canonical_original_code:
void ft_putendl_fd(char *s, int fd)
{
 ft_putstr_fd(s, fd);
 ft_putchar_fd('\n', fd);
}

variable_types:
s
char *

variable_types: fd int


decompiled_code:
__int64 __fastcall ft_strcat(__int64 a1, char *a2)
{
unsigned int v4; // eax
char v5; // dl
__int64 v6; // rsi
unsigned int v7; // edi
__int64 v8; // rax

v4 = ft_strlen();
v5 = *a2;
v6 = v4;
if ( v5 )
{
v7 = v4;
LODWORD(v8) = 0;
do
{
*(_BYTE *)(a1 + (unsigned int)(v6 + v8)) = v5;
v8 = (unsigned int)(v8 + 1);
v5 = a2[v8];
}
while ( v5 );
v6 = (unsigned int)v8 + v7;
}
*(_BYTE *)(a1 + v6) = 0;
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, char *a2)
{
unsigned int v4; // eax
char v5; // dl
__int64 v6; // rsi
unsigned int v7; // edi
__int64 v8; // rax

v4 = ft_strlen();
v5 = *a2;
v6 = v4;
if ( v5 )
{
v7 = v4;
LODWORD(v8) = 0;
do
{
*(_BYTE *)(a1 + (unsigned int)(v6 + v8)) = v5;
v8 = (unsigned int)(v8 + 1);
v5 = a2[v8];
}
while ( v5 );
v6 = (unsigned int)v8 + v7;
}
*(_BYTE *)(a1 + v6) = 0;
return a1;
}

original_code:
char *ft_strcat(char *dest, const char *src)
{
 unsigned int index;
 unsigned int length;
 length = ft_strlen(dest);
 index = 0;
 while (src[index] != 0)
 {
  dest[index + length] = src[index];
  index++;
 }
 dest[index + length] = 0;
 return (dest);
}

canonical_original_code:
char *ft_strcat(char *dest, char *src)
{
 unsigned int index;
 unsigned int length;
 length = ft_strlen(dest);
 index = 0;
 while (src[index] != 0)
 {
  dest[index + length] = src[index];
  index++;
 }
 dest[index + length] = 0;
 return (dest);
}

variable_types:
dest
char *

variable_types:
index
unsigned int

variable_types:
length
unsigned int


decompiled_code:
_BOOL8 ft_strequ()
{
return (unsigned int)ft_strcmp() == 0;
}

canonical_decompiled_code:
_BOOL8 func0()
{
return (unsigned int)ft_strcmp() == 0;
}

original_code:
int ft_strequ(const char *s1, const char *s2)
{
 return (!ft_strcmp(s1, s2));
}

canonical_original_code:
int ft_strequ(char *s1, char *s2)
{
 return (!ft_strcmp(s1, s2));
}


decompiled_code:
void *__fastcall ft_memmove(void *dest, unsigned __int64 a2, size_t a3)
{
void *v4; // rsp
__int64 v6; // [rsp+0h] [rbp-20h] BYREF
unsigned __int64 v7; // [rsp+8h] [rbp-18h]

v4 = alloca(a3);
if ( a2 == 0 || dest == 0LL || !a3 )
return dest;
v7 = a2;
ft_memcpy(&v6, a2, a3);
if ( (unsigned __int64)dest <= v7 )
{
ft_memcpy(dest, &v6, a3);
return dest;
}
memcpy(dest, &v6, a3);
return dest;
}

canonical_decompiled_code:
void *__fastcall func0(void *dest, unsigned __int64 a2, size_t a3)
{
void *v4; // rsp
__int64 v6; // [rsp+0h] [rbp-20h] BYREF
unsigned __int64 v7; // [rsp+8h] [rbp-18h]

v4 = alloca(a3);
if ( a2 == 0 || dest == 0LL || !a3 )
return dest;
v7 = a2;
ft_memcpy(&v6, a2, a3);
if ( (unsigned __int64)dest <= v7 )
{
ft_memcpy(dest, &v6, a3);
return dest;
}
memcpy(dest, &v6, a3);
return dest;
}

original_code:
void *ft_memmove(void *s1, const void *s2, size_t n)
{
 char tmp[n];
 char *dest;
 const char *src;
 dest = s1;
 src = s2;
 if (s1 && s2 && n)
 {
  ft_memcpy(tmp, src, n);
  if (s1 > s2)
  {
   while (n > 0)
   {
    dest[n - 1] = tmp[n - 1];
    n--;
   }
  }
  else
   ft_memcpy(dest, tmp, n);
 }
 return (s1);
}

canonical_original_code:
void *ft_memmove(void *s1, void *s2, unsigned long n)
{
 char tmp[-1];
 char *dest;
 char *src;
 dest = s1;
 src = s2;
 if (s1 && s2 && n)
 {
  ft_memcpy(tmp, src, n);
  if (s1 > s2)
  {
   while (n > 0)
   {
    dest[n - 1] = tmp[n - 1];
    n--;
   }
  }
  else
   ft_memcpy(dest, tmp, n);
 }
 return (s1);
}

variable_types:
n
unsigned long

variable_types:
tmp
char [-1]


decompiled_code:
__int64 __fastcall ft_todo(char *a1, char a2)
{
char v2; // al
unsigned int v3; // er8
int v4; // ecx
__int64 v5; // rax
char v6; // dl

v2 = *a1;
v3 = 0;
if ( *a1 )
{
v4 = 0;
while ( a2 == v2 )
{
LABEL_3:
v2 = a1[++v4];
if ( !v2 )
return v3;
}
++v3;
v5 = v4 + 1;
while ( 1 )
{
v6 = a1[v5];
v4 = v5++;
if ( !v6 )
break;
if ( v6 == a2 )
goto LABEL_3;
}
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *a1, char a2)
{
char v2; // al
unsigned int v3; // er8
int v4; // ecx
__int64 v5; // rax
char v6; // dl

v2 = *a1;
v3 = 0;
if ( *a1 )
{
v4 = 0;
while ( a2 == v2 )
{
LABEL_3:
v2 = a1[++v4];
if ( !v2 )
return v3;
}
++v3;
v5 = v4 + 1;
while ( 1 )
{
v6 = a1[v5];
v4 = v5++;
if ( !v6 )
break;
if ( v6 == a2 )
goto LABEL_3;
}
}
return v3;
}

original_code:
static int ft_todo(const char *s, char c)
{
 int i;
 int cp;
 i = 0;
 cp = 0;
 while (s[i] != 0)
 {
  if (s[i] != c)
  {
   cp++;
   while (s[i] != c && s[i] != 0)
    i++;
  }
  if (s[i] != 0)
   i++;
 }
 return (cp);
}

canonical_original_code:
static int ft_todo(char *s, char c)
{
 int i;
 int cp;
 i = 0;
 cp = 0;
 while (s[i] != 0)
 {
  if (s[i] != c)
  {
   cp++;
   while (s[i] != c && s[i] != 0)
    i++;
  }
  if (s[i] != 0)
   i++;
 }
 return (cp);
}

variable_types: c char

variable_types: i int

variable_types: cp int


decompiled_code:
__int64 __fastcall ft_modlen(_BYTE *a1, char a2)
{
__int64 v2; // rax
char v3; // dl
unsigned int v4; // er8

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

canonical_decompiled_code:
__int64 __fastcall func1(_BYTE *a1, char a2)
{
__int64 v2; // rax
char v3; // dl
unsigned int v4; // er8

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

original_code:
static int ft_modlen(const char *s, char c)
{
 int i;
 i = 0;
 while (s[i] != c && s[i] != 0)
  i++;
 return (i);
}

canonical_original_code:
static int ft_modlen(char *s, char c)
{
 int i;
 i = 0;
 while (s[i] != c && s[i] != 0)
  i++;
 return (i);
}


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

v2 = ft_itoa();
return ft_putstr_fd(v2, a2);
}

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

v2 = ft_itoa();
return ft_putstr_fd(v2, a2);
}

original_code:
void ft_putnbr_fd(int n, int fd)
{
 ft_putstr_fd(ft_itoa(n), fd);
}

variable_types: n int


original_code:
char *ft_strncat(char *dest, const char *src, size_t n)
{
 size_t index;
 size_t length;
 length = ft_strlen(dest);
 index = 0;
 while (index < n && src[index] != 0)
 {
  dest[index + length] = src[index];
  index++;
 }
 dest[index + length] = 0;
 return (dest);
}

canonical_original_code:
char *ft_strncat(char *dest, char *src, unsigned long n)
{
 unsigned long index;
 unsigned long length;
 length = ft_strlen(dest);
 index = 0;
 while (index < n && src[index] != 0)
 {
  dest[index + length] = src[index];
  index++;
 }
 dest[index + length] = 0;
 return (dest);
}

variable_types:
src
char *

variable_types:
index
unsigned long

variable_types:
length
unsigned long


decompiled_code:
__int64 __fastcall ft_strncmp(_BYTE *a1, _BYTE *a2, __int64 a3)
{
int v5; // edx
int v6; // er8
__int64 v7; // rcx
__int64 v8; // rax

if ( a3 == 0 || a2 == 0LL || !a1 )
return 0LL;
v5 = (char)*a1;
v6 = (char)*a2;
v7 = a3 - 1;
v8 = 0LL;
if ( *a1 != *a2 )
return (unsigned int)(v5 - v6);
while ( 1 )
{
if ( !(_BYTE)v5 )
return (unsigned int)-(char)v6;
if ( !(_BYTE)v6 )
break;
if ( v7 != v8 )
{
v5 = (char)a1[++v8];
v6 = (char)a2[v8];
if ( a1[v8] == a2[v8] )
continue;
}
return (unsigned int)(v5 - v6);
}
return (unsigned int)(char)v5;
}

canonical_decompiled_code:
__int64 __fastcall func0(_BYTE *a1, _BYTE *a2, __int64 a3)
{
int v5; // edx
int v6; // er8
__int64 v7; // rcx
__int64 v8; // rax

if ( a3 == 0 || a2 == 0LL || !a1 )
return 0LL;
v5 = (char)*a1;
v6 = (char)*a2;
v7 = a3 - 1;
v8 = 0LL;
if ( *a1 != *a2 )
return (unsigned int)(v5 - v6);
while ( 1 )
{
if ( !(_BYTE)v5 )
return (unsigned int)-(char)v6;
if ( !(_BYTE)v6 )
break;
if ( v7 != v8 )
{
v5 = (char)a1[++v8];
v6 = (char)a2[v8];
if ( a1[v8] == a2[v8] )
continue;
}
return (unsigned int)(v5 - v6);
}
return (unsigned int)(char)v5;
}

original_code:
int ft_strncmp(const char *s1, const char *s2, size_t n)
{
 size_t i;
 i = 0;
 if (s1 && s2 && n)
 {
  while (s1[i] == s2[i] && s1[i] && s2[i] && i < n - 1)
   i++;
  return (s1[i] - s2[i]);
 }
 return (0);
}

canonical_original_code:
int ft_strncmp(char *s1, char *s2, unsigned long n)
{
 unsigned long i;
 i = 0;
 if (s1 && s2 && n)
 {
  while (s1[i] == s2[i] && s1[i] && s2[i] && i < n - 1)
   i++;
  return (s1[i] - s2[i]);
 }
 return (0);
}

variable_types:
i
unsigned long


decompiled_code:
__int64 ft_putnbr()
{
__int64 v0; // rax

v0 = ft_itoa();
return ft_putstr(v0);
}

canonical_decompiled_code:
__int64 func0()
{
__int64 v0; // rax

v0 = ft_itoa();
return ft_putstr(v0);
}

original_code:
void ft_putnbr(int n)
{
 ft_putstr(ft_itoa(n));
}


decompiled_code:
// attributes: thunk
void ft_elemdel(void *ptr)
{
free(ptr);
}

canonical_decompiled_code:
void func0(void *ptr)
{
free(ptr);
}

original_code:
static void ft_elemdel(void *content, size_t size)
{
 free(content);
 size = 0;
}

canonical_original_code:
static void ft_elemdel(void *content, unsigned long size)
{
 free(content);
 size = 0;
}

variable_types:
content
void *

variable_types:
size
unsigned long


original_code:
t_list *ft_lstmap(t_list *lst, t_list *(*f)(t_list *elem))
{
 t_list *new;
 new = ((void *)0);
 if (lst)
 {
  new = ft_lstnew((f(lst))->content, lst->content_size);
  if (!new)
   return (((void *)0));
  if (lst->next)
  {
   new->next = ft_lstmap(lst->next, f);
   if (new->next == ((void *)0))
    ft_lstdel(&new, &ft_elemdel);
  }
 }
 return (new);
}

canonical_original_code:
struct s_list *ft_lstmap(struct s_list *lst, struct s_list *(*f)(struct s_list *elem))
{
 struct s_list *new;
 new = ((void *)0);
 if (lst)
 {
  new = ft_lstnew((f(lst))->content, lst->content_size);
  if (!new)
   return (((void *)0));
  if (lst->next)
  {
   new->next = ft_lstmap(lst->next, f);
   if (new->next == ((void *)0))
    ft_lstdel(&new, &ft_elemdel);
  }
 }
 return (new);
}

variable_types:
lst
struct s_list *

variable_types:
f
struct s_list *(*)(struct s_list *elem)

variable_types: struct s_list { void *content; unsigned long content_size; struct s_list *next; } *


decompiled_code:
ssize_t __fastcall ft_putstr_fd(void *buf, int fd)
{
_BYTE *v3; // rbx
_BYTE *v4; // rsi
ssize_t result; // rax

if ( *(_BYTE *)buf )
{
v3 = buf;
do
{
v4 = v3++;
result = write(fd, v4, 1uLL);
}
while ( *v3 );
}
return result;
}

canonical_decompiled_code:
ssize_t __fastcall func0(void *buf, int fd)
{
_BYTE *v3; // rbx
_BYTE *v4; // rsi
ssize_t result; // rax

if ( *(_BYTE *)buf )
{
v3 = buf;
do
{
v4 = v3++;
result = write(fd, v4, 1uLL);
}
while ( *v3 );
}
return result;
}

original_code:
void ft_putstr_fd(char const *s, int fd)
{
 int i;
 i = 0;
 while (s[i])
 {
  write(fd, &s[i], 1);
  i++;
 }
}

canonical_original_code:
void ft_putstr_fd(char *s, int fd)
{
 int i;
 i = 0;
 while (s[i])
 {
  write(fd, &s[i], 1);
  i++;
 }
}

variable_types:
s
char *

variable_types: fd int


decompiled_code:
unsigned __int64 __fastcall ft_strlcat(__int64 a1, __int64 a2, unsigned __int64 a3)
{
unsigned __int64 v5; // rax
unsigned __int64 v6; // rbp
__int64 v7; // rax
unsigned __int64 v8; // rsi
char v9; // dl

v5 = ((__int64 (*)(void))ft_strlen)();
if ( v5 >= a3 )
return a3 + ft_strlen(a2);
v6 = v5;
v7 = 0LL;
v8 = v6;
if ( a3 - 1 != v6 )
{
while ( 1 )
{
v9 = *(_BYTE *)(a2 + v7);
v8 = v6 + v7;
if ( !v9 )
break;
*(_BYTE *)(a1 + v6 + v7++) = v9;
if ( v7 == a3 - 1 - v6 )
{
v8 = v6 + v7;
break;
}
}
}
*(_BYTE *)(a1 + v8) = 0;
return v6 + ft_strlen(a2);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func0(__int64 a1, __int64 a2, unsigned __int64 a3)
{
unsigned __int64 v5; // rax
unsigned __int64 v6; // rbp
__int64 v7; // rax
unsigned __int64 v8; // rsi
char v9; // dl

v5 = ((__int64 (*)(void))ft_strlen)();
if ( v5 >= a3 )
return a3 + ft_strlen(a2);
v6 = v5;
v7 = 0LL;
v8 = v6;
if ( a3 - 1 != v6 )
{
while ( 1 )
{
v9 = *(_BYTE *)(a2 + v7);
v8 = v6 + v7;
if ( !v9 )
break;
*(_BYTE *)(a1 + v6 + v7++) = v9;
if ( v7 == a3 - 1 - v6 )
{
v8 = v6 + v7;
break;
}
}
}
*(_BYTE *)(a1 + v8) = 0;
return v6 + ft_strlen(a2);
}

original_code:
size_t ft_strlcat(char *dest, const char *src, size_t buf)
{
 size_t index;
 size_t l;
 l = ft_strlen(dest);
 index = 0;
 if (buf > l)
 {
  while (index < buf - l - 1 && src[index] != 0)
  {
   dest[index + l] = src[index];
   index++;
  }
  dest[l + index] = 0;
 }
 else
  return (buf + ft_strlen(src));
 return (l + ft_strlen(src));
}

canonical_original_code:
unsigned long ft_strlcat(char *dest, char *src, unsigned long buf)
{
 unsigned long index;
 unsigned long l;
 l = ft_strlen(dest);
 index = 0;
 if (buf > l)
 {
  while (index < buf - l - 1 && src[index] != 0)
  {
   dest[index + l] = src[index];
   index++;
  }
  dest[l + index] = 0;
 }
 else
  return (buf + ft_strlen(src));
 return (l + ft_strlen(src));
}

variable_types:
dest
char *

variable_types:
buf
unsigned long

variable_types:
l
unsigned long


decompiled_code:
void *__fastcall ft_memset(void *a1, unsigned __int8 a2, size_t a3)
{
void *result; // rax

if ( a3 && a1 )
result = memset(a1, a2, a3);
else
result = a1;
return result;
}

canonical_decompiled_code:
void *__fastcall func0(void *a1, unsigned __int8 a2, size_t a3)
{
void *result; // rax

if ( a3 && a1 )
result = memset(a1, a2, a3);
else
result = a1;
return result;
}

original_code:
void *ft_memset(void *dest, int c, size_t length)
{
 unsigned char *dst;
 size_t i;
 i = 0;
 dst = (unsigned char *)dest;
 if (length && dest)
 {
  while (i < length)
  {
   dst[i] = (unsigned char)c;
   i++;
  }
 }
 return (dest);
}

canonical_original_code:
void *ft_memset(void *dest, int c, unsigned long length)
{
 unsigned char *dst;
 unsigned long i;
 i = 0;
 dst = (unsigned char *)dest;
 if (length && dest)
 {
  while (i < length)
  {
   dst[i] = (unsigned char)c;
   i++;
  }
 }
 return (dest);
}

variable_types:
dest
void *

variable_types: c int

variable_types:
dst
unsigned char *


decompiled_code:
__int64 __fastcall ft_strncpy(__int64 a1, __int64 a2, unsigned __int64 a3)
{
unsigned __int64 v4; // rdi
char v5; // al

v4 = 0LL;
if ( a3 )
{
while ( 1 )
{
v5 = *(_BYTE *)(a2 + v4);
if ( !v5 )
break;
*(_BYTE *)(a1 + v4++) = v5;
if ( a3 == v4 )
return a1;
}
if ( a3 > v4 )
memset((void *)(a1 + v4), 0, a3 - v4);
}
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, unsigned __int64 a3)
{
unsigned __int64 v4; // rdi
char v5; // al

v4 = 0LL;
if ( a3 )
{
while ( 1 )
{
v5 = *(_BYTE *)(a2 + v4);
if ( !v5 )
break;
*(_BYTE *)(a1 + v4++) = v5;
if ( a3 == v4 )
return a1;
}
if ( a3 > v4 )
memset((void *)(a1 + v4), 0, a3 - v4);
}
return a1;
}

original_code:
char *ft_strncpy(char *copy, const char *src, size_t n)
{
 size_t index;
 index = 0;
 while (index < n && src[index] != 0)
 {
  copy[index] = src[index];
  index++;
 }
 while (index < n)
 {
  copy[index] = 0;
  index++;
 }
 return (copy);
}

canonical_original_code:
char *ft_strncpy(char *copy, char *src, unsigned long n)
{
 unsigned long index;
 index = 0;
 while (index < n && src[index] != 0)
 {
  copy[index] = src[index];
  index++;
 }
 while (index < n)
 {
  copy[index] = 0;
  index++;
 }
 return (copy);
}

variable_types:
copy
char *

variable_types:
src
char *

variable_types:
n
unsigned long


decompiled_code:
ssize_t __fastcall ft_putstr(void *buf)
{
_BYTE *i; // rbx
_BYTE *v2; // rsi
ssize_t result; // rax

if ( buf )
{
for ( i = buf; *i; result = write(1, v2, 1uLL) )
v2 = i++;
}
return result;
}

canonical_decompiled_code:
ssize_t __fastcall func0(void *buf)
{
_BYTE *i; // rbx
_BYTE *v2; // rsi
ssize_t result; // rax

if ( buf )
{
for ( i = buf; *i; result = write(1, v2, 1uLL) )
v2 = i++;
}
return result;
}

original_code:
void ft_putstr(char const *s)
{
 int i;
 if (s)
 {
  i = 0;
  while (s[i] != 0)
  {
   write(1, &s[i], 1);
   i++;
  }
 }
}

canonical_original_code:
void ft_putstr(char *s)
{
 int i;
 if (s)
 {
  i = 0;
  while (s[i] != 0)
  {
   write(1, &s[i], 1);
   i++;
  }
 }
}

variable_types: i int


decompiled_code:
__int64 __fastcall ft_memccpy(__int64 a1, __int64 a2, unsigned __int8 a3, unsigned __int64 a4)
{
int v7; // ecx
unsigned __int64 v8; // rax
char v9; // dl
int v10; // esi

if ( a4 == 0 || a2 == 0 )
return 0LL;
v7 = a3;
v8 = 0LL;
if ( !a1 )
return 0LL;
while ( 1 )
{
v9 = *(_BYTE *)(a2 + v8);
if ( v9 == v7 )
break;
*(_BYTE *)(a1 + v8++) = v9;
if ( a4 <= v8 )
{
v10 = *(char *)(a2 + v8);
v9 = *(_BYTE *)(a2 + v8);
goto LABEL_6;
}
}
v10 = v7;
LABEL_6:
if ( v7 != v10 || v8 >= a4 )
return 0LL;
*(_BYTE *)(a1 + v8) = v9;
return a1 + v8 + 1;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, unsigned __int8 a3, unsigned __int64 a4)
{
int v7; // ecx
unsigned __int64 v8; // rax
char v9; // dl
int v10; // esi

if ( a4 == 0 || a2 == 0 )
return 0LL;
v7 = a3;
v8 = 0LL;
if ( !a1 )
return 0LL;
while ( 1 )
{
v9 = *(_BYTE *)(a2 + v8);
if ( v9 == v7 )
break;
*(_BYTE *)(a1 + v8++) = v9;
if ( a4 <= v8 )
{
v10 = *(char *)(a2 + v8);
v9 = *(_BYTE *)(a2 + v8);
goto LABEL_6;
}
}
v10 = v7;
LABEL_6:
if ( v7 != v10 || v8 >= a4 )
return 0LL;
*(_BYTE *)(a1 + v8) = v9;
return a1 + v8 + 1;
}

original_code:
void *ft_memccpy(void *s1, const void *s2, int c, size_t n)
{
 size_t i;
 char *dst;
 const char *src;
 dst = s1;
 src = s2;
 if (s1 && s2 && n)
 {
  i = 0;
  while (i < n && src[i] != (unsigned char)c)
  {
   dst[i] = src[i];
   i++;
  }
  if (src[i] == (unsigned char)c && i < n)
  {
   dst[i] = src[i];
   return (&dst[i + 1]);
  }
 }
 return (((void *)0));
}

canonical_original_code:
void *ft_memccpy(void *s1, void *s2, int c, unsigned long n)
{
 unsigned long i;
 char *dst;
 char *src;
 dst = s1;
 src = s2;
 if (s1 && s2 && n)
 {
  i = 0;
  while (i < n && src[i] != (unsigned char)c)
  {
   dst[i] = src[i];
   i++;
  }
  if (src[i] == (unsigned char)c && i < n)
  {
   dst[i] = src[i];
   return (&dst[i + 1]);
  }
 }
 return (((void *)0));
}

variable_types:
i
unsigned long

variable_types:
dst
char *


decompiled_code:
int __fastcall ft_term(__int64 a1, int a2)
{
char *v2; // rax
char *v3; // rax
char *v4; // rax
char *v5; // rax
int v7[3]; // [rsp+4h] [rbp-64h] BYREF
struct termios termios_p; // [rsp+10h] [rbp-58h] BYREF

tcgetattr(0, &termios_p);
termios_p.c_lflag &= 0xFFFFFFF5;
*(_WORD *)&termios_p.c_cc[5] = 256;
tcsetattr(0, 0, &termios_p);
v7[0] = tgetnum("li");
v7[2] = a2;
v7[1] = tgetnum("co");
v2 = tgetstr("ti", 0LL);
tputs(v2, 1, (int (*)(int))&ft_printchar);
v3 = tgetstr("vi", 0LL);
tputs(v3, 1, (int (*)(int))&ft_printchar);
ft_aff_lst(a1, v7, 0LL);
ft_travel_lst(a1, v7, &termios_p);
v4 = tgetstr("ve", 0LL);
tputs(v4, 1, (int (*)(int))&ft_printchar);
v5 = tgetstr("te", 0LL);
tputs(v5, 1, (int (*)(int))&ft_printchar);
termios_p.c_lflag |= 0xAu;
return tcsetattr(0, 0, &termios_p);
}

canonical_decompiled_code:
int __fastcall func0(__int64 a1, int a2)
{
char *v2; // rax
char *v3; // rax
char *v4; // rax
char *v5; // rax
int v7[3]; // [rsp+4h] [rbp-64h] BYREF
struct termios termios_p; // [rsp+10h] [rbp-58h] BYREF

tcgetattr(0, &termios_p);
termios_p.c_lflag &= 0xFFFFFFF5;
*(_WORD *)&termios_p.c_cc[5] = 256;
tcsetattr(0, 0, &termios_p);
v7[0] = tgetnum("li");
v7[2] = a2;
v7[1] = tgetnum("co");
v2 = tgetstr("ti", 0LL);
tputs(v2, 1, (int (*)(int))&ft_printchar);
v3 = tgetstr("vi", 0LL);
tputs(v3, 1, (int (*)(int))&ft_printchar);
ft_aff_lst(a1, v7, 0LL);
ft_travel_lst(a1, v7, &termios_p);
v4 = tgetstr("ve", 0LL);
tputs(v4, 1, (int (*)(int))&ft_printchar);
v5 = tgetstr("te", 0LL);
tputs(v5, 1, (int (*)(int))&ft_printchar);
termios_p.c_lflag |= 0xAu;
return tcsetattr(0, 0, &termios_p);
}

original_code:
void ft_term(t_alst *data, int width)
{
 t_term edge;
 struct termios term;
 tcgetattr(0, &term);
 term.c_lflag &= ~(0000002);
 term.c_lflag &= ~(0000010);
 term.c_cc[6] = 1;
 term.c_cc[5] = 0;
 tcsetattr(0, 0, &term);
 edge.h = tgetnum("li");
 edge.w = tgetnum("co");
 edge.max_c = width;
 tputs(tgetstr("ti", ((void *)0)), 1, ft_printchar);
 tputs(tgetstr("vi", ((void *)0)), 1, ft_printchar);
 ft_aff_lst(data, &edge, 0);
 ft_travel_lst(data, &edge, &term);
 tputs(tgetstr("ve", ((void *)0)), 1, ft_printchar);
 tputs(tgetstr("te", ((void *)0)), 1, ft_printchar);
 term.c_lflag |= 0000002;
 term.c_lflag |= 0000010;
 tcsetattr(0, 0, &term);
}

canonical_original_code:
void ft_term(struct s_alst *data, int width)
{
 struct s_term edge;
 struct termios term;
 tcgetattr(0, &term);
 term.c_lflag &= ~(0000002);
 term.c_lflag &= ~(0000010);
 term.c_cc[6] = 1;
 term.c_cc[5] = 0;
 tcsetattr(0, 0, &term);
 edge.h = tgetnum("li");
 edge.w = tgetnum("co");
 edge.max_c = width;
 tputs(tgetstr("ti", ((void *)0)), 1, ft_printchar);
 tputs(tgetstr("vi", ((void *)0)), 1, ft_printchar);
 ft_aff_lst(data, &edge, 0);
 ft_travel_lst(data, &edge, &term);
 tputs(tgetstr("ve", ((void *)0)), 1, ft_printchar);
 tputs(tgetstr("te", ((void *)0)), 1, ft_printchar);
 term.c_lflag |= 0000002;
 term.c_lflag |= 0000010;
 tcsetattr(0, 0, &term);
}

variable_types: struct s_alst { char *param; int size; int select; int i; struct s_alst *next; struct s_alst *prev; } *

variable_types: width int

variable_types: struct s_term { int h; int w; int max_c; }

variable_types: struct termios { unsigned int c_iflag; unsigned int c_oflag; unsigned int c_cflag; unsigned int c_lflag; unsigned char c_line; unsigned char c_cc[32]; unsigned int c_ispeed; unsigned int c_ospeed; }


decompiled_code:
char *__fastcall ft_strrchr(__int64 a1, int a2)
{
int v2; // eax
int v3; // edx
char *result; // rax
__int64 v5; // rcx

v2 = ft_strlen();
if ( v2 < 0 )
return 0LL;
v3 = v2;
result = (char *)(a1 + v2);
v5 = (__int64)&result[-v3 - 1];
while ( *result != a2 )
{
if ( --result == (char *)v5 )
return 0LL;
}
return result;
}

canonical_decompiled_code:
char *__fastcall func0(__int64 a1, int a2)
{
int v2; // eax
int v3; // edx
char *result; // rax
__int64 v5; // rcx

v2 = ft_strlen();
if ( v2 < 0 )
return 0LL;
v3 = v2;
result = (char *)(a1 + v2);
v5 = (__int64)&result[-v3 - 1];
while ( *result != a2 )
{
if ( --result == (char *)v5 )
return 0LL;
}
return result;
}

original_code:
char *ft_strrchr(const char *src, int c)
{
 int l;
 l = ft_strlen(src);
 while (l >= 0)
 {
  if (src[l] == c)
   return ((char *) &src[l]);
  l--;
 }
 return (((void *)0));
}

canonical_original_code:
char *ft_strrchr(char *src, int c)
{
 int l;
 l = ft_strlen(src);
 while (l >= 0)
 {
  if (src[l] == c)
   return ((char *) &src[l]);
  l--;
 }
 return (((void *)0));
}

variable_types: l int


decompiled_code:
__int64 __fastcall ft_isalnum(unsigned int a1)
{
int v1; // ebx

v1 = ft_isdigit();
return v1 + (unsigned int)ft_isalpha(a1);
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1)
{
int v1; // ebx

v1 = ft_isdigit();
return v1 + (unsigned int)ft_isalpha(a1);
}

original_code:
int ft_isalnum(int c)
{
 return (ft_isdigit(c) + ft_isalpha(c));
}


decompiled_code:
void __fastcall ft_lstdelone(void **a1, void (__fastcall *a2)(_QWORD, _QWORD))
{
if ( a1 )
{
if ( a2 )
{
a2(*(_QWORD *)*a1, *((_QWORD *)*a1 + 1));
free(*a1);
*a1 = 0LL;
}
}
}

canonical_decompiled_code:
void __fastcall func0(void **a1, void (__fastcall *a2)(_QWORD, _QWORD))
{
if ( a1 )
{
if ( a2 )
{
a2(*(_QWORD *)*a1, *((_QWORD *)*a1 + 1));
free(*a1);
*a1 = 0LL;
}
}
}

original_code:
void ft_lstdelone(t_list **alst, void (*del)(void *, size_t))
{
 if (alst && del)
 {
  del((*alst)->content, (*alst)->content_size);
  free(*alst);
  *alst = ((void *)0);
 }
}

canonical_original_code:
void ft_lstdelone(struct s_list **alst, void (*del)(void *, unsigned long))
{
 if (alst && del)
 {
  del((*alst)->content, (*alst)->content_size);
  free(*alst);
  *alst = ((void *)0);
 }
}

variable_types: struct s_list { void *content; unsigned long content_size; struct s_list *next; } **

variable_types:
del
void (*)(void *, unsigned long)


decompiled_code:
__int64 __fastcall ft_strmap(_BYTE *a1, __int64 (*a2)(void))
{
__int64 v2; // rax
__int64 v3; // r12
int v4; // er14
__int64 v5; // rax

if ( !a1 )
return 0LL;
if ( !a2 )
return 0LL;
v2 = ft_strlen();
v3 = ft_strnew(v2 + 1);
if ( !v3 )
return 0LL;
if ( *a1 )
{
v4 = 0;
v5 = 0LL;
do
{
*(_BYTE *)(v3 + v5) = a2();
v5 = (unsigned int)++v4;
}
while ( a1[v4] );
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func0(_BYTE *a1, __int64 (*a2)(void))
{
__int64 v2; // rax
__int64 v3; // r12
int v4; // er14
__int64 v5; // rax

if ( !a1 )
return 0LL;
if ( !a2 )
return 0LL;
v2 = ft_strlen();
v3 = ft_strnew(v2 + 1);
if ( !v3 )
return 0LL;
if ( *a1 )
{
v4 = 0;
v5 = 0LL;
do
{
*(_BYTE *)(v3 + v5) = a2();
v5 = (unsigned int)++v4;
}
while ( a1[v4] );
}
return v3;
}

original_code:
char *ft_strmap(char const *s, char (*f)(char))
{
 unsigned int i;
 char *new;
 i = 0;
 if (!(s && f))
  return (((void *)0));
 new = ft_strnew(ft_strlen(s) + 1);
 if (new == ((void *)0))
  return (((void *)0));
 while (s[i])
 {
  new[i] = f((char)s[i]);
  i++;
 }
 return (new);
}

canonical_original_code:
char *ft_strmap(char *s, char (*f)(char))
{
 unsigned int i;
 char *new;
 i = 0;
 if (!(s && f))
  return (((void *)0));
 new = ft_strnew(ft_strlen(s) + 1);
 if (new == ((void *)0))
  return (((void *)0));
 while (s[i])
 {
  new[i] = f((char)s[i]);
  i++;
 }
 return (new);
}

variable_types:
s
char *

variable_types:
f
char (*)(char)

variable_types:
i
unsigned int

variable_types:
new
char *


decompiled_code:
void __fastcall ft_memdel(void **a1)
{
free(*a1);
*a1 = 0LL;
}

canonical_decompiled_code:
void __fastcall func0(void **a1)
{
free(*a1);
*a1 = 0LL;
}

original_code:
void ft_memdel(void **ap)
{
 free(*ap);
 *ap = ((void *)0);
}

variable_types:
ap
void **


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

v4 = ft_strnew(a3 + 1);
if ( a1 && v4 )
result = ft_strncpy(v4, a1 + a2, a3);
else
result = 0LL;
return result;
}

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

v4 = ft_strnew(a3 + 1);
if ( a1 && v4 )
result = ft_strncpy(v4, a1 + a2, a3);
else
result = 0LL;
return result;
}

original_code:
char *ft_strsub(const char *src, unsigned int start, size_t n)
{
 char *new;
 new = ft_strnew(n + 1);
 if (!src || !new)
  return (((void *)0));
 new = ft_strncpy(new, &src[start], n);
 return (new);
}

canonical_original_code:
char *ft_strsub(char *src, unsigned int start, unsigned long n)
{
 char *new;
 new = ft_strnew(n + 1);
 if (!src || !new)
  return (((void *)0));
 new = ft_strncpy(new, &src[start], n);
 return (new);
}

variable_types:
src
char *

variable_types:
start
unsigned int


decompiled_code:
__int64 __fastcall key_hook(__int64 a1, __int64 a2)
{
int buf[7]; // [rsp+Ch] [rbp-1Ch] BYREF

while ( 1 )
{
ft_bzero(buf, 4LL);
read(0, buf, 4uLL);
if ( buf[0] == 32 )
{
*(_DWORD *)(a1 + 12) = *(_DWORD *)(a1 + 12) == 0;
return 1LL;
}
if ( buf[0] == 4348699 )
return 1LL;
if ( buf[0] == 4283163 )
break;
if ( buf[0] == 10 )
{
ft_quit(a1, a2, 1LL);
}
else if ( buf[0] == 27 )
{
ft_quit(a1, a2, 0LL);
}
}
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
int buf[7]; // [rsp+Ch] [rbp-1Ch] BYREF

while ( 1 )
{
ft_bzero(buf, 4LL);
read(0, buf, 4uLL);
if ( buf[0] == 32 )
{
*(_DWORD *)(a1 + 12) = *(_DWORD *)(a1 + 12) == 0;
return 1LL;
}
if ( buf[0] == 4348699 )
return 1LL;
if ( buf[0] == 4283163 )
break;
if ( buf[0] == 10 )
{
ft_quit(a1, a2, 1LL);
}
else if ( buf[0] == 27 )
{
ft_quit(a1, a2, 0LL);
}
}
return 0xFFFFFFFFLL;
}

original_code:
int key_hook(t_alst *d, struct termios *term)
{
 t_code code;
 while (1)
 {
  ft_bzero(code.key, 4);
  read(0, code.key, 4);
  if (code.c == 32)
  {
   d->select = (d->select == 0 ? 1 : 0);
   return (1);
  }
  else if (code.c == 4348699)
   return (1);
  else if (code.c == 4283163)
   return (-1);
  else if (code.c == 10)
   ft_quit(d, term, 1);
  else if (code.c == 27)
   ft_quit(d, term, 0);
 }
}

canonical_original_code:
int key_hook(struct s_alst *d, struct termios *term)
{
 union u_code code;
 while (1)
 {
  ft_bzero(code.key, 4);
  read(0, code.key, 4);
  if (code.c == 32)
  {
   d->select = (d->select == 0 ? 1 : 0);
   return (1);
  }
  else if (code.c == 4348699)
   return (1);
  else if (code.c == 4283163)
   return (-1);
  else if (code.c == 10)
   ft_quit(d, term, 1);
  else if (code.c == 27)
   ft_quit(d, term, 0);
 }
}

variable_types: struct termios { unsigned int c_iflag; unsigned int c_oflag; unsigned int c_cflag; unsigned int c_lflag; unsigned char c_line; unsigned char c_cc[32]; unsigned int c_ispeed; unsigned int c_ospeed; } *

variable_types: union u_code { unsigned int c; char key[4]; }

user_defined_types: struct s_alst { char *param; int size; int select; int i; struct s_alst *next; struct s_alst *prev; }


decompiled_code:
void *__fastcall ft_memalloc(__int64 a1)
{
void *v1; // rax
void *v2; // r12

v1 = malloc(8 * a1);
v2 = v1;
if ( v1 )
ft_bzero(v1, a1);
return v2;
}

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

v1 = malloc(8 * a1);
v2 = v1;
if ( v1 )
ft_bzero(v1, a1);
return v2;
}

original_code:
void *ft_memalloc(size_t size)
{
 void *mem;
 mem = malloc(sizeof(void *) * size);
 if (mem)
  ft_bzero(mem, size);
 else
  return (((void *)0));
 return (mem);
}

canonical_original_code:
void *ft_memalloc(unsigned long size)
{
 void *mem;
 mem = malloc(sizeof(void *) * size);
 if (mem)
  ft_bzero(mem, size);
 else
  return (((void *)0));
 return (mem);
}

variable_types:
size
unsigned long

variable_types:
mem
void *


decompiled_code:
_BOOL8 ft_strnequ()
{
return (unsigned int)ft_strncmp() == 0;
}

canonical_decompiled_code:
_BOOL8 func0()
{
return (unsigned int)ft_strncmp() == 0;
}

original_code:
int ft_strnequ(const char *s1, const char *s2, size_t n)
{
 return (!ft_strncmp(s1, s2, n));
}

canonical_original_code:
int ft_strnequ(char *s1, char *s2, unsigned long n)
{
 return (!ft_strncmp(s1, s2, n));
}

variable_types:
n
unsigned long


decompiled_code:
__int64 __fastcall ft_memchr(__int64 a1, char a2, unsigned __int64 a3)
{
__int64 v3; // rax
__int64 v4; // r8

if ( !a3 || !a1 )
return 0LL;
v3 = 0LL;
while ( 1 )
{
v4 = a1 + v3;
if ( *(_BYTE *)(a1 + v3) == a2 )
break;
if ( a3 <= ++v3 )
return 0LL;
}
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, char a2, unsigned __int64 a3)
{
__int64 v3; // rax
__int64 v4; // r8

if ( !a3 || !a1 )
return 0LL;
v3 = 0LL;
while ( 1 )
{
v4 = a1 + v3;
if ( *(_BYTE *)(a1 + v3) == a2 )
break;
if ( a3 <= ++v3 )
return 0LL;
}
return v4;
}

original_code:
void *ft_memchr(const void *ptr, int c, size_t n)
{
 const unsigned char *src;
 size_t i;
 src = (const unsigned char *)ptr;
 if (n && ptr)
 {
  i = 0;
  while (i < n)
  {
   if (src[i] == (unsigned char)c)
    return ((void *)&src[i]);
   i++;
  }
 }
 return (((void *)0));
}

canonical_original_code:
void *ft_memchr(void *ptr, int c, unsigned long n)
{
 unsigned char *src;
 unsigned long i;
 src = (unsigned char *)ptr;
 if (n && ptr)
 {
  i = 0;
  while (i < n)
  {
   if (src[i] == (unsigned char)c)
    return ((void *)&src[i]);
   i++;
  }
 }
 return (((void *)0));
}

variable_types:
ptr
void *

variable_types: c int

variable_types:
src
unsigned char *

variable_types:
i
unsigned long


decompiled_code:
void __fastcall ft_return_lst(__int64 a1, unsigned int a2, unsigned int a3)
{
unsigned int v4; // er12
__int64 v6; // rdi

v4 = a2;
if ( *(_DWORD *)(a1 + 12) )
{
if ( a2 )
write(1, &unk_70, 1uLL);
v4 = a2 + 1;
write(1, *(const void **)a1, *(int *)(a1 + 8));
}
v6 = *(_QWORD *)(a1 + 24);
if ( *(_DWORD *)(v6 + 16) != a3 )
ft_return_lst(v6, v4, a3);
free((void *)a1);
}

canonical_decompiled_code:
void __fastcall func0(__int64 a1, unsigned int a2, unsigned int a3)
{
unsigned int v4; // er12
__int64 v6; // rdi

v4 = a2;
if ( *(_DWORD *)(a1 + 12) )
{
if ( a2 )
write(1, &unk_70, 1uLL);
v4 = a2 + 1;
write(1, *(const void **)a1, *(int *)(a1 + 8));
}
v6 = *(_QWORD *)(a1 + 24);
if ( *(_DWORD *)(v6 + 16) != a3 )
func0(v6, v4, a3);
free((void *)a1);
}

original_code:
void ft_return_lst(t_alst *data, int spc, int begin)
{
 if (data->select)
 {
  if (spc)
   write(1, " ", 1);
  write(1, data->param, data->size);
  spc++;
 }
 if (data->next->i != begin)
  ft_return_lst(data->next, spc, begin);
 free(data);
}

canonical_original_code:
void ft_return_lst(struct s_alst *data, int spc, int begin)
{
 if (data->select)
 {
  if (spc)
   write(1, " ", 1);
  write(1, data->param, data->size);
  spc++;
 }
 if (data->next->i != begin)
  ft_return_lst(data->next, spc, begin);
 free(data);
}

variable_types: struct s_alst { char *param; int size; int select; int i; struct s_alst *next; struct s_alst *prev; } *

variable_types: spc int

variable_types: begin int


decompiled_code:
__int64 __fastcall ft_aff_lst(__int64 a1, __int64 a2, int a3)
{
while ( 1 )
{
ft_aff_elem(a1, a2, 0LL);
a1 = *(_QWORD *)(a1 + 24);
if ( *(_DWORD *)(a1 + 16) <= a3 )
break;
++a3;
}
return 0LL;
}

original_code:
int ft_aff_lst(t_alst *data, t_term *e, int j)
{
 ft_aff_elem(data, e, 0);
 if (data->next->i > j)
  return (ft_aff_lst(data->next, e, j + 1));
 return (0);
}

canonical_original_code:
int ft_aff_lst(struct s_alst *data, struct s_term *e, int j)
{
 ft_aff_elem(data, e, 0);
 if (data->next->i > j)
  return (ft_aff_lst(data->next, e, j + 1));
 return (0);
}

variable_types: struct s_term { int h; int w; int max_c; } *

variable_types: j int


original_code:
int ft_get_param(t_alst **data, char **argv, int argc)
{
 t_alst *new;
 t_alst *begin;
 int i;
 int tmp;
 new = ((void *)0);
 i = 1;
 tmp = 0;
 while (i < argc)
 {
  new = ft_new_alst(argv[i], *data, i);
  if (*data)
   data = &new;
  else
   *data = new;
  data = &new;
  if (i == 1)
   begin = new;
  tmp = (new->size > tmp ? new->size : tmp);
  i++;
 }
 begin->prev = new;
 new->next = begin;
 return (tmp);
}

canonical_original_code:
int ft_get_param(struct s_alst **data, char **argv, int argc)
{
 struct s_alst *new;
 struct s_alst *begin;
 int i;
 int tmp;
 new = ((void *)0);
 i = 1;
 tmp = 0;
 while (i < argc)
 {
  new = ft_new_alst(argv[i], *data, i);
  if (*data)
   data = &new;
  else
   *data = new;
  data = &new;
  if (i == 1)
   begin = new;
  tmp = (new->size > tmp ? new->size : tmp);
  i++;
 }
 begin->prev = new;
 new->next = begin;
 return (tmp);
}

variable_types: struct s_alst { char *param; int size; int select; int i; struct s_alst *next; struct s_alst *prev; } **

variable_types:
argv
char **

variable_types: argc int

variable_types: i int

variable_types: tmp int


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

if ( a1 )
{
if ( *(_QWORD *)(a1 + 16) )
ft_lstiter();
result = a2(a1);
}
return result;
}

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

if ( a1 )
{
if ( *(_QWORD *)(a1 + 16) )
func0();
result = a2(a1);
}
return result;
}

original_code:
void ft_lstiter(t_list *lst, void (*f)(t_list *elem))
{
 if (lst)
 {
  if (lst->next)
   ft_lstiter(lst->next, f);
  f(lst);
 }
}

canonical_original_code:
void ft_lstiter(struct s_list *lst, void (*f)(struct s_list *elem))
{
 if (lst)
 {
  if (lst->next)
   ft_lstiter(lst->next, f);
  f(lst);
 }
}

variable_types: struct s_list { void *content; unsigned long content_size; struct s_list *next; } *

variable_types:
f
void (*)(struct s_list *elem)


decompiled_code:
__int64 __fastcall ft_memcmp(__int64 a1, __int64 a2, unsigned __int64 a3)
{
unsigned int v5; // edx
__int64 v7; // rax

if ( a3 == 0 || a2 == 0 || !a1 )
return 0;
v7 = 0LL;
while ( 1 )
{
v5 = *(unsigned __int8 *)(a1 + v7) - *(unsigned __int8 *)(a2 + v7);
if ( v5 )
break;
if ( a3 <= ++v7 )
return 0LL;
}
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, unsigned __int64 a3)
{
unsigned int v5; // edx
__int64 v7; // rax

if ( a3 == 0 || a2 == 0 || !a1 )
return 0;
v7 = 0LL;
while ( 1 )
{
v5 = *(unsigned __int8 *)(a1 + v7) - *(unsigned __int8 *)(a2 + v7);
if ( v5 )
break;
if ( a3 <= ++v7 )
return 0LL;
}
return v5;
}

original_code:
int ft_memcmp(const void *str1, const void *str2, size_t n)
{
 const unsigned char *s1;
 const unsigned char *s2;
 int cmp;
 size_t i;
 cmp = 0;
 s1 = str1;
 s2 = str2;
 if (str1 && str2 && n)
 {
  i = 0;
  while (i < n && (cmp = s1[i] - s2[i]) == 0)
   i++;
 }
 return (cmp);
}

canonical_original_code:
int ft_memcmp(void *str1, void *str2, unsigned long n)
{
 unsigned char *s1;
 unsigned char *s2;
 int cmp;
 unsigned long i;
 cmp = 0;
 s1 = str1;
 s2 = str2;
 if (str1 && str2 && n)
 {
  i = 0;
  while (i < n && (cmp = s1[i] - s2[i]) == 0)
   i++;
 }
 return (cmp);
}

variable_types:
n
unsigned long

variable_types: cmp int


decompiled_code:
int __fastcall ft_aff_elem(__int64 a1, _DWORD *a2, int a3)
{
int v4; // eax
int v5; // ebp
int v6; // er13
char *v7; // rax
char *v8; // rax
char *v9; // rax
char *v11; // rax
char *v12; // rax

v4 = *(_DWORD *)(a1 + 16);
v5 = a2[2] * (v4 / *a2);
v6 = v4 % *a2;
v7 = tgetstr("cm", 0LL);
v8 = tgoto(v7, v5, v6);
tputs(v8, 1, (int (*)(int))&ft_printchar);
if ( *(_DWORD *)(a1 + 12) == 1 )
{
v12 = tgetstr("mr", 0LL);
tputs(v12, 1, (int (*)(int))&ft_printchar);
}
if ( a3 )
{
v11 = tgetstr("us", 0LL);
tputs(v11, 1, (int (*)(int))&ft_printchar);
}
write(1, *(const void **)a1, *(int *)(a1 + 8));
v9 = tgetstr("me", 0LL);
return tputs(v9, 1, (int (*)(int))&ft_printchar);
}

canonical_decompiled_code:
int __fastcall func0(__int64 a1, _DWORD *a2, int a3)
{
int v4; // eax
int v5; // ebp
int v6; // er13
char *v7; // rax
char *v8; // rax
char *v9; // rax
char *v11; // rax
char *v12; // rax

v4 = *(_DWORD *)(a1 + 16);
v5 = a2[2] * (v4 / *a2);
v6 = v4 % *a2;
v7 = tgetstr("cm", 0LL);
v8 = tgoto(v7, v5, v6);
tputs(v8, 1, (int (*)(int))&ft_printchar);
if ( *(_DWORD *)(a1 + 12) == 1 )
{
v12 = tgetstr("mr", 0LL);
tputs(v12, 1, (int (*)(int))&ft_printchar);
}
if ( a3 )
{
v11 = tgetstr("us", 0LL);
tputs(v11, 1, (int (*)(int))&ft_printchar);
}
write(1, *(const void **)a1, *(int *)(a1 + 8));
v9 = tgetstr("me", 0LL);
return tputs(v9, 1, (int (*)(int))&ft_printchar);
}

original_code:
void ft_aff_elem(t_alst *d, t_term *e, int cursor)
{
 int x;
 int y;
 x = d->i / e->h * e->max_c;
 y = d->i % e->h;
 tputs(tgoto(tgetstr("cm", ((void *)0)), x, y), 1, ft_printchar);
 if (d->select == 1)
  tputs(tgetstr("mr", ((void *)0)), 1, ft_printchar);
 if (cursor)
  tputs(tgetstr("us", ((void *)0)), 1, ft_printchar);
 write(1, d->param, d->size);
 tputs(tgetstr("me", ((void *)0)), 1, ft_printchar);
}

canonical_original_code:
void ft_aff_elem(struct s_alst *d, struct s_term *e, int cursor)
{
 int x;
 int y;
 x = d->i / e->h * e->max_c;
 y = d->i % e->h;
 tputs(tgoto(tgetstr("cm", ((void *)0)), x, y), 1, ft_printchar);
 if (d->select == 1)
  tputs(tgetstr("mr", ((void *)0)), 1, ft_printchar);
 if (cursor)
  tputs(tgetstr("us", ((void *)0)), 1, ft_printchar);
 write(1, d->param, d->size);
 tputs(tgetstr("me", ((void *)0)), 1, ft_printchar);
}

variable_types: cursor int

variable_types: x int

variable_types: y int

user_defined_types: struct s_term { int h; int w; int max_c; }