sgen

decompiled_code:
int __fastcall sgen(char *format, __int64 a2, __int64 a3)
{
fputc(9, stdout);
fprintf(stdout, format, a2, a3);
return fputc(10, stdout);
}

canonical_decompiled_code:
int __fastcall func23(char *format, __int64 a2, __int64 a3)
{
fputc(9, stdout);
fprintf(stdout, format, a2, a3);
return fputc(10, stdout);
}

original_code:
void sgen(char *s, char *inst, char *s2)
{
    fputc('\t', stdout);
    fprintf(stdout, s, inst, s2);
    fputc('\n', stdout);
}


repo: jezze/gaz

decompiled_code:
int __fastcall sgen2(char *format, __int64 a2, unsigned int a3, __int64 a4)
{
fputc(9, stdout);
fprintf(stdout, format, a2, a3, a4);
return fputc(10, stdout);
}

canonical_decompiled_code:
int __fastcall func24(char *format, __int64 a2, unsigned int a3, __int64 a4)
{
fputc(9, stdout);
fprintf(stdout, format, a2, a3, a4);
return fputc(10, stdout);
}

original_code:
void sgen2(char *s, char *inst, int v, char *s2)
{
    fputc('\t', stdout);
    fprintf(stdout, s, inst, v, s2);
    fputc('\n', stdout);
}

variable_types:
s
char *

variable_types:
inst
char *

variable_types: v int

return_type: void


genlab

decompiled_code:
int __fastcall genlab(unsigned int a1)
{
return fprintf(stdout, "%c%d:\n", 76LL, a1);
}

canonical_decompiled_code:
int __fastcall func25(unsigned int a1)
{
return fprintf(stdout, "%c%d:\n", 76LL, a1);
}

original_code:
void genlab(int id)
{
    fprintf(stdout, "%c%d:\n", 'L', id);
}

variable_types: id int


putback

decompiled_code:
void __fastcall putback(int a1)
{
Putback = a1;
}

canonical_decompiled_code:
void __fastcall func0(int a1)
{
Putback = a1;
}

original_code:
static void putback(int c)
{
    Putback = c;
}

variable_types: c int


next

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

result = Putback;
if ( Putback )
{
Putback = 0;
}
else
{
result = fgetc(stdin);
if ( result == 10 )
++Line;
}
return result;
}

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

result = Putback;
if ( Putback )
{
Putback = 0;
}
else
{
result = fgetc(stdin);
if ( result == 10 )
++Line;
}
return result;
}

original_code:
int next(void)
{
    int c;
    if (Putback)
    {
        c = Putback;
        Putback = 0;
        return c;
    }
    c = fgetc(stdin);
    if ('\n' == c)
        Line++;
    return c;
}

canonical_original_code:
int next()
{
    int c;
    if (Putback)
    {
        c = Putback;
        Putback = 0;
        return c;
    }
    c = fgetc(stdin);
    if ('\n' == c)
        Line++;
    return c;
}

return_type: int


skip

decompiled_code:
__int64 skip()
{
unsigned __int64 v0; // rbx
__int64 v1; // rbp
int v2; // eax
int v3; // eax
int v4; // ebx

v0 = (unsigned int)next();
v1 = 0x100003600LL;
LABEL_14:
if ( (_DWORD)v0 == -1 )
goto LABEL_15;
while ( (unsigned int)v0 <= 0x20 )
{
if ( !_bittest64(&v1, v0) )
return (unsigned int)v0;
v0 = (unsigned int)next();
}
if ( (_DWORD)v0 == 47 )
{
v2 = next();
if ( v2 == 42 )
{
v3 = 0;
while ( 1 )
{
v4 = v3;
v3 = next();
if ( v3 == -1 )
break;
if ( v3 == 47 && v4 == 42 )
{
v0 = (unsigned int)next();
goto LABEL_14;
}
}
LABEL_15:
strcpy(Text, "<EOF>");
LODWORD(v0) = -1;
return (unsigned int)v0;
}
putback(v2);
}
return (unsigned int)v0;
}

canonical_decompiled_code:
__int64 func4()
{
unsigned __int64 v0; // rbx
__int64 v1; // rbp
int v2; // eax
int v3; // eax
int v4; // ebx

v0 = (unsigned int)func3();
v1 = 0x100003600LL;
LABEL_14:
if ( (_DWORD)v0 == -1 )
goto LABEL_15;
while ( (unsigned int)v0 <= 0x20 )
{
if ( !_bittest64(&v1, v0) )
return (unsigned int)v0;
v0 = (unsigned int)func3();
}
if ( (_DWORD)v0 == 47 )
{
v2 = func3();
if ( v2 == 42 )
{
v3 = 0;
while ( 1 )
{
v4 = v3;
v3 = func3();
if ( v3 == -1 )
break;
if ( v3 == 47 && v4 == 42 )
{
v0 = (unsigned int)func3();
goto LABEL_14;
}
}
LABEL_15:
strcpy(Text, "<EOF>");
LODWORD(v0) = -1;
return (unsigned int)v0;
}
func0(v2);
}
return (unsigned int)v0;
}

variable_types: nl int

variable_types: p int


hexchar

decompiled_code:
__int64 hexchar()
{
int v0; // er13
int v1; // ebp
int v2; // eax
int v3; // ebx
const char *v4; // rdx

v0 = 0;
v1 = 0;
while ( 1 )
{
v3 = next();
if ( !isxdigit(v3) )
break;
v2 = tolower(v3);
v1 = chrpos("0123456789abcdef", v2) + 16 * v1;
v0 = 1;
}
putback(v3);
if ( !v0 )
error((int)"missing digits after '\\x'", 0, v4);
if ( v1 > 255 )
error((int)"value out of range after '\\x'", 0, v4);
return (unsigned int)v1;
}

canonical_decompiled_code:
__int64 func5()
{
int v0; // er13
int v1; // ebp
int v2; // eax
int v3; // ebx
const char *v4; // rdx

v0 = 0;
v1 = 0;
while ( 1 )
{
v3 = func3();
if ( !isxdigit(v3) )
break;
v2 = tolower(v3);
v1 = func1("0123456789abcdef", v2) + 16 * v1;
v0 = 1;
}
func0(v3);
if ( !v0 )
error((int)"missing digits after '\\x'", 0, v4);
if ( v1 > 255 )
error((int)"value out of range after '\\x'", 0, v4);
return (unsigned int)v1;
}

original_code:
static int hexchar(void)
{
    int c, h, n = 0, f = 0;
    while (isxdigit(c = next()))
    {
        h = chrpos("0123456789abcdef", tolower(c));
        n = n * 16 + h;
        f = 1;
    }
    putback(c);
    if (!f)
        error("missing digits after '\\x'", ((void *)0));
    if (n > 255)
        error("value out of range after '\\x'", ((void *)0));
    return n;
}

canonical_original_code:
static int hexchar()
{
    int c; int h; int n = 0; int f = 0;
    while (isxdigit(c = next()))
    {
        h = chrpos("0123456789abcdef", tolower(c));
        n = n * 16 + h;
        f = 1;
    }
    putback(c);
    if (!f)
        error("missing digits after '\\x'", ((void *)0));
    if (n > 255)
        error("value out of range after '\\x'", ((void *)0));
    return n;
}

variable_types: h int

variable_types: n int

variable_types: f int


scanch

decompiled_code:
unsigned int scanch()
{
unsigned int result; // eax
int i; // ebx

result = next();
if ( result == 92 )
{
result = next();
switch ( result )
{
case '"':
result = 290;
break;
case '\'':
case '\\':
return result;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
for ( i = 0; result - 48 <= 7; result = next() )
i = result + 8 * i - 48;
putback(result);
result = i;
break;
case 'a':
result = 7;
break;
case 'b':
result = 8;
break;
case 'f':
result = 12;
break;
case 'n':
result = 10;
break;
case 'r':
result = 13;
break;
case 't':
result = 9;
break;
case 'v':
result = 11;
break;
case 'x':
result = hexchar();
break;
default:
cerror("unknown escape sequence: %s", (const char *)result);
result = 32;
break;
}
}
return result;
}

canonical_decompiled_code:
unsigned int func6()
{
unsigned int result; // eax
int i; // ebx

result = func3();
if ( result == 92 )
{
result = func3();
switch ( result )
{
case '"':
result = 290;
break;
case '\'':
case '\\':
return result;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
for ( i = 0; result - 48 <= 7; result = func3() )
i = result + 8 * i - 48;
func0(result);
result = i;
break;
case 'a':
result = 7;
break;
case 'b':
result = 8;
break;
case 'f':
result = 12;
break;
case 'n':
result = 10;
break;
case 'r':
result = 13;
break;
case 't':
result = 9;
break;
case 'v':
result = 11;
break;
case 'x':
result = func5();
break;
default:
cerror("unknown escape sequence: %s", (const char *)result);
result = 32;
break;
}
}
return result;
}

original_code:
static int scanch(void)
{
    int c = next();
    int c2;
    if ('\\' == c)
    {
        switch (c = next())
        {
        case 'a':
            return '\a';
        case 'b':
            return '\b';
        case 'f':
            return '\f';
        case 'n':
            return '\n';
        case 'r':
            return '\r';
        case 't':
            return '\t';
        case 'v':
            return '\v';
        case '\\':
            return '\\';
        case '"':
            return '"' | 256;
        case '\'':
            return '\'';
        case '0':
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
            for (c2 = 0; isdigit(c) && c < '8'; c = next())
                c2 = c2 * 8 + (c - '0');
            putback(c);
            return c2;
        case 'x':
            return hexchar();
        default:
            cerror("unknown escape sequence: %s", c);
            return ' ';
        }
    }
    return c;
}

canonical_original_code:
static int scanch()
{
    int c = next();
    int c2;
    if ('\\' == c)
    {
        switch (c = next())
        {
        case 'a':
            return '\a';
        case 'b':
            return '\b';
        case 'f':
            return '\f';
        case 'n':
            return '\n';
        case 'r':
            return '\r';
        case 't':
            return '\t';
        case 'v':
            return '\v';
        case '\\':
            return '\\';
        case '"':
            return '"' | 256;
        case '\'':
            return '\'';
        case '0':
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
            for (c2 = 0; isdigit(c) && c < '8'; c = next())
                c2 = c2 * 8 + (c - '0');
            putback(c);
            return c2;
        case 'x':
            return hexchar();
        default:
            cerror("unknown escape sequence: %s", c);
            return ' ';
        }
    }
    return c;
}


scanint

