OuvrirChat

decompiled_code:
__int64 __fastcall OuvrirChat(int fd, __int64 a2, int *a3, char *a4)
{
int v5; // eax
int v6; // er15
int v7; // er13
int v8; // ebx
int v9; // ebp
int v10; // er12
char *v11; // rbx
char *v12; // r13
int v13; // ebp
int v14; // ebx
int v15; // ebx
int v16; // ebx
int v18; // er12
__int64 v19; // rbp
int v20; // er13
signed int v21; // ebp
int v22; // ebp
unsigned int v23; // [rsp+4h] [rbp-284h]
int v25; // [rsp+10h] [rbp-278h]
unsigned int v26; // [rsp+10h] [rbp-278h]
unsigned int v27; // [rsp+18h] [rbp-270h]
unsigned int v28; // [rsp+1Ch] [rbp-26Ch]
unsigned int v29; // [rsp+1Ch] [rbp-26Ch]
int v30; // [rsp+20h] [rbp-268h]
int v31; // [rsp+2Ch] [rbp-25Ch]
char buf; // [rsp+4Fh] [rbp-239h] BYREF
char v35[256]; // [rsp+50h] [rbp-238h] BYREF
char v36[248]; // [rsp+150h] [rbp-138h] BYREF
int v37; // [rsp+248h] [rbp-40h]
__int16 v38; // [rsp+24Ch] [rbp-3Ch]
char v39; // [rsp+24Eh] [rbp-3Ah]

v31 = strlen(a4);
printf("ouvrir chat %i \n", (unsigned int)fd);
AfficherAttenteCratyle(fd);
v5 = fcntl(fd, 3, 0LL);
v23 = v5;
v6 = 0;
v7 = 1;
BYTE1(v5) |= 8u;
v27 = v5;
while ( 1 )
{
fcntl(fd, 4, v27);
v9 = read(fd, v36, 0xFFuLL);
fcntl(fd, 4, v23);
if ( v9 == -1 )
{
if ( *_errno_location() == 11 )
usleep(0x61A8u);
else
MINITELEnvoyerCaractere(fd, 20);
v8 = 0;
goto LABEL_6;
}
MINITELEnvoyerCaractere(fd, 20);
if ( v9 == 2 )
{
v8 = 0;
if ( v36[0] == 32 )
goto LABEL_6;
LABEL_14:
v36[v9] = 0;
v25 = v9 - 1 + v31;
if ( v25 <= 39 )
{
v28 = 1;
}
else
{
v25 = 40 - v25;
printf("LOCAL:CalculLignes : %d\n", (unsigned int)v25);
v28 = 2;
}
printf("LOCAL:LignesTexteMinitel : %d -- CalculLignes %d\n", v28, (unsigned int)v25);
MINITELCurseurXY(fd, 22, 3);
MINITELEnvoyerTexte(fd, "Envoi... ");
v10 = v7 + 1;
if ( (unsigned __int8)(v7 + 1) >= 0x13u )
v10 = 2;
MINITELCurseurXY(fd, v10 + 2, 1);
MINITELEnvoyerTexte(fd, a4);
MINITELChangerAttribut(fd, 66);
printf("LigneEnCours : %d\n", (unsigned __int8)v10);
if ( v9 - 1 > 0 )
{
v11 = v36;
v12 = &v36[v9 - 2 + 1];
v30 = v9;
v13 = v28;
do
{
if ( v13 > 1 && (unsigned __int8)v10 > 0xFu && (_DWORD)v11 + v31 - (unsigned int)v36 == 40 )
{
MINITELCurseurXY(fd, 4, 1);
MINITELChangerAttribut(fd, 66);
v13 = 1;
v10 = 2;
}
if ( *v11 <= 31 )
{
MINITELChangerAttribut(fd, 65);
MINITELEnvoyerCaractere(fd, 33);
MINITELChangerAttribut(fd, 66);
}
else
{
MINITELEnvoyerCaractere(fd, *v11);
}
++v11;
}
while ( v12 != v11 );
LOBYTE(v28) = v13;
v9 = v30;
}
MINITELChangerAttribut(fd, 71);
if ( v25 + 39 >= 0 )
{
v14 = 0;
do
{
MINITELEnvoyerCaractere(fd, 32);
++v14;
}
while ( v14 <= v25 + 39 );
}
LOBYTE(v10) = v28 + v10;
v7 = v10 - 1;
if ( (unsigned __int8)(v10 - 1) <= 0xEu )
{
MINITELCurseurXY(fd, v10 + 2, 1);
v15 = 40;
do
{
MINITELEnvoyerCaractere(fd, 32);
--v15;
}
while ( v15 );
}
AfficherAttenteCratyle(fd);
printf("bufMinitel:%s:%d\n", v36, (unsigned int)v9);
if ( !memcmp(v36, "CLEARSCREEN", 0xBuLL) )
{
puts("CRATYLE_CLEAR_SENTENCE ");
MINITELCurseurXY(fd, 2, 1);
MINITELChangerAttribut(fd, 79);
MINITELEnvoyerTexte(fd, "// (ratyle //");
MINITELChangerAttribut(fd, 76);
MINITELCurseurXY(fd, 3, 1);
v16 = 40;
do
{
MINITELEnvoyerCaractere(fd, 95);
--v16;
}
while ( v16 );
AfficherAttenteCratyle(fd);
}
else if ( !memcmp(v36, "CHATPROPRE", 0xAuLL) )
{
InitChat(fd);
AfficherAttenteCratyle(fd);
v7 = 1;
}
else
{
write(*(_DWORD *)(a2 + 4), v36, v9);
}
v8 = 0;
if ( !memcmp(v36, "quitCRATYLE", 0xBuLL) )
{
puts("CRATYLE_ESCAPE_SENTENCE ");
AfficherAurevoirCratyle(fd);
v8 = 1;
}
memset(v36, 0, sizeof(v36));
v37 = 0;
v38 = 0;
v39 = 0;
goto LABEL_6;
}
if ( v9 <= 2 )
{
v8 = 0;
goto LABEL_6;
}
v8 = 0;
if ( v36[0] > 31 )
goto LABEL_14;
LABEL_6:
if ( (unsigned int)read(*a3, &buf, 1uLL) == -1 && *_errno_location() == 11 )
break;
v35[v6++] = buf;
LABEL_8:
if ( v8 )
return 0LL;
}
if ( !v6 )
goto LABEL_8;
v35[v6] = 0;
printf("MinitelxDansRien : strServeur %s \n", v35);
fcntl(fd, 4, v23);
if ( strcmp(v35, "quitCRATYLE") )
{
v26 = v6 + 2;
if ( v6 + 2 <= 39 )
{
v29 = 1;
}
else
{
v26 = 40 - v26;
printf("DISTANT:CalculLignes : %d\n", v26);
v29 = 2;
}
printf("LOCAL:LignesTexteMinitel : %d -- CalculLignes %d\n", v29, v26);
v18 = v7 + 1;
if ( (unsigned __int8)(v7 + 1) >= 0x13u )
v18 = 2;
MINITELCurseurXY(fd, v18 + 2, 1);
MINITELEnvoyerTexte(fd, "-->");
MINITELChangerAttribut(fd, 66);
if ( v6 > 0 )
{
v19 = 1LL;
v20 = v29;
while ( 1 )
{
MINITELEnvoyerCaractere(fd, *(&buf + v19));
if ( v6 == v19 )
break;
if ( (unsigned __int8)v18 > 0xFu && v20 > 1 && (_DWORD)v19 == 37 )
{
MINITELCurseurXY(fd, 4, 1);
MINITELChangerAttribut(fd, 66);
v20 = 1;
v18 = 2;
}
++v19;
}
LOBYTE(v29) = v20;
}
MINITELChangerAttribut(fd, 71);
if ( (int)(v26 + 39) >= 0 )
{
v21 = 0;
do
{
MINITELEnvoyerCaractere(fd, 32);
++v21;
}
while ( v21 <= (int)(v26 + 39) );
}
LOBYTE(v18) = v29 + v18;
v7 = v18 - 1;
if ( (unsigned __int8)(v18 - 1) <= 0xEu )
{
MINITELCurseurXY(fd, v18 + 2, 1);
v22 = 40;
do
{
MINITELEnvoyerCaractere(fd, 32);
--v22;
}
while ( v22 );
}
AfficherAttenteCratyle(fd);
v6 = 0;
goto LABEL_8;
}
puts("On me dit aurevoir dans l'oreille....");
AfficherAurevoirCratyle(fd);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func12(int fd, __int64 a2, int *a3, char *a4)
{
int v5; // eax
int v6; // er15
int v7; // er13
int v8; // ebx
int v9; // ebp
int v10; // er12
char *v11; // rbx
char *v12; // r13
int v13; // ebp
int v14; // ebx
int v15; // ebx
int v16; // ebx
int v18; // er12
__int64 v19; // rbp
int v20; // er13
signed int v21; // ebp
int v22; // ebp
unsigned int v23; // [rsp+4h] [rbp-284h]
int v25; // [rsp+10h] [rbp-278h]
unsigned int v26; // [rsp+10h] [rbp-278h]
unsigned int v27; // [rsp+18h] [rbp-270h]
unsigned int v28; // [rsp+1Ch] [rbp-26Ch]
unsigned int v29; // [rsp+1Ch] [rbp-26Ch]
int v30; // [rsp+20h] [rbp-268h]
int v31; // [rsp+2Ch] [rbp-25Ch]
char buf; // [rsp+4Fh] [rbp-239h] BYREF
char v35[256]; // [rsp+50h] [rbp-238h] BYREF
char v36[248]; // [rsp+150h] [rbp-138h] BYREF
int v37; // [rsp+248h] [rbp-40h]
__int16 v38; // [rsp+24Ch] [rbp-3Ch]
char v39; // [rsp+24Eh] [rbp-3Ah]

v31 = strlen(a4);
printf("ouvrir chat %i \n", (unsigned int)fd);
func10(fd);
v5 = fcntl(fd, 3, 0LL);
v23 = v5;
v6 = 0;
v7 = 1;
BYTE1(v5) |= 8u;
v27 = v5;
while ( 1 )
{
fcntl(fd, 4, v27);
v9 = read(fd, v36, 0xFFuLL);
fcntl(fd, 4, v23);
if ( v9 == -1 )
{
if ( *_errno_location() == 11 )
usleep(0x61A8u);
else
func4(fd, 20);
v8 = 0;
goto LABEL_6;
}
func4(fd, 20);
if ( v9 == 2 )
{
v8 = 0;
if ( v36[0] == 32 )
goto LABEL_6;
LABEL_14:
v36[v9] = 0;
v25 = v9 - 1 + v31;
if ( v25 <= 39 )
{
v28 = 1;
}
else
{
v25 = 40 - v25;
printf("LOCAL:CalculLignes : %d\n", (unsigned int)v25);
v28 = 2;
}
printf("LOCAL:LignesTexteMinitel : %d -- CalculLignes %d\n", v28, (unsigned int)v25);
func6(fd, 22, 3);
func5(fd, "Envoi... ");
v10 = v7 + 1;
if ( (unsigned __int8)(v7 + 1) >= 0x13u )
v10 = 2;
func6(fd, v10 + 2, 1);
func5(fd, a4);
func8(fd, 66);
printf("LigneEnCours : %d\n", (unsigned __int8)v10);
if ( v9 - 1 > 0 )
{
v11 = v36;
v12 = &v36[v9 - 2 + 1];
v30 = v9;
v13 = v28;
do
{
if ( v13 > 1 && (unsigned __int8)v10 > 0xFu && (_DWORD)v11 + v31 - (unsigned int)v36 == 40 )
{
func6(fd, 4, 1);
func8(fd, 66);
v13 = 1;
v10 = 2;
}
if ( *v11 <= 31 )
{
func8(fd, 65);
func4(fd, 33);
func8(fd, 66);
}
else
{
func4(fd, *v11);
}
++v11;
}
while ( v12 != v11 );
LOBYTE(v28) = v13;
v9 = v30;
}
func8(fd, 71);
if ( v25 + 39 >= 0 )
{
v14 = 0;
do
{
func4(fd, 32);
++v14;
}
while ( v14 <= v25 + 39 );
}
LOBYTE(v10) = v28 + v10;
v7 = v10 - 1;
if ( (unsigned __int8)(v10 - 1) <= 0xEu )
{
func6(fd, v10 + 2, 1);
v15 = 40;
do
{
func4(fd, 32);
--v15;
}
while ( v15 );
}
func10(fd);
printf("bufMinitel:%s:%d\n", v36, (unsigned int)v9);
if ( !memcmp(v36, "CLEARSCREEN", 0xBuLL) )
{
puts("CRATYLE_CLEAR_SENTENCE ");
func6(fd, 2, 1);
func8(fd, 79);
func5(fd, "// (ratyle //");
func8(fd, 76);
func6(fd, 3, 1);
v16 = 40;
do
{
func4(fd, 95);
--v16;
}
while ( v16 );
func10(fd);
}
else if ( !memcmp(v36, "CHATPROPRE", 0xAuLL) )
{
func9(fd);
func10(fd);
v7 = 1;
}
else
{
write(*(_DWORD *)(a2 + 4), v36, v9);
}
v8 = 0;
if ( !memcmp(v36, "quitCRATYLE", 0xBuLL) )
{
puts("CRATYLE_ESCAPE_SENTENCE ");
func11(fd);
v8 = 1;
}
memset(v36, 0, sizeof(v36));
v37 = 0;
v38 = 0;
v39 = 0;
goto LABEL_6;
}
if ( v9 <= 2 )
{
v8 = 0;
goto LABEL_6;
}
v8 = 0;
if ( v36[0] > 31 )
goto LABEL_14;
LABEL_6:
if ( (unsigned int)read(*a3, &buf, 1uLL) == -1 && *_errno_location() == 11 )
break;
v35[v6++] = buf;
LABEL_8:
if ( v8 )
return 0LL;
}
if ( !v6 )
goto LABEL_8;
v35[v6] = 0;
printf("MinitelxDansRien : strServeur %s \n", v35);
fcntl(fd, 4, v23);
if ( strcmp(v35, "quitCRATYLE") )
{
v26 = v6 + 2;
if ( v6 + 2 <= 39 )
{
v29 = 1;
}
else
{
v26 = 40 - v26;
printf("DISTANT:CalculLignes : %d\n", v26);
v29 = 2;
}
printf("LOCAL:LignesTexteMinitel : %d -- CalculLignes %d\n", v29, v26);
v18 = v7 + 1;
if ( (unsigned __int8)(v7 + 1) >= 0x13u )
v18 = 2;
func6(fd, v18 + 2, 1);
func5(fd, "-->");
func8(fd, 66);
if ( v6 > 0 )
{
v19 = 1LL;
v20 = v29;
while ( 1 )
{
func4(fd, *(&buf + v19));
if ( v6 == v19 )
break;
if ( (unsigned __int8)v18 > 0xFu && v20 > 1 && (_DWORD)v19 == 37 )
{
func6(fd, 4, 1);
func8(fd, 66);
v20 = 1;
v18 = 2;
}
++v19;
}
LOBYTE(v29) = v20;
}
func8(fd, 71);
if ( (int)(v26 + 39) >= 0 )
{
v21 = 0;
do
{
func4(fd, 32);
++v21;
}
while ( v21 <= (int)(v26 + 39) );
}
LOBYTE(v18) = v29 + v18;
v7 = v18 - 1;
if ( (unsigned __int8)(v18 - 1) <= 0xEu )
{
func6(fd, v18 + 2, 1);
v22 = 40;
do
{
func4(fd, 32);
--v22;
}
while ( v22 );
}
func10(fd);
v6 = 0;
goto LABEL_8;
}
puts("On me dit aurevoir dans l'oreille....");
func11(fd);
return 0LL;
}

original_code:
int OuvrirChat (int iFdMinitel, int* fdPipeOut, int* fdPipeIn, const unsigned char* strPhilosophe)
{
    int STOP;
    int k;
    unsigned char LigneEnCours = 1;
    int iLignesTexteMinitel = 0;
    int iLongueurPhilosophe, iLongueurPrefixe;
    int iNbCaracteresRecus, iCalculLignes;
    char bufMinitel[255];
    iLongueurPhilosophe = strlen((const char*)strPhilosophe);
    iLongueurPrefixe = strlen ("-->");
    STOP = 0;
    printf("ouvrir chat %i \n", iFdMinitel);
    AfficherAttenteCratyle(iFdMinitel);
    unsigned char strServeur[255];
    int iLnMessage = 0;
    int flags = fcntl(iFdMinitel, 3, 0);
     while (STOP == 0)
     {
        fcntl (iFdMinitel, 4, flags | 04000);
        iNbCaracteresRecus = read(iFdMinitel,bufMinitel,255);
        fcntl (iFdMinitel, 4, flags);
        if (iNbCaracteresRecus == -1 && (*__errno_location ()) == 11)
        {
            usleep(25000);
        }
        else
        {
            MINITELEnvoyerCaractere(iFdMinitel, 0x14);
            if(((iNbCaracteresRecus == 2) && (bufMinitel[0] != 0x20)) || ((iNbCaracteresRecus >= 3) && (bufMinitel[0] >= 0x20)))
            {
                bufMinitel[iNbCaracteresRecus] = '\0';
                iLignesTexteMinitel = 1;
                iCalculLignes = iNbCaracteresRecus-1 + iLongueurPhilosophe;
                while(iCalculLignes-40 >= 0)
                {
                    iCalculLignes = 40 - iCalculLignes;
                    printf("LOCAL:CalculLignes : %d\n", iCalculLignes);
                    iLignesTexteMinitel++;
                }
                printf("LOCAL:LignesTexteMinitel : %d -- CalculLignes %d\n", iLignesTexteMinitel, iCalculLignes);
                MINITELCurseurXY(iFdMinitel, 22, 3);
                MINITELEnvoyerTexte(iFdMinitel, (const unsigned char*)"Envoi...              ");
                LigneEnCours++;
                if(LigneEnCours > 18)
                {
                    LigneEnCours = 2;
                }
                MINITELCurseurXY(iFdMinitel, (LigneEnCours + 2), 1);
                MINITELEnvoyerTexte(iFdMinitel, strPhilosophe);
                MINITELChangerAttribut(iFdMinitel, 0x42);
                printf("LigneEnCours : %d\n", LigneEnCours) ;
                for(k = 0; k < (iNbCaracteresRecus - 1); k++)
                {
                    if(iLignesTexteMinitel >= 2 && LigneEnCours+2 >= 18 && k+iLongueurPhilosophe == 40)
                    {
                        LigneEnCours = 2;
                        MINITELCurseurXY(iFdMinitel, (LigneEnCours + 2), 1);
                        MINITELChangerAttribut(iFdMinitel, 0x42);
                        iLignesTexteMinitel = 1;
                    }
                    if(bufMinitel[k] >= 0x20)
                    {
                        MINITELEnvoyerCaractere(iFdMinitel, bufMinitel[k]);
                    }
                    else
                    {
                        MINITELChangerAttribut(iFdMinitel, 0x41);
                        MINITELEnvoyerCaractere(iFdMinitel, '!');
                        MINITELChangerAttribut(iFdMinitel, 0x42);
                    }
                }
                MINITELChangerAttribut(iFdMinitel, 0x47);
                for(k = 0 ; k < 40 +iCalculLignes ; k++)
                    MINITELEnvoyerCaractere(iFdMinitel, ' ');
                LigneEnCours += iLignesTexteMinitel-1;
                if(LigneEnCours+3 < 18)
                {
                    MINITELCurseurXY(iFdMinitel, (LigneEnCours + 3), 1);
                    for(k = 0; k < 40; k++)
                    {
                        MINITELEnvoyerCaractere(iFdMinitel, ' ');
                    }
                }
                AfficherAttenteCratyle(iFdMinitel);
                printf("bufMinitel:%s:%d\n", bufMinitel, iNbCaracteresRecus);
                if (strncmp (bufMinitel, "CLEARSCREEN", strlen("CLEARSCREEN")) == 0)
                {
                    printf ("CRATYLE_CLEAR_SENTENCE \n");
                    MINITELCurseurXY(iFdMinitel, 2, 1);
                    MINITELChangerAttribut(iFdMinitel, 0x4F);
                    MINITELEnvoyerTexte(iFdMinitel, (unsigned char*)"// (ratyle //");
                    MINITELChangerAttribut(iFdMinitel, 0x4C);
                    MINITELCurseurXY(iFdMinitel, 3, 1);
                    for(k = 0; k < 40; k++)
                    {
                        MINITELEnvoyerCaractere(iFdMinitel, '_');
                    }
                    AfficherAttenteCratyle(iFdMinitel);
                }
                else
                {
                    if (strncmp (bufMinitel, "CHATPROPRE", strlen("CHATPROPRE")) == 0)
                    {
                        InitChat(iFdMinitel);
                        AfficherAttenteCratyle(iFdMinitel);
                        LigneEnCours = 1;
                    }
                    else
                    {
                        write (fdPipeOut[1], bufMinitel, iNbCaracteresRecus);
                    }
                }
                if (strncmp (bufMinitel, "quitCRATYLE", strlen("quitCRATYLE")) == 0)
                {
                    printf ("CRATYLE_ESCAPE_SENTENCE \n");
                    AfficherAurevoirCratyle(iFdMinitel);
                    STOP = 1;
                }
                memset(bufMinitel, '\0', sizeof(bufMinitel));
            }
        }
        char buffer[1];
        iNbCaracteresRecus = read(fdPipeIn[0],buffer,1);
        if (iNbCaracteresRecus == -1 && (*__errno_location ()) == 11)
        {
            if(iLnMessage != 0)
            {
                strServeur[iLnMessage] = '\0';
                printf("MinitelxDansRien : strServeur %s \n", strServeur);
                fcntl (iFdMinitel, 4, flags);
                if (strcmp ((const char*)strServeur, "quitCRATYLE") == 0)
                {
                    printf ("On me dit aurevoir dans l'oreille....\n");
                    AfficherAurevoirCratyle(iFdMinitel);
                    STOP = 1;
                }
                else
                {
                    iLignesTexteMinitel = 1;
                    iCalculLignes = iLnMessage-1 + iLongueurPrefixe;
                    while(iCalculLignes-40 >= 0)
                    {
                        iCalculLignes = 40 - iCalculLignes;
                        printf("DISTANT:CalculLignes : %d\n", iCalculLignes);
                        iLignesTexteMinitel++;
                    }
                    printf("LOCAL:LignesTexteMinitel : %d -- CalculLignes %d\n", iLignesTexteMinitel, iCalculLignes);
                    LigneEnCours++;
                    if(LigneEnCours > 18)
                    {
                        LigneEnCours = 2;
                    }
                    MINITELCurseurXY(iFdMinitel, (LigneEnCours + 2), 1);
                    MINITELEnvoyerTexte(iFdMinitel, (const unsigned char*)"-->");
                    MINITELChangerAttribut(iFdMinitel, 0x42);
                    for(k = 0; k < iLnMessage; k++)
                    {
                        if(iLignesTexteMinitel >= 2 && LigneEnCours+2 >= 18 && k+iLongueurPrefixe == 40)
                        {
                            LigneEnCours = 2;
                            MINITELCurseurXY(iFdMinitel, (LigneEnCours + 2), 1);
                            MINITELChangerAttribut(iFdMinitel, 0x42);
                            iLignesTexteMinitel = 1;
                        }
                        MINITELEnvoyerCaractere(iFdMinitel, strServeur[k]);
                    }
                    MINITELChangerAttribut(iFdMinitel, 0x47);
                    for(k = 0 ; k < 40 +iCalculLignes ; k++)
                        MINITELEnvoyerCaractere(iFdMinitel, ' ');
                    LigneEnCours += iLignesTexteMinitel-1;
                    if(LigneEnCours+3 < 18)
                    {
                        MINITELCurseurXY(iFdMinitel, (LigneEnCours + 3), 1);
                        for(k = 0; k < 40; k++)
                        {
                            MINITELEnvoyerCaractere(iFdMinitel, ' ');
                        }
                    }
                    AfficherAttenteCratyle(iFdMinitel);
                }
                iLnMessage = 0;
            }
        }
        else
        {
            strServeur[iLnMessage++] = buffer[0];
        }
     }
    return 0;
}

canonical_original_code:
int OuvrirChat(int iFdMinitel, int *fdPipeOut, int *fdPipeIn, unsigned char *strPhilosophe)
{
    int STOP;
    int k;
    unsigned char LigneEnCours = 1;
    int iLignesTexteMinitel = 0;
    int iLongueurPhilosophe; int iLongueurPrefixe;
    int iNbCaracteresRecus; int iCalculLignes;
    char bufMinitel[255];
    iLongueurPhilosophe = strlen((char *)strPhilosophe);
    iLongueurPrefixe = strlen ("-->");
    STOP = 0;
    printf("ouvrir chat %i \n", iFdMinitel);
    AfficherAttenteCratyle(iFdMinitel);
    unsigned char strServeur[255];
    int iLnMessage = 0;
    int flags = fcntl(iFdMinitel, 3, 0);
     while (STOP == 0)
     {
        fcntl (iFdMinitel, 4, flags | 04000);
        iNbCaracteresRecus = read(iFdMinitel,bufMinitel,255);
        fcntl (iFdMinitel, 4, flags);
        if (iNbCaracteresRecus == -1 && (*__errno_location ()) == 11)
        {
            usleep(25000);
        }
        else
        {
            MINITELEnvoyerCaractere(iFdMinitel, 0x14);
            if(((iNbCaracteresRecus == 2) && (bufMinitel[0] != 0x20)) || ((iNbCaracteresRecus >= 3) && (bufMinitel[0] >= 0x20)))
            {
                bufMinitel[iNbCaracteresRecus] = '\0';
                iLignesTexteMinitel = 1;
                iCalculLignes = iNbCaracteresRecus-1 + iLongueurPhilosophe;
                while(iCalculLignes-40 >= 0)
                {
                    iCalculLignes = 40 - iCalculLignes;
                    printf("LOCAL:CalculLignes : %d\n", iCalculLignes);
                    iLignesTexteMinitel++;
                }
                printf("LOCAL:LignesTexteMinitel : %d -- CalculLignes %d\n", iLignesTexteMinitel, iCalculLignes);
                MINITELCurseurXY(iFdMinitel, 22, 3);
                MINITELEnvoyerTexte(iFdMinitel, (unsigned char *)"Envoi...              ");
                LigneEnCours++;
                if(LigneEnCours > 18)
                {
                    LigneEnCours = 2;
                }
                MINITELCurseurXY(iFdMinitel, (LigneEnCours + 2), 1);
                MINITELEnvoyerTexte(iFdMinitel, strPhilosophe);
                MINITELChangerAttribut(iFdMinitel, 0x42);
                printf("LigneEnCours : %d\n", LigneEnCours) ;
                for(k = 0; k < (iNbCaracteresRecus - 1); k++)
                {
                    if(iLignesTexteMinitel >= 2 && LigneEnCours+2 >= 18 && k+iLongueurPhilosophe == 40)
                    {
                        LigneEnCours = 2;
                        MINITELCurseurXY(iFdMinitel, (LigneEnCours + 2), 1);
                        MINITELChangerAttribut(iFdMinitel, 0x42);
                        iLignesTexteMinitel = 1;
                    }
                    if(bufMinitel[k] >= 0x20)
                    {
                        MINITELEnvoyerCaractere(iFdMinitel, bufMinitel[k]);
                    }
                    else
                    {
                        MINITELChangerAttribut(iFdMinitel, 0x41);
                        MINITELEnvoyerCaractere(iFdMinitel, '!');
                        MINITELChangerAttribut(iFdMinitel, 0x42);
                    }
                }
                MINITELChangerAttribut(iFdMinitel, 0x47);
                for(k = 0 ; k < 40 +iCalculLignes ; k++)
                    MINITELEnvoyerCaractere(iFdMinitel, ' ');
                LigneEnCours += iLignesTexteMinitel-1;
                if(LigneEnCours+3 < 18)
                {
                    MINITELCurseurXY(iFdMinitel, (LigneEnCours + 3), 1);
                    for(k = 0; k < 40; k++)
                    {
                        MINITELEnvoyerCaractere(iFdMinitel, ' ');
                    }
                }
                AfficherAttenteCratyle(iFdMinitel);
                printf("bufMinitel:%s:%d\n", bufMinitel, iNbCaracteresRecus);
                if (strncmp (bufMinitel, "CLEARSCREEN", strlen("CLEARSCREEN")) == 0)
                {
                    printf ("CRATYLE_CLEAR_SENTENCE \n");
                    MINITELCurseurXY(iFdMinitel, 2, 1);
                    MINITELChangerAttribut(iFdMinitel, 0x4F);
                    MINITELEnvoyerTexte(iFdMinitel, (unsigned char *)"// (ratyle //");
                    MINITELChangerAttribut(iFdMinitel, 0x4C);
                    MINITELCurseurXY(iFdMinitel, 3, 1);
                    for(k = 0; k < 40; k++)
                    {
                        MINITELEnvoyerCaractere(iFdMinitel, '_');
                    }
                    AfficherAttenteCratyle(iFdMinitel);
                }
                else
                {
                    if (strncmp (bufMinitel, "CHATPROPRE", strlen("CHATPROPRE")) == 0)
                    {
                        InitChat(iFdMinitel);
                        AfficherAttenteCratyle(iFdMinitel);
                        LigneEnCours = 1;
                    }
                    else
                    {
                        write (fdPipeOut[1], bufMinitel, iNbCaracteresRecus);
                    }
                }
                if (strncmp (bufMinitel, "quitCRATYLE", strlen("quitCRATYLE")) == 0)
                {
                    printf ("CRATYLE_ESCAPE_SENTENCE \n");
                    AfficherAurevoirCratyle(iFdMinitel);
                    STOP = 1;
                }
                memset(bufMinitel, '\0', sizeof(bufMinitel));
            }
        }
        char buffer[1];
        iNbCaracteresRecus = read(fdPipeIn[0],buffer,1);
        if (iNbCaracteresRecus == -1 && (*__errno_location ()) == 11)
        {
            if(iLnMessage != 0)
            {
                strServeur[iLnMessage] = '\0';
                printf("MinitelxDansRien : strServeur %s \n", strServeur);
                fcntl (iFdMinitel, 4, flags);
                if (strcmp ((char *)strServeur, "quitCRATYLE") == 0)
                {
                    printf ("On me dit aurevoir dans l'oreille....\n");
                    AfficherAurevoirCratyle(iFdMinitel);
                    STOP = 1;
                }
                else
                {
                    iLignesTexteMinitel = 1;
                    iCalculLignes = iLnMessage-1 + iLongueurPrefixe;
                    while(iCalculLignes-40 >= 0)
                    {
                        iCalculLignes = 40 - iCalculLignes;
                        printf("DISTANT:CalculLignes : %d\n", iCalculLignes);
                        iLignesTexteMinitel++;
                    }
                    printf("LOCAL:LignesTexteMinitel : %d -- CalculLignes %d\n", iLignesTexteMinitel, iCalculLignes);
                    LigneEnCours++;
                    if(LigneEnCours > 18)
                    {
                        LigneEnCours = 2;
                    }
                    MINITELCurseurXY(iFdMinitel, (LigneEnCours + 2), 1);
                    MINITELEnvoyerTexte(iFdMinitel, (unsigned char *)"-->");
                    MINITELChangerAttribut(iFdMinitel, 0x42);
                    for(k = 0; k < iLnMessage; k++)
                    {
                        if(iLignesTexteMinitel >= 2 && LigneEnCours+2 >= 18 && k+iLongueurPrefixe == 40)
                        {
                            LigneEnCours = 2;
                            MINITELCurseurXY(iFdMinitel, (LigneEnCours + 2), 1);
                            MINITELChangerAttribut(iFdMinitel, 0x42);
                            iLignesTexteMinitel = 1;
                        }
                        MINITELEnvoyerCaractere(iFdMinitel, strServeur[k]);
                    }
                    MINITELChangerAttribut(iFdMinitel, 0x47);
                    for(k = 0 ; k < 40 +iCalculLignes ; k++)
                        MINITELEnvoyerCaractere(iFdMinitel, ' ');
                    LigneEnCours += iLignesTexteMinitel-1;
                    if(LigneEnCours+3 < 18)
                    {
                        MINITELCurseurXY(iFdMinitel, (LigneEnCours + 3), 1);
                        for(k = 0; k < 40; k++)
                        {
                            MINITELEnvoyerCaractere(iFdMinitel, ' ');
                        }
                    }
                    AfficherAttenteCratyle(iFdMinitel);
                }
                iLnMessage = 0;
            }
        }
        else
        {
            strServeur[iLnMessage++] = buffer[0];
        }
     }
    return 0;
}

variable_types:
fdPipeOut
int *

variable_types:
fdPipeIn
int *

variable_types:
strPhilosophe
unsigned char *

variable_types: STOP int

variable_types:
LigneEnCours
unsigned char

variable_types: iLignesTexteMinitel int

variable_types: iLongueurPhilosophe int

variable_types: iLongueurPrefixe int

variable_types: iCalculLignes int

variable_types:
bufMinitel
char [255]

variable_types:
strServeur
unsigned char [255]

variable_types: iLnMessage int

variable_types: flags int

variable_types:
buffer
char [1]


TestImprime

repo: d-j-a-y/Cratyle

decompiled_code:
__int64 TestImprime()
{
unsigned int v0; // eax
unsigned int v1; // ebp
_QWORD *v2; // rbx
_BYTE v4[88]; // [rsp+0h] [rbp-58h] BYREF

v0 = OuvrirConnectionImprimante("/dev/ttyUSB3", v4);
v1 = v0;
if ( v0 == -1 )
{
perror("OuvrirConnectionImprim 1 failed!");
}
else
{
MINITELEnvoyerCaractere(v0, 12LL);
v2 = &CratyleDico;
do
{
CratyleImprime(*v2, v1);
usleep(0x61A8u);
v2 += 250;
}
while ( v2 != (_QWORD *)(unsigned int)((_DWORD)&CratyleDico + 1200000) );
if ( v1 )
{
FermerConnection(v1, v4);
v1 = 0;
}
}
return v1;
}

canonical_decompiled_code:
__int64 func0()
{
unsigned int v0; // eax
unsigned int v1; // ebp
_QWORD *v2; // rbx
_BYTE v4[88]; // [rsp+0h] [rbp-58h] BYREF

v0 = OuvrirConnectionImprimante("/dev/ttyUSB3", v4);
v1 = v0;
if ( v0 == -1 )
{
perror("OuvrirConnectionImprim 1 failed!");
}
else
{
MINITELEnvoyerCaractere(v0, 12LL);
v2 = &CratyleDico;
do
{
CratyleImprime(*v2, v1);
usleep(0x61A8u);
v2 += 250;
}
while ( v2 != (_QWORD *)(unsigned int)((_DWORD)&CratyleDico + 1200000) );
if ( v1 )
{
FermerConnection(v1, v4);
v1 = 0;
}
}
return v1;
}

original_code:
int TestImprime()
{
        int iFdImprim1Test = 0;
    struct termios oldtioImprim1Test;
        if((iFdImprim1Test = OuvrirConnectionImprimante("/dev/ttyUSB3", &oldtioImprim1Test)) == -1)
        {
            perror("OuvrirConnectionImprim 1 failed!");
            return -1;
        }
        MINITELEnvoyerCaractere(iFdImprim1Test, 0x0C);
        int i;
        for (i =0; i < 600 ; i++)
        {
          CratyleImprime(CratyleDico[i][0], iFdImprim1Test);
          usleep(25000);
        }
        if (iFdImprim1Test) FermerConnection(iFdImprim1Test, &oldtioImprim1Test );
        return 0;
}

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

variable_types: i int

return_type: int


TestOuverture

decompiled_code:
__int64 TestOuverture()
{
unsigned int v0; // ebx
unsigned int v1; // ebp
__int64 v3; // [rsp+0h] [rbp-98h] BYREF
char v4[88]; // [rsp+40h] [rbp-58h] BYREF

v0 = OuvrirConnectionMinitel("/dev/ttyUSB0", v4);
if ( v0 == -1 )
{
perror("OuvrirConnectionMinitel 1 failed!");
}
else
{
v1 = OuvrirConnectionMinitel("/dev/ttyUSB1", &v3);
if ( v1 == -1 )
{
perror("OuvrirConnectionMinitel 2 failed!");
v0 = -1;
}
else
{
printf("TestOuverture chat 1 %i \n", v0);
printf("TestOuverture chat 2 %i \n", v1);
AfficherAttenteCratyle(v0);
AfficherAttenteCratyle(v1);
v0 = 0;
}
}
return v0;
}

canonical_decompiled_code:
__int64 func1()
{
unsigned int v0; // ebx
unsigned int v1; // ebp
__int64 v3; // [rsp+0h] [rbp-98h] BYREF
char v4[88]; // [rsp+40h] [rbp-58h] BYREF

v0 = OuvrirConnectionMinitel("/dev/ttyUSB0", v4);
if ( v0 == -1 )
{
perror("OuvrirConnectionMinitel 1 failed!");
}
else
{
v1 = OuvrirConnectionMinitel("/dev/ttyUSB1", &v3);
if ( v1 == -1 )
{
perror("OuvrirConnectionMinitel 2 failed!");
v0 = -1;
}
else
{
printf("TestOuverture chat 1 %i \n", v0);
printf("TestOuverture chat 2 %i \n", v1);
AfficherAttenteCratyle(v0);
AfficherAttenteCratyle(v1);
v0 = 0;
}
}
return v0;
}

original_code:
int TestOuverture ()
{
            int fdMinitel1Modem;
            struct termios oldtioMinitel1;
            if((fdMinitel1Modem = OuvrirConnectionMinitel("/dev/ttyUSB0", &oldtioMinitel1)) == -1)
            {
                perror("OuvrirConnectionMinitel 1 failed!");
                return -1;
            }
                                 int fdMinitel2Modem;
                struct termios oldtioMinitel2;
                if((fdMinitel2Modem = OuvrirConnectionMinitel("/dev/ttyUSB1", &oldtioMinitel2)) == -1)
                {
                    perror("OuvrirConnectionMinitel 2 failed!");
                    return -1;
                }
    printf("TestOuverture chat 1 %i \n", fdMinitel1Modem);
    printf("TestOuverture chat 2 %i \n", fdMinitel2Modem);
AfficherAttenteCratyle(fdMinitel1Modem);
AfficherAttenteCratyle(fdMinitel2Modem);
return 0;
}

canonical_original_code:
int TestOuverture()
{
            int fdMinitel1Modem;
            struct termios oldtioMinitel1;
            if((fdMinitel1Modem = OuvrirConnectionMinitel("/dev/ttyUSB0", &oldtioMinitel1)) == -1)
            {
                perror("OuvrirConnectionMinitel 1 failed!");
                return -1;
            }
                                 int fdMinitel2Modem;
                struct termios oldtioMinitel2;
                if((fdMinitel2Modem = OuvrirConnectionMinitel("/dev/ttyUSB1", &oldtioMinitel2)) == -1)
                {
                    perror("OuvrirConnectionMinitel 2 failed!");
                    return -1;
                }
    printf("TestOuverture chat 1 %i \n", fdMinitel1Modem);
    printf("TestOuverture chat 2 %i \n", fdMinitel2Modem);
AfficherAttenteCratyle(fdMinitel1Modem);
AfficherAttenteCratyle(fdMinitel2Modem);
return 0;
}

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


TestSalopeDeCigale

decompiled_code:
int TestSalopeDeCigale()
{
int v0; // ebx
int result; // eax
__int64 v2[2]; // [rsp+0h] [rbp-208h] BYREF
char v3[232]; // [rsp+10h] [rbp-1F8h] BYREF
int v4; // [rsp+F8h] [rbp-110h]
__int16 v5; // [rsp+FCh] [rbp-10Ch]
char v6; // [rsp+FEh] [rbp-10Ah]
char v7[24]; // [rsp+100h] [rbp-108h] BYREF
__int64 v8; // [rsp+118h] [rbp-F0h]
char v9[216]; // [rsp+120h] [rbp-E8h] BYREF
int v10; // [rsp+1F8h] [rbp-10h]
__int16 v11; // [rsp+1FCh] [rbp-Ch]
char v12; // [rsp+1FEh] [rbp-Ah]

strcpy(v7, "salope de cigale");
v8 = 0LL;
memset(v9, 0, sizeof(v9));
v10 = 0;
v11 = 0;
v12 = 0;
v2[0] = 0LL;
v2[1] = 0LL;
memset(v3, 0, sizeof(v3));
v4 = 0;
v5 = 0;
v6 = 0;
v0 = 100;
do
{
Cratylation(v7, v2, 0LL);
result = printf("%s ", (const char *)v2);
--v0;
}
while ( v0 );
return result;
}

canonical_decompiled_code:
int func4()
{
int v0; // ebx
int result; // eax
__int64 v2[2]; // [rsp+0h] [rbp-208h] BYREF
char v3[232]; // [rsp+10h] [rbp-1F8h] BYREF
int v4; // [rsp+F8h] [rbp-110h]
__int16 v5; // [rsp+FCh] [rbp-10Ch]
char v6; // [rsp+FEh] [rbp-10Ah]
char v7[24]; // [rsp+100h] [rbp-108h] BYREF
__int64 v8; // [rsp+118h] [rbp-F0h]
char v9[216]; // [rsp+120h] [rbp-E8h] BYREF
int v10; // [rsp+1F8h] [rbp-10h]
__int16 v11; // [rsp+1FCh] [rbp-Ch]
char v12; // [rsp+1FEh] [rbp-Ah]

strcpy(v7, "salope de cigale");
v8 = 0LL;
memset(v9, 0, sizeof(v9));
v10 = 0;
v11 = 0;
v12 = 0;
v2[0] = 0LL;
v2[1] = 0LL;
memset(v3, 0, sizeof(v3));
v4 = 0;
v5 = 0;
v6 = 0;
v0 = 100;
do
{
Cratylation(v7, v2, 0LL);
result = printf("%s ", (const char *)v2);
--v0;
}
while ( v0 );
return result;
}

original_code:
void TestSalopeDeCigale ()
{
    char strSalopeDeCigale[255]= "salope de cigale", strCratyle[255]= "";
    int j;
    for (j = 0; j++ < 100;)
    {
        Cratylation(strSalopeDeCigale, strCratyle, 0);
        printf("%s ",strCratyle);
    }
}

canonical_original_code:
void TestSalopeDeCigale()
{
    char strSalopeDeCigale[255] = "salope de cigale"; char strCratyle[255] = "";
    int j;
    for (j = 0; j++ < 100;)
    {
        Cratylation(strSalopeDeCigale, strCratyle, 0);
        printf("%s ",strCratyle);
    }
}

variable_types:
strSalopeDeCigale
char [255]

variable_types:
strCratyle
char [255]

variable_types: j int

return_type: void


CratyleGenre

decompiled_code:
__int64 __fastcall CratyleGenre(char *s1)
{
const char **v1; // rbx
int v2; // ebp
const char *v3; // rsi
char v4; // al
unsigned int v5; // edx

v1 = (const char **)&CratyleBaseGenreNombre;
v2 = -1;
do
{
++v2;
v3 = *v1;
if ( !*v1 )
return 0;
v1 += 3;
}
while ( strcmp(s1, v3) );
v4 = **((_BYTE **)&CratyleBaseGenreNombre + 3 * v2 + 1);
v5 = 2;
if ( v4 != 77 )
{
v5 = 3;
if ( v4 != 78 )
v5 = v4 == 70;
}
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func1(char *s1)
{
const char **v1; // rbx
int v2; // ebp
const char *v3; // rsi
char v4; // al
unsigned int v5; // edx

v1 = (const char **)&CratyleBaseGenreNombre;
v2 = -1;
do
{
++v2;
v3 = *v1;
if ( !*v1 )
return 0;
v1 += 3;
}
while ( strcmp(s1, v3) );
v4 = **((_BYTE **)&CratyleBaseGenreNombre + 3 * v2 + 1);
v5 = 2;
if ( v4 != 77 )
{
v5 = 3;
if ( v4 != 78 )
v5 = v4 == 70;
}
return v5;
}

original_code:
genre CratyleGenre(const char* strMot)
{
    genre enumGenre = genre_indefinit;
    int iIndex = -1, iMotTrouve = -1;
    while((CratyleBaseGenreNombre[++iIndex][0] != '\0') && ((iMotTrouve = strcmp(strMot, CratyleBaseGenreNombre[iIndex][0])) != 0));
    if (iMotTrouve == 0)
    {
        switch (*CratyleBaseGenreNombre[iIndex][1])
        {
        case 'M' : enumGenre = masculin; break;
        case 'F' : enumGenre = feminin; break;
        case 'N' : enumGenre = neutre; break;
        }
    }
    return enumGenre;
}

canonical_original_code:
enum cratyle_genre CratyleGenre(char *strMot)
{
    enum cratyle_genre enumGenre = genre_indefinit;
    int iIndex = -1; int iMotTrouve = -1;
    while((CratyleBaseGenreNombre[++iIndex][0] != '\0') && ((iMotTrouve = strcmp(strMot, CratyleBaseGenreNombre[iIndex][0])) != 0));
    if (iMotTrouve == 0)
    {
        switch (*CratyleBaseGenreNombre[iIndex][1])
        {
        case 'M' : enumGenre = masculin; break;
        case 'F' : enumGenre = feminin; break;
        case 'N' : enumGenre = neutre; break;
        }
    }
    return enumGenre;
}

variable_types:
strMot
char *

variable_types: enum cratyle_genre { genre_indefinit=0, feminin=1, masculin=2, neutre=3 }

variable_types: iIndex int

variable_types: iMotTrouve int


CratyleNombre

decompiled_code:
__int64 __fastcall CratyleNombre(char *s1, int *a2)
{
const char **v2; // rbx
int v3; // eax
int v4; // ebp
char v5; // al
unsigned int v6; // edx

v2 = (const char **)CratyleBaseGenreNombre;
v3 = -1;
v4 = -1;
while ( 1 )
{
++v4;
if ( !*v2 )
break;
v3 = strcasecmp(s1, *v2);
v2 += 3;
if ( !v3 )
{
if ( !a2 )
{
v5 = *(_BYTE *)(CratyleBaseGenreNombre[3 * v4 + 1] + 1LL);
v6 = 2;
if ( v5 == 80 )
return v6;
LABEL_12:
v6 = 1;
if ( v5 != 83 )
v6 = 3 * (v5 == 73);
goto LABEL_14;
}
goto LABEL_8;
}
}
if ( !a2 )
goto LABEL_9;
LABEL_8:
*a2 = -1;
LABEL_9:
v6 = 0;
if ( v3 )
return v6;
v5 = *(_BYTE *)(CratyleBaseGenreNombre[3 * v4 + 1] + 1LL);
v6 = 2;
if ( v5 != 80 )
goto LABEL_12;
LABEL_14:
if ( a2 )
*a2 = v4;
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func3(char *s1, int *a2)
{
const char **v2; // rbx
int v3; // eax
int v4; // ebp
char v5; // al
unsigned int v6; // edx

v2 = (const char **)CratyleBaseGenreNombre;
v3 = -1;
v4 = -1;
while ( 1 )
{
++v4;
if ( !*v2 )
break;
v3 = strcasecmp(s1, *v2);
v2 += 3;
if ( !v3 )
{
if ( !a2 )
{
v5 = *(_BYTE *)(CratyleBaseGenreNombre[3 * v4 + 1] + 1LL);
v6 = 2;
if ( v5 == 80 )
return v6;
LABEL_12:
v6 = 1;
if ( v5 != 83 )
v6 = 3 * (v5 == 73);
goto LABEL_14;
}
goto LABEL_8;
}
}
if ( !a2 )
goto LABEL_9;
LABEL_8:
*a2 = -1;
LABEL_9:
v6 = 0;
if ( v3 )
return v6;
v5 = *(_BYTE *)(CratyleBaseGenreNombre[3 * v4 + 1] + 1LL);
v6 = 2;
if ( v5 != 80 )
goto LABEL_12;
LABEL_14:
if ( a2 )
*a2 = v4;
return v6;
}

original_code:
nombre CratyleNombre(const char* strMot, int* iBaseGenreNombreIndex)
{
    nombre enumNombre = nombre_indefinit;
    int iIndex = -1, iMotTrouve = -1;
    while((CratyleBaseGenreNombre[++iIndex][0] != '\0') && ((iMotTrouve = strcasecmp(strMot, CratyleBaseGenreNombre[iIndex][0])) != 0));
    if (iBaseGenreNombreIndex) *iBaseGenreNombreIndex = -1;
    if (iMotTrouve == 0)
    {
        switch (*(CratyleBaseGenreNombre[iIndex][1]+sizeof(char)))
        {
        case 'S' : enumNombre = singulier; break;
        case 'P' : enumNombre = pluriel; break;
        case 'I' : enumNombre = invariable; break;
        }
        if (iBaseGenreNombreIndex) *iBaseGenreNombreIndex = iIndex;
    }
    return enumNombre;
}

canonical_original_code:
enum cratyle_nombre CratyleNombre(char *strMot, int *iBaseGenreNombreIndex)
{
    enum cratyle_nombre enumNombre = nombre_indefinit;
    int iIndex = -1; int iMotTrouve = -1;
    while((CratyleBaseGenreNombre[++iIndex][0] != '\0') && ((iMotTrouve = strcasecmp(strMot, CratyleBaseGenreNombre[iIndex][0])) != 0));
    if (iBaseGenreNombreIndex) *iBaseGenreNombreIndex = -1;
    if (iMotTrouve == 0)
    {
        switch (*(CratyleBaseGenreNombre[iIndex][1]+sizeof(char)))
        {
        case 'S' : enumNombre = singulier; break;
        case 'P' : enumNombre = pluriel; break;
        case 'I' : enumNombre = invariable; break;
        }
        if (iBaseGenreNombreIndex) *iBaseGenreNombreIndex = iIndex;
    }
    return enumNombre;
}

variable_types:
iBaseGenreNombreIndex
int *

variable_types: enum cratyle_nombre { nombre_indefinit=0, singulier=1, pluriel=2, invariable=3 }


CratyleMotSingulier

decompiled_code:
void *__fastcall CratyleMotSingulier(int a1)
{
const char *v1; // rbp
void *v2; // rbx
size_t v3; // rax
char *v4; // rax

if ( a1 == -1 )
return 0LL;
v1 = (const char *)CratyleBaseGenreNombre[3 * a1 + 2];
v2 = (void *)v1;
if ( v1 )
{
v3 = strlen((const char *)CratyleBaseGenreNombre[3 * a1 + 2]);
v4 = (char *)malloc(v3);
v2 = v4;
if ( v4 )
strcpy(v4, v1);
}
return v2;
}

canonical_decompiled_code:
void *__fastcall func5(int a1)
{
const char *v1; // rbp
void *v2; // rbx
size_t v3; // rax
char *v4; // rax

if ( a1 == -1 )
return 0LL;
v1 = (const char *)CratyleBaseGenreNombre[3 * a1 + 2];
v2 = (void *)v1;
if ( v1 )
{
v3 = strlen((const char *)CratyleBaseGenreNombre[3 * a1 + 2]);
v4 = (char *)malloc(v3);
v2 = v4;
if ( v4 )
strcpy(v4, v1);
}
return v2;
}

original_code:
char * CratyleMotSingulier(int iBaseGenreNombreIndex)
{
    char* strMotAuSingulier = ((void *)0);
    if (iBaseGenreNombreIndex == -1 )
        return ((void *)0);
    if (CratyleBaseGenreNombre[iBaseGenreNombreIndex][2] != 0)
    {
        strMotAuSingulier = malloc(strlen(CratyleBaseGenreNombre[iBaseGenreNombreIndex][2])*sizeof(char));
        if (strMotAuSingulier != ((void *)0)) strcpy(strMotAuSingulier, CratyleBaseGenreNombre[iBaseGenreNombreIndex][2]);
    }
    return strMotAuSingulier;
}

canonical_original_code:
char *CratyleMotSingulier(int iBaseGenreNombreIndex)
{
    char *strMotAuSingulier = ((void *)0);
    if (iBaseGenreNombreIndex == -1 )
        return ((void *)0);
    if (CratyleBaseGenreNombre[iBaseGenreNombreIndex][2] != 0)
    {
        strMotAuSingulier = malloc(strlen(CratyleBaseGenreNombre[iBaseGenreNombreIndex][2])*sizeof(char));
        if (strMotAuSingulier != ((void *)0)) strcpy(strMotAuSingulier, CratyleBaseGenreNombre[iBaseGenreNombreIndex][2]);
    }
    return strMotAuSingulier;
}

variable_types: iBaseGenreNombreIndex int

variable_types:
strMotAuSingulier
char *

return_type: char *


CratyleMotPluriel

decompiled_code:
const char *__fastcall CratyleMotPluriel(char *s1)
{
const char **v1; // rbp
int v2; // ebx
int v3; // er12
const char *v4; // r14
int v5; // eax
int v6; // er12
const char *v7; // rbx
size_t v8; // rax
char *v9; // rax

v1 = (const char **)CratyleBaseGenreNombre;
v2 = -1;
while ( 1 )
{
v3 = v2++;
v4 = *v1;
if ( !*v1 )
break;
v5 = strcmp(s1, *v1);
v1 += 3;
if ( !v5 )
{
v6 = v3 + 2;
v4 = 0LL;
if ( *(_BYTE *)(CratyleBaseGenreNombre[3 * v6 + 1] + 1LL) == 80 )
{
v4 = (const char *)CratyleBaseGenreNombre[3 * v6 + 2];
if ( v4 )
{
v4 = 0LL;
if ( !strcmp(s1, (const char *)CratyleBaseGenreNombre[3 * v6 + 2]) )
{
v7 = (const char *)CratyleBaseGenreNombre[3 * v6];
v8 = strlen(v7);
v9 = (char *)malloc(v8);
v4 = v9;
if ( v9 )
strcpy(v9, v7);
}
}
}
return v4;
}
}
return v4;
}

canonical_decompiled_code:
const char *__fastcall func6(char *s1)
{
const char **v1; // rbp
int v2; // ebx
int v3; // er12
const char *v4; // r14
int v5; // eax
int v6; // er12
const char *v7; // rbx
size_t v8; // rax
char *v9; // rax

v1 = (const char **)CratyleBaseGenreNombre;
v2 = -1;
while ( 1 )
{
v3 = v2++;
v4 = *v1;
if ( !*v1 )
break;
v5 = strcmp(s1, *v1);
v1 += 3;
if ( !v5 )
{
v6 = v3 + 2;
v4 = 0LL;
if ( *(_BYTE *)(CratyleBaseGenreNombre[3 * v6 + 1] + 1LL) == 80 )
{
v4 = (const char *)CratyleBaseGenreNombre[3 * v6 + 2];
if ( v4 )
{
v4 = 0LL;
if ( !strcmp(s1, (const char *)CratyleBaseGenreNombre[3 * v6 + 2]) )
{
v7 = (const char *)CratyleBaseGenreNombre[3 * v6];
v8 = strlen(v7);
v9 = (char *)malloc(v8);
v4 = v9;
if ( v9 )
strcpy(v9, v7);
}
}
}
return v4;
}
}
return v4;
}

original_code:
char* CratyleMotPluriel(const char* strMot)
{
    char* strMotPluriel = ((void *)0);
    int iIndex = -1, iMotTrouve = -1;
    while((CratyleBaseGenreNombre[++iIndex][0] != '\0') && ((iMotTrouve = strcmp(strMot, CratyleBaseGenreNombre[iIndex][0])) != 0));
    if (iMotTrouve == 0)
    {
        if ( ( *(CratyleBaseGenreNombre[iIndex+1][1]+sizeof(char)) == 'P' ) )
        {
            if(CratyleBaseGenreNombre[iIndex+1][2] != 0)
            {
                if (strcmp (strMot,CratyleBaseGenreNombre[iIndex+1][2]) == 0)
                {
                    strMotPluriel = malloc(strlen(CratyleBaseGenreNombre[iIndex+1][0])*sizeof(char));
                    if (strMotPluriel != ((void *)0)) strcpy(strMotPluriel, CratyleBaseGenreNombre[iIndex+1][0]);
                }
            }
        }
    }
    return strMotPluriel;
}

canonical_original_code:
char *CratyleMotPluriel(char *strMot)
{
    char *strMotPluriel = ((void *)0);
    int iIndex = -1; int iMotTrouve = -1;
    while((CratyleBaseGenreNombre[++iIndex][0] != '\0') && ((iMotTrouve = strcmp(strMot, CratyleBaseGenreNombre[iIndex][0])) != 0));
    if (iMotTrouve == 0)
    {
        if ( ( *(CratyleBaseGenreNombre[iIndex+1][1]+sizeof(char)) == 'P' ) )
        {
            if(CratyleBaseGenreNombre[iIndex+1][2] != 0)
            {
                if (strcmp (strMot,CratyleBaseGenreNombre[iIndex+1][2]) == 0)
                {
                    strMotPluriel = malloc(strlen(CratyleBaseGenreNombre[iIndex+1][0])*sizeof(char));
                    if (strMotPluriel != ((void *)0)) strcpy(strMotPluriel, CratyleBaseGenreNombre[iIndex+1][0]);
                }
            }
        }
    }
    return strMotPluriel;
}

variable_types:
strMotPluriel
char *


CratyleImprime

decompiled_code:
__int64 __fastcall CratyleImprime(const char *a1, unsigned int a2)
{
int v2; // eax

if ( !a1 )
return 0xFFFFFFFFLL;
if ( !a2 )
return 0xFFFFFFFFLL;
v2 = iCaracteresImprime_0 + strlen(a1) + 1;
if ( v2 > 1920 )
{
iCaracteresImprime_0 = 0;
MINITELEnvoyerCaractere(a2, 12LL);
}
else
{
iCaracteresImprime_0 = v2;
}
printf("CratyleImprime %s - nb : %d\n", a1, (unsigned int)iCaracteresImprime_0);
MINITELEnvoyerTexte(a2, a1);
MINITELEnvoyerTexte(a2, " ");
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(const char *a1, unsigned int a2)
{
int v2; // eax

if ( !a1 )
return 0xFFFFFFFFLL;
if ( !a2 )
return 0xFFFFFFFFLL;
v2 = iCaracteresImprime_0 + strlen(a1) + 1;
if ( v2 > 1920 )
{
iCaracteresImprime_0 = 0;
MINITELEnvoyerCaractere(a2, 12LL);
}
else
{
iCaracteresImprime_0 = v2;
}
printf("CratyleImprime %s - nb : %d\n", a1, (unsigned int)iCaracteresImprime_0);
MINITELEnvoyerTexte(a2, a1);
MINITELEnvoyerTexte(a2, " ");
return 0LL;
}

original_code:
int CratyleImprime (char * strMot, int iFileDescriptor)
{
    static int iCaracteresImprime = 0;
    if (!strMot || !iFileDescriptor) return -1;
    iCaracteresImprime = iCaracteresImprime + strlen(strMot) + 1;
    if(iCaracteresImprime > 1920 )
    {
        iCaracteresImprime = 0;
        MINITELEnvoyerCaractere(iFileDescriptor, 0x0C);
    }
    printf("CratyleImprime %s - nb : %d\n", strMot, iCaracteresImprime);
 MINITELEnvoyerTexte(iFileDescriptor, (const unsigned char*)strMot);
    MINITELEnvoyerTexte(iFileDescriptor, (const unsigned char*)" ");
    return 0;
}

canonical_original_code:
int CratyleImprime(char *strMot, int iFileDescriptor)
{
    static int iCaracteresImprime = 0;
    if (!strMot || !iFileDescriptor) return -1;
    iCaracteresImprime = iCaracteresImprime + strlen(strMot) + 1;
    if(iCaracteresImprime > 1920 )
    {
        iCaracteresImprime = 0;
        MINITELEnvoyerCaractere(iFileDescriptor, 0x0C);
    }
    printf("CratyleImprime %s - nb : %d\n", strMot, iCaracteresImprime);
 MINITELEnvoyerTexte(iFileDescriptor, (unsigned char *)strMot);
    MINITELEnvoyerTexte(iFileDescriptor, (unsigned char *)" ");
    return 0;
}

variable_types: iFileDescriptor int

variable_types: iCaracteresImprime int


CratyleInit

decompiled_code:
void CratyleInit()
{
__int64 v0; // rdx
__int64 v1; // rsi
__int64 v2; // rax
int v3; // ecx
int v4; // ecx
__int64 v5; // rax

if ( CratyleDico )
{
v0 = 0LL;
v1 = 1LL;
do
{
v2 = -1LL;
do
v3 = v2++;
while ( *(_QWORD *)((char *)&CratyleDico + 8 * v2 + v0) );
*((_DWORD *)&CratyleIndex + v1 - 1) = v3;
v4 = v1;
v5 = *(_QWORD *)((char *)&CratyleDico + v0 + 2000);
++v1;
v0 += 2000LL;
}
while ( v5 );
}
else
{
v4 = 0;
}
CratyleDicoIndex = v4;
}

canonical_decompiled_code:
void func8()
{
__int64 v0; // rdx
__int64 v1; // rsi
__int64 v2; // rax
int v3; // ecx
int v4; // ecx
__int64 v5; // rax

if ( CratyleDico )
{
v0 = 0LL;
v1 = 1LL;
do
{
v2 = -1LL;
do
v3 = v2++;
while ( *(_QWORD *)((char *)&CratyleDico + 8 * v2 + v0) );
*((_DWORD *)&CratyleIndex + v1 - 1) = v3;
v4 = v1;
v5 = *(_QWORD *)((char *)&CratyleDico + v0 + 2000);
++v1;
v0 += 2000LL;
}
while ( v5 );
}
else
{
v4 = 0;
}
CratyleDicoIndex = v4;
}

original_code:
void CratyleInit()
{
    int iMot = -1, iSyno = -1;
        while((CratyleDico[++iMot][0] != '\0') )
        {
            while ((CratyleDico[iMot][++iSyno]) != '\0');
            CratyleIndex[iMot] = iSyno-1;
            iSyno=-1;
        }
        CratyleDicoIndex = iMot;
}

canonical_original_code:
void CratyleInit()
{
    int iMot = -1; int iSyno = -1;
        while((CratyleDico[++iMot][0] != '\0') )
        {
            while ((CratyleDico[iMot][++iSyno]) != '\0');
            CratyleIndex[iMot] = iSyno-1;
            iSyno=-1;
        }
        CratyleDicoIndex = iMot;
}

variable_types: iMot int

variable_types: iSyno int


CratyleCase

decompiled_code:
size_t __fastcall CratyleCase(char *s, _DWORD *a2, _DWORD *a3)
{
const unsigned __int16 **v4; // rbp
size_t result; // rax

*a2 = 0;
*a3 = 0;
v4 = _ctype_b_loc();
if ( ((*v4)[*s] & 0x200) == 0 )
*a2 = 1;
result = strlen(s);
if ( result > 1 )
{
result = (size_t)*v4;
if ( ((*v4)[s[1]] & 0x200) == 0 )
*a3 = 1;
}
return result;
}

canonical_decompiled_code:
size_t __fastcall func9(char *s, _DWORD *a2, _DWORD *a3)
{
const unsigned __int16 **v4; // rbp
size_t result; // rax

*a2 = 0;
*a3 = 0;
v4 = _ctype_b_loc();
if ( ((*v4)[*s] & 0x200) == 0 )
*a2 = 1;
result = strlen(s);
if ( result > 1 )
{
result = (size_t)*v4;
if ( ((*v4)[s[1]] & 0x200) == 0 )
*a3 = 1;
}
return result;
}

original_code:
void CratyleCase(char * strMot, int *PremiereLettre,int *FauxTout)
{
    *PremiereLettre = 0;
    *FauxTout = 0;
    if (!((*__ctype_b_loc ())[(int) ((strMot[0]))] & (unsigned short int) _ISlower))
        *PremiereLettre = 1;
    if(strlen(strMot) > 1 && !((*__ctype_b_loc ())[(int) ((strMot[1]))] & (unsigned short int) _ISlower))
        *FauxTout = 1;
}

canonical_original_code:
void CratyleCase(char *strMot, int *PremiereLettre, int *FauxTout)
{
    *PremiereLettre = 0;
    *FauxTout = 0;
    if (!((*__ctype_b_loc ())[(int) ((strMot[0]))] & (unsigned short) _ISlower))
        *PremiereLettre = 1;
    if(strlen(strMot) > 1 && !((*__ctype_b_loc ())[(int) ((strMot[1]))] & (unsigned short) _ISlower))
        *FauxTout = 1;
}

variable_types:
PremiereLettre
int *

variable_types:
FauxTout
int *


covertToUpper

decompiled_code:
char *__fastcall covertToUpper(const char *a1)
{
char *v1; // rbx
const __int32_t *v2; // rcx
char *v3; // rax
__int32_t v4; // edx

v1 = strdup(a1);
v2 = *_ctype_toupper_loc();
v3 = v1;
do
{
v4 = v2[*v3++];
*(v3 - 1) = v4;
}
while ( (_BYTE)v4 );
return v1;
}

canonical_decompiled_code:
char *__fastcall func10(const char *a1)
{
char *v1; // rbx
const __int32_t *v2; // rcx
char *v3; // rax
__int32_t v4; // edx

v1 = strdup(a1);
v2 = *_ctype_toupper_loc();
v3 = v1;
do
{
v4 = v2[*v3++];
*(v3 - 1) = v4;
}
while ( (_BYTE)v4 );
return v1;
}

original_code:
char *covertToUpper(const char *str)
{
    char *newstr, *p;
    p = newstr = strdup(str);
    while(*p++=toupper(*p));
    return newstr;
}

canonical_original_code:
char *covertToUpper(char *str)
{
    char *newstr; char *p;
    p = newstr = strdup(str);
    while(*p++=toupper(*p));
    return newstr;
}

variable_types:
str
char *

variable_types:
newstr
char *

variable_types:
p
char *


main

canonical_name: main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
struct timespec tp; // [rsp+0h] [rbp-20h] BYREF
pthread_t newthread; // [rsp+10h] [rbp-10h] BYREF
int v5; // [rsp+1Ch] [rbp-4h]

fd = open("/dev/midi1", 1, envp);
pthread_create(&newthread, 0LL, getTap, 0LL);
while ( 1 )
{
v5 = 0;
pthread_mutex_lock(&mutex);
do
{
if ( bTap == 1 )
break;
clock_gettime(0, &tp);
tp.tv_sec += period_ns / 1000000000;
tp.tv_nsec += period_ns % 1000000000;
if ( tp.tv_nsec > 1000000000 )
{
++tp.tv_sec;
tp.tv_nsec -= 1000000000LL;
}
v5 = pthread_cond_timedwait(&cond, &mutex, &tp);
}
while ( v5 != 110 );
tick();
bTap = 0;
pthread_mutex_unlock(&mutex);
}
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
struct timespec tp; // [rsp+0h] [rbp-20h] BYREF
pthread_t newthread; // [rsp+10h] [rbp-10h] BYREF
int v5; // [rsp+1Ch] [rbp-4h]

fd = open("/dev/midi1", 1, envp);
pthread_create(&newthread, 0LL, getTap, 0LL);
while ( 1 )
{
v5 = 0;
pthread_mutex_lock(&mutex);
do
{
if ( bTap == 1 )
break;
clock_gettime(0, &tp);
tp.tv_sec += period_ns / 1000000000;
tp.tv_nsec += period_ns % 1000000000;
if ( tp.tv_nsec > 1000000000 )
{
++tp.tv_sec;
tp.tv_nsec -= 1000000000LL;
}
v5 = pthread_cond_timedwait(&cond, &mutex, &tp);
}
while ( v5 != 110 );
func7();
bTap = 0;
pthread_mutex_unlock(&mutex);
}
}

original_code:
int main(int argc, char *argv[]) {
  int my_private_data = 12;
  struct ukorg_callbacks my_callbacks = {
    on_tick,
    on_prog_msg
  };
  ukorg_register_listener(&my_callbacks,&my_private_data);
  ukorg_start();
  getchar();
  return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: struct ukorg_callbacks { void (*on_tick)(void *); void (*on_prog_msg)(struct _ProgMsg { char name[12]; char pad1[2]; char trigger; char pattern; char voiceMode; char scale; char pad2; char delaySync; char delayTime; char delayDepth; char delayType; char modLfoSpeed; char modDepth; char modType; char eqHiFreq; char eqHiGain; char eqLoFreq; char eqLoGain; char arpTempo[2]; char arpOnOff; char arpType; char arpGateTime; char arpResolution; char arpSwing; char kbdOctave; union { struct _LayeredParams { struct _SynthParams { char midiChannel; char assignMode; char unisonDetune; char pitchTune; char pitchBendRange; char pitchBendTranspose; char pitchVibratoInt; char osc1Wave; char osc1WaveformCtrl1; char osc1WaveformCtrl2; char osc1DgwsWave; char pad1; char osc2Wave; char osc2Semitone; char osc2Tune; char portamentoTime; char osc1Level; char osc2Level; char noiseLevel; char filterType; char filterCutoff; char filterResonance; char filterEg1Int; char filterVelocitySense; char filterKbdTrack; char ampLevel; char ampPanpot; char ampDistortion; char ampVelocitySense; char ampKeyboardTrack; char eg1Attack; char eg1Decay; char eg1Sustain; char eg1Release; char eg2Attack; char eg2Decay; char eg2Sustain; char eg2Release; char lfo1Wave; char lfo1Freq; char lfo1Sync; char lfo2Wave; char lfo2Freq; char lfo2Sync; char patch1SrcDst; char patch1Int; char patch2SrcDst; char patch2Int; char patch3SrcDst; char patch3Int; char patch4SrcDst; char patch4Int; char pad2[56]; } timbre[2]; } synths; struct _VocoderParams {  } vocoder; } params; } *, void *); }

user_defined_types: struct ukorg_callbacks { void (*on_tick)(void *); void (*on_prog_msg)(struct _ProgMsg *, void *); }

user_defined_types: struct _ProgMsg { char name[12]; char pad1[2]; char trigger; char pattern; char voiceMode; char scale; char pad2; char delaySync; char delayTime; char delayDepth; char delayType; char modLfoSpeed; char modDepth; char modType; char eqHiFreq; char eqHiGain; char eqLoFreq; char eqLoGain; char arpTempo[2]; char arpOnOff; char arpType; char arpGateTime; char arpResolution; char arpSwing; char kbdOctave; union { struct _LayeredParams synths; struct _VocoderParams vocoder; } params; }

user_defined_types: struct _LayeredParams { struct _SynthParams timbre[2]; }


decompiled_code:
int __fastcall nuevo_evento(void *ptr)
{
FILE *v1; // rax

v1 = fopen("eventos.dat", "ab");
file = v1;
if ( !v1 )
return puts("error: no se pudo abrir el archivo");
fwrite(ptr, 0xBCuLL, 1uLL, v1);
fclose(file);
return printf("Evento #%d creado exitosamente!\n", *(unsigned int *)ptr);
}

canonical_decompiled_code:
int __fastcall func0(void *ptr)
{
FILE *v1; // rax

v1 = fopen("eventos.dat", "ab");
file = v1;
if ( !v1 )
return puts("error: no se pudo abrir el archivo");
fwrite(ptr, 0xBCuLL, 1uLL, v1);
fclose(file);
return printf("Evento #%d creado exitosamente!\n", *(unsigned int *)ptr);
}

original_code:
void nuevo_evento(evento * ptr_evento)
{
 file = fopen("eventos.dat", "ab");
 if(file == ((void *)0)) printf("error: no se pudo abrir el archivo\n");
 else
 {
  fwrite(ptr_evento, sizeof(evento), 1, file);
  fclose(file);
  printf("Evento #%d creado exitosamente!\n", ptr_evento->id);
 }
}

canonical_original_code:
void nuevo_evento(struct _evento *ptr_evento)
{
 file = fopen("eventos.dat", "ab");
 if(file == ((void *)0)) printf("error: no se pudo abrir el archivo\n");
 else
 {
  fwrite(ptr_evento, sizeof(evento), 1, file);
  fclose(file);
  printf("Evento #%d creado exitosamente!\n", ptr_evento->id);
 }
}

variable_types: struct _evento { int id; char titl[60]; char desc[120]; int estado; } *


decompiled_code:
void mostrar_evento()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
void mostrar_evento(evento * ptr_evento)
{
}

canonical_original_code:
void mostrar_evento(struct _evento *ptr_evento)
{
}

user_defined_types: struct _evento { int id; char titl[60]; char desc[120]; int estado; }


decompiled_code:
void eliminar_evento()
{
;
}

canonical_decompiled_code:
void func2()
{
;
}

original_code:
void eliminar_evento(evento * ptr_evento)
{
}

canonical_original_code:
void eliminar_evento(struct _evento *ptr_evento)
{
}


decompiled_code:
void modificar_evento()
{
;
}

canonical_decompiled_code:
void func3()
{
;
}

original_code:
void modificar_evento(evento * ptr_evento)
{
}

canonical_original_code:
void modificar_evento(struct _evento *ptr_evento)
{
}


decompiled_code:
void concretar_evento()
{
;
}

canonical_decompiled_code:
void func4()
{
;
}

original_code:
void concretar_evento(evento * ptr_evento)
{
}

canonical_original_code:
void concretar_evento(struct _evento *ptr_evento)
{
}


decompiled_code:
void listar_eventos()
{
;
}

canonical_decompiled_code:
void func5()
{
;
}

original_code:
void listar_eventos()
{
}

canonical_original_code:
void listar_eventos()
{
}


decompiled_code:
void vaciar_eventos()
{
;
}

canonical_decompiled_code:
void func6()
{
;
}

original_code:
void vaciar_eventos()
{
}

canonical_original_code:
void vaciar_eventos()
{
}


repo: dagit/Cyclone-Language

decompiled_code:
void term_reset_stats()
{
term_stats[0] = 0;
term_stats[1] = 0;
term_stats[2] = 0;
}

canonical_decompiled_code:
void func0()
{
term_stats[0] = 0;
term_stats[1] = 0;
term_stats[2] = 0;
}

original_code:
static void term_reset_stats(void)
{
  term_stats.fresh = 0;
  term_stats.fresh_small = 0;
  term_stats.fresh_large = 0;
}

canonical_original_code:
static void term_reset_stats()
{
  term_stats.fresh = 0;
  term_stats.fresh_small = 0;
  term_stats.fresh_large = 0;
}


decompiled_code:
__int64 __fastcall term_fresh(__int64 a1)
{
++term_stats[0];
return tv_fresh(term_sort_region, a1);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
++term_stats[0];
return tv_fresh(term_sort_region, a1);
}

original_code:
gen_e term_fresh(const char *name)
{
  term_stats.fresh++;
  return (gen_e)tv_fresh(term_sort_region,name);
}

canonical_original_code:
struct gen_e_ *term_fresh(char *name)
{
  term_stats.fresh++;
  return (struct gen_e_ *)tv_fresh(term_sort_region,name);
}

variable_types:
name
char *

return_type: struct gen_e_ { enum sort_kind { flowrow_sort=0, setif_sort=1, setst_sort=2, term_sort=3 } sort; } *


decompiled_code:
__int64 __fastcall term_fresh_large(__int64 a1)
{
++term_stats[2];
return tv_fresh_large(term_sort_region, a1);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
++term_stats[2];
return tv_fresh_large(term_sort_region, a1);
}

original_code:
gen_e term_fresh_large(const char *name)
{
  term_stats.fresh_large++;
  return (gen_e)tv_fresh_large(term_sort_region,name);
}

canonical_original_code:
struct gen_e_ *term_fresh_large(char *name)
{
  term_stats.fresh_large++;
  return (struct gen_e_ *)tv_fresh_large(term_sort_region,name);
}

user_defined_types: enum sort_kind { flowrow_sort=0, setif_sort=1, setst_sort=2, term_sort=3 }


decompiled_code:
__int64 __fastcall term_fresh_small(__int64 a1)
{
++term_stats[1];
return tv_fresh_small(term_sort_region, a1);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
++term_stats[1];
return tv_fresh_small(term_sort_region, a1);
}

original_code:
gen_e term_fresh_small(const char *name)
{
  term_stats.fresh_small++;
  return (gen_e)tv_fresh_small(term_sort_region,name);
}

canonical_original_code:
struct gen_e_ *term_fresh_small(char *name)
{
  term_stats.fresh_small++;
  return (struct gen_e_ *)tv_fresh_small(term_sort_region,name);
}


decompiled_code:
void *term_zero()
{
return &zero;
}

canonical_decompiled_code:
void *func5()
{
return &zero;
}

original_code:
gen_e term_zero(void)
{
  return (gen_e)&zero;
}

canonical_original_code:
struct gen_e_ *term_zero()
{
  return (gen_e)&zero;
}


decompiled_code:
void *term_one()
{
return &one;
}

canonical_decompiled_code:
void *func6()
{
return &one;
}

original_code:
gen_e term_one(void)
{
  return (gen_e)&one;
}

canonical_original_code:
struct gen_e_ *term_one()
{
  return (gen_e)&one;
}


decompiled_code:
void *term_wild()
{
return &wild;
}

canonical_decompiled_code:
void *func7()
{
return &wild;
}

original_code:
gen_e term_wild(void)
{
  return (gen_e)&wild;
}

canonical_original_code:
struct gen_e_ *term_wild()
{
  return (gen_e)&wild;
}


decompiled_code:
__int64 __fastcall term_constant(__int64 a1)
{
__int64 v1; // rbp
__int64 v2; // rbx
int v4[8]; // [rsp+8h] [rbp-20h] BYREF

v1 = _rc_rstrdup(banshee_nonptr_region, a1);
v4[0] = 4;
v4[1] = stamp_string(v1);
v2 = term_hash_find(term_sort_hash, v4, 2LL);
if ( !v2 )
{
v2 = _rc_ralloc_small0(term_constant_region, 16LL);
*(_DWORD *)v2 = 4;
*(_DWORD *)(v2 + 4) = stamp_fresh();
*(_QWORD *)(v2 + 8) = v1;
term_hash_insert(term_sort_hash, v2, v4, 2LL);
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
__int64 v1; // rbp
__int64 v2; // rbx
int v4[8]; // [rsp+8h] [rbp-20h] BYREF

v1 = _rc_rstrdup(banshee_nonptr_region, a1);
v4[0] = 4;
v4[1] = stamp_string(v1);
v2 = term_hash_find(term_sort_hash, v4, 2LL);
if ( !v2 )
{
v2 = _rc_ralloc_small0(term_constant_region, 16LL);
*(_DWORD *)v2 = 4;
*(_DWORD *)(v2 + 4) = stamp_fresh();
*(_QWORD *)(v2 + 8) = v1;
term_hash_insert(term_sort_hash, v2, v4, 2LL);
}
return v2;
}

original_code:
gen_e term_constant(const char *str)
{
  stamp st[2];
  gen_e result;
  char *name = (((void)0), __rc_rstrdup)(banshee_nonptr_region,str);
  ((void) (0));
  st[0] = 4;
  st[1] = stamp_string(name);
  if ( (result = term_hash_find(term_sort_hash,st,2)) == ((void *)0))
    {
      term_constant_ c = (sizeof(struct term_constant_) < (1 << (13 - 3)) ? (((void)0), __rc_ralloc_small0)((term_constant_region), sizeof(struct term_constant_)) : (((void)0), __rc_typed_ralloc)((term_constant_region), sizeof(struct term_constant_), 0));
      c->type = 4;
      c->st = stamp_fresh();
      c->name = name;
      result = (gen_e) c;
      term_hash_insert(term_sort_hash,result,st,2);
      return result;
    }
  else
    {
      return result;
    }
}

canonical_original_code:
struct gen_e_ *term_constant(char *str)
{
  int st[2];
  struct gen_e_ *result;
  char *name = (((void)0), __rc_rstrdup)(banshee_nonptr_region,str);
  ((void) (0));
  st[0] = 4;
  st[1] = stamp_string(name);
  if ( (result = term_hash_find(term_sort_hash,st,2)) == ((void *)0))
    {
      struct term_constant_ *c = (sizeof(struct term_constant_) < (1 << (13 - 3)) ? (((void)0), __rc_ralloc_small0)((term_constant_region), sizeof(struct term_constant_)) : (((void)0), __rc_typed_ralloc)((term_constant_region), sizeof(struct term_constant_), 0));
      c->type = 4;
      c->st = stamp_fresh();
      c->name = name;
      result = (struct gen_e_ *) c;
      term_hash_insert(term_sort_hash,result,st,2);
      return result;
    }
  else
    {
      return result;
    }
}

variable_types:
st
int [2]

variable_types: struct gen_e_ { enum sort_kind { flowrow_sort=0, setif_sort=1, setst_sort=2, term_sort=3 } sort; } *

variable_types: struct term_constant_ { enum sort_kind { flowrow_sort=0, setif_sort=1, setst_sort=2, term_sort=3 } sort; int type; int st; char *name; } *

user_defined_types: struct term_constant_ { enum sort_kind sort; int type; int st; char *name; }


decompiled_code:
bool __fastcall term_is_initial_var(_DWORD *a1)
{
return *a1 == -1;
}

canonical_decompiled_code:
bool __fastcall func9(_DWORD *a1)
{
return *a1 == -1;
}

original_code:
bool term_is_initial_var(gen_e e)
{
  return ((gen_term)e)->type == -1;
}

canonical_original_code:
unsigned char term_is_initial_var(struct gen_e_ *e)
{
  return ((struct gen_term *)e)->type == -1;
}

return_type: unsigned char

user_defined_types: struct gen_term { enum sort_kind sort; int type; int st; }


decompiled_code:
__int64 __fastcall term_get_stamp(_DWORD *a1)
{
__int64 result; // rax

if ( *a1 == -1 )
result = *(unsigned int *)(term_get_ecr(a1) + 4);
else
result = (unsigned int)a1[1];
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(_DWORD *a1)
{
__int64 result; // rax

if ( *a1 == -1 )
result = *(unsigned int *)(func10(a1) + 4);
else
result = (unsigned int)a1[1];
return result;
}

original_code:
stamp term_get_stamp(gen_e e)
{
  if ( ((gen_term)e)->type == -1 )
    return ((gen_term)term_get_ecr(e))->st;
  else
    return ((gen_term)e)->st;
}

canonical_original_code:
int term_get_stamp(struct gen_e_ *e)
{
  if ( ((struct gen_term *)e)->type == -1 )
    return ((struct gen_term *)term_get_ecr(e))->st;
  else
    return ((struct gen_term *)e)->st;
}


decompiled_code:
bool __fastcall term_is_zero(_DWORD *a1)
{
return *(_DWORD *)term_get_ecr(a1) == 0;
}

canonical_decompiled_code:
bool __fastcall func13(_DWORD *a1)
{
return *(_DWORD *)func10(a1) == 0;
}

original_code:
bool term_is_zero(gen_e e)
{
  return ( ((gen_term)term_get_ecr(e))->type == 0);
}

canonical_original_code:
unsigned char term_is_zero(struct gen_e_ *e)
{
  return ( ((struct gen_term *)term_get_ecr(e))->type == 0);
}


decompiled_code:
bool __fastcall term_is_wild(_DWORD *a1)
{
return *(_DWORD *)term_get_ecr(a1) == 6;
}

canonical_decompiled_code:
bool __fastcall func14(_DWORD *a1)
{
return *(_DWORD *)func10(a1) == 6;
}

original_code:
bool term_is_wild(gen_e e)
{
  return ( ((gen_term)term_get_ecr(e))->type == 6);
}

canonical_original_code:
unsigned char term_is_wild(struct gen_e_ *e)
{
  return ( ((struct gen_term *)term_get_ecr(e))->type == 6);
}


decompiled_code:
bool __fastcall term_is_one(_DWORD *a1)
{
return *(_DWORD *)term_get_ecr(a1) == 1;
}

canonical_decompiled_code:
bool __fastcall func15(_DWORD *a1)
{
return *(_DWORD *)func10(a1) == 1;
}

original_code:
bool term_is_one(gen_e e)
{
  return ( ((gen_term)term_get_ecr(e))->type == 1);
}

canonical_original_code:
unsigned char term_is_one(struct gen_e_ *e)
{
  return ( ((struct gen_term *)term_get_ecr(e))->type == 1);
}


decompiled_code:
bool __fastcall term_is_var(_DWORD *a1)
{
return *(_DWORD *)term_get_ecr(a1) == -1;
}

canonical_decompiled_code:
bool __fastcall func16(_DWORD *a1)
{
return *(_DWORD *)func10(a1) == -1;
}

original_code:
bool term_is_var(gen_e e)
{
  return ( ((gen_term)term_get_ecr(e))->type == -1);
}

canonical_original_code:
unsigned char term_is_var(struct gen_e_ *e)
{
  return ( ((struct gen_term *)term_get_ecr(e))->type == -1);
}


decompiled_code:
_BOOL8 __fastcall term_is_bottom(_DWORD *a1)
{
bool v1; // dl
_BOOL8 result; // rax

v1 = term_is_zero(a1);
result = 1LL;
if ( !v1 )
result = term_is_var(a1);
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func17(_DWORD *a1)
{
bool v1; // dl
_BOOL8 result; // rax

v1 = func13(a1);
result = 1LL;
if ( !v1 )
result = func16(a1);
return result;
}

original_code:
static bool term_is_bottom(gen_e e)
{
  return (term_is_zero(e) || term_is_var(e));
}

canonical_original_code:
static unsigned char term_is_bottom(struct gen_e_ *e)
{
  return (term_is_zero(e) || term_is_var(e));
}


decompiled_code:
bool __fastcall term_is_constant(_DWORD *a1)
{
return *(_DWORD *)term_get_ecr(a1) == 4;
}

canonical_decompiled_code:
bool __fastcall func18(_DWORD *a1)
{
return *(_DWORD *)func10(a1) == 4;
}

original_code:
bool term_is_constant(gen_e e)
{
  return ( ((gen_term)term_get_ecr(e))->type == 4);
}

canonical_original_code:
unsigned char term_is_constant(struct gen_e_ *e)
{
  return ( ((struct gen_term *)term_get_ecr(e))->type == 4);
}


decompiled_code:
__int64 __fastcall term_get_constant_name(_DWORD *a1)
{
__int64 v1; // rbx
bool v2; // dl
__int64 result; // rax

v1 = term_get_ecr(a1);
v2 = term_is_constant((_DWORD *)v1);
result = 0LL;
if ( v2 )
result = *(_QWORD *)(v1 + 8);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func19(_DWORD *a1)
{
__int64 v1; // rbx
bool v2; // dl
__int64 result; // rax

v1 = func10(a1);
v2 = func18((_DWORD *)v1);
result = 0LL;
if ( v2 )
result = *(_QWORD *)(v1 + 8);
return result;
}

original_code:
char *term_get_constant_name(gen_e e)
{
  gen_e ecr = term_get_ecr(e);
  if(! term_is_constant(ecr))
    return ((void *)0);
  else
    return ((term_constant_)ecr)->name;
}

canonical_original_code:
char *term_get_constant_name(struct gen_e_ *e)
{
  struct gen_e_ *ecr = term_get_ecr(e);
  if(! term_is_constant(ecr))
    return ((void *)0);
  else
    return ((struct term_constant_ *)ecr)->name;
}


decompiled_code:
bool __fastcall term_eq(_DWORD *a1, _DWORD *a2)
{
return eq(a1, a2);
}

canonical_decompiled_code:
bool __fastcall func20(_DWORD *a1, _DWORD *a2)
{
return func12(a1, a2);
}

original_code:
bool term_eq(gen_e e1, gen_e e2)
{
  return eq(e1,e2);
}

canonical_original_code:
unsigned char term_eq(struct gen_e_ *e1, struct gen_e_ *e2)
{
  return eq(e1,e2);
}


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

term_rollback_info_region = newregion();
term_constant_region = newregion();
term_var_region = newregion();
term_sort_region = newregion();
result = make_term_hash(0LL);
term_sort_hash = result;
return result;
}

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

term_rollback_info_region = newregion();
term_constant_region = newregion();
term_var_region = newregion();
term_sort_region = newregion();
result = make_term_hash(0LL);
term_sort_hash = result;
return result;
}

original_code:
void term_init(void)
{
  term_rollback_info_region = newregion();
  term_constant_region = newregion();
  term_var_region = newregion();
  term_sort_region = newregion();
  term_sort_hash = make_term_hash(((void *)0));
}

canonical_original_code:
void term_init()
{
  term_rollback_info_region = newregion();
  term_constant_region = newregion();
  term_var_region = newregion();
  term_sort_region = newregion();
  term_sort_hash = make_term_hash(((void *)0));
}


decompiled_code:
__int64 term_reset()
{
term_hash_delete(term_sort_hash);
deleteregion(term_sort_region);
deleteregion(term_var_region);
deleteregion(term_constant_region);
deleteregion(term_rollback_info_region);
term_reset_stats();
return term_init();
}

canonical_decompiled_code:
__int64 func28()
{
term_hash_delete(term_sort_hash);
deleteregion(term_sort_region);
deleteregion(term_var_region);
deleteregion(term_constant_region);
deleteregion(term_rollback_info_region);
func0();
return func27();
}

original_code:
void term_reset(void)
{
  term_hash_delete(term_sort_hash);
  deleteregion(term_sort_region);
  deleteregion(term_var_region);
  deleteregion(term_constant_region);
  deleteregion(term_rollback_info_region);
  term_reset_stats();
  term_init();
}

canonical_original_code:
void term_reset()
{
  term_hash_delete(term_sort_hash);
  deleteregion(term_sort_region);
  deleteregion(term_var_region);
  deleteregion(term_constant_region);
  deleteregion(term_rollback_info_region);
  term_reset_stats();
  term_init();
}


decompiled_code:
__int64 term_set_fields()
{
return deserialize_set_obj(&term_current_rollback_info);
}

canonical_decompiled_code:
__int64 func37()
{
return deserialize_set_obj(&term_current_rollback_info);
}

original_code:
void term_set_fields(void)
{
  deserialize_set_obj((void **)&term_current_rollback_info);
}

canonical_original_code:
void term_set_fields()
{
  deserialize_set_obj((void **)&term_current_rollback_info);
}


eq

decompiled_code:
bool __fastcall eq(_DWORD *a1, _DWORD *a2)
{
int v2; // ebx

v2 = term_get_stamp(a1);
return v2 == (unsigned int)term_get_stamp(a2);
}

canonical_decompiled_code:
bool __fastcall func12(_DWORD *a1, _DWORD *a2)
{
int v2; // ebx

v2 = func11(a1);
return v2 == (unsigned int)func11(a2);
}

original_code:
static bool eq(gen_e e1, gen_e e2)
{
  return term_get_stamp(e1) == term_get_stamp(e2);
}

canonical_original_code:
static unsigned char eq(struct gen_e_ *e1, struct gen_e_ *e2)
{
  return term_get_stamp(e1) == term_get_stamp(e2);
}


decompiled_code:
__int64 __fastcall check2(int a1)
{
if ( a1 <= 0x1FFFFFFF )
return (unsigned int)a1;
_fail("stamp.c", 64LL, "check2", "Unable to create a stamp with regular index\n");
return check1();
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
if ( a1 <= 0x1FFFFFFF )
return (unsigned int)a1;
_fail("stamp.c", 64LL, "check2", "Unable to create a stamp with regular index\n");
return func1();
}

original_code:
static inline stamp check2(int i)
{
  if (i > bounds2)
    __fail("stamp.c", 64, __FUNCTION__, "Unable to create a stamp with regular index\n");
  return i;
}

canonical_original_code:
static inline int check2(int i)
{
  if (i > bounds2)
    __fail("stamp.c", 64, __FUNCTION__, "Unable to create a stamp with regular index\n");
  return i;
}

variable_types: i int


decompiled_code:
__int64 __fastcall check1(unsigned int a1)
{
if ( a1 != 0x80000000 )
return a1;
_fail("stamp.c", 57LL, "check1", "Unable to create stamp with small index\n");
return check3();
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int a1)
{
if ( a1 != 0x80000000 )
return a1;
_fail("stamp.c", 57LL, "check1", "Unable to create stamp with small index\n");
return func2();
}

original_code:
static inline stamp check1(int i)
{
  if (i <= bounds1)
    __fail("stamp.c", 57, __FUNCTION__, "Unable to create stamp with small index\n");
  return i;
}

canonical_original_code:
static inline int check1(int i)
{
  if (i <= bounds1)
    __fail("stamp.c", 57, __FUNCTION__, "Unable to create stamp with small index\n");
  return i;
}


decompiled_code:
__int64 __fastcall check3(unsigned int a1)
{
if ( a1 != 0x7FFFFFFF )
return a1;
_fail("stamp.c", 71LL, "check3", "Unable to create a stamp with large index\n");
return new_stamp_list();
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1)
{
if ( a1 != 0x7FFFFFFF )
return a1;
_fail("stamp.c", 71LL, "check3", "Unable to create a stamp with large index\n");
return func3();
}

original_code:
static inline stamp check3(int i)
{
  if (i >= bounds3)
    __fail("stamp.c", 71, __FUNCTION__, "Unable to create a stamp with large index\n");
  return i;
}

canonical_original_code:
static inline int check3(int i)
{
  if (i >= bounds3)
    __fail("stamp.c", 71, __FUNCTION__, "Unable to create a stamp with large index\n");
  return i;
}


decompiled_code:
__int64 stamp_fresh()
{
return check2(++count2);
}

canonical_decompiled_code:
__int64 func31()
{
return func0(++count2);
}

original_code:
stamp stamp_fresh(void)
{
  return (check2(++count2));
}

canonical_original_code:
int stamp_fresh()
{
  return (check2(++count2));
}


decompiled_code:
__int64 stamp_fresh_small()
{
return check1(--count1);
}

canonical_decompiled_code:
__int64 func32()
{
return func1(--count1);
}

original_code:
stamp stamp_fresh_small(void)
{
  return (check1(--count1));
}

canonical_original_code:
int stamp_fresh_small()
{
  return (check1(--count1));
}


decompiled_code:
__int64 stamp_fresh_large()
{
return check3(++count3);
}

canonical_decompiled_code:
__int64 func33()
{
return func2(++count3);
}

original_code:
stamp stamp_fresh_large(void)
{
  return (check3(++count3));
}

canonical_original_code:
int stamp_fresh_large()
{
  return (check3(++count3));
}


decompiled_code:
__int64 __fastcall stamp_string(__int64 a1)
{
unsigned int v2[3]; // [rsp+Ch] [rbp-Ch] BYREF

if ( !(unsigned __int8)hash_table_lookup(str_hash, a1, v2) )
{
v2[0] = stamp_fresh();
hash_table_insert(str_hash, a1, (int)v2[0]);
}
return v2[0];
}

canonical_decompiled_code:
__int64 __fastcall func34(__int64 a1)
{
unsigned int v2[3]; // [rsp+Ch] [rbp-Ch] BYREF

if ( !(unsigned __int8)hash_table_lookup(str_hash, a1, v2) )
{
v2[0] = func31();
hash_table_insert(str_hash, a1, (int)v2[0]);
}
return v2[0];
}

original_code:
stamp stamp_string(const char *str)
{
  int st;
  ((void) (0));
  if (! hash_table_lookup(str_hash,(hash_key)str, (hash_data *) &st))
    {
      st = stamp_fresh();
      (void)hash_table_insert(str_hash,(hash_key)str,(hash_data) st);
    }
  return st;
}

canonical_original_code:
int stamp_string(char *str)
{
  int st;
  ((void) (0));
  if (! hash_table_lookup(str_hash,(void *)str, (void **) &st))
    {
      st = stamp_fresh();
      (void)hash_table_insert(str_hash,(void *)str,(void *) st);
    }
  return st;
}

variable_types: st int


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

count1 = 0;
count2 = 2000;
count3 = 0x1FFFFFFF;
result = make_persistent_string_hash_table(32LL, 0LL);
str_hash = result;
return result;
}

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

count1 = 0;
count2 = 2000;
count3 = 0x1FFFFFFF;
result = make_persistent_string_hash_table(32LL, 0LL);
str_hash = result;
return result;
}

original_code:
void stamp_init(void)
{
  count1 = 0;
  count2 = 2000;
  count3 = 536870911;
  str_hash = make_persistent_string_hash_table(32,
            0);
}

canonical_original_code:
void stamp_init()
{
  count1 = 0;
  count2 = 2000;
  count3 = 536870911;
  str_hash = make_persistent_string_hash_table(32,
            0);
}


decompiled_code:
__int64 stamp_reset()
{
return stamp_init();
}

canonical_decompiled_code:
__int64 func36()
{
return func35();
}

original_code:
void stamp_reset(void)
{
  stamp_init();
}

canonical_original_code:
void stamp_reset()
{
  stamp_init();
}


decompiled_code:
__int64 stamp_set_fields()
{
return deserialize_set_obj(&str_hash);
}

canonical_decompiled_code:
__int64 func40()
{
return deserialize_set_obj(&str_hash);
}

original_code:
void stamp_set_fields(void)
{
  deserialize_set_obj((void **)&str_hash);
}

canonical_original_code:
void stamp_set_fields()
{
  deserialize_set_obj((void **)&str_hash);
}


original_code:
unsigned long stamp_hash(hash_key key)
{
  unsigned long keyval = (unsigned long)key;
  keyval += (keyval << 12);
  keyval ^= (keyval >> 22);
  keyval += (keyval << 4);
  keyval ^= (keyval >> 9);
  keyval += (keyval << 10);
  keyval ^= (keyval >> 2);
  keyval += (keyval << 7);
  keyval ^= (keyval >> 12);
  return keyval;
}

canonical_original_code:
unsigned long stamp_hash(void *key)
{
  unsigned long keyval = (unsigned long)key;
  keyval += (keyval << 12);
  keyval ^= (keyval >> 22);
  keyval += (keyval << 4);
  keyval ^= (keyval >> 9);
  keyval += (keyval << 10);
  keyval ^= (keyval >> 2);
  keyval += (keyval << 7);
  keyval ^= (keyval >> 12);
  return keyval;
}

variable_types:
key
void *

variable_types:
keyval
unsigned long

return_type: unsigned long


decompiled_code:
bool __fastcall stamp_eq(__int64 a1, __int64 a2)
{
return a2 == a1;
}

canonical_decompiled_code:
bool __fastcall func44(__int64 a1, __int64 a2)
{
return a2 == a1;
}

original_code:
bool stamp_eq(hash_key s1, hash_key s2)
{
  return s1 == s2;
}

canonical_original_code:
unsigned char stamp_eq(void *s1, void *s2)
{
  return s1 == s2;
}


blowup

decompiled_code:
void __fastcall __noreturn blowup(char a1)
{
if ( (a1 & 1) != 0 )
longjmp(Lo_exception, 1);
longjmp(Hi_exception, 1);
}

canonical_decompiled_code:
void __fastcall __noreturn func7(char a1)
{
if ( (a1 & 1) != 0 )
longjmp(Lo_exception, 1);
longjmp(Hi_exception, 1);
}

original_code:
void blowup (int n) {
    if (n & 1) {
 longjmp(Lo_exception, 1);
    } else {
 longjmp(Hi_exception, 1);
    }
}

canonical_original_code:
void blowup(int n) {
    if (n & 1) {
 longjmp(Lo_exception, 1);
    } else {
 longjmp(Hi_exception, 1);
    }
}

variable_types: n int


decompiled_code:
int __fastcall lo_function(char a1)
{
int result; // eax

result = _setjmp(Lo_exception);
if ( !result )
blowup(a1);
++LO;
return result;
}

canonical_decompiled_code:
int __fastcall func8(char a1)
{
int result; // eax

result = _setjmp(Lo_exception);
if ( !result )
func7(a1);
++LO;
return result;
}

original_code:
void lo_function (volatile int n) {
    if (_setjmp (Lo_exception) != 0) {
 LO++;
    } else {
 blowup(n);
    }
}

canonical_original_code:
void lo_function(int n) {
    if (_setjmp (Lo_exception) != 0) {
 LO++;
    } else {
 blowup(n);
    }
}


decompiled_code:
int __fastcall hi_function(char a1)
{
int result; // eax

result = _setjmp(Hi_exception);
if ( !result )
return lo_function(a1);
++HI;
return result;
}

canonical_decompiled_code:
int __fastcall func9(char a1)
{
int result; // eax

result = _setjmp(Hi_exception);
if ( !result )
return func8(a1);
++HI;
return result;
}

original_code:
void hi_function (volatile int n) {
    if (_setjmp (Hi_exception) != 0) {
 HI++;
    } else {
 lo_function(n);
    }
}

canonical_original_code:
void hi_function(int n) {
    if (_setjmp (Hi_exception) != 0) {
 HI++;
    } else {
 lo_function(n);
    }
}


decompiled_code:
int __fastcall some_function(char a1)
{
return hi_function(a1);
}

canonical_decompiled_code:
int __fastcall func10(char a1)
{
return func9(a1);
}

original_code:
void some_function (int n) {
    hi_function(n);
}

canonical_original_code:
void some_function(int n) {
    hi_function(n);
}


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // eax
char v4; // di
__time_t v5; // rsi
struct timeval v7; // [rsp+0h] [rbp-38h] BYREF
struct timeval tv; // [rsp+10h] [rbp-28h] BYREF
int v9; // [rsp+2Ch] [rbp-Ch]

v3 = 1;
if ( argc == 2 )
v3 = atoi(argv[1]);
v9 = v3;
v7.tv_sec = 0LL;
v7.tv_usec = 0LL;
tv.tv_sec = 0LL;
tv.tv_usec = 0LL;
gettimeofday(&v7, 0LL);
while ( v9 )
{
v4 = v9--;
some_function(v4);
}
printf("Exceptions: HI=%d / LO=%d\n", (unsigned int)HI, (unsigned int)LO);
gettimeofday(&tv, 0LL);
v5 = tv.tv_sec - v7.tv_sec;
v7.tv_sec = tv.tv_sec - v7.tv_sec;
if ( tv.tv_usec - v7.tv_usec < 0 )
{
v7.tv_usec = tv.tv_usec - v7.tv_usec + 1000000;
v7.tv_sec = v5 - 1;
}
else
{
v7.tv_usec = tv.tv_usec - v7.tv_usec;
}
fprintf(_bss_start, "%d.%06d\n", v7.tv_sec, v7.tv_usec);
fflush(_bss_start);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // eax
char v4; // di
__time_t v5; // rsi
struct timeval v7; // [rsp+0h] [rbp-38h] BYREF
struct timeval tv; // [rsp+10h] [rbp-28h] BYREF
int v9; // [rsp+2Ch] [rbp-Ch]

v3 = 1;
if ( argc == 2 )
v3 = atoi(argv[1]);
v9 = v3;
v7.tv_sec = 0LL;
v7.tv_usec = 0LL;
tv.tv_sec = 0LL;
tv.tv_usec = 0LL;
gettimeofday(&v7, 0LL);
while ( v9 )
{
v4 = v9--;
func10(v4);
}
printf("Exceptions: HI=%d / LO=%d\n", (unsigned int)HI, (unsigned int)LO);
gettimeofday(&tv, 0LL);
v5 = tv.tv_sec - v7.tv_sec;
v7.tv_sec = tv.tv_sec - v7.tv_sec;
if ( tv.tv_usec - v7.tv_usec < 0 )
{
v7.tv_usec = tv.tv_usec - v7.tv_usec + 1000000;
v7.tv_sec = v5 - 1;
}
else
{
v7.tv_usec = tv.tv_usec - v7.tv_usec;
}
fprintf(_bss_start, "%d.%06d\n", v7.tv_sec, v7.tv_usec);
fflush(_bss_start);
return 0;
}

original_code:
int
main(int argc, char *argv[]) {
    int volatile N = ((argc == 2) ? atoi(argv[1]) : 1);
    { struct timeval __start = { 0, 0 }; struct timeval __end = { 0, 0 }; gettimeofday(&__start,((void *)0));
    while (N) {
 some_function(N--);
    }
    printf("Exceptions: HI=%d / LO=%d\n", HI, LO);
    gettimeofday(&__end,((void *)0)); __start.tv_sec = __end.tv_sec - __start.tv_sec; __start.tv_usec = __end.tv_usec - __start.tv_usec; if(__start.tv_usec < 0) { __start.tv_usec += 1000000; __start.tv_sec --; } fprintf(stderr, "%d.%06d\n",__start.tv_sec, __start.tv_usec); fflush(stderr); }
    return(0);
}

canonical_original_code:
int main(int argc, char *argv[]) {
    int N = ((argc == 2) ? atoi(argv[1]) : 1);
    { struct timeval __start = { 0, 0 }; struct timeval __end = { 0, 0 }; gettimeofday(&__start,((void *)0));
    while (N) {
 some_function(N--);
    }
    printf("Exceptions: HI=%d / LO=%d\n", HI, LO);
    gettimeofday(&__end,((void *)0)); __start.tv_sec = __end.tv_sec - __start.tv_sec; __start.tv_usec = __end.tv_usec - __start.tv_usec; if(__start.tv_usec < 0) { __start.tv_usec += 1000000; __start.tv_sec --; } fprintf(stderr, "%d.%06d\n",__start.tv_sec, __start.tv_usec); fflush(stderr); }
    return(0);
}

variable_types: N int

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


hash

decompiled_code:
__int64 __fastcall hash(int a1, __int64 a2, int a3)
{
__int64 v3; // r8
__int64 v4; // rdx
unsigned int v5; // er9

if ( a3 <= 0 )
return 0;
v3 = (unsigned int)a3;
v4 = 0LL;
v5 = 0;
do
{
v5 = a1 & (v5 + primes[(int)v4 % 15] * abs32(*(_DWORD *)(a2 + 4 * v4)));
++v4;
}
while ( v4 != v3 );
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, __int64 a2, int a3)
{
__int64 v3; // r8
__int64 v4; // rdx
unsigned int v5; // er9

if ( a3 <= 0 )
return 0;
v3 = (unsigned int)a3;
v4 = 0LL;
v5 = 0;
do
{
v5 = a1 & (v5 + primes[(int)v4 % 15] * abs32(*(_DWORD *)(a2 + 4 * v4)));
++v4;
}
while ( v4 != v3 );
return v5;
}

original_code:
static int hash(int ub, stamp stamps[], int len)
{
  int i, n;
  n = 0;
  for (i = 0; i < len; i++)
    {
      n = (n + (primes[i % 15] * abs(stamps[i]))) & ub;
    }
  return n;
}

canonical_original_code:
static int hash(int ub, int stamps[], int len)
{
  int i; int n;
  n = 0;
  for (i = 0; i < len; i++)
    {
      n = (n + (primes[i % 15] * abs(stamps[i]))) & ub;
    }
  return n;
}

variable_types: ub int

variable_types:
stamps
int []

variable_types: len int


rehash

original_code:
static void rehash(hash_set hs)
{
  int *old_table;
  int old_capacity, i;
  old_table = hs->table;
  old_capacity = hs->capacity;
  hs->capacity *= 2;
  hs->ub = ((1<<++hs->size)-1);
  hs->table = (int *)calloc(hs->capacity, sizeof(int));
  ((void) (0));
  for (i = 0; i < old_capacity; i++)
    {
      reinsert(hs->table, hs->ub, old_table[i]);
    }
  free(old_table);
}

canonical_original_code:
static void rehash(struct hash_set *hs)
{
  int *old_table;
  int old_capacity; int i;
  old_table = hs->table;
  old_capacity = hs->capacity;
  hs->capacity *= 2;
  hs->ub = ((1<<++hs->size)-1);
  hs->table = (int *)calloc(hs->capacity, sizeof(int));
  ((void) (0));
  for (i = 0; i < old_capacity; i++)
    {
      reinsert(hs->table, hs->ub, old_table[i]);
    }
  free(old_table);
}

variable_types: struct hash_set { int *table; unsigned int ub; unsigned int capacity; unsigned int inserts; unsigned int size; } *


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

result = (unsigned int)(*(_DWORD *)(a1 + 28) + 1);
*(_DWORD *)(a1 + 28) = result;
if ( *(_DWORD *)(a1 + 24) == (_DWORD)result )
result = rehash(a1);
return result;
}

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

result = (unsigned int)(*(_DWORD *)(a1 + 28) + 1);
*(_DWORD *)(a1 + 28) = result;
if ( *(_DWORD *)(a1 + 24) == (_DWORD)result )
result = func1(a1);
return result;
}

original_code:
static void post_insert(hash_set hs)
{
  int capacity = hs->capacity;
  int inserts = ++hs->inserts;
  float percent_capacity = capacity * .85;
  if ( (float) inserts >= percent_capacity)
    {
      rehash(hs);
    }
}

canonical_original_code:
static void post_insert(struct hash_set *hs)
{
  int capacity = hs->capacity;
  int inserts = ++hs->inserts;
  float percent_capacity = capacity * .85;
  if ( (float) inserts >= percent_capacity)
    {
      rehash(hs);
    }
}

variable_types: capacity int

variable_types: inserts int

user_defined_types: struct hash_set { int *table; unsigned int ub; unsigned int capacity; unsigned int inserts; unsigned int size; }


walk

decompiled_code:
const void ***__fastcall walk(const void ***a1, const void *a2, int a3)
{
const void ***v3; // rbx
size_t v5; // r14
const void **v6; // rbp

v3 = a1;
if ( a1 )
{
v5 = 4LL * a3;
while ( 1 )
{
v6 = *v3;
if ( *(_DWORD *)*v3 == a3 && !memcmp(a2, v6[1], v5) )
break;
v3 = (const void ***)v3[1];
if ( !v3 )
return v3;
}
v3 = (const void ***)v6[2];
}
return v3;
}

canonical_decompiled_code:
const void ***__fastcall func3(const void ***a1, const void *a2, int a3)
{
const void ***v3; // rbx
size_t v5; // r14
const void **v6; // rbp

v3 = a1;
if ( a1 )
{
v5 = 4LL * a3;
while ( 1 )
{
v6 = *v3;
if ( *(_DWORD *)*v3 == a3 && !memcmp(a2, v6[1], v5) )
break;
v3 = (const void ***)v3[1];
if ( !v3 )
return v3;
}
v3 = (const void ***)v6[2];
}
return v3;
}

original_code:
static gen_e walk(term_bucket b, stamp stamps[], int len)
{
  term_bucket cur;
  for(cur = b; cur; cur = cur->next)
    {
      if (len == cur->entry->length
   && (memcmp(stamps, cur->entry->stamps, sizeof(int)*len) == 0) )
 return cur->entry->e;
    }
  return ((void *)0);
}

canonical_original_code:
static struct gen_e_ *walk(struct term_bucket *b, int stamps[], int len)
{
  struct term_bucket *cur;
  for(cur = b; cur; cur = cur->next)
    {
      if (len == cur->entry->length
   && (memcmp(stamps, cur->entry->stamps, sizeof(int)*len) == 0) )
 return cur->entry->e;
    }
  return ((void *)0);
}

variable_types: struct term_bucket { struct hash_entry { int length; int *stamps; struct gen_e_ *e; } *entry; struct term_bucket *next; } *

variable_types: struct term_bucket { struct hash_entry { int length; int *stamps; struct gen_e_ { enum sort_kind { flowrow_sort=0, setif_sort=1, setst_sort=2, term_sort=3 } sort; } *e; } *entry; struct term_bucket *next; } *

user_defined_types: struct term_bucket { struct hash_entry *entry; struct term_bucket *next; }


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

term_bucketptr_region = newregion();
term_bucket_region = newregion();
term_hash_region = newregion();
result = newregion();
hash_entry_region = result;
return result;
}

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

