decompiled_code:
__int64 __fastcall check_octal(_BYTE *a1, _BYTE *a2)
{
_BYTE *v2; // rax
unsigned int v3; // edx

if ( a1 == a2 )
return 1LL;
v2 = a1;
while ( 1 )
{
v3 = *v2 & 0xDF;
LOBYTE(v3) = *v2 == 46 || (*v2 & 0xDF) == 69;
if ( (_BYTE)v3 )
break;
if ( a2 == ++v2 )
{
while ( (unsigned __int8)(*a1 - 56) > 1u )
{
if ( ++a1 == v2 )
return 1LL;
}
return v3;
}
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func2(_BYTE *a1, _BYTE *a2)
{
_BYTE *v2; // rax
unsigned int v3; // edx

if ( a1 == a2 )
return 1LL;
v2 = a1;
while ( 1 )
{
v3 = *v2 & 0xDF;
LOBYTE(v3) = *v2 == 46 || (*v2 & 0xDF) == 69;
if ( (_BYTE)v3 )
break;
if ( a2 == ++v2 )
{
while ( (unsigned __int8)(*a1 - 56) > 1u )
{
if ( ++a1 == v2 )
return 1LL;
}
return v3;
}
}
return v3;
}

original_code:
static _Bool check_octal(const char* start, const char* end) {
    for (const char* c = start; c != end; ++c) {
        if (*c == '.' || *c == 'E' || *c == 'e') {
            return 1;
        }
    }
    for (const char* c = start; c != end; ++c) {
        if (*c == '8' || *c == '9') {
            return 0;
        }
    }
    return 1;
}

canonical_original_code:
static _Bool check_octal(char *start, char *end) {
    for (char *c = start; c != end; ++c) {
        if (*c == '.' || *c == 'E' || *c == 'e') {
            return 1;
        }
    }
    for (char *c = start; c != end; ++c) {
        if (*c == '8' || *c == '9') {
            return 0;
        }
    }
    return 1;
}

variable_types:
start
char *

variable_types:
end
char *

variable_types:
c
char *


repo: novalis/cexpr

decompiled_code:
__int64 __fastcall read_hex_literal(unsigned __int8 **a1)
{
unsigned __int8 *v2; // rdi
unsigned __int8 v3; // al
unsigned __int8 *v4; // rcx
bool v5; // r8
bool v6; // dl
unsigned __int8 *v8; // rcx
unsigned __int8 *v9; // [rsp+8h] [rbp-8h] BYREF

v2 = *a1;
v9 = v2;
v3 = *v2;
if ( !*v2 )
goto LABEL_9;
v4 = v2 + 1;
v5 = 0;
while ( 1 )
{
while ( 1 )
{
v2 = v4 - 1;
v6 = (unsigned __int8)(v3 - 48) > 9u && (unsigned __int8)((v3 & 0xDF) - 65) > 5u;
if ( v6 )
break;
v9 = v4;
v3 = *v4;
v2 = v4++;
if ( !v3 )
goto LABEL_8;
}
if ( v3 != 46 )
break;
if ( v5 )
goto LABEL_10;
v9 = v4;
v3 = *v4;
v2 = v4;
v5 = v6;
++v4;
if ( !v3 )
{
LABEL_8:
if ( !v5 )
goto LABEL_9;
goto LABEL_10;
}
}
if ( !v5 )
{
v2 = v9;
LABEL_9:
*a1 = v2;
return 1LL;
}
if ( v3 != 112 )
{
LABEL_10:
*a1 = v2;
return 0LL;
}
v9 = v4;
read_integer_literal(&v9);
v2 = v9;
if ( v8 != v9 )
goto LABEL_9;
*a1 = v8;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned __int8 **a1)
{
unsigned __int8 *v2; // rdi
unsigned __int8 v3; // al
unsigned __int8 *v4; // rcx
bool v5; // r8
bool v6; // dl
unsigned __int8 *v8; // rcx
unsigned __int8 *v9; // [rsp+8h] [rbp-8h] BYREF

v2 = *a1;
v9 = v2;
v3 = *v2;
if ( !*v2 )
goto LABEL_9;
v4 = v2 + 1;
v5 = 0;
while ( 1 )
{
while ( 1 )
{
v2 = v4 - 1;
v6 = (unsigned __int8)(v3 - 48) > 9u && (unsigned __int8)((v3 & 0xDF) - 65) > 5u;
if ( v6 )
break;
v9 = v4;
v3 = *v4;
v2 = v4++;
if ( !v3 )
goto LABEL_8;
}
if ( v3 != 46 )
break;
if ( v5 )
goto LABEL_10;
v9 = v4;
v3 = *v4;
v2 = v4;
v5 = v6;
++v4;
if ( !v3 )
{
LABEL_8:
if ( !v5 )
goto LABEL_9;
goto LABEL_10;
}
}
if ( !v5 )
{
v2 = v9;
LABEL_9:
*a1 = v2;
return 1LL;
}
if ( v3 != 112 )
{
LABEL_10:
*a1 = v2;
return 0LL;
}
v9 = v4;
func0(&v9);
v2 = v9;
if ( v8 != v9 )
goto LABEL_9;
*a1 = v8;
return 0LL;
}

original_code:
static _Bool read_hex_literal(const char** pos_ref) {
    char c;
    _Bool dot_seen = 0;
    const char* pos = *pos_ref;
    while ((c = *pos)) {
        if ((c < '0' || c > '9') && (c < 'A' || c > 'F') && (c < 'a' || c > 'f')) {
            if (c == '.') {
                if (dot_seen) {
                    *pos_ref = pos;
                    return 0;
                }
                dot_seen = 1;
                pos ++;
            } else {
                break;
            }
        } else {
            pos ++;
        }
    }
    if (dot_seen) {
        if (*pos != 'p') {
            *pos_ref = pos;
            return 0;
        }
        pos ++;
        const char* old_pos = pos;
        read_integer_literal(&pos);
        if (old_pos == pos) {
            *pos_ref = pos;
            return 0;
        }
    }
    *pos_ref = pos;
    return 1;
}

canonical_original_code:
static _Bool read_hex_literal(char **pos_ref) {
    char c;
    _Bool dot_seen = 0;
    char *pos = *pos_ref;
    while ((c = *pos)) {
        if ((c < '0' || c > '9') && (c < 'A' || c > 'F') && (c < 'a' || c > 'f')) {
            if (c == '.') {
                if (dot_seen) {
                    *pos_ref = pos;
                    return 0;
                }
                dot_seen = 1;
                pos ++;
            } else {
                break;
            }
        } else {
            pos ++;
        }
    }
    if (dot_seen) {
        if (*pos != 'p') {
            *pos_ref = pos;
            return 0;
        }
        pos ++;
        char *old_pos = pos;
        read_integer_literal(&pos);
        if (old_pos == pos) {
            *pos_ref = pos;
            return 0;
        }
    }
    *pos_ref = pos;
    return 1;
}

variable_types: c char

variable_types:
pos
char *


decompiled_code:
void __fastcall add_child_token_rule(char *a1, unsigned __int8 *a2, int a3)
{
unsigned __int8 *v4; // r12
__int64 i; // rbx
char *v7; // rax

v4 = a2;
for ( i = *a2; (_BYTE)i; i = *v4 )
{
v7 = *(char **)a1;
if ( !*(_QWORD *)a1 )
{
v7 = (char *)calloc(0x100uLL, 0x10uLL);
*(_QWORD *)a1 = v7;
}
++v4;
a1 = &v7[16 * i];
}
*((_DWORD *)a1 + 2) = a3;
}

canonical_decompiled_code:
void __fastcall func4(char *a1, unsigned __int8 *a2, int a3)
{
unsigned __int8 *v4; // r12
__int64 i; // rbx
char *v7; // rax

v4 = a2;
for ( i = *a2; (_BYTE)i; i = *v4 )
{
v7 = *(char **)a1;
if ( !*(_QWORD *)a1 )
{
v7 = (char *)calloc(0x100uLL, 0x10uLL);
*(_QWORD *)a1 = v7;
}
++v4;
a1 = &v7[16 * i];
}
*((_DWORD *)a1 + 2) = a3;
}

original_code:
static void add_child_token_rule(struct token_rule* rule, const char* text,
                          enum token_type token_type) {
    unsigned char c = *text;
    if (!c) {
        rule->token_type = token_type;
        return;
    }
    if (rule->children == 0) {
        rule->children = calloc(256, sizeof(struct token_rule));
    }
    add_child_token_rule(rule->children + c, text + 1, token_type);
}

canonical_original_code:
static void add_child_token_rule(struct token_rule *rule, char *text, enum token_type token_type) {
    unsigned char c = *text;
    if (!c) {
        rule->token_type = token_type;
        return;
    }
    if (rule->children == 0) {
        rule->children = calloc(256, sizeof(struct token_rule));
    }
    add_child_token_rule(rule->children + c, text + 1, token_type);
}

variable_types: struct token_rule { struct token_rule *children; enum token_type { LITERAL_OR_ID=1, OPEN_PAREN=2, CLOSE_PAREN=3, OPEN_BRACKET=4, CLOSE_BRACKET=5, OPEN_CURLY=6, CLOSE_CURLY=7, BANG=8, PERCENT=9, CARET=10, AMPERSAND=11, BAR=12, STAR=13, MINUS=14, PLUS=15, SLASH=16, LEFT_SHIFT=17, RIGHT_SHIFT=18, BANG_EQUAL=19, PERCENT_EQUAL=20, CARET_EQUAL=21, AMPERSAND_EQUAL=22, BAR_EQUAL=23, STAR_EQUAL=24, MINUS_EQUAL=25, PLUS_EQUAL=26, SLASH_EQUAL=27, LEFT_SHIFT_EQUAL=28, RIGHT_SHIFT_EQUAL=29, ARROW=30, DOT=31, ASSIGN=32, IS_EQUAL=33, LTE=34, GTE=35, LT=36, GT=37, DOUBLE_AMPERSAND=38, DOUBLE_BAR=39, DOUBLE_PLUS=40, DOUBLE_MINUS=41, QUESTION=42, COLON=43, SIZEOF=44, COMMA=45, TILDE=46, TYPECAST=47, FUNCTION_CALL=48, SUBSCRIPT=49, REFERENCE=50, DEREFERENCE=51, UNARY_MINUS=52, POSTINCREMENT=53, POSTDECREMENT=54, PREINCREMENT=55, PREDECREMENT=56, START_COMMENT=57, BOGUS=58, END_OF_EXPRESSION=59 } token_type; } *

variable_types:
text
char *

variable_types:
c
unsigned char

return_type: void

user_defined_types: struct token_rule { struct token_rule *children; enum token_type token_type; }


decompiled_code:
void __fastcall done_lex(int a1, int a2, int a3, int a4, int a5, int a6, int a7, struct obstack obstack)
{
obstack_free(&obstack, 0LL);
}

canonical_decompiled_code:
void __fastcall func7(int a1, int a2, int a3, int a4, int a5, int a6, int a7, struct obstack obstack)
{
obstack_free(&obstack, 0LL);
}

original_code:
void done_lex(lex_buf buf) {
    __extension__ ({ struct obstack *__o = (&buf.obstack); void *__obj = (0); if (__obj > (void *) __o->chunk && __obj < (void *) __o->chunk_limit) __o->next_free = __o->object_base = (char *) __obj; else (obstack_free) (__o, __obj); });
}

canonical_original_code:
void done_lex(struct lex_buf buf) {
    __extension__ ({ struct obstack *__o = (&buf.obstack); void *__obj = (0); if (__obj > (void *) __o->chunk && __obj < (void *) __o->chunk_limit) __o->next_free = __o->object_base = (char *) __obj; else (obstack_free) (__o, __obj); });
}

variable_types: struct lex_buf { char *pos; struct obstack { long chunk_size; struct _obstack_chunk { char *limit; struct _obstack_chunk *prev; char contents[4]; } *chunk; char *object_base; char *next_free; char *chunk_limit; union { long tempint; void *tempptr; } temp; int alignment_mask; struct _obstack_chunk *(*chunkfun)(void *, long); void (*freefun)(void *, struct _obstack_chunk *); void *extra_arg; unsigned int use_extra_arg; unsigned int maybe_empty_object; unsigned int alloc_failed; } obstack; }

variable_types: struct obstack { long chunk_size; struct _obstack_chunk { char *limit; struct _obstack_chunk *prev; char contents[4]; } *chunk; char *object_base; char *next_free; char *chunk_limit; union { long tempint; void *tempptr; } temp; int alignment_mask; struct _obstack_chunk *(*chunkfun)(void *, long); void (*freefun)(void *, struct _obstack_chunk *); void *extra_arg; unsigned int use_extra_arg; unsigned int maybe_empty_object; unsigned int alloc_failed; } *

user_defined_types: struct lex_buf { char *pos; struct obstack obstack; }

user_defined_types: struct obstack { long chunk_size; struct _obstack_chunk *chunk; char *object_base; char *next_free; char *chunk_limit; union { long tempint; void *tempptr; } temp; int alignment_mask; struct _obstack_chunk *(*chunkfun)(void *, long); void (*freefun)(void *, struct _obstack_chunk *); void *extra_arg; unsigned int use_extra_arg; unsigned int maybe_empty_object; unsigned int alloc_failed; }


decompiled_code:
__int64 __fastcall get_next_token(unsigned __int8 **a1)
{
unsigned __int8 *v2; // rbp
__int64 v3; // rax
__int64 v4; // rdx
__int64 v5; // rsi
char v6; // dl
__int64 result; // rax
unsigned __int8 *v8; // rsi
const unsigned __int16 **v9; // rax
__int64 v10; // rcx
unsigned __int8 v11; // al
unsigned __int8 *v12; // rcx
unsigned __int8 v13; // dl
int v14; // ecx
unsigned __int8 *v15; // rax
unsigned __int8 *v16; // rsi
unsigned __int8 *v17; // rsi
char v18; // cl
unsigned __int8 *v19; // r12
unsigned __int8 *v20; // rsi
signed __int64 v21; // rdx
__int64 v22; // [rsp+0h] [rbp-28h] BYREF
__int64 v23; // [rsp+8h] [rbp-20h]

v2 = *a1;
v23 = 0LL;
while ( 1 )
{
while ( 1 )
{
LABEL_2:
v3 = rules;
v4 = *(_QWORD *)rules;
if ( *(_QWORD *)rules )
{
while ( 1 )
{
v5 = v3;
v3 = v4 + 16LL * *v2;
v14 = *(_DWORD *)(v3 + 8);
if ( !v14 )
break;
v4 = *(_QWORD *)v3;
++v2;
if ( !*(_QWORD *)v3 )
goto LABEL_7;
}
v14 = *(_DWORD *)(v5 + 8);
v3 = v5;
}
else
{
v14 = *(_DWORD *)(rules + 8);
}
LABEL_7:
if ( v14 == 31 )
{
if ( (unsigned __int8)(*v2 - 48) <= 9u )
v2 = read_literal_or_id_constprop_0((__int64)a1, v2 - 1, (__int64)&v22);
else
LODWORD(v22) = 31;
goto LABEL_14;
}
if ( v14 != 57 )
break;
v11 = *v2;
while ( v11 )
{
v12 = v2;
v13 = v11;
v11 = *++v2;
if ( v13 == 42 && v11 == 47 )
{
v2 = v12 + 2;
goto LABEL_2;
}
}
}
if ( rules != v3 )
{
LODWORD(v22) = v14;
goto LABEL_14;
}
v6 = *v2;
if ( (char)*v2 > 95 )
break;
if ( v6 > 31 )
{
switch ( v6 )
{
case ' ':
goto LABEL_16;
case '"':
case '\'':
v15 = v2;
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
case 'G':
case 'H':
case 'I':
case 'J':
case 'K':
case 'L':
case 'M':
case 'N':
case 'O':
case 'P':
case 'Q':
case 'R':
case 'S':
case 'T':
case 'U':
case 'V':
case 'W':
case 'X':
case 'Y':
case 'Z':
case '_':
goto LABEL_20;
default:
goto LABEL_19;
}
while ( 1 )
{
v17 = v15;
v18 = *++v15;
if ( v6 == v18 )
{
v19 = v17 + 2;
v20 = v2;
v21 = v19 - v2;
v2 = v19;
LODWORD(v22) = 1;
v23 = obstack_strndup(a1 + 1, v20, v21);
goto LABEL_14;
}
if ( !v18 )
break;
v16 = v17 + 2;
if ( v18 == 92 )
v15 = v16;
}
LODWORD(v22) = 58;
v2 = v15;
goto LABEL_14;
}
if ( !v6 )
{
LODWORD(v22) = 59;
goto LABEL_14;
}
if ( (unsigned __int8)(v6 - 9) > 2u )
goto LABEL_19;
LABEL_16:
++v2;
}
if ( (unsigned __int8)(v6 - 97) > 0x19u )
{
LABEL_19:
v8 = v2++;
LODWORD(v22) = 58;
v23 = obstack_strdup(a1 + 1, v8);
goto LABEL_14;
}
LABEL_20:
if ( memcmp(v2, "sizeof", 6uLL) || (v9 = _ctype_b_loc(), v10 = (char)v2[6], ((*v9)[v10] & 8) != 0) || (_BYTE)v10 == 95 )
{
v2 = read_literal_or_id_constprop_0((__int64)a1, v2, (__int64)&v22);
}
else
{
LODWORD(v22) = 44;
v2 += 6;
}
LABEL_14:
result = v22;
*a1 = v2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(unsigned __int8 **a1)
{
unsigned __int8 *v2; // rbp
__int64 v3; // rax
__int64 v4; // rdx
__int64 v5; // rsi
char v6; // dl
__int64 result; // rax
unsigned __int8 *v8; // rsi
const unsigned __int16 **v9; // rax
__int64 v10; // rcx
unsigned __int8 v11; // al
unsigned __int8 *v12; // rcx
unsigned __int8 v13; // dl
int v14; // ecx
unsigned __int8 *v15; // rax
unsigned __int8 *v16; // rsi
unsigned __int8 *v17; // rsi
char v18; // cl
unsigned __int8 *v19; // r12
unsigned __int8 *v20; // rsi
signed __int64 v21; // rdx
__int64 v22; // [rsp+0h] [rbp-28h] BYREF
__int64 v23; // [rsp+8h] [rbp-20h]

v2 = *a1;
v23 = 0LL;
while ( 1 )
{
while ( 1 )
{
LABEL_2:
v3 = rules;
v4 = *(_QWORD *)rules;
if ( *(_QWORD *)rules )
{
while ( 1 )
{
v5 = v3;
v3 = v4 + 16LL * *v2;
v14 = *(_DWORD *)(v3 + 8);
if ( !v14 )
break;
v4 = *(_QWORD *)v3;
++v2;
if ( !*(_QWORD *)v3 )
goto LABEL_7;
}
v14 = *(_DWORD *)(v5 + 8);
v3 = v5;
}
else
{
v14 = *(_DWORD *)(rules + 8);
}
LABEL_7:
if ( v14 == 31 )
{
if ( (unsigned __int8)(*v2 - 48) <= 9u )
v2 = func5((__int64)a1, v2 - 1, (__int64)&v22);
else
LODWORD(v22) = 31;
goto LABEL_14;
}
if ( v14 != 57 )
break;
v11 = *v2;
while ( v11 )
{
v12 = v2;
v13 = v11;
v11 = *++v2;
if ( v13 == 42 && v11 == 47 )
{
v2 = v12 + 2;
goto LABEL_2;
}
}
}
if ( rules != v3 )
{
LODWORD(v22) = v14;
goto LABEL_14;
}
v6 = *v2;
if ( (char)*v2 > 95 )
break;
if ( v6 > 31 )
{
switch ( v6 )
{
case ' ':
goto LABEL_16;
case '"':
case '\'':
v15 = v2;
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
case 'G':
case 'H':
case 'I':
case 'J':
case 'K':
case 'L':
case 'M':
case 'N':
case 'O':
case 'P':
case 'Q':
case 'R':
case 'S':
case 'T':
case 'U':
case 'V':
case 'W':
case 'X':
case 'Y':
case 'Z':
case '_':
goto LABEL_20;
default:
goto LABEL_19;
}
while ( 1 )
{
v17 = v15;
v18 = *++v15;
if ( v6 == v18 )
{
v19 = v17 + 2;
v20 = v2;
v21 = v19 - v2;
v2 = v19;
LODWORD(v22) = 1;
v23 = obstack_strndup(a1 + 1, v20, v21);
goto LABEL_14;
}
if ( !v18 )
break;
v16 = v17 + 2;
if ( v18 == 92 )
v15 = v16;
}
LODWORD(v22) = 58;
v2 = v15;
goto LABEL_14;
}
if ( !v6 )
{
LODWORD(v22) = 59;
goto LABEL_14;
}
if ( (unsigned __int8)(v6 - 9) > 2u )
goto LABEL_19;
LABEL_16:
++v2;
}
if ( (unsigned __int8)(v6 - 97) > 0x19u )
{
LABEL_19:
v8 = v2++;
LODWORD(v22) = 58;
v23 = obstack_strdup(a1 + 1, v8);
goto LABEL_14;
}
LABEL_20:
if ( memcmp(v2, "sizeof", 6uLL) || (v9 = _ctype_b_loc(), v10 = (char)v2[6], ((*v9)[v10] & 8) != 0) || (_BYTE)v10 == 95 )
{
v2 = func5((__int64)a1, v2, (__int64)&v22);
}
else
{
LODWORD(v22) = 44;
v2 += 6;
}
LABEL_14:
result = v22;
*a1 = v2;
return result;
}

original_code:
struct token get_next_token(lex_buf* buf) {
    const char* pos = buf->pos;
    struct token token;
    token.token_value = 0;
    while (1) {
        struct token_rule *rule = rules;
        while (rule->children && rule->children[(unsigned char)*pos].token_type) {
            rule = rule->children + (unsigned char)*pos++;
        }
        if (rule->token_type == DOT) {
            char nextc = *pos;
            if (nextc < '0' || nextc > '9') {
                token.token_type = rule->token_type;
            } else {
                pos = read_literal_or_id(buf, pos - 1, &token);
            }
            goto done;
        } else if (rule->token_type == START_COMMENT) {
            while (*pos) {
                char c = *pos++;
                if (c == '*') {
                    if (*pos == '/') {
                        pos++;
                        break;
                    }
                }
            }
        } else if (rule != rules) {
            token.token_type = rule->token_type;
            goto done;
        } else {
            switch (*pos) {
            case 0:
                token.token_type = END_OF_EXPRESSION;
                goto done;
            case ' ': case '\t': case '\v': case '\n':
                break;
            case '\'':
            case '"':
            {
                char delimiter = *pos;
                const char *start = pos;
                while (*++pos != delimiter) {
                    if (!*pos) {
                        token.token_type = BOGUS;
                        goto done;
                    } else if (*pos == '\\') {
                        pos ++;
                    }
                }
                pos++;
                char* val = obstack_strndup(&buf->obstack, start, pos - start);
                token.token_value = val;
                token.token_type = LITERAL_OR_ID;
                goto done;
            }
            case '_': case 'A': case 'a': case 'B': case 'b': case 'C': case 'c': case 'D': case 'd': case 'E': case 'e': case 'F': case 'f': case 'G': case 'g': case 'H': case 'h': case 'I': case 'i': case 'J': case 'j': case 'K': case 'k': case 'L': case 'l': case 'M': case 'm': case 'N': case 'n': case 'O': case 'o': case 'P': case 'p': case 'Q': case 'q': case 'R': case 'r': case 'S': case 's': case 'T': case 't': case 'U': case 'u': case 'V': case 'v': case 'W': case 'w': case 'X': case 'x': case 'Y': case 'y': case 'Z': case 'z': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
                if (strncmp(pos, "sizeof", 6) == 0 &&
                    !((*__ctype_b_loc ())[(int) ((pos[6]))] & (unsigned short int) _ISalnum) &&
                    pos[6] != '_') {
                        token.token_type = SIZEOF;
                        pos += 6;
                        goto done;
                } else {
                    pos = read_literal_or_id(buf, pos, &token);
                    goto done;
                }
                break;
            default:
                token.token_value = obstack_strdup(&buf->obstack, pos);
                token.token_type = BOGUS;
                pos++;
                goto done;
            }
            ++pos;
        }
    }
done:
    buf->pos = pos;
    return token;
}

canonical_original_code:
struct token get_next_token(struct lex_buf *buf) {
    char *pos = buf->pos;
    struct token token;
    token.token_value = 0;
    while (1) {
        struct token_rule *rule = rules;
        while (rule->children && rule->children[(unsigned char)*pos].token_type) {
            rule = rule->children + (unsigned char)*pos++;
        }
        if (rule->token_type == DOT) {
            char nextc = *pos;
            if (nextc < '0' || nextc > '9') {
                token.token_type = rule->token_type;
            } else {
                pos = read_literal_or_id(buf, pos - 1, &token);
            }
            goto done;
        } else if (rule->token_type == START_COMMENT) {
            while (*pos) {
                char c = *pos++;
                if (c == '*') {
                    if (*pos == '/') {
                        pos++;
                        break;
                    }
                }
            }
        } else if (rule != rules) {
            token.token_type = rule->token_type;
            goto done;
        } else {
            switch (*pos) {
            case 0:
                token.token_type = END_OF_EXPRESSION;
                goto done;
            case ' ': case '\t': case '\v': case '\n':
                break;
            case '\'':
            case '"':
            {
                char delimiter = *pos;
                char *start = pos;
                while (*++pos != delimiter) {
                    if (!*pos) {
                        token.token_type = BOGUS;
                        goto done;
                    } else if (*pos == '\\') {
                        pos ++;
                    }
                }
                pos++;
                char *val = obstack_strndup(&buf->obstack, start, pos - start);
                token.token_value = val;
                token.token_type = LITERAL_OR_ID;
                goto done;
            }
            case '_': case 'A': case 'a': case 'B': case 'b': case 'C': case 'c': case 'D': case 'd': case 'E': case 'e': case 'F': case 'f': case 'G': case 'g': case 'H': case 'h': case 'I': case 'i': case 'J': case 'j': case 'K': case 'k': case 'L': case 'l': case 'M': case 'm': case 'N': case 'n': case 'O': case 'o': case 'P': case 'p': case 'Q': case 'q': case 'R': case 'r': case 'S': case 's': case 'T': case 't': case 'U': case 'u': case 'V': case 'v': case 'W': case 'w': case 'X': case 'x': case 'Y': case 'y': case 'Z': case 'z': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
                if (strncmp(pos, "sizeof", 6) == 0 &&
                    !((*__ctype_b_loc ())[(int) ((pos[6]))] & (unsigned short) _ISalnum) &&
                    pos[6] != '_') {
                        token.token_type = SIZEOF;
                        pos += 6;
                        goto done;
                } else {
                    pos = read_literal_or_id(buf, pos, &token);
                    goto done;
                }
                break;
            default:
                token.token_value = obstack_strdup(&buf->obstack, pos);
                token.token_type = BOGUS;
                pos++;
                goto done;
            }
            ++pos;
        }
    }
done:
    buf->pos = pos;
    return token;
}

variable_types: struct lex_buf { char *pos; struct obstack { long chunk_size; struct _obstack_chunk { char *limit; struct _obstack_chunk *prev; char contents[4]; } *chunk; char *object_base; char *next_free; char *chunk_limit; union { long tempint; void *tempptr; } temp; int alignment_mask; struct _obstack_chunk *(*chunkfun)(void *, long); void (*freefun)(void *, struct _obstack_chunk *); void *extra_arg; unsigned int use_extra_arg; unsigned int maybe_empty_object; unsigned int alloc_failed; } obstack; } *

variable_types: struct token { enum token_type { LITERAL_OR_ID=1, OPEN_PAREN=2, CLOSE_PAREN=3, OPEN_BRACKET=4, CLOSE_BRACKET=5, OPEN_CURLY=6, CLOSE_CURLY=7, BANG=8, PERCENT=9, CARET=10, AMPERSAND=11, BAR=12, STAR=13, MINUS=14, PLUS=15, SLASH=16, LEFT_SHIFT=17, RIGHT_SHIFT=18, BANG_EQUAL=19, PERCENT_EQUAL=20, CARET_EQUAL=21, AMPERSAND_EQUAL=22, BAR_EQUAL=23, STAR_EQUAL=24, MINUS_EQUAL=25, PLUS_EQUAL=26, SLASH_EQUAL=27, LEFT_SHIFT_EQUAL=28, RIGHT_SHIFT_EQUAL=29, ARROW=30, DOT=31, ASSIGN=32, IS_EQUAL=33, LTE=34, GTE=35, LT=36, GT=37, DOUBLE_AMPERSAND=38, DOUBLE_BAR=39, DOUBLE_PLUS=40, DOUBLE_MINUS=41, QUESTION=42, COLON=43, SIZEOF=44, COMMA=45, TILDE=46, TYPECAST=47, FUNCTION_CALL=48, SUBSCRIPT=49, REFERENCE=50, DEREFERENCE=51, UNARY_MINUS=52, POSTINCREMENT=53, POSTDECREMENT=54, PREINCREMENT=55, PREDECREMENT=56, START_COMMENT=57, BOGUS=58, END_OF_EXPRESSION=59 } token_type; char *token_value; }

variable_types: nextc char

variable_types: delimiter char

variable_types:
val
char *

user_defined_types: struct token { enum token_type token_type; char *token_value; }


repo: nowylie/space

original_code:
window_t *window_get(Window id)
{
 window_t *window;
 do { unsigned _hf_bkt,_hf_hashv; window=((void *)0); if (window_map) { do { unsigned _hj_i,_hj_j,_hj_k; unsigned char *_hj_key=(unsigned char*)(&id); _hf_hashv = 0xfeedbeef; _hj_i = _hj_j = 0x9e3779b9; _hj_k = (unsigned)(sizeof(Window)); while (_hj_k >= 12) { _hj_i += (_hj_key[0] + ( (unsigned)_hj_key[1] << 8 ) + ( (unsigned)_hj_key[2] << 16 ) + ( (unsigned)_hj_key[3] << 24 ) ); _hj_j += (_hj_key[4] + ( (unsigned)_hj_key[5] << 8 ) + ( (unsigned)_hj_key[6] << 16 ) + ( (unsigned)_hj_key[7] << 24 ) ); _hf_hashv += (_hj_key[8] + ( (unsigned)_hj_key[9] << 8 ) + ( (unsigned)_hj_key[10] << 16 ) + ( (unsigned)_hj_key[11] << 24 ) ); do { _hj_i -= _hj_j; _hj_i -= _hf_hashv; _hj_i ^= ( _hf_hashv >> 13 ); _hj_j -= _hf_hashv; _hj_j -= _hj_i; _hj_j ^= ( _hj_i << 8 ); _hf_hashv -= _hj_i; _hf_hashv -= _hj_j; _hf_hashv ^= ( _hj_j >> 13 ); _hj_i -= _hj_j; _hj_i -= _hf_hashv; _hj_i ^= ( _hf_hashv >> 12 ); _hj_j -= _hf_hashv; _hj_j -= _hj_i; _hj_j ^= ( _hj_i << 16 ); _hf_hashv -= _hj_i; _hf_hashv -= _hj_j; _hf_hashv ^= ( _hj_j >> 5 ); _hj_i -= _hj_j; _hj_i -= _hf_hashv; _hj_i ^= ( _hf_hashv >> 3 ); _hj_j -= _hf_hashv; _hj_j -= _hj_i; _hj_j ^= ( _hj_i << 10 ); _hf_hashv -= _hj_i; _hf_hashv -= _hj_j; _hf_hashv ^= ( _hj_j >> 15 ); } while (0); _hj_key += 12; _hj_k -= 12; } _hf_hashv += sizeof(Window); switch ( _hj_k ) { case 11: _hf_hashv += ( (unsigned)_hj_key[10] << 24 ); case 10: _hf_hashv += ( (unsigned)_hj_key[9] << 16 ); case 9: _hf_hashv += ( (unsigned)_hj_key[8] << 8 ); case 8: _hj_j += ( (unsigned)_hj_key[7] << 24 ); case 7: _hj_j += ( (unsigned)_hj_key[6] << 16 ); case 6: _hj_j += ( (unsigned)_hj_key[5] << 8 ); case 5: _hj_j += _hj_key[4]; case 4: _hj_i += ( (unsigned)_hj_key[3] << 24 ); case 3: _hj_i += ( (unsigned)_hj_key[2] << 16 ); case 2: _hj_i += ( (unsigned)_hj_key[1] << 8 ); case 1: _hj_i += _hj_key[0]; } do { _hj_i -= _hj_j; _hj_i -= _hf_hashv; _hj_i ^= ( _hf_hashv >> 13 ); _hj_j -= _hf_hashv; _hj_j -= _hj_i; _hj_j ^= ( _hj_i << 8 ); _hf_hashv -= _hj_i; _hf_hashv -= _hj_j; _hf_hashv ^= ( _hj_j >> 13 ); _hj_i -= _hj_j; _hj_i -= _hf_hashv; _hj_i ^= ( _hf_hashv >> 12 ); _hj_j -= _hf_hashv; _hj_j -= _hj_i; _hj_j ^= ( _hj_i << 16 ); _hf_hashv -= _hj_i; _hf_hashv -= _hj_j; _hf_hashv ^= ( _hj_j >> 5 ); _hj_i -= _hj_j; _hj_i -= _hf_hashv; _hj_i ^= ( _hf_hashv >> 3 ); _hj_j -= _hf_hashv; _hj_j -= _hj_i; _hj_j ^= ( _hj_i << 10 ); _hf_hashv -= _hj_i; _hf_hashv -= _hj_j; _hf_hashv ^= ( _hj_j >> 15 ); } while (0); _hf_bkt = _hf_hashv & ((window_map)->hh.tbl->num_buckets-1); } while(0); if ((1)) { do { if ((window_map)->hh.tbl->buckets[ _hf_bkt ].hh_head) do { (window) = (__typeof(window))(((void*)(((char*)((window_map)->hh.tbl->buckets[ _hf_bkt ].hh_head)) - (((window_map)->hh.tbl)->hho)))); } while(0); else window=((void *)0); while (window) { if ((window)->hh.keylen == sizeof(Window)) { if ((memcmp((window)->hh.key,&id,sizeof(Window))) == 0) break; } if ((window)->hh.hh_next) do { (window) = (__typeof(window))(((void*)(((char*)((window)->hh.hh_next)) - (((window_map)->hh.tbl)->hho)))); } while(0); else window = ((void *)0); } } while(0); } } } while (0);
 return window;
}

canonical_original_code:
struct window_def *window_get(unsigned long id)
{
 struct window_def *window;
 do { unsigned int _hf_bkt; unsigned int _hf_hashv; window=((void *)0); if (window_map) { do { unsigned int _hj_i; unsigned int _hj_j; unsigned int _hj_k; unsigned char *_hj_key = (unsigned char*)(&id); _hf_hashv = 0xfeedbeef; _hj_i = _hj_j = 0x9e3779b9; _hj_k = (unsigned int)(sizeof(Window)); while (_hj_k >= 12) { _hj_i += (_hj_key[0] + ( (unsigned int)_hj_key[1] << 8 ) + ( (unsigned int)_hj_key[2] << 16 ) + ( (unsigned int)_hj_key[3] << 24 ) ); _hj_j += (_hj_key[4] + ( (unsigned int)_hj_key[5] << 8 ) + ( (unsigned int)_hj_key[6] << 16 ) + ( (unsigned int)_hj_key[7] << 24 ) ); _hf_hashv += (_hj_key[8] + ( (unsigned int)_hj_key[9] << 8 ) + ( (unsigned int)_hj_key[10] << 16 ) + ( (unsigned int)_hj_key[11] << 24 ) ); do { _hj_i -= _hj_j; _hj_i -= _hf_hashv; _hj_i ^= ( _hf_hashv >> 13 ); _hj_j -= _hf_hashv; _hj_j -= _hj_i; _hj_j ^= ( _hj_i << 8 ); _hf_hashv -= _hj_i; _hf_hashv -= _hj_j; _hf_hashv ^= ( _hj_j >> 13 ); _hj_i -= _hj_j; _hj_i -= _hf_hashv; _hj_i ^= ( _hf_hashv >> 12 ); _hj_j -= _hf_hashv; _hj_j -= _hj_i; _hj_j ^= ( _hj_i << 16 ); _hf_hashv -= _hj_i; _hf_hashv -= _hj_j; _hf_hashv ^= ( _hj_j >> 5 ); _hj_i -= _hj_j; _hj_i -= _hf_hashv; _hj_i ^= ( _hf_hashv >> 3 ); _hj_j -= _hf_hashv; _hj_j -= _hj_i; _hj_j ^= ( _hj_i << 10 ); _hf_hashv -= _hj_i; _hf_hashv -= _hj_j; _hf_hashv ^= ( _hj_j >> 15 ); } while (0); _hj_key += 12; _hj_k -= 12; } _hf_hashv += sizeof(Window); switch ( _hj_k ) { case 11: _hf_hashv += ( (unsigned int)_hj_key[10] << 24 ); case 10: _hf_hashv += ( (unsigned int)_hj_key[9] << 16 ); case 9: _hf_hashv += ( (unsigned int)_hj_key[8] << 8 ); case 8: _hj_j += ( (unsigned int)_hj_key[7] << 24 ); case 7: _hj_j += ( (unsigned int)_hj_key[6] << 16 ); case 6: _hj_j += ( (unsigned int)_hj_key[5] << 8 ); case 5: _hj_j += _hj_key[4]; case 4: _hj_i += ( (unsigned int)_hj_key[3] << 24 ); case 3: _hj_i += ( (unsigned int)_hj_key[2] << 16 ); case 2: _hj_i += ( (unsigned int)_hj_key[1] << 8 ); case 1: _hj_i += _hj_key[0]; } do { _hj_i -= _hj_j; _hj_i -= _hf_hashv; _hj_i ^= ( _hf_hashv >> 13 ); _hj_j -= _hf_hashv; _hj_j -= _hj_i; _hj_j ^= ( _hj_i << 8 ); _hf_hashv -= _hj_i; _hf_hashv -= _hj_j; _hf_hashv ^= ( _hj_j >> 13 ); _hj_i -= _hj_j; _hj_i -= _hf_hashv; _hj_i ^= ( _hf_hashv >> 12 ); _hj_j -= _hf_hashv; _hj_j -= _hj_i; _hj_j ^= ( _hj_i << 16 ); _hf_hashv -= _hj_i; _hf_hashv -= _hj_j; _hf_hashv ^= ( _hj_j >> 5 ); _hj_i -= _hj_j; _hj_i -= _hf_hashv; _hj_i ^= ( _hf_hashv >> 3 ); _hj_j -= _hf_hashv; _hj_j -= _hj_i; _hj_j ^= ( _hj_i << 10 ); _hf_hashv -= _hj_i; _hf_hashv -= _hj_j; _hf_hashv ^= ( _hj_j >> 15 ); } while (0); _hf_bkt = _hf_hashv & ((window_map)->hh.tbl->num_buckets-1); } while(0); if ((1)) { do { if ((window_map)->hh.tbl->buckets[ _hf_bkt ].hh_head) do { (window) = (__typeof(window))(((void *)(((char *)((window_map)->hh.tbl->buckets[ _hf_bkt ].hh_head)) - (((window_map)->hh.tbl)->hho)))); } while(0); else window=((void *)0); while (window) { if ((window)->hh.keylen == sizeof(Window)) { if ((memcmp((window)->hh.key,&id,sizeof(Window))) == 0) break; } if ((window)->hh.hh_next) do { (window) = (__typeof(window))(((void *)(((char *)((window)->hh.hh_next)) - (((window_map)->hh.tbl)->hho)))); } while(0); else window = ((void *)0); } } while(0); } } } while (0);
 return window;
}

variable_types:
id
unsigned long

variable_types: struct window_def { unsigned long id; int x; unsigned int width; unsigned long pixmap; unsigned long picture; char mapped; char dirty; struct window_def *prev; struct UT_hash_handle { struct UT_hash_table { struct UT_hash_bucket { struct UT_hash_handle *hh_head; unsigned int count; unsigned int expand_mult; } *buckets; unsigned int num_buckets; unsigned int num_items; struct UT_hash_handle *tail; long hho; unsigned int ideal_chain_maxlen; unsigned int nonideal_items; unsigned int ineff_expands; unsigned int signature; } *tbl; void *prev; void *next; struct UT_hash_handle *hh_prev; struct UT_hash_handle *hh_next; void *key; unsigned int keylen; unsigned int hashv; } hh; } *

user_defined_types: struct window_def { unsigned long id; int x; unsigned int width; unsigned long pixmap; unsigned long picture; char mapped; char dirty; struct window_def *prev; struct UT_hash_handle hh; }

user_defined_types: struct UT_hash_handle { struct UT_hash_table *tbl; void *prev; void *next; struct UT_hash_handle *hh_prev; struct UT_hash_handle *hh_next; void *key; unsigned int keylen; unsigned int hashv; }

user_defined_types: struct UT_hash_table { struct UT_hash_bucket *buckets; unsigned int num_buckets; unsigned int num_items; struct UT_hash_handle *tail; long hho; unsigned int ideal_chain_maxlen; unsigned int nonideal_items; unsigned int ineff_expands; unsigned int signature; }


decompiled_code:
__int64 __fastcall window_list_remove(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rdx
__int64 v3; // rcx

result = window_get(a1);
v2 = *(_QWORD *)(result + 56);
if ( window_list == result )
{
v3 = *(_QWORD *)(result + 48);
window_list = *(_QWORD *)(result + 56);
if ( window_list_last != result )
goto LABEL_3;
}
else
{
v3 = *(_QWORD *)(result + 48);
if ( window_list_last != result )
goto LABEL_3;
}
window_list_last = v3;
LABEL_3:
if ( v3 )
{
*(_QWORD *)(v3 + 56) = v2;
v2 = *(_QWORD *)(result + 56);
}
if ( v2 )
*(_QWORD *)(v2 + 48) = v3;
*(_QWORD *)(result + 48) = 0LL;
*(_QWORD *)(result + 56) = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rdx
__int64 v3; // rcx

result = func0(a1);
v2 = *(_QWORD *)(result + 56);
if ( window_list == result )
{
v3 = *(_QWORD *)(result + 48);
window_list = *(_QWORD *)(result + 56);
if ( window_list_last != result )
goto LABEL_3;
}
else
{
v3 = *(_QWORD *)(result + 48);
if ( window_list_last != result )
goto LABEL_3;
}
window_list_last = v3;
LABEL_3:
if ( v3 )
{
*(_QWORD *)(v3 + 56) = v2;
v2 = *(_QWORD *)(result + 56);
}
if ( v2 )
*(_QWORD *)(v2 + 48) = v3;
*(_QWORD *)(result + 48) = 0LL;
*(_QWORD *)(result + 56) = 0LL;
return result;
}

original_code:
window_t *window_list_remove(Window id)
{
 window_t *window = window_get(id);
 if (window_list == window)
  window_list = window->next;
 if (window_list_last == window)
  window_list_last = window->prev;
 if (window->prev != ((void *)0)) {
  window->prev->next = window->next;
 }
 if (window->next != ((void *)0)) {
  window->next->prev = window->prev;
 }
 window->prev = ((void *)0);
 window->next = ((void *)0);
 return window;
}

canonical_original_code:
struct window_def *window_list_remove(unsigned long id)
{
 struct window_def *window = window_get(id);
 if (window_list == window)
  window_list = window->next;
 if (window_list_last == window)
  window_list_last = window->prev;
 if (window->prev != ((void *)0)) {
  window->prev->next = window->next;
 }
 if (window->next != ((void *)0)) {
  window->next->prev = window->prev;
 }
 window->prev = ((void *)0);
 window->next = ((void *)0);
 return window;
}

return_type: struct window_def { unsigned long id; int x; unsigned int width; unsigned long pixmap; unsigned long picture; char mapped; char dirty; struct window_def *prev; struct UT_hash_handle { struct UT_hash_table { struct UT_hash_bucket { struct UT_hash_handle *hh_head; unsigned int count; unsigned int expand_mult; } *buckets; unsigned int num_buckets; unsigned int num_items; struct UT_hash_handle *tail; long hho; unsigned int ideal_chain_maxlen; unsigned int nonideal_items; unsigned int ineff_expands; unsigned int signature; } *tbl; void *prev; void *next; struct UT_hash_handle *hh_prev; struct UT_hash_handle *hh_next; void *key; unsigned int keylen; unsigned int hashv; } hh; } *


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

result = window_get(a1);
v2 = window_list;
*(_QWORD *)(result + 48) = 0LL;
*(_QWORD *)(result + 56) = v2;
if ( v2 )
*(_QWORD *)(v2 + 48) = result;
else
window_list_last = result;
window_list = result;
return result;
}

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

result = func0(a1);
v2 = window_list;
*(_QWORD *)(result + 48) = 0LL;
*(_QWORD *)(result + 56) = v2;
if ( v2 )
*(_QWORD *)(v2 + 48) = result;
else
window_list_last = result;
window_list = result;
return result;
}

original_code:
void window_list_prepend(Window id)
{
 window_t *window = window_get(id);
 window->prev = ((void *)0);
 window->next = window_list;
 if (window_list != ((void *)0))
  window_list->prev = window;
 else
  window_list_last = window;
 window_list = window;
}

canonical_original_code:
void window_list_prepend(unsigned long id)
{
 struct window_def *window = window_get(id);
 window->prev = ((void *)0);
 window->next = window_list;
 if (window_list != ((void *)0))
  window_list->prev = window;
 else
  window_list_last = window;
 window_list = window;
}

user_defined_types: struct UT_hash_bucket { struct UT_hash_handle *hh_head; unsigned int count; unsigned int expand_mult; }


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

result = window_get(a1);
v2 = window_list_last;
*(_QWORD *)(result + 56) = 0LL;
*(_QWORD *)(result + 48) = v2;
if ( v2 )
*(_QWORD *)(v2 + 56) = result;
else
window_list = result;
window_list_last = result;
return result;
}

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

