miseAJour

decompiled_code:
void __fastcall miseAJour(const char ***a1, const char **a2)
{
const char ***v2; // rbp
const char **v3; // rax
char *v4; // r13
const char *v5; // r14
char v6[41]; // [rsp+1h] [rbp-29h] BYREF

if ( a2 )
{
v2 = recherche(a1, a2);
v3 = *v2;
if ( *v2 && (v4 = (char *)*v3) != 0LL && (v5 = *a2, !strcmp(*v3, *a2)) )
{
strcpy(v4, v5);
strcpy((char *)(*v2)[1], a2[1]);
strcpy((char *)(*v2)[2], a2[2]);
strcpy((char *)(*v2)[3], a2[3]);
}
else
{
puts(aLaFiche);
printf(aVoulezVousEnIn);
fflush(stdout);
scanf("%c%*c", v6);
if ( (v6[0] & 0xDF) == 79 )
inserer(a1, a2);
}
}
}

canonical_decompiled_code:
void __fastcall func7(const char ***a1, const char **a2)
{
const char ***v2; // rbp
const char **v3; // rax
char *v4; // r13
const char *v5; // r14
char v6[41]; // [rsp+1h] [rbp-29h] BYREF

if ( a2 )
{
v2 = func1(a1, a2);
v3 = *v2;
if ( *v2 && (v4 = (char *)*v3) != 0LL && (v5 = *a2, !strcmp(*v3, *a2)) )
{
strcpy(v4, v5);
strcpy((char *)(*v2)[1], a2[1]);
strcpy((char *)(*v2)[2], a2[2]);
strcpy((char *)(*v2)[3], a2[3]);
}
else
{
puts(aLaFiche);
printf(aVoulezVousEnIn);
fflush(stdout);
scanf("%c%*c", v6);
if ( (v6[0] & 0xDF) == 79 )
func4(a1, a2);
}
}
}

original_code:
void miseAJour (noeud_t ** pracine, noeud_t * saisie_t)
{
    noeud_t ** cour;
    char choix_t;
    if (saisie_t != ((void *)0))
    {
        cour = recherche(pracine,saisie_t);
        if (((*cour) == ((void *)0)) || ((**cour).nom == ((void *)0)) || ((strcmp((**cour).nom,(*saisie_t).nom)) != 0))
        {
            printf("La fiche à mettre à jour n'existe pas !\n");
            printf("Voulez-vous en insérer une nouvelle ? ([O]ui/[N]on) ");
            fflush(stdout);
            scanf("%c%*c",&choix_t);
            if ((choix_t == 'O') || (choix_t == 'o'))
            {
                inserer(pracine,saisie_t);
            }
        }
        else
        {
            strcpy((**cour).nom,(*saisie_t).nom);
            strcpy((**cour).prenom,(*saisie_t).prenom);
            strcpy((**cour).login,(*saisie_t).login);
            strcpy((**cour).mdp,(*saisie_t).mdp);
        }
    }
}

canonical_original_code:
void miseAJour(struct noeud **pracine, struct noeud *saisie_t)
{
    struct noeud **cour;
    char choix_t;
    if (saisie_t != ((void *)0))
    {
        cour = recherche(pracine,saisie_t);
        if (((*cour) == ((void *)0)) || ((**cour).nom == ((void *)0)) || ((strcmp((**cour).nom,(*saisie_t).nom)) != 0))
        {
            printf("La fiche à mettre à jour n'existe pas !\n");
            printf("Voulez-vous en insérer une nouvelle ? ([O]ui/[N]on) ");
            fflush(stdout);
            scanf("%c%*c",&choix_t);
            if ((choix_t == 'O') || (choix_t == 'o'))
            {
                inserer(pracine,saisie_t);
            }
        }
        else
        {
            strcpy((**cour).nom,(*saisie_t).nom);
            strcpy((**cour).prenom,(*saisie_t).prenom);
            strcpy((**cour).login,(*saisie_t).login);
            strcpy((**cour).mdp,(*saisie_t).mdp);
        }
    }
}


rechercheNom

repo: vlnk/isima

decompiled_code:
void __fastcall rechercheNom(__int64 a1, const char *a2)
{
const char *v2; // r12

if ( a1 )
{
v2 = *(const char **)a1;
if ( *(_QWORD *)a1 )
{
if ( !strcmp(*(const char **)a1, a2) )
{
printf("[nom : %s]\n", v2);
printf("[prenom : %s]\n", *(const char **)(a1 + 8));
printf("[login : %s]\n", *(const char **)(a1 + 16));
printf("[mdp : %s]\n", *(const char **)(a1 + 24));
putchar(10);
}
rechercheNom(*(_QWORD *)(a1 + 40), a2);
rechercheNom(*(_QWORD *)(a1 + 32), a2);
}
}
}

canonical_decompiled_code:
void __fastcall func8(__int64 a1, const char *a2)
{
const char *v2; // r12

if ( a1 )
{
v2 = *(const char **)a1;
if ( *(_QWORD *)a1 )
{
if ( !strcmp(*(const char **)a1, a2) )
{
printf("[nom : %s]\n", v2);
printf("[prenom : %s]\n", *(const char **)(a1 + 8));
printf("[login : %s]\n", *(const char **)(a1 + 16));
printf("[mdp : %s]\n", *(const char **)(a1 + 24));
putchar(10);
}
func8(*(_QWORD *)(a1 + 40), a2);
func8(*(_QWORD *)(a1 + 32), a2);
}
}
}

original_code:
void rechercheNom (noeud_t * r,char * nom_t)
{
    int comp_nom = 0;
    if ((r != ((void *)0)) && ((*r).nom != ((void *)0)))
    {
        comp_nom = strcmp((*r).nom,nom_t);
        if (comp_nom == 0)
        {
            printf("[nom : %s]\n",(*r).nom);
            printf("[prenom : %s]\n",(*r).prenom);
            printf("[login : %s]\n",(*r).login);
            printf("[mdp : %s]\n",(*r).mdp);
            printf("\n");
        }
        rechercheNom((*r).d,nom_t);
        rechercheNom((*r).g,nom_t);
    }
}

canonical_original_code:
void rechercheNom(struct noeud *r, char *nom_t)
{
    int comp_nom = 0;
    if ((r != ((void *)0)) && ((*r).nom != ((void *)0)))
    {
        comp_nom = strcmp((*r).nom,nom_t);
        if (comp_nom == 0)
        {
            printf("[nom : %s]\n",(*r).nom);
            printf("[prenom : %s]\n",(*r).prenom);
            printf("[login : %s]\n",(*r).login);
            printf("[mdp : %s]\n",(*r).mdp);
            printf("\n");
        }
        rechercheNom((*r).d,nom_t);
        rechercheNom((*r).g,nom_t);
    }
}

variable_types: struct noeud { char *nom; char *prenom; char *login; char *mdp; struct noeud *g; struct noeud *d; } *

return_type: void


recherchePrenom

decompiled_code:
void __fastcall recherchePrenom(__int64 a1, const char *a2)
{
const char *v2; // r12

if ( a1 )
{
v2 = *(const char **)a1;
if ( *(_QWORD *)a1 )
{
if ( !strcmp(*(const char **)(a1 + 8), a2) )
{
printf("[nom : %s]\n", v2);
printf("[prenom : %s]\n", *(const char **)(a1 + 8));
printf("[login : %s]\n", *(const char **)(a1 + 16));
printf("[mdp : %s]\n", *(const char **)(a1 + 24));
putchar(10);
}
recherchePrenom(*(_QWORD *)(a1 + 40), a2);
recherchePrenom(*(_QWORD *)(a1 + 32), a2);
}
}
}

canonical_decompiled_code:
void __fastcall func9(__int64 a1, const char *a2)
{
const char *v2; // r12

if ( a1 )
{
v2 = *(const char **)a1;
if ( *(_QWORD *)a1 )
{
if ( !strcmp(*(const char **)(a1 + 8), a2) )
{
printf("[nom : %s]\n", v2);
printf("[prenom : %s]\n", *(const char **)(a1 + 8));
printf("[login : %s]\n", *(const char **)(a1 + 16));
printf("[mdp : %s]\n", *(const char **)(a1 + 24));
putchar(10);
}
func9(*(_QWORD *)(a1 + 40), a2);
func9(*(_QWORD *)(a1 + 32), a2);
}
}
}

original_code:
void recherchePrenom (noeud_t * r, char * prenom_t)
{
    int comp_prenom = 0;
    if ((r != ((void *)0)) && ((*r).nom != ((void *)0)))
    {
        comp_prenom = strcmp((*r).prenom,prenom_t);
        if (comp_prenom == 0)
        {
            printf("[nom : %s]\n",(*r).nom);
            printf("[prenom : %s]\n",(*r).prenom);
            printf("[login : %s]\n",(*r).login);
            printf("[mdp : %s]\n",(*r).mdp);
            printf("\n");
        }
        recherchePrenom((*r).d,prenom_t);
        recherchePrenom((*r).g,prenom_t);
    }
}

canonical_original_code:
void recherchePrenom(struct noeud *r, char *prenom_t)
{
    int comp_prenom = 0;
    if ((r != ((void *)0)) && ((*r).nom != ((void *)0)))
    {
        comp_prenom = strcmp((*r).prenom,prenom_t);
        if (comp_prenom == 0)
        {
            printf("[nom : %s]\n",(*r).nom);
            printf("[prenom : %s]\n",(*r).prenom);
            printf("[login : %s]\n",(*r).login);
            printf("[mdp : %s]\n",(*r).mdp);
            printf("\n");
        }
        recherchePrenom((*r).d,prenom_t);
        recherchePrenom((*r).g,prenom_t);
    }
}

user_defined_types: struct noeud { char *nom; char *prenom; char *login; char *mdp; struct noeud *g; struct noeud *d; }


original_code:
void affiche_menu ()
{
    printf("\n");
    printf("#-------------------------------#\n");
    printf("#      Gestion de fichiers      #\n");
    printf("#                               #\n");
    printf("# 0 -> Quitter                  #\n");
    printf("# 1 -> Affichage                #\n");
    printf("# 2 -> Insertion/Mise a jour    #\n");
    printf("# 3 -> Suppression              #\n");
    printf("# 4 -> Recherche                #\n");
    printf("# 5 -> Ecriture                 #\n");
    printf("# 6 -> Lecture                  #\n");
    printf("# 7 -> Liberation               #\n");
    printf("#-------------------------------#\n");
    printf("\n");
}

canonical_original_code:
void affiche_menu()
{
    printf("\n");
    printf("#-------------------------------#\n");
    printf("#      Gestion de fichiers      #\n");
    printf("#                               #\n");
    printf("# 0 -> Quitter                  #\n");
    printf("# 1 -> Affichage                #\n");
    printf("# 2 -> Insertion/Mise a jour    #\n");
    printf("# 3 -> Suppression              #\n");
    printf("# 4 -> Recherche                #\n");
    printf("# 5 -> Ecriture                 #\n");
    printf("# 6 -> Lecture                  #\n");
    printf("# 7 -> Liberation               #\n");
    printf("#-------------------------------#\n");
    printf("\n");
}


saisie

decompiled_code:
char **saisie()
{
char **v0; // rax
char **v1; // rbx
char *v2; // r14
char *v3; // r13
char *v4; // r12
char *v5; // rbp
char v7[32]; // [rsp+1h] [rbp-A9h]
char v8[32]; // [rsp+2h] [rbp-A8h] BYREF
char v9[32]; // [rsp+22h] [rbp-88h] BYREF
char src[32]; // [rsp+42h] [rbp-68h] BYREF
char s[72]; // [rsp+62h] [rbp-48h] BYREF

v0 = (char **)malloc(0x30uLL);
v1 = v0;
if ( v0 )
{
*v0 = 0LL;
v0[1] = 0LL;
v0[5] = 0LL;
v0[4] = 0LL;
printf("Quel nom ? ");
fflush(stdout);
fgets(s, 32, stdin);
src[strlen(s) + 31] = 0;
printf(aQuelPr);
fflush(stdout);
fgets(src, 32, stdin);
v9[strlen(src) + 31] = 0;
printf("Quel login ? ");
fflush(stdout);
fgets(v9, 32, stdin);
v8[strlen(v9) + 31] = 0;
printf("Quel mot de passe ? ");
fflush(stdout);
fgets(v8, 32, stdin);
v7[strlen(v8)] = 0;
if ( src[0] && s[0] )
{
v2 = (char *)malloc(0x20uLL);
*v1 = v2;
v3 = (char *)malloc(0x20uLL);
v1[1] = v3;
v4 = (char *)malloc(0x20uLL);
v1[2] = v4;
v5 = (char *)malloc(0x20uLL);
v1[3] = v5;
if ( v4 == 0LL || v2 == 0LL || v3 == 0LL || !v5 )
{
puts("Allocation impossible !");
}
else
{
strcpy(v2, s);
strcpy(v3, src);
strcpy(v4, v9);
strcpy(v5, v8);
v1[4] = 0LL;
v1[5] = 0LL;
}
}
else
{
puts(aFicheIncompl);
v1 = 0LL;
}
}
else
{
puts(aLAlloctionA);
}
return v1;
}

canonical_decompiled_code:
char **func3()
{
char **v0; // rax
char **v1; // rbx
char *v2; // r14
char *v3; // r13
char *v4; // r12
char *v5; // rbp
char v7[32]; // [rsp+1h] [rbp-A9h]
char v8[32]; // [rsp+2h] [rbp-A8h] BYREF
char v9[32]; // [rsp+22h] [rbp-88h] BYREF
char src[32]; // [rsp+42h] [rbp-68h] BYREF
char s[72]; // [rsp+62h] [rbp-48h] BYREF

v0 = (char **)malloc(0x30uLL);
v1 = v0;
if ( v0 )
{
*v0 = 0LL;
v0[1] = 0LL;
v0[5] = 0LL;
v0[4] = 0LL;
printf("Quel nom ? ");
fflush(stdout);
fgets(s, 32, stdin);
src[strlen(s) + 31] = 0;
printf(aQuelPr);
fflush(stdout);
fgets(src, 32, stdin);
v9[strlen(src) + 31] = 0;
printf("Quel login ? ");
fflush(stdout);
fgets(v9, 32, stdin);
v8[strlen(v9) + 31] = 0;
printf("Quel mot de passe ? ");
fflush(stdout);
fgets(v8, 32, stdin);
v7[strlen(v8)] = 0;
if ( src[0] && s[0] )
{
v2 = (char *)malloc(0x20uLL);
*v1 = v2;
v3 = (char *)malloc(0x20uLL);
v1[1] = v3;
v4 = (char *)malloc(0x20uLL);
v1[2] = v4;
v5 = (char *)malloc(0x20uLL);
v1[3] = v5;
if ( v4 == 0LL || v2 == 0LL || v3 == 0LL || !v5 )
{
puts("Allocation impossible !");
}
else
{
strcpy(v2, s);
strcpy(v3, src);
strcpy(v4, v9);
strcpy(v5, v8);
v1[4] = 0LL;
v1[5] = 0LL;
}
}
else
{
puts(aFicheIncompl);
v1 = 0LL;
}
}
else
{
puts(aLAlloctionA);
}
return v1;
}

