yyparse

decompiled_code:
__int64 yyparse()
{
const char **v0; // rbx
unsigned __int64 v1; // r12
char *v2; // rbp
char *i; // r15
unsigned __int64 v4; // rax
signed __int64 v5; // rbx
char *v6; // rax
char *v7; // r13
void *v8; // rax
size_t v9; // rdx
size_t v10; // r10
unsigned __int64 v11; // rbp
__int64 v12; // r14
unsigned int v13; // er13
unsigned int v14; // er10
int v15; // eax
int v16; // er11
int v17; // ecx
int v18; // eax
size_t v19; // r11
unsigned __int8 v20; // r14
const char *v21; // r13
__int64 v22; // rax
int v23; // esi
unsigned int v24; // er13
int v25; // er13
int v26; // edx
int v27; // esi
__int64 v28; // rax
char *v30; // r14
unsigned int v31; // er12
int v32; // ecx
const char **v33; // r14
int v34; // esi
__int64 v35; // rdx
unsigned int v36; // eax
int v37; // [rsp+0h] [rbp-828h]
unsigned int v38; // [rsp+0h] [rbp-828h]
int v39; // [rsp+0h] [rbp-828h]
size_t v40; // [rsp+0h] [rbp-828h]
int v41; // [rsp+0h] [rbp-828h]
int v42; // [rsp+0h] [rbp-828h]
int v43; // [rsp+0h] [rbp-828h]
size_t v44; // [rsp+0h] [rbp-828h]
size_t v45; // [rsp+0h] [rbp-828h]
size_t v46; // [rsp+0h] [rbp-828h]
size_t v47; // [rsp+0h] [rbp-828h]
size_t v48; // [rsp+0h] [rbp-828h]
size_t v49; // [rsp+0h] [rbp-828h]
size_t v50; // [rsp+0h] [rbp-828h]
size_t v51; // [rsp+0h] [rbp-828h]
size_t v52; // [rsp+0h] [rbp-828h]
size_t v53; // [rsp+0h] [rbp-828h]
size_t v54; // [rsp+0h] [rbp-828h]
size_t v55; // [rsp+0h] [rbp-828h]
size_t v56; // [rsp+0h] [rbp-828h]
size_t v57; // [rsp+0h] [rbp-828h]
size_t v58; // [rsp+0h] [rbp-828h]
size_t v59; // [rsp+0h] [rbp-828h]
size_t v60; // [rsp+0h] [rbp-828h]
size_t v61; // [rsp+0h] [rbp-828h]
size_t v62; // [rsp+0h] [rbp-828h]
size_t v63; // [rsp+0h] [rbp-828h]
size_t v64; // [rsp+0h] [rbp-828h]
size_t v65; // [rsp+0h] [rbp-828h]
char *v66; // [rsp+8h] [rbp-820h]
void *v67; // [rsp+8h] [rbp-820h]
int v68; // [rsp+14h] [rbp-814h]
signed __int64 v69; // [rsp+18h] [rbp-810h]
char src[400]; // [rsp+20h] [rbp-808h] BYREF
char v71[1656]; // [rsp+1B0h] [rbp-678h] BYREF

if ( yydebug )
fwrite("Starting parse\n", 1uLL, 0xFuLL, stderr);
v0 = (const char **)v71;
yynerrs = 0;
v66 = v71;
v1 = 200LL;
v2 = src;
yychar = -2;
v68 = 0;
v37 = 0;
for ( i = src; ; i += 2 )
{
*(_WORD *)i = v37;
v4 = 2 * v1;
if ( i < &v2[2 * v1 - 2] )
goto LABEL_50;
v5 = i - v2;
if ( v1 > 0x270F )
goto LABEL_110;
v1 = 10000LL;
if ( v4 <= 0x2710 )
v1 = v4;
v6 = (char *)malloc(10 * v1 + 7);
v7 = v6;
if ( !v6 )
{
LABEL_110:
v30 = i;
v31 = 2;
yyerror();
goto LABEL_53;
}
memcpy(v6, v2, v5 + 2);
v69 = 8 * (((i - v2) >> 1) + 1);
v8 = memcpy(&v7[2 * v1], v66, v69);
v9 = v69;
v10 = (size_t)v8;
if ( v2 != src )
{
v69 = (signed __int64)v8;
v67 = (void *)v9;
free(v2);
v10 = v69;
v9 = (size_t)v67;
}
i = &v7[v5];
v11 = (unsigned __int64)&v7[2 * v1 - 2];
v0 = (const char **)(v10 + v9 - 8);
if ( yydebug )
break;
if ( (unsigned __int64)i >= v11 )
{
v22 = yychar;
v30 = i;
v2 = v7;
v31 = 1;
if ( yychar == -2 )
goto LABEL_59;
goto LABEL_54;
}
v66 = (char *)v10;
v2 = v7;
LABEL_14:
if ( v37 == 41 )
{
v30 = i;
v31 = 0;
goto LABEL_53;
}
v12 = v37;
v13 = yypact[v37];
v14 = v13;
if ( v13 == -63 )
goto LABEL_29;
v15 = yychar;
if ( yychar == -2 )
{
if ( yydebug )
{
fwrite("Reading a token: ", 1uLL, 0x11uLL, stderr);
v14 = v13;
}
v38 = v14;
v15 = yylex();
v14 = v38;
yychar = v15;
}
if ( v15 <= 0 )
{
yychar = 0;
v16 = 0;
if ( yydebug )
{
LODWORD(v69) = v14;
fwrite("Now at end of input.\n", 1uLL, 0x15uLL, stderr);
v16 = 0;
v14 = v69;
}
}
else
{
v16 = 2;
if ( v15 <= 273 )
v16 = (unsigned __int8)yytranslate[v15];
v14 = v13 + v16;
if ( yydebug )
{
v42 = v16;
LODWORD(v69) = v13 + v16;
fprintf(stderr, "%s ", "Next token is");
yy_symbol_print_constprop_0(stderr, v42);
fputc(10, stderr);
v14 = v69;
v16 = v42;
}
}
if ( v14 > 0xFB || yycheck[v14] != v16 )
{
LABEL_29:
v18 = (unsigned __int8)yydefact[v12];
if ( yydefact[v12] )
goto LABEL_27;
}
else
{
v17 = yytable[v14];
if ( v17 > 0 )
{
v68 = (v68 == 0) + v68 - 1;
if ( yydebug )
{
LODWORD(v69) = yytable[v14];
v43 = v16;
fprintf(stderr, "%s ", "Shifting");
yy_symbol_print_constprop_0(stderr, v43);
fputc(10, stderr);
v17 = v69;
}
v37 = v17;
++v0;
yychar = -2;
*v0 = (const char *)yylval;
continue;
}
if ( v17 != -43 )
{
v18 = -v17;
LABEL_27:
v19 = v18;
v20 = yyr2[v18];
v21 = v0[1 - v20];
if ( yydebug )
{
v69 = v18;
v39 = v18;
yy_reduce_print_isra_0((__int64)i, v18);
v19 = v69;
switch ( v39 )
{
case 18:
LABEL_80:
v40 = v19;
printf("line %d: declared '%s'\n", yylineno, *v0);
v19 = v40;
break;
case 19:
LABEL_98:
v56 = v19;
printf("line %d: scalar declared '%s' and assigned to '%s'\n", yylineno, *(v0 - 2), *v0);
v19 = v56;
break;
case 20:
LABEL_97:
v55 = v19;
printf("line %d: array declared '%s'\n", yylineno, *(v0 - 2));
v19 = v55;
break;
case 21:
LABEL_96:
v54 = v19;
printf("line %d: hash declared '%s'\n", yylineno, *(v0 - 2));
v19 = v54;
break;
case 22:
LABEL_95:
v53 = v19;
printf("line %d: function '%s' defined\n", yylineno, *(v0 - 4));
v19 = v53;
break;
case 36:
LABEL_94:
v52 = v19;
printf("line %d: array %s[], index %i\n", yylineno, *(v0 - 3), *((unsigned int *)v0 - 2));
v19 = v52;
break;
case 37:
LABEL_93:
v51 = v19;
printf("line %d: hash %s{}, indexed by expression\n", yylineno, *(v0 - 3));
v19 = v51;
break;
case 38:
LABEL_92:
v50 = v19;
printf("line %d: addition\n", yylineno);
v19 = v50;
break;
case 39:
LABEL_86:
v44 = v19;
printf("line %d: subtraction\n", yylineno);
v19 = v44;
break;
case 40:
LABEL_107:
v65 = v19;
printf("line %d: multiplication\n", yylineno);
v19 = v65;
break;
case 41:
LABEL_106:
v64 = v19;
printf("line %d: division\n", yylineno);
v19 = v64;
break;
case 42:
LABEL_105:
v63 = v19;
printf("line %d: unary minus\n", yylineno);
v19 = v63;
break;
case 43:
LABEL_104:
v62 = v19;
printf("line %d: less than\n", yylineno);
v19 = v62;
break;
case 44:
LABEL_103:
v61 = v19;
printf("line %d: more than\n", yylineno);
v19 = v61;
break;
case 45:
LABEL_102:
v60 = v19;
printf("line %d: less than or equal\n", yylineno);
v19 = v60;
break;
case 46:
LABEL_101:
v59 = v19;
printf("line %d: more than or equal\n", yylineno);
v19 = v59;
break;
case 47:
LABEL_90:
v48 = v19;
printf("line %d: equal\n", yylineno);
v19 = v48;
break;
case 48:
LABEL_89:
v47 = v19;
printf("line %d: not equal\n", yylineno);
v19 = v47;
break;
case 49:
LABEL_88:
v46 = v19;
printf("line %d: approximate equall\n", yylineno);
v19 = v46;
break;
case 50:
LABEL_87:
v45 = v19;
printf("line %d: unary negation\n", yylineno);
v19 = v45;
break;
case 52:
LABEL_100:
v58 = v19;
printf("line %d: string concatenation\n", yylineno);
v19 = v58;
break;
case 53:
LABEL_99:
v57 = v19;
printf("line %d: function %s() call\n", yylineno, *(v0 - 3));
v19 = v57;
break;
case 58:
LABEL_91:
v49 = v19;
printf("line %d: if1\n", yylineno);
v19 = v49;
break;
default:
break;
}
v32 = (unsigned __int8)yyr1[v19];
i -= 2 * v20;
v33 = &v0[-v20];
if ( yydebug )
{
v41 = (unsigned __int8)yyr1[v19];
fprintf(stderr, "%s ", "-> $$ =");
yy_symbol_print_constprop_0(stderr, v41);
fputc(10, stderr);
v32 = v41;
if ( yydebug )
{
yy_stack_print((__int16 *)v2, (unsigned __int64)i);
v32 = v41;
}
}
}
else
{
switch ( v18 )
{
case 18:
goto LABEL_80;
case 19:
goto LABEL_98;
case 20:
goto LABEL_97;
case 21:
goto LABEL_96;
case 22:
goto LABEL_95;
case 36:
goto LABEL_94;
case 37:
goto LABEL_93;
case 38:
goto LABEL_92;
case 39:
goto LABEL_86;
case 40:
goto LABEL_107;
case 41:
goto LABEL_106;
case 42:
goto LABEL_105;
case 43:
goto LABEL_104;
case 44:
goto LABEL_103;
case 45:
goto LABEL_102;
case 46:
goto LABEL_101;
case 47:
goto LABEL_90;
case 48:
goto LABEL_89;
case 49:
goto LABEL_88;
case 50:
goto LABEL_87;
case 52:
goto LABEL_100;
case 53:
goto LABEL_99;
case 58:
goto LABEL_91;
default:
v32 = (unsigned __int8)yyr1[v18];
i -= 2 * v20;
v33 = &v0[-v20];
break;
}
}
v34 = *(__int16 *)i;
v33[1] = v21;
v0 = v33 + 1;
v35 = v32 - 36;
v36 = v34 + yypgoto[v35];
if ( v36 <= 0xFB && (_WORD)v34 == yycheck[v36] )
v37 = yytable[v36];
else
v37 = yydefgoto[v35];
continue;
}
}
v22 = yychar;
v23 = -2;
if ( yychar == -2 || (v23 = 2, (unsigned int)yychar > 0x111) )
{
if ( !v68 )
goto LABEL_69;
}
else
{
v23 = (unsigned __int8)yytranslate[yychar];
if ( !v68 )
{
LABEL_69:
++yynerrs;
yyerror();
goto LABEL_38;
}
}
if ( v68 == 3 )
{
if ( yychar > 0 )
{
yydestruct_isra_0("Error: discarding", v23);
yychar = -2;
goto LABEL_38;
}
if ( !yychar )
{
v30 = i;
v31 = 1;
goto LABEL_70;
}
}
LABEL_38:
while ( 1 )
{
if ( v13 != -63 )
{
v24 = v13 + 1;
if ( v24 <= 0xFB && yycheck[v24] == 1 )
{
v25 = yytable[v24];
if ( v25 > 0 )
break;
}
}
if ( i == v2 )
{
v30 = i;
v31 = 1;
goto LABEL_53;
}
i -= 2;
--v0;
yydestruct_isra_0("Error: popping", (unsigned __int8)yystos[v12]);
v12 = *(__int16 *)i;
if ( yydebug )
yy_stack_print((__int16 *)v2, (unsigned __int64)i);
v13 = yypact[v12];
}
v26 = yydebug;
v0[1] = (const char *)yylval;
if ( v26 )
{
++v0;
fprintf(stderr, "%s ", "Shifting");
yy_symbol_print_constprop_0(stderr, (unsigned __int8)yystos[v25]);
fputc(10, stderr);
v37 = v25;
}
else
{
v37 = v25;
++v0;
}
v68 = 3;
}
v66 = (char *)v10;
fprintf(stderr, "Stack size increased to %lu\n", v1);
if ( (unsigned __int64)i < v11 )
{
v2 = v7;
LABEL_50:
if ( yydebug )
fprintf(stderr, "Entering state %d\n", (unsigned int)v37);
goto LABEL_14;
}
v30 = i;
v2 = v7;
v31 = 1;
LABEL_53:
v22 = yychar;
if ( yychar == -2 )
goto LABEL_56;
LABEL_54:
v27 = 2;
if ( (unsigned int)v22 > 0x111 )
goto LABEL_55;
LABEL_70:
v27 = (unsigned __int8)yytranslate[v22];
LABEL_55:
yydestruct_isra_0("Cleanup: discarding lookahead", v27);
LABEL_56:
if ( yydebug )
yy_stack_print((__int16 *)v2, (unsigned __int64)v30);
LABEL_59:
while ( v30 != v2 )
{
v28 = *(__int16 *)v30;
v30 -= 2;
yydestruct_isra_0("Cleanup: popping", (unsigned __int8)yystos[v28]);
}
if ( v2 != src )
free(v2);
return v31;
}