result = func0(a1);
v2 = window_list_last;
*(_QWORD *)(result + 56) = 0LL;
*(_QWORD *)(result + 48) = v2;
if ( v2 )
*(_QWORD *)(v2 + 56) = result;
else
window_list = result;
window_list_last = result;
return result;
}

original_code:
void window_list_append(Window id)
{
 window_t *window = window_get(id);
 window->prev = window_list_last;
 window->next = ((void *)0);
 if (window_list_last != ((void *)0))
  window_list_last->next = window;
 else
  window_list = window;
 window_list_last = window;
}

canonical_original_code:
void window_list_append(unsigned long id)
{
 struct window_def *window = window_get(id);
 window->prev = window_list_last;
 window->next = ((void *)0);
 if (window_list_last != ((void *)0))
  window_list_last->next = window;
 else
  window_list = window;
 window_list_last = window;
}


decompiled_code:
__int64 __fastcall window_list_move_before(__int64 a1)
{
__int64 v1; // r9
__int64 result; // rax
__int64 v3; // r8
__int64 v4; // rdx

window_list_remove(a1);
result = window_get(v1);
v4 = *(_QWORD *)(result + 48);
*(_QWORD *)(v3 + 56) = result;
*(_QWORD *)(v3 + 48) = v4;
if ( v4 )
*(_QWORD *)(v4 + 56) = v3;
*(_QWORD *)(result + 48) = v3;
return result;
}