decompiled_code:
__int64 __fastcall scanint(int c)
{
unsigned int v1; // ebp
__int64 v2; // r12
int v3; // er14
unsigned int v4; // er13
int v5; // eax
int v6; // ebx

v1 = c;
LODWORD(v2) = 0;
v3 = 10;
if ( c == 48 )
{
Text[0] = 48;
v1 = next();
LODWORD(v2) = 1;
v3 = 8;
if ( v1 == 120 )
{
Text[1] = 120;
v1 = next();
LODWORD(v2) = 2;
v3 = 16;
}
}
v2 = (int)v2;
v4 = 0;
while ( 1 )
{
v5 = tolower(v1);
v6 = chrpos("0123456789abcdef", v5);
if ( v6 < 0 )
break;
Text[v2] = v1;
if ( v6 >= v3 )
cerror("invalid digit in integer literal: %s", (const char *)v1);
v4 = v6 + v3 * v4;
v1 = next();
++v2;
}
putback(v1);
Text[(int)v2] = 0;
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func8(int c)
{
unsigned int v1; // ebp
__int64 v2; // r12
int v3; // er14
unsigned int v4; // er13
int v5; // eax
int v6; // ebx

v1 = c;
LODWORD(v2) = 0;
v3 = 10;
if ( c == 48 )
{
Text[0] = 48;
v1 = func3();
LODWORD(v2) = 1;
v3 = 8;
if ( v1 == 120 )
{
Text[1] = 120;
v1 = func3();
LODWORD(v2) = 2;
v3 = 16;
}
}
v2 = (int)v2;
v4 = 0;
while ( 1 )
{
v5 = tolower(v1);
v6 = func1("0123456789abcdef", v5);
if ( v6 < 0 )
break;
Text[v2] = v1;
if ( v6 >= v3 )
cerror("invalid digit in integer literal: %s", (const char *)v1);
v4 = v6 + v3 * v4;
v1 = func3();
++v2;
}
func0(v1);
Text[(int)v2] = 0;
return v4;
}

original_code:
static int scanint(int c)
{
    int val = 0;
    int radix = 10;
    int k, i = 0;
    if ('0' == c)
    {
        Text[i++] = '0';
        if ((c = next()) == 'x')
        {
            radix = 16;
            Text[i++] = c;
            c = next();
        }
        else
        {
            radix = 8;
        }
    }
    while ((k = chrpos("0123456789abcdef", tolower(c))) >= 0)
    {
        Text[i++] = c;
        if (k >= radix)
            cerror("invalid digit in integer literal: %s", c);
        val = val * radix + k;
        c = next();
    }
    putback(c);
    Text[i] = 0;
    return val;
}

canonical_original_code:
static int scanint(int c)
{
    int val = 0;
    int radix = 10;
    int k; int i = 0;
    if ('0' == c)
    {
        Text[i++] = '0';
        if ((c = next()) == 'x')
        {
            radix = 16;
            Text[i++] = c;
            c = next();
        }
        else
        {
            radix = 8;
        }
    }
    while ((k = chrpos("0123456789abcdef", tolower(c))) >= 0)
    {
        Text[i++] = c;
        if (k >= radix)
            cerror("invalid digit in integer literal: %s", c);
        val = val * radix + k;
        c = next();
    }
    putback(c);
    Text[i] = 0;
    return val;
}

variable_types: val int

variable_types: radix int

variable_types: k int

variable_types: i int


scanident

decompiled_code:
__int64 __fastcall scanident(int a1, __int64 a2, int a3)
{
unsigned int v4; // ebp
int v5; // er12
const char *v6; // rdx

v4 = 0;
v5 = a3 - 1;
while ( isalpha(a1) || (unsigned int)(a1 - 48) <= 9 || a1 == 95 )
{
if ( v5 == v4 )
{
error((int)"identifier too long", 0, v6);
++v4;
}
else if ( v5 > (int)v4 )
{
*(_BYTE *)(a2 + (int)v4++) = a1;
}
a1 = next();
}
putback(a1);
*(_BYTE *)(a2 + (int)v4) = 0;
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func9(int a1, __int64 a2, int a3)
{
unsigned int v4; // ebp
int v5; // er12
const char *v6; // rdx

v4 = 0;
v5 = a3 - 1;
while ( isalpha(a1) || (unsigned int)(a1 - 48) <= 9 || a1 == 95 )
{
if ( v5 == v4 )
{
error((int)"identifier too long", 0, v6);
++v4;
}
else if ( v5 > (int)v4 )
{
*(_BYTE *)(a2 + (int)v4++) = a1;
}
a1 = func3();
}
func0(a1);
*(_BYTE *)(a2 + (int)v4) = 0;
return v4;
}

original_code:
static int scanident(int c, char *buf, int lim)
{
    int i = 0;
    while (isalpha(c) || isdigit(c) || '_' == c)
    {
        if (lim - 1 == i)
        {
            error("identifier too long", ((void *)0));
            i++;
        }
        else if (i < lim - 1)
        {
            buf[i++] = c;
        }
        c = next();
    }
    putback(c);
    buf[i] = 0;
    return i;
}

variable_types:
buf
char *

variable_types: lim int


scanpp

decompiled_code:
__int64 scanpp()
{
unsigned int v0; // ebx
unsigned int v1; // ebx
int v3; // eax
int v4; // eax
int v5; // eax
int v6; // eax
int v7; // eax
int v8; // eax
int v9; // eax
int v10; // eax
int v11; // eax
int v12; // eax
int v13; // eax
int v14; // eax
int v15; // eax
int v16; // eax
const char *v17; // rdx
int v18; // eax
const char *v19; // rdx
int v20; // eax
int v21; // eax
const char *v22; // rdx
int v23; // eax

v0 = Rejected;
if ( Rejected == -1 )
{
while ( 2 )
{
Value = 0;
v1 = skip();
*(_WORD *)&Text[1] = 0;
Text[3] = 0;
Text[0] = v1;
switch ( v1 )
{
case 0xFFFFFFFF:
strcpy(Text, "<EOF>");
v0 = 71;
break;
case 0x21u:
v3 = next();
if ( v3 == 61 )
{
Text[1] = 61;
v0 = 12;
}
else
{
putback(v3);
v0 = 72;
}
break;
case 0x22u:
Value = scanstr(Text);
v0 = 64;
break;
case 0x23u:
v18 = next();
scanident(v18, (unsigned int)((_DWORD)Text + 1), 511);
v0 = keyword(Text);
if ( !v0 )
{
error((int)"unknown preprocessor command: %s", (int)Text, v19);
v0 = 46;
}
break;
case 0x25u:
v4 = next();
if ( v4 == 61 )
{
Text[1] = 61;
v0 = 23;
}
else
{
putback(v4);
v0 = 2;
}
break;
case 0x26u:
v5 = next();
if ( v5 == 38 )
{
Text[1] = 38;
v0 = 16;
}
else if ( v5 == 61 )
{
Text[1] = 61;
v0 = 19;
}
else
{
putback(v5);
v0 = 13;
}
break;
case 0x27u:
Value = scanch();
Text[1] = Value;
if ( next() != 39 )
error((int)"expected '\\'' at end of char literal", 0, v17);
Text[2] = 39;
v0 = 50;
break;
case 0x28u:
v0 = 53;
break;
case 0x29u:
v0 = 60;
break;
case 0x2Au:
v6 = next();
if ( v6 == 61 )
{
Text[1] = 61;
v0 = 28;
}
else
{
putback(v6);
v0 = 1;
}
break;
case 0x2Bu:
v7 = next();
if ( v7 == 43 )
{
Text[1] = 43;
v0 = 48;
}
else if ( v7 == 61 )
{
Text[1] = 61;
v0 = 25;
}
else
{
putback(v7);
v0 = 3;
}
break;
case 0x2Cu:
v0 = 35;
break;
case 0x2Du:
v8 = next();
switch ( v8 )
{
case '-':
Text[1] = 45;
v0 = 37;
break;
case '=':
Text[1] = 61;
v0 = 22;
break;
case '>':
Text[1] = 62;
v0 = 18;
break;
default:
putback(v8);
v0 = 4;
break;
}
break;
case 0x2Eu:
v20 = next();
if ( v20 == 46 )
{
Text[2] = 46;
Text[1] = 46;
Text[3] = 0;
v21 = next();
v0 = 41;
if ( v21 != 46 )
{
putback(v21);
error((int)"incomplete '...'", 0, v22);
}
}
else
{
putback(v20);
v0 = 40;
}
break;
case 0x2Fu:
v9 = next();
if ( v9 == 61 )
{
Text[1] = 61;
v0 = 27;
}
else
{
putback(v9);
v0 = 0;
}
break;
case 0x3Au:
v0 = 34;
break;
case 0x3Bu:
v0 = 61;
break;
case 0x3Cu:
v10 = next();
if ( v10 == 60 )
{
Text[1] = 60;
v11 = next();
if ( v11 == 61 )
{
Text[2] = 61;
v0 = 21;
}
else
{
putback(v11);
v0 = 5;
}
}
else if ( v10 == 61 )
{
Text[1] = 61;
v0 = 10;
}
else
{
putback(v10);
v0 = 9;
}
break;
case 0x3Du:
v12 = next();
if ( v12 == 61 )
{
Text[1] = 61;
v0 = 11;
}
else
{
putback(v12);
v0 = 29;
}
break;
case 0x3Eu:
v13 = next();
if ( v13 == 62 )
{
Text[1] = 62;
v14 = next();
if ( v14 == 61 )
{
Text[1] = 61;
v0 = 26;
}
else
{
putback(v14);
v0 = 6;
}
}
else if ( v13 == 61 )
{
Text[1] = 61;
v0 = 8;
}
else
{
putback(v13);
v0 = 7;
}
break;
case 0x3Fu:
v0 = 55;
break;
case 0x5Bu:
v0 = 52;
break;
case 0x5Du:
v0 = 57;
break;
case 0x5Eu:
v15 = next();
if ( v15 == 61 )
{
Text[1] = 61;
v0 = 20;
}
else
{
putback(v15);
v0 = 14;
}
break;
case 0x7Bu:
v0 = 51;
break;
case 0x7Cu:
v16 = next();
if ( v16 == 124 )
{
Text[1] = 124;
v0 = 17;
}
else if ( v16 == 61 )
{
Text[1] = 61;
v0 = 24;
}
else
{
putback(v16);
v0 = 15;
}
break;
case 0x7Du:
v0 = 56;
break;
case 0x7Eu:
v0 = 67;
break;
default:
if ( v1 - 48 <= 9 )
{
Value = scanint(v1);
v0 = 50;
}
else
{
v23 = isalpha(v1);
if ( v1 != 95 && !v23 )
{
cerror("funny input character: %s", (const char *)v1);
continue;
}
Value = scanident(v1, (__int64)Text, 512);
v0 = keyword(Text);
if ( !v0 )
v0 = 46;
}
break;
}
break;
}
}
else
{
Rejected = -1;
strcpy(Text, Rejtext);
Value = Rejval;
}
return v0;
}

canonical_decompiled_code:
__int64 func10()
{
unsigned int v0; // ebx
unsigned int v1; // ebx
int v3; // eax
int v4; // eax
int v5; // eax
int v6; // eax
int v7; // eax
int v8; // eax
int v9; // eax
int v10; // eax
int v11; // eax
int v12; // eax
int v13; // eax
int v14; // eax
int v15; // eax
int v16; // eax
const char *v17; // rdx
int v18; // eax
const char *v19; // rdx
int v20; // eax
int v21; // eax
const char *v22; // rdx
int v23; // eax

v0 = Rejected;
if ( Rejected == -1 )
{
while ( 2 )
{
Value = 0;
v1 = func4();
*(_WORD *)&Text[1] = 0;
Text[3] = 0;
Text[0] = v1;
switch ( v1 )
{
case 0xFFFFFFFF:
strcpy(Text, "<EOF>");
v0 = 71;
break;
case 0x21u:
v3 = func3();
if ( v3 == 61 )
{
Text[1] = 61;
v0 = 12;
}
else
{
func0(v3);
v0 = 72;
}
break;
case 0x22u:
Value = func7(Text);
v0 = 64;
break;
case 0x23u:
v18 = func3();
func9(v18, (unsigned int)((_DWORD)Text + 1), 511);
v0 = func2(Text);
if ( !v0 )
{
error((int)"unknown preprocessor command: %s", (int)Text, v19);
v0 = 46;
}
break;
case 0x25u:
v4 = func3();
if ( v4 == 61 )
{
Text[1] = 61;
v0 = 23;
}
else
{
func0(v4);
v0 = 2;
}
break;
case 0x26u:
v5 = func3();
if ( v5 == 38 )
{
Text[1] = 38;
v0 = 16;
}
else if ( v5 == 61 )
{
Text[1] = 61;
v0 = 19;
}
else
{
func0(v5);
v0 = 13;
}
break;
case 0x27u:
Value = func6();
Text[1] = Value;
if ( func3() != 39 )
error((int)"expected '\\'' at end of char literal", 0, v17);
Text[2] = 39;
v0 = 50;
break;
case 0x28u:
v0 = 53;
break;
case 0x29u:
v0 = 60;
break;
case 0x2Au:
v6 = func3();
if ( v6 == 61 )
{
Text[1] = 61;
v0 = 28;
}
else
{
func0(v6);
v0 = 1;
}
break;
case 0x2Bu:
v7 = func3();
if ( v7 == 43 )
{
Text[1] = 43;
v0 = 48;
}
else if ( v7 == 61 )
{
Text[1] = 61;
v0 = 25;
}
else
{
func0(v7);
v0 = 3;
}
break;
case 0x2Cu:
v0 = 35;
break;
case 0x2Du:
v8 = func3();
switch ( v8 )
{
case '-':
Text[1] = 45;
v0 = 37;
break;
case '=':
Text[1] = 61;
v0 = 22;
break;
case '>':
Text[1] = 62;
v0 = 18;
break;
default:
func0(v8);
v0 = 4;
break;
}
break;
case 0x2Eu:
v20 = func3();
if ( v20 == 46 )
{
Text[2] = 46;
Text[1] = 46;
Text[3] = 0;
v21 = func3();
v0 = 41;
if ( v21 != 46 )
{
func0(v21);
error((int)"incomplete '...'", 0, v22);
}
}
else
{
func0(v20);
v0 = 40;
}
break;
case 0x2Fu:
v9 = func3();
if ( v9 == 61 )
{
Text[1] = 61;
v0 = 27;
}
else
{
func0(v9);
v0 = 0;
}
break;
case 0x3Au:
v0 = 34;
break;
case 0x3Bu:
v0 = 61;
break;
case 0x3Cu:
v10 = func3();
if ( v10 == 60 )
{
Text[1] = 60;
v11 = func3();
if ( v11 == 61 )
{
Text[2] = 61;
v0 = 21;
}
else
{
func0(v11);
v0 = 5;
}
}
else if ( v10 == 61 )
{
Text[1] = 61;
v0 = 10;
}
else
{
func0(v10);
v0 = 9;
}
break;
case 0x3Du:
v12 = func3();
if ( v12 == 61 )
{
Text[1] = 61;
v0 = 11;
}
else
{
func0(v12);
v0 = 29;
}
break;
case 0x3Eu:
v13 = func3();
if ( v13 == 62 )
{
Text[1] = 62;
v14 = func3();
if ( v14 == 61 )
{
Text[1] = 61;
v0 = 26;
}
else
{
func0(v14);
v0 = 6;
}
}
else if ( v13 == 61 )
{
Text[1] = 61;
v0 = 8;
}
else
{
func0(v13);
v0 = 7;
}
break;
case 0x3Fu:
v0 = 55;
break;
case 0x5Bu:
v0 = 52;
break;
case 0x5Du:
v0 = 57;
break;
case 0x5Eu:
v15 = func3();
if ( v15 == 61 )
{
Text[1] = 61;
v0 = 20;
}
else
{
func0(v15);
v0 = 14;
}
break;
case 0x7Bu:
v0 = 51;
break;
case 0x7Cu:
v16 = func3();
if ( v16 == 124 )
{
Text[1] = 124;
v0 = 17;
}
else if ( v16 == 61 )
{
Text[1] = 61;
v0 = 24;
}
else
{
func0(v16);
v0 = 15;
}
break;
case 0x7Du:
v0 = 56;
break;
case 0x7Eu:
v0 = 67;
break;
default:
if ( v1 - 48 <= 9 )
{
Value = func8(v1);
v0 = 50;
}
else
{
v23 = isalpha(v1);
if ( v1 != 95 && !v23 )
{
cerror("funny input character: %s", (const char *)v1);
continue;
}
Value = func9(v1, (__int64)Text, 512);
v0 = func2(Text);
if ( !v0 )
v0 = 46;
}
break;
}
break;
}
}
else
{
Rejected = -1;
strcpy(Text, Rejtext);
Value = Rejval;
}
return v0;
}

original_code:
static int scanpp(void)
{
    int c, t;
    if (Rejected != -1)
    {
        t = Rejected;
        Rejected = -1;
        strcpy(Text, Rejtext);
        Value = Rejval;
        return t;
    }
    for (;;)
    {
        Value = 0;
        c = skip();
        memset(Text, 0, 4);
        Text[0] = c;
        switch (c)
        {
        case '!':
            if ((c = next()) == '=')
            {
                Text[1] = '=';
                return NOTEQ;
            }
            else
            {
                putback(c);
                return XMARK;
            }
        case '%':
            if ((c = next()) == '=')
            {
                Text[1] = '=';
                return ASMOD;
            }
            else
            {
                putback(c);
                return MOD;
            }
        case '&':
            if ((c = next()) == '&')
            {
                Text[1] = '&';
                return LOGAND;
            }
            else if ('=' == c)
            {
                Text[1] = '=';
                return ASAND;
            }
            else
            {
                putback(c);
                return AMPER;
            }
        case '(':
            return LPAREN;
        case ')':
            return RPAREN;
        case '*':
            if ((c = next()) == '=')
            {
                Text[1] = '=';
                return ASMUL;
            }
            else
            {
                putback(c);
                return STAR;
            }
        case '+':
            if ((c = next()) == '+')
            {
                Text[1] = '+';
                return INCR;
            }
            else if ('=' == c)
            {
                Text[1] = '=';
                return ASPLUS;
            }
            else
            {
                putback(c);
                return PLUS;
            }
        case ',':
            return COMMA;
        case '-':
            if ((c = next()) == '-')
            {
                Text[1] = '-';
                return DECR;
            }
            else if ('=' == c)
            {
                Text[1] = '=';
                return ASMINUS;
            }
            else if ('>' == c)
            {
                Text[1] = '>';
                return ARROW;
            }
            else
            {
                putback(c);
                return MINUS;
            }
        case '/':
            if ((c = next()) == '=')
            {
                Text[1] = '=';
                return ASDIV;
            }
            else
            {
                putback(c);
                return SLASH;
            }
        case ':':
            return COLON;
        case ';':
            return SEMI;
        case '<':
            if ((c = next()) == '<')
            {
                Text[1] = '<';
                if ((c = next()) == '=')
                {
                    Text[2] = '=';
                    return ASLSHIFT;
                }
                else
                {
                    putback(c);
                    return LSHIFT;
                }
            }
            else if ('=' == c)
            {
                Text[1] = '=';
                return LTEQ;
            }
            else
            {
                putback(c);
                return LESS;
            }
        case '=':
            if ((c = next()) == '=')
            {
                Text[1] = '=';
                return EQUAL;
            }
            else
            {
                putback(c);
                return ASSIGN;
            }
        case '>':
            if ((c = next()) == '>')
            {
                Text[1] = '>';
                if ((c = next()) == '=')
                {
                    Text[1] = '=';
                    return ASRSHIFT;
                }
                else
                {
                    putback(c);
                    return RSHIFT;
                }
            }
            else if ('=' == c)
            {
                Text[1] = '=';
                return GTEQ;
            }
            else
            {
                putback(c);
                return GREATER;
            }
        case '?':
            return QMARK;
        case '[':
            return LBRACK;
        case ']':
            return RBRACK;
        case '^':
            if ((c = next()) == '=')
            {
                Text[1] = '=';
                return ASXOR;
            }
            else
            {
                putback(c);
                return CARET;
            }
        case '{':
            return LBRACE;
        case '|':
            if ((c = next()) == '|')
            {
                Text[1] = '|';
                return LOGOR;
            }
            else if ('=' == c)
            {
                Text[1] = '=';
                return ASOR;
            }
            else
            {
                putback(c);
                return PIPE;
            }
        case '}':
            return RBRACE;
        case '~':
            return TILDE;
        case (-1):
            strcpy(Text, "<EOF>");
            return XEOF;
        case '\'':
            Text[1] = Value = scanch();
            if ((c = next()) != '\'')
                error("expected '\\'' at end of char literal", ((void *)0));
            Text[2] = '\'';
            return INTLIT;
        case '"':
            Value = scanstr(Text);
            return STRLIT;
        case '#':
            Text[0] = '#';
            scanident(next(), &Text[1], 512 -1);
            if ((t = keyword(Text)) != 0)
                return t;
            error("unknown preprocessor command: %s", Text);
            return IDENT;
        case '.':
            if ((c = next()) == '.')
            {
                Text[1] = Text[2] = '.';
                Text[3] = 0;
                if ((c = next()) == '.')
                    return ELLIPSIS;
                putback(c);
                error("incomplete '...'", ((void *)0));
                return ELLIPSIS;
            }
            putback(c);
            return DOT;
        default:
            if (isdigit(c))
            {
                Value = scanint(c);
                return INTLIT;
            }
            else if (isalpha(c) || '_' == c)
            {
                Value = scanident(c, Text, 512);
                if ((t = keyword(Text)) != 0)
                    return t;
                return IDENT;
            }
            else
            {
                cerror("funny input character: %s", c);
                break;
            }
        }
    }
}

canonical_original_code:
static int scanpp()
{
    int c; int t;
    if (Rejected != -1)
    {
        t = Rejected;
        Rejected = -1;
        strcpy(Text, Rejtext);
        Value = Rejval;
        return t;
    }
    for (;;)
    {
        Value = 0;
        c = skip();
        memset(Text, 0, 4);
        Text[0] = c;
        switch (c)
        {
        case '!':
            if ((c = next()) == '=')
            {
                Text[1] = '=';
                return NOTEQ;
            }
            else
            {
                putback(c);
                return XMARK;
            }
        case '%':
            if ((c = next()) == '=')
            {
                Text[1] = '=';
                return ASMOD;
            }
            else
            {
                putback(c);
                return MOD;
            }
        case '&':
            if ((c = next()) == '&')
            {
                Text[1] = '&';
                return LOGAND;
            }
            else if ('=' == c)
            {
                Text[1] = '=';
                return ASAND;
            }
            else
            {
                putback(c);
                return AMPER;
            }
        case '(':
            return LPAREN;
        case ')':
            return RPAREN;
        case '*':
            if ((c = next()) == '=')
            {
                Text[1] = '=';
                return ASMUL;
            }
            else
            {
                putback(c);
                return STAR;
            }
        case '+':
            if ((c = next()) == '+')
            {
                Text[1] = '+';
                return INCR;
            }
            else if ('=' == c)
            {
                Text[1] = '=';
                return ASPLUS;
            }
            else
            {
                putback(c);
                return PLUS;
            }
        case ',':
            return COMMA;
        case '-':
            if ((c = next()) == '-')
            {
                Text[1] = '-';
                return DECR;
            }
            else if ('=' == c)
            {
                Text[1] = '=';
                return ASMINUS;
            }
            else if ('>' == c)
            {
                Text[1] = '>';
                return ARROW;
            }
            else
            {
                putback(c);
                return MINUS;
            }
        case '/':
            if ((c = next()) == '=')
            {
                Text[1] = '=';
                return ASDIV;
            }
            else
            {
                putback(c);
                return SLASH;
            }
        case ':':
            return COLON;
        case ';':
            return SEMI;
        case '<':
            if ((c = next()) == '<')
            {
                Text[1] = '<';
                if ((c = next()) == '=')
                {
                    Text[2] = '=';
                    return ASLSHIFT;
                }
                else
                {
                    putback(c);
                    return LSHIFT;
                }
            }
            else if ('=' == c)
            {
                Text[1] = '=';
                return LTEQ;
            }
            else
            {
                putback(c);
                return LESS;
            }
        case '=':
            if ((c = next()) == '=')
            {
                Text[1] = '=';
                return EQUAL;
            }
            else
            {
                putback(c);
                return ASSIGN;
            }
        case '>':
            if ((c = next()) == '>')
            {
                Text[1] = '>';
                if ((c = next()) == '=')
                {
                    Text[1] = '=';
                    return ASRSHIFT;
                }
                else
                {
                    putback(c);
                    return RSHIFT;
                }
            }
            else if ('=' == c)
            {
                Text[1] = '=';
                return GTEQ;
            }
            else
            {
                putback(c);
                return GREATER;
            }
        case '?':
            return QMARK;
        case '[':
            return LBRACK;
        case ']':
            return RBRACK;
        case '^':
            if ((c = next()) == '=')
            {
                Text[1] = '=';
                return ASXOR;
            }
            else
            {
                putback(c);
                return CARET;
            }
        case '{':
            return LBRACE;
        case '|':
            if ((c = next()) == '|')
            {
                Text[1] = '|';
                return LOGOR;
            }
            else if ('=' == c)
            {
                Text[1] = '=';
                return ASOR;
            }
            else
            {
                putback(c);
                return PIPE;
            }
        case '}':
            return RBRACE;
        case '~':
            return TILDE;
        case (-1):
            strcpy(Text, "<EOF>");
            return XEOF;
        case '\'':
            Text[1] = Value = scanch();
            if ((c = next()) != '\'')
                error("expected '\\'' at end of char literal", ((void *)0));
            Text[2] = '\'';
            return INTLIT;
        case '"':
            Value = scanstr(Text);
            return STRLIT;
        case '#':
            Text[0] = '#';
            scanident(next(), &Text[1], 512 -1);
            if ((t = keyword(Text)) != 0)
                return t;
            error("unknown preprocessor command: %s", Text);
            return IDENT;
        case '.':
            if ((c = next()) == '.')
            {
                Text[1] = Text[2] = '.';
                Text[3] = 0;
                if ((c = next()) == '.')
                    return ELLIPSIS;
                putback(c);
                error("incomplete '...'", ((void *)0));
                return ELLIPSIS;
            }
            putback(c);
            return DOT;
        default:
            if (isdigit(c))
            {
                Value = scanint(c);
                return INTLIT;
            }
            else if (isalpha(c) || '_' == c)
            {
                Value = scanident(c, Text, 512);
                if ((t = keyword(Text)) != 0)
                    return t;
                return IDENT;
            }
            else
            {
                cerror("funny input character: %s", c);
                break;
            }
        }
    }
}

variable_types: t int


scan

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

result = scanpp();
if ( Syntoken == (_DWORD)result )
Syntoken = 0;
return result;
}

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

result = func10();
if ( Syntoken == (_DWORD)result )
Syntoken = 0;
return result;
}