canonical_decompiled_code:
__int64 func5()
{
const char **v0; // rbx
unsigned __int64 v1; // r12
char *v2; // rbp
char *i; // r15
unsigned __int64 v4; // rax
signed __int64 v5; // rbx
char *v6; // rax
char *v7; // r13
void *v8; // rax
size_t v9; // rdx
size_t v10; // r10
unsigned __int64 v11; // rbp
__int64 v12; // r14
unsigned int v13; // er13
unsigned int v14; // er10
int v15; // eax
int v16; // er11
int v17; // ecx
int v18; // eax
size_t v19; // r11
unsigned __int8 v20; // r14
const char *v21; // r13
__int64 v22; // rax
int v23; // esi
unsigned int v24; // er13
int v25; // er13
int v26; // edx
int v27; // esi
__int64 v28; // rax
char *v30; // r14
unsigned int v31; // er12
int v32; // ecx
const char **v33; // r14
int v34; // esi
__int64 v35; // rdx
unsigned int v36; // eax
int v37; // [rsp+0h] [rbp-828h]
unsigned int v38; // [rsp+0h] [rbp-828h]
int v39; // [rsp+0h] [rbp-828h]
size_t v40; // [rsp+0h] [rbp-828h]
int v41; // [rsp+0h] [rbp-828h]
int v42; // [rsp+0h] [rbp-828h]
int v43; // [rsp+0h] [rbp-828h]
size_t v44; // [rsp+0h] [rbp-828h]
size_t v45; // [rsp+0h] [rbp-828h]
size_t v46; // [rsp+0h] [rbp-828h]
size_t v47; // [rsp+0h] [rbp-828h]
size_t v48; // [rsp+0h] [rbp-828h]
size_t v49; // [rsp+0h] [rbp-828h]
size_t v50; // [rsp+0h] [rbp-828h]
size_t v51; // [rsp+0h] [rbp-828h]
size_t v52; // [rsp+0h] [rbp-828h]
size_t v53; // [rsp+0h] [rbp-828h]
size_t v54; // [rsp+0h] [rbp-828h]
size_t v55; // [rsp+0h] [rbp-828h]
size_t v56; // [rsp+0h] [rbp-828h]
size_t v57; // [rsp+0h] [rbp-828h]
size_t v58; // [rsp+0h] [rbp-828h]
size_t v59; // [rsp+0h] [rbp-828h]
size_t v60; // [rsp+0h] [rbp-828h]
size_t v61; // [rsp+0h] [rbp-828h]
size_t v62; // [rsp+0h] [rbp-828h]
size_t v63; // [rsp+0h] [rbp-828h]
size_t v64; // [rsp+0h] [rbp-828h]
size_t v65; // [rsp+0h] [rbp-828h]
char *v66; // [rsp+8h] [rbp-820h]
void *v67; // [rsp+8h] [rbp-820h]
int v68; // [rsp+14h] [rbp-814h]
signed __int64 v69; // [rsp+18h] [rbp-810h]
char src[400]; // [rsp+20h] [rbp-808h] BYREF
char v71[1656]; // [rsp+1B0h] [rbp-678h] BYREF

if ( yydebug )
fwrite("Starting parse\n", 1uLL, 0xFuLL, stderr);
v0 = (const char **)v71;
yynerrs = 0;
v66 = v71;
v1 = 200LL;
v2 = src;
yychar = -2;
v68 = 0;
v37 = 0;
for ( i = src; ; i += 2 )
{
*(_WORD *)i = v37;
v4 = 2 * v1;
if ( i < &v2[2 * v1 - 2] )
goto LABEL_50;
v5 = i - v2;
if ( v1 > 0x270F )
goto LABEL_110;
v1 = 10000LL;
if ( v4 <= 0x2710 )
v1 = v4;
v6 = (char *)malloc(10 * v1 + 7);
v7 = v6;
if ( !v6 )
{
LABEL_110:
v30 = i;
v31 = 2;
func4();
goto LABEL_53;
}
memcpy(v6, v2, v5 + 2);
v69 = 8 * (((i - v2) >> 1) + 1);
v8 = memcpy(&v7[2 * v1], v66, v69);
v9 = v69;
v10 = (size_t)v8;
if ( v2 != src )
{
v69 = (signed __int64)v8;
v67 = (void *)v9;
free(v2);
v10 = v69;
v9 = (size_t)v67;
}
i = &v7[v5];
v11 = (unsigned __int64)&v7[2 * v1 - 2];
v0 = (const char **)(v10 + v9 - 8);
if ( yydebug )
break;
if ( (unsigned __int64)i >= v11 )
{
v22 = yychar;
v30 = i;
v2 = v7;
v31 = 1;
if ( yychar == -2 )
goto LABEL_59;
goto LABEL_54;
}
v66 = (char *)v10;
v2 = v7;
LABEL_14:
if ( v37 == 41 )
{
v30 = i;
v31 = 0;
goto LABEL_53;
}
v12 = v37;
v13 = yypact[v37];
v14 = v13;
if ( v13 == -63 )
goto LABEL_29;
v15 = yychar;
if ( yychar == -2 )
{
if ( yydebug )
{
fwrite("Reading a token: ", 1uLL, 0x11uLL, stderr);
v14 = v13;
}
v38 = v14;
v15 = yylex();
v14 = v38;
yychar = v15;
}
if ( v15 <= 0 )
{
yychar = 0;
v16 = 0;
if ( yydebug )
{
LODWORD(v69) = v14;
fwrite("Now at end of input.\n", 1uLL, 0x15uLL, stderr);
v16 = 0;
v14 = v69;
}
}
else
{
v16 = 2;
if ( v15 <= 273 )
v16 = (unsigned __int8)yytranslate[v15];
v14 = v13 + v16;
if ( yydebug )
{
v42 = v16;
LODWORD(v69) = v13 + v16;
fprintf(stderr, "%s ", "Next token is");
func1(stderr, v42);
fputc(10, stderr);
v14 = v69;
v16 = v42;
}
}
if ( v14 > 0xFB || yycheck[v14] != v16 )
{
LABEL_29:
v18 = (unsigned __int8)yydefact[v12];
if ( yydefact[v12] )
goto LABEL_27;
}
else
{
v17 = yytable[v14];
if ( v17 > 0 )
{
v68 = (v68 == 0) + v68 - 1;
if ( yydebug )
{
LODWORD(v69) = yytable[v14];
v43 = v16;
fprintf(stderr, "%s ", "Shifting");
func1(stderr, v43);
fputc(10, stderr);
v17 = v69;
}
v37 = v17;
++v0;
yychar = -2;
*v0 = (const char *)yylval;
continue;
}
if ( v17 != -43 )
{
v18 = -v17;
LABEL_27:
v19 = v18;
v20 = yyr2[v18];
v21 = v0[1 - v20];
if ( yydebug )
{
v69 = v18;
v39 = v18;
func3((__int64)i, v18);
v19 = v69;
switch ( v39 )
{
case 18:
LABEL_80:
v40 = v19;
printf("line %d: declared '%s'\n", yylineno, *v0);
v19 = v40;
break;
case 19:
LABEL_98:
v56 = v19;
printf("line %d: scalar declared '%s' and assigned to '%s'\n", yylineno, *(v0 - 2), *v0);
v19 = v56;
break;
case 20:
LABEL_97:
v55 = v19;
printf("line %d: array declared '%s'\n", yylineno, *(v0 - 2));
v19 = v55;
break;
case 21:
LABEL_96:
v54 = v19;
printf("line %d: hash declared '%s'\n", yylineno, *(v0 - 2));
v19 = v54;
break;
case 22:
LABEL_95:
v53 = v19;
printf("line %d: function '%s' defined\n", yylineno, *(v0 - 4));
v19 = v53;
break;
case 36:
LABEL_94:
v52 = v19;
printf("line %d: array %s[], index %i\n", yylineno, *(v0 - 3), *((unsigned int *)v0 - 2));
v19 = v52;
break;
case 37:
LABEL_93:
v51 = v19;
printf("line %d: hash %s{}, indexed by expression\n", yylineno, *(v0 - 3));
v19 = v51;
break;
case 38:
LABEL_92:
v50 = v19;
printf("line %d: addition\n", yylineno);
v19 = v50;
break;
case 39:
LABEL_86:
v44 = v19;
printf("line %d: subtraction\n", yylineno);
v19 = v44;
break;
case 40:
LABEL_107:
v65 = v19;
printf("line %d: multiplication\n", yylineno);
v19 = v65;
break;
case 41:
LABEL_106:
v64 = v19;
printf("line %d: division\n", yylineno);
v19 = v64;
break;
case 42:
LABEL_105:
v63 = v19;
printf("line %d: unary minus\n", yylineno);
v19 = v63;
break;
case 43:
LABEL_104:
v62 = v19;
printf("line %d: less than\n", yylineno);
v19 = v62;
break;
case 44:
LABEL_103:
v61 = v19;
printf("line %d: more than\n", yylineno);
v19 = v61;
break;
case 45:
LABEL_102:
v60 = v19;
printf("line %d: less than or equal\n", yylineno);
v19 = v60;
break;
case 46:
LABEL_101:
v59 = v19;
printf("line %d: more than or equal\n", yylineno);
v19 = v59;
break;
case 47:
LABEL_90:
v48 = v19;
printf("line %d: equal\n", yylineno);
v19 = v48;
break;
case 48:
LABEL_89:
v47 = v19;
printf("line %d: not equal\n", yylineno);
v19 = v47;
break;
case 49:
LABEL_88:
v46 = v19;
printf("line %d: approximate equall\n", yylineno);
v19 = v46;
break;
case 50:
LABEL_87:
v45 = v19;
printf("line %d: unary negation\n", yylineno);
v19 = v45;
break;
case 52:
LABEL_100:
v58 = v19;
printf("line %d: string concatenation\n", yylineno);
v19 = v58;
break;
case 53:
LABEL_99:
v57 = v19;
printf("line %d: function %s() call\n", yylineno, *(v0 - 3));
v19 = v57;
break;
case 58:
LABEL_91:
v49 = v19;
printf("line %d: if1\n", yylineno);
v19 = v49;
break;
default:
break;
}
v32 = (unsigned __int8)yyr1[v19];
i -= 2 * v20;
v33 = &v0[-v20];
if ( yydebug )
{
v41 = (unsigned __int8)yyr1[v19];
fprintf(stderr, "%s ", "-> $$ =");
func1(stderr, v41);
fputc(10, stderr);
v32 = v41;
if ( yydebug )
{
func0((__int16 *)v2, (unsigned __int64)i);
v32 = v41;
}
}
}
else
{
switch ( v18 )
{
case 18:
goto LABEL_80;
case 19:
goto LABEL_98;
case 20:
goto LABEL_97;
case 21:
goto LABEL_96;
case 22:
goto LABEL_95;
case 36:
goto LABEL_94;
case 37:
goto LABEL_93;
case 38:
goto LABEL_92;
case 39:
goto LABEL_86;
case 40:
goto LABEL_107;
case 41:
goto LABEL_106;
case 42:
goto LABEL_105;
case 43:
goto LABEL_104;
case 44:
goto LABEL_103;
case 45:
goto LABEL_102;
case 46:
goto LABEL_101;
case 47:
goto LABEL_90;
case 48:
goto LABEL_89;
case 49:
goto LABEL_88;
case 50:
goto LABEL_87;
case 52:
goto LABEL_100;
case 53:
goto LABEL_99;
case 58:
goto LABEL_91;
default:
v32 = (unsigned __int8)yyr1[v18];
i -= 2 * v20;
v33 = &v0[-v20];
break;
}
}
v34 = *(__int16 *)i;
v33[1] = v21;
v0 = v33 + 1;
v35 = v32 - 36;
v36 = v34 + yypgoto[v35];
if ( v36 <= 0xFB && (_WORD)v34 == yycheck[v36] )
v37 = yytable[v36];
else
v37 = yydefgoto[v35];
continue;
}
}
v22 = yychar;
v23 = -2;
if ( yychar == -2 || (v23 = 2, (unsigned int)yychar > 0x111) )
{
if ( !v68 )
goto LABEL_69;
}
else
{
v23 = (unsigned __int8)yytranslate[yychar];
if ( !v68 )
{
LABEL_69:
++yynerrs;
func4();
goto LABEL_38;
}
}
if ( v68 == 3 )
{
if ( yychar > 0 )
{
func2("Error: discarding", v23);
yychar = -2;
goto LABEL_38;
}
if ( !yychar )
{
v30 = i;
v31 = 1;
goto LABEL_70;
}
}
LABEL_38:
while ( 1 )
{
if ( v13 != -63 )
{
v24 = v13 + 1;
if ( v24 <= 0xFB && yycheck[v24] == 1 )
{
v25 = yytable[v24];
if ( v25 > 0 )
break;
}
}
if ( i == v2 )
{
v30 = i;
v31 = 1;
goto LABEL_53;
}
i -= 2;
--v0;
func2("Error: popping", (unsigned __int8)yystos[v12]);
v12 = *(__int16 *)i;
if ( yydebug )
func0((__int16 *)v2, (unsigned __int64)i);
v13 = yypact[v12];
}
v26 = yydebug;
v0[1] = (const char *)yylval;
if ( v26 )
{
++v0;
fprintf(stderr, "%s ", "Shifting");
func1(stderr, (unsigned __int8)yystos[v25]);
fputc(10, stderr);
v37 = v25;
}
else
{
v37 = v25;
++v0;
}
v68 = 3;
}
v66 = (char *)v10;
fprintf(stderr, "Stack size increased to %lu\n", v1);
if ( (unsigned __int64)i < v11 )
{
v2 = v7;
LABEL_50:
if ( yydebug )
fprintf(stderr, "Entering state %d\n", (unsigned int)v37);
goto LABEL_14;
}
v30 = i;
v2 = v7;
v31 = 1;
LABEL_53:
v22 = yychar;
if ( yychar == -2 )
goto LABEL_56;
LABEL_54:
v27 = 2;
if ( (unsigned int)v22 > 0x111 )
goto LABEL_55;
LABEL_70:
v27 = (unsigned __int8)yytranslate[v22];
LABEL_55:
func2("Cleanup: discarding lookahead", v27);
LABEL_56:
if ( yydebug )
func0((__int16 *)v2, (unsigned __int64)v30);
LABEL_59:
while ( v30 != v2 )
{
v28 = *(__int16 *)v30;
v30 -= 2;
func2("Cleanup: popping", (unsigned __int8)yystos[v28]);
}
if ( v2 != src )
free(v2);
return v31;
}