original_code:
void window_list_move_before(Window id, Window sibling)
{
 window_t *window, *after;
 window = window_list_remove(id);
 after = window_get(sibling);
 window->prev = after->prev;
 window->next = after;
 if (after->prev != ((void *)0))
  after->prev->next = window;
 after->prev = window;
}

canonical_original_code:
void window_list_move_before(unsigned long id, unsigned long sibling)
{
 struct window_def *window; struct window_def *after;
 window = window_list_remove(id);
 after = window_get(sibling);
 window->prev = after->prev;
 window->next = after;
 if (after->prev != ((void *)0))
  after->prev->next = window;
 after->prev = window;
}

variable_types:
sibling
unsigned long


decompiled_code:
__int64 __fastcall window_list_move_after(__int64 a1)
{
__int64 v1; // r9
__int64 result; // rax
__int64 v3; // r8
__int64 v4; // rdx
__int64 v5; // rdx

window_list_remove(a1);
result = window_get(v1);
v4 = *(_QWORD *)(result + 56);
*(_QWORD *)(v3 + 48) = result;
*(_QWORD *)(v3 + 56) = v4;
v5 = *(_QWORD *)(result + 56);
if ( v5 )
*(_QWORD *)(v5 + 48) = v3;
*(_QWORD *)(result + 56) = v3;
return result;
}