original_code:
noeud_t * saisie ()
{
    noeud_t * saisie_t;
    char nom[32];
    char prenom[32];
    char login[32];
    char mdp[32];
    saisie_t = (noeud_t *) malloc(sizeof(noeud_t));
    if (saisie_t == ((void *)0))
    {
        printf("L'alloction a échoué !\n");
    }
    else
    {
        (*saisie_t).nom = ((void *)0);
        (*saisie_t).prenom = ((void *)0);
        (*saisie_t).d = ((void *)0);
        (*saisie_t).g = ((void *)0);
        printf("Quel nom ? ");
        fflush(stdout);
        fgets(nom, 32, stdin);
        nom[strlen(nom) - 1] = '\0';
        printf("Quel prénom ? ");
        fflush(stdout);
        fgets(prenom, 32, stdin);
        prenom[strlen(prenom) - 1] = '\0';
        printf("Quel login ? ");
        fflush(stdout);
        fgets(login, 32, stdin);
        login[strlen(login) - 1] = '\0';
        printf("Quel mot de passe ? ");
        fflush(stdout);
        fgets(mdp, 32, stdin);
        mdp[strlen(mdp) - 1] = '\0';
        if ((strcmp(prenom,"\0") != 0) && (strcmp(nom,"\0") != 0))
        {
            (*saisie_t).nom = (char *) malloc(sizeof(char)*32);
            (*saisie_t).prenom = (char *) malloc(sizeof(char)*32);
            (*saisie_t).login = (char *) malloc(sizeof(char)*32);
            (*saisie_t).mdp = (char *) malloc(sizeof(char)*32);
            if (((*saisie_t).nom == ((void *)0)) || ((*saisie_t).prenom == ((void *)0)) || ((*saisie_t).login == ((void *)0)) || ((*saisie_t).mdp == ((void *)0)))
            {
                printf("Allocation impossible !\n");
            }
            else
            {
                strcpy((*saisie_t).nom,nom);
                strcpy((*saisie_t).prenom,prenom);
                strcpy((*saisie_t).login,login);
                strcpy((*saisie_t).mdp,mdp);
                (*saisie_t).g = ((void *)0);
                (*saisie_t).d = ((void *)0);
            }
        }
        else
        {
            printf("Fiche incomplète !\n");
            saisie_t = ((void *)0);
        }
    }
    return saisie_t;
}

canonical_original_code:
struct noeud *saisie()
{
    struct noeud *saisie_t;
    char nom[32];
    char prenom[32];
    char login[32];
    char mdp[32];
    saisie_t = (struct noeud *) malloc(sizeof(noeud_t));
    if (saisie_t == ((void *)0))
    {
        printf("L'alloction a échoué !\n");
    }
    else
    {
        (*saisie_t).nom = ((void *)0);
        (*saisie_t).prenom = ((void *)0);
        (*saisie_t).d = ((void *)0);
        (*saisie_t).g = ((void *)0);
        printf("Quel nom ? ");
        fflush(stdout);
        fgets(nom, 32, stdin);
        nom[strlen(nom) - 1] = '\0';
        printf("Quel prénom ? ");
        fflush(stdout);
        fgets(prenom, 32, stdin);
        prenom[strlen(prenom) - 1] = '\0';
        printf("Quel login ? ");
        fflush(stdout);
        fgets(login, 32, stdin);
        login[strlen(login) - 1] = '\0';
        printf("Quel mot de passe ? ");
        fflush(stdout);
        fgets(mdp, 32, stdin);
        mdp[strlen(mdp) - 1] = '\0';
        if ((strcmp(prenom,"\0") != 0) && (strcmp(nom,"\0") != 0))
        {
            (*saisie_t).nom = (char *) malloc(sizeof(char)*32);
            (*saisie_t).prenom = (char *) malloc(sizeof(char)*32);
            (*saisie_t).login = (char *) malloc(sizeof(char)*32);
            (*saisie_t).mdp = (char *) malloc(sizeof(char)*32);
            if (((*saisie_t).nom == ((void *)0)) || ((*saisie_t).prenom == ((void *)0)) || ((*saisie_t).login == ((void *)0)) || ((*saisie_t).mdp == ((void *)0)))
            {
                printf("Allocation impossible !\n");
            }
            else
            {
                strcpy((*saisie_t).nom,nom);
                strcpy((*saisie_t).prenom,prenom);
                strcpy((*saisie_t).login,login);
                strcpy((*saisie_t).mdp,mdp);
                (*saisie_t).g = ((void *)0);
                (*saisie_t).d = ((void *)0);
            }
        }
        else
        {
            printf("Fiche incomplète !\n");
            saisie_t = ((void *)0);
        }
    }
    return saisie_t;
}

variable_types:
nom
char [32]

variable_types:
prenom
char [32]

variable_types:
login
char [32]

variable_types:
mdp
char [32]

return_type: struct noeud { char *nom; char *prenom; char *login; char *mdp; struct noeud *g; struct noeud *d; } *


InsertionBil

original_code:
bilatere_t ** InsertionBil(bilatere_t ** b, bilatere_t * elt)
{
    elt->suiv = (**b).suiv;
    elt->prec = *b;
    (*b)->suiv->prec = elt;
    (*b)->suiv = elt;
    return &(**b).suiv;
}

canonical_original_code:
struct struct4 **InsertionBil(struct struct4 **b, struct struct4 *elt)
{
    elt->suiv = (**b).suiv;
    elt->prec = *b;
    (*b)->suiv->prec = elt;
    (*b)->suiv = elt;
    return &(**b).suiv;
}

variable_types:
b
struct struct4 **

variable_types:
elt
struct struct4 *

return_type: struct struct4 { char chaine_sem[7]; struct struct2 { char chaine_act[-1]; struct struct2 *suiv; } *action_s; struct struct4 *prec; struct struct4 *suiv; } **

user_defined_types: struct struct4 { char chaine_sem[7]; struct struct2 *action_s; struct struct4 *prec; struct struct4 *suiv; }


TransfoBilatere

decompiled_code:
__int64 __fastcall TransfoBilatere(const char **a1, __int64 a2)
{
const char *v2; // r13
__int64 v3; // r12
__int64 *v4; // rbp
char *v5; // rbx
__int64 v7; // [rsp+8h] [rbp-30h] BYREF

v7 = a2;
v2 = *a1;
if ( *a1 )
{
v3 = (__int64)a1;
v4 = &v7;
do
{
v5 = (char *)calloc(1uLL, 0x20uLL);
strcpy(v5, v2);
*((_QWORD *)v5 + 1) = *(_QWORD *)(*(_QWORD *)v3 + 8LL);
v4 = (__int64 *)InsertionBil(v4, (__int64)v5);
v3 = *(_QWORD *)v3 + 16LL;
v2 = *(const char **)v3;
}
while ( *(_QWORD *)v3 );
}
return v7;
}

original_code:
bilatere_t * TransfoBilatere (semaine_t ** p_sem, bilatere_t * p_bil)
{
    semaine_t ** prec = p_sem;
    bilatere_t ** prec_bil = &p_bil;
    bilatere_t * nouv = ((void *)0);
    while (*prec)
    {
        nouv = (bilatere_t *) calloc (1,sizeof(bilatere_t));
        strcpy((*nouv).chaine_sem,(**prec).chaine_sem);
        (*nouv).action_s = (**prec).action_s;
        prec_bil = InsertionBil(prec_bil,nouv);
        prec = &(**prec).suiv;
    }
    return p_bil;
}

canonical_original_code:
struct struct4 *TransfoBilatere(struct struct1 **p_sem, struct struct4 *p_bil)
{
    struct struct1 **prec = p_sem;
    struct struct4 **prec_bil = &p_bil;
    struct struct4 *nouv = ((void *)0);
    while (*prec)
    {
        nouv = (struct struct4 *) calloc (1,sizeof(bilatere_t));
        strcpy((*nouv).chaine_sem,(**prec).chaine_sem);
        (*nouv).action_s = (**prec).action_s;
        prec_bil = InsertionBil(prec_bil,nouv);
        prec = &(**prec).suiv;
    }
    return p_bil;
}

variable_types: struct struct1 { char chaine_sem[7]; struct struct2 *action_s; struct struct1 *suiv; } **

variable_types: struct struct1 { char chaine_sem[7]; struct struct2 { char chaine_act[-1]; struct struct2 *suiv; } *action_s; struct struct1 *suiv; } **

variable_types: struct struct4 { char chaine_sem[7]; struct struct2 { char chaine_act[-1]; struct struct2 *suiv; } *action_s; struct struct4 *prec; struct struct4 *suiv; } **


LiberationBil

original_code:
void LiberationBil(bilatere_t * p_bil)
{
    bilatere_t * cour_bil = (*p_bil).suiv;
    bilatere_t * tmp_bil = ((void *)0);
    int verif = 0;
    while ((cour_bil != ((void *)0)) && ((*cour_bil).action_s != ((void *)0)))
    {
        tmp_bil = cour_bil;
        cour_bil = (*cour_bil).suiv;
        (*tmp_bil).action_s = ((void *)0);
        (*tmp_bil).prec = ((void *)0);
        (*tmp_bil).suiv = ((void *)0);
        free(tmp_bil);
    }
    (*p_bil).suiv = ((void *)0);
    (*p_bil).prec = ((void *)0);
}

canonical_original_code:
void LiberationBil(struct struct4 *p_bil)
{
    struct struct4 *cour_bil = (*p_bil).suiv;
    struct struct4 *tmp_bil = ((void *)0);
    int verif = 0;
    while ((cour_bil != ((void *)0)) && ((*cour_bil).action_s != ((void *)0)))
    {
        tmp_bil = cour_bil;
        cour_bil = (*cour_bil).suiv;
        (*tmp_bil).action_s = ((void *)0);
        (*tmp_bil).prec = ((void *)0);
        (*tmp_bil).suiv = ((void *)0);
        free(tmp_bil);
    }
    (*p_bil).suiv = ((void *)0);
    (*p_bil).prec = ((void *)0);
}

variable_types: struct struct4 { char chaine_sem[7]; struct struct2 { char chaine_act[-1]; struct struct2 *suiv; } *action_s; struct struct4 *prec; struct struct4 *suiv; } *

variable_types: verif int


RechercheMotif

decompiled_code:
__int64 __fastcall RechercheMotif(__int64 a1, __int64 a2, const char *a3)
{
__int64 v3; // r13
unsigned int v5; // er12
__int64 i; // rbx
char *v7; // rbp
char haystack[11]; // [rsp+5h] [rbp-B3h] BYREF
char v10; // [rsp+10h] [rbp-A8h] BYREF

if ( !a1 )
return 0;
v3 = a1;
v5 = 0;
do
{
v10 = 0;
for ( i = *(_QWORD *)(v3 + 8); i; i = *(_QWORD *)(i + 16) )
{
sscanf((const char *)i, "%3c%10c", &v10, haystack);
if ( strstr(haystack, a3) )
{
v7 = (char *)(a2 + 13LL * (int)v5);
strcpy(v7, (const char *)v3);
strncat(v7, (const char *)i, 3uLL);
v7[10] = 0;
++v5;
}
}
v3 = *(_QWORD *)(v3 + 16);
}
while ( v3 );
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, const char *a3)
{
__int64 v3; // r13
unsigned int v5; // er12
__int64 i; // rbx
char *v7; // rbp
char haystack[11]; // [rsp+5h] [rbp-B3h] BYREF
char v10; // [rsp+10h] [rbp-A8h] BYREF

if ( !a1 )
return 0;
v3 = a1;
v5 = 0;
do
{
v10 = 0;
for ( i = *(_QWORD *)(v3 + 8); i; i = *(_QWORD *)(i + 16) )
{
sscanf((const char *)i, "%3c%10c", &v10, haystack);
if ( strstr(haystack, a3) )
{
v7 = (char *)(a2 + 13LL * (int)v5);
strcpy(v7, (const char *)v3);
strncat(v7, (const char *)i, 3uLL);
v7[10] = 0;
++v5;
}
}
v3 = *(_QWORD *)(v3 + 16);
}
while ( v3 );
return v5;
}

original_code:
int RechercheMotif(semaine_t * p_sem, motif_t * p_motif, char * motif_rech)
{
    semaine_t * cour_sem = p_sem;
    action_t * cour_act = (*cour_sem).action_s;
    int compteur = 0;
    char dechet[100];
    char libelle[11];
    while (cour_sem)
    {
        libelle[11] = '\0';
        cour_act = (*cour_sem).action_s;
        while (cour_act)
        {
            sscanf(cour_act->chaine_act,"%3c%10c",dechet,libelle);
            if (strstr(libelle,motif_rech) != ((void *)0))
            {
                strcpy(p_motif[compteur].motif,cour_sem->chaine_sem);
                strncat(p_motif[compteur].motif,cour_act->chaine_act,3);
                p_motif[compteur].motif[10] = '\0';
                compteur++;
            }
            cour_act = (*cour_act).suiv;
        }
        cour_sem = (*cour_sem).suiv;
    }
    return compteur;
}

