talloc

decompiled_code:
void *talloc()
{
void *result; // rax

result = malloc(0x20uLL);
if ( !result )
{
printf("Error: ran out of memory");
exit(1);
}
return result;
}

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

result = malloc(0x20uLL);
if ( !result )
{
printf("Error: ran out of memory");
exit(1);
}
return result;
}

original_code:
static struct tnode *talloc(void) {
    struct tnode *p = (struct tnode *)malloc(sizeof(struct tnode));
    if (p == ((void *)0)) {
        printf("Error: ran out of memory");
        exit(1);
    }
    return p;
}

canonical_original_code:
static struct tnode *talloc() {
    struct tnode *p = (struct tnode *)malloc(sizeof(struct tnode));
    if (p == ((void *)0)) {
        printf("Error: ran out of memory");
        exit(1);
    }
    return p;
}

variable_types: struct tnode { char *word; int count; struct tnode *left; struct tnode *right; } *


lalloc

repo: ptdecker/cbasics

decompiled_code:
void *lalloc()
{
void *result; // rax

result = malloc(0x10uLL);
if ( !result )
{
printf("Error: ran out of memory");
exit(1);
}
return result;
}

canonical_decompiled_code:
void *func4()
{
void *result; // rax

result = malloc(0x10uLL);
if ( !result )
{
printf("Error: ran out of memory");
exit(1);
}
return result;
}

original_code:
static struct linklist *lalloc(void) {
    struct linklist *p = (struct linklist *)malloc(sizeof(struct linklist));
    if (p == ((void *)0)) {
        printf("Error: ran out of memory");
        exit(1);
    }
    return p;
}

canonical_original_code:
static struct linklist *lalloc() {
    struct linklist *p = (struct linklist *)malloc(sizeof(struct linklist));
    if (p == ((void *)0)) {
        printf("Error: ran out of memory");
        exit(1);
    }
    return p;
}

variable_types: struct linklist { int linenum; struct linklist *next; } *


mystrdup

decompiled_code:
char *__fastcall mystrdup(char *src)
{
size_t v1; // rax
char *v2; // rax

v1 = strlen(src);
v2 = (char *)malloc(v1 + 1);
if ( !v2 )
{
printf("Error: ran out of memory");
exit(1);
}
return strcpy(v2, src);
}

canonical_decompiled_code:
char *__fastcall func6(char *src)
{
size_t v1; // rax
char *v2; // rax

v1 = strlen(src);
v2 = (char *)malloc(v1 + 1);
if ( !v2 )
{
printf("Error: ran out of memory");
exit(1);
}
return strcpy(v2, src);
}

original_code:
static char *mystrdup(char *s) {
    char *p = (char *)malloc(strlen(s) + 1);
    if (p == ((void *)0)) {
        printf("Error: ran out of memory");
        exit(1);
    }
    strcpy(p, s);
    return p;
}

variable_types:
s
char *

variable_types:
p
char *

return_type: char *


eatchar

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

prior = current;
current = next;
result = getchar();
next = result;
return result;
}

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

prior = current;
current = next;
result = getchar();
next = result;
return result;
}

original_code:
static void eatchar(void) {
    prior = current;
    current = next;
    next = getchar();
}

canonical_original_code:
static void eatchar() {
    prior = current;
    current = next;
    next = getchar();
}

return_type: void


mathfun

decompiled_code:
int __fastcall mathfun(char *s1)
{
bool v1; // cf
bool v2; // zf
_BYTE *v4; // rdi
__int64 v5; // rcx
char *v6; // rsi
char v7; // al
bool v8; // cf
bool v9; // zf
const char *v10; // rdi
__int64 v11; // rcx
char *v12; // rsi
char v13; // al
bool v14; // cf
bool v15; // zf
const char *v16; // rdi
__int64 v17; // rcx
char *v18; // rsi
char v19; // al
bool v20; // cf
bool v21; // zf
const char *v22; // rdi
__int64 v23; // rcx
char *v24; // rsi
char v25; // al
bool v26; // cf
bool v27; // zf
const char *v28; // rdi
__int64 v29; // rcx
char *v30; // rsi
char v31; // al
bool v32; // cf
bool v33; // zf
const char *v34; // rdi
__int64 v35; // rcx
char *v36; // rsi
char v37; // al
bool v38; // cf
bool v39; // zf
const char *v40; // rdi
__int64 v41; // rcx
char *v42; // rsi
char v43; // al
bool v44; // cf
bool v45; // zf
const char *v46; // rdi
__int64 v47; // rcx
char *v48; // rsi
char v49; // al
bool v50; // cf
bool v51; // zf
const char *v52; // rdi
__int64 v53; // rcx
char *v54; // rsi
char v55; // al
bool v56; // cf
bool v57; // zf
const char *v58; // rdi
__int64 v59; // rcx
char *v60; // rsi
char v61; // al
bool v62; // cf
bool v63; // zf
const char *v64; // rdi
__int64 v65; // rcx
char *v66; // rsi
char v67; // al
bool v68; // cf
bool v69; // zf
const char *v70; // rdi
__int64 v71; // rcx
char *v72; // rsi
char v73; // al
bool v74; // cf
bool v75; // zf
const char *v76; // rdi
__int64 v77; // rcx
char *v78; // rsi
char v79; // al
bool v80; // cf
bool v81; // zf
const char *v82; // rdi
__int64 v83; // rcx
char *v84; // rsi
char v85; // al
bool v86; // cf
bool v87; // zf
const char *v88; // rdi
__int64 v89; // rcx
char *v90; // rsi
char v91; // al
bool v92; // cf
bool v93; // zf
const char *v94; // rdi
__int64 v95; // rcx
char *v96; // rsi
double v97; // rbx
double v98; // xmm0_8
double v99; // xmm0_8
double v101; // xmm0_8
double v102; // xmm0_8
double v103; // xmm0_8
double v104; // xmm0_8
double v105; // xmm0_8
double v106; // xmm0_8
double v107; // xmm0_8
double v108; // xmm0_8
double v109; // rbx
double v110; // xmm0_8
double v111; // xmm0_8
double v112; // xmm0_8
double v113; // xmm0_8
double v114; // xmm0_8
__m128d v115; // xmm3
__m128d v116; // xmm1
double v117; // xmm0_8
double v118; // xmm0_8
__m128d v119; // xmm0
__m128d v120; // xmm3
double v121; // xmm0_8
double v122; // xmm0_8
double v123; // xmm0_8
double v124; // xmm0_8
double v125; // xmm0_8
double v126; // xmm0_8
double v127; // xmm0_8
double v128; // xmm0_8
double v129; // xmm0_8
double v130; // xmm0_8
double v131; // xmm0_8
double v132; // xmm0_8
double v133; // xmm0_8
double v134; // xmm0_8

v4 = &unk_A8A;
v5 = 4LL;
v6 = s1;
do
{
if ( !v5 )
break;
v1 = (unsigned __int8)*v6 < *v4;
v2 = *v6++ == *v4++;
--v5;
}
while ( v2 );
v7 = (!v1 && !v2) - v1;
v8 = 0;
v9 = v7 == 0;
if ( !v7 )
{
if ( dasize(v4, v6) )
{
v101 = dapop();
v102 = sin(v101);
return dapush(v102);
}
return puts("Stack is empty");
}
v10 = "cos";
v11 = 4LL;
v12 = s1;
do
{
if ( !v11 )
break;
v8 = (unsigned __int8)*v12 < (unsigned int)*v10;
v9 = *v12++ == *v10++;
--v11;
}
while ( v9 );
v13 = (!v8 && !v9) - v8;
v14 = 0;
v15 = v13 == 0;
if ( !v13 )
{
if ( dasize(v10, v12) )
{
v103 = dapop();
v104 = cos(v103);
return dapush(v104);
}
return puts("Stack is empty");
}
v16 = "acos";
v17 = 5LL;
v18 = s1;
do
{
if ( !v17 )
break;
v14 = (unsigned __int8)*v18 < (unsigned int)*v16;
v15 = *v18++ == *v16++;
--v17;
}
while ( v15 );
v19 = (!v14 && !v15) - v14;
v20 = 0;
v21 = v19 == 0;
if ( !v19 )
{
if ( dasize(v16, v18) )
{
v105 = dapop();
v106 = acos(v105);
return dapush(v106);
}
return puts("Stack is empty");
}
v22 = "asin";
v23 = 5LL;
v24 = s1;
do
{
if ( !v23 )
break;
v20 = (unsigned __int8)*v24 < (unsigned int)*v22;
v21 = *v24++ == *v22++;
--v23;
}
while ( v21 );
v25 = (!v20 && !v21) - v20;
v26 = 0;
v27 = v25 == 0;
if ( !v25 )
{
if ( dasize(v22, v24) )
{
v107 = dapop();
v108 = asin(v107);
return dapush(v108);
}
return puts("Stack is empty");
}
v28 = "atan2";
v29 = 6LL;
v30 = s1;
do
{
if ( !v29 )
break;
v26 = (unsigned __int8)*v30 < (unsigned int)*v28;
v27 = *v30++ == *v28++;
--v29;
}
while ( v27 );
v31 = (!v26 && !v27) - v26;
v32 = 0;
v33 = v31 == 0;
if ( !v31 )
{
if ( (unsigned __int64)dasize(v28, v30) > 1 )
{
v109 = dapop();
v110 = dapop();
v111 = atan2(v110, v109);
return dapush(v111);
}
return puts("Less than two items are on the stack");
}
v34 = "atan";
v35 = 5LL;
v36 = s1;
do
{
if ( !v35 )
break;
v32 = (unsigned __int8)*v36 < (unsigned int)*v34;
v33 = *v36++ == *v34++;
--v35;
}
while ( v33 );
v37 = (!v32 && !v33) - v32;
v38 = 0;
v39 = v37 == 0;
if ( !v37 )
{
if ( dasize(v34, v36) )
{
v112 = dapop();
v113 = atan(v112);
return dapush(v113);
}
return puts("Stack is empty");
}
v40 = "ceil";
v41 = 5LL;
v42 = s1;
do
{
if ( !v41 )
break;
v38 = (unsigned __int8)*v42 < (unsigned int)*v40;
v39 = *v42++ == *v40++;
--v41;
}
while ( v39 );
v43 = (!v38 && !v39) - v38;
v44 = 0;
v45 = v43 == 0;
if ( !v43 )
{
if ( !dasize(v40, v42) )
return puts("Stack is empty");
v114 = dapop();
v115.m128d_f64[0] = v114;
if ( COERCE_DOUBLE(*(_QWORD *)&v114 & LC10) < 4.503599627370496e15 )
{
v116.m128d_f64[0] = (double)(int)v114;
*(_QWORD *)&v115.m128d_f64[0] = COERCE_UNSIGNED_INT64(COERCE_DOUBLE(*(_OWORD *)&_mm_cmpgt_sd(v115, v116) & LC11) + v116.m128d_f64[0]) | ~(_QWORD)LC10 & *(_QWORD *)&v114;
}
return dapush(v115.m128d_f64[0]);
}
v46 = "cosh";
v47 = 5LL;
v48 = s1;
do
{
if ( !v47 )
break;
v44 = (unsigned __int8)*v48 < (unsigned int)*v46;
v45 = *v48++ == *v46++;
--v47;
}
while ( v45 );
v49 = (!v44 && !v45) - v44;
v50 = 0;
v51 = v49 == 0;
if ( !v49 )
{
if ( dasize(v46, v48) )
{
v117 = dapop();
v118 = cosh(v117);
return dapush(v118);
}
return puts("Stack is empty");
}
v52 = "floor";
v53 = 6LL;
v54 = s1;
do
{
if ( !v53 )
break;
v50 = (unsigned __int8)*v54 < (unsigned int)*v52;
v51 = *v54++ == *v52++;
--v53;
}
while ( v51 );
v55 = (!v50 && !v51) - v50;
v56 = 0;
v57 = v55 == 0;
if ( !v55 )
{
if ( !dasize(v52, v54) )
return puts("Stack is empty");
v119.m128d_f64[0] = dapop();
v115.m128d_f64[0] = v119.m128d_f64[0];
if ( COERCE_DOUBLE(*(_QWORD *)&v119.m128d_f64[0] & LC10) < 4.503599627370496e15 )
{
v120.m128d_f64[0] = (double)(int)v119.m128d_f64[0];
*(_QWORD *)&v115.m128d_f64[0] = COERCE_UNSIGNED_INT64(v120.m128d_f64[0] - COERCE_DOUBLE(*(_OWORD *)&_mm_cmpgt_sd(v120, v119) & LC11)) | ~(_QWORD)LC10 & *(_QWORD *)&v119.m128d_f64[0];
}
return dapush(v115.m128d_f64[0]);
}
v58 = "log";
v59 = 4LL;
v60 = s1;
do
{
if ( !v59 )
break;
v56 = (unsigned __int8)*v60 < (unsigned int)*v58;
v57 = *v60++ == *v58++;
--v59;
}
while ( v57 );
v61 = (!v56 && !v57) - v56;
v62 = 0;
v63 = v61 == 0;
if ( !v61 )
{
if ( dasize(v58, v60) )
{
v121 = dapop();
v122 = log(v121);
return dapush(v122);
}
return puts("Stack is empty");
}
v64 = "log10";
v65 = 6LL;
v66 = s1;
do
{
if ( !v65 )
break;
v62 = (unsigned __int8)*v66 < (unsigned int)*v64;
v63 = *v66++ == *v64++;
--v65;
}
while ( v63 );
v67 = (!v62 && !v63) - v62;
v68 = 0;
v69 = v67 == 0;
if ( !v67 )
{
if ( dasize(v64, v66) )
{
v123 = dapop();
v124 = log10(v123);
return dapush(v124);
}
return puts("Stack is empty");
}
v70 = "sinh";
v71 = 5LL;
v72 = s1;
do
{
if ( !v71 )
break;
v68 = (unsigned __int8)*v72 < (unsigned int)*v70;
v69 = *v72++ == *v70++;
--v71;
}
while ( v69 );
v73 = (!v68 && !v69) - v68;
v74 = 0;
v75 = v73 == 0;
if ( !v73 )
{
if ( dasize(v70, v72) )
{
v125 = dapop();
v126 = sinh(v125);
return dapush(v126);
}
return puts("Stack is empty");
}
v76 = "sqrt";
v77 = 5LL;
v78 = s1;
do
{
if ( !v77 )
break;
v74 = (unsigned __int8)*v78 < (unsigned int)*v76;
v75 = *v78++ == *v76++;
--v77;
}
while ( v75 );
v79 = (!v74 && !v75) - v74;
v80 = 0;
v81 = v79 == 0;
if ( !v79 )
{
if ( dasize(v76, v78) )
{
v127 = dapop();
if ( v127 < 0.0 )
v128 = sqrt(v127);
else
v128 = sqrt(v127);
return dapush(v128);
}
return puts("Stack is empty");
}
v82 = "tan";
v83 = 4LL;
v84 = s1;
do
{
if ( !v83 )
break;
v80 = (unsigned __int8)*v84 < (unsigned int)*v82;
v81 = *v84++ == *v82++;
--v83;
}
while ( v81 );
v85 = (!v80 && !v81) - v80;
v86 = 0;
v87 = v85 == 0;
if ( !v85 )
{
if ( dasize(v82, v84) )
{
v129 = dapop();
v130 = tan(v129);
return dapush(v130);
}
return puts("Stack is empty");
}
v88 = "tanh";
v89 = 5LL;
v90 = s1;
do
{
if ( !v89 )
break;
v86 = (unsigned __int8)*v90 < (unsigned int)*v88;
v87 = *v90++ == *v88++;
--v89;
}
while ( v87 );
v91 = (!v86 && !v87) - v86;
v92 = 0;
v93 = v91 == 0;
if ( !v91 )
{
if ( dasize(v88, v90) )
{
v131 = dapop();
v132 = tanh(v131);
return dapush(v132);
}
return puts("Stack is empty");
}
v94 = "exp";
v95 = 4LL;
v96 = s1;
do
{
if ( !v95 )
break;
v92 = (unsigned __int8)*v96 < (unsigned int)*v94;
v93 = *v96++ == *v94++;
--v95;
}
while ( v93 );
if ( (!v92 && !v93) == v92 )
{
if ( dasize(v94, v96) )
{
v133 = dapop();
v134 = exp(v133);
return dapush(v134);
}
return puts("Stack is empty");
}
if ( !strcmp(s1, "pi") )
return dapush(3.14159265);
if ( !strcmp(s1, "phi") )
return dapush(1.61803399);
if ( !strcmp(s1, "quit") )
exit(0);
if ( !strcmp(s1, "pow") )
{
if ( (unsigned __int64)dasize(s1, "pow") > 1 )
{
v97 = dapop();
v98 = dapop();
v99 = pow(v98, v97);
return dapush(v99);
}
return puts("Less than two items are on the stack");
}
return printf("Error: Unknown function name '%s'\n", s1);
}