original_code:
void window_list_move_after(Window id, Window sibling)
{
 window_t *window, *before;
 window = window_list_remove(id);
 before = window_get(sibling);
 window->prev = before;
 window->next = before->next;
 if (before->next != ((void *)0))
  before->next->prev = window;
 before->next = window;
}

canonical_original_code:
void window_list_move_after(unsigned long id, unsigned long sibling)
{
 struct window_def *window; struct window_def *before;
 window = window_list_remove(id);
 before = window_get(sibling);
 window->prev = before;
 window->next = before->next;
 if (before->next != ((void *)0))
  before->next->prev = window;
 before->next = window;
}


decompiled_code:
__int64 window_list_get()
{
return window_list;
}

canonical_decompiled_code:
__int64 func6()
{
return window_list;
}

original_code:
window_t *window_list_get()
{
 return window_list;
}

canonical_original_code:
struct window_def *window_list_get()
{
 return window_list;
}


original_code:
void window_create(Window id)
{
 window_t *window = malloc(sizeof(window_t));
 window->id = id;
 window->mapped = 0;
 window->dirty = 1;
 do { unsigned _ha_bkt; (window)->hh.next = ((void *)0); (window)->hh.key = (char*)(&((window)->id)); (window)->hh.keylen = (unsigned)(sizeof(Window)); if (!(window_map)) { window_map = (window); (window_map)->hh.prev = ((void *)0); do { (window_map)->hh.tbl = (UT_hash_table*)malloc(sizeof(UT_hash_table)); if (!((window_map)->hh.tbl)) { exit(-1); } memset((window_map)->hh.tbl, 0, sizeof(UT_hash_table)); (window_map)->hh.tbl->tail = &((window_map)->hh); (window_map)->hh.tbl->num_buckets = 32; (window_map)->hh.tbl->log2_num_buckets = 5; (window_map)->hh.tbl->hho = (char*)(&(window_map)->hh) - (char*)(window_map); (window_map)->hh.tbl->buckets = (UT_hash_bucket*)malloc(32*sizeof(struct UT_hash_bucket)); if (! (window_map)->hh.tbl->buckets) { exit(-1); } memset((window_map)->hh.tbl->buckets, 0, 32*sizeof(struct UT_hash_bucket)); ; (window_map)->hh.tbl->signature = 0xa0111fe1; } while(0); } else { (window_map)->hh.tbl->tail->next = (window); (window)->hh.prev = ((void*)(((char*)((window_map)->hh.tbl->tail)) - (((window_map)->hh.tbl)->hho))); (window_map)->hh.tbl->tail = &((window)->hh); } (window_map)->hh.tbl->num_items++; (window)->hh.tbl = (window_map)->hh.tbl; do { unsigned _hj_i,_hj_j,_hj_k; unsigned char *_hj_key=(unsigned char*)(&((window)->id)); (window)->hh.hashv = 0xfeedbeef; _hj_i = _hj_j = 0x9e3779b9; _hj_k = (unsigned)(sizeof(Window)); while (_hj_k >= 12) { _hj_i += (_hj_key[0] + ( (unsigned)_hj_key[1] << 8 ) + ( (unsigned)_hj_key[2] << 16 ) + ( (unsigned)_hj_key[3] << 24 ) ); _hj_j += (_hj_key[4] + ( (unsigned)_hj_key[5] << 8 ) + ( (unsigned)_hj_key[6] << 16 ) + ( (unsigned)_hj_key[7] << 24 ) ); (window)->hh.hashv += (_hj_key[8] + ( (unsigned)_hj_key[9] << 8 ) + ( (unsigned)_hj_key[10] << 16 ) + ( (unsigned)_hj_key[11] << 24 ) ); do { _hj_i -= _hj_j; _hj_i -= (window)->hh.hashv; _hj_i ^= ( (window)->hh.hashv >> 13 ); _hj_j -= (window)->hh.hashv; _hj_j -= _hj_i; _hj_j ^= ( _hj_i << 8 ); (window)->hh.hashv -= _hj_i; (window)->hh.hashv -= _hj_j; (window)->hh.hashv ^= ( _hj_j >> 13 ); _hj_i -= _hj_j; _hj_i -= (window)->hh.hashv; _hj_i ^= ( (window)->hh.hashv >> 12 ); _hj_j -= (window)->hh.hashv; _hj_j -= _hj_i; _hj_j ^= ( _hj_i << 16 ); (window)->hh.hashv -= _hj_i; (window)->hh.hashv -= _hj_j; (window)->hh.hashv ^= ( _hj_j >> 5 ); _hj_i -= _hj_j; _hj_i -= (window)->hh.hashv; _hj_i ^= ( (window)->hh.hashv >> 3 ); _hj_j -= (window)->hh.hashv; _hj_j -= _hj_i; _hj_j ^= ( _hj_i << 10 ); (window)->hh.hashv -= _hj_i; (window)->hh.hashv -= _hj_j; (window)->hh.hashv ^= ( _hj_j >> 15 ); } while (0); _hj_key += 12; _hj_k -= 12; } (window)->hh.hashv += sizeof(Window); switch ( _hj_k ) { case 11: (window)->hh.hashv += ( (unsigned)_hj_key[10] << 24 ); case 10: (window)->hh.hashv += ( (unsigned)_hj_key[9] << 16 ); case 9: (window)->hh.hashv += ( (unsigned)_hj_key[8] << 8 ); case 8: _hj_j += ( (unsigned)_hj_key[7] << 24 ); case 7: _hj_j += ( (unsigned)_hj_key[6] << 16 ); case 6: _hj_j += ( (unsigned)_hj_key[5] << 8 ); case 5: _hj_j += _hj_key[4]; case 4: _hj_i += ( (unsigned)_hj_key[3] << 24 ); case 3: _hj_i += ( (unsigned)_hj_key[2] << 16 ); case 2: _hj_i += ( (unsigned)_hj_key[1] << 8 ); case 1: _hj_i += _hj_key[0]; } do { _hj_i -= _hj_j; _hj_i -= (window)->hh.hashv; _hj_i ^= ( (window)->hh.hashv >> 13 ); _hj_j -= (window)->hh.hashv; _hj_j -= _hj_i; _hj_j ^= ( _hj_i << 8 ); (window)->hh.hashv -= _hj_i; (window)->hh.hashv -= _hj_j; (window)->hh.hashv ^= ( _hj_j >> 13 ); _hj_i -= _hj_j; _hj_i -= (window)->hh.hashv; _hj_i ^= ( (window)->hh.hashv >> 12 ); _hj_j -= (window)->hh.hashv; _hj_j -= _hj_i; _hj_j ^= ( _hj_i << 16 ); (window)->hh.hashv -= _hj_i; (window)->hh.hashv -= _hj_j; (window)->hh.hashv ^= ( _hj_j >> 5 ); _hj_i -= _hj_j; _hj_i -= (window)->hh.hashv; _hj_i ^= ( (window)->hh.hashv >> 3 ); _hj_j -= (window)->hh.hashv; _hj_j -= _hj_i; _hj_j ^= ( _hj_i << 10 ); (window)->hh.hashv -= _hj_i; (window)->hh.hashv -= _hj_j; (window)->hh.hashv ^= ( _hj_j >> 15 ); } while (0); _ha_bkt = (window)->hh.hashv & ((window_map)->hh.tbl->num_buckets-1); } while(0); do { (window_map)->hh.tbl->buckets[_ha_bkt].count++; (&(window)->hh)->hh_next = (window_map)->hh.tbl->buckets[_ha_bkt].hh_head; (&(window)->hh)->hh_prev = ((void *)0); if ((window_map)->hh.tbl->buckets[_ha_bkt].hh_head) { ((window_map)->hh.tbl->buckets[_ha_bkt]).hh_head->hh_prev = (&(window)->hh); } ((window_map)->hh.tbl->buckets[_ha_bkt]).hh_head=&(window)->hh; if ((window_map)->hh.tbl->buckets[_ha_bkt].count >= (((window_map)->hh.tbl->buckets[_ha_bkt].expand_mult+1) * 10) && (&(window)->hh)->tbl->noexpand != 1) { do { unsigned _he_bkt; unsigned _he_bkt_i; struct UT_hash_handle *_he_thh, *_he_hh_nxt; UT_hash_bucket *_he_new_buckets, *_he_newbkt; _he_new_buckets = (UT_hash_bucket*)malloc(2 * (&(window)->hh)->tbl->num_buckets * sizeof(struct UT_hash_bucket)); if (!_he_new_buckets) { exit(-1); } memset(_he_new_buckets, 0, 2 * (&(window)->hh)->tbl->num_buckets * sizeof(struct UT_hash_bucket)); (&(window)->hh)->tbl->ideal_chain_maxlen = ((&(window)->hh)->tbl->num_items >> ((&(window)->hh)->tbl->log2_num_buckets+1)) + (((&(window)->hh)->tbl->num_items & (((&(window)->hh)->tbl->num_buckets*2)-1)) ? 1 : 0); (&(window)->hh)->tbl->nonideal_items = 0; for(_he_bkt_i = 0; _he_bkt_i < (&(window)->hh)->tbl->num_buckets; _he_bkt_i++) { _he_thh = (&(window)->hh)->tbl->buckets[ _he_bkt_i ].hh_head; while (_he_thh) { _he_hh_nxt = _he_thh->hh_next; do { _he_bkt = ((_he_thh->hashv) & (((&(window)->hh)->tbl->num_buckets*2) - 1)); } while(0); _he_newbkt = &(_he_new_buckets[ _he_bkt ]); if (++(_he_newbkt->count) > (&(window)->hh)->tbl->ideal_chain_maxlen) { (&(window)->hh)->tbl->nonideal_items++; _he_newbkt->expand_mult = _he_newbkt->count / (&(window)->hh)->tbl->ideal_chain_maxlen; } _he_thh->hh_prev = ((void *)0); _he_thh->hh_next = _he_newbkt->hh_head; if (_he_newbkt->hh_head) _he_newbkt->hh_head->hh_prev = _he_thh; _he_newbkt->hh_head = _he_thh; _he_thh = _he_hh_nxt; } } free((&(window)->hh)->tbl->buckets); (&(window)->hh)->tbl->num_buckets *= 2; (&(window)->hh)->tbl->log2_num_buckets++; (&(window)->hh)->tbl->buckets = _he_new_buckets; (&(window)->hh)->tbl->ineff_expands = ((&(window)->hh)->tbl->nonideal_items > ((&(window)->hh)->tbl->num_items >> 1)) ? ((&(window)->hh)->tbl->ineff_expands+1) : 0; if ((&(window)->hh)->tbl->ineff_expands > 1) { (&(window)->hh)->tbl->noexpand=1; ; } ; } while(0); } } while(0); ; ; ; } while(0);
 window->prev = ((void *)0);
 window->next = ((void *)0);
 window->pixmap = 0L;
 window->picture = 0L;
 window_list_prepend(id);
}

