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

result = ungetc(a1, in);
if ( a1 == 10 )
--line;
return result;
}

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

result = ungetc(a1, in);
if ( a1 == 10 )
--line;
return result;
}

original_code:
void put_char(char c) {
 ungetc(c, in);
 if(c == '\n') {
  line--;
    }
}


lex

repo: ptigas/ciscal

decompiled_code:
int lex()
{
int v0; // er13
__int64 v1; // rbx
char v2; // di
char v3; // bp
char v4; // r8
char v5; // di
char v6; // r8
__int64 v7; // r12
__int64 v8; // rax
int result; // eax
__int64 v10; // r14
char v11; // di
const char *v12; // r12
int v13; // ebp

if ( !in )
in = stdin;
LABEL_3:
v0 = 0;
v1 = 0LL;
while ( 1 )
{
v2 = get_char();
v3 = v2;
if ( !(unsigned int)isAlpha(v2) )
{
if ( isNum(v2) )
{
v7 = 0LL;
goto LABEL_9;
}
v5 = v4;
if ( !(unsigned int)isWhite(v4) )
{
if ( isOperator(v5) )
{
v7 = (unsigned int)(((v6 - 43) & 0xFD) != 0) + 3;
goto LABEL_9;
}
switch ( v6 )
{
case '[':
v7 = 12LL;
break;
case ']':
v7 = 13LL;
break;
case '{':
v7 = 10LL;
break;
case '}':
v7 = 11LL;
break;
default:
switch ( v6 )
{
case '(':
v7 = 14LL;
break;
case ')':
v7 = 15LL;
break;
case '<':
v7 = 5LL;
break;
case '>':
v7 = 6LL;
break;
case '=':
v7 = 7LL;
break;
case ',':
v7 = 16LL;
break;
case ';':
v7 = 17LL;
break;
case ':':
v7 = 18LL;
break;
default:
v7 = 20LL;
if ( v6 == -1 )
{
v7 = 19LL;
break;
}
LABEL_9:
if ( (_DWORD)v1 != 5 )
goto LABEL_10;
goto LABEL_22;
}
if ( (_DWORD)v1 != 5 )
goto LABEL_11;
v1 = 5LL;
if ( v3 != 42 )
goto LABEL_11;
LABEL_23:
result = get_char();
if ( (_BYTE)result == 47 )
{
token = 48;
return result;
}
goto LABEL_24;
}
if ( (_DWORD)v1 == 5 )
goto LABEL_11;
LABEL_10:
if ( v3 != 47 )
goto LABEL_11;
LOBYTE(result) = get_char();
if ( (_BYTE)result == 42 )
{
v3 = 42;
v1 = 5LL;
goto LABEL_11;
}
LABEL_24:
put_char(result);
goto LABEL_11;
}
v7 = 2LL;
goto LABEL_9;
}
v7 = 1LL;
if ( (_DWORD)v1 != 5 )
goto LABEL_10;
LABEL_22:
v1 = 5LL;
if ( v3 == 42 )
goto LABEL_23;
LABEL_11:
LODWORD(v1) = state[21 * v1 + v7];
if ( (_DWORD)v1 != 5 )
{
if ( (_DWORD)v1 == 9 )
goto LABEL_3;
if ( v0 <= 29 )
{
v8 = v0++;
*(&id_string + v8) = v3;
}
if ( (unsigned int)(v1 - 6) <= 0x2B )
break;
}
}
if ( (_DWORD)v1 == 6 )
{
v11 = v3;
v12 = reserved;
v13 = 0;
put_char(v11);
v10 = v0 - 1;
*(&id_string + v10) = 0;
while ( 1 )
{
result = strcmp(v12, &id_string);
if ( !result )
break;
++v13;
v12 += 31;
if ( v13 == 18 )
goto LABEL_20;
}
token = v13 + 29;
}
else
{
if ( (_DWORD)v1 == 7 )
{
put_char(v3);
v10 = v0 - 1;
*(&id_string + v10) = 0;
result = atoi(&id_string);
id_value = result;
}
else
{
result = v1 - 13;
v10 = v0;
if ( (unsigned int)(v1 - 13) <= 1 )
{
result = put_char(v3);
v10 = v0 - 1;
}
}
LABEL_20:
*(&id_string + v10) = 0;
token = v1;
}
return result;
}

canonical_decompiled_code:
int func7()
{
int v0; // er13
__int64 v1; // rbx
char v2; // di
char v3; // bp
char v4; // r8
char v5; // di
char v6; // r8
__int64 v7; // r12
__int64 v8; // rax
int result; // eax
__int64 v10; // r14
char v11; // di
const char *v12; // r12
int v13; // ebp

if ( !in )
in = stdin;
LABEL_3:
v0 = 0;
v1 = 0LL;
while ( 1 )
{
v2 = func5();
v3 = v2;
if ( !(unsigned int)func0(v2) )
{
if ( func1(v2) )
{
v7 = 0LL;
goto LABEL_9;
}
v5 = v4;
if ( !(unsigned int)func3(v4) )
{
if ( func4(v5) )
{
v7 = (unsigned int)(((v6 - 43) & 0xFD) != 0) + 3;
goto LABEL_9;
}
switch ( v6 )
{
case '[':
v7 = 12LL;
break;
case ']':
v7 = 13LL;
break;
case '{':
v7 = 10LL;
break;
case '}':
v7 = 11LL;
break;
default:
switch ( v6 )
{
case '(':
v7 = 14LL;
break;
case ')':
v7 = 15LL;
break;
case '<':
v7 = 5LL;
break;
case '>':
v7 = 6LL;
break;
case '=':
v7 = 7LL;
break;
case ',':
v7 = 16LL;
break;
case ';':
v7 = 17LL;
break;
case ':':
v7 = 18LL;
break;
default:
v7 = 20LL;
if ( v6 == -1 )
{
v7 = 19LL;
break;
}
LABEL_9:
if ( (_DWORD)v1 != 5 )
goto LABEL_10;
goto LABEL_22;
}
if ( (_DWORD)v1 != 5 )
goto LABEL_11;
v1 = 5LL;
if ( v3 != 42 )
goto LABEL_11;
LABEL_23:
result = func5();
if ( (_BYTE)result == 47 )
{
token = 48;
return result;
}
goto LABEL_24;
}
if ( (_DWORD)v1 == 5 )
goto LABEL_11;
LABEL_10:
if ( v3 != 47 )
goto LABEL_11;
LOBYTE(result) = func5();
if ( (_BYTE)result == 42 )
{
v3 = 42;
v1 = 5LL;
goto LABEL_11;
}
LABEL_24:
func6(result);
goto LABEL_11;
}
v7 = 2LL;
goto LABEL_9;
}
v7 = 1LL;
if ( (_DWORD)v1 != 5 )
goto LABEL_10;
LABEL_22:
v1 = 5LL;
if ( v3 == 42 )
goto LABEL_23;
LABEL_11:
LODWORD(v1) = state[21 * v1 + v7];
if ( (_DWORD)v1 != 5 )
{
if ( (_DWORD)v1 == 9 )
goto LABEL_3;
if ( v0 <= 29 )
{
v8 = v0++;
*(&id_string + v8) = v3;
}
if ( (unsigned int)(v1 - 6) <= 0x2B )
break;
}
}
if ( (_DWORD)v1 == 6 )
{
v11 = v3;
v12 = reserved;
v13 = 0;
func6(v11);
v10 = v0 - 1;
*(&id_string + v10) = 0;
while ( 1 )
{
result = strcmp(v12, &id_string);
if ( !result )
break;
++v13;
v12 += 31;
if ( v13 == 18 )
goto LABEL_20;
}
token = v13 + 29;
}
else
{
if ( (_DWORD)v1 == 7 )
{
func6(v3);
v10 = v0 - 1;
*(&id_string + v10) = 0;
result = atoi(&id_string);
id_value = result;
}
else
{
result = v1 - 13;
v10 = v0;
if ( (unsigned int)(v1 - 13) <= 1 )
{
result = func6(v3);
v10 = v0 - 1;
}
}
LABEL_20:
*(&id_string + v10) = 0;
token = v1;
}
return result;
}

original_code:
void lex() {
    char c, cold;
    int S;
    int i;
    enum chartype ic;
    int j;
    if (in == ((void *)0)) {
        in = stdin;
    }
    i = 0;
    S = NF_START;
    while (1) {
  cold = c;
  c = get_char();
        if (isAlpha(c)) {
            ic = alpha;
        } else if (isNum(c)) {
            ic = digit;
        } else if (isWhite(c)) {
            ic = white;
        } else if (isOperator(c)) {
            if(c == '+' || c == '-') {
                ic = addop;
            } else {
                ic = mulop;
            }
        } else {
            if (c == '[') {
                ic = lbbrac;
   } else if (c == ']') {
                ic = rbbrac;
   } else if (c == '{') {
                ic = lbrac;
   } else if (c == '}') {
                ic = rbrac;
   } else if (c == '(') {
                ic = lpar;
   } else if (c == ')') {
                ic = rpar;
   } else if (c == '<') {
                ic = lt;
   } else if (c == '>') {
                ic = gt;
   } else if (c == '=') {
                ic = eq;
   } else if (c == ',') {
                ic = comma;
   } else if (c == ';') {
                ic = scol;
   } else if (c == ':') {
                ic = col;
   } else if (c == -1) {
                ic = eof;
   } else {
                ic = other;
            }
        }
        if (S != NF_COMMENT) {
            if (c == '/') {
                c = get_char();
                if (c == '*') {
                    S = NF_COMMENT;
                } else {
                    put_char(c);
     c = '/';
                }
            }
        } else {
            if (c == '*') {
                c = get_char();
                if (c == '/') {
                    S = COMMENT;
                    token = S;
                    return;
                } else {
                    put_char(c);
     c = '*';
                }
            }
        }
  S = state[S][ic];
        if (S != NF_COMMENT) {
            if (S != WHITE){
                if (i < 30){
                    id_string[i++] = c;
                }
            } else {
                i = 0;
                S = NF_START;
                continue;
            }
            if (((S>=ID)&&(S<=ERROR)) && S != WHITE) {
                if (S == ID) {
                    put_char(c);
     c = cold;
     i--;
     id_string[i] = '\0';
                    for(j=0; j < 18; j++) {
                        if (strcmp(reserved[j], id_string) == 0) {
                            S = TK_AND + j;
                            token = S;
                            return;
                        }
                    }
                }
                if (S == INTEGER) {
                    put_char(c);
     c = cold;
     i--;
     id_string[i] = '\0';
                    id_value = atoi(id_string);
                }
                if (S == TK_GT || S == TK_LT ) {
                    put_char(c);
     c = cold;
     i--;
                }
    id_string[i] = '\0';
                i = 0;
                token = S;
                return;
            }
        }
    }
    token = -1;
    return;
}

canonical_original_code:
void lex() {
    char c; char cold;
    int S;
    int i;
    enum chartype ic;
    int j;
    if (in == ((void *)0)) {
        in = stdin;
    }
    i = 0;
    S = NF_START;
    while (1) {
  cold = c;
  c = get_char();
        if (isAlpha(c)) {
            ic = alpha;
        } else if (isNum(c)) {
            ic = digit;
        } else if (isWhite(c)) {
            ic = white;
        } else if (isOperator(c)) {
            if(c == '+' || c == '-') {
                ic = addop;
            } else {
                ic = mulop;
            }
        } else {
            if (c == '[') {
                ic = lbbrac;
   } else if (c == ']') {
                ic = rbbrac;
   } else if (c == '{') {
                ic = lbrac;
   } else if (c == '}') {
                ic = rbrac;
   } else if (c == '(') {
                ic = lpar;
   } else if (c == ')') {
                ic = rpar;
   } else if (c == '<') {
                ic = lt;
   } else if (c == '>') {
                ic = gt;
   } else if (c == '=') {
                ic = eq;
   } else if (c == ',') {
                ic = comma;
   } else if (c == ';') {
                ic = scol;
   } else if (c == ':') {
                ic = col;
   } else if (c == -1) {
                ic = eof;
   } else {
                ic = other;
            }
        }
        if (S != NF_COMMENT) {
            if (c == '/') {
                c = get_char();
                if (c == '*') {
                    S = NF_COMMENT;
                } else {
                    put_char(c);
     c = '/';
                }
            }
        } else {
            if (c == '*') {
                c = get_char();
                if (c == '/') {
                    S = COMMENT;
                    token = S;
                    return;
                } else {
                    put_char(c);
     c = '*';
                }
            }
        }
  S = state[S][ic];
        if (S != NF_COMMENT) {
            if (S != WHITE){
                if (i < 30){
                    id_string[i++] = c;
                }
            } else {
                i = 0;
                S = NF_START;
                continue;
            }
            if (((S>=ID)&&(S<=ERROR)) && S != WHITE) {
                if (S == ID) {
                    put_char(c);
     c = cold;
     i--;
     id_string[i] = '\0';
                    for(j=0; j < 18; j++) {
                        if (strcmp(reserved[j], id_string) == 0) {
                            S = TK_AND + j;
                            token = S;
                            return;
                        }
                    }
                }
                if (S == INTEGER) {
                    put_char(c);
     c = cold;
     i--;
     id_string[i] = '\0';
                    id_value = atoi(id_string);
                }
                if (S == TK_GT || S == TK_LT ) {
                    put_char(c);
     c = cold;
     i--;
                }
    id_string[i] = '\0';
                i = 0;
                token = S;
                return;
            }
        }
    }
    token = -1;
    return;
}

variable_types: c char

variable_types: cold char

variable_types: S int

variable_types: i int

variable_types: enum chartype { digit=0, alpha=1, white=2, addop=3, mulop=4, lt=5, gt=6, eq=7, slash=8, star=9, lbrac=10, rbrac=11, lbbrac=12, rbbrac=13, lpar=14, rpar=15, comma=16, scol=17, col=18, eof=19, other=20 }

variable_types: j int

return_type: void


decompiled_code:
char *__fastcall label_x86(const char *a1)
{
char v2[56]; // [rsp+0h] [rbp-38h] BYREF

sprintf(v2, ".L%s", a1);
return strdup(v2);
}

canonical_decompiled_code:
char *__fastcall func0(const char *a1)
{
char v2[56]; // [rsp+0h] [rbp-38h] BYREF

sprintf(v2, ".L%s", a1);
return strdup(v2);
}

original_code:
char * label_x86( char *l ){
    char s[35];
    sprintf(s, ".L%s", l);
    return strdup(s);
}

canonical_original_code:
char *label_x86(char *l){
    char s[35];
    sprintf(s, ".L%s", l);
    return strdup(s);
}

variable_types:
l
char *

variable_types:
s
char [35]

return_type: char *