canonical_decompiled_code:
int __fastcall func0(char *s1)
{
bool v1; // cf
bool v2; // zf
_BYTE *v4; // rdi
__int64 v5; // rcx
char *v6; // rsi
char v7; // al
bool v8; // cf
bool v9; // zf
const char *v10; // rdi
__int64 v11; // rcx
char *v12; // rsi
char v13; // al
bool v14; // cf
bool v15; // zf
const char *v16; // rdi
__int64 v17; // rcx
char *v18; // rsi
char v19; // al
bool v20; // cf
bool v21; // zf
const char *v22; // rdi
__int64 v23; // rcx
char *v24; // rsi
char v25; // al
bool v26; // cf
bool v27; // zf
const char *v28; // rdi
__int64 v29; // rcx
char *v30; // rsi
char v31; // al
bool v32; // cf
bool v33; // zf
const char *v34; // rdi
__int64 v35; // rcx
char *v36; // rsi
char v37; // al
bool v38; // cf
bool v39; // zf
const char *v40; // rdi
__int64 v41; // rcx
char *v42; // rsi
char v43; // al
bool v44; // cf
bool v45; // zf
const char *v46; // rdi
__int64 v47; // rcx
char *v48; // rsi
char v49; // al
bool v50; // cf
bool v51; // zf
const char *v52; // rdi
__int64 v53; // rcx
char *v54; // rsi
char v55; // al
bool v56; // cf
bool v57; // zf
const char *v58; // rdi
__int64 v59; // rcx
char *v60; // rsi
char v61; // al
bool v62; // cf
bool v63; // zf
const char *v64; // rdi
__int64 v65; // rcx
char *v66; // rsi
char v67; // al
bool v68; // cf
bool v69; // zf
const char *v70; // rdi
__int64 v71; // rcx
char *v72; // rsi
char v73; // al
bool v74; // cf
bool v75; // zf
const char *v76; // rdi
__int64 v77; // rcx
char *v78; // rsi
char v79; // al
bool v80; // cf
bool v81; // zf
const char *v82; // rdi
__int64 v83; // rcx
char *v84; // rsi
char v85; // al
bool v86; // cf
bool v87; // zf
const char *v88; // rdi
__int64 v89; // rcx
char *v90; // rsi
char v91; // al
bool v92; // cf
bool v93; // zf
const char *v94; // rdi
__int64 v95; // rcx
char *v96; // rsi
double v97; // rbx
double v98; // xmm0_8
double v99; // xmm0_8
double v101; // xmm0_8
double v102; // xmm0_8
double v103; // xmm0_8
double v104; // xmm0_8
double v105; // xmm0_8
double v106; // xmm0_8
double v107; // xmm0_8
double v108; // xmm0_8
double v109; // rbx
double v110; // xmm0_8
double v111; // xmm0_8
double v112; // xmm0_8
double v113; // xmm0_8
double v114; // xmm0_8
__m128d v115; // xmm3
__m128d v116; // xmm1
double v117; // xmm0_8
double v118; // xmm0_8
__m128d v119; // xmm0
__m128d v120; // xmm3
double v121; // xmm0_8
double v122; // xmm0_8
double v123; // xmm0_8
double v124; // xmm0_8
double v125; // xmm0_8
double v126; // xmm0_8
double v127; // xmm0_8
double v128; // xmm0_8
double v129; // xmm0_8
double v130; // xmm0_8
double v131; // xmm0_8
double v132; // xmm0_8
double v133; // xmm0_8
double v134; // xmm0_8

v4 = &unk_A8A;
v5 = 4LL;
v6 = s1;
do
{
if ( !v5 )
break;
v1 = (unsigned __int8)*v6 < *v4;
v2 = *v6++ == *v4++;
--v5;
}
while ( v2 );
v7 = (!v1 && !v2) - v1;
v8 = 0;
v9 = v7 == 0;
if ( !v7 )
{
if ( dasize(v4, v6) )
{
v101 = dapop();
v102 = sin(v101);
return dapush(v102);
}
return puts("Stack is empty");
}
v10 = "cos";
v11 = 4LL;
v12 = s1;
do
{
if ( !v11 )
break;
v8 = (unsigned __int8)*v12 < (unsigned int)*v10;
v9 = *v12++ == *v10++;
--v11;
}
while ( v9 );
v13 = (!v8 && !v9) - v8;
v14 = 0;
v15 = v13 == 0;
if ( !v13 )
{
if ( dasize(v10, v12) )
{
v103 = dapop();
v104 = cos(v103);
return dapush(v104);
}
return puts("Stack is empty");
}
v16 = "acos";
v17 = 5LL;
v18 = s1;
do
{
if ( !v17 )
break;
v14 = (unsigned __int8)*v18 < (unsigned int)*v16;
v15 = *v18++ == *v16++;
--v17;
}
while ( v15 );
v19 = (!v14 && !v15) - v14;
v20 = 0;
v21 = v19 == 0;
if ( !v19 )
{
if ( dasize(v16, v18) )
{
v105 = dapop();
v106 = acos(v105);
return dapush(v106);
}
return puts("Stack is empty");
}
v22 = "asin";
v23 = 5LL;
v24 = s1;
do
{
if ( !v23 )
break;
v20 = (unsigned __int8)*v24 < (unsigned int)*v22;
v21 = *v24++ == *v22++;
--v23;
}
while ( v21 );
v25 = (!v20 && !v21) - v20;
v26 = 0;
v27 = v25 == 0;
if ( !v25 )
{
if ( dasize(v22, v24) )
{
v107 = dapop();
v108 = asin(v107);
return dapush(v108);
}
return puts("Stack is empty");
}
v28 = "atan2";
v29 = 6LL;
v30 = s1;
do
{
if ( !v29 )
break;
v26 = (unsigned __int8)*v30 < (unsigned int)*v28;
v27 = *v30++ == *v28++;
--v29;
}
while ( v27 );
v31 = (!v26 && !v27) - v26;
v32 = 0;
v33 = v31 == 0;
if ( !v31 )
{
if ( (unsigned __int64)dasize(v28, v30) > 1 )
{
v109 = dapop();
v110 = dapop();
v111 = atan2(v110, v109);
return dapush(v111);
}
return puts("Less than two items are on the stack");
}
v34 = "atan";
v35 = 5LL;
v36 = s1;
do
{
if ( !v35 )
break;
v32 = (unsigned __int8)*v36 < (unsigned int)*v34;
v33 = *v36++ == *v34++;
--v35;
}
while ( v33 );
v37 = (!v32 && !v33) - v32;
v38 = 0;
v39 = v37 == 0;
if ( !v37 )
{
if ( dasize(v34, v36) )
{
v112 = dapop();
v113 = atan(v112);
return dapush(v113);
}
return puts("Stack is empty");
}
v40 = "ceil";
v41 = 5LL;
v42 = s1;
do
{
if ( !v41 )
break;
v38 = (unsigned __int8)*v42 < (unsigned int)*v40;
v39 = *v42++ == *v40++;
--v41;
}
while ( v39 );
v43 = (!v38 && !v39) - v38;
v44 = 0;
v45 = v43 == 0;
if ( !v43 )
{
if ( !dasize(v40, v42) )
return puts("Stack is empty");
v114 = dapop();
v115.m128d_f64[0] = v114;
if ( COERCE_DOUBLE(*(_QWORD *)&v114 & LC10) < 4.503599627370496e15 )
{
v116.m128d_f64[0] = (double)(int)v114;
*(_QWORD *)&v115.m128d_f64[0] = COERCE_UNSIGNED_INT64(COERCE_DOUBLE(*(_OWORD *)&_mm_cmpgt_sd(v115, v116) & LC11) + v116.m128d_f64[0]) | ~(_QWORD)LC10 & *(_QWORD *)&v114;
}
return dapush(v115.m128d_f64[0]);
}
v46 = "cosh";
v47 = 5LL;
v48 = s1;
do
{
if ( !v47 )
break;
v44 = (unsigned __int8)*v48 < (unsigned int)*v46;
v45 = *v48++ == *v46++;
--v47;
}
while ( v45 );
v49 = (!v44 && !v45) - v44;
v50 = 0;
v51 = v49 == 0;
if ( !v49 )
{
if ( dasize(v46, v48) )
{
v117 = dapop();
v118 = cosh(v117);
return dapush(v118);
}
return puts("Stack is empty");
}
v52 = "floor";
v53 = 6LL;
v54 = s1;
do
{
if ( !v53 )
break;
v50 = (unsigned __int8)*v54 < (unsigned int)*v52;
v51 = *v54++ == *v52++;
--v53;
}
while ( v51 );
v55 = (!v50 && !v51) - v50;
v56 = 0;
v57 = v55 == 0;
if ( !v55 )
{
if ( !dasize(v52, v54) )
return puts("Stack is empty");
v119.m128d_f64[0] = dapop();
v115.m128d_f64[0] = v119.m128d_f64[0];
if ( COERCE_DOUBLE(*(_QWORD *)&v119.m128d_f64[0] & LC10) < 4.503599627370496e15 )
{
v120.m128d_f64[0] = (double)(int)v119.m128d_f64[0];
*(_QWORD *)&v115.m128d_f64[0] = COERCE_UNSIGNED_INT64(v120.m128d_f64[0] - COERCE_DOUBLE(*(_OWORD *)&_mm_cmpgt_sd(v120, v119) & LC11)) | ~(_QWORD)LC10 & *(_QWORD *)&v119.m128d_f64[0];
}
return dapush(v115.m128d_f64[0]);
}
v58 = "log";
v59 = 4LL;
v60 = s1;
do
{
if ( !v59 )
break;
v56 = (unsigned __int8)*v60 < (unsigned int)*v58;
v57 = *v60++ == *v58++;
--v59;
}
while ( v57 );
v61 = (!v56 && !v57) - v56;
v62 = 0;
v63 = v61 == 0;
if ( !v61 )
{
if ( dasize(v58, v60) )
{
v121 = dapop();
v122 = log(v121);
return dapush(v122);
}
return puts("Stack is empty");
}
v64 = "log10";
v65 = 6LL;
v66 = s1;
do
{
if ( !v65 )
break;
v62 = (unsigned __int8)*v66 < (unsigned int)*v64;
v63 = *v66++ == *v64++;
--v65;
}
while ( v63 );
v67 = (!v62 && !v63) - v62;
v68 = 0;
v69 = v67 == 0;
if ( !v67 )
{
if ( dasize(v64, v66) )
{
v123 = dapop();
v124 = log10(v123);
return dapush(v124);
}
return puts("Stack is empty");
}
v70 = "sinh";
v71 = 5LL;
v72 = s1;
do
{
if ( !v71 )
break;
v68 = (unsigned __int8)*v72 < (unsigned int)*v70;
v69 = *v72++ == *v70++;
--v71;
}
while ( v69 );
v73 = (!v68 && !v69) - v68;
v74 = 0;
v75 = v73 == 0;
if ( !v73 )
{
if ( dasize(v70, v72) )
{
v125 = dapop();
v126 = sinh(v125);
return dapush(v126);
}
return puts("Stack is empty");
}
v76 = "sqrt";
v77 = 5LL;
v78 = s1;
do
{
if ( !v77 )
break;
v74 = (unsigned __int8)*v78 < (unsigned int)*v76;
v75 = *v78++ == *v76++;
--v77;
}
while ( v75 );
v79 = (!v74 && !v75) - v74;
v80 = 0;
v81 = v79 == 0;
if ( !v79 )
{
if ( dasize(v76, v78) )
{
v127 = dapop();
if ( v127 < 0.0 )
v128 = sqrt(v127);
else
v128 = sqrt(v127);
return dapush(v128);
}
return puts("Stack is empty");
}
v82 = "tan";
v83 = 4LL;
v84 = s1;
do
{
if ( !v83 )
break;
v80 = (unsigned __int8)*v84 < (unsigned int)*v82;
v81 = *v84++ == *v82++;
--v83;
}
while ( v81 );
v85 = (!v80 && !v81) - v80;
v86 = 0;
v87 = v85 == 0;
if ( !v85 )
{
if ( dasize(v82, v84) )
{
v129 = dapop();
v130 = tan(v129);
return dapush(v130);
}
return puts("Stack is empty");
}
v88 = "tanh";
v89 = 5LL;
v90 = s1;
do
{
if ( !v89 )
break;
v86 = (unsigned __int8)*v90 < (unsigned int)*v88;
v87 = *v90++ == *v88++;
--v89;
}
while ( v87 );
v91 = (!v86 && !v87) - v86;
v92 = 0;
v93 = v91 == 0;
if ( !v91 )
{
if ( dasize(v88, v90) )
{
v131 = dapop();
v132 = tanh(v131);
return dapush(v132);
}
return puts("Stack is empty");
}
v94 = "exp";
v95 = 4LL;
v96 = s1;
do
{
if ( !v95 )
break;
v92 = (unsigned __int8)*v96 < (unsigned int)*v94;
v93 = *v96++ == *v94++;
--v95;
}
while ( v93 );
if ( (!v92 && !v93) == v92 )
{
if ( dasize(v94, v96) )
{
v133 = dapop();
v134 = exp(v133);
return dapush(v134);
}
return puts("Stack is empty");
}
if ( !strcmp(s1, "pi") )
return dapush(3.14159265);
if ( !strcmp(s1, "phi") )
return dapush(1.61803399);
if ( !strcmp(s1, "quit") )
exit(0);
if ( !strcmp(s1, "pow") )
{
if ( (unsigned __int64)dasize(s1, "pow") > 1 )
{
v97 = dapop();
v98 = dapop();
v99 = pow(v98, v97);
return dapush(v99);
}
return puts("Less than two items are on the stack");
}
return printf("Error: Unknown function name '%s'\n", s1);
}