original_code:
int scan(void)
{
    int t = scanpp();
    if (t == Syntoken)
        Syntoken = 0;
    return t;
}

canonical_original_code:
int scan()
{
    int t = scanpp();
    if (t == Syntoken)
        Syntoken = 0;
    return t;
}


reject

decompiled_code:
char *reject()
{
Rejected = Token;
Rejval = Value;
return strcpy(Rejtext, Text);
}

canonical_decompiled_code:
char *func12()
{
Rejected = Token;
Rejval = Value;
return strcpy(Rejtext, Text);
}

original_code:
void reject(void)
{
    Rejected = Token;
    Rejval = Value;
    strcpy(Rejtext, Text);
}

canonical_original_code:
void reject()
{
    Rejected = Token;
    Rejval = Value;
    strcpy(Rejtext, Text);
}


decompiled_code:
__int64 break_stmt()
{
const char *v0; // rdx

Token = scan();
if ( !Bsp )
error((int)"'break' not in loop/switch context", 0, v0);
genjump((unsigned int)Breakstk[Bsp - 1]);
return semi();
}

canonical_decompiled_code:
__int64 func0()
{
const char *v0; // rdx

Token = scan();
if ( !Bsp )
error((int)"'break' not in loop/switch context", 0, v0);
genjump((unsigned int)Breakstk[Bsp - 1]);
return semi();
}

original_code:
static void break_stmt(void)
{
    Token = scan();
    if (!Bsp)
        error("'break' not in loop/switch context", ((void *)0));
    genjump(Breakstk[Bsp - 1]);
    semi();
}

canonical_original_code:
static void break_stmt()
{
    Token = scan();
    if (!Bsp)
        error("'break' not in loop/switch context", ((void *)0));
    genjump(Breakstk[Bsp - 1]);
    semi();
}


decompiled_code:
__int64 continue_stmt()
{
const char *v0; // rdx

Token = scan();
if ( !Csp )
error((int)"'continue' not in loop context", 0, v0);
genjump((unsigned int)Contstk[Csp - 1]);
return semi();
}

canonical_decompiled_code:
__int64 func1()
{
const char *v0; // rdx

Token = scan();
if ( !Csp )
error((int)"'continue' not in loop context", 0, v0);
genjump((unsigned int)Contstk[Csp - 1]);
return semi();
}

original_code:
static void continue_stmt(void)
{
    Token = scan();
    if (!Csp)
        error("'continue' not in loop context", ((void *)0));
    genjump(Contstk[Csp - 1]);
    semi();
}

canonical_original_code:
static void continue_stmt()
{
    Token = scan();
    if (!Csp)
        error("'continue' not in loop context", ((void *)0));
    genjump(Contstk[Csp - 1]);
    semi();
}


pushbrk

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

if ( Bsp > 15 )
fatal("too many nested loops/switches");
LODWORD(result) = Bsp++;
result = (int)result;
Breakstk[(int)result] = a1;
return result;
}

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

if ( Bsp > 15 )
fatal("too many nested loops/switches");
LODWORD(result) = Bsp++;
result = (int)result;
Breakstk[(int)result] = a1;
return result;
}

original_code:
static void pushbrk(int id)
{
    if (Bsp >= 16)
        fatal("too many nested loops/switches");
    Breakstk[Bsp++] = id;
}


pushcont

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

if ( Csp > 15 )
fatal("too many nested loops/switches");
LODWORD(result) = Csp++;
result = (int)result;
Contstk[(int)result] = a1;
return result;
}

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

if ( Csp > 15 )
fatal("too many nested loops/switches");
LODWORD(result) = Csp++;
result = (int)result;
Contstk[(int)result] = a1;
return result;
}

original_code:
static void pushcont(int id)
{
    if (Csp >= 16)
        fatal("too many nested loops/switches");
    Contstk[Csp++] = id;
}


decompiled_code:
__int64 return_stmt()
{
const char *v0; // rdx
const char *v1; // rdx
char v3[4]; // [rsp+8h] [rbp-10h] BYREF
unsigned int v4; // [rsp+Ch] [rbp-Ch]

Token = scan();
if ( Token == 61 )
{
if ( symbols[10 * Thisfn + 2] != 7 )
error((int)"missing value after 'return'", 0, v0);
}
else
{
if ( (unsigned int)expr(v3) )
rvalue(v3);
if ( !(unsigned int)typematch(v4, (unsigned int)symbols[10 * Thisfn + 2]) )
error((int)"incompatible type in 'return'", 0, v1);
}
genjump((unsigned int)Retlab);
return semi();
}

canonical_decompiled_code:
__int64 func4()
{
const char *v0; // rdx
const char *v1; // rdx
char v3[4]; // [rsp+8h] [rbp-10h] BYREF
unsigned int v4; // [rsp+Ch] [rbp-Ch]

Token = scan();
if ( Token == 61 )
{
if ( symbols[10 * Thisfn + 2] != 7 )
error((int)"missing value after 'return'", 0, v0);
}
else
{
if ( (unsigned int)expr(v3) )
rvalue(v3);
if ( !(unsigned int)typematch(v4, (unsigned int)symbols[10 * Thisfn + 2]) )
error((int)"incompatible type in 'return'", 0, v1);
}
genjump((unsigned int)Retlab);
return semi();
}

original_code:
static void return_stmt(void)
{
    int lv[LV];
    Token = scan();
    if (Token != SEMI)
    {
        if (expr(lv))
            rvalue(lv);
        if (!typematch(lv[LVPRIM], symbols[Thisfn].prims))
            error("incompatible type in 'return'", ((void *)0));
    }
    else
    {
        if (symbols[Thisfn].prims != PVOID)
            error("missing value after 'return'", ((void *)0));
    }
    genjump(Retlab);
    semi();
}

canonical_original_code:
static void return_stmt()
{
    int lv[-1];
    Token = scan();
    if (Token != SEMI)
    {
        if (expr(lv))
            rvalue(lv);
        if (!typematch(lv[LVPRIM], symbols[Thisfn].prims))
            error("incompatible type in 'return'", ((void *)0));
    }
    else
    {
        if (symbols[Thisfn].prims != PVOID)
            error("missing value after 'return'", ((void *)0));
    }
    genjump(Retlab);
    semi();
}

variable_types:
lv
int [-1]


compound

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

if ( a1 )
Token = scan();
if ( Token == 56 )
{
LABEL_6:
result = scan();
Token = result;
}
else
{
while ( 1 )
{
result = eofcheck();
if ( (_DWORD)result )
break;
stmt();
if ( Token == 56 )
goto LABEL_6;
}
}
return result;
}

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