decompiled_code:
__int64 __fastcall add_machine_code_x86(char *src)
{
char *v1; // rax
char *v2; // rdx
__int64 result; // rax

v1 = (char *)malloc(0x110uLL);
v2 = strcpy(v1, src);
result = mc;
if ( mc )
{
*(_QWORD *)(mc + 264) = v2;
mc = (__int64)v2;
*((_QWORD *)v2 + 32) = result;
}
else
{
*((_QWORD *)v2 + 32) = 0LL;
*((_QWORD *)v2 + 33) = 0LL;
mc = (__int64)v2;
mc_tail = v2;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(char *src)
{
char *v1; // rax
char *v2; // rdx
__int64 result; // rax

v1 = (char *)malloc(0x110uLL);
v2 = strcpy(v1, src);
result = mc;
if ( mc )
{
*(_QWORD *)(mc + 264) = v2;
mc = (__int64)v2;
*((_QWORD *)v2 + 32) = result;
}
else
{
*((_QWORD *)v2 + 32) = 0LL;
*((_QWORD *)v2 + 33) = 0LL;
mc = (__int64)v2;
mc_tail = v2;
}
return result;
}

original_code:
void add_machine_code_x86( char *s ){
    struct code *tmp;
    tmp = (struct code*)malloc(sizeof(struct code));
    sprintf(tmp->cmd, "%s", s);
    if ( mc == ((void *)0) ){
        tmp->next = ((void *)0);
        tmp->prev = ((void *)0);
        mc = tmp;
        mc_tail = tmp;
    }else{
        mc->prev = tmp;
        tmp->next = mc;
        mc = tmp;
    }
}

canonical_original_code:
void add_machine_code_x86(char *s){
    struct code *tmp;
    tmp = (struct code *)malloc(sizeof(struct code));
    sprintf(tmp->cmd, "%s", s);
    if ( mc == ((void *)0) ){
        tmp->next = ((void *)0);
        tmp->prev = ((void *)0);
        mc = tmp;
        mc_tail = tmp;
    }else{
        mc->prev = tmp;
        tmp->next = mc;
        mc = tmp;
    }
}

variable_types:
s
char *

variable_types: struct code { char cmd[255]; struct code *next; struct code *prev; } *


decompiled_code:
__int64 gnlvcode_x86()
{
__int64 v0; // rbp
int i; // ebx
char v3[280]; // [rsp+0h] [rbp-118h] BYREF

v0 = lookup();
sprintf(v3, "\tmovl -4(%%ebp), %%ebx\n");
add_machine_code_x86(v3);
for ( i = *(_DWORD *)(v0 + 12); ncur - 1 > i; ++i )
{
sprintf(v3, "\tmovl -4(%%ebx), %%ebx\n");
add_machine_code_x86(v3);
}
sprintf(v3, "\tsubl $%d, %%ebx\n", *(unsigned int *)(v0 + 8));
return add_machine_code_x86(v3);
}

canonical_decompiled_code:
__int64 func3()
{
__int64 v0; // rbp
int i; // ebx
char v3[280]; // [rsp+0h] [rbp-118h] BYREF

v0 = lookup();
sprintf(v3, "\tmovl -4(%%ebp), %%ebx\n");
func2(v3);
for ( i = *(_DWORD *)(v0 + 12); ncur - 1 > i; ++i )
{
sprintf(v3, "\tmovl -4(%%ebx), %%ebx\n");
func2(v3);
}
sprintf(v3, "\tsubl $%d, %%ebx\n", *(unsigned int *)(v0 + 8));
return func2(v3);
}

original_code:
void gnlvcode_x86(char *name) {
 char s_tmp[255];
 int i;
 SYMBOL *p = lookup(name);
 sprintf(s_tmp, "\tmovl -4(%%ebp), %%ebx\n");
 add_machine_code_x86( s_tmp );
 for(i=p->level; i<ncur-1; i++) {
  sprintf(s_tmp, "\tmovl -4(%%ebx), %%ebx\n");
  add_machine_code_x86( s_tmp );
 }
 sprintf(s_tmp, "\tsubl $%d, %%ebx\n", p->offset);
 add_machine_code_x86( s_tmp );
}

canonical_original_code:
void gnlvcode_x86(char *name) {
 char s_tmp[255];
 int i;
 struct symbol *p = lookup(name);
 sprintf(s_tmp, "\tmovl -4(%%ebp), %%ebx\n");
 add_machine_code_x86( s_tmp );
 for(i=p->level; i<ncur-1; i++) {
  sprintf(s_tmp, "\tmovl -4(%%ebx), %%ebx\n");
  add_machine_code_x86( s_tmp );
 }
 sprintf(s_tmp, "\tsubl $%d, %%ebx\n", p->offset);
 add_machine_code_x86( s_tmp );
}

variable_types:
name
char *

variable_types: struct symbol { char *name; int offset; int level; struct function { enum FTYPE { FUNC=0, PROC=1, PROG=2 } type; int size; int genquad; struct symbol *args; struct symbol *first_arg; int num_arg; int has_return; } func; struct argument { enum PARTYPE { IN=0, INOUT=1 } type; struct symbol *next_arg; struct symbol *func; int offset; int num; } arg; struct variable { int offset; } var; enum T { TYPE_FUNC=0, TYPE_VAR=1, TYPE_CONST=2, TYPE_TMP=3, TYPE_ARG=4 } type; struct symbol *next; } *

user_defined_types: struct symbol { char *name; int offset; int level; struct function func; struct argument arg; struct variable var; enum T type; struct symbol *next; }

user_defined_types: struct function { enum FTYPE type; int size; int genquad; struct symbol *args; struct symbol *first_arg; int num_arg; int has_return; }

user_defined_types: struct argument { enum PARTYPE type; struct symbol *next_arg; struct symbol *func; int offset; int num; }


decompiled_code:
__int64 __fastcall load_x86(const char *a1, const char *a2)
{
const unsigned __int16 **v2; // rax
__int64 v3; // rcx
__int64 result; // rax
__int64 v5; // rdx
__int64 v6; // [rsp+8h] [rbp-120h]
char s[280]; // [rsp+10h] [rbp-118h] BYREF

v2 = _ctype_b_loc();
v3 = *a2;
if ( ((*v2)[v3] & 0x400) == 0 && (_BYTE)v3 != 36 )
{
sprintf(s, "\tmovl $%s, %%%s\n", a2, a1);
return add_machine_code_x86(s);
}
result = lookup(a2);
if ( *(_DWORD *)(result + 12) == ncur )
{
v5 = *(unsigned int *)(result + 8);
if ( *(_DWORD *)(result + 92) != 4 || *(_DWORD *)(result + 56) != 1 )
{
sprintf(s, "\tmovl -%d(%%ebp), %%%s\n", v5, a1);
return add_machine_code_x86(s);
}
sprintf(s, "\tmovl -%d(%%ebp), %%edx\n", v5);
add_machine_code_x86(s);
sprintf(s, "\tmovl (%%edx), %%%s\n", a1);
return add_machine_code_x86(s);
}
if ( *(_DWORD *)(result + 12) < ncur )
{
v6 = result;
gnlvcode_x86(*(_QWORD *)result);
if ( *(_DWORD *)(v6 + 92) == 4 && *(_DWORD *)(v6 + 56) == 1 )
{
sprintf(s, "\tmovl (%%ebx), %%ebx\n");
add_machine_code_x86(s);
}
sprintf(s, "\tmovl (%%ebx), %%%s\n", a1);
return add_machine_code_x86(s);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(const char *a1, const char *a2)
{
const unsigned __int16 **v2; // rax
__int64 v3; // rcx
__int64 result; // rax
__int64 v5; // rdx
__int64 v6; // [rsp+8h] [rbp-120h]
char s[280]; // [rsp+10h] [rbp-118h] BYREF

v2 = _ctype_b_loc();
v3 = *a2;
if ( ((*v2)[v3] & 0x400) == 0 && (_BYTE)v3 != 36 )
{
sprintf(s, "\tmovl $%s, %%%s\n", a2, a1);
return func2(s);
}
result = lookup(a2);
if ( *(_DWORD *)(result + 12) == ncur )
{
v5 = *(unsigned int *)(result + 8);
if ( *(_DWORD *)(result + 92) != 4 || *(_DWORD *)(result + 56) != 1 )
{
sprintf(s, "\tmovl -%d(%%ebp), %%%s\n", v5, a1);
return func2(s);
}
sprintf(s, "\tmovl -%d(%%ebp), %%edx\n", v5);
func2(s);
sprintf(s, "\tmovl (%%edx), %%%s\n", a1);
return func2(s);
}
if ( *(_DWORD *)(result + 12) < ncur )
{
v6 = result;
func3(*(_QWORD *)result);
if ( *(_DWORD *)(v6 + 92) == 4 && *(_DWORD *)(v6 + 56) == 1 )
{
sprintf(s, "\tmovl (%%ebx), %%ebx\n");
func2(s);
}
sprintf(s, "\tmovl (%%ebx), %%%s\n", a1);
return func2(s);
}
return result;
}

original_code:
void load_x86( char *R, char *a ){
 char s_tmp[255];
    if ( !((*__ctype_b_loc ())[(int) ((*a))] & (unsigned short int) _ISalpha) && *a != '$' ){
        sprintf(s_tmp, "\tmovl $%s, %%%s\n", a, R);
        add_machine_code_x86( s_tmp );
    }else{
        SYMBOL *p = lookup(a);
  if (p->level == ncur) {
   if (p->type == TYPE_ARG && p->arg.type == INOUT) {
    sprintf(s_tmp, "\tmovl -%d(%%ebp), %%edx\n", p->offset);
          add_machine_code_x86( s_tmp );
    sprintf(s_tmp, "\tmovl (%%edx), %%%s\n", R);
          add_machine_code_x86( s_tmp );
   } else {
    sprintf(s_tmp, "\tmovl  -%d(%%ebp), %%%s\n", p->offset, R);
          add_machine_code_x86( s_tmp );
   }
   return;
  }else if (p->level < ncur) {
   gnlvcode_x86(p->name);
   if (p->type == TYPE_ARG && p->arg.type == INOUT) {
    sprintf(s_tmp, "\tmovl (%%ebx), %%ebx\n");
          add_machine_code_x86( s_tmp );
    sprintf(s_tmp, "\tmovl (%%ebx), %%%s\n", R);
          add_machine_code_x86( s_tmp );
   } else {
    sprintf(s_tmp, "\tmovl (%%ebx), %%%s\n", R);
          add_machine_code_x86( s_tmp );
   }
   return;
  }
    }
}

canonical_original_code:
void load_x86(char *R, char *a){
 char s_tmp[255];
    if ( !((*__ctype_b_loc ())[(int) ((*a))] & (unsigned short) _ISalpha) && *a != '$' ){
        sprintf(s_tmp, "\tmovl $%s, %%%s\n", a, R);
        add_machine_code_x86( s_tmp );
    }else{
        struct symbol *p = lookup(a);
  if (p->level == ncur) {
   if (p->type == TYPE_ARG && p->arg.type == INOUT) {
    sprintf(s_tmp, "\tmovl -%d(%%ebp), %%edx\n", p->offset);
          add_machine_code_x86( s_tmp );
    sprintf(s_tmp, "\tmovl (%%edx), %%%s\n", R);
          add_machine_code_x86( s_tmp );
   } else {
    sprintf(s_tmp, "\tmovl  -%d(%%ebp), %%%s\n", p->offset, R);
          add_machine_code_x86( s_tmp );
   }
   return;
  }else if (p->level < ncur) {
   gnlvcode_x86(p->name);
   if (p->type == TYPE_ARG && p->arg.type == INOUT) {
    sprintf(s_tmp, "\tmovl (%%ebx), %%ebx\n");
          add_machine_code_x86( s_tmp );
    sprintf(s_tmp, "\tmovl (%%ebx), %%%s\n", R);
          add_machine_code_x86( s_tmp );
   } else {
    sprintf(s_tmp, "\tmovl (%%ebx), %%%s\n", R);
          add_machine_code_x86( s_tmp );
   }
   return;
  }
    }
}

variable_types:
R
char *

variable_types:
a
char *

user_defined_types: enum T { TYPE_FUNC=0, TYPE_VAR=1, TYPE_CONST=2, TYPE_TMP=3, TYPE_ARG=4 }


decompiled_code:
__int64 __fastcall store_x86(const char *a1, __int64 a2)
{
__int64 v2; // rbx
__int64 result; // rax
int v4; // eax
__int64 v5; // rcx
char v6[280]; // [rsp+0h] [rbp-118h] BYREF

v2 = lookup(a2);
result = ncur;
if ( *(_DWORD *)(v2 + 12) == ncur )
{
v5 = *(unsigned int *)(v2 + 8);
if ( *(_DWORD *)(v2 + 92) == 4 && *(_DWORD *)(v2 + 56) == 1 )
{
sprintf(v6, "\tmovl -%d(%%ebp), %%edx\n", (unsigned int)v5);
add_machine_code_x86(v6);
sprintf(v6, "\tmovl %%%s, (%%edx)\n", a1);
return add_machine_code_x86(v6);
}
sprintf(v6, "\tmovl %%%s, -%d(%%ebp)\n", a1, v5);
result = add_machine_code_x86(v6);
}
else if ( *(_DWORD *)(v2 + 12) < ncur || *(_DWORD *)(v2 + 92) == 3 )
{
gnlvcode_x86(*(_QWORD *)v2);
v4 = *(_DWORD *)(v2 + 92);
if ( v4 == 3 || v4 == 4 && *(_DWORD *)(v2 + 56) == 1 )
{
sprintf(v6, "\tmovl (%%ebx), %%ebx\n");
add_machine_code_x86(v6);
sprintf(v6, "\tmovl (%%ebx), %%%s\n", a1);
}
else
{
sprintf(v6, "\tmovl %%%s, (%%ebx)\n", a1);
}
return add_machine_code_x86(v6);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(const char *a1, __int64 a2)
{
__int64 v2; // rbx
__int64 result; // rax
int v4; // eax
__int64 v5; // rcx
char v6[280]; // [rsp+0h] [rbp-118h] BYREF

v2 = lookup(a2);
result = ncur;
if ( *(_DWORD *)(v2 + 12) == ncur )
{
v5 = *(unsigned int *)(v2 + 8);
if ( *(_DWORD *)(v2 + 92) == 4 && *(_DWORD *)(v2 + 56) == 1 )
{
sprintf(v6, "\tmovl -%d(%%ebp), %%edx\n", (unsigned int)v5);
func2(v6);
sprintf(v6, "\tmovl %%%s, (%%edx)\n", a1);
return func2(v6);
}
sprintf(v6, "\tmovl %%%s, -%d(%%ebp)\n", a1, v5);
result = func2(v6);
}
else if ( *(_DWORD *)(v2 + 12) < ncur || *(_DWORD *)(v2 + 92) == 3 )
{
func3(*(_QWORD *)v2);
v4 = *(_DWORD *)(v2 + 92);
if ( v4 == 3 || v4 == 4 && *(_DWORD *)(v2 + 56) == 1 )
{
sprintf(v6, "\tmovl (%%ebx), %%ebx\n");
func2(v6);
sprintf(v6, "\tmovl (%%ebx), %%%s\n", a1);
}
else
{
sprintf(v6, "\tmovl %%%s, (%%ebx)\n", a1);
}
return func2(v6);
}
return result;
}

original_code:
void store_x86( char *R, char *a ){
 char s_tmp[255];
 SYMBOL *p = lookup(a);
 if (p->level == ncur) {
  if (p->type == TYPE_ARG && p->arg.type == INOUT) {
   sprintf(s_tmp, "\tmovl -%d(%%ebp), %%edx\n", p->offset);
         add_machine_code_x86( s_tmp );
   sprintf(s_tmp, "\tmovl %%%s, (%%edx)\n", R);
         add_machine_code_x86( s_tmp );
  } else {
   sprintf(s_tmp, "\tmovl %%%s, -%d(%%ebp)\n", R, p->offset);
         add_machine_code_x86( s_tmp );
  }
  return;
 }else if (p->level < ncur || p->type == TYPE_TMP) {
  gnlvcode_x86(p->name);
  if ( p->type == TYPE_TMP || (p->type == TYPE_ARG && p->arg.type == INOUT)) {
   sprintf(s_tmp, "\tmovl (%%ebx), %%ebx\n");
         add_machine_code_x86( s_tmp );
   sprintf(s_tmp, "\tmovl (%%ebx), %%%s\n", R);
         add_machine_code_x86( s_tmp );
  } else {
   sprintf(s_tmp, "\tmovl %%%s, (%%ebx)\n", R);
         add_machine_code_x86( s_tmp );
  }
  return;
 }
}

canonical_original_code:
void store_x86(char *R, char *a){
 char s_tmp[255];
 struct symbol *p = lookup(a);
 if (p->level == ncur) {
  if (p->type == TYPE_ARG && p->arg.type == INOUT) {
   sprintf(s_tmp, "\tmovl -%d(%%ebp), %%edx\n", p->offset);
         add_machine_code_x86( s_tmp );
   sprintf(s_tmp, "\tmovl %%%s, (%%edx)\n", R);
         add_machine_code_x86( s_tmp );
  } else {
   sprintf(s_tmp, "\tmovl %%%s, -%d(%%ebp)\n", R, p->offset);
         add_machine_code_x86( s_tmp );
  }
  return;
 }else if (p->level < ncur || p->type == TYPE_TMP) {
  gnlvcode_x86(p->name);
  if ( p->type == TYPE_TMP || (p->type == TYPE_ARG && p->arg.type == INOUT)) {
   sprintf(s_tmp, "\tmovl (%%ebx), %%ebx\n");
         add_machine_code_x86( s_tmp );
   sprintf(s_tmp, "\tmovl (%%ebx), %%%s\n", R);
         add_machine_code_x86( s_tmp );
  } else {
   sprintf(s_tmp, "\tmovl %%%s, (%%ebx)\n", R);
         add_machine_code_x86( s_tmp );
  }
  return;
 }
}


decompiled_code:
void generate_final_x86()
{
const char *v0; // rbx
int v1; // edx
const char *v2; // rax
__int64 v3; // rax
__int64 v4; // rbx
__int64 v5; // rax
__int64 v6; // rdx
int v7; // eax
int v8; // eax
const char *v9; // rax
const char *v10; // rax
const char *v11; // rax
int v12; // edx
const char *v13; // rax
const char *v14; // rax
__int64 v15; // rdx
const char *v16; // rsi
_DWORD *v17; // rbx
__int64 v18; // rax
bool v19; // cf
bool v20; // zf
const char *v21; // rsi
unsigned int *v22; // r13
unsigned int v23; // er13
const char *v24; // rdi
__int64 v25; // rcx
unsigned int v26; // er14
char v27[296]; // [rsp+0h] [rbp-128h] BYREF

v0 = (const char *)gqp;
if ( gqp )
{
while ( 1 )
{
v2 = (const char *)label(v0 + 140);
sprintf(v27, "%s:\n", v2);
add_machine_code_x86(v27);
if ( !strcmp(v0, "begin_block") )
{
v3 = lookup(v0 + 35);
v4 = v3;
if ( !v3 )
_assert_fail("tmp != NULL", "cg_x86.c", 0xBBu, "generate_final_x86");
if ( *(_DWORD *)(v3 + 16) == 2 )
{
strcpy(&prog_name, *(const char **)v3);
strcpy(v27, "main:\n");
add_machine_code_x86(v27);
sprintf(v27, "\tmovl %%esp, %%ebp\n");
add_machine_code_x86(v27);
sprintf(v27, "\tsubl $%d, %%esp\n", *(unsigned int *)(cur_scope + 48LL));
}
else
{
sprintf(v27, "\tmovl %%ebp, %%esp\n");
}
add_machine_code_x86(v27);
ncur = *(_DWORD *)(v4 + 12);
goto LABEL_10;
}
if ( !strcmp(v0, "end_block") )
break;
if ( !strcmp(v0, "jump") )
{
v6 = label(v0 + 105);
sprintf(v27, "\tjmp %s\n", v6);
goto LABEL_20;
}
if ( !strcmp(v0, "print") )
{
load_x86("eax", v0 + 35);
sprintf(v27, "\tsubl $%d, %%esp\n", *(unsigned int *)(cur_scope + 48LL));
add_machine_code_x86(v27);
strcpy(v27, "\tcall print\n");
add_machine_code_x86(v27);
sprintf(v27, "\taddl $%d, %%esp\n", *(unsigned int *)(cur_scope + 48LL));
goto LABEL_20;
}
v1 = *(unsigned __int8 *)v0;
if ( v1 == 58 && v0[1] == 61 && !v0[2] )
{
load_x86("eax", v0 + 35);
store_x86("eax", (__int64)(v0 + 105));
}
else
{
v7 = *(unsigned __int8 *)v0;
if ( v7 == 43 && !v0[1] )
{
load_x86("eax", v0 + 35);
load_x86("edx", v0 + 70);
sprintf(v27, "\taddl %%edx, %%eax\n");
LABEL_24:
add_machine_code_x86(v27);
store_x86("eax", (__int64)(v0 + 105));
goto LABEL_10;
}
if ( v7 == 45 && !v0[1] )
{
load_x86("eax", v0 + 35);
load_x86("edx", v0 + 70);
sprintf(v27, "\tsubl %%edx, %%eax\n");
goto LABEL_24;
}
if ( v7 == 42 && !v0[1] )
{
load_x86("eax", v0 + 35);
load_x86("ecx", v0 + 70);
sprintf(v27, "\timul %%ecx\n");
goto LABEL_24;
}
if ( v7 == 47 && !v0[1] )
{
load_x86("eax", v0 + 35);
load_x86("ecx", v0 + 70);
sprintf(v27, "\tcltd\n\tidiv %%ecx\n");
goto LABEL_24;
}
if ( v7 == 61 && !v0[1]
|| v7 == 60 && !v0[1]
|| v7 == 62 && !v0[1]
|| v1 == 60 && v0[1] == 61 && !v0[2]
|| v1 == 62 && v0[1] == 61 && !v0[2]
|| v1 == 60 && v0[1] == 62 && !v0[2] )
{
load_x86("eax", v0 + 35);
load_x86("edx", v0 + 70);
sprintf(v27, "\tcmp %%edx, %%eax\n");
add_machine_code_x86(v27);
v8 = *(unsigned __int8 *)v0;
if ( v8 == 61 && !v0[1] )
{
v9 = (const char *)label(v0 + 105);
sprintf(v27, "\tje %s\n", v9);
add_machine_code_x86(v27);
v8 = *(unsigned __int8 *)v0;
}
if ( v8 == 60 && !v0[1] )
{
v10 = (const char *)label(v0 + 105);
sprintf(v27, "\tjl %s\n", v10);
add_machine_code_x86(v27);
v8 = *(unsigned __int8 *)v0;
}
if ( v8 == 62 && !v0[1] )
{
v11 = (const char *)label(v0 + 105);
sprintf(v27, "\tjg %s\n", v11);
add_machine_code_x86(v27);
}
v12 = *(unsigned __int8 *)v0;
if ( v12 == 60 && v0[1] == 61 && !v0[2] )
{
v13 = (const char *)label(v0 + 105);
sprintf(v27, "\tjle %s\n", v13);
add_machine_code_x86(v27);
v12 = *(unsigned __int8 *)v0;
}
if ( v12 == 62 && v0[1] == 61 && !v0[2] )
{
v14 = (const char *)label(v0 + 105);
sprintf(v27, "\tjge %s\n", v14);
add_machine_code_x86(v27);
v12 = *(unsigned __int8 *)v0;
}
if ( v12 != 60 || v0[1] != 62 || v0[2] )
goto LABEL_10;
v15 = label(v0 + 105);
sprintf(v27, "\tjne %s\n", v15);
goto LABEL_20;
}
if ( !strcmp(v0, "call") )
{
v17 = (_DWORD *)lookup(v0 + 105);
arguments -= v17[12];
if ( v17[3] == ncur )
{
sprintf(v27, "\tmovl -4(%%ebp), %%edx\n");
add_machine_code_x86(v27);
sprintf(v27, "\tmovl %%edx, -%d(%%ebp)\n", (unsigned int)(*(_DWORD *)(cur_scope + 48LL) + 4));
}
else
{
if ( v17[3] <= ncur )
{
LABEL_87:
sprintf(v27, "\tsubl $%d, %%ebp\n", *(unsigned int *)(cur_scope + 48LL));
add_machine_code_x86(v27);
sprintf(v27, "\tmovl %%ebp, %%esp\n");
add_machine_code_x86(v27);
sprintf(v27, "\tpopl %%eax\n");
add_machine_code_x86(v27);
sprintf(v27, "\tcall L%d\n", (unsigned int)v17[6]);
add_machine_code_x86(v27);
sprintf(v27, "\taddl $%d, %%ebp\n", *(unsigned int *)(cur_scope + 48LL));
add_machine_code_x86(v27);
sprintf(v27, "\tmovl %%ebp, %%esp\n");
add_machine_code_x86(v27);
goto LABEL_10;
}
sprintf(v27, "\tmovl %%ebp, -%d(%%ebp)\n", (unsigned int)(*(_DWORD *)(cur_scope + 48LL) + 4));
}
add_machine_code_x86(v27);
goto LABEL_87;
}
if ( !strcmp(v0, "par") )
{
v18 = lookup(v0 + 70);
v19 = v0[35] < 0x43u;
v20 = v0[35] == 67;
v21 = v0 + 35;
v22 = (unsigned int *)v18;
if ( v0[35] != 67
|| (v19 = v0[36] < 0x56u, v20 = v0[36] == 86, v0[36] != 86)
|| (v19 = 0, v20 = v0[37] == 0, v0[37]) )
{
v24 = "RET";
v25 = 4LL;
do
{
if ( !v25 )
break;
v19 = *v21 < (unsigned int)*v24;
v20 = *v21++ == *v24++;
--v25;
}
while ( v20 );
if ( (!v19 && !v20) == v19 )
{
sprintf(v27, "\tmovl %%ebp, %%edx\n");
add_machine_code_x86(v27);
sprintf(v27, "\taddl $-%d, %%edx\n", v22[2]);
add_machine_code_x86(v27);
sprintf(v27, "\tmovl %%edx, -%d(%%ebp)\n", (unsigned int)(*(_DWORD *)(cur_scope + 48LL) + 8));
goto LABEL_20;
}
v26 = *(_DWORD *)(cur_scope + 48LL) + 4 * arguments++ + 12;
if ( *(_DWORD *)(v18 + 12) == ncur )
{
if ( *(_DWORD *)(v18 + 92) != 4 || *(_DWORD *)(v18 + 56) != 1 )
{
sprintf(v27, "\tmovl %%ebp, %%edx\n");
add_machine_code_x86(v27);
sprintf(v27, "\taddl $-%d, %%edx\n", v22[2]);
add_machine_code_x86(v27);
sprintf(v27, "\tmovl %%edx, -%d(%%ebp)\n", v26);
goto LABEL_20;
}
sprintf(v27, "\tmovl %%ebp, %%edx\n");
add_machine_code_x86(v27);
sprintf(v27, "\taddl $-%d, %%edx\n", v22[2]);
add_machine_code_x86(v27);
sprintf(v27, "\tmovl (%%edx), %%eax\n");
}
else
{
gnlvcode(*(_QWORD *)v18, v21);
if ( v22[23] != 4 || v22[14] != 1 )
{
sprintf(v27, "\tmovl %%ebx, -%d(%%ebp)\n", v26);
goto LABEL_20;
}
sprintf(v27, "\tmovl (%%ebx), %%eax\n");
}
add_machine_code_x86(v27);
sprintf(v27, "\tmovl %%eax, -%d(%%ebp)\n", v26);
goto LABEL_20;
}
v23 = *(_DWORD *)(cur_scope + 48LL) + 4 * arguments++ + 12;
load_x86("edx", v0 + 70);
sprintf(v27, "\tmovl %%edx, -%d(%%ebp)\n\n", v23);
LABEL_20:
add_machine_code_x86(v27);
goto LABEL_10;
}
if ( !strcmp(v0, "halt") )
{
sprintf(v27, "\tmovl %%ebp, %%esp\n");
add_machine_code_x86(v27);
strcpy(v27, "\tret\n");
add_machine_code_x86(v27);
return;
}
if ( !strcmp(v0, "retv") )
{
v16 = v0 + 35;
if ( v0[35] == 95 && !v0[36] )
v16 = "0";
load_x86("eax", v16);
sprintf(v27, "\tmovl -8(%%ebp), %%edx\n");
add_machine_code_x86(v27);
sprintf(v27, "\tmovl %%eax, (%%edx)\n");
add_machine_code_x86(v27);
LABEL_18:
sprintf(v27, "\tmovl %%ebp, %%esp\n");
add_machine_code_x86(v27);
strcpy(v27, "\tret\n");
add_machine_code_x86(v27);
goto LABEL_10;
}
}
LABEL_10:
v0 = *(const char **)(gqp + 184LL);
gqp = v0;
if ( !v0 )
return;
}
fputc(10, stderr);
v5 = lookup(v0 + 35);
if ( !v5 )
_assert_fail("tmp != NULL", "cg_x86.c", 0xD3u, "generate_final_x86");
if ( *(_DWORD *)(v5 + 16) == 2 )
goto LABEL_10;
goto LABEL_18;
}
}

canonical_decompiled_code:
void func6()
{
const char *v0; // rbx
int v1; // edx
const char *v2; // rax
__int64 v3; // rax
__int64 v4; // rbx
__int64 v5; // rax
__int64 v6; // rdx
int v7; // eax
int v8; // eax
const char *v9; // rax
const char *v10; // rax
const char *v11; // rax
int v12; // edx
const char *v13; // rax
const char *v14; // rax
__int64 v15; // rdx
const char *v16; // rsi
_DWORD *v17; // rbx
__int64 v18; // rax
bool v19; // cf
bool v20; // zf
const char *v21; // rsi
unsigned int *v22; // r13
unsigned int v23; // er13
const char *v24; // rdi
__int64 v25; // rcx
unsigned int v26; // er14
char v27[296]; // [rsp+0h] [rbp-128h] BYREF

v0 = (const char *)gqp;
if ( gqp )
{
while ( 1 )
{
v2 = (const char *)label(v0 + 140);
sprintf(v27, "%s:\n", v2);
func2(v27);
if ( !strcmp(v0, "begin_block") )
{
v3 = lookup(v0 + 35);
v4 = v3;
if ( !v3 )
_assert_fail("tmp != NULL", "cg_x86.c", 0xBBu, "generate_final_x86");
if ( *(_DWORD *)(v3 + 16) == 2 )
{
strcpy(&prog_name, *(const char **)v3);
strcpy(v27, "main:\n");
func2(v27);
sprintf(v27, "\tmovl %%esp, %%ebp\n");
func2(v27);
sprintf(v27, "\tsubl $%d, %%esp\n", *(unsigned int *)(cur_scope + 48LL));
}
else
{
sprintf(v27, "\tmovl %%ebp, %%esp\n");
}
func2(v27);
ncur = *(_DWORD *)(v4 + 12);
goto LABEL_10;
}
if ( !strcmp(v0, "end_block") )
break;
if ( !strcmp(v0, "jump") )
{
v6 = label(v0 + 105);
sprintf(v27, "\tjmp %s\n", v6);
goto LABEL_20;
}
if ( !strcmp(v0, "print") )
{
func4("eax", v0 + 35);
sprintf(v27, "\tsubl $%d, %%esp\n", *(unsigned int *)(cur_scope + 48LL));
func2(v27);
strcpy(v27, "\tcall print\n");
func2(v27);
sprintf(v27, "\taddl $%d, %%esp\n", *(unsigned int *)(cur_scope + 48LL));
goto LABEL_20;
}
v1 = *(unsigned __int8 *)v0;
if ( v1 == 58 && v0[1] == 61 && !v0[2] )
{
func4("eax", v0 + 35);
func5("eax", (__int64)(v0 + 105));
}
else
{
v7 = *(unsigned __int8 *)v0;
if ( v7 == 43 && !v0[1] )
{
func4("eax", v0 + 35);
func4("edx", v0 + 70);
sprintf(v27, "\taddl %%edx, %%eax\n");
LABEL_24:
func2(v27);
func5("eax", (__int64)(v0 + 105));
goto LABEL_10;
}
if ( v7 == 45 && !v0[1] )
{
func4("eax", v0 + 35);
func4("edx", v0 + 70);
sprintf(v27, "\tsubl %%edx, %%eax\n");
goto LABEL_24;
}
if ( v7 == 42 && !v0[1] )
{
func4("eax", v0 + 35);
func4("ecx", v0 + 70);
sprintf(v27, "\timul %%ecx\n");
goto LABEL_24;
}
if ( v7 == 47 && !v0[1] )
{
func4("eax", v0 + 35);
func4("ecx", v0 + 70);
sprintf(v27, "\tcltd\n\tidiv %%ecx\n");
goto LABEL_24;
}
if ( v7 == 61 && !v0[1]
|| v7 == 60 && !v0[1]
|| v7 == 62 && !v0[1]
|| v1 == 60 && v0[1] == 61 && !v0[2]
|| v1 == 62 && v0[1] == 61 && !v0[2]
|| v1 == 60 && v0[1] == 62 && !v0[2] )
{
func4("eax", v0 + 35);
func4("edx", v0 + 70);
sprintf(v27, "\tcmp %%edx, %%eax\n");
func2(v27);
v8 = *(unsigned __int8 *)v0;
if ( v8 == 61 && !v0[1] )
{
v9 = (const char *)label(v0 + 105);
sprintf(v27, "\tje %s\n", v9);
func2(v27);
v8 = *(unsigned __int8 *)v0;
}
if ( v8 == 60 && !v0[1] )
{
v10 = (const char *)label(v0 + 105);
sprintf(v27, "\tjl %s\n", v10);
func2(v27);
v8 = *(unsigned __int8 *)v0;
}
if ( v8 == 62 && !v0[1] )
{
v11 = (const char *)label(v0 + 105);
sprintf(v27, "\tjg %s\n", v11);
func2(v27);
}
v12 = *(unsigned __int8 *)v0;
if ( v12 == 60 && v0[1] == 61 && !v0[2] )
{
v13 = (const char *)label(v0 + 105);
sprintf(v27, "\tjle %s\n", v13);
func2(v27);
v12 = *(unsigned __int8 *)v0;
}
if ( v12 == 62 && v0[1] == 61 && !v0[2] )
{
v14 = (const char *)label(v0 + 105);
sprintf(v27, "\tjge %s\n", v14);
func2(v27);
v12 = *(unsigned __int8 *)v0;
}
if ( v12 != 60 || v0[1] != 62 || v0[2] )
goto LABEL_10;
v15 = label(v0 + 105);
sprintf(v27, "\tjne %s\n", v15);
goto LABEL_20;
}
if ( !strcmp(v0, "call") )
{
v17 = (_DWORD *)lookup(v0 + 105);
arguments -= v17[12];
if ( v17[3] == ncur )
{
sprintf(v27, "\tmovl -4(%%ebp), %%edx\n");
func2(v27);
sprintf(v27, "\tmovl %%edx, -%d(%%ebp)\n", (unsigned int)(*(_DWORD *)(cur_scope + 48LL) + 4));
}
else
{
if ( v17[3] <= ncur )
{
LABEL_87:
sprintf(v27, "\tsubl $%d, %%ebp\n", *(unsigned int *)(cur_scope + 48LL));
func2(v27);
sprintf(v27, "\tmovl %%ebp, %%esp\n");
func2(v27);
sprintf(v27, "\tpopl %%eax\n");
func2(v27);
sprintf(v27, "\tcall L%d\n", (unsigned int)v17[6]);
func2(v27);
sprintf(v27, "\taddl $%d, %%ebp\n", *(unsigned int *)(cur_scope + 48LL));
func2(v27);
sprintf(v27, "\tmovl %%ebp, %%esp\n");
func2(v27);
goto LABEL_10;
}
sprintf(v27, "\tmovl %%ebp, -%d(%%ebp)\n", (unsigned int)(*(_DWORD *)(cur_scope + 48LL) + 4));
}
func2(v27);
goto LABEL_87;
}
if ( !strcmp(v0, "par") )
{
v18 = lookup(v0 + 70);
v19 = v0[35] < 0x43u;
v20 = v0[35] == 67;
v21 = v0 + 35;
v22 = (unsigned int *)v18;
if ( v0[35] != 67
|| (v19 = v0[36] < 0x56u, v20 = v0[36] == 86, v0[36] != 86)
|| (v19 = 0, v20 = v0[37] == 0, v0[37]) )
{
v24 = "RET";
v25 = 4LL;
do
{
if ( !v25 )
break;
v19 = *v21 < (unsigned int)*v24;
v20 = *v21++ == *v24++;
--v25;
}
while ( v20 );
if ( (!v19 && !v20) == v19 )
{
sprintf(v27, "\tmovl %%ebp, %%edx\n");
func2(v27);
sprintf(v27, "\taddl $-%d, %%edx\n", v22[2]);
func2(v27);
sprintf(v27, "\tmovl %%edx, -%d(%%ebp)\n", (unsigned int)(*(_DWORD *)(cur_scope + 48LL) + 8));
goto LABEL_20;
}
v26 = *(_DWORD *)(cur_scope + 48LL) + 4 * arguments++ + 12;
if ( *(_DWORD *)(v18 + 12) == ncur )
{
if ( *(_DWORD *)(v18 + 92) != 4 || *(_DWORD *)(v18 + 56) != 1 )
{
sprintf(v27, "\tmovl %%ebp, %%edx\n");
func2(v27);
sprintf(v27, "\taddl $-%d, %%edx\n", v22[2]);
func2(v27);
sprintf(v27, "\tmovl %%edx, -%d(%%ebp)\n", v26);
goto LABEL_20;
}
sprintf(v27, "\tmovl %%ebp, %%edx\n");
func2(v27);
sprintf(v27, "\taddl $-%d, %%edx\n", v22[2]);
func2(v27);
sprintf(v27, "\tmovl (%%edx), %%eax\n");
}
else
{
gnlvcode(*(_QWORD *)v18, v21);
if ( v22[23] != 4 || v22[14] != 1 )
{
sprintf(v27, "\tmovl %%ebx, -%d(%%ebp)\n", v26);
goto LABEL_20;
}
sprintf(v27, "\tmovl (%%ebx), %%eax\n");
}
func2(v27);
sprintf(v27, "\tmovl %%eax, -%d(%%ebp)\n", v26);
goto LABEL_20;
}
v23 = *(_DWORD *)(cur_scope + 48LL) + 4 * arguments++ + 12;
func4("edx", v0 + 70);
sprintf(v27, "\tmovl %%edx, -%d(%%ebp)\n\n", v23);
LABEL_20:
func2(v27);
goto LABEL_10;
}
if ( !strcmp(v0, "halt") )
{
sprintf(v27, "\tmovl %%ebp, %%esp\n");
func2(v27);
strcpy(v27, "\tret\n");
func2(v27);
return;
}
if ( !strcmp(v0, "retv") )
{
v16 = v0 + 35;
if ( v0[35] == 95 && !v0[36] )
v16 = "0";
func4("eax", v16);
sprintf(v27, "\tmovl -8(%%ebp), %%edx\n");
func2(v27);
sprintf(v27, "\tmovl %%eax, (%%edx)\n");
func2(v27);
LABEL_18:
sprintf(v27, "\tmovl %%ebp, %%esp\n");
func2(v27);
strcpy(v27, "\tret\n");
func2(v27);
goto LABEL_10;
}
}
LABEL_10:
v0 = *(const char **)(gqp + 184LL);
gqp = v0;
if ( !v0 )
return;
}
fputc(10, stderr);
v5 = lookup(v0 + 35);
if ( !v5 )
_assert_fail("tmp != NULL", "cg_x86.c", 0xD3u, "generate_final_x86");
if ( *(_DWORD *)(v5 + 16) == 2 )
goto LABEL_10;
goto LABEL_18;
}
}

original_code:
void generate_final_x86() {
 char s_tmp[255];
 while(gqp != ((void *)0)){
  struct quad* q = gqp;
  sprintf(s_tmp, "%s:\n", label(q->label));
  add_machine_code_x86( s_tmp );
  if (!strcmp(q->op,"begin_block")) {
   SYMBOL *tmp = lookup(q->x);
   ((void) sizeof ((tmp != ((void *)0)) ? 1 : 0), __extension__ ({ if (tmp != ((void *)0)) ; else __assert_fail ("tmp != NULL", "cg_x86.c", 187, __extension__ __PRETTY_FUNCTION__); }));
   if (tmp->func.type == PROG) {
    sprintf(prog_name, "%s", tmp->name);
    sprintf(s_tmp, "main:\n");
             add_machine_code_x86( s_tmp );
    sprintf(s_tmp, "\tmovl %%esp, %%ebp\n");
             add_machine_code_x86( s_tmp );
    sprintf(s_tmp, "\tsubl $%d, %%esp\n", cur_scope->framelength);
             add_machine_code_x86( s_tmp );
   } else {
    sprintf(s_tmp, "\tmovl %%ebp, %%esp\n");
             add_machine_code_x86( s_tmp );
   }
   ncur = tmp->level;
  } else if (!strcmp(q->op,"end_block")) {
   fprintf(stderr, "\n");
   SYMBOL *tmp = lookup(q->x);
   ((void) sizeof ((tmp != ((void *)0)) ? 1 : 0), __extension__ ({ if (tmp != ((void *)0)) ; else __assert_fail ("tmp != NULL", "cg_x86.c", 211, __extension__ __PRETTY_FUNCTION__); }));
   if (tmp->func.type != PROG) {
    sprintf(s_tmp, "\tmovl %%ebp, %%esp\n");
             add_machine_code_x86( s_tmp );
    sprintf(s_tmp, "\tret\n");
          add_machine_code_x86( s_tmp );
   }
  } else if ( strcmp( q->op, "jump") == 0){
            sprintf(s_tmp, "\tjmp %s\n", label(q->z) );
            add_machine_code_x86( s_tmp );
        } else if ( strcmp( q->op, "print") == 0){
   load_x86("eax", q->x);
   sprintf(s_tmp, "\tsubl $%d, %%esp\n", cur_scope->framelength);
            add_machine_code_x86( s_tmp );
   sprintf(s_tmp, "\tcall print\n");
   add_machine_code_x86( s_tmp );
   sprintf(s_tmp, "\taddl $%d, %%esp\n", cur_scope->framelength);
            add_machine_code_x86( s_tmp );
        } else if ( strcmp( q->op, ":=") == 0){
            load_x86("eax", q->x);
            store_x86("eax", q->z);
        } else if ( strcmp( q->op, "+") == 0){
            load_x86("eax", q->x);
            load_x86("edx", q->y);
            sprintf(s_tmp, "\taddl %%edx, %%eax\n" );
            add_machine_code_x86( s_tmp );
            store_x86("eax", q->z);
        } else if ( strcmp( q->op, "-") == 0){
            load_x86("eax", q->x);
            load_x86("edx", q->y);
            sprintf(s_tmp, "\tsubl %%edx, %%eax\n" );
            add_machine_code_x86( s_tmp );
            store_x86("eax", q->z);
        } else if ( strcmp( q->op, "*") == 0){
            load_x86("eax", q->x);
            load_x86("ecx", q->y);
            sprintf(s_tmp, "\timul %%ecx\n" );
            add_machine_code_x86( s_tmp );
            store_x86("eax", q->z);
        } else if ( strcmp( q->op, "/") == 0){
            load_x86("eax", q->x);
            load_x86("ecx", q->y);
            sprintf(s_tmp, "\tcltd\n\tidiv %%ecx\n" );
            add_machine_code_x86( s_tmp );
            store_x86("eax", q->z);
        } else if ( strcmp( q->op, "=") == 0 || strcmp( q->op, "<") == 0 || strcmp( q->op, ">") == 0 || strcmp( q->op, "<=") == 0 || strcmp( q->op, ">=") == 0 || strcmp( q->op, "<>") == 0 ){
            load_x86("eax", q->x);
            load_x86("edx", q->y);
            sprintf(s_tmp, "\tcmp %%edx, %%eax\n" );
            add_machine_code_x86( s_tmp );
            if ( strcmp( q->op, "=") == 0 ){
                sprintf(s_tmp, "\tje %s\n", label(q->z) );
                add_machine_code_x86( s_tmp );
            }
            if ( strcmp( q->op, "<") == 0 ){
                sprintf(s_tmp, "\tjl %s\n", label(q->z) );
                add_machine_code_x86( s_tmp );
            }
            if ( strcmp( q->op, ">") == 0 ){
                sprintf(s_tmp, "\tjg %s\n", label(q->z) );
                add_machine_code_x86( s_tmp );
            }
            if ( strcmp( q->op, "<=") == 0 ){
                sprintf(s_tmp, "\tjle %s\n", label(q->z) );
                add_machine_code_x86( s_tmp );
            }
            if ( strcmp( q->op, ">=") == 0 ){
                sprintf(s_tmp, "\tjge %s\n", label(q->z) );
                add_machine_code_x86( s_tmp );
            }
            if ( strcmp( q->op, "<>") == 0 ){
                sprintf(s_tmp, "\tjne %s\n", label(q->z) );
                add_machine_code_x86( s_tmp );
            }
        } else if ( strcmp( q->op, "call") == 0){
   SYMBOL *p = lookup( q->z );
   arguments -= p->func.num_arg;
   if ( p->level == ncur ) {
    sprintf(s_tmp, "\tmovl -4(%%ebp), %%edx\n");
             add_machine_code_x86( s_tmp );
    sprintf(s_tmp, "\tmovl %%edx, -%d(%%ebp)\n", cur_scope->framelength+4);
             add_machine_code_x86( s_tmp );
   } else if ( p->level > ncur ) {
    sprintf(s_tmp, "\tmovl %%ebp, -%d(%%ebp)\n", cur_scope->framelength+4);
             add_machine_code_x86( s_tmp );
   }
   sprintf(s_tmp, "\tsubl $%d, %%ebp\n", cur_scope->framelength);
            add_machine_code_x86( s_tmp );
   sprintf(s_tmp, "\tmovl %%ebp, %%esp\n");
            add_machine_code_x86( s_tmp );
   sprintf(s_tmp, "\tpopl %%eax\n");
            add_machine_code_x86( s_tmp );
   sprintf(s_tmp, "\tcall L%d\n", p->func.genquad);
   add_machine_code_x86( s_tmp );
   sprintf(s_tmp, "\taddl $%d, %%ebp\n", cur_scope->framelength );
            add_machine_code_x86( s_tmp );
   sprintf(s_tmp, "\tmovl %%ebp, %%esp\n");
            add_machine_code_x86( s_tmp );
        } else if ( strcmp( q->op, "par") == 0){
            SYMBOL *p = lookup( q->y );
            if ( !strcmp(q->x, "CV") ){
    int d = cur_scope->framelength + 12 + 4*arguments;
    arguments++;
                load_x86("edx", q->y);
    sprintf(s_tmp, "\tmovl %%edx, -%d(%%ebp)\n\n", d);
                add_machine_code_x86( s_tmp );
            } else if ( !strcmp(q->x, "RET") ){
    sprintf(s_tmp, "\tmovl %%ebp, %%edx\n");
             add_machine_code_x86( s_tmp );
    sprintf(s_tmp, "\taddl $-%d, %%edx\n", p->offset);
             add_machine_code_x86( s_tmp );
    sprintf(s_tmp, "\tmovl %%edx, -%d(%%ebp)\n", cur_scope->framelength+8);
             add_machine_code_x86( s_tmp );
            } else {
    int d = cur_scope->framelength + 12 + 4*arguments;
    arguments++;
    if ( ncur == p->level ) {
     if (p->type == TYPE_ARG && p->arg.type == INOUT ) {
      sprintf(s_tmp, "\tmovl %%ebp, %%edx\n");
               add_machine_code_x86( s_tmp );
      sprintf(s_tmp, "\taddl $-%d, %%edx\n", p->offset);
               add_machine_code_x86( s_tmp );
      sprintf(s_tmp, "\tmovl (%%edx), %%eax\n");
               add_machine_code_x86( s_tmp );
      sprintf(s_tmp, "\tmovl %%eax, -%d(%%ebp)\n", d);
               add_machine_code_x86( s_tmp );
     } else {
      sprintf(s_tmp, "\tmovl %%ebp, %%edx\n");
               add_machine_code_x86( s_tmp );
      sprintf(s_tmp, "\taddl $-%d, %%edx\n", p->offset);
      add_machine_code_x86( s_tmp );
      sprintf(s_tmp, "\tmovl %%edx, -%d(%%ebp)\n", d);
               add_machine_code_x86( s_tmp );
     }
    } else {
     gnlvcode(p->name);
     if (p->type == TYPE_ARG && p->arg.type == INOUT) {
      sprintf(s_tmp, "\tmovl (%%ebx), %%eax\n");
               add_machine_code_x86( s_tmp );
      sprintf(s_tmp, "\tmovl %%eax, -%d(%%ebp)\n", d);
               add_machine_code_x86( s_tmp );
     } else {
      sprintf(s_tmp, "\tmovl %%ebx, -%d(%%ebp)\n", d);
               add_machine_code_x86( s_tmp );
     }
    }
   }
        }else if ( strcmp( q->op, "halt") == 0){
   sprintf(s_tmp, "\tmovl %%ebp, %%esp\n");
            add_machine_code_x86( s_tmp );
   sprintf(s_tmp, "\tret\n");
   add_machine_code_x86( s_tmp );
   return;
  }else if ( strcmp( q->op, "retv") == 0){
            if( strcmp(q->x,"_") != 0 ){
                load_x86("eax", q->x);
            }else{
                load_x86("eax", "0");
            }
   sprintf(s_tmp, "\tmovl -8(%%ebp), %%edx\n");
            add_machine_code_x86( s_tmp );
            sprintf(s_tmp, "\tmovl %%eax, (%%edx)\n");
            add_machine_code_x86( s_tmp );
   sprintf(s_tmp, "\tmovl %%ebp, %%esp\n");
            add_machine_code_x86( s_tmp );
   sprintf(s_tmp, "\tret\n");
         add_machine_code_x86( s_tmp );
        }
  gqp = gqp->prev;
 }
}

canonical_original_code:
void generate_final_x86() {
 char s_tmp[255];
 while(gqp != ((void *)0)){
  struct quad *q = gqp;
  sprintf(s_tmp, "%s:\n", label(q->label));
  add_machine_code_x86( s_tmp );
  if (!strcmp(q->op,"begin_block")) {
   struct symbol *tmp = lookup(q->x);
   ((void) sizeof ((tmp != ((void *)0)) ? 1 : 0), __extension__ ({ if (tmp != ((void *)0)) ; else __assert_fail ("tmp != NULL", "cg_x86.c", 187, __extension__ __PRETTY_FUNCTION__); }));
   if (tmp->func.type == PROG) {
    sprintf(prog_name, "%s", tmp->name);
    sprintf(s_tmp, "main:\n");
             add_machine_code_x86( s_tmp );
    sprintf(s_tmp, "\tmovl %%esp, %%ebp\n");
             add_machine_code_x86( s_tmp );
    sprintf(s_tmp, "\tsubl $%d, %%esp\n", cur_scope->framelength);
             add_machine_code_x86( s_tmp );
   } else {
    sprintf(s_tmp, "\tmovl %%ebp, %%esp\n");
             add_machine_code_x86( s_tmp );
   }
   ncur = tmp->level;
  } else if (!strcmp(q->op,"end_block")) {
   fprintf(stderr, "\n");
   struct symbol *tmp = lookup(q->x);
   ((void) sizeof ((tmp != ((void *)0)) ? 1 : 0), __extension__ ({ if (tmp != ((void *)0)) ; else __assert_fail ("tmp != NULL", "cg_x86.c", 211, __extension__ __PRETTY_FUNCTION__); }));
   if (tmp->func.type != PROG) {
    sprintf(s_tmp, "\tmovl %%ebp, %%esp\n");
             add_machine_code_x86( s_tmp );
    sprintf(s_tmp, "\tret\n");
          add_machine_code_x86( s_tmp );
   }
  } else if ( strcmp( q->op, "jump") == 0){
            sprintf(s_tmp, "\tjmp %s\n", label(q->z) );
            add_machine_code_x86( s_tmp );
        } else if ( strcmp( q->op, "print") == 0){
   load_x86("eax", q->x);
   sprintf(s_tmp, "\tsubl $%d, %%esp\n", cur_scope->framelength);
            add_machine_code_x86( s_tmp );
   sprintf(s_tmp, "\tcall print\n");
   add_machine_code_x86( s_tmp );
   sprintf(s_tmp, "\taddl $%d, %%esp\n", cur_scope->framelength);
            add_machine_code_x86( s_tmp );
        } else if ( strcmp( q->op, ":=") == 0){
            load_x86("eax", q->x);
            store_x86("eax", q->z);
        } else if ( strcmp( q->op, "+") == 0){
            load_x86("eax", q->x);
            load_x86("edx", q->y);
            sprintf(s_tmp, "\taddl %%edx, %%eax\n" );
            add_machine_code_x86( s_tmp );
            store_x86("eax", q->z);
        } else if ( strcmp( q->op, "-") == 0){
            load_x86("eax", q->x);
            load_x86("edx", q->y);
            sprintf(s_tmp, "\tsubl %%edx, %%eax\n" );
            add_machine_code_x86( s_tmp );
            store_x86("eax", q->z);
        } else if ( strcmp( q->op, "*") == 0){
            load_x86("eax", q->x);
            load_x86("ecx", q->y);
            sprintf(s_tmp, "\timul %%ecx\n" );
            add_machine_code_x86( s_tmp );
            store_x86("eax", q->z);
        } else if ( strcmp( q->op, "/") == 0){
            load_x86("eax", q->x);
            load_x86("ecx", q->y);
            sprintf(s_tmp, "\tcltd\n\tidiv %%ecx\n" );
            add_machine_code_x86( s_tmp );
            store_x86("eax", q->z);
        } else if ( strcmp( q->op, "=") == 0 || strcmp( q->op, "<") == 0 || strcmp( q->op, ">") == 0 || strcmp( q->op, "<=") == 0 || strcmp( q->op, ">=") == 0 || strcmp( q->op, "<>") == 0 ){
            load_x86("eax", q->x);
            load_x86("edx", q->y);
            sprintf(s_tmp, "\tcmp %%edx, %%eax\n" );
            add_machine_code_x86( s_tmp );
            if ( strcmp( q->op, "=") == 0 ){
                sprintf(s_tmp, "\tje %s\n", label(q->z) );
                add_machine_code_x86( s_tmp );
            }
            if ( strcmp( q->op, "<") == 0 ){
                sprintf(s_tmp, "\tjl %s\n", label(q->z) );
                add_machine_code_x86( s_tmp );
            }
            if ( strcmp( q->op, ">") == 0 ){
                sprintf(s_tmp, "\tjg %s\n", label(q->z) );
                add_machine_code_x86( s_tmp );
            }
            if ( strcmp( q->op, "<=") == 0 ){
                sprintf(s_tmp, "\tjle %s\n", label(q->z) );
                add_machine_code_x86( s_tmp );
            }
            if ( strcmp( q->op, ">=") == 0 ){
                sprintf(s_tmp, "\tjge %s\n", label(q->z) );
                add_machine_code_x86( s_tmp );
            }
            if ( strcmp( q->op, "<>") == 0 ){
                sprintf(s_tmp, "\tjne %s\n", label(q->z) );
                add_machine_code_x86( s_tmp );
            }
        } else if ( strcmp( q->op, "call") == 0){
   struct symbol *p = lookup( q->z );
   arguments -= p->func.num_arg;
   if ( p->level == ncur ) {
    sprintf(s_tmp, "\tmovl -4(%%ebp), %%edx\n");
             add_machine_code_x86( s_tmp );
    sprintf(s_tmp, "\tmovl %%edx, -%d(%%ebp)\n", cur_scope->framelength+4);
             add_machine_code_x86( s_tmp );
   } else if ( p->level > ncur ) {
    sprintf(s_tmp, "\tmovl %%ebp, -%d(%%ebp)\n", cur_scope->framelength+4);
             add_machine_code_x86( s_tmp );
   }
   sprintf(s_tmp, "\tsubl $%d, %%ebp\n", cur_scope->framelength);
            add_machine_code_x86( s_tmp );
   sprintf(s_tmp, "\tmovl %%ebp, %%esp\n");
            add_machine_code_x86( s_tmp );
   sprintf(s_tmp, "\tpopl %%eax\n");
            add_machine_code_x86( s_tmp );
   sprintf(s_tmp, "\tcall L%d\n", p->func.genquad);
   add_machine_code_x86( s_tmp );
   sprintf(s_tmp, "\taddl $%d, %%ebp\n", cur_scope->framelength );
            add_machine_code_x86( s_tmp );
   sprintf(s_tmp, "\tmovl %%ebp, %%esp\n");
            add_machine_code_x86( s_tmp );
        } else if ( strcmp( q->op, "par") == 0){
            struct symbol *p = lookup( q->y );
            if ( !strcmp(q->x, "CV") ){
    int d = cur_scope->framelength + 12 + 4*arguments;
    arguments++;
                load_x86("edx", q->y);
    sprintf(s_tmp, "\tmovl %%edx, -%d(%%ebp)\n\n", d);
                add_machine_code_x86( s_tmp );
            } else if ( !strcmp(q->x, "RET") ){
    sprintf(s_tmp, "\tmovl %%ebp, %%edx\n");
             add_machine_code_x86( s_tmp );
    sprintf(s_tmp, "\taddl $-%d, %%edx\n", p->offset);
             add_machine_code_x86( s_tmp );
    sprintf(s_tmp, "\tmovl %%edx, -%d(%%ebp)\n", cur_scope->framelength+8);
             add_machine_code_x86( s_tmp );
            } else {
    int d = cur_scope->framelength + 12 + 4*arguments;
    arguments++;
    if ( ncur == p->level ) {
     if (p->type == TYPE_ARG && p->arg.type == INOUT ) {
      sprintf(s_tmp, "\tmovl %%ebp, %%edx\n");
               add_machine_code_x86( s_tmp );
      sprintf(s_tmp, "\taddl $-%d, %%edx\n", p->offset);
               add_machine_code_x86( s_tmp );
      sprintf(s_tmp, "\tmovl (%%edx), %%eax\n");
               add_machine_code_x86( s_tmp );
      sprintf(s_tmp, "\tmovl %%eax, -%d(%%ebp)\n", d);
               add_machine_code_x86( s_tmp );
     } else {
      sprintf(s_tmp, "\tmovl %%ebp, %%edx\n");
               add_machine_code_x86( s_tmp );
      sprintf(s_tmp, "\taddl $-%d, %%edx\n", p->offset);
      add_machine_code_x86( s_tmp );
      sprintf(s_tmp, "\tmovl %%edx, -%d(%%ebp)\n", d);
               add_machine_code_x86( s_tmp );
     }
    } else {
     gnlvcode(p->name);
     if (p->type == TYPE_ARG && p->arg.type == INOUT) {
      sprintf(s_tmp, "\tmovl (%%ebx), %%eax\n");
               add_machine_code_x86( s_tmp );
      sprintf(s_tmp, "\tmovl %%eax, -%d(%%ebp)\n", d);
               add_machine_code_x86( s_tmp );
     } else {
      sprintf(s_tmp, "\tmovl %%ebx, -%d(%%ebp)\n", d);
               add_machine_code_x86( s_tmp );
     }
    }
   }
        }else if ( strcmp( q->op, "halt") == 0){
   sprintf(s_tmp, "\tmovl %%ebp, %%esp\n");
            add_machine_code_x86( s_tmp );
   sprintf(s_tmp, "\tret\n");
   add_machine_code_x86( s_tmp );
   return;
  }else if ( strcmp( q->op, "retv") == 0){
            if( strcmp(q->x,"_") != 0 ){
                load_x86("eax", q->x);
            }else{
                load_x86("eax", "0");
            }
   sprintf(s_tmp, "\tmovl -8(%%ebp), %%edx\n");
            add_machine_code_x86( s_tmp );
            sprintf(s_tmp, "\tmovl %%eax, (%%edx)\n");
            add_machine_code_x86( s_tmp );
   sprintf(s_tmp, "\tmovl %%ebp, %%esp\n");
            add_machine_code_x86( s_tmp );
   sprintf(s_tmp, "\tret\n");
         add_machine_code_x86( s_tmp );
        }
  gqp = gqp->prev;
 }
}

variable_types: struct quad { char op[35]; char x[35]; char label[35]; struct quad *next; struct quad *prev; } *

variable_types: d int


decompiled_code:
__int64 pop_scope()
{
__int64 v0; // rax
__int64 result; // rax
__int64 v2; // rdx

--level;
v0 = *(_QWORD *)(cur_scope + 24);
if ( v0 && !*(_DWORD *)(v0 + 52) && !*(_DWORD *)(v0 + 16) )
{
fprintf(stderr, "line %d: function %s has no return stat.\n", line, *(const char **)v0);
exit(1);
}
result = *(_QWORD *)(cur_scope + 40);
if ( result )
{
v2 = *(_QWORD *)(result + 16);
*(_QWORD *)(result + 32) = 0LL;
for ( cur_scope = result; v2; v2 = *(_QWORD *)(v2 + 96) )
{
while ( 1 )
{
result = *(unsigned int *)(v2 + 92);
if ( !(_DWORD)result )
{
result = *(_QWORD *)(v2 + 40);
if ( result )
break;
}
v2 = *(_QWORD *)(v2 + 96);
if ( !v2 )
return result;
}
do
result = *(_QWORD *)(result + 64);
while ( result );
}
}
return result;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 v0; // rax
__int64 result; // rax
__int64 v2; // rdx

--level;
v0 = *(_QWORD *)(cur_scope + 24);
if ( v0 && !*(_DWORD *)(v0 + 52) && !*(_DWORD *)(v0 + 16) )
{
fprintf(stderr, "line %d: function %s has no return stat.\n", line, *(const char **)v0);
exit(1);
}
result = *(_QWORD *)(cur_scope + 40);
if ( result )
{
v2 = *(_QWORD *)(result + 16);
*(_QWORD *)(result + 32) = 0LL;
for ( cur_scope = result; v2; v2 = *(_QWORD *)(v2 + 96) )
{
while ( 1 )
{
result = *(unsigned int *)(v2 + 92);
if ( !(_DWORD)result )
{
result = *(_QWORD *)(v2 + 40);
if ( result )
break;
}
v2 = *(_QWORD *)(v2 + 96);
if ( !v2 )
return result;
}
do
result = *(_QWORD *)(result + 64);
while ( result );
}
}
return result;
}

original_code:
void pop_scope() {
 SYMBOL *cur, *arg;
 level--;
 if (cur_scope->from) {
  if(cur_scope->from->func.has_return == 0 && cur_scope->from->func.type == FUNC) {
   fprintf(stderr, "line %d: function %s has no return stat.\n", line, cur_scope->from->name);
   exit(1);
  }
 }
 if(cur_scope->prev != ((void *)0)) {
  cur_scope->prev->next = ((void *)0);
  cur_scope = cur_scope->prev;
  cur = cur_scope->symbols;
  while(cur != ((void *)0)) {
   if (cur->type == TYPE_FUNC) {
    arg = cur->func.first_arg;
    while(arg != ((void *)0)) {
     arg = arg->arg.next_arg;
    }
   }
   cur = cur->next;
  }
 }
}

canonical_original_code:
void pop_scope() {
 struct symbol *cur; struct symbol *arg;
 level--;
 if (cur_scope->from) {
  if(cur_scope->from->func.has_return == 0 && cur_scope->from->func.type == FUNC) {
   fprintf(stderr, "line %d: function %s has no return stat.\n", line, cur_scope->from->name);
   exit(1);
  }
 }
 if(cur_scope->prev != ((void *)0)) {
  cur_scope->prev->next = ((void *)0);
  cur_scope = cur_scope->prev;
  cur = cur_scope->symbols;
  while(cur != ((void *)0)) {
   if (cur->type == TYPE_FUNC) {
    arg = cur->func.first_arg;
    while(arg != ((void *)0)) {
     arg = arg->arg.next_arg;
    }
   }
   cur = cur->next;
  }
 }
}


decompiled_code:
size_t print_symbol_table()
{
__int64 i; // r12
__int64 j; // rbx
int v2; // eax
__int64 v3; // rdx
__int64 v4; // rbp

fwrite("-------------\n", 1uLL, 0xEuLL, stderr);
for ( i = global_scope; i; i = *(_QWORD *)(i + 32) )
{
fprintf(stderr, "%d: %s\n", *(unsigned int *)(i + 8), *(const char **)i);
for ( j = *(_QWORD *)(i + 16); j; j = *(_QWORD *)(j + 96) )
{
fprintf(stderr, "\t%s", *(const char **)j);
v2 = *(_DWORD *)(j + 92);
if ( v2 )
{
v3 = *(unsigned int *)(j + 8);
if ( v2 == 1 )
{
fprintf(stderr, "[V] offset %d", v3);
}
else if ( v2 == 4 )
{
fprintf(stderr, "[A] offset %d", v3);
}
else
{
fprintf(stderr, "[E] offset %d", v3);
}
}
else
{
v4 = *(_QWORD *)(j + 40);
fputc(40, stderr);
for ( ; v4; v4 = *(_QWORD *)(v4 + 64) )
fprintf(stderr, "%s ", *(const char **)v4);
fputc(41, stderr);
}
fputc(10, stderr);
}
fputc(10, stderr);
}
return fwrite("-------------\n", 1uLL, 0xEuLL, stderr);
}

canonical_decompiled_code:
size_t func1()
{
__int64 i; // r12
__int64 j; // rbx
int v2; // eax
__int64 v3; // rdx
__int64 v4; // rbp

fwrite("-------------\n", 1uLL, 0xEuLL, stderr);
for ( i = global_scope; i; i = *(_QWORD *)(i + 32) )
{
fprintf(stderr, "%d: %s\n", *(unsigned int *)(i + 8), *(const char **)i);
for ( j = *(_QWORD *)(i + 16); j; j = *(_QWORD *)(j + 96) )
{
fprintf(stderr, "\t%s", *(const char **)j);
v2 = *(_DWORD *)(j + 92);
if ( v2 )
{
v3 = *(unsigned int *)(j + 8);
if ( v2 == 1 )
{
fprintf(stderr, "[V] offset %d", v3);
}
else if ( v2 == 4 )
{
fprintf(stderr, "[A] offset %d", v3);
}
else
{
fprintf(stderr, "[E] offset %d", v3);
}
}
else
{
v4 = *(_QWORD *)(j + 40);
fputc(40, stderr);
for ( ; v4; v4 = *(_QWORD *)(v4 + 64) )
fprintf(stderr, "%s ", *(const char **)v4);
fputc(41, stderr);
}
fputc(10, stderr);
}
fputc(10, stderr);
}
return fwrite("-------------\n", 1uLL, 0xEuLL, stderr);
}

original_code:
void print_symbol_table() {
 SCOPE *cur;
 SYMBOL *sym, *arg;
 fprintf(stderr, "-------------\n");
 cur = global_scope;
 while (cur != ((void *)0)) {
  fprintf(stderr, "%d: %s\n", cur->level, cur->name);
  sym = cur->symbols;
  while (sym != ((void *)0)) {
   fprintf(stderr, "\t%s", sym->name);
   if (sym->type == TYPE_FUNC) {
    arg = sym->func.first_arg;
    fprintf(stderr, "(");
    while(arg != ((void *)0)) {
     fprintf(stderr, "%s ", arg->name);
     arg = arg->arg.next_arg;
    }
    fprintf(stderr, ")");
   } else if (sym->type == TYPE_VAR) {
    fprintf(stderr, "[V] offset %d", sym->offset);
   } else if (sym->type == TYPE_ARG) {
    fprintf(stderr, "[A] offset %d", sym->offset);
   } else {
    fprintf(stderr, "[E] offset %d", sym->offset);
   }
   fprintf(stderr, "\n");
   sym = sym->next;
  }
  fprintf(stderr, "\n");
  cur = cur->next;
 }
 fprintf(stderr, "-------------\n");
}

canonical_original_code:
void print_symbol_table() {
 struct scope *cur;
 struct symbol *sym; struct symbol *arg;
 fprintf(stderr, "-------------\n");
 cur = global_scope;
 while (cur != ((void *)0)) {
  fprintf(stderr, "%d: %s\n", cur->level, cur->name);
  sym = cur->symbols;
  while (sym != ((void *)0)) {
   fprintf(stderr, "\t%s", sym->name);
   if (sym->type == TYPE_FUNC) {
    arg = sym->func.first_arg;
    fprintf(stderr, "(");
    while(arg != ((void *)0)) {
     fprintf(stderr, "%s ", arg->name);
     arg = arg->arg.next_arg;
    }
    fprintf(stderr, ")");
   } else if (sym->type == TYPE_VAR) {
    fprintf(stderr, "[V] offset %d", sym->offset);
   } else if (sym->type == TYPE_ARG) {
    fprintf(stderr, "[A] offset %d", sym->offset);
   } else {
    fprintf(stderr, "[E] offset %d", sym->offset);
   }
   fprintf(stderr, "\n");
   sym = sym->next;
  }
  fprintf(stderr, "\n");
  cur = cur->next;
 }
 fprintf(stderr, "-------------\n");
}

variable_types: struct scope { char *name; int level; struct symbol { char *name; int offset; int level; struct function { enum FTYPE { FUNC=0, PROC=1, PROG=2 } type; int size; int genquad; struct symbol *args; struct symbol *first_arg; int num_arg; int has_return; } func; struct argument { enum PARTYPE { IN=0, INOUT=1 } type; struct symbol *next_arg; struct symbol *func; int offset; int num; } arg; struct variable { int offset; } var; enum T { TYPE_FUNC=0, TYPE_VAR=1, TYPE_CONST=2, TYPE_TMP=3, TYPE_ARG=4 } type; struct symbol *next; } *symbols; struct symbol *from; struct scope *next; struct scope *prev; int framelength; } *

user_defined_types: struct scope { char *name; int level; struct symbol *symbols; struct symbol *from; struct scope *next; struct scope *prev; int framelength; }


decompiled_code:
__int64 __fastcall install_symbol(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rdx

result = cur_scope;
if ( *(_DWORD *)(a1 + 92) )
{
*(_DWORD *)(a1 + 12) = *(_DWORD *)(cur_scope + 8);
}
else if ( *(_DWORD *)(a1 + 16) == 2 )
{
*(_DWORD *)(a1 + 12) = 1;
}
else
{
*(_DWORD *)(a1 + 12) = *(_DWORD *)(cur_scope + 8) + 1;
}
v2 = *(_QWORD *)(result + 16);
if ( v2 )
*(_QWORD *)(a1 + 96) = v2;
*(_QWORD *)(result + 16) = a1;
return result;
}

original_code:
void install_symbol(SYMBOL *sym) {
 if (sym->type == TYPE_FUNC && sym->func.type == PROG) {
  sym->level = 1;
 } else {
  if ( sym->type == TYPE_FUNC ) {
   sym->level = cur_scope->level+1;
  } else {
   sym->level = cur_scope->level;
  }
 }
 if(cur_scope->symbols == ((void *)0)) {
  cur_scope->symbols = sym;
 } else {
  sym->next = cur_scope->symbols;
  cur_scope->symbols = sym;
 }
}

canonical_original_code:
void install_symbol(struct symbol *sym) {
 if (sym->type == TYPE_FUNC && sym->func.type == PROG) {
  sym->level = 1;
 } else {
  if ( sym->type == TYPE_FUNC ) {
   sym->level = cur_scope->level+1;
  } else {
   sym->level = cur_scope->level;
  }
 }
 if(cur_scope->symbols == ((void *)0)) {
  cur_scope->symbols = sym;
 } else {
  sym->next = cur_scope->symbols;
  cur_scope->symbols = sym;
 }
}


original_code:
void add_argument(char *name, PARTYPE par) {
 SYMBOL *sym = (SYMBOL*)malloc(sizeof(SYMBOL));
 sym->offset = cur_scope->framelength;
 sym->type = TYPE_ARG;
 sym->name = strdup(name);
 sym->arg.type = par;
 sym->arg.num = ++cur_scope->prev->symbols->func.num_arg;
 sym->arg.next_arg = ((void *)0);
 sym->arg.func = cur_scope->prev->symbols;
 sym->level = cur_scope->level;
 cur_scope->framelength += 4;
 install_symbol(sym);
 if( cur_scope->prev->symbols->func.args == ((void *)0) ) {
  cur_scope->prev->symbols->func.first_arg = sym;
  cur_scope->prev->symbols->func.args = sym;
 } else {
  cur_scope->prev->symbols->func.args->arg.next_arg = sym;
  cur_scope->prev->symbols->func.args = sym;
 }
}

canonical_original_code:
void add_argument(char *name, enum PARTYPE par) {
 struct symbol *sym = (SYMBOL*)malloc(sizeof(SYMBOL));
 sym->offset = cur_scope->framelength;
 sym->type = TYPE_ARG;
 sym->name = strdup(name);
 sym->arg.type = par;
 sym->arg.num = ++cur_scope->prev->symbols->func.num_arg;
 sym->arg.next_arg = ((void *)0);
 sym->arg.func = cur_scope->prev->symbols;
 sym->level = cur_scope->level;
 cur_scope->framelength += 4;
 install_symbol(sym);
 if( cur_scope->prev->symbols->func.args == ((void *)0) ) {
  cur_scope->prev->symbols->func.first_arg = sym;
  cur_scope->prev->symbols->func.args = sym;
 } else {
  cur_scope->prev->symbols->func.args->arg.next_arg = sym;
  cur_scope->prev->symbols->func.args = sym;
 }
}

variable_types:
par
enum PARTYPE { IN=0, INOUT=1 }


lookup

decompiled_code:
__int64 __fastcall lookup(char *s2)
{
__int64 v1; // rbp
__int64 v2; // r12

v1 = cur_scope;
if ( !cur_scope )
return 0LL;
while ( 1 )
{
v2 = *(_QWORD *)(v1 + 16);
if ( v2 )
break;
LABEL_7:
v1 = *(_QWORD *)(v1 + 40);
if ( !v1 )
return 0LL;
}
while ( strcmp(*(const char **)v2, s2) )
{
v2 = *(_QWORD *)(v2 + 96);
if ( !v2 )
goto LABEL_7;
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func4(char *s2)
{
__int64 v1; // rbp
__int64 v2; // r12

v1 = cur_scope;
if ( !cur_scope )
return 0LL;
while ( 1 )
{
v2 = *(_QWORD *)(v1 + 16);
if ( v2 )
break;
LABEL_7:
v1 = *(_QWORD *)(v1 + 40);
if ( !v1 )
return 0LL;
}
while ( strcmp(*(const char **)v2, s2) )
{
v2 = *(_QWORD *)(v2 + 96);
if ( !v2 )
goto LABEL_7;
}
return v2;
}

original_code:
SYMBOL * lookup(char *name) {
 SCOPE *cur;
 SYMBOL *sym;
 cur = cur_scope;
 while (cur != ((void *)0)) {
  sym = cur->symbols;
  while (sym != ((void *)0)) {
   if(!strcmp(sym->name, name)) {
    return sym;
   }
   sym = sym->next;
  }
  cur = cur->prev;
 }
 return ((void *)0);
}

canonical_original_code:
struct symbol *lookup(char *name) {
 struct scope *cur;
 struct symbol *sym;
 cur = cur_scope;
 while (cur != ((void *)0)) {
  sym = cur->symbols;
  while (sym != ((void *)0)) {
   if(!strcmp(sym->name, name)) {
    return sym;
   }
   sym = sym->next;
  }
  cur = cur->prev;
 }
 return ((void *)0);
}

return_type: struct symbol { char *name; int offset; int level; struct function { enum FTYPE { FUNC=0, PROC=1, PROG=2 } type; int size; int genquad; struct symbol *args; struct symbol *first_arg; int num_arg; int has_return; } func; struct argument { enum PARTYPE { IN=0, INOUT=1 } type; struct symbol *next_arg; struct symbol *func; int offset; int num; } arg; struct variable { int offset; } var; enum T { TYPE_FUNC=0, TYPE_VAR=1, TYPE_CONST=2, TYPE_TMP=3, TYPE_ARG=4 } type; struct symbol *next; } *


decompiled_code:
__int64 __fastcall new_variable(char *s2, int a2)
{
void *v2; // rax
__int64 v3; // r13
__int64 v4; // rbp
__int64 v5; // rax
char *v6; // rax

v2 = malloc(0x68uLL);
v3 = cur_scope;
v4 = (__int64)v2;
LODWORD(v2) = *(_DWORD *)(cur_scope + 48);
*(_DWORD *)(v4 + 8) = (_DWORD)v2;
*(_DWORD *)(v3 + 48) = (_DWORD)v2 + 4;
v5 = lookup(s2);
if ( v5 && *(_DWORD *)(v5 + 12) == *(_DWORD *)(v3 + 8) )
{
if ( *(_DWORD *)(v5 + 92) != 4 )
{
fprintf(stderr, "error line %d: redecleration of %s in the same scope.\n", line, s2);
exit(1);
}
fprintf(stderr, "error line %d: redecleration of argument %s\n", line, s2);
exit(1);
}
*(_DWORD *)(v4 + 92) = 2 * (a2 == 1) + 1;
v6 = strdup(s2);
*(_QWORD *)(v4 + 96) = 0LL;
*(_QWORD *)v4 = v6;
return install_symbol(v4);
}

canonical_decompiled_code:
__int64 __fastcall func6(char *s2, int a2)
{
void *v2; // rax
__int64 v3; // r13
__int64 v4; // rbp
__int64 v5; // rax
char *v6; // rax

v2 = malloc(0x68uLL);
v3 = cur_scope;
v4 = (__int64)v2;
LODWORD(v2) = *(_DWORD *)(cur_scope + 48);
*(_DWORD *)(v4 + 8) = (_DWORD)v2;
*(_DWORD *)(v3 + 48) = (_DWORD)v2 + 4;
v5 = func4(s2);
if ( v5 && *(_DWORD *)(v5 + 12) == *(_DWORD *)(v3 + 8) )
{
if ( *(_DWORD *)(v5 + 92) != 4 )
{
fprintf(stderr, "error line %d: redecleration of %s in the same scope.\n", line, s2);
exit(1);
}
fprintf(stderr, "error line %d: redecleration of argument %s\n", line, s2);
exit(1);
}
*(_DWORD *)(v4 + 92) = 2 * (a2 == 1) + 1;
v6 = strdup(s2);
*(_QWORD *)(v4 + 96) = 0LL;
*(_QWORD *)v4 = v6;
return func2(v4);
}

original_code:
void new_variable(char *name, int istmp) {
 SYMBOL *t;
 SYMBOL *sym = (SYMBOL*)malloc(sizeof(SYMBOL));
 sym->offset = cur_scope->framelength;
 cur_scope->framelength += 4;
 t = lookup(name);
 if(t != ((void *)0)) {
  if(t->level == cur_scope->level) {
   if (t->type == TYPE_ARG) {
    fprintf(stderr, "error line %d: redecleration of argument %s\n", line, name);
    exit(1);
   } else {
    fprintf(stderr, "error line %d: redecleration of %s in the same scope.\n", line, name);
    exit(1);
   }
  }
 }
 if (istmp == 1) {
  sym->type = TYPE_TMP;
 } else {
  sym->type = TYPE_VAR;
 }
 sym->name = strdup(name);
 sym->next = ((void *)0);
 install_symbol(sym);
}

canonical_original_code:
void new_variable(char *name, int istmp) {
 struct symbol *t;
 struct symbol *sym = (SYMBOL*)malloc(sizeof(SYMBOL));
 sym->offset = cur_scope->framelength;
 cur_scope->framelength += 4;
 t = lookup(name);
 if(t != ((void *)0)) {
  if(t->level == cur_scope->level) {
   if (t->type == TYPE_ARG) {
    fprintf(stderr, "error line %d: redecleration of argument %s\n", line, name);
    exit(1);
   } else {
    fprintf(stderr, "error line %d: redecleration of %s in the same scope.\n", line, name);
    exit(1);
   }
  }
 }
 if (istmp == 1) {
  sym->type = TYPE_TMP;
 } else {
  sym->type = TYPE_VAR;
 }
 sym->name = strdup(name);
 sym->next = ((void *)0);
 install_symbol(sym);
}

variable_types: istmp int


decompiled_code:
__int64 __fastcall new_function(char *s2, int a2)
{
_DWORD *v2; // rbp
char *v3; // rax

v2 = malloc(0x68uLL);
if ( lookup(s2) )
{
fprintf(stderr, "error line %d: redecleration of %s\n", line, s2);
exit(1);
}
v2[23] = 0;
v3 = strdup(s2);
v2[4] = a2;
*(_QWORD *)v2 = v3;
*((_QWORD *)v2 + 6) = 0LL;
*((_QWORD *)v2 + 4) = 0LL;
*((_QWORD *)v2 + 12) = 0LL;
return install_symbol((__int64)v2);
}

canonical_decompiled_code:
__int64 __fastcall func7(char *s2, int a2)
{
_DWORD *v2; // rbp
char *v3; // rax

v2 = malloc(0x68uLL);
if ( func4(s2) )
{
fprintf(stderr, "error line %d: redecleration of %s\n", line, s2);
exit(1);
}
v2[23] = 0;
v3 = strdup(s2);
v2[4] = a2;
*(_QWORD *)v2 = v3;
*((_QWORD *)v2 + 6) = 0LL;
*((_QWORD *)v2 + 4) = 0LL;
*((_QWORD *)v2 + 12) = 0LL;
return func2((__int64)v2);
}

original_code:
void new_function(char *name, FTYPE type) {
 SYMBOL *t;
 SYMBOL *sym = (SYMBOL*)malloc(sizeof(SYMBOL));
 t = lookup(name);
 if(t != ((void *)0)) {
  fprintf(stderr, "error line %d: redecleration of %s\n", line, name);
  exit(1);
 }
 sym->type = TYPE_FUNC;
 sym->name = strdup(name);
 sym->func.type = type;
 sym->func.num_arg = 0;
 sym->func.has_return = 0;
 sym->func.args = ((void *)0);
 sym->next = ((void *)0);
 install_symbol(sym);
}

canonical_original_code:
void new_function(char *name, enum FTYPE type) {
 struct symbol *t;
 struct symbol *sym = (SYMBOL*)malloc(sizeof(SYMBOL));
 t = lookup(name);
 if(t != ((void *)0)) {
  fprintf(stderr, "error line %d: redecleration of %s\n", line, name);
  exit(1);
 }
 sym->type = TYPE_FUNC;
 sym->name = strdup(name);
 sym->func.type = type;
 sym->func.num_arg = 0;
 sym->func.has_return = 0;
 sym->func.args = ((void *)0);
 sym->next = ((void *)0);
 install_symbol(sym);
}

variable_types:
type
enum FTYPE { FUNC=0, PROC=1, PROG=2 }


decompiled_code:
__int64 __fastcall is_const(const char *a1)
{
unsigned int v1; // ebp
size_t v2; // r13

v1 = 0;
v2 = strlen(a1);
while ( 1 )
{
if ( v1 >= v2 )
return 1LL;
if ( ((*_ctype_b_loc())[a1[v1]] & 0x800) == 0 )
break;
++v1;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1)
{
unsigned int v1; // ebp
size_t v2; // r13

v1 = 0;
v2 = strlen(a1);
while ( 1 )
{
if ( v1 >= v2 )
return 1LL;
if ( ((*_ctype_b_loc())[a1[v1]] & 0x800) == 0 )
break;
++v1;
}
return 0LL;
}

original_code:
int is_const(char *s) {
 unsigned int i;
 for(i=0; i<strlen(s); i++) {
  if(!((*__ctype_b_loc ())[(int) ((s[i]))] & (unsigned short int) _ISdigit)) {
   return 0;
  }
 }
 return 1;
}

canonical_original_code:
int is_const(char *s) {
 unsigned int i;
 for(i=0; i<strlen(s); i++) {
  if(!((*__ctype_b_loc ())[(int) ((s[i]))] & (unsigned short) _ISdigit)) {
   return 0;
  }
 }
 return 1;
}

variable_types:
i
unsigned int

return_type: int


label

decompiled_code:
char *__fastcall label(const char *a1)
{
char v2[56]; // [rsp+0h] [rbp-38h] BYREF

sprintf(v2, "L%s", a1);
return strdup(v2);
}

canonical_decompiled_code:
char *__fastcall func1(const char *a1)
{
char v2[56]; // [rsp+0h] [rbp-38h] BYREF

sprintf(v2, "L%s", a1);
return strdup(v2);
}

original_code:
char * label( char *l ){
    char s[35];
    sprintf(s, "L%s", l);
    return strdup(s);
}

canonical_original_code:
char *label(char *l){
    char s[35];
    sprintf(s, "L%s", l);
    return strdup(s);
}


decompiled_code:
__int64 __fastcall add_machine_code(char *src)
{
char *v1; // rax
char *v2; // rdx
__int64 result; // rax

v1 = (char *)malloc(0x110uLL);
v2 = strcpy(v1, src);
result = mc;
if ( mc )
{
*(_QWORD *)(mc + 264) = v2;
mc = (__int64)v2;
*((_QWORD *)v2 + 32) = result;
}
else
{
*((_QWORD *)v2 + 32) = 0LL;
*((_QWORD *)v2 + 33) = 0LL;
mc = (__int64)v2;
mc_tail = v2;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(char *src)
{
char *v1; // rax
char *v2; // rdx
__int64 result; // rax

v1 = (char *)malloc(0x110uLL);
v2 = strcpy(v1, src);
result = mc;
if ( mc )
{
*(_QWORD *)(mc + 264) = v2;
mc = (__int64)v2;
*((_QWORD *)v2 + 32) = result;
}
else
{
*((_QWORD *)v2 + 32) = 0LL;
*((_QWORD *)v2 + 33) = 0LL;
mc = (__int64)v2;
mc_tail = v2;
}
return result;
}

original_code:
void add_machine_code( char *s ){
    struct code *tmp;
    tmp = (struct code*)malloc(sizeof(struct code));
    sprintf(tmp->cmd, "%s", s);
    if ( mc == ((void *)0) ){
        tmp->next = ((void *)0);
        tmp->prev = ((void *)0);
        mc = tmp;
        mc_tail = tmp;
    }else{
        mc->prev = tmp;
        tmp->next = mc;
        mc = tmp;
    }
}

canonical_original_code:
void add_machine_code(char *s){
    struct code *tmp;
    tmp = (struct code *)malloc(sizeof(struct code));
    sprintf(tmp->cmd, "%s", s);
    if ( mc == ((void *)0) ){
        tmp->next = ((void *)0);
        tmp->prev = ((void *)0);
        mc = tmp;
        mc_tail = tmp;
    }else{
        mc->prev = tmp;
        tmp->next = mc;
        mc = tmp;
    }
}

user_defined_types: struct code { char cmd[255]; struct code *next; struct code *prev; }


gnlvcode

decompiled_code:
__int64 gnlvcode()
{
__int64 v0; // r14
int i; // ebx
_OWORD v3[18]; // [rsp+0h] [rbp-128h] BYREF

v0 = lookup();
strcpy((char *)&v3[1], "R[0]+4]\n");
v3[0] = _mm_load_si128((const __m128i *)&LC6);
add_machine_code((char *)v3);
for ( i = *(_DWORD *)(v0 + 12); ncur - 1 > i; ++i )
{
strcpy((char *)v3, "\tmovi R[255], M[R[55]+4]\n");
add_machine_code((char *)v3);
}
sprintf((char *)v3, "\tmovi R[254], %d\n", *(unsigned int *)(v0 + 8));
add_machine_code((char *)v3);
strcpy((char *)&v3[1], "254], R[255]\n");
v3[0] = _mm_load_si128((const __m128i *)&LC7);
return add_machine_code((char *)v3);
}

original_code:
void gnlvcode(char *name) {
 char s_tmp[255];
 int i;
 SYMBOL *p = lookup(name);
 sprintf(s_tmp, "\tmovi R[255], M[R[0]+4]\n");
 add_machine_code( s_tmp );
 for(i=p->level; i<ncur-1; i++) {
  sprintf(s_tmp, "\tmovi R[255], M[R[55]+4]\n");
  add_machine_code( s_tmp );
 }
 sprintf(s_tmp, "\tmovi R[254], %d\n", p->offset);
 add_machine_code( s_tmp );
 sprintf(s_tmp, "\taddi R[255], R[254], R[255]\n");
 add_machine_code( s_tmp );
}

canonical_original_code:
void gnlvcode(char *name) {
 char s_tmp[255];
 int i;
 struct symbol *p = lookup(name);
 sprintf(s_tmp, "\tmovi R[255], M[R[0]+4]\n");
 add_machine_code( s_tmp );
 for(i=p->level; i<ncur-1; i++) {
  sprintf(s_tmp, "\tmovi R[255], M[R[55]+4]\n");
  add_machine_code( s_tmp );
 }
 sprintf(s_tmp, "\tmovi R[254], %d\n", p->offset);
 add_machine_code( s_tmp );
 sprintf(s_tmp, "\taddi R[255], R[254], R[255]\n");
 add_machine_code( s_tmp );
}

variable_types: i int


load

decompiled_code:
__int64 __fastcall load(const char *a1, const char *a2)
{
const unsigned __int16 **v2; // rax
__int64 v3; // rcx
__int64 v4; // rbp
__int64 result; // rax
int v6; // edx
__m128i v7; // [rsp+0h] [rbp-118h] BYREF
char v8[16]; // [rsp+10h] [rbp-108h] BYREF

v2 = _ctype_b_loc();
v3 = *a2;
if ( ((*v2)[v3] & 0x400) == 0 && (_BYTE)v3 != 36 )
{
sprintf(v7.m128i_i8, "\tmovi %s, %s\n", a1, a2);
return add_machine_code(v7.m128i_i8);
}
v4 = lookup(a2);
result = *(unsigned int *)(v4 + 12);
if ( (_DWORD)result != 1 )
{
v6 = ncur;
if ( (_DWORD)result != ncur )
goto LABEL_5;
if ( *(_DWORD *)(v4 + 92) == 4 && *(_DWORD *)(v4 + 56) == 1 )
{
sprintf(v7.m128i_i8, "\tmovi R[255], M[R[0]+%d]\n", *(unsigned int *)(v4 + 8));
add_machine_code(v7.m128i_i8);
LABEL_16:
sprintf(v7.m128i_i8, "\tmovi %s, M[R[255]]\n", a1);
return add_machine_code(v7.m128i_i8);
}
goto LABEL_10;
}
if ( *(_DWORD *)(v4 + 92) != 3 )
{
sprintf(v7.m128i_i8, "\tmovi %s, M[%d]\n", a1, (unsigned int)(*(_DWORD *)(v4 + 8) + 600));
return add_machine_code(v7.m128i_i8);
}
v6 = ncur;
if ( ncur == 1 )
{
LABEL_10:
sprintf(v7.m128i_i8, "\tmovi %s, M[R[0]+%d]\n", a1, *(unsigned int *)(v4 + 8));
return add_machine_code(v7.m128i_i8);
}
LABEL_5:
if ( (int)result < v6 )
{
gnlvcode(*(_QWORD *)v4);
if ( *(_DWORD *)(v4 + 92) == 4 && *(_DWORD *)(v4 + 56) == 1 )
{
strcpy(v8, "R[255]]\n");
v7 = _mm_load_si128((const __m128i *)&LC6);
add_machine_code(v7.m128i_i8);
}
goto LABEL_16;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(const char *a1, const char *a2)
{
const unsigned __int16 **v2; // rax
__int64 v3; // rcx
__int64 v4; // rbp
__int64 result; // rax
int v6; // edx
__m128i v7; // [rsp+0h] [rbp-118h] BYREF
char v8[16]; // [rsp+10h] [rbp-108h] BYREF

v2 = _ctype_b_loc();
v3 = *a2;
if ( ((*v2)[v3] & 0x400) == 0 && (_BYTE)v3 != 36 )
{
sprintf(v7.m128i_i8, "\tmovi %s, %s\n", a1, a2);
return func3(v7.m128i_i8);
}
v4 = lookup(a2);
result = *(unsigned int *)(v4 + 12);
if ( (_DWORD)result != 1 )
{
v6 = ncur;
if ( (_DWORD)result != ncur )
goto LABEL_5;
if ( *(_DWORD *)(v4 + 92) == 4 && *(_DWORD *)(v4 + 56) == 1 )
{
sprintf(v7.m128i_i8, "\tmovi R[255], M[R[0]+%d]\n", *(unsigned int *)(v4 + 8));
func3(v7.m128i_i8);
LABEL_16:
sprintf(v7.m128i_i8, "\tmovi %s, M[R[255]]\n", a1);
return func3(v7.m128i_i8);
}
goto LABEL_10;
}
if ( *(_DWORD *)(v4 + 92) != 3 )
{
sprintf(v7.m128i_i8, "\tmovi %s, M[%d]\n", a1, (unsigned int)(*(_DWORD *)(v4 + 8) + 600));
return func3(v7.m128i_i8);
}
v6 = ncur;
if ( ncur == 1 )
{
LABEL_10:
sprintf(v7.m128i_i8, "\tmovi %s, M[R[0]+%d]\n", a1, *(unsigned int *)(v4 + 8));
return func3(v7.m128i_i8);
}
LABEL_5:
if ( (int)result < v6 )
{
func4(*(_QWORD *)v4);
if ( *(_DWORD *)(v4 + 92) == 4 && *(_DWORD *)(v4 + 56) == 1 )
{
strcpy(v8, "R[255]]\n");
v7 = _mm_load_si128((const __m128i *)&LC6);
func3(v7.m128i_i8);
}
goto LABEL_16;
}
return result;
}

original_code:
void load( char *R, char *a ){
 char s_tmp[255];
    if ( !((*__ctype_b_loc ())[(int) ((*a))] & (unsigned short int) _ISalpha) && *a != '$' ){
        sprintf(s_tmp, "\tmovi %s, %s\n", R, a);
        add_machine_code( s_tmp );
    }else{
        SYMBOL *p = lookup(a);
  if (p->level == 1 && p->type != TYPE_TMP) {
   sprintf(s_tmp, "\tmovi %s, M[%d]\n", R, 600+p->offset);
         add_machine_code( s_tmp );
  } else {
   if (p->level == ncur) {
    if (p->type == TYPE_ARG && p->arg.type == INOUT) {
     sprintf(s_tmp, "\tmovi R[255], M[R[0]+%d]\n", p->offset);
           add_machine_code( s_tmp );
     sprintf(s_tmp, "\tmovi %s, M[R[255]]\n", R);
           add_machine_code( s_tmp );
    } else {
     sprintf(s_tmp, "\tmovi %s, M[R[0]+%d]\n", R, p->offset);
           add_machine_code( s_tmp );
    }
    return;
   }else if (p->level < ncur) {
    gnlvcode(p->name);
    if (p->type == TYPE_ARG && p->arg.type == INOUT) {
     sprintf(s_tmp, "\tmovi R[255], M[R[255]]\n");
           add_machine_code( s_tmp );
     sprintf(s_tmp, "\tmovi %s, M[R[255]]\n", R);
           add_machine_code( s_tmp );
    } else {
     sprintf(s_tmp, "\tmovi %s, M[R[255]]\n", R);
           add_machine_code( s_tmp );
    }
    return;
   }
  }
    }
}

canonical_original_code:
void load(char *R, char *a){
 char s_tmp[255];
    if ( !((*__ctype_b_loc ())[(int) ((*a))] & (unsigned short) _ISalpha) && *a != '$' ){
        sprintf(s_tmp, "\tmovi %s, %s\n", R, a);
        add_machine_code( s_tmp );
    }else{
        struct symbol *p = lookup(a);
  if (p->level == 1 && p->type != TYPE_TMP) {
   sprintf(s_tmp, "\tmovi %s, M[%d]\n", R, 600+p->offset);
         add_machine_code( s_tmp );
  } else {
   if (p->level == ncur) {
    if (p->type == TYPE_ARG && p->arg.type == INOUT) {
     sprintf(s_tmp, "\tmovi R[255], M[R[0]+%d]\n", p->offset);
           add_machine_code( s_tmp );
     sprintf(s_tmp, "\tmovi %s, M[R[255]]\n", R);
           add_machine_code( s_tmp );
    } else {
     sprintf(s_tmp, "\tmovi %s, M[R[0]+%d]\n", R, p->offset);
           add_machine_code( s_tmp );
    }
    return;
   }else if (p->level < ncur) {
    gnlvcode(p->name);
    if (p->type == TYPE_ARG && p->arg.type == INOUT) {
     sprintf(s_tmp, "\tmovi R[255], M[R[255]]\n");
           add_machine_code( s_tmp );
     sprintf(s_tmp, "\tmovi %s, M[R[255]]\n", R);
           add_machine_code( s_tmp );
    } else {
     sprintf(s_tmp, "\tmovi %s, M[R[255]]\n", R);
           add_machine_code( s_tmp );
    }
    return;
   }
  }
    }
}


store

decompiled_code:
__int64 __fastcall store(const char *a1, __int64 a2)
{
__int64 v2; // rbx
__int64 result; // rax
int v4; // eax
__m128i v5; // [rsp+0h] [rbp-118h] BYREF
char v6[16]; // [rsp+10h] [rbp-108h] BYREF

v2 = lookup(a2);
result = *(unsigned int *)(v2 + 12);
if ( (_DWORD)result == 1 )
{
if ( *(_DWORD *)(v2 + 92) != 3 )
{
sprintf(v5.m128i_i8, "\tmovi M[%d], %s\n", (unsigned int)(*(_DWORD *)(v2 + 8) + 600), a1);
return add_machine_code(v5.m128i_i8);
}
if ( ncur != 1 )
goto LABEL_8;
LABEL_17:
sprintf(v5.m128i_i8, "\tmovi M[R[0]+%d], %s\n", *(unsigned int *)(v2 + 8), a1);
return add_machine_code(v5.m128i_i8);
}
if ( (_DWORD)result == ncur )
{
if ( *(_DWORD *)(v2 + 92) == 4 && *(_DWORD *)(v2 + 56) == 1 )
{
sprintf(v5.m128i_i8, "\tmovi R[255], M[R[0]+%d]\n", *(unsigned int *)(v2 + 8));
add_machine_code(v5.m128i_i8);
LABEL_11:
sprintf(v5.m128i_i8, "\tmovi M[R[255]], %s\n", a1);
return add_machine_code(v5.m128i_i8);
}
goto LABEL_17;
}
if ( (int)result < ncur || *(_DWORD *)(v2 + 92) == 3 )
{
LABEL_8:
gnlvcode(*(_QWORD *)v2);
v4 = *(_DWORD *)(v2 + 92);
if ( v4 == 3 || v4 == 4 && *(_DWORD *)(v2 + 56) == 1 )
{
strcpy(v6, "R[255]]\n");
v5 = _mm_load_si128((const __m128i *)&LC6);
add_machine_code(v5.m128i_i8);
}
goto LABEL_11;
}
return result;
}

original_code:
void store( char *R, char *a ){
 char s_tmp[255];
 SYMBOL *p = lookup(a);
 if (p->level == 1 && p->type != TYPE_TMP) {
  sprintf(s_tmp, "\tmovi M[%d], %s\n", 600+p->offset, R);
        add_machine_code( s_tmp );
 } else {
  if (p->level == ncur) {
   if (p->type == TYPE_ARG && p->arg.type == INOUT) {
    sprintf(s_tmp, "\tmovi R[255], M[R[0]+%d]\n", p->offset);
          add_machine_code( s_tmp );
    sprintf(s_tmp, "\tmovi M[R[255]], %s\n", R);
          add_machine_code( s_tmp );
   } else {
    sprintf(s_tmp, "\tmovi M[R[0]+%d], %s\n", p->offset, R);
          add_machine_code( s_tmp );
   }
   return;
  }else if (p->level < ncur || p->type == TYPE_TMP) {
   gnlvcode(p->name);
   if ( p->type == TYPE_TMP || (p->type == TYPE_ARG && p->arg.type == INOUT)) {
    sprintf(s_tmp, "\tmovi R[255], M[R[255]]\n");
          add_machine_code( s_tmp );
    sprintf(s_tmp, "\tmovi M[R[255]], %s\n", R);
          add_machine_code( s_tmp );
   } else {
    sprintf(s_tmp, "\tmovi M[R[255]], %s\n", R);
          add_machine_code( s_tmp );
   }
   return;
  }
 }
}

canonical_original_code:
void store(char *R, char *a){
 char s_tmp[255];
 struct symbol *p = lookup(a);
 if (p->level == 1 && p->type != TYPE_TMP) {
  sprintf(s_tmp, "\tmovi M[%d], %s\n", 600+p->offset, R);
        add_machine_code( s_tmp );
 } else {
  if (p->level == ncur) {
   if (p->type == TYPE_ARG && p->arg.type == INOUT) {
    sprintf(s_tmp, "\tmovi R[255], M[R[0]+%d]\n", p->offset);
          add_machine_code( s_tmp );
    sprintf(s_tmp, "\tmovi M[R[255]], %s\n", R);
          add_machine_code( s_tmp );
   } else {
    sprintf(s_tmp, "\tmovi M[R[0]+%d], %s\n", p->offset, R);
          add_machine_code( s_tmp );
   }
   return;
  }else if (p->level < ncur || p->type == TYPE_TMP) {
   gnlvcode(p->name);
   if ( p->type == TYPE_TMP || (p->type == TYPE_ARG && p->arg.type == INOUT)) {
    sprintf(s_tmp, "\tmovi R[255], M[R[255]]\n");
          add_machine_code( s_tmp );
    sprintf(s_tmp, "\tmovi M[R[255]], %s\n", R);
          add_machine_code( s_tmp );
   } else {
    sprintf(s_tmp, "\tmovi M[R[255]], %s\n", R);
          add_machine_code( s_tmp );
   }
   return;
  }
 }
}