original_code:
static void mathfun(char s[]) {
    double operand;
    if (strcmp(s, "sin") == 0)
        if (dasize() > 0)
            dapush(sin(dapop()));
        else
            printf("Stack is empty\n");
    else if (strcmp(s, "cos") == 0)
        if (dasize() > 0)
            dapush(cos(dapop()));
        else
            printf("Stack is empty\n");
    else if (strcmp(s, "acos") == 0)
        if (dasize() > 0)
            dapush(acos(dapop()));
        else
            printf("Stack is empty\n");
    else if (strcmp(s, "asin") == 0)
        if (dasize() > 0)
            dapush(asin(dapop()));
        else
            printf("Stack is empty\n");
    else if (strcmp(s, "atan2") == 0)
        if (dasize() > 1) {
            operand = dapop();
            dapush(atan2(dapop(), operand));
        } else
            printf("Less than two items are on the stack\n");
    else if (strcmp(s, "atan") == 0)
        if (dasize() > 0)
            dapush(atan(dapop()));
        else
            printf("Stack is empty\n");
    else if (strcmp(s, "ceil") == 0)
        if (dasize() > 0)
            dapush(ceil(dapop()));
        else
            printf("Stack is empty\n");
    else if (strcmp(s, "cosh") == 0)
        if (dasize() > 0)
            dapush(cosh(dapop()));
        else
            printf("Stack is empty\n");
    else if (strcmp(s, "floor") == 0)
        if (dasize() > 0)
            dapush(floor(dapop()));
        else
            printf("Stack is empty\n");
    else if (strcmp(s, "log") == 0)
        if (dasize() > 0)
            dapush(log(dapop()));
        else
            printf("Stack is empty\n");
    else if (strcmp(s, "log10") == 0)
        if (dasize() > 0)
            dapush(log10(dapop()));
        else
            printf("Stack is empty\n");
    else if (strcmp(s, "sinh") == 0)
        if (dasize() > 0)
            dapush(sinh(dapop()));
        else
            printf("Stack is empty\n");
    else if (strcmp(s, "sqrt") == 0)
        if (dasize() > 0)
            dapush(sqrt(dapop()));
        else
            printf("Stack is empty\n");
    else if (strcmp(s, "tan") == 0)
        if (dasize() > 0)
            dapush(tan(dapop()));
        else
            printf("Stack is empty\n");
    else if (strcmp(s, "tanh") == 0)
        if (dasize() > 0)
            dapush(tanh(dapop()));
        else
            printf("Stack is empty\n");
    else if (strcmp(s, "exp") == 0)
        if (dasize() > 0)
            dapush(exp(dapop()));
        else
            printf("Stack is empty\n");
    else if (strcmp(s, "pi") == 0)
        dapush(3.14159265L);
    else if (strcmp(s, "phi") == 0)
        dapush(1.61803399L);
    else if (strcmp(s, "quit") == 0)
        exit(0);
    else if (strcmp(s, "pow") == 0) {
        if (dasize() > 1) {
            operand = dapop();
            dapush(pow(dapop(), operand));
        } else
            printf("Less than two items are on the stack\n");
    } else
        printf("Error: Unknown function name '%s'\n", s);
}

variable_types:
s
char []

variable_types: operand double


ftoc

decompiled_code:
__int64 __fastcall ftoc(int a1)
{
return (unsigned int)((5 * a1 - 160) / 9);
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
return (unsigned int)((5 * a1 - 160) / 9);
}

original_code:
static int ftoc(int ftemp) {
    return 5 * (ftemp - 32) / 9;
}

variable_types: ftemp int

return_type: int


main

canonical_name: main

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

for ( i = 0; i != 320; i += 20 )
{
v4 = ftoc(i);
printf("%d\t%d\n", i, v4);
}
return 0;
}

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

for ( i = 0; i != 320; i += 20 )
{
v4 = func0(i);
printf("%d\t%d\n", i, v4);
}
return 0;
}

original_code:
int main(void) {
    int fahr;
    int lower = 0;
    int upper = 300;
    int step = 20;
    for (fahr = lower; fahr <= upper; fahr += step)
        printf("%d\t%d\n", fahr, ftoc(fahr));
    return 0;
}

canonical_original_code:
int main() {
    int fahr;
    int lower = 0;
    int upper = 300;
    int step = 20;
    for (fahr = lower; fahr <= upper; fahr += step)
        printf("%d\t%d\n", fahr, ftoc(fahr));
    return 0;
}

variable_types: fahr int

variable_types: lower int

variable_types: upper int

variable_types: step int


finfo

decompiled_code:
int __fastcall finfo(char *s)
{
char *v1; // rbx
time_t timer; // [rsp+8h] [rbp-B0h] BYREF
struct stat v4; // [rsp+10h] [rbp-A8h] BYREF

if ( stat(s, &v4) == -1 )
return fprintf(stderr, "finfo: cannot access %s\n", s);
if ( (v4.st_mode & 0xF000) == 0x4000 )
dirwalk(s, (void (__fastcall *)(char *))finfo);
timer = v4.st_mtim.tv_sec;
v1 = ctime(&timer);
v1[strlen(v1) - 1] = 0;
return printf("%8lld %s (modified %s)\n", v4.st_size, s, v1);
}

canonical_decompiled_code:
int __fastcall func1(char *s)
{
char *v1; // rbx
time_t timer; // [rsp+8h] [rbp-B0h] BYREF
struct stat v4; // [rsp+10h] [rbp-A8h] BYREF

if ( stat(s, &v4) == -1 )
return fprintf(stderr, "finfo: cannot access %s\n", s);
if ( (v4.st_mode & 0xF000) == 0x4000 )
func0(s, (void (__fastcall *)(char *))finfo);
timer = v4.st_mtim.tv_sec;
v1 = ctime(&timer);
v1[strlen(v1) - 1] = 0;
return printf("%8lld %s (modified %s)\n", v4.st_size, s, v1);
}

original_code:
static void finfo(char *name) {
    struct stat stbuf;
    time_t filetime;
    char *timestr;
    if (stat(name, &stbuf) == -1) {
        fprintf(stderr, "finfo: cannot access %s\n", name);
        return;
    }
    if (((((stbuf.st_mode)) & 0170000) == (0040000)))
        dirwalk(name, finfo);
    filetime = stbuf.st_mtime;
    timestr = ctime(&filetime);
    timestr[strlen(timestr)-1] = '\0';
    printf("%8lld %s (modified %s)\n", (long long)stbuf.st_size, name, timestr);
}

canonical_original_code:
static void finfo(char *name) {
    struct stat stbuf;
    long filetime;
    char *timestr;
    if (stat(name, &stbuf) == -1) {
        fprintf(stderr, "finfo: cannot access %s\n", name);
        return;
    }
    if (((((stbuf.st_mode)) & 0170000) == (0040000)))
        dirwalk(name, finfo);
    filetime = stbuf.st_mtime;
    timestr = ctime(&filetime);
    timestr[strlen(timestr)-1] = '\0';
    printf("%8lld %s (modified %s)\n", (long long)stbuf.st_size, name, timestr);
}

variable_types:
name
char *

variable_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; long st_atime; unsigned long st_atimensec; long st_mtime; unsigned long st_mtimensec; long st_ctime; unsigned long st_ctimensec; long __glibc_reserved[3]; }

variable_types: filetime long

variable_types:
timestr
char *


main

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

if ( argc == 1 )
{
finfo(".");
}
else
{
v3 = (char **)argv;
if ( argc > 1 )
{
do
finfo(*++v3);
while ( v3 != (char **)&argv[argc - 1] );
}
}
exit(0);
}

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

if ( argc == 1 )
{
func1(".");
}
else
{
v3 = (char **)argv;
if ( argc > 1 )
{
do
func1(*++v3);
while ( v3 != (char **)&argv[argc - 1] );
}
}
exit(0);
}

original_code:
int main(int argc, char **argv) {
    if (argc == 1)
        finfo(".");
    else
        while (--argc > 0)
            finfo(*++argv);
    exit(0);
}

variable_types: argc int

variable_types:
argv
char **


lower

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

result = a1 + 32;
if ( (unsigned __int8)(a1 - 65) >= 0x1Au )
result = a1;
return result;
}

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

result = a1 + 32;
if ( (unsigned __int8)(a1 - 65) >= 0x1Au )
result = a1;
return result;
}

original_code:
static char lower(char c) {
    return (c >= 'A' && c <= 'Z') ? c + 'a' - 'A' : c;
}

variable_types: c char

return_type: char


main

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

v3 = lower(0x54u);
putchar(v3);
v4 = lower(0x74u);
putchar(v4);
putchar(10);
return 0;
}

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

v3 = func0(0x54u);
putchar(v3);
v4 = func0(0x74u);
putchar(v4);
putchar(10);
return 0;
}

original_code:
int main(void) {
    (void)putchar(lower('T'));
    (void)putchar(lower('t'));
    (void)putchar('\n');
    return 0;
}

canonical_original_code:
int main() {
    (void)putchar(lower('T'));
    (void)putchar(lower('t'));
    (void)putchar('\n');
    return 0;
}


isnottab

decompiled_code:
_BOOL8 __fastcall isnottab(int a1, __int64 a2)
{
bool v2; // al

v2 = 0;
if ( a1 <= 250 )
v2 = *(_BYTE *)(a2 + a1) == 0;
return v2;
}

original_code:
static _Bool isnottab(int pos, char *tabstop) {
    return (pos < (250 + 1)) && (tabstop[pos] == 0);
}

variable_types: pos int

variable_types:
tabstop
char *


detab

decompiled_code:
int __fastcall detab(__int64 a1)
{
int v2; // ebx
int v3; // edi
int result; // eax
char v5; // bp

v2 = 1;
while ( 1 )
{
result = getchar();
v5 = result;
if ( (_BYTE)result == 0xFF )
break;
if ( (_BYTE)result == 9 )
{
do
{
putchar(32);
v3 = v2++;
}
while ( isnottab(v3, a1) );
}
else
{
putchar((char)result);
++v2;
if ( v5 == 10 )
v2 = 1;
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func2(__int64 a1)
{
int v2; // ebx
int v3; // edi
int result; // eax
char v5; // bp

v2 = 1;
while ( 1 )
{
result = getchar();
v5 = result;
if ( (_BYTE)result == 0xFF )
break;
if ( (_BYTE)result == 9 )
{
do
{
putchar(32);
v3 = v2++;
}
while ( func0(v3, a1) );
}
else
{
putchar((char)result);
++v2;
if ( v5 == 10 )
v2 = 1;
}
}
return result;
}

original_code:
static void detab(char *tabstop) {
    char c;
    int pos = 1;
    while ((c = getchar()) != (-1))
        if (c == '\t')
            do
                (void)putchar(' ');
            while (isnottab(pos++, tabstop));
        else {
            (void)putchar(c);
            if (c == '\n')
                pos = 1;
            else
                pos++;
        }
}


cons

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

switch ( *(_BYTE *)(b + a1) )
{
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
result = 0LL;
break;
case 'y':
result = 1LL;
if ( qword_C50 != a1 )
result = (unsigned int)cons(a1 - 1) ^ 1;
break;
default:
result = 1LL;
break;
}
return result;
}

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

switch ( *(_BYTE *)(b + a1) )
{
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
result = 0LL;
break;
case 'y':
result = 1LL;
if ( qword_C50 != a1 )
result = (unsigned int)func0(a1 - 1) ^ 1;
break;
default:
result = 1LL;
break;
}
return result;
}

original_code:
static _Bool cons(size_t i) {
    switch (b[i]) {
        case 'a':
        case 'e':
        case 'i':
        case 'o':
        case 'u':
            return 0;
        case 'y':
            return (i == k0) ? 1 : !cons(i - 1);
        default:
            return 1;
    }
}

canonical_original_code:
static _Bool cons(unsigned long i) {
    switch (b[i]) {
        case 'a':
        case 'e':
        case 'i':
        case 'o':
        case 'u':
            return 0;
        case 'y':
            return (i == k0) ? 1 : !cons(i - 1);
        default:
            return 1;
    }
}

variable_types:
i
unsigned long


m

decompiled_code:
__int64 m()
{
__int64 v0; // rbx
unsigned __int64 v1; // rbp
__int64 v2; // r12
unsigned __int64 v4; // rbx
unsigned __int64 v5; // rbx

v0 = qword_C50;
v1 = j;
if ( qword_C50 > (unsigned __int64)j )
return 0LL;
while ( (unsigned __int8)cons(v0) )
{
if ( ++v0 > v1 )
return 0LL;
}
v4 = v0 + 1;
if ( v4 > v1 )
return 0LL;
v2 = 0LL;
do
{
if ( (unsigned __int8)cons(v4) )
{
v5 = v4 + 1;
++v2;
if ( v5 > v1 )
return v2;
while ( (unsigned __int8)cons(v5) )
{
if ( ++v5 > v1 )
return v2;
}
v4 = v5 + 1;
}
else
{
++v4;
}
}
while ( v4 <= v1 );
return v2;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 v0; // rbx
unsigned __int64 v1; // rbp
__int64 v2; // r12
unsigned __int64 v4; // rbx
unsigned __int64 v5; // rbx

v0 = qword_C50;
v1 = j;
if ( qword_C50 > (unsigned __int64)j )
return 0LL;
while ( (unsigned __int8)func0(v0) )
{
if ( ++v0 > v1 )
return 0LL;
}
v4 = v0 + 1;
if ( v4 > v1 )
return 0LL;
v2 = 0LL;
do
{
if ( (unsigned __int8)func0(v4) )
{
v5 = v4 + 1;
++v2;
if ( v5 > v1 )
return v2;
while ( (unsigned __int8)func0(v5) )
{
if ( ++v5 > v1 )
return v2;
}
v4 = v5 + 1;
}
else
{
++v4;
}
}
while ( v4 <= v1 );
return v2;
}

original_code:
static size_t m() {
    size_t n = 0;
    size_t i = k0;
    while (1) {
        if (i > j)
            return n;
        if (! cons(i))
            break;
        i++;
    }
    i++;
    while (1) {
        while (1) {
            if (i > j)
                return n;
            if (cons(i))
                break;
            i++;
        }
        i++;
        n++;
        while (1) {
            if (i > j)
                return n;
            if (! cons(i))
                break;
            i++;
        }
        i++;
    }
}

canonical_original_code:
static unsigned long m() {
    unsigned long n = 0;
    unsigned long i = k0;
    while (1) {
        if (i > j)
            return n;
        if (! cons(i))
            break;
        i++;
    }
    i++;
    while (1) {
        while (1) {
            if (i > j)
                return n;
            if (cons(i))
                break;
            i++;
        }
        i++;
        n++;
        while (1) {
            if (i > j)
                return n;
            if (! cons(i))
                break;
            i++;
        }
        i++;
    }
}

variable_types:
n
unsigned long

return_type: unsigned long


vowelinstem

decompiled_code:
__int64 vowelinstem()
{
__int64 v0; // rbx
unsigned __int64 v1; // rbp

v0 = qword_C50;
v1 = j;
if ( qword_C50 > (unsigned __int64)j )
return 0LL;
while ( (unsigned __int8)cons(v0) )
{
if ( ++v0 > v1 )
return 0LL;
}
return 1LL;
}

canonical_decompiled_code:
__int64 func2()
{
__int64 v0; // rbx
unsigned __int64 v1; // rbp

v0 = qword_C50;
v1 = j;
if ( qword_C50 > (unsigned __int64)j )
return 0LL;
while ( (unsigned __int8)func0(v0) )
{
if ( ++v0 > v1 )
return 0LL;
}
return 1LL;
}

original_code:
static _Bool vowelinstem() {
    size_t i;
    for (i = k0; i <= j; i++)
        if (! cons(i))
            return 1;
    return 0;
}

canonical_original_code:
static _Bool vowelinstem() {
    unsigned long i;
    for (i = k0; i <= j; i++)
        if (! cons(i))
            return 1;
    return 0;
}


doublec

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

if ( qword_C50 + 1 <= a1 && *(_BYTE *)(b + a1) == *(_BYTE *)(b + a1 - 1) )
result = cons(a1);
else
result = 0LL;
return result;
}

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