original_code:
int
yyparse (void)
{
    int yystate;
    int yyerrstatus;
    yytype_int16 yyssa[200];
    yytype_int16 *yyss;
    yytype_int16 *yyssp;
    YYSTYPE yyvsa[200];
    YYSTYPE *yyvs;
    YYSTYPE *yyvsp;
    long unsigned int yystacksize;
  int yyn;
  int yyresult;
  int yytoken = 0;
  YYSTYPE yyval;
  int yylen = 0;
  yyssp = yyss = yyssa;
  yyvsp = yyvs = yyvsa;
  yystacksize = 200;
  do { if (yydebug) fprintf (stderr, "Starting parse\n"); } while (0);
  yystate = 0;
  yyerrstatus = 0;
  yynerrs = 0;
  yychar = (-2);
  goto yysetstate;
yynewstate:
  yyssp++;
yysetstate:
  *yyssp = (yytype_int16) yystate;
  if (yyss + yystacksize - 1 <= yyssp)
    {
      long unsigned int yysize = (long unsigned int) (yyssp - yyss + 1);
      if (10000 <= yystacksize)
        goto yyexhaustedlab;
      yystacksize *= 2;
      if (10000 < yystacksize)
        yystacksize = 10000;
      {
        yytype_int16 *yyss1 = yyss;
        union yyalloc *yyptr =
          (union yyalloc *) malloc (((yystacksize) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) + (sizeof (union yyalloc) - 1)));
        if (! yyptr)
          goto yyexhaustedlab;
        do { long unsigned int yynewbytes; __builtin_memcpy (&yyptr->yyss_alloc, yyss, (yysize) * sizeof (*(yyss))); yyss = &yyptr->yyss_alloc; yynewbytes = yystacksize * sizeof (*yyss) + (sizeof (union yyalloc) - 1); yyptr += yynewbytes / sizeof (*yyptr); } while (0);
        do { long unsigned int yynewbytes; __builtin_memcpy (&yyptr->yyvs_alloc, yyvs, (yysize) * sizeof (*(yyvs))); yyvs = &yyptr->yyvs_alloc; yynewbytes = yystacksize * sizeof (*yyvs) + (sizeof (union yyalloc) - 1); yyptr += yynewbytes / sizeof (*yyptr); } while (0);
        if (yyss1 != yyssa)
          free (yyss1);
      }
      yyssp = yyss + yysize - 1;
      yyvsp = yyvs + yysize - 1;
      do { if (yydebug) fprintf (stderr, "Stack size increased to %lu\n", (unsigned long) yystacksize); } while (0);
      if (yyss + yystacksize - 1 <= yyssp)
        goto yyabortlab;
    }
  do { if (yydebug) fprintf (stderr, "Entering state %d\n", yystate); } while (0);
  if (yystate == 41)
    goto yyacceptlab;
  goto yybackup;
yybackup:
  yyn = yypact[yystate];
  if ((!!((yyn) == (-63))))
    goto yydefault;
  if (yychar == (-2))
    {
      do { if (yydebug) fprintf (stderr, "Reading a token: "); } while (0);
      yychar = yylex ();
    }
  if (yychar <= 0)
    {
      yychar = yytoken = 0;
      do { if (yydebug) fprintf (stderr, "Now at end of input.\n"); } while (0);
    }
  else
    {
      yytoken = ((unsigned) (yychar) <= 273 ? yytranslate[yychar] : 2);
      do { if (yydebug) { fprintf (stderr, "%s ", "Next token is"); yy_symbol_print (stderr, yytoken, &yylval); fprintf (stderr, "\n"); } } while (0);
    }
  yyn += yytoken;
  if (yyn < 0 || 251 < yyn || yycheck[yyn] != yytoken)
    goto yydefault;
  yyn = yytable[yyn];
  if (yyn <= 0)
    {
      if ((!!((yyn) == (-43))))
        goto yyerrlab;
      yyn = -yyn;
      goto yyreduce;
    }
  if (yyerrstatus)
    yyerrstatus--;
  do { if (yydebug) { fprintf (stderr, "%s ", "Shifting"); yy_symbol_print (stderr, yytoken, &yylval); fprintf (stderr, "\n"); } } while (0);
  yychar = (-2);
  yystate = yyn;

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yyvsp = yylval;

#pragma GCC diagnostic pop

  goto yynewstate;
yydefault:
  yyn = yydefact[yystate];
  if (yyn == 0)
    goto yyerrlab;
  goto yyreduce;
yyreduce:
  yylen = yyr2[yyn];
  yyval = yyvsp[1-yylen];
  do { if (yydebug) yy_reduce_print (yyssp, yyvsp, yyn); } while (0);
  switch (yyn)
    {
        case 18:
    {printf("line %d: declared '%s'\n", yylineno, (yyvsp[0].s)); }
    break;
  case 19:
    {printf("line %d: scalar declared '%s' and assigned to '%s'\n", yylineno, (yyvsp[-2].s), (yyvsp[0].s));}
    break;
  case 20:
    {printf("line %d: array declared '%s'\n", yylineno, (yyvsp[-2].s));}
    break;
  case 21:
    {printf("line %d: hash declared '%s'\n", yylineno, (yyvsp[-2].s));}
    break;
  case 22:
    {printf("line %d: function '%s' defined\n", yylineno, (yyvsp[-4].s));}
    break;
  case 36:
    {printf("line %d: array %s[], index %i\n", yylineno, (yyvsp[-3].s), (yyvsp[-1].i));}
    break;
  case 37:
    {printf("line %d: hash %s{}, indexed by expression\n", yylineno, (yyvsp[-3].s));}
    break;
  case 38:
    {printf("line %d: addition\n", yylineno);}
    break;
  case 39:
    {printf("line %d: subtraction\n", yylineno);}
    break;
  case 40:
    {printf("line %d: multiplication\n", yylineno);}
    break;
  case 41:
    {printf("line %d: division\n", yylineno);}
    break;
  case 42:
    {printf("line %d: unary minus\n", yylineno);}
    break;
  case 43:
    {printf("line %d: less than\n", yylineno);}
    break;
  case 44:
    {printf("line %d: more than\n", yylineno);}
    break;
  case 45:
    {printf("line %d: less than or equal\n", yylineno);}
    break;
  case 46:
    {printf("line %d: more than or equal\n", yylineno);}
    break;
  case 47:
    {printf("line %d: equal\n", yylineno);}
    break;
  case 48:
    {printf("line %d: not equal\n", yylineno);}
    break;
  case 49:
    {printf("line %d: approximate equall\n", yylineno);}
    break;
  case 50:
    {printf("line %d: unary negation\n", yylineno);}
    break;
  case 52:
    {printf("line %d: string concatenation\n", yylineno);}
    break;
  case 53:
    {printf("line %d: function %s() call\n", yylineno, (yyvsp[-3].s));}
    break;
  case 58:
    {printf("line %d: if1\n", yylineno);}
    break;
      default: break;
    }
  do { if (yydebug) { fprintf (stderr, "%s ", "-> $$ ="); yy_symbol_print (stderr, yyr1[yyn], &yyval); fprintf (stderr, "\n"); } } while (0);
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  do { if (yydebug) yy_stack_print ((yyss), (yyssp)); } while (0);
  *++yyvsp = yyval;
  {
    const int yylhs = yyr1[yyn] - 36;
    const int yyi = yypgoto[yylhs] + *yyssp;
    yystate = (0 <= yyi && yyi <= 251 && yycheck[yyi] == *yyssp
               ? yytable[yyi]
               : yydefgoto[yylhs]);
  }
  goto yynewstate;
yyerrlab:
  yytoken = yychar == (-2) ? (-2) : ((unsigned) (yychar) <= 273 ? yytranslate[yychar] : 2);
  if (!yyerrstatus)
    {
      ++yynerrs;
      yyerror ("syntax error");
    }
  if (yyerrstatus == 3)
    {
      if (yychar <= 0)
        {
          if (yychar == 0)
            goto yyabortlab;
        }
      else
        {
          yydestruct ("Error: discarding",
                      yytoken, &yylval);
          yychar = (-2);
        }
    }
  goto yyerrlab1;
yyerrorlab:
  if (0)
    goto yyerrorlab;
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  do { if (yydebug) yy_stack_print ((yyss), (yyssp)); } while (0);
  yystate = *yyssp;
  goto yyerrlab1;
yyerrlab1:
  yyerrstatus = 3;
  for (;;)
    {
      yyn = yypact[yystate];
      if (!(!!((yyn) == (-63))))
        {
          yyn += 1;
          if (0 <= yyn && yyn <= 251 && yycheck[yyn] == 1)
            {
              yyn = yytable[yyn];
              if (0 < yyn)
                break;
            }
        }
      if (yyssp == yyss)
        goto yyabortlab;
      yydestruct ("Error: popping",
                  yystos[yystate], yyvsp);
      (yyvsp -= (1), yyssp -= (1));
      yystate = *yyssp;
      do { if (yydebug) yy_stack_print ((yyss), (yyssp)); } while (0);
    }

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yyvsp = yylval;

#pragma GCC diagnostic pop

  do { if (yydebug) { fprintf (stderr, "%s ", "Shifting"); yy_symbol_print (stderr, yystos[yyn], yyvsp); fprintf (stderr, "\n"); } } while (0);
  yystate = yyn;
  goto yynewstate;
yyacceptlab:
  yyresult = 0;
  goto yyreturn;
yyabortlab:
  yyresult = 1;
  goto yyreturn;
yyexhaustedlab:
  yyerror ("memory exhausted");
  yyresult = 2;
yyreturn:
  if (yychar != (-2))
    {
      yytoken = ((unsigned) (yychar) <= 273 ? yytranslate[yychar] : 2);
      yydestruct ("Cleanup: discarding lookahead",
                  yytoken, &yylval);
    }
  (yyvsp -= (yylen), yyssp -= (yylen));
  do { if (yydebug) yy_stack_print ((yyss), (yyssp)); } while (0);
  while (yyssp != yyss)
    {
      yydestruct ("Cleanup: popping",
                  yystos[*yyssp], yyvsp);
      (yyvsp -= (1), yyssp -= (1));
    }
  if (yyss != yyssa)
    free (yyss);
  return yyresult;
}

canonical_original_code:
int yyparse()
{
    int yystate;
    int yyerrstatus;
    short yyssa[200];
    short *yyss;
    short *yyssp;
    union YYSTYPE yyvsa[200];
    union YYSTYPE *yyvs;
    union YYSTYPE *yyvsp;
    unsigned long yystacksize;
  int yyn;
  int yyresult;
  int yytoken = 0;
  union YYSTYPE yyval;
  int yylen = 0;
  yyssp = yyss = yyssa;
  yyvsp = yyvs = yyvsa;
  yystacksize = 200;
  do { if (yydebug) fprintf (stderr, "Starting parse\n"); } while (0);
  yystate = 0;
  yyerrstatus = 0;
  yynerrs = 0;
  yychar = (-2);
  goto yysetstate;
yynewstate:
  yyssp++;
yysetstate:
  *yyssp = (short) yystate;
  if (yyss + yystacksize - 1 <= yyssp)
    {
      unsigned long yysize = (long unsigned int) (yyssp - yyss + 1);
      if (10000 <= yystacksize)
        goto yyexhaustedlab;
      yystacksize *= 2;
      if (10000 < yystacksize)
        yystacksize = 10000;
      {
        short *yyss1 = yyss;
        union yyalloc *yyptr = (union yyalloc *) malloc (((yystacksize) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) + (sizeof (union yyalloc) - 1)));
        if (! yyptr)
          goto yyexhaustedlab;
        do { unsigned long yynewbytes; __builtin_memcpy (&yyptr->yyss_alloc, yyss, (yysize) * sizeof (*(yyss))); yyss = &yyptr->yyss_alloc; yynewbytes = yystacksize * sizeof (*yyss) + (sizeof (union yyalloc) - 1); yyptr += yynewbytes / sizeof (*yyptr); } while (0);
        do { unsigned long yynewbytes; __builtin_memcpy (&yyptr->yyvs_alloc, yyvs, (yysize) * sizeof (*(yyvs))); yyvs = &yyptr->yyvs_alloc; yynewbytes = yystacksize * sizeof (*yyvs) + (sizeof (union yyalloc) - 1); yyptr += yynewbytes / sizeof (*yyptr); } while (0);
        if (yyss1 != yyssa)
          free (yyss1);
      }
      yyssp = yyss + yysize - 1;
      yyvsp = yyvs + yysize - 1;
      do { if (yydebug) fprintf (stderr, "Stack size increased to %lu\n", (unsigned long) yystacksize); } while (0);
      if (yyss + yystacksize - 1 <= yyssp)
        goto yyabortlab;
    }
  do { if (yydebug) fprintf (stderr, "Entering state %d\n", yystate); } while (0);
  if (yystate == 41)
    goto yyacceptlab;
  goto yybackup;
yybackup:
  yyn = yypact[yystate];
  if ((!!((yyn) == (-63))))
    goto yydefault;
  if (yychar == (-2))
    {
      do { if (yydebug) fprintf (stderr, "Reading a token: "); } while (0);
      yychar = yylex ();
    }
  if (yychar <= 0)
    {
      yychar = yytoken = 0;
      do { if (yydebug) fprintf (stderr, "Now at end of input.\n"); } while (0);
    }
  else
    {
      yytoken = ((unsigned int) (yychar) <= 273 ? yytranslate[yychar] : 2);
      do { if (yydebug) { fprintf (stderr, "%s ", "Next token is"); yy_symbol_print (stderr, yytoken, &yylval); fprintf (stderr, "\n"); } } while (0);
    }
  yyn += yytoken;
  if (yyn < 0 || 251 < yyn || yycheck[yyn] != yytoken)
    goto yydefault;
  yyn = yytable[yyn];
  if (yyn <= 0)
    {
      if ((!!((yyn) == (-43))))
        goto yyerrlab;
      yyn = -yyn;
      goto yyreduce;
    }
  if (yyerrstatus)
    yyerrstatus--;
  do { if (yydebug) { fprintf (stderr, "%s ", "Shifting"); yy_symbol_print (stderr, yytoken, &yylval); fprintf (stderr, "\n"); } } while (0);
  yychar = (-2);
  yystate = yyn;

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yyvsp = yylval;

#pragma GCC diagnostic pop

  goto yynewstate;
yydefault:
  yyn = yydefact[yystate];
  if (yyn == 0)
    goto yyerrlab;
  goto yyreduce;