term_bucketptr_region = newregion();
term_bucket_region = newregion();
term_hash_region = newregion();
result = newregion();
hash_entry_region = result;
return result;
}

original_code:
void term_hash_init()
{
  term_bucketptr_region = newregion();
  term_bucket_region = newregion();
  term_hash_region = newregion();
  hash_entry_region = newregion();
}


decompiled_code:
__int64 term_hash_reset()
{
deleteregion(term_bucketptr_region);
deleteregion(term_bucket_region);
deleteregion(term_hash_region);
deleteregion(hash_entry_region);
return term_hash_init();
}

canonical_decompiled_code:
__int64 func12()
{
deleteregion(term_bucketptr_region);
deleteregion(term_bucket_region);
deleteregion(term_hash_region);
deleteregion(hash_entry_region);
return func11();
}

original_code:
void term_hash_reset()
{
  deleteregion(term_bucketptr_region);
  deleteregion(term_bucket_region);
  deleteregion(term_hash_region);
  deleteregion(hash_entry_region);
  term_hash_init();
}


startoutputingbits

decompiled_code:
void startoutputingbits()
{
S_buffer = 0;
S_bitstogo = 8;
}

canonical_decompiled_code:
void func2()
{
S_buffer = 0;
S_bitstogo = 8;
}