if ( qword_C50 + 1 <= a1 && *(_BYTE *)(b + a1) == *(_BYTE *)(b + a1 - 1) )
result = func0(a1);
else
result = 0LL;
return result;
}

original_code:
static _Bool doublec(size_t j) {
    if (j < k0+1)
        return 0;
    if (b[j] != b[j-1])
        return 0;
    return cons(j);
}

canonical_original_code:
static _Bool doublec(unsigned long j) {
    if (j < k0+1)
        return 0;
    if (b[j] != b[j-1])
        return 0;
    return cons(j);
}

variable_types:
j
unsigned long


cvc

decompiled_code:
char __fastcall cvc(unsigned __int64 a1)
{
char result; // al
char v2; // dl

result = 0;
if ( qword_C50 + 2 <= a1 )
{
result = cons(a1);
if ( result )
{
v2 = cons(a1 - 1);
result = 0;
if ( !v2 )
{
result = cons(a1 - 2);
if ( result )
result = (unsigned int)(*(char *)(b + a1) - 119) > 2;
}
}
}
return result;
}

canonical_decompiled_code:
char __fastcall func4(unsigned __int64 a1)
{
char result; // al
char v2; // dl

result = 0;
if ( qword_C50 + 2 <= a1 )
{
result = func0(a1);
if ( result )
{
v2 = func0(a1 - 1);
result = 0;
if ( !v2 )
{
result = func0(a1 - 2);
if ( result )
result = (unsigned int)(*(char *)(b + a1) - 119) > 2;
}
}
}
return result;
}

original_code:
static _Bool cvc(size_t i) {
    int ch;
    if (i < k0 + 2 || !cons(i) || cons(i - 1) || !cons(i - 2))
        return 0;
    ch = b[i];
    if (ch == 'w' || ch == 'x' || ch == 'y')
        return 0;
    return 1;
}

canonical_original_code:
static _Bool cvc(unsigned long i) {
    int ch;
    if (i < k0 + 2 || !cons(i) || cons(i - 1) || !cons(i - 2))
        return 0;
    ch = b[i];
    if (ch == 'w' || ch == 'x' || ch == 'y')
        return 0;
    return 1;
}

variable_types: ch int


ends

decompiled_code:
__int64 __fastcall ends(char *a1)
{
size_t v1; // rbx
unsigned __int64 v2; // rbp
__int64 result; // rax
__int64 v4; // r12
int v5; // edx

v1 = *a1;
v2 = k;
result = 0LL;
if ( a1[v1] == *(_BYTE *)(b + k) && k + 1 - qword_C50 >= v1 )
{
v4 = k - v1;
v5 = memcmp((const void *)(b + k - v1 + 1), a1 + 1, v1);
result = 0LL;
if ( !v5 )
{
if ( v2 < v1 )
v4 = 0LL;
j = v4;
result = 1LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(char *a1)
{
size_t v1; // rbx
unsigned __int64 v2; // rbp
__int64 result; // rax
__int64 v4; // r12
int v5; // edx

v1 = *a1;
v2 = k;
result = 0LL;
if ( a1[v1] == *(_BYTE *)(b + k) && k + 1 - qword_C50 >= v1 )
{
v4 = k - v1;
v5 = memcmp((const void *)(b + k - v1 + 1), a1 + 1, v1);
result = 0LL;
if ( !v5 )
{
if ( v2 < v1 )
v4 = 0LL;
j = v4;
result = 1LL;
}
}
return result;
}

original_code:
static _Bool ends(char *s) {
    size_t length = (size_t)s[0];
    if (s[length] != b[k])
        return 0;
    if (length > k - k0 + 1)
        return 0;
    if (memcmp(b + k - length + 1, s + 1, length) != 0)
        return 0;
    j = (length > k) ? 0 : (k - length);
    return 1;
}

canonical_original_code:
static _Bool ends(char *s) {
    unsigned long length = (size_t)s[0];
    if (s[length] != b[k])
        return 0;
    if (length > k - k0 + 1)
        return 0;
    if (memcmp(b + k - length + 1, s + 1, length) != 0)
        return 0;
    j = (length > k) ? 0 : (k - length);
    return 1;
}

variable_types:
s
char *

variable_types:
length
unsigned long


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

result = ends(byte_EA2);
if ( (_BYTE)result )
{
result = vowelinstem();
if ( (_BYTE)result )
{
result = k;
*(_BYTE *)(b + k) = 105;
}
}
return result;
}

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

result = func6(byte_EA2);
if ( (_BYTE)result )
{
result = func2();
if ( (_BYTE)result )
{
result = k;
*(_BYTE *)(b + k) = 105;
}
}
return result;
}

original_code:
static void step1c() {
    if (ends("\01" "y") && vowelinstem())
        b[k] = 'i';
}


decompiled_code:
unsigned __int64 step4()
{
__int64 v0; // rbx
unsigned __int64 result; // rax

v0 = b;
result = (unsigned __int8)(*(_BYTE *)(b + k - 1) - 97);
switch ( *(_BYTE *)(b + k - 1) )
{
case 'a':
result = ends(byte_EA5);
if ( (_BYTE)result )
goto LABEL_5;
break;
case 'c':
if ( (unsigned __int8)ends(byte_EA9) )
goto LABEL_5;
result = ends(byte_EAF);
if ( (_BYTE)result )
goto LABEL_5;
break;
case 'e':
result = ends(byte_EB5);
if ( (_BYTE)result )
goto LABEL_5;
break;
case 'i':
result = ends(byte_EB9);
if ( (_BYTE)result )
goto LABEL_5;
break;
case 'l':
if ( (unsigned __int8)ends(byte_EBD) )
goto LABEL_5;
result = ends(byte_EC3);
if ( (_BYTE)result )
goto LABEL_5;
break;
case 'n':
if ( (unsigned __int8)ends(byte_EC9) )
goto LABEL_5;
if ( (unsigned __int8)ends(byte_ECE) )
goto LABEL_5;
if ( (unsigned __int8)ends(byte_ED5) )
goto LABEL_5;
result = ends(byte_EDB);
if ( (_BYTE)result )
goto LABEL_5;
break;
case 'o':
if ( (unsigned __int8)ends(byte_EE0)
&& j >= (unsigned __int64)qword_C50
&& (unsigned __int8)(*(_BYTE *)(v0 + j) - 115) <= 1u )
{
goto LABEL_5;
}
result = ends(byte_EE5);
if ( (_BYTE)result )
goto LABEL_5;
break;
case 's':
result = ends(byte_EE9);
if ( (_BYTE)result )
goto LABEL_5;
break;
case 't':
if ( (unsigned __int8)ends(byte_EEE) )
goto LABEL_5;
result = ends(byte_EF3);
if ( (_BYTE)result )
goto LABEL_5;
break;
case 'u':
result = ends(byte_EF8);
if ( (_BYTE)result )
goto LABEL_5;
break;
case 'v':
result = ends(byte_EFD);
if ( (_BYTE)result )
goto LABEL_5;
break;
case 'z':
result = ends(byte_F02);
if ( (_BYTE)result )
{
LABEL_5:
result = m();
if ( result > 1 )
{
result = j;
k = j;
}
}
break;
default:
return result;
}
return result;
}

canonical_decompiled_code:
unsigned __int64 func8()
{
__int64 v0; // rbx
unsigned __int64 result; // rax

v0 = b;
result = (unsigned __int8)(*(_BYTE *)(b + k - 1) - 97);
switch ( *(_BYTE *)(b + k - 1) )
{
case 'a':
result = func6(byte_EA5);
if ( (_BYTE)result )
goto LABEL_5;
break;
case 'c':
if ( (unsigned __int8)func6(byte_EA9) )
goto LABEL_5;
result = func6(byte_EAF);
if ( (_BYTE)result )
goto LABEL_5;
break;
case 'e':
result = func6(byte_EB5);
if ( (_BYTE)result )
goto LABEL_5;
break;
case 'i':
result = func6(byte_EB9);
if ( (_BYTE)result )
goto LABEL_5;
break;
case 'l':
if ( (unsigned __int8)func6(byte_EBD) )
goto LABEL_5;
result = func6(byte_EC3);
if ( (_BYTE)result )
goto LABEL_5;
break;
case 'n':
if ( (unsigned __int8)func6(byte_EC9) )
goto LABEL_5;
if ( (unsigned __int8)func6(byte_ECE) )
goto LABEL_5;
if ( (unsigned __int8)func6(byte_ED5) )
goto LABEL_5;
result = func6(byte_EDB);
if ( (_BYTE)result )
goto LABEL_5;
break;
case 'o':
if ( (unsigned __int8)func6(byte_EE0)
&& j >= (unsigned __int64)qword_C50
&& (unsigned __int8)(*(_BYTE *)(v0 + j) - 115) <= 1u )
{
goto LABEL_5;
}
result = func6(byte_EE5);
if ( (_BYTE)result )
goto LABEL_5;
break;
case 's':
result = func6(byte_EE9);
if ( (_BYTE)result )
goto LABEL_5;
break;
case 't':
if ( (unsigned __int8)func6(byte_EEE) )
goto LABEL_5;
result = func6(byte_EF3);
if ( (_BYTE)result )
goto LABEL_5;
break;
case 'u':
result = func6(byte_EF8);
if ( (_BYTE)result )
goto LABEL_5;
break;
case 'v':
result = func6(byte_EFD);
if ( (_BYTE)result )
goto LABEL_5;
break;
case 'z':
result = func6(byte_F02);
if ( (_BYTE)result )
{
LABEL_5:
result = func1();
if ( result > 1 )
{
result = j;
k = j;
}
}
break;
default:
return result;
}
return result;
}

original_code:
static void step4() {
    switch (b[k-1]) {
        case 'a':
            if (ends("\02" "al"))
                break;
            return;
        case 'c':
            if (ends("\04" "ance"))
                break;
            if (ends("\04" "ence"))
                break;
            return;
        case 'e':
            if (ends("\02" "er"))
                break;
            return;
        case 'i':
            if (ends("\02" "ic"))
                break;
            return;
        case 'l':
            if (ends("\04" "able"))
                break;
            if (ends("\04" "ible"))
                break;
            return;
        case 'n':
            if (ends("\03" "ant"))
                break;
            if (ends("\05" "ement"))
                break;
            if (ends("\04" "ment"))
                break;
            if (ends("\03" "ent"))
                break;
            return;
        case 'o':
            if (ends("\03" "ion") && j >= k0 && (b[j] == 's' || b[j] == 't'))
                break;
            if (ends("\02" "ou"))
                break;
            return;
        case 's':
            if (ends("\03" "ism"))
                break;
            return;
        case 't':
            if (ends("\03" "ate"))
                break;
            if (ends("\03" "iti"))
                break;
            return;
        case 'u':
            if (ends("\03" "ous"))
                break;
            return;
        case 'v':
            if (ends("\03" "ive"))
                break;
            return;
        case 'z':
            if (ends("\03" "ize"))
                break;
            return;
        default:
            return;
    }
    if (m() > 1)
        k = j;
}


setto

decompiled_code:
void *__fastcall setto(char *a1)
{
size_t v1; // rbp
__int64 v2; // rbx
void *result; // rax

v1 = *a1;
v2 = j;
result = memmove((void *)(b + j + 1), a1 + 1, v1);
k = v1 + v2;
return result;
}

canonical_decompiled_code:
void *__fastcall func9(char *a1)
{
size_t v1; // rbp
__int64 v2; // rbx
void *result; // rax

v1 = *a1;
v2 = j;
result = memmove((void *)(b + j + 1), a1 + 1, v1);
k = v1 + v2;
return result;
}

original_code:
static void setto(char *s) {
    size_t length = (size_t)s[0];
    memmove(b + j + 1, s + 1, length);
    k = j + length;
}

canonical_original_code:
static void setto(char *s) {
    unsigned long length = (size_t)s[0];
    memmove(b + j + 1, s + 1, length);
    k = j + length;
}


r

decompiled_code:
void *__fastcall r(char *a1)
{
void *result; // rax

result = (void *)m();
if ( result )
result = setto(a1);
return result;
}

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

result = (void *)func1();
if ( result )
result = func9(a1);
return result;
}

original_code:
static void r(char *s) {
    if (m() > 0)
        setto(s);
}


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

