declaration

decompiled_code:
char *__fastcall declaration(char *dest)
{
char *result; // rax

puts(s);
identificator(0, 0);
strcpy(dest, token);
askForNext();
if ( *token != 58 )
{
fprintf(stderr, "%s : Le token attendu est ':'\n", "erreur de syntaxe");
goto LABEL_5;
}
type();
strcpy(dest + 9, token);
askForNext();
result = token;
if ( *token != 59 )
{
fprintf(stderr, "%s : Le token attendu est ';'\n", "erreur de syntaxe");
LABEL_5:
exit(1);
}
return result;
}

canonical_decompiled_code:
char *__fastcall func3(char *dest)
{
char *result; // rax

puts(s);
func2(0, 0);
strcpy(dest, token);
func0();
if ( *token != 58 )
{
fprintf(stderr, "%s : Le token attendu est ':'\n", "erreur de syntaxe");
goto LABEL_5;
}
func1();
strcpy(dest + 9, token);
func0();
result = token;
if ( *token != 59 )
{
fprintf(stderr, "%s : Le token attendu est ';'\n", "erreur de syntaxe");
LABEL_5:
exit(1);
}
return result;
}

original_code:
void declaration(declare *cur_decl)
{
    printf("Analyse d'une déclaration...\n");
    identificator(0, 0);
    strcpy(cur_decl->var, token);
    askForNext();
    if (*token != ':') {
        fprintf(stderr, "%s : Le token attendu est \':\'\n", "erreur de syntaxe");
        exit(1);
    }
    type();
    strcpy(cur_decl->type, token);
    askForNext();
    if (*token != ';') {
        fprintf(stderr, "%s : Le token attendu est \';\'\n", "erreur de syntaxe");
        exit(1);
    }
}

canonical_original_code:
void declaration(struct _declaration *cur_decl)
{
    printf("Analyse d'une déclaration...\n");
    identificator(0, 0);
    strcpy(cur_decl->var, token);
    askForNext();
    if (*token != ':') {
        fprintf(stderr, "%s : Le token attendu est \':\'\n", "erreur de syntaxe");
        exit(1);
    }
    type();
    strcpy(cur_decl->type, token);
    askForNext();
    if (*token != ';') {
        fprintf(stderr, "%s : Le token attendu est \';\'\n", "erreur de syntaxe");
        exit(1);
    }
}

variable_types: struct _declaration { char var[9]; char type[7]; struct _declaration *next; } *


declarations

decompiled_code:
bool declarations()
{
__int64 v0; // r13
char *v1; // rax
char *v2; // rbp
char *v3; // r12
bool v4; // zf
__int64 v5; // rdx
bool result; // al
char *v7; // rax

peek_next(&token);
while ( 1 )
{
v3 = cur_proc;
v4 = strcmp(token, "declare") == 0;
v5 = *((_QWORD *)cur_proc + 2);
result = !v4;
if ( !v4 )
break;
if ( v5 )
{
v0 = *((_QWORD *)cur_proc + 3);
v1 = (char *)malloc(0x18uLL);
*(_QWORD *)(v0 + 16) = v1;
v2 = v1;
*((_QWORD *)v3 + 3) = v1;
}
else
{
v7 = (char *)malloc(0x18uLL);
*((_QWORD *)v3 + 3) = v7;
v2 = v7;
*((_QWORD *)v3 + 2) = v7;
}
*(_QWORD *)v2 = 0LL;
*(_WORD *)(v2 + 13) = 0;
v2[8] = 0;
*(_DWORD *)(v2 + 9) = 0;
v2[15] = 0;
*((_QWORD *)v2 + 2) = 0LL;
askForNext();
declaration(v2);
peek_next(&token);
}
if ( !v5 )
{
fprintf(stderr, aSAuMoinsUne1D, "erreur de syntaxe");
exit(1);
}
return result;
}

canonical_decompiled_code:
bool func4()
{
__int64 v0; // r13
char *v1; // rax
char *v2; // rbp
char *v3; // r12
bool v4; // zf
__int64 v5; // rdx
bool result; // al
char *v7; // rax

peek_next(&token);
while ( 1 )
{
v3 = cur_proc;
v4 = strcmp(token, "declare") == 0;
v5 = *((_QWORD *)cur_proc + 2);
result = !v4;
if ( !v4 )
break;
if ( v5 )
{
v0 = *((_QWORD *)cur_proc + 3);
v1 = (char *)malloc(0x18uLL);
*(_QWORD *)(v0 + 16) = v1;
v2 = v1;
*((_QWORD *)v3 + 3) = v1;
}
else
{
v7 = (char *)malloc(0x18uLL);
*((_QWORD *)v3 + 3) = v7;
v2 = v7;
*((_QWORD *)v3 + 2) = v7;
}
*(_QWORD *)v2 = 0LL;
*(_WORD *)(v2 + 13) = 0;
v2[8] = 0;
*(_DWORD *)(v2 + 9) = 0;
v2[15] = 0;
*((_QWORD *)v2 + 2) = 0LL;
func0();
func3(v2);
peek_next(&token);
}
if ( !v5 )
{
fprintf(stderr, aSAuMoinsUne1D, "erreur de syntaxe");
exit(1);
}
return result;
}

original_code:
void declarations()
{
    declare *cur_decl;
    peek_next(&token);
    while (!strcmp(token, "declare")) {
        if (!cur_proc->first_declare) {
            cur_decl = cur_proc->first_declare = cur_proc->last_declare = malloc(sizeof(declare));
        }
        else {
            cur_decl = cur_proc->last_declare->next = malloc(sizeof(declare));
            cur_proc->last_declare = cur_decl;
        }
        *cur_decl = (declare) {"", "", ((void *)0)};
        askForNext();
        declaration(cur_decl);
        peek_next(&token);
    }
    if (!cur_proc->first_declare) {
        fprintf(stderr, "%s : Au moins une (1) déclaration doit être faite.\n", "erreur de syntaxe");
        exit(1);
    }
}

canonical_original_code:
void declarations()
{
    struct _declaration *cur_decl;
    peek_next(&token);
    while (!strcmp(token, "declare")) {
        if (!cur_proc->first_declare) {
            cur_decl = cur_proc->first_declare = cur_proc->last_declare = malloc(sizeof(declare));
        }
        else {
            cur_decl = cur_proc->last_declare->next = malloc(sizeof(declare));
            cur_proc->last_declare = cur_decl;
        }
        *cur_decl = (struct _declaration) {"", "", ((void *)0)};
        askForNext();
        declaration(cur_decl);
        peek_next(&token);
    }
    if (!cur_proc->first_declare) {
        fprintf(stderr, "%s : Au moins une (1) déclaration doit être faite.\n", "erreur de syntaxe");
        exit(1);
    }
}

return_type: void

user_defined_types: struct _declaration { char var[9]; char type[7]; struct _declaration *next; }


number

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

askForNext();
printf("Analyse d'un nombre, le token est :\n%s\n", token);
if ( (unsigned int)_isoc99_sscanf(token, "%f", &v2) )
return 0LL;
if ( !a1 )
{
fprintf(stderr, aSLeTokenAttend_6, "erreur de syntaxe");
exit(1);
}
return 1LL;
}

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

func0();
printf("Analyse d'un nombre, le token est :\n%s\n", token);
if ( (unsigned int)_isoc99_sscanf(token, "%f", &v2) )
return 0LL;
if ( !a1 )
{
fprintf(stderr, aSLeTokenAttend_6, "erreur de syntaxe");
exit(1);
}
return 1LL;
}

original_code:
int number(int maybe)
{
    float f;
    askForNext();
    printf("Analyse d'un nombre, le token est :\n%s\n", token);
    if (sscanf(token, "%f", &f) == 0){
        if (maybe) {
            return 1;
        }
        fprintf(stderr, "%s : Le token attendu doit être un nombre.\n", "erreur de syntaxe");
        exit(1);
    }
    return 0;
}

variable_types: maybe int

variable_types: f float

return_type: int


decompiled_code:
__int64 __fastcall find_decl(char *s2)
{
__int64 i; // r12

for ( i = *((_QWORD *)cur_proc + 2); i; i = *(_QWORD *)(i + 16) )
{
if ( !strcmp((const char *)i, s2) )
break;
}
return i;
}

canonical_decompiled_code:
__int64 __fastcall func6(char *s2)
{
__int64 i; // r12

for ( i = *((_QWORD *)cur_proc + 2); i; i = *(_QWORD *)(i + 16) )
{
if ( !strcmp((const char *)i, s2) )
break;
}
return i;
}

original_code:
declare* find_decl(char *var)
{
    declare* cur, *first;
    cur = first = cur_proc->first_declare;
    if (!first) {
        return ((void *)0);
    }
    while (cur) {
        if (!strcmp(cur->var, var)) {
            return cur;
        }
        cur = cur->next;
    }
    return ((void *)0);
}

canonical_original_code:
struct _declaration *find_decl(char *var)
{
    struct _declaration *cur; struct _declaration *first;
    cur = first = cur_proc->first_declare;
    if (!first) {
        return ((void *)0);
    }
    while (cur) {
        if (!strcmp(cur->var, var)) {
            return cur;
        }
        cur = cur->next;
    }
    return ((void *)0);
}

variable_types:
var
char *

return_type: struct _declaration { char var[9]; char type[7]; struct _declaration *next; } *


factor

decompiled_code:
char __fastcall factor(const char *a1)
{
__int64 v1; // rax
bool v2; // zf

puts("Analyse d'un facteur...");
if ( (unsigned int)identificator(0, 1) )
{
rewind_pos(token);
LODWORD(v1) = number(1);
if ( !(_DWORD)v1 )
return v1;
if ( *token == 40 )
{
arithmetic_expression(a1);
LOBYTE(v1) = (_BYTE)token;
if ( *token == 41 )
return v1;
fprintf(stderr, "%s : Le token attendu est ')'\n", "erreur de syntaxe");
}
else
{
fprintf(stderr, "%s : Le token attendu est un nombre, une variable ou '('\n", "erreur de syntaxe");
}
LABEL_12:
exit(1);
}
v1 = find_decl(token);
if ( !v1 )
{
fprintf(stderr, aSLaVariableDoi, "erreur de syntaxe");
exit(1);
}
if ( !strcmp(a1, "entier") )
{
v2 = strcmp((const char *)(v1 + 9), "entier") == 0;
LOBYTE(v1) = !v2;
if ( !v2 )
{
fprintf(stderr, aSUneVariableEn, "erreur de syntaxe");
goto LABEL_12;
}
}
return v1;
}

canonical_decompiled_code:
char __fastcall func7(const char *a1)
{
__int64 v1; // rax
bool v2; // zf

puts("Analyse d'un facteur...");
if ( (unsigned int)func2(0, 1) )
{
rewind_pos(token);
LODWORD(v1) = func5(1);
if ( !(_DWORD)v1 )
return v1;
if ( *token == 40 )
{
func9(a1);
LOBYTE(v1) = (_BYTE)token;
if ( *token == 41 )
return v1;
fprintf(stderr, "%s : Le token attendu est ')'\n", "erreur de syntaxe");
}
else
{
fprintf(stderr, "%s : Le token attendu est un nombre, une variable ou '('\n", "erreur de syntaxe");
}
LABEL_12:
exit(1);
}
v1 = func6(token);
if ( !v1 )
{
fprintf(stderr, aSLaVariableDoi, "erreur de syntaxe");
exit(1);
}
if ( !strcmp(a1, "entier") )
{
v2 = strcmp((const char *)(v1 + 9), "entier") == 0;
LOBYTE(v1) = !v2;
if ( !v2 )
{
fprintf(stderr, aSUneVariableEn, "erreur de syntaxe");
goto LABEL_12;
}
}
return v1;
}

original_code:
void factor(char *affecting_type)
{
    printf("Analyse d'un facteur...\n");
    if (!identificator(0, 1)) {
        declare *this_var_decl = find_decl(token);
        if (!this_var_decl) {
            fprintf(stderr, "%s : La variable doit être préalablement déclarée\n", "erreur de syntaxe");
            exit(1);
        }
        if (!strcmp(affecting_type, "entier") && strcmp(this_var_decl->type, "entier")) {
            fprintf(stderr, "%s : Une variable entière ne peut se faire attribuer un résultat réel.\n", "erreur de syntaxe");
            exit(1);
        }
        return;
    }
    rewind_pos(token);
    if (!number(1)) {
        return;
    }
    if (*token != '(') {
       fprintf(stderr, "%s : Le token attendu est un nombre, une variable ou \'(\'\n", "erreur de syntaxe");
       exit(1);
    }
    arithmetic_expression(affecting_type);
    if (*token != ')') {
       fprintf(stderr, "%s : Le token attendu est \')\'\n", "erreur de syntaxe");
       exit(1);
    }
}

canonical_original_code:
void factor(char *affecting_type)
{
    printf("Analyse d'un facteur...\n");
    if (!identificator(0, 1)) {
        struct _declaration *this_var_decl = find_decl(token);
        if (!this_var_decl) {
            fprintf(stderr, "%s : La variable doit être préalablement déclarée\n", "erreur de syntaxe");
            exit(1);
        }
        if (!strcmp(affecting_type, "entier") && strcmp(this_var_decl->type, "entier")) {
            fprintf(stderr, "%s : Une variable entière ne peut se faire attribuer un résultat réel.\n", "erreur de syntaxe");
            exit(1);
        }
        return;
    }
    rewind_pos(token);
    if (!number(1)) {
        return;
    }
    if (*token != '(') {
       fprintf(stderr, "%s : Le token attendu est un nombre, une variable ou \'(\'\n", "erreur de syntaxe");
       exit(1);
    }
    arithmetic_expression(affecting_type);
    if (*token != ')') {
       fprintf(stderr, "%s : Le token attendu est \')\'\n", "erreur de syntaxe");
       exit(1);
    }
}


term