canonical_original_code:
int RechercheMotif(struct struct1 *p_sem, struct struct3 *p_motif, char *motif_rech)
{
    struct struct1 *cour_sem = p_sem;
    struct struct2 *cour_act = (*cour_sem).action_s;
    int compteur = 0;
    char dechet[100];
    char libelle[11];
    while (cour_sem)
    {
        libelle[11] = '\0';
        cour_act = (*cour_sem).action_s;
        while (cour_act)
        {
            sscanf(cour_act->chaine_act,"%3c%10c",dechet,libelle);
            if (strstr(libelle,motif_rech) != ((void *)0))
            {
                strcpy(p_motif[compteur].motif,cour_sem->chaine_sem);
                strncat(p_motif[compteur].motif,cour_act->chaine_act,3);
                p_motif[compteur].motif[10] = '\0';
                compteur++;
            }
            cour_act = (*cour_act).suiv;
        }
        cour_sem = (*cour_sem).suiv;
    }
    return compteur;
}

variable_types: struct struct1 { char chaine_sem[7]; struct struct2 { char chaine_act[-1]; struct struct2 *suiv; } *action_s; struct struct1 *suiv; } *

variable_types: compteur int

variable_types:
dechet
char [100]

variable_types:
libelle
char [11]

return_type: int

user_defined_types: struct struct1 { char chaine_sem[7]; struct struct2 *action_s; struct struct1 *suiv; }


AffichageMotif

decompiled_code:
int __fastcall AffichageMotif(char *s, int a2)
{
char *v2; // rbx
int result; // eax

if ( !a2 )
return puts("Aucune date correspondante");
if ( a2 > 0 )
{
v2 = s;
do
{
result = puts(v2);
v2 += 13;
}
while ( v2 != &s[13 * (a2 - 1) + 13] );
}
return result;
}

canonical_decompiled_code:
int __fastcall func1(char *s, int a2)
{
char *v2; // rbx
int result; // eax

if ( !a2 )
return puts("Aucune date correspondante");
if ( a2 > 0 )
{
v2 = s;
do
{
result = puts(v2);
v2 += 13;
}
while ( v2 != &s[13 * (a2 - 1) + 13] );
}
return result;
}

original_code:
void AffichageMotif(motif_t * p_motif, int compteur)
{
    int compteur_aff = 0;
    if (compteur == 0)
    {
        printf("Aucune date correspondante\n");
    }
    else
    {
        while (compteur_aff < compteur)
        {
            printf("%s\n",p_motif[compteur_aff].motif);
            compteur_aff++;
        }
    }
}

canonical_original_code:
void AffichageMotif(struct struct3 *p_motif, int compteur)
{
    int compteur_aff = 0;
    if (compteur == 0)
    {
        printf("Aucune date correspondante\n");
    }
    else
    {
        while (compteur_aff < compteur)
        {
            printf("%s\n",p_motif[compteur_aff].motif);
            compteur_aff++;
        }
    }
}


InsererSem

decompiled_code:
char *__fastcall InsererSem(char **a1, const char *a2)
{
char *v2; // rax
char *v3; // rbx

v2 = (char *)malloc(0x18uLL);
v3 = v2;
if ( v2 )
{
strcpy(v2, a2);
*((_QWORD *)v3 + 1) = 0LL;
*((_QWORD *)v3 + 2) = *a1;
*a1 = v3;
}
return v3;
}

canonical_decompiled_code:
char *__fastcall func0(char **a1, const char *a2)
{
char *v2; // rax
char *v3; // rbx

v2 = (char *)malloc(0x18uLL);
v3 = v2;
if ( v2 )
{
strcpy(v2, a2);
*((_QWORD *)v3 + 1) = 0LL;
*((_QWORD *)v3 + 2) = *a1;
*a1 = v3;
}
return v3;
}

original_code:
semaine_t * InsererSem(semaine_t ** prec, char * chaine_sem)
{
    semaine_t * new = (semaine_t *) malloc (sizeof(semaine_t));
    if(new)
    {
        strcpy((*new).chaine_sem,chaine_sem);
        (*new).action_s = ((void *)0);
        (*new).suiv = ((void *)0);
        (*new).suiv = *prec;
        *prec = new;
    }
    return new;
}

canonical_original_code:
struct struct1 *InsererSem(struct struct1 **prec, char *chaine_sem)
{
    struct struct1 *new = (semaine_t *) malloc (sizeof(semaine_t));
    if(new)
    {
        strcpy((*new).chaine_sem,chaine_sem);
        (*new).action_s = ((void *)0);
        (*new).suiv = ((void *)0);
        (*new).suiv = *prec;
        *prec = new;
    }
    return new;
}

variable_types:
prec
struct struct1 **

return_type: struct struct1 { char chaine_sem[7]; struct struct2 { char chaine_act[-1]; struct struct2 *suiv; } *action_s; struct struct1 *suiv; } *


InsererAct

decompiled_code:
char *__fastcall InsererAct(char **a1, const char *a2)
{
char *v2; // rax
char *v3; // rbx

v2 = (char *)malloc(0x18uLL);
v3 = v2;
if ( v2 )
{
strcpy(v2, a2);
*((_QWORD *)v3 + 2) = *a1;
*a1 = v3;
}
return v3;
}

canonical_decompiled_code:
char *__fastcall func1(char **a1, const char *a2)
{
char *v2; // rax
char *v3; // rbx

v2 = (char *)malloc(0x18uLL);
v3 = v2;
if ( v2 )
{
strcpy(v2, a2);
*((_QWORD *)v3 + 2) = *a1;
*a1 = v3;
}
return v3;
}

original_code:
action_t * InsererAct(action_t ** prec, char * chaine_act)
{
    action_t * new = (action_t *) malloc (sizeof(action_t));
    if(new)
    {
        strcpy((*new).chaine_act,chaine_act);
        (*new).suiv = *prec;
        *prec = new;
    }
    return new;
}

canonical_original_code:
struct struct2 *InsererAct(struct struct2 **prec, char *chaine_act)
{
    struct struct2 *new = (action_t *) malloc (sizeof(action_t));
    if(new)
    {
        strcpy((*new).chaine_act,chaine_act);
        (*new).suiv = *prec;
        *prec = new;
    }
    return new;
}

variable_types:
prec
struct struct2 **

variable_types: struct struct2 { char chaine_act[-1]; struct struct2 *suiv; } *


Liberation

decompiled_code:
void __fastcall Liberation(void *ptr)
{
_QWORD *v1; // rbp
_QWORD *v2; // rbx
void *v3; // rdi
_QWORD *v4; // rbx

v1 = ptr;
if ( ptr )
{
while ( 1 )
{
v2 = (_QWORD *)v1[1];
while ( v2 )
{
v3 = v2;
v2 = (_QWORD *)v2[2];
free(v3);
}
v4 = (_QWORD *)v1[2];
free(v1);
if ( !v4 )
break;
v1 = v4;
}
}
}

canonical_decompiled_code:
void __fastcall func2(void *ptr)
{
_QWORD *v1; // rbp
_QWORD *v2; // rbx
void *v3; // rdi
_QWORD *v4; // rbx

v1 = ptr;
if ( ptr )
{
while ( 1 )
{
v2 = (_QWORD *)v1[1];
while ( v2 )
{
v3 = v2;
v2 = (_QWORD *)v2[2];
free(v3);
}
v4 = (_QWORD *)v1[2];
free(v1);
if ( !v4 )
break;
v1 = v4;
}
}
}

original_code:
void Liberation(semaine_t * p_sem)
{
    semaine_t * cour_sem = p_sem;
    action_t * cour_act;
    action_t * tmp_act;
    semaine_t * tmp_sem;
    while (cour_sem)
    {
        cour_act = (*cour_sem).action_s;
        while (cour_act)
        {
            tmp_act = cour_act;
            cour_act = (*cour_act).suiv;
            free(tmp_act);
        }
        tmp_sem = cour_sem;
        cour_sem = (*cour_sem).suiv;
        free(tmp_sem);
    }
    p_sem = ((void *)0);
}

canonical_original_code:
void Liberation(struct struct1 *p_sem)
{
    struct struct1 *cour_sem = p_sem;
    struct struct2 *cour_act;
    struct struct2 *tmp_act;
    struct struct1 *tmp_sem;
    while (cour_sem)
    {
        cour_act = (*cour_sem).action_s;
        while (cour_act)
        {
            tmp_act = cour_act;
            cour_act = (*cour_act).suiv;
            free(tmp_act);
        }
        tmp_sem = cour_sem;
        cour_sem = (*cour_sem).suiv;
        free(tmp_sem);
    }
    p_sem = ((void *)0);
}

user_defined_types: struct struct2 { char chaine_act[-1]; struct struct2 *suiv; }


initialiser

decompiled_code:
void __fastcall initialiser(_QWORD *a1, unsigned int a2, int a3)
{
_QWORD *v4; // rbp
__int64 v5; // r13
__int64 v6; // r12
__int64 v7; // rbx

srand(a2);
if ( a3 > 0 )
{
v4 = a1;
v5 = (__int64)&a1[(unsigned int)(a3 - 1) + 1];
v6 = 4LL * (unsigned int)a3;
do
{
v7 = 0LL;
do
{
*(_DWORD *)(*v4 + v7) = 100 * (rand() % 7);
v7 += 4LL;
}
while ( v6 != v7 );
++v4;
}
while ( v4 != (_QWORD *)v5 );
}
}

original_code:
void initialiser(int ** mat,int germe,int taille_t)
{
    int i=0,j=0;
    srand(germe);
    for(i=0;i<taille_t;i++)
    {
        for(j=0;j<taille_t;j++)
        {
            mat[i][j] = (rand()%7)*100;
        }
    }
}

canonical_original_code:
void initialiser(int **mat, int germe, int taille_t)
{
    int i = 0; int j = 0;
    srand(germe);
    for(i=0;i<taille_t;i++)
    {
        for(j=0;j<taille_t;j++)
        {
            mat[i][j] = (rand()%7)*100;
        }
    }
}

variable_types:
mat
int **

variable_types: germe int

variable_types: i int

variable_types: j int


remplir

decompiled_code:
__int64 __fastcall remplir(__int64 a1, int a2, int a3, int a4, int a5, int a6, int a7)
{
__int64 v8; // r12
_QWORD *v9; // r14
__int64 v10; // r15
__int64 v11; // r13
int *v12; // rcx
int v13; // edx
__int64 result; // rax
int v18; // [rsp+1Ch] [rbp-3Ch]

v8 = 8LL * a4;
v9 = (_QWORD *)(a1 + v8);
v10 = a5;
v11 = 4LL * a5;
v12 = (int *)(*(_QWORD *)(a1 + v8) + v11);
v13 = *v12;
result = (unsigned int)(*v12 / 100);
if ( (_DWORD)result == a2 )
{
*v12 = v13 % 100 + 100 * a3;
if ( !(v13 % 100) )
*(_DWORD *)(*v9 + 4LL * a5) += a6;
result = (unsigned int)(a7 - 1);
v18 = result;
if ( (int)result > a4 )
{
result = (unsigned int)(*(_DWORD *)(*(_QWORD *)(a1 + v8 + 8) + 4LL * a5) / 100);
if ( (_DWORD)result == a2 )
result = remplir(a1, a2, a3, a4 + 1, a5, a6, a7);
}
if ( a4 > 0 )
{
result = (unsigned int)(*(_DWORD *)(*(_QWORD *)(a1 + v8 - 8) + 4 * v10) / 100);
if ( (_DWORD)result == a2 )
result = remplir(a1, a2, a3, a4 - 1, a5, a6, a7);
}
if ( v18 > a5 )
{
result = (unsigned int)(*(_DWORD *)(*v9 + v11 + 4) / 100);
if ( (_DWORD)result == a2 )
result = remplir(a1, a2, a3, a4, a5 + 1, a6, a7);
}
if ( a5 > 0 )
{
result = (unsigned int)(*(_DWORD *)(*v9 + v11 - 4) / 100);
if ( (_DWORD)result == a2 )
result = remplir(a1, a2, a3, a4, a5 - 1, a6, a7);
}
}
return result;
}

original_code:
void remplir(int ** mat, int old_color, int new_color, int i, int j, int iteration, int taille_t)
{
    int cour = mat[i][j];
    int iter_cour = mat[i][j]%100;
    if (cour/100 == old_color)
    {
        mat[i][j] = new_color*100 + iter_cour;
        if (cour%100 == 0)
        {
                mat[i][j] = mat[i][j] + iteration;
        }
        if ((i < (taille_t - 1)) && (mat[i+1][j]/100 == old_color))
        {
            remplir(mat, old_color, new_color, i+1, j, iteration,taille_t);
  }
        if ((i > 0) && (mat[i-1][j]/100 == old_color))
  {
            remplir(mat, old_color, new_color, i-1, j, iteration,taille_t);
  }
        if ((j < (taille_t - 1)) && (mat[i][j+1]/100 == old_color))
  {
   remplir(mat, old_color, new_color, i, j+1, iteration,taille_t);
  }
        if ((j > 0) && (mat[i][j-1]/100 == old_color))
  {
   remplir(mat, old_color, new_color, i, j-1, iteration,taille_t);
  }
    }
}

canonical_original_code:
void remplir(int **mat, int old_color, int new_color, int i, int j, int iteration, int taille_t)
{
    int cour = mat[i][j];
    int iter_cour = mat[i][j]%100;
    if (cour/100 == old_color)
    {
        mat[i][j] = new_color*100 + iter_cour;
        if (cour%100 == 0)
        {
                mat[i][j] = mat[i][j] + iteration;
        }
        if ((i < (taille_t - 1)) && (mat[i+1][j]/100 == old_color))
        {
            remplir(mat, old_color, new_color, i+1, j, iteration,taille_t);
  }
        if ((i > 0) && (mat[i-1][j]/100 == old_color))
  {
            remplir(mat, old_color, new_color, i-1, j, iteration,taille_t);
  }
        if ((j < (taille_t - 1)) && (mat[i][j+1]/100 == old_color))
  {
   remplir(mat, old_color, new_color, i, j+1, iteration,taille_t);
  }
        if ((j > 0) && (mat[i][j-1]/100 == old_color))
  {
   remplir(mat, old_color, new_color, i, j-1, iteration,taille_t);
  }
    }
}