canonical_original_code:
void window_create(unsigned long id)
{
 struct window_def *window = malloc(sizeof(window_t));
 window->id = id;
 window->mapped = 0;
 window->dirty = 1;
 do { unsigned int _ha_bkt; (window)->hh.next = ((void *)0); (window)->hh.key = (char *)(&((window)->id)); (window)->hh.keylen = (unsigned int)(sizeof(Window)); if (!(window_map)) { window_map = (window); (window_map)->hh.prev = ((void *)0); do { (window_map)->hh.tbl = (struct UT_hash_table *)malloc(sizeof(UT_hash_table)); if (!((window_map)->hh.tbl)) { exit(-1); } memset((window_map)->hh.tbl, 0, sizeof(UT_hash_table)); (window_map)->hh.tbl->tail = &((window_map)->hh); (window_map)->hh.tbl->num_buckets = 32; (window_map)->hh.tbl->log2_num_buckets = 5; (window_map)->hh.tbl->hho = (char *)(&(window_map)->hh) - (char *)(window_map); (window_map)->hh.tbl->buckets = (struct UT_hash_bucket *)malloc(32*sizeof(struct UT_hash_bucket)); if (! (window_map)->hh.tbl->buckets) { exit(-1); } memset((window_map)->hh.tbl->buckets, 0, 32*sizeof(struct UT_hash_bucket)); ; (window_map)->hh.tbl->signature = 0xa0111fe1; } while(0); } else { (window_map)->hh.tbl->tail->next = (window); (window)->hh.prev = ((void *)(((char *)((window_map)->hh.tbl->tail)) - (((window_map)->hh.tbl)->hho))); (window_map)->hh.tbl->tail = &((window)->hh); } (window_map)->hh.tbl->num_items++; (window)->hh.tbl = (window_map)->hh.tbl; do { unsigned int _hj_i; unsigned int _hj_j; unsigned int _hj_k; unsigned char *_hj_key = (unsigned char*)(&((window)->id)); (window)->hh.hashv = 0xfeedbeef; _hj_i = _hj_j = 0x9e3779b9; _hj_k = (unsigned int)(sizeof(Window)); while (_hj_k >= 12) { _hj_i += (_hj_key[0] + ( (unsigned int)_hj_key[1] << 8 ) + ( (unsigned int)_hj_key[2] << 16 ) + ( (unsigned int)_hj_key[3] << 24 ) ); _hj_j += (_hj_key[4] + ( (unsigned int)_hj_key[5] << 8 ) + ( (unsigned int)_hj_key[6] << 16 ) + ( (unsigned int)_hj_key[7] << 24 ) ); (window)->hh.hashv += (_hj_key[8] + ( (unsigned int)_hj_key[9] << 8 ) + ( (unsigned int)_hj_key[10] << 16 ) + ( (unsigned int)_hj_key[11] << 24 ) ); do { _hj_i -= _hj_j; _hj_i -= (window)->hh.hashv; _hj_i ^= ( (window)->hh.hashv >> 13 ); _hj_j -= (window)->hh.hashv; _hj_j -= _hj_i; _hj_j ^= ( _hj_i << 8 ); (window)->hh.hashv -= _hj_i; (window)->hh.hashv -= _hj_j; (window)->hh.hashv ^= ( _hj_j >> 13 ); _hj_i -= _hj_j; _hj_i -= (window)->hh.hashv; _hj_i ^= ( (window)->hh.hashv >> 12 ); _hj_j -= (window)->hh.hashv; _hj_j -= _hj_i; _hj_j ^= ( _hj_i << 16 ); (window)->hh.hashv -= _hj_i; (window)->hh.hashv -= _hj_j; (window)->hh.hashv ^= ( _hj_j >> 5 ); _hj_i -= _hj_j; _hj_i -= (window)->hh.hashv; _hj_i ^= ( (window)->hh.hashv >> 3 ); _hj_j -= (window)->hh.hashv; _hj_j -= _hj_i; _hj_j ^= ( _hj_i << 10 ); (window)->hh.hashv -= _hj_i; (window)->hh.hashv -= _hj_j; (window)->hh.hashv ^= ( _hj_j >> 15 ); } while (0); _hj_key += 12; _hj_k -= 12; } (window)->hh.hashv += sizeof(Window); switch ( _hj_k ) { case 11: (window)->hh.hashv += ( (unsigned int)_hj_key[10] << 24 ); case 10: (window)->hh.hashv += ( (unsigned int)_hj_key[9] << 16 ); case 9: (window)->hh.hashv += ( (unsigned int)_hj_key[8] << 8 ); case 8: _hj_j += ( (unsigned int)_hj_key[7] << 24 ); case 7: _hj_j += ( (unsigned int)_hj_key[6] << 16 ); case 6: _hj_j += ( (unsigned int)_hj_key[5] << 8 ); case 5: _hj_j += _hj_key[4]; case 4: _hj_i += ( (unsigned int)_hj_key[3] << 24 ); case 3: _hj_i += ( (unsigned int)_hj_key[2] << 16 ); case 2: _hj_i += ( (unsigned int)_hj_key[1] << 8 ); case 1: _hj_i += _hj_key[0]; } do { _hj_i -= _hj_j; _hj_i -= (window)->hh.hashv; _hj_i ^= ( (window)->hh.hashv >> 13 ); _hj_j -= (window)->hh.hashv; _hj_j -= _hj_i; _hj_j ^= ( _hj_i << 8 ); (window)->hh.hashv -= _hj_i; (window)->hh.hashv -= _hj_j; (window)->hh.hashv ^= ( _hj_j >> 13 ); _hj_i -= _hj_j; _hj_i -= (window)->hh.hashv; _hj_i ^= ( (window)->hh.hashv >> 12 ); _hj_j -= (window)->hh.hashv; _hj_j -= _hj_i; _hj_j ^= ( _hj_i << 16 ); (window)->hh.hashv -= _hj_i; (window)->hh.hashv -= _hj_j; (window)->hh.hashv ^= ( _hj_j >> 5 ); _hj_i -= _hj_j; _hj_i -= (window)->hh.hashv; _hj_i ^= ( (window)->hh.hashv >> 3 ); _hj_j -= (window)->hh.hashv; _hj_j -= _hj_i; _hj_j ^= ( _hj_i << 10 ); (window)->hh.hashv -= _hj_i; (window)->hh.hashv -= _hj_j; (window)->hh.hashv ^= ( _hj_j >> 15 ); } while (0); _ha_bkt = (window)->hh.hashv & ((window_map)->hh.tbl->num_buckets-1); } while(0); do { (window_map)->hh.tbl->buckets[_ha_bkt].count++; (&(window)->hh)->hh_next = (window_map)->hh.tbl->buckets[_ha_bkt].hh_head; (&(window)->hh)->hh_prev = ((void *)0); if ((window_map)->hh.tbl->buckets[_ha_bkt].hh_head) { ((window_map)->hh.tbl->buckets[_ha_bkt]).hh_head->hh_prev = (&(window)->hh); } ((window_map)->hh.tbl->buckets[_ha_bkt]).hh_head=&(window)->hh; if ((window_map)->hh.tbl->buckets[_ha_bkt].count >= (((window_map)->hh.tbl->buckets[_ha_bkt].expand_mult+1) * 10) && (&(window)->hh)->tbl->noexpand != 1) { do { unsigned int _he_bkt; unsigned int _he_bkt_i; struct UT_hash_handle *_he_thh; struct UT_hash_handle *_he_hh_nxt; struct UT_hash_bucket *_he_new_buckets; struct UT_hash_bucket *_he_newbkt; _he_new_buckets = (struct UT_hash_bucket *)malloc(2 * (&(window)->hh)->tbl->num_buckets * sizeof(struct UT_hash_bucket)); if (!_he_new_buckets) { exit(-1); } memset(_he_new_buckets, 0, 2 * (&(window)->hh)->tbl->num_buckets * sizeof(struct UT_hash_bucket)); (&(window)->hh)->tbl->ideal_chain_maxlen = ((&(window)->hh)->tbl->num_items >> ((&(window)->hh)->tbl->log2_num_buckets+1)) + (((&(window)->hh)->tbl->num_items & (((&(window)->hh)->tbl->num_buckets*2)-1)) ? 1 : 0); (&(window)->hh)->tbl->nonideal_items = 0; for(_he_bkt_i = 0; _he_bkt_i < (&(window)->hh)->tbl->num_buckets; _he_bkt_i++) { _he_thh = (&(window)->hh)->tbl->buckets[ _he_bkt_i ].hh_head; while (_he_thh) { _he_hh_nxt = _he_thh->hh_next; do { _he_bkt = ((_he_thh->hashv) & (((&(window)->hh)->tbl->num_buckets*2) - 1)); } while(0); _he_newbkt = &(_he_new_buckets[ _he_bkt ]); if (++(_he_newbkt->count) > (&(window)->hh)->tbl->ideal_chain_maxlen) { (&(window)->hh)->tbl->nonideal_items++; _he_newbkt->expand_mult = _he_newbkt->count / (&(window)->hh)->tbl->ideal_chain_maxlen; } _he_thh->hh_prev = ((void *)0); _he_thh->hh_next = _he_newbkt->hh_head; if (_he_newbkt->hh_head) _he_newbkt->hh_head->hh_prev = _he_thh; _he_newbkt->hh_head = _he_thh; _he_thh = _he_hh_nxt; } } free((&(window)->hh)->tbl->buckets); (&(window)->hh)->tbl->num_buckets *= 2; (&(window)->hh)->tbl->log2_num_buckets++; (&(window)->hh)->tbl->buckets = _he_new_buckets; (&(window)->hh)->tbl->ineff_expands = ((&(window)->hh)->tbl->nonideal_items > ((&(window)->hh)->tbl->num_items >> 1)) ? ((&(window)->hh)->tbl->ineff_expands+1) : 0; if ((&(window)->hh)->tbl->ineff_expands > 1) { (&(window)->hh)->tbl->noexpand=1; ; } ; } while(0); } } while(0); ; ; ; } while(0);
 window->prev = ((void *)0);
 window->next = ((void *)0);
 window->pixmap = 0L;
 window->picture = 0L;
 window_list_prepend(id);
}

variable_types: struct UT_hash_handle { struct UT_hash_table { struct UT_hash_bucket { struct UT_hash_handle *hh_head; unsigned int count; unsigned int expand_mult; } *buckets; unsigned int num_buckets; unsigned int num_items; struct UT_hash_handle *tail; long hho; unsigned int ideal_chain_maxlen; unsigned int nonideal_items; unsigned int ineff_expands; unsigned int signature; } *tbl; void *prev; void *next; struct UT_hash_handle *hh_prev; struct UT_hash_handle *hh_next; void *key; unsigned int keylen; unsigned int hashv; } *

variable_types: struct UT_hash_bucket { struct UT_hash_handle { struct UT_hash_table { struct UT_hash_bucket *buckets; unsigned int num_buckets; unsigned int num_items; struct UT_hash_handle *tail; long hho; unsigned int ideal_chain_maxlen; unsigned int nonideal_items; unsigned int ineff_expands; unsigned int signature; } *tbl; void *prev; void *next; struct UT_hash_handle *hh_prev; struct UT_hash_handle *hh_next; void *key; unsigned int keylen; unsigned int hashv; } *hh_head; unsigned int count; unsigned int expand_mult; } *


decompiled_code:
int window_list_populate()
{
int result; // eax
signed int v1; // ebx
__int64 v2; // rbp
__int64 v3; // rdi
unsigned int v4; // [rsp+4h] [rbp-34h] BYREF
Window v5; // [rsp+8h] [rbp-30h] BYREF
Window v6; // [rsp+10h] [rbp-28h] BYREF
Window *v7; // [rsp+18h] [rbp-20h] BYREF

result = XQueryTree(conn, conn->screens[(__int64)conn->default_screen].root, &v5, &v6, &v7, &v4);
v1 = v4 - 1;
if ( (int)(v4 - 1) >= 0 )
{
v2 = v1;
do
{
--v1;
v3 = v7[v2--];
result = window_create(v3);
}
while ( v1 != -1 );
}
if ( v7 )
result = XFree(v7);
return result;
}

canonical_decompiled_code:
int func8()
{
int result; // eax
signed int v1; // ebx
__int64 v2; // rbp
__int64 v3; // rdi
unsigned int v4; // [rsp+4h] [rbp-34h] BYREF
Window v5; // [rsp+8h] [rbp-30h] BYREF
Window v6; // [rsp+10h] [rbp-28h] BYREF
Window *v7; // [rsp+18h] [rbp-20h] BYREF

result = XQueryTree(conn, conn->screens[(__int64)conn->default_screen].root, &v5, &v6, &v7, &v4);
v1 = v4 - 1;
if ( (int)(v4 - 1) >= 0 )
{
v2 = v1;
do
{
--v1;
v3 = v7[v2--];
result = func7(v3);
}
while ( v1 != -1 );
}
if ( v7 )
result = XFree(v7);
return result;
}

original_code:
void window_list_populate()
{
 Window root, parent, *children;
 unsigned num_children;
 int i;
 XQueryTree(conn, ((&((_XPrivDisplay)(conn))->screens[(((_XPrivDisplay)(conn))->default_screen)])->root), &root, &parent, &children, &num_children);
 for (i = num_children - 1; i >= 0; i--) {
  window_create(children[i]);
 }
 if (children != ((void *)0))
  XFree(children);
}

canonical_original_code:
void window_list_populate()
{
 unsigned long root; unsigned long parent; unsigned long *children;
 unsigned int num_children;
 int i;
 XQueryTree(conn, ((&((_XPrivDisplay)(conn))->screens[(((_XPrivDisplay)(conn))->default_screen)])->root), &root, &parent, &children, &num_children);
 for (i = num_children - 1; i >= 0; i--) {
  window_create(children[i]);
 }
 if (children != ((void *)0))
  XFree(children);
}

variable_types:
root
unsigned long

variable_types:
parent
unsigned long

variable_types:
children
unsigned long *

variable_types: i int


decompiled_code:
__int64 __fastcall window_set_mapped(__int64 a1)
{
__int64 result; // rax
char v3; // r8
__int64 v4; // rbx
__int64 v5; // rax
__int64 v6; // rsi
__int64 v7; // r12
Pixmap v8; // rsi
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // rsi
Display *v12; // rdi
_DWORD v13[26]; // [rsp+0h] [rbp-68h] BYREF

result = window_get(a1);
if ( result )
{
*(_BYTE *)(result + 40) = v3;
v4 = result;
if ( v3 == 1 )
{
v5 = XRenderFindVisualFormat(conn, visual);
v6 = *(_QWORD *)(v4 + 32);
v13[11] = 1;
v7 = v5;
if ( v6 )
XRenderFreePicture(conn);
v8 = *(_QWORD *)(v4 + 24);
if ( v8 )
XFreePixmap(conn, v8);
v9 = XCompositeNameWindowPixmap(conn, a1);
*(_QWORD *)(v4 + 24) = v9;
v10 = XRenderCreatePicture(conn, v9, v7, 256LL, v13);
v11 = *(_QWORD *)(v4 + 24);
v12 = conn;
*(_QWORD *)(v4 + 32) = v10;
XDamageCreate(v12, v11, 3LL);
window_list_remove(a1);
result = window_list_append(a1);
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1)
{
__int64 result; // rax
char v3; // r8
__int64 v4; // rbx
__int64 v5; // rax
__int64 v6; // rsi
__int64 v7; // r12
Pixmap v8; // rsi
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // rsi
Display *v12; // rdi
_DWORD v13[26]; // [rsp+0h] [rbp-68h] BYREF

result = func0(a1);
if ( result )
{
*(_BYTE *)(result + 40) = v3;
v4 = result;
if ( v3 == 1 )
{
v5 = XRenderFindVisualFormat(conn, visual);
v6 = *(_QWORD *)(v4 + 32);
v13[11] = 1;
v7 = v5;
if ( v6 )
XRenderFreePicture(conn);
v8 = *(_QWORD *)(v4 + 24);
if ( v8 )
XFreePixmap(conn, v8);
v9 = XCompositeNameWindowPixmap(conn, a1);
*(_QWORD *)(v4 + 24) = v9;
v10 = XRenderCreatePicture(conn, v9, v7, 256LL, v13);
v11 = *(_QWORD *)(v4 + 24);
v12 = conn;
*(_QWORD *)(v4 + 32) = v10;
XDamageCreate(v12, v11, 3LL);
func1(a1);
result = func3(a1);
}
}
return result;
}

original_code:
void window_set_mapped(Window id, bool mapped)
{
 window_t *window = window_get(id);
 if (window == ((void *)0))
  return;
 window->mapped = mapped;
 if (mapped == 1) {
  XRenderPictFormat *format;
  XRenderPictureAttributes pa;
  format = XRenderFindVisualFormat(conn, visual);
  pa.subwindow_mode = 1;
  if (window->picture != 0L)
   XRenderFreePicture(conn, window->picture);
  if (window->pixmap != 0L)
   XFreePixmap(conn, window->pixmap);
  window->pixmap = XCompositeNameWindowPixmap(conn, id);
  window->picture = XRenderCreatePicture(conn, window->pixmap,
    format, (1 << 8), &pa);
  XDamageCreate(conn, window->pixmap, 3);
  window_list_remove(id);
  window_list_append(id);
 }
}

canonical_original_code:
void window_set_mapped(unsigned long id, char mapped)
{
 struct window_def *window = window_get(id);
 if (window == ((void *)0))
  return;
 window->mapped = mapped;
 if (mapped == 1) {
  struct XRenderPictFormat *format;
  struct _XRenderPictureAttributes pa;
  format = XRenderFindVisualFormat(conn, visual);
  pa.subwindow_mode = 1;
  if (window->picture != 0L)
   XRenderFreePicture(conn, window->picture);
  if (window->pixmap != 0L)
   XFreePixmap(conn, window->pixmap);
  window->pixmap = XCompositeNameWindowPixmap(conn, id);
  window->picture = XRenderCreatePicture(conn, window->pixmap,
    format, (1 << 8), &pa);
  XDamageCreate(conn, window->pixmap, 3);
  window_list_remove(id);
  window_list_append(id);
 }
}

variable_types: mapped char

variable_types: struct XRenderPictFormat { unsigned long id; int type; int depth; struct XRenderDirectFormat { short red; short redMask; short green; short greenMask; short blue; short blueMask; short alpha; short alphaMask; } direct; unsigned long colormap; } *

variable_types: struct _XRenderPictureAttributes { int repeat; unsigned long alpha_map; int alpha_x_origin; int alpha_y_origin; int clip_x_origin; int clip_y_origin; unsigned long clip_mask; int graphics_exposures; int subwindow_mode; int poly_edge; int poly_mode; unsigned long dither; int component_alpha; }

user_defined_types: struct XRenderPictFormat { unsigned long id; int type; int depth; struct XRenderDirectFormat direct; unsigned long colormap; }


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

result = window_get(a1);
if ( result )
*(_BYTE *)(result + 41) = 1;
return result;
}

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

result = func0(a1);
if ( result )
*(_BYTE *)(result + 41) = 1;
return result;
}

original_code:
void window_damaged(Window id)
{
 window_t *window = window_get(id);
 if (window == ((void *)0))
  return;
 window->dirty = 1;
}

canonical_original_code:
void window_damaged(unsigned long id)
{
 struct window_def *window = window_get(id);
 if (window == ((void *)0))
  return;
 window->dirty = 1;
}