startinputingbits

decompiled_code:
void startinputingbits()
{
S_buffer = 0;
S_bitstogo = 0;
}

canonical_decompiled_code:
void func3()
{
S_buffer = 0;
S_bitstogo = 0;
}


doneoutputingbits

decompiled_code:
int doneoutputingbits()
{
int result; // eax

if ( S_bitstogo <= 7 )
{
result = putc(S_buffer >> S_bitstogo, stdout);
++cmpbytes;
}
return result;
}

canonical_decompiled_code:
int func4()
{
int result; // eax

if ( S_bitstogo <= 7 )
{
result = putc(S_buffer >> S_bitstogo, stdout);
++cmpbytes;
}
return result;
}

original_code:
void
doneoutputingbits()
{
 if (S_bitstogo<8)
 {
  putc(S_buffer>>S_bitstogo, stdout);
  cmpbytes += 1;
 }
}


startencoding

decompiled_code:
void startencoding()
{
S_low = 0LL;
S_high = 0xFFFFLL;
S_bitstofollow = 0LL;
}

canonical_decompiled_code:
void func5()
{
S_low = 0LL;
S_high = 0xFFFFLL;
S_bitstofollow = 0LL;
}

original_code:
void
startencoding()
{
 S_low = 0;
 S_high = ((codevalue)((1<<16)-1));
 S_bitstofollow = 0;
}


