main

canonical_name: main

repo: d-j-a-y/Cratyle

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
unsigned int v4; // eax
unsigned int v5; // er12
unsigned int v6; // eax
unsigned int v7; // eax
unsigned int v8; // eax
unsigned int v9; // eax
unsigned int v10; // eax
unsigned int v11; // eax
unsigned int v12; // eax
__pid_t v13; // eax
unsigned int v14; // eax
__int64 v15; // rdi
unsigned int v17; // eax
int v18; // er13
int v19; // ebp
int v20; // ebx
__int64 v21; // rdx
__int64 v22; // rdx
__int64 v23; // rdx
size_t v24; // rax
size_t v25; // rax
size_t v26; // rax
size_t v27; // rax
size_t v28; // rax
size_t v29; // rax
size_t v30; // rax
size_t v31; // rax
size_t v32; // rax
size_t v33; // rax
char *v34; // rax
size_t v35; // rax
size_t v36; // rax
char *v37; // rax
size_t v38; // rax
size_t v39; // rax
char *v40; // rax
size_t v41; // rax
unsigned int v42; // eax
__int64 v43; // rdi
unsigned int v44; // eax
__int64 v45; // rdi
char buf; // [rsp+Dh] [rbp-9ABh] BYREF
char v47; // [rsp+Eh] [rbp-9AAh] BYREF
char v48; // [rsp+Fh] [rbp-9A9h] BYREF
int pipedes[2]; // [rsp+10h] [rbp-9A8h] BYREF
int v50[2]; // [rsp+18h] [rbp-9A0h] BYREF
int v51[2]; // [rsp+20h] [rbp-998h] BYREF
int v52[2]; // [rsp+28h] [rbp-990h] BYREF
int v53[2]; // [rsp+30h] [rbp-988h] BYREF
int v54[2]; // [rsp+38h] [rbp-980h] BYREF
char v55[64]; // [rsp+40h] [rbp-978h] BYREF
char s[16]; // [rsp+80h] [rbp-938h] BYREF
char v57[239]; // [rsp+90h] [rbp-928h] BYREF
char v58[16]; // [rsp+180h] [rbp-838h] BYREF
char v59[239]; // [rsp+190h] [rbp-828h] BYREF
char s1[16]; // [rsp+280h] [rbp-738h] BYREF
char v61[239]; // [rsp+290h] [rbp-728h] BYREF
char v62[16]; // [rsp+380h] [rbp-638h] BYREF
char v63[239]; // [rsp+390h] [rbp-628h] BYREF
char v64[16]; // [rsp+480h] [rbp-538h] BYREF
char v65[239]; // [rsp+490h] [rbp-528h] BYREF
char src[16]; // [rsp+580h] [rbp-438h] BYREF
char v67[239]; // [rsp+590h] [rbp-428h] BYREF
char v68[16]; // [rsp+680h] [rbp-338h] BYREF
char v69[239]; // [rsp+690h] [rbp-328h] BYREF
char v70[16]; // [rsp+780h] [rbp-238h] BYREF
char v71[239]; // [rsp+790h] [rbp-228h] BYREF
char v72[16]; // [rsp+880h] [rbp-138h] BYREF
char v73[239]; // [rsp+890h] [rbp-128h] BYREF

CratyleInit(argc, argv, envp);
v3 = time(0LL);
srand(v3);
if ( pipe(pipedes) == -1 || pipe(v50) == -1 || pipe(v51) == -1 )
{
v5 = 1;
perror("pipe failed!");
}
else
{
v4 = fcntl(pipedes[0], 3, 0LL);
BYTE1(v4) |= 8u;
v5 = fcntl(pipedes[0], 4, v4);
if ( v5 == -1 )
{
perror("fnctl : fdMinitel1");
}
else
{
v6 = fcntl(v50[0], 3, 0LL);
BYTE1(v6) |= 8u;
v5 = fcntl(v50[0], 4, v6);
if ( v5 == -1 )
{
perror("fnctl : fdMinitel2");
}
else
{
v7 = fcntl(v51[0], 3, 0LL);
BYTE1(v7) |= 8u;
v5 = fcntl(v51[0], 4, v7);
if ( v5 == -1 )
{
perror("fnctl : fdMinitel3");
}
else if ( pipe(v52) == -1 || pipe(v53) == -1 || pipe(v54) == -1 )
{
v5 = -1;
perror("pipeOut failed!");
}
else
{
v8 = fcntl(v52[0], 3, 0LL);
BYTE1(v8) |= 8u;
v5 = fcntl(v52[0], 4, v8);
if ( v5 == -1 )
{
perror("fnctl : fdMinitel1Out");
}
else
{
v9 = fcntl(v53[0], 3, 0LL);
BYTE1(v9) |= 8u;
v5 = fcntl(v53[0], 4, v9);
if ( v5 == -1 )
{
perror("fnctl : fdMinitel2Out");
}
else
{
v10 = fcntl(v54[0], 3, 0LL);
BYTE1(v10) |= 8u;
v5 = fcntl(v54[0], 4, v10);
if ( v5 == -1 )
{
perror("fnctl : fdMinitel3Out");
}
else
{
puts(::s);
v11 = fork();
v5 = v11;
if ( v11 == -1 )
{
perror("Minitel1 fork failed!");
}
else if ( v11 )
{
printf("pid Minitel1 %d\n", v11);
sleep(1u);
puts("I am the CRATYLE Serveur");
puts("Cratyle,wait ok");
*(_OWORD *)v72 = 0LL;
memset(v57, 0, sizeof(v57));
*(_OWORD *)s = 0LL;
memset(v59, 0, sizeof(v59));
*(_OWORD *)v58 = 0LL;
memset(v61, 0, sizeof(v61));
*(_OWORD *)s1 = 0LL;
memset(v63, 0, sizeof(v63));
*(_OWORD *)v62 = 0LL;
memset(v65, 0, sizeof(v65));
*(_OWORD *)v64 = 0LL;
memset(v67, 0, sizeof(v67));
*(_OWORD *)src = 0LL;
memset(v69, 0, sizeof(v69));
*(_OWORD *)v68 = 0LL;
memset(v71, 0, sizeof(v71));
*(_OWORD *)v70 = 0LL;
memset(v73, 0, sizeof(v73));
v17 = OuvrirConnectionImprimante("/dev/ttyUSB3", v55);
v5 = v17;
if ( v17 == -1 )
{
perror("OuvrirConnectionImprim 1 failed!");
}
else
{
v18 = 0;
v19 = 0;
MINITELEnvoyerCaractere(v17, 12LL);
v20 = 0;
while ( !STOP )
{
if ( (unsigned int)read(pipedes[0], &buf, 1uLL) != -1 || *_errno_location() != 11 )
{
if ( v20 > 252 || buf == 10 )
{
s[v20] = 0;
v24 = strlen(s);
printf("CRATYLE : strMinitel1 %s : %i : strlen %i\n", s, (unsigned int)v20, v24);
if ( !strncmp(s, "quitCRATYLE", 0xBuLL) )
{
v25 = strlen(s);
write(v53[1], s, v25);
v26 = strlen(s);
write(v54[1], s, v26);
STOP = 1;
printf(aCratyleMerciPo);
}
else
{
Cratylation(s, v62, v5);
strcpy(v68, "Cratyle:");
v39 = strlen(v68);
v40 = stpcpy(&v68[v39], v62);
write(v53[1], v68, v40 - v68);
v41 = strlen(v68);
v20 = 0;
write(v54[1], v68, v41);
}
}
else
{
v21 = v20++;
s[v21] = buf;
}
}
if ( (unsigned int)read(v50[0], &v47, 1uLL) != -1 || *_errno_location() != 11 )
{
if ( v47 == 10 || v19 > 252 )
{
v58[v19] = 0;
v30 = strlen(v58);
printf("CRATYLE : strMinitel2 %s : %i : strlen %i\n", v58, (unsigned int)v19, v30);
if ( !strncmp(v58, "quitCRATYLE", 0xBuLL) )
{
v31 = strlen(v58);
write(v52[1], v58, v31);
v32 = strlen(v58);
write(v54[1], v58, v32);
STOP = 1;
printf(aCratyleMerciPo);
}
else
{
Cratylation(v58, v64, v5);
strcpy(v70, "Hermogene:");
v36 = strlen(v70);
v37 = stpcpy(&v70[v36], v64);
write(v52[1], v70, v37 - v70);
v38 = strlen(v70);
v19 = 0;
write(v54[1], v70, v38);
}
}
else
{
v22 = v19++;
v58[v22] = v47;
}
}
if ( (unsigned int)read(v51[0], &v48, 1uLL) != -1 || *_errno_location() != 11 )
{
if ( v48 == 10 || v18 > 252 )
{
s1[v18] = 0;
v27 = strlen(s1);
printf("CRATYLE : strMinitel3 %s : %i : strlen %i\n", s1, (unsigned int)v18, v27);
if ( !strncmp(s1, "quitCRATYLE", 0xBuLL) )
{
v28 = strlen(s1);
write(v52[1], s1, v28);
v29 = strlen(s1);
write(v53[1], s1, v29);
STOP = 1;
printf(aCratyleMerciPo);
}
else
{
Cratylation(s1, src, v5);
strcpy(v72, "Socrate:");
v33 = strlen(v72);
v34 = stpcpy(&v72[v33], src);
write(v52[1], v72, v34 - v72);
v35 = strlen(v72);
v18 = 0;
write(v53[1], v72, v35);
}
}
else
{
v23 = v18++;
s1[v23] = v48;
}
}
}
if ( v5 )
FermerConnection(v5, v55);
v5 = 0;
puts("CRATYLE : Attente de le minitel.....");
usleep(0x61A80u);
puts("CRATYLE : Attente de le autre minitel.....");
usleep(0xC3500u);
puts("CRATYLE fin");
}
}
else
{
v12 = fork();
if ( v12 == -1 )
{
v5 = -1;
perror("Minitel2 fork failed!");
}
else if ( v12 )
{
printf("pid Minitel2 %d\n", v12);
puts("I am Minitel1");
usleep(0x9C4u);
puts("Minitel1, wait ok");
v42 = OuvrirConnectionMinitel("/dev/ttyUSB0", v72);
v5 = v42;
if ( v42 == -1 )
{
perror("OuvrirConnectionMinitel 1 failed!");
}
else
{
InitChat(v42);
OuvrirChat(v5, pipedes, v52, "Cratyle:");
v43 = v5;
v5 = 0;
FermerConnection(v43, v72);
write(pipedes[1], "quitCRATYLE", 0xBuLL);
close(pipedes[1]);
close(pipedes[0]);
puts("Minitel1, finito!");
}
}
else
{
v13 = fork();
v5 = v13;
if ( v13 == -1 )
{
perror("Minitel3 fork failed!");
}
else if ( v13 )
{
puts("I am Minitel2");
usleep(0x9C4u);
puts("Minitel2, wait ok");
v44 = OuvrirConnectionMinitel("/dev/ttyUSB1", v72);
v5 = v44;
if ( v44 == -1 )
{
perror("OuvrirConnectionMinitel 2 failed!");
}
else
{
InitChat(v44);
OuvrirChat(v5, v50, v53, "Hermogene:");
v45 = v5;
v5 = 0;
FermerConnection(v45, v72);
close(v50[1]);
close(v50[0]);
puts("Minitel2 exit normal");
}
}
else
{
puts("I am Minitel3");
usleep(0x9C4u);
puts("Minitel3, wait ok");
v14 = OuvrirConnectionMinitel("/dev/ttyUSB2", v72);
v5 = v14;
if ( v14 == -1 )
{
perror("OuvrirConnectionMinitel 3 failed!");
}
else
{
InitChat(v14);
puts("Minitel3, ouvrir chat");
OuvrirChat(v5, v51, v54, "Socrate:");
v15 = v5;
v5 = 0;
FermerConnection(v15, v72);
close(v51[1]);
close(v51[0]);
puts("Minitel3 exit normal");
}
}
}
}
}
}
}
}
}
}
}
return v5;
}