decompiled_code:
__int64 __fastcall window_draw(__int64 a1)
{
__int64 result; // rax
__int64 v2; // r8

result = window_get(a1);
if ( result )
result = XRenderComposite(
conn,
1LL,
*(_QWORD *)(result + 32),
0LL,
v2,
0LL,
0LL,
0LL,
0LL,
*(unsigned int *)(result + 8),
*(unsigned int *)(result + 12),
*(unsigned int *)(result + 16),
*(unsigned int *)(result + 20));
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1)
{
__int64 result; // rax
__int64 v2; // r8

result = func0(a1);
if ( result )
result = XRenderComposite(
conn,
1LL,
*(_QWORD *)(result + 32),
0LL,
v2,
0LL,
0LL,
0LL,
0LL,
*(unsigned int *)(result + 8),
*(unsigned int *)(result + 12),
*(unsigned int *)(result + 16),
*(unsigned int *)(result + 20));
return result;
}

original_code:
void window_draw(Window id, Picture surface)
{
 window_t *window = window_get(id);
 if (window == ((void *)0))
  return;
 XRenderComposite(conn, 1, window->picture, 0L, surface, 0, 0,
   0, 0, window->x, window->y, window->width, window->height);
}

canonical_original_code:
void window_draw(unsigned long id, unsigned long surface)
{
 struct window_def *window = window_get(id);
 if (window == ((void *)0))
  return;
 XRenderComposite(conn, 1, window->picture, 0L, surface, 0, 0,
   0, 0, window->x, window->y, window->width, window->height);
}

variable_types:
surface
unsigned long


decompiled_code:
__int64 window_list_draw()
{
__int64 i; // rbx
__int64 result; // rax

for ( i = window_list; i; i = *(_QWORD *)(i + 56) )
{
while ( *(_BYTE *)(i + 40) != 1 )
{
i = *(_QWORD *)(i + 56);
if ( !i )
return result;
}
result = window_draw(*(_QWORD *)i);
}
return result;
}

canonical_decompiled_code:
__int64 func14()
{
__int64 i; // rbx
__int64 result; // rax

for ( i = window_list; i; i = *(_QWORD *)(i + 56) )
{
while ( *(_BYTE *)(i + 40) != 1 )
{
i = *(_QWORD *)(i + 56);
if ( !i )
return result;
}
result = func13(*(_QWORD *)i);
}
return result;
}

original_code:
void window_list_draw(Picture surface)
{
 window_t *window = window_list;
 while (window != ((void *)0))
 {
  if (window->mapped == 1) {
   window_draw(window->id, surface);
  }
  window = window->next;
 }
}

canonical_original_code:
void window_list_draw(unsigned long surface)
{
 struct window_def *window = window_list;
 while (window != ((void *)0))
 {
  if (window->mapped == 1) {
   window_draw(window->id, surface);
  }
  window = window->next;
 }
}


original_code:
void window_destroy(Window id)
{
 window_t *window;
 window = window_list_remove(id);
 do { unsigned _hd_bkt; struct UT_hash_handle *_hd_hh_del; if ( ((window)->hh.prev == ((void *)0)) && ((window)->hh.next == ((void *)0)) ) { free((window_map)->hh.tbl->buckets); ; free((window_map)->hh.tbl); window_map = ((void *)0); } else { _hd_hh_del = &((window)->hh); if ((window) == ((void*)(((char*)((window_map)->hh.tbl->tail)) - (((window_map)->hh.tbl)->hho)))) { (window_map)->hh.tbl->tail = (UT_hash_handle*)((ptrdiff_t)((window)->hh.prev) + (window_map)->hh.tbl->hho); } if ((window)->hh.prev) { ((UT_hash_handle*)((ptrdiff_t)((window)->hh.prev) + (window_map)->hh.tbl->hho))->next = (window)->hh.next; } else { do { (window_map) = (__typeof(window_map))((window)->hh.next); } while(0); } if (_hd_hh_del->next) { ((UT_hash_handle*)((ptrdiff_t)_hd_hh_del->next + (window_map)->hh.tbl->hho))->prev = _hd_hh_del->prev; } do { _hd_bkt = ((_hd_hh_del->hashv) & (((window_map)->hh.tbl->num_buckets) - 1)); } while(0); ((window_map)->hh.tbl->buckets[_hd_bkt]).count--; if (((window_map)->hh.tbl->buckets[_hd_bkt]).hh_head == _hd_hh_del) { ((window_map)->hh.tbl->buckets[_hd_bkt]).hh_head = _hd_hh_del->hh_next; } if (_hd_hh_del->hh_prev) { _hd_hh_del->hh_prev->hh_next = _hd_hh_del->hh_next; } if (_hd_hh_del->hh_next) { _hd_hh_del->hh_next->hh_prev = _hd_hh_del->hh_prev; }; (window_map)->hh.tbl->num_items--; } ; } while (0);
 free(window);
}

canonical_original_code:
void window_destroy(unsigned long id)
{
 struct window_def *window;
 window = window_list_remove(id);
 do { unsigned int _hd_bkt; struct UT_hash_handle *_hd_hh_del; if ( ((window)->hh.prev == ((void *)0)) && ((window)->hh.next == ((void *)0)) ) { free((window_map)->hh.tbl->buckets); ; free((window_map)->hh.tbl); window_map = ((void *)0); } else { _hd_hh_del = &((window)->hh); if ((window) == ((void *)(((char *)((window_map)->hh.tbl->tail)) - (((window_map)->hh.tbl)->hho)))) { (window_map)->hh.tbl->tail = (struct UT_hash_handle *)((long)((window)->hh.prev) + (window_map)->hh.tbl->hho); } if ((window)->hh.prev) { ((struct UT_hash_handle *)((long)((window)->hh.prev) + (window_map)->hh.tbl->hho))->next = (window)->hh.next; } else { do { (window_map) = (__typeof(window_map))((window)->hh.next); } while(0); } if (_hd_hh_del->next) { ((struct UT_hash_handle *)((long)_hd_hh_del->next + (window_map)->hh.tbl->hho))->prev = _hd_hh_del->prev; } do { _hd_bkt = ((_hd_hh_del->hashv) & (((window_map)->hh.tbl->num_buckets) - 1)); } while(0); ((window_map)->hh.tbl->buckets[_hd_bkt]).count--; if (((window_map)->hh.tbl->buckets[_hd_bkt]).hh_head == _hd_hh_del) { ((window_map)->hh.tbl->buckets[_hd_bkt]).hh_head = _hd_hh_del->hh_next; } if (_hd_hh_del->hh_prev) { _hd_hh_del->hh_prev->hh_next = _hd_hh_del->hh_next; } if (_hd_hh_del->hh_next) { _hd_hh_del->hh_next->hh_prev = _hd_hh_del->hh_prev; }; (window_map)->hh.tbl->num_items--; } ; } while (0);
 free(window);
}


decompiled_code:
void process_opts()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code:
void process_opts(int argc, char** argv)
{
}

canonical_original_code:
void process_opts(int argc, char **argv)
{
}

variable_types: argc int

variable_types:
argv
char **


decompiled_code:
__int64 __fastcall allow_input_passthrough(__int64 a1)
{
__int64 v1; // rbp

v1 = XFixesCreateRegion(conn, 0LL, 0LL);
XFixesSetWindowShapeRegion(conn, a1, 0LL, 0LL, 0LL, 0LL);
XFixesSetWindowShapeRegion(conn, a1, 2LL, 0LL, 0LL, v1);
return XFixesDestroyRegion(conn, v1);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
__int64 v1; // rbp

v1 = XFixesCreateRegion(conn, 0LL, 0LL);
XFixesSetWindowShapeRegion(conn, a1, 0LL, 0LL, 0LL, 0LL);
XFixesSetWindowShapeRegion(conn, a1, 2LL, 0LL, 0LL, v1);
return XFixesDestroyRegion(conn, v1);
}

original_code:
void allow_input_passthrough(Window overlay)
{
 XserverRegion region = XFixesCreateRegion(conn, ((void *)0), 0);
 XFixesSetWindowShapeRegion(conn, overlay, 0, 0, 0, 0);
 XFixesSetWindowShapeRegion(conn, overlay, 2, 0, 0, region);
 XFixesDestroyRegion(conn, region);
}

canonical_original_code:
void allow_input_passthrough(unsigned long overlay)
{
 unsigned long region = XFixesCreateRegion(conn, ((void *)0), 0);
 XFixesSetWindowShapeRegion(conn, overlay, 0, 0, 0, 0);
 XFixesSetWindowShapeRegion(conn, overlay, 2, 0, 0, region);
 XFixesDestroyRegion(conn, region);
}

variable_types:
overlay
unsigned long

variable_types:
region
unsigned long


original_code:
frame_t * frame_get( Window id )
{
   frame_t *frame;
   do { unsigned _hf_bkt,_hf_hashv; frame=((void *)0); if (frame_map) { do { unsigned _hj_i,_hj_j,_hj_k; unsigned char *_hj_key=(unsigned char*)(&id); _hf_hashv = 0xfeedbeef; _hj_i = _hj_j = 0x9e3779b9; _hj_k = (unsigned)(sizeof(Window)); while (_hj_k >= 12) { _hj_i += (_hj_key[0] + ( (unsigned)_hj_key[1] << 8 ) + ( (unsigned)_hj_key[2] << 16 ) + ( (unsigned)_hj_key[3] << 24 ) ); _hj_j += (_hj_key[4] + ( (unsigned)_hj_key[5] << 8 ) + ( (unsigned)_hj_key[6] << 16 ) + ( (unsigned)_hj_key[7] << 24 ) ); _hf_hashv += (_hj_key[8] + ( (unsigned)_hj_key[9] << 8 ) + ( (unsigned)_hj_key[10] << 16 ) + ( (unsigned)_hj_key[11] << 24 ) ); do { _hj_i -= _hj_j; _hj_i -= _hf_hashv; _hj_i ^= ( _hf_hashv >> 13 ); _hj_j -= _hf_hashv; _hj_j -= _hj_i; _hj_j ^= ( _hj_i << 8 ); _hf_hashv -= _hj_i; _hf_hashv -= _hj_j; _hf_hashv ^= ( _hj_j >> 13 ); _hj_i -= _hj_j; _hj_i -= _hf_hashv; _hj_i ^= ( _hf_hashv >> 12 ); _hj_j -= _hf_hashv; _hj_j -= _hj_i; _hj_j ^= ( _hj_i << 16 ); _hf_hashv -= _hj_i; _hf_hashv -= _hj_j; _hf_hashv ^= ( _hj_j >> 5 ); _hj_i -= _hj_j; _hj_i -= _hf_hashv; _hj_i ^= ( _hf_hashv >> 3 ); _hj_j -= _hf_hashv; _hj_j -= _hj_i; _hj_j ^= ( _hj_i << 10 ); _hf_hashv -= _hj_i; _hf_hashv -= _hj_j; _hf_hashv ^= ( _hj_j >> 15 ); } while (0); _hj_key += 12; _hj_k -= 12; } _hf_hashv += sizeof(Window); switch ( _hj_k ) { case 11: _hf_hashv += ( (unsigned)_hj_key[10] << 24 ); case 10: _hf_hashv += ( (unsigned)_hj_key[9] << 16 ); case 9: _hf_hashv += ( (unsigned)_hj_key[8] << 8 ); case 8: _hj_j += ( (unsigned)_hj_key[7] << 24 ); case 7: _hj_j += ( (unsigned)_hj_key[6] << 16 ); case 6: _hj_j += ( (unsigned)_hj_key[5] << 8 ); case 5: _hj_j += _hj_key[4]; case 4: _hj_i += ( (unsigned)_hj_key[3] << 24 ); case 3: _hj_i += ( (unsigned)_hj_key[2] << 16 ); case 2: _hj_i += ( (unsigned)_hj_key[1] << 8 ); case 1: _hj_i += _hj_key[0]; } do { _hj_i -= _hj_j; _hj_i -= _hf_hashv; _hj_i ^= ( _hf_hashv >> 13 ); _hj_j -= _hf_hashv; _hj_j -= _hj_i; _hj_j ^= ( _hj_i << 8 ); _hf_hashv -= _hj_i; _hf_hashv -= _hj_j; _hf_hashv ^= ( _hj_j >> 13 ); _hj_i -= _hj_j; _hj_i -= _hf_hashv; _hj_i ^= ( _hf_hashv >> 12 ); _hj_j -= _hf_hashv; _hj_j -= _hj_i; _hj_j ^= ( _hj_i << 16 ); _hf_hashv -= _hj_i; _hf_hashv -= _hj_j; _hf_hashv ^= ( _hj_j >> 5 ); _hj_i -= _hj_j; _hj_i -= _hf_hashv; _hj_i ^= ( _hf_hashv >> 3 ); _hj_j -= _hf_hashv; _hj_j -= _hj_i; _hj_j ^= ( _hj_i << 10 ); _hf_hashv -= _hj_i; _hf_hashv -= _hj_j; _hf_hashv ^= ( _hj_j >> 15 ); } while (0); _hf_bkt = _hf_hashv & ((frame_map)->hh.tbl->num_buckets-1); } while(0); if ((1)) { do { if ((frame_map)->hh.tbl->buckets[ _hf_bkt ].hh_head) do { (frame) = (__typeof(frame))(((void*)(((char*)((frame_map)->hh.tbl->buckets[ _hf_bkt ].hh_head)) - (((frame_map)->hh.tbl)->hho)))); } while(0); else frame=((void *)0); while (frame) { if ((frame)->hh.keylen == sizeof(Window)) { if ((memcmp((frame)->hh.key,&id,sizeof(Window))) == 0) break; } if ((frame)->hh.hh_next) do { (frame) = (__typeof(frame))(((void*)(((char*)((frame)->hh.hh_next)) - (((frame_map)->hh.tbl)->hho)))); } while(0); else frame = ((void *)0); } } while(0); } } } while (0);
   return frame;
}