result = (unsigned __int8)(*(_BYTE *)(b + k - 1) - 97);
switch ( *(_BYTE *)(b + k - 1) )
{
case 'a':
if ( (unsigned __int8)ends("\aational") )
goto LABEL_26;
result = ends(byte_F40);
if ( (_BYTE)result )
result = (__int64)r(byte_F48);
break;
case 'c':
if ( (unsigned __int8)ends(byte_F4E) )
{
result = (__int64)r(byte_EAF);
}
else
{
result = ends(byte_F54);
if ( (_BYTE)result )
result = (__int64)r(byte_EA9);
}
break;
case 'e':
result = ends(byte_F5A);
if ( (_BYTE)result )
goto LABEL_11;
break;
case 'g':
result = ends(byte_FD1);
if ( (_BYTE)result )
result = (__int64)r(byte_FD7);
break;
case 'l':
if ( (unsigned __int8)ends(byte_F60) )
goto LABEL_14;
if ( (unsigned __int8)ends(byte_F65) )
goto LABEL_35;
if ( (unsigned __int8)ends(byte_F6B) )
{
result = (__int64)r(byte_EDB);
}
else if ( (unsigned __int8)ends(byte_F72) )
{
result = (__int64)r(byte_F34);
}
else
{
result = ends(byte_F77);
if ( (_BYTE)result )
goto LABEL_22;
}
break;
case 'o':
if ( (unsigned __int8)ends("\aization") )
{
LABEL_11:
result = (__int64)r(byte_F02);
}
else if ( (unsigned __int8)ends(byte_F87) || (result = ends(byte_F8E), (_BYTE)result) )
{
LABEL_26:
result = (__int64)r(byte_EEE);
}
break;
case 's':
if ( (unsigned __int8)ends(byte_F94) )
goto LABEL_35;
if ( (unsigned __int8)ends("\aiveness") )
goto LABEL_29;
if ( (unsigned __int8)ends("\afulness") )
{
result = (__int64)r(byte_FAD);
}
else
{
result = ends("\aousness");
if ( (_BYTE)result )
LABEL_22:
result = (__int64)r(byte_EF8);
}
break;
case 't':
if ( (unsigned __int8)ends(byte_FBB) )
{
LABEL_35:
result = (__int64)r(byte_EA5);
}
else if ( (unsigned __int8)ends(byte_FC2) )
{
LABEL_29:
result = (__int64)r(byte_EFD);
}
else
{
result = ends(byte_FC9);
if ( (_BYTE)result )
LABEL_14:
result = (__int64)r(byte_F2B);
}
break;
default:
return result;
}
return result;
}

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

result = (unsigned __int8)(*(_BYTE *)(b + k - 1) - 97);
switch ( *(_BYTE *)(b + k - 1) )
{
case 'a':
if ( (unsigned __int8)func6("\aational") )
goto LABEL_26;
result = func6(byte_F40);
if ( (_BYTE)result )
result = (__int64)func11(byte_F48);
break;
case 'c':
if ( (unsigned __int8)func6(byte_F4E) )
{
result = (__int64)func11(byte_EAF);
}
else
{
result = func6(byte_F54);
if ( (_BYTE)result )
result = (__int64)func11(byte_EA9);
}
break;
case 'e':
result = func6(byte_F5A);
if ( (_BYTE)result )
goto LABEL_11;
break;
case 'g':
result = func6(byte_FD1);
if ( (_BYTE)result )
result = (__int64)func11(byte_FD7);
break;
case 'l':
if ( (unsigned __int8)func6(byte_F60) )
goto LABEL_14;
if ( (unsigned __int8)func6(byte_F65) )
goto LABEL_35;
if ( (unsigned __int8)func6(byte_F6B) )
{
result = (__int64)func11(byte_EDB);
}
else if ( (unsigned __int8)func6(byte_F72) )
{
result = (__int64)func11(byte_F34);
}
else
{
result = func6(byte_F77);
if ( (_BYTE)result )
goto LABEL_22;
}
break;
case 'o':
if ( (unsigned __int8)func6("\aization") )
{
LABEL_11:
result = (__int64)func11(byte_F02);
}
else if ( (unsigned __int8)func6(byte_F87) || (result = func6(byte_F8E), (_BYTE)result) )
{
LABEL_26:
result = (__int64)func11(byte_EEE);
}
break;
case 's':
if ( (unsigned __int8)func6(byte_F94) )
goto LABEL_35;
if ( (unsigned __int8)func6("\aiveness") )
goto LABEL_29;
if ( (unsigned __int8)func6("\afulness") )
{
result = (__int64)func11(byte_FAD);
}
else
{
result = func6("\aousness");
if ( (_BYTE)result )
LABEL_22:
result = (__int64)func11(byte_EF8);
}
break;
case 't':
if ( (unsigned __int8)func6(byte_FBB) )
{
LABEL_35:
result = (__int64)func11(byte_EA5);
}
else if ( (unsigned __int8)func6(byte_FC2) )
{
LABEL_29:
result = (__int64)func11(byte_EFD);
}
else
{
result = func6(byte_FC9);
if ( (_BYTE)result )
LABEL_14:
result = (__int64)func11(byte_F2B);
}
break;
default:
return result;
}
return result;
}


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

result = *(unsigned __int8 *)(b + k);
if ( (_BYTE)result == 108 )
{
if ( (unsigned __int8)ends(byte_FF8) )
return (__int64)r(byte_EB9);
result = ends(byte_FAD);
if ( !(_BYTE)result )
return result;
return (__int64)r(byte_EA0);
}
if ( (char)result > 108 )
{
if ( (_BYTE)result != 115 )
return result;
result = ends(byte_FFE);
if ( !(_BYTE)result )
return result;
return (__int64)r(byte_EA0);
}
if ( (_BYTE)result != 101 )
{
if ( (_BYTE)result != 105 )
return result;
result = ends(byte_FF1);
if ( !(_BYTE)result )
return result;
return (__int64)r(byte_EB9);
}
if ( (unsigned __int8)ends(byte_FDC) )
return (__int64)r(byte_EB9);
if ( (unsigned __int8)ends(byte_FE3) )
return (__int64)r(byte_EA0);
result = ends(byte_FEA);
if ( (_BYTE)result )
result = (__int64)r(byte_EA5);
return result;
}

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

result = *(unsigned __int8 *)(b + k);
if ( (_BYTE)result == 108 )
{
if ( (unsigned __int8)func6(byte_FF8) )
return (__int64)func11(byte_EB9);
result = func6(byte_FAD);
if ( !(_BYTE)result )
return result;
return (__int64)func11(byte_EA0);
}
if ( (char)result > 108 )
{
if ( (_BYTE)result != 115 )
return result;
result = func6(byte_FFE);
if ( !(_BYTE)result )
return result;
return (__int64)func11(byte_EA0);
}
if ( (_BYTE)result != 101 )
{
if ( (_BYTE)result != 105 )
return result;
result = func6(byte_FF1);
if ( !(_BYTE)result )
return result;
return (__int64)func11(byte_EB9);
}
if ( (unsigned __int8)func6(byte_FDC) )
return (__int64)func11(byte_EB9);
if ( (unsigned __int8)func6(byte_FE3) )
return (__int64)func11(byte_EA0);
result = func6(byte_FEA);
if ( (_BYTE)result )
result = (__int64)func11(byte_EA5);
return result;
}


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char **v3; // rbx
const char **v4; // rbp
FILE *v5; // rdi

if ( argc <= 1 )
return 0;
v3 = argv + 1;
v4 = &argv[(unsigned int)(argc - 2) + 2];
do
{
v5 = fopen(*v3, "r");
if ( !v5 )
{
fprintf(stderr, "File %s not found\n", *v3);
exit(1);
}
stemfile(v5);
++v3;
}
while ( v3 != v4 );
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char **v3; // rbx
const char **v4; // rbp
FILE *v5; // rdi

if ( argc <= 1 )
return 0;
v3 = argv + 1;
v4 = &argv[(unsigned int)(argc - 2) + 2];
do
{
v5 = fopen(*v3, "r");
if ( !v5 )
{
fprintf(stderr, "File %s not found\n", *v3);
exit(1);
}
func15(v5);
++v3;
}
while ( v3 != v4 );
return 0;
}

original_code:
int main(void) {
    struct tnode *root = ((void *)0);
    char word[50] = "";
    char unstemmed[50] = "";
    int line = 1;
    while (getword(word, 50) != (-1))
        if (((*__ctype_b_loc ())[(int) ((word[0]))] & (unsigned short int) _ISalpha)) {
            lowerstr(word);
            if (isnotstopword(word)) {
                strncpy(unstemmed, word, 50);
                squeezechar(word, '\'');
                word[stem(word, 0, strlen(word) - 1) + 1] = '\0';
                root = treeadd(root, word, unstemmed, line);
            }
        } else if (word[0] == '\n')
            line++;
    treeprint(root);
    return 0;
}

canonical_original_code:
int main() {
    struct tnode *root = ((void *)0);
    char word[50] = "";
    char unstemmed[50] = "";
    int line = 1;
    while (getword(word, 50) != (-1))
        if (((*__ctype_b_loc ())[(int) ((word[0]))] & (unsigned short) _ISalpha)) {
            lowerstr(word);
            if (isnotstopword(word)) {
                strncpy(unstemmed, word, 50);
                squeezechar(word, '\'');
                word[stem(word, 0, strlen(word) - 1) + 1] = '\0';
                root = treeadd(root, word, unstemmed, line);
            }
        } else if (word[0] == '\n')
            line++;
    treeprint(root);
    return 0;
}

variable_types: struct tnode { char *word; int wordcount; struct linkwords { char *word; struct linkwords *next; } *words; struct linklist { int linenum; struct linklist *next; } *lines; struct tnode *left; struct tnode *right; } *

variable_types:
word
char [50]

variable_types:
unstemmed
char [50]

variable_types: line int

user_defined_types: struct tnode { char *word; int wordcount; struct linkwords *words; struct linklist *lines; struct tnode *left; struct tnode *right; }


printbits

decompiled_code:
int __fastcall printbits(int a1)
{
int v1; // ebx
int result; // eax

printf("0b");
v1 = 32;
do
{
if ( (a1 & (1 << --v1)) != 0 )
result = putchar(49);
else
result = putchar(48);
}
while ( v1 );
return result;
}

canonical_decompiled_code:
int __fastcall func1(int a1)
{
int v1; // ebx
int result; // eax

printf("0b");
v1 = 32;
do
{
if ( (a1 & (1 << --v1)) != 0 )
result = putchar(49);
else
result = putchar(48);
}
while ( v1 );
return result;
}

original_code:
static void printbits(unsigned x) {
    unsigned i;
    printf("0b");
    for(i = (unsigned)(8 * sizeof(int)); i > 0; i--)
        (_Bool)(x & (1 << (i - 1))) ? putchar('1') : putchar('0');
}

canonical_original_code:
static void printbits(unsigned int x) {
    unsigned int i;
    printf("0b");
    for(i = (unsigned int)(8 * sizeof(int)); i > 0; i--)
        (_Bool)(x & (1 << (i - 1))) ? putchar('1') : putchar('0');
}

variable_types:
x
unsigned int

variable_types:
i
unsigned int


repo: ptesarik/xcrash-scripts

decompiled_code:
_BOOL8 __fastcall list_empty(_QWORD *a1)
{
return *a1 == (_QWORD)a1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func6(_QWORD *a1)
{
return *a1 == (_QWORD)a1;
}

original_code:
static inline int list_empty(const struct list_head_xcrash *head)
{
 return head->next == head;
}

canonical_original_code:
static inline int list_empty(struct list_head_xcrash *head)
{
 return head->next == head;
}

variable_types: struct list_head_xcrash { struct list_head_xcrash *next; } *


original_code:
static void
init_file(struct parsed_file *pf, const char *name)
{
 pf->name = name;
 INIT_LIST_HEAD(&pf->parsed);
 INIT_LIST_HEAD(&pf->raw);
 pf->loc.first.pf = pf;
 pf->loc.last.pf = pf;
 pf->clean = 1;
}

canonical_original_code:
static void init_file(struct parsed_file *pf, char *name)
{
 pf->name = name;
 INIT_LIST_HEAD(&pf->parsed);
 INIT_LIST_HEAD(&pf->raw);
 pf->loc.first.pf = pf;
 pf->loc.last.pf = pf;
 pf->clean = 1;
}

variable_types: struct parsed_file { char *name; struct list_head_xcrash { struct list_head_xcrash *next; } parsed; struct list_head_xcrash raw; struct loc { struct pos_t { struct parsed_file *pf; int line; unsigned short column; struct dynstr { struct list_head_xcrash list; struct list_head_xcrash node_first; struct list_head_xcrash dup_list; struct node { struct list_head_xcrash list; enum node_type { nt_type=0, nt_expr=1, nt_var=2, nt_decl=3 } type; union { struct type { enum type_category { type_basic=0, type_typedef=1, type_struct=2, type_union=3, type_enum=4, type_pointer=5, type_array=6, type_func=7, type_typeof=8 } category; unsigned int flags; unsigned long btype; } t; struct expr { int op; union { long num; double f; }; } e; }; struct dynstr *str; struct node *parent; struct list_head_xcrash dup_list; struct loc loc; struct list_head_xcrash first_list; struct list_head_xcrash user_list; void *user_data; int nchild; struct list_head_xcrash child[]; } *cpp_cond; struct macro_exp { int refcount; struct hashed_macro { struct hashed_macro *next; char *name; struct list_head_xcrash params; int nparams; struct node *cpp_cond; struct loc loc; int undef; int hidden; int hasparam; int isparam; int noexpand; int variadic; } *hm; struct dynstr *first; struct dynstr *exp_first; struct { struct dynstr *first; } params[]; } *exp; int token; int refcount; union dynstr_flags_t { struct { int fake; int macro; }; unsigned int val; } flags; unsigned long len; char text[]; } *text; } first; struct loc *parent; } loc; int clean; } *

variable_types:
name
char *

user_defined_types: struct parsed_file { char *name; struct list_head_xcrash parsed; struct list_head_xcrash raw; struct loc loc; int clean; }

user_defined_types: struct loc { struct pos_t first; struct loc *parent; }

user_defined_types: struct pos_t { struct parsed_file *pf; int line; unsigned short column; struct dynstr *text; }

user_defined_types: struct dynstr { struct list_head_xcrash list; struct list_head_xcrash node_first; struct list_head_xcrash dup_list; struct node *cpp_cond; struct macro_exp *exp; int token; int refcount; union dynstr_flags_t flags; unsigned long len; char text[]; }

user_defined_types: struct node { struct list_head_xcrash list; enum node_type type; union { struct type t; struct expr e; }; struct dynstr *str; struct node *parent; struct list_head_xcrash dup_list; struct loc loc; struct list_head_xcrash first_list; struct list_head_xcrash user_list; void *user_data; int nchild; struct list_head_xcrash child[]; }

user_defined_types: struct macro_exp { int refcount; struct hashed_macro *hm; struct dynstr *first; struct dynstr *exp_first; struct { struct dynstr *first; } params[]; }

user_defined_types: struct type { enum type_category category; unsigned int flags; unsigned long btype; }


decompiled_code:
void *__fastcall get_basedir(void *src)
{
char *v1; // rax
void *v2; // r12
signed __int64 v3; // rbx

v1 = strrchr((const char *)src, 47);
v2 = &unk_C70;
if ( v1 )
{
v3 = v1 - (_BYTE *)src;
v2 = malloc(v1 - (_BYTE *)src + 2);
memcpy(v2, src, v3 + 1);
*((_BYTE *)v2 + v3 + 1) = 0;
}
return v2;
}

canonical_decompiled_code:
void *__fastcall func11(void *src)
{
char *v1; // rax
void *v2; // r12
signed __int64 v3; // rbx

v1 = strrchr((const char *)src, 47);
v2 = &unk_C70;
if ( v1 )
{
v3 = v1 - (_BYTE *)src;
v2 = malloc(v1 - (_BYTE *)src + 2);
memcpy(v2, src, v3 + 1);
*((_BYTE *)v2 + v3 + 1) = 0;
}
return v2;
}

original_code:
static char *
get_basedir(const char *path)
{
 char *p, *ret;
 if ( (p = strrchr(path, '/')) ) {
  ret = malloc(p - path + 2);
  memcpy(ret, path, p - path + 1);
  ret[p - path + 1] = 0;
 } else
  ret = "./";
 return ret;
}

canonical_original_code:
static char *get_basedir(char *path)
{
 char *p; char *ret;
 if ( (p = strrchr(path, '/')) ) {
  ret = malloc(p - path + 2);
  memcpy(ret, path, p - path + 1);
  ret[p - path + 1] = 0;
 } else
  ret = "./";
 return ret;
}

variable_types:
path
char *

variable_types:
p
char *

variable_types:
ret
char *


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

result = cleartypedefs();
if ( predef_types[0] )
{
v1 = predef_types;
do
{
result = addtypedef();
++v1;
}
while ( *v1 );
}
return result;
}

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