variable_types: iteration int

variable_types: cour int


fin

original_code:
int fin(int ** mat, int taille_t)
{
    int i=0,j=0;
    int valeur_origine = mat[0][0]/100;
    int verif = 0;
    for(i=0;i<taille_t;i++)
    {
        for(j=0;j<taille_t;j++)
        {
            if (mat[i][j]/100 != valeur_origine)
            {
                verif = 1;
                break;
            }
        }
    }
    return verif;
}

canonical_original_code:
int fin(int **mat, int taille_t)
{
    int i = 0; int j = 0;
    int valeur_origine = mat[0][0]/100;
    int verif = 0;
    for(i=0;i<taille_t;i++)
    {
        for(j=0;j<taille_t;j++)
        {
            if (mat[i][j]/100 != valeur_origine)
            {
                verif = 1;
                break;
            }
        }
    }
    return verif;
}


Affichage

original_code:
void Affichage(semaine_t * p_sem)
{
    semaine_t * cour_sem = p_sem;
    action_t * cour_act;
    char annee[5];
    char semaine[3];
    char jour[2];
    char heure[3];
    char libelle[11];
    while (cour_sem)
    {
        jour[1] = '\0';
        annee[4] = '\0';
        semaine[2] = '\0';
        heure[2] = '\0';
        libelle[10] = '\0';
        cour_act = (*cour_sem).action_s;
        sscanf(cour_sem->chaine_sem,"%4c%2c",annee,semaine);
        while (cour_act)
        {
            sscanf(cour_act->chaine_act,"%1c%2c%10c",jour,heure,libelle);
            printf("ANNEE : %s\n",annee);
            printf("SEMAINE : %s\n",semaine);
            printf("JOUR : %s\n",jour);
            printf("HEURE : %s\n",heure);
            printf("LIBELLE : %s\n",libelle);
            printf("\n");
            cour_act = (*cour_act).suiv;
        }
        cour_sem = (*cour_sem).suiv;
    }
    printf("--------------------------------------------\n");
}

canonical_original_code:
void Affichage(struct struct1 *p_sem)
{
    struct struct1 *cour_sem = p_sem;
    struct struct2 *cour_act;
    char annee[5];
    char semaine[3];
    char jour[2];
    char heure[3];
    char libelle[11];
    while (cour_sem)
    {
        jour[1] = '\0';
        annee[4] = '\0';
        semaine[2] = '\0';
        heure[2] = '\0';
        libelle[10] = '\0';
        cour_act = (*cour_sem).action_s;
        sscanf(cour_sem->chaine_sem,"%4c%2c",annee,semaine);
        while (cour_act)
        {
            sscanf(cour_act->chaine_act,"%1c%2c%10c",jour,heure,libelle);
            printf("ANNEE : %s\n",annee);
            printf("SEMAINE : %s\n",semaine);
            printf("JOUR : %s\n",jour);
            printf("HEURE : %s\n",heure);
            printf("LIBELLE : %s\n",libelle);
            printf("\n");
            cour_act = (*cour_act).suiv;
        }
        cour_sem = (*cour_sem).suiv;
    }
    printf("--------------------------------------------\n");
}

variable_types:
annee
char [5]

variable_types:
semaine
char [3]

variable_types:
jour
char [2]

variable_types:
heure
char [3]


Menu

decompiled_code:
int __fastcall Menu(int a1, __int64 a2)
{
int result; // eax

puts("\n<choix menu> :");
puts("0) Quitter");
puts("1) Affichage");
puts("2) Recherche par date");
puts("3) Suppression");
puts("4) Ecriture");
puts("5) Transformation en liste bilatere");
puts("6) Recherche de motifs");
result = puts("\n<argument> :\n<menu 1,2> -> date\n<menu 5> -> fichier d'ecriture\n<menu 6> -> motif");
if ( a1 == 1 )
{
printf("Veuillez choisir votre choix ? ");
fflush(stdout);
scanf("%d%*c", a2);
result = putchar(10);
}
return result;
}

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

puts("\n<choix menu> :");
puts("0) Quitter");
puts("1) Affichage");
puts("2) Recherche par date");
puts("3) Suppression");
puts("4) Ecriture");
puts("5) Transformation en liste bilatere");
puts("6) Recherche de motifs");
result = puts("\n<argument> :\n<menu 1,2> -> date\n<menu 5> -> fichier d'ecriture\n<menu 6> -> motif");
if ( a1 == 1 )
{
printf("Veuillez choisir votre choix ? ");
fflush(stdout);
scanf("%d%*c", a2);
result = putchar(10);
}
return result;
}

original_code:
void Menu(int saisie, int * choix)
{
    printf("\n<choix menu> :\n");
    printf("0) Quitter\n");
    printf("1) Affichage\n");
    printf("2) Recherche par date\n");
    printf("3) Suppression\n");
    printf("4) Ecriture\n");
    printf("5) Transformation en liste bilatere\n");
    printf("6) Recherche de motifs\n");
    printf("\n<argument> :\n<menu 1,2> -> date\n<menu 5> -> fichier d'ecriture\n<menu 6> -> motif\n");
    if (saisie == 1)
    {
        printf("Veuillez choisir votre choix ? ");
        fflush(stdout);
        scanf("%d%*c",choix);
        printf("\n");
    }
}

canonical_original_code:
void Menu(int saisie, int *choix)
{
    printf("\n<choix menu> :\n");
    printf("0) Quitter\n");
    printf("1) Affichage\n");
    printf("2) Recherche par date\n");
    printf("3) Suppression\n");
    printf("4) Ecriture\n");
    printf("5) Transformation en liste bilatere\n");
    printf("6) Recherche de motifs\n");
    printf("\n<argument> :\n<menu 1,2> -> date\n<menu 5> -> fichier d'ecriture\n<menu 6> -> motif\n");
    if (saisie == 1)
    {
        printf("Veuillez choisir votre choix ? ");
        fflush(stdout);
        scanf("%d%*c",choix);
        printf("\n");
    }
}

variable_types: saisie int

variable_types:
choix
int *


id

decompiled_code:
void id()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code:
double id(double valeur)
{
    return valeur;
}

variable_types: valeur double

return_type: double


repo: vlohacks/misc

decompiled_code:
struct _IO_FILE *ui_terminal_init()
{
__int64 *v0; // rax
struct _IO_FILE *result; // rax

v0 = color_fx_map;
do
*v0++ = (__int64)&color_none;
while ( v0 != (__int64 *)(unsigned int)((_DWORD)color_fx_map + 128) );
result = stdout;
ui_terminal_fd = stdout;
color_4throw = color_hilight;
color_otherrow = color_reset;
color_std = color_reset;
color_fx_map[0] = (__int64)color_lgreen;
color_fx_map[1] = (__int64)color_lgreen;
color_fx_map[2] = (__int64)color_lgreen;
color_fx_map[3] = (__int64)color_lgreen;
color_fx_map[4] = (__int64)color_lgreen;
color_fx_map[5] = (__int64)color_lblue;
color_fx_map[6] = (__int64)color_lblue;
color_fx_map[7] = (__int64)color_lblue;
color_fx_map[8] = (__int64)color_lmagenta;
color_fx_map[9] = (__int64)color_lred;
color_fx_map[10] = (__int64)color_lblue;
color_fx_map[11] = (__int64)color_lyellow;
color_fx_map[12] = (__int64)color_lblue;
color_fx_map[14] = (__int64)&color_none;
color_fx_map[13] = (__int64)color_lyellow;
color_fx_map[15] = (__int64)color_lyellow;
return result;
}

canonical_decompiled_code:
struct _IO_FILE *func0()
{
__int64 *v0; // rax
struct _IO_FILE *result; // rax

v0 = color_fx_map;
do
*v0++ = (__int64)&color_none;
while ( v0 != (__int64 *)(unsigned int)((_DWORD)color_fx_map + 128) );
result = stdout;
ui_terminal_fd = stdout;
color_4throw = color_hilight;
color_otherrow = color_reset;
color_std = color_reset;
color_fx_map[0] = (__int64)color_lgreen;
color_fx_map[1] = (__int64)color_lgreen;
color_fx_map[2] = (__int64)color_lgreen;
color_fx_map[3] = (__int64)color_lgreen;
color_fx_map[4] = (__int64)color_lgreen;
color_fx_map[5] = (__int64)color_lblue;
color_fx_map[6] = (__int64)color_lblue;
color_fx_map[7] = (__int64)color_lblue;
color_fx_map[8] = (__int64)color_lmagenta;
color_fx_map[9] = (__int64)color_lred;
color_fx_map[10] = (__int64)color_lblue;
color_fx_map[11] = (__int64)color_lyellow;
color_fx_map[12] = (__int64)color_lblue;
color_fx_map[14] = (__int64)&color_none;
color_fx_map[13] = (__int64)color_lyellow;
color_fx_map[15] = (__int64)color_lyellow;
return result;
}

original_code:
void ui_terminal_init()
{
    int i;
    int have_ansi = 1;
    for (i=0; i<16; i++)
        color_fx_map[i] = color_none;
    ui_terminal_fd = stdout;
    if (have_ansi) {
        color_4throw = color_hilight;
        color_otherrow = color_reset;
        color_std = color_reset;
        color_fx_map[0] = color_lgreen;
        color_fx_map[1] = color_lgreen;
        color_fx_map[2] = color_lgreen;
        color_fx_map[3] = color_lgreen;
        color_fx_map[4] = color_lgreen;
        color_fx_map[5] = color_lblue;
        color_fx_map[6] = color_lblue;
        color_fx_map[7] = color_lblue;
        color_fx_map[8] = color_lmagenta;
        color_fx_map[9] = color_lred;
        color_fx_map[10] = color_lblue;
        color_fx_map[11] = color_lyellow;
        color_fx_map[12] = color_lblue;
        color_fx_map[14] = color_none;
        color_fx_map[13] = color_lyellow;
        color_fx_map[15] = color_lyellow;
    }
}


decompiled_code:
size_t __fastcall ui_terminal_print_moduleinfo(__int64 a1)
{
size_t result; // rax
__int64 v2; // rbx
__int64 v3; // rdx
char v4; // si
__int64 v5; // rax

fputc(10, ui_terminal_fd);
fprintf(ui_terminal_fd, "song title : %s\n", (const char *)a1);
fprintf(ui_terminal_fd, "channels : %i\n", *(unsigned __int16 *)(a1 + 108));
fprintf(ui_terminal_fd, "patterns : %i\n", *(unsigned __int16 *)(a1 + 114));
fprintf(ui_terminal_fd, "orders : %i\n", *(unsigned __int16 *)(a1 + 116));
result = fwrite("\n--== Samples ==--\n", 1uLL, 0x13uLL, ui_terminal_fd);
if ( *(_WORD *)(a1 + 110) )
{
v2 = 0LL;
do
{
v3 = *(_QWORD *)(a1 + 376) + 80 * v2;
v4 = *(_BYTE *)(v3 + 36);
v5 = (unsigned int)v4;
if ( v4 >= 8 )
v5 = (unsigned int)(v5 - 16);
fprintf(
ui_terminal_fd,
"%22s | v=%2i l=%6i lena= %1i, ls=%6i ll=%6i le=%6i ft=%1i c2spd=%u\n",
(const char *)v3,
*(unsigned __int8 *)(v3 + 40),
*(unsigned int *)(v3 + 32),
*(unsigned __int8 *)(v3 + 41),
*(unsigned int *)(v3 + 44),
*(unsigned int *)(v3 + 48),
*(unsigned int *)(v3 + 52),
v5,
*(unsigned __int16 *)(v3 + 38));
++v2;
result = *(unsigned __int16 *)(a1 + 110);
}
while ( (int)result > (int)v2 );
}
return result;
}

canonical_decompiled_code:
size_t __fastcall func1(__int64 a1)
{
size_t result; // rax
__int64 v2; // rbx
__int64 v3; // rdx
char v4; // si
__int64 v5; // rax

fputc(10, ui_terminal_fd);
fprintf(ui_terminal_fd, "song title : %s\n", (const char *)a1);
fprintf(ui_terminal_fd, "channels : %i\n", *(unsigned __int16 *)(a1 + 108));
fprintf(ui_terminal_fd, "patterns : %i\n", *(unsigned __int16 *)(a1 + 114));
fprintf(ui_terminal_fd, "orders : %i\n", *(unsigned __int16 *)(a1 + 116));
result = fwrite("\n--== Samples ==--\n", 1uLL, 0x13uLL, ui_terminal_fd);
if ( *(_WORD *)(a1 + 110) )
{
v2 = 0LL;
do
{
v3 = *(_QWORD *)(a1 + 376) + 80 * v2;
v4 = *(_BYTE *)(v3 + 36);
v5 = (unsigned int)v4;
if ( v4 >= 8 )
v5 = (unsigned int)(v5 - 16);
fprintf(
ui_terminal_fd,
"%22s | v=%2i l=%6i lena= %1i, ls=%6i ll=%6i le=%6i ft=%1i c2spd=%u\n",
(const char *)v3,
*(unsigned __int8 *)(v3 + 40),
*(unsigned int *)(v3 + 32),
*(unsigned __int8 *)(v3 + 41),
*(unsigned int *)(v3 + 44),
*(unsigned int *)(v3 + 48),
*(unsigned int *)(v3 + 52),
v5,
*(unsigned __int16 *)(v3 + 38));
++v2;
result = *(unsigned __int16 *)(a1 + 110);
}
while ( (int)result > (int)v2 );
}
return result;
}

original_code:
void ui_terminal_print_moduleinfo(module_t * module)
{
    int i;
    fprintf(ui_terminal_fd, "\n");
    fprintf(ui_terminal_fd, "song title   : %s\n", module->song_title);
    fprintf(ui_terminal_fd, "channels     : %i\n", (int)module->num_channels);
    fprintf(ui_terminal_fd, "patterns     : %i\n", (int)module->num_patterns);
    fprintf(ui_terminal_fd, "orders       : %i\n", (int)module->num_orders);
    fprintf(ui_terminal_fd, "\n--== Samples ==--\n");
    for (i = 0; i < module->num_samples; i++) {
        module_sample_header_t * sh = &(module->samples[i].header);
        fprintf(ui_terminal_fd, "%22s | v=%2i l=%6i lena= %1i, ls=%6i ll=%6i le=%6i ft=%1i c2spd=%u\n", sh->name, sh->volume, sh->length, sh->loop_enabled, sh->loop_start, sh->loop_length, sh->loop_end, (sh->finetune >=8 ? -(16-sh->finetune) : sh->finetune), sh->c2spd );
    }
}