canonical_original_code:
struct frame_t *frame_get(unsigned long id)
{
   struct frame_t *frame;
   do { unsigned int _hf_bkt; unsigned int _hf_hashv; frame=((void *)0); if (frame_map) { do { unsigned int _hj_i; unsigned int _hj_j; unsigned int _hj_k; unsigned char *_hj_key = (unsigned char*)(&id); _hf_hashv = 0xfeedbeef; _hj_i = _hj_j = 0x9e3779b9; _hj_k = (unsigned int)(sizeof(Window)); while (_hj_k >= 12) { _hj_i += (_hj_key[0] + ( (unsigned int)_hj_key[1] << 8 ) + ( (unsigned int)_hj_key[2] << 16 ) + ( (unsigned int)_hj_key[3] << 24 ) ); _hj_j += (_hj_key[4] + ( (unsigned int)_hj_key[5] << 8 ) + ( (unsigned int)_hj_key[6] << 16 ) + ( (unsigned int)_hj_key[7] << 24 ) ); _hf_hashv += (_hj_key[8] + ( (unsigned int)_hj_key[9] << 8 ) + ( (unsigned int)_hj_key[10] << 16 ) + ( (unsigned int)_hj_key[11] << 24 ) ); do { _hj_i -= _hj_j; _hj_i -= _hf_hashv; _hj_i ^= ( _hf_hashv >> 13 ); _hj_j -= _hf_hashv; _hj_j -= _hj_i; _hj_j ^= ( _hj_i << 8 ); _hf_hashv -= _hj_i; _hf_hashv -= _hj_j; _hf_hashv ^= ( _hj_j >> 13 ); _hj_i -= _hj_j; _hj_i -= _hf_hashv; _hj_i ^= ( _hf_hashv >> 12 ); _hj_j -= _hf_hashv; _hj_j -= _hj_i; _hj_j ^= ( _hj_i << 16 ); _hf_hashv -= _hj_i; _hf_hashv -= _hj_j; _hf_hashv ^= ( _hj_j >> 5 ); _hj_i -= _hj_j; _hj_i -= _hf_hashv; _hj_i ^= ( _hf_hashv >> 3 ); _hj_j -= _hf_hashv; _hj_j -= _hj_i; _hj_j ^= ( _hj_i << 10 ); _hf_hashv -= _hj_i; _hf_hashv -= _hj_j; _hf_hashv ^= ( _hj_j >> 15 ); } while (0); _hj_key += 12; _hj_k -= 12; } _hf_hashv += sizeof(Window); switch ( _hj_k ) { case 11: _hf_hashv += ( (unsigned int)_hj_key[10] << 24 ); case 10: _hf_hashv += ( (unsigned int)_hj_key[9] << 16 ); case 9: _hf_hashv += ( (unsigned int)_hj_key[8] << 8 ); case 8: _hj_j += ( (unsigned int)_hj_key[7] << 24 ); case 7: _hj_j += ( (unsigned int)_hj_key[6] << 16 ); case 6: _hj_j += ( (unsigned int)_hj_key[5] << 8 ); case 5: _hj_j += _hj_key[4]; case 4: _hj_i += ( (unsigned int)_hj_key[3] << 24 ); case 3: _hj_i += ( (unsigned int)_hj_key[2] << 16 ); case 2: _hj_i += ( (unsigned int)_hj_key[1] << 8 ); case 1: _hj_i += _hj_key[0]; } do { _hj_i -= _hj_j; _hj_i -= _hf_hashv; _hj_i ^= ( _hf_hashv >> 13 ); _hj_j -= _hf_hashv; _hj_j -= _hj_i; _hj_j ^= ( _hj_i << 8 ); _hf_hashv -= _hj_i; _hf_hashv -= _hj_j; _hf_hashv ^= ( _hj_j >> 13 ); _hj_i -= _hj_j; _hj_i -= _hf_hashv; _hj_i ^= ( _hf_hashv >> 12 ); _hj_j -= _hf_hashv; _hj_j -= _hj_i; _hj_j ^= ( _hj_i << 16 ); _hf_hashv -= _hj_i; _hf_hashv -= _hj_j; _hf_hashv ^= ( _hj_j >> 5 ); _hj_i -= _hj_j; _hj_i -= _hf_hashv; _hj_i ^= ( _hf_hashv >> 3 ); _hj_j -= _hf_hashv; _hj_j -= _hj_i; _hj_j ^= ( _hj_i << 10 ); _hf_hashv -= _hj_i; _hf_hashv -= _hj_j; _hf_hashv ^= ( _hj_j >> 15 ); } while (0); _hf_bkt = _hf_hashv & ((frame_map)->hh.tbl->num_buckets-1); } while(0); if ((1)) { do { if ((frame_map)->hh.tbl->buckets[ _hf_bkt ].hh_head) do { (frame) = (__typeof(frame))(((void *)(((char *)((frame_map)->hh.tbl->buckets[ _hf_bkt ].hh_head)) - (((frame_map)->hh.tbl)->hho)))); } while(0); else frame=((void *)0); while (frame) { if ((frame)->hh.keylen == sizeof(Window)) { if ((memcmp((frame)->hh.key,&id,sizeof(Window))) == 0) break; } if ((frame)->hh.hh_next) do { (frame) = (__typeof(frame))(((void *)(((char *)((frame)->hh.hh_next)) - (((frame_map)->hh.tbl)->hho)))); } while(0); else frame = ((void *)0); } } while(0); } } } while (0);
   return frame;
}

variable_types:
id
unsigned long

variable_types: struct frame_t { unsigned long id; int x; int y; unsigned int width; unsigned int height; struct window_t { unsigned long id; char *name; char *icon_name; long flags; int min_width; int min_height; int max_width; int max_height; int width_inc; int height_inc; int base_width; int base_height; } *child; struct UT_hash_handle { struct UT_hash_table { struct UT_hash_bucket { struct UT_hash_handle *hh_head; unsigned int count; unsigned int expand_mult; } *buckets; unsigned int num_buckets; unsigned int num_items; struct UT_hash_handle *tail; long hho; unsigned int ideal_chain_maxlen; unsigned int nonideal_items; unsigned int ineff_expands; unsigned int signature; } *tbl; void *prev; void *next; struct UT_hash_handle *hh_prev; struct UT_hash_handle *hh_next; void *key; unsigned int keylen; unsigned int hashv; } hh; } *

user_defined_types: struct frame_t { unsigned long id; int x; int y; unsigned int width; unsigned int height; struct window_t *child; struct UT_hash_handle hh; }


main

canonical_name: main

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

if ( argc != 3 )
{
fwrite("Usage: blk2html <.blk file> <block number>\n", 1uLL, 0x2BuLL, stderr);
exit(1);
}
STREAM = fopen(argv[1], "r");
if ( !STREAM )
{
fprintf(stderr, "Couldn't open .blk file \"%s\"!\n", argv[1]);
exit(1);
}
v3 = atoi(argv[2]);
gotoblock(v3);
last = (__int64)"black";
dumpblock();
fclose(STREAM);
return 0;
}

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

if ( argc != 3 )
{
fwrite("Usage: blk2html <.blk file> <block number>\n", 1uLL, 0x2BuLL, stderr);
exit(1);
}
STREAM = fopen(argv[1], "r");
if ( !STREAM )
{
fprintf(stderr, "Couldn't open .blk file \"%s\"!\n", argv[1]);
exit(1);
}
v3 = atoi(argv[2]);
func22(v3);
last = (__int64)"black";
func23();
fclose(STREAM);
return 0;
}

original_code:
int main(int argc, char *argv[]) {
 if(argc != 3) {
  fprintf(stderr,"Usage: blk2html <.blk file> <block number>\n");
  exit(1);
 }
 STREAM = fopen(argv[1],"r");
 if(!STREAM) {
  fprintf(stderr,"Couldn't open .blk file \"%s\"!\n",argv[1]);
  exit(1);
 }
 gotoblock(atoi(argv[2]));
 last = "black";
 dumpblock();
 fclose(STREAM);
 return 0;
}

variable_types:
argv
char *[]

return_type: int


nul

decompiled_code:
void nul()
{
;
}

canonical_decompiled_code:
void func7()
{
;
}

original_code:
void nul(long word) {
}

canonical_original_code:
void nul(long word) {
}

variable_types: word long


SHORT

decompiled_code:
int __fastcall SHORT(__int64 a1)
{
__int64 v1; // rsi
int result; // eax

last = (__int64)"yellow";
v1 = a1 >> 5;
if ( (a1 & 0x10) != 0 )
result = printf("0x%X", v1);
else
result = printf("%i", v1);
return result;
}

canonical_decompiled_code:
int __fastcall func8(__int64 a1)
{
__int64 v1; // rsi
int result; // eax

last = (__int64)"yellow";
v1 = a1 >> 5;
if ( (a1 & 0x10) != 0 )
result = printf("0x%X", v1);
else
result = printf("%i", v1);
return result;
}

original_code:
void SHORT(long word) {
 last="yellow";
 if((word >> 4) & 1)
  printf("0x%X",word >> 5);
 else
  printf("%i",word >> 5);
}


cSHORT

decompiled_code:
int __fastcall cSHORT(__int64 a1)
{
__int64 v1; // rsi
int result; // eax

last = (__int64)"green";
v1 = a1 >> 5;
if ( (a1 & 0x10) != 0 )
result = printf("0x%X", v1);
else
result = printf("%i", v1);
return result;
}

canonical_decompiled_code:
int __fastcall func9(__int64 a1)
{
__int64 v1; // rsi
int result; // eax

last = (__int64)"green";
v1 = a1 >> 5;
if ( (a1 & 0x10) != 0 )
result = printf("0x%X", v1);
else
result = printf("%i", v1);
return result;
}

original_code:
void cSHORT(long word) {
 last="green";
 if((word >> 4) & 1)
  printf("0x%X",word >> 5);
 else
  printf("%i",word >> 5);
}


unpack

original_code:
char *unpack(long word) {
 static char buf[8];
 int i;
 for(i=0;i<7;i++) {
  if(word & 0x80000000) {
   word = word << 1;
   if(word & 0x80000000) {
    word = word << 1;
    buf[i] = chars[((word >> 27) & 0x1F)+16];
    word = word << 5;
   } else {
    buf[i] = chars[((word >> 28) & 7)+8];
    word = word << 4;
   }
  } else {
   buf[i] = chars[(word >> 28) & 7];
   word = word << 4;
  }
 }
 for(i=6;i>=0;i--) {
  if(buf[i] == ' ')
   buf[i] = 0;
  else
   break;
 }
 buf[7] = 0;
 return buf;
}

variable_types:
buf
char [8]

return_type: char *


exten

decompiled_code:
void __fastcall exten(int a1)
{
__int64 v1; // rdi
const char *v2; // rax

v1 = a1 & 0xFFFFFFF0;
if ( (_DWORD)v1 )
{
v2 = (const char *)unpack(v1);
printf("%s", (const char *)last, v2);
}
}

canonical_decompiled_code:
void __fastcall func11(int a1)
{
__int64 v1; // rdi
const char *v2; // rax

v1 = a1 & 0xFFFFFFF0;
if ( (_DWORD)v1 )
{
v2 = (const char *)func10(v1);
printf("%s", (const char *)last, v2);
}
}

original_code:
void exten(long word) {
 if(word & 0xFFFFFFF0) {
  printf("%s",last,unpack(word & 0xFFFFFFF0));
 } else {
 }
}


execute

decompiled_code:
int __fastcall execute(int a1)
{
const char *v1; // rax

last = (__int64)"yellow";
v1 = (const char *)unpack(a1 & 0xFFFFFFF0);
return printf("%s", v1);
}

canonical_decompiled_code:
int __fastcall func12(int a1)
{
const char *v1; // rax

last = (__int64)"yellow";
v1 = (const char *)func10(a1 & 0xFFFFFFF0);
return printf("%s", v1);
}

original_code:
void execute(long word) {
 last="yellow";
 printf("%s",unpack(word & 0xFFFFFFF0));
}


comment

decompiled_code:
int __fastcall comment(int a1)
{
const char *v1; // rax

last = (__int64)"black";
v1 = (const char *)unpack(a1 & 0xFFFFFFF0);
return printf("%s", v1);
}

canonical_decompiled_code:
int __fastcall func13(int a1)
{
const char *v1; // rax

last = (__int64)"black";
v1 = (const char *)func10(a1 & 0xFFFFFFF0);
return printf("%s", v1);
}

original_code:
void comment(long word) {
 last="black";
 printf("%s",unpack(word & 0xFFFFFFF0));
}


red