original_code:
int main()
{
    CratyleInit();
 srand(time(((void *)0)));
    pid_t pid_Minitel1, pid_Minitel2, pid_Minitel3;
    int fdMinitel1[2], fdMinitel2[2], fdMinitel3[2];
    int fdMinitel1Out[2], fdMinitel2Out[2], fdMinitel3Out[2];
    if(pipe(fdMinitel1)==-1 || pipe(fdMinitel2)==-1 || pipe(fdMinitel3)==-1)
    {
        perror("pipe failed!");
        return 1;
    }
    int flags = fcntl(fdMinitel1[0], 3, 0);
    if (fcntl (fdMinitel1[0], 4, flags | 04000) == -1)
    {
  perror("fnctl : fdMinitel1");
  return -1;
    }
    flags = fcntl(fdMinitel2[0], 3, 0);
    if (fcntl (fdMinitel2[0], 4, flags | 04000) == -1)
    {
  perror("fnctl : fdMinitel2");
  return -1;
    }
    flags = fcntl(fdMinitel3[0], 3, 0);
    if (fcntl (fdMinitel3[0], 4, flags | 04000) == -1)
    {
  perror("fnctl : fdMinitel3");
  return -1;
    }
    if(pipe(fdMinitel1Out)==-1 || pipe(fdMinitel2Out)==-1 || pipe(fdMinitel3Out)==-1)
    {
        perror("pipeOut failed!");
        return -1;
    }
    flags = fcntl(fdMinitel1Out[0], 3, 0);
    if (fcntl (fdMinitel1Out[0], 4, flags | 04000) == -1)
    {
  perror("fnctl : fdMinitel1Out");
  return -1;
    }
    flags = fcntl(fdMinitel2Out[0], 3, 0);
    if (fcntl (fdMinitel2Out[0], 4, flags | 04000) == -1)
    {
  perror("fnctl : fdMinitel2Out");
  return -1;
    }
    flags = fcntl(fdMinitel3Out[0], 3, 0);
    if (fcntl (fdMinitel3Out[0], 4, flags | 04000) == -1)
    {
  perror("fnctl : fdMinitel3Out");
  return -1;
    }
    printf("Démarrage du programme\n");
    pid_Minitel1=fork();
    if(pid_Minitel1==-1)
    {
        perror("Minitel1 fork failed!");
        return -1;
    }
    if(pid_Minitel1==0)
    {
        pid_Minitel2=fork();
        if(pid_Minitel2==-1)
        {
            perror("Minitel2 fork failed!" );
            return -1;
        }
        if(pid_Minitel2==0)
        {
            pid_Minitel3=fork();
            if(pid_Minitel3==-1)
            {
                perror("Minitel3 fork failed!" );
                return -1;
            }
            if(pid_Minitel3==0)
            {
                printf("I am Minitel3\n");
                usleep(2500);
                printf("Minitel3, wait ok\n");
                int fdMinitel3Modem;
                struct termios oldtioMinitel3;
                if((fdMinitel3Modem = OuvrirConnectionMinitel("/dev/ttyUSB2", &oldtioMinitel3)) == -1)
                {
                    perror("OuvrirConnectionMinitel 3 failed!");
                    return -1;
                }
                InitChat(fdMinitel3Modem);
                printf("Minitel3, ouvrir chat\n");
                OuvrirChat(fdMinitel3Modem, fdMinitel3, fdMinitel3Out, SOCRATE);
                FermerConnection(fdMinitel3Modem, &oldtioMinitel3);
                close(fdMinitel3[1]);
                close(fdMinitel3[0]);
                printf("Minitel3 exit normal\n");
                return 0;
            }
            else
            {
                printf("I am Minitel2\n");
                usleep(2500);
                printf("Minitel2, wait ok\n");
                int fdMinitel2Modem;
                struct termios oldtioMinitel2;
                if((fdMinitel2Modem = OuvrirConnectionMinitel("/dev/ttyUSB1", &oldtioMinitel2)) == -1)
                {
                    perror("OuvrirConnectionMinitel 2 failed!");
                    return -1;
                }
                InitChat(fdMinitel2Modem);
                OuvrirChat(fdMinitel2Modem, fdMinitel2, fdMinitel2Out, HERMOGENE);
                FermerConnection(fdMinitel2Modem, &oldtioMinitel2);
                close(fdMinitel2[1]);
                close(fdMinitel2[0]);
                printf("Minitel2 exit normal\n");
                return 0;
            }
        }
        else
        {
        printf("pid Minitel2 %d\n", pid_Minitel2);
            printf("I am Minitel1\n");
            usleep(2500);
            printf("Minitel1, wait ok\n");
            int fdMinitel1Modem;
            struct termios oldtioMinitel1;
            if((fdMinitel1Modem = OuvrirConnectionMinitel("/dev/ttyUSB0", &oldtioMinitel1)) == -1)
            {
                perror("OuvrirConnectionMinitel 1 failed!");
                return -1;
            }
            InitChat(fdMinitel1Modem);
            OuvrirChat(fdMinitel1Modem, fdMinitel1, fdMinitel1Out, CRATYLE);
            FermerConnection(fdMinitel1Modem, &oldtioMinitel1);
            write(fdMinitel1[1],"quitCRATYLE",strlen("quitCRATYLE"));
            close(fdMinitel1[1]);
            close(fdMinitel1[0]);
            printf("Minitel1, finito!\n");
            return 0;
        }
    }
    else
    {
        printf("pid Minitel1 %d\n", pid_Minitel1);
        sleep(1);
        printf("I am the CRATYLE Serveur\n");
        printf("Cratyle,wait ok\n");
        char bufferM1[1], bufferM2[1], bufferM3[1];
        char strMinitel1[255]= "", strMinitel2[255]= "", strMinitel3[255]= "";
        char strMinitel1Cratyle[255]= "", strMinitel2Cratyle[255]= "", strMinitel3Cratyle[255]= "";
        char strMinitel1CratyleAuteur[255]= "", strMinitel2CratyleAuteur[255]= "", strMinitel3CratyleAuteur[255]= "";
        int iIndexMinitel1, iIndexMinitel2, iIndexMinitel3;
        int iNbCaracteresRecus;
        int iFdImprim1;
        iFdImprim1 = 0;
        struct termios oldtioImprim1;
        if((iFdImprim1 = OuvrirConnectionImprimante("/dev/ttyUSB3", &oldtioImprim1)) == -1)
        {
            perror("OuvrirConnectionImprim 1 failed!");
            return -1;
        }
        MINITELEnvoyerCaractere(iFdImprim1, 0x0C);
        iIndexMinitel1 = iIndexMinitel2 = iIndexMinitel3 = 0;
        while (STOP == 0)
        {
            iNbCaracteresRecus = read(fdMinitel1[0],bufferM1,1);
            if (iNbCaracteresRecus == -1 && (*__errno_location ()) == 11)
            {
            }
            else
            {
                if((int)bufferM1[0] != 10 && (iIndexMinitel1 + 2) < 255)
                    strMinitel1[iIndexMinitel1++] = bufferM1[0];
                else
                {
                    strMinitel1[iIndexMinitel1] = '\0';
                    printf("CRATYLE : strMinitel1 %s : %i : strlen %i\n", strMinitel1, iIndexMinitel1, strlen(strMinitel1));
                    if (strncmp (strMinitel1, "quitCRATYLE", strlen("quitCRATYLE")) == 0)
                    {
                        write(fdMinitel2Out[1], strMinitel1, strlen(strMinitel1));
                        write(fdMinitel3Out[1], strMinitel1, strlen(strMinitel1));
                        STOP = 1;
                        printf("CRATYLE : merci pour la conversation.\nà la prochaine.... ");
                    }
                    else
                    {
                        Cratylation(strMinitel1, strMinitel1Cratyle, iFdImprim1);
                        strcpy(strMinitel1CratyleAuteur, (const char*)CRATYLE);
                        strcat (strMinitel1CratyleAuteur, strMinitel1Cratyle );
                        write(fdMinitel2Out[1], strMinitel1CratyleAuteur, strlen(strMinitel1CratyleAuteur));
                        write(fdMinitel3Out[1], strMinitel1CratyleAuteur, strlen(strMinitel1CratyleAuteur));
                        iIndexMinitel1=0;
                    }
                }
            }
            iNbCaracteresRecus = read(fdMinitel2[0],bufferM2,1);
            if (iNbCaracteresRecus == -1 && (*__errno_location ()) == 11)
            {
            }
            else
            {
                if((int)bufferM2[0] != 10 && (iIndexMinitel2 + 2) < 255)
                    strMinitel2[iIndexMinitel2++] = bufferM2[0];
                else
                {
                    strMinitel2[iIndexMinitel2] = '\0';
                printf("CRATYLE : strMinitel2 %s : %i : strlen %i\n", strMinitel2, iIndexMinitel2, strlen(strMinitel2));
                    if (strncmp (strMinitel2, "quitCRATYLE", strlen("quitCRATYLE")) == 0)
                    {
                        write(fdMinitel1Out[1], strMinitel2, strlen(strMinitel2));
                        write(fdMinitel3Out[1], strMinitel2, strlen(strMinitel2));
                        STOP = 1;
                        printf("CRATYLE : merci pour la conversation.\nà la prochaine.... ");
                    }
                    else
                    {
                        Cratylation(strMinitel2, strMinitel2Cratyle, iFdImprim1);
                        strcpy(strMinitel2CratyleAuteur, (const char*)HERMOGENE);
                        strcat (strMinitel2CratyleAuteur, strMinitel2Cratyle );
                        write(fdMinitel1Out[1], strMinitel2CratyleAuteur, strlen(strMinitel2CratyleAuteur));
                        write(fdMinitel3Out[1], strMinitel2CratyleAuteur, strlen(strMinitel2CratyleAuteur));
                        iIndexMinitel2=0;
                    }
                }
            }
            iNbCaracteresRecus = read(fdMinitel3[0],bufferM3,1);
            if (iNbCaracteresRecus == -1 && (*__errno_location ()) == 11)
            {
            }
            else
            {
                if((int)bufferM3[0] != 10 && (iIndexMinitel3 + 2) < 255)
                    strMinitel3[iIndexMinitel3++] = bufferM3[0];
                else
                {
                    strMinitel3[iIndexMinitel3] = '\0';
                    printf("CRATYLE : strMinitel3 %s : %i : strlen %i\n", strMinitel3, iIndexMinitel3, strlen(strMinitel3));
                    if (strncmp (strMinitel3, "quitCRATYLE", strlen("quitCRATYLE")) == 0)
                    {
                        write(fdMinitel1Out[1], strMinitel3, strlen(strMinitel3));
                        write(fdMinitel2Out[1], strMinitel3, strlen(strMinitel3));
                        STOP = 1;
                        printf("CRATYLE : merci pour la conversation.\nà la prochaine.... ");
                    }
                    else
                    {
                        Cratylation(strMinitel3, strMinitel3Cratyle, iFdImprim1);
                        strcpy(strMinitel3CratyleAuteur, (const char*)SOCRATE);
                        strcat (strMinitel3CratyleAuteur, strMinitel3Cratyle );
                        write(fdMinitel1Out[1], strMinitel3CratyleAuteur, strlen(strMinitel3CratyleAuteur));
                        write(fdMinitel2Out[1], strMinitel3CratyleAuteur, strlen(strMinitel3CratyleAuteur));
                        iIndexMinitel3=0;
                    }
                }
            }
        }
        if (iFdImprim1) FermerConnection(iFdImprim1, &oldtioImprim1 );
        printf("CRATYLE : Attente de le minitel.....\n");
        usleep(400000);
        printf("CRATYLE : Attente de le autre minitel.....\n");
        usleep(800000);
        printf("CRATYLE fin\n");
    }
    return 0;
}