startdecoding

decompiled_code:
__int64 __fastcall startdecoding()
{
__int64 result; // rax
int v1; // edx
int v2; // ebx

S_low = 0LL;
S_high = 0xFFFFLL;
S_value = 0LL;
v1 = S_bitstogo;
v2 = 16;
do
{
if ( !v1 )
{
LODWORD(result) = getc(stdin);
v1 = 8;
}
S_value = (result & 1) + 2 * S_value;
result = (unsigned int)((int)result >> 1);
--v1;
--v2;
}
while ( v2 );
S_bitstogo = v1;
S_buffer = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6()
{
__int64 result; // rax
int v1; // edx
int v2; // ebx

S_low = 0LL;
S_high = 0xFFFFLL;
S_value = 0LL;
v1 = S_bitstogo;
v2 = 16;
do
{
if ( !v1 )
{
LODWORD(result) = getc(stdin);
v1 = 8;
}
S_value = (result & 1) + 2 * S_value;
result = (unsigned int)((int)result >> 1);
--v1;
--v2;
}
while ( v2 );
S_bitstogo = v1;
S_buffer = result;
return result;
}

original_code:
void
startdecoding()
{
 register int i;
 register int buffer, bitstogo;
 S_low = 0;
 S_high = ((codevalue)((1<<16)-1));
 S_value = 0;
 bitstogo = S_bitstogo;
 for (i=0; i<16; i++)
  { if (bitstogo==0) { buffer = getc(stdin); bitstogo = 8; } S_value = (S_value<<1)+(buffer&1); buffer >>= 1; bitstogo -=1; };
 S_bitstogo = bitstogo;
 S_buffer = buffer;
}

canonical_original_code:
void startdecoding()
{
 register int i;
 register int buffer; register int bitstogo;
 S_low = 0;
 S_high = ((codevalue)((1<<16)-1));
 S_value = 0;
 bitstogo = S_bitstogo;
 for (i=0; i<16; i++)
  { if (bitstogo==0) { buffer = getc(stdin); bitstogo = 8; } S_value = (S_value<<1)+(buffer&1); buffer >>= 1; bitstogo -=1; };
 S_bitstogo = bitstogo;
 S_buffer = buffer;
}

variable_types: buffer int

variable_types: bitstogo int


doneencoding

decompiled_code:
__int64 doneencoding()
{
__int64 v0; // rbp
int v1; // ebx
__int64 result; // rax

v0 = S_bitstofollow + 1;
if ( (unsigned __int64)S_low > 0x3FFF )
{
v1 = S_buffer >> 1;
LOBYTE(v1) = (S_buffer >> 1) | 0x80;
result = (unsigned int)(S_bitstogo - 1);
if ( S_bitstogo == 1 )
{
putc(v1, stdout);
++cmpbytes;
result = 8LL;
}
for ( ; v0; --v0 )
{
v1 >>= 1;
result = (unsigned int)(result - 1);
if ( !(_DWORD)result )
{
putc(v1, stdout);
++cmpbytes;
result = 8LL;
}
}
}
else
{
v1 = S_buffer >> 1;
result = (unsigned int)(S_bitstogo - 1);
if ( S_bitstogo == 1 )
{
putc(v1, stdout);
++cmpbytes;
result = 8LL;
}
for ( ; v0; --v0 )
{
v1 >>= 1;
LOBYTE(v1) = v1 | 0x80;
result = (unsigned int)(result - 1);
if ( !(_DWORD)result )
{
putc(v1, stdout);
++cmpbytes;
result = 8LL;
}
}
}
S_bitstofollow = 0LL;
S_buffer = v1;
S_bitstogo = result;
return result;
}

canonical_decompiled_code:
__int64 func7()
{
__int64 v0; // rbp
int v1; // ebx
__int64 result; // rax

v0 = S_bitstofollow + 1;
if ( (unsigned __int64)S_low > 0x3FFF )
{
v1 = S_buffer >> 1;
LOBYTE(v1) = (S_buffer >> 1) | 0x80;
result = (unsigned int)(S_bitstogo - 1);
if ( S_bitstogo == 1 )
{
putc(v1, stdout);
++cmpbytes;
result = 8LL;
}
for ( ; v0; --v0 )
{
v1 >>= 1;
result = (unsigned int)(result - 1);
if ( !(_DWORD)result )
{
putc(v1, stdout);
++cmpbytes;
result = 8LL;
}
}
}
else
{
v1 = S_buffer >> 1;
result = (unsigned int)(S_bitstogo - 1);
if ( S_bitstogo == 1 )
{
putc(v1, stdout);
++cmpbytes;
result = 8LL;
}
for ( ; v0; --v0 )
{
v1 >>= 1;
LOBYTE(v1) = v1 | 0x80;
result = (unsigned int)(result - 1);
if ( !(_DWORD)result )
{
putc(v1, stdout);
++cmpbytes;
result = 8LL;
}
}
}
S_bitstofollow = 0LL;
S_buffer = v1;
S_bitstogo = result;
return result;
}

original_code:
void
doneencoding()
{
 register long bitstofollow;
 register int buffer, bitstogo;
 bitstofollow = S_bitstofollow;
 buffer = S_buffer;
 bitstogo = S_bitstogo;
 bitstofollow += 1;
 if (S_low<(((codevalue)((1<<16)-1))/4+1))
 {
  { { buffer >>= 1; if ((0)) buffer |= 0x80; bitstogo -= 1; if (bitstogo==0) { putc(buffer, stdout); bitstogo = 8; cmpbytes += 1; } }; while (bitstofollow) { { buffer >>= 1; if (!(0)) buffer |= 0x80; bitstogo -= 1; if (bitstogo==0) { putc(buffer, stdout); bitstogo = 8; cmpbytes += 1; } }; bitstofollow -= 1; } };
 }
 else
 {
  { { buffer >>= 1; if ((1)) buffer |= 0x80; bitstogo -= 1; if (bitstogo==0) { putc(buffer, stdout); bitstogo = 8; cmpbytes += 1; } }; while (bitstofollow) { { buffer >>= 1; if (!(1)) buffer |= 0x80; bitstogo -= 1; if (bitstogo==0) { putc(buffer, stdout); bitstogo = 8; cmpbytes += 1; } }; bitstofollow -= 1; } };
 }
 S_bitstofollow = bitstofollow;
 S_buffer = buffer;
 S_bitstogo = bitstogo;
}

canonical_original_code:
void doneencoding()
{
 register long bitstofollow;
 register int buffer; register int bitstogo;
 bitstofollow = S_bitstofollow;
 buffer = S_buffer;
 bitstogo = S_bitstogo;
 bitstofollow += 1;
 if (S_low<(((codevalue)((1<<16)-1))/4+1))
 {
  { { buffer >>= 1; if ((0)) buffer |= 0x80; bitstogo -= 1; if (bitstogo==0) { putc(buffer, stdout); bitstogo = 8; cmpbytes += 1; } }; while (bitstofollow) { { buffer >>= 1; if (!(0)) buffer |= 0x80; bitstogo -= 1; if (bitstogo==0) { putc(buffer, stdout); bitstogo = 8; cmpbytes += 1; } }; bitstofollow -= 1; } };
 }
 else
 {
  { { buffer >>= 1; if ((1)) buffer |= 0x80; bitstogo -= 1; if (bitstogo==0) { putc(buffer, stdout); bitstogo = 8; cmpbytes += 1; } }; while (bitstofollow) { { buffer >>= 1; if (!(1)) buffer |= 0x80; bitstogo -= 1; if (bitstogo==0) { putc(buffer, stdout); bitstogo = 8; cmpbytes += 1; } }; bitstofollow -= 1; } };
 }
 S_bitstofollow = bitstofollow;
 S_buffer = buffer;
 S_bitstogo = bitstogo;
}

variable_types: bitstofollow long


vfail

decompiled_code:
void __fastcall __noreturn vfail(char *format, __gnuc_va_list arg)
{
vfprintf(stderr, format, arg);
fflush(stderr);
fflush(stdout);
abort();
}

canonical_decompiled_code:
void __fastcall __noreturn func0(char *format, __gnuc_va_list arg)
{
vfprintf(stderr, format, arg);
fflush(stderr);
fflush(stdout);
abort();
}

original_code:
static void vfail(const char *fmt, va_list args)
{
  vfprintf(stderr, fmt, args);
  fflush(stderr);
  fflush(stdout);
  abort();
  while (1);
}

canonical_original_code:
static void vfail(char *fmt, __builtin_va_list args)
{
  vfprintf(stderr, fmt, args);
  fflush(stderr);
  fflush(stdout);
  abort();
  while (1);
}

variable_types:
fmt
char *


xmalloc

decompiled_code:
void *__fastcall xmalloc(size_t a1)
{
void *result; // rax

result = malloc(a1);
if ( !result )
abort();
return result;
}

canonical_decompiled_code:
void *__fastcall func1(size_t a1)
{
void *result; // rax

result = malloc(a1);
if ( !result )
abort();
return result;
}

original_code:
void *xmalloc(size_t size)
{
  void *x = malloc(size);
  if (!x) abort();
  return x;
}

canonical_original_code:
void *xmalloc(unsigned long size)
{
  void *x = malloc(size);
  if (!x) abort();
  return x;
}

variable_types:
size
unsigned long

variable_types:
x
void *

return_type: void *


xrealloc

decompiled_code:
void *__fastcall xrealloc(void *a1, size_t a2)
{
void *result; // rax

result = realloc(a1, a2);
if ( !result )
abort();
return result;
}

canonical_decompiled_code:
void *__fastcall func2(void *a1, size_t a2)
{
void *result; // rax

result = realloc(a1, a2);
if ( !result )
abort();
return result;
}

original_code:
void *xrealloc(void *p, size_t newsize)
{
  void *x = realloc(p, newsize);
  if (!x) abort();
  return x;
}

canonical_original_code:
void *xrealloc(void *p, unsigned long newsize)
{
  void *x = realloc(p, newsize);
  if (!x) abort();
  return x;
}

variable_types:
p
void *

variable_types:
newsize
unsigned long


decompiled_code:
__int64 __fastcall align_to(__int64 a1, unsigned __int64 a2)
{
return a2 * (int)((a2 + a1 - 1) / a2);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, unsigned __int64 a2)
{
return a2 * (int)((a2 + a1 - 1) / a2);
}

original_code:
unsigned long align_to(unsigned long n, unsigned long alignment)
{
  int count = (n + alignment - 1) / alignment;
  return count * alignment;
}

variable_types:
n
unsigned long

variable_types:
alignment
unsigned long

variable_types: count int