canonical_original_code:
void ui_terminal_print_moduleinfo(struct module_t *module)
{
    int i;
    fprintf(ui_terminal_fd, "\n");
    fprintf(ui_terminal_fd, "song title   : %s\n", module->song_title);
    fprintf(ui_terminal_fd, "channels     : %i\n", (int)module->num_channels);
    fprintf(ui_terminal_fd, "patterns     : %i\n", (int)module->num_patterns);
    fprintf(ui_terminal_fd, "orders       : %i\n", (int)module->num_orders);
    fprintf(ui_terminal_fd, "\n--== Samples ==--\n");
    for (i = 0; i < module->num_samples; i++) {
        struct module_sample_header_t *sh = &(module->samples[i].header);
        fprintf(ui_terminal_fd, "%22s | v=%2i l=%6i lena= %1i, ls=%6i ll=%6i le=%6i ft=%1i c2spd=%u\n", sh->name, sh->volume, sh->length, sh->loop_enabled, sh->loop_start, sh->loop_length, sh->loop_end, (sh->finetune >=8 ? -(16-sh->finetune) : sh->finetune), sh->c2spd );
    }
}

variable_types: struct module_t { char song_title[21]; struct module_info_t { char default_file_extension[8]; char description[64]; union { struct { char signature[8]; } flags_mod; struct { unsigned char st2vibrato; unsigned char st2tempo; unsigned char amigaslides; unsigned char amigalimits; unsigned char st30volumeslides; unsigned short st3_version; unsigned char default_panning; unsigned char mono; } flags_s3m; struct { unsigned char version_major; unsigned char version_minor; } flags_stm; struct { unsigned char stereo; unsigned char use_instruments; unsigned char linear_slides; unsigned char old_effects; unsigned char g_effect_link_memory; unsigned short created_with; unsigned short compatible_with; } flags_it; }; } module_info; enum module_type_t { module_type_mod=0, module_type_s3m=1, module_type_mtm=2, module_type_stm=3, module_type_it=4 } module_type; unsigned short num_channels; unsigned short num_samples; unsigned short num_instruments; unsigned short num_patterns; unsigned short num_orders; unsigned char orders[256]; struct module_sample_t { struct module_sample_header_t { char name[29]; unsigned int length; char finetune; unsigned short c2spd; unsigned char volume; unsigned char loop_enabled; unsigned int loop_start; unsigned int loop_length; unsigned int loop_end; unsigned int susloop_start; unsigned int susloop_end; unsigned char global_volume; unsigned char vibrato_speed; unsigned char vibrato_depth; unsigned char vibrato_waveform; unsigned char vibrato_rate; unsigned char pan; } header; short *data; } *samples; struct module_instrument_t { char name[26]; unsigned char new_note_action; unsigned char duplicate_check_type; unsigned char duplicate_check_action; unsigned char fadeout; char pitch_pan_separation; unsigned char pitch_pan_center; unsigned char default_pan; unsigned char random_volume_variation; unsigned char random_panning_variation; unsigned char note_sample_table[240]; struct module_instrument_envelope_t { unsigned char flags; unsigned char num_nodes; unsigned char loop_start; unsigned char loop_end; unsigned char susloop_start; unsigned char susloop_end; struct module_instrument_envelope_node_t { unsigned char value; unsigned short tick; } *nodes; } volume_envelope; struct module_instrument_envelope_t pan_envelope; struct module_instrument_envelope_t pitch_envelope; } *instruments; struct module_pattern_t { unsigned short num_rows; struct module_pattern_row_t { struct module_pattern_data_t { unsigned char sample_num; int period_index; char volume; unsigned char effect_num; unsigned char effect_value; } *data; } *rows; } *patterns; unsigned char initial_speed; unsigned char initial_bpm; unsigned char initial_master_volume; unsigned char mix_volume; unsigned char initial_panning[64]; unsigned char channel_volume[64]; unsigned char panning_separation; char *song_message; } *

variable_types: struct module_sample_header_t { char name[29]; unsigned int length; char finetune; unsigned short c2spd; unsigned char volume; unsigned char loop_enabled; unsigned int loop_start; unsigned int loop_length; unsigned int loop_end; unsigned int susloop_start; unsigned int susloop_end; unsigned char global_volume; unsigned char vibrato_speed; unsigned char vibrato_depth; unsigned char vibrato_waveform; unsigned char vibrato_rate; unsigned char pan; } *

user_defined_types: struct module_t { char song_title[21]; struct module_info_t module_info; enum module_type_t module_type; unsigned short num_channels; unsigned short num_samples; unsigned short num_instruments; unsigned short num_patterns; unsigned short num_orders; unsigned char orders[256]; struct module_sample_t *samples; struct module_instrument_t *instruments; struct module_pattern_t *patterns; unsigned char initial_speed; unsigned char initial_bpm; unsigned char initial_master_volume; unsigned char mix_volume; unsigned char initial_panning[64]; unsigned char channel_volume[64]; unsigned char panning_separation; char *song_message; }

user_defined_types: struct module_sample_t { struct module_sample_header_t header; short *data; }

user_defined_types: struct module_instrument_t { char name[26]; unsigned char new_note_action; unsigned char duplicate_check_type; unsigned char duplicate_check_action; unsigned char fadeout; char pitch_pan_separation; unsigned char pitch_pan_center; unsigned char default_pan; unsigned char random_volume_variation; unsigned char random_panning_variation; unsigned char note_sample_table[240]; struct module_instrument_envelope_t volume_envelope; struct module_instrument_envelope_t pan_envelope; struct module_instrument_envelope_t pitch_envelope; }

user_defined_types: struct module_pattern_t { unsigned short num_rows; struct module_pattern_row_t *rows; }

user_defined_types: struct module_instrument_envelope_t { unsigned char flags; unsigned char num_nodes; unsigned char loop_start; unsigned char loop_end; unsigned char susloop_start; unsigned char susloop_end; struct module_instrument_envelope_node_t *nodes; }

user_defined_types: struct module_pattern_row_t { struct module_pattern_data_t *data; }


decompiled_code:
void ui_terminal_print_order_info()
{
;
}

canonical_decompiled_code:
void func2()
{
;
}

original_code:
void ui_terminal_print_order_info(player_t * player)
{
    int current_pattern = player->current_pattern;
    int current_order = player->current_order;
}

canonical_original_code:
void ui_terminal_print_order_info(struct player_t *player)
{
    int current_pattern = player->current_pattern;
    int current_order = player->current_order;
}

variable_types: struct player_t { struct player_channel_t { unsigned char sample_num; float sample_pos; float sample_step; int period_index; unsigned short period; unsigned int frequency; unsigned char sample_delay; unsigned short dest_period; unsigned char dest_sample_num; char dest_volume; unsigned char panning; char volume; char volume_master; unsigned char effect_num; unsigned char effect_value; unsigned char effect_last_value[26]; unsigned char effect_last_value_y[26]; int vibrato_state; int tremolo_state; int tremor_state; unsigned char vibrato_waveform; unsigned char tremolo_waveform; unsigned char pattern_loop_position; unsigned char pattern_loop_count; } *channels; struct module_t { char song_title[21]; struct module_info_t { char default_file_extension[8]; char description[64]; union { struct { char signature[8]; } flags_mod; struct { unsigned char st2vibrato; unsigned char st2tempo; unsigned char amigaslides; unsigned char amigalimits; unsigned char st30volumeslides; unsigned short st3_version; unsigned char default_panning; unsigned char mono; } flags_s3m; struct { unsigned char version_major; unsigned char version_minor; } flags_stm; struct { unsigned char stereo; unsigned char use_instruments; unsigned char linear_slides; unsigned char old_effects; unsigned char g_effect_link_memory; unsigned short created_with; unsigned short compatible_with; } flags_it; }; } module_info; enum module_type_t { module_type_mod=0, module_type_s3m=1, module_type_mtm=2, module_type_stm=3, module_type_it=4 } module_type; unsigned short num_channels; unsigned short num_samples; unsigned short num_instruments; unsigned short num_patterns; unsigned short num_orders; unsigned char orders[256]; struct module_sample_t { struct module_sample_header_t { char name[29]; unsigned int length; char finetune; unsigned short c2spd; unsigned char volume; unsigned char loop_enabled; unsigned int loop_start; unsigned int loop_length; unsigned int loop_end; unsigned int susloop_start; unsigned int susloop_end; unsigned char global_volume; unsigned char vibrato_speed; unsigned char vibrato_depth; unsigned char vibrato_waveform; unsigned char vibrato_rate; unsigned char pan; } header; short *data; } *samples; struct module_instrument_t { char name[26]; unsigned char new_note_action; unsigned char duplicate_check_type; unsigned char duplicate_check_action; unsigned char fadeout; char pitch_pan_separation; unsigned char pitch_pan_center; unsigned char default_pan; unsigned char random_volume_variation; unsigned char random_panning_variation; unsigned char note_sample_table[240]; struct module_instrument_envelope_t { unsigned char flags; unsigned char num_nodes; unsigned char loop_start; unsigned char loop_end; unsigned char susloop_start; unsigned char susloop_end; struct module_instrument_envelope_node_t { unsigned char value; unsigned short tick; } *nodes; } volume_envelope; struct module_instrument_envelope_t pan_envelope; struct module_instrument_envelope_t pitch_envelope; } *instruments; struct module_pattern_t { unsigned short num_rows; struct module_pattern_row_t { struct module_pattern_data_t { unsigned char sample_num; int period_index; char volume; unsigned char effect_num; unsigned char effect_value; } *data; } *rows; } *patterns; unsigned char initial_speed; unsigned char initial_bpm; unsigned char initial_master_volume; unsigned char mix_volume; unsigned char initial_panning[64]; unsigned char channel_volume[64]; unsigned char panning_separation; char *song_message; } *module; void (**effect_map)(struct player_t *, int); void (*newrow_action)(struct player_t *, struct module_pattern_data_t *, int); void *callback_user_ptr; void (*order_callback)(struct player_t *, void *user_ptr); void (*row_callback)(struct player_t *, void *user_ptr); void (*tick_callback)(struct player_t *, void *user_ptr); void (*channel_sample_callback)(struct player_t *, void *user_ptr); unsigned int channel_sample_callback_mask; unsigned short *period_table; enum player_resampling_t { player_resampling_none=0, player_resampling_linear=1 } resampling; enum defs_mod_paulafreq_index_t { PAL=0, NTSC=1 } paula_freq_index; int protracker_strict_mode; unsigned short period_top; unsigned short period_bottom; unsigned char speed; unsigned short bpm; float tick_pos; float tick_duration; unsigned int sample_rate; int current_tick; int current_pattern; int current_order; int current_row; int do_break; int next_order; int next_row; int pattern_delay; int pattern_delay_active; int loop_module; int loop_pattern; int solo_channel; int playing; } *

user_defined_types: struct player_t { struct player_channel_t *channels; struct module_t *module; void (**effect_map)(struct player_t *, int); void (*newrow_action)(struct player_t *, struct module_pattern_data_t *, int); void *callback_user_ptr; void (*order_callback)(struct player_t *, void *user_ptr); void (*row_callback)(struct player_t *, void *user_ptr); void (*tick_callback)(struct player_t *, void *user_ptr); void (*channel_sample_callback)(struct player_t *, void *user_ptr); unsigned int channel_sample_callback_mask; unsigned short *period_table; enum player_resampling_t resampling; enum defs_mod_paulafreq_index_t paula_freq_index; int protracker_strict_mode; unsigned short period_top; unsigned short period_bottom; unsigned char speed; unsigned short bpm; float tick_pos; float tick_duration; unsigned int sample_rate; int current_tick; int current_pattern; int current_order; int current_row; int do_break; int next_order; int next_row; int pattern_delay; int pattern_delay_active; int loop_module; int loop_pattern; int solo_channel; int playing; }


decompiled_code:
int __fastcall ui_terminal_print_row_info(__int64 a1)
{
__int64 v1; // r9
__int64 v2; // r8
const char *v3; // r14
_QWORD *v4; // r12
__int64 v5; // rax
__int64 v6; // rbp
char v7; // dl
char s[3]; // [rsp+7h] [rbp-31h] BYREF
char v10[2]; // [rsp+Ah] [rbp-2Eh] BYREF
char v11[44]; // [rsp+Ch] [rbp-2Ch] BYREF

v1 = *(unsigned int *)(a1 + 132);
v2 = *(unsigned int *)(a1 + 124);
v3 = (const char *)color_otherrow;
if ( (v1 & 3) == 0 )
v3 = (const char *)color_4throw;
v4 = (_QWORD *)(*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 392LL) + 16LL * (int)v2 + 8) + 8LL * (int)v1);
fprintf(ui_terminal_fd, "%s%02d:%02d:%02d|", v3, *(unsigned int *)(a1 + 128), v2, v1);
v5 = *(_QWORD *)(a1 + 8);
if ( *(_WORD *)(v5 + 108) )
{
v6 = 0LL;
do
{
ui_periodindex2note(*(unsigned int *)(*v4 + 12 * v6 + 4), v11, *(_DWORD *)(v5 + 104) != 4);
v7 = *(_BYTE *)(*v4 + 12 * v6 + 8);
if ( v7 >= 0 )
sprintf(s, "%02i", (unsigned int)v7);
else
strcpy(s, "..");
ui_map_effect_num(v10, *(unsigned int *)(*(_QWORD *)(a1 + 8) + 104LL), *(unsigned __int8 *)(*v4 + 12 * v6 + 9));
fprintf(
ui_terminal_fd,
"%s%02d%s%s%02X%s|",
v11,
*(unsigned __int8 *)(*v4 + 12 * v6),
s,
v10,
*(unsigned __int8 *)(*v4 + 12 * v6 + 10),
v3);
v5 = *(_QWORD *)(a1 + 8);
++v6;
}
while ( *(unsigned __int16 *)(v5 + 108) > (int)v6 );
}
fprintf(ui_terminal_fd, "%s\n", (const char *)color_std);
return fflush(ui_terminal_fd);
}