if ( a1 )
Token = scan();
if ( Token == 56 )
{
LABEL_6:
result = scan();
Token = result;
}
else
{
while ( 1 )
{
result = eofcheck();
if ( (_DWORD)result )
break;
func7();
if ( Token == 56 )
goto LABEL_6;
}
}
return result;
}

original_code:
void compound(int lbr)
{
    if (lbr)
        Token = scan();
    while (RBRACE != Token)
    {
        if (eofcheck())
            return;
        stmt();
    }
    Token = scan();
}

variable_types: lbr int


stmt

decompiled_code:
int __fastcall stmt(__int64 a1, __int64 a2, const char *a3)
{
switch ( Token )
{
case 31:
break_stmt();
break;
case 32:
wrong_ctx(32, a2, a3);
break;
case 36:
continue_stmt();
break;
case 38:
wrong_ctx(38, a2, a3);
break;
case 39:
do_stmt();
break;
case 45:
for_stmt();
break;
case 47:
if_stmt();
break;
case 51:
compound(1);
break;
case 59:
return_stmt();
break;
case 61:
Token = scan();
break;
case 66:
switch_stmt();
break;
case 70:
while_stmt();
break;
default:
rexpr(0LL);
semi();
break;
}
return clear();
}

canonical_decompiled_code:
int __fastcall func7(__int64 a1, __int64 a2, const char *a3)
{
switch ( Token )
{
case 31:
func0();
break;
case 32:
func5(32, a2, a3);
break;
case 36:
func1();
break;
case 38:
func5(38, a2, a3);
break;
case 39:
func8();
break;
case 45:
func9();
break;
case 47:
func10();
break;
case 51:
func6(1);
break;
case 59:
func4();
break;
case 61:
Token = scan();
break;
case 66:
func12();
break;
case 70:
func13();
break;
default:
rexpr(0LL);
semi();
break;
}
return clear();
}

original_code:
static void stmt(void)
{
    switch (Token)
    {
    case BREAK:
        break_stmt();
        break;
    case CONTINUE:
        continue_stmt();
        break;
    case DO:
        do_stmt();
        break;
    case FOR:
        for_stmt();
        break;
    case IF:
        if_stmt();
        break;
    case RETURN:
        return_stmt();
        break;
    case SWITCH:
        switch_stmt();
        break;
    case WHILE:
        while_stmt();
        break;
    case LBRACE:
        compound(1);
        break;
    case SEMI:
        Token = scan();
        break;
    case DEFAULT:
        wrong_ctx(DEFAULT);
        break;
    case CASE:
        wrong_ctx(CASE);
        break;
    default:
        rexpr(0);
        semi();
        break;
    }
    clear(1);
}

canonical_original_code:
static void stmt()
{
    switch (Token)
    {
    case BREAK:
        break_stmt();
        break;
    case CONTINUE:
        continue_stmt();
        break;
    case DO:
        do_stmt();
        break;
    case FOR:
        for_stmt();
        break;
    case IF:
        if_stmt();
        break;
    case RETURN:
        return_stmt();
        break;
    case SWITCH:
        switch_stmt();
        break;
    case WHILE:
        while_stmt();
        break;
    case LBRACE:
        compound(1);
        break;
    case SEMI:
        Token = scan();
        break;
    case DEFAULT:
        wrong_ctx(DEFAULT);
        break;
    case CASE:
        wrong_ctx(CASE);
        break;
    default:
        rexpr(0);
        semi();
        break;
    }
    clear(1);
}


decompiled_code:
__int64 __fastcall do_stmt(__int64 a1, __int64 a2)
{
unsigned int v2; // ebp
unsigned int v3; // ebx
unsigned int v4; // er12
const char *v5; // rdx
__int64 result; // rax

Token = scan();
v2 = label();
v3 = label();
pushbrk(v3);
v4 = label();
pushcont(v4);
genlab(v2);
stmt(v2, a2, v5);
match(70LL, "'while'");
lparen();
genlab(v4);
rexpr(0LL);
genbrtrue(v2);
clear();
genlab(v3);
rparen();
result = semi();
--Bsp;
--Csp;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, __int64 a2)
{
unsigned int v2; // ebp
unsigned int v3; // ebx
unsigned int v4; // er12
const char *v5; // rdx
__int64 result; // rax

Token = scan();
v2 = label();
v3 = label();
func2(v3);
v4 = label();
func3(v4);
genlab(v2);
func7(v2, a2, v5);
match(70LL, "'while'");
lparen();
genlab(v4);
rexpr(0LL);
genbrtrue(v2);
clear();
genlab(v3);
rparen();
result = semi();
--Bsp;
--Csp;
return result;
}

original_code:
static void do_stmt(void)
{
    int ls, lb, lc;
    Token = scan();
    ls = label();
    pushbrk(lb = label());
    pushcont(lc = label());
    genlab(ls);
    stmt();
    match(WHILE, "'while'");
    lparen();
    genlab(lc);
    rexpr(0);
    genbrtrue(ls);
    clear(1);
    genlab(lb);
    rparen();
    semi();
    Bsp--;
    Csp--;
}

canonical_original_code:
static void do_stmt()
{
    int ls; int lb; int lc;
    Token = scan();
    ls = label();
    pushbrk(lb = label());
    pushcont(lc = label());
    genlab(ls);
    stmt();
    match(WHILE, "'while'");
    lparen();
    genlab(lc);
    rexpr(0);
    genbrtrue(ls);
    clear(1);
    genlab(lb);
    rparen();
    semi();
    Bsp--;
    Csp--;
}

variable_types: ls int

variable_types: lb int

variable_types: lc int


decompiled_code:
__int64 __fastcall for_stmt(__int64 a1, __int64 a2)
{
unsigned int v2; // er13
unsigned int v3; // er12
unsigned int v4; // ebp
unsigned int v5; // ebx
const char *v6; // rdx
__int64 result; // rax

Token = scan();
v2 = label();
v3 = label();
v4 = label();
pushbrk(v4);
v5 = label();
pushcont(v5);
lparen();
if ( Token != 61 )
{
rexpr(0LL);
clear();
}
semi();
genlab(v2);
if ( Token != 61 )
{
rexpr(0LL);
genbrfalse(v4);
clear();
}
genjump(v3);
semi();
genlab(v5);
if ( Token != 60 )
rexpr(0LL);
clear();
genjump(v2);
rparen();
genlab(v3);
stmt(v3, a2, v6);
genjump(v5);
result = genlab(v4);
--Bsp;
--Csp;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, __int64 a2)
{
unsigned int v2; // er13
unsigned int v3; // er12
unsigned int v4; // ebp
unsigned int v5; // ebx
const char *v6; // rdx
__int64 result; // rax

Token = scan();
v2 = label();
v3 = label();
v4 = label();
func2(v4);
v5 = label();
func3(v5);
lparen();
if ( Token != 61 )
{
rexpr(0LL);
clear();
}
semi();
genlab(v2);
if ( Token != 61 )
{
rexpr(0LL);
genbrfalse(v4);
clear();
}
genjump(v3);
semi();
genlab(v5);
if ( Token != 60 )
rexpr(0LL);
clear();
genjump(v2);
rparen();
genlab(v3);
func7(v3, a2, v6);
genjump(v5);
result = genlab(v4);
--Bsp;
--Csp;
return result;
}

original_code:
static void for_stmt(void)
{
    int ls, lbody, lb, lc;
    Token = scan();
    ls = label();
    lbody = label();
    pushbrk(lb = label());
    pushcont(lc = label());
    lparen();
    if (Token != SEMI)
    {
        rexpr(0);
        clear(1);
    }
    semi();
    genlab(ls);
    if (Token != SEMI)
    {
        rexpr(0);
        genbrfalse(lb);
        clear(1);
    }
    genjump(lbody);
    semi();
    genlab(lc);
    if (Token != RPAREN)
        rexpr(0);
    clear(1);
    genjump(ls);
    rparen();
    genlab(lbody);
    stmt();
    genjump(lc);
    genlab(lb);
    Bsp--;
    Csp--;
}

canonical_original_code:
static void for_stmt()
{
    int ls; int lbody; int lb; int lc;
    Token = scan();
    ls = label();
    lbody = label();
    pushbrk(lb = label());
    pushcont(lc = label());
    lparen();
    if (Token != SEMI)
    {
        rexpr(0);
        clear(1);
    }
    semi();
    genlab(ls);
    if (Token != SEMI)
    {
        rexpr(0);
        genbrfalse(lb);
        clear(1);
    }
    genjump(lbody);
    semi();
    genlab(lc);
    if (Token != RPAREN)
        rexpr(0);
    clear(1);
    genjump(ls);
    rparen();
    genlab(lbody);
    stmt();
    genjump(lc);
    genlab(lb);
    Bsp--;
    Csp--;
}

variable_types: lbody int


decompiled_code:
__int64 __fastcall if_stmt(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
const char *v3; // rdx
__int64 v5; // rbp
const char *v6; // rdx

Token = scan();
lparen();
rexpr(0LL);
v2 = (unsigned int)label();
genbrfalse(v2);
clear();
rparen(1LL);
stmt(1LL, a2, v3);
if ( Token == 42 )
{
v5 = (unsigned int)label();
genjump(v5);
genlab((unsigned int)v2);
Token = scan();
stmt((unsigned int)v2, a2, v6);
LODWORD(v2) = v5;
}
return genlab((unsigned int)v2);
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
const char *v3; // rdx
__int64 v5; // rbp
const char *v6; // rdx

Token = scan();
lparen();
rexpr(0LL);
v2 = (unsigned int)label();
genbrfalse(v2);
clear();
rparen(1LL);
func7(1LL, a2, v3);
if ( Token == 42 )
{
v5 = (unsigned int)label();
genjump(v5);
genlab((unsigned int)v2);
Token = scan();
func7((unsigned int)v2, a2, v6);
LODWORD(v2) = v5;
}
return genlab((unsigned int)v2);
}

original_code:
static void if_stmt(void)
{
    int l1, l2;
    Token = scan();
    lparen();
    rexpr(0);
    l1 = label();
    genbrfalse(l1);
    clear(1);
    rparen();
    stmt();
    if (ELSE == Token)
    {
        l2 = label();
        genjump(l2);
        genlab(l1);
        l1 = l2;
        Token = scan();
        stmt();
    }
    genlab(l1);
}

canonical_original_code:
static void if_stmt()
{
    int l1; int l2;
    Token = scan();
    lparen();
    rexpr(0);
    l1 = label();
    genbrfalse(l1);
    clear(1);
    rparen();
    stmt();
    if (ELSE == Token)
    {
        l2 = label();
        genjump(l2);
        genlab(l1);
        l1 = l2;
        Token = scan();
        stmt();
    }
    genlab(l1);
}