decompiled_code:
__int64 __fastcall term(const char *a1)
{
__int64 result; // rax

puts("Analyse d'un terme...");
do
{
do
{
factor(a1);
askForNext();
result = (unsigned __int8)*token;
}
while ( (_BYTE)result == 42 );
}
while ( (_BYTE)result == 47 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(const char *a1)
{
__int64 result; // rax

puts("Analyse d'un terme...");
do
{
do
{
func7(a1);
func0();
result = (unsigned __int8)*token;
}
while ( (_BYTE)result == 42 );
}
while ( (_BYTE)result == 47 );
return result;
}

original_code:
void term(char *affecting_type)
{
    printf("Analyse d'un terme...\n");
    do {
        factor(affecting_type);
        askForNext();
    } while (*token == '*' || *token == '/');
}


decompiled_code:
__int64 __fastcall arithmetic_expression(const char *a1)
{
__int64 result; // rax

puts(aAnalyseDUneExp);
do
{
term(a1);
result = (unsigned int)(unsigned __int8)*token - 43;
}
while ( ((*token - 43) & 0xFD) == 0 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(const char *a1)
{
__int64 result; // rax

puts(aAnalyseDUneExp);
do
{
func8(a1);
result = (unsigned int)(unsigned __int8)*token - 43;
}
while ( ((*token - 43) & 0xFD) == 0 );
return result;
}

original_code:
void arithmetic_expression(char *affecting_type)
{
    printf("Analyse d'une expression arithmétique\n");
    do {
        term(affecting_type);
    } while (*token == '+' || *token == '-');
}


decompiled_code:
__int64 affectation_instruction()
{
__int64 v0; // rax
__int64 v1; // rbx

puts("Analyse d'une instruction d'affectation...");
identificator(0, 0);
v0 = find_decl(token);
if ( !v0 )
{
fprintf(stderr, aSLaVariableDoi, "erreur de syntaxe");
goto LABEL_5;
}
v1 = v0;
askForNext();
if ( *token != 61 )
{
fprintf(stderr, "%s : Le token attendu est '='\n", "erreur de syntaxe");
LABEL_5:
exit(1);
}
return arithmetic_expression((const char *)(v1 + 9));
}

canonical_decompiled_code:
__int64 func10()
{
__int64 v0; // rax
__int64 v1; // rbx

puts("Analyse d'une instruction d'affectation...");
func2(0, 0);
v0 = func6(token);
if ( !v0 )
{
fprintf(stderr, aSLaVariableDoi, "erreur de syntaxe");
goto LABEL_5;
}
v1 = v0;
func0();
if ( *token != 61 )
{
fprintf(stderr, "%s : Le token attendu est '='\n", "erreur de syntaxe");
LABEL_5:
exit(1);
}
return func9((const char *)(v1 + 9));
}

original_code:
void affectation_instruction()
{
    declare *affecting_var_decl;
    printf("Analyse d'une instruction d'affectation...\n");
    identificator(0, 0);
    affecting_var_decl = find_decl(token);
    if (!affecting_var_decl) {
        fprintf(stderr, "%s : La variable doit être préalablement déclarée\n", "erreur de syntaxe");
        exit(1);
    }
    askForNext();
    if (*token != '=') {
        fprintf(stderr, "%s : Le token attendu est \'=\'\n", "erreur de syntaxe");
        exit(1);
    }
    arithmetic_expression(affecting_var_decl->type);
}

canonical_original_code:
void affectation_instruction()
{
    struct _declaration *affecting_var_decl;
    printf("Analyse d'une instruction d'affectation...\n");
    identificator(0, 0);
    affecting_var_decl = find_decl(token);
    if (!affecting_var_decl) {
        fprintf(stderr, "%s : La variable doit être préalablement déclarée\n", "erreur de syntaxe");
        exit(1);
    }
    askForNext();
    if (*token != '=') {
        fprintf(stderr, "%s : Le token attendu est \'=\'\n", "erreur de syntaxe");
        exit(1);
    }
    arithmetic_expression(affecting_var_decl->type);
}


decompiled_code:
char *affectation_instructions()
{
char *result; // rax

do
{
affectation_instruction();
result = token;
}
while ( *token == 59 );
return result;
}

canonical_decompiled_code:
char *func11()
{
char *result; // rax

do
{
func10();
result = token;
}
while ( *token == 59 );
return result;
}

original_code:
void affectation_instructions()
{
    do {
        affectation_instruction();
    }
    while (*token == ';');
}


procedure

decompiled_code:
__int64 procedure()
{
askForNext();
printf("Analyse d'un bloc 'Procedure', le token est:\n'%s'\n", token);
if ( strcmp(token, "Procedure") )
{
fprintf(stderr, "%s : Le token attendu est 'Procedure'\n", "erreur de syntaxe");
goto LABEL_5;
}
identificator(1, 0);
declarations();
affectation_instructions();
if ( strcmp(token, "Fin_Procedure") )
{
fprintf(stderr, "%s : Le token attendu est 'Fin_Procedure'\n", "erreur de syntaxe");
LABEL_5:
exit(1);
}
return identificator(1, 0);
}

canonical_decompiled_code:
__int64 func12()
{
func0();
printf("Analyse d'un bloc 'Procedure', le token est:\n'%s'\n", token);
if ( strcmp(token, "Procedure") )
{
fprintf(stderr, "%s : Le token attendu est 'Procedure'\n", "erreur de syntaxe");
goto LABEL_5;
}
func2(1, 0);
func4();
func11();
if ( strcmp(token, "Fin_Procedure") )
{
fprintf(stderr, "%s : Le token attendu est 'Fin_Procedure'\n", "erreur de syntaxe");
LABEL_5:
exit(1);
}
return func2(1, 0);
}

original_code:
void procedure()
{
    askForNext();
    printf("Analyse d'un bloc \'Procedure\', le token est:\n\'%s\'\n", token);
    if (strcmp(token, "Procedure") != 0)
    {
        fprintf(stderr, "%s : Le token attendu est \'Procedure\'\n", "erreur de syntaxe");
        exit(1);
    }
    identificator(1,0);
    declarations();
    affectation_instructions();
    if (strcmp(token, "Fin_Procedure"))
    {
        fprintf(stderr, "%s : Le token attendu est \'Fin_Procedure\'\n", "erreur de syntaxe");
        exit(1);
    }
    identificator(1, 0);
}


decompiled_code:
__int64 analyse_syntax()
{
char *v0; // rbx
char *v1; // rax
__int64 result; // rax

token = (char *)malloc(0x10uLL);
do
{
if ( firstp )
{
v0 = cur_proc;
v1 = (char *)malloc(0x28uLL);
*((_QWORD *)v0 + 4) = v1;
cur_proc = v1;
*((_QWORD *)v1 + 4) = 0LL;
}
else
{
v1 = (char *)malloc(0x28uLL);
firstp = (__int64)v1;
*((_QWORD *)v1 + 4) = 0LL;
cur_proc = v1;
}
*(_OWORD *)v1 = 0LL;
*((_OWORD *)v1 + 1) = 0LL;
procedure();
result = peek_next(&token);
}
while ( token );
return result;
}

canonical_decompiled_code:
__int64 func13()
{
char *v0; // rbx
char *v1; // rax
__int64 result; // rax

token = (char *)malloc(0x10uLL);
do
{
if ( firstp )
{
v0 = cur_proc;
v1 = (char *)malloc(0x28uLL);
*((_QWORD *)v0 + 4) = v1;
cur_proc = v1;
*((_QWORD *)v1 + 4) = 0LL;
}
else
{
v1 = (char *)malloc(0x28uLL);
firstp = (__int64)v1;
*((_QWORD *)v1 + 4) = 0LL;
cur_proc = v1;
}
*(_OWORD *)v1 = 0LL;
*((_OWORD *)v1 + 1) = 0LL;
func12();
result = peek_next(&token);
}
while ( token );
return result;
}

original_code:
void analyse_syntax()
{
    token = malloc(sizeof(char)*16);
    do {
        if (firstp == ((void *)0)) {
            firstp = malloc(sizeof(proc));
            *firstp = (proc){"", ((void *)0), ((void *)0)};
            cur_proc = firstp;
        }
        else {
            cur_proc->next = malloc(sizeof(proc));
            cur_proc = cur_proc->next;
            *cur_proc = (proc){"", ((void *)0), ((void *)0)};
        }
        procedure();
        peek_next(&token);
    }
    while (token != ((void *)0));
}

canonical_original_code:
void analyse_syntax()
{
    token = malloc(sizeof(char)*16);
    do {
        if (firstp == ((void *)0)) {
            firstp = malloc(sizeof(proc));
            *firstp = (struct _procedure){"", ((void *)0), ((void *)0)};
            cur_proc = firstp;
        }
        else {
            cur_proc->next = malloc(sizeof(proc));
            cur_proc = cur_proc->next;
            *cur_proc = (struct _procedure){"", ((void *)0), ((void *)0)};
        }
        procedure();
        peek_next(&token);
    }
    while (token != ((void *)0));
}

user_defined_types: struct _procedure { char id[9]; struct _declaration *first_declare; struct _declaration *last_declare; struct _procedure *next; }


decompiled_code:
size_t __fastcall rewind_pos(const char *a1)
{
size_t result; // rax

*cur_pos = cur_pos[MAIN_BUFFER - INIT_POS];
result = ~strlen(a1);
cur_pos += result;
return result;
}

canonical_decompiled_code:
size_t __fastcall func0(const char *a1)
{
size_t result; // rax

*cur_pos = cur_pos[MAIN_BUFFER - INIT_POS];
result = ~strlen(a1);
cur_pos += result;
return result;
}

original_code:
void rewind_pos(char *token)
{
    cur_pos[0] = MAIN_BUFFER[cur_pos-INIT_POS];
    cur_pos-=strlen(token)+1;
}

variable_types:
token
char *


in

decompiled_code:
__int64 __fastcall in(const char *a1, char a2)
{
const char *v2; // rax

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

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

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

original_code:
int in(const char delims[], char token)
{
    int i;
    for (i = 0; i < strlen(delims); i++) {
        if (token == delims[i]) {
            return 1;
        }
    }
    return 0;
}

canonical_original_code:
int in(char delims[], char token)
{
    int i;
    for (i = 0; i < strlen(delims); i++) {
        if (token == delims[i]) {
            return 1;
        }
    }
    return 0;
}

variable_types:
delims
char []

variable_types: token char

variable_types: i int


next

decompiled_code:
__int64 __fastcall next(char **a1)
{
char *v1; // rbp
__int64 v2; // rbx
__int64 v3; // r12
unsigned int v4; // er14
char *v5; // rax
const char *v6; // rbp
int v7; // ebx
unsigned int v8; // er12

v1 = cur_pos;
v2 = INIT_POS;
if ( (unsigned __int64)cur_pos > INIT_POS + BUFLEN - 1 )
{
*a1 = (_BYTE *)(rewind_pos + 1);
return (unsigned int)-2;
}
v3 = MAIN_BUFFER;
while ( (unsigned int)in(" \n\t=+-*/:;()", v1[v3 - v2]) )
{
cur_pos = ++v1;
v4 = v1[v3 - v2 - 1];
if ( (unsigned int)in("=+-*/:;()", v1[v3 - v2 - 1]) )
{
sprintf(*a1, "%c", v4);
return 0LL;
}
}
v5 = strtok(v1, " \n\t=+-*/:;()");
v6 = v5;
if ( !v5 )
{
*a1 = 0LL;
return (unsigned int)-1;
}
v7 = strlen(v5);
v8 = v7;
if ( (int)malloc_usable_size(*a1) < v7 )
{
*a1 = 0LL;
return v8;
}
cur_pos += v7;
strcpy(*a1, v6);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(char **a1)
{
char *v1; // rbp
__int64 v2; // rbx
__int64 v3; // r12
unsigned int v4; // er14
char *v5; // rax
const char *v6; // rbp
int v7; // ebx
unsigned int v8; // er12

v1 = cur_pos;
v2 = INIT_POS;
if ( (unsigned __int64)cur_pos > INIT_POS + BUFLEN - 1 )
{
*a1 = (_BYTE *)(rewind_pos + 1);
return (unsigned int)-2;
}
v3 = MAIN_BUFFER;
while ( (unsigned int)func1(" \n\t=+-*/:;()", v1[v3 - v2]) )
{
cur_pos = ++v1;
v4 = v1[v3 - v2 - 1];
if ( (unsigned int)func1("=+-*/:;()", v1[v3 - v2 - 1]) )
{
sprintf(*a1, "%c", v4);
return 0LL;
}
}
v5 = strtok(v1, " \n\t=+-*/:;()");
v6 = v5;
if ( !v5 )
{
*a1 = 0LL;
return (unsigned int)-1;
}
v7 = strlen(v5);
v8 = v7;
if ( (int)malloc_usable_size(*a1) < v7 )
{
*a1 = 0LL;
return v8;
}
cur_pos += v7;
strcpy(*a1, v6);
return 0LL;
}

original_code:
int next(char **token)
{
    if (cur_pos > INIT_POS+BUFLEN-1) {
        *token = ((void *)0)+1;
        return -2;
    }
    char *tok = ((void *)0);
    while (in(lexicon.all_delims, MAIN_BUFFER[cur_pos-INIT_POS])) {
        cur_pos++;
        if (in(lexicon.delims_n_tokens, MAIN_BUFFER[cur_pos-INIT_POS-1])) {
            sprintf(*token, "%c\0", MAIN_BUFFER[cur_pos-INIT_POS-1]);
            return 0;
        }
    }
    tok = strtok(cur_pos, lexicon.all_delims);
    if (!tok) {
        *token = ((void *)0);
        return -1;
    }
    int toksize = strlen(tok);
    if (toksize > malloc_usable_size(*token)) {
        *token = ((void *)0);
        return toksize;
    }
    cur_pos += toksize;
    strcpy(*token, tok);
    return 0;
}

variable_types:
token
char **

variable_types:
tok
char *

variable_types: toksize int


decompiled_code:
size_t __fastcall peek_next(char **a1)
{
const char *v1; // rbp

v1 = *a1;
next(a1);
return rewind_pos(v1);
}

canonical_decompiled_code:
size_t __fastcall func3(char **a1)
{
const char *v1; // rbp

v1 = *a1;
func2(a1);
return func0(v1);
}

original_code:
void peek_next(char **token)
{
    char *tok = *token;
    next(token);
    rewind_pos(tok);
}


decompiled_code:
__int64 __fastcall is_reserved(char *s2)
{
const char *v1; // rbx

v1 = "Procedure";
while ( strcmp(v1, s2) )
{
v1 += 16;
if ( v1 == (const char *)743 )
return 0LL;
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(char *s2)
{
const char *v1; // rbx

v1 = "Procedure";
while ( strcmp(v1, s2) )
{
v1 += 16;
if ( v1 == (const char *)743 )
return 0LL;
}
return 1LL;
}

original_code:
int is_reserved(char *token)
{
    int i;
    for (i = 0; i < 5; i++) {
        if (!strcmp(lexicon.reserved_words[i], token)) {
            return 1;
        }
    }
    return 0;
}


decompiled_code:
__int64 print_help()
{
puts("Usage: ./matrix_multiply -n<matrix_dimension> -a<algorithm> [-p]");
return 0LL;
}

canonical_decompiled_code:
__int64 func7()
{
puts("Usage: ./matrix_multiply -n<matrix_dimension> -a<algorithm> [-p]");
return 0LL;
}

original_code:
int print_help()
{
  printf("Usage: ./matrix_multiply -n<matrix_dimension> -a<algorithm> [-p]\n");
  return 0;
}


decompiled_code:
__int64 __fastcall e_flags(__int64 a1, __int64 a2, __int64 a3)
{
return a3;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 a3)
{
return a3;
}

original_code:
char *
e_flags(const char *text, const int size, void *context)
{
    return (char*)context;
}

canonical_original_code:
char *e_flags(char *text, int size, void *context)
{
    return (char *)context;
}

variable_types:
text
char *

variable_types: size int

variable_types:
context
void *

return_type: char *


complain

decompiled_code:
int complain(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
fprintf(stderr, "%s: ", pgm);
vfprintf(stderr, format, arg);
fputc(10, stderr);
return fflush(stderr);
}

canonical_decompiled_code:
int func2(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
fprintf(stderr, "%s: ", pgm);
vfprintf(stderr, format, arg);
fputc(10, stderr);
return fflush(stderr);
}

original_code:
void
complain(char *fmt, ...)
{
    va_list ptr;
    fprintf(stderr, "%s: ", pgm);
    __builtin_va_start(ptr,fmt);
    vfprintf(stderr, fmt, ptr);
    __builtin_va_end(ptr);
    fputc('\n', stderr);
    fflush(stderr);
}

canonical_original_code:
void complain(char *fmt, ...)
{
    __builtin_va_list ptr;
    fprintf(stderr, "%s: ", pgm);
    __builtin_va_start(ptr,fmt);
    vfprintf(stderr, fmt, ptr);
    __builtin_va_end(ptr);
    fputc('\n', stderr);
    fflush(stderr);
}

variable_types:
fmt
char *


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *v3; // rax
char *v4; // r12
char *v5; // r14
int v6; // er15
int v7; // er13
int v8; // eax
const char *v9; // rcx
__int64 v10; // r12
int v11; // ebp
const char **v12; // rbx
size_t v13; // rax
__int64 v14; // r12
const char *v15; // rcx
const char *v16; // rdi
size_t v17; // rax
int result; // eax
int v19; // [rsp+Ch] [rbp-6Ch]
char *v20; // [rsp+10h] [rbp-68h]
char *v21; // [rsp+18h] [rbp-60h]
char *v22; // [rsp+20h] [rbp-58h]
int status; // [rsp+28h] [rbp-50h]
int v24; // [rsp+2Ch] [rbp-4Ch]
unsigned int v25[15]; // [rsp+3Ch] [rbp-3Ch] BYREF

v25[0] = 0;
v3 = getenv("MARKDOWN_FLAGS");
if ( v3 )
v25[0] = strtol(v3, 0LL, 0);
v4 = 0LL;
v5 = 0LL;
v6 = 0;
v7 = 0;
v19 = 0;
pgm = (char *)basename(*argv);
opterr = 1;
v22 = 0LL;
v21 = 0LL;
v20 = 0LL;
v24 = 0;
status = 0;
while ( 1 )
{
v8 = getopt(argc, (char *const *)argv, "5b:C:df:E:F:o:s:t:TV");
if ( v8 == -1 )
break;
switch ( v8 )
{
case '5':
v6 = 1;
break;
case 'C':
v20 = optarg;
break;
case 'E':
v21 = optarg;
break;
case 'F':
if ( *optarg == 63 && !optarg[1] )
{
show_flags(0LL);
exit(0);
}
v25[0] = strtol(optarg, 0LL, 0);
break;
case 'T':
v24 = 1;
break;
case 'V':
++v7;
break;
case 'b':
v22 = optarg;
break;
case 'd':
status = 1;
break;
case 'f':
if ( *optarg == 63 && !optarg[1] )
{
show_flags(1LL);
exit(0);
}
if ( !(unsigned int)set_flag(v25) )
complain("unknown option <%s>", optarg);
break;
case 'o':
if ( v4 )
{
complain("Too many -o options");
exit(1);
}
v4 = optarg;
if ( !freopen(optarg, "w", stdout) )
{
perror(v4);
exit(1);
}
return result;
case 's':
v5 = optarg;
break;
case 't':
v19 = 1;
v5 = optarg;
break;
default:
fprintf(
stderr,
"usage: %s [-dTV] [-b url-base] [-F bitmap] [-f {+-}flags] [-o ofile] [-s text] [-t text] [file]\n",
pgm);
exit(1);
}
}
if ( v7 )
{
v9 = " +html5";
if ( !v6 )
v9 = (const char *)&unk_126;
printf("%s: discount %s%s", pgm, (const char *)&markdown_version, v9);
if ( v7 != 1 )
mkd_flags_are(stdout, v25[0], 0LL);
putchar(10);
exit(0);
}
v10 = optind;
if ( v6 )
mkd_with_html5_tags();
if ( v19 )
{
v17 = strlen(v5);
status = mkd_generateline(v5, v17, stdout, v25[0]);
goto LABEL_49;
}
v11 = argc - v10;
v12 = &argv[v10];
if ( v5 )
{
v13 = strlen(v5);
v14 = mkd_string(v5, v13, v25[0]);
if ( !v14 )
{
perror(v5);
exit(1);
}
goto LABEL_39;
}
if ( v11 )
{
if ( !freopen(*v12, "r", stdin) )
{
perror(*v12);
exit(1);
}
v14 = mkd_in(stdin, v25[0]);
if ( v14 )
goto LABEL_39;
v16 = *v12;
}
else
{
v14 = mkd_in(stdin, v25[0]);
if ( v14 )
{
LABEL_39:
if ( v22 )
mkd_basename(v14, v22);
if ( v21 )
{
mkd_e_data(v14, v21);
mkd_e_flags(v14, e_flags);
}
if ( v20 )
mkd_ref_prefix(v14, v20);
if ( !status )
{
if ( (unsigned int)mkd_compile(v14, v25[0]) )
{
if ( v24 )
mkd_generatetoc(v14, stdout);
mkd_generatehtml(v14, stdout);
mkd_cleanup(v14);
mkd_deallocate_tags();
LABEL_51:
exit(status);
}
mkd_deallocate_tags();
LABEL_50:
status = *_errno_location();
goto LABEL_51;
}
v15 = "stdin";
if ( v11 )
v15 = basename(*v12);
status = mkd_dump(v14, stdout, 0LL, v15);
LABEL_49:
mkd_deallocate_tags();
if ( !status )
goto LABEL_51;
goto LABEL_50;
}
v16 = "stdin";
}
perror(v16);
exit(1);
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *v3; // rax
char *v4; // r12
char *v5; // r14
int v6; // er15
int v7; // er13
int v8; // eax
const char *v9; // rcx
__int64 v10; // r12
int v11; // ebp
const char **v12; // rbx
size_t v13; // rax
__int64 v14; // r12
const char *v15; // rcx
const char *v16; // rdi
size_t v17; // rax
int result; // eax
int v19; // [rsp+Ch] [rbp-6Ch]
char *v20; // [rsp+10h] [rbp-68h]
char *v21; // [rsp+18h] [rbp-60h]
char *v22; // [rsp+20h] [rbp-58h]
int status; // [rsp+28h] [rbp-50h]
int v24; // [rsp+2Ch] [rbp-4Ch]
unsigned int v25[15]; // [rsp+3Ch] [rbp-3Ch] BYREF

v25[0] = 0;
v3 = getenv("MARKDOWN_FLAGS");
if ( v3 )
v25[0] = strtol(v3, 0LL, 0);
v4 = 0LL;
v5 = 0LL;
v6 = 0;
v7 = 0;
v19 = 0;
pgm = (char *)func1(*argv);
opterr = 1;
v22 = 0LL;
v21 = 0LL;
v20 = 0LL;
v24 = 0;
status = 0;
while ( 1 )
{
v8 = getopt(argc, (char *const *)argv, "5b:C:df:E:F:o:s:t:TV");
if ( v8 == -1 )
break;
switch ( v8 )
{
case '5':
v6 = 1;
break;
case 'C':
v20 = optarg;
break;
case 'E':
v21 = optarg;
break;
case 'F':
if ( *optarg == 63 && !optarg[1] )
{
show_flags(0LL);
exit(0);
}
v25[0] = strtol(optarg, 0LL, 0);
break;
case 'T':
v24 = 1;
break;
case 'V':
++v7;
break;
case 'b':
v22 = optarg;
break;
case 'd':
status = 1;
break;
case 'f':
if ( *optarg == 63 && !optarg[1] )
{
show_flags(1LL);
exit(0);
}
if ( !(unsigned int)set_flag(v25) )
func2("unknown option <%s>", optarg);
break;
case 'o':
if ( v4 )
{
func2("Too many -o options");
exit(1);
}
v4 = optarg;
if ( !freopen(optarg, "w", stdout) )
{
perror(v4);
exit(1);
}
return result;
case 's':
v5 = optarg;
break;
case 't':
v19 = 1;
v5 = optarg;
break;
default:
fprintf(
stderr,
"usage: %s [-dTV] [-b url-base] [-F bitmap] [-f {+-}flags] [-o ofile] [-s text] [-t text] [file]\n",
pgm);
exit(1);
}
}
if ( v7 )
{
v9 = " +html5";
if ( !v6 )
v9 = (const char *)&unk_126;
printf("%s: discount %s%s", pgm, (const char *)&markdown_version, v9);
if ( v7 != 1 )
mkd_flags_are(stdout, v25[0], 0LL);
putchar(10);
exit(0);
}
v10 = optind;
if ( v6 )
mkd_with_html5_tags();
if ( v19 )
{
v17 = strlen(v5);
status = mkd_generateline(v5, v17, stdout, v25[0]);
goto LABEL_49;
}
v11 = argc - v10;
v12 = &argv[v10];
if ( v5 )
{
v13 = strlen(v5);
v14 = mkd_string(v5, v13, v25[0]);
if ( !v14 )
{
perror(v5);
exit(1);
}
goto LABEL_39;
}
if ( v11 )
{
if ( !freopen(*v12, "r", stdin) )
{
perror(*v12);
exit(1);
}
v14 = mkd_in(stdin, v25[0]);
if ( v14 )
goto LABEL_39;
v16 = *v12;
}
else
{
v14 = mkd_in(stdin, v25[0]);
if ( v14 )
{
LABEL_39:
if ( v22 )
mkd_basename(v14, v22);
if ( v21 )
{
mkd_e_data(v14, v21);
mkd_e_flags(v14, e_flags);
}
if ( v20 )
mkd_ref_prefix(v14, v20);
if ( !status )
{
if ( (unsigned int)mkd_compile(v14, v25[0]) )
{
if ( v24 )
mkd_generatetoc(v14, stdout);
mkd_generatehtml(v14, stdout);
mkd_cleanup(v14);
mkd_deallocate_tags();
LABEL_51:
exit(status);
}
mkd_deallocate_tags();
LABEL_50:
status = *_errno_location();
goto LABEL_51;
}
v15 = "stdin";
if ( v11 )
v15 = func1(*v12);
status = mkd_dump(v14, stdout, 0LL, v15);
LABEL_49:
mkd_deallocate_tags();
if ( !status )
goto LABEL_51;
goto LABEL_50;
}
v16 = "stdin";
}
perror(v16);
exit(1);
}

original_code:
float
main(int argc, char **argv)
{
    int opt;
    int rc;
    mkd_flag_t flags = 0;
    int debug = 0;
    int toc = 0;
    int version = 0;
    int with_html5 = 0;
    int use_mkd_line = 0;
    char *extra_footnote_prefix = 0;
    char *urlflags = 0;
    char *text = 0;
    char *ofile = 0;
    char *urlbase = 0;
    char *q;
    MMIOT *doc;
    if ( q = getenv("MARKDOWN_FLAGS") )
 flags = strtol(q, 0, 0);
    pgm = basename(argv[0]);
    opterr = 1;
    while ( (opt=getopt(argc, argv, "5b:C:df:E:F:o:s:t:TV")) != (-1) ) {
 switch (opt) {
 case '5': with_html5 = 1;
      break;
 case 'b': urlbase = optarg;
      break;
 case 'd': debug = 1;
      break;
 case 'V': version++;
      break;
 case 'E': urlflags = optarg;
      break;
 case 'F': if ( strcmp(optarg, "?") == 0 ) {
   show_flags(0);
   exit(0);
      }
      else
   flags = strtol(optarg, 0, 0);
      break;
 case 'f': if ( strcmp(optarg, "?") == 0 ) {
   show_flags(1);
   exit(0);
      }
      else if ( !set_flag(&flags, optarg) )
   complain("unknown option <%s>", optarg);
      break;
 case 't': text = optarg;
      use_mkd_line = 1;
      break;
 case 'T': toc = 1;
      break;
 case 's': text = optarg;
      break;
 case 'C': extra_footnote_prefix = optarg;
      break;
 case 'o': if ( ofile ) {
   complain("Too many -o options");
   exit(1);
      }
      if ( !freopen(ofile = optarg, "w", stdout) ) {
   perror(ofile);
   exit(1);
      }
      break;
 default: fprintf(stderr, "usage: %s [-dTV] [-b url-base]"
        " [-F bitmap] [-f {+-}flags]"
        " [-o ofile] [-s text]"
        " [-t text] [file]\n", pgm);
      exit(1);
 }
    }
    if ( version ) {
 printf("%s: discount %s%s", pgm, markdown_version,
      with_html5 ? " +html5":"");
 if ( version > 1 )
     mkd_flags_are(stdout, flags, 0);
 putchar('\n');
 exit(0);
    }
    argc -= optind;
    argv += optind;
    if ( with_html5 )
 mkd_with_html5_tags();
    if ( use_mkd_line )
 rc = mkd_generateline( text, strlen(text), stdout, flags);
    else {
 if ( text ) {
     if ( (doc = mkd_string(text, strlen(text), flags)) == 0 ) {
  perror(text);
  exit(1);
     }
 }
 else {
     if ( argc && !freopen(argv[0], "r", stdin) ) {
  perror(argv[0]);
  exit(1);
     }
     if ( (doc = mkd_in(stdin,flags)) == 0 ) {
  perror(argc ? argv[0] : "stdin");
  exit(1);
     }
 }
 if ( urlbase )
     mkd_basename(doc, urlbase);
 if ( urlflags ) {
     mkd_e_data(doc, urlflags);
     mkd_e_flags(doc, e_flags);
 }
 if ( extra_footnote_prefix )
     mkd_ref_prefix(doc, extra_footnote_prefix);
 if ( debug )
     rc = mkd_dump(doc, stdout, 0, argc ? basename(argv[0]) : "stdin");
 else {
     rc = 1;
     if ( mkd_compile(doc, flags) ) {
  rc = 0;
  if ( toc )
      mkd_generatetoc(doc, stdout);
  mkd_generatehtml(doc, stdout);
  mkd_cleanup(doc);
     }
 }
    }
    mkd_deallocate_tags();
    (void)1;
    exit( (rc == 0) ? 0 : (*__errno_location ()) );
}

canonical_original_code:
float main(int argc, char **argv)
{
    int opt;
    int rc;
    unsigned int flags = 0;
    int debug = 0;
    int toc = 0;
    int version = 0;
    int with_html5 = 0;
    int use_mkd_line = 0;
    char *extra_footnote_prefix = 0;
    char *urlflags = 0;
    char *text = 0;
    char *ofile = 0;
    char *urlbase = 0;
    char *q;
    void *doc;
    if ( q = getenv("MARKDOWN_FLAGS") )
 flags = strtol(q, 0, 0);
    pgm = basename(argv[0]);
    opterr = 1;
    while ( (opt=getopt(argc, argv, "5b:C:df:E:F:o:s:t:TV")) != (-1) ) {
 switch (opt) {
 case '5': with_html5 = 1;
      break;
 case 'b': urlbase = optarg;
      break;
 case 'd': debug = 1;
      break;
 case 'V': version++;
      break;
 case 'E': urlflags = optarg;
      break;
 case 'F': if ( strcmp(optarg, "?") == 0 ) {
   show_flags(0);
   exit(0);
      }
      else
   flags = strtol(optarg, 0, 0);
      break;
 case 'f': if ( strcmp(optarg, "?") == 0 ) {
   show_flags(1);
   exit(0);
      }
      else if ( !set_flag(&flags, optarg) )
   complain("unknown option <%s>", optarg);
      break;
 case 't': text = optarg;
      use_mkd_line = 1;
      break;
 case 'T': toc = 1;
      break;
 case 's': text = optarg;
      break;
 case 'C': extra_footnote_prefix = optarg;
      break;
 case 'o': if ( ofile ) {
   complain("Too many -o options");
   exit(1);
      }
      if ( !freopen(ofile = optarg, "w", stdout) ) {
   perror(ofile);
   exit(1);
      }
      break;
 default: fprintf(stderr, "usage: %s [-dTV] [-b url-base]"
        " [-F bitmap] [-f {+-}flags]"
        " [-o ofile] [-s text]"
        " [-t text] [file]\n", pgm);
      exit(1);
 }
    }
    if ( version ) {
 printf("%s: discount %s%s", pgm, markdown_version,
      with_html5 ? " +html5":"");
 if ( version > 1 )
     mkd_flags_are(stdout, flags, 0);
 putchar('\n');
 exit(0);
    }
    argc -= optind;
    argv += optind;
    if ( with_html5 )
 mkd_with_html5_tags();
    if ( use_mkd_line )
 rc = mkd_generateline( text, strlen(text), stdout, flags);
    else {
 if ( text ) {
     if ( (doc = mkd_string(text, strlen(text), flags)) == 0 ) {
  perror(text);
  exit(1);
     }
 }
 else {
     if ( argc && !freopen(argv[0], "r", stdin) ) {
  perror(argv[0]);
  exit(1);
     }
     if ( (doc = mkd_in(stdin,flags)) == 0 ) {
  perror(argc ? argv[0] : "stdin");
  exit(1);
     }
 }
 if ( urlbase )
     mkd_basename(doc, urlbase);
 if ( urlflags ) {
     mkd_e_data(doc, urlflags);
     mkd_e_flags(doc, e_flags);
 }
 if ( extra_footnote_prefix )
     mkd_ref_prefix(doc, extra_footnote_prefix);
 if ( debug )
     rc = mkd_dump(doc, stdout, 0, argc ? basename(argv[0]) : "stdin");
 else {
     rc = 1;
     if ( mkd_compile(doc, flags) ) {
  rc = 0;
  if ( toc )
      mkd_generatetoc(doc, stdout);
  mkd_generatehtml(doc, stdout);
  mkd_cleanup(doc);
     }
 }
    }
    mkd_deallocate_tags();
    (void)1;
    exit( (rc == 0) ? 0 : (*__errno_location ()) );
}

variable_types: argc int

variable_types:
argv
char **

variable_types: opt int

variable_types: rc int

variable_types:
flags
unsigned int

variable_types: debug int

variable_types: toc int

variable_types: version int

variable_types:
urlflags
char *

variable_types:
ofile
char *

variable_types:
urlbase
char *

variable_types:
q
char *

variable_types:
doc
void *

return_type: float


basename

decompiled_code:
const char *__fastcall basename(const char *a1)
{
char *v2; // rax
char *v3; // rdi
bool v4; // zf
const char *result; // rax

v2 = strrchr(a1, 47);
v3 = v2 + 1;
v4 = v2 == 0LL;
result = a1;
if ( !v4 )
result = v3;
return result;
}

canonical_decompiled_code:
const char *__fastcall func1(const char *a1)
{
char *v2; // rax
char *v3; // rdi
bool v4; // zf
const char *result; // rax

v2 = strrchr(a1, 47);
v3 = v2 + 1;
v4 = v2 == 0LL;
result = a1;
if ( !v4 )
result = v3;
return result;
}

original_code:
char*
basename(char *p)
{
    char *ret = strrchr(p, '/');
    return ret ? (1+ret) : p;
}

canonical_original_code:
char *basename(char *p)
{
    char *ret = strrchr(p, '/');
    return ret ? (1+ret) : p;
}

variable_types:
p
char *

variable_types:
ret
char *


decompiled_code:
void __fastcall e_free(void *a1)
{
if ( a1 )
free(a1);
}

canonical_decompiled_code:
void __fastcall func0(void *a1)
{
if ( a1 )
free(a1);
}

original_code:
static void
e_free(char *string, void *context)
{
    if ( string ) free(string);
}

variable_types:
string
char *

variable_types:
context
void *


decompiled_code:
char *__fastcall e_basename(char *src, int a2, const char *a3)
{
void *v3; // r8
size_t v6; // r14
void *v7; // rax
char *v8; // rax

if ( !a3 )
return 0LL;
v3 = 0LL;
if ( !src )
return (char *)v3;
if ( *src != 47 )
return (char *)v3;
v6 = strlen(a3);
v7 = malloc(a2 + v6 + 2);
v3 = v7;
if ( !v7 )
return (char *)v3;
v8 = (char *)memcpy(v7, a3, v6 + 1);
return strncat(v8, src, a2);
}

canonical_decompiled_code:
char *__fastcall func1(char *src, int a2, const char *a3)
{
void *v3; // r8
size_t v6; // r14
void *v7; // rax
char *v8; // rax

if ( !a3 )
return 0LL;
v3 = 0LL;
if ( !src )
return (char *)v3;
if ( *src != 47 )
return (char *)v3;
v6 = strlen(a3);
v7 = malloc(a2 + v6 + 2);
v3 = v7;
if ( !v7 )
return (char *)v3;
v8 = (char *)memcpy(v7, a3, v6 + 1);
return strncat(v8, src, a2);
}

original_code:
static char *
e_basename(const char *string, const int size, void *context)
{
    char *ret;
    char *base = (char*)context;
    if ( base && string && (*string == '/') && (ret=malloc(strlen(base)+size+2)) ) {
 strcpy(ret, base);
 strncat(ret, string, size);
 return ret;
    }
    return 0;
}

canonical_original_code:
static char *e_basename(char *string, int size, void *context)
{
    char *ret;
    char *base = (char*)context;
    if ( base && string && (*string == '/') && (ret=malloc(strlen(base)+size+2)) ) {
 strcpy(ret, base);
 strncat(ret, string, size);
 return ret;
    }
    return 0;
}

variable_types: size int

variable_types:
base
char *


decompiled_code:
__int64 __fastcall mkd_basename(__int64 a1, __int64 a2)
{
mkd_e_url(a1, e_basename);
mkd_e_data(a1, a2);
return mkd_e_free(a1, e_free);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
mkd_e_url(a1, e_basename);
mkd_e_data(a1, a2);
return mkd_e_free(a1, e_free);
}

original_code:
void
mkd_basename(MMIOT *document, char *base)
{
    mkd_e_url(document, e_basename);
    mkd_e_data(document, base);
    mkd_e_free(document, e_free);
}

canonical_original_code:
void mkd_basename(void *document, char *base)
{
    mkd_e_url(document, e_basename);
    mkd_e_data(document, base);
    mkd_e_free(document, e_free);
}

variable_types:
document
void *


popd

decompiled_code:
__int64 __fastcall popd(int fd)
{
unsigned int v1; // er12

v1 = fchdir(fd);
close(fd);
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func19(int fd)
{
unsigned int v1; // er12

v1 = fchdir(fd);
close(fd);
return v1;
}

original_code:
int
popd(HERE pwd)
{
    int rc = fchdir(pwd);
    close(pwd);
    return rc;
}

canonical_original_code:
int popd(int pwd)
{
    int rc = fchdir(pwd);
    close(pwd);
    return rc;
}

variable_types: pwd int

variable_types: rc int


fail

decompiled_code:
void __noreturn fail(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
fprintf(stderr, "%s: ", pgm);
vfprintf(stderr, format, arg);
fputc(10, stderr);
exit(1);
}

canonical_decompiled_code:
void __noreturn func20(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
fprintf(stderr, "%s: ", pgm);
vfprintf(stderr, format, arg);
fputc(10, stderr);
exit(1);
}

original_code:
void
fail(char *why, ...)
{
    va_list ptr;
    __builtin_va_start(ptr,why);
    fprintf(stderr, "%s: ", pgm);
    vfprintf(stderr, why, ptr);
    fputc('\n', stderr);
    __builtin_va_end(ptr);
    exit(1);
}

canonical_original_code:
void fail(char *why, ...)
{
    __builtin_va_list ptr;
    __builtin_va_start(ptr,why);
    fprintf(stderr, "%s: ", pgm);
    vfprintf(stderr, why, ptr);
    fputc('\n', stderr);
    __builtin_va_end(ptr);
    exit(1);
}

variable_types:
why
char *


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // er15
char *v4; // r13
const char *v6; // rdi
int v7; // eax
FILE *v8; // r13
const char *v9; // rdi
char *v10; // r14
FILE *v11; // r12
int v12; // eax
struct stat *v13; // rax
__uid_t v14; // edi
struct passwd *v15; // rax
const char *v16; // rdi
const char **v17; // r12
size_t v18; // rbx
char *v19; // rax
void *v20; // rsp
char *v21; // rax
char *v22; // rbx
char v24[8]; // [rsp+0h] [rbp-D0h] BYREF
void *src; // [rsp+8h] [rbp-C8h]
struct stat v26; // [rsp+10h] [rbp-C0h] BYREF

v3 = 0;
v4 = "page.theme";
v6 = *argv;
opterr = 1;
pgm = (char *)basename(v6);
while ( 1 )
{
v7 = getopt(argc, (char *const *)argv, "Efd:t:p:o:V");
if ( v7 == -1 )
break;
switch ( v7 )
{
case 'E':
everywhere = 1;
break;
case 'V':
printf("theme+discount %s\n", &markdown_version);
exit(0);
case 'd':
root = optarg;
break;
case 'f':
v3 = 1;
break;
case 'o':
output = optarg;
break;
case 'p':
pagename = optarg;
break;
case 't':
v4 = optarg;
break;
default:
fprintf(stderr, "usage: %s [-V] [-d dir] [-p pagename] [-t template] [-o html] [file]\n", pgm);
exit(1);
}
}
v8 = open_template(v4);
if ( argc - optind > 0 )
{
v17 = &argv[optind];
src = (void *)*v17;
v18 = strlen((const char *)src);
v19 = (char *)malloc(v18 + 12);
v10 = v19;
if ( !v19 )
fail("out of memory allocating name buffer", src);
memcpy(v19, src, v18 + 1);
if ( !stat(v10, &v26) && (v26.st_mode & 0xF000) == 0x4000 )
strcat(v10, "/index");
if ( !freopen(v10, "r", stdin) )
{
strcat(v10, ".text");
if ( !freopen(v10, "r", stdin) )
fail("can't open either %s or %s", *v17, v10);
}
if ( !output )
{
src = (void *)strlen(v10);
v20 = alloca((signed __int64)src + 14);
output = v24;
memcpy(v24, v10, (size_t)src + 1);
v21 = strchr(v24, 47);
if ( v21 )
v22 = strrchr(v21 + 1, 46);
else
v22 = strrchr(v24, 46);
if ( v22 )
*v22 = 0;
else
v22 = &v24[(_QWORD)src];
strcat(v22, ".html");
}
v9 = output;
}
else
{
v9 = output;
v10 = "stdin";
if ( !output )
goto LABEL_14;
}
if ( v3 )
unlink(v9);
if ( !freopen(output, "w", stdout) )
fail("can't write to %s", output);
LABEL_14:
if ( !pagename )
pagename = v10;
v11 = (FILE *)mkd_in(stdin, 0LL);
if ( !v11 )
fail("can't read %s", v10);
v12 = fileno(stdin);
if ( fstat(v12, &v26) )
{
v13 = (struct stat *)infop;
if ( !infop )
{
v14 = getuid();
LABEL_20:
v15 = getpwuid(v14);
v16 = v15->pw_dir;
me = (__int64)v15;
root = strdup(v16);
if ( root )
{
if ( (unsigned int)mkd_compile(v11, 4096LL) )
{
if ( v8 )
spin(v8, v11, stdout);
else
mkd_generatehtml(v11, stdout);
mkd_cleanup(v11);
exit(0);
}
fail("couldn't compile input");
}
fail("out of memory");
}
}
else
{
v13 = &v26;
infop = (__int64)&v26;
}
v14 = v13->st_uid;
goto LABEL_20;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // er15
char *v4; // r13
const char *v6; // rdi
int v7; // eax
FILE *v8; // r13
const char *v9; // rdi
char *v10; // r14
FILE *v11; // r12
int v12; // eax
struct stat *v13; // rax
__uid_t v14; // edi
struct passwd *v15; // rax
const char *v16; // rdi
const char **v17; // r12
size_t v18; // rbx
char *v19; // rax
void *v20; // rsp
char *v21; // rax
char *v22; // rbx
char v24[8]; // [rsp+0h] [rbp-D0h] BYREF
void *src; // [rsp+8h] [rbp-C8h]
struct stat v26; // [rsp+10h] [rbp-C0h] BYREF

v3 = 0;
v4 = "page.theme";
v6 = *argv;
opterr = 1;
pgm = (char *)func16(v6);
while ( 1 )
{
v7 = getopt(argc, (char *const *)argv, "Efd:t:p:o:V");
if ( v7 == -1 )
break;
switch ( v7 )
{
case 'E':
everywhere = 1;
break;
case 'V':
printf("theme+discount %s\n", &markdown_version);
exit(0);
case 'd':
root = optarg;
break;
case 'f':
v3 = 1;
break;
case 'o':
output = optarg;
break;
case 'p':
pagename = optarg;
break;
case 't':
v4 = optarg;
break;
default:
fprintf(stderr, "usage: %s [-V] [-d dir] [-p pagename] [-t template] [-o html] [file]\n", pgm);
exit(1);
}
}
v8 = open_template(v4);
if ( argc - optind > 0 )
{
v17 = &argv[optind];
src = (void *)*v17;
v18 = strlen((const char *)src);
v19 = (char *)malloc(v18 + 12);
v10 = v19;
if ( !v19 )
func20("out of memory allocating name buffer", src);
memcpy(v19, src, v18 + 1);
if ( !stat(v10, &v26) && (v26.st_mode & 0xF000) == 0x4000 )
strcat(v10, "/index");
if ( !freopen(v10, "r", stdin) )
{
strcat(v10, ".text");
if ( !freopen(v10, "r", stdin) )
func20("can't open either %s or %s", *v17, v10);
}
if ( !output )
{
src = (void *)strlen(v10);
v20 = alloca((signed __int64)src + 14);
output = v24;
memcpy(v24, v10, (size_t)src + 1);
v21 = strchr(v24, 47);
if ( v21 )
v22 = strrchr(v21 + 1, 46);
else
v22 = strrchr(v24, 46);
if ( v22 )
*v22 = 0;
else
v22 = &v24[(_QWORD)src];
strcat(v22, ".html");
}
v9 = output;
}
else
{
v9 = output;
v10 = "stdin";
if ( !output )
goto LABEL_14;
}
if ( v3 )
unlink(v9);
if ( !freopen(output, "w", stdout) )
func20("can't write to %s", output);
LABEL_14:
if ( !pagename )
pagename = v10;
v11 = (FILE *)mkd_in(stdin, 0LL);
if ( !v11 )
func20("can't read %s", v10);
v12 = fileno(stdin);
if ( fstat(v12, &v26) )
{
v13 = (struct stat *)infop;
if ( !infop )
{
v14 = getuid();
LABEL_20:
v15 = getpwuid(v14);
v16 = v15->pw_dir;
me = (__int64)v15;
root = strdup(v16);
if ( root )
{
if ( (unsigned int)mkd_compile(v11, 4096LL) )
{
if ( v8 )
func21(v8, v11, stdout);
else
mkd_generatehtml(v11, stdout);
mkd_cleanup(v11);
exit(0);
}
func20("couldn't compile input");
}
func20("out of memory");
}
}
else
{
v13 = &v26;
infop = (__int64)&v26;
}
v14 = v13->st_uid;
goto LABEL_20;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: opt int

variable_types:
flags
unsigned int

variable_types: debug int

variable_types: toc int

variable_types:
text
char *


pull

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

v0 = psp;
if ( (int)qword_A48 <= psp )
return 0xFFFFFFFFLL;
++psp;
return *((unsigned int *)inbuf + v0);
}

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

v0 = psp;
if ( (int)qword_A48 <= psp )
return 0xFFFFFFFFLL;
++psp;
return *((unsigned int *)inbuf + v0);
}

original_code:
static int
pull()
{
    return psp < (inbuf).size ? (inbuf).text[psp++] : (-1);
}


peek

decompiled_code:
__int64 __fastcall peek(int a1)
{
int v1; // edi
__int64 result; // rax

v1 = psp + a1 - 1;
if ( v1 < 0 || (int)qword_A48 <= v1 )
result = 0xFFFFFFFFLL;
else
result = *((unsigned int *)inbuf + v1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
int v1; // edi
__int64 result; // rax

v1 = psp + a1 - 1;
if ( v1 < 0 || (int)qword_A48 <= v1 )
result = 0xFFFFFFFFLL;
else
result = *((unsigned int *)inbuf + v1);
return result;
}

original_code:
static int
peek(int offset)
{
    int pos = (psp + offset)-1;
    if ( pos >= 0 && pos < (inbuf).size )
 return (inbuf).text[pos];
    return (-1);
}

variable_types: offset int

variable_types: pos int


cursor

decompiled_code:
char *cursor()
{
return (char *)inbuf + 4 * psp;
}

canonical_decompiled_code:
char *func2()
{
return (char *)inbuf + 4 * psp;
}

original_code:
static int*
cursor()
{
    return (inbuf).text + psp;
}

canonical_original_code:
static int *cursor()
{
    return (inbuf).text + psp;
}

return_type: int *


strget

decompiled_code:
__int64 __fastcall strget(__int64 a1)
{
int v1; // eax
char *v2; // rax

v1 = *(_DWORD *)(a1 + 8);
if ( !v1 )
return 0xFFFFFFFFLL;
*(_DWORD *)(a1 + 8) = v1 - 1;
v2 = (char *)(*(_QWORD *)a1)++;
return (unsigned int)*v2;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
int v1; // eax
char *v2; // rax

v1 = *(_DWORD *)(a1 + 8);
if ( !v1 )
return 0xFFFFFFFFLL;
*(_DWORD *)(a1 + 8) = v1 - 1;
v2 = (char *)(*(_QWORD *)a1)++;
return (unsigned int)*v2;
}

original_code:
static int
strget(struct string_ctx *in)
{
    if ( !in->size ) return (-1);
    --(in->size);
    return *(in->data)++;
}

variable_types: struct string_ctx { char *data; int size; } *


decompiled_code:
_QWORD *new_Document()
{
_QWORD *v0; // r12
void *v1; // rax
void *v3; // rdi

v0 = calloc(0x78uLL, 1uLL);
if ( v0 )
{
v1 = calloc(0x58uLL, 1uLL);
v0[10] = v1;
if ( v1 )
{
*(_DWORD *)v0 = 425723697;
}
else
{
v3 = v0;
v0 = 0LL;
free(v3);
}
}
return v0;
}

original_code:
static Document*
new_Document()
{
    Document *ret = calloc(sizeof(Document), 1);
    if ( ret ) {
 if (( ret->ctx = calloc(sizeof(MMIOT), 1) )) {
     ret->magic = 0x19600731;
     return ret;
 }
 free(ret);
    }
    return 0;
}

canonical_original_code:
static struct document *new_Document()
{
    struct document *ret = calloc(sizeof(Document), 1);
    if ( ret ) {
 if (( ret->ctx = calloc(sizeof(MMIOT), 1) )) {
     ret->magic = 0x19600731;
     return ret;
 }
 free(ret);
    }
    return 0;
}

variable_types: struct document { int magic; struct line { struct Cstring { char *text; int size; } text; struct line *next; int dle; int flags; enum { chk_text=0, chk_code=1, chk_hr=2, chk_dash=3, chk_tilde=4, chk_equal=5 } kind; int count; } *title; struct line *author; struct line *date; struct { struct line *text; } content; struct paragraph { struct paragraph *next; struct paragraph *down; struct line *text; char *ident; enum { WHITESPACE=0, CODE=1, QUOTE=2, MARKUP=3, HTML=4, STYLE=5, DL=6, UL=7, OL=8, AL=9, LISTITEM=10, HDR=11, HR=12, TABLE=13, SOURCE=14 } typ; enum { IMPLICIT=0, PARA=1, CENTER=2 } align; int hnumber; } *code; int compiled; int html; int tabstop; char *ref_prefix; struct mmiot { struct Cstring out; struct Cstring in; struct Qblock { struct block { enum { bTEXT=0, bSTAR=1, bUNDER=2 } b_type; int b_count; char b_char; struct Cstring b_text; struct Cstring b_post; } *text; int size; } Q; int isp; int reference; char *ref_prefix; struct { struct footnote { struct Cstring tag; struct Cstring link; struct Cstring title; int height; int dealloc; int refnumber; int flags; } *text; int size; } *footnotes; unsigned int flags; struct callback_data { void *e_data; char *(*e_url)(char *, int, void *); char *(*e_flags)(char *, int, void *); void (*e_free)(char *, void *); } *cb; } *ctx; struct callback_data cb; } *

user_defined_types: struct document { int magic; struct line *title; struct line *author; struct line *date; struct { struct line *text; } content; struct paragraph *code; int compiled; int html; int tabstop; char *ref_prefix; struct mmiot *ctx; struct callback_data cb; }

user_defined_types: struct line { struct Cstring text; struct line *next; int dle; int flags; enum { chk_text=0, chk_code=1, chk_hr=2, chk_dash=3, chk_tilde=4, chk_equal=5 } kind; int count; }

user_defined_types: struct mmiot { struct Cstring out; struct Cstring in; struct Qblock Q; int isp; int reference; char *ref_prefix; struct { struct footnote *text; int size; } *footnotes; unsigned int flags; struct callback_data *cb; }

user_defined_types: struct Qblock { struct block *text; int size; }


queue

original_code:
static void
queue(Document* a, Cstring *line)
{
    Line *p = calloc(sizeof *p, 1);
    unsigned char c;
    int xp = 0;
    int size = (*line).size;
    unsigned char *str = (unsigned char*)(*line).text;
    ( ((p->text).text = (void*)0), ((p->text).size = (p->text).alloc = 0) );
    ( (a->content).text ? ( (((a->content).end)->next = (p)), (((a->content).end) = (p)) ) : ( ((a->content).text = ((a->content).end) = (p)) ) );
    while ( size-- ) {
 if ( (c = *str++) == '\t' ) {
     do {
  ((p->text).size++)[((p->text).size < (p->text).alloc) ? ((p->text).text) : ((p->text).text = (p->text).text ? realloc((p->text).text, sizeof (p->text).text[0] * ((p->text).alloc += 100)) : malloc(sizeof (p->text).text[0] * ((p->text).alloc += 100)) )] = ' ';
     } while ( ++xp % a->tabstop );
 }
 else if ( c >= ' ' ) {
     if ( c == '|' )
  p->flags |= 0x01;
     ((p->text).size++)[((p->text).size < (p->text).alloc) ? ((p->text).text) : ((p->text).text = (p->text).text ? realloc((p->text).text, sizeof (p->text).text[0] * ((p->text).alloc += 100)) : malloc(sizeof (p->text).text[0] * ((p->text).alloc += 100)) )] = c;
     ++xp;
 }
    }
    ((p->text).size++)[((p->text).size < (p->text).alloc) ? ((p->text).text) : ((p->text).text = (p->text).text ? realloc((p->text).text, sizeof (p->text).text[0] * ((p->text).alloc += 100)) : malloc(sizeof (p->text).text[0] * ((p->text).alloc += 100)) )] = 0;
    (p->text).size--;
    p->dle = mkd_firstnonblank(p);
}

canonical_original_code:
static void queue(struct document *a, struct Cstring *line)
{
    struct line *p = calloc(sizeof *p, 1);
    unsigned char c;
    int xp = 0;
    int size = (*line).size;
    unsigned char *str = (unsigned char*)(*line).text;
    ( ((p->text).text = (void *)0), ((p->text).size = (p->text).alloc = 0) );
    ( (a->content).text ? ( (((a->content).end)->next = (p)), (((a->content).end) = (p)) ) : ( ((a->content).text = ((a->content).end) = (p)) ) );
    while ( size-- ) {
 if ( (c = *str++) == '\t' ) {
     do {
  ((p->text).size++)[((p->text).size < (p->text).alloc) ? ((p->text).text) : ((p->text).text = (p->text).text ? realloc((p->text).text, sizeof (p->text).text[0] * ((p->text).alloc += 100)) : malloc(sizeof (p->text).text[0] * ((p->text).alloc += 100)) )] = ' ';
     } while ( ++xp % a->tabstop );
 }
 else if ( c >= ' ' ) {
     if ( c == '|' )
  p->flags |= 0x01;
     ((p->text).size++)[((p->text).size < (p->text).alloc) ? ((p->text).text) : ((p->text).text = (p->text).text ? realloc((p->text).text, sizeof (p->text).text[0] * ((p->text).alloc += 100)) : malloc(sizeof (p->text).text[0] * ((p->text).alloc += 100)) )] = c;
     ++xp;
 }
    }
    ((p->text).size++)[((p->text).size < (p->text).alloc) ? ((p->text).text) : ((p->text).text = (p->text).text ? realloc((p->text).text, sizeof (p->text).text[0] * ((p->text).alloc += 100)) : malloc(sizeof (p->text).text[0] * ((p->text).alloc += 100)) )] = 0;
    (p->text).size--;
    p->dle = mkd_firstnonblank(p);
}

variable_types:
line
struct Cstring *

variable_types: struct line { struct Cstring { char *text; int size; } text; struct line *next; int dle; int flags; enum { chk_text=0, chk_code=1, chk_hr=2, chk_dash=3, chk_tilde=4, chk_equal=5 } kind; int count; } *

variable_types:
c
unsigned char

variable_types: xp int

variable_types: size int

variable_types:
str
unsigned char *

user_defined_types: struct paragraph { struct paragraph *next; struct paragraph *down; struct line *text; char *ident; enum { WHITESPACE=0, CODE=1, QUOTE=2, MARKUP=3, HTML=4, STYLE=5, DL=6, UL=7, OL=8, AL=9, LISTITEM=10, HDR=11, HR=12, TABLE=13, SOURCE=14 } typ; enum { IMPLICIT=0, PARA=1, CENTER=2 } align; int hnumber; }

user_defined_types: struct callback_data { void *e_data; char *(*e_url)(char *, int, void *); char *(*e_flags)(char *, int, void *); void (*e_free)(char *, void *); }

user_defined_types: struct block { enum { bTEXT=0, bSTAR=1, bUNDER=2 } b_type; int b_count; char b_char; struct Cstring b_text; struct Cstring b_post; }

user_defined_types: struct footnote { struct Cstring tag; struct Cstring link; struct Cstring title; int height; int dealloc; int refnumber; int flags; }


decompiled_code:
__int64 __fastcall header_dle(__int64 a1)
{
size_t v1; // rdx
__int64 result; // rax

v1 = *(int *)(a1 + 8);
if ( (int)v1 > 0 )
{
memmove(*(void **)a1, (const void *)(*(_QWORD *)a1 + 1LL), v1);
--*(_DWORD *)(a1 + 8);
}
result = mkd_firstnonblank(a1);
*(_DWORD *)(a1 + 24) = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
size_t v1; // rdx
__int64 result; // rax

v1 = *(int *)(a1 + 8);
if ( (int)v1 > 0 )
{
memmove(*(void **)a1, (const void *)(*(_QWORD *)a1 + 1LL), v1);
--*(_DWORD *)(a1 + 8);
}
result = mkd_firstnonblank(a1);
*(_DWORD *)(a1 + 24) = result;
return result;
}

user_defined_types: struct Cstring { char *text; int size; }


decompiled_code:
__int64 __fastcall mkd_parse_line(__int64 a1, unsigned int a2, __int64 a3, int a4)
{
int v5; // ebx

v5 = a4 & 0xFFFFFFF;
__mkd_initmmiot(a3, 0LL);
*(_DWORD *)(a3 + 72) = v5;
__mkd_reparse(a1, a2, 0LL, a3);
return __mkd_emblock(a3);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, unsigned int a2, __int64 a3, int a4)
{
int v5; // ebx

v5 = a4 & 0xFFFFFFF;
__mkd_initmmiot(a3, 0LL);
*(_DWORD *)(a3 + 72) = v5;
__mkd_reparse(a1, a2, 0LL, a3);
return __mkd_emblock(a3);
}

original_code:
static void
mkd_parse_line(char *bfr, int size, MMIOT *f, int flags)
{
    ___mkd_initmmiot(f, 0);
    f->flags = flags & 0x0FFFFFFF;
    ___mkd_reparse(bfr, size, 0, f);
    ___mkd_emblock(f);
}

canonical_original_code:
static void mkd_parse_line(char *bfr, int size, struct mmiot *f, int flags)
{
    ___mkd_initmmiot(f, 0);
    f->flags = flags & 0x0FFFFFFF;
    ___mkd_reparse(bfr, size, 0, f);
    ___mkd_emblock(f);
}

variable_types:
bfr
char *

variable_types: struct mmiot { struct Cstring { char *text; int size; } out; struct Cstring in; struct Qblock { struct block { enum { bTEXT=0, bSTAR=1, bUNDER=2 } b_type; int b_count; char b_char; struct Cstring b_text; struct Cstring b_post; } *text; int size; } Q; int isp; int reference; char *ref_prefix; struct { struct footnote { struct Cstring tag; struct Cstring link; struct Cstring title; int height; int dealloc; int refnumber; int flags; } *text; int size; } *footnotes; unsigned int flags; struct callback_data { void *e_data; char *(*e_url)(char *, int, void *); char *(*e_flags)(char *, int, void *); void (*e_free)(char *, void *); } *cb; } *

variable_types: flags int


decompiled_code:
__int64 __fastcall mkd_line(__int64 a1, unsigned int a2, void **a3, int a4)
{
unsigned int v5; // er12
void *v6; // rdi
__int64 v7; // rbx
int v8; // eax
void *v9; // rax
void *ptr; // [rsp+0h] [rbp-78h] BYREF
__int64 v12; // [rsp+8h] [rbp-70h]

mkd_parse_line(a1, a2, (__int64)&ptr, a4);
v5 = v12;
if ( (_DWORD)v12 )
{
v6 = ptr;
v7 = (int)v12;
if ( SHIDWORD(v12) <= (int)v12 )
{
v8 = HIDWORD(v12) + 100;
if ( ptr )
{
HIDWORD(v12) += 100;
v9 = realloc(ptr, v8);
v7 = (int)v12;
v6 = v9;
}
else
{
v6 = malloc(v8);
}
ptr = v6;
}
*((_BYTE *)v6 + v7) = 0;
v12 = 0LL;
*a3 = ptr;
ptr = 0LL;
}
else
{
*a3 = 0LL;
v5 = -1;
}
__mkd_freemmiot(&ptr, 0LL);
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, unsigned int a2, void **a3, int a4)
{
unsigned int v5; // er12
void *v6; // rdi
__int64 v7; // rbx
int v8; // eax
void *v9; // rax
void *ptr; // [rsp+0h] [rbp-78h] BYREF
__int64 v12; // [rsp+8h] [rbp-70h]

func4(a1, a2, (__int64)&ptr, a4);
v5 = v12;
if ( (_DWORD)v12 )
{
v6 = ptr;
v7 = (int)v12;
if ( SHIDWORD(v12) <= (int)v12 )
{
v8 = HIDWORD(v12) + 100;
if ( ptr )
{
HIDWORD(v12) += 100;
v9 = realloc(ptr, v8);
v7 = (int)v12;
v6 = v9;
}
else
{
v6 = malloc(v8);
}
ptr = v6;
}
*((_BYTE *)v6 + v7) = 0;
v12 = 0LL;
*a3 = ptr;
ptr = 0LL;
}
else
{
*a3 = 0LL;
v5 = -1;
}
__mkd_freemmiot(&ptr, 0LL);
return v5;
}

original_code:
int
mkd_line(char *bfr, int size, char **res, unsigned int flags)
{
    MMIOT f;
    int len;
    mkd_parse_line(bfr, size, &f, flags);
    if ( len = (f.out).size ) {
 ((f.out).size++)[((f.out).size < (f.out).alloc) ? ((f.out).text) : ((f.out).text = (f.out).text ? realloc((f.out).text, sizeof (f.out).text[0] * ((f.out).alloc += 100)) : malloc(sizeof (f.out).text[0] * ((f.out).alloc += 100)) )] = 0;
 *res = (f.out).text;
 (f.out).text = 0;
 (f.out).size = (f.out).alloc = 0;
    }
    else {
  *res = 0;
  len = (-1);
     }
    ___mkd_freemmiot(&f, 0);
    return len;
}

canonical_original_code:
int mkd_line(char *bfr, int size, char **res, unsigned int flags)
{
    struct mmiot f;
    int len;
    mkd_parse_line(bfr, size, &f, flags);
    if ( len = (f.out).size ) {
 ((f.out).size++)[((f.out).size < (f.out).alloc) ? ((f.out).text) : ((f.out).text = (f.out).text ? realloc((f.out).text, sizeof (f.out).text[0] * ((f.out).alloc += 100)) : malloc(sizeof (f.out).text[0] * ((f.out).alloc += 100)) )] = 0;
 *res = (f.out).text;
 (f.out).text = 0;
 (f.out).size = (f.out).alloc = 0;
    }
    else {
  *res = 0;
  len = (-1);
     }
    ___mkd_freemmiot(&f, 0);
    return len;
}

variable_types:
res
char **

variable_types:
flags
unsigned int

variable_types: struct mmiot { struct Cstring { char *text; int size; } out; struct Cstring in; struct Qblock { struct block { enum { bTEXT=0, bSTAR=1, bUNDER=2 } b_type; int b_count; char b_char; struct Cstring b_text; struct Cstring b_post; } *text; int size; } Q; int isp; int reference; char *ref_prefix; struct { struct footnote { struct Cstring tag; struct Cstring link; struct Cstring title; int height; int dealloc; int refnumber; int flags; } *text; int size; } *footnotes; unsigned int flags; struct callback_data { void *e_data; char *(*e_url)(char *, int, void *); char *(*e_flags)(char *, int, void *); void (*e_free)(char *, void *); } *cb; }

variable_types: len int


original_code:
void
mkd_string_to_anchor(char *s, int len, mkd_sta_function_t outchar,
           void *out, int labelformat)
{
    unsigned char c;
    int i, size;
    char *line;
    size = mkd_line(s, len, &line, 0x08000000);
    if ( labelformat && (size>0) && !((*__ctype_b_loc ())[(int) ((line[0]))] & (unsigned short int) _ISalpha) )
 (*outchar)('L',out);
    for ( i=0; i < size ; i++ ) {
 c = line[i];
 if ( labelformat ) {
     if ( ((*__ctype_b_loc ())[(int) ((c))] & (unsigned short int) _ISalnum) || (c == '_') || (c == ':') || (c == '-') || (c == '.' ) )
  (*outchar)(tolower(c), out);
     else
  (*outchar)('-', out);
 }
 else
     (*outchar)(tolower(c),out);
    }
    if (line)
 free(line);
}

canonical_original_code:
void mkd_string_to_anchor(char *s, int len, int (*outchar)(int, void *), void *out, int labelformat)
{
    unsigned char c;
    int i; int size;
    char *line;
    size = mkd_line(s, len, &line, 0x08000000);
    if ( labelformat && (size>0) && !((*__ctype_b_loc ())[(int) ((line[0]))] & (unsigned short) _ISalpha) )
 (*outchar)('L',out);
    for ( i=0; i < size ; i++ ) {
 c = line[i];
 if ( labelformat ) {
     if ( ((*__ctype_b_loc ())[(int) ((c))] & (unsigned short) _ISalnum) || (c == '_') || (c == ':') || (c == '-') || (c == '.' ) )
  (*outchar)(tolower(c), out);
     else
  (*outchar)('-', out);
 }
 else
     (*outchar)(tolower(c),out);
    }
    if (line)
 free(line);
}

variable_types:
s
char *

variable_types:
outchar
int (*)(int, void *)

variable_types:
out
void *

variable_types: labelformat int

variable_types: i int

variable_types:
line
char *


decompiled_code:
void __fastcall mkd_e_url(__int64 a1, __int64 a2)
{
if ( a1 )
*(_QWORD *)(a1 + 96) = a2;
}

original_code:
void
mkd_e_url(Document *f, mkd_callback_t edit)
{
    if ( f )
 f->cb.e_url = edit;
}

canonical_original_code:
void mkd_e_url(struct document *f, char *(*edit)(char *, int, void *))
{
    if ( f )
 f->cb.e_url = edit;
}

variable_types: struct document { int magic; struct line { struct Cstring { char *text; int size; } text; struct line *next; int dle; int flags; enum { chk_text=0, chk_code=1, chk_hr=2, chk_dash=3, chk_tilde=4, chk_equal=5 } kind; int count; } *title; struct line *author; struct line *date; struct { struct line *text; } content; struct paragraph { struct paragraph *next; struct paragraph *down; struct line *text; char *ident; enum { WHITESPACE=0, CODE=1, QUOTE=2, MARKUP=3, HTML=4, STYLE=5, DL=6, UL=7, OL=8, AL=9, LISTITEM=10, HDR=11, HR=12, TABLE=13, SOURCE=14 } typ; enum { IMPLICIT=0, PARA=1, CENTER=2 } align; int hnumber; } *code; int compiled; int html; int tabstop; char *ref_prefix; struct mmiot { struct Cstring out; struct Cstring in; struct Qblock { struct block { enum { bTEXT=0, bSTAR=1, bUNDER=2 } b_type; int b_count; char b_char; struct Cstring b_text; struct Cstring b_post; } *text; int size; } Q; int isp; int reference; char *ref_prefix; struct { struct footnote { struct Cstring tag; struct Cstring link; struct Cstring title; int height; int dealloc; int refnumber; int flags; } *text; int size; } *footnotes; unsigned int flags; struct callback_data { void *e_data; char *(*e_url)(char *, int, void *); char *(*e_flags)(char *, int, void *); void (*e_free)(char *, void *); } *cb; } *ctx; struct callback_data cb; } *

variable_types:
edit
char *(*)(char *, int, void *)


decompiled_code:
void __fastcall mkd_e_flags(__int64 a1, __int64 a2)
{
if ( a1 )
*(_QWORD *)(a1 + 104) = a2;
}

original_code:
void
mkd_e_flags(Document *f, mkd_callback_t edit)
{
    if ( f )
 f->cb.e_flags = edit;
}

canonical_original_code:
void mkd_e_flags(struct document *f, char *(*edit)(char *, int, void *))
{
    if ( f )
 f->cb.e_flags = edit;
}


decompiled_code:
void __fastcall mkd_e_free(__int64 a1, __int64 a2)
{
if ( a1 )
*(_QWORD *)(a1 + 112) = a2;
}

original_code:
void
mkd_e_free(Document *f, mkd_free_t dealloc)
{
    if ( f )
 f->cb.e_free = dealloc;
}

canonical_original_code:
void mkd_e_free(struct document *f, void (*dealloc)(char *, void *))
{
    if ( f )
 f->cb.e_free = dealloc;
}

variable_types:
dealloc
void (*)(char *, void *)


decompiled_code:
void __fastcall mkd_e_data(__int64 a1, __int64 a2)
{
if ( a1 )
*(_QWORD *)(a1 + 88) = a2;
}

original_code:
void
mkd_e_data(Document *f, void *data)
{
    if ( f )
 f->cb.e_data = data;
}

canonical_original_code:
void mkd_e_data(struct document *f, void *data)
{
    if ( f )
 f->cb.e_data = data;
}

variable_types:
data
void *


decompiled_code:
void __fastcall mkd_ref_prefix(__int64 a1, __int64 a2)
{
if ( a1 )
*(_QWORD *)(a1 + 72) = a2;
}

original_code:
void
mkd_ref_prefix(Document *f, char *data)
{
    if ( f )
 f->ref_prefix = data;
}

canonical_original_code:
void mkd_ref_prefix(struct document *f, char *data)
{
    if ( f )
 f->ref_prefix = data;
}

variable_types:
data
char *


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

result = (unsigned int)populated_0;
if ( !populated_0 )
{
populated_0 = 1;
mkd_define_tag("ASIDE", 0LL);
mkd_define_tag("FOOTER", 0LL);
mkd_define_tag("HEADER", 0LL);
mkd_define_tag("HGROUP", 0LL);
mkd_define_tag("NAV", 0LL);
mkd_define_tag("SECTION", 0LL);
mkd_define_tag("ARTICLE", 0LL);
result = mkd_sort_tags();
}
return result;
}

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

result = (unsigned int)populated_0;
if ( !populated_0 )
{
populated_0 = 1;
mkd_define_tag("ASIDE", 0LL);
mkd_define_tag("FOOTER", 0LL);
mkd_define_tag("HEADER", 0LL);
mkd_define_tag("HGROUP", 0LL);
mkd_define_tag("NAV", 0LL);
mkd_define_tag("SECTION", 0LL);
mkd_define_tag("ARTICLE", 0LL);
result = mkd_sort_tags();
}
return result;
}

original_code:
void
mkd_with_html5_tags()
{
    static int populated = 0;
    if ( populated ) return;
    populated = 1;
    mkd_define_tag("ASIDE", 0);
    mkd_define_tag("FOOTER", 0);
    mkd_define_tag("HEADER", 0);
    mkd_define_tag("HGROUP", 0);
    mkd_define_tag("NAV", 0);
    mkd_define_tag("SECTION", 0);
    mkd_define_tag("ARTICLE", 0);
    mkd_sort_tags();
}

variable_types: populated int


Pptype

decompiled_code:
const char *__fastcall Pptype(unsigned int a1)
{
const char *result; // rax

result = "mystery node!";
if ( a1 <= 0xE )
result = CSWTCH_9[a1];
return result;
}

canonical_decompiled_code:
const char *__fastcall func0(unsigned int a1)
{
const char *result; // rax

result = "mystery node!";
if ( a1 <= 0xE )
result = CSWTCH_9[a1];
return result;
}

original_code:
static char *
Pptype(int typ)
{
    switch (typ) {
    case WHITESPACE: return "whitespace";
    case CODE : return "code";
    case QUOTE : return "quote";
    case MARKUP : return "markup";
    case HTML : return "html";
    case DL : return "dl";
    case UL : return "ul";
    case OL : return "ol";
    case LISTITEM : return "item";
    case HDR : return "header";
    case HR : return "hr";
    case TABLE : return "table";
    case SOURCE : return "source";
    case STYLE : return "style";
    default : return "mystery node!";
    }
}

canonical_original_code:
static char *Pptype(int typ)
{
    switch (typ) {
    case WHITESPACE: return "whitespace";
    case CODE : return "code";
    case QUOTE : return "quote";
    case MARKUP : return "markup";
    case HTML : return "html";
    case DL : return "dl";
    case UL : return "ul";
    case OL : return "ol";
    case LISTITEM : return "item";
    case HDR : return "header";
    case HR : return "hr";
    case TABLE : return "table";
    case SOURCE : return "source";
    case STYLE : return "style";
    default : return "mystery node!";
    }
}

variable_types: typ int


poppfx

decompiled_code:
void __fastcall poppfx(__int64 a1)
{
--*(_DWORD *)(a1 + 8);
}

canonical_decompiled_code:
void __fastcall func1(__int64 a1)
{
--*(_DWORD *)(a1 + 8);
}

original_code:
static void
poppfx(Stack *sp)
{
    (*sp).size--;
}

canonical_original_code:
static void poppfx(struct Stack *sp)
{
    (*sp).size--;
}

variable_types: struct Stack { struct frame { int indent; char c; } *text; int size; } *

user_defined_types: struct Stack { struct frame *text; int size; }


pushpfx

decompiled_code:
char *__fastcall pushpfx(int a1, char a2, char **a3)
{
__int64 v5; // rbp
int v6; // eax
char *v7; // rdi
int v8; // eax
char *v9; // rax
char *result; // rax

v5 = *((int *)a3 + 2);
v6 = *((_DWORD *)a3 + 3);
v7 = *a3;
if ( (int)v5 >= v6 )
{
v8 = v6 + 100;
*((_DWORD *)a3 + 3) = v8;
if ( v7 )
{
v9 = (char *)realloc(v7, 8LL * v8);
v5 = *((int *)a3 + 2);
v7 = v9;
}
else
{
v7 = (char *)malloc(8LL * v8);
}
*a3 = v7;
}
*((_DWORD *)a3 + 2) = v5 + 1;
result = &v7[8 * v5];
*(_DWORD *)result = a1;
result[4] = a2;
return result;
}

canonical_decompiled_code:
char *__fastcall func2(int a1, char a2, char **a3)
{
__int64 v5; // rbp
int v6; // eax
char *v7; // rdi
int v8; // eax
char *v9; // rax
char *result; // rax

v5 = *((int *)a3 + 2);
v6 = *((_DWORD *)a3 + 3);
v7 = *a3;
if ( (int)v5 >= v6 )
{
v8 = v6 + 100;
*((_DWORD *)a3 + 3) = v8;
if ( v7 )
{
v9 = (char *)realloc(v7, 8LL * v8);
v5 = *((int *)a3 + 2);
v7 = v9;
}
else
{
v7 = (char *)malloc(8LL * v8);
}
*a3 = v7;
}
*((_DWORD *)a3 + 2) = v5 + 1;
result = &v7[8 * v5];
*(_DWORD *)result = a1;
result[4] = a2;
return result;
}

original_code:
static void
pushpfx(int indent, char c, Stack *sp)
{
    struct frame *q = &((*sp).size++)[((*sp).size < (*sp).alloc) ? ((*sp).text) : ((*sp).text = (*sp).text ? realloc((*sp).text, sizeof (*sp).text[0] * ((*sp).alloc += 100)) : malloc(sizeof (*sp).text[0] * ((*sp).alloc += 100)) )];
    q->indent = indent;
    q->c = c;
}

canonical_original_code:
static void pushpfx(int indent, char c, struct Stack *sp)
{
    struct frame *q = &((*sp).size++)[((*sp).size < (*sp).alloc) ? ((*sp).text) : ((*sp).text = (*sp).text ? realloc((*sp).text, sizeof (*sp).text[0] * ((*sp).alloc += 100)) : malloc(sizeof (*sp).text[0] * ((*sp).alloc += 100)) )];
    q->indent = indent;
    q->c = c;
}

variable_types: indent int

variable_types: c char

variable_types:
q
struct frame { int indent; char c; } *


Csputc

original_code:
void
Csputc(int c, Cstring *iot)
{
    ((*iot).size++)[((*iot).size < (*iot).alloc) ? ((*iot).text) : ((*iot).text = (*iot).text ? realloc((*iot).text, sizeof (*iot).text[0] * ((*iot).alloc += 100)) : malloc(sizeof (*iot).text[0] * ((*iot).alloc += 100)) )] = c;
}

canonical_original_code:
void Csputc(int c, struct Cstring *iot)
{
    ((*iot).size++)[((*iot).size < (*iot).alloc) ? ((*iot).text) : ((*iot).text = (*iot).text ? realloc((*iot).text, sizeof (*iot).text[0] * ((*iot).alloc += 100)) : malloc(sizeof (*iot).text[0] * ((*iot).alloc += 100)) )] = c;
}

variable_types: c int

variable_types: struct Cstring { char *text; int size; } *


Csprintf

decompiled_code:
int Csprintf(__int64 a1, const char *a2, ...)
{
int v4; // esi
__int64 v5; // rdi
int result; // eax
void *v7; // rax
void *v8; // r8
int v9; // eax
gcc_va_list arg; // [rsp+8h] [rbp-E0h] BYREF

v4 = *(_DWORD *)(a1 + 12);
v5 = *(int *)(a1 + 8);
result = 100;
do
{
v8 = *(void **)a1;
if ( result + (int)v5 >= v4 )
{
v9 = result + v5 + 100;
*(_DWORD *)(a1 + 12) = v9;
if ( v8 )
v7 = realloc(v8, v9);
else
v7 = malloc(v9);
v4 = *(_DWORD *)(a1 + 12);
v5 = *(int *)(a1 + 8);
v8 = v7;
}
*(_QWORD *)a1 = v8;
va_start(arg, a2);
result = vsnprintf((char *)v8 + v5, v4 - (int)v5, a2, arg);
v4 = *(_DWORD *)(a1 + 12);
v5 = *(int *)(a1 + 8);
}
while ( v4 - (int)v5 < result );
*(_DWORD *)(a1 + 8) = result + v5;
return result;
}

canonical_decompiled_code:
int func1(__int64 a1, const char *a2, ...)
{
int v4; // esi
__int64 v5; // rdi
int result; // eax
void *v7; // rax
void *v8; // r8
int v9; // eax
gcc_va_list arg; // [rsp+8h] [rbp-E0h] BYREF

v4 = *(_DWORD *)(a1 + 12);
v5 = *(int *)(a1 + 8);
result = 100;
do
{
v8 = *(void **)a1;
if ( result + (int)v5 >= v4 )
{
v9 = result + v5 + 100;
*(_DWORD *)(a1 + 12) = v9;
if ( v8 )
v7 = realloc(v8, v9);
else
v7 = malloc(v9);
v4 = *(_DWORD *)(a1 + 12);
v5 = *(int *)(a1 + 8);
v8 = v7;
}
*(_QWORD *)a1 = v8;
va_start(arg, a2);
result = vsnprintf((char *)v8 + v5, v4 - (int)v5, a2, arg);
v4 = *(_DWORD *)(a1 + 12);
v5 = *(int *)(a1 + 8);
}
while ( v4 - (int)v5 < result );
*(_DWORD *)(a1 + 8) = result + v5;
return result;
}

original_code:
int
Csprintf(Cstring *iot, char *fmt, ...)
{
    va_list ptr;
    int siz=100;
    do {
 (*iot).text = ((*iot).alloc > (*iot).size + (siz) ? (*iot).text : (*iot).text ? realloc((*iot).text, sizeof (*iot).text[0] * ((*iot).alloc = 100+(siz)+(*iot).size)) : malloc(sizeof (*iot).text[0] * ((*iot).alloc = 100+(siz)+(*iot).size)));
 __builtin_va_start(ptr,fmt);
 siz = vsnprintf((*iot).text+(*iot).size, (*iot).alloc-(*iot).size, fmt, ptr);
 __builtin_va_end(ptr);
    } while ( siz > ((*iot).alloc-(*iot).size) );
    (*iot).size += siz;
    return siz;
}

canonical_original_code:
int Csprintf(struct Cstring *iot, char *fmt, ...)
{
    __builtin_va_list ptr;
    int siz = 100;
    do {
 (*iot).text = ((*iot).alloc > (*iot).size + (siz) ? (*iot).text : (*iot).text ? realloc((*iot).text, sizeof (*iot).text[0] * ((*iot).alloc = 100+(siz)+(*iot).size)) : malloc(sizeof (*iot).text[0] * ((*iot).alloc = 100+(siz)+(*iot).size)));
 __builtin_va_start(ptr,fmt);
 siz = vsnprintf((*iot).text+(*iot).size, (*iot).alloc-(*iot).size, fmt, ptr);
 __builtin_va_end(ptr);
    } while ( siz > ((*iot).alloc-(*iot).size) );
    (*iot).size += siz;
    return siz;
}

variable_types:
fmt
char *

variable_types: siz int


Cswrite

original_code:
int
Cswrite(Cstring *iot, char *bfr, int size)
{
    (*iot).text = ((*iot).alloc > (*iot).size + (size) ? (*iot).text : (*iot).text ? realloc((*iot).text, sizeof (*iot).text[0] * ((*iot).alloc = 100+(size)+(*iot).size)) : malloc(sizeof (*iot).text[0] * ((*iot).alloc = 100+(size)+(*iot).size)));
    memcpy((*iot).text+(*iot).size, bfr, size);
    (*iot).size += size;
    return size;
}

canonical_original_code:
int Cswrite(struct Cstring *iot, char *bfr, int size)
{
    (*iot).text = ((*iot).alloc > (*iot).size + (size) ? (*iot).text : (*iot).text ? realloc((*iot).text, sizeof (*iot).text[0] * ((*iot).alloc = 100+(size)+(*iot).size)) : malloc(sizeof (*iot).text[0] * ((*iot).alloc = 100+(size)+(*iot).size)));
    memcpy((*iot).text+(*iot).size, bfr, size);
    (*iot).size += size;
    return size;
}

variable_types:
bfr
char *

variable_types: size int


Csreparse

original_code:
void
Csreparse(Cstring *iot, char *buf, int size, int flags)
{
    MMIOT f;
    ___mkd_initmmiot(&f, 0);
    ___mkd_reparse(buf, size, 0, &f);
    ___mkd_emblock(&f);
    memcpy((((*iot).size += ((f.out).size)) - ((f.out).size)) + ((*iot).text = (*iot).text ? realloc((*iot).text, sizeof (*iot).text[0] * ((*iot).alloc += (f.out).size)) : malloc(sizeof (*iot).text[0] * ((*iot).alloc += (f.out).size))), ((f.out).text), sizeof((*iot).text[0])*((f.out).size));
    ___mkd_freemmiot(&f, 0);
}

canonical_original_code:
void Csreparse(struct Cstring *iot, char *buf, int size, int flags)
{
    struct mmiot f;
    ___mkd_initmmiot(&f, 0);
    ___mkd_reparse(buf, size, 0, &f);
    ___mkd_emblock(&f);
    memcpy((((*iot).size += ((f.out).size)) - ((f.out).size)) + ((*iot).text = (*iot).text ? realloc((*iot).text, sizeof (*iot).text[0] * ((*iot).alloc += (f.out).size)) : malloc(sizeof (*iot).text[0] * ((*iot).alloc += (f.out).size))), ((f.out).text), sizeof((*iot).text[0])*((f.out).size));
    ___mkd_freemmiot(&f, 0);
}

variable_types:
buf
char *

variable_types: flags int

variable_types: struct mmiot { struct Cstring { char *text; int size; } out; struct Cstring in; struct Qblock { struct block { enum { bTEXT=0, bSTAR=1, bUNDER=2 } b_type; int b_count; char b_char; struct Cstring b_text; struct Cstring b_post; } *text; int size; } Q; int isp; int reference; char *ref_prefix; struct { struct footnote { struct Cstring tag; struct Cstring link; struct Cstring title; int height; int dealloc; int refnumber; int flags; } *text; int size; } *footnotes; unsigned int flags; struct callback_data { void *e_data; char *(*e_url)(char *, int, void *); char *(*e_flags)(char *, int, void *); void (*e_free)(char *, void *); } *cb; }


decompiled_code:
const char *__fastcall mkd_xmlchar(char a1)
{
const char *result; // rax

switch ( a1 )
{
case '"':
result = """;
break;
case '&':
result = "&";
break;
case '\'':
result = "'";
break;
case '<':
result = "<";
break;
case '>':
result = ">";
break;
default:
result = 0LL;
break;
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func0(char a1)
{
const char *result; // rax

switch ( a1 )
{
case '"':
result = """;
break;
case '&':
result = "&";
break;
case '\'':
result = "'";
break;
case '<':
result = "<";
break;
case '>':
result = ">";
break;
default:
result = 0LL;
break;
}
return result;
}

original_code:
static char *
mkd_xmlchar(unsigned char c)
{
    switch (c) {
    case '<': return "<";
    case '>': return ">";
    case '&': return "&";
    case '"': return """;
    case '\'': return "'";
    default: if ( (((c) & ~0x7f) == 0) || (c & 0x80) )
      return 0;
  return "";
    }
}

canonical_original_code:
static char *mkd_xmlchar(unsigned char c)
{
    switch (c) {
    case '<': return "<";
    case '>': return ">";
    case '&': return "&";
    case '"': return """;
    case '\'': return "'";
    default: if ( (((c) & ~0x7f) == 0) || (c & 0x80) )
      return 0;
  return "";
    }
}

variable_types:
c
unsigned char


decompiled_code:
void mkd_initialize()
{
unsigned int v0; // eax

if ( need_to_initrng )
{
need_to_initrng = 0;
v0 = time(0LL);
srandom(v0);
}
}

canonical_decompiled_code:
void func0()
{
unsigned int v0; // eax

if ( need_to_initrng )
{
need_to_initrng = 0;
v0 = time(0LL);
srandom(v0);
}
}

original_code:
void
mkd_initialize()
{
    if ( need_to_initrng ) {
 need_to_initrng = 0;
 srandom((unsigned int)time(0));
    }
}


decompiled_code:
__int64 mkd_shlib_destructor()
{
return mkd_deallocate_tags();
}

canonical_decompiled_code:
__int64 func1()
{
return mkd_deallocate_tags();
}

original_code:
void
mkd_shlib_destructor()
{
    mkd_deallocate_tags();
}


decompiled_code:
__int64 __fastcall sort_by_flag(const void *a1, const void *a2)
{
return (unsigned int)(*((_DWORD *)a1 + 7) - *((_DWORD *)a2 + 7));
}

canonical_decompiled_code:
__int64 __fastcall func0(const void *a1, const void *a2)
{
return (unsigned int)(*((_DWORD *)a1 + 7) - *((_DWORD *)a2 + 7));
}

original_code:
int
sort_by_flag(struct _opt *a, struct _opt *b)
{
    return a->flag - b->flag;
}

variable_types: struct _opt { char *name; char *desc; int off; int skip; int sayenable; unsigned int flag; } *

variable_types:
b
struct _opt *


decompiled_code:
int __fastcall sort_by_name(const void *a1, const void *a2)
{
return strcmp(*(const char **)a1, *(const char **)a2);
}

canonical_decompiled_code:
int __fastcall func1(const void *a1, const void *a2)
{
return strcmp(*(const char **)a1, *(const char **)a2);
}

original_code:
int
sort_by_name(struct _opt *a, struct _opt *b)
{
    return strcmp(a->name,b->name);
}

user_defined_types: struct _opt { char *name; char *desc; int off; int skip; int sayenable; unsigned int flag; }


decompiled_code:
void __fastcall show_flags(int a1)
{
char **v1; // rbx
const char *v2; // rcx
const char *v3; // rdx
const char *v4; // rbx
const char *v5; // rsi

if ( a1 )
{
qsort(opts, 0x19uLL, 0x20uLL, sort_by_name);
v1 = opts;
do
{
while ( *((_DWORD *)v1 + 5) )
{
v1 += 4;
if ( v1 == (char **)&unk_580 )
return;
}
v2 = v1[1];
v3 = *v1;
v1 += 4;
fprintf(stderr, "%16s : %s\n", v3, v2);
}
while ( v1 != (char **)&unk_580 );
}
else
{
qsort(opts, 0x19uLL, 0x20uLL, (__compar_fn_t)sort_by_flag);
v4 = (const char *)&off_268;
do
{
if ( !*((_DWORD *)v4 + 3) )
{
fprintf(stderr, "%08lx : ", *((unsigned int *)v4 + 5));
if ( *((_DWORD *)v4 + 4) )
{
v5 = "enable ";
if ( *((_DWORD *)v4 + 2) )
v5 = "disable ";
fprintf(stderr, v5);
}
fprintf(stderr, "%s\n", *(const char **)v4);
}
v4 += 32;
}
while ( v4 != " " );
}
}

canonical_decompiled_code:
void __fastcall func2(int a1)
{
char **v1; // rbx
const char *v2; // rcx
const char *v3; // rdx
const char *v4; // rbx
const char *v5; // rsi

if ( a1 )
{
qsort(opts, 0x19uLL, 0x20uLL, sort_by_name);
v1 = opts;
do
{
while ( *((_DWORD *)v1 + 5) )
{
v1 += 4;
if ( v1 == (char **)&unk_580 )
return;
}
v2 = v1[1];
v3 = *v1;
v1 += 4;
fprintf(stderr, "%16s : %s\n", v3, v2);
}
while ( v1 != (char **)&unk_580 );
}
else
{
qsort(opts, 0x19uLL, 0x20uLL, (__compar_fn_t)sort_by_flag);
v4 = (const char *)&off_268;
do
{
if ( !*((_DWORD *)v4 + 3) )
{
fprintf(stderr, "%08lx : ", *((unsigned int *)v4 + 5));
if ( *((_DWORD *)v4 + 4) )
{
v5 = "enable ";
if ( *((_DWORD *)v4 + 2) )
v5 = "disable ";
fprintf(stderr, v5);
}
fprintf(stderr, "%s\n", *(const char **)v4);
}
v4 += 32;
}
while ( v4 != " " );
}
}

original_code:
void
show_flags(int byname)
{
    int i;
    if ( byname ) {
 qsort(opts, (sizeof opts / sizeof opts[0]), sizeof(opts[0]), sort_by_name);
 for (i=0; i < (sizeof opts / sizeof opts[0]); i++)
     if ( ! opts[i].skip )
  fprintf(stderr, "%16s : %s\n", opts[i].name, opts[i].desc);
    }
    else {
 qsort(opts, (sizeof opts / sizeof opts[0]), sizeof(opts[0]), sort_by_flag);
 for (i=0; i < (sizeof opts / sizeof opts[0]); i++)
     if ( ! opts[i].skip ) {
  fprintf(stderr, "%08lx : ", (long)opts[i].flag);
  if ( opts[i].sayenable )
      fprintf(stderr, opts[i].off ? "disable " : "enable ");
  fprintf(stderr, "%s\n", opts[i].desc);
     }
    }
}

variable_types: byname int

variable_types: i int


decompiled_code:
__int64 __fastcall set_flag(int *a1, char *a2)
{
char *i; // r14
char v3; // al
int v4; // er12
__int64 v5; // rbx
int v6; // eax
int v7; // edx
int v8; // eax

for ( i = strtok(a2, ","); i; i = strtok(0LL, ",") )
{
v3 = *i;
if ( ((*i - 43) & 0xFD) != 0 )
{
v4 = strncasecmp(i, "no", 2uLL);
if ( v4 )
v4 = 1;
else
i += 2;
}
else
{
++i;
v4 = v3 == 43;
}
v5 = 0LL;
while ( strcasecmp(i, opts[4 * v5]) )
{
if ( ++v5 == 25 )
return 0LL;
}
if ( dword_270[8 * (int)v5] )
v4 ^= 1u;
v6 = dword_27C[8 * (int)v5];
v7 = v6 | *a1;
v8 = *a1 & ~v6;
if ( v4 )
v8 = v7;
*a1 = v8;
}
return 1LL;
}

original_code:
int
set_flag(mkd_flag_t *flags, char *optionstring)
{
    int i;
    int enable;
    char *arg;
    for ( arg = strtok(optionstring, ","); arg; arg = strtok(((void *)0), ",") ) {
 if ( *arg == '+' || *arg == '-' )
     enable = (*arg++ == '+') ? 1 : 0;
 else if ( strncasecmp(arg, "no", 2) == 0 ) {
     arg += 2;
     enable = 0;
 }
 else
     enable = 1;
 for ( i=0; i < (sizeof opts / sizeof opts[0]); i++ )
     if ( strcasecmp(arg, opts[i].name) == 0 )
  break;
 if ( i < (sizeof opts / sizeof opts[0]) ) {
     if ( opts[i].off )
  enable = !enable;
     if ( enable )
  *flags |= opts[i].flag;
     else
  *flags &= ~opts[i].flag;
 }
 else
     return 0;
    }
    return 1;
}

canonical_original_code:
int set_flag(unsigned int *flags, char *optionstring)
{
    int i;
    int enable;
    char *arg;
    for ( arg = strtok(optionstring, ","); arg; arg = strtok(((void *)0), ",") ) {
 if ( *arg == '+' || *arg == '-' )
     enable = (*arg++ == '+') ? 1 : 0;
 else if ( strncasecmp(arg, "no", 2) == 0 ) {
     arg += 2;
     enable = 0;
 }
 else
     enable = 1;
 for ( i=0; i < (sizeof opts / sizeof opts[0]); i++ )
     if ( strcasecmp(arg, opts[i].name) == 0 )
  break;
 if ( i < (sizeof opts / sizeof opts[0]) ) {
     if ( opts[i].off )
  enable = !enable;
     if ( enable )
  *flags |= opts[i].flag;
     else
  *flags &= ~opts[i].flag;
 }
 else
     return 0;
    }
    return 1;
}

variable_types:
flags
unsigned int *

variable_types:
optionstring
char *

variable_types: enable int

variable_types:
arg
char *


decompiled_code:
void __fastcall mkd_cleanup(void *ptr)
{
__int64 v2; // rdi
_QWORD *v3; // rdi
void *v4; // rdi
void *v5; // rdi
void *v6; // rdi
_QWORD *v7; // rdi

if ( ptr && *(_DWORD *)ptr == 425723697 )
{
v2 = *((_QWORD *)ptr + 10);
if ( v2 )
{
__mkd_freemmiot(v2, 0LL);
free(*((void **)ptr + 10));
}
v3 = (_QWORD *)*((_QWORD *)ptr + 6);
if ( v3 )
__mkd_freeParagraph(v3);
v4 = (void *)*((_QWORD *)ptr + 1);
if ( v4 )
__mkd_freeLine(v4);
v5 = (void *)*((_QWORD *)ptr + 2);
if ( v5 )
__mkd_freeLine(v5);
v6 = (void *)*((_QWORD *)ptr + 3);
if ( v6 )
__mkd_freeLine(v6);
v7 = (_QWORD *)*((_QWORD *)ptr + 4);
if ( v7 )
__mkd_freeLines(v7);
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func8(void *ptr)
{
__int64 v2; // rdi
_QWORD *v3; // rdi
void *v4; // rdi
void *v5; // rdi
void *v6; // rdi
_QWORD *v7; // rdi

if ( ptr && *(_DWORD *)ptr == 425723697 )
{
v2 = *((_QWORD *)ptr + 10);
if ( v2 )
{
func6(v2, 0LL);
free(*((void **)ptr + 10));
}
v3 = (_QWORD *)*((_QWORD *)ptr + 6);
if ( v3 )
func2(v3);
v4 = (void *)*((_QWORD *)ptr + 1);
if ( v4 )
func0(v4);
v5 = (void *)*((_QWORD *)ptr + 2);
if ( v5 )
func0(v5);
v6 = (void *)*((_QWORD *)ptr + 3);
if ( v6 )
func0(v6);
v7 = (_QWORD *)*((_QWORD *)ptr + 4);
if ( v7 )
func1(v7);
free(ptr);
}
}

original_code:
void
mkd_cleanup(Document *doc)
{
    if ( doc && (doc->magic == 0x19600731) ) {
 if ( doc->ctx ) {
     ___mkd_freemmiot(doc->ctx, 0);
     free(doc->ctx);
 }
 if ( doc->code) ___mkd_freeParagraph(doc->code);
 if ( doc->title) ___mkd_freeLine(doc->title);
 if ( doc->author) ___mkd_freeLine(doc->author);
 if ( doc->date) ___mkd_freeLine(doc->date);
 if ( (doc->content).text ) ___mkd_freeLines((doc->content).text);
 memset(doc, 0, sizeof doc[0]);
 free(doc);
    }
}

canonical_original_code:
void mkd_cleanup(struct document *doc)
{
    if ( doc && (doc->magic == 0x19600731) ) {
 if ( doc->ctx ) {
     ___mkd_freemmiot(doc->ctx, 0);
     free(doc->ctx);
 }
 if ( doc->code) ___mkd_freeParagraph(doc->code);
 if ( doc->title) ___mkd_freeLine(doc->title);
 if ( doc->author) ___mkd_freeLine(doc->author);
 if ( doc->date) ___mkd_freeLine(doc->date);
 if ( (doc->content).text ) ___mkd_freeLines((doc->content).text);
 memset(doc, 0, sizeof doc[0]);
 free(doc);
    }
}

variable_types: struct document { int magic; struct line { struct Cstring { char *text; int size; } text; struct line *next; int dle; int flags; enum { chk_text=0, chk_code=1, chk_hr=2, chk_dash=3, chk_tilde=4, chk_equal=5 } kind; int count; } *title; struct line *author; struct line *date; struct { struct line *text; } content; struct paragraph { struct paragraph *next; struct paragraph *down; struct line *text; char *ident; enum { WHITESPACE=0, CODE=1, QUOTE=2, MARKUP=3, HTML=4, STYLE=5, DL=6, UL=7, OL=8, AL=9, LISTITEM=10, HDR=11, HR=12, TABLE=13, SOURCE=14 } typ; enum { IMPLICIT=0, PARA=1, CENTER=2 } align; int hnumber; } *code; int compiled; int html; int tabstop; char *ref_prefix; struct mmiot { struct Cstring out; struct Cstring in; struct Qblock { struct block { enum { bTEXT=0, bSTAR=1, bUNDER=2 } b_type; int b_count; char b_char; struct Cstring b_text; struct Cstring b_post; } *text; int size; } Q; int isp; int reference; char *ref_prefix; struct { struct footnote { struct Cstring tag; struct Cstring link; struct Cstring title; int height; int dealloc; int refnumber; int flags; } *text; int size; } *footnotes; unsigned int flags; struct callback_data { void *e_data; char *(*e_url)(char *, int, void *); char *(*e_flags)(char *, int, void *); void (*e_free)(char *, void *); } *cb; } *ctx; struct callback_data cb; } *


emfill

original_code:
static void
emfill(block *p)
{
    int j;
    if ( p->b_type == bTEXT )
 return;
    for (j=0; j < p->b_count; j++)
   ((p->b_text).size++)[((p->b_text).size < (p->b_text).alloc) ? ((p->b_text).text) : ((p->b_text).text = (p->b_text).text ? realloc((p->b_text).text, sizeof (p->b_text).text[0] * ((p->b_text).alloc += 100)) : malloc(sizeof (p->b_text).text[0] * ((p->b_text).alloc += 100)) )] = p->b_char;
    p->b_count = 0;
}

canonical_original_code:
static void emfill(struct block *p)
{
    int j;
    if ( p->b_type == bTEXT )
 return;
    for (j=0; j < p->b_count; j++)
   ((p->b_text).size++)[((p->b_text).size < (p->b_text).alloc) ? ((p->b_text).text) : ((p->b_text).text = (p->b_text).text ? realloc((p->b_text).text, sizeof (p->b_text).text[0] * ((p->b_text).alloc += 100)) : malloc(sizeof (p->b_text).text[0] * ((p->b_text).alloc += 100)) )] = p->b_char;
    p->b_count = 0;
}

variable_types: struct block { enum { bTEXT=0, bSTAR=1, bUNDER=2 } b_type; int b_count; char b_char; struct Cstring { char *text; int size; } b_text; struct Cstring b_post; } *

variable_types: j int


emclose

original_code:
static void
emclose(MMIOT *f, int first, int last)
{
    int j;
    for (j=first+1; j<last-1; j++)
 emfill(&(f->Q).text[j]);
}

canonical_original_code:
static void emclose(struct mmiot *f, int first, int last)
{
    int j;
    for (j=first+1; j<last-1; j++)
 emfill(&(f->Q).text[j]);
}

variable_types: struct mmiot { struct Cstring { char *text; int size; } out; struct Cstring in; struct Qblock { struct block { enum { bTEXT=0, bSTAR=1, bUNDER=2 } b_type; int b_count; char b_char; struct Cstring b_text; struct Cstring b_post; } *text; int size; } Q; int isp; int reference; char *ref_prefix; struct { struct footnote { struct Cstring tag; struct Cstring link; struct Cstring title; int height; int dealloc; int refnumber; int flags; } *text; int size; } *footnotes; unsigned int flags; struct callback_data { void *e_data; char *(*e_url)(char *, int, void *); char *(*e_flags)(char *, int, void *); void (*e_free)(char *, void *); } *cb; } *

variable_types: first int

variable_types: last int


emmatch

original_code:
static void
emmatch(MMIOT *f, int first, int last)
{
    block *start = &(f->Q).text[first];
    int e, e2, match;
    switch (start->b_count) {
    case 2: if ( e = empair(f,first,last,match=2) )
  break;
    case 1: e = empair(f,first,last,match=1);
     break;
    case 0: return;
    default:
     e = empair(f,first,last,1);
     e2= empair(f,first,last,2);
     if ( e2 >= e ) {
  e = e2;
  match = 2;
     }
     else
  match = 1;
     break;
    }
    if ( e ) {
 block *end = &(f->Q).text[e];
 end->b_count -= match;
 start->b_count -= match;
 emblock(f, first, e);
 ((start->b_text)).text = (((start->b_text)).alloc > ((start->b_text)).size + ((emtags[match-1].size-1)) ? ((start->b_text)).text : ((start->b_text)).text ? realloc(((start->b_text)).text, sizeof ((start->b_text)).text[0] * (((start->b_text)).alloc = 100+((emtags[match-1].size-1))+((start->b_text)).size)) : malloc(sizeof ((start->b_text)).text[0] * (((start->b_text)).alloc = 100+((emtags[match-1].size-1))+((start->b_text)).size))); if ( (start->b_text).size ) { memmove((start->b_text).text+(emtags[match-1].size-1), (start->b_text).text, (start->b_text).size); } memcpy( (start->b_text).text, (emtags[match-1].open), (emtags[match-1].size-1) ); (start->b_text).size += (emtags[match-1].size-1);
 memcpy((((end->b_post).size += (emtags[match-1].size)) - (emtags[match-1].size)) + ((end->b_post).text = (end->b_post).text ? realloc((end->b_post).text, sizeof (end->b_post).text[0] * ((end->b_post).alloc += emtags[match-1].size)) : malloc(sizeof (end->b_post).text[0] * ((end->b_post).alloc += emtags[match-1].size))), (emtags[match-1].close), sizeof((end->b_post).text[0])*(emtags[match-1].size));
 emmatch(f, first, last);
    }
}

canonical_original_code:
static void emmatch(struct mmiot *f, int first, int last)
{
    struct block *start = &(f->Q).text[first];
    int e; int e2; int match;
    switch (start->b_count) {
    case 2: if ( e = empair(f,first,last,match=2) )
  break;
    case 1: e = empair(f,first,last,match=1);
     break;
    case 0: return;
    default:
     e = empair(f,first,last,1);
     e2= empair(f,first,last,2);
     if ( e2 >= e ) {
  e = e2;
  match = 2;
     }
     else
  match = 1;
     break;
    }
    if ( e ) {
 struct block *end = &(f->Q).text[e];
 end->b_count -= match;
 start->b_count -= match;
 emblock(f, first, e);
 ((start->b_text)).text = (((start->b_text)).alloc > ((start->b_text)).size + ((emtags[match-1].size-1)) ? ((start->b_text)).text : ((start->b_text)).text ? realloc(((start->b_text)).text, sizeof ((start->b_text)).text[0] * (((start->b_text)).alloc = 100+((emtags[match-1].size-1))+((start->b_text)).size)) : malloc(sizeof ((start->b_text)).text[0] * (((start->b_text)).alloc = 100+((emtags[match-1].size-1))+((start->b_text)).size))); if ( (start->b_text).size ) { memmove((start->b_text).text+(emtags[match-1].size-1), (start->b_text).text, (start->b_text).size); } memcpy( (start->b_text).text, (emtags[match-1].open), (emtags[match-1].size-1) ); (start->b_text).size += (emtags[match-1].size-1);
 memcpy((((end->b_post).size += (emtags[match-1].size)) - (emtags[match-1].size)) + ((end->b_post).text = (end->b_post).text ? realloc((end->b_post).text, sizeof (end->b_post).text[0] * ((end->b_post).alloc += emtags[match-1].size)) : malloc(sizeof (end->b_post).text[0] * ((end->b_post).alloc += emtags[match-1].size))), (emtags[match-1].close), sizeof((end->b_post).text[0])*(emtags[match-1].size));
 emmatch(f, first, last);
    }
}

variable_types: e int

variable_types: match int


emblock

decompiled_code:
void __fastcall emblock(__int64 a1, int a2, int a3)
{
int v3; // er13
int v5; // ebx
__int64 v6; // rbp
int v7; // esi

v3 = a2;
if ( a2 <= a3 )
{
v5 = a2;
v6 = 48LL * a2;
do
{
while ( !*(_DWORD *)(*(_QWORD *)(a1 + 32) + v6) )
{
++v5;
v6 += 48LL;
if ( a3 < v5 )
goto LABEL_6;
}
v7 = v5++;
emmatch(a1, v7, a3);
v6 += 48LL;
}
while ( a3 >= v5 );
}
LABEL_6:
emclose(a1, v3, a3);
}

original_code:
static void
emblock(MMIOT *f, int first, int last)
{
    int i;
    for ( i = first; i <= last; i++ )
 if ( (f->Q).text[i].b_type != bTEXT )
     emmatch(f, i, last);
    emclose(f, first, last);
}

canonical_original_code:
static void emblock(struct mmiot *f, int first, int last)
{
    int i;
    for ( i = first; i <= last; i++ )
 if ( (f->Q).text[i].b_type != bTEXT )
     emmatch(f, i, last);
    emclose(f, first, last);
}