result = cleartypedefs();
if ( predef_types[0] )
{
v1 = predef_types;
do
{
result = addtypedef();
++v1;
}
while ( *v1 );
}
return result;
}

original_code:
void init_predef_types(void)
{
 const char **p;
 cleartypedefs();
 for (p = predef_types; *p; ++p)
  addtypedef(*p);
}

canonical_original_code:
void init_predef_types()
{
 char **p;
 cleartypedefs();
 for (p = predef_types; *p; ++p)
  addtypedef(*p);
}

variable_types:
p
char **


decompiled_code:
__int64 __fastcall walk_tree(_QWORD ***a1, __int64 (__fastcall *a2)(_QWORD **, __int64), __int64 a3)
{
_QWORD **v3; // rbp
_QWORD *v4; // r12
unsigned int i; // eax
unsigned int v6; // ebx
__int64 v7; // rax
__int64 v8; // rbp
__int64 v10; // [rsp+0h] [rbp-48h]

v3 = *a1;
v4 = **a1;
if ( a1 == *a1 )
return 0;
v10 = (__int64)a1;
for ( i = a2(v3, a3); ; i = a2(v3, a3) )
{
v6 = i;
if ( i == 1 )
break;
v7 = check_current_node((__int64)v3, v10, (__int64)v4);
v8 = v7;
if ( v7 )
{
if ( v6 != 2 )
{
v6 = walk_children(v7, a2, a3);
if ( v6 == 1 )
return v6;
}
v10 = v8;
}
v3 = (_QWORD **)v4;
if ( v4 == a1 )
return 0;
v4 = (_QWORD *)*v4;
}
return v6;
}

original_code:
enum walk_action
walk_tree(struct list_head_xcrash *tree, walkfn *fn, void *data)
{
 node_t *item, *next;
 struct list_head_xcrash *prev = tree;
 for (item = ({ const struct list_head_xcrash *__mptr = ((tree)->next); (typeof(*item) *)( (char *)__mptr - __builtin_offsetof (typeof(*item), list) );}), next = ({ const struct list_head_xcrash *__mptr = (item->list.next); (typeof(*item) *)( (char *)__mptr - __builtin_offsetof (typeof(*item), list) );}); &item->list != (tree); item = next, next = ({ const struct list_head_xcrash *__mptr = (next->list.next); (typeof(*next) *)( (char *)__mptr - __builtin_offsetof (typeof(*next), list) );})) {
  enum walk_action act = fn(item, data);
  if (act == walk_terminate)
   return walk_terminate;
  if (! (item = check_current_node(item, prev, &next->list)) )
   continue;
  if (act != walk_skip_children &&
      walk_children(item, fn, data) == walk_terminate)
   return walk_terminate;
  prev = &item->list;
 }
 return walk_continue;
}

canonical_original_code:
enum walk_action walk_tree(struct list_head_xcrash *tree, enum walk_action (*fn)(struct node *, void *), void *data)
{
 struct node *item; struct node *next;
 struct list_head_xcrash *prev = tree;
 for (item = ({ struct list_head_xcrash *__mptr = ((tree)->next); (typeof(*item) *)( (char *)__mptr - __builtin_offsetof (typeof(*item), list) );}), next = ({ struct list_head_xcrash *__mptr = (item->list.next); (typeof(*item) *)( (char *)__mptr - __builtin_offsetof (typeof(*item), list) );}); &item->list != (tree); item = next, next = ({ struct list_head_xcrash *__mptr = (next->list.next); (typeof(*next) *)( (char *)__mptr - __builtin_offsetof (typeof(*next), list) );})) {
  enum walk_action act = fn(item, data);
  if (act == walk_terminate)
   return walk_terminate;
  if (! (item = check_current_node(item, prev, &next->list)) )
   continue;
  if (act != walk_skip_children &&
      walk_children(item, fn, data) == walk_terminate)
   return walk_terminate;
  prev = &item->list;
 }
 return walk_continue;
}

variable_types: enum walk_action { walk_continue=0, walk_terminate=1, walk_skip_children=2 } (*)(struct node { struct list_head_xcrash list; enum node_type { nt_type=0, nt_expr=1, nt_var=2, nt_decl=3 } type; union { struct type { enum type_category { type_basic=0, type_typedef=1, type_struct=2, type_union=3, type_enum=4, type_pointer=5, type_array=6, type_func=7, type_typeof=8 } category; unsigned int flags; unsigned long btype; } t; struct expr { int op; union { long num; double f; }; } e; }; struct dynstr { struct list_head_xcrash list; struct list_head_xcrash node_first; struct list_head_xcrash dup_list; struct node *cpp_cond; struct macro_exp { int refcount; struct hashed_macro { struct hashed_macro *next; char *name; struct list_head_xcrash params; int nparams; struct node *cpp_cond; struct loc { struct pos_t { struct parsed_file { char *name; struct list_head_xcrash parsed; struct list_head_xcrash raw; struct loc loc; int clean; } *pf; int line; unsigned short column; struct dynstr *text; } first; struct loc *parent; } loc; int undef; int hidden; int hasparam; int isparam; int noexpand; int variadic; } *hm; struct dynstr *first; struct dynstr *exp_first; struct { struct dynstr *first; } params[]; } *exp; int token; int refcount; union dynstr_flags_t { struct { int fake; int macro; }; unsigned int val; } flags; unsigned long len; char text[]; } *str; struct node *parent; struct list_head_xcrash dup_list; struct loc loc; struct list_head_xcrash first_list; struct list_head_xcrash user_list; void *user_data; int nchild; struct list_head_xcrash child[]; } *, void *)

variable_types:
data
void *

variable_types: struct node { struct list_head_xcrash { struct list_head_xcrash *next; } list; enum node_type { nt_type=0, nt_expr=1, nt_var=2, nt_decl=3 } type; union { struct type { enum type_category { type_basic=0, type_typedef=1, type_struct=2, type_union=3, type_enum=4, type_pointer=5, type_array=6, type_func=7, type_typeof=8 } category; unsigned int flags; unsigned long btype; } t; struct expr { int op; union { long num; double f; }; } e; }; struct dynstr { struct list_head_xcrash list; struct list_head_xcrash node_first; struct list_head_xcrash dup_list; struct node *cpp_cond; struct macro_exp { int refcount; struct hashed_macro { struct hashed_macro *next; char *name; struct list_head_xcrash params; int nparams; struct node *cpp_cond; struct loc { struct pos_t { struct parsed_file { char *name; struct list_head_xcrash parsed; struct list_head_xcrash raw; struct loc loc; int clean; } *pf; int line; unsigned short column; struct dynstr *text; } first; struct loc *parent; } loc; int undef; int hidden; int hasparam; int isparam; int noexpand; int variadic; } *hm; struct dynstr *first; struct dynstr *exp_first; struct { struct dynstr *first; } params[]; } *exp; int token; int refcount; union dynstr_flags_t { struct { int fake; int macro; }; unsigned int val; } flags; unsigned long len; char text[]; } *str; struct node *parent; struct list_head_xcrash dup_list; struct loc loc; struct list_head_xcrash first_list; struct list_head_xcrash user_list; void *user_data; int nchild; struct list_head_xcrash child[]; } *

user_defined_types: struct hashed_macro { struct hashed_macro *next; char *name; struct list_head_xcrash params; int nparams; struct node *cpp_cond; struct loc loc; int undef; int hidden; int hasparam; int isparam; int noexpand; int variadic; }