canonical_original_code:
int main()
{
    CratyleInit();
 srand(time(((void *)0)));
    int pid_Minitel1; int pid_Minitel2; int pid_Minitel3;
    int fdMinitel1[2]; int fdMinitel2[2]; int fdMinitel3[2];
    int fdMinitel1Out[2]; int fdMinitel2Out[2]; int fdMinitel3Out[2];
    if(pipe(fdMinitel1)==-1 || pipe(fdMinitel2)==-1 || pipe(fdMinitel3)==-1)
    {
        perror("pipe failed!");
        return 1;
    }
    int flags = fcntl(fdMinitel1[0], 3, 0);
    if (fcntl (fdMinitel1[0], 4, flags | 04000) == -1)
    {
  perror("fnctl : fdMinitel1");
  return -1;
    }
    flags = fcntl(fdMinitel2[0], 3, 0);
    if (fcntl (fdMinitel2[0], 4, flags | 04000) == -1)
    {
  perror("fnctl : fdMinitel2");
  return -1;
    }
    flags = fcntl(fdMinitel3[0], 3, 0);
    if (fcntl (fdMinitel3[0], 4, flags | 04000) == -1)
    {
  perror("fnctl : fdMinitel3");
  return -1;
    }
    if(pipe(fdMinitel1Out)==-1 || pipe(fdMinitel2Out)==-1 || pipe(fdMinitel3Out)==-1)
    {
        perror("pipeOut failed!");
        return -1;
    }
    flags = fcntl(fdMinitel1Out[0], 3, 0);
    if (fcntl (fdMinitel1Out[0], 4, flags | 04000) == -1)
    {
  perror("fnctl : fdMinitel1Out");
  return -1;
    }
    flags = fcntl(fdMinitel2Out[0], 3, 0);
    if (fcntl (fdMinitel2Out[0], 4, flags | 04000) == -1)
    {
  perror("fnctl : fdMinitel2Out");
  return -1;
    }
    flags = fcntl(fdMinitel3Out[0], 3, 0);
    if (fcntl (fdMinitel3Out[0], 4, flags | 04000) == -1)
    {
  perror("fnctl : fdMinitel3Out");
  return -1;
    }
    printf("Démarrage du programme\n");
    pid_Minitel1=fork();
    if(pid_Minitel1==-1)
    {
        perror("Minitel1 fork failed!");
        return -1;
    }
    if(pid_Minitel1==0)
    {
        pid_Minitel2=fork();
        if(pid_Minitel2==-1)
        {
            perror("Minitel2 fork failed!" );
            return -1;
        }
        if(pid_Minitel2==0)
        {
            pid_Minitel3=fork();
            if(pid_Minitel3==-1)
            {
                perror("Minitel3 fork failed!" );
                return -1;
            }
            if(pid_Minitel3==0)
            {
                printf("I am Minitel3\n");
                usleep(2500);
                printf("Minitel3, wait ok\n");
                int fdMinitel3Modem;
                struct termios oldtioMinitel3;
                if((fdMinitel3Modem = OuvrirConnectionMinitel("/dev/ttyUSB2", &oldtioMinitel3)) == -1)
                {
                    perror("OuvrirConnectionMinitel 3 failed!");
                    return -1;
                }
                InitChat(fdMinitel3Modem);
                printf("Minitel3, ouvrir chat\n");
                OuvrirChat(fdMinitel3Modem, fdMinitel3, fdMinitel3Out, SOCRATE);
                FermerConnection(fdMinitel3Modem, &oldtioMinitel3);
                close(fdMinitel3[1]);
                close(fdMinitel3[0]);
                printf("Minitel3 exit normal\n");
                return 0;
            }
            else
            {
                printf("I am Minitel2\n");
                usleep(2500);
                printf("Minitel2, wait ok\n");
                int fdMinitel2Modem;
                struct termios oldtioMinitel2;
                if((fdMinitel2Modem = OuvrirConnectionMinitel("/dev/ttyUSB1", &oldtioMinitel2)) == -1)
                {
                    perror("OuvrirConnectionMinitel 2 failed!");
                    return -1;
                }
                InitChat(fdMinitel2Modem);
                OuvrirChat(fdMinitel2Modem, fdMinitel2, fdMinitel2Out, HERMOGENE);
                FermerConnection(fdMinitel2Modem, &oldtioMinitel2);
                close(fdMinitel2[1]);
                close(fdMinitel2[0]);
                printf("Minitel2 exit normal\n");
                return 0;
            }
        }
        else
        {
        printf("pid Minitel2 %d\n", pid_Minitel2);
            printf("I am Minitel1\n");
            usleep(2500);
            printf("Minitel1, wait ok\n");
            int fdMinitel1Modem;
            struct termios oldtioMinitel1;
            if((fdMinitel1Modem = OuvrirConnectionMinitel("/dev/ttyUSB0", &oldtioMinitel1)) == -1)
            {
                perror("OuvrirConnectionMinitel 1 failed!");
                return -1;
            }
            InitChat(fdMinitel1Modem);
            OuvrirChat(fdMinitel1Modem, fdMinitel1, fdMinitel1Out, CRATYLE);
            FermerConnection(fdMinitel1Modem, &oldtioMinitel1);
            write(fdMinitel1[1],"quitCRATYLE",strlen("quitCRATYLE"));
            close(fdMinitel1[1]);
            close(fdMinitel1[0]);
            printf("Minitel1, finito!\n");
            return 0;
        }
    }
    else
    {
        printf("pid Minitel1 %d\n", pid_Minitel1);
        sleep(1);
        printf("I am the CRATYLE Serveur\n");
        printf("Cratyle,wait ok\n");
        char bufferM1[1]; char bufferM2[1]; char bufferM3[1];
        char strMinitel1[255] = ""; char strMinitel2[255] = ""; char strMinitel3[255] = "";
        char strMinitel1Cratyle[255] = ""; char strMinitel2Cratyle[255] = ""; char strMinitel3Cratyle[255] = "";
        char strMinitel1CratyleAuteur[255] = ""; char strMinitel2CratyleAuteur[255] = ""; char strMinitel3CratyleAuteur[255] = "";
        int iIndexMinitel1; int iIndexMinitel2; int iIndexMinitel3;
        int iNbCaracteresRecus;
        int iFdImprim1;
        iFdImprim1 = 0;
        struct termios oldtioImprim1;
        if((iFdImprim1 = OuvrirConnectionImprimante("/dev/ttyUSB3", &oldtioImprim1)) == -1)
        {
            perror("OuvrirConnectionImprim 1 failed!");
            return -1;
        }
        MINITELEnvoyerCaractere(iFdImprim1, 0x0C);
        iIndexMinitel1 = iIndexMinitel2 = iIndexMinitel3 = 0;
        while (STOP == 0)
        {
            iNbCaracteresRecus = read(fdMinitel1[0],bufferM1,1);
            if (iNbCaracteresRecus == -1 && (*__errno_location ()) == 11)
            {
            }
            else
            {
                if((int)bufferM1[0] != 10 && (iIndexMinitel1 + 2) < 255)
                    strMinitel1[iIndexMinitel1++] = bufferM1[0];
                else
                {
                    strMinitel1[iIndexMinitel1] = '\0';
                    printf("CRATYLE : strMinitel1 %s : %i : strlen %i\n", strMinitel1, iIndexMinitel1, strlen(strMinitel1));
                    if (strncmp (strMinitel1, "quitCRATYLE", strlen("quitCRATYLE")) == 0)
                    {
                        write(fdMinitel2Out[1], strMinitel1, strlen(strMinitel1));
                        write(fdMinitel3Out[1], strMinitel1, strlen(strMinitel1));
                        STOP = 1;
                        printf("CRATYLE : merci pour la conversation.\nà la prochaine.... ");
                    }
                    else
                    {
                        Cratylation(strMinitel1, strMinitel1Cratyle, iFdImprim1);
                        strcpy(strMinitel1CratyleAuteur, (char *)CRATYLE);
                        strcat (strMinitel1CratyleAuteur, strMinitel1Cratyle );
                        write(fdMinitel2Out[1], strMinitel1CratyleAuteur, strlen(strMinitel1CratyleAuteur));
                        write(fdMinitel3Out[1], strMinitel1CratyleAuteur, strlen(strMinitel1CratyleAuteur));
                        iIndexMinitel1=0;
                    }
                }
            }
            iNbCaracteresRecus = read(fdMinitel2[0],bufferM2,1);
            if (iNbCaracteresRecus == -1 && (*__errno_location ()) == 11)
            {
            }
            else
            {
                if((int)bufferM2[0] != 10 && (iIndexMinitel2 + 2) < 255)
                    strMinitel2[iIndexMinitel2++] = bufferM2[0];
                else
                {
                    strMinitel2[iIndexMinitel2] = '\0';
                printf("CRATYLE : strMinitel2 %s : %i : strlen %i\n", strMinitel2, iIndexMinitel2, strlen(strMinitel2));
                    if (strncmp (strMinitel2, "quitCRATYLE", strlen("quitCRATYLE")) == 0)
                    {
                        write(fdMinitel1Out[1], strMinitel2, strlen(strMinitel2));
                        write(fdMinitel3Out[1], strMinitel2, strlen(strMinitel2));
                        STOP = 1;
                        printf("CRATYLE : merci pour la conversation.\nà la prochaine.... ");
                    }
                    else
                    {
                        Cratylation(strMinitel2, strMinitel2Cratyle, iFdImprim1);
                        strcpy(strMinitel2CratyleAuteur, (char *)HERMOGENE);
                        strcat (strMinitel2CratyleAuteur, strMinitel2Cratyle );
                        write(fdMinitel1Out[1], strMinitel2CratyleAuteur, strlen(strMinitel2CratyleAuteur));
                        write(fdMinitel3Out[1], strMinitel2CratyleAuteur, strlen(strMinitel2CratyleAuteur));
                        iIndexMinitel2=0;
                    }
                }
            }
            iNbCaracteresRecus = read(fdMinitel3[0],bufferM3,1);
            if (iNbCaracteresRecus == -1 && (*__errno_location ()) == 11)
            {
            }
            else
            {
                if((int)bufferM3[0] != 10 && (iIndexMinitel3 + 2) < 255)
                    strMinitel3[iIndexMinitel3++] = bufferM3[0];
                else
                {
                    strMinitel3[iIndexMinitel3] = '\0';
                    printf("CRATYLE : strMinitel3 %s : %i : strlen %i\n", strMinitel3, iIndexMinitel3, strlen(strMinitel3));
                    if (strncmp (strMinitel3, "quitCRATYLE", strlen("quitCRATYLE")) == 0)
                    {
                        write(fdMinitel1Out[1], strMinitel3, strlen(strMinitel3));
                        write(fdMinitel2Out[1], strMinitel3, strlen(strMinitel3));
                        STOP = 1;
                        printf("CRATYLE : merci pour la conversation.\nà la prochaine.... ");
                    }
                    else
                    {
                        Cratylation(strMinitel3, strMinitel3Cratyle, iFdImprim1);
                        strcpy(strMinitel3CratyleAuteur, (char *)SOCRATE);
                        strcat (strMinitel3CratyleAuteur, strMinitel3Cratyle );
                        write(fdMinitel1Out[1], strMinitel3CratyleAuteur, strlen(strMinitel3CratyleAuteur));
                        write(fdMinitel2Out[1], strMinitel3CratyleAuteur, strlen(strMinitel3CratyleAuteur));
                        iIndexMinitel3=0;
                    }
                }
            }
        }
        if (iFdImprim1) FermerConnection(iFdImprim1, &oldtioImprim1 );
        printf("CRATYLE : Attente de le minitel.....\n");
        usleep(400000);
        printf("CRATYLE : Attente de le autre minitel.....\n");
        usleep(800000);
        printf("CRATYLE fin\n");
    }
    return 0;
}