canonical_decompiled_code:
int __fastcall func3(__int64 a1)
{
__int64 v1; // r9
__int64 v2; // r8
const char *v3; // r14
_QWORD *v4; // r12
__int64 v5; // rax
__int64 v6; // rbp
char v7; // dl
char s[3]; // [rsp+7h] [rbp-31h] BYREF
char v10[2]; // [rsp+Ah] [rbp-2Eh] BYREF
char v11[44]; // [rsp+Ch] [rbp-2Ch] BYREF

v1 = *(unsigned int *)(a1 + 132);
v2 = *(unsigned int *)(a1 + 124);
v3 = (const char *)color_otherrow;
if ( (v1 & 3) == 0 )
v3 = (const char *)color_4throw;
v4 = (_QWORD *)(*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 392LL) + 16LL * (int)v2 + 8) + 8LL * (int)v1);
fprintf(ui_terminal_fd, "%s%02d:%02d:%02d|", v3, *(unsigned int *)(a1 + 128), v2, v1);
v5 = *(_QWORD *)(a1 + 8);
if ( *(_WORD *)(v5 + 108) )
{
v6 = 0LL;
do
{
ui_periodindex2note(*(unsigned int *)(*v4 + 12 * v6 + 4), v11, *(_DWORD *)(v5 + 104) != 4);
v7 = *(_BYTE *)(*v4 + 12 * v6 + 8);
if ( v7 >= 0 )
sprintf(s, "%02i", (unsigned int)v7);
else
strcpy(s, "..");
ui_map_effect_num(v10, *(unsigned int *)(*(_QWORD *)(a1 + 8) + 104LL), *(unsigned __int8 *)(*v4 + 12 * v6 + 9));
fprintf(
ui_terminal_fd,
"%s%02d%s%s%02X%s|",
v11,
*(unsigned __int8 *)(*v4 + 12 * v6),
s,
v10,
*(unsigned __int8 *)(*v4 + 12 * v6 + 10),
v3);
v5 = *(_QWORD *)(a1 + 8);
++v6;
}
while ( *(unsigned __int16 *)(v5 + 108) > (int)v6 );
}
fprintf(ui_terminal_fd, "%s\n", (const char *)color_std);
return fflush(ui_terminal_fd);
}

original_code:
void ui_terminal_print_row_info(player_t * player)
{
    int i;
    char note[4];
    char effect[2];
    char volume[3];
    int current_order = player->current_order;
    int current_row = player->current_row;
    int current_pattern = player->current_pattern;
    char * the_std_color = current_row % 4 ? color_otherrow : color_4throw;
    module_pattern_row_t * row = &(player->module->patterns[current_pattern].rows[current_row]);
    fprintf(ui_terminal_fd, "%s%02d:%02d:%02d|", the_std_color, current_order, current_pattern, current_row );
    for (i = 0; i < player->module->num_channels; i++) {
        ui_periodindex2note(row->data[i].period_index, note, player->module->module_type == module_type_it ? 0 : 1);
        if (row->data[i].volume >= 0)
            sprintf(volume, "%02i", row->data[i].volume);
        else
            strcpy(volume, "..");
        ui_map_effect_num(effect, player->module->module_type,row->data[i].effect_num);
        fprintf(ui_terminal_fd, "%s%02d%s%s%02X%s|",
                note, row->data[i].sample_num, volume, effect, row->data[i].effect_value, the_std_color);
    }
    fprintf(ui_terminal_fd, "%s\n", color_std);
    fflush(ui_terminal_fd);
}

canonical_original_code:
void ui_terminal_print_row_info(struct player_t *player)
{
    int i;
    char note[4];
    char effect[2];
    char volume[3];
    int current_order = player->current_order;
    int current_row = player->current_row;
    int current_pattern = player->current_pattern;
    char *the_std_color = current_row % 4 ? color_otherrow : color_4throw;
    struct module_pattern_row_t *row = &(player->module->patterns[current_pattern].rows[current_row]);
    fprintf(ui_terminal_fd, "%s%02d:%02d:%02d|", the_std_color, current_order, current_pattern, current_row );
    for (i = 0; i < player->module->num_channels; i++) {
        ui_periodindex2note(row->data[i].period_index, note, player->module->module_type == module_type_it ? 0 : 1);
        if (row->data[i].volume >= 0)
            sprintf(volume, "%02i", row->data[i].volume);
        else
            strcpy(volume, "..");
        ui_map_effect_num(effect, player->module->module_type,row->data[i].effect_num);
        fprintf(ui_terminal_fd, "%s%02d%s%s%02X%s|",
                note, row->data[i].sample_num, volume, effect, row->data[i].effect_value, the_std_color);
    }
    fprintf(ui_terminal_fd, "%s\n", color_std);
    fflush(ui_terminal_fd);
}

variable_types:
note
char [4]

variable_types:
effect
char [2]

variable_types:
volume
char [3]

variable_types: struct module_pattern_row_t { struct module_pattern_data_t { unsigned char sample_num; int period_index; char volume; unsigned char effect_num; unsigned char effect_value; } *data; } *

user_defined_types: enum player_resampling_t { player_resampling_none=0, player_resampling_linear=1 }

user_defined_types: enum defs_mod_paulafreq_index_t { PAL=0, NTSC=1 }

user_defined_types: struct player_channel_t { unsigned char sample_num; float sample_pos; float sample_step; int period_index; unsigned short period; unsigned int frequency; unsigned char sample_delay; unsigned short dest_period; unsigned char dest_sample_num; char dest_volume; unsigned char panning; char volume; char volume_master; unsigned char effect_num; unsigned char effect_value; unsigned char effect_last_value[26]; unsigned char effect_last_value_y[26]; int vibrato_state; int tremolo_state; int tremor_state; unsigned char vibrato_waveform; unsigned char tremolo_waveform; unsigned char pattern_loop_position; unsigned char pattern_loop_count; }

user_defined_types: struct module_info_t { char default_file_extension[8]; char description[64]; union { struct { char signature[8]; } flags_mod; struct { unsigned char st2vibrato; unsigned char st2tempo; unsigned char amigaslides; unsigned char amigalimits; unsigned char st30volumeslides; unsigned short st3_version; unsigned char default_panning; unsigned char mono; } flags_s3m; struct { unsigned char version_major; unsigned char version_minor; } flags_stm; struct { unsigned char stereo; unsigned char use_instruments; unsigned char linear_slides; unsigned char old_effects; unsigned char g_effect_link_memory; unsigned short created_with; unsigned short compatible_with; } flags_it; }; }

user_defined_types: enum module_type_t { module_type_mod=0, module_type_s3m=1, module_type_mtm=2, module_type_stm=3, module_type_it=4 }

user_defined_types: struct module_sample_header_t { char name[29]; unsigned int length; char finetune; unsigned short c2spd; unsigned char volume; unsigned char loop_enabled; unsigned int loop_start; unsigned int loop_length; unsigned int loop_end; unsigned int susloop_start; unsigned int susloop_end; unsigned char global_volume; unsigned char vibrato_speed; unsigned char vibrato_depth; unsigned char vibrato_waveform; unsigned char vibrato_rate; unsigned char pan; }

user_defined_types: struct module_instrument_envelope_node_t { unsigned char value; unsigned short tick; }


decompiled_code:
int __fastcall ui_terminal_refresh(__int64 a1, _BYTE *a2)
{
int result; // eax

if ( (*(_DWORD *)a2 & 1) != 0 )
*a2 &= 0xFEu;
if ( (*(_DWORD *)a2 & 2) != 0 )
*a2 &= 0xFDu;
result = *(_DWORD *)a2;
if ( (*(_DWORD *)a2 & 4) != 0 )
{
*a2 &= 0xFBu;
result = ui_terminal_print_row_info(a1);
}
return result;
}

canonical_decompiled_code:
int __fastcall func4(__int64 a1, _BYTE *a2)
{
int result; // eax

if ( (*(_DWORD *)a2 & 1) != 0 )
*a2 &= 0xFEu;
if ( (*(_DWORD *)a2 & 2) != 0 )
*a2 &= 0xFDu;
result = *(_DWORD *)a2;
if ( (*(_DWORD *)a2 & 4) != 0 )
{
*a2 &= 0xFBu;
result = func3(a1);
}
return result;
}

original_code:
void ui_terminal_refresh(player_t * player, ui_dirty_t * ui_dirty)
{
    if (ui_dirty->order) {
        ui_dirty->order = 0;
        ui_terminal_print_order_info(player);
    }
    if (ui_dirty->tick) {
        ui_dirty->tick = 0;
    }
    if (ui_dirty->row) {
        ui_dirty->row = 0;
        ui_terminal_print_row_info(player);
    }
}

canonical_original_code:
void ui_terminal_refresh(struct player_t *player, struct ui_dirty_t *ui_dirty)
{
    if (ui_dirty->order) {
        ui_dirty->order = 0;
        ui_terminal_print_order_info(player);
    }
    if (ui_dirty->tick) {
        ui_dirty->tick = 0;
    }
    if (ui_dirty->row) {
        ui_dirty->row = 0;
        ui_terminal_print_row_info(player);
    }
}

variable_types: struct ui_dirty_t { int order; int tick; int row; int sample; } *

user_defined_types: struct module_pattern_data_t { unsigned char sample_num; int period_index; char volume; unsigned char effect_num; unsigned char effect_value; }


