usage

decompiled_code:
void __fastcall __noreturn usage(const char *a1)
{
printf("\n\nUsage: %s <IP> \n\n", a1);
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func12(const char *a1)
{
printf("\n\nUsage: %s <IP> \n\n", a1);
exit(1);
}

original_code:
void usage( const char *argument ) {
   printf( "\n\nUsage: %s <IP> \n\n", argument );
   exit( 1 );
}

canonical_original_code:
void usage(char *argument) {
   printf( "\n\nUsage: %s <IP> \n\n", argument );
   exit( 1 );
}

variable_types:
argument
char *


repo: KinG-InFeT/Sorgenti

decompiled_code:
void __noreturn print_error()
{
perror("ERROR!");
exit(1);
}

canonical_decompiled_code:
void __noreturn func13()
{
perror("ERROR!");
exit(1);
}

original_code:
void print_error() {
   perror( "ERROR!" );
   exit( 1 );
}

return_type: void


riri

decompiled_code:
int riri()
{
puts("RIRI !");
return getchar();
}

canonical_decompiled_code:
int func7()
{
puts("RIRI !");
return getchar();
}

original_code:
void riri(void)
{
    printf("RIRI !\n");
 getchar();
}

canonical_original_code:
void riri()
{
    printf("RIRI !\n");
 getchar();
}


fifi

decompiled_code:
int fifi()
{
puts("FIFI !");
return getchar();
}

canonical_decompiled_code:
int func8()
{
puts("FIFI !");
return getchar();
}

original_code:
void fifi(void)
{
    printf("FIFI !\n");
 getchar();
}

canonical_original_code:
void fifi()
{
    printf("FIFI !\n");
 getchar();
}


loulou

decompiled_code:
int loulou()
{
puts("LOULOU !");
return getchar();
}

canonical_decompiled_code:
int func9()
{
puts("LOULOU !");
return getchar();
}

original_code:
void loulou(void)
{
    printf("LOULOU !\n");
 getchar();
}

canonical_original_code:
void loulou()
{
    printf("LOULOU !\n");
 getchar();
}


donald

decompiled_code:
int donald()
{
puts("DONALD !");
return getchar();
}

canonical_decompiled_code:
int func10()
{
puts("DONALD !");
return getchar();
}

original_code:
void donald(void)
{
    printf("DONALD !\n");
 getchar();
}

canonical_original_code:
void donald()
{
    printf("DONALD !\n");
 getchar();
}


picsou

decompiled_code:
int picsou()
{
puts("PICSOU !");
return getchar();
}

canonical_decompiled_code:
int func11()
{
puts("PICSOU !");
return getchar();
}

original_code:
void picsou(void)
{
    printf("PICSOU !\n");
 getchar();
}

canonical_original_code:
void picsou()
{
    printf("PICSOU !\n");
 getchar();
}


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rdx
unsigned int v4; // eax
_BYTE v6[48]; // [rsp+0h] [rbp-238h] BYREF
char v7[48]; // [rsp+30h] [rbp-208h] BYREF
char v8[48]; // [rsp+60h] [rbp-1D8h] BYREF
char v9[48]; // [rsp+90h] [rbp-1A8h] BYREF
char v10[48]; // [rsp+C0h] [rbp-178h] BYREF
char v11[50]; // [rsp+F0h] [rbp-148h] BYREF
char v12[142]; // [rsp+122h] [rbp-116h] BYREF
char v13[136]; // [rsp+1B0h] [rbp-88h] BYREF

strcpy(v12, "Titre du menu");
Menu_new(v13, v12, envp);
Menu_new(&v12[14], "Sous Menu", v3);
Menu_newItem(v11, riri, "Riri");
Menu_newItem(v10, fifi, "Fifi");
Menu_newItem(v9, loulou, "Loulou");
Menu_newItem(v8, donald, "Donald");
Menu_newItem(v7, picsou, "Picsou");
Menu_newItemSubMenu(v6, &v12[14], "Sous Menu");
Menu_addItem(v13, v11);
Menu_addItem(v13, v10);
Menu_addItem(v13, v9);
Menu_addItem(v13, v8);
Menu_addItem(v13, v7);
Menu_addItem(v13, v6);
Menu_addItem(&v12[14], v8);
Menu_removeItemById(v13, 1LL);
Menu_removeItemByLabel(v13, "Donald");
Menu_addItem(v13, v8);
while ( 1 )
{
v4 = Menu_choose(v13);
if ( v4 == -1 )
break;
if ( !(unsigned int)Menu_do(v13, v4) )
puts("Erreur lors du lancement d'une action.");
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rdx
unsigned int v4; // eax
_BYTE v6[48]; // [rsp+0h] [rbp-238h] BYREF
char v7[48]; // [rsp+30h] [rbp-208h] BYREF
char v8[48]; // [rsp+60h] [rbp-1D8h] BYREF
char v9[48]; // [rsp+90h] [rbp-1A8h] BYREF
char v10[48]; // [rsp+C0h] [rbp-178h] BYREF
char v11[50]; // [rsp+F0h] [rbp-148h] BYREF
char v12[142]; // [rsp+122h] [rbp-116h] BYREF
char v13[136]; // [rsp+1B0h] [rbp-88h] BYREF

strcpy(v12, "Titre du menu");
func12(v13, v12, envp);
func12(&v12[14], "Sous Menu", v3);
func21(v11, riri, "Riri");
func21(v10, fifi, "Fifi");
func21(v9, loulou, "Loulou");
func21(v8, donald, "Donald");
func21(v7, picsou, "Picsou");
func22(v6, &v12[14], "Sous Menu");
func13(v13, v11);
func13(v13, v10);
func13(v13, v9);
func13(v13, v8);
func13(v13, v7);
func13(v13, v6);
func13(&v12[14], v8);
func15(v13, 1LL);
func14(v13, "Donald");
func13(v13, v8);
while ( 1 )
{
v4 = func19(v13);
if ( v4 == -1 )
break;
if ( !(unsigned int)func20(v13, v4) )
puts("Erreur lors du lancement d'une action.");
}
return 0;
}

original_code:
int main(void)
{
    Menu myMenu;
    Menu mySubMenu;
    char titre[] = "Titre du menu";
    Menu_new(&myMenu, titre);
    Menu_new(&mySubMenu, "Sous Menu");
    Item item_riri;
    Menu_newItem(&item_riri, riri, "Riri");
    Item item_fifi;
    Menu_newItem(&item_fifi, fifi, "Fifi");
    Item item_loulou;
    Menu_newItem(&item_loulou, loulou, "Loulou");
    Item item_donald;
    Menu_newItem(&item_donald, donald, "Donald");
    Item item_picsou;
    Menu_newItem(&item_picsou, picsou, "Picsou");
    Item item_sousMenu;
    Menu_newItemSubMenu(&item_sousMenu, &mySubMenu, "Sous Menu");
    Menu_addItem(&myMenu, &item_riri);
    Menu_addItem(&myMenu, &item_fifi);
    Menu_addItem(&myMenu, &item_loulou);
    Menu_addItem(&myMenu, &item_donald);
    Menu_addItem(&myMenu, &item_picsou);
    Menu_addItem(&myMenu, &item_sousMenu);
    Menu_addItem(&mySubMenu, &item_donald);
    Menu_removeItemById(&myMenu, 1);
    Menu_removeItemByLabel(&myMenu, "Donald");
    Menu_addItem(&myMenu, &item_donald);
    while(1)
    {
        int action = Menu_choose(&myMenu);
        if(action == -1)
        {
            break;
        }
        else
        {
            if(!Menu_do(&myMenu, action))
            {
                printf("Erreur lors du lancement d'une action.\n");
            }
        }
    }
    return 0;
}

canonical_original_code:
int main()
{
    struct Menu myMenu;
    struct Menu mySubMenu;
    char titre[] = "Titre du menu";
    Menu_new(&myMenu, titre);
    Menu_new(&mySubMenu, "Sous Menu");
    struct Item item_riri;
    Menu_newItem(&item_riri, riri, "Riri");
    struct Item item_fifi;
    Menu_newItem(&item_fifi, fifi, "Fifi");
    struct Item item_loulou;
    Menu_newItem(&item_loulou, loulou, "Loulou");
    struct Item item_donald;
    Menu_newItem(&item_donald, donald, "Donald");
    struct Item item_picsou;
    Menu_newItem(&item_picsou, picsou, "Picsou");
    struct Item item_sousMenu;
    Menu_newItemSubMenu(&item_sousMenu, &mySubMenu, "Sous Menu");
    Menu_addItem(&myMenu, &item_riri);
    Menu_addItem(&myMenu, &item_fifi);
    Menu_addItem(&myMenu, &item_loulou);
    Menu_addItem(&myMenu, &item_donald);
    Menu_addItem(&myMenu, &item_picsou);
    Menu_addItem(&myMenu, &item_sousMenu);
    Menu_addItem(&mySubMenu, &item_donald);
    Menu_removeItemById(&myMenu, 1);
    Menu_removeItemByLabel(&myMenu, "Donald");
    Menu_addItem(&myMenu, &item_donald);
    while(1)
    {
        int action = Menu_choose(&myMenu);
        if(action == -1)
        {
            break;
        }
        else
        {
            if(!Menu_do(&myMenu, action))
            {
                printf("Erreur lors du lancement d'une action.\n");
            }
        }
    }
    return 0;
}

variable_types: struct Menu { int nombreItem; struct Item { struct Item *suivant; struct Menu *sousMenu; void (*fonction)(); char label[20]; } *premier; char titre[100]; }

variable_types:
titre
char []

variable_types: struct Item { struct Item *suivant; struct Menu { int nombreItem; struct Item *premier; char titre[100]; } *sousMenu; void (*fonction)(); char label[20]; }

variable_types: action int

return_type: int


decompiled_code:
__int64 __fastcall Menu_new(__int64 a1, const char *a2)
{
size_t v2; // rdx
__int64 result; // rax

*(_DWORD *)a1 = 0;
*(_QWORD *)(a1 + 8) = 0LL;
v2 = strlen(a2);
result = 0LL;
if ( v2 <= 0x64 )
{
strcpy((char *)(a1 + 16), a2);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, const char *a2)
{
size_t v2; // rdx
__int64 result; // rax

*(_DWORD *)a1 = 0;
*(_QWORD *)(a1 + 8) = 0LL;
v2 = strlen(a2);
result = 0LL;
if ( v2 <= 0x64 )
{
strcpy((char *)(a1 + 16), a2);
result = 1LL;
}
return result;
}

original_code:
int Menu_new(Menu* menu, char titre[])
{
    menu->nombreItem = 0;
    menu->premier = ((void *)0);
    if(strlen(titre) <= 100)
    {
        strcpy(menu->titre, titre);
    }
    else
    {
        return 0;
    }
 return 1;
}

canonical_original_code:
int Menu_new(struct Menu *menu, char titre[])
{
    menu->nombreItem = 0;
    menu->premier = ((void *)0);
    if(strlen(titre) <= 100)
    {
        strcpy(menu->titre, titre);
    }
    else
    {
        return 0;
    }
 return 1;
}

variable_types: struct Menu { int nombreItem; struct Item { struct Item *suivant; struct Menu *sousMenu; void (*fonction)(); char label[20]; } *premier; char titre[100]; } *

user_defined_types: struct Menu { int nombreItem; struct Item *premier; char titre[100]; }


decompiled_code:
__int64 __fastcall Menu_addItem(__int64 a1, __int64 a2)
{
_QWORD *v3; // rax
_QWORD *v4; // rdx

if ( !*(_DWORD *)a1 )
{
*(_QWORD *)(a1 + 8) = a2;
LABEL_3:
++*(_DWORD *)a1;
return 1LL;
}
v3 = *(_QWORD **)(a1 + 8);
if ( v3 )
{
do
{
v4 = v3;
v3 = (_QWORD *)*v3;
}
while ( v3 );
*v4 = a2;
goto LABEL_3;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, __int64 a2)
{
_QWORD *v3; // rax
_QWORD *v4; // rdx

if ( !*(_DWORD *)a1 )
{
*(_QWORD *)(a1 + 8) = a2;
LABEL_3:
++*(_DWORD *)a1;
return 1LL;
}
v3 = *(_QWORD **)(a1 + 8);
if ( v3 )
{
do
{
v4 = v3;
v3 = (_QWORD *)*v3;
}
while ( v3 );
*v4 = a2;
goto LABEL_3;
}
return 0LL;
}

original_code:
int Menu_addItem(Menu* menu, Item* item)
{
    if(menu->nombreItem==0)
    {
        menu->premier = item;
    }
    else
    {
        Item* buffer = ((void *)0);
        buffer=menu->premier;
        if(buffer == ((void *)0))
            return 0;
        while(buffer->suivant)
        {
            buffer = buffer->suivant;
        }
        buffer->suivant = item;
    }
 menu->nombreItem ++;
 return 1;
}

canonical_original_code:
int Menu_addItem(struct Menu *menu, struct Item *item)
{
    if(menu->nombreItem==0)
    {
        menu->premier = item;
    }
    else
    {
        struct Item *buffer = ((void *)0);
        buffer=menu->premier;
        if(buffer == ((void *)0))
            return 0;
        while(buffer->suivant)
        {
            buffer = buffer->suivant;
        }
        buffer->suivant = item;
    }
 menu->nombreItem ++;
 return 1;
}

variable_types:
item
struct Item *

variable_types: struct Item { struct Item *suivant; struct Menu { int nombreItem; struct Item *premier; char titre[100]; } *sousMenu; void (*fonction)(); char label[20]; } *

user_defined_types: struct Item { struct Item *suivant; struct Menu *sousMenu; void (*fonction)(); char label[20]; }


decompiled_code:
__int64 __fastcall Menu_removeItemByLabel(__int64 a1, const char *a2)
{
__int64 *v2; // rbx
_QWORD *v3; // r12

v2 = *(__int64 **)(a1 + 8);
do
{
v3 = v2;
v2 = (__int64 *)*v2;
}
while ( strcmp((const char *)v2 + 24, a2) );
*v3 = *v2;
return 1LL;
}

original_code:
int Menu_removeItemByLabel(Menu* menu, const char nom[])
{
 Item* item = menu->premier;
 while(strcmp(item->suivant->label, nom))
 {
  item = item->suivant;
 }
 item->suivant = item->suivant->suivant;
 return 1;
}

canonical_original_code:
int Menu_removeItemByLabel(struct Menu *menu, char nom[])
{
 struct Item *item = menu->premier;
 while(strcmp(item->suivant->label, nom))
 {
  item = item->suivant;
 }
 item->suivant = item->suivant->suivant;
 return 1;
}

variable_types:
nom
char []


decompiled_code:
__int64 __fastcall Menu_removeItemById(__int64 a1, int a2)
{
__int64 result; // rax
_QWORD **v3; // rdx
int i; // eax

result = 0LL;
if ( a2 >= 0 && *(_DWORD *)a1 > a2 )
{
v3 = *(_QWORD ***)(a1 + 8);
if ( a2 > 1 )
{
for ( i = 1; i != a2; ++i )
v3 = (_QWORD **)*v3;
}
*v3 = (_QWORD *)**v3;
--*(_DWORD *)a1;
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func15(__int64 a1, int a2)
{
__int64 result; // rax
_QWORD **v3; // rdx
int i; // eax

result = 0LL;
if ( a2 >= 0 && *(_DWORD *)a1 > a2 )
{
v3 = *(_QWORD ***)(a1 + 8);
if ( a2 > 1 )
{
for ( i = 1; i != a2; ++i )
v3 = (_QWORD **)*v3;
}
*v3 = (_QWORD *)**v3;
--*(_DWORD *)a1;
result = 1LL;
}
return result;
}

original_code:
int Menu_removeItemById(Menu* menu, int id)
{
    if((id < 0)||(id >= menu->nombreItem))
    {
        return 0;
    }
    else
    {
        int i;
 Item* item = menu->premier;
        for(i = 1; i<id; i++)
  {
   item = item->suivant;
  }
  item->suivant = item->suivant->suivant;
        menu->nombreItem --;
    }
 return 1;
}

canonical_original_code:
int Menu_removeItemById(struct Menu *menu, int id)
{
    if((id < 0)||(id >= menu->nombreItem))
    {
        return 0;
    }
    else
    {
        int i;
 struct Item *item = menu->premier;
        for(i = 1; i<id; i++)
  {
   item = item->suivant;
  }
  item->suivant = item->suivant->suivant;
        menu->nombreItem --;
    }
 return 1;
}

variable_types: id int

variable_types: i int


decompiled_code:
__int64 __fastcall Menu_free(int *a1)
{
int v1; // ebx
__int64 result; // rax

if ( *a1 > 0 )
{
v1 = 0;
do
result = Menu_removeItemById((__int64)a1, v1++);
while ( *a1 > v1 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func16(int *a1)
{
int v1; // ebx
__int64 result; // rax

if ( *a1 > 0 )
{
v1 = 0;
do
result = func15((__int64)a1, v1++);
while ( *a1 > v1 );
}
return result;
}

original_code:
void Menu_free(Menu* menu)
{
    int buffer;
    for(buffer = 0; buffer < menu->nombreItem; buffer ++)
    {
        Menu_removeItemById(menu, buffer);
    }
}

canonical_original_code:
void Menu_free(struct Menu *menu)
{
    int buffer;
    for(buffer = 0; buffer < menu->nombreItem; buffer ++)
    {
        Menu_removeItemById(menu, buffer);
    }
}

variable_types: buffer int


lire

decompiled_code:
__int64 __fastcall lire(char *s, int a2)
{
char *v2; // rax
unsigned int v3; // edx
char *v4; // rax

v2 = fgets(s, a2, _bss_start);
v3 = 0;
if ( v2 )
{
v4 = strchr(s, 10);
v3 = 1;
if ( v4 )
*v4 = 0;
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func17(char *s, int a2)
{
char *v2; // rax
unsigned int v3; // edx
char *v4; // rax

v2 = fgets(s, a2, _bss_start);
v3 = 0;
if ( v2 )
{
v4 = strchr(s, 10);
v3 = 1;
if ( v4 )
*v4 = 0;
}
return v3;
}

original_code:
int lire(char *chaine, int longueur)
{
    char *positionEntree = ((void *)0);
    if (fgets(chaine, longueur, stdin) != ((void *)0))
    {
        positionEntree = strchr(chaine, '\n');
        if (positionEntree != ((void *)0))
        {
            *positionEntree = '\0';
        }
        return 1;
    }
    else
    {
        return 0;
    }
}

variable_types:
chaine
char *

variable_types: longueur int

variable_types:
positionEntree
char *


inputLong

original_code:
long inputLong()
{
    char nombreTexte[100] = {0};
    if (lire(nombreTexte, 100))
    {
        return strtol(nombreTexte, ((void *)0), 10);
    }
    else
    {
        return 0;
    }
}

variable_types:
nombreTexte
char [100]

return_type: long


decompiled_code:
__int64 __fastcall Menu_choose(__int64 a1)
{
const char *v1; // rbp
int v2; // esi
int v3; // ebx
__int64 v4; // rbx
__int64 result; // rax

do
{
printf("\x1B[H\x1B[2J");
v1 = *(const char **)(a1 + 8);
printf("-------- %s --------\n", (const char *)(a1 + 16));
v2 = *(_DWORD *)a1;
if ( *(int *)a1 > 0 )
{
v3 = 0;
do
{
printf("%d- %s\n", (unsigned int)++v3, v1 + 24);
v1 = *(const char **)v1;
v2 = *(_DWORD *)a1;
}
while ( v3 < *(_DWORD *)a1 );
}
printf("%d- Quitter\n", (unsigned int)(v2 + 1));
v4 = inputLong();
}
while ( v4 <= 0 || *(_DWORD *)a1 + 1 < v4 );
printf("\x1B[H\x1B[2J");
if ( *(_DWORD *)a1 + 1 == v4 )
result = 0xFFFFFFFFLL;
else
result = (unsigned int)(v4 - 1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func19(__int64 a1)
{
const char *v1; // rbp
int v2; // esi
int v3; // ebx
__int64 v4; // rbx
__int64 result; // rax

do
{
printf("\x1B[H\x1B[2J");
v1 = *(const char **)(a1 + 8);
printf("-------- %s --------\n", (const char *)(a1 + 16));
v2 = *(_DWORD *)a1;
if ( *(int *)a1 > 0 )
{
v3 = 0;
do
{
printf("%d- %s\n", (unsigned int)++v3, v1 + 24);
v1 = *(const char **)v1;
v2 = *(_DWORD *)a1;
}
while ( v3 < *(_DWORD *)a1 );
}
printf("%d- Quitter\n", (unsigned int)(v2 + 1));
v4 = func18();
}
while ( v4 <= 0 || *(_DWORD *)a1 + 1 < v4 );
printf("\x1B[H\x1B[2J");
if ( *(_DWORD *)a1 + 1 == v4 )
result = 0xFFFFFFFFLL;
else
result = (unsigned int)(v4 - 1);
return result;
}

original_code:
int Menu_choose(Menu* menu)
{
    long choix = 0;
    while((choix <= 0) || (choix > menu->nombreItem+1))
    {
  printf("\033[H\033[2J");
        int buffer;
  Item* item = menu->premier;
        printf("-------- %s --------\n", menu->titre);
        for(buffer = 0; buffer < menu->nombreItem; buffer++)
        {
            printf("%d- %s\n", buffer+1, item->label);
     item = item->suivant;
        }
        printf("%d- Quitter\n", menu->nombreItem + 1);
        choix = inputLong();
    }
 printf("\033[H\033[2J");
    if(choix==(menu->nombreItem + 1))
    {
        return -1;
    }
    else
    {
        return (int)(choix - 1);
    }
}

canonical_original_code:
int Menu_choose(struct Menu *menu)
{
    long choix = 0;
    while((choix <= 0) || (choix > menu->nombreItem+1))
    {
  printf("\033[H\033[2J");
        int buffer;
  struct Item *item = menu->premier;
        printf("-------- %s --------\n", menu->titre);
        for(buffer = 0; buffer < menu->nombreItem; buffer++)
        {
            printf("%d- %s\n", buffer+1, item->label);
     item = item->suivant;
        }
        printf("%d- Quitter\n", menu->nombreItem + 1);
        choix = inputLong();
    }
 printf("\033[H\033[2J");
    if(choix==(menu->nombreItem + 1))
    {
        return -1;
    }
    else
    {
        return (int)(choix - 1);
    }
}

variable_types: choix long


decompiled_code:
__int64 __fastcall Menu_do(__int64 a1, int a2)
{
__int64 result; // rax
_QWORD *v3; // rbx
void (*v4)(void); // rax
__int64 v5; // rdi
unsigned int v6; // eax

result = 0LL;
if ( a2 >= 0 && *(_DWORD *)a1 > a2 )
{
v3 = *(_QWORD **)(a1 + 8);
if ( a2 > 0 )
{
do
{
v3 = (_QWORD *)*v3;
LODWORD(result) = result + 1;
}
while ( a2 != (_DWORD)result );
}
v4 = (void (*)(void))v3[2];
if ( v4 )
{
v4();
result = 1LL;
}
else
{
v5 = v3[1];
result = 1LL;
if ( v5 )
{
v6 = Menu_choose(v5);
Menu_do(v3[1], v6);
result = 1LL;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func20(__int64 a1, int a2)
{
__int64 result; // rax
_QWORD *v3; // rbx
void (*v4)(void); // rax
__int64 v5; // rdi
unsigned int v6; // eax

result = 0LL;
if ( a2 >= 0 && *(_DWORD *)a1 > a2 )
{
v3 = *(_QWORD **)(a1 + 8);
if ( a2 > 0 )
{
do
{
v3 = (_QWORD *)*v3;
LODWORD(result) = result + 1;
}
while ( a2 != (_DWORD)result );
}
v4 = (void (*)(void))v3[2];
if ( v4 )
{
v4();
result = 1LL;
}
else
{
v5 = v3[1];
result = 1LL;
if ( v5 )
{
v6 = func19(v5);
func20(v3[1], v6);
result = 1LL;
}
}
}
return result;
}

original_code:
int Menu_do(Menu* menu, int action)
{
    if((action<0)||(action >= menu->nombreItem))
    {
        return 0;
    }
    else
    {
    callback fonction;
 int i;
 Item* item = menu->premier;
 for(i=0; i<action; i++)
 {
     item = item->suivant;
 }
 if(item->fonction)
 {
        fonction = item->fonction;
        fonction();
    }
    else if(item->sousMenu)
    {
        Menu_do(item->sousMenu, Menu_choose(item->sousMenu));
    }
    }
    return 1;
}

canonical_original_code:
int Menu_do(struct Menu *menu, int action)
{
    if((action<0)||(action >= menu->nombreItem))
    {
        return 0;
    }
    else
    {
    void (*fonction)();
 int i;
 struct Item *item = menu->premier;
 for(i=0; i<action; i++)
 {
     item = item->suivant;
 }
 if(item->fonction)
 {
        fonction = item->fonction;
        fonction();
    }
    else if(item->sousMenu)
    {
        Menu_do(item->sousMenu, Menu_choose(item->sousMenu));
    }
    }
    return 1;
}

variable_types:
fonction
void (*)()


decompiled_code:
__int64 __fastcall Menu_newItem(__int64 a1, __int64 a2, const char *a3)
{
*(_QWORD *)(a1 + 16) = a2;
strcpy((char *)(a1 + 24), a3);
*(_QWORD *)a1 = 0LL;
*(_QWORD *)(a1 + 8) = 0LL;
return 1LL;
}

original_code:
int Menu_newItem(Item* item, callback fonction, const char nom[])
{
    item->fonction = fonction;
    strcpy(item->label, nom);
    item->suivant=((void *)0);
    item->sousMenu=((void *)0);
    return 1;
}

canonical_original_code:
int Menu_newItem(struct Item *item, void (*fonction)(), char nom[])
{
    item->fonction = fonction;
    strcpy(item->label, nom);
    item->suivant=((void *)0);
    item->sousMenu=((void *)0);
    return 1;
}


decompiled_code:
__int64 __fastcall Menu_newItemSubMenu(__int64 a1, __int64 a2, const char *a3)
{
*(_QWORD *)(a1 + 16) = 0LL;
*(_QWORD *)(a1 + 8) = a2;
strcpy((char *)(a1 + 24), a3);
*(_QWORD *)a1 = 0LL;
return 1LL;
}

original_code:
int Menu_newItemSubMenu(Item* item, Menu* subMenu, const char nom[])
{
    item->fonction = ((void *)0);
    item->sousMenu = subMenu;
    strcpy(item->label, nom);
    item->suivant = ((void *)0);
    return 1;
}

canonical_original_code:
int Menu_newItemSubMenu(struct Item *item, struct Menu *subMenu, char nom[])
{
    item->fonction = ((void *)0);
    item->sousMenu = subMenu;
    strcpy(item->label, nom);
    item->suivant = ((void *)0);
    return 1;
}

variable_types:
subMenu
struct Menu *


main

repo: Klafyvel/asciiArt

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
dictionnaireInit(argc, argv, envp);
if ( argc > 1 )
printAA(argv[1]);
return 1;
}

original_code:
int main(int argc, char* argv[])
{
 dictionnaireInit();
 if(argc > 1)
  printAA(argv[1]);
 return 1;
}

canonical_original_code:
int main(int argc, char *argv[])
{
 dictionnaireInit();
 if(argc > 1)
  printAA(argv[1]);
 return 1;
}

variable_types: argc int

variable_types:
argv
char *[]


dictionnaireInit

original_code:
void dictionnaireInit()
{
 DICTIONNAIRE[0].car=32;
 strcpy(DICTIONNAIRE[0].lettre[0],"   ");
 strcpy(DICTIONNAIRE[0].lettre[1],"   ");
 strcpy(DICTIONNAIRE[0].lettre[2],"   ");
 strcpy(DICTIONNAIRE[0].lettre[3],"   ");
 strcpy(DICTIONNAIRE[0].lettre[4],"   ");
 strcpy(DICTIONNAIRE[0].lettre[5],"   ");
 DICTIONNAIRE[1].car='!';
 strcpy(DICTIONNAIRE[1].lettre[0]," _ ");
 strcpy(DICTIONNAIRE[1].lettre[1],"| |");
 strcpy(DICTIONNAIRE[1].lettre[2],"| |");
 strcpy(DICTIONNAIRE[1].lettre[3],"|_|");
 strcpy(DICTIONNAIRE[1].lettre[4]," _ ");
 strcpy(DICTIONNAIRE[1].lettre[5],"|_|");
 DICTIONNAIRE[2].car='0';
 strcpy(DICTIONNAIRE[2].lettre[0]," ______ ");
 strcpy(DICTIONNAIRE[2].lettre[1],"|  __  |");
 strcpy(DICTIONNAIRE[2].lettre[2],"| |  | |");
 strcpy(DICTIONNAIRE[2].lettre[3],"| |  | |");
 strcpy(DICTIONNAIRE[2].lettre[4],"| |__| |");
 strcpy(DICTIONNAIRE[2].lettre[5],"|______|");
 DICTIONNAIRE[3].car='1';
 strcpy(DICTIONNAIRE[3].lettre[0],"  ___   ");
 strcpy(DICTIONNAIRE[3].lettre[1]," /   |  ");
 strcpy(DICTIONNAIRE[3].lettre[2],"/_|  |  ");
 strcpy(DICTIONNAIRE[3].lettre[3],"  |  |  ");
 strcpy(DICTIONNAIRE[3].lettre[4]," _|  |_ ");
 strcpy(DICTIONNAIRE[3].lettre[5],"|______|");
 DICTIONNAIRE[4].car='2';
 strcpy(DICTIONNAIRE[4].lettre[0],"  ____  ");
 strcpy(DICTIONNAIRE[4].lettre[1]," /    \\ ");
 strcpy(DICTIONNAIRE[4].lettre[2],"|_ /  / ");
 strcpy(DICTIONNAIRE[4].lettre[3],"  /  /  ");
 strcpy(DICTIONNAIRE[4].lettre[4]," /  /__ ");
 strcpy(DICTIONNAIRE[4].lettre[5],"|______|");
 DICTIONNAIRE[5].car='3';
 strcpy(DICTIONNAIRE[5].lettre[0],"  ____  ");
 strcpy(DICTIONNAIRE[5].lettre[1]," /___ \\ ");
 strcpy(DICTIONNAIRE[5].lettre[2],"   __| |");
 strcpy(DICTIONNAIRE[5].lettre[3],"  |__  |");
 strcpy(DICTIONNAIRE[5].lettre[4]," ____/ |");
 strcpy(DICTIONNAIRE[5].lettre[5]," \\_____/");
 DICTIONNAIRE[6].car='4';
 strcpy(DICTIONNAIRE[6].lettre[0],"    __  ");
 strcpy(DICTIONNAIRE[6].lettre[1],"   / /  ");
 strcpy(DICTIONNAIRE[6].lettre[2],"  / /_  ");
 strcpy(DICTIONNAIRE[6].lettre[3]," / /| |_");
 strcpy(DICTIONNAIRE[6].lettre[4],"|___  _|");
 strcpy(DICTIONNAIRE[6].lettre[5],"    |_| ");
 DICTIONNAIRE[7].car='5';
 strcpy(DICTIONNAIRE[7].lettre[0]," ______ ");
 strcpy(DICTIONNAIRE[7].lettre[1],"|  ____|");
 strcpy(DICTIONNAIRE[7].lettre[2],"| |___  ");
 strcpy(DICTIONNAIRE[7].lettre[3],"|____ \\ ");
 strcpy(DICTIONNAIRE[7].lettre[4]," ____| |");
 strcpy(DICTIONNAIRE[7].lettre[5],"|______/");
 DICTIONNAIRE[8].car='6';
 strcpy(DICTIONNAIRE[8].lettre[0]," ______ ");
 strcpy(DICTIONNAIRE[8].lettre[1],"/  ____|");
 strcpy(DICTIONNAIRE[8].lettre[2],"| |___  ");
 strcpy(DICTIONNAIRE[8].lettre[3],"|  __ \\ ");
 strcpy(DICTIONNAIRE[8].lettre[4],"| |___| |");
 strcpy(DICTIONNAIRE[8].lettre[5],"|______/ ");
 DICTIONNAIRE[9].car='7';
 strcpy(DICTIONNAIRE[9].lettre[0]," ______ ");
 strcpy(DICTIONNAIRE[9].lettre[1],"|_____ |");
 strcpy(DICTIONNAIRE[9].lettre[2],"   __/ /");
 strcpy(DICTIONNAIRE[9].lettre[3],"  |_  _|");
 strcpy(DICTIONNAIRE[9].lettre[4],"   / /  ");
 strcpy(DICTIONNAIRE[9].lettre[5],"  /_/   ");
 DICTIONNAIRE[10].car='8';
 strcpy(DICTIONNAIRE[10].lettre[0],"  ____  ");
 strcpy(DICTIONNAIRE[10].lettre[1]," / -- \\ ");
 strcpy(DICTIONNAIRE[10].lettre[2],"| |__| |");
 strcpy(DICTIONNAIRE[10].lettre[3],"|  __  |");
 strcpy(DICTIONNAIRE[10].lettre[4],"| |__| |");
 strcpy(DICTIONNAIRE[10].lettre[5]," \\____/ ");
 DICTIONNAIRE[11].car='9';
 strcpy(DICTIONNAIRE[11].lettre[0],"  ____  ");
 strcpy(DICTIONNAIRE[11].lettre[1]," / -- \\ ");
 strcpy(DICTIONNAIRE[11].lettre[2],"| |__| |");
 strcpy(DICTIONNAIRE[11].lettre[3]," \\___  |");
 strcpy(DICTIONNAIRE[11].lettre[4],"  ___| |");
 strcpy(DICTIONNAIRE[11].lettre[5]," |_____|");
 DICTIONNAIRE[12].car='?';
 strcpy(DICTIONNAIRE[12].lettre[0],"  _____ ");
 strcpy(DICTIONNAIRE[12].lettre[1]," /___  \\");
 strcpy(DICTIONNAIRE[12].lettre[2],"     | |");
 strcpy(DICTIONNAIRE[12].lettre[3],"    / / ");
 strcpy(DICTIONNAIRE[12].lettre[4],"   |_|  ");
 strcpy(DICTIONNAIRE[12].lettre[5],"   [ ]  ");
 DICTIONNAIRE[13].car='<';
 strcpy(DICTIONNAIRE[13].lettre[0],"  __");
 strcpy(DICTIONNAIRE[13].lettre[1]," / /");
 strcpy(DICTIONNAIRE[13].lettre[2],"/ / ");
 strcpy(DICTIONNAIRE[13].lettre[3],"\\ \\ ");
 strcpy(DICTIONNAIRE[13].lettre[4]," \\_\\");
 strcpy(DICTIONNAIRE[13].lettre[5],"    ");
 DICTIONNAIRE[14].car='A';
 strcpy(DICTIONNAIRE[14].lettre[0],"  ____  ");
 strcpy(DICTIONNAIRE[14].lettre[1]," / __ \\ ");
 strcpy(DICTIONNAIRE[14].lettre[2],"| |__| |");
 strcpy(DICTIONNAIRE[14].lettre[3],"|  __  |");
 strcpy(DICTIONNAIRE[14].lettre[4],"| |  | |");
 strcpy(DICTIONNAIRE[14].lettre[5],"|_|  |_|");
 DICTIONNAIRE[15].car='B';
 strcpy(DICTIONNAIRE[15].lettre[0]," _____  ");
 strcpy(DICTIONNAIRE[15].lettre[1],"|  _  \\ ");
 strcpy(DICTIONNAIRE[15].lettre[2],"| |_| / ");
 strcpy(DICTIONNAIRE[15].lettre[3],"|  __ \\ ");
 strcpy(DICTIONNAIRE[15].lettre[4],"| |__| |");
 strcpy(DICTIONNAIRE[15].lettre[5],"|_____/ ");
 DICTIONNAIRE[16].car='C';
 strcpy(DICTIONNAIRE[16].lettre[0],"  _____ ");
 strcpy(DICTIONNAIRE[16].lettre[1]," /  ___|");
 strcpy(DICTIONNAIRE[16].lettre[2],"|  /    ");
 strcpy(DICTIONNAIRE[16].lettre[3],"| |     ");
 strcpy(DICTIONNAIRE[16].lettre[4],"|  \\___ ");
 strcpy(DICTIONNAIRE[16].lettre[5]," \\_____|");
 DICTIONNAIRE[17].car='D';
 strcpy(DICTIONNAIRE[17].lettre[0]," ____   ");
 strcpy(DICTIONNAIRE[17].lettre[1],"|  _ \\  ");
 strcpy(DICTIONNAIRE[17].lettre[2],"| | \\ \\ ");
 strcpy(DICTIONNAIRE[17].lettre[3],"| |  | |");
 strcpy(DICTIONNAIRE[17].lettre[4],"| |_/ / ");
 strcpy(DICTIONNAIRE[17].lettre[5],"|___ /  ");
 DICTIONNAIRE[18].car='E';
 strcpy(DICTIONNAIRE[18].lettre[0]," ______ ");
 strcpy(DICTIONNAIRE[18].lettre[1],"|  ____|");
 strcpy(DICTIONNAIRE[18].lettre[2],"| |___  ");
 strcpy(DICTIONNAIRE[18].lettre[3],"|  ___| ");
 strcpy(DICTIONNAIRE[18].lettre[4],"| |____ ");
 strcpy(DICTIONNAIRE[18].lettre[5],"|______|");
 DICTIONNAIRE[19].car='F';
 strcpy(DICTIONNAIRE[19].lettre[0]," ______ ");
 strcpy(DICTIONNAIRE[19].lettre[1],"|  ____|");
 strcpy(DICTIONNAIRE[19].lettre[2],"| |___  ");
 strcpy(DICTIONNAIRE[19].lettre[3],"|  ___| ");
 strcpy(DICTIONNAIRE[19].lettre[4],"| |     ");
 strcpy(DICTIONNAIRE[19].lettre[5],"|_|     ");
 DICTIONNAIRE[20].car='G';
 strcpy(DICTIONNAIRE[20].lettre[0],"  _____ ");
 strcpy(DICTIONNAIRE[20].lettre[1]," /  ___|");
 strcpy(DICTIONNAIRE[20].lettre[2],"| / __  ");
 strcpy(DICTIONNAIRE[20].lettre[3],"| ||_ \\ ");
 strcpy(DICTIONNAIRE[20].lettre[4],"| \\__/ |");
 strcpy(DICTIONNAIRE[20].lettre[5]," \\____/ ");
 DICTIONNAIRE[21].car='H';
 strcpy(DICTIONNAIRE[21].lettre[0]," _    _ ");
 strcpy(DICTIONNAIRE[21].lettre[1],"| |  | |");
 strcpy(DICTIONNAIRE[21].lettre[2],"| |__| |");
 strcpy(DICTIONNAIRE[21].lettre[3],"|  __  |");
 strcpy(DICTIONNAIRE[21].lettre[4],"| |  | |");
 strcpy(DICTIONNAIRE[21].lettre[5],"|_|  |_|");
 DICTIONNAIRE[22].car='I';
 strcpy(DICTIONNAIRE[22].lettre[0]," ______ ");
 strcpy(DICTIONNAIRE[22].lettre[1],"|_    _|");
 strcpy(DICTIONNAIRE[22].lettre[2],"  |  |  ");
 strcpy(DICTIONNAIRE[22].lettre[3],"  |  |  ");
 strcpy(DICTIONNAIRE[22].lettre[4]," _|  |_ ");
 strcpy(DICTIONNAIRE[22].lettre[5],"|______|");
 DICTIONNAIRE[23].car='J';
 strcpy(DICTIONNAIRE[23].lettre[0]," ______ ");
 strcpy(DICTIONNAIRE[23].lettre[1],"|__   _|");
 strcpy(DICTIONNAIRE[23].lettre[2],"   | |  ");
 strcpy(DICTIONNAIRE[23].lettre[3],"   | |  ");
 strcpy(DICTIONNAIRE[23].lettre[4]," __/ /  ");
 strcpy(DICTIONNAIRE[23].lettre[5],"|___/   ");
 DICTIONNAIRE[24].car='K';
 strcpy(DICTIONNAIRE[24].lettre[0]," __   __");
 strcpy(DICTIONNAIRE[24].lettre[1],"|  | / /");
 strcpy(DICTIONNAIRE[24].lettre[2],"|  |/ / ");
 strcpy(DICTIONNAIRE[24].lettre[3],"|    |  ");
 strcpy(DICTIONNAIRE[24].lettre[4],"|  |\\ \\ ");
 strcpy(DICTIONNAIRE[24].lettre[5],"|__| \\_\\");
 DICTIONNAIRE[25].car='L';
 strcpy(DICTIONNAIRE[25].lettre[0]," _      ");
 strcpy(DICTIONNAIRE[25].lettre[1],"| |     ");
 strcpy(DICTIONNAIRE[25].lettre[2],"| |     ");
 strcpy(DICTIONNAIRE[25].lettre[3],"| |     ");
 strcpy(DICTIONNAIRE[25].lettre[4],"| |____ ");
 strcpy(DICTIONNAIRE[25].lettre[5],"|______|");
 DICTIONNAIRE[26].car='M';
 strcpy(DICTIONNAIRE[26].lettre[0]," _    _ ");
 strcpy(DICTIONNAIRE[26].lettre[1],"| \\  / |");
 strcpy(DICTIONNAIRE[26].lettre[2],"||\\\\//||");
 strcpy(DICTIONNAIRE[26].lettre[3],"|| \\/ ||");
 strcpy(DICTIONNAIRE[26].lettre[4],"||    ||");
 strcpy(DICTIONNAIRE[26].lettre[5],"||    ||");
 DICTIONNAIRE[27].car='N';
 strcpy(DICTIONNAIRE[27].lettre[0]," __   _ ");
 strcpy(DICTIONNAIRE[27].lettre[1],"|  \\ | |");
 strcpy(DICTIONNAIRE[27].lettre[2],"|   \\| |");
 strcpy(DICTIONNAIRE[27].lettre[3],"| |\\   |");
 strcpy(DICTIONNAIRE[27].lettre[4],"| | \\  |");
 strcpy(DICTIONNAIRE[27].lettre[5],"|_|  \\_|");
 DICTIONNAIRE[28].car='O';
 strcpy(DICTIONNAIRE[28].lettre[0],"  ____  ");
 strcpy(DICTIONNAIRE[28].lettre[1]," / __ \\ ");
 strcpy(DICTIONNAIRE[28].lettre[2],"| |  | |");
 strcpy(DICTIONNAIRE[28].lettre[3],"| |  | |");
 strcpy(DICTIONNAIRE[28].lettre[4],"| |__| |");
 strcpy(DICTIONNAIRE[28].lettre[5]," \\____/ ");
 DICTIONNAIRE[29].car='P';
 strcpy(DICTIONNAIRE[29].lettre[0]," _____  ");
 strcpy(DICTIONNAIRE[29].lettre[1],"|  __ \\ ");
 strcpy(DICTIONNAIRE[29].lettre[2],"| |__\\ |");
 strcpy(DICTIONNAIRE[29].lettre[3],"|  ___/ ");
 strcpy(DICTIONNAIRE[29].lettre[4],"| |     ");
 strcpy(DICTIONNAIRE[29].lettre[5],"|_|     ");
 DICTIONNAIRE[30].car='Q';
 strcpy(DICTIONNAIRE[30].lettre[0],"  ____  ");
 strcpy(DICTIONNAIRE[30].lettre[1]," / __ \\ ");
 strcpy(DICTIONNAIRE[30].lettre[2],"| |  | |");
 strcpy(DICTIONNAIRE[30].lettre[3],"| | _| |");
 strcpy(DICTIONNAIRE[30].lettre[4],"| |_\\ \\|");
 strcpy(DICTIONNAIRE[30].lettre[5]," \\___\\_\\");
 DICTIONNAIRE[31].car='R';
 strcpy(DICTIONNAIRE[31].lettre[0]," _____  ");
 strcpy(DICTIONNAIRE[31].lettre[1],"|  __ \\ ");
 strcpy(DICTIONNAIRE[31].lettre[2],"| |__\\ |");
 strcpy(DICTIONNAIRE[31].lettre[3],"|    _/ ");
 strcpy(DICTIONNAIRE[31].lettre[4],"| |\\ \\  ");
 strcpy(DICTIONNAIRE[31].lettre[5],"|_| \\_\\ ");
 DICTIONNAIRE[32].car='S';
 strcpy(DICTIONNAIRE[32].lettre[0],"  _____ ");
 strcpy(DICTIONNAIRE[32].lettre[1]," / ____|");
 strcpy(DICTIONNAIRE[32].lettre[2],"| |___  ");
 strcpy(DICTIONNAIRE[32].lettre[3]," \\___ \\ ");
 strcpy(DICTIONNAIRE[32].lettre[4]," ____| |");
 strcpy(DICTIONNAIRE[32].lettre[5],"|_____/ ");
 DICTIONNAIRE[33].car='T';
 strcpy(DICTIONNAIRE[33].lettre[0]," ______ ");
 strcpy(DICTIONNAIRE[33].lettre[1],"|_    _|");
 strcpy(DICTIONNAIRE[33].lettre[2],"  |  |  ");
 strcpy(DICTIONNAIRE[33].lettre[3],"  |  |  ");
 strcpy(DICTIONNAIRE[33].lettre[4],"  |  |  ");
 strcpy(DICTIONNAIRE[33].lettre[5],"  |__|  ");
 DICTIONNAIRE[34].car='U';
 strcpy(DICTIONNAIRE[34].lettre[0]," _    _ ");
 strcpy(DICTIONNAIRE[34].lettre[1],"| |  | |");
 strcpy(DICTIONNAIRE[34].lettre[2],"| |  | |");
 strcpy(DICTIONNAIRE[34].lettre[3],"| |  | |");
 strcpy(DICTIONNAIRE[34].lettre[4],"| |__| |");
 strcpy(DICTIONNAIRE[34].lettre[5]," \\____/ ");
 DICTIONNAIRE[35].car='V';
 strcpy(DICTIONNAIRE[35].lettre[0]," _    _ ");
 strcpy(DICTIONNAIRE[35].lettre[1],"| |  | |");
 strcpy(DICTIONNAIRE[35].lettre[2],"| |  | |");
 strcpy(DICTIONNAIRE[35].lettre[3]," \\ \\/ / ");
 strcpy(DICTIONNAIRE[35].lettre[4],"  \\  /  ");
 strcpy(DICTIONNAIRE[35].lettre[5],"   \\/   ");
 DICTIONNAIRE[36].car='W';
 strcpy(DICTIONNAIRE[36].lettre[0],"        ");
 strcpy(DICTIONNAIRE[36].lettre[1],"||    ||");
 strcpy(DICTIONNAIRE[36].lettre[2],"||    ||");
 strcpy(DICTIONNAIRE[36].lettre[3],"|| /\\ ||");
 strcpy(DICTIONNAIRE[36].lettre[4],"||//\\\\||");
 strcpy(DICTIONNAIRE[36].lettre[5],"|_/  \\_|");
 DICTIONNAIRE[37].car='X';
 strcpy(DICTIONNAIRE[37].lettre[0]," _    _ ");
 strcpy(DICTIONNAIRE[37].lettre[1],"| |  | |");
 strcpy(DICTIONNAIRE[37].lettre[2]," \\ \\/ / ");
 strcpy(DICTIONNAIRE[37].lettre[3],"  \\  /  ");
 strcpy(DICTIONNAIRE[37].lettre[4]," / /\\ \\ ");
 strcpy(DICTIONNAIRE[37].lettre[5],"|_|  |_|");
 DICTIONNAIRE[38].car='Y';
 strcpy(DICTIONNAIRE[38].lettre[0],"__   __ ");
 strcpy(DICTIONNAIRE[38].lettre[1],"\\ \\ / / ");
 strcpy(DICTIONNAIRE[38].lettre[2]," \\ v /  ");
 strcpy(DICTIONNAIRE[38].lettre[3],"  | |   ");
 strcpy(DICTIONNAIRE[38].lettre[4],"  | |   ");
 strcpy(DICTIONNAIRE[38].lettre[5],"  |_|   ");
 DICTIONNAIRE[39].car='Z';
 strcpy(DICTIONNAIRE[39].lettre[0]," ______ ");
 strcpy(DICTIONNAIRE[39].lettre[1],"|____  |");
 strcpy(DICTIONNAIRE[39].lettre[2],"    / / ");
 strcpy(DICTIONNAIRE[39].lettre[3],"   / /  ");
 strcpy(DICTIONNAIRE[39].lettre[4]," _/ /__ ");
 strcpy(DICTIONNAIRE[39].lettre[5],"|______|");
}


foundALetter

decompiled_code:
char *__fastcall foundALetter(char a1)
{
int v2; // er9
int v3; // edi
int v5; // esi
int v6; // eax
char v7; // dl

if ( (unsigned __int8)((a1 & 0xDF) - 65) <= 0x19u )
{
v2 = 40;
v3 = 0;
goto LABEL_10;
}
if ( (unsigned __int8)(a1 - 32) <= 1u )
{
v2 = 40;
v3 = 0;
while ( 1 )
{
LABEL_10:
while ( 1 )
{
v6 = (v3 + v2) / 2;
v5 = v6;
v7 = DICTIONNAIRE[49 * v6];
if ( v7 >= a1 )
break;
LABEL_9:
v3 = v5;
}
if ( v7 > a1 )
{
v2 = (v3 + v2) / 2;
v5 = v3;
goto LABEL_9;
}
if ( v7 == a1 )
return &DICTIONNAIRE[49 * v6];
}
}
if ( (unsigned __int8)(a1 - 48) <= 9u )
{
v2 = 40;
v3 = 0;
goto LABEL_10;
}
return 0LL;
}

canonical_decompiled_code:
char *__fastcall func1(char a1)
{
int v2; // er9
int v3; // edi
int v5; // esi
int v6; // eax
char v7; // dl

if ( (unsigned __int8)((a1 & 0xDF) - 65) <= 0x19u )
{
v2 = 40;
v3 = 0;
goto LABEL_10;
}
if ( (unsigned __int8)(a1 - 32) <= 1u )
{
v2 = 40;
v3 = 0;
while ( 1 )
{
LABEL_10:
while ( 1 )
{
v6 = (v3 + v2) / 2;
v5 = v6;
v7 = DICTIONNAIRE[49 * v6];
if ( v7 >= a1 )
break;
LABEL_9:
v3 = v5;
}
if ( v7 > a1 )
{
v2 = (v3 + v2) / 2;
v5 = v3;
goto LABEL_9;
}
if ( v7 == a1 )
return &DICTIONNAIRE[49 * v6];
}
}
if ( (unsigned __int8)(a1 - 48) <= 9u )
{
v2 = 40;
v3 = 0;
goto LABEL_10;
}
return 0LL;
}

original_code:
struct s_dict* foundALetter(char letter)
{
 if((letter<'a' || letter>'z')&&(letter<'A' || letter>'Z')&&(letter<32 || letter>33)&&(letter<'0' || letter>'9')&&(letter!='<' || letter!='?'))
  return ((void *)0);
 int id = 0;
 int ifin = 40;
 struct s_dict* ptr = ((void *)0);
 do
 {
  int milieu=(id + ifin)/2;
  ptr = &DICTIONNAIRE[milieu];
  if((ptr->car)<letter) {
   id = milieu;
  }
  else if(letter<(ptr->car)){
   ifin = milieu;
  }
 }while(ptr->car != letter);
 return ptr;
}

canonical_original_code:
struct s_dict *foundALetter(char letter)
{
 if((letter<'a' || letter>'z')&&(letter<'A' || letter>'Z')&&(letter<32 || letter>33)&&(letter<'0' || letter>'9')&&(letter!='<' || letter!='?'))
  return ((void *)0);
 int id = 0;
 int ifin = 40;
 struct s_dict *ptr = ((void *)0);
 do
 {
  int milieu = (id + ifin)/2;
  ptr = &DICTIONNAIRE[milieu];
  if((ptr->car)<letter) {
   id = milieu;
  }
  else if(letter<(ptr->car)){
   ifin = milieu;
  }
 }while(ptr->car != letter);
 return ptr;
}

variable_types: letter char

variable_types: ifin int

variable_types: struct s_dict { char car; char lettre[6][8]; } *

variable_types: milieu int


printAA

decompiled_code:
__int64 __fastcall printAA(const char *a1)
{
size_t v1; // rbx
size_t i; // rax
char v3; // al
__int64 v4; // r13
__int64 v5; // r14
char *v6; // rbx
char *v7; // rbp
const char *v8; // r12
int v9; // edi
__int64 v10; // r15
int v13; // [rsp+Ch] [rbp-3Ch]

v1 = 0LL;
for ( i = strlen(a1); i > v1; i = strlen(a1) )
{
v3 = a1[v1];
if ( (unsigned __int8)(v3 - 97) <= 0x19u )
a1[v1] = v3 - 32;
++v1;
}
v13 = i;
v4 = 0LL;
v5 = (__int64)&a1[(unsigned int)(i - 1) + 1];
do
{
v8 = a1;
v10 = 0x7FFFFFE93FF0003LL;
if ( v13 > 0 )
{
do
{
v9 = *(unsigned __int8 *)v8;
if ( (unsigned __int8)(v9 - 32) <= 0x3Au && _bittest64(&v10, (unsigned int)(v9 - 32)) )
{
v6 = &foundALetter(v9)[v4];
v7 = v6 + 8;
do
putchar(*++v6);
while ( v6 != v7 );
}
else
{
putchar((char)v9);
}
++v8;
}
while ( v8 != (const char *)v5 );
}
putchar(10);
v4 += 8LL;
}
while ( v4 != 48 );
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(const char *a1)
{
size_t v1; // rbx
size_t i; // rax
char v3; // al
__int64 v4; // r13
__int64 v5; // r14
char *v6; // rbx
char *v7; // rbp
const char *v8; // r12
int v9; // edi
__int64 v10; // r15
int v13; // [rsp+Ch] [rbp-3Ch]

v1 = 0LL;
for ( i = strlen(a1); i > v1; i = strlen(a1) )
{
v3 = a1[v1];
if ( (unsigned __int8)(v3 - 97) <= 0x19u )
a1[v1] = v3 - 32;
++v1;
}
v13 = i;
v4 = 0LL;
v5 = (__int64)&a1[(unsigned int)(i - 1) + 1];
do
{
v8 = a1;
v10 = 0x7FFFFFE93FF0003LL;
if ( v13 > 0 )
{
do
{
v9 = *(unsigned __int8 *)v8;
if ( (unsigned __int8)(v9 - 32) <= 0x3Au && _bittest64(&v10, (unsigned int)(v9 - 32)) )
{
v6 = &func1(v9)[v4];
v7 = v6 + 8;
do
putchar(*++v6);
while ( v6 != v7 );
}
else
{
putchar((char)v9);
}
++v8;
}
while ( v8 != (const char *)v5 );
}
putchar(10);
v4 += 8LL;
}
while ( v4 != 48 );
return 1LL;
}

original_code:
int printAA(char chaine[])
{
 int i, j, k;
 for(i=0; i<strlen(chaine); i++)
 {
  if(chaine[i]>='a' && chaine[i]<='z')
   chaine[i]-= 32;
 }
 int size = strlen(chaine);
 struct s_dict* asciiArt;
 for(j=0; j<6; j++)
 {
  for(i=0; i<size; i++)
  {
   if((chaine[i]>='A' && chaine[i]<='Z')||(chaine[i]>=32 && chaine[i]<=33)||(chaine[i]>='0' && chaine[i]<='9')||(chaine[i]=='<' || chaine[i]=='?'))
   {
    asciiArt = foundALetter(chaine[i]);
    for(k=0; k<8; k++)
    {
     putchar(asciiArt->lettre[j][k]);
    }
   }
   else
    printf("%c", chaine[i]);
  }
  printf("\n");
 }
 return 1;
}

canonical_original_code:
int printAA(char chaine[])
{
 int i; int j; int k;
 for(i=0; i<strlen(chaine); i++)
 {
  if(chaine[i]>='a' && chaine[i]<='z')
   chaine[i]-= 32;
 }
 int size = strlen(chaine);
 struct s_dict *asciiArt;
 for(j=0; j<6; j++)
 {
  for(i=0; i<size; i++)
  {
   if((chaine[i]>='A' && chaine[i]<='Z')||(chaine[i]>=32 && chaine[i]<=33)||(chaine[i]>='0' && chaine[i]<='9')||(chaine[i]=='<' || chaine[i]=='?'))
   {
    asciiArt = foundALetter(chaine[i]);
    for(k=0; k<8; k++)
    {
     putchar(asciiArt->lettre[j][k]);
    }
   }
   else
    printf("%c", chaine[i]);
  }
  printf("\n");
 }
 return 1;
}

variable_types:
chaine
char []

variable_types: j int

variable_types: k int

variable_types: size int

user_defined_types: struct s_dict { char car; char lettre[6][8]; }


repo: Klowner/gluppy

original_code:
size_t handle_galx(void *buffer, size_t size, size_t nmemb, void *data) {
 struct galx_search *galx = (struct galx_search*)data;
 char pattern[] = "name=\"GALX\"value=\"\0";
 unsigned int data_length = size * nmemb;
 unsigned char *ptr = (unsigned char*)buffer;
 int i;
 for(i = 0; i < data_length; i++) {
  if(galx->state == 'c') {
   if(*ptr == '"') {
    galx->state = 'd';
    *galx->target_end = '\0';
   } else {
    *galx->target_end = *ptr;
    galx->target_end++;
   }
  }
  if((int)*ptr > 32 && galx->state == 's') {
   if( pattern[galx->pos] == *ptr) {
    galx->pos += 1;
    if(galx->pos == strlen(pattern)) {
     galx->state = 'c';
    }
   } else {
    galx->pos = 0;
   }
  }
  ++ptr;
 }
 if(galx->state == 'd')
  return 0;
 return size * nmemb;
}

canonical_original_code:
unsigned long handle_galx(void *buffer, unsigned long size, unsigned long nmemb, void *data) {
 struct galx_search *galx = (struct galx_search*)data;
 char pattern[] = "name=\"GALX\"value=\"\0";
 unsigned int data_length = size * nmemb;
 unsigned char *ptr = (unsigned char*)buffer;
 int i;
 for(i = 0; i < data_length; i++) {
  if(galx->state == 'c') {
   if(*ptr == '"') {
    galx->state = 'd';
    *galx->target_end = '\0';
   } else {
    *galx->target_end = *ptr;
    galx->target_end++;
   }
  }
  if((int)*ptr > 32 && galx->state == 's') {
   if( pattern[galx->pos] == *ptr) {
    galx->pos += 1;
    if(galx->pos == strlen(pattern)) {
     galx->state = 'c';
    }
   } else {
    galx->pos = 0;
   }
  }
  ++ptr;
 }
 if(galx->state == 'd')
  return 0;
 return size * nmemb;
}

variable_types:
buffer
void *

variable_types:
size
unsigned long

variable_types:
nmemb
unsigned long

variable_types:
data
void *

variable_types: struct galx_search { int pos; char state; char *target; char *target_end; } *

variable_types:
pattern
char []

variable_types:
ptr
unsigned char *

variable_types: i int

return_type: unsigned long


decompiled_code:
__int64 __fastcall write_data(const char *a1, __int64 a2)
{
printf(a1);
return a2;
}

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

original_code:
size_t write_data(void *buffer, size_t size, size_t nmemb, void *userp) {
 printf(buffer);
 return size;
}

canonical_original_code:
unsigned long write_data(void *buffer, unsigned long size, unsigned long nmemb, void *userp) {
 printf(buffer);
 return size;
}

variable_types:
userp
void *


bit

repo: Koistinen/Endgame

decompiled_code:
__int64 __fastcall bit(char a1)
{
return 1LL << a1;
}

canonical_decompiled_code:
__int64 __fastcall func7(char a1)
{
return 1LL << a1;
}

original_code:
Bitboard
bit(int64_t n) {
  return 1ull<<n;
}

canonical_original_code:
unsigned long bit(long n) {
  return 1ull<<n;
}

variable_types: n long


decompiled_code:
int __fastcall BB_print(__int64 a1)
{
__int64 v1; // rbp
__int64 v2; // rbx
__int64 v3; // rax
int result; // eax

puts("========");
v1 = 64LL;
do
{
v2 = v1 - 8;
do
{
v3 = bit(v2);
putchar(byte_40200D[(a1 & v3) == 0]);
++v2;
}
while ( v2 != v1 );
result = putchar(10);
v1 -= 8LL;
}
while ( v1 );
return result;
}

canonical_decompiled_code:
int __fastcall func8(__int64 a1)
{
__int64 v1; // rbp
__int64 v2; // rbx
__int64 v3; // rax
int result; // eax

puts("========");
v1 = 64LL;
do
{
v2 = v1 - 8;
do
{
v3 = func7(v2);
putchar(byte_40200D[(a1 & v3) == 0]);
++v2;
}
while ( v2 != v1 );
result = putchar(10);
v1 -= 8LL;
}
while ( v1 );
return result;
}

original_code:
void
BB_print(Bitboard bb) {
  int64_t rank;
  int64_t file;
  printf("========\n");
  for (rank=8;rank--;) {
    for (file=0;file<8;++file)
      printf("%c", "*-"[!(bb&bit(rank*8+file))]);
    printf("\n");
  }
}

canonical_original_code:
void BB_print(unsigned long bb) {
  long rank;
  long file;
  printf("========\n");
  for (rank=8;rank--;) {
    for (file=0;file<8;++file)
      printf("%c", "*-"[!(bb&bit(rank*8+file))]);
    printf("\n");
  }
}

variable_types:
bb
unsigned long

variable_types: rank long

variable_types: file long


occupied

original_code:
Bitboard
occupied(Position *p)
{
  Bitboard oc = 0;
  int64_t i;
  for(i=p->n;i--;)
    oc |= bit(p->piece[i]);
  return oc;
}

canonical_original_code:
unsigned long occupied(struct Position *p)
{
  unsigned long oc = 0;
  long i;
  for(i=p->n;i--;)
    oc |= bit(p->piece[i]);
  return oc;
}

variable_types: struct Position { long piece[33]; long wtm; char *type; long side[33]; int n; long kings[2]; } *

variable_types:
oc
unsigned long

variable_types: i long


original_code:
int64_t
pos_offset(Position *p)
{
  int64_t i;
  int64_t value = p->wtm<<(6*p->n);
  for(i=p->n;i--;) {
    value += p->piece[i]<<(6*i);
  }
  return value;
}

canonical_original_code:
long pos_offset(struct Position *p)
{
  long i;
  long value = p->wtm<<(6*p->n);
  for(i=p->n;i--;) {
    value += p->piece[i]<<(6*i);
  }
  return value;
}

variable_types: value long

user_defined_types: struct Position { long piece[33]; long wtm; char *type; long side[33]; int n; long kings[2]; }


original_code:
Bitboard
gen_moves(Position *p, int64_t mover, Bitboard oc)
{
  Bitboard mv = 0;
  Bitboard bb;
  int64_t from = p->piece[mover];
  switch (p->type[mover]) {
  case 'K':
    mv = bit(from);
    if (7!=(from&7))
      mv |= mv << 1;
    if (from&7)
      mv |= (mv >> 1);
    mv |= (mv<<8) | (mv>>8);
    mv ^= bit(from);
    break;
  case 'R':
    for (bb = bit(from); (bb>>=1) & 0x7f7f7f7f7f7f7f7full;) {
      mv |= bb;
      if (bb&oc) break;
    }
    for (bb = bit(from); (bb<<=1) & 0xfefefefefefefefeull;) {
      mv |= bb;
      if (bb&oc) break;
    }
    for (bb = bit(from); bb>>=8;) {
      mv |= bb;
      if (bb&oc) break;
    }
    for (bb = bit(from); bb<<=8;) {
      mv |= bb;
      if (bb&oc) break;
    }
    break;
    default:
    printf("Internal error! Can't generate moves for unknown piece \"%c\".\n", p->type[mover]);
    exit(1);
  }
  return mv;
}

canonical_original_code:
unsigned long gen_moves(struct Position *p, long mover, unsigned long oc)
{
  unsigned long mv = 0;
  unsigned long bb;
  long from = p->piece[mover];
  switch (p->type[mover]) {
  case 'K':
    mv = bit(from);
    if (7!=(from&7))
      mv |= mv << 1;
    if (from&7)
      mv |= (mv >> 1);
    mv |= (mv<<8) | (mv>>8);
    mv ^= bit(from);
    break;
  case 'R':
    for (bb = bit(from); (bb>>=1) & 0x7f7f7f7f7f7f7f7full;) {
      mv |= bb;
      if (bb&oc) break;
    }
    for (bb = bit(from); (bb<<=1) & 0xfefefefefefefefeull;) {
      mv |= bb;
      if (bb&oc) break;
    }
    for (bb = bit(from); bb>>=8;) {
      mv |= bb;
      if (bb&oc) break;
    }
    for (bb = bit(from); bb<<=8;) {
      mv |= bb;
      if (bb&oc) break;
    }
    break;
    default:
    printf("Internal error! Can't generate moves for unknown piece \"%c\".\n", p->type[mover]);
    exit(1);
  }
  return mv;
}

variable_types: mover long

variable_types:
mv
unsigned long

variable_types: from long


decompiled_code:
__int64 __fastcall mark_check(__int64 a1, __int64 a2, __int64 a3, __int64 a4, char a5)
{
__int64 v8; // rax
unsigned __int64 v9; // r12
__int64 i; // rbx
__int64 result; // rax

v8 = occupied(a2);
v9 = gen_moves(a2, a3, v8);
for ( i = 63LL; i != -1; --i )
{
result = bit(i);
if ( (v9 & result) != 0 )
{
*(_QWORD *)(a2 + 8 * a4) = i;
result = a1 + pos_offset(a2);
if ( *(_BYTE *)result != 0xFF )
*(_BYTE *)result = a5;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, __int64 a2, __int64 a3, __int64 a4, char a5)
{
__int64 v8; // rax
unsigned __int64 v9; // r12
__int64 i; // rbx
__int64 result; // rax

v8 = func9(a2);
v9 = func11(a2, a3, v8);
for ( i = 63LL; i != -1; --i )
{
result = func7(i);
if ( (v9 & result) != 0 )
{
*(_QWORD *)(a2 + 8 * a4) = i;
result = a1 + func10(a2);
if ( *(_BYTE *)result != 0xFF )
*(_BYTE *)result = a5;
}
}
return result;
}

original_code:
void
mark_check(Byte *tb, Position *p, int64_t mover, int64_t checked, int64_t value)
{
  int64_t ind;
  int64_t sq;
  Bitboard oc = occupied(p);
  Bitboard mv = gen_moves(p, mover, oc);
  for (sq=64;sq--;) {
    if (mv&bit(sq)) {
      p->piece[checked] = sq;
      ind = pos_offset(p);
      if (-1 != tb[ind])
 tb[ind] = value;
    }
  }
}

canonical_original_code:
void mark_check(char *tb, struct Position *p, long mover, long checked, long value)
{
  long ind;
  long sq;
  unsigned long oc = occupied(p);
  unsigned long mv = gen_moves(p, mover, oc);
  for (sq=64;sq--;) {
    if (mv&bit(sq)) {
      p->piece[checked] = sq;
      ind = pos_offset(p);
      if (-1 != tb[ind])
 tb[ind] = value;
    }
  }
}

variable_types:
tb
char *

variable_types: checked long

variable_types: ind long

variable_types: sq long


original_code:
void
count_positions(Byte *tb, int64_t n) {
  int64_t count[256];
  int64_t i;
  for (i=256;i--;) count[i] = 0;
  for (i=n;i--;) ++count[0xff&tb[i]];
  for (i=256;i--;)
    if (count[i])
      printf("%3d: %15ld\n", (Byte)i, count[i]);
}

canonical_original_code:
void count_positions(char *tb, long n) {
  long count[256];
  long i;
  for (i=256;i--;) count[i] = 0;
  for (i=n;i--;) ++count[0xff&tb[i]];
  for (i=256;i--;)
    if (count[i])
      printf("%3d: %15ld\n", (char)i, count[i]);
}

variable_types:
count
long [256]


original_code:
void
mark_legal(Byte *tb, Position *p)
{
  int64_t i;
  int64_t illegal_count = 0;
  int64_t legal_count = 0;
  int64_t position_count = 0;
  for(p->wtm=2;p->wtm--;) {
    p->piece[p->n]=1;
    for(i=p->n;i--;) p->piece[i] = 077;
    while(p->piece[p->n]) {
      {
 Byte value = 101;
 Bitboard oc=0;
 for(i=p->n;i--;) {
   Bitboard bb = bit(p->piece[i]);
   if(oc&bb) value = -1;
   oc |= bb;
 }
 if (101 == value) ++legal_count;
 if (-1 == value) ++illegal_count;
 ++position_count;
 tb[pos_offset(p)] = value;
      }
      if (0 == p->piece[p->kings[!p->wtm]]) {
   for (i=p->n;i--;) {
     if (p->side[i]==p->wtm) {
       mark_check(tb, p, i, p->kings[!p->wtm], -1);
     }
   }
   p->piece[p->kings[!p->wtm]] = 0;
 }
      for(i=0;!p->piece[i]--;) {
 p->piece[i++] = 077;
      }
    }
  }
  printf("%ld legal and %ld illegal out of %ld positions when initializing.\n",
  legal_count, illegal_count, position_count);
}

canonical_original_code:
void mark_legal(char *tb, struct Position *p)
{
  long i;
  long illegal_count = 0;
  long legal_count = 0;
  long position_count = 0;
  for(p->wtm=2;p->wtm--;) {
    p->piece[p->n]=1;
    for(i=p->n;i--;) p->piece[i] = 077;
    while(p->piece[p->n]) {
      {
 char value = 101;
 unsigned long oc = 0;
 for(i=p->n;i--;) {
   unsigned long bb = bit(p->piece[i]);
   if(oc&bb) value = -1;
   oc |= bb;
 }
 if (101 == value) ++legal_count;
 if (-1 == value) ++illegal_count;
 ++position_count;
 tb[pos_offset(p)] = value;
      }
      if (0 == p->piece[p->kings[!p->wtm]]) {
   for (i=p->n;i--;) {
     if (p->side[i]==p->wtm) {
       mark_check(tb, p, i, p->kings[!p->wtm], -1);
     }
   }
   p->piece[p->kings[!p->wtm]] = 0;
 }
      for(i=0;!p->piece[i]--;) {
 p->piece[i++] = 077;
      }
    }
  }
  printf("%ld legal and %ld illegal out of %ld positions when initializing.\n",
  legal_count, illegal_count, position_count);
}

variable_types: value char


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
_QWORD *v3; // r14
const char *v4; // r15
__int64 v5; // rbx
unsigned int v6; // er12
char v7; // bp
unsigned __int64 v8; // rbx
char *v9; // rbp
int i; // er12
char *s; // [rsp+8h] [rbp-50h]
int v13; // [rsp+18h] [rbp-40h]

if ( argc != 2 )
{
printf("usage: %s KXKY\n", *argv);
exit(1);
}
v3 = malloc(0x238uLL);
v4 = argv[1];
v3[34] = v4;
v13 = strlen(v4);
*((_DWORD *)v3 + 136) = v13;
if ( v13 > 32 )
{
printf("Sorry, no way I can compute endings with %d pieces.\n", (unsigned int)v13);
exit(1);
}
v5 = v13 - 1LL;
if ( !v13 )
{
v6 = 0;
goto LABEL_20;
}
s = PIECECHARS;
v6 = 0;
while ( 1 )
{
v7 = v4[v5];
if ( !strchr(s, v7) )
{
printf("Sorry, \"%c\" is an unknown piece type. Try one of \"%s\".\n", (unsigned int)v7, s);
exit(1);
}
v3[v5 + 35] = (int)v6;
if ( v7 == 75 )
v3[(int)v6++ + 69] = v5;
if ( !v5 )
break;
--v5;
}
if ( v6 != 2 )
{
LABEL_20:
printf("Sorry, endings with %d kings don't make sense to me. Try one with 2.\n", v6);
exit(1);
}
printf("Ending %s has %d men!\n", v4, (unsigned int)v13);
v8 = 1LL << (6 * *((_BYTE *)v3 + 544) + 1);
v9 = (char *)malloc(v8);
printf("Table has %ld bytes.\n", v8);
mark_legal((__int64)v9, (__int64)v3);
count_positions((__int64)v9, v8);
for ( i = creat(argv[1], 0x1B6u); v8 > 0x1000000; v9 += 0x1000000 )
{
if ( write(i, v9, 0x1000000uLL) != 0x1000000 )
{
printf("Error: Failed to write the %s table properly.\n", argv[1]);
exit(1);
}
v8 -= 0x1000000LL;
}
if ( write(i, v9, v8) != v8 )
{
printf("Error: Failed to write the %s table properly.\n", argv[1]);
exit(1);
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
_QWORD *v3; // r14
const char *v4; // r15
__int64 v5; // rbx
unsigned int v6; // er12
char v7; // bp
unsigned __int64 v8; // rbx
char *v9; // rbp
int i; // er12
char *s; // [rsp+8h] [rbp-50h]
int v13; // [rsp+18h] [rbp-40h]

if ( argc != 2 )
{
printf("usage: %s KXKY\n", *argv);
exit(1);
}
v3 = malloc(0x238uLL);
v4 = argv[1];
v3[34] = v4;
v13 = strlen(v4);
*((_DWORD *)v3 + 136) = v13;
if ( v13 > 32 )
{
printf("Sorry, no way I can compute endings with %d pieces.\n", (unsigned int)v13);
exit(1);
}
v5 = v13 - 1LL;
if ( !v13 )
{
v6 = 0;
goto LABEL_20;
}
s = PIECECHARS;
v6 = 0;
while ( 1 )
{
v7 = v4[v5];
if ( !strchr(s, v7) )
{
printf("Sorry, \"%c\" is an unknown piece type. Try one of \"%s\".\n", (unsigned int)v7, s);
exit(1);
}
v3[v5 + 35] = (int)v6;
if ( v7 == 75 )
v3[(int)v6++ + 69] = v5;
if ( !v5 )
break;
--v5;
}
if ( v6 != 2 )
{
LABEL_20:
printf("Sorry, endings with %d kings don't make sense to me. Try one with 2.\n", v6);
exit(1);
}
printf("Ending %s has %d men!\n", v4, (unsigned int)v13);
v8 = 1LL << (6 * *((_BYTE *)v3 + 544) + 1);
v9 = (char *)malloc(v8);
printf("Table has %ld bytes.\n", v8);
func14((__int64)v9, (__int64)v3);
func13((__int64)v9, v8);
for ( i = creat(argv[1], 0x1B6u); v8 > 0x1000000; v9 += 0x1000000 )
{
if ( write(i, v9, 0x1000000uLL) != 0x1000000 )
{
printf("Error: Failed to write the %s table properly.\n", argv[1]);
exit(1);
}
v8 -= 0x1000000LL;
}
if ( write(i, v9, v8) != v8 )
{
printf("Error: Failed to write the %s table properly.\n", argv[1]);
exit(1);
}
return 0;
}

original_code:
int
main(int argc, char *argv[])
{
  Byte *tb;
  int64_t i;
  int kings=0;
  int fd;
  size_t sz;
  Position *p;
  if (2 != argc) {
    printf("usage: %s KXKY\n", argv[0]);
    exit(1);
  }
  p = malloc(sizeof(Position));
  p->type = argv[1];
  p->n = strlen(argv[1]);
  if (32 < p->n) {
    printf("Sorry, no way I can compute endings with %d pieces.\n", p->n);
    exit(1);
  }
  for(i=p->n;i--;) {
    char piece = argv[1][i];
    if (((void *)0)==strchr(PIECECHARS, piece)) {
      printf("Sorry, \"%c\" is an unknown piece type. Try one of \"%s\".\n", piece, PIECECHARS);
      exit(1);
    }
    p->side[i] = kings;
    if ('K' == piece) {
      p->kings[kings] = i;
      ++kings;
    }
  }
  if (2!=kings) {
    printf("Sorry, endings with %d kings don't make sense to me. Try one with 2.\n", kings);
    exit(1);
  }
  printf("Ending %s has %d men!\n", argv[1], p->n);
  sz = sizeof(Byte)<<(1+6*p->n);
  tb = malloc(sz);
  printf("Table has %ld bytes.\n", sz);
  mark_legal(tb, p);
  count_positions(tb, sz);
  fd = creat(argv[1], 00666);
  while (sz>(1<<24)) {
    if ((1<<24)!=write(fd, tb, 1<<24)) {
      printf("Error: Failed to write the %s table properly.\n", argv[1]);
      exit(1);
    }
    sz -= 1<<24; tb += 1<<24;
  }
  if (sz!=(size_t)write(fd, tb, sz)) {
    printf("Error: Failed to write the %s table properly.\n", argv[1]);
    exit(1);
  }
  return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
  char *tb;
  long i;
  int kings = 0;
  int fd;
  unsigned long sz;
  struct Position *p;
  if (2 != argc) {
    printf("usage: %s KXKY\n", argv[0]);
    exit(1);
  }
  p = malloc(sizeof(Position));
  p->type = argv[1];
  p->n = strlen(argv[1]);
  if (32 < p->n) {
    printf("Sorry, no way I can compute endings with %d pieces.\n", p->n);
    exit(1);
  }
  for(i=p->n;i--;) {
    char piece = argv[1][i];
    if (((void *)0)==strchr(PIECECHARS, piece)) {
      printf("Sorry, \"%c\" is an unknown piece type. Try one of \"%s\".\n", piece, PIECECHARS);
      exit(1);
    }
    p->side[i] = kings;
    if ('K' == piece) {
      p->kings[kings] = i;
      ++kings;
    }
  }
  if (2!=kings) {
    printf("Sorry, endings with %d kings don't make sense to me. Try one with 2.\n", kings);
    exit(1);
  }
  printf("Ending %s has %d men!\n", argv[1], p->n);
  sz = sizeof(Byte)<<(1+6*p->n);
  tb = malloc(sz);
  printf("Table has %ld bytes.\n", sz);
  mark_legal(tb, p);
  count_positions(tb, sz);
  fd = creat(argv[1], 00666);
  while (sz>(1<<24)) {
    if ((1<<24)!=write(fd, tb, 1<<24)) {
      printf("Error: Failed to write the %s table properly.\n", argv[1]);
      exit(1);
    }
    sz -= 1<<24; tb += 1<<24;
  }
  if (sz!=(unsigned long)write(fd, tb, sz)) {
    printf("Error: Failed to write the %s table properly.\n", argv[1]);
    exit(1);
  }
  return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: kings int

variable_types: fd int

variable_types:
sz
unsigned long

variable_types: piece char


repo: Koistinen/Urban

decompiled_code:
__int64 get_bit()
{
char v0; // al

v0 = cin;
cin = (unsigned __int8)(2 * cin);
if ( !cin )
{
v0 = getchar();
cin = (unsigned __int8)(2 * v0) + 1;
}
return v0 & 0x80;
}

canonical_decompiled_code:
__int64 func12()
{
char v0; // al

v0 = cin;
cin = (unsigned __int8)(2 * cin);
if ( !cin )
{
v0 = getchar();
cin = (unsigned __int8)(2 * v0) + 1;
}
return v0 & 0x80;
}

original_code:
int get_bit() {
  unsigned int carry;
  carry=cin&0x80;
  cin=(cin<<1)&0xff;
  if(cin) {
    return(carry);
  } else {
    cin=getchar();
    carry=cin&0x80;
    cin=(cin<<1)&0xff;
    ++cin;
    return(carry);
  }
}

variable_types:
carry
unsigned int


repo: KostyaKow/iosink

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

init_input_lib(argc, argv, envp);
move_mouse(100LL, 100LL);
while ( 1 )
{
_isoc99_scanf("%i%i", v4, &v3);
move_mouse(v4[0], v3);
}
}

original_code:
int main(void) {
   init_input_lib();
   move_mouse(100, 100);
   int x, y;
   for (;;) {
      scanf("%i%i", &x, &y);
      move_mouse(x, y);
   }
}

canonical_original_code:
int main() {
   init_input_lib();
   move_mouse(100, 100);
   int x; int y;
   for (;;) {
      scanf("%i%i", &x, &y);
      move_mouse(x, y);
   }
}

variable_types: x int

variable_types: y int


decompiled_code:
void __fastcall __noreturn mouse_moving_test(__int64 a1, __int64 a2, __int64 a3)
{
unsigned int v3; // [rsp+8h] [rbp-10h] BYREF
unsigned int v4[3]; // [rsp+Ch] [rbp-Ch] BYREF

init_input_lib(a1, a2, a3);
move_mouse(100LL, 100LL);
while ( 1 )
{
printf("\nenter coordinates to move the mouse to: ");
_isoc99_scanf("%i%i", v4, &v3);
move_mouse(v4[0], v3);
}
}

canonical_decompiled_code:
void __fastcall __noreturn func0(__int64 a1, __int64 a2, __int64 a3)
{
unsigned int v3; // [rsp+8h] [rbp-10h] BYREF
unsigned int v4[3]; // [rsp+Ch] [rbp-Ch] BYREF

init_input_lib(a1, a2, a3);
move_mouse(100LL, 100LL);
while ( 1 )
{
printf("\nenter coordinates to move the mouse to: ");
_isoc99_scanf("%i%i", v4, &v3);
move_mouse(v4[0], v3);
}
}

original_code:
void mouse_moving_test() {
   init_input_lib();
   move_mouse(100, 100);
   int x, y;
   while (1) {
      printf("\nenter coordinates to move the mouse to: ");
      scanf("%i%i", &x, &y);
      move_mouse(x, y);
   }
}

canonical_original_code:
void mouse_moving_test() {
   init_input_lib();
   move_mouse(100, 100);
   int x; int y;
   while (1) {
      printf("\nenter coordinates to move the mouse to: ");
      scanf("%i%i", &x, &y);
      move_mouse(x, y);
   }
}


decompiled_code:
void init_input_lib()
{
Display *v0; // rax

if ( !initialized_0 )
{
initialized_0 = 1;
input_data = XOpenDisplay(0LL);
v0 = (Display *)XRootWindow(input_data, 0);
*(&input_data + 1) = v0;
XSelectInput(input_data, (Window)v0, 2LL);
}
}

canonical_decompiled_code:
void func0()
{
Display *v0; // rax

if ( !initialized_0 )
{
initialized_0 = 1;
input_data = XOpenDisplay(0LL);
v0 = (Display *)XRootWindow(input_data, 0);
*(&input_data + 1) = v0;
XSelectInput(input_data, (Window)v0, 2LL);
}
}

original_code:
void init_input_lib(void) {
   static bool initialized = 0;
   if (initialized)
      return;
   initialized = 1;
   input_data.dpy = XOpenDisplay(0);
   input_data.root_window = XRootWindow(input_data.dpy, 0);
   XSelectInput(input_data.dpy, input_data.root_window, (1L<<1));
}

canonical_original_code:
void init_input_lib() {
   static char initialized = 0;
   if (initialized)
      return;
   initialized = 1;
   input_data.dpy = XOpenDisplay(0);
   input_data.root_window = XRootWindow(input_data.dpy, 0);
   XSelectInput(input_data.dpy, input_data.root_window, (1L<<1));
}

variable_types: initialized char


decompiled_code:
int __fastcall move_mouse(int a1, int a2)
{
XWarpPointer(input_data, 0LL, (Window)*(&input_data + 1), 0, 0, 0, 0, a1, a2);
return XFlush(input_data);
}

canonical_decompiled_code:
int __fastcall func1(int a1, int a2)
{
XWarpPointer(input_data, 0LL, (Window)*(&input_data + 1), 0, 0, 0, 0, a1, a2);
return XFlush(input_data);
}

original_code:
void move_mouse(int x, int y) {
   XWarpPointer(input_data.dpy, 0L, input_data.root_window, 0, 0, 0, 0, x, y);
   XFlush(input_data.dpy);
}


decompiled_code:
void mouse_press()
{
;
}

canonical_decompiled_code:
void func2()
{
;
}

original_code:
void mouse_press(byte key) {
}

canonical_original_code:
void mouse_press(char key) {
}

variable_types: key char


decompiled_code:
void mouse_release()
{
;
}

canonical_decompiled_code:
void func3()
{
;
}

original_code: void mouse_release(byte key) {}

canonical_original_code: void mouse_release(char key) {}


decompiled_code:
void key_press()
{
;
}

canonical_decompiled_code:
void func4()
{
;
}

original_code: void key_press(unsigned key) {}

canonical_original_code: void key_press(unsigned int key) {}

variable_types:
key
unsigned int


decompiled_code:
void key_release()
{
;
}

canonical_decompiled_code:
void func5()
{
;
}

original_code: void key_release(unsigned key) {}

canonical_original_code: void key_release(unsigned int key) {}


decompiled_code:
__int64 test_action_clean()
{
__int64 v0; // rbx
unsigned __int64 v1; // rbp
unsigned __int64 v2; // r12
__int64 result; // rax

v0 = hash_init(128LL);
hash_set(v0, "test", "value");
hash_set(v0, "test1", "value1");
hash_clean(v0);
v1 = hash_get(v0, "test");
v2 = hash_get(v0, "test1");
hash_destroy(v0);
if ( v2 | v1 )
{
puts("\nTEST FOR clean ACTION failed.\nMust return empty values-");
if ( !v2 )
v2 = (unsigned __int64)"-";
if ( !v1 )
v1 = (unsigned __int64)"-";
printf("But return ->%s<- ->%s<-\n", (const char *)v1, (const char *)v2);
result = 1LL;
}
else
{
puts("\nTEST FOR clean ACTION successfully completed");
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 v0; // rbx
unsigned __int64 v1; // rbp
unsigned __int64 v2; // r12
__int64 result; // rax

v0 = hash_init(128LL);
hash_set(v0, "test", "value");
hash_set(v0, "test1", "value1");
hash_clean(v0);
v1 = hash_get(v0, "test");
v2 = hash_get(v0, "test1");
hash_destroy(v0);
if ( v2 | v1 )
{
puts("\nTEST FOR clean ACTION failed.\nMust return empty values-");
if ( !v2 )
v2 = (unsigned __int64)"-";
if ( !v1 )
v1 = (unsigned __int64)"-";
printf("But return ->%s<- ->%s<-\n", (const char *)v1, (const char *)v2);
result = 1LL;
}
else
{
puts("\nTEST FOR clean ACTION successfully completed");
result = 0LL;
}
return result;
}

original_code:
int test_action_clean()
{
  hash_t *hashtabl;
  void *value;
  void *value_1;
  hashtabl = hash_init(128);
  hash_set(hashtabl, "test", "value");
  hash_set(hashtabl, "test1", "value1");
  hash_clean(hashtabl);
  value = hash_get(hashtabl, "test");
  value_1 = hash_get(hashtabl, "test1");
  hash_destroy(hashtabl);
  if ((!value) && (!value_1))
  {
    printf("\nTEST FOR clean ACTION successfully completed\n");
    return 0;
  }
  else
  {
    printf("\nTEST FOR clean ACTION failed.\nMust return empty values-\n");
    printf("But return ->%s<- ->%s<-\n",value?(char *)value:"-", value_1?(char *)value_1:"-");
    return 1;
  }
}

canonical_original_code:
int test_action_clean()
{
  struct hash_s *hashtabl;
  void *value;
  void *value_1;
  hashtabl = hash_init(128);
  hash_set(hashtabl, "test", "value");
  hash_set(hashtabl, "test1", "value1");
  hash_clean(hashtabl);
  value = hash_get(hashtabl, "test");
  value_1 = hash_get(hashtabl, "test1");
  hash_destroy(hashtabl);
  if ((!value) && (!value_1))
  {
    printf("\nTEST FOR clean ACTION successfully completed\n");
    return 0;
  }
  else
  {
    printf("\nTEST FOR clean ACTION failed.\nMust return empty values-\n");
    printf("But return ->%s<- ->%s<-\n",value?(char *)value:"-", value_1?(char *)value_1:"-");
    return 1;
  }
}

variable_types: struct hash_s { int size; struct node_ls { void *data; struct node_ls *next; } **nodes; } *

variable_types:
value
void *

user_defined_types: struct hash_s { int size; struct node_ls **nodes; }


decompiled_code:
__int64 stress_set_get_test()
{
__int64 v0; // rbp
int i; // ebx
int v2; // er12
char *v3; // rbx
char v5[72]; // [rsp+0h] [rbp-48h] BYREF

v0 = hash_init(128LL);
for ( i = 0; i != 10000; ++i )
{
itoa(i, v5);
hash_set(v0, v5, v5);
}
v2 = 0;
while ( 1 )
{
itoa(v2, v5);
v3 = (char *)hash_get(v0, v5);
if ( v3 != v5 )
break;
if ( ++v2 == 10000 )
{
puts("\nSTRESS TEST set AND get ACTIONS successfully completed");
hash_destroy(v0);
return 0LL;
}
}
printf("\nSTRESS TEST set AND get ACTIONS failed.\nMust return ->%s<-\n", v5);
if ( !v3 )
v3 = "-";
printf("But return ->%s<-\n", v3);
hash_destroy(v0);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func5()
{
__int64 v0; // rbp
int i; // ebx
int v2; // er12
char *v3; // rbx
char v5[72]; // [rsp+0h] [rbp-48h] BYREF

v0 = hash_init(128LL);
for ( i = 0; i != 10000; ++i )
{
func4(i, v5);
hash_set(v0, v5, v5);
}
v2 = 0;
while ( 1 )
{
func4(v2, v5);
v3 = (char *)hash_get(v0, v5);
if ( v3 != v5 )
break;
if ( ++v2 == 10000 )
{
puts("\nSTRESS TEST set AND get ACTIONS successfully completed");
hash_destroy(v0);
return 0LL;
}
}
printf("\nSTRESS TEST set AND get ACTIONS failed.\nMust return ->%s<-\n", v5);
if ( !v3 )
v3 = "-";
printf("But return ->%s<-\n", v3);
hash_destroy(v0);
return 0xFFFFFFFFLL;
}

original_code:
int stress_set_get_test()
{
  hash_t *hashtabl;
  int i;
  int cols = 10000;
  char a[20];
  void *value;
  hashtabl = hash_init(128);
  for(i=0; i < cols; ++i)
  {
    itoa(i, a);
    hash_set(hashtabl, a, a);
  }
  for(i=0; i < cols; ++i)
  {
    itoa(i, a);
    value = hash_get(hashtabl, a);
    if (!(a == value))
    {
      printf("\nSTRESS TEST set AND get ACTIONS failed.\nMust return ->%s<-\n", a);
      printf("But return ->%s<-\n",value?(char *)value:"-");
      hash_destroy(hashtabl);
      return -1;
    }
  }
  printf("\nSTRESS TEST set AND get ACTIONS successfully completed\n");
  hash_destroy(hashtabl);
  return 0;
}

canonical_original_code:
int stress_set_get_test()
{
  struct hash_s *hashtabl;
  int i;
  int cols = 10000;
  char a[20];
  void *value;
  hashtabl = hash_init(128);
  for(i=0; i < cols; ++i)
  {
    itoa(i, a);
    hash_set(hashtabl, a, a);
  }
  for(i=0; i < cols; ++i)
  {
    itoa(i, a);
    value = hash_get(hashtabl, a);
    if (!(a == value))
    {
      printf("\nSTRESS TEST set AND get ACTIONS failed.\nMust return ->%s<-\n", a);
      printf("But return ->%s<-\n",value?(char *)value:"-");
      hash_destroy(hashtabl);
      return -1;
    }
  }
  printf("\nSTRESS TEST set AND get ACTIONS successfully completed\n");
  hash_destroy(hashtabl);
  return 0;
}

variable_types: i int

variable_types: cols int

variable_types:
a
char [20]

user_defined_types: struct node_ls { void *data; struct node_ls *next; }


decompiled_code:
__int64 stress_set_get_remove_test()
{
__int64 v0; // rbp
int i; // ebx
int j; // ebx
int k; // ebx
int l; // ebx
int v5; // ebx
char *v7; // r12
char v8[72]; // [rsp+0h] [rbp-48h] BYREF

v0 = hash_init(500LL);
for ( i = 0; i != 5000; ++i )
{
itoa(i, v8);
hash_set(v0, v8, v8);
}
for ( j = 0; j != 100; ++j )
{
itoa(j, v8);
hash_remove(v0, v8);
}
for ( k = 1000; k != 1100; ++k )
{
itoa(k, v8);
hash_remove(v0, v8);
}
for ( l = 4990; l != 5000; ++l )
{
itoa(l, v8);
hash_remove(v0, v8);
}
v5 = 1000;
while ( 1 )
{
itoa(v5, v8);
v7 = (char *)hash_get(v0, v8);
if ( v5 > 4989 || (unsigned int)(v5 - 1000) <= 0x63 )
{
if ( v7 )
goto LABEL_11;
goto LABEL_14;
}
if ( v7 && v5 <= 99 )
{
LABEL_11:
printf("\nSTRESS TEST set, get AND remove ACTIONS failed.\nMust return ->%s<-\n", v8);
goto LABEL_12;
}
if ( v5 > 99 && v7 != v8 )
break;
LABEL_14:
if ( ++v5 == 5000 )
{
puts("\nSTRESS TEST set, get AND remove ACTIONS successfully completed");
hash_destroy(v0);
return 0LL;
}
}
printf("\nSTRESS TEST set, get AND remove ACTIONS failed.\nMust return ->%s<-\n", v8);
if ( !v7 )
v7 = "-";
LABEL_12:
printf("But return ->%s<-\n", v7);
hash_destroy(v0);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func6()
{
__int64 v0; // rbp
int i; // ebx
int j; // ebx
int k; // ebx
int l; // ebx
int v5; // ebx
char *v7; // r12
char v8[72]; // [rsp+0h] [rbp-48h] BYREF

v0 = hash_init(500LL);
for ( i = 0; i != 5000; ++i )
{
func4(i, v8);
hash_set(v0, v8, v8);
}
for ( j = 0; j != 100; ++j )
{
func4(j, v8);
hash_remove(v0, v8);
}
for ( k = 1000; k != 1100; ++k )
{
func4(k, v8);
hash_remove(v0, v8);
}
for ( l = 4990; l != 5000; ++l )
{
func4(l, v8);
hash_remove(v0, v8);
}
v5 = 1000;
while ( 1 )
{
func4(v5, v8);
v7 = (char *)hash_get(v0, v8);
if ( v5 > 4989 || (unsigned int)(v5 - 1000) <= 0x63 )
{
if ( v7 )
goto LABEL_11;
goto LABEL_14;
}
if ( v7 && v5 <= 99 )
{
LABEL_11:
printf("\nSTRESS TEST set, get AND remove ACTIONS failed.\nMust return ->%s<-\n", v8);
goto LABEL_12;
}
if ( v5 > 99 && v7 != v8 )
break;
LABEL_14:
if ( ++v5 == 5000 )
{
puts("\nSTRESS TEST set, get AND remove ACTIONS successfully completed");
hash_destroy(v0);
return 0LL;
}
}
printf("\nSTRESS TEST set, get AND remove ACTIONS failed.\nMust return ->%s<-\n", v8);
if ( !v7 )
v7 = "-";
LABEL_12:
printf("But return ->%s<-\n", v7);
hash_destroy(v0);
return 0xFFFFFFFFLL;
}

original_code:
int stress_set_get_remove_test()
{
  hash_t *hashtabl;
  int i;
  int cols = 5000;
  char a[20];
  void *value;
  int fl;
  hashtabl = hash_init(500);
  for(i= 0; i < cols; ++i)
  {
    itoa(i, a);
    hash_set(hashtabl, a, a);
  }
  for(i = 0; i <100 ; ++i)
  {
    itoa(i, a);
    hash_remove(hashtabl, a);
  }
  for(i = 1000; i < 1100; ++i)
  {
    itoa(i, a);
    hash_remove(hashtabl, a);
  }
  for(i = 4990; i < 5000; ++i)
  {
    itoa(i, a);
    hash_remove(hashtabl, a);
  }
  for(i = 1000; i < 5000; ++i)
  {
    fl = 0;
    itoa(i, a);
    value = hash_get(hashtabl, a);
    if (i < 100)
      fl = 1;
    if (i >= 4990)
      fl = 1;
    if (( i >= 1000 ) && ( i < 1100 ) )
      fl = 1;
    if ((value && fl) || ( !(a == value) && !fl))
    {
      printf("\nSTRESS TEST set, get AND remove ACTIONS failed.\nMust return ->%s<-\n", a);
      printf("But return ->%s<-\n",value?(char *)value:"-");
      hash_destroy(hashtabl);
      return -1;
    }
  }
  printf("\nSTRESS TEST set, get AND remove ACTIONS successfully completed\n");
  hash_destroy(hashtabl);
  return 0;
}

canonical_original_code:
int stress_set_get_remove_test()
{
  struct hash_s *hashtabl;
  int i;
  int cols = 5000;
  char a[20];
  void *value;
  int fl;
  hashtabl = hash_init(500);
  for(i= 0; i < cols; ++i)
  {
    itoa(i, a);
    hash_set(hashtabl, a, a);
  }
  for(i = 0; i <100 ; ++i)
  {
    itoa(i, a);
    hash_remove(hashtabl, a);
  }
  for(i = 1000; i < 1100; ++i)
  {
    itoa(i, a);
    hash_remove(hashtabl, a);
  }
  for(i = 4990; i < 5000; ++i)
  {
    itoa(i, a);
    hash_remove(hashtabl, a);
  }
  for(i = 1000; i < 5000; ++i)
  {
    fl = 0;
    itoa(i, a);
    value = hash_get(hashtabl, a);
    if (i < 100)
      fl = 1;
    if (i >= 4990)
      fl = 1;
    if (( i >= 1000 ) && ( i < 1100 ) )
      fl = 1;
    if ((value && fl) || ( !(a == value) && !fl))
    {
      printf("\nSTRESS TEST set, get AND remove ACTIONS failed.\nMust return ->%s<-\n", a);
      printf("But return ->%s<-\n",value?(char *)value:"-");
      hash_destroy(hashtabl);
      return -1;
    }
  }
  printf("\nSTRESS TEST set, get AND remove ACTIONS successfully completed\n");
  hash_destroy(hashtabl);
  return 0;
}

variable_types: fl int


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *v3; // rbx
unsigned int v4; // er12
unsigned int v5; // ebp
__int64 v7[5]; // [rsp+0h] [rbp-58h] BYREF
char v8; // [rsp+28h] [rbp-30h] BYREF

v7[0] = (__int64)test_actions_init_set_get;
v7[4] = (__int64)test_action_remove;
v7[2] = (__int64)test_action_clean;
v7[3] = (__int64)test_actions_init_destroy;
v7[1] = (__int64)stress_set_get_test;
puts("\n ------ START TESTING hash ------");
v3 = (char *)v7;
v4 = 0;
v5 = 0;
do
{
if ( (*(unsigned int (__fastcall **)(const char *, const char **))v3)("\n ------ START TESTING hash ------", argv) )
++v4;
else
++v5;
v3 += 8;
}
while ( v3 != &v8 );
puts("\n ------ END TESTING hash ------");
printf("\n completed -> %i \n success -> %i \n failed -> %i \n", 5LL, v5, v4);
return 0;
}

original_code:
int main()
{
  int cols = 3;
  void *tests_arr[cols];
  int faild = 0;
  int success = 0;
  int i;
  tests_arr[0] = &test_actions_init_set_get;
  tests_arr[1] = &test_actions_init_destroy;
  tests_arr[2] = &test_action_remove;
  printf("\n ------ START TESTING hash ------\n");
  for(i=0; i < cols; ++i)
  {
    if (!test_init(i, tests_arr[i]))
      success++;
    else
      faild++;
  }
  printf("\n ------ END TESTING hash ------\n");
  printf("\n completed -> %d \n success -> %d \n failed -> %d \n", i, success, faild);
}

canonical_original_code:
int main()
{
  int cols = 3;
  void *tests_arr[-1];
  int faild = 0;
  int success = 0;
  int i;
  tests_arr[0] = &test_actions_init_set_get;
  tests_arr[1] = &test_actions_init_destroy;
  tests_arr[2] = &test_action_remove;
  printf("\n ------ START TESTING hash ------\n");
  for(i=0; i < cols; ++i)
  {
    if (!test_init(i, tests_arr[i]))
      success++;
    else
      faild++;
  }
  printf("\n ------ END TESTING hash ------\n");
  printf("\n completed -> %d \n success -> %d \n failed -> %d \n", i, success, faild);
}

variable_types: faild int

variable_types: success int


decompiled_code:
__int64 __fastcall test_init(__int64 a1, __int64 (*a2)(void))
{
unsigned int v2; // ebx

clock();
v2 = a2();
clock();
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 (*a2)(void))
{
unsigned int v2; // ebx

clock();
v2 = a2();
clock();
return v2;
}

original_code:
int test_init(int number,int(*func)())
{
  int resp;
  clock_t t = clock();
  resp = func();
  t = clock()-t;
  return resp;
}

canonical_original_code:
int test_init(int number, int (*func)())
{
  int resp;
  long t = clock();
  resp = func();
  t = clock()-t;
  return resp;
}

variable_types: number int

variable_types:
func
int (*)()

variable_types: resp int

variable_types: t long


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbx
unsigned int v4; // er12
unsigned int v5; // ebp
__int64 v7[7]; // [rsp+0h] [rbp-38h]

v7[0] = (__int64)test_actions_init_set_get;
v7[1] = (__int64)test_actions_init_destroy;
v7[2] = (__int64)test_action_remove;
puts("\n ------ START TESTING hash ------");
v3 = 0LL;
v4 = 0;
v5 = 0;
do
{
if ( (unsigned int)test_init((unsigned int)v3, (__int64 (*)(void))v7[v3]) )
++v4;
else
++v5;
++v3;
}
while ( v3 != 3 );
puts("\n ------ END TESTING hash ------");
printf("\n completed -> %d \n success -> %d \n failed -> %d \n", 3LL, v5, v4);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbx
unsigned int v4; // er12
unsigned int v5; // ebp
__int64 v7[7]; // [rsp+0h] [rbp-38h]

v7[0] = (__int64)test_actions_init_set_get;
v7[1] = (__int64)test_actions_init_destroy;
v7[2] = (__int64)test_action_remove;
puts("\n ------ START TESTING hash ------");
v3 = 0LL;
v4 = 0;
v5 = 0;
do
{
if ( (unsigned int)func4((unsigned int)v3, (__int64 (*)(void))v7[v3]) )
++v4;
else
++v5;
++v3;
}
while ( v3 != 3 );
puts("\n ------ END TESTING hash ------");
printf("\n completed -> %d \n success -> %d \n failed -> %d \n", 3LL, v5, v4);
return 0;
}


getdiff

repo: Kuwagata/Raytracer

decompiled_code:
double __fastcall getdiff(__int64 a1)
{
return *(double *)(*(_QWORD *)(a1 + 32) + 24LL);
}

canonical_decompiled_code:
double __fastcall func0(__int64 a1)
{
return *(double *)(*(_QWORD *)(a1 + 32) + 24LL);
}

original_code:
double getdiff(obj_t * obj) {
   return obj->sceneData->diffuse;
}

canonical_original_code:
double getdiff(struct obj_type *obj) {
   return obj->sceneData->diffuse;
}

variable_types: struct obj_type { struct obj_type *next; int objid; int objcat; char *objclass; void *typeData; union { struct sceneobj { struct triple { double x; double y; double z; } color; double diffuse; double specular; double (*hits)(struct triple *base, struct triple *dir, struct obj_type *obj); struct triple (*getcolor)(struct obj_type *obj); double (*getdiffuse)(struct obj_type *obj); double (*getspecular)(struct obj_type *obj); struct triple hitloc; struct triple normal; double distance; } *sceneData; struct lightobj { struct triple emissivity; struct triple center; } *lightData; }; } *

return_type: double

user_defined_types: struct obj_type { struct obj_type *next; int objid; int objcat; char *objclass; void *typeData; union { struct sceneobj *sceneData; struct lightobj *lightData; }; }

user_defined_types: struct sceneobj { struct triple color; double diffuse; double specular; double (*hits)(struct triple *base, struct triple *dir, struct obj_type *obj); struct triple (*getcolor)(struct obj_type *obj); double (*getdiffuse)(struct obj_type *obj); double (*getspecular)(struct obj_type *obj); struct triple hitloc; struct triple normal; double distance; }


getspec

decompiled_code:
double __fastcall getspec(__int64 a1)
{
return *(double *)(*(_QWORD *)(a1 + 32) + 32LL);
}

canonical_decompiled_code:
double __fastcall func1(__int64 a1)
{
return *(double *)(*(_QWORD *)(a1 + 32) + 32LL);
}

original_code:
double getspec(obj_t * obj) {
   return obj->sceneData->specular;
}

canonical_original_code:
double getspec(struct obj_type *obj) {
   return obj->sceneData->specular;
}

user_defined_types: struct lightobj { struct triple emissivity; struct triple center; }

user_defined_types: struct triple { double x; double y; double z; }


decompiled_code:
int __fastcall sceneobj_dump(__int64 a1)
{
object_dump();
tl_print3("Ambient color: ", *(_QWORD *)(a1 + 32));
fprintf(stderr, "Diffuse reflectivity: %lf\n", *(double *)(*(_QWORD *)(a1 + 32) + 24LL));
return fprintf(stderr, "Specular reflectivity: %lf\n", *(double *)(*(_QWORD *)(a1 + 32) + 32LL));
}

canonical_decompiled_code:
int __fastcall func3(__int64 a1)
{
object_dump();
tl_print3("Ambient color: ", *(_QWORD *)(a1 + 32));
fprintf(stderr, "Diffuse reflectivity: %lf\n", *(double *)(*(_QWORD *)(a1 + 32) + 24LL));
return fprintf(stderr, "Specular reflectivity: %lf\n", *(double *)(*(_QWORD *)(a1 + 32) + 32LL));
}

original_code:
void sceneobj_dump(obj_t *obj){
   object_dump(obj);
   tl_print3("Ambient color: ", &obj->sceneData->color);
   fprintf(stderr, "Diffuse reflectivity:  %lf\n", obj->sceneData->diffuse);
   fprintf(stderr, "Specular reflectivity:  %lf\n", obj->sceneData->specular);
   return;
}

canonical_original_code:
void sceneobj_dump(struct obj_type *obj){
   object_dump(obj);
   tl_print3("Ambient color: ", &obj->sceneData->color);
   fprintf(stderr, "Diffuse reflectivity:  %lf\n", obj->sceneData->diffuse);
   fprintf(stderr, "Specular reflectivity:  %lf\n", obj->sceneData->specular);
   return;
}


original_code:
double polygon_hits(triple_t *base, triple_t *dir, obj_t *obj) {
   double dist;
   int edgectr;
   polygon_t *polygonPtr;
   triple_t vec_to_hit;
   triple_t crossproduct;
   double dotproduct;
   double lastdot;
   dist = plane_hits(base, dir, obj);
   if(dist == -1)
      return -1;
   polygonPtr = (polygon_t *) (((plane_t *)obj->typeData)->priv);
   lastdot = 0;
   for(edgectr = 0; edgectr < polygonPtr->numEdges; edgectr++) {
      vec_to_hit = tl_diff3(&obj->sceneData->hitloc, &polygonPtr->edges[edgectr].point);
      vec_to_hit = tl_unitvec3(&vec_to_hit);
      crossproduct = tl_cross3(&polygonPtr->edges[edgectr].edgeDir, &vec_to_hit);
      crossproduct = tl_unitvec3(&crossproduct);
      dotproduct = tl_dot3(&crossproduct, &obj->sceneData->normal);
      if(edgectr != 0)
         if((lastdot * dotproduct) <= 0)
            return -1;
      lastdot = dotproduct;
    }
    return dist;
}

canonical_original_code:
double polygon_hits(struct triple *base, struct triple *dir, struct obj_type *obj) {
   double dist;
   int edgectr;
   struct polygon_type *polygonPtr;
   struct triple vec_to_hit;
   struct triple crossproduct;
   double dotproduct;
   double lastdot;
   dist = plane_hits(base, dir, obj);
   if(dist == -1)
      return -1;
   polygonPtr = (struct polygon_type *) (((struct plane_type *)obj->typeData)->priv);
   lastdot = 0;
   for(edgectr = 0; edgectr < polygonPtr->numEdges; edgectr++) {
      vec_to_hit = tl_diff3(&obj->sceneData->hitloc, &polygonPtr->edges[edgectr].point);
      vec_to_hit = tl_unitvec3(&vec_to_hit);
      crossproduct = tl_cross3(&polygonPtr->edges[edgectr].edgeDir, &vec_to_hit);
      crossproduct = tl_unitvec3(&crossproduct);
      dotproduct = tl_dot3(&crossproduct, &obj->sceneData->normal);
      if(edgectr != 0)
         if((lastdot * dotproduct) <= 0)
            return -1;
      lastdot = dotproduct;
    }
    return dist;
}

variable_types: struct triple { double x; double y; double z; } *

variable_types:
dir
struct triple *

variable_types: struct obj_type { struct obj_type *next; int objid; int objcat; char *objclass; void *typeData; union { struct sceneobj { struct triple color; double diffuse; double specular; double (*hits)(struct triple *base, struct triple *dir, struct obj_type *obj); struct triple (*getcolor)(struct obj_type *obj); double (*getdiffuse)(struct obj_type *obj); double (*getspecular)(struct obj_type *obj); struct triple hitloc; struct triple normal; double distance; } *sceneData; struct lightobj { struct triple emissivity; struct triple center; } *lightData; }; } *

variable_types: dist double

variable_types: edgectr int

variable_types: struct polygon_type { int numEdges; struct edge_type { struct triple { double x; double y; double z; } point; struct triple edgeDir; } *edges; void *priv; } *

variable_types: dotproduct double

variable_types: lastdot double

user_defined_types: struct polygon_type { int numEdges; struct edge_type *edges; void *priv; }

user_defined_types: struct plane_type { struct triple point; struct triple normal; void *priv; }

user_defined_types: struct edge_type { struct triple point; struct triple edgeDir; }


decompiled_code:
int __fastcall polygon_dump(__int64 a1)
{
unsigned int *v1; // r13
int result; // eax
__int64 v3; // r12
__int64 v4; // rbp

v1 = *(unsigned int **)(*(_QWORD *)(a1 + 24) + 48LL);
plane_dump();
fwrite("Polygon data:\n", 1uLL, 0xEuLL, stderr);
result = fprintf(stderr, "Number of edges: %d\n", *v1);
if ( (int)*v1 > 0 )
{
v3 = 0LL;
do
{
v4 = *((_QWORD *)v1 + 1);
fprintf(stderr, "Edge %d: ", (unsigned int)v3);
tl_print3("Point: ", v4 + 48 * v3);
fputc(10, stderr);
tl_print3(" Direction: ", v4 + 48 * v3 + 24);
result = fputc(10, stderr);
++v3;
}
while ( (int)*v1 > (int)v3 );
}
return result;
}

canonical_decompiled_code:
int __fastcall func2(__int64 a1)
{
unsigned int *v1; // r13
int result; // eax
__int64 v3; // r12
__int64 v4; // rbp

v1 = *(unsigned int **)(*(_QWORD *)(a1 + 24) + 48LL);
plane_dump();
fwrite("Polygon data:\n", 1uLL, 0xEuLL, stderr);
result = fprintf(stderr, "Number of edges: %d\n", *v1);
if ( (int)*v1 > 0 )
{
v3 = 0LL;
do
{
v4 = *((_QWORD *)v1 + 1);
fprintf(stderr, "Edge %d: ", (unsigned int)v3);
tl_print3("Point: ", v4 + 48 * v3);
fputc(10, stderr);
tl_print3(" Direction: ", v4 + 48 * v3 + 24);
result = fputc(10, stderr);
++v3;
}
while ( (int)*v1 > (int)v3 );
}
return result;
}

original_code:
void polygon_dump(obj_t *obj) {
   int edgectr;
   edge_t *edgeptr;
   polygon_t *polygon = (polygon_t *) ((plane_t *) obj->typeData)->priv;
   plane_dump(obj);
   fprintf(stderr, "Polygon data:\n");
   fprintf(stderr, "Number of edges: %d\n", polygon->numEdges);
   for(edgectr = 0; edgectr < polygon->numEdges; edgectr++) {
      edgeptr = polygon->edges;
      fprintf(stderr, "Edge %d: ", edgectr);
      tl_print3("Point:     ", &(edgeptr + edgectr)->point);
      fprintf(stderr, "\n");
      tl_print3("        Direction: ", &(edgeptr + edgectr)->edgeDir);
      fprintf(stderr, "\n");
   }
}

canonical_original_code:
void polygon_dump(struct obj_type *obj) {
   int edgectr;
   struct edge_type *edgeptr;
   struct polygon_type *polygon = (polygon_t *) ((plane_t *) obj->typeData)->priv;
   plane_dump(obj);
   fprintf(stderr, "Polygon data:\n");
   fprintf(stderr, "Number of edges: %d\n", polygon->numEdges);
   for(edgectr = 0; edgectr < polygon->numEdges; edgectr++) {
      edgeptr = polygon->edges;
      fprintf(stderr, "Edge %d: ", edgectr);
      tl_print3("Point:     ", &(edgeptr + edgectr)->point);
      fprintf(stderr, "\n");
      tl_print3("        Direction: ", &(edgeptr + edgectr)->edgeDir);
      fprintf(stderr, "\n");
   }
}

variable_types: struct edge_type { struct triple { double x; double y; double z; } point; struct triple edgeDir; } *


decompiled_code:
double __fastcall tl_length3(double *a1)
{
double v1; // xmm0_8
double result; // xmm0_8

v1 = a1[2] * a1[2] + *a1 * *a1 + a1[1] * a1[1];
if ( v1 < 0.0 )
result = sqrt(v1);
else
result = sqrt(v1);
return result;
}

canonical_decompiled_code:
double __fastcall func0(double *a1)
{
double v1; // xmm0_8
double result; // xmm0_8

v1 = a1[2] * a1[2] + *a1 * *a1 + a1[1] * a1[1];
if ( v1 < 0.0 )
result = sqrt(v1);
else
result = sqrt(v1);
return result;
}

original_code:
double tl_length3(triple_t * v1) {
   double sum = 0.0;
   sum = v1->x*v1->x + v1->y*v1->y + v1->z*v1->z;
   return sqrt(sum);
}

canonical_original_code:
double tl_length3(struct triple *v1) {
   double sum = 0.0;
   sum = v1->x*v1->x + v1->y*v1->y + v1->z*v1->z;
   return sqrt(sum);
}

variable_types: sum double


decompiled_code:
double __fastcall tl_dot3(double *a1, double *a2)
{
return *a1 * *a2 + a1[1] * a2[1] + a1[2] * a2[2];
}

canonical_decompiled_code:
double __fastcall func3(double *a1, double *a2)
{
return *a1 * *a2 + a1[1] * a2[1] + a1[2] * a2[2];
}

original_code:
double tl_dot3(triple_t * v1, triple_t * v2) {
   double sum;
   sum = (v1->x * v2->x) + (v1->y * v2->y) + (v1->z * v2->z);
   return sum;
}

canonical_original_code:
double tl_dot3(struct triple *v1, struct triple *v2) {
   double sum;
   sum = (v1->x * v2->x) + (v1->y * v2->y) + (v1->z * v2->z);
   return sum;
}


decompiled_code:
int __fastcall tl_print3(const char *a1, double *a2)
{
return fprintf(stderr, "%s %8.4lf %8.4lf %8.4lf\n", a1, *a2, a2[1], a2[2]);
}

canonical_decompiled_code:
int __fastcall func6(const char *a1, double *a2)
{
return fprintf(stderr, "%s %8.4lf %8.4lf %8.4lf\n", a1, *a2, a2[1], a2[2]);
}

original_code:
void tl_print3(char *label, triple_t *v) {
   fprintf(stderr, "%s %8.4lf %8.4lf %8.4lf\n", label, v->x, v->y, v->z);
}

canonical_original_code:
void tl_print3(char *label, struct triple *v) {
   fprintf(stderr, "%s %8.4lf %8.4lf %8.4lf\n", label, v->x, v->y, v->z);
}

variable_types:
label
char *


decompiled_code:
double *__fastcall tl_cross3(double *a1, double *a2, double *a3)
{
double *result; // rax
double v4; // xmm2_8
double v5; // xmm3_8
double v6; // xmm1_8
double v7; // xmm0_8
double v8; // xmm5_8
double v9; // xmm6_8

result = a1;
v4 = a2[1];
v5 = a3[2];
v6 = a2[2];
v7 = a3[1];
v8 = *a3;
v9 = *a2;
*a1 = v4 * v5 - v6 * v7;
a1[1] = v6 * v8 - v5 * v9;
a1[2] = v7 * v9 - v4 * v8;
return result;
}

canonical_decompiled_code:
double *__fastcall func7(double *a1, double *a2, double *a3)
{
double *result; // rax
double v4; // xmm2_8
double v5; // xmm3_8
double v6; // xmm1_8
double v7; // xmm0_8
double v8; // xmm5_8
double v9; // xmm6_8

result = a1;
v4 = a2[1];
v5 = a3[2];
v6 = a2[2];
v7 = a3[1];
v8 = *a3;
v9 = *a2;
*a1 = v4 * v5 - v6 * v7;
a1[1] = v6 * v8 - v5 * v9;
a1[2] = v7 * v9 - v4 * v8;
return result;
}

original_code:
triple_t tl_cross3(triple_t *v, triple_t *w) {
   triple_t result;
   result.x = (v->y * w->z) - (v->z * w->y);
   result.y = (v->z * w->x) - (v->x * w->z);
   result.z = (v->x * w->y) - (v->y * w->x);
   return result;
}

canonical_original_code:
struct triple tl_cross3(struct triple *v, struct triple *w) {
   struct triple result;
   result.x = (v->y * w->z) - (v->z * w->y);
   result.y = (v->z * w->x) - (v->x * w->z);
   result.z = (v->x * w->y) - (v->y * w->x);
   return result;
}

variable_types:
v
struct triple *

variable_types:
w
struct triple *

variable_types: struct triple { double x; double y; double z; }


decompiled_code:
double *__fastcall tl_xform3(double *a1, double *a2, double *a3)
{
double v4; // r14
double v5; // r13
double v6; // xmm0_8

v4 = tl_dot3(a2, a3);
v5 = tl_dot3(a2 + 3, a3);
v6 = tl_dot3(a2 + 6, a3);
*a1 = v4;
a1[1] = v5;
a1[2] = v6;
return a1;
}

canonical_decompiled_code:
double *__fastcall func9(double *a1, double *a2, double *a3)
{
double v4; // r14
double v5; // r13
double v6; // xmm0_8

v4 = func3(a2, a3);
v5 = func3(a2 + 3, a3);
v6 = func3(a2 + 6, a3);
*a1 = v4;
a1[1] = v5;
a1[2] = v6;
return a1;
}

original_code:
triple_t tl_xform3(triple_t rotation[3], triple_t *p) {
   triple_t result;
   result.x = tl_dot3(&rotation[0], p);
   result.y = tl_dot3(&rotation[1], p);
   result.z = tl_dot3(&rotation[2], p);
   return result;
}

canonical_original_code:
struct triple tl_xform3(struct triple rotation[3], struct triple *p) {
   struct triple result;
   result.x = tl_dot3(&rotation[0], p);
   result.y = tl_dot3(&rotation[1], p);
   result.z = tl_dot3(&rotation[2], p);
   return result;
}

variable_types:
rotation
struct triple [3]

variable_types:
p
struct triple *

return_type: struct triple { double x; double y; double z; }


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

v1 = *(double **)(*(_QWORD *)(a1 + 24) + 48LL);
plane_dump();
fprintf(stderr, "Tile Height: %lf Tile Width: %lf\n", v1[17], v1[18]);
tl_print3("Orientation: ", v1);
tl_print3("Background Color: ", v1 + 3);
fprintf(stderr, "Background Diffuse: %lf\n", v1[15]);
fprintf(stderr, "Background Specular: %lf\n", v1[16]);
fwrite("Rotation Matrix:\n", 1uLL, 0x11uLL, stderr);
tl_print3(&unk_462, v1 + 6);
tl_print3(&unk_462, v1 + 9);
tl_print3(&unk_462, v1 + 12);
return fputc(10, stderr);
}

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

v1 = *(double **)(*(_QWORD *)(a1 + 24) + 48LL);
plane_dump();
fprintf(stderr, "Tile Height: %lf Tile Width: %lf\n", v1[17], v1[18]);
tl_print3("Orientation: ", v1);
tl_print3("Background Color: ", v1 + 3);
fprintf(stderr, "Background Diffuse: %lf\n", v1[15]);
fprintf(stderr, "Background Specular: %lf\n", v1[16]);
fwrite("Rotation Matrix:\n", 1uLL, 0x11uLL, stderr);
tl_print3(&unk_462, v1 + 6);
tl_print3(&unk_462, v1 + 9);
tl_print3(&unk_462, v1 + 12);
return fputc(10, stderr);
}

original_code:
void tplane_dump(obj_t *obj) {
   plane_t *plane = (plane_t *)(obj->typeData);
   tplane_t *tplane = (tplane_t *) (plane->priv);
   plane_dump(obj);
   fprintf(stderr, "Tile Height: %lf   Tile Width: %lf\n", tplane->tileHeight, tplane->tileWidth);
   tl_print3("Orientation: ", &tplane->orientation);
   tl_print3("Background Color: ", &tplane->bkgrndcolor);
   fprintf(stderr, "Background Diffuse: %lf\n", tplane->bkgrnddiff);
   fprintf(stderr, "Background Specular: %lf\n", tplane->bkgrndspec);
   fprintf(stderr, "Rotation Matrix:\n");
   tl_print3("", &tplane->rotate[0]);
   tl_print3("", &tplane->rotate[1]);
   tl_print3("", &tplane->rotate[2]);
   fprintf(stderr, "\n");
}

canonical_original_code:
void tplane_dump(struct obj_type *obj) {
   struct plane_type *plane = (plane_t *)(obj->typeData);
   struct tplane_type *tplane = (tplane_t *) (plane->priv);
   plane_dump(obj);
   fprintf(stderr, "Tile Height: %lf   Tile Width: %lf\n", tplane->tileHeight, tplane->tileWidth);
   tl_print3("Orientation: ", &tplane->orientation);
   tl_print3("Background Color: ", &tplane->bkgrndcolor);
   fprintf(stderr, "Background Diffuse: %lf\n", tplane->bkgrnddiff);
   fprintf(stderr, "Background Specular: %lf\n", tplane->bkgrndspec);
   fprintf(stderr, "Rotation Matrix:\n");
   tl_print3("", &tplane->rotate[0]);
   tl_print3("", &tplane->rotate[1]);
   tl_print3("", &tplane->rotate[2]);
   fprintf(stderr, "\n");
}

variable_types: struct obj_type { struct obj_type *next; int objid; int objcat; char *objclass; void *typeData; union { struct sceneobj { struct triple { double x; double y; double z; } color; double diffuse; double specular; double (*hits)(struct triple *base, struct triple *dir, struct obj_type *obj); struct triple (*getcolor)(struct obj_type *obj); double (*getdiffuse)(struct obj_type *obj); double (*getspecular)(struct obj_type *obj); struct triple hitloc; struct triple normal; double distance; } *sceneData; struct lightobj { struct triple emissivity; struct triple center; } *lightData; }; } *

variable_types: struct plane_type { struct triple { double x; double y; double z; } point; struct triple normal; void *priv; } *

variable_types: struct tplane_type { struct triple { double x; double y; double z; } orientation; struct triple bkgrndcolor; struct triple rotate[3]; double bkgrnddiff; double bkgrndspec; double tileHeight; double tileWidth; } *

user_defined_types: struct tplane_type { struct triple orientation; struct triple bkgrndcolor; struct triple rotate[3]; double bkgrnddiff; double bkgrndspec; double tileHeight; double tileWidth; }


original_code:
int tp_select(obj_t *obj) {
   plane_t *plane = (plane_t *) obj->typeData;
   tplane_t *tplane = (tplane_t*)(plane->priv);
   int relx;
   int rely;
   triple_t newhit;
   newhit = tl_diff3(&obj->sceneData->hitloc, &plane->point);
   newhit = tl_xform3(tplane->rotate, &newhit);
   relx = (int) (newhit.x / tplane->tileWidth);
   rely = (int) (newhit.y / tplane->tileHeight);
   if((newhit.x < 0) && (newhit.y < 0))
      return (relx + rely) % 2;
   if((newhit.x < 0) || (newhit.y < 0))
      return (relx + rely + 1) % 2;
   else
      return (relx + rely) % 2;
}

canonical_original_code:
int tp_select(struct obj_type *obj) {
   struct plane_type *plane = (plane_t *) obj->typeData;
   struct tplane_type *tplane = (tplane_t*)(plane->priv);
   int relx;
   int rely;
   struct triple newhit;
   newhit = tl_diff3(&obj->sceneData->hitloc, &plane->point);
   newhit = tl_xform3(tplane->rotate, &newhit);
   relx = (int) (newhit.x / tplane->tileWidth);
   rely = (int) (newhit.y / tplane->tileHeight);
   if((newhit.x < 0) && (newhit.y < 0))
      return (relx + rely) % 2;
   if((newhit.x < 0) || (newhit.y < 0))
      return (relx + rely + 1) % 2;
   else
      return (relx + rely) % 2;
}

variable_types: relx int

variable_types: rely int


decompiled_code:
double __fastcall tp_getdiffuse(__int64 a1)
{
__int64 v1; // rbp
double result; // xmm0_8

v1 = *(_QWORD *)(*(_QWORD *)(a1 + 24) + 48LL);
if ( (unsigned int)tp_select(a1) )
result = *(double *)(*(_QWORD *)(a1 + 32) + 24LL);
else
result = *(double *)(v1 + 120);
return result;
}

canonical_decompiled_code:
double __fastcall func3(__int64 a1)
{
__int64 v1; // rbp
double result; // xmm0_8

v1 = *(_QWORD *)(*(_QWORD *)(a1 + 24) + 48LL);
if ( (unsigned int)func2(a1) )
result = *(double *)(*(_QWORD *)(a1 + 32) + 24LL);
else
result = *(double *)(v1 + 120);
return result;
}

original_code:
double tp_getdiffuse(obj_t *obj) {
   plane_t *plnPtr = (plane_t *)obj->typeData;
   tplane_t *tp = (tplane_t *)plnPtr->priv;
   if (tp_select(obj))
      return obj->sceneData->diffuse;
   else
      return tp->bkgrnddiff;
}

canonical_original_code:
double tp_getdiffuse(struct obj_type *obj) {
   struct plane_type *plnPtr = (plane_t *)obj->typeData;
   struct tplane_type *tp = (tplane_t *)plnPtr->priv;
   if (tp_select(obj))
      return obj->sceneData->diffuse;
   else
      return tp->bkgrnddiff;
}


decompiled_code:
double __fastcall tp_getspecular(__int64 a1)
{
__int64 v1; // rbp
double result; // xmm0_8

v1 = *(_QWORD *)(*(_QWORD *)(a1 + 24) + 48LL);
if ( (unsigned int)tp_select(a1) )
result = *(double *)(*(_QWORD *)(a1 + 32) + 32LL);
else
result = *(double *)(v1 + 128);
return result;
}

canonical_decompiled_code:
double __fastcall func4(__int64 a1)
{
__int64 v1; // rbp
double result; // xmm0_8

v1 = *(_QWORD *)(*(_QWORD *)(a1 + 24) + 48LL);
if ( (unsigned int)func2(a1) )
result = *(double *)(*(_QWORD *)(a1 + 32) + 32LL);
else
result = *(double *)(v1 + 128);
return result;
}

original_code:
double tp_getspecular(obj_t *obj) {
   plane_t *plnPtr = (plane_t *)obj->typeData;
   tplane_t *tp = (tplane_t *)plnPtr->priv;
   if (tp_select(obj))
      return obj->sceneData->specular;
   else
      return tp->bkgrndspec;
}

canonical_original_code:
double tp_getspecular(struct obj_type *obj) {
   struct plane_type *plnPtr = (plane_t *)obj->typeData;
   struct tplane_type *tp = (tplane_t *)plnPtr->priv;
   if (tp_select(obj))
      return obj->sceneData->specular;
   else
      return tp->bkgrndspec;
}


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

v1 = *(_QWORD *)(a1 + 32);
object_dump();
fwrite("Light Data:\n", 1uLL, 0xCuLL, stderr);
tl_print3("Center coordinates: ", v1 + 24);
return tl_print3("Emissivity: ", v1);
}

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

v1 = *(_QWORD *)(a1 + 32);
object_dump();
fwrite("Light Data:\n", 1uLL, 0xCuLL, stderr);
tl_print3("Center coordinates: ", v1 + 24);
return tl_print3("Emissivity: ", v1);
}

original_code:
void light_dump(obj_t *obj) {
   lightobj_t *light = obj->lightData;
   object_dump(obj);
   fprintf(stderr, "Light Data:\n");
   tl_print3("Center coordinates: ", &light->center);
   tl_print3("Emissivity: ", &light->emissivity);
}

canonical_original_code:
void light_dump(struct obj_type *obj) {
   struct lightobj *light = obj->lightData;
   object_dump(obj);
   fprintf(stderr, "Light Data:\n");
   tl_print3("Center coordinates: ", &light->center);
   tl_print3("Emissivity: ", &light->emissivity);
}

variable_types: struct lightobj { struct triple { double x; double y; double z; } emissivity; struct triple center; } *