decompiled_code:
__int64 __fastcall switch_block(__int64 a1, __int64 a2)
{
unsigned int v2; // er13
__int64 v3; // r14
__int64 v4; // rdi
const char *v5; // rdx
int v6; // ebp
__int64 v7; // r12
__int64 result; // rax
const char *v9; // rdx
int v10; // ebx
__int64 v11; // rbx
unsigned int v12; // eax
int v13[256]; // [rsp+0h] [rbp-828h] BYREF
int v14[266]; // [rsp+400h] [rbp-428h] BYREF

Token = scan();
v2 = label();
pushbrk(v2);
v3 = (unsigned int)label();
v4 = v3;
genjump(v3);
if ( Token == 56 )
{
LABEL_20:
error((int)"empty switch", 0, v5);
genjump(v2);
genlab((unsigned int)v3);
LODWORD(v7) = v2;
v6 = 0;
LABEL_16:
genswitch(v14, v13, (unsigned int)v6, (unsigned int)v7);
gentext();
genlab(v2);
result = scan();
Token = result;
--Bsp;
}
else
{
v6 = 0;
LODWORD(v7) = 0;
while ( 1 )
{
result = eofcheck();
v10 = result;
if ( (_DWORD)result )
break;
LOBYTE(v9) = Token == 38 || Token == 32;
if ( (_BYTE)v9 && v6 > 255 )
{
a2 = 0LL;
v4 = (__int64)"too many 'case's in 'switch'";
error((int)"too many 'case's in 'switch'", 0, v9);
v6 = v10;
}
switch ( Token )
{
case ' ':
Token = scan();
v11 = v6;
v14[v6++] = constexpr();
v12 = label();
v4 = v12;
v13[v11] = v12;
genlab(v12);
colon();
break;
case '&':
Token = scan();
v7 = (unsigned int)label();
v4 = v7;
genlab(v7);
colon();
break;
case '8':
if ( v6 )
{
genjump(v2);
genlab((unsigned int)v3);
if ( !(_DWORD)v7 )
LODWORD(v7) = v2;
}
else
{
if ( !(_DWORD)v7 )
goto LABEL_20;
v14[0] = 0;
v13[0] = v7;
genjump(v2);
genlab((unsigned int)v3);
v6 = 1;
}
goto LABEL_16;
default:
stmt(v4, a2, v9);
break;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, __int64 a2)
{
unsigned int v2; // er13
__int64 v3; // r14
__int64 v4; // rdi
const char *v5; // rdx
int v6; // ebp
__int64 v7; // r12
__int64 result; // rax
const char *v9; // rdx
int v10; // ebx
__int64 v11; // rbx
unsigned int v12; // eax
int v13[256]; // [rsp+0h] [rbp-828h] BYREF
int v14[266]; // [rsp+400h] [rbp-428h] BYREF

Token = scan();
v2 = label();
func2(v2);
v3 = (unsigned int)label();
v4 = v3;
genjump(v3);
if ( Token == 56 )
{
LABEL_20:
error((int)"empty switch", 0, v5);
genjump(v2);
genlab((unsigned int)v3);
LODWORD(v7) = v2;
v6 = 0;
LABEL_16:
genswitch(v14, v13, (unsigned int)v6, (unsigned int)v7);
gentext();
genlab(v2);
result = scan();
Token = result;
--Bsp;
}
else
{
v6 = 0;
LODWORD(v7) = 0;
while ( 1 )
{
result = eofcheck();
v10 = result;
if ( (_DWORD)result )
break;
LOBYTE(v9) = Token == 38 || Token == 32;
if ( (_BYTE)v9 && v6 > 255 )
{
a2 = 0LL;
v4 = (__int64)"too many 'case's in 'switch'";
error((int)"too many 'case's in 'switch'", 0, v9);
v6 = v10;
}
switch ( Token )
{
case ' ':
Token = scan();
v11 = v6;
v14[v6++] = constexpr();
v12 = label();
v4 = v12;
v13[v11] = v12;
genlab(v12);
colon();
break;
case '&':
Token = scan();
v7 = (unsigned int)label();
v4 = v7;
genlab(v7);
colon();
break;
case '8':
if ( v6 )
{
genjump(v2);
genlab((unsigned int)v3);
if ( !(_DWORD)v7 )
LODWORD(v7) = v2;
}
else
{
if ( !(_DWORD)v7 )
goto LABEL_20;
v14[0] = 0;
v13[0] = v7;
genjump(v2);
genlab((unsigned int)v3);
v6 = 1;
}
goto LABEL_16;
default:
func7(v4, a2, v9);
break;
}
}
}
return result;
}

original_code:
static void switch_block(void)
{
    int lb, ls, ldflt = 0;
    int cval[256];
    int clab[256];
    int nc = 0;
    Token = scan();
    pushbrk(lb = label());
    ls = label();
    genjump(ls);
    while (RBRACE != Token)
    {
        if (eofcheck())
            return;
        if ((CASE == Token || DEFAULT == Token) && nc >= 256)
        {
            error("too many 'case's in 'switch'", ((void *)0));
            nc = 0;
        }
        if (CASE == Token)
        {
            Token = scan();
            cval[nc] = constexpr();
            genlab(clab[nc++] = label());
            colon();
        }
        else if (DEFAULT == Token)
        {
            Token = scan();
            ldflt = label();
            genlab(ldflt);
            colon();
        }
        else
        {
            stmt();
        }
    }
    if (!nc)
    {
        if (ldflt)
        {
            cval[nc] = 0;
            clab[nc++] = ldflt;
        }
        else
        {
            error("empty switch", ((void *)0));
        }
    }
    genjump(lb);
    genlab(ls);
    genswitch(cval, clab, nc, ldflt? ldflt: lb);
    gentext();
    genlab(lb);
    Token = scan();
    Bsp--;
}

canonical_original_code:
static void switch_block()
{
    int lb; int ls; int ldflt = 0;
    int cval[256];
    int clab[256];
    int nc = 0;
    Token = scan();
    pushbrk(lb = label());
    ls = label();
    genjump(ls);
    while (RBRACE != Token)
    {
        if (eofcheck())
            return;
        if ((CASE == Token || DEFAULT == Token) && nc >= 256)
        {
            error("too many 'case's in 'switch'", ((void *)0));
            nc = 0;
        }
        if (CASE == Token)
        {
            Token = scan();
            cval[nc] = constexpr();
            genlab(clab[nc++] = label());
            colon();
        }
        else if (DEFAULT == Token)
        {
            Token = scan();
            ldflt = label();
            genlab(ldflt);
            colon();
        }
        else
        {
            stmt();
        }
    }
    if (!nc)
    {
        if (ldflt)
        {
            cval[nc] = 0;
            clab[nc++] = ldflt;
        }
        else
        {
            error("empty switch", ((void *)0));
        }
    }
    genjump(lb);
    genlab(ls);
    genswitch(cval, clab, nc, ldflt? ldflt: lb);
    gentext();
    genlab(lb);
    Token = scan();
    Bsp--;
}

variable_types: ldflt int

variable_types:
cval
int [256]

variable_types:
clab
int [256]

variable_types: nc int


decompiled_code:
__int64 __fastcall switch_stmt(__int64 a1, __int64 a2)
{
const char *v2; // rdi
const char *v3; // rdx

Token = scan();
lparen();
rexpr(1LL);
v2 = 0LL;
clear();
rparen(0LL);
if ( Token != 51 )
{
a2 = 0LL;
v2 = "'{' expected after 'switch'";
error((int)"'{' expected after 'switch'", 0, v3);
}
return switch_block((__int64)v2, a2);
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, __int64 a2)
{
const char *v2; // rdi
const char *v3; // rdx

Token = scan();
lparen();
rexpr(1LL);
v2 = 0LL;
clear();
rparen(0LL);
if ( Token != 51 )
{
a2 = 0LL;
v2 = "'{' expected after 'switch'";
error((int)"'{' expected after 'switch'", 0, v3);
}
return func11((__int64)v2, a2);
}

original_code:
static void switch_stmt(void)
{
    Token = scan();
    lparen();
    rexpr(1);
    clear(0);
    rparen();
    if (Token != LBRACE)
        error("'{' expected after 'switch'", ((void *)0));
    switch_block();
}

canonical_original_code:
static void switch_stmt()
{
    Token = scan();
    lparen();
    rexpr(1);
    clear(0);
    rparen();
    if (Token != LBRACE)
        error("'{' expected after 'switch'", ((void *)0));
    switch_block();
}


decompiled_code:
__int64 __fastcall while_stmt(__int64 a1, __int64 a2)
{
unsigned int v2; // ebx
unsigned int v3; // ebp
const char *v4; // rdx
__int64 result; // rax

Token = scan();
v2 = label();
pushbrk(v2);
v3 = label();
pushcont(v3);
genlab(v3);
lparen();
rexpr(0LL);
genbrfalse(v2);
clear();
rparen(1LL);
stmt(1LL, a2, v4);
genjump(v3);
result = genlab(v2);
--Bsp;
--Csp;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, __int64 a2)
{
unsigned int v2; // ebx
unsigned int v3; // ebp
const char *v4; // rdx
__int64 result; // rax

Token = scan();
v2 = label();
func2(v2);
v3 = label();
func3(v3);
genlab(v3);
lparen();
rexpr(0LL);
genbrfalse(v2);
clear();
rparen(1LL);
func7(1LL, a2, v4);
genjump(v3);
result = genlab(v2);
--Bsp;
--Csp;
return result;
}

original_code:
static void while_stmt(void)
{
    int lb, lc;
    Token = scan();
    pushbrk(lb = label());
    pushcont(lc = label());
    genlab(lc);
    lparen();
    rexpr(0);
    genbrfalse(lb);
    clear(1);
    rparen();
    stmt();
    genjump(lc);
    genlab(lb);
    Bsp--;
    Csp--;
}

canonical_original_code:
static void while_stmt()
{
    int lb; int lc;
    Token = scan();
    pushbrk(lb = label());
    pushcont(lc = label());
    genlab(lc);
    lparen();
    rexpr(0);
    genbrfalse(lb);
    clear(1);
    rparen();
    stmt();
    genjump(lc);
    genlab(lb);
    Bsp--;
    Csp--;
}


repo: jezze/xurfaced

decompiled_code:
void xurfaced_signal_term()
{
*((_DWORD *)&xurfaced + 290) = 0;
}

canonical_decompiled_code:
void func0()
{
*((_DWORD *)&xurfaced + 290) = 0;
}

original_code:
static void xurfaced_signal_term(int sig)
{
    xurfaced.running = 0;
}

variable_types: sig int


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

v0 = xurfaced_menu_init(&xurfaced);
if ( v0 )
{
v1 = v0;
pthread_mutex_lock((pthread_mutex_t *)(unsigned int)((_DWORD)&xurfaced + 1184));
if ( *((_QWORD *)&xurfaced + 164) )
xurfaced_menu_destroy();
*((_QWORD *)&xurfaced + 164) = v1;
pthread_mutex_unlock((pthread_mutex_t *)(unsigned int)((_DWORD)&xurfaced + 1184));
}
}

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

v0 = xurfaced_menu_init(&xurfaced);
if ( v0 )
{
v1 = v0;
pthread_mutex_lock((pthread_mutex_t *)(unsigned int)((_DWORD)&xurfaced + 1184));
if ( *((_QWORD *)&xurfaced + 164) )
xurfaced_menu_destroy();
*((_QWORD *)&xurfaced + 164) = v1;
pthread_mutex_unlock((pthread_mutex_t *)(unsigned int)((_DWORD)&xurfaced + 1184));
}
}

original_code:
static void xurfaced_signal_usr1(int sig)
{
    struct xurfaced_menu *menu = xurfaced_menu_init(&xurfaced);
    if (!menu)
        return;
    pthread_mutex_lock(&xurfaced.mutexMenu);
    if (xurfaced.menu)
        xurfaced_menu_destroy(xurfaced.menu);
    xurfaced.menu = menu;
    pthread_mutex_unlock(&xurfaced.mutexMenu);
}

variable_types: struct xurfaced_menu { struct xurfaced_menu_option_list { struct xurfaced_menu_option { unsigned int type; char *name; char *description; char *command; struct animation_properties { float translationX; float translationY; float sizeX; float sizeY; float rotationX; float rotationY; float alpha; } animationProperties; struct xurfaced_menu_option *next; struct xurfaced_menu_option *prev; } *head; struct xurfaced_menu_option *current; } *opts; struct animation_properties animationProperties; } *

user_defined_types: struct xurfaced_menu { struct xurfaced_menu_option_list *opts; struct animation_properties animationProperties; }

user_defined_types: struct xurfaced_menu_option_list { struct xurfaced_menu_option *head; struct xurfaced_menu_option *current; }

user_defined_types: struct xurfaced_menu_option { unsigned int type; char *name; char *description; char *command; struct animation_properties animationProperties; struct xurfaced_menu_option *next; struct xurfaced_menu_option *prev; }


decompiled_code:
__pid_t __fastcall xurfaced_execute(void *src, int *a2)
{
size_t v2; // rax
char *v3; // rbx
char *v4; // rax
__pid_t result; // eax
__int64 v6; // rax
_DWORD stat_loc[3]; // [rsp+Ch] [rbp-111Ch] BYREF
char v8; // [rsp+18h] [rbp-1110h] BYREF
char dest[4120]; // [rsp+110h] [rbp-1018h] BYREF

v2 = strlen((const char *)src);
memcpy(dest, src, v2 + 1);
*(_QWORD *)&stat_loc[1] = strtok(dest, " ");
v3 = &v8;
do
{
v4 = strtok(0LL, " ");
*(_QWORD *)v3 = v4;
v3 += 8;
}
while ( v4 );
result = fork();
if ( result != -1 )
{
if ( !result )
{
getpid();
if ( a2 )
{
close(1);
dup(a2[1]);
close(*a2);
close(a2[1]);
}
v6 = *((_QWORD *)&xurfaced + 144);
if ( *(_QWORD *)v6 )
close(*(_DWORD *)(v6 + 8));
setsid();
execvp(*(const char **)&stat_loc[1], (char *const *)&stat_loc[1]);
exit(1);
}
if ( a2 )
{
close(a2[1]);
result = wait((__WAIT_STATUS)stat_loc);
}
}
return result;
}

canonical_decompiled_code:
__pid_t __fastcall func7(void *src, int *a2)
{
size_t v2; // rax
char *v3; // rbx
char *v4; // rax
__pid_t result; // eax
__int64 v6; // rax
_DWORD stat_loc[3]; // [rsp+Ch] [rbp-111Ch] BYREF
char v8; // [rsp+18h] [rbp-1110h] BYREF
char dest[4120]; // [rsp+110h] [rbp-1018h] BYREF

v2 = strlen((const char *)src);
memcpy(dest, src, v2 + 1);
*(_QWORD *)&stat_loc[1] = strtok(dest, " ");
v3 = &v8;
do
{
v4 = strtok(0LL, " ");
*(_QWORD *)v3 = v4;
v3 += 8;
}
while ( v4 );
result = fork();
if ( result != -1 )
{
if ( !result )
{
getpid();
if ( a2 )
{
close(1);
dup(a2[1]);
close(*a2);
close(a2[1]);
}
v6 = *((_QWORD *)&xurfaced + 144);
if ( *(_QWORD *)v6 )
close(*(_DWORD *)(v6 + 8));
setsid();
execvp(*(const char **)&stat_loc[1], (char *const *)&stat_loc[1]);
exit(1);
}
if ( a2 )
{
close(a2[1]);
result = wait((__WAIT_STATUS)stat_loc);
}
}
return result;
}

original_code:
void xurfaced_execute(char *command, int pipe[])
{
    char args[4096], *argv[32];
    memcpy(args, command, strlen(command) + 1);
    argv[0] = strtok(args, " ");
    unsigned int i = 0;
    while ((argv[++i] = strtok(0, " ")));
    int pid = fork();
    int pchild;
    if (pid == -1)
        return;
    if (!pid)
    {
        pchild = getpid();
        if (pipe)
        {
            close(1);
            dup(pipe[1]);
            close(pipe[0]);
            close(pipe[1]);
        }
        if (xurfaced.backend->display)
            close(xurfaced.backend->descriptor);
        setsid();
        execvp(argv[0], argv);
        exit(1);
    }
    if (pipe)
    {
        close(pipe[1]);
        int status;
        wait(&status);
    }
}

canonical_original_code:
void xurfaced_execute(char *command, int pipe[])
{
    char args[4096]; char *argv[32];
    memcpy(args, command, strlen(command) + 1);
    argv[0] = strtok(args, " ");
    unsigned int i = 0;
    while ((argv[++i] = strtok(0, " ")));
    int pid = fork();
    int pchild;
    if (pid == -1)
        return;
    if (!pid)
    {
        pchild = getpid();
        if (pipe)
        {
            close(1);
            dup(pipe[1]);
            close(pipe[0]);
            close(pipe[1]);
        }
        if (xurfaced.backend->display)
            close(xurfaced.backend->descriptor);
        setsid();
        execvp(argv[0], argv);
        exit(1);
    }
    if (pipe)
    {
        close(pipe[1]);
        int status;
        wait(&status);
    }
}

variable_types:
command
char *

variable_types:
pipe
int []

variable_types:
args
char [4096]

variable_types:
argv
char *[32]

variable_types:
i
unsigned int

variable_types: pid int

variable_types: pchild int

variable_types: status int


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
xurfaced_init((char *)&xurfaced);
xurfaced_run(&xurfaced);
xurfaced_destroy(&xurfaced);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
func8((char *)&xurfaced);
func3(&xurfaced);
func6(&xurfaced);
return 0;
}

original_code:
int main(int argc, char *argv[])
{
    xurfaced_init(&xurfaced);
    xurfaced_run(&xurfaced);
    xurfaced_destroy(&xurfaced);
    return 0;
}

variable_types: argc int

variable_types:
argv
char *[]


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

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

original_code:
void xurfaced_client_destroy(struct xurfaced_client *client)
{
    free(client);
}

variable_types: struct xurfaced_client { unsigned long window; unsigned long picture; struct xurfaced_client *next; struct xurfaced_client *prev; } *


decompiled_code:
_QWORD *xurfaced_client_list_create()
{
_QWORD *result; // rax

result = malloc(0x10uLL);
*result = 0LL;
result[1] = 0LL;
return result;
}

canonical_decompiled_code:
_QWORD *func1()
{
_QWORD *result; // rax

result = malloc(0x10uLL);
*result = 0LL;
result[1] = 0LL;
return result;
}

original_code:
struct xurfaced_client_list *xurfaced_client_list_create()
{
    struct xurfaced_client_list *list = malloc(sizeof (struct xurfaced_client_list));
    list->head = 0;
    list->current = 0;
    return list;
}