yyreduce:
  yylen = yyr2[yyn];
  yyval = yyvsp[1-yylen];
  do { if (yydebug) yy_reduce_print (yyssp, yyvsp, yyn); } while (0);
  switch (yyn)
    {
        case 18:
    {printf("line %d: declared '%s'\n", yylineno, (yyvsp[0].s)); }
    break;
  case 19:
    {printf("line %d: scalar declared '%s' and assigned to '%s'\n", yylineno, (yyvsp[-2].s), (yyvsp[0].s));}
    break;
  case 20:
    {printf("line %d: array declared '%s'\n", yylineno, (yyvsp[-2].s));}
    break;
  case 21:
    {printf("line %d: hash declared '%s'\n", yylineno, (yyvsp[-2].s));}
    break;
  case 22:
    {printf("line %d: function '%s' defined\n", yylineno, (yyvsp[-4].s));}
    break;
  case 36:
    {printf("line %d: array %s[], index %i\n", yylineno, (yyvsp[-3].s), (yyvsp[-1].i));}
    break;
  case 37:
    {printf("line %d: hash %s{}, indexed by expression\n", yylineno, (yyvsp[-3].s));}
    break;
  case 38:
    {printf("line %d: addition\n", yylineno);}
    break;
  case 39:
    {printf("line %d: subtraction\n", yylineno);}
    break;
  case 40:
    {printf("line %d: multiplication\n", yylineno);}
    break;
  case 41:
    {printf("line %d: division\n", yylineno);}
    break;
  case 42:
    {printf("line %d: unary minus\n", yylineno);}
    break;
  case 43:
    {printf("line %d: less than\n", yylineno);}
    break;
  case 44:
    {printf("line %d: more than\n", yylineno);}
    break;
  case 45:
    {printf("line %d: less than or equal\n", yylineno);}
    break;
  case 46:
    {printf("line %d: more than or equal\n", yylineno);}
    break;
  case 47:
    {printf("line %d: equal\n", yylineno);}
    break;
  case 48:
    {printf("line %d: not equal\n", yylineno);}
    break;
  case 49:
    {printf("line %d: approximate equall\n", yylineno);}
    break;
  case 50:
    {printf("line %d: unary negation\n", yylineno);}
    break;
  case 52:
    {printf("line %d: string concatenation\n", yylineno);}
    break;
  case 53:
    {printf("line %d: function %s() call\n", yylineno, (yyvsp[-3].s));}
    break;
  case 58:
    {printf("line %d: if1\n", yylineno);}
    break;
      default: break;
    }
  do { if (yydebug) { fprintf (stderr, "%s ", "-> $$ ="); yy_symbol_print (stderr, yyr1[yyn], &yyval); fprintf (stderr, "\n"); } } while (0);
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  do { if (yydebug) yy_stack_print ((yyss), (yyssp)); } while (0);
  *++yyvsp = yyval;
  {
    int yylhs = yyr1[yyn] - 36;
    int yyi = yypgoto[yylhs] + *yyssp;
    yystate = (0 <= yyi && yyi <= 251 && yycheck[yyi] == *yyssp
               ? yytable[yyi]
               : yydefgoto[yylhs]);
  }
  goto yynewstate;
yyerrlab:
  yytoken = yychar == (-2) ? (-2) : ((unsigned int) (yychar) <= 273 ? yytranslate[yychar] : 2);
  if (!yyerrstatus)
    {
      ++yynerrs;
      yyerror ("syntax error");
    }
  if (yyerrstatus == 3)
    {
      if (yychar <= 0)
        {
          if (yychar == 0)
            goto yyabortlab;
        }
      else
        {
          yydestruct ("Error: discarding",
                      yytoken, &yylval);
          yychar = (-2);
        }
    }
  goto yyerrlab1;
yyerrorlab:
  if (0)
    goto yyerrorlab;
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  do { if (yydebug) yy_stack_print ((yyss), (yyssp)); } while (0);
  yystate = *yyssp;
  goto yyerrlab1;
yyerrlab1:
  yyerrstatus = 3;
  for (;;)
    {
      yyn = yypact[yystate];
      if (!(!!((yyn) == (-63))))
        {
          yyn += 1;
          if (0 <= yyn && yyn <= 251 && yycheck[yyn] == 1)
            {
              yyn = yytable[yyn];
              if (0 < yyn)
                break;
            }
        }
      if (yyssp == yyss)
        goto yyabortlab;
      yydestruct ("Error: popping",
                  yystos[yystate], yyvsp);
      (yyvsp -= (1), yyssp -= (1));
      yystate = *yyssp;
      do { if (yydebug) yy_stack_print ((yyss), (yyssp)); } while (0);
    }

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yyvsp = yylval;

#pragma GCC diagnostic pop

  do { if (yydebug) { fprintf (stderr, "%s ", "Shifting"); yy_symbol_print (stderr, yystos[yyn], yyvsp); fprintf (stderr, "\n"); } } while (0);
  yystate = yyn;
  goto yynewstate;
yyacceptlab:
  yyresult = 0;
  goto yyreturn;
yyabortlab:
  yyresult = 1;
  goto yyreturn;
yyexhaustedlab:
  yyerror ("memory exhausted");
  yyresult = 2;
yyreturn:
  if (yychar != (-2))
    {
      yytoken = ((unsigned int) (yychar) <= 273 ? yytranslate[yychar] : 2);
      yydestruct ("Cleanup: discarding lookahead",
                  yytoken, &yylval);
    }
  (yyvsp -= (yylen), yyssp -= (yylen));
  do { if (yydebug) yy_stack_print ((yyss), (yyssp)); } while (0);
  while (yyssp != yyss)
    {
      yydestruct ("Cleanup: popping",
                  yystos[*yyssp], yyvsp);
      (yyvsp -= (1), yyssp -= (1));
    }
  if (yyss != yyssa)
    free (yyss);
  return yyresult;
}

variable_types: yystate int

variable_types: yyerrstatus int

variable_types:
yyssa
short [200]

variable_types:
yyss
short *

variable_types:
yyssp
short *

variable_types:
yyvsa
union YYSTYPE { char *s; int i; } [200]

variable_types:
yyvs
union YYSTYPE { char *s; int i; } *

variable_types:
yyvsp
union YYSTYPE { char *s; int i; } *

variable_types:
yystacksize
unsigned long

variable_types: yyn int

variable_types: yyresult int

variable_types: yytoken int

variable_types:
yyval
union YYSTYPE { char *s; int i; }

variable_types: yylen int

variable_types:
yysize
unsigned long

variable_types: union yyalloc { short yyss_alloc; union YYSTYPE { char *s; int i; } yyvs_alloc; } *

variable_types:
yynewbytes
unsigned long

variable_types: yylhs int

variable_types: yyi int

user_defined_types: union yyalloc { short yyss_alloc; union YYSTYPE yyvs_alloc; }


createGradeRecord

decompiled_code:
void *createGradeRecord()
{
_QWORD *v0; // rbx
void *result; // rax

v0 = malloc(0x18uLL);
gradeRecord = (__int64)v0;
*v0 = malloc(0x50uLL);
v0[2] = malloc(1uLL);
result = malloc(0xBuLL);
v0[1] = result;
return result;
}

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

v0 = malloc(0x18uLL);
gradeRecord = (__int64)v0;
*v0 = malloc(0x50uLL);
v0[2] = malloc(1uLL);
result = malloc(0xBuLL);
v0[1] = result;
return result;
}

original_code:
void createGradeRecord()
{
  gradeRecord = (dbrecord *) malloc(sizeof(dbrecord));
  gradeRecord->Name = (char *) malloc(80);
  gradeRecord->Grade = (char *) malloc(1);
  gradeRecord->SSN = (char *) malloc(11);
}

canonical_original_code:
void createGradeRecord()
{
  gradeRecord = (struct dbrecord *) malloc(sizeof(dbrecord));
  gradeRecord->Name = (char *) malloc(80);
  gradeRecord->Grade = (char *) malloc(1);
  gradeRecord->SSN = (char *) malloc(11);
}

return_type: void

user_defined_types: struct dbrecord { char *Name; char *SSN; char *Grade; }


checkfordone

decompiled_code:
bool __fastcall checkfordone(const char *a1, const char *a2)
{
bool v2; // zf
bool result; // al

v2 = strcmp(a2, "Done") == 0;
result = !v2;
if ( !v2 )
{
fprintf(stderr, "Invalid response to %s command (%s)\n", a1, a2);
exit(1);
}
return result;
}

canonical_decompiled_code:
bool __fastcall func8(const char *a1, const char *a2)
{
bool v2; // zf
bool result; // al

v2 = strcmp(a2, "Done") == 0;
result = !v2;
if ( !v2 )
{
fprintf(stderr, "Invalid response to %s command (%s)\n", a1, a2);
exit(1);
}
return result;
}

original_code:
void checkfordone(char *command, char *replybuffer)
{
 if (strcmp(replybuffer, "Done") != 0)
 {
  fprintf(stderr, "Invalid response to %s command (%s)\n", command, replybuffer);
  exit(1);
 }
}

variable_types:
command
char *

variable_types:
replybuffer
char *


usage

decompiled_code:
void __fastcall __noreturn usage(const char *a1)
{
fprintf(
stderr,
"Usage: %s (-r size [-o offset])|-f filename [-s serialport]\n\tserialport defaults to /dev/ttyUSB0\n",
a1);
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func12(const char *a1)
{
fprintf(
stderr,
"Usage: %s (-r size [-o offset])|-f filename [-s serialport]\n\tserialport defaults to /dev/ttyUSB0\n",
a1);
exit(1);
}

original_code:
void usage(char *argv0)
{
 fprintf(stderr, "Usage: %s (-r size [-o offset])|-f filename [-s serialport]\n" "\tserialport defaults to /dev/ttyUSB0\n", argv0);
 exit(1);
}


ZeroPadding

repo: asrAachen/ASR

decompiled_code:
__int64 __fastcall ZeroPadding(__int64 a1, int a2)
{
_QWORD *v2; // rcx
__int64 v3; // rdx
__int64 result; // rax

v2 = (_QWORD *)(a1 + 8LL * a2);
v3 = (unsigned int)(8 * (1024 - a2));
*v2 = 0LL;
*(_QWORD *)((char *)v2 + v3 - 8) = 0LL;
result = 0LL;
memset(
(void *)((unsigned __int64)(v2 + 1) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)v3 + (_DWORD)v2 - (((_DWORD)v2 + 8) & 0xFFFFFFF8)) >> 3));
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, int a2)
{
_QWORD *v2; // rcx
__int64 v3; // rdx
__int64 result; // rax

v2 = (_QWORD *)(a1 + 8LL * a2);
v3 = (unsigned int)(8 * (1024 - a2));
*v2 = 0LL;
*(_QWORD *)((char *)v2 + v3 - 8) = 0LL;
result = 0LL;
memset(
(void *)((unsigned __int64)(v2 + 1) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)v3 + (_DWORD)v2 - (((_DWORD)v2 + 8) & 0xFFFFFFF8)) >> 3));
return result;
}

original_code:
static void ZeroPadding(double *Re_Signal, int N_sig)
{
  int i;
  for(i=N_sig; i<1024; i++) Re_Signal[i]=0.0;
}

variable_types: i int


decompiled_code:
__int64 __fastcall modemctl_link_set_active(unsigned int *a1, unsigned __int8 a2)
{
__int64 v2; // rdi
__int64 result; // rax
int v4[3]; // [rsp+Ch] [rbp-Ch] BYREF

v2 = *a1;
v4[0] = a2;
result = c_ioctl(v2, 28465LL, v4);
if ( (int)result > 0 )
result = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int *a1, unsigned __int8 a2)
{
__int64 v2; // rdi
__int64 result; // rax
int v4[3]; // [rsp+Ch] [rbp-Ch] BYREF

v2 = *a1;
v4[0] = a2;
result = c_ioctl(v2, 28465LL, v4);
if ( (int)result > 0 )
result = 0LL;
return result;
}

original_code:
int modemctl_link_set_active(fwloader_context *ctx, _Bool enabled) {
 unsigned status = enabled;
 int ret;
 unsigned long ioctl_code;
 ioctl_code = (((0U) << (((0 +8)+8)+14)) | ((('o')) << (0 +8)) | (((0x31)) << 0) | ((0) << ((0 +8)+8)));
 ret = c_ioctl(ctx->link_fd, ioctl_code, &status);
 if (ret < 0) {
  do {} while (0);
  goto fail;
 }
 return 0;
fail:
 return ret;
}

canonical_original_code:
int modemctl_link_set_active(struct fwloader_context *ctx, _Bool enabled) {
 unsigned int status = enabled;
 int ret;
 unsigned long ioctl_code;
 ioctl_code = (((0U) << (((0 +8)+8)+14)) | ((('o')) << (0 +8)) | (((0x31)) << 0) | ((0) << ((0 +8)+8)));
 ret = c_ioctl(ctx->link_fd, ioctl_code, &status);
 if (ret < 0) {
  do {} while (0);
  goto fail;
 }
 return 0;
fail:
 return ret;
}

variable_types: struct fwloader_context { int link_fd; int boot_fd; int radio_fd; char *radio_data; 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]; } radio_stat; } *

variable_types:
status
unsigned int

variable_types: ret int

return_type: int

user_defined_types: struct fwloader_context { int link_fd; int boot_fd; int radio_fd; char *radio_data; struct stat radio_stat; }


decompiled_code:
__int64 __fastcall modemctl_link_set_enabled(unsigned int *a1, unsigned __int8 a2)
{
__int64 v2; // rdi
__int64 result; // rax
int v4[3]; // [rsp+Ch] [rbp-Ch] BYREF

v2 = *a1;
v4[0] = a2;
result = c_ioctl(v2, 28464LL, v4);
if ( (int)result > 0 )
result = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int *a1, unsigned __int8 a2)
{
__int64 v2; // rdi
__int64 result; // rax
int v4[3]; // [rsp+Ch] [rbp-Ch] BYREF

v2 = *a1;
v4[0] = a2;
result = c_ioctl(v2, 28464LL, v4);
if ( (int)result > 0 )
result = 0LL;
return result;
}

original_code:
int modemctl_link_set_enabled(fwloader_context *ctx, _Bool enabled) {
 unsigned status = enabled;
 int ret;
 unsigned long ioctl_code;
 ioctl_code = (((0U) << (((0 +8)+8)+14)) | ((('o')) << (0 +8)) | (((0x30)) << 0) | ((0) << ((0 +8)+8)));
 ret = c_ioctl(ctx->link_fd, ioctl_code, &status);
 if (ret < 0) {
  do {} while (0);
  goto fail;
 }
 return 0;
fail:
 return ret;
}

canonical_original_code:
int modemctl_link_set_enabled(struct fwloader_context *ctx, _Bool enabled) {
 unsigned int status = enabled;
 int ret;
 unsigned long ioctl_code;
 ioctl_code = (((0U) << (((0 +8)+8)+14)) | ((('o')) << (0 +8)) | (((0x30)) << 0) | ((0) << ((0 +8)+8)));
 ret = c_ioctl(ctx->link_fd, ioctl_code, &status);
 if (ret < 0) {
  do {} while (0);
  goto fail;
 }
 return 0;
fail:
 return ret;
}

user_defined_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]; }