variable_types: flags int

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: iNbCaracteresRecus int


OuvrirConnection

decompiled_code:
int __fastcall OuvrirConnection(int fd, struct termios *a2)
{
struct termios v3; // [rsp+0h] [rbp-48h] BYREF

tcgetattr(fd, a2);
*(_OWORD *)&v3.c_line = 0LL;
*(_OWORD *)&v3.c_cc[15] = 0LL;
*(_QWORD *)&v3.c_cc[31] = 0LL;
v3.c_ospeed = 0;
*(_QWORD *)&v3.c_iflag = 272LL;
*(_QWORD *)&v3.c_cflag = 0x2000009E9LL;
v3.c_cc[4] = 4;
v3.c_cc[6] = 1;
tcflush(fd, 0);
return tcsetattr(fd, 0, &v3);
}

canonical_decompiled_code:
int __fastcall func0(int fd, struct termios *a2)
{
struct termios v3; // [rsp+0h] [rbp-48h] BYREF

tcgetattr(fd, a2);
*(_OWORD *)&v3.c_line = 0LL;
*(_OWORD *)&v3.c_cc[15] = 0LL;
*(_QWORD *)&v3.c_cc[31] = 0LL;
v3.c_ospeed = 0;
*(_QWORD *)&v3.c_iflag = 272LL;
*(_QWORD *)&v3.c_cflag = 0x2000009E9LL;
v3.c_cc[4] = 4;
v3.c_cc[6] = 1;
tcflush(fd, 0);
return tcsetattr(fd, 0, &v3);
}

original_code:
void OuvrirConnection (int iFileDescriptor, struct termios* oldtio)
{
    struct termios newtio;
    tcgetattr(iFileDescriptor,oldtio);
    bzero(&newtio, sizeof(newtio));
    newtio.c_cflag = 0000011 | 0000040 | 0004000 | 0000200;
    newtio.c_iflag = 0000020 | 0000400;
 newtio.c_cflag |= 0000400;
 newtio.c_cflag |= 0000100;
     newtio.c_oflag = 0;
     newtio.c_lflag = 0000002;
     newtio.c_cc[0] = 0;
     newtio.c_cc[1] = 0;
     newtio.c_cc[2] = 0;
     newtio.c_cc[3] = 0;
     newtio.c_cc[4] = 4;
     newtio.c_cc[5] = 0;
     newtio.c_cc[6] = 1;
     newtio.c_cc[7] = 0;
     newtio.c_cc[8] = 0;
     newtio.c_cc[9] = 0;
     newtio.c_cc[10] = 0;
     newtio.c_cc[11] = 0;
     newtio.c_cc[12] = 0;
     newtio.c_cc[13] = 0;
     newtio.c_cc[14] = 0;
     newtio.c_cc[15] = 0;
     newtio.c_cc[16] = 0;
    tcflush(iFileDescriptor, 0);
    tcsetattr(iFileDescriptor,0,&newtio);
}

canonical_original_code:
void OuvrirConnection(int iFileDescriptor, struct termios *oldtio)
{
    struct termios newtio;
    tcgetattr(iFileDescriptor,oldtio);
    bzero(&newtio, sizeof(newtio));
    newtio.c_cflag = 0000011 | 0000040 | 0004000 | 0000200;
    newtio.c_iflag = 0000020 | 0000400;
 newtio.c_cflag |= 0000400;
 newtio.c_cflag |= 0000100;
     newtio.c_oflag = 0;
     newtio.c_lflag = 0000002;
     newtio.c_cc[0] = 0;
     newtio.c_cc[1] = 0;
     newtio.c_cc[2] = 0;
     newtio.c_cc[3] = 0;
     newtio.c_cc[4] = 4;
     newtio.c_cc[5] = 0;
     newtio.c_cc[6] = 1;
     newtio.c_cc[7] = 0;
     newtio.c_cc[8] = 0;
     newtio.c_cc[9] = 0;
     newtio.c_cc[10] = 0;
     newtio.c_cc[11] = 0;
     newtio.c_cc[12] = 0;
     newtio.c_cc[13] = 0;
     newtio.c_cc[14] = 0;
     newtio.c_cc[15] = 0;
     newtio.c_cc[16] = 0;
    tcflush(iFileDescriptor, 0);
    tcsetattr(iFileDescriptor,0,&newtio);
}

variable_types: iFileDescriptor int

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

return_type: void


OuvrirConnectionMinitel