decompiled_code:
__int64 __fastcall walk_children(__int64 a1, __int64 (__fastcall *a2)(_QWORD **, __int64), __int64 a3)
{
_QWORD ***v4; // rbx
int v5; // ebp
__int64 result; // rax

if ( *(int *)(a1 + 184) <= 0 )
return 0LL;
v4 = (_QWORD ***)(a1 + 192);
v5 = 0;
while ( 1 )
{
result = walk_tree(v4, a2, a3);
if ( (_DWORD)result == 1 )
break;
++v5;
v4 += 2;
if ( *(_DWORD *)(a1 + 184) <= v5 )
return 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func15(__int64 a1, __int64 (__fastcall *a2)(_QWORD **, __int64), __int64 a3)
{
_QWORD ***v4; // rbx
int v5; // ebp
__int64 result; // rax

if ( *(int *)(a1 + 184) <= 0 )
return 0LL;
v4 = (_QWORD ***)(a1 + 192);
v5 = 0;
while ( 1 )
{
result = func14(v4, a2, a3);
if ( (_DWORD)result == 1 )
break;
++v5;
v4 += 2;
if ( *(_DWORD *)(a1 + 184) <= v5 )
return 0LL;
}
return result;
}

original_code:
static inline enum walk_action
walk_children(node_t *node, walkfn *fn, void *data)
{
 int i;
 for (i = 0; i < node->nchild; ++i)
  if (walk_tree(&node->child[i], fn, data) == walk_terminate)
   return walk_terminate;
 return walk_continue;
}

canonical_original_code:
static inline enum walk_action walk_children(struct node *node, enum walk_action (*fn)(struct node *, void *), void *data)
{
 int i;
 for (i = 0; i < node->nchild; ++i)
  if (walk_tree(&node->child[i], fn, data) == walk_terminate)
   return walk_terminate;
 return walk_continue;
}

variable_types: enum walk_action { walk_continue=0, walk_terminate=1, walk_skip_children=2 } (*)(struct node *, void *)

variable_types: i int

user_defined_types: struct list_head_xcrash { struct list_head_xcrash *next; }

user_defined_types: enum node_type { nt_type=0, nt_expr=1, nt_var=2, nt_decl=3 }

user_defined_types: struct expr { int op; union { long num; double f; }; }

user_defined_types: enum type_category { type_basic=0, type_typedef=1, type_struct=2, type_union=3, type_enum=4, type_pointer=5, type_array=6, type_func=7, type_typeof=8 }

user_defined_types: union dynstr_flags_t { struct { int fake; int macro; }; unsigned int val; }


decompiled_code:
__int64 __fastcall walk_tree_single(__int64 *a1, __int64 (__fastcall *a2)(_QWORD **, __int64), __int64 a3)
{
__int64 v4; // r13
__int64 v5; // r14
__int64 result; // rax
__int64 v7; // rdi

v4 = a1[1];
v5 = *a1;
result = a2((_QWORD **)a1, a3);
if ( (_DWORD)result != 1 )
{
if ( (_DWORD)result == 2 )
{
result = 0LL;
}
else
{
v7 = check_current_node((__int64)a1, v4, v5);
result = 0LL;
if ( v7 )
result = walk_children(v7, a2, a3);
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func16(__int64 *a1, __int64 (__fastcall *a2)(_QWORD **, __int64), __int64 a3)
{
__int64 v4; // r13
__int64 v5; // r14
__int64 result; // rax
__int64 v7; // rdi

v4 = a1[1];
v5 = *a1;
result = a2((_QWORD **)a1, a3);
if ( (_DWORD)result != 1 )
{
if ( (_DWORD)result == 2 )
{
result = 0LL;
}
else
{
v7 = func8((__int64)a1, v4, v5);
result = 0LL;
if ( v7 )
result = func15(v7, a2, a3);
}
}
return result;
}

original_code:
enum walk_action
walk_tree_single(node_t *tree, walkfn *fn, void *data)
{
 struct list_head_xcrash *prev = tree->list.prev,
  *next = tree->list.next;
 switch (fn(tree, data)) {
 case walk_terminate: return walk_terminate;
 case walk_skip_children: return walk_continue;
 case walk_continue: break;
 }
 if (! (tree = check_current_node(tree, prev, next)) )
  return walk_continue;
 return walk_children(tree, fn, data);
}

canonical_original_code:
enum walk_action walk_tree_single(struct node *tree, enum walk_action (*fn)(struct node *, void *), void *data)
{
 struct list_head_xcrash *prev = tree->list.prev; struct list_head_xcrash *next = tree->list.next;
 switch (fn(tree, data)) {
 case walk_terminate: return walk_terminate;
 case walk_skip_children: return walk_continue;
 case walk_continue: break;
 }
 if (! (tree = check_current_node(tree, prev, next)) )
  return walk_continue;
 return walk_children(tree, fn, data);
}

return_type: enum walk_action { walk_continue=0, walk_terminate=1, walk_skip_children=2 }


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
void *v3; // rax
__int64 v4; // rbp
int v5; // ebx
int v6; // eax
int result; // eax
int v8; // [rsp+Ch] [rbp-3Ch] BYREF
void *input; // [rsp+10h] [rbp-38h] BYREF
__int64 v10[6]; // [rsp+18h] [rbp-30h] BYREF

INIT_LIST_HEAD(v10);
input = get_basedir((void *)*argv);
argp_parse(&argp, argc, (char **)argv, 0, &v8, &input);
files = argc - v8 + 1;
v3 = calloc(files, 0x68uLL);
qword_C68 = (__int64)v3;
if ( v3 )
{
init_builtin_file((__int64)v3);
if ( files > 1 )
{
v4 = 104LL;
v5 = 1;
do
{
v6 = v8++;
++v5;
init_file(qword_C68 + v4, (__int64)argv[v6]);
v4 += 104LL;
}
while ( files > v5 );
}
result = xform_files(&input, &files);
}
else
{
perror("Cannot allocate file array");
result = 1;
}
return result;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
void *v3; // rax
__int64 v4; // rbp
int v5; // ebx
int v6; // eax
int result; // eax
int v8; // [rsp+Ch] [rbp-3Ch] BYREF
void *input; // [rsp+10h] [rbp-38h] BYREF
__int64 v10[6]; // [rsp+18h] [rbp-30h] BYREF

func0(v10);
input = func11((void *)*argv);
argp_parse(&argp, argc, (char **)argv, 0, &v8, &input);
files = argc - v8 + 1;
v3 = calloc(files, 0x68uLL);
qword_C68 = (__int64)v3;
if ( v3 )
{
func12((__int64)v3);
if ( files > 1 )
{
v4 = 104LL;
v5 = 1;
do
{
v6 = v8++;
++v5;
func9(qword_C68 + v4, (__int64)argv[v6]);
v4 += 104LL;
}
while ( files > v5 );
}
result = xform_files(&input, &files);
}
else
{
perror("Cannot allocate file array");
result = 1;
}
return result;
}

original_code:
int main(int argc, char **argv)
{
 struct arguments arguments;
 int argf, i;
 INIT_LIST_HEAD(&arguments.xform_names);
 arguments.basedir = get_basedir(argv[0]);
 argp_parse(&argp, argc, argv, 0, &argf, &arguments);
 files.n = argc - argf + 1;
 if (! (files.array = calloc(files.n, sizeof(struct parsed_file))) ) {
  perror("Cannot allocate file array");
  return 1;
 }
 i = 0;
 init_builtin_file(&files.array[i++]);
 while(i < files.n)
  init_file(&files.array[i++], argv[argf++]);
 return xform_files(&arguments, &files);
}

canonical_original_code:
int main(int argc, char **argv)
{
 struct arguments arguments;
 int argf; int i;
 INIT_LIST_HEAD(&arguments.xform_names);
 arguments.basedir = get_basedir(argv[0]);
 argp_parse(&argp, argc, argv, 0, &argf, &arguments);
 files.n = argc - argf + 1;
 if (! (files.array = calloc(files.n, sizeof(struct parsed_file))) ) {
  perror("Cannot allocate file array");
  return 1;
 }
 i = 0;
 init_builtin_file(&files.array[i++]);
 while(i < files.n)
  init_file(&files.array[i++], argv[argf++]);
 return xform_files(&arguments, &files);
}

variable_types: argc int

variable_types:
argv
char **

variable_types: struct arguments { char *basedir; struct list_head_xcrash { struct list_head_xcrash *next; } xform_names; }

variable_types: argf int

user_defined_types: struct arguments { char *basedir; struct list_head_xcrash xform_names; }


canonical_decompiled_code:
_BOOL8 __fastcall func0(_QWORD *a1)
{
return *a1 == (_QWORD)a1;
}


decompiled_code:
__int64 __fastcall find_var_scope(__int64 a1)
{
const char **v1; // rbp
__int64 v2; // rbx

v1 = *(const char ***)(a1 + 72);
v2 = find_scope(a1, 0LL);
if ( (const char **)v2 == v1 + 1 && (unsigned int)is_header_file(v1) )
v2 = 0LL;
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
const char **v1; // rbp
__int64 v2; // rbx

v1 = *(const char ***)(a1 + 72);
v2 = find_scope(a1, 0LL);
if ( (const char **)v2 == v1 + 1 && (unsigned int)func3(v1) )
v2 = 0LL;
return v2;
}

original_code:
struct list_head_xcrash *
find_var_scope(node_t *node)
{
 struct parsed_file *pf = node->loc.first.pf;
 struct list_head_xcrash *tree = &pf->parsed;
 struct list_head_xcrash *scope = find_scope(node, ((void *)0));
 if (scope == tree && is_header_file(pf))
  return ((void *)0);
 return scope;
}

canonical_original_code:
struct list_head_xcrash *find_var_scope(struct node *node)
{
 struct parsed_file *pf = node->loc.first.pf;
 struct list_head_xcrash *tree = &pf->parsed;
 struct list_head_xcrash *scope = find_scope(node, ((void *)0));
 if (scope == tree && is_header_file(pf))
  return ((void *)0);
 return scope;
}

variable_types: struct node { struct list_head_xcrash list; enum node_type { nt_type=0, nt_expr=1, nt_var=2, nt_decl=3 } type; union { struct type { enum type_category { type_basic=0, type_typedef=1, type_struct=2, type_union=3, type_enum=4, type_pointer=5, type_array=6, type_func=7, type_typeof=8 } category; unsigned int flags; unsigned long btype; } t; struct expr { int op; union { long num; double f; }; } e; }; struct dynstr { struct list_head_xcrash list; struct list_head_xcrash node_first; struct list_head_xcrash dup_list; struct node *cpp_cond; struct macro_exp { int refcount; struct hashed_macro { struct hashed_macro *next; char *name; struct list_head_xcrash params; int nparams; struct node *cpp_cond; struct loc { struct pos_t { struct parsed_file { char *name; struct list_head_xcrash parsed; struct list_head_xcrash raw; struct loc loc; int clean; } *pf; int line; unsigned short column; struct dynstr *text; } first; struct loc *parent; } loc; int undef; int hidden; int hasparam; int isparam; int noexpand; int variadic; } *hm; struct dynstr *first; struct dynstr *exp_first; struct { struct dynstr *first; } params[]; } *exp; int token; int refcount; union dynstr_flags_t { struct { int fake; int macro; }; unsigned int val; } flags; unsigned long len; char text[]; } *str; struct node *parent; struct list_head_xcrash dup_list; struct loc loc; struct list_head_xcrash first_list; struct list_head_xcrash user_list; void *user_data; int nchild; struct list_head_xcrash child[]; } *

return_type: struct list_head_xcrash { struct list_head_xcrash *next; } *


decompiled_code:
__int64 __fastcall varscope_add(__int64 a1)
{
__int64 v1; // r12
_QWORD *v2; // rbx
__int64 result; // rax

v1 = find_var_scope(a1);
v2 = malloc(0x18uLL);
result = (unsigned int)mkhash((char *)(*(_QWORD *)(a1 + 40) + 112LL), v1);
*v2 = vshash[(unsigned int)result];
v2[1] = a1;
v2[2] = v1;
vshash[(unsigned int)result] = (__int64)v2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
__int64 v1; // r12
_QWORD *v2; // rbx
__int64 result; // rax

v1 = func5(a1);
v2 = malloc(0x18uLL);
result = (unsigned int)func2((char *)(*(_QWORD *)(a1 + 40) + 112LL), v1);
*v2 = vshash[(unsigned int)result];
v2[1] = a1;
v2[2] = v1;
vshash[(unsigned int)result] = (__int64)v2;
return result;
}

original_code:
static void
varscope_add(node_t *node)
{
 struct list_head_xcrash *scope = find_var_scope(node);
 struct varscope *vs = malloc(sizeof(struct varscope));
 unsigned idx = mkhash(node->str->text, scope);
 vs->next = vshash[idx];
 vs->node = node;
 vs->scope = scope;
 vshash[idx] = vs;
}

canonical_original_code:
static void varscope_add(struct node *node)
{
 struct list_head_xcrash *scope = find_var_scope(node);
 struct varscope *vs = malloc(sizeof(struct varscope));
 unsigned int idx = mkhash(node->str->text, scope);
 vs->next = vshash[idx];
 vs->node = node;
 vs->scope = scope;
 vshash[idx] = vs;
}

variable_types: struct list_head_xcrash { struct list_head_xcrash *next; } *

variable_types: struct varscope { struct varscope *next; struct node { struct list_head_xcrash { struct list_head_xcrash *next; } list; enum node_type { nt_type=0, nt_expr=1, nt_var=2, nt_decl=3 } type; union { struct type { enum type_category { type_basic=0, type_typedef=1, type_struct=2, type_union=3, type_enum=4, type_pointer=5, type_array=6, type_func=7, type_typeof=8 } category; unsigned int flags; unsigned long btype; } t; struct expr { int op; union { long num; double f; }; } e; }; struct dynstr { struct list_head_xcrash list; struct list_head_xcrash node_first; struct list_head_xcrash dup_list; struct node *cpp_cond; struct macro_exp { int refcount; struct hashed_macro { struct hashed_macro *next; char *name; struct list_head_xcrash params; int nparams; struct node *cpp_cond; struct loc { struct pos_t { struct parsed_file { char *name; struct list_head_xcrash parsed; struct list_head_xcrash raw; struct loc loc; int clean; } *pf; int line; unsigned short column; struct dynstr *text; } first; struct loc *parent; } loc; int undef; int hidden; int hasparam; int isparam; int noexpand; int variadic; } *hm; struct dynstr *first; struct dynstr *exp_first; struct { struct dynstr *first; } params[]; } *exp; int token; int refcount; union dynstr_flags_t { struct { int fake; int macro; }; unsigned int val; } flags; unsigned long len; char text[]; } *str; struct node *parent; struct list_head_xcrash dup_list; struct loc loc; struct list_head_xcrash first_list; struct list_head_xcrash user_list; void *user_data; int nchild; struct list_head_xcrash child[]; } *node; struct list_head_xcrash *scope; } *

variable_types:
idx
unsigned int

user_defined_types: struct varscope { struct varscope *next; struct node *node; struct list_head_xcrash *scope; }


decompiled_code:
__int64 __fastcall fill_varscope(__int64 a1)
{
int v1; // eax

v1 = *(_DWORD *)(a1 + 16);
if ( v1 == 2 )
{
if ( *(_QWORD *)(a1 + 40) )
{
LABEL_8:
varscope_add(a1);
return 0LL;
}
}
else if ( !v1
&& *(_QWORD *)(a1 + 40)
&& (unsigned int)(*(_DWORD *)(a1 + 24) - 2) <= 2
&& !list_empty((_QWORD *)(a1 + 192)) )
{
goto LABEL_8;
}
return 0LL;
}

original_code:
static enum walk_action
fill_varscope(node_t *node, void *data)
{
 if (node->type == nt_var && node->str)
  varscope_add(node);
 else if (node->type == nt_type && node->str &&
   (node->t.category == type_struct ||
    node->t.category == type_union ||
    node->t.category == type_enum) &&
   !list_empty(&node->child[cht_body]))
  varscope_add(node);
 return walk_continue;
}

canonical_original_code:
static enum walk_action fill_varscope(struct node *node, void *data)
{
 if (node->type == nt_var && node->str)
  varscope_add(node);
 else if (node->type == nt_type && node->str &&
   (node->t.category == type_struct ||
    node->t.category == type_union ||
    node->t.category == type_enum) &&
   !list_empty(&node->child[cht_body]))
  varscope_add(node);
 return walk_continue;
}

user_defined_types: enum walk_action { walk_continue=0, walk_terminate=1, walk_skip_children=2 }


decompiled_code:
void free_varscope()
{
const char *v0; // rbp
_QWORD *v1; // rbx
void *v2; // rdi

v0 = (const char *)vshash;
do
{
v1 = *(_QWORD **)v0;
if ( *(_QWORD *)v0 )
{
do
{
v2 = v1;
v1 = (_QWORD *)*v1;
free(v2);
}
while ( v1 );
}
*(_QWORD *)v0 = 0LL;
v0 += 8;
}
while ( v0 != "var " );
}

canonical_decompiled_code:
void func8()
{
const char *v0; // rbp
_QWORD *v1; // rbx
void *v2; // rdi

v0 = (const char *)vshash;
do
{
v1 = *(_QWORD **)v0;
if ( *(_QWORD *)v0 )
{
do
{
v2 = v1;
v1 = (_QWORD *)*v1;
free(v2);
}
while ( v1 );
}
*(_QWORD *)v0 = 0LL;
v0 += 8;
}
while ( v0 != "var " );
}

original_code:
void
free_varscope(void)
{
 unsigned idx;
 for (idx = 0; idx < 8192; ++idx) {
  struct varscope *vs, *vsnext;
  for (vs = vshash[idx]; vs; vs = vsnext) {
   vsnext = vs->next;
   free(vs);
  }
  vshash[idx] = ((void *)0);
 }
}

canonical_original_code:
void free_varscope()
{
 unsigned int idx;
 for (idx = 0; idx < 8192; ++idx) {
  struct varscope *vs; struct varscope *vsnext;
  for (vs = vshash[idx]; vs; vs = vsnext) {
   vsnext = vs->next;
   free(vs);
  }
  vshash[idx] = ((void *)0);
 }
}


decompiled_code:
__int64 __fastcall init_varscope(int *a1)
{
__int64 v1; // rbx
__int64 result; // rax

free_varscope();
v1 = *((_QWORD *)a1 + 1);
result = 104LL * *a1;
if ( result )
{
do
{
walk_tree(v1 + 8, fill_varscope, 0LL);
v1 += 104LL;
result = *((_QWORD *)a1 + 1) + 104LL * *a1;
}
while ( v1 != result );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(int *a1)
{
__int64 v1; // rbx
__int64 result; // rax

func8();
v1 = *((_QWORD *)a1 + 1);
result = 104LL * *a1;
if ( result )
{
do
{
walk_tree(v1 + 8, fill_varscope, 0LL);
v1 += 104LL;
result = *((_QWORD *)a1 + 1) + 104LL * *a1;
}
while ( v1 != result );
}
return result;
}

original_code:
void
init_varscope(const struct file_array *files)
{
 struct parsed_file *pf;
 free_varscope();
 for ((pf) = (files)->array; (pf) != &(files)->array[(files)->n]; ++(pf))
  walk_tree(&pf->parsed, fill_varscope, ((void *)0));
}

canonical_original_code:
void init_varscope(struct file_array *files)
{
 struct parsed_file *pf;
 free_varscope();
 for ((pf) = (files)->array; (pf) != &(files)->array[(files)->n]; ++(pf))
  walk_tree(&pf->parsed, fill_varscope, ((void *)0));
}

variable_types: struct file_array { int n; struct parsed_file { char *name; struct list_head_xcrash { struct list_head_xcrash *next; } parsed; struct list_head_xcrash raw; struct loc { struct pos_t { struct parsed_file *pf; int line; unsigned short column; struct dynstr { struct list_head_xcrash list; struct list_head_xcrash node_first; struct list_head_xcrash dup_list; struct node { struct list_head_xcrash list; enum node_type { nt_type=0, nt_expr=1, nt_var=2, nt_decl=3 } type; union { struct type { enum type_category { type_basic=0, type_typedef=1, type_struct=2, type_union=3, type_enum=4, type_pointer=5, type_array=6, type_func=7, type_typeof=8 } category; unsigned int flags; unsigned long btype; } t; struct expr { int op; union { long num; double f; }; } e; }; struct dynstr *str; struct node *parent; struct list_head_xcrash dup_list; struct loc loc; struct list_head_xcrash first_list; struct list_head_xcrash user_list; void *user_data; int nchild; struct list_head_xcrash child[]; } *cpp_cond; struct macro_exp { int refcount; struct hashed_macro { struct hashed_macro *next; char *name; struct list_head_xcrash params; int nparams; struct node *cpp_cond; struct loc loc; int undef; int hidden; int hasparam; int isparam; int noexpand; int variadic; } *hm; struct dynstr *first; struct dynstr *exp_first; struct { struct dynstr *first; } params[]; } *exp; int token; int refcount; union dynstr_flags_t { struct { int fake; int macro; }; unsigned int val; } flags; unsigned long len; char text[]; } *text; } first; struct loc *parent; } loc; int clean; } *array; } *

user_defined_types: struct file_array { int n; struct parsed_file *array; }


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

result = a2;
while ( !*(_DWORD *)(result + 16) )
{
if ( *(_DWORD *)(result + 24) != 1 )
break;
result = (__int64)varscope_traverse(a1, result, 2, (char *)(*(_QWORD *)(result + 40) + 112LL));
if ( !result )
break;
result = first_node(result + 192);
if ( (*(_BYTE *)(result + 28) & 0x20) == 0 )
return 0LL;
}
return result;
}

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

result = a2;
while ( !*(_DWORD *)(result + 16) )
{
if ( *(_DWORD *)(result + 24) != 1 )
break;
result = (__int64)varscope_traverse(a1, result, 2, (char *)(*(_QWORD *)(result + 40) + 112LL));
if ( !result )
break;
result = func1(result + 192);
if ( (*(_BYTE *)(result + 28) & 0x20) == 0 )
return 0LL;
}
return result;
}

original_code:
node_t *
resolve_typedef(struct list_head_xcrash *tree, node_t *type)
{
 while (type->type == nt_type && type->t.category == type_typedef) {
  node_t *var = varscope_traverse(tree, type,
      nt_var, type->str->text);
  if (!var)
   return ((void *)0);
  type = first_node(&var->child[chv_type]);
  if (! (type->t.flags & (1U << 5)))
   return ((void *)0);
 }
 return type;
}

canonical_original_code:
struct node *resolve_typedef(struct list_head_xcrash *tree, struct node *type)
{
 while (type->type == nt_type && type->t.category == type_typedef) {
  struct node *var = varscope_traverse(tree, type,
      nt_var, type->str->text);
  if (!var)
   return ((void *)0);
  type = first_node(&var->child[chv_type]);
  if (! (type->t.flags & (1U << 5)))
   return ((void *)0);
 }
 return type;
}

variable_types:
tree
struct list_head_xcrash *

variable_types:
type
struct node *

return_type: struct node { struct list_head_xcrash { struct list_head_xcrash *next; } list; enum node_type { nt_type=0, nt_expr=1, nt_var=2, nt_decl=3 } type; union { struct type { enum type_category { type_basic=0, type_typedef=1, type_struct=2, type_union=3, type_enum=4, type_pointer=5, type_array=6, type_func=7, type_typeof=8 } category; unsigned int flags; unsigned long btype; } t; struct expr { int op; union { long num; double f; }; } e; }; struct dynstr { struct list_head_xcrash list; struct list_head_xcrash node_first; struct list_head_xcrash dup_list; struct node *cpp_cond; struct macro_exp { int refcount; struct hashed_macro { struct hashed_macro *next; char *name; struct list_head_xcrash params; int nparams; struct node *cpp_cond; struct loc { struct pos_t { struct parsed_file { char *name; struct list_head_xcrash parsed; struct list_head_xcrash raw; struct loc loc; int clean; } *pf; int line; unsigned short column; struct dynstr *text; } first; struct loc *parent; } loc; int undef; int hidden; int hasparam; int isparam; int noexpand; int variadic; } *hm; struct dynstr *first; struct dynstr *exp_first; struct { struct dynstr *first; } params[]; } *exp; int token; int refcount; union dynstr_flags_t { struct { int fake; int macro; }; unsigned int val; } flags; unsigned long len; char text[]; } *str; struct node *parent; struct list_head_xcrash dup_list; struct loc loc; struct list_head_xcrash first_list; struct list_head_xcrash user_list; void *user_data; int nchild; struct list_head_xcrash child[]; } *


decompiled_code:
__int64 __fastcall expr_type(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rbx
_BOOL4 v3; // edx
__int64 v4; // rax
__int64 v5; // rbx
__int64 v6; // rax
__int64 v7; // rbx
_BOOL4 v8; // edx

if ( *(_DWORD *)(a1 + 16) != 1 )
_assert_fail("expr->type == nt_expr", "varscope.c", 0xDFu, "expr_type");
if ( *(_DWORD *)(a1 + 24) == 335 )
{
v4 = first_node(a1 + 192);
result = varscope_find_expr(v4);
if ( result )
{
if ( *(_DWORD *)(result + 16) != 2 )
_assert_fail("var->type == nt_var", "varscope.c", 0xE5u, "expr_type");
v5 = result + 192;
if ( list_empty((_QWORD *)(result + 192)) )
{
result = 0LL;
}
else
{
v6 = first_node(v5);
if ( *(_DWORD *)(v6 + 16) )
_assert_fail("type->type == nt_type", "varscope.c", 0xEBu, "expr_type");
if ( (unsigned int)(*(_DWORD *)(v6 + 24) - 5) > 1 )
_assert_fail(
"type->t.category == type_array || type->t.category == type_pointer",
"varscope.c",
0xEEu,
"expr_type");
v7 = v6 + 192;
v8 = list_empty((_QWORD *)(v6 + 192));
result = 0LL;
if ( !v8 )
result = first_node(v7);
}
}
}
else
{
result = varscope_find_expr(a1);
if ( result )
{
if ( *(_DWORD *)(result + 16) != 2 )
_assert_fail("var->type == nt_var", "varscope.c", 0xF7u, "expr_type");
v2 = result + 192;
v3 = list_empty((_QWORD *)(result + 192));
result = 0LL;
if ( !v3 )
result = first_node(v2);
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rbx
_BOOL4 v3; // edx
__int64 v4; // rax
__int64 v5; // rbx
__int64 v6; // rax
__int64 v7; // rbx
_BOOL4 v8; // edx

if ( *(_DWORD *)(a1 + 16) != 1 )
_assert_fail("expr->type == nt_expr", "varscope.c", 0xDFu, "expr_type");
if ( *(_DWORD *)(a1 + 24) == 335 )
{
v4 = func1(a1 + 192);
result = func11(v4);
if ( result )
{
if ( *(_DWORD *)(result + 16) != 2 )
_assert_fail("var->type == nt_var", "varscope.c", 0xE5u, "expr_type");
v5 = result + 192;
if ( func0((_QWORD *)(result + 192)) )
{
result = 0LL;
}
else
{
v6 = func1(v5);
if ( *(_DWORD *)(v6 + 16) )
_assert_fail("type->type == nt_type", "varscope.c", 0xEBu, "expr_type");
if ( (unsigned int)(*(_DWORD *)(v6 + 24) - 5) > 1 )
_assert_fail(
"type->t.category == type_array || type->t.category == type_pointer",
"varscope.c",
0xEEu,
"expr_type");
v7 = v6 + 192;
v8 = func0((_QWORD *)(v6 + 192));
result = 0LL;
if ( !v8 )
result = func1(v7);
}
}
}
else
{
result = func11(a1);
if ( result )
{
if ( *(_DWORD *)(result + 16) != 2 )
_assert_fail("var->type == nt_var", "varscope.c", 0xF7u, "expr_type");
v2 = result + 192;
v3 = func0((_QWORD *)(result + 192));
result = 0LL;
if ( !v3 )
result = func1(v2);
}
}
return result;
}

original_code:
static node_t *
expr_type(node_t *expr)
{
 node_t *var, *type;
 ((void) sizeof ((expr->type == nt_expr) ? 1 : 0), __extension__ ({ if (expr->type == nt_expr) ; else __assert_fail ("expr->type == nt_expr", "varscope.c", 223, __extension__ __PRETTY_FUNCTION__); }));
 if (expr->e.op == ARRAY) {
  var = first_node(&expr->child[che_arg1]);
  if (! (var = varscope_find_expr(var)) )
   return ((void *)0);
  ((void) sizeof ((var->type == nt_var) ? 1 : 0), __extension__ ({ if (var->type == nt_var) ; else __assert_fail ("var->type == nt_var", "varscope.c", 229, __extension__ __PRETTY_FUNCTION__); }));
  if (list_empty(&var->child[chv_type]))
   return ((void *)0);
  type = first_node(&var->child[chv_type]);
  ((void) sizeof ((type->type == nt_type) ? 1 : 0), __extension__ ({ if (type->type == nt_type) ; else __assert_fail ("type->type == nt_type", "varscope.c", 235, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((type->t.category == type_array || type->t.category == type_pointer) ? 1 : 0), __extension__ ({ if (type->t.category == type_array || type->t.category == type_pointer) ; else __assert_fail ("type->t.category == type_array || type->t.category == type_pointer", "varscope.c", 238, __extension__ __PRETTY_FUNCTION__); }));
  return !list_empty(&type->child[cht_type])
   ? first_node(&type->child[cht_type])
   : ((void *)0);
 } else {
  if (! (var = varscope_find_expr(expr)) )
   return ((void *)0);
  ((void) sizeof ((var->type == nt_var) ? 1 : 0), __extension__ ({ if (var->type == nt_var) ; else __assert_fail ("var->type == nt_var", "varscope.c", 247, __extension__ __PRETTY_FUNCTION__); }));
  return !list_empty(&var->child[chv_type])
   ? first_node(&var->child[chv_type])
   : ((void *)0);
 }
}

canonical_original_code:
static struct node *expr_type(struct node *expr)
{
 struct node *var; struct node *type;
 ((void) sizeof ((expr->type == nt_expr) ? 1 : 0), __extension__ ({ if (expr->type == nt_expr) ; else __assert_fail ("expr->type == nt_expr", "varscope.c", 223, __extension__ __PRETTY_FUNCTION__); }));
 if (expr->e.op == ARRAY) {
  var = first_node(&expr->child[che_arg1]);
  if (! (var = varscope_find_expr(var)) )
   return ((void *)0);
  ((void) sizeof ((var->type == nt_var) ? 1 : 0), __extension__ ({ if (var->type == nt_var) ; else __assert_fail ("var->type == nt_var", "varscope.c", 229, __extension__ __PRETTY_FUNCTION__); }));
  if (list_empty(&var->child[chv_type]))
   return ((void *)0);
  type = first_node(&var->child[chv_type]);
  ((void) sizeof ((type->type == nt_type) ? 1 : 0), __extension__ ({ if (type->type == nt_type) ; else __assert_fail ("type->type == nt_type", "varscope.c", 235, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((type->t.category == type_array || type->t.category == type_pointer) ? 1 : 0), __extension__ ({ if (type->t.category == type_array || type->t.category == type_pointer) ; else __assert_fail ("type->t.category == type_array || type->t.category == type_pointer", "varscope.c", 238, __extension__ __PRETTY_FUNCTION__); }));
  return !list_empty(&type->child[cht_type])
   ? first_node(&type->child[cht_type])
   : ((void *)0);
 } else {
  if (! (var = varscope_find_expr(expr)) )
   return ((void *)0);
  ((void) sizeof ((var->type == nt_var) ? 1 : 0), __extension__ ({ if (var->type == nt_var) ; else __assert_fail ("var->type == nt_var", "varscope.c", 247, __extension__ __PRETTY_FUNCTION__); }));
  return !list_empty(&var->child[chv_type])
   ? first_node(&var->child[chv_type])
   : ((void *)0);
 }
}

variable_types:
expr
struct node *

user_defined_types: struct parsed_file { char *name; struct list_head_xcrash parsed; struct list_head_xcrash raw; struct loc loc; int clean; }


original_code:
node_t *
varscope_symbol(const struct file_array *files, const char *name)
{
 struct list_head_xcrash *tree;
 char localname[strlen(name) + 1];
 char *spec, *sep;
 spec = localname;
 strcpy(spec, name);
 if ( (sep = strchr(spec, ':')) ) {
  struct parsed_file *pf;
  *sep = 0;
  if (! (pf = find_file(files, spec)) )
   return ((void *)0);
  tree = &pf->parsed;
 } else {
  sep = spec - 1;
  tree = ((void *)0);
 }
 struct list_head_xcrash *scope = tree;
 node_t *node = ((void *)0);
 do {
  spec = sep + 1;
  if ( (sep = strchr(spec, '.')) )
   *sep = 0;
  if (node)
   scope = node_scope(node);
  if (! (node = find_symbol(files, scope, spec)) )
   return ((void *)0);
  if (! (node = resolve_typedef(tree, node)) )
   return ((void *)0);
 } while (sep && sep[1]);
 return node;
}

canonical_original_code:
struct node *varscope_symbol(struct file_array *files, char *name)
{
 struct list_head_xcrash *tree;
 char localname[-1];
 char *spec; char *sep;
 spec = localname;
 strcpy(spec, name);
 if ( (sep = strchr(spec, ':')) ) {
  struct parsed_file *pf;
  *sep = 0;
  if (! (pf = find_file(files, spec)) )
   return ((void *)0);
  tree = &pf->parsed;
 } else {
  sep = spec - 1;
  tree = ((void *)0);
 }
 struct list_head_xcrash *scope = tree;
 struct node *node = ((void *)0);
 do {
  spec = sep + 1;
  if ( (sep = strchr(spec, '.')) )
   *sep = 0;
  if (node)
   scope = node_scope(node);
  if (! (node = find_symbol(files, scope, spec)) )
   return ((void *)0);
  if (! (node = resolve_typedef(tree, node)) )
   return ((void *)0);
 } while (sep && sep[1]);
 return node;
}

variable_types: struct file_array { int n; struct parsed_file *array; } *

variable_types:
name
char *

variable_types:
localname
char [-1]

variable_types:
spec
char *

variable_types:
sep
char *

variable_types: struct parsed_file { char *name; struct list_head_xcrash { struct list_head_xcrash *next; } parsed; struct list_head_xcrash raw; struct loc { struct pos_t { struct parsed_file *pf; int line; unsigned short column; struct dynstr { struct list_head_xcrash list; struct list_head_xcrash node_first; struct list_head_xcrash dup_list; struct node { struct list_head_xcrash list; enum node_type { nt_type=0, nt_expr=1, nt_var=2, nt_decl=3 } type; union { struct type { enum type_category { type_basic=0, type_typedef=1, type_struct=2, type_union=3, type_enum=4, type_pointer=5, type_array=6, type_func=7, type_typeof=8 } category; unsigned int flags; unsigned long btype; } t; struct expr { int op; union { long num; double f; }; } e; }; struct dynstr *str; struct node *parent; struct list_head_xcrash dup_list; struct loc loc; struct list_head_xcrash first_list; struct list_head_xcrash user_list; void *user_data; int nchild; struct list_head_xcrash child[]; } *cpp_cond; struct macro_exp { int refcount; struct hashed_macro { struct hashed_macro *next; char *name; struct list_head_xcrash params; int nparams; struct node *cpp_cond; struct loc loc; int undef; int hidden; int hasparam; int isparam; int noexpand; int variadic; } *hm; struct dynstr *first; struct dynstr *exp_first; struct { struct dynstr *first; } params[]; } *exp; int token; int refcount; union dynstr_flags_t { struct { int fake; int macro; }; unsigned int val; } flags; unsigned long len; char text[]; } *text; } first; struct loc *parent; } loc; int clean; } *

user_defined_types: struct loc { struct pos_t first; struct loc *parent; }


decompiled_code:
_BOOL8 __fastcall ind_is_pointer(char a1)
{
return (a1 & 0xFD) == 0xFD;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(char a1)
{
return (a1 & 0xFD) == 0xFD;
}

original_code:
static inline int
ind_is_pointer(ind_t ind)
{
 return (ind == ind_pointer || ind == ind_implicit);
}

canonical_original_code:
static inline int ind_is_pointer(char ind)
{
 return (ind == ind_pointer || ind == ind_implicit);
}

variable_types: ind char