decompiled_code:
__int64 __fastcall modemctl_wait_link_ready(unsigned int *a1)
{
__int64 result; // rax
struct timeval v2; // [rsp+0h] [rbp-38h] BYREF
struct timeval tv; // [rsp+10h] [rbp-28h] BYREF

v2 = 0LL;
tv = 0LL;
gettimeofday(&v2, 0LL);
while ( 1 )
{
result = c_ioctl(*a1, 28467LL, 0LL);
if ( (int)result < 0 )
break;
if ( (_DWORD)result == 1 )
return 0LL;
usleep(0xC350u);
gettimeofday(&tv, 0LL);
if ( 1000 * (tv.tv_sec - v2.tv_sec) + (tv.tv_usec - v2.tv_usec) / 1000 > 1999 )
return 4294967186LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int *a1)
{
__int64 result; // rax
struct timeval v2; // [rsp+0h] [rbp-38h] BYREF
struct timeval tv; // [rsp+10h] [rbp-28h] BYREF

v2 = 0LL;
tv = 0LL;
gettimeofday(&v2, 0LL);
while ( 1 )
{
result = c_ioctl(*a1, 28467LL, 0LL);
if ( (int)result < 0 )
break;
if ( (_DWORD)result == 1 )
return 0LL;
usleep(0xC350u);
gettimeofday(&tv, 0LL);
if ( 1000 * (tv.tv_sec - v2.tv_sec) + (tv.tv_usec - v2.tv_usec) / 1000 > 1999 )
return 4294967186LL;
}
return result;
}

original_code:
int modemctl_wait_link_ready(fwloader_context *ctx) {
 int ret;
 struct timeval tv_start = {};
 struct timeval tv_end = {};
 gettimeofday(&tv_start, 0);;
 long diff = 0;
 do {
  ret = c_ioctl(ctx->link_fd, (((0U) << (((0 +8)+8)+14)) | ((('o')) << (0 +8)) | (((0x33)) << 0) | ((0) << ((0 +8)+8))), 0);
  if (ret < 0) {
   goto fail;
  }
  if (ret == 1) {
   return 0;
  }
  usleep((50 * 1000));
  gettimeofday(&tv_end, 0);;
  diff = (tv_end.tv_sec - tv_start.tv_sec) * 1000;
  diff += (tv_end.tv_usec - tv_start.tv_usec) / 1000;
 } while (diff < 2000);
 ret = -110;
fail:
 return ret;
}

canonical_original_code:
int modemctl_wait_link_ready(struct fwloader_context *ctx) {
 int ret;
 struct timeval tv_start = {};
 struct timeval tv_end = {};
 gettimeofday(&tv_start, 0);;
 long diff = 0;
 do {
  ret = c_ioctl(ctx->link_fd, (((0U) << (((0 +8)+8)+14)) | ((('o')) << (0 +8)) | (((0x33)) << 0) | ((0) << ((0 +8)+8))), 0);
  if (ret < 0) {
   goto fail;
  }
  if (ret == 1) {
   return 0;
  }
  usleep((50 * 1000));
  gettimeofday(&tv_end, 0);;
  diff = (tv_end.tv_sec - tv_start.tv_sec) * 1000;
  diff += (tv_end.tv_usec - tv_start.tv_usec) / 1000;
 } while (diff < 2000);
 ret = -110;
fail:
 return ret;
}

variable_types: struct timeval { long tv_sec; long tv_usec; }

variable_types: diff long


decompiled_code:
__int64 __fastcall modemctl_wait_modem_online(__int64 a1)
{
__int64 result; // rax
struct timeval v2; // [rsp+0h] [rbp-38h] BYREF
struct timeval tv; // [rsp+10h] [rbp-28h] BYREF

v2 = 0LL;
tv = 0LL;
gettimeofday(&v2, 0LL);
while ( 1 )
{
result = c_ioctl(*(unsigned int *)(a1 + 4), 28455LL, 0LL);
if ( (int)result < 0 )
break;
if ( (_DWORD)result == 4 )
return 0LL;
usleep(0xC350u);
gettimeofday(&tv, 0LL);
if ( 1000 * (tv.tv_sec - v2.tv_sec) + (tv.tv_usec - v2.tv_usec) / 1000 > 1999 )
return 4294967186LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
__int64 result; // rax
struct timeval v2; // [rsp+0h] [rbp-38h] BYREF
struct timeval tv; // [rsp+10h] [rbp-28h] BYREF

v2 = 0LL;
tv = 0LL;
gettimeofday(&v2, 0LL);
while ( 1 )
{
result = c_ioctl(*(unsigned int *)(a1 + 4), 28455LL, 0LL);
if ( (int)result < 0 )
break;
if ( (_DWORD)result == 4 )
return 0LL;
usleep(0xC350u);
gettimeofday(&tv, 0LL);
if ( 1000 * (tv.tv_sec - v2.tv_sec) + (tv.tv_usec - v2.tv_usec) / 1000 > 1999 )
return 4294967186LL;
}
return result;
}

original_code:
int modemctl_wait_modem_online(fwloader_context *ctx) {
 int ret;
 struct timeval tv_start = {};
 struct timeval tv_end = {};
 gettimeofday(&tv_start, 0);;
 long diff = 0;
 do {
  ret = c_ioctl(ctx->boot_fd, (((0U) << (((0 +8)+8)+14)) | ((('o')) << (0 +8)) | (((0x27)) << 0) | ((0) << ((0 +8)+8))), 0);
  if (ret < 0) {
   goto fail;
  }
  if (ret == STATE_ONLINE) {
   return 0;
  }
  usleep((50 * 1000));
  gettimeofday(&tv_end, 0);;
  diff = (tv_end.tv_sec - tv_start.tv_sec) * 1000;
  diff += (tv_end.tv_usec - tv_start.tv_usec) / 1000;
 } while (diff < 2000);
 ret = -110;
fail:
 return ret;
}

canonical_original_code:
int modemctl_wait_modem_online(struct fwloader_context *ctx) {
 int ret;
 struct timeval tv_start = {};
 struct timeval tv_end = {};
 gettimeofday(&tv_start, 0);;
 long diff = 0;
 do {
  ret = c_ioctl(ctx->boot_fd, (((0U) << (((0 +8)+8)+14)) | ((('o')) << (0 +8)) | (((0x27)) << 0) | ((0) << ((0 +8)+8))), 0);
  if (ret < 0) {
   goto fail;
  }
  if (ret == STATE_ONLINE) {
   return 0;
  }
  usleep((50 * 1000));
  gettimeofday(&tv_end, 0);;
  diff = (tv_end.tv_sec - tv_start.tv_sec) * 1000;
  diff += (tv_end.tv_usec - tv_start.tv_usec) / 1000;
 } while (diff < 2000);
 ret = -110;
fail:
 return ret;
}

user_defined_types: struct timeval { long tv_sec; long tv_usec; }


decompiled_code:
__int64 __fastcall modemctl_modem_power(__int64 a1, char a2)
{
__int64 v2; // rdi
__int64 result; // rax

v2 = *(unsigned int *)(a1 + 4);
if ( a2 )
result = c_ioctl(v2, 28441LL, 0LL);
else
result = c_ioctl(v2, 28448LL, 0LL);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, char a2)
{
__int64 v2; // rdi
__int64 result; // rax

v2 = *(unsigned int *)(a1 + 4);
if ( a2 )
result = c_ioctl(v2, 28441LL, 0LL);
else
result = c_ioctl(v2, 28448LL, 0LL);
return result;
}


decompiled_code:
__int64 __fastcall modemctl_modem_boot_power(__int64 a1, char a2)
{
__int64 v2; // rdi
__int64 result; // rax

v2 = *(unsigned int *)(a1 + 4);
if ( a2 )
result = c_ioctl(v2, 28450LL, 0LL);
else
result = c_ioctl(v2, 28451LL, 0LL);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, char a2)
{
__int64 v2; // rdi
__int64 result; // rax

v2 = *(unsigned int *)(a1 + 4);
if ( a2 )
result = c_ioctl(v2, 28450LL, 0LL);
else
result = c_ioctl(v2, 28451LL, 0LL);
return result;
}


calculateCRC

decompiled_code:
char __fastcall calculateCRC(__int64 a1, __int64 a2, __int64 a3)
{
_BYTE *v3; // rsi
_BYTE *v4; // rdx
char result; // al

v3 = (_BYTE *)(a1 + a2);
if ( !a3 )
return 0;
v4 = &v3[a3];
result = 0;
do
result ^= *v3++;
while ( v4 != v3 );
return result;
}

canonical_decompiled_code:
char __fastcall func6(__int64 a1, __int64 a2, __int64 a3)
{
_BYTE *v3; // rsi
_BYTE *v4; // rdx
char result; // al

v3 = (_BYTE *)(a1 + a2);
if ( !a3 )
return 0;
v4 = &v3[a3];
result = 0;
do
result ^= *v3++;
while ( v4 != v3 );
return result;
}

original_code:
unsigned char calculateCRC(void* data, size_t offset, size_t length)
{
 unsigned char crc = 0;
 unsigned char *ptr = (unsigned char*)(data + offset);
 while (length--) {
  crc ^= *ptr++;
 }
 return crc;
}

canonical_original_code:
unsigned char calculateCRC(void *data, unsigned long offset, unsigned long length)
{
 unsigned char crc = 0;
 unsigned char *ptr = (unsigned char*)(data + offset);
 while (length--) {
  crc ^= *ptr++;
 }
 return crc;
}

variable_types:
data
void *

variable_types:
offset
unsigned long

variable_types:
length
unsigned long

variable_types:
crc
unsigned char

variable_types:
ptr
unsigned char *

return_type: unsigned char


main

canonical_name: main

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

if ( argc <= 1 )
v3 = boot_modem_i9250(argc, argv, envp);
else
v3 = boot_modem_i9100(argc, argv, envp);
if ( v3 < 0 )
printf("[xmm6260-sec]: E/failed to boot modem at %s:%s:%d\n", "modem-ctl.c", "main", 41LL);
return v3;
}

original_code:
int main(int argc, char** argv) {
 int ret;
 if (argc > 1) {
  ret = boot_modem_i9100();
 }
 else {
  ret = boot_modem_i9250();
 }
 if (ret < 0) {
  do { printf("[" "xmm6260-sec" "]: " "E/" "failed to boot modem" " at %s:%s:%d\n", "modem-ctl.c", __func__, 41); } while (0);
  goto fail;
 }
 else {
  do {} while (0);
 }
fail:
 return ret;
}

canonical_original_code:
int main(int argc, char **argv) {
 int ret;
 if (argc > 1) {
  ret = boot_modem_i9100();
 }
 else {
  ret = boot_modem_i9250();
 }
 if (ret < 0) {
  do { printf("[" "xmm6260-sec" "]: " "E/" "failed to boot modem" " at %s:%s:%d\n", "modem-ctl.c", __func__, 41); } while (0);
  goto fail;
 }
 else {
  do {} while (0);
 }
fail:
 return ret;
}

variable_types: argc int

variable_types:
argv
char **


decompiled_code:
__int64 __fastcall c_ioctl(unsigned int a1, unsigned __int64 a2, __int64 a3)
{
int v3; // er12
int *v5; // rax
char *v6; // rax

if ( a3 )
{
v3 = ioctl(a1, a2);
if ( v3 >= 0 )
return (unsigned int)v3;
}
else
{
v3 = ioctl(a1, a2);
if ( v3 >= 0 )
return (unsigned int)v3;
}
v5 = _errno_location();
v6 = strerror(*v5);
printf("[xmm6260-sec]: E/ioctl fd=%d code=%lx failed: %s at %s:%s:%d\n", a1, a2, v6, "io_helpers.c", "c_ioctl", 41LL);
return (unsigned int)v3;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1, unsigned __int64 a2, __int64 a3)
{
int v3; // er12
int *v5; // rax
char *v6; // rax

if ( a3 )
{
v3 = ioctl(a1, a2);
if ( v3 >= 0 )
return (unsigned int)v3;
}
else
{
v3 = ioctl(a1, a2);
if ( v3 >= 0 )
return (unsigned int)v3;
}
v5 = _errno_location();
v6 = strerror(*v5);
printf("[xmm6260-sec]: E/ioctl fd=%d code=%lx failed: %s at %s:%s:%d\n", a1, a2, v6, "io_helpers.c", "c_ioctl", 41LL);
return (unsigned int)v3;
}

original_code:
int c_ioctl(int fd, unsigned long code, void* data) {
 int ret;
 if (!data) {
  ret = ioctl(fd, code);
 }
 else {
  ret = ioctl(fd, code, data);
 }
 if (ret < 0) {
  do { printf("[" "xmm6260-sec" "]: " "E/" "ioctl fd=%d code=%lx failed: %s" " at %s:%s:%d\n", fd, code, strerror((*__errno_location ())), "io_helpers.c", __func__, 41); } while (0);
 }
 else {
  do {} while (0);
 }
 return ret;
}

canonical_original_code:
int c_ioctl(int fd, unsigned long code, void *data) {
 int ret;
 if (!data) {
  ret = ioctl(fd, code);
 }
 else {
  ret = ioctl(fd, code, data);
 }
 if (ret < 0) {
  do { printf("[" "xmm6260-sec" "]: " "E/" "ioctl fd=%d code=%lx failed: %s" " at %s:%s:%d\n", fd, code, strerror((*__errno_location ())), "io_helpers.c", __func__, 41); } while (0);
 }
 else {
  do {} while (0);
 }
 return ret;
}

variable_types: fd int

variable_types:
code
unsigned long


decompiled_code:
__int64 __fastcall read_select(signed int a1, unsigned int a2)
{
int v2; // er12
int *v4; // rax
char *v5; // rax
struct timeval v6; // [rsp+0h] [rbp-A8h] BYREF
fd_set readfds; // [rsp+10h] [rbp-98h] BYREF

v6.tv_sec = a2 / 0x3E8;
v6.tv_usec = 1000 * (a2 % 0x3E8);
memset(&readfds, 0, sizeof(readfds));
readfds.fds_bits[a1 / 64] |= 1LL << (a1 % 64);
v2 = select(a1 + 1, &readfds, 0LL, 0LL, &v6);
if ( v2 < 0 )
{
v4 = _errno_location();
v5 = strerror(*v4);
printf(
"[xmm6260-sec]: E/failed to select the fd %d ret=%d: %s at %s:%s:%d\n",
(unsigned int)a1,
(unsigned int)v2,
v5,
"io_helpers.c",
"read_select",
65LL);
}
return (unsigned int)v2;
}

canonical_decompiled_code:
__int64 __fastcall func1(signed int a1, unsigned int a2)
{
int v2; // er12
int *v4; // rax
char *v5; // rax
struct timeval v6; // [rsp+0h] [rbp-A8h] BYREF
fd_set readfds; // [rsp+10h] [rbp-98h] BYREF

v6.tv_sec = a2 / 0x3E8;
v6.tv_usec = 1000 * (a2 % 0x3E8);
memset(&readfds, 0, sizeof(readfds));
readfds.fds_bits[a1 / 64] |= 1LL << (a1 % 64);
v2 = select(a1 + 1, &readfds, 0LL, 0LL, &v6);
if ( v2 < 0 )
{
v4 = _errno_location();
v5 = strerror(*v4);
printf(
"[xmm6260-sec]: E/failed to select the fd %d ret=%d: %s at %s:%s:%d\n",
(unsigned int)a1,
(unsigned int)v2,
v5,
"io_helpers.c",
"read_select",
65LL);
}
return (unsigned int)v2;
}

original_code:
int read_select(int fd, unsigned timeout) {
 int ret = 0;
 struct timeval tv = {
  tv.tv_sec = timeout / 1000,
  tv.tv_usec = 1000 * (timeout % 1000),
 };
 fd_set read_set;
 do { int __d0, __d1; __asm__ __volatile__ ("cld; rep; " "stosq" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&read_set)->__fds_bits)[0]) : "memory"); } while (0);
 ((void) (((&read_set)->__fds_bits)[((fd) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) (1UL << ((fd) % (8 * (int) sizeof (__fd_mask)))))));
 ret = select(fd + 1, &read_set, 0, 0, &tv);
 if (ret < 0) {
  do { printf("[" "xmm6260-sec" "]: " "E/" "failed to select the fd %d ret=%d: %s" " at %s:%s:%d\n", fd, ret, strerror((*__errno_location ())), "io_helpers.c", __func__, 65); } while (0);
  goto fail;
 }
 if (ret < 1 || !((((&read_set)->__fds_bits)[((fd) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) (1UL << ((fd) % (8 * (int) sizeof (__fd_mask)))))) != 0)) {
  do {} while (0);
  goto fail;
 }