decompiled_code:
int __fastcall red(int a1)
{
const char *v1; // rax

last = (__int64)"red";
v1 = (const char *)unpack(a1 & 0xFFFFFFF0);
return printf("
%s", v1);
}

canonical_decompiled_code:
int __fastcall func14(int a1)
{
const char *v1; // rax

last = (__int64)"red";
v1 = (const char *)func10(a1 & 0xFFFFFFF0);
return printf("
%s", v1);
}

original_code:
void red(long word) {
 last="red";
 printf("
%s",unpack(word & 0xFFFFFFF0));
}


qCOMPILE

decompiled_code:
int __fastcall qCOMPILE(int a1)
{
const char *v1; // rax

last = (__int64)"green";
v1 = (const char *)unpack(a1 & 0xFFFFFFF0);
return printf("%s", v1);
}

canonical_decompiled_code:
int __fastcall func15(int a1)
{
const char *v1; // rax

last = (__int64)"green";
v1 = (const char *)func10(a1 & 0xFFFFFFF0);
return printf("%s", v1);
}

original_code:
void qCOMPILE(long word) {
 last="green";
 printf("%s",unpack(word & 0xFFFFFFF0));
}


COMPILE

decompiled_code:
int __fastcall COMPILE(int a1)
{
const char *v1; // rax

last = (__int64)"cyan";
v1 = (const char *)unpack(a1 & 0xFFFFFFF0);
return printf("%s", v1);
}

canonical_decompiled_code:
int __fastcall func16(int a1)
{
const char *v1; // rax

last = (__int64)"cyan";
v1 = (const char *)func10(a1 & 0xFFFFFFF0);
return printf("%s", v1);
}

original_code:
void COMPILE(long word) {
 last="cyan";
 printf("%s",unpack(word & 0xFFFFFFF0));
}


doit

decompiled_code:
void __fastcall doit(char a1)
{
typetbl[a1 & 0xF]();
}

canonical_decompiled_code:
void __fastcall func17(char a1)
{
typetbl[a1 & 0xF]();
}

original_code:
void doit(long int word) {
 typetbl[word & 0x0F](word);
}

canonical_original_code:
void doit(long word) {
 typetbl[word & 0x0F](word);
}


getword

decompiled_code:
__int64 getword()
{
__int64 v0; // rbp
unsigned __int16 v1; // bx
__int64 v2; // rbx
int v3; // eax

v0 = (unsigned __int8)fgetc(STREAM);
v1 = (unsigned __int16)fgetc(STREAM) << 8;
v2 = ((fgetc(STREAM) << 16) & 0xFF0000) + v0 + (v1 & 0xFF00);
v3 = fgetc(STREAM);
++count;
return v2 + (v3 << 24);
}

canonical_decompiled_code:
__int64 func18()
{
__int64 v0; // rbp
unsigned __int16 v1; // bx
__int64 v2; // rbx
int v3; // eax

v0 = (unsigned __int8)fgetc(STREAM);
v1 = (unsigned __int16)fgetc(STREAM) << 8;
v2 = ((fgetc(STREAM) << 16) & 0xFF0000) + v0 + (v1 & 0xFF00);
v3 = fgetc(STREAM);
++count;
return v2 + (v3 << 24);
}

original_code:
long getword(void) {
 long int word;
 word = fgetc(STREAM) & 0xFF;
 word += (fgetc(STREAM) & 0xFF) <<8;
 word += (fgetc(STREAM) & 0xFF) <<16;
 word += (fgetc(STREAM) & 0xFF) <<24;
 count++;
 return word;
}

canonical_original_code:
long getword() {
 long word;
 word = fgetc(STREAM) & 0xFF;
 word += (fgetc(STREAM) & 0xFF) <<8;
 word += (fgetc(STREAM) & 0xFF) <<16;
 word += (fgetc(STREAM) & 0xFF) <<24;
 count++;
 return word;
}

return_type: long


NUM

decompiled_code:
int __fastcall NUM(char a1)
{
__int64 v1; // rax
int result; // eax

last = (__int64)"yellow";
v1 = getword();
if ( (a1 & 0x10) != 0 )
result = printf("0x%X", v1);
else
result = printf("%i", v1);
return result;
}

canonical_decompiled_code:
int __fastcall func19(char a1)
{
__int64 v1; // rax
int result; // eax

last = (__int64)"yellow";
v1 = func18();
if ( (a1 & 0x10) != 0 )
result = printf("0x%X", v1);
else
result = printf("%i", v1);
return result;
}

original_code:
void NUM(long word) {
 last="yellow";
 if((word >> 4) & 1)
  printf("0x%X",getword());
 else
  printf("%i",getword());
}


cNUM

decompiled_code:
int __fastcall cNUM(char a1)
{
__int64 v1; // rax
int result; // eax

last = (__int64)"green";
v1 = getword();
if ( (a1 & 0x10) != 0 )
result = printf("0x%X", v1);
else
result = printf("%i", v1);
return result;
}

canonical_decompiled_code:
int __fastcall func20(char a1)
{
__int64 v1; // rax
int result; // eax

last = (__int64)"green";
v1 = func18();
if ( (a1 & 0x10) != 0 )
result = printf("0x%X", v1);
else
result = printf("%i", v1);
return result;
}

original_code:
void cNUM(long word) {
 last="green";
 if((word >> 4) & 1)
  printf("0x%X",getword());
 else
  printf("%i",getword());
}


variable

decompiled_code:
int __fastcall variable(int a1)
{
const char *v1; // rax
__int64 v2; // r8

last = (__int64)"magenta";
getword();
v1 = (const char *)unpack(a1 & 0xFFFFFFF0);
return printf("%s %u", v1, v2);
}

canonical_decompiled_code:
int __fastcall func21(int a1)
{
const char *v1; // rax
__int64 v2; // r8

last = (__int64)"magenta";
func18();
v1 = (const char *)func10(a1 & 0xFFFFFFF0);
return printf("%s %u", v1, v2);
}

original_code:
void variable(long word) {
 last="magenta";
 printf("%s %u",unpack(word & 0xFFFFFFF0),getword());
}


gotoblock

decompiled_code:
int __fastcall gotoblock(int a1)
{
return fseek(STREAM, (a1 - 12) << 10, 0);
}

canonical_decompiled_code:
int __fastcall func22(int a1)
{
return fseek(STREAM, (a1 - 12) << 10, 0);
}

original_code:
void gotoblock(int block) {
 fseek(STREAM,-12*1024+block*1024,0);
}

variable_types: block int


dumpblock

decompiled_code:
void dumpblock()
{
char v0; // bp

count = 0;
do
{
v0 = getword();
if ( (v0 & 0xF) != 0 )
printf("  ");
doit(v0);
}
while ( count <= 255 );
}

canonical_decompiled_code:
void func23()
{
char v0; // bp

count = 0;
do
{
v0 = func18();
if ( (v0 & 0xF) != 0 )
printf("  ");
func17(v0);
}
while ( count <= 255 );
}

original_code:
void dumpblock(void) {
 long word;
 for(count = 0; count < 256;) {
  word = getword();
  if((word & 0x0F) != 0) {
   printf("  ");
  }
  doit(word);
 }
}

canonical_original_code:
void dumpblock() {
 long word;
 for(count = 0; count < 256;) {
  word = getword();
  if((word & 0x0F) != 0) {
   printf("  ");
  }
  doit(word);
 }
}


original_code:
static inline double chi2_intrinsic_double(int n, const double* x, const double* y) {
    double result=0;
    const __m128d eps = _mm_set1_pd(((double)2.22507385850720138309023271733240406e-308L));
    const __m128d zero = _mm_setzero_pd();
    __m128d chi2 = _mm_setzero_pd();
    for ( ; n>1; n-=2) {
        const __m128d a = _mm_loadu_pd(x);
        const __m128d b = _mm_loadu_pd(y);
 x+=2;
 y+=2;
        const __m128d a_plus_b = _mm_add_pd(a,b);
        const __m128d a_plus_b_plus_eps = _mm_add_pd(a_plus_b,eps);
        const __m128d a_minus_b = _mm_sub_pd(a,b);
        const __m128d a_minus_b_sq = _mm_mul_pd(a_minus_b, a_minus_b);
        const __m128d quotient = _mm_div_pd(a_minus_b_sq, a_plus_b_plus_eps);
        chi2 = _mm_add_pd(chi2, quotient);
    }
    const __m128d shuffle = ((__m128d)__builtin_ia32_shufpd ((__v2df)(__m128d)(chi2), (__v2df)(__m128d)(chi2), (int)((((0) << 1) | (1)))));
    const __m128d sum = _mm_add_pd(chi2, shuffle);
    _mm_store_sd(&result,sum);
    _mm_empty();
    if (n)
        result += chi2_baseline_double(n, x, y);
    return result;
}

canonical_original_code:
static inline double chi2_intrinsic_double(int n, double *x, double *y) {
    double result = 0;
    double eps = _mm_set1_pd(((double)2.22507385850720138309023271733240406e-308L));
    double zero = _mm_setzero_pd();
    double chi2 = _mm_setzero_pd();
    for ( ; n>1; n-=2) {
        double a = _mm_loadu_pd(x);
        double b = _mm_loadu_pd(y);
 x+=2;
 y+=2;
        double a_plus_b = _mm_add_pd(a,b);
        double a_plus_b_plus_eps = _mm_add_pd(a_plus_b,eps);
        double a_minus_b = _mm_sub_pd(a,b);
        double a_minus_b_sq = _mm_mul_pd(a_minus_b, a_minus_b);
        double quotient = _mm_div_pd(a_minus_b_sq, a_plus_b_plus_eps);
        chi2 = _mm_add_pd(chi2, quotient);
    }
    double shuffle = ((__m128d)__builtin_ia32_shufpd ((__v2df)(__m128d)(chi2), (__v2df)(__m128d)(chi2), (int)((((0) << 1) | (1)))));
    double sum = _mm_add_pd(chi2, shuffle);
    _mm_store_sd(&result,sum);
    _mm_empty();
    if (n)
        result += chi2_baseline_double(n, x, y);
    return result;
}

variable_types: n int

variable_types:
x
double *

variable_types:
y
double *

variable_types: result double

variable_types: eps double

variable_types: zero double

variable_types: a double

variable_types: b double

variable_types: quotient double

variable_types: shuffle double

variable_types: sum double

return_type: double


decompiled_code:
// attributes: thunk
__m128d __fastcall chi2_double(int a1, __int64 a2, __int64 a3)
{
return chi2_intrinsic_double(a1, a2, a3);
}

canonical_decompiled_code:
__m128d __fastcall func10(int a1, __int64 a2, __int64 a3)
{
return func9(a1, a2, a3);
}

original_code:
double chi2_double(const int dim, const double* const x, const double* const y) {
    double (*chi2_double)(const int, const double*, const double*) = chi2_baseline_double;
    chi2_double = chi2_intrinsic_double;
    return chi2_double(dim, x, y);
}

canonical_original_code:
double chi2_double(int dim, double *x, double *y) {
    double (*chi2_double)(int, double *, double *) = chi2_baseline_double;
    chi2_double = chi2_intrinsic_double;
    return chi2_double(dim, x, y);
}

variable_types: dim int


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
void *v3; // r13
void *v4; // r12
void *v5; // rbp
int v6; // ebx
__int64 i; // rax
__int64 j; // rax
int v9; // eax
int v10; // ebx
int v11; // eax
int result; // eax
double v13; // [rsp+8h] [rbp-30h]

v3 = memalign(0x10uLL, 0x16E3600uLL);
v4 = memalign(0x10uLL, 0x2DC6C00uLL);
v5 = malloc(0xF42400uLL);
if ( v4 == 0LL || v3 == 0LL || !v5 )
{
free(v3);
free(v4);
free(v5);
result = 1;
}
else
{
v6 = clock();
for ( i = 0LL; i != 3000000; ++i )
*((double *)v3 + i) = 1.0 / ((double)(int)i + 1.0);
for ( j = 0LL; j != 6000000; ++j )
*((double *)v4 + j) = 1.0 / ((double)(int)j + 1.0);
v9 = clock();
printf("init time: %8.4f\n", (double)(v9 - v6) * 0.000001);
v10 = clock();
v13 = chi2_distance_double(3000LL, 1000LL, v3, 2000LL, v4, v5);
v11 = clock();
printf("chi2 time: %8.4f\n", (double)(v11 - v10) * 0.000001);
printf("result: %e\n", v13);
free(v3);
free(v4);
free(v5);
result = 0;
}
return result;
}

original_code:
int main()
{
    const int dim=3000;
    const int n1=1000;
    const int n2=2000;
    int i,j;
    double *data1 = (double*)memalign(16,dim*n1*sizeof(double));
    double *data2 = (double*)memalign(16,dim*n2*sizeof(double));
    double *K = (double*)malloc(n1*n2*sizeof(double));
    if ((!data1) || (!data2) || (!K)) {
       free(data1);
       free(data2);
       free(K);
       return 1;
    }
    const clock_t before_init=clock();
    for (i=0;i<n1*dim;i++)
     data1[i]=1./(double)(i+1.);
    for (i=0;i<n2*dim;i++)
     data2[i]=1./(double)(i+1.);
    const clock_t after_init=clock();
    printf("init time: %8.4f\n",(after_init-before_init)*1./((__clock_t) 1000000));
    const clock_t before_chi2=clock();
    const double mean_K = chi2_distance_double(dim, n1, data1, n2, data2, K);
    const clock_t after_chi2=clock();
    printf("chi2 time: %8.4f\n",(after_chi2-before_chi2)*1./((__clock_t) 1000000));
    printf("result: %e\n",mean_K);
    free(data1);
    free(data2);
    free(K);
    return 0;
}

canonical_original_code:
int main()
{
    int dim = 3000;
    int n1 = 1000;
    int n2 = 2000;
    int i; int j;
    double *data1 = (double*)memalign(16,dim*n1*sizeof(double));
    double *data2 = (double*)memalign(16,dim*n2*sizeof(double));
    double *K = (double*)malloc(n1*n2*sizeof(double));
    if ((!data1) || (!data2) || (!K)) {
       free(data1);
       free(data2);
       free(K);
       return 1;
    }
    long before_init = clock();
    for (i=0;i<n1*dim;i++)
     data1[i]=1./(double)(i+1.);
    for (i=0;i<n2*dim;i++)
     data2[i]=1./(double)(i+1.);
    long after_init = clock();
    printf("init time: %8.4f\n",(after_init-before_init)*1./((long) 1000000));
    long before_chi2 = clock();
    double mean_K = chi2_distance_double(dim, n1, data1, n2, data2, K);
    long after_chi2 = clock();
    printf("chi2 time: %8.4f\n",(after_chi2-before_chi2)*1./((long) 1000000));
    printf("result: %e\n",mean_K);
    free(data1);
    free(data2);
    free(K);
    return 0;
}

variable_types: i int

variable_types: j int

variable_types:
K
double *


repo: nqv/aranea

decompiled_code:
__int64 init_conf()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func0()
{
return 0LL;
}

original_code:
static
int init_conf() {
    return 0;
}

canonical_original_code:
static int init_conf() {
    return 0;
}


decompiled_code:
void __fastcall __noreturn print_help(const char *a1)
{
fprintf(stdout, "Usage: %s [OPTION]...\n", a1);
fprintf(
stdout,
"Options:\n%s",
" -d Run as daemon (background) mode\n"
" -p PORT Server listening port\n"
" -r DOCUMENT_ROOT Server root (absolute path)\n");
fprintf(stdout, "Version: %s (AUTH=%d CGI=%d CHROOT=%d VFORK=%d)\n", "0.1", 0LL, 0LL, 0LL, 0LL);
exit(0);
}

canonical_decompiled_code:
void __fastcall __noreturn func1(const char *a1)
{
fprintf(stdout, "Usage: %s [OPTION]...\n", a1);
fprintf(
stdout,
"Options:\n%s",
" -d Run as daemon (background) mode\n"
" -p PORT Server listening port\n"
" -r DOCUMENT_ROOT Server root (absolute path)\n");
fprintf(stdout, "Version: %s (AUTH=%d CGI=%d CHROOT=%d VFORK=%d)\n", "0.1", 0LL, 0LL, 0LL, 0LL);
exit(0);
}

original_code:
static
void print_help(const char *name) {
    fprintf(stdout, "Usage: %s [OPTION]...\n", name);
    fprintf(stdout, "Options:\n%s",
            "  -d                   Run as daemon (background) mode\n"
            "  -p PORT              Server listening port\n"
            "  -r DOCUMENT_ROOT     Server root (absolute path)\n"
            );
    fprintf(stdout, "Version: %s (AUTH=%d CGI=%d CHROOT=%d VFORK=%d)\n",
            "0.1", 0, 0, 0, 0);
    exit(0);
}

canonical_original_code:
static void print_help(char *name) {
    fprintf(stdout, "Usage: %s [OPTION]...\n", name);
    fprintf(stdout, "Options:\n%s",
            "  -d                   Run as daemon (background) mode\n"
            "  -p PORT              Server listening port\n"
            "  -r DOCUMENT_ROOT     Server root (absolute path)\n"
            );
    fprintf(stdout, "Version: %s (AUTH=%d CGI=%d CHROOT=%d VFORK=%d)\n",
            "0.1", 0, 0, 0, 0);
    exit(0);
}

variable_types:
name
char *


decompiled_code:
__int64 __fastcall parse_options(int a1, const char **a2)
{
char v2; // r9
int v3; // eax
int v4; // er8
__int64 v5; // rcx
const char *v6; // rdx
char v7; // dl
const char *v9; // rdx
__int64 v10; // rdx

g_server[1] = "8080";
g_config = (__int64)".";
if ( a1 <= 1 )
return 0LL;
v2 = 0;
v3 = 1;
v4 = flags_;
do
{
while ( 1 )
{
v5 = v3;
v6 = a2[v5];
if ( *v6 != 45 )
goto LABEL_3;
v7 = v6[1];
if ( v7 != 112 )
break;
v9 = a2[v5 + 1];
++v3;
if ( !v9 )
{
if ( v2 )
flags_ = v4;
v10 = 112LL;
goto LABEL_25;
}
g_server[1] = v9;
LABEL_3:
if ( a1 <= ++v3 )
goto LABEL_9;
}
if ( v7 > 112 )
{
if ( v7 == 114 )
{
++v3;
if ( !a2[v5 + 1] )
{
if ( v2 )
flags_ = v4;
v10 = 114LL;
LABEL_25:
fprintf(stderr, "Option %c requires an argument.\n", v10);
return 0xFFFFFFFFLL;
}
g_config = (__int64)a2[v5 + 1];
}
goto LABEL_3;
}
if ( v7 != 100 )
{
if ( v7 == 104 )
{
if ( v2 )
flags_ = v4;
print_help(*a2);
}
goto LABEL_3;
}
++v3;
v4 |= 2u;
v2 = 1;
}
while ( a1 > v3 );
LABEL_9:
if ( v2 )
flags_ = v4;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1, const char **a2)
{
char v2; // r9
int v3; // eax
int v4; // er8
__int64 v5; // rcx
const char *v6; // rdx
char v7; // dl
const char *v9; // rdx
__int64 v10; // rdx

g_server[1] = "8080";
g_config = (__int64)".";
if ( a1 <= 1 )
return 0LL;
v2 = 0;
v3 = 1;
v4 = flags_;
do
{
while ( 1 )
{
v5 = v3;
v6 = a2[v5];
if ( *v6 != 45 )
goto LABEL_3;
v7 = v6[1];
if ( v7 != 112 )
break;
v9 = a2[v5 + 1];
++v3;
if ( !v9 )
{
if ( v2 )
flags_ = v4;
v10 = 112LL;
goto LABEL_25;
}
g_server[1] = v9;
LABEL_3:
if ( a1 <= ++v3 )
goto LABEL_9;
}
if ( v7 > 112 )
{
if ( v7 == 114 )
{
++v3;
if ( !a2[v5 + 1] )
{
if ( v2 )
flags_ = v4;
v10 = 114LL;
LABEL_25:
fprintf(stderr, "Option %c requires an argument.\n", v10);
return 0xFFFFFFFFLL;
}
g_config = (__int64)a2[v5 + 1];
}
goto LABEL_3;
}
if ( v7 != 100 )
{
if ( v7 == 104 )
{
if ( v2 )
flags_ = v4;
func1(*a2);
}
goto LABEL_3;
}
++v3;
v4 |= 2u;
v2 = 1;
}
while ( a1 > v3 );
LABEL_9:
if ( v2 )
flags_ = v4;
return 0LL;
}

original_code:
static
int parse_options(int argc, char **argv) {
    int i;
    g_server.port = "8080";
    g_config.root = ".";
    for (i = 1; i < argc; ++i) {
        if (argv[i][0] == '-') {
            switch (argv[i][1]) {
            case 'd':
                flags_ |= FLAG_DAEMON;
                break;
            case 'h':
                print_help(argv[0]);
                break;
            case 'p':
                ++i;
                do { if ((argv[i]) == ((void *)0)) { fprintf(stderr, "Option %c requires an argument.\n", 'p'); return -1; } } while (0);
                g_server.port = argv[i];
                break;
            case 'r':
                ++i;
                do { if ((argv[i]) == ((void *)0)) { fprintf(stderr, "Option %c requires an argument.\n", 'r'); return -1; } } while (0);
                g_config.root = argv[i];
                break;
            }
        }
    }
    return 0;
}

variable_types: argc int

variable_types:
argv
char **