decompiled_code:
__int64 __fastcall OuvrirConnectionMinitel(const char *a1, struct termios *a2)
{
int v2; // eax
unsigned int v3; // er12

v2 = open(a1, 258);
if ( v2 < 0 )
{
v3 = -1;
perror("OuvrirConnectionMinitel : strMinitelPort");
}
else
{
v3 = v2;
OuvrirConnection(v2, a2);
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func1(const char *a1, struct termios *a2)
{
int v2; // eax
unsigned int v3; // er12

v2 = open(a1, 258);
if ( v2 < 0 )
{
v3 = -1;
perror("OuvrirConnectionMinitel : strMinitelPort");
}
else
{
v3 = v2;
func0(v2, a2);
}
return v3;
}

original_code:
int OuvrirConnectionMinitel (char* strMinitelPort, struct termios* oldtio)
{
    int fd;
    fd = open(strMinitelPort, 02 | 0400 );
    if(fd < 0)
 {
  perror("OuvrirConnectionMinitel : strMinitelPort");
  return -1;
 }
    OuvrirConnection(fd, oldtio);
    return fd;
}

canonical_original_code:
int OuvrirConnectionMinitel(char *strMinitelPort, struct termios *oldtio)
{
    int fd;
    fd = open(strMinitelPort, 02 | 0400 );
    if(fd < 0)
 {
  perror("OuvrirConnectionMinitel : strMinitelPort");
  return -1;
 }
    OuvrirConnection(fd, oldtio);
    return fd;
}

variable_types:
strMinitelPort
char *

variable_types: fd int

return_type: int

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


OuvrirConnectionImprimante

decompiled_code:
__int64 __fastcall OuvrirConnectionImprimante(const char *a1, struct termios *a2)
{
int v2; // eax
unsigned int v3; // er12

v2 = open(a1, 257);
if ( v2 < 0 )
{
v3 = -1;
perror("OuvrirConnectionImprimante : strImprimantePort");
}
else
{
v3 = v2;
OuvrirConnection(v2, a2);
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func2(const char *a1, struct termios *a2)
{
int v2; // eax
unsigned int v3; // er12

v2 = open(a1, 257);
if ( v2 < 0 )
{
v3 = -1;
perror("OuvrirConnectionImprimante : strImprimantePort");
}
else
{
v3 = v2;
func0(v2, a2);
}
return v3;
}

original_code:
int OuvrirConnectionImprimante (char* strImprimantePort, struct termios* oldtio)
{
    int fd;
    fd = open(strImprimantePort, 01 | 0400 );
    if(fd < 0)
 {
  perror("OuvrirConnectionImprimante : strImprimantePort");
  return -1;
 }
    OuvrirConnection(fd, oldtio);
    return fd;
}

canonical_original_code:
int OuvrirConnectionImprimante(char *strImprimantePort, struct termios *oldtio)
{
    int fd;
    fd = open(strImprimantePort, 01 | 0400 );
    if(fd < 0)
 {
  perror("OuvrirConnectionImprimante : strImprimantePort");
  return -1;
 }
    OuvrirConnection(fd, oldtio);
    return fd;
}

variable_types:
strImprimantePort
char *


FermerConnection

decompiled_code:
int __fastcall FermerConnection(int a1, const struct termios *a2)
{
return tcsetattr(a1, 0, a2);
}

canonical_decompiled_code:
int __fastcall func3(int a1, const struct termios *a2)
{
return tcsetattr(a1, 0, a2);
}

original_code:
void FermerConnection (int fd, struct termios* oldtio)
{
    tcsetattr(fd,0,oldtio);
}

canonical_original_code:
void FermerConnection(int fd, struct termios *oldtio)
{
    tcsetattr(fd,0,oldtio);
}


MINITELEnvoyerCaractere

decompiled_code:
void __fastcall MINITELEnvoyerCaractere(int a1, char a2)
{
char buf[12]; // [rsp+Ch] [rbp-Ch] BYREF

buf[0] = a2;
if ( write(a1, buf, 1uLL) < 0 )
perror("write");
}

canonical_decompiled_code:
void __fastcall func4(int a1, char a2)
{
char buf[12]; // [rsp+Ch] [rbp-Ch] BYREF

buf[0] = a2;
if ( write(a1, buf, 1uLL) < 0 )
perror("write");
}

original_code:
void MINITELEnvoyerCaractere(int Fichier, unsigned char Caractere)
{
 if(write(Fichier, &Caractere, 1) < 0)
 {
  perror ("write");
 }
}

variable_types: Fichier int

variable_types:
Caractere
unsigned char


MINITELEnvoyerTexte

decompiled_code:
void __fastcall MINITELEnvoyerTexte(int a1, char *a2)
{
char v3; // si
char *v4; // rbx

v3 = *a2;
if ( v3 )
{
v4 = a2 + 1;
do
{
++v4;
MINITELEnvoyerCaractere(a1, v3);
v3 = *(v4 - 1);
}
while ( v3 );
}
}

canonical_decompiled_code:
void __fastcall func5(int a1, char *a2)
{
char v3; // si
char *v4; // rbx

v3 = *a2;
if ( v3 )
{
v4 = a2 + 1;
do
{
++v4;
func4(a1, v3);
v3 = *(v4 - 1);
}
while ( v3 );
}
}

original_code:
void MINITELEnvoyerTexte(int Fichier, const unsigned char Texte[])
{
 int k = 0;
 while(Texte[k] != '\0')
 {
  MINITELEnvoyerCaractere(Fichier, Texte[k]);
  k++;
 }
}

canonical_original_code:
void MINITELEnvoyerTexte(int Fichier, unsigned char Texte[])
{
 int k = 0;
 while(Texte[k] != '\0')
 {
  MINITELEnvoyerCaractere(Fichier, Texte[k]);
  k++;
 }
}

variable_types:
Texte
unsigned char []

variable_types: k int


MINITELCurseurXY

decompiled_code:
void __fastcall MINITELCurseurXY(int a1, char a2, char a3)
{
MINITELEnvoyerCaractere(a1, 31);
MINITELEnvoyerCaractere(a1, a2 + 64);
MINITELEnvoyerCaractere(a1, a3 + 64);
}

canonical_decompiled_code:
void __fastcall func6(int a1, char a2, char a3)
{
func4(a1, 31);
func4(a1, a2 + 64);
func4(a1, a3 + 64);
}

original_code:
void MINITELCurseurXY(int Fichier, unsigned char X, unsigned char Y)
{
 MINITELEnvoyerCaractere(Fichier, 0x1F);
 MINITELEnvoyerCaractere(Fichier, (0x40 + X));
 MINITELEnvoyerCaractere(Fichier, (0x40 + Y));
}

variable_types:
X
unsigned char

variable_types:
Y
unsigned char


MINITELBloquerClavier

decompiled_code:
void __fastcall MINITELBloquerClavier(int a1, int a2)
{
char v3; // si

puts("MINITELBloquerClavier");
MINITELEnvoyerCaractere(a1, 27);
MINITELEnvoyerCaractere(a1, 91);
MINITELEnvoyerCaractere(a1, 50);
v3 = 104;
if ( a2 != 1 )
v3 = 108;
MINITELEnvoyerCaractere(a1, v3);
}

canonical_decompiled_code:
void __fastcall func7(int a1, int a2)
{
char v3; // si

puts("MINITELBloquerClavier");
func4(a1, 27);
func4(a1, 91);
func4(a1, 50);
v3 = 104;
if ( a2 != 1 )
v3 = 108;
func4(a1, v3);
}

original_code:
void MINITELBloquerClavier(int Fichier, int iBloque)
{
    printf("MINITELBloquerClavier\n");
 MINITELEnvoyerCaractere(Fichier, 0x1B);
 MINITELEnvoyerCaractere(Fichier, 0x5b);
 MINITELEnvoyerCaractere(Fichier, 0x32);
    if (iBloque == 1)
        MINITELEnvoyerCaractere(Fichier, 0x68);
    else
        MINITELEnvoyerCaractere(Fichier, 0x6c);
}

variable_types: iBloque int


MINITELChangerAttribut

decompiled_code:
void __fastcall MINITELChangerAttribut(int a1, char a2)
{
MINITELEnvoyerCaractere(a1, 27);
MINITELEnvoyerCaractere(a1, a2);
}

canonical_decompiled_code:
void __fastcall func8(int a1, char a2)
{
func4(a1, 27);
func4(a1, a2);
}

original_code:
void MINITELChangerAttribut(int Fichier, unsigned char Commande)
{
 MINITELEnvoyerCaractere(Fichier, 0x1B);
 MINITELEnvoyerCaractere(Fichier, Commande);
}

variable_types:
Commande
unsigned char


InitChat

decompiled_code:
void __fastcall InitChat(int a1)
{
int v1; // ebx

v1 = 40;
puts(aVidageDeL);
MINITELEnvoyerCaractere(a1, 12);
puts(" -");
puts("Intro...");
MINITELCurseurXY(a1, 1, 1);
MINITELCurseurXY(a1, 2, 1);
MINITELChangerAttribut(a1, 79);
MINITELEnvoyerTexte(a1, "// (ratyle //");
MINITELChangerAttribut(a1, 76);
MINITELCurseurXY(a1, 3, 1);
do
{
MINITELEnvoyerCaractere(a1, 95);
--v1;
}
while ( v1 );
}

original_code:
void InitChat (int iFdMinitel)
{
 printf ("Vidage de l'écran...\n");
 MINITELEnvoyerCaractere(iFdMinitel, 0x0C);
 printf (" -\n");
 printf ("Intro...\n");
 MINITELCurseurXY(iFdMinitel, 1, 1);
 int k =0;
   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, '_');
    }
}

canonical_original_code:
void InitChat(int iFdMinitel)
{
 printf ("Vidage de l'écran...\n");
 MINITELEnvoyerCaractere(iFdMinitel, 0x0C);
 printf (" -\n");
 printf ("Intro...\n");
 MINITELCurseurXY(iFdMinitel, 1, 1);
 int k = 0;
   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, '_');
    }
}

variable_types: iFdMinitel int


AfficherAttenteCratyle

decompiled_code:
void __fastcall AfficherAttenteCratyle(int a1)
{
int v1; // ebx
int v2; // ebx
int v3; // ebx

v1 = 40;
puts("AfficherAttenteCratyle");
MINITELCurseurXY(a1, 21, 1);
do
{
MINITELEnvoyerCaractere(a1, 95);
--v1;
}
while ( v1 );
v2 = 40;
MINITELCurseurXY(a1, 22, 1);
MINITELEnvoyerTexte(a1, " Entrez votre message : ");
MINITELCurseurXY(a1, 23, 1);
do
{
MINITELEnvoyerCaractere(a1, 32);
--v2;
}
while ( v2 );
v3 = 40;
MINITELCurseurXY(a1, 24, 1);
do
{
MINITELEnvoyerCaractere(a1, 32);
--v3;
}
while ( v3 );
MINITELCurseurXY(a1, 23, 3);
MINITELEnvoyerCaractere(a1, 62);
MINITELEnvoyerCaractere(a1, 32);
MINITELEnvoyerCaractere(a1, 17);
}

original_code:
void AfficherAttenteCratyle(int iFdMini)
{
    int k;
    printf("AfficherAttenteCratyle\n");
    MINITELCurseurXY(iFdMini, 21, 1);
    for(k = 0; k < 40; k++)
    {
        MINITELEnvoyerCaractere(iFdMini, '_');
    }
    MINITELCurseurXY(iFdMini, 22, 1);
    MINITELEnvoyerTexte(iFdMini, (const unsigned char*)"  Entrez votre message :          ");
    MINITELCurseurXY(iFdMini, 23, 1);
    for(k = 0; k < 40; k++)
    {
        MINITELEnvoyerCaractere(iFdMini, ' ');
    }
    MINITELCurseurXY(iFdMini, 24, 1);
    for(k = 0; k < 40; k++)
    {
        MINITELEnvoyerCaractere(iFdMini, ' ');
    }
    MINITELCurseurXY(iFdMini, 23, 3);
    MINITELEnvoyerCaractere(iFdMini, '>');
    MINITELEnvoyerCaractere(iFdMini, ' ');
    MINITELEnvoyerCaractere(iFdMini, 0x11);
}

canonical_original_code:
void AfficherAttenteCratyle(int iFdMini)
{
    int k;
    printf("AfficherAttenteCratyle\n");
    MINITELCurseurXY(iFdMini, 21, 1);
    for(k = 0; k < 40; k++)
    {
        MINITELEnvoyerCaractere(iFdMini, '_');
    }
    MINITELCurseurXY(iFdMini, 22, 1);
    MINITELEnvoyerTexte(iFdMini, (unsigned char *)"  Entrez votre message :          ");
    MINITELCurseurXY(iFdMini, 23, 1);
    for(k = 0; k < 40; k++)
    {
        MINITELEnvoyerCaractere(iFdMini, ' ');
    }
    MINITELCurseurXY(iFdMini, 24, 1);
    for(k = 0; k < 40; k++)
    {
        MINITELEnvoyerCaractere(iFdMini, ' ');
    }
    MINITELCurseurXY(iFdMini, 23, 3);
    MINITELEnvoyerCaractere(iFdMini, '>');
    MINITELEnvoyerCaractere(iFdMini, ' ');
    MINITELEnvoyerCaractere(iFdMini, 0x11);
}

variable_types: iFdMini int


AfficherAurevoirCratyle

decompiled_code:
void __fastcall AfficherAurevoirCratyle(unsigned int a1)
{
int v1; // ebx
int v2; // ebx

v1 = 40;
printf("AfficherAurevoirCratyle : %i\n", a1);
MINITELEnvoyerCaractere(a1, 12);
MINITELCurseurXY(a1, 1, 1);
do
{
MINITELEnvoyerCaractere(a1, 95);
--v1;
}
while ( v1 );
v2 = 45;
MINITELChangerAttribut(a1, 79);
MINITELEnvoyerTexte(a1, "*CratYle StOP*");
do
{
MINITELEnvoyerCaractere(a1, 95);
--v2;
}
while ( v2 );
}