fail:
 return ret;
}

canonical_original_code:
int read_select(int fd, unsigned int timeout) {
 int ret = 0;
 struct timeval tv = {
  tv.tv_sec = timeout / 1000,
  tv.tv_usec = 1000 * (timeout % 1000),
 };
 struct fd_set read_set;
 do { int __d0; int __d1; __asm__ __volatile__ ("cld; rep; " "stosq" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&read_set)->__fds_bits)[0]) : "memory"); } while (0);
 ((void) (((&read_set)->__fds_bits)[((fd) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) (1UL << ((fd) % (8 * (int) sizeof (__fd_mask)))))));
 ret = select(fd + 1, &read_set, 0, 0, &tv);
 if (ret < 0) {
  do { printf("[" "xmm6260-sec" "]: " "E/" "failed to select the fd %d ret=%d: %s" " at %s:%s:%d\n", fd, ret, strerror((*__errno_location ())), "io_helpers.c", __func__, 65); } while (0);
  goto fail;
 }
 if (ret < 1 || !((((&read_set)->__fds_bits)[((fd) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) (1UL << ((fd) % (8 * (int) sizeof (__fd_mask)))))) != 0)) {
  do {} while (0);
  goto fail;
 }
fail:
 return ret;
}

variable_types:
timeout
unsigned int


receive