variable_types: struct xurfaced_client_list { struct xurfaced_client { unsigned long window; unsigned long picture; struct xurfaced_client *next; struct xurfaced_client *prev; } *head; struct xurfaced_client *current; } *

user_defined_types: struct xurfaced_client_list { struct xurfaced_client *head; struct xurfaced_client *current; }


decompiled_code:
void __fastcall xurfaced_client_list_destroy(_QWORD *a1)
{
_QWORD *v2; // rbx
void *v3; // rdi

v2 = (_QWORD *)*a1;
do
{
v3 = v2;
v2 = (_QWORD *)v2[2];
xurfaced_client_destroy(v3);
}
while ( (_QWORD *)*a1 != v2 );
a1[1] = 0LL;
}

canonical_decompiled_code:
void __fastcall func2(_QWORD *a1)
{
_QWORD *v2; // rbx
void *v3; // rdi

v2 = (_QWORD *)*a1;
do
{
v3 = v2;
v2 = (_QWORD *)v2[2];
func0(v3);
}
while ( (_QWORD *)*a1 != v2 );
a1[1] = 0LL;
}

original_code:
void xurfaced_client_list_destroy(struct xurfaced_client_list *list)
{
    struct xurfaced_client *current = list->head;
    do
    {
        struct xurfaced_client *next = current->next;
        xurfaced_client_destroy(current);
        current = next;
    }
    while (current != list->head);
    list->current = 0;
}

user_defined_types: struct xurfaced_client { unsigned long window; unsigned long picture; struct xurfaced_client *next; struct xurfaced_client *prev; }


decompiled_code:
_QWORD *xurfaced_menu_option_create()
{
_QWORD *result; // rax

result = malloc(0x50uLL);
result[1] = 0LL;
result[2] = 0LL;
result[3] = 0LL;
*((_DWORD *)result + 14) = 0;
result[8] = 0LL;
result[9] = 0LL;
return result;
}

canonical_decompiled_code:
_QWORD *func0()
{
_QWORD *result; // rax

result = malloc(0x50uLL);
result[1] = 0LL;
result[2] = 0LL;
result[3] = 0LL;
*((_DWORD *)result + 14) = 0;
result[8] = 0LL;
result[9] = 0LL;
return result;
}

original_code:
struct xurfaced_menu_option *xurfaced_menu_option_create()
{
    struct xurfaced_menu_option *option = malloc(sizeof (struct xurfaced_menu_option));
    option->name = 0;
    option->description = 0;
    option->command = 0;
    option->animationProperties.alpha = 0;
    option->next = 0;
    option->prev = 0;
    return option;
}

variable_types: struct xurfaced_menu_option { unsigned int type; char *name; char *description; char *command; struct animation_properties { float translationX; float translationY; float sizeX; float sizeY; float rotationX; float rotationY; float alpha; } animationProperties; struct xurfaced_menu_option *next; struct xurfaced_menu_option *prev; } *