decompiled_code:
_BOOL8 __fastcall cmdline_parse_output_opts(char *s, __int64 a2)
{
char *v4; // rax
bool v5; // zf
_BOOL8 result; // rax

if ( !memcmp(s, "raw:", 4uLL) )
{
v4 = strchr(s, 58);
if ( !v4 || !v4[1] )
{
fwrite("You have to specify a file name for raw output!\n", 1uLL, 0x30uLL, stderr);
return 1LL;
}
*(_QWORD *)(*(_QWORD *)(a2 + 8) + 16LL) = v4 + 1;
**(_DWORD **)(a2 + 8) = 2;
}
if ( !memcmp(s, "benchmark", 9uLL) )
**(_DWORD **)(a2 + 8) = 3;
v5 = memcmp(s, "alsa", 4uLL) == 0;
result = !v5;
if ( !v5 )
return 0LL;
**(_DWORD **)(a2 + 8) = 1;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(char *s, __int64 a2)
{
char *v4; // rax
bool v5; // zf
_BOOL8 result; // rax

if ( !memcmp(s, "raw:", 4uLL) )
{
v4 = strchr(s, 58);
if ( !v4 || !v4[1] )
{
fwrite("You have to specify a file name for raw output!\n", 1uLL, 0x30uLL, stderr);
return 1LL;
}
*(_QWORD *)(*(_QWORD *)(a2 + 8) + 16LL) = v4 + 1;
**(_DWORD **)(a2 + 8) = 2;
}
if ( !memcmp(s, "benchmark", 9uLL) )
**(_DWORD **)(a2 + 8) = 3;
v5 = memcmp(s, "alsa", 4uLL) == 0;
result = !v5;
if ( !v5 )
return 0LL;
**(_DWORD **)(a2 + 8) = 1;
return result;
}

original_code:
int cmdline_parse_output_opts(char * cmdline, modplay_application_t * app)
{
    char * p;
    if (!strncmp(cmdline, "raw:", 4)) {
        p = strstr(cmdline, ":");
        if (p != 0) {
            p++;
            if ((*p) == 0) {
                p = 0;
            } else {
                app->output_opts->output_device = p;
            }
        }
        if (p == 0) {
            fprintf(stderr, "You have to specify a file name for raw output!\n");
            return 1;
        }
        app->output_opts->driver = output_driver_raw;
    }
    if (!strncmp(cmdline, "benchmark", 9)) {
        app->output_opts->driver = output_driver_benchmark;
    }
    if (!strncmp(cmdline, "alsa", 4)) {
        app->output_opts->driver = output_driver_alsa;
    }
    return 0;
}

canonical_original_code:
int cmdline_parse_output_opts(char *cmdline, struct modplay_application_t *app)
{
    char *p;
    if (!strncmp(cmdline, "raw:", 4)) {
        p = strstr(cmdline, ":");
        if (p != 0) {
            p++;
            if ((*p) == 0) {
                p = 0;
            } else {
                app->output_opts->output_device = p;
            }
        }
        if (p == 0) {
            fprintf(stderr, "You have to specify a file name for raw output!\n");
            return 1;
        }
        app->output_opts->driver = output_driver_raw;
    }
    if (!strncmp(cmdline, "benchmark", 9)) {
        app->output_opts->driver = output_driver_benchmark;
    }
    if (!strncmp(cmdline, "alsa", 4)) {
        app->output_opts->driver = output_driver_alsa;
    }
    return 0;
}

variable_types:
cmdline
char *

variable_types: struct modplay_application_t { struct player_t { struct player_channel_t { unsigned char sample_num; float sample_pos; float sample_step; int period_index; unsigned short period; unsigned int frequency; unsigned char sample_delay; unsigned short dest_period; unsigned char dest_sample_num; char dest_volume; unsigned char panning; char volume; char volume_master; unsigned char effect_num; unsigned char effect_value; unsigned char effect_last_value[26]; unsigned char effect_last_value_y[26]; int vibrato_state; int tremolo_state; int tremor_state; unsigned char vibrato_waveform; unsigned char tremolo_waveform; unsigned char pattern_loop_position; unsigned char pattern_loop_count; } *channels; struct module_t { char song_title[21]; struct module_info_t { char default_file_extension[8]; char description[64]; union { struct { char signature[8]; } flags_mod; struct { unsigned char st2vibrato; unsigned char st2tempo; unsigned char amigaslides; unsigned char amigalimits; unsigned char st30volumeslides; unsigned short st3_version; unsigned char default_panning; unsigned char mono; } flags_s3m; struct { unsigned char version_major; unsigned char version_minor; } flags_stm; struct { unsigned char stereo; unsigned char use_instruments; unsigned char linear_slides; unsigned char old_effects; unsigned char g_effect_link_memory; unsigned short created_with; unsigned short compatible_with; } flags_it; }; } module_info; enum module_type_t { module_type_mod=0, module_type_s3m=1, module_type_mtm=2, module_type_stm=3, module_type_it=4 } module_type; unsigned short num_channels; unsigned short num_samples; unsigned short num_instruments; unsigned short num_patterns; unsigned short num_orders; unsigned char orders[256]; struct module_sample_t { struct module_sample_header_t { char name[29]; unsigned int length; char finetune; unsigned short c2spd; unsigned char volume; unsigned char loop_enabled; unsigned int loop_start; unsigned int loop_length; unsigned int loop_end; unsigned int susloop_start; unsigned int susloop_end; unsigned char global_volume; unsigned char vibrato_speed; unsigned char vibrato_depth; unsigned char vibrato_waveform; unsigned char vibrato_rate; unsigned char pan; } header; short *data; } *samples; struct module_instrument_t { char name[26]; unsigned char new_note_action; unsigned char duplicate_check_type; unsigned char duplicate_check_action; unsigned char fadeout; char pitch_pan_separation; unsigned char pitch_pan_center; unsigned char default_pan; unsigned char random_volume_variation; unsigned char random_panning_variation; unsigned char note_sample_table[240]; struct module_instrument_envelope_t { unsigned char flags; unsigned char num_nodes; unsigned char loop_start; unsigned char loop_end; unsigned char susloop_start; unsigned char susloop_end; struct module_instrument_envelope_node_t { unsigned char value; unsigned short tick; } *nodes; } volume_envelope; struct module_instrument_envelope_t pan_envelope; struct module_instrument_envelope_t pitch_envelope; } *instruments; struct module_pattern_t { unsigned short num_rows; struct module_pattern_row_t { struct module_pattern_data_t { unsigned char sample_num; int period_index; char volume; unsigned char effect_num; unsigned char effect_value; } *data; } *rows; } *patterns; unsigned char initial_speed; unsigned char initial_bpm; unsigned char initial_master_volume; unsigned char mix_volume; unsigned char initial_panning[64]; unsigned char channel_volume[64]; unsigned char panning_separation; char *song_message; } *module; void (**effect_map)(struct player_t *, int); void (*newrow_action)(struct player_t *, struct module_pattern_data_t *, int); void *callback_user_ptr; void (*order_callback)(struct player_t *, void *user_ptr); void (*row_callback)(struct player_t *, void *user_ptr); void (*tick_callback)(struct player_t *, void *user_ptr); void (*channel_sample_callback)(struct player_t *, void *user_ptr); unsigned int channel_sample_callback_mask; unsigned short *period_table; enum player_resampling_t { player_resampling_none=0, player_resampling_linear=1 } resampling; enum defs_mod_paulafreq_index_t { PAL=0, NTSC=1 } paula_freq_index; int protracker_strict_mode; unsigned short period_top; unsigned short period_bottom; unsigned char speed; unsigned short bpm; float tick_pos; float tick_duration; unsigned int sample_rate; int current_tick; int current_pattern; int current_order; int current_row; int do_break; int next_order; int next_row; int pattern_delay; int pattern_delay_active; int loop_module; int loop_pattern; int solo_channel; int playing; } *player; struct output_opts_t { enum output_drivers_t { output_driver_portaudio=0, output_driver_alsa=1, output_driver_raw=2, output_driver_benchmark=3, output_driver_sb16=4 } driver; int buffer_size; int sample_rate; char *output_device; } *output_opts; char *output_config; char **playlist; int playlist_count; int loop_playlist; int running; enum ui_flavour_t { ui_flavour_quiet=0, ui_flavour_terminal=1, ui_flavour_curses=2 } ui_flavour; struct ui_dirty_t { int order; int tick; int row; int sample; } ui_dirty; } *

variable_types:
p
char *

user_defined_types: struct modplay_application_t { struct player_t *player; struct output_opts_t *output_opts; char *output_config; char **playlist; int playlist_count; int loop_playlist; int running; enum ui_flavour_t ui_flavour; struct ui_dirty_t ui_dirty; }

user_defined_types: struct output_opts_t { enum output_drivers_t driver; int buffer_size; int sample_rate; char *output_device; }


decompiled_code:
int __fastcall cmdline_usage(const char *a1)
{
return fprintf(
stderr,
"Usage: %s [options] <modulefile> [<modulefile2> ...]\n"
"\n"
"Options:\n"
" -r <rate> Use sample rate <rate>, default is 44100\n"
" -i <interpolation> Use interpolation type <interpolation>\n"
" possible values: none, linear. Default is linear\n"
" -P Enable protracker strict mode:\n"
" no panning, only 3 octaves\n"
" -f <amiga frequency> Set the amiga paula base frequecy\n"
" possible values: pal, ntsc. Default is pal.\n"
" -b <buffer size> Set audio output buffer size. Default is 1024\n"
" -l Loop the modules list\n"
" -L Loop single module\n"
" -o Output configuration, possible values:\n"
" portaudio use portaudio\n"
" raw:<filename.ext> raw output to <filename.ext>\n"
" benchmark show samples/sec performance "
" (not actually making noise) -h This text\n"
" -s <channel> solo <channel>\n"
" -p <pattern> loop <pattern>\n",
a1);
}

canonical_decompiled_code:
int __fastcall func3(const char *a1)
{
return fprintf(
stderr,
"Usage: %s [options] <modulefile> [<modulefile2> ...]\n"
"\n"
"Options:\n"
" -r <rate> Use sample rate <rate>, default is 44100\n"
" -i <interpolation> Use interpolation type <interpolation>\n"
" possible values: none, linear. Default is linear\n"
" -P Enable protracker strict mode:\n"
" no panning, only 3 octaves\n"
" -f <amiga frequency> Set the amiga paula base frequecy\n"
" possible values: pal, ntsc. Default is pal.\n"
" -b <buffer size> Set audio output buffer size. Default is 1024\n"
" -l Loop the modules list\n"
" -L Loop single module\n"
" -o Output configuration, possible values:\n"
" portaudio use portaudio\n"
" raw:<filename.ext> raw output to <filename.ext>\n"
" benchmark show samples/sec performance "
" (not actually making noise) -h This text\n"
" -s <channel> solo <channel>\n"
" -p <pattern> loop <pattern>\n",
a1);
}

original_code:
void cmdline_usage (char * prog)
{
    fprintf (stderr,
            "Usage: %s [options] <modulefile> [<modulefile2> ...]\n\n"
            "Options:\n"
            "   -r <rate>               Use sample rate <rate>, default is 44100\n"
            "   -i <interpolation>      Use interpolation type <interpolation>\n"
            "                           possible values: none, linear. Default is linear\n"
            "   -P                      Enable protracker strict mode:\n"
            "                           no panning, only 3 octaves\n"
            "   -f <amiga frequency>    Set the amiga paula base frequecy\n"
            "                           possible values: pal, ntsc. Default is pal.\n"
            "   -b <buffer size>        Set audio output buffer size. Default is 1024\n"
            "   -l                      Loop the modules list\n"
            "   -L                      Loop single module\n"
            "   -o                      Output configuration, possible values:\n"
            "                                   portaudio               use portaudio\n"
            "                                   raw:<filename.ext>      raw output to <filename.ext>\n"
            "                                   benchmark               show samples/sec performance "
            "                                                           (not actually making noise)"
            "   -h                      This text\n"
            "   -s <channel>            solo <channel>\n"
            "   -p <pattern>            loop <pattern>\n", prog);
}

canonical_original_code:
void cmdline_usage(char *prog)
{
    fprintf (stderr,
            "Usage: %s [options] <modulefile> [<modulefile2> ...]\n\n"
            "Options:\n"
            "   -r <rate>               Use sample rate <rate>, default is 44100\n"
            "   -i <interpolation>      Use interpolation type <interpolation>\n"
            "                           possible values: none, linear. Default is linear\n"
            "   -P                      Enable protracker strict mode:\n"
            "                           no panning, only 3 octaves\n"
            "   -f <amiga frequency>    Set the amiga paula base frequecy\n"
            "                           possible values: pal, ntsc. Default is pal.\n"
            "   -b <buffer size>        Set audio output buffer size. Default is 1024\n"
            "   -l                      Loop the modules list\n"
            "   -L                      Loop single module\n"
            "   -o                      Output configuration, possible values:\n"
            "                                   portaudio               use portaudio\n"
            "                                   raw:<filename.ext>      raw output to <filename.ext>\n"
            "                                   benchmark               show samples/sec performance "
            "                                                           (not actually making noise)"
            "   -h                      This text\n"
            "   -s <channel>            solo <channel>\n"
            "   -p <pattern>            loop <pattern>\n", prog);
}

variable_types:
prog
char *


decompiled_code:
__int64 __fastcall cmdline_parse(int argc, char **argv, _QWORD *a3)
{
int v4; // eax
__int64 result; // rax
__int64 v6; // r13
__int64 v7; // r13
__int64 v8; // r13
__int64 v9; // r13
int v10; // eax

cmdline_set_default_config_player((_DWORD *)*a3);
cmdline_set_default_config_output((_DWORD *)a3[1]);
if ( argc <= 1 )
{
LABEL_4:
cmdline_usage(*argv);
result = 1LL;
}
else
{
while ( 2 )
{
v4 = getopt(argc, argv, "i:r:f:b:hPlLp:s:o:");
if ( v4 == -1 )
{
v10 = optind;
if ( optind >= argc )
{
fwrite("error: no mod file specified\n", 1uLL, 0x1DuLL, stderr);
a3[3] = 0LL;
*((_DWORD *)a3 + 8) = 0;
result = 1LL;
}
else
{
a3[3] = &argv[optind];
*((_DWORD *)a3 + 8) = argc - v10;
result = 0LL;
}
}
else
{
switch ( v4 )
{
case '?':
switch ( optopt )
{
case 'b':
case 'f':
case 'i':
case 'o':
case 'r':
fprintf(stderr, "Option -%c requires an argument.\n", (unsigned int)optopt);
result = 1LL;
break;
default:
if ( (unsigned int)(optopt - 48) > 0x4A )
fprintf(stderr, "Unknown option character `\\x%x'.\n", (unsigned int)optopt);
else
fprintf(stderr, "Unknown option `-%c'.\n", (unsigned int)optopt);
result = 1LL;
break;
}
break;
case 'L':
*(_DWORD *)(*a3 + 156LL) = 1;
continue;
case 'P':
player_set_protracker_strict_mode(*a3, 1LL);
continue;
case 'b':
v7 = a3[1];
*(_DWORD *)(v7 + 4) = atoi(optarg);
continue;
case 'f':
if ( !strcmp(optarg, "ntsc") )
{
*(_DWORD *)(*a3 + 92LL) = 1;
}
else if ( !strcmp(optarg, "pal") )
{
*(_DWORD *)(*a3 + 92LL) = 0;
}
else
{
fprintf(stderr, "illegal amiga frequency option: %s\n", optarg);
}
continue;
case 'i':
if ( !strcmp(optarg, "linear") )
{
*(_DWORD *)(*a3 + 88LL) = 1;
}
else if ( !strcmp(optarg, "none") )
{
*(_DWORD *)(*a3 + 88LL) = 0;
}
else
{
fprintf(stderr, "illegal interpolation option: %s\n", optarg);
}
continue;
case 'l':
*((_DWORD *)a3 + 9) = 1;
continue;
case 'o':
if ( !cmdline_parse_output_opts(optarg, (__int64)a3) )
continue;
result = 1LL;
break;
case 'p':
v8 = *a3;
*(_DWORD *)(v8 + 160) = atoi(optarg);
continue;
case 'r':
v6 = a3[1];
*(_DWORD *)(v6 + 8) = atoi(optarg);
*(_DWORD *)(*a3 + 116LL) = (int)(float)*(int *)(a3[1] + 8LL);
continue;
case 's':
v9 = *a3;
*(_DWORD *)(v9 + 164) = atoi(optarg);
continue;
default:
goto LABEL_4;
}
}
break;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(int argc, char **argv, _QWORD *a3)
{
int v4; // eax
__int64 result; // rax
__int64 v6; // r13
__int64 v7; // r13
__int64 v8; // r13
__int64 v9; // r13
int v10; // eax

func0((_DWORD *)*a3);
func1((_DWORD *)a3[1]);
if ( argc <= 1 )
{
LABEL_4:
func3(*argv);
result = 1LL;
}
else
{
while ( 2 )
{
v4 = getopt(argc, argv, "i:r:f:b:hPlLp:s:o:");
if ( v4 == -1 )
{
v10 = optind;
if ( optind >= argc )
{
fwrite("error: no mod file specified\n", 1uLL, 0x1DuLL, stderr);
a3[3] = 0LL;
*((_DWORD *)a3 + 8) = 0;
result = 1LL;
}
else
{
a3[3] = &argv[optind];
*((_DWORD *)a3 + 8) = argc - v10;
result = 0LL;
}
}
else
{
switch ( v4 )
{
case '?':
switch ( optopt )
{
case 'b':
case 'f':
case 'i':
case 'o':
case 'r':
fprintf(stderr, "Option -%c requires an argument.\n", (unsigned int)optopt);
result = 1LL;
break;
default:
if ( (unsigned int)(optopt - 48) > 0x4A )
fprintf(stderr, "Unknown option character `\\x%x'.\n", (unsigned int)optopt);
else
fprintf(stderr, "Unknown option `-%c'.\n", (unsigned int)optopt);
result = 1LL;
break;
}
break;
case 'L':
*(_DWORD *)(*a3 + 156LL) = 1;
continue;
case 'P':
player_set_protracker_strict_mode(*a3, 1LL);
continue;
case 'b':
v7 = a3[1];
*(_DWORD *)(v7 + 4) = atoi(optarg);
continue;
case 'f':
if ( !strcmp(optarg, "ntsc") )
{
*(_DWORD *)(*a3 + 92LL) = 1;
}
else if ( !strcmp(optarg, "pal") )
{
*(_DWORD *)(*a3 + 92LL) = 0;
}
else
{
fprintf(stderr, "illegal amiga frequency option: %s\n", optarg);
}
continue;
case 'i':
if ( !strcmp(optarg, "linear") )
{
*(_DWORD *)(*a3 + 88LL) = 1;
}
else if ( !strcmp(optarg, "none") )
{
*(_DWORD *)(*a3 + 88LL) = 0;
}
else
{
fprintf(stderr, "illegal interpolation option: %s\n", optarg);
}
continue;
case 'l':
*((_DWORD *)a3 + 9) = 1;
continue;
case 'o':
if ( !func2(optarg, (__int64)a3) )
continue;
result = 1LL;
break;
case 'p':
v8 = *a3;
*(_DWORD *)(v8 + 160) = atoi(optarg);
continue;
case 'r':
v6 = a3[1];
*(_DWORD *)(v6 + 8) = atoi(optarg);
*(_DWORD *)(*a3 + 116LL) = (int)(float)*(int *)(a3[1] + 8LL);
continue;
case 's':
v9 = *a3;
*(_DWORD *)(v9 + 164) = atoi(optarg);
continue;
default:
goto LABEL_4;
}
}
break;
}
}
return result;
}

original_code:
int cmdline_parse(int argc, char ** argv, modplay_application_t * app) {
    int c;
    cmdline_set_default_config_player(app->player);
    cmdline_set_default_config_output(app->output_opts);
    if (argc < 2) {
        cmdline_usage(argv[0]);
        return 1;
    }
    while ((c = getopt(argc, argv, "i:r:f:b:hPlLp:s:o:")) != -1) {
        switch (c) {
            case 'i':
                if (!strcmp(optarg, "linear")) {
                    app->player->resampling = player_resampling_linear;
                } else if (!strcmp(optarg, "none")) {
                    app->player->resampling = player_resampling_none;
                } else {
                    fprintf(stderr, "illegal interpolation option: %s\n", optarg);
                }
                break;
            case 'r':
                app->output_opts->sample_rate = atoi(optarg);
                app->player->sample_rate = (float)app->output_opts->sample_rate;
                break;
            case 'f':
                if (!strcmp(optarg, "ntsc")) {
                    app->player->paula_freq_index = NTSC;
                } else if (!strcmp(optarg, "pal")) {
                    app->player->paula_freq_index = PAL;
                } else {
                    fprintf(stderr, "illegal amiga frequency option: %s\n", optarg);
                }
                break;
            case 'b':
                app->output_opts->buffer_size = atoi(optarg);
                break;
            case 'P':
                player_set_protracker_strict_mode(app->player, 1);
                break;
            case 'L':
                app->player->loop_module = 1;
                break;
            case 'l':
                app->loop_playlist = 1;
                break;
            case 'p':
                app->player->loop_pattern = atoi(optarg);
                break;
            case 's':
                app->player->solo_channel = atoi(optarg);
                break;
            case 'o':
                if (cmdline_parse_output_opts(optarg, app))
                    return 1;
                break;
            case '?':
                switch (optopt) {
                    case 'o':
                    case 'r':
                    case 'i':
                    case 'f':
                    case 'b':
                        fprintf(stderr, "Option -%c requires an argument.\n", optopt);
                        return 1;
                        break;
                    default:
                        if ((optopt >= 48) && (optopt <= 122))
                            fprintf(stderr, "Unknown option `-%c'.\n", optopt);
                        else
                            fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt);
                        return 1;
                        break;
                }
            case 'h':
            default:
                cmdline_usage(argv[0]);
                return 1;
                break;
        }
    }
    if (optind > (argc - 1)) {
        fprintf(stderr, "error: no mod file specified\n");
        app->playlist = 0;
        app->playlist_count = 0;
        return 1;
    } else {
        app->playlist = &argv[optind];
        app->playlist_count = argc - optind;
    }
    return 0;
}

canonical_original_code:
int cmdline_parse(int argc, char **argv, struct modplay_application_t *app) {
    int c;
    cmdline_set_default_config_player(app->player);
    cmdline_set_default_config_output(app->output_opts);
    if (argc < 2) {
        cmdline_usage(argv[0]);
        return 1;
    }
    while ((c = getopt(argc, argv, "i:r:f:b:hPlLp:s:o:")) != -1) {
        switch (c) {
            case 'i':
                if (!strcmp(optarg, "linear")) {
                    app->player->resampling = player_resampling_linear;
                } else if (!strcmp(optarg, "none")) {
                    app->player->resampling = player_resampling_none;
                } else {
                    fprintf(stderr, "illegal interpolation option: %s\n", optarg);
                }
                break;
            case 'r':
                app->output_opts->sample_rate = atoi(optarg);
                app->player->sample_rate = (float)app->output_opts->sample_rate;
                break;
            case 'f':
                if (!strcmp(optarg, "ntsc")) {
                    app->player->paula_freq_index = NTSC;
                } else if (!strcmp(optarg, "pal")) {
                    app->player->paula_freq_index = PAL;
                } else {
                    fprintf(stderr, "illegal amiga frequency option: %s\n", optarg);
                }
                break;
            case 'b':
                app->output_opts->buffer_size = atoi(optarg);
                break;
            case 'P':
                player_set_protracker_strict_mode(app->player, 1);
                break;
            case 'L':
                app->player->loop_module = 1;
                break;
            case 'l':
                app->loop_playlist = 1;
                break;
            case 'p':
                app->player->loop_pattern = atoi(optarg);
                break;
            case 's':
                app->player->solo_channel = atoi(optarg);
                break;
            case 'o':
                if (cmdline_parse_output_opts(optarg, app))
                    return 1;
                break;
            case '?':
                switch (optopt) {
                    case 'o':
                    case 'r':
                    case 'i':
                    case 'f':
                    case 'b':
                        fprintf(stderr, "Option -%c requires an argument.\n", optopt);
                        return 1;
                        break;
                    default:
                        if ((optopt >= 48) && (optopt <= 122))
                            fprintf(stderr, "Unknown option `-%c'.\n", optopt);
                        else
                            fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt);
                        return 1;
                        break;
                }
            case 'h':
            default:
                cmdline_usage(argv[0]);
                return 1;
                break;
        }
    }
    if (optind > (argc - 1)) {
        fprintf(stderr, "error: no mod file specified\n");
        app->playlist = 0;
        app->playlist_count = 0;
        return 1;
    } else {
        app->playlist = &argv[optind];
        app->playlist_count = argc - optind;
    }
    return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: c int

user_defined_types: enum ui_flavour_t { ui_flavour_quiet=0, ui_flavour_terminal=1, ui_flavour_curses=2 }

user_defined_types: struct ui_dirty_t { int order; int tick; int row; int sample; }

user_defined_types: enum output_drivers_t { output_driver_portaudio=0, output_driver_alsa=1, output_driver_raw=2, output_driver_benchmark=3, output_driver_sb16=4 }

user_defined_types: struct module_t { char song_title[21]; struct module_info_t module_info; enum module_type_t module_type; unsigned short num_channels; unsigned short num_samples; unsigned short num_instruments; unsigned short num_patterns; unsigned short num_orders; unsigned char orders[256]; struct module_sample_t *samples; struct module_instrument_t *instruments; struct module_pattern_t *patterns; unsigned char initial_speed; unsigned char initial_bpm; unsigned char initial_master_volume; unsigned char mix_volume; unsigned char initial_panning[64]; unsigned char channel_volume[64]; unsigned char panning_separation; char *song_message; }


decompiled_code:
char __fastcall effects_stm_A_settempo(__int64 a1, int a2)
{
char result; // al

if ( !*(_DWORD *)(a1 + 120) )
{
result = *(_BYTE *)(*(_QWORD *)a1 + 104LL * a2 + 34) >> 4;
*(_BYTE *)(a1 + 104) = result;
}
return result;
}

canonical_decompiled_code:
char __fastcall func0(__int64 a1, int a2)
{
char result; // al

if ( !*(_DWORD *)(a1 + 120) )
{
result = *(_BYTE *)(*(_QWORD *)a1 + 104LL * a2 + 34) >> 4;
*(_BYTE *)(a1 + 104) = result;
}
return result;
}

original_code:
void effects_stm_A_settempo(player_t * player, int channel)
{
    if (player->current_tick == 0) {
        player->speed = player->channels[channel].effect_value >> 4;
    }
}

canonical_original_code:
void effects_stm_A_settempo(struct player_t *player, int channel)
{
    if (player->current_tick == 0) {
        player->speed = player->channels[channel].effect_value >> 4;
    }
}

variable_types: channel int

user_defined_types: struct module_sample_t { struct module_sample_header_t header; short *data; }

user_defined_types: struct module_instrument_t { char name[26]; unsigned char new_note_action; unsigned char duplicate_check_type; unsigned char duplicate_check_action; unsigned char fadeout; char pitch_pan_separation; unsigned char pitch_pan_center; unsigned char default_pan; unsigned char random_volume_variation; unsigned char random_panning_variation; unsigned char note_sample_table[240]; struct module_instrument_envelope_t volume_envelope; struct module_instrument_envelope_t pan_envelope; struct module_instrument_envelope_t pitch_envelope; }

user_defined_types: struct module_pattern_t { unsigned short num_rows; struct module_pattern_row_t *rows; }

user_defined_types: struct module_instrument_envelope_t { unsigned char flags; unsigned char num_nodes; unsigned char loop_start; unsigned char loop_end; unsigned char susloop_start; unsigned char susloop_end; struct module_instrument_envelope_node_t *nodes; }


original_code:
void effects_stm_B_positionjump(player_t * player, int channel)
{
    if (player->channels[channel].effect_value < player->current_order) {
        if (!player->loop_module)
            return;
    }
    if (player->current_tick == 0) {
        player->next_order = player->channels[channel].effect_value;
        player->next_row = 0;
        player->do_break = 1;
    }
}

canonical_original_code:
void effects_stm_B_positionjump(struct player_t *player, int channel)
{
    if (player->channels[channel].effect_value < player->current_order) {
        if (!player->loop_module)
            return;
    }
    if (player->current_tick == 0) {
        player->next_order = player->channels[channel].effect_value;
        player->next_row = 0;
        player->do_break = 1;
    }
}

user_defined_types: struct player_t { struct player_channel_t *channels; struct module_t *module; void (**effect_map)(struct player_t *, int); void (*newrow_action)(struct player_t *, struct module_pattern_data_t *, int); void *callback_user_ptr; void (*order_callback)(struct player_t *, void *user_ptr); void (*row_callback)(struct player_t *, void *user_ptr); void (*tick_callback)(struct player_t *, void *user_ptr); void (*channel_sample_callback)(struct player_t *, void *user_ptr); unsigned int channel_sample_callback_mask; unsigned short *period_table; enum player_resampling_t resampling; enum defs_mod_paulafreq_index_t paula_freq_index; int protracker_strict_mode; unsigned short period_top; unsigned short period_bottom; unsigned char speed; unsigned short bpm; float tick_pos; float tick_duration; unsigned int sample_rate; int current_tick; int current_pattern; int current_order; int current_row; int do_break; int next_order; int next_row; int pattern_delay; int pattern_delay_active; int loop_module; int loop_pattern; int solo_channel; int playing; }

user_defined_types: enum player_resampling_t { player_resampling_none=0, player_resampling_linear=1 }

user_defined_types: enum defs_mod_paulafreq_index_t { PAL=0, NTSC=1 }

user_defined_types: struct module_pattern_row_t { struct module_pattern_data_t *data; }


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

if ( !*(_DWORD *)(a1 + 120) )
{
result = (*(_BYTE *)(*(_QWORD *)a1 + 104LL * a2 + 34) & 0xF)
+ 10 * (unsigned int)(*(_BYTE *)(*(_QWORD *)a1 + 104LL * a2 + 34) >> 4);
*(_DWORD *)(a1 + 144) = result;
*(_DWORD *)(a1 + 136) = 1;
}
return result;
}

original_code:
void effects_stm_C_patternbreak(player_t * player, int channel)
{
    if (player->current_tick == 0) {
        player->next_row = ((player->channels[channel].effect_value >> 4) * 10 + (player->channels[channel].effect_value & 0x0f));
        player->do_break = 1;
    }
}

canonical_original_code:
void effects_stm_C_patternbreak(struct player_t *player, int channel)
{
    if (player->current_tick == 0) {
        player->next_row = ((player->channels[channel].effect_value >> 4) * 10 + (player->channels[channel].effect_value & 0x0f));
        player->do_break = 1;
    }
}

user_defined_types: struct player_channel_t { unsigned char sample_num; float sample_pos; float sample_step; int period_index; unsigned short period; unsigned int frequency; unsigned char sample_delay; unsigned short dest_period; unsigned char dest_sample_num; char dest_volume; unsigned char panning; char volume; char volume_master; unsigned char effect_num; unsigned char effect_value; unsigned char effect_last_value[26]; unsigned char effect_last_value_y[26]; int vibrato_state; int tremolo_state; int tremor_state; unsigned char vibrato_waveform; unsigned char tremolo_waveform; unsigned char pattern_loop_position; unsigned char pattern_loop_count; }

user_defined_types: struct module_info_t { char default_file_extension[8]; char description[64]; union { struct { char signature[8]; } flags_mod; struct { unsigned char st2vibrato; unsigned char st2tempo; unsigned char amigaslides; unsigned char amigalimits; unsigned char st30volumeslides; unsigned short st3_version; unsigned char default_panning; unsigned char mono; } flags_s3m; struct { unsigned char version_major; unsigned char version_minor; } flags_stm; struct { unsigned char stereo; unsigned char use_instruments; unsigned char linear_slides; unsigned char old_effects; unsigned char g_effect_link_memory; unsigned short created_with; unsigned short compatible_with; } flags_it; }; }

user_defined_types: enum module_type_t { module_type_mod=0, module_type_s3m=1, module_type_mtm=2, module_type_stm=3, module_type_it=4 }

user_defined_types: struct module_sample_header_t { char name[29]; unsigned int length; char finetune; unsigned short c2spd; unsigned char volume; unsigned char loop_enabled; unsigned int loop_start; unsigned int loop_length; unsigned int loop_end; unsigned int susloop_start; unsigned int susloop_end; unsigned char global_volume; unsigned char vibrato_speed; unsigned char vibrato_depth; unsigned char vibrato_waveform; unsigned char vibrato_rate; unsigned char pan; }