canonical_decompiled_code:
void __fastcall func11(unsigned int a1)
{
int v1; // ebx
int v2; // ebx

v1 = 40;
printf("AfficherAurevoirCratyle : %i\n", a1);
func4(a1, 12);
func6(a1, 1, 1);
do
{
func4(a1, 95);
--v1;
}
while ( v1 );
v2 = 45;
func8(a1, 79);
func5(a1, "*CratYle StOP*");
do
{
func4(a1, 95);
--v2;
}
while ( v2 );
}

original_code:
void AfficherAurevoirCratyle(int iFdMini)
{
    printf ("AfficherAurevoirCratyle : %i\n", iFdMini);
    MINITELEnvoyerCaractere(iFdMini, 0x0C);
    MINITELCurseurXY(iFdMini, 1, 1);
    int k=0;
    for(k = 0; k < 40; k++)
    {
        MINITELEnvoyerCaractere(iFdMini, '_');
    }
    MINITELChangerAttribut(iFdMini, 0x4F);
    MINITELEnvoyerTexte(iFdMini, (unsigned char*) "*CratYle StOP*");
    for(k = 0; k < 45; k++)
    {
        MINITELEnvoyerCaractere(iFdMini, '_');
    }
}

canonical_original_code:
void AfficherAurevoirCratyle(int iFdMini)
{
    printf ("AfficherAurevoirCratyle : %i\n", iFdMini);
    MINITELEnvoyerCaractere(iFdMini, 0x0C);
    MINITELCurseurXY(iFdMini, 1, 1);
    int k = 0;
    for(k = 0; k < 40; k++)
    {
        MINITELEnvoyerCaractere(iFdMini, '_');
    }
    MINITELChangerAttribut(iFdMini, 0x4F);
    MINITELEnvoyerTexte(iFdMini, (unsigned char *) "*CratYle StOP*");
    for(k = 0; k < 45; k++)
    {
        MINITELEnvoyerCaractere(iFdMini, '_');
    }
}


OuvrirChat