decompiled_code:
void __fastcall xurfaced_menu_option_destroy(void *ptr)
{
free(*((void **)ptr + 1));
free(*((void **)ptr + 2));
free(*((void **)ptr + 3));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func1(void *ptr)
{
free(*((void **)ptr + 1));
free(*((void **)ptr + 2));
free(*((void **)ptr + 3));
free(ptr);
}

original_code:
void xurfaced_menu_option_destroy(struct xurfaced_menu_option *option)
{
    free(option->name);
    free(option->description);
    free(option->command);
    free(option);
}

user_defined_types: struct animation_properties { float translationX; float translationY; float sizeX; float sizeY; float rotationX; float rotationY; float alpha; }


decompiled_code:
_QWORD *xurfaced_menu_option_list_create()
{
_QWORD *result; // rax

result = malloc(0x10uLL);
*result = 0LL;
result[1] = 0LL;
return result;
}

canonical_decompiled_code:
_QWORD *func2()
{
_QWORD *result; // rax

result = malloc(0x10uLL);
*result = 0LL;
result[1] = 0LL;
return result;
}

original_code:
struct xurfaced_menu_option_list *xurfaced_menu_option_list_create()
{
    struct xurfaced_menu_option_list *list = malloc(sizeof (struct xurfaced_menu_option_list));
    list->head = 0;
    list->current = 0;
    return list;
}

variable_types: struct xurfaced_menu_option_list { struct xurfaced_menu_option { unsigned int type; char *name; char *description; char *command; struct animation_properties { float translationX; float translationY; float sizeX; float sizeY; float rotationX; float rotationY; float alpha; } animationProperties; struct xurfaced_menu_option *next; struct xurfaced_menu_option *prev; } *head; struct xurfaced_menu_option *current; } *


decompiled_code:
_QWORD *xurfaced_menu_create()
{
_QWORD *v0; // rbx

v0 = malloc(0x28uLL);
*v0 = xurfaced_menu_option_list_create();
return v0;
}

canonical_decompiled_code:
_QWORD *func7()
{
_QWORD *v0; // rbx

v0 = malloc(0x28uLL);
*v0 = func2();
return v0;
}

original_code:
struct xurfaced_menu *xurfaced_menu_create()
{
    struct xurfaced_menu *menu = malloc(sizeof (struct xurfaced_menu));
    menu->opts = xurfaced_menu_option_list_create();
    return menu;
}

return_type: struct xurfaced_menu { struct xurfaced_menu_option_list { struct xurfaced_menu_option { unsigned int type; char *name; char *description; char *command; struct animation_properties { float translationX; float translationY; float sizeX; float sizeY; float rotationX; float rotationY; float alpha; } animationProperties; struct xurfaced_menu_option *next; struct xurfaced_menu_option *prev; } *head; struct xurfaced_menu_option *current; } *opts; struct animation_properties animationProperties; } *


decompiled_code:
void __fastcall xurfaced_menu_destroy(void *ptr)
{
xurfaced_menu_option_list_destroy(*(_QWORD **)ptr);
free(*(void **)ptr);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func8(void *ptr)
{
func3(*(_QWORD **)ptr);
free(*(void **)ptr);
free(ptr);
}

original_code:
void xurfaced_menu_destroy(struct xurfaced_menu *menu)
{
    xurfaced_menu_option_list_destroy(menu->opts);
    free(menu->opts);
    free(menu);
}


decompiled_code:
__int64 __fastcall xurfaced_menu_activate(__int64 a1)
{
__int64 result; // rax
_BYTE *v2; // rdi

result = *(_QWORD *)(*(_QWORD *)a1 + 8LL);
v2 = *(_BYTE **)(result + 24);
if ( *v2 )
result = xurfaced_execute(v2, 0LL);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
__int64 result; // rax
_BYTE *v2; // rdi

result = *(_QWORD *)(*(_QWORD *)a1 + 8LL);
v2 = *(_BYTE **)(result + 24);
if ( *v2 )
result = xurfaced_execute(v2, 0LL);
return result;
}

original_code:
void xurfaced_menu_activate(struct xurfaced_menu *menu)
{
    if (strlen(menu->opts->current->command))
        xurfaced_execute(menu->opts->current->command, 0);
}


decompiled_code:
__int64 __fastcall xurfaced_menu_next(_QWORD **a1, int a2)
{
_QWORD *v2; // rdi
__int64 result; // rax
__int64 v4; // rcx

v2 = *a1;
result = v2[1];
v4 = *(_QWORD *)(*v2 + 72LL);
if ( v4 != result )
{
for ( result = *(_QWORD *)(result + 64); result; result = *(_QWORD *)(result + 64) )
{
if ( **(_BYTE **)(result + 8) )
{
--a2;
if ( v4 == result || !a2 )
break;
}
}
v2[1] = result;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(_QWORD **a1, int a2)
{
_QWORD *v2; // rdi
__int64 result; // rax
__int64 v4; // rcx

v2 = *a1;
result = v2[1];
v4 = *(_QWORD *)(*v2 + 72LL);
if ( v4 != result )
{
for ( result = *(_QWORD *)(result + 64); result; result = *(_QWORD *)(result + 64) )
{
if ( **(_BYTE **)(result + 8) )
{
--a2;
if ( v4 == result || !a2 )
break;
}
}
v2[1] = result;
}
return result;
}

original_code:
void xurfaced_menu_next(struct xurfaced_menu *menu, unsigned int num)
{
    struct xurfaced_menu_option *option = menu->opts->current;
    if (option == menu->opts->head->prev)
        return;
    while ((option = option->next))
    {
        if (!strlen(option->name))
            continue;
        if (!--num)
            break;
        if (option == menu->opts->head->prev)
            break;
    }
    menu->opts->current = option;
}

variable_types:
num
unsigned int


decompiled_code:
double __fastcall xurfaced_render_convert(unsigned __int8 a1)
{
return (double)a1 / 255.0;
}

canonical_decompiled_code:
double __fastcall func0(unsigned __int8 a1)
{
return (double)a1 / 255.0;
}

original_code:
static double xurfaced_render_convert(unsigned int value)
{
    return (double)(value & 0xFF) / (double)0xFF;
}

variable_types:
value
unsigned int

return_type: double


decompiled_code:
__int64 __fastcall xurfaced_render_blit_background(int a1, int a2)
{
cairo_rectangle(xurfacedRenderCairo, 0.0, 0.0, (double)a1, (double)a2);
cairo_set_source(xurfacedRenderCairo, xurfacedRenderCairoBackgroundPattern);
cairo_fill_preserve(xurfacedRenderCairo);
cairo_set_source_surface(xurfacedRenderCairo, xurfacedRenderCairoBackgroundImage, 0.0);
cairo_fill_preserve(xurfacedRenderCairo);
cairo_set_source_rgba(xurfacedRenderCairo, 0.0, 0.0, 0.0, 0.8);
return cairo_fill(xurfacedRenderCairo);
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1, int a2)
{
cairo_rectangle(xurfacedRenderCairo, 0.0, 0.0, (double)a1, (double)a2);
cairo_set_source(xurfacedRenderCairo, xurfacedRenderCairoBackgroundPattern);
cairo_fill_preserve(xurfacedRenderCairo);
cairo_set_source_surface(xurfacedRenderCairo, xurfacedRenderCairoBackgroundImage, 0.0);
cairo_fill_preserve(xurfacedRenderCairo);
cairo_set_source_rgba(xurfacedRenderCairo, 0.0, 0.0, 0.0, 0.8);
return cairo_fill(xurfacedRenderCairo);
}

original_code:
static void xurfaced_render_blit_background(int width, int height)
{
    cairo_rectangle(xurfacedRenderCairo, 0, 0, width, height);
    cairo_set_source(xurfacedRenderCairo, xurfacedRenderCairoBackgroundPattern);
    cairo_fill_preserve(xurfacedRenderCairo);
    cairo_set_source_surface(xurfacedRenderCairo, xurfacedRenderCairoBackgroundImage, 0, 0);
    cairo_fill_preserve(xurfacedRenderCairo);
    cairo_set_source_rgba(xurfacedRenderCairo, 0.0, 0.0, 0.0, 0.8);
    cairo_fill(xurfacedRenderCairo);
}

variable_types: width int

variable_types: height int


decompiled_code:
void __fastcall limb_litem_destroy(void *ptr, void (__fastcall *a2)(_QWORD))
{
if ( a2 )
a2(*(_QWORD *)ptr);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func0(void *ptr, void (__fastcall *a2)(_QWORD))
{
if ( a2 )
a2(*(_QWORD *)ptr);
free(ptr);
}

original_code:
void limb_litem_destroy(struct limb_litem *item, void (*pre_callback)(void *data))
{
    if (pre_callback)
        pre_callback(item->data);
    free(item);
}

variable_types: struct limb_litem { void *data; struct limb_litem *next; } *


decompiled_code:
__int64 __fastcall limb_llist_count(__int64 *a1)
{
__int64 v1; // rax
unsigned int v2; // edx

v1 = *a1;
if ( !*a1 )
return 0;
v2 = 0;
do
{
++v2;
v1 = *(_QWORD *)(v1 + 8);
}
while ( v1 );
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 *a1)
{
__int64 v1; // rax
unsigned int v2; // edx

v1 = *a1;
if ( !*a1 )
return 0;
v2 = 0;
do
{
++v2;
v1 = *(_QWORD *)(v1 + 8);
}
while ( v1 );
return v2;
}

original_code:
unsigned int limb_llist_count(struct limb_llist *list)
{
    struct limb_litem *current;
    unsigned int i = 0;
    for (current = list->head; current; current = current->next)
        i++;
    return i;
}

variable_types: struct limb_llist { struct limb_litem { void *data; struct limb_litem *next; } *head; } *

return_type: unsigned int

user_defined_types: struct limb_llist { struct limb_litem *head; }


decompiled_code:
_QWORD *limb_llist_create()
{
_QWORD *result; // rax

result = malloc(8uLL);
*result = 0LL;
return result;
}

canonical_decompiled_code:
_QWORD *func3()
{
_QWORD *result; // rax

result = malloc(8uLL);
*result = 0LL;
return result;
}

original_code:
struct limb_llist *limb_llist_create()
{
    struct limb_llist *list = (struct limb_llist *)malloc(sizeof (struct limb_llist));
    list->head = 0;
    return list;
}

return_type: struct limb_llist { struct limb_litem { void *data; struct limb_litem *next; } *head; } *


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

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

original_code:
void limb_llist_destroy(struct limb_llist *list)
{
    free(list);
}

user_defined_types: struct limb_litem { void *data; struct limb_litem *next; }


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

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

original_code:
void limb_literator_destroy(struct limb_literator *iterator)
{
    free(iterator);
}

variable_types: struct limb_literator { struct limb_llist { struct limb_litem { void *data; struct limb_litem *next; } *head; } *list; struct limb_litem *current; } *

user_defined_types: struct limb_literator { struct limb_llist *list; struct limb_litem *current; }


decompiled_code:
void __fastcall limb_literator_reset(__int64 a1)
{
*(_QWORD *)(a1 + 8) = 0LL;
}

canonical_decompiled_code:
void __fastcall func9(__int64 a1)
{
*(_QWORD *)(a1 + 8) = 0LL;
}

original_code:
void limb_literator_reset(struct limb_literator *iterator)
{
    iterator->current = 0;
}


original_code:
void remove_pair_at(int num_pairs, char **pairs, int p) {
  int i = 0;
  if (pairs[p] != ((void *)0)) free(pairs[p]);
  pairs[p] = ((void *)0);
  for (i = p; i < num_pairs; i++) {
    pairs[i] = pairs[i + 1];
  }
}

variable_types:
pairs
char **

variable_types: p int

variable_types: i int


decompiled_code:
__int64 __fastcall get_num_pairs(char *a1)
{
char v1; // al
char *v2; // rdi
unsigned int v3; // edx

v1 = *a1;
if ( !*a1 )
return 0;
v2 = a1 + 1;
v3 = 0;
do
{
if ( v1 != 32 )
v3 -= ((*v2 & 0xDF) == 0) - 1;
v1 = *v2++;
}
while ( v1 );
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func8(char *a1)
{
char v1; // al
char *v2; // rdi
unsigned int v3; // edx

v1 = *a1;
if ( !*a1 )
return 0;
v2 = a1 + 1;
v3 = 0;
do
{
if ( v1 != 32 )
v3 -= ((*v2 & 0xDF) == 0) - 1;
v1 = *v2++;
}
while ( v1 );
return v3;
}

original_code:
int get_num_pairs(char *str) {
  int i = 0;
  int num_pairs = 0;
  while (str[i] != '\0') {
    if (!((*(str + i) == ' ') || (*(str + i + 1) == ' ') || (*(str + i + 1) == '\0'))) {
      num_pairs++;
    }
    i++;
  }
  return num_pairs;
}

variable_types:
str
char *


decompiled_code:
void __fastcall destroy_letter_pairs(int a1, void **a2)
{
void **v2; // rbx

if ( a1 > 0 )
{
v2 = a2;
do
{
if ( *v2 )
free(*v2);
++v2;
}
while ( v2 != &a2[(unsigned int)(a1 - 1) + 1] );
}
free(a2);
}

canonical_decompiled_code:
void __fastcall func9(int a1, void **a2)
{
void **v2; // rbx

if ( a1 > 0 )
{
v2 = a2;
do
{
if ( *v2 )
free(*v2);
++v2;
}
while ( v2 != &a2[(unsigned int)(a1 - 1) + 1] );
}
free(a2);
}

original_code:
void destroy_letter_pairs(int num_pairs, char **pairs) {
  int i = 0;
  for (i = 0; i < num_pairs; i++) {
    if (pairs[i] != ((void *)0)) free(pairs[i]);
  }
  free(pairs);
}


decompiled_code:
double __fastcall white_similarity(char *a1, char *a2)
{
int v2; // er14
int v3; // er12
void **v4; // r15
void **v5; // rbx
void **v6; // rbp
__int64 v7; // r13
int v8; // er15
__int64 v9; // rax
_BYTE *v10; // rdx
void **v12; // [rsp+0h] [rbp-48h]
int v13; // [rsp+Ch] [rbp-3Ch]

v2 = get_num_pairs(a1);
v3 = get_num_pairs(a2);
v4 = (void **)letter_pairs(v2, a1);
v12 = v4;
v5 = (void **)letter_pairs(v3, a2);
v13 = v2 + v3;
if ( v2 <= 0 )
{
v8 = 0;
}
else
{
v6 = v4;
v7 = (__int64)&v4[(unsigned int)(v2 - 1) + 1];
v8 = 0;
do
{
if ( v3 > 0 )
{
v9 = 0LL;
while ( 1 )
{
v10 = v5[v9];
if ( *(_BYTE *)*v6 == *v10 && *((_BYTE *)*v6 + 1) == v10[1] )
break;
if ( ++v9 == v3 )
goto LABEL_7;
}
++v8;
remove_pair_at(--v3, (__int64)v5, v9);
}
LABEL_7:
++v6;
}
while ( v6 != (void **)v7 );
}
destroy_letter_pairs(v2, v12);
destroy_letter_pairs(v3, v5);
return ((double)v8 + (double)v8) / (double)v13;
}

original_code:
double white_similarity(char *str1, char *str2) {
  int num_pairs1 = get_num_pairs(str1);
  int num_pairs2 = get_num_pairs(str2);
  char **pairs1 = letter_pairs(num_pairs1, str1);
  char **pairs2 = letter_pairs(num_pairs2, str2);
  int i = 0;
  int j = 0;
  int intersection = 0;
  int sum = num_pairs1 + num_pairs2;
  for (i = 0; i < num_pairs1; i++) {
    for (j = 0; j < num_pairs2; j++) {
      if ((pairs1[i][0] == pairs2[j][0] && pairs1[i][1] == pairs2[j][1])) {
        intersection++;
        num_pairs2--;
        remove_pair_at(num_pairs2, pairs2, j);
        break;
      }
    }
  }
  destroy_letter_pairs(num_pairs1, pairs1);
  destroy_letter_pairs(num_pairs2, pairs2);
  return (2.0 * intersection) / sum;
}

variable_types: j int

variable_types: intersection int

variable_types: sum int


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
double v3; // xmm0_8
int result; // eax

if ( argc <= 2 )
{
puts("Please supply two strings to compare.");
result = 1;
}
else
{
v3 = white_similarity((char *)argv[1], (char *)argv[2]);
printf("White Similarity for '%s' and '%s' is %f\n", argv[1], argv[2], v3);
result = 0;
}
return result;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
double v3; // xmm0_8
int result; // eax

if ( argc <= 2 )
{
puts("Please supply two strings to compare.");
result = 1;
}
else
{
v3 = func10((char *)argv[1], (char *)argv[2]);
printf("White Similarity for '%s' and '%s' is %f\n", argv[1], argv[2], v3);
result = 0;
}
return result;
}

original_code:
int main(int argc, char *argv[]) {
  double d;
  if (argc < 3) {
    printf("Please supply two strings to compare.\n");
    return 1;
  }
  d = white_similarity(argv[1], argv[2]);
  printf("White Similarity for '%s' and '%s' is %f\n", argv[1], argv[2], d);
  return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: d double


decompiled_code:
__int64 __fastcall ft_save_grid_size(__int64 a1, __int64 a2, int *a3, int *a4)
{
int v6; // eax
__int64 result; // rax

*a3 = ft_atoi(a2);
v6 = ft_atoi(a1);
*a4 = v6;
if ( *a3 <= 6 )
{
ft_putstr(a1);
ft_putendl("\x1B[33m: is not a valable argument\x1B[0m");
ft_putendl("\x1B[33mAt least 7 columns are needed\x1B[0m");
result = 0xFFFFFFFFLL;
}
else if ( v6 <= 5 )
{
ft_putstr(a2);
ft_putendl("\x1B[33m: is not a valable argument\x1B[0m");
ft_putendl("\x1B[33mAt least 6 lines are needed\x1B[0m");
result = 0xFFFFFFFFLL;
}
else
{
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, int *a3, int *a4)
{
int v6; // eax
__int64 result; // rax

*a3 = ft_atoi(a2);
v6 = ft_atoi(a1);
*a4 = v6;
if ( *a3 <= 6 )
{
ft_putstr(a1);
ft_putendl("\x1B[33m: is not a valable argument\x1B[0m");
ft_putendl("\x1B[33mAt least 7 columns are needed\x1B[0m");
result = 0xFFFFFFFFLL;
}
else if ( v6 <= 5 )
{
ft_putstr(a2);
ft_putendl("\x1B[33m: is not a valable argument\x1B[0m");
ft_putendl("\x1B[33mAt least 6 lines are needed\x1B[0m");
result = 0xFFFFFFFFLL;
}
else
{
result = 0LL;
}
return result;
}

original_code:
static int ft_save_grid_size(char *s1, char *s2, int *li, int *co)
{
 *li = ft_atoi(s2);
 *co = ft_atoi(s1);
 if (*li < 7)
 {
  ft_putstr(s1);
  ft_putendl("\033[33m: is not a valable argument\033[0m");
  ft_putendl("\033[33mAt least 7 columns are needed\033[0m");
  return (-1);
 }
 if (*co < 6)
 {
  ft_putstr(s2);
  ft_putendl("\033[33m: is not a valable argument\033[0m");
  ft_putendl("\033[33mAt least 6 lines are needed\033[0m");
  return (-1);
 }
 return (0);
}

variable_types:
li
int *

variable_types:
co
int *


decompiled_code:
__int64 __fastcall ft_init_grid(_QWORD *a1, int a2, int a3)
{
void *v4; // rax
__int64 v5; // rbx
_QWORD *v6; // r13
void *v7; // rax
__int64 v8; // rax
__int64 result; // rax

v4 = malloc(8LL * (a2 + 1));
*a1 = v4;
if ( !v4 )
return 0xFFFFFFFFLL;
if ( a2 <= 0 )
{
LABEL_10:
*(_QWORD *)(*a1 + 8LL * (a2 + 1) - 8) = 0LL;
result = 0LL;
}
else
{
v5 = 0LL;
while ( 1 )
{
v6 = (_QWORD *)(*a1 + v5);
v7 = malloc(a3 + 1);
*v6 = v7;
if ( !v7 )
break;
if ( a3 > 0 )
{
v8 = 0LL;
do
*(_BYTE *)(*(_QWORD *)(*a1 + v5) + v8++) = 46;
while ( a3 != v8 );
}
*(_BYTE *)(*(_QWORD *)(*a1 + v5) + a3) = 0;
v5 += 8LL;
if ( v5 == 8LL * (unsigned int)a2 )
goto LABEL_10;
}
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(_QWORD *a1, int a2, int a3)
{
void *v4; // rax
__int64 v5; // rbx
_QWORD *v6; // r13
void *v7; // rax
__int64 v8; // rax
__int64 result; // rax

v4 = malloc(8LL * (a2 + 1));
*a1 = v4;
if ( !v4 )
return 0xFFFFFFFFLL;
if ( a2 <= 0 )
{
LABEL_10:
*(_QWORD *)(*a1 + 8LL * (a2 + 1) - 8) = 0LL;
result = 0LL;
}
else
{
v5 = 0LL;
while ( 1 )
{
v6 = (_QWORD *)(*a1 + v5);
v7 = malloc(a3 + 1);
*v6 = v7;
if ( !v7 )
break;
if ( a3 > 0 )
{
v8 = 0LL;
do
*(_BYTE *)(*(_QWORD *)(*a1 + v5) + v8++) = 46;
while ( a3 != v8 );
}
*(_BYTE *)(*(_QWORD *)(*a1 + v5) + a3) = 0;
v5 += 8LL;
if ( v5 == 8LL * (unsigned int)a2 )
goto LABEL_10;
}
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
static int ft_init_grid(char ***grid, int li, int co)
{
 int i;
 int j;
 if (!(*grid = (char **)malloc(sizeof(char *) * (li + 1))))
  return (-1);
 i = 0;
 while (i < li)
 {
  if (!((*grid)[i] = (char *)malloc(sizeof(char) * (co + 1))))
   return (-1);
  j = 0;
  while (j < co)
  {
   (*grid)[i][j] = '.';
   ++j;
  }
  (*grid)[i][co] = '\0';
  ++i;
 }
 (*grid)[li] = ((void *)0);
 return (0);
}

variable_types:
grid
char ***

variable_types: li int

variable_types: co int


decompiled_code:
__int64 __fastcall ft_init_grid_of_choices(_QWORD *a1, int a2)
{
void *v2; // rax
__int64 v3; // rax

v2 = malloc(4LL * a2);
*a1 = v2;
if ( !v2 )
return 0xFFFFFFFFLL;
if ( a2 <= 0 )
return 0LL;
v3 = 0LL;
do
{
*(_DWORD *)(*a1 + v3) = 0;
v3 += 4LL;
}
while ( v3 != 4LL * (unsigned int)a2 );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(_QWORD *a1, int a2)
{
void *v2; // rax
__int64 v3; // rax

v2 = malloc(4LL * a2);
*a1 = v2;
if ( !v2 )
return 0xFFFFFFFFLL;
if ( a2 <= 0 )
return 0LL;
v3 = 0LL;
do
{
*(_DWORD *)(*a1 + v3) = 0;
v3 += 4LL;
}
while ( v3 != 4LL * (unsigned int)a2 );
return 0LL;
}

original_code:
static int ft_init_grid_of_choices(int **choices, int li)
{
 int i;
 if (!((*choices) = (int *)malloc(sizeof(int) * li)))
  return (-1);
 i = 0;
 while (i < li)
 {
  (*choices)[i] = 0;
  ++i;
 }
 return (0);
}

variable_types:
choices
int **


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int result; // eax
_QWORD v4[4]; // [rsp+0h] [rbp-68h] BYREF
_QWORD v5[4]; // [rsp+20h] [rbp-48h] BYREF
__int64 v6; // [rsp+40h] [rbp-28h] BYREF
int v7; // [rsp+48h] [rbp-20h] BYREF
int v8[7]; // [rsp+4Ch] [rbp-1Ch] BYREF

if ( (argc & 0xFFFFFFFD) != 1 )
{
ft_putendl("\x1B[33m0 or 2 arguments needed to play\x1B[0m");
return -1;
}
if ( argc == 1 )
{
v8[0] = 6;
v7 = 7;
}
else if ( argc == 3 )
{
result = ft_save_grid_size((__int64)argv[1], (__int64)argv[2], &v7, v8);
if ( result == -1 )
return result;
}
result = ft_init_grid(&v6, v7, v8[0]);
if ( result != -1 )
{
result = ft_init_grid_of_choices(v5, v7);
if ( result != -1 )
{
result = ft_init_grid_of_choices(v4, v7);
if ( result != -1 )
result = -((unsigned int)ft_play_the_game(&v6, v5, v4) == -1);
}
}
return result;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int result; // eax
_QWORD v4[4]; // [rsp+0h] [rbp-68h] BYREF
_QWORD v5[4]; // [rsp+20h] [rbp-48h] BYREF
__int64 v6; // [rsp+40h] [rbp-28h] BYREF
int v7; // [rsp+48h] [rbp-20h] BYREF
int v8[7]; // [rsp+4Ch] [rbp-1Ch] BYREF

if ( (argc & 0xFFFFFFFD) != 1 )
{
ft_putendl("\x1B[33m0 or 2 arguments needed to play\x1B[0m");
return -1;
}
if ( argc == 1 )
{
v8[0] = 6;
v7 = 7;
}
else if ( argc == 3 )
{
result = func0((__int64)argv[1], (__int64)argv[2], &v7, v8);
if ( result == -1 )
return result;
}
result = func1(&v6, v7, v8[0]);
if ( result != -1 )
{
result = func2(v5, v7);
if ( result != -1 )
{
result = func2(v4, v7);
if ( result != -1 )
result = -((unsigned int)ft_play_the_game(&v6, v5, v4) == -1);
}
}
return result;
}

original_code:
int main(int ac, char **av)
{
 t_all a;
 t_s me;
 t_s you;
 if (ac != 3 && ac != 1)
 {
  ft_putendl("\033[33m0 or 2 arguments needed to play\033[0m");
  return (-1);
 }
 if (ac == 1)
 {
  a.co = 6;
  a.li = 7;
 }
 if (ac == 3 && ft_save_grid_size(av[1], av[2], &(a.li), &(a.co)) == -1)
  return (-1);
 if (ft_init_grid(&(a.grid), a.li, a.co) == -1)
  return (-1);
 if ((ft_init_grid_of_choices(&(me.choices), a.li) == -1)
  || (ft_init_grid_of_choices(&(you.choices), a.li) == -1))
  return (-1);
 if (ft_play_the_game(&a, &me, &you) == -1)
  return (-1);
 return (0);
}

canonical_original_code:
int main(int ac, char **av)
{
 struct s_all a;
 struct s_s me;
 struct s_s you;
 if (ac != 3 && ac != 1)
 {
  ft_putendl("\033[33m0 or 2 arguments needed to play\033[0m");
  return (-1);
 }
 if (ac == 1)
 {
  a.co = 6;
  a.li = 7;
 }
 if (ac == 3 && ft_save_grid_size(av[1], av[2], &(a.li), &(a.co)) == -1)
  return (-1);
 if (ft_init_grid(&(a.grid), a.li, a.co) == -1)
  return (-1);
 if ((ft_init_grid_of_choices(&(me.choices), a.li) == -1)
  || (ft_init_grid_of_choices(&(you.choices), a.li) == -1))
  return (-1);
 if (ft_play_the_game(&a, &me, &you) == -1)
  return (-1);
 return (0);
}

variable_types: ac int

variable_types:
av
char **

variable_types: struct s_all { char **grid; int li; int co; int i; int j; }

variable_types: struct s_s { int *choices; int *save; char symb1; char symb2; int keep; }


decompiled_code:
__int64 __fastcall ft_bin_to_str(_BYTE *a1)
{
_BYTE *v1; // rax
char v2; // dl
char v3; // cl
int v4; // eax
__int64 result; // rax

v1 = a1 + 7;
v2 = 0;
v3 = 1;
while ( 1 )
{
if ( *v1 == 49 )
v2 += v3;
v3 *= 2;
if ( v1 == a1 )
break;
--v1;
}
v4 = j_3;
*(_BYTE *)(str + j_3) = v2;
result = (unsigned int)(v4 + 1);
j_3 = result;
if ( ++nb_bit == len )
{
*(_BYTE *)(str + (int)result) = 0;
ft_putendl(str);
j_3 = 0;
result = gfree(str);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(_BYTE *a1)
{
_BYTE *v1; // rax
char v2; // dl
char v3; // cl
int v4; // eax
__int64 result; // rax

v1 = a1 + 7;
v2 = 0;
v3 = 1;
while ( 1 )
{
if ( *v1 == 49 )
v2 += v3;
v3 *= 2;
if ( v1 == a1 )
break;
--v1;
}
v4 = j_3;
*(_BYTE *)(str + j_3) = v2;
result = (unsigned int)(v4 + 1);
j_3 = result;
if ( ++nb_bit == len )
{
*(_BYTE *)(str + (int)result) = 0;
func14(str);
j_3 = 0;
result = func17(str);
}
return result;
}

original_code:
void ft_bin_to_str(char *one_byte)
{
 int k;
 int i;
 int c;
 static int j = 0;
 k = 1;
 c = 0;
 i = 8;
 while (--i >= 0)
 {
  if (one_byte[i] == '1')
   c += k;
  k *= 2;
 }
 str[j] = c;
 ++j;
 ++nb_bit;
 if (nb_bit == len)
 {
  str[j] = '\0';
  ft_putendl(str);
  j = 0;
  gfree((void *)str);
 }
}

variable_types: k int

variable_types: i int

variable_types: c int


decompiled_code:
__int64 __fastcall ft_bin_to_len(_BYTE *a1, __int64 a2)
{
_BYTE *v2; // rax
unsigned int v3; // ebx
__int64 v4; // rdx

v2 = a1 + 31;
v3 = 0;
LODWORD(v4) = 1;
while ( 1 )
{
if ( *v2 == 49 )
v3 += v4;
v4 = (unsigned int)(2 * v4);
if ( v2 == a1 )
break;
--v2;
}
ft_putstr("len = ", a2, v4, v2 - 1);
ft_putnbr(v3);
ft_putchar(10LL);
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func8(_BYTE *a1, __int64 a2)
{
_BYTE *v2; // rax
unsigned int v3; // ebx
__int64 v4; // rdx

v2 = a1 + 31;
v3 = 0;
LODWORD(v4) = 1;
while ( 1 )
{
if ( *v2 == 49 )
v3 += v4;
v4 = (unsigned int)(2 * v4);
if ( v2 == a1 )
break;
--v2;
}
func16("len = ", a2, v4, v2 - 1);
func15(v3);
func13(10LL);
return v3;
}

original_code:
int ft_bin_to_len(char *str_len)
{
 int k;
 int i;
 int c;
 k = 1;
 c = 0;
 i = 32;
 while (--i >= 0)
 {
  if (str_len[i] == '1')
   c += k;
  k *= 2;
 }
 ft_putstr("len = ");
 ft_putnbr(c);
 ft_putchar('\n');
 return (c);
}


decompiled_code:
__int64 __fastcall ft_bin_to_pid(_BYTE *a1)
{
_BYTE *v1; // rax
__int64 v2; // rdx
__int64 v3; // rcx

v1 = a1 + 31;
v2 = 0LL;
LODWORD(v3) = 1;
while ( 1 )
{
if ( *v1 == 49 )
v2 = (unsigned int)(v2 + v3);
v3 = (unsigned int)(2 * v3);
if ( v1 == a1 )
break;
--v1;
}
pid = v2;
ft_putstr("pid = ", v1 - 1, v2, v3);
ft_putnbr((unsigned int)pid);
return ft_putchar(10LL);
}

canonical_decompiled_code:
__int64 __fastcall func9(_BYTE *a1)
{
_BYTE *v1; // rax
__int64 v2; // rdx
__int64 v3; // rcx

v1 = a1 + 31;
v2 = 0LL;
LODWORD(v3) = 1;
while ( 1 )
{
if ( *v1 == 49 )
v2 = (unsigned int)(v2 + v3);
v3 = (unsigned int)(2 * v3);
if ( v1 == a1 )
break;
--v1;
}
pid = v2;
func16("pid = ", v1 - 1, v2, v3);
func15((unsigned int)pid);
return func13(10LL);
}

original_code:
void ft_bin_to_pid(char *str_pid)
{
 int k;
 int i;
 int c;
 k = 1;
 c = 0;
 i = 32;
 while (--i >= 0)
 {
  if (str_pid[i] == '1')
   c += k;
  k *= 2;
 }
 pid = c;
 ft_putstr("pid = ");
 ft_putnbr(pid);
 ft_putchar('\n');
}


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

if ( a1 == 10 )
{
one_byte[i_2] = 49;
}
else if ( a1 == 12 )
{
one_byte[i_2] = 48;
}
result = (unsigned int)(i_2 - 1);
if ( i_2 - 1 < 0 )
{
i_2 = 7;
result = ft_bin_to_str(one_byte);
}
else
{
--i_2;
}
return result;
}

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

if ( a1 == 10 )
{
one_byte[i_2] = 49;
}
else if ( a1 == 12 )
{
one_byte[i_2] = 48;
}
result = (unsigned int)(i_2 - 1);
if ( i_2 - 1 < 0 )
{
i_2 = 7;
result = func7(one_byte);
}
else
{
--i_2;
}
return result;
}

original_code:
void ft_signal_str(int sign)
{
 static int i = 7;
 if (sign == 10)
 {
  one_byte[i] = '1';
 }
 else if (sign == 12)
 {
  one_byte[i] = '0';
 }
 --i;
 if (i < 0)
 {
  i = 7;
  ft_bin_to_str(one_byte);
 }
}

variable_types: sign int


decompiled_code:
__int64 __fastcall ft_signal_len(int a1, int *a2)
{
int v2; // eax
bool v3; // sf
__int64 result; // rax

v2 = *a2;
if ( *a2 < 0 )
return ft_signal_str(a1);
if ( a1 == 10 )
{
str_pid[v2] = 49;
}
else if ( a1 == 12 )
{
str_pid[v2] = 48;
}
v3 = *a2 - 1 < 0;
result = (unsigned int)(*a2 - 1);
*a2 = result;
if ( v3 )
{
len = ft_bin_to_len(str_pid, (__int64)a2);
result = gmalloc(len + 1);
str = result;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(int a1, int *a2)
{
int v2; // eax
bool v3; // sf
__int64 result; // rax

v2 = *a2;
if ( *a2 < 0 )
return func10(a1);
if ( a1 == 10 )
{
str_pid[v2] = 49;
}
else if ( a1 == 12 )
{
str_pid[v2] = 48;
}
v3 = *a2 - 1 < 0;
result = (unsigned int)(*a2 - 1);
*a2 = result;
if ( v3 )
{
len = func8(str_pid, (__int64)a2);
result = func18(len + 1);
str = result;
}
return result;
}

original_code:
void ft_signal_len(int sign, int *j)
{
 if (*j < 0)
  ft_signal_str(sign);
 else
 {
  if (sign == 10)
   str_pid[*j] = '1';
  else if (sign == 12)
   str_pid[*j] = '0';
  --(*j);
  if (*j < 0)
  {
   len = ft_bin_to_len(str_pid);
   str = (char *)gmalloc(sizeof(char) * (len + 1));
  }
 }
}

variable_types:
j
int *


decompiled_code:
void __fastcall ft_signal_pid(int a1)
{
int v1; // eax

if ( nb_bit == len && len )
{
j_0 = 31;
nb_bit = 0;
len = 0;
v1 = 31;
}
else
{
v1 = i_1;
if ( i_1 < 0 )
{
ft_signal_len(a1, &j_0);
return;
}
}
if ( a1 == 10 )
{
str_pid[v1] = 49;
}
else if ( a1 == 12 )
{
str_pid[v1] = 48;
}
i_1 = v1 - 1;
if ( v1 - 1 < 0 )
ft_bin_to_pid(str_pid);
}

original_code:
void ft_signal_pid(int sign)
{
 static int i = 31;
 static int j = 31;
 if (nb_bit == len && len != 0)
 {
  i = 31;
  j = 31;
  nb_bit = 0;
  len = 0;
 }
 if (i < 0)
  ft_signal_len(sign, &j);
 else
 {
  if (sign == 10)
   str_pid[i] = '1';
  else if (sign == 12)
   str_pid[i] = '0';
  --i;
  if (i < 0)
   ft_bin_to_pid(str_pid);
 }
}

variable_types: j int


decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
int *v4; // rax
char *v5; // rax

nb_bit = 0;
len = 0;
v3 = getpid();
ft_putnbr(v3);
ft_putchar(10LL);
one_byte[0] = 48;
byte_404091 = 48;
byte_404092 = 48;
byte_404093 = 48;
byte_404094 = 48;
byte_404095 = 48;
byte_404096 = 48;
byte_404097 = 48;
v4 = (int *)str_pid;
do
{
*(_BYTE *)v4 = 48;
v4 = (int *)((char *)v4 + 1);
}
while ( &j_3 != v4 );
v5 = (char *)&str_len;
do
*v5++ = 48;
while ( v5 != str_pid );
signal(10, ft_signal_pid);
signal(12, ft_signal_pid);
while ( 1 )
;
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
int *v4; // rax
char *v5; // rax

nb_bit = 0;
len = 0;
v3 = getpid();
func15(v3);
func13(10LL);
one_byte[0] = 48;
byte_404091 = 48;
byte_404092 = 48;
byte_404093 = 48;
byte_404094 = 48;
byte_404095 = 48;
byte_404096 = 48;
byte_404097 = 48;
v4 = (int *)str_pid;
do
{
*(_BYTE *)v4 = 48;
v4 = (int *)((char *)v4 + 1);
}
while ( &j_3 != v4 );
v5 = (char *)&str_len;
do
*v5++ = 48;
while ( v5 != str_pid );
signal(10, ft_signal_pid);
signal(12, ft_signal_pid);
while ( 1 )
;
}

original_code:
int main(void)
{
 int j;
 nb_bit = 0;
 len = 0;
 ft_putnbr(getpid());
 ft_putchar('\n');
 j = 0;
 while (j < 8)
 {
  one_byte[j] = '0';
  ++j;
 }
 j = 0;
 while (j < 32)
 {
  str_pid[j] = '0';
  ++j;
 }
 j = 0;
 while (j < 32)
 {
  str_len[j] = '0';
  ++j;
 }
 signal(10, ft_signal_pid);
 signal(12, ft_signal_pid);
 while (1)
  ;
 return (0);
}

canonical_original_code:
int main()
{
 int j;
 nb_bit = 0;
 len = 0;
 ft_putnbr(getpid());
 ft_putchar('\n');
 j = 0;
 while (j < 8)
 {
  one_byte[j] = '0';
  ++j;
 }
 j = 0;
 while (j < 32)
 {
  str_pid[j] = '0';
  ++j;
 }
 j = 0;
 while (j < 32)
 {
  str_len[j] = '0';
  ++j;
 }
 signal(10, ft_signal_pid);
 signal(12, ft_signal_pid);
 while (1)
  ;
 return (0);
}


decompiled_code:
double __fastcall ft_vect_norm(double *a1)
{
double v1; // xmm0_8
double result; // xmm0_8

v1 = a1[2] * a1[2] + *a1 * *a1 + a1[1] * a1[1];
if ( v1 < 0.0 )
result = sqrt(v1);
else
result = sqrt(v1);
return result;
}

canonical_decompiled_code:
double __fastcall func0(double *a1)
{
double v1; // xmm0_8
double result; // xmm0_8

v1 = a1[2] * a1[2] + *a1 * *a1 + a1[1] * a1[1];
if ( v1 < 0.0 )
result = sqrt(v1);
else
result = sqrt(v1);
return result;
}

original_code:
double ft_vect_norm(t_v *vect)
{
 return (sqrt(vect->x * vect->x + vect->y * vect->y + vect->z * vect->z));
}

canonical_original_code:
double ft_vect_norm(struct s_v *vect)
{
 return (sqrt(vect->x * vect->x + vect->y * vect->y + vect->z * vect->z));
}

variable_types: struct s_v { double x; double y; double z; } *


original_code:
void ft_normalize_vect(t_v *vect)
{
 double norm;
 norm = ft_vect_norm(vect);
 vect->x *= 1 / norm;
 vect->y *= 1 / norm;
 vect->z *= 1 / norm;
}

canonical_original_code:
void ft_normalize_vect(struct s_v *vect)
{
 double norm;
 norm = ft_vect_norm(vect);
 vect->x *= 1 / norm;
 vect->y *= 1 / norm;
 vect->z *= 1 / norm;
}

variable_types: norm double

user_defined_types: struct s_v { double x; double y; double z; }