decompiled_code:
__int64 __fastcall receive(int fd, void *buf, size_t nbytes)
{
int v4; // eax
unsigned int v6; // er12

v4 = read_select(fd, 0x32u);
if ( v4 > 0 )
return (unsigned int)read(fd, buf, nbytes);
v6 = v4;
printf("[xmm6260-sec]: E/failed to select the fd %d at %s:%s:%d\n", (unsigned int)fd, "io_helpers.c", "receive", 81LL);
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func2(int fd, void *buf, size_t nbytes)
{
int v4; // eax
unsigned int v6; // er12

v4 = func1(fd, 0x32u);
if ( v4 > 0 )
return (unsigned int)read(fd, buf, nbytes);
v6 = v4;
printf("[xmm6260-sec]: E/failed to select the fd %d at %s:%s:%d\n", (unsigned int)fd, "io_helpers.c", "receive", 81LL);
return v6;
}

original_code:
int receive(int fd, void *buf, size_t size) {
 int ret;
 if ((ret = read_select(fd, 50)) < 1) {
  do { printf("[" "xmm6260-sec" "]: " "E/" "failed to select the fd %d" " at %s:%s:%d\n", fd, "io_helpers.c", __func__, 81); } while (0);
  return ret;
 }
 else {
  do {} while (0);
 }
 return read(fd, buf, size);
}

canonical_original_code:
int receive(int fd, void *buf, unsigned long size) {
 int ret;
 if ((ret = read_select(fd, 50)) < 1) {
  do { printf("[" "xmm6260-sec" "]: " "E/" "failed to select the fd %d" " at %s:%s:%d\n", fd, "io_helpers.c", __func__, 81); } while (0);
  return ret;
 }
 else {
  do {} while (0);
 }
 return read(fd, buf, size);
}

variable_types:
buf
void *

variable_types:
size
unsigned long


decompiled_code:
__int64 __fastcall expect_data(int a1, const void *a2, size_t a3)
{
void *v4; // rsp
int v5; // eax
__int64 v6; // r12
unsigned int v7; // er13
_BYTE v9[32]; // [rsp+0h] [rbp-20h] BYREF

v4 = alloca(a3);
v5 = receive(a1, v9, a3);
v6 = v5;
if ( v5 == a3 )
{
v7 = memcmp(v9, a2, v5);
hexdump(v9, v6);
}
else
{
v7 = -1;
printf("[xmm6260-sec]: E/failed to receive data at %s:%s:%d\n", "io_helpers.c", "expect_data", 96LL);
}
return v7;
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1, const void *a2, size_t a3)
{
void *v4; // rsp
int v5; // eax
__int64 v6; // r12
unsigned int v7; // er13
_BYTE v9[32]; // [rsp+0h] [rbp-20h] BYREF

v4 = alloca(a3);
v5 = func2(a1, v9, a3);
v6 = v5;
if ( v5 == a3 )
{
v7 = memcmp(v9, a2, v5);
hexdump(v9, v6);
}
else
{
v7 = -1;
printf("[xmm6260-sec]: E/failed to receive data at %s:%s:%d\n", "io_helpers.c", "expect_data", 96LL);
}
return v7;
}

original_code:
int expect_data(int fd, void *data, size_t size) {
 int ret;
 char buf[size];
 if ((ret = receive(fd, buf, size)) != size) {
  ret = -1;
  do { printf("[" "xmm6260-sec" "]: " "E/" "failed to receive data" " at %s:%s:%d\n", "io_helpers.c", __func__, 96); } while (0);
  return ret;
 }
 ret = memcmp(buf, data, size);
 hexdump(buf, size);
 return ret;
}

canonical_original_code:
int expect_data(int fd, void *data, unsigned long size) {
 int ret;
 char buf[-1];
 if ((ret = receive(fd, buf, size)) != size) {
  ret = -1;
  do { printf("[" "xmm6260-sec" "]: " "E/" "failed to receive data" " at %s:%s:%d\n", "io_helpers.c", __func__, 96); } while (0);
  return ret;
 }
 ret = memcmp(buf, data, size);
 hexdump(buf, size);
 return ret;
}

variable_types:
buf
char [-1]


hexdump

decompiled_code:
int __fastcall hexdump(char *a1, unsigned __int64 a2)
{
char *v2; // rbx
__int128 *v3; // rbp
char *v4; // r12
__int64 v5; // rcx
char *v6; // rdi
int result; // eax
__int128 v8[3]; // [rsp+0h] [rbp-58h] BYREF
char v9; // [rsp+30h] [rbp-28h]

if ( a2 )
{
v2 = a1;
if ( a2 > 0x10 )
a2 = 16LL;
v9 = 0;
v3 = v8;
v8[0] = 0LL;
v8[1] = 0LL;
v4 = &a1[a2];
v8[2] = 0LL;
do
{
v5 = (unsigned int)*v2;
v6 = (char *)v3;
++v2;
v3 = (__int128 *)((char *)v3 + 3);
result = snprintf(v6, 4uLL, "%02x ", v5);
}
while ( v2 != v4 );
}
return result;
}

original_code:
void hexdump(void* data, size_t size) {
 if (size < 1) {
  return;
 }
 char *_data = (char*)data;
 char __hd_buf[16 * 3 + 1];
 size_t len = size < 16 ? size : 16;
 memset(__hd_buf, 0, sizeof(__hd_buf));
 int i;
 for (i = 0; i < len; i++) {
  snprintf(__hd_buf + i * 3, 4, "%02x ", _data[i]);
 }
 __hd_buf[sizeof(__hd_buf) - 1] = '\0';
 do {} while (0);
}

canonical_original_code:
void hexdump(void *data, unsigned long size) {
 if (size < 1) {
  return;
 }
 char *_data = (char*)data;
 char __hd_buf[-1];
 unsigned long len = size < 16 ? size : 16;
 memset(__hd_buf, 0, sizeof(__hd_buf));
 int i;
 for (i = 0; i < len; i++) {
  snprintf(__hd_buf + i * 3, 4, "%02x ", _data[i]);
 }
 __hd_buf[sizeof(__hd_buf) - 1] = '\0';
 do {} while (0);
}

variable_types:
len
unsigned long

variable_types: i int


Parse

repo: aszeszo/xnv

decompiled_code:
__int64 __fastcall Parse(int a1, __int64 a2)
{
int v2; // ebp
_BYTE *v4; // r8
const char *v5; // rdi
__int64 result; // rax
char *v7; // rax
char v8; // al
_BYTE *v9; // rsi
int v10; // ecx
int v11; // edx
char v12; // di
char v13; // r8

v2 = a1;
if ( a1 > 1 )
{
while ( 1 )
{
v4 = *(_BYTE **)(a2 + 8);
if ( *v4 != 45 )
break;
if ( !strcmp(*(const char **)(a2 + 8), "-display") )
{
v7 = *(char **)(a2 + 16);
--v2;
a2 += 8LL;
display_name = v7;
LABEL_8:
--v2;
a2 += 8LL;
if ( v2 <= 1 )
goto LABEL_13;
}
else
{
if ( strcmp(*(const char **)(a2 + 8), "-timeout") )
{
v8 = v4[1];
if ( v8 )
{
v9 = v4 + 1;
v10 = verbose;
v11 = showall;
v12 = 0;
v13 = 0;
do
{
while ( v8 == 97 )
{
*(_QWORD *)(a2 + 8) = v9;
v8 = *++v9;
++v11;
v12 = 1;
if ( !v8 )
goto LABEL_24;
}
if ( v8 != 118 )
{
if ( v12 )
showall = v11;
if ( v13 )
verbose = v10;
fprintf(stderr, "%s: -%c: unknown option\n", (const char *)cmdname, (unsigned int)v8);
usage();
}
*(_QWORD *)(a2 + 8) = v9;
v8 = *++v9;
++v10;
v13 = 1;
}
while ( v8 );
LABEL_24:
if ( v12 )
showall = v11;
if ( v13 )
verbose = v10;
}
goto LABEL_8;
}
v5 = *(const char **)(a2 + 16);
v2 -= 2;
a2 += 16LL;
timeout = atoi(v5);
if ( v2 <= 1 )
goto LABEL_13;
}
}
if ( !strcmp(*(const char **)(a2 + 8), "x11") )
{
AddProto(1);
}
else if ( !strcmp(*(const char **)(a2 + 8), "news") )
{
AddProto(2);
}
else if ( !strcmp(*(const char **)(a2 + 8), "x11news") )
{
AddProto(3);
}
else
{
if ( strcmp(*(const char **)(a2 + 8), "sunview") )
{
fprintf(stderr, "%s: %s: unknown protocol\n", (const char *)cmdname, *(const char **)(a2 + 8));
usage();
}
AddProto(4);
}
goto LABEL_8;
}
LABEL_13:
result = (unsigned int)n_proto;
if ( !n_proto )
{
fprintf(stderr, "%s: no protocols specified\n", (const char *)cmdname);
usage();
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(int a1, __int64 a2)
{
int v2; // ebp
_BYTE *v4; // r8
const char *v5; // rdi
__int64 result; // rax
char *v7; // rax
char v8; // al
_BYTE *v9; // rsi
int v10; // ecx
int v11; // edx
char v12; // di
char v13; // r8

v2 = a1;
if ( a1 > 1 )
{
while ( 1 )
{
v4 = *(_BYTE **)(a2 + 8);
if ( *v4 != 45 )
break;
if ( !strcmp(*(const char **)(a2 + 8), "-display") )
{
v7 = *(char **)(a2 + 16);
--v2;
a2 += 8LL;
display_name = v7;
LABEL_8:
--v2;
a2 += 8LL;
if ( v2 <= 1 )
goto LABEL_13;
}
else
{
if ( strcmp(*(const char **)(a2 + 8), "-timeout") )
{
v8 = v4[1];
if ( v8 )
{
v9 = v4 + 1;
v10 = verbose;
v11 = showall;
v12 = 0;
v13 = 0;
do
{
while ( v8 == 97 )
{
*(_QWORD *)(a2 + 8) = v9;
v8 = *++v9;
++v11;
v12 = 1;
if ( !v8 )
goto LABEL_24;
}
if ( v8 != 118 )
{
if ( v12 )
showall = v11;
if ( v13 )
verbose = v10;
fprintf(stderr, "%s: -%c: unknown option\n", (const char *)cmdname, (unsigned int)v8);
func7();
}
*(_QWORD *)(a2 + 8) = v9;
v8 = *++v9;
++v10;
v13 = 1;
}
while ( v8 );
LABEL_24:
if ( v12 )
showall = v11;
if ( v13 )
verbose = v10;
}
goto LABEL_8;
}
v5 = *(const char **)(a2 + 16);
v2 -= 2;
a2 += 16LL;
timeout = atoi(v5);
if ( v2 <= 1 )
goto LABEL_13;
}
}
if ( !strcmp(*(const char **)(a2 + 8), "x11") )
{
AddProto(1);
}
else if ( !strcmp(*(const char **)(a2 + 8), "news") )
{
AddProto(2);
}
else if ( !strcmp(*(const char **)(a2 + 8), "x11news") )
{
AddProto(3);
}
else
{
if ( strcmp(*(const char **)(a2 + 8), "sunview") )
{
fprintf(stderr, "%s: %s: unknown protocol\n", (const char *)cmdname, *(const char **)(a2 + 8));
func7();
}
AddProto(4);
}
goto LABEL_8;
}
LABEL_13:
result = (unsigned int)n_proto;
if ( !n_proto )
{
fprintf(stderr, "%s: no protocols specified\n", (const char *)cmdname);
func7();
}
return result;
}

original_code:
static void
Parse (int argc, char* argv[])
{
    for (;argc > 1; argv++, argc--) {
 if (argv[1][0] == '-') {
     if (!strcmp(argv[1], "-display")) {
  display_name=argv[2];
  argv++;
  argc--;
  continue;
     }
     if (!strcmp(argv[1], "-timeout")) {
                timeout = atoi(argv[2]);
                argv++;
                argc--;
                continue;
            }
     for (; argv[1][1]; argv[1]++) {
         switch (argv[1][1]) {
         case 'a':
      showall++;
      break;
  case 'v':
      verbose++;
      break;
  default:
      fprintf(stderr, "%s: -%c: unknown option\n",
       cmdname,argv[1][1]);
      usage();
         }
     }
 }
 else {
     if (!strcmp(argv[1], "x11")) {
  AddProto(1);
     } else if (!strcmp(argv[1], "news")) {
  AddProto(2);
     } else if (!strcmp(argv[1], "x11news")) {
  AddProto(3);
     } else if (!strcmp(argv[1], "sunview")) {
  AddProto(4);
     } else {
  fprintf(stderr, "%s: %s: unknown protocol\n",
   cmdname,argv[1]);
  usage();
     }
 }
    }
    if (!n_proto) {
 fprintf(stderr, "%s: no protocols specified\n",
  cmdname);
 usage();
    }
}

canonical_original_code:
static void Parse(int argc, char *argv[])
{
    for (;argc > 1; argv++, argc--) {
 if (argv[1][0] == '-') {
     if (!strcmp(argv[1], "-display")) {
  display_name=argv[2];
  argv++;
  argc--;
  continue;
     }
     if (!strcmp(argv[1], "-timeout")) {
                timeout = atoi(argv[2]);
                argv++;
                argc--;
                continue;
            }
     for (; argv[1][1]; argv[1]++) {
         switch (argv[1][1]) {
         case 'a':
      showall++;
      break;
  case 'v':
      verbose++;
      break;
  default:
      fprintf(stderr, "%s: -%c: unknown option\n",
       cmdname,argv[1][1]);
      usage();
         }
     }
 }
 else {
     if (!strcmp(argv[1], "x11")) {
  AddProto(1);
     } else if (!strcmp(argv[1], "news")) {
  AddProto(2);
     } else if (!strcmp(argv[1], "x11news")) {
  AddProto(3);
     } else if (!strcmp(argv[1], "sunview")) {
  AddProto(4);
     } else {
  fprintf(stderr, "%s: %s: unknown protocol\n",
   cmdname,argv[1]);
  usage();
     }
 }
    }
    if (!n_proto) {
 fprintf(stderr, "%s: no protocols specified\n",
  cmdname);
 usage();
    }
}

variable_types:
argv
char *[]


ConnectToX

decompiled_code:
_BOOL8 __fastcall ConnectToX(char *a1)
{
unsigned int v1; // er12
Display *v2; // rbx

v1 = timeout;
if ( (int)timeout > 0 )
{
signal(14, OnAlarm);
alarm(v1);
}
display = XOpenDisplay(a1);
v2 = display;
if ( (int)timeout > 0 )
alarm(0);
return v2 != 0LL;
}

canonical_decompiled_code:
_BOOL8 __fastcall func9(char *a1)
{
unsigned int v1; // er12
Display *v2; // rbx

v1 = timeout;
if ( (int)timeout > 0 )
{
signal(14, OnAlarm);
alarm(v1);
}
display = XOpenDisplay(a1);
v2 = display;
if ( (int)timeout > 0 )
alarm(0);
return v2 != 0LL;
}

original_code:
static int
ConnectToX (const char* display_name)
{
     if(timeout > 0){
       signal(14, OnAlarm);
       alarm(timeout);
     }
     display=XOpenDisplay(display_name);
     if(timeout > 0)
       alarm(0);
     return((display != ((void *)0)));
}

canonical_original_code:
static int ConnectToX(char *display_name)
{
     if(timeout > 0){
       signal(14, OnAlarm);
       alarm(timeout);
     }
     display=XOpenDisplay(display_name);
     if(timeout > 0)
       alarm(0);
     return((display != ((void *)0)));
}


OnAlarm

decompiled_code:
void __noreturn OnAlarm()
{
fwrite("winsysck timeout\n", 1uLL, 0x11uLL, stderr);
exit(1);
}

canonical_decompiled_code:
void __noreturn func10()
{
fwrite("winsysck timeout\n", 1uLL, 0x11uLL, stderr);
exit(1);
}

original_code:
static void OnAlarm(int i)
{
      fprintf(stderr, "winsysck timeout\n");
      exit(1);
}


Probe

decompiled_code:
void __noreturn Probe()
{
int v0; // ebp
__int64 i; // rbx
__int64 v2; // r8

v0 = 0;
for ( i = 0LL; i != 4; ++i )
{
v2 = (unsigned int)proto_list[i];
if ( !(_DWORD)v2 )
break;
if ( (_DWORD)v2 == 1 )
{
if ( ConnectToX(display_name) )
{
++v0;
if ( verbose )
puts("x11");
DisconnectFromX_isra_0();
if ( !showall )
exit(0);
}
}
else if ( (unsigned int)(v2 - 2) > 2 )
{
fprintf(stderr, "%s: WSGO: proto_list[%d]==%d\n", (const char *)cmdname, (unsigned int)i, v2);
}
}
exit(v0 == 0);
}

canonical_decompiled_code:
void __noreturn func12()
{
int v0; // ebp
__int64 i; // rbx
__int64 v2; // r8

v0 = 0;
for ( i = 0LL; i != 4; ++i )
{
v2 = (unsigned int)proto_list[i];
if ( !(_DWORD)v2 )
break;
if ( (_DWORD)v2 == 1 )
{
if ( func9(display_name) )
{
++v0;
if ( verbose )
puts("x11");
func11();
if ( !showall )
exit(0);
}
}
else if ( (unsigned int)(v2 - 2) > 2 )
{
fprintf(stderr, "%s: WSGO: proto_list[%d]==%d\n", (const char *)cmdname, (unsigned int)i, v2);
}
}
exit(v0 == 0);
}

original_code:
static void
Probe(void)
{
    int i, found=0;
    for(i=0; (i < 4) && (proto_list[i] != 0); i++) {
 switch (proto_list[i]) {
 case 1:
     if (ConnectToX(display_name)) {
  found++;
  if (verbose) printf("%s\n","x11");
         DisconnectFromX();
  if (!showall) exit(0);
     }
     break;
 case 2:
 case 3:
 case 4:
     break;
 default:
     fprintf(stderr, "%s: WSGO: proto_list[%d]==%d\n",
      cmdname,i,proto_list[i]);
 }
    }
    exit(!found);
}

canonical_original_code:
static void Probe()
{
    int i; int found = 0;
    for(i=0; (i < 4) && (proto_list[i] != 0); i++) {
 switch (proto_list[i]) {
 case 1:
     if (ConnectToX(display_name)) {
  found++;
  if (verbose) printf("%s\n","x11");
         DisconnectFromX();
  if (!showall) exit(0);
     }
     break;
 case 2:
 case 3:
 case 4:
     break;
 default:
     fprintf(stderr, "%s: WSGO: proto_list[%d]==%d\n",
      cmdname,i,proto_list[i]);
 }
    }
    exit(!found);
}

variable_types: found int


main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
cmdname = (__int64)*argv;
Parse(argc, argv, envp);
Probe();
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
cmdname = (__int64)*argv;
func8(argc, argv, envp);
func12();
}

original_code:
int
main (int argc, char* argv[])
{
    cmdname=argv[0];
    Parse(argc,argv);
    Probe();
    exit(0);
}

canonical_original_code:
int main(int argc, char *argv[])
{
    cmdname=argv[0];
    Parse(argc,argv);
    Probe();
    exit(0);
}


usage

decompiled_code:
void __noreturn usage()
{
fprintf(
stderr,
"usage: %s %s\n\t%s\n",
(const char *)cmdname,
"[-va] [-display display_name] [-timeout seconds] protocol [...]",
"protocol can be one of: x11 news x11news sunview");
exit(2);
}

canonical_decompiled_code:
void __noreturn func7()
{
fprintf(
stderr,
"usage: %s %s\n\t%s\n",
(const char *)cmdname,
"[-va] [-display display_name] [-timeout seconds] protocol [...]",
"protocol can be one of: x11 news x11news sunview");
exit(2);
}

original_code:
static void
usage () {
    fprintf(stderr, "usage: %s %s\n\t%s\n", cmdname,
     "[-va] [-display display_name] [-timeout seconds] protocol [...]",
     "protocol can be one of: x11 news x11news sunview");
    exit(2);
}

canonical_original_code:
static void usage() {
    fprintf(stderr, "usage: %s %s\n\t%s\n", cmdname,
     "[-va] [-display display_name] [-timeout seconds] protocol [...]",
     "protocol can be one of: x11 news x11news sunview");
    exit(2);
}


dumpCmap

decompiled_code:
int dumpCmap()
{
unsigned __int64 i; // rax
unsigned __int16 *v1; // rbx
unsigned int v2; // ebp
unsigned __int16 v3; // dx
__int64 v4; // rcx
__int64 v5; // rsi
__int64 v6; // r8
int result; // eax
XColor v8[257]; // [rsp+0h] [rbp-1018h] BYREF

for ( i = 0LL; i != 256; ++i )
v8[i].pixel = i;
v1 = &v8[0].red;
v2 = 0;
XQueryColors(dsp, dsp->screens[(__int64)screen].cmap, v8, 256);
do
{
v3 = *v1;
v4 = *((unsigned __int8 *)v1 + 3);
v5 = v2;
v6 = *((unsigned __int8 *)v1 + 5);
++v2;
v1 += 8;
result = printf("/name%02x\t%3d %3d %3d RGBcolor def\n", v5, HIBYTE(v3), v4, v6);
}
while ( v2 != 256 );
return result;
}

canonical_decompiled_code:
int func0()
{
unsigned __int64 i; // rax
unsigned __int16 *v1; // rbx
unsigned int v2; // ebp
unsigned __int16 v3; // dx
__int64 v4; // rcx
__int64 v5; // rsi
__int64 v6; // r8
int result; // eax
XColor v8[257]; // [rsp+0h] [rbp-1018h] BYREF

for ( i = 0LL; i != 256; ++i )
v8[i].pixel = i;
v1 = &v8[0].red;
v2 = 0;
XQueryColors(dsp, dsp->screens[(__int64)screen].cmap, v8, 256);
do
{
v3 = *v1;
v4 = *((unsigned __int8 *)v1 + 3);
v5 = v2;
v6 = *((unsigned __int8 *)v1 + 5);
++v2;
v1 += 8;
result = printf("/name%02x\t%3d %3d %3d RGBcolor def\n", v5, HIBYTE(v3), v4, v6);
}
while ( v2 != 256 );
return result;
}

original_code:
static void
dumpCmap(void)
{
    register int i;
    XColor color[256];
    for (i = 0; i < 256; i++)
 color[i].pixel = i;
    XQueryColors(dsp, ((&((_XPrivDisplay)(dsp))->screens[screen])->cmap), color, 256);
    for (i = 0; i < 256; i++) {
 printf("/name%02x	%3d %3d %3d RGBcolor def\n",
       i, color[i].red >> 8, color[i].green >> 8, color[i].blue >> 8);
    }
}

canonical_original_code:
static void dumpCmap()
{
    register int i;
    struct XColor color[256];
    for (i = 0; i < 256; i++)
 color[i].pixel = i;
    XQueryColors(dsp, ((&((_XPrivDisplay)(dsp))->screens[screen])->cmap), color, 256);
    for (i = 0; i < 256; i++) {
 printf("/name%02x	%3d %3d %3d RGBcolor def\n",
       i, color[i].red >> 8, color[i].green >> 8, color[i].blue >> 8);
    }
}

variable_types: struct XColor { unsigned long pixel; unsigned short red; char flags; char pad; } [256]


decompiled_code:
__int64 __fastcall redisplay_direct(Drawable a1)
{
int v1; // ecx
int v2; // edx
bool v3; // zf
int v4; // esi
int v5; // eax
int v6; // er14
int v7; // ebp
float i; // xmm0_4
int v9; // er15
int v10; // ebp
float v11; // xmm0_4
int v12; // er15
int v13; // ebp
float v14; // xmm0_4
__int64 result; // rax
float v16; // [rsp+8h] [rbp-50h]
int v17; // [rsp+10h] [rbp-48h]
unsigned int v18; // [rsp+10h] [rbp-48h]
int v19; // [rsp+14h] [rbp-44h]
int j; // [rsp+14h] [rbp-44h]
int v21; // [rsp+14h] [rbp-44h]
float v22; // [rsp+18h] [rbp-40h]
float v23; // [rsp+18h] [rbp-40h]
float v24; // [rsp+1Ch] [rbp-3Ch]

v24 = *(float *)&LC1;
v16 = *(float *)&LC2;
if ( win == a1 )
{
v16 = (float)width * 0.0625;
v24 = (float)height / 48.0;
}
LOBYTE(v1) = roffset_2;
if ( !got_offsets_3 )
{
v2 = -1;
got_offsets_3 = 1;
v3 = !_BitScanForward((unsigned int *)&v1, visual->red_mask);
if ( v3 )
v1 = -1;
v3 = !_BitScanForward((unsigned int *)&v4, visual->green_mask);
roffset_2 = v1;
if ( v3 )
v4 = -1;
v3 = !_BitScanForward((unsigned int *)&v5, visual->blue_mask);
goffset_1 = v4;
if ( !v3 )
v2 = v5;
boffset_0 = v2;
}
v17 = 0;
v19 = 0;
v22 = (float)0;
while ( 1 )
{
++v17;
v6 = 0;
v7 = (int)(float)(v22 * v24);
v22 = (float)v17;
for ( i = (float)0; ; i = (float)v6 )
{
++v6;
XSetForeground(dsp, gc, (v19 - 1 + v6) << v1);
XFillRectangle(
dsp,
a1,
gc,
(int)(float)(i * v16),
v7,
(int)(float)((float)(v16 * (float)v6) - (float)(int)(float)(i * v16)),
(int)(float)((float)((float)v17 * v24) - (float)v7));
if ( v6 == 16 )
break;
LOBYTE(v1) = roffset_2;
}
v19 += 16;
if ( v17 == 16 )
break;
LOBYTE(v1) = roffset_2;
}
for ( j = 0; j != 256; j += 16 )
{
++v17;
v9 = 0;
v10 = (int)(float)(v22 * v24);
v22 = (float)v17;
v11 = (float)0;
do
{
++v9;
XSetForeground(dsp, gc, (j - 1 + v9) << goffset_1);
XFillRectangle(
dsp,
a1,
gc,
(int)(float)(v11 * v16),
v10,
(int)(float)((float)(v16 * (float)v9) - (float)(int)(float)(v11 * v16)),
(int)(float)((float)((float)v17 * v24) - (float)v10));
v11 = (float)v9;
}
while ( v9 != 16 );
}
v18 = 0;
v21 = 32;
v23 = (float)32;
do
{
++v21;
v12 = 0;
v13 = (int)(float)(v23 * v24);
v23 = (float)v21;
v14 = (float)0;
do
{
++v12;
XSetForeground(dsp, gc, (int)((v18 - 1 + v12) << boffset_0));
XFillRectangle(
dsp,
a1,
gc,
(int)(float)(v14 * v16),
v13,
(int)(float)((float)(v16 * (float)v12) - (float)(int)(float)(v14 * v16)),
(int)(float)((float)((float)v21 * v24) - (float)v13));
v14 = (float)v12;
}
while ( v12 != 16 );
v18 += 16;
result = v18;
}
while ( v18 != 256 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(Drawable a1)
{
int v1; // ecx
int v2; // edx
bool v3; // zf
int v4; // esi
int v5; // eax
int v6; // er14
int v7; // ebp
float i; // xmm0_4
int v9; // er15
int v10; // ebp
float v11; // xmm0_4
int v12; // er15
int v13; // ebp
float v14; // xmm0_4
__int64 result; // rax
float v16; // [rsp+8h] [rbp-50h]
int v17; // [rsp+10h] [rbp-48h]
unsigned int v18; // [rsp+10h] [rbp-48h]
int v19; // [rsp+14h] [rbp-44h]
int j; // [rsp+14h] [rbp-44h]
int v21; // [rsp+14h] [rbp-44h]
float v22; // [rsp+18h] [rbp-40h]
float v23; // [rsp+18h] [rbp-40h]
float v24; // [rsp+1Ch] [rbp-3Ch]

v24 = *(float *)&LC1;
v16 = *(float *)&LC2;
if ( win == a1 )
{
v16 = (float)width * 0.0625;
v24 = (float)height / 48.0;
}
LOBYTE(v1) = roffset_2;
if ( !got_offsets_3 )
{
v2 = -1;
got_offsets_3 = 1;
v3 = !_BitScanForward((unsigned int *)&v1, visual->red_mask);
if ( v3 )
v1 = -1;
v3 = !_BitScanForward((unsigned int *)&v4, visual->green_mask);
roffset_2 = v1;
if ( v3 )
v4 = -1;
v3 = !_BitScanForward((unsigned int *)&v5, visual->blue_mask);
goffset_1 = v4;
if ( !v3 )
v2 = v5;
boffset_0 = v2;
}
v17 = 0;
v19 = 0;
v22 = (float)0;
while ( 1 )
{
++v17;
v6 = 0;
v7 = (int)(float)(v22 * v24);
v22 = (float)v17;
for ( i = (float)0; ; i = (float)v6 )
{
++v6;
XSetForeground(dsp, gc, (v19 - 1 + v6) << v1);
XFillRectangle(
dsp,
a1,
gc,
(int)(float)(i * v16),
v7,
(int)(float)((float)(v16 * (float)v6) - (float)(int)(float)(i * v16)),
(int)(float)((float)((float)v17 * v24) - (float)v7));
if ( v6 == 16 )
break;
LOBYTE(v1) = roffset_2;
}
v19 += 16;
if ( v17 == 16 )
break;
LOBYTE(v1) = roffset_2;
}
for ( j = 0; j != 256; j += 16 )
{
++v17;
v9 = 0;
v10 = (int)(float)(v22 * v24);
v22 = (float)v17;
v11 = (float)0;
do
{
++v9;
XSetForeground(dsp, gc, (j - 1 + v9) << goffset_1);
XFillRectangle(
dsp,
a1,
gc,
(int)(float)(v11 * v16),
v10,
(int)(float)((float)(v16 * (float)v9) - (float)(int)(float)(v11 * v16)),
(int)(float)((float)((float)v17 * v24) - (float)v10));
v11 = (float)v9;
}
while ( v9 != 16 );
}
v18 = 0;
v21 = 32;
v23 = (float)32;
do
{
++v21;
v12 = 0;
v13 = (int)(float)(v23 * v24);
v23 = (float)v21;
v14 = (float)0;
do
{
++v12;
XSetForeground(dsp, gc, (int)((v18 - 1 + v12) << boffset_0));
XFillRectangle(
dsp,
a1,
gc,
(int)(float)(v14 * v16),
v13,
(int)(float)((float)(v16 * (float)v12) - (float)(int)(float)(v14 * v16)),
(int)(float)((float)((float)v21 * v24) - (float)v13));
v14 = (float)v12;
}
while ( v12 != 16 );
v18 += 16;
result = v18;
}
while ( v18 != 256 );
return result;
}

original_code:
static void
redisplay_direct(Window window)
{
    register int i,
                j, k;
    register float fw;
    register float fh;
    static int roffset, goffset, boffset;
    static int got_offsets = 0;
    if (window == win) {
 fw = (float) width / 16.0;
 fh = (float) height / (3 * 16.0);
    } else {
 fw = (float) 48 / 16.0;
 fh = (float) 48 / (3 * 16.0);
    }
    if (!got_offsets) {
 got_offsets = 1;
 roffset = ffs(visual->red_mask)-1;
 goffset = ffs(visual->green_mask)-1;
 boffset = ffs(visual->blue_mask)-1;
    }
    k = 0;
    for (i = 0; i < 16; i++, k++) {
 register int y = (int) (k * fh);
 register int h = (k + 1) * fh - y;
 for (j = 0; j < 16; j++) {
     register int x = (int) (j * fw);
     register int w = (j + 1) * fw - x;
     XSetForeground(dsp, gc, (i * 16 + j)<<roffset);
     XFillRectangle(dsp, window, gc, x, y, w, h);
 }
    }
    for (i = 0; i < 16; i++, k++) {
 register int y = (int) (k * fh);
 register int h = (k + 1) * fh - y;
 for (j = 0; j < 16; j++) {
     register int x = (int) (j * fw);
     register int w = (j + 1) * fw - x;
     XSetForeground(dsp, gc, (i * 16 + j)<<goffset);
     XFillRectangle(dsp, window, gc, x, y, w, h);
 }
    }
    for (i = 0; i < 16; i++, k++) {
 register int y = (int) (k * fh);
 register int h = (k + 1) * fh - y;
 for (j = 0; j < 16; j++) {
     register int x = (int) (j * fw);
     register int w = (j + 1) * fw - x;
     XSetForeground(dsp, gc, (i * 16 + j)<<boffset);
     XFillRectangle(dsp, window, gc, x, y, w, h);
 }
    }
}

canonical_original_code:
static void redisplay_direct(unsigned long window)
{
    register int i; register int j; register int k;
    register float fw;
    register float fh;
    static int roffset; static int goffset; static int boffset;
    static int got_offsets = 0;
    if (window == win) {
 fw = (float) width / 16.0;
 fh = (float) height / (3 * 16.0);
    } else {
 fw = (float) 48 / 16.0;
 fh = (float) 48 / (3 * 16.0);
    }
    if (!got_offsets) {
 got_offsets = 1;
 roffset = ffs(visual->red_mask)-1;
 goffset = ffs(visual->green_mask)-1;
 boffset = ffs(visual->blue_mask)-1;
    }
    k = 0;
    for (i = 0; i < 16; i++, k++) {
 register int y = (int) (k * fh);
 register int h = (k + 1) * fh - y;
 for (j = 0; j < 16; j++) {
     register int x = (int) (j * fw);
     register int w = (j + 1) * fw - x;
     XSetForeground(dsp, gc, (i * 16 + j)<<roffset);
     XFillRectangle(dsp, window, gc, x, y, w, h);
 }
    }
    for (i = 0; i < 16; i++, k++) {
 register int y = (int) (k * fh);
 register int h = (k + 1) * fh - y;
 for (j = 0; j < 16; j++) {
     register int x = (int) (j * fw);
     register int w = (j + 1) * fw - x;
     XSetForeground(dsp, gc, (i * 16 + j)<<goffset);
     XFillRectangle(dsp, window, gc, x, y, w, h);
 }
    }
    for (i = 0; i < 16; i++, k++) {
 register int y = (int) (k * fh);
 register int h = (k + 1) * fh - y;
 for (j = 0; j < 16; j++) {
     register int x = (int) (j * fw);
     register int w = (j + 1) * fw - x;
     XSetForeground(dsp, gc, (i * 16 + j)<<boffset);
     XFillRectangle(dsp, window, gc, x, y, w, h);
 }
    }
}

variable_types:
window
unsigned long

variable_types: j int

variable_types: k int

variable_types: fw float

variable_types: fh float

variable_types: roffset int

variable_types: goffset int

variable_types: boffset int

variable_types: y int

variable_types: h int

variable_types: x int

variable_types: w int


decompiled_code:
__int64 __fastcall redisplay_indexed(Drawable a1)
{
int v1; // xmm0_4
double v2; // xmm0_8
double v3; // xmm0_8
int v4; // eax
__int64 result; // rax
int v6; // ebx
unsigned __int64 v7; // r15
int v8; // ebp
float v9; // xmm0_4
unsigned __int64 v10; // rdx
__int64 v11; // [rsp-10h] [rbp-78h]
float v12; // [rsp+8h] [rbp-60h]
int v13; // [rsp+10h] [rbp-58h]
int v14; // [rsp+14h] [rbp-54h]
unsigned __int64 v15; // [rsp+18h] [rbp-50h]
float v16; // [rsp+20h] [rbp-48h]
float v17; // [rsp+24h] [rbp-44h]

v13 = cmap_size;
if ( cmap_size == 16 )
{
v13 = 4;
v1 = LC6;
}
else if ( cmap_size == 256 )
{
v13 = 16;
v1 = LC5;
}
else
{
v1 = LC7;
if ( cmap_size != 2 )
{
v2 = (double)cmap_size;
if ( (double)cmap_size < 0.0 )
v3 = sqrt(v2);
else
v3 = sqrt(v2);
v4 = (int)v3;
*(float *)&v1 = (float)(int)v3;
v13 = v4;
}
}
if ( win == a1 )
{
v12 = (float)width / *(float *)&v1;
v17 = (float)height / *(float *)&v1;
}
else
{
v12 = 48.0 / *(float *)&v1;
v17 = 48.0 / *(float *)&v1;
}
result = v13;
if ( v13 > 0 )
{
v14 = 0;
v15 = 0LL;
v16 = (float)0;
do
{
++v14;
v6 = 0;
v7 = v15;
v8 = (int)(float)(v16 * v17);
v16 = (float)v14;
v9 = (float)0;
do
{
v10 = v7;
++v6;
++v7;
XSetForeground(dsp, gc, v10);
XFillRectangle(
dsp,
a1,
gc,
(int)(float)(v9 * v12),
v8,
(int)(float)((float)(v12 * (float)v6) - (float)(int)(float)(v9 * v12)),
(int)(float)((float)((float)v14 * v17) - (float)v8));
result = v11;
v9 = (float)v6;
}
while ( v6 != v13 );
v15 += v13;
}
while ( v14 != v13 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(Drawable a1)
{
int v1; // xmm0_4
double v2; // xmm0_8
double v3; // xmm0_8
int v4; // eax
__int64 result; // rax
int v6; // ebx
unsigned __int64 v7; // r15
int v8; // ebp
float v9; // xmm0_4
unsigned __int64 v10; // rdx
__int64 v11; // [rsp-10h] [rbp-78h]
float v12; // [rsp+8h] [rbp-60h]
int v13; // [rsp+10h] [rbp-58h]
int v14; // [rsp+14h] [rbp-54h]
unsigned __int64 v15; // [rsp+18h] [rbp-50h]
float v16; // [rsp+20h] [rbp-48h]
float v17; // [rsp+24h] [rbp-44h]

v13 = cmap_size;
if ( cmap_size == 16 )
{
v13 = 4;
v1 = LC6;
}
else if ( cmap_size == 256 )
{
v13 = 16;
v1 = LC5;
}
else
{
v1 = LC7;
if ( cmap_size != 2 )
{
v2 = (double)cmap_size;
if ( (double)cmap_size < 0.0 )
v3 = sqrt(v2);
else
v3 = sqrt(v2);
v4 = (int)v3;
*(float *)&v1 = (float)(int)v3;
v13 = v4;
}
}
if ( win == a1 )
{
v12 = (float)width / *(float *)&v1;
v17 = (float)height / *(float *)&v1;
}
else
{
v12 = 48.0 / *(float *)&v1;
v17 = 48.0 / *(float *)&v1;
}
result = v13;
if ( v13 > 0 )
{
v14 = 0;
v15 = 0LL;
v16 = (float)0;
do
{
++v14;
v6 = 0;
v7 = v15;
v8 = (int)(float)(v16 * v17);
v16 = (float)v14;
v9 = (float)0;
do
{
v10 = v7;
++v6;
++v7;
XSetForeground(dsp, gc, v10);
XFillRectangle(
dsp,
a1,
gc,
(int)(float)(v9 * v12),
v8,
(int)(float)((float)(v12 * (float)v6) - (float)(int)(float)(v9 * v12)),
(int)(float)((float)((float)v14 * v17) - (float)v8));
result = v11;
v9 = (float)v6;
}
while ( v6 != v13 );
v15 += v13;
}
while ( v14 != v13 );
}
return result;
}

original_code:
static void
redisplay_indexed(Window window)
{
    int max;
    register int i,
                 j;
    register float fw;
    register float fh;
    switch (cmap_size) {
        case 2: max = 2; break;
        case 16: max = 4; break;
        case 256: max = 16; break;
        default: max = (int)sqrt((double)cmap_size);
    }
    if (window == win) {
 fw = (float) width / (float)max;
 fh = (float) height / (float)max;
    } else {
 fw = (float) 48 / (float)max;
 fh = (float) 48 / (float)max;
    }
    for (i = 0; i < max; i++) {
 register int y = (int) (i * fh);
 register int h = (i + 1) * fh - y;
 for (j = 0; j < max; j++) {
     register int x = (int) (j * fw);
     register int w = (j + 1) * fw - x;
     XSetForeground(dsp, gc, i * max + j);
     XFillRectangle(dsp, window, gc, x, y, w, h);
 }
    }
}

canonical_original_code:
static void redisplay_indexed(unsigned long window)
{
    int max;
    register int i; register int j;
    register float fw;
    register float fh;
    switch (cmap_size) {
        case 2: max = 2; break;
        case 16: max = 4; break;
        case 256: max = 16; break;
        default: max = (int)sqrt((double)cmap_size);
    }
    if (window == win) {
 fw = (float) width / (float)max;
 fh = (float) height / (float)max;
    } else {
 fw = (float) 48 / (float)max;
 fh = (float) 48 / (float)max;
    }
    for (i = 0; i < max; i++) {
 register int y = (int) (i * fh);
 register int h = (i + 1) * fh - y;
 for (j = 0; j < max; j++) {
     register int x = (int) (j * fw);
     register int w = (j + 1) * fw - x;
     XSetForeground(dsp, gc, i * max + j);
     XFillRectangle(dsp, window, gc, x, y, w, h);
 }
    }
}

variable_types: max int


redisplay

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

if ( (unsigned int)(visual->c_class - 4) <= 1 )
result = redisplay_direct(a1);
else
result = redisplay_indexed(a1);
return result;
}

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

if ( (unsigned int)(visual->c_class - 4) <= 1 )
result = func1(a1);
else
result = func2(a1);
return result;
}

original_code:
static void
redisplay (Window w)
{
    if (visual->class == 4 || visual->class == 5)
     redisplay_direct(w);
    else
     redisplay_indexed(w);
}

canonical_original_code:
static void redisplay(unsigned long w)
{
    if (visual->class == 4 || visual->class == 5)
     redisplay_direct(w);
    else
     redisplay_indexed(w);
}

variable_types:
w
unsigned long