decompiled_code:
__int64 __fastcall OuvrirChat(int fd, __int64 a2, int *a3, char *a4)
{
char v4; // r14
int v5; // eax
int v6; // er12
int v7; // ebx
int v9; // ebx
int v10; // ebp
char v11; // si
unsigned int v12; // er14
__int64 v13; // rdx
char *v14; // r12
char v15; // bl
char *v16; // r14
char v17; // si
int v18; // er14
int v19; // ebx
char v20; // bp
unsigned int v21; // ebp
int v22; // er12
char v23; // si
char v24; // bl
__int64 i; // rbp
int v26; // er14
char v27; // r12
int v28; // ebx
int v29; // ebx
int v30; // ebp
int v31; // [rsp+8h] [rbp-290h]
char v32; // [rsp+8h] [rbp-290h]
char v33; // [rsp+8h] [rbp-290h]
unsigned int v34; // [rsp+Ch] [rbp-28Ch]
unsigned int v36; // [rsp+18h] [rbp-280h]
char v37; // [rsp+20h] [rbp-278h]
__int64 v38; // [rsp+20h] [rbp-278h]
int v39; // [rsp+28h] [rbp-270h]
int v40; // [rsp+28h] [rbp-270h]
size_t n; // [rsp+30h] [rbp-268h]
int v42; // [rsp+38h] [rbp-260h]
unsigned int v43; // [rsp+38h] [rbp-260h]
int v44; // [rsp+3Ch] [rbp-25Ch]
char v47; // [rsp+5Fh] [rbp-239h] BYREF
_QWORD buf[31]; // [rsp+60h] [rbp-238h] BYREF
int v49; // [rsp+158h] [rbp-140h]
__int16 v50; // [rsp+15Ch] [rbp-13Ch]
char v51; // [rsp+15Eh] [rbp-13Ah]
char v52; // [rsp+15Fh] [rbp-139h]
__int64 v53; // [rsp+160h] [rbp-138h] BYREF
int v54; // [rsp+168h] [rbp-130h]

v4 = 1;
v44 = strlen(a4);
printf("ouvrir chat %i \n", (unsigned int)fd);
AfficherAttenteCratyle(fd);
v5 = fcntl(fd, 3, 0LL);
v31 = 0;
v34 = v5;
BYTE1(v5) |= 8u;
v36 = v5;
while ( 1 )
{
fcntl(fd, 4, v36);
v6 = read(fd, buf, 0xFFuLL);
fcntl(fd, 4, v34);
if ( v6 == -1 )
{
if ( *_errno_location() == 11 )
{
v7 = 0;
usleep(0x61A8u);
goto LABEL_6;
}
MINITELEnvoyerCaractere(fd, 20);
LABEL_5:
v7 = 0;
goto LABEL_6;
}
MINITELEnvoyerCaractere(fd, 20);
if ( v6 == 2 )
{
if ( LOBYTE(buf[0]) == 32 )
goto LABEL_5;
}
else
{
v7 = 0;
if ( v6 <= 2 || SLOBYTE(buf[0]) <= 31 )
goto LABEL_6;
}
n = v6;
*((_BYTE *)buf + v6) = 0;
v9 = v6 - 1 + v44;
if ( v9 <= 39 )
{
v10 = 1;
}
else
{
v10 = 2;
v9 = 40 - v9;
printf("LOCAL:CalculLignes : %d\n", (unsigned int)v9);
}
printf("LOCAL:LignesTexteMinitel : %d -- CalculLignes %d\n", (unsigned int)v10, (unsigned int)v9);
MINITELCurseurXY(fd, 22, 3);
MINITELEnvoyerTexte(fd, "Envoi... ");
v37 = v4 + 1;
if ( (unsigned __int8)(v4 + 1) > 0x12u )
{
v37 = 2;
v12 = 2;
v11 = 4;
}
else
{
v11 = v4 + 3;
v12 = (unsigned __int8)(v4 + 1);
}
MINITELCurseurXY(fd, v11, 1);
MINITELEnvoyerTexte(fd, a4);
MINITELChangerAttribut(fd, 66);
printf("LigneEnCours : %d\n", v12);
if ( v6 - 1 > 0 )
{
v13 = (unsigned int)(v6 - 2);
v39 = v6;
v14 = (char *)buf;
v42 = v9;
v15 = v37;
v16 = (char *)buf + v13 + 1;
do
{
while ( 1 )
{
if ( v10 > 1 && (unsigned __int8)v15 > 0xFu )
{
v10 = 2;
if ( v44 - (unsigned int)buf + (_DWORD)v14 == 40 )
{
v10 = 1;
MINITELCurseurXY(fd, 4, 1);
v15 = 2;
MINITELChangerAttribut(fd, 66);
}
}
v17 = *v14;
if ( *v14 <= 31 )
break;
++v14;
MINITELEnvoyerCaractere(fd, v17);
if ( v16 == v14 )
goto LABEL_25;
}
++v14;
MINITELChangerAttribut(fd, 65);
MINITELEnvoyerCaractere(fd, 33);
MINITELChangerAttribut(fd, 66);
}
while ( v16 != v14 );
LABEL_25:
v37 = v15;
v6 = v39;
v9 = v42;
}
v18 = 0;
MINITELChangerAttribut(fd, 71);
v19 = v9 + 39;
if ( v19 >= 0 )
{
do
{
++v18;
MINITELEnvoyerCaractere(fd, 32);
}
while ( v19 >= v18 );
}
v20 = v37 + v10;
v4 = v20 - 1;
if ( (unsigned __int8)(v20 - 1) <= 0xEu )
{
v29 = 40;
MINITELCurseurXY(fd, v20 + 2, 1);
do
{
MINITELEnvoyerCaractere(fd, 32);
--v29;
}
while ( v29 );
}
AfficherAttenteCratyle(fd);
printf("bufMinitel:%s:%d\n", (const char *)buf, (unsigned int)v6);
if ( buf[0] == 0x5243535241454C43LL && LOWORD(buf[1]) == 17733 && BYTE2(buf[1]) == 78 )
{
v28 = 40;
puts("CRATYLE_CLEAR_SENTENCE ");
MINITELCurseurXY(fd, 2, 1);
MINITELChangerAttribut(fd, 79);
MINITELEnvoyerTexte(fd, "// (ratyle //");
MINITELChangerAttribut(fd, 76);
MINITELCurseurXY(fd, 3, 1);
do
{
MINITELEnvoyerCaractere(fd, 95);
--v28;
}
while ( v28 );
AfficherAttenteCratyle(fd);
}
else if ( buf[0] == 0x504F525054414843LL && LOWORD(buf[1]) == 17746 )
{
v4 = 1;
InitChat(fd);
AfficherAttenteCratyle(fd);
}
else
{
write(*(_DWORD *)(a2 + 4), buf, n);
}
if ( buf[0] == 0x5441524374697571LL && LOWORD(buf[1]) == 19545 && BYTE2(buf[1]) == 69 )
{
v7 = 1;
puts("CRATYLE_ESCAPE_SENTENCE ");
AfficherAurevoirCratyle(fd);
}
else
{
v7 = 0;
}
memset(buf, 0, sizeof(buf));
v49 = 0;
v50 = 0;
v51 = 0;
LABEL_6:
if ( (unsigned int)read(*a3, &v47, 1uLL) == -1 && *_errno_location() == 11 )
break;
*((_BYTE *)&v53 + v31++) = v47;
LABEL_8:
if ( v7 )
return 0LL;
}
if ( !v31 )
goto LABEL_8;
v38 = v31;
*((_BYTE *)&v53 + v31) = 0;
printf("MinitelxDansRien : strServeur %s \n", (const char *)&v53);
fcntl(fd, 4, v34);
if ( v53 != 0x5441524374697571LL || v54 != 4541529 )
{
v21 = v31 + 2;
if ( v31 + 2 <= 39 )
{
v22 = 1;
}
else
{
v22 = 2;
v21 = 40 - v21;
printf("DISTANT:CalculLignes : %d\n", v21);
}
printf("LOCAL:LignesTexteMinitel : %d -- CalculLignes %d\n", (unsigned int)v22, v21);
v32 = v4 + 1;
if ( (unsigned __int8)(v4 + 1) > 0x12u )
{
v32 = 2;
v23 = 4;
}
else
{
v23 = v4 + 3;
}
MINITELCurseurXY(fd, v23, 1);
MINITELEnvoyerTexte(fd, "-->");
MINITELChangerAttribut(fd, 66);
v40 = v7;
v24 = v32;
v43 = v21;
for ( i = 1LL; ; ++i )
{
MINITELEnvoyerCaractere(fd, *(&v52 + i));
if ( v38 == i )
break;
if ( (unsigned __int8)v24 > 0xFu && v22 > 1 && (_DWORD)i == 37 )
{
v22 = 1;
MINITELCurseurXY(fd, 4, 1);
v24 = 2;
MINITELChangerAttribut(fd, 66);
}
}
v33 = v24;
v26 = 0;
v7 = v40;
MINITELChangerAttribut(fd, 71);
if ( (int)(v43 + 39) >= 0 )
{
do
{
++v26;
MINITELEnvoyerCaractere(fd, 32);
}
while ( (int)(v43 + 39) >= v26 );
}
v27 = v33 + v22;
v4 = v27 - 1;
if ( (unsigned __int8)(v27 - 1) <= 0xEu )
{
v30 = 40;
MINITELCurseurXY(fd, v27 + 2, 1);
do
{
MINITELEnvoyerCaractere(fd, 32);
--v30;
}
while ( v30 );
}
AfficherAttenteCratyle(fd);
v31 = 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)
{
char v4; // r14
int v5; // eax
int v6; // er12
int v7; // ebx
int v9; // ebx
int v10; // ebp
char v11; // si
unsigned int v12; // er14
__int64 v13; // rdx
char *v14; // r12
char v15; // bl
char *v16; // r14
char v17; // si
int v18; // er14
int v19; // ebx
char v20; // bp
unsigned int v21; // ebp
int v22; // er12
char v23; // si
char v24; // bl
__int64 i; // rbp
int v26; // er14
char v27; // r12
int v28; // ebx
int v29; // ebx
int v30; // ebp
int v31; // [rsp+8h] [rbp-290h]
char v32; // [rsp+8h] [rbp-290h]
char v33; // [rsp+8h] [rbp-290h]
unsigned int v34; // [rsp+Ch] [rbp-28Ch]
unsigned int v36; // [rsp+18h] [rbp-280h]
char v37; // [rsp+20h] [rbp-278h]
__int64 v38; // [rsp+20h] [rbp-278h]
int v39; // [rsp+28h] [rbp-270h]
int v40; // [rsp+28h] [rbp-270h]
size_t n; // [rsp+30h] [rbp-268h]
int v42; // [rsp+38h] [rbp-260h]
unsigned int v43; // [rsp+38h] [rbp-260h]
int v44; // [rsp+3Ch] [rbp-25Ch]
char v47; // [rsp+5Fh] [rbp-239h] BYREF
_QWORD buf[31]; // [rsp+60h] [rbp-238h] BYREF
int v49; // [rsp+158h] [rbp-140h]
__int16 v50; // [rsp+15Ch] [rbp-13Ch]
char v51; // [rsp+15Eh] [rbp-13Ah]
char v52; // [rsp+15Fh] [rbp-139h]
__int64 v53; // [rsp+160h] [rbp-138h] BYREF
int v54; // [rsp+168h] [rbp-130h]

v4 = 1;
v44 = strlen(a4);
printf("ouvrir chat %i \n", (unsigned int)fd);
func10(fd);
v5 = fcntl(fd, 3, 0LL);
v31 = 0;
v34 = v5;
BYTE1(v5) |= 8u;
v36 = v5;
while ( 1 )
{
fcntl(fd, 4, v36);
v6 = read(fd, buf, 0xFFuLL);
fcntl(fd, 4, v34);
if ( v6 == -1 )
{
if ( *_errno_location() == 11 )
{
v7 = 0;
usleep(0x61A8u);
goto LABEL_6;
}
func4(fd, 20);
LABEL_5:
v7 = 0;
goto LABEL_6;
}
func4(fd, 20);
if ( v6 == 2 )
{
if ( LOBYTE(buf[0]) == 32 )
goto LABEL_5;
}
else
{
v7 = 0;
if ( v6 <= 2 || SLOBYTE(buf[0]) <= 31 )
goto LABEL_6;
}
n = v6;
*((_BYTE *)buf + v6) = 0;
v9 = v6 - 1 + v44;
if ( v9 <= 39 )
{
v10 = 1;
}
else
{
v10 = 2;
v9 = 40 - v9;
printf("LOCAL:CalculLignes : %d\n", (unsigned int)v9);
}
printf("LOCAL:LignesTexteMinitel : %d -- CalculLignes %d\n", (unsigned int)v10, (unsigned int)v9);
func6(fd, 22, 3);
func5(fd, "Envoi... ");
v37 = v4 + 1;
if ( (unsigned __int8)(v4 + 1) > 0x12u )
{
v37 = 2;
v12 = 2;
v11 = 4;
}
else
{
v11 = v4 + 3;
v12 = (unsigned __int8)(v4 + 1);
}
func6(fd, v11, 1);
func5(fd, a4);
func8(fd, 66);
printf("LigneEnCours : %d\n", v12);
if ( v6 - 1 > 0 )
{
v13 = (unsigned int)(v6 - 2);
v39 = v6;
v14 = (char *)buf;
v42 = v9;
v15 = v37;
v16 = (char *)buf + v13 + 1;
do
{
while ( 1 )
{
if ( v10 > 1 && (unsigned __int8)v15 > 0xFu )
{
v10 = 2;
if ( v44 - (unsigned int)buf + (_DWORD)v14 == 40 )
{
v10 = 1;
func6(fd, 4, 1);
v15 = 2;
func8(fd, 66);
}
}
v17 = *v14;
if ( *v14 <= 31 )
break;
++v14;
func4(fd, v17);
if ( v16 == v14 )
goto LABEL_25;
}
++v14;
func8(fd, 65);
func4(fd, 33);
func8(fd, 66);
}
while ( v16 != v14 );
LABEL_25:
v37 = v15;
v6 = v39;
v9 = v42;
}
v18 = 0;
func8(fd, 71);
v19 = v9 + 39;
if ( v19 >= 0 )
{
do
{
++v18;
func4(fd, 32);
}
while ( v19 >= v18 );
}
v20 = v37 + v10;
v4 = v20 - 1;
if ( (unsigned __int8)(v20 - 1) <= 0xEu )
{
v29 = 40;
func6(fd, v20 + 2, 1);
do
{
func4(fd, 32);
--v29;
}
while ( v29 );
}
func10(fd);
printf("bufMinitel:%s:%d\n", (const char *)buf, (unsigned int)v6);
if ( buf[0] == 0x5243535241454C43LL && LOWORD(buf[1]) == 17733 && BYTE2(buf[1]) == 78 )
{
v28 = 40;
puts("CRATYLE_CLEAR_SENTENCE ");
func6(fd, 2, 1);
func8(fd, 79);
func5(fd, "// (ratyle //");
func8(fd, 76);
func6(fd, 3, 1);
do
{
func4(fd, 95);
--v28;
}
while ( v28 );
func10(fd);
}
else if ( buf[0] == 0x504F525054414843LL && LOWORD(buf[1]) == 17746 )
{
v4 = 1;
func9(fd);
func10(fd);
}
else
{
write(*(_DWORD *)(a2 + 4), buf, n);
}
if ( buf[0] == 0x5441524374697571LL && LOWORD(buf[1]) == 19545 && BYTE2(buf[1]) == 69 )
{
v7 = 1;
puts("CRATYLE_ESCAPE_SENTENCE ");
func11(fd);
}
else
{
v7 = 0;
}
memset(buf, 0, sizeof(buf));
v49 = 0;
v50 = 0;
v51 = 0;
LABEL_6:
if ( (unsigned int)read(*a3, &v47, 1uLL) == -1 && *_errno_location() == 11 )
break;
*((_BYTE *)&v53 + v31++) = v47;
LABEL_8:
if ( v7 )
return 0LL;
}
if ( !v31 )
goto LABEL_8;
v38 = v31;
*((_BYTE *)&v53 + v31) = 0;
printf("MinitelxDansRien : strServeur %s \n", (const char *)&v53);
fcntl(fd, 4, v34);
if ( v53 != 0x5441524374697571LL || v54 != 4541529 )
{
v21 = v31 + 2;
if ( v31 + 2 <= 39 )
{
v22 = 1;
}
else
{
v22 = 2;
v21 = 40 - v21;
printf("DISTANT:CalculLignes : %d\n", v21);
}
printf("LOCAL:LignesTexteMinitel : %d -- CalculLignes %d\n", (unsigned int)v22, v21);
v32 = v4 + 1;
if ( (unsigned __int8)(v4 + 1) > 0x12u )
{
v32 = 2;
v23 = 4;
}
else
{
v23 = v4 + 3;
}
func6(fd, v23, 1);
func5(fd, "-->");
func8(fd, 66);
v40 = v7;
v24 = v32;
v43 = v21;
for ( i = 1LL; ; ++i )
{
func4(fd, *(&v52 + i));
if ( v38 == i )
break;
if ( (unsigned __int8)v24 > 0xFu && v22 > 1 && (_DWORD)i == 37 )
{
v22 = 1;
func6(fd, 4, 1);
v24 = 2;
func8(fd, 66);
}
}
v33 = v24;
v26 = 0;
v7 = v40;
func8(fd, 71);
if ( (int)(v43 + 39) >= 0 )
{
do
{
++v26;
func4(fd, 32);
}
while ( (int)(v43 + 39) >= v26 );
}
v27 = v33 + v22;
v4 = v27 - 1;
if ( (unsigned __int8)(v27 - 1) <= 0xEu )
{
v30 = 40;
func6(fd, v27 + 2, 1);
do
{
func4(fd, 32);
--v30;
}
while ( v30 );
}
func10(fd);
v31 = 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

decompiled_code:
__int64 TestImprime()
{
unsigned int v0; // eax
unsigned int v1; // er12
char *v2; // rbx
__int64 v3; // rdi
_BYTE v5[88]; // [rsp+0h] [rbp-58h] BYREF

v0 = OuvrirConnectionImprimante("/dev/ttyUSB3", v5);
v1 = v0;
if ( v0 == -1 )
{
perror("OuvrirConnectionImprim 1 failed!");
return v1;
}
v2 = (char *)&CratyleDico;
MINITELEnvoyerCaractere(v0, 12LL);
do
{
v3 = *(_QWORD *)v2;
v2 += 2000;
CratyleImprime(v3, v1);
usleep(0x61A8u);
}
while ( v2 != (char *)&CratyleDico + 1200000 );
if ( !v1 )
return v1;
FermerConnection(v1, v5);
return 0LL;
}

canonical_decompiled_code:
__int64 func0()
{
unsigned int v0; // eax
unsigned int v1; // er12
char *v2; // rbx
__int64 v3; // rdi
_BYTE v5[88]; // [rsp+0h] [rbp-58h] BYREF

v0 = OuvrirConnectionImprimante("/dev/ttyUSB3", v5);
v1 = v0;
if ( v0 == -1 )
{
perror("OuvrirConnectionImprim 1 failed!");
return v1;
}
v2 = (char *)&CratyleDico;
MINITELEnvoyerCaractere(v0, 12LL);
do
{
v3 = *(_QWORD *)v2;
v2 += 2000;
CratyleImprime(v3, v1);
usleep(0x61A8u);
}
while ( v2 != (char *)&CratyleDico + 1200000 );
if ( !v1 )
return v1;
FermerConnection(v1, v5);
return 0LL;
}

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


TestOuverture

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

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

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

v0 = OuvrirConnectionMinitel("/dev/ttyUSB0", &v4);
if ( v0 == -1 )
{
perror("OuvrirConnectionMinitel 1 failed!");
}
else
{
v1 = OuvrirConnectionMinitel("/dev/ttyUSB1", v5);
if ( v1 == -1 )
{
v0 = -1;
perror("OuvrirConnectionMinitel 2 failed!");
}
else
{
printf("TestOuverture chat 1 %i \n", v0);
printf("TestOuverture chat 2 %i \n", v1);
v2 = v0;
v0 = 0;
AfficherAttenteCratyle(v2);
AfficherAttenteCratyle(v1);
}
}
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;
}


TestSalopeDeCigale

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

v0 = 100;
memset(v3, 0, sizeof(v3));
v2[0] = (__int128)_mm_load_si128((const __m128i *)&LC17);
v2[1] = 0LL;
v7 = 0LL;
v4 = 0;
v5 = 0;
v6 = 0;
memset(v8, 0, sizeof(v8));
v9 = 0;
v10 = 0;
v11 = 0;
do
{
Cratylation(v2, &v7, 0LL);
result = printf("%s ", (const char *)&v7);
--v0;
}
while ( v0 );
return result;
}

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

v0 = 100;
memset(v3, 0, sizeof(v3));
v2[0] = (__int128)_mm_load_si128((const __m128i *)&LC17);
v2[1] = 0LL;
v7 = 0LL;
v4 = 0;
v5 = 0;
v6 = 0;
memset(v8, 0, sizeof(v8));
v9 = 0;
v10 = 0;
v11 = 0;
do
{
Cratylation(v2, &v7, 0LL);
result = printf("%s ", (const char *)&v7);
--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


CratyleGenre

decompiled_code:
__int64 __fastcall CratyleGenre(char *s1)
{
__int64 v1; // rbx
__int64 v2; // r12
const char *v3; // rsi

v1 = 0LL;
do
{
v2 = (int)v1;
v3 = (&CratyleBaseGenreNombre)[3 * v1];
if ( !v3 )
return 0LL;
++v1;
}
while ( strcmp(s1, v3) );
if ( (unsigned __int8)(*(&CratyleBaseGenreNombre)[3 * v2 + 1] - 70) > 8u )
return 0LL;
return (unsigned int)CSWTCH_17[(unsigned __int8)(*(&CratyleBaseGenreNombre)[3 * v2 + 1] - 70)];
}

canonical_decompiled_code:
__int64 __fastcall func1(char *s1)
{
__int64 v1; // rbx
__int64 v2; // r12
const char *v3; // rsi

v1 = 0LL;
do
{
v2 = (int)v1;
v3 = (&CratyleBaseGenreNombre)[3 * v1];
if ( !v3 )
return 0LL;
++v1;
}
while ( strcmp(s1, v3) );
if ( (unsigned __int8)(*(&CratyleBaseGenreNombre)[3 * v2 + 1] - 70) > 8u )
return 0LL;
return (unsigned int)CSWTCH_17[(unsigned __int8)(*(&CratyleBaseGenreNombre)[3 * v2 + 1] - 70)];
}

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)
{
int v3; // ebp
const char **v4; // rbx
const char *v5; // rsi
__int64 result; // rax

v3 = -1;
v4 = (const char **)&CratyleBaseGenreNombre;
do
{
v5 = *v4;
++v3;
if ( !*v4 )
{
if ( a2 )
*a2 = -1;
return 0LL;
}
v4 += 3;
}
while ( strcasecmp(s1, v5) );
if ( a2 )
{
*a2 = -1;
if ( (unsigned __int8)((&CratyleBaseGenreNombre)[3 * v3 + 1][1] - 73) > 0xAu )
result = 0LL;
else
result = (unsigned int)CSWTCH_20[(unsigned __int8)((&CratyleBaseGenreNombre)[3 * v3 + 1][1] - 73)];
*a2 = v3;
}
else
{
result = 0LL;
if ( (unsigned __int8)((&CratyleBaseGenreNombre)[3 * v3 + 1][1] - 73) <= 0xAu )
result = (unsigned int)CSWTCH_20[(unsigned __int8)((&CratyleBaseGenreNombre)[3 * v3 + 1][1] - 73)];
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(char *s1, int *a2)
{
int v3; // ebp
const char **v4; // rbx
const char *v5; // rsi
__int64 result; // rax

v3 = -1;
v4 = (const char **)&CratyleBaseGenreNombre;
do
{
v5 = *v4;
++v3;
if ( !*v4 )
{
if ( a2 )
*a2 = -1;
return 0LL;
}
v4 += 3;
}
while ( strcasecmp(s1, v5) );
if ( a2 )
{
*a2 = -1;
if ( (unsigned __int8)((&CratyleBaseGenreNombre)[3 * v3 + 1][1] - 73) > 0xAu )
result = 0LL;
else
result = (unsigned int)CSWTCH_20[(unsigned __int8)((&CratyleBaseGenreNombre)[3 * v3 + 1][1] - 73)];
*a2 = v3;
}
else
{
result = 0LL;
if ( (unsigned __int8)((&CratyleBaseGenreNombre)[3 * v3 + 1][1] - 73) <= 0xAu )
result = (unsigned int)CSWTCH_20[(unsigned __int8)((&CratyleBaseGenreNombre)[3 * v3 + 1][1] - 73)];
}
return result;
}

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)
{
void *v1; // r8
char *v2; // rbp
size_t v3; // rbx
void *v4; // rax

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

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

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

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:
char *__fastcall CratyleMotPluriel(char *s1)
{
__int64 v1; // rbx
const char *v2; // rsi
int v3; // ebp
char *v4; // r8
__int64 v6; // rbp
__int64 v7; // rbx
char **v8; // rax
int v9; // eax
char *v10; // rbp
size_t v11; // rbx
char *v12; // rax

v1 = -1LL;
do
{
v3 = v1;
v4 = (&CratyleBaseGenreNombre)[3 * v1 + 3];
if ( !v4 )
return v4;
v2 = (&CratyleBaseGenreNombre)[3 * v1++ + 3];
}
while ( strcmp(s1, v2) );
v6 = v3 + 2;
v7 = 3 * v6;
v8 = &(&CratyleBaseGenreNombre)[3 * v6];
if ( v8[1][1] != 80 )
return 0LL;
v4 = v8[2];
if ( !v4 )
return v4;
v9 = strcmp(s1, v8[2]);
v4 = 0LL;
if ( v9 )
return v4;
v10 = (&CratyleBaseGenreNombre)[3 * v6];
v11 = strlen((&CratyleBaseGenreNombre)[v7]);
v12 = (char *)malloc(v11);
v4 = v12;
if ( !v12 )
return v4;
return (char *)memcpy(v12, v10, v11 + 1);
}

canonical_decompiled_code:
char *__fastcall func6(char *s1)
{
__int64 v1; // rbx
const char *v2; // rsi
int v3; // ebp
char *v4; // r8
__int64 v6; // rbp
__int64 v7; // rbx
char **v8; // rax
int v9; // eax
char *v10; // rbp
size_t v11; // rbx
char *v12; // rax

v1 = -1LL;
do
{
v3 = v1;
v4 = (&CratyleBaseGenreNombre)[3 * v1 + 3];
if ( !v4 )
return v4;
v2 = (&CratyleBaseGenreNombre)[3 * v1++ + 3];
}
while ( strcmp(s1, v2) );
v6 = v3 + 2;
v7 = 3 * v6;
v8 = &(&CratyleBaseGenreNombre)[3 * v6];
if ( v8[1][1] != 80 )
return 0LL;
v4 = v8[2];
if ( !v4 )
return v4;
v9 = strcmp(s1, v8[2]);
v4 = 0LL;
if ( v9 )
return v4;
v10 = (&CratyleBaseGenreNombre)[3 * v6];
v11 = strlen((&CratyleBaseGenreNombre)[v7]);
v12 = (char *)malloc(v11);
v4 = v12;
if ( !v12 )
return v4;
return (char *)memcpy(v12, v10, v11 + 1);
}

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)
{
__int64 v2; // rdx

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

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

if ( !a1 )
return 0xFFFFFFFFLL;
if ( !a2 )
return 0xFFFFFFFFLL;
v2 = iCaracteresImprime_0 + (unsigned int)strlen(a1) + 1;
if ( (int)v2 > 1920 )
{
iCaracteresImprime_0 = 0;
MINITELEnvoyerCaractere(a2, 12LL);
v2 = (unsigned int)iCaracteresImprime_0;
}
else
{
iCaracteresImprime_0 = v2;
}
printf("CratyleImprime %s - nb : %d\n", a1, v2);
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:
__int64 CratyleInit()
{
__int64 v0; // rdx
__int64 v1; // rcx
__int64 v2; // rdi
__int64 i; // rax
int v4; // esi
__int64 result; // rax

v0 = CratyleDico[0];
if ( CratyleDico[0] )
{
v1 = 0LL;
v2 = 1LL;
do
{
for ( i = -1LL; ; v0 = CratyleDico[i + 1 + v1] )
{
v4 = i++;
if ( !v0 )
break;
}
v0 = CratyleDico[v1 + 250];
*((_DWORD *)&CratyleIndex + v2 - 1) = v4;
result = (unsigned int)v2;
v1 += 250LL;
++v2;
}
while ( v0 );
CratyleDicoIndex = result;
}
else
{
result = 0LL;
CratyleDicoIndex = 0;
}
return result;
}

canonical_decompiled_code:
__int64 func8()
{
__int64 v0; // rdx
__int64 v1; // rcx
__int64 v2; // rdi
__int64 i; // rax
int v4; // esi
__int64 result; // rax

v0 = CratyleDico[0];
if ( CratyleDico[0] )
{
v1 = 0LL;
v2 = 1LL;
do
{
for ( i = -1LL; ; v0 = CratyleDico[i + 1 + v1] )
{
v4 = i++;
if ( !v0 )
break;
}
v0 = CratyleDico[v1 + 250];
*((_DWORD *)&CratyleIndex + v2 - 1) = v4;
result = (unsigned int)v2;
v1 += 250LL;
++v2;
}
while ( v0 );
CratyleDicoIndex = result;
}
else
{
result = 0LL;
CratyleDicoIndex = 0;
}
return result;
}

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; // rax
const unsigned __int16 *v5; // r13
size_t result; // rax

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

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

*a2 = 0;
*a3 = 0;
v4 = _ctype_b_loc();
v5 = *v4;
if ( ((*v4)[*s] & 0x200) == 0 )
*a2 = 1;
result = strlen(s);
if ( result > 1 )
{
result = s[1];
if ( (v5[result] & 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; // r12
const __int32_t *v2; // rcx
char *v3; // rax
__int64 v4; // rdx

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

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

v1 = strdup(a1);
v2 = *_ctype_toupper_loc();
v3 = v1;
do
{
v4 = *v3++;
LODWORD(v4) = v2[v4];
*(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 *