yyparse

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

if ( yydebug )
fwrite("Starting parse\n", 1uLL, 0xFuLL, stderr);
v0 = v81;
yynerrs = 0;
v1 = (__int16 *)src;
v71 = v81;
v2 = 200LL;
v3 = src;
yychar = -2;
v78 = 0;
v56 = 0;
while ( 1 )
{
*v1 = v56;
v4 = 2 * v2;
if ( v1 < (__int16 *)&v3[2 * v2 - 2] )
goto LABEL_40;
v5 = (char *)v1 - v3;
v6 = (((char *)v1 - v3) >> 1) + 1;
if ( v2 > 0x270F )
goto LABEL_124;
v2 = 10000LL;
if ( v4 <= 0x2710 )
v2 = v4;
v7 = (__int16 *)malloc(10 * v2 + 7);
v8 = v7;
if ( !v7 )
{
LABEL_124:
v54 = v1;
v55 = 2;
yyerror("memory exhausted");
v1 = (__int16 *)v3;
goto LABEL_60;
}
memcpy(v7, v3, v5 + 2);
v9 = (char *)memcpy(&v8[v2], v71, 8 * v6);
v10 = 8 * v6;
v11 = v9;
if ( v3 != src )
{
v72 = v9;
free(v3);
v11 = v72;
v10 = 8 * v6;
}
v1 = (__int16 *)((char *)v8 + v5);
v12 = (unsigned __int64)&v8[v2 - 1];
v0 = &v11[v10 - 8];
if ( yydebug )
break;
if ( (unsigned __int64)v1 >= v12 )
{
v20 = yychar;
v54 = v1;
v55 = 1;
v1 = v8;
if ( yychar == -2 )
goto LABEL_67;
goto LABEL_61;
}
v71 = v11;
v3 = (char *)v8;
LABEL_14:
if ( v56 == 13 )
{
v54 = v1;
v55 = 0;
v1 = (__int16 *)v3;
goto LABEL_60;
}
v13 = v56;
v14 = yypact[v56];
v15 = v14;
if ( v14 == -18 )
{
LABEL_22:
v18 = (unsigned __int8)yydefact[v13];
v19 = yydefact[v13];
if ( v19 )
{
v23 = (unsigned __int8)yyr2[(unsigned __int8)yydefact[v13]];
v24 = (unsigned __int8)yyr2[(unsigned __int8)yydefact[v13]];
v25 = *(_QWORD *)&v0[8 * (1 - v23)];
if ( yydebug )
{
yy_reduce_print_isra_0((__int64)v1, v18);
v24 = (unsigned __int8)v23;
v19 = v18;
}
switch ( v19 )
{
case 2:
v61 = v24;
v37 = "command2 EOL";
goto LABEL_88;
case 3:
v61 = v24;
v37 = "command2 pipe_list EOL";
goto LABEL_88;
case 4:
v61 = v24;
v37 = "command2 input EOL";
goto LABEL_88;
case 5:
v61 = v24;
v37 = "command2 output EOL";
goto LABEL_88;
case 6:
v61 = v24;
v37 = "command2 pipe_list input EOL";
goto LABEL_88;
case 7:
v61 = v24;
v37 = "command2 pipe_list output EOL";
goto LABEL_88;
case 8:
v61 = v24;
v37 = "command2 input output EOL";
goto LABEL_88;
case 9:
v61 = v24;
v37 = "command2 pipe_list input output EOL";
goto LABEL_88;
case 10:
v63 = v24;
v41 = v1;
YaccDebug("error EOL");
v1 = (__int16 *)v3;
v55 = 1;
v54 = &v41[-v63];
goto LABEL_60;
case 11:
v61 = v24;
v37 = "EOL";
LABEL_88:
v38 = v1;
v55 = 0;
v1 = (__int16 *)v3;
YaccDebug(v37);
v54 = &v38[-v61];
goto LABEL_60;
case 12:
v62 = v24;
v39 = "WORD";
goto LABEL_92;
case 13:
v62 = v24;
v39 = "WORD arg_list";
LABEL_92:
YaccDebug(v39);
v40 = v62;
v32 = 2;
v56 = 30;
v1 -= v40;
v31 = &v0[-8 * v40];
break;
case 14:
v70 = v24;
YaccDebug("PIPE command2");
v53 = v70;
v32 = 3;
v56 = 31;
v1 -= v53;
v31 = &v0[-8 * v53];
break;
case 15:
v69 = v24;
v51 = "pipe";
goto LABEL_117;
case 16:
v69 = v24;
v51 = "pipe pipe_list";
LABEL_117:
YaccDebug(v51);
v52 = v69;
v32 = 4;
v56 = 32;
v1 -= v52;
v31 = &v0[-8 * v52];
break;
case 17:
v68 = v24;
YaccDebug("LESS WORD");
v50 = v68;
v32 = 5;
v56 = 33;
v1 -= v50;
v31 = &v0[-8 * v50];
break;
case 18:
v67 = v24;
v48 = "output2";
goto LABEL_112;
case 19:
v67 = v24;
v48 = "output2 error_redir";
goto LABEL_112;
case 20:
v67 = v24;
v48 = "error_redir";
LABEL_112:
YaccDebug(v48);
v49 = v67;
v32 = 6;
v56 = 34;
v1 -= v49;
v31 = &v0[-8 * v49];
break;
case 21:
v66 = v24;
v46 = "GREATER WORD";
goto LABEL_109;
case 22:
v66 = v24;
v46 = "GTGT WORD";
LABEL_109:
YaccDebug(v46);
v47 = v66;
v32 = 7;
v56 = 35;
v1 -= v47;
v31 = &v0[-8 * v47];
break;
case 23:
v65 = v24;
v44 = "TWOGT WORD";
goto LABEL_106;
case 24:
v65 = v24;
v44 = "GTAMP";
LABEL_106:
YaccDebug(v44);
v45 = v65;
v32 = 8;
v56 = 36;
v1 -= v45;
v31 = &v0[-8 * v45];
break;
case 25:
v64 = v24;
v42 = "INTEGER";
goto LABEL_101;
case 26:
v64 = v24;
v42 = "WORD";
goto LABEL_101;
case 27:
v64 = v24;
v42 = "STRING";
goto LABEL_101;
case 28:
v64 = v24;
v42 = "MINUS arg";
LABEL_101:
YaccDebug(v42);
v43 = v64;
v32 = 9;
v56 = 37;
v1 -= v43;
v31 = &v0[-8 * v43];
break;
case 29:
v60 = v24;
v35 = "arg";
goto LABEL_85;
case 30:
v60 = v24;
v35 = "arg_list";
LABEL_85:
YaccDebug(v35);
v36 = v60;
v32 = 10;
v56 = 38;
v1 -= v36;
v31 = &v0[-8 * v36];
break;
default:
v1 -= v24;
v56 = (unsigned __int8)yyr1[v18];
v31 = &v0[-8 * v24];
v32 = v56 - 28;
break;
}
LABEL_76:
if ( yydebug )
{
v79 = v32;
v75 = v31;
fprintf(stderr, "%s ", "-> $$ =");
yy_symbol_print_constprop_0(stderr, v56);
fputc(10, stderr);
v31 = v75;
v32 = v79;
if ( yydebug )
{
v76 = v79;
v59 = v31;
yy_stack_print((__int16 *)v3, (unsigned __int64)v1);
v32 = v76;
v31 = v59;
}
}
goto LABEL_77;
}
v20 = yychar;
v21 = -2;
if ( yychar != -2 )
{
v21 = 2;
if ( (unsigned int)yychar <= 0x11A )
v21 = (unsigned __int8)yytranslate[yychar];
}
if ( !v78 )
{
++yynerrs;
yyerror("syntax error");
goto LABEL_32;
}
if ( v78 == 3 )
{
if ( yychar > 0 )
{
yydestruct_isra_0("Error: discarding", v21);
yychar = -2;
goto LABEL_32;
}
if ( !yychar )
{
v54 = v1;
v55 = 1;
v1 = (__int16 *)v3;
goto LABEL_62;
}
}
LABEL_32:
while ( 1 )
{
if ( v14 != -18 )
{
v22 = v14 + 1;
if ( v22 <= 0x34 && yycheck[v22] == 1 )
{
v26 = (unsigned __int8)yytable[v22];
if ( v26 )
break;
}
}
if ( v3 == (char *)v1 )
{
v54 = v1;
v55 = 1;
goto LABEL_60;
}
--v1;
v0 -= 8;
yydestruct_isra_0("Error: popping", (unsigned __int8)yystos[v13]);
v13 = *v1;
if ( yydebug )
yy_stack_print((__int16 *)v3, (unsigned __int64)v1);
v14 = yypact[v13];
}
v27 = yydebug;
*((_QWORD *)v0 + 1) = yylval;
if ( v27 )
{
v0 += 8;
fprintf(stderr, "%s ", "Shifting");
yy_symbol_print_constprop_0(stderr, (unsigned __int8)yystos[v26]);
fputc(10, stderr);
v56 = v26;
}
else
{
v56 = v26;
v0 += 8;
}
v78 = 3;
goto LABEL_51;
}
v16 = yychar;
if ( yychar == -2 )
{
if ( yydebug )
{
fwrite("Reading a token: ", 1uLL, 0x11uLL, stderr);
v15 = v14;
}
v58 = v15;
v16 = yylex();
v15 = v58;
yychar = v16;
}
if ( v16 <= 0 )
{
yychar = 0;
v17 = 0;
if ( yydebug )
{
v73 = v15;
fwrite("Now at end of input.\n", 1uLL, 0x15uLL, stderr);
v17 = 0;
v15 = v73;
}
}
else
{
v17 = 2;
if ( v16 <= 282 )
{
v17 = (unsigned __int8)yytranslate[v16];
v15 = v14 + v17;
if ( yydebug )
{
LABEL_53:
v57 = v17;
v74 = v15;
fprintf(stderr, "%s ", "Next token is");
yy_symbol_print_constprop_0(stderr, v57);
fputc(10, stderr);
v15 = v74;
v17 = v57;
goto LABEL_20;
}
}
else
{
v15 = v14 + 2;
if ( yydebug )
goto LABEL_53;
}
}
LABEL_20:
if ( v15 > 0x34 || (unsigned __int8)yycheck[v15] != v17 )
goto LABEL_22;
v56 = (unsigned __int8)yytable[v15];
if ( !yytable[v15] )
{
v25 = *((_QWORD *)v0 + 1);
if ( yydebug )
{
yy_reduce_print_isra_0((__int64)v1, 0);
v31 = v0;
v32 = -28;
goto LABEL_76;
}
v31 = v0;
v32 = -28;
LABEL_77:
v33 = *v1;
*((_QWORD *)v31 + 1) = v25;
v0 = v31 + 8;
v34 = v33 + yypgoto[v32];
if ( v34 <= 0x34 && v33 == (unsigned __int8)yycheck[v34] )
v56 = (unsigned __int8)yytable[v34];
else
v56 = yydefgoto[v32];
goto LABEL_51;
}
v78 = (v78 == 0) + v78 - 1;
if ( yydebug )
{
v77 = v17;
fprintf(stderr, "%s ", "Shifting");
yy_symbol_print_constprop_0(stderr, v77);
fputc(10, stderr);
}
v0 += 8;
yychar = -2;
*(_QWORD *)v0 = yylval;
LABEL_51:
++v1;
}
v71 = v11;
fprintf(stderr, "Stack size increased to %lu\n", v2);
if ( (unsigned __int64)v1 < v12 )
{
v3 = (char *)v8;
LABEL_40:
if ( yydebug )
fprintf(stderr, "Entering state %d\n", (unsigned int)v56);
goto LABEL_14;
}
v54 = v1;
v55 = 1;
v1 = v8;
LABEL_60:
v20 = yychar;
if ( yychar == -2 )
goto LABEL_64;
LABEL_61:
v28 = 2;
if ( (unsigned int)v20 > 0x11A )
goto LABEL_63;
LABEL_62:
v28 = (unsigned __int8)yytranslate[v20];
LABEL_63:
yydestruct_isra_0("Cleanup: discarding lookahead", v28);
LABEL_64:
if ( yydebug )
yy_stack_print(v1, (unsigned __int64)v54);
LABEL_67:
while ( v1 != v54 )
{
v29 = *v54--;
yydestruct_isra_0("Cleanup: popping", (unsigned __int8)yystos[v29]);
}
if ( v1 != (__int16 *)src )
free(v1);
return v55;
}

canonical_decompiled_code:
__int64 func6()
{
char *v0; // rbx
__int16 *v1; // r14
unsigned __int64 v2; // r12
char *v3; // rbp
unsigned __int64 v4; // rax
signed __int64 v5; // rbx
__int64 v6; // r15
__int16 *v7; // rax
__int16 *v8; // r13
char *v9; // rax
__int64 v10; // rdx
char *v11; // r10
unsigned __int64 v12; // rbp
__int64 v13; // r13
unsigned int v14; // er15
unsigned int v15; // er11
int v16; // eax
int v17; // er10
int v18; // esi
char v19; // al
__int64 v20; // rax
int v21; // esi
unsigned int v22; // er15
int v23; // edi
__int64 v24; // rdx
__int64 v25; // r13
int v26; // er15
int v27; // edx
int v28; // esi
__int64 v29; // rax
char *v31; // r10
int v32; // ecx
int v33; // esi
unsigned int v34; // eax
const char *v35; // rdi
__int64 v36; // rdx
const char *v37; // rdi
__int16 *v38; // rbx
const char *v39; // rdi
__int64 v40; // rdx
__int16 *v41; // rbx
const char *v42; // rdi
__int64 v43; // rdx
const char *v44; // rdi
__int64 v45; // rdx
const char *v46; // rdi
__int64 v47; // rdx
const char *v48; // rdi
__int64 v49; // rdx
__int64 v50; // rdx
const char *v51; // rdi
__int64 v52; // rdx
__int64 v53; // rdx
__int16 *v54; // rbx
unsigned int v55; // er12
int v56; // [rsp+0h] [rbp-828h]
int v57; // [rsp+0h] [rbp-828h]
unsigned int v58; // [rsp+0h] [rbp-828h]
char *v59; // [rsp+0h] [rbp-828h]
unsigned __int8 v60; // [rsp+0h] [rbp-828h]
unsigned __int8 v61; // [rsp+0h] [rbp-828h]
unsigned __int8 v62; // [rsp+0h] [rbp-828h]
unsigned __int8 v63; // [rsp+0h] [rbp-828h]
unsigned __int8 v64; // [rsp+0h] [rbp-828h]
unsigned __int8 v65; // [rsp+0h] [rbp-828h]
unsigned __int8 v66; // [rsp+0h] [rbp-828h]
unsigned __int8 v67; // [rsp+0h] [rbp-828h]
unsigned __int8 v68; // [rsp+0h] [rbp-828h]
unsigned __int8 v69; // [rsp+0h] [rbp-828h]
unsigned __int8 v70; // [rsp+0h] [rbp-828h]
char *v71; // [rsp+8h] [rbp-820h]
char *v72; // [rsp+10h] [rbp-818h]
unsigned int v73; // [rsp+10h] [rbp-818h]
unsigned int v74; // [rsp+10h] [rbp-818h]
char *v75; // [rsp+10h] [rbp-818h]
int v76; // [rsp+10h] [rbp-818h]
int v77; // [rsp+10h] [rbp-818h]
int v78; // [rsp+18h] [rbp-810h]
int v79; // [rsp+1Ch] [rbp-80Ch]
char src[400]; // [rsp+20h] [rbp-808h] BYREF
char v81[1656]; // [rsp+1B0h] [rbp-678h] BYREF

if ( yydebug )
fwrite("Starting parse\n", 1uLL, 0xFuLL, stderr);
v0 = v81;
yynerrs = 0;
v1 = (__int16 *)src;
v71 = v81;
v2 = 200LL;
v3 = src;
yychar = -2;
v78 = 0;
v56 = 0;
while ( 1 )
{
*v1 = v56;
v4 = 2 * v2;
if ( v1 < (__int16 *)&v3[2 * v2 - 2] )
goto LABEL_40;
v5 = (char *)v1 - v3;
v6 = (((char *)v1 - v3) >> 1) + 1;
if ( v2 > 0x270F )
goto LABEL_124;
v2 = 10000LL;
if ( v4 <= 0x2710 )
v2 = v4;
v7 = (__int16 *)malloc(10 * v2 + 7);
v8 = v7;
if ( !v7 )
{
LABEL_124:
v54 = v1;
v55 = 2;
func4("memory exhausted");
v1 = (__int16 *)v3;
goto LABEL_60;
}
memcpy(v7, v3, v5 + 2);
v9 = (char *)memcpy(&v8[v2], v71, 8 * v6);
v10 = 8 * v6;
v11 = v9;
if ( v3 != src )
{
v72 = v9;
free(v3);
v11 = v72;
v10 = 8 * v6;
}
v1 = (__int16 *)((char *)v8 + v5);
v12 = (unsigned __int64)&v8[v2 - 1];
v0 = &v11[v10 - 8];
if ( yydebug )
break;
if ( (unsigned __int64)v1 >= v12 )
{
v20 = yychar;
v54 = v1;
v55 = 1;
v1 = v8;
if ( yychar == -2 )
goto LABEL_67;
goto LABEL_61;
}
v71 = v11;
v3 = (char *)v8;
LABEL_14:
if ( v56 == 13 )
{
v54 = v1;
v55 = 0;
v1 = (__int16 *)v3;
goto LABEL_60;
}
v13 = v56;
v14 = yypact[v56];
v15 = v14;
if ( v14 == -18 )
{
LABEL_22:
v18 = (unsigned __int8)yydefact[v13];
v19 = yydefact[v13];
if ( v19 )
{
v23 = (unsigned __int8)yyr2[(unsigned __int8)yydefact[v13]];
v24 = (unsigned __int8)yyr2[(unsigned __int8)yydefact[v13]];
v25 = *(_QWORD *)&v0[8 * (1 - v23)];
if ( yydebug )
{
func3((__int64)v1, v18);
v24 = (unsigned __int8)v23;
v19 = v18;
}
switch ( v19 )
{
case 2:
v61 = v24;
v37 = "command2 EOL";
goto LABEL_88;
case 3:
v61 = v24;
v37 = "command2 pipe_list EOL";
goto LABEL_88;
case 4:
v61 = v24;
v37 = "command2 input EOL";
goto LABEL_88;
case 5:
v61 = v24;
v37 = "command2 output EOL";
goto LABEL_88;
case 6:
v61 = v24;
v37 = "command2 pipe_list input EOL";
goto LABEL_88;
case 7:
v61 = v24;
v37 = "command2 pipe_list output EOL";
goto LABEL_88;
case 8:
v61 = v24;
v37 = "command2 input output EOL";
goto LABEL_88;
case 9:
v61 = v24;
v37 = "command2 pipe_list input output EOL";
goto LABEL_88;
case 10:
v63 = v24;
v41 = v1;
func5("error EOL");
v1 = (__int16 *)v3;
v55 = 1;
v54 = &v41[-v63];
goto LABEL_60;
case 11:
v61 = v24;
v37 = "EOL";
LABEL_88:
v38 = v1;
v55 = 0;
v1 = (__int16 *)v3;
func5(v37);
v54 = &v38[-v61];
goto LABEL_60;
case 12:
v62 = v24;
v39 = "WORD";
goto LABEL_92;
case 13:
v62 = v24;
v39 = "WORD arg_list";
LABEL_92:
func5(v39);
v40 = v62;
v32 = 2;
v56 = 30;
v1 -= v40;
v31 = &v0[-8 * v40];
break;
case 14:
v70 = v24;
func5("PIPE command2");
v53 = v70;
v32 = 3;
v56 = 31;
v1 -= v53;
v31 = &v0[-8 * v53];
break;
case 15:
v69 = v24;
v51 = "pipe";
goto LABEL_117;
case 16:
v69 = v24;
v51 = "pipe pipe_list";
LABEL_117:
func5(v51);
v52 = v69;
v32 = 4;
v56 = 32;
v1 -= v52;
v31 = &v0[-8 * v52];
break;
case 17:
v68 = v24;
func5("LESS WORD");
v50 = v68;
v32 = 5;
v56 = 33;
v1 -= v50;
v31 = &v0[-8 * v50];
break;
case 18:
v67 = v24;
v48 = "output2";
goto LABEL_112;
case 19:
v67 = v24;
v48 = "output2 error_redir";
goto LABEL_112;
case 20:
v67 = v24;
v48 = "error_redir";
LABEL_112:
func5(v48);
v49 = v67;
v32 = 6;
v56 = 34;
v1 -= v49;
v31 = &v0[-8 * v49];
break;
case 21:
v66 = v24;
v46 = "GREATER WORD";
goto LABEL_109;
case 22:
v66 = v24;
v46 = "GTGT WORD";
LABEL_109:
func5(v46);
v47 = v66;
v32 = 7;
v56 = 35;
v1 -= v47;
v31 = &v0[-8 * v47];
break;
case 23:
v65 = v24;
v44 = "TWOGT WORD";
goto LABEL_106;
case 24:
v65 = v24;
v44 = "GTAMP";
LABEL_106:
func5(v44);
v45 = v65;
v32 = 8;
v56 = 36;
v1 -= v45;
v31 = &v0[-8 * v45];
break;
case 25:
v64 = v24;
v42 = "INTEGER";
goto LABEL_101;
case 26:
v64 = v24;
v42 = "WORD";
goto LABEL_101;
case 27:
v64 = v24;
v42 = "STRING";
goto LABEL_101;
case 28:
v64 = v24;
v42 = "MINUS arg";
LABEL_101:
func5(v42);
v43 = v64;
v32 = 9;
v56 = 37;
v1 -= v43;
v31 = &v0[-8 * v43];
break;
case 29:
v60 = v24;
v35 = "arg";
goto LABEL_85;
case 30:
v60 = v24;
v35 = "arg_list";
LABEL_85:
func5(v35);
v36 = v60;
v32 = 10;
v56 = 38;
v1 -= v36;
v31 = &v0[-8 * v36];
break;
default:
v1 -= v24;
v56 = (unsigned __int8)yyr1[v18];
v31 = &v0[-8 * v24];
v32 = v56 - 28;
break;
}
LABEL_76:
if ( yydebug )
{
v79 = v32;
v75 = v31;
fprintf(stderr, "%s ", "-> $$ =");
func1(stderr, v56);
fputc(10, stderr);
v31 = v75;
v32 = v79;
if ( yydebug )
{
v76 = v79;
v59 = v31;
func0((__int16 *)v3, (unsigned __int64)v1);
v32 = v76;
v31 = v59;
}
}
goto LABEL_77;
}
v20 = yychar;
v21 = -2;
if ( yychar != -2 )
{
v21 = 2;
if ( (unsigned int)yychar <= 0x11A )
v21 = (unsigned __int8)yytranslate[yychar];
}
if ( !v78 )
{
++yynerrs;
func4("syntax error");
goto LABEL_32;
}
if ( v78 == 3 )
{
if ( yychar > 0 )
{
func2("Error: discarding", v21);
yychar = -2;
goto LABEL_32;
}
if ( !yychar )
{
v54 = v1;
v55 = 1;
v1 = (__int16 *)v3;
goto LABEL_62;
}
}
LABEL_32:
while ( 1 )
{
if ( v14 != -18 )
{
v22 = v14 + 1;
if ( v22 <= 0x34 && yycheck[v22] == 1 )
{
v26 = (unsigned __int8)yytable[v22];
if ( v26 )
break;
}
}
if ( v3 == (char *)v1 )
{
v54 = v1;
v55 = 1;
goto LABEL_60;
}
--v1;
v0 -= 8;
func2("Error: popping", (unsigned __int8)yystos[v13]);
v13 = *v1;
if ( yydebug )
func0((__int16 *)v3, (unsigned __int64)v1);
v14 = yypact[v13];
}
v27 = yydebug;
*((_QWORD *)v0 + 1) = yylval;
if ( v27 )
{
v0 += 8;
fprintf(stderr, "%s ", "Shifting");
func1(stderr, (unsigned __int8)yystos[v26]);
fputc(10, stderr);
v56 = v26;
}
else
{
v56 = v26;
v0 += 8;
}
v78 = 3;
goto LABEL_51;
}
v16 = yychar;
if ( yychar == -2 )
{
if ( yydebug )
{
fwrite("Reading a token: ", 1uLL, 0x11uLL, stderr);
v15 = v14;
}
v58 = v15;
v16 = yylex();
v15 = v58;
yychar = v16;
}
if ( v16 <= 0 )
{
yychar = 0;
v17 = 0;
if ( yydebug )
{
v73 = v15;
fwrite("Now at end of input.\n", 1uLL, 0x15uLL, stderr);
v17 = 0;
v15 = v73;
}
}
else
{
v17 = 2;
if ( v16 <= 282 )
{
v17 = (unsigned __int8)yytranslate[v16];
v15 = v14 + v17;
if ( yydebug )
{
LABEL_53:
v57 = v17;
v74 = v15;
fprintf(stderr, "%s ", "Next token is");
func1(stderr, v57);
fputc(10, stderr);
v15 = v74;
v17 = v57;
goto LABEL_20;
}
}
else
{
v15 = v14 + 2;
if ( yydebug )
goto LABEL_53;
}
}
LABEL_20:
if ( v15 > 0x34 || (unsigned __int8)yycheck[v15] != v17 )
goto LABEL_22;
v56 = (unsigned __int8)yytable[v15];
if ( !yytable[v15] )
{
v25 = *((_QWORD *)v0 + 1);
if ( yydebug )
{
func3((__int64)v1, 0);
v31 = v0;
v32 = -28;
goto LABEL_76;
}
v31 = v0;
v32 = -28;
LABEL_77:
v33 = *v1;
*((_QWORD *)v31 + 1) = v25;
v0 = v31 + 8;
v34 = v33 + yypgoto[v32];
if ( v34 <= 0x34 && v33 == (unsigned __int8)yycheck[v34] )
v56 = (unsigned __int8)yytable[v34];
else
v56 = yydefgoto[v32];
goto LABEL_51;
}
v78 = (v78 == 0) + v78 - 1;
if ( yydebug )
{
v77 = v17;
fprintf(stderr, "%s ", "Shifting");
func1(stderr, v77);
fputc(10, stderr);
}
v0 += 8;
yychar = -2;
*(_QWORD *)v0 = yylval;
LABEL_51:
++v1;
}
v71 = v11;
fprintf(stderr, "Stack size increased to %lu\n", v2);
if ( (unsigned __int64)v1 < v12 )
{
v3 = (char *)v8;
LABEL_40:
if ( yydebug )
fprintf(stderr, "Entering state %d\n", (unsigned int)v56);
goto LABEL_14;
}
v54 = v1;
v55 = 1;
v1 = v8;
LABEL_60:
v20 = yychar;
if ( yychar == -2 )
goto LABEL_64;
LABEL_61:
v28 = 2;
if ( (unsigned int)v20 > 0x11A )
goto LABEL_63;
LABEL_62:
v28 = (unsigned __int8)yytranslate[v20];
LABEL_63:
func2("Cleanup: discarding lookahead", v28);
LABEL_64:
if ( yydebug )
func0(v1, (unsigned __int64)v54);
LABEL_67:
while ( v1 != v54 )
{
v29 = *v54--;
func2("Cleanup: popping", (unsigned __int8)yystos[v29]);
}
if ( v1 != (__int16 *)src )
free(v1);
return v55;
}

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 == 13)
    goto yyacceptlab;
  goto yybackup;
yybackup:
  yyn = yypact[yystate];
  if ((!!((yyn) == (-18))))
    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) <= 282 ? 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 || 52 < yyn || yycheck[yyn] != yytoken)
    goto yydefault;
  yyn = yytable[yyn];
  if (yyn <= 0)
    {
      if (0)
        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 2:
    {
       YaccDebug("command2 EOL");
       goto yyacceptlab;
   }
    break;
  case 3:
    {
       YaccDebug("command2 pipe_list EOL");
       goto yyacceptlab;
   }
    break;
  case 4:
    {
       YaccDebug("command2 input EOL");
       goto yyacceptlab;
   }
    break;
  case 5:
    {
       YaccDebug("command2 output EOL");
       goto yyacceptlab;
   }
    break;
  case 6:
    {
       YaccDebug("command2 pipe_list input EOL");
       goto yyacceptlab;
   }
    break;
  case 7:
    {
       YaccDebug("command2 pipe_list output EOL");
       goto yyacceptlab;
   }
    break;
  case 8:
    {
       YaccDebug("command2 input output EOL");
       goto yyacceptlab;
   }
    break;
  case 9:
    {
       YaccDebug("command2 pipe_list input output EOL");
       goto yyacceptlab;
   }
    break;
  case 10:
    {
       YaccDebug("error EOL");
       goto yyabortlab;
   }
    break;
  case 11:
    {
       YaccDebug("EOL");
       goto yyacceptlab;
   }
    break;
  case 12:
    {
       YaccDebug("WORD");
   }
    break;
  case 13:
    {
       YaccDebug("WORD arg_list");
   }
    break;
  case 14:
    {
       YaccDebug("PIPE command2");
   }
    break;
  case 15:
    {
       YaccDebug("pipe");
   }
    break;
  case 16:
    {
       YaccDebug("pipe pipe_list");
   }
    break;
  case 17:
    {
       YaccDebug("LESS WORD");
   }
    break;
  case 18:
    {
       YaccDebug("output2");
   }
    break;
  case 19:
    {
       YaccDebug("output2 error_redir");
   }
    break;
  case 20:
    {
       YaccDebug("error_redir");
   }
    break;
  case 21:
    {
       YaccDebug("GREATER WORD");
   }
    break;
  case 22:
    {
       YaccDebug("GTGT WORD");
       }
    break;
  case 23:
    {
       YaccDebug("TWOGT WORD");
   }
    break;
  case 24:
    {
       YaccDebug("GTAMP");
   }
    break;
  case 25:
    {
       YaccDebug("INTEGER");
   }
    break;
  case 26:
    {
       YaccDebug("WORD");
   }
    break;
  case 27:
    {
       YaccDebug("STRING");
   }
    break;
  case 28:
    {
       YaccDebug("MINUS arg");
   }
    break;
  case 29:
    {
       YaccDebug("arg");
   }
    break;
  case 30:
    {
       YaccDebug("arg_list");
   }
    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] - 28;
    const int yyi = yypgoto[yylhs] + *yyssp;
    yystate = (0 <= yyi && yyi <= 52 && yycheck[yyi] == *yyssp
               ? yytable[yyi]
               : yydefgoto[yylhs]);
  }
  goto yynewstate;
yyerrlab:
  yytoken = yychar == (-2) ? (-2) : ((unsigned) (yychar) <= 282 ? 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) == (-18))))
        {
          yyn += 1;
          if (0 <= yyn && yyn <= 52 && 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) <= 282 ? 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 == 13)
    goto yyacceptlab;
  goto yybackup;
yybackup:
  yyn = yypact[yystate];
  if ((!!((yyn) == (-18))))
    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) <= 282 ? 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 || 52 < yyn || yycheck[yyn] != yytoken)
    goto yydefault;
  yyn = yytable[yyn];
  if (yyn <= 0)
    {
      if (0)
        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 2:
    {
       YaccDebug("command2 EOL");
       goto yyacceptlab;
   }
    break;
  case 3:
    {
       YaccDebug("command2 pipe_list EOL");
       goto yyacceptlab;
   }
    break;
  case 4:
    {
       YaccDebug("command2 input EOL");
       goto yyacceptlab;
   }
    break;
  case 5:
    {
       YaccDebug("command2 output EOL");
       goto yyacceptlab;
   }
    break;
  case 6:
    {
       YaccDebug("command2 pipe_list input EOL");
       goto yyacceptlab;
   }
    break;
  case 7:
    {
       YaccDebug("command2 pipe_list output EOL");
       goto yyacceptlab;
   }
    break;
  case 8:
    {
       YaccDebug("command2 input output EOL");
       goto yyacceptlab;
   }
    break;
  case 9:
    {
       YaccDebug("command2 pipe_list input output EOL");
       goto yyacceptlab;
   }
    break;
  case 10:
    {
       YaccDebug("error EOL");
       goto yyabortlab;
   }
    break;
  case 11:
    {
       YaccDebug("EOL");
       goto yyacceptlab;
   }
    break;
  case 12:
    {
       YaccDebug("WORD");
   }
    break;
  case 13:
    {
       YaccDebug("WORD arg_list");
   }
    break;
  case 14:
    {
       YaccDebug("PIPE command2");
   }
    break;
  case 15:
    {
       YaccDebug("pipe");
   }
    break;
  case 16:
    {
       YaccDebug("pipe pipe_list");
   }
    break;
  case 17:
    {
       YaccDebug("LESS WORD");
   }
    break;
  case 18:
    {
       YaccDebug("output2");
   }
    break;
  case 19:
    {
       YaccDebug("output2 error_redir");
   }
    break;
  case 20:
    {
       YaccDebug("error_redir");
   }
    break;
  case 21:
    {
       YaccDebug("GREATER WORD");
   }
    break;
  case 22:
    {
       YaccDebug("GTGT WORD");
       }
    break;
  case 23:
    {
       YaccDebug("TWOGT WORD");
   }
    break;
  case 24:
    {
       YaccDebug("GTAMP");
   }
    break;
  case 25:
    {
       YaccDebug("INTEGER");
   }
    break;
  case 26:
    {
       YaccDebug("WORD");
   }
    break;
  case 27:
    {
       YaccDebug("STRING");
   }
    break;
  case 28:
    {
       YaccDebug("MINUS arg");
   }
    break;
  case 29:
    {
       YaccDebug("arg");
   }
    break;
  case 30:
    {
       YaccDebug("arg_list");
   }
    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] - 28;
    int yyi = yypgoto[yylhs] + *yyssp;
    yystate = (0 <= yyi && yyi <= 52 && yycheck[yyi] == *yyssp
               ? yytable[yyi]
               : yydefgoto[yylhs]);
  }
  goto yynewstate;
yyerrlab:
  yytoken = yychar == (-2) ? (-2) : ((unsigned int) (yychar) <= 282 ? 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) == (-18))))
        {
          yyn += 1;
          if (0 <= yyn && yyn <= 52 && 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) <= 282 ? 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: union YYSTYPE { char ***plist; char **args; char *sb; int i; } [200]

variable_types: union YYSTYPE { char ***plist; char **args; char *sb; int i; } *

variable_types:
yystacksize
unsigned long

variable_types: yyn int

variable_types: yyresult int

variable_types: yytoken int

variable_types: yylen int

variable_types:
yysize
unsigned long

variable_types: union yyalloc { short yyss_alloc; union YYSTYPE { char ***plist; char **args; char *sb; 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; }


YaccDebug

decompiled_code:
int __fastcall YaccDebug(const char *a1)
{
int result; // eax

result = YaccDebugFlag;
if ( YaccDebugFlag )
result = fprintf(stderr, "-- %s --\n", a1);
return result;
}

canonical_decompiled_code:
int __fastcall func5(const char *a1)
{
int result; // eax

result = YaccDebugFlag;
if ( YaccDebugFlag )
result = fprintf(stderr, "-- %s --\n", a1);
return result;
}

original_code:
void YaccDebug(char *sb)
{
    if (YaccDebugFlag) {
 fprintf(stderr, "-- %s --\n", sb);
    }
}

variable_types:
sb
char *

return_type: void


repo: ajbonkoski/lcm-spy-lite

decompiled_code:
_QWORD *string_create()
{
_QWORD *v0; // rax
_QWORD *v1; // r12
_BYTE *v2; // rax

v0 = calloc(1uLL, 0x18uLL);
v0[1] = 8LL;
v1 = v0;
v2 = malloc(8uLL);
v1[2] = 0LL;
*v1 = v2;
*v2 = 0;
return v1;
}

canonical_decompiled_code:
_QWORD *func0()
{
_QWORD *v0; // rax
_QWORD *v1; // r12
_BYTE *v2; // rax

v0 = calloc(1uLL, 0x18uLL);
v0[1] = 8LL;
v1 = v0;
v2 = malloc(8uLL);
v1[2] = 0LL;
*v1 = v2;
*v2 = 0;
return v1;
}

original_code:
static inline string_t *string_create(void)
{
    string_t *this = calloc(1, sizeof(string_t));
    this->datasz = 8;
    this->data = malloc(this->datasz * sizeof(char));
    this->data[0] = '\0';
    this->len = 0;
    return this;
}

canonical_original_code:
static inline struct string_t *string_create()
{
    struct string_t *this = calloc(1, sizeof(string_t));
    this->datasz = 8;
    this->data = malloc(this->datasz * sizeof(char));
    this->data[0] = '\0';
    this->len = 0;
    return this;
}

variable_types: struct string_t { char *data; unsigned long datasz; unsigned long len; } *


decompiled_code:
void __fastcall string_destroy(void *ptr)
{
free(*(void **)ptr);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func1(void *ptr)
{
free(*(void **)ptr);
free(ptr);
}

original_code:
static inline void string_destroy(string_t *this)
{
    free(this->data);
    free(this);
}

canonical_original_code:
static inline void string_destroy(struct string_t *this)
{
    free(this->data);
    free(this);
}

user_defined_types: struct string_t { char *data; unsigned long datasz; unsigned long len; }


decompiled_code:
__int64 __fastcall is_ident_char(unsigned __int8 a1)
{
return (a1 == 95) | (unsigned __int8)(((*_ctype_b_loc())[a1] & 0xC00) != 0);
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned __int8 a1)
{
return (a1 == 95) | (unsigned __int8)(((*_ctype_b_loc())[a1] & 0xC00) != 0);
}

original_code:
static inline int is_ident_char(uint8_t ch)
{
    return ((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short int) _ISalpha) || ((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short int) _ISdigit) || ch == '_';
}

canonical_original_code:
static inline int is_ident_char(unsigned char ch)
{
    return ((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short) _ISalpha) || ((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short) _ISdigit) || ch == '_';
}

variable_types:
ch
unsigned char

return_type: int


decompiled_code:
__int64 __fastcall is_first_ident_char(unsigned __int8 a1)
{
return ((a1 == 95) | ((*_ctype_b_loc())[a1] >> 10)) & 1;
}

original_code:
static inline int is_first_ident_char(uint8_t ch)
{
    return ((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short int) _ISalpha) || ch == '_';
}

canonical_original_code:
static inline int is_first_ident_char(unsigned char ch)
{
    return ((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short) _ISalpha) || ch == '_';
}


decompiled_code:
__suseconds_t timestamp_now()
{
struct timeval v1; // [rsp+0h] [rbp-18h] BYREF

gettimeofday(&v1, 0LL);
return v1.tv_usec + 1000000 * v1.tv_sec;
}

canonical_decompiled_code:
__suseconds_t func0()
{
struct timeval v1; // [rsp+0h] [rbp-18h] BYREF

gettimeofday(&v1, 0LL);
return v1.tv_usec + 1000000 * v1.tv_sec;
}

original_code:
uint64_t timestamp_now(void)
{
    struct timeval tv;
    gettimeofday(&tv, ((void *)0));
    return (uint64_t) tv.tv_sec * 1000000 + tv.tv_usec;
}

canonical_original_code:
unsigned long timestamp_now()
{
    struct timeval tv;
    gettimeofday(&tv, ((void *)0));
    return (unsigned long) tv.tv_sec * 1000000 + tv.tv_usec;
}

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

return_type: unsigned long


main

canonical_name: main

repo: ajbonkoski/pianoserver

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // ebx
int v4; // ebp
void *v5; // rdi

if ( mkfifo("/tmp/piano_pipe_in", 0x1B6u) != -1 || *__errno_location() == 17 )
{
v3 = open("/tmp/piano_pipe_in", 2048);
if ( v3 != -1 )
{
v4 = creat("/tmp/piano_output", 0x1A4u);
if ( v4 != -1 )
{
while ( 1 )
{
forward_pianobar_output(v4);
v5 = (void *)get_input(v3);
if ( v5 )
handle_input(v5);
usleep(0x186A0u);
}
}
}
fwrite("Error: Could not open named input pipe\n", 1uLL, 0x27uLL, stderr);
exit(1);
}
perror("Error creating named pipe");
exit(1);
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // ebx
int v4; // ebp
void *v5; // rdi

if ( mkfifo("/tmp/piano_pipe_in", 0x1B6u) != -1 || *__errno_location() == 17 )
{
v3 = open("/tmp/piano_pipe_in", 2048);
if ( v3 != -1 )
{
v4 = creat("/tmp/piano_output", 0x1A4u);
if ( v4 != -1 )
{
while ( 1 )
{
func8(v4);
v5 = (void *)func7(v3);
if ( v5 )
func14(v5);
usleep(0x186A0u);
}
}
}
fwrite("Error: Could not open named input pipe\n", 1uLL, 0x27uLL, stderr);
exit(1);
}
perror("Error creating named pipe");
exit(1);
}

original_code:
int main(int argc, char *argv[]){
  int ret_val;
  ret_val = mkfifo("/tmp/piano_pipe_in", 0666);
  if((ret_val == -1) && ((*__errno_location ()) != 17)){
    perror("Error creating named pipe");
    exit(1);
  }
  int fd_in, fd_out;
  if((fd_in= open("/tmp/piano_pipe_in", 00 | 04000)) == -1){
    fprintf(stderr, "Error: Could not open named input pipe\n");
    exit(1);
  }
  if((fd_out = creat("/tmp/piano_output", 0644)) == -1){
    fprintf(stderr, "Error: Could not open named input pipe\n");
    exit(1);
  }
  while(1){
    forward_pianobar_output(fd_out);
    char *buf = get_input(fd_in);
    if(buf){
      ;
      handle_input(buf);
    }
    usleep(100000);
  }
  return 0;
}

canonical_original_code:
int main(int argc, char *argv[]){
  int ret_val;
  ret_val = mkfifo("/tmp/piano_pipe_in", 0666);
  if((ret_val == -1) && ((*__errno_location ()) != 17)){
    perror("Error creating named pipe");
    exit(1);
  }
  int fd_in; int fd_out;
  if((fd_in= open("/tmp/piano_pipe_in", 00 | 04000)) == -1){
    fprintf(stderr, "Error: Could not open named input pipe\n");
    exit(1);
  }
  if((fd_out = creat("/tmp/piano_output", 0644)) == -1){
    fprintf(stderr, "Error: Could not open named input pipe\n");
    exit(1);
  }
  while(1){
    forward_pianobar_output(fd_out);
    char *buf = get_input(fd_in);
    if(buf){
      ;
      handle_input(buf);
    }
    usleep(100000);
  }
  return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types:
buf
char *


decompiled_code:
char *__fastcall get_input(int a1)
{
int v1; // eax
int v2; // edx
int v3; // eax
char *result; // rax

v1 = read(a1, buf, 0xFFuLL);
if ( !v1 )
return 0LL;
v2 = v1;
v3 = v1 - 1;
if ( buf[v3] == 10 )
v2 = v3;
result = buf;
buf[v2] = 0;
return result;
}

canonical_decompiled_code:
char *__fastcall func7(int a1)
{
int v1; // eax
int v2; // edx
int v3; // eax
char *result; // rax

v1 = read(a1, buf, 0xFFuLL);
if ( !v1 )
return 0LL;
v2 = v1;
v3 = v1 - 1;
if ( buf[v3] == 10 )
v2 = v3;
result = buf;
buf[v2] = 0;
return result;
}

original_code:
char *get_input(int fd){
  int numread = read(fd, buf, 255);
  if(!numread)
    return ((void *)0);
  if(buf[numread-1] == '\n')
    --numread;
  buf[numread] = 0;
  return buf;
}

variable_types: fd int

variable_types: numread int

return_type: char *


decompiled_code:
ssize_t __fastcall forward_pianobar_output(int fd)
{
ssize_t result; // rax
_BYTE v2[264]; // [rsp-108h] [rbp-108h] BYREF

result = (unsigned int)pianobar_pid;
if ( pianobar_pid )
{
while ( 1 )
{
result = read(pianobar_stdout, v2, 0xFFuLL);
if ( (int)result <= 0 )
break;
write(fd, v2, (int)result);
}
}
return result;
}

canonical_decompiled_code:
ssize_t __fastcall func8(int fd)
{
ssize_t result; // rax
_BYTE v2[264]; // [rsp-108h] [rbp-108h] BYREF

result = (unsigned int)pianobar_pid;
if ( pianobar_pid )
{
while ( 1 )
{
result = read(pianobar_stdout, v2, 0xFFuLL);
if ( (int)result <= 0 )
break;
write(fd, v2, (int)result);
}
}
return result;
}

original_code:
void forward_pianobar_output(int fd_out){
  char buf[255 +1];
  int numread;
  if(!(pianobar_pid))
    return;
  do {
    numread = read(pianobar_stdout, buf, 255);
    if(numread > 0)
      write(fd_out, buf, numread);
  } while(numread > 0);
}

canonical_original_code:
void forward_pianobar_output(int fd_out){
  char buf[-1];
  int numread;
  if(!(pianobar_pid))
    return;
  do {
    numread = read(pianobar_stdout, buf, 255);
    if(numread > 0)
      write(fd_out, buf, numread);
  } while(numread > 0);
}

variable_types:
buf
char [-1]


decompiled_code:
int start_pianobar()
{
__pid_t v0; // eax
int result; // eax
int fd; // [rsp+0h] [rbp-18h] BYREF
int v3; // [rsp+4h] [rbp-14h]
int pipedes[2]; // [rsp+8h] [rbp-10h] BYREF

if ( pianobar_pid )
return fwrite("Error: pianobar is already running...\n", 1uLL, 0x26uLL, stderr);
puts("starting pianobar...");
if ( pipe(&fd) == -1 )
{
fwrite("Pipe Failed.\n", 1uLL, 0xDuLL, stderr);
exit(1);
}
if ( pipe(pipedes) == -1 )
{
fwrite("Pipe Failed.\n", 1uLL, 0xDuLL, stderr);
exit(1);
}
v0 = fork();
pianobar_pid = v0;
if ( v0 == -1 )
{
fwrite("Fork Failed.\n", 1uLL, 0xDuLL, stderr);
exit(1);
}
if ( v0 )
{
close(fd);
close(pipedes[1]);
pianobar_stdin = v3;
pianobar_stdout = pipedes[0];
result = fcntl(pipedes[0], 4, 2048LL);
}
else
{
close(v3);
close(pipedes[0]);
close(0);
dup(fd);
close(1);
dup(pipedes[1]);
result = execlp("pianobar", "pianobar", 0LL);
}
return result;
}

canonical_decompiled_code:
int func9()
{
__pid_t v0; // eax
int result; // eax
int fd; // [rsp+0h] [rbp-18h] BYREF
int v3; // [rsp+4h] [rbp-14h]
int pipedes[2]; // [rsp+8h] [rbp-10h] BYREF

if ( pianobar_pid )
return fwrite("Error: pianobar is already running...\n", 1uLL, 0x26uLL, stderr);
puts("starting pianobar...");
if ( pipe(&fd) == -1 )
{
fwrite("Pipe Failed.\n", 1uLL, 0xDuLL, stderr);
exit(1);
}
if ( pipe(pipedes) == -1 )
{
fwrite("Pipe Failed.\n", 1uLL, 0xDuLL, stderr);
exit(1);
}
v0 = fork();
pianobar_pid = v0;
if ( v0 == -1 )
{
fwrite("Fork Failed.\n", 1uLL, 0xDuLL, stderr);
exit(1);
}
if ( v0 )
{
close(fd);
close(pipedes[1]);
pianobar_stdin = v3;
pianobar_stdout = pipedes[0];
result = fcntl(pipedes[0], 4, 2048LL);
}
else
{
close(v3);
close(pipedes[0]);
close(0);
dup(fd);
close(1);
dup(pipedes[1]);
result = execlp("pianobar", "pianobar", 0LL);
}
return result;
}

original_code:
void start_pianobar(){
  if((pianobar_pid)){
    fprintf(stderr, "Error: pianobar is already running...\n");
    return;
  }
  printf("starting pianobar...\n");
  int in[2];
  int out[2];
  if(pipe(in) == -1){
    fprintf(stderr, "Pipe Failed.\n");
    exit(1);
  }
  if(pipe(out) == -1){
    fprintf(stderr, "Pipe Failed.\n");
    exit(1);
  }
  pianobar_pid = fork();
  if(pianobar_pid == -1){
    fprintf(stderr, "Fork Failed.\n");
    exit(1);
  }
  if(pianobar_pid == 0){
    close(in[1]);
    close(out[0]);
    close(0);
    dup(in[0]);
    close(1);
    dup(out[1]);
    execlp("pianobar", "pianobar", ((void *)0));
  }else{
    close(in[0]);
    close(out[1]);
    pianobar_stdin = in[1];
    pianobar_stdout = out[0];
    fcntl(pianobar_stdout, 4, 04000);
  }
}

variable_types:
in
int [2]

variable_types:
out
int [2]


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

puts("stopping pianobar...");
if ( !pianobar_pid )
return fwrite("Error: pianobar is not running...\n", 1uLL, 0x22uLL, stderr);
result = kill(pianobar_pid, 9);
pianobar_pid = 0;
return result;
}

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

puts("stopping pianobar...");
if ( !pianobar_pid )
return fwrite("Error: pianobar is not running...\n", 1uLL, 0x22uLL, stderr);
result = kill(pianobar_pid, 9);
pianobar_pid = 0;
return result;
}

original_code:
void stop_pianobar(){
  printf("stopping pianobar...\n");
  if(!(pianobar_pid)){
    fprintf(stderr, "Error: pianobar is not running...\n");
  }else{
    kill(pianobar_pid, 9);
    pianobar_pid = 0;
  }
}


decompiled_code:
int restart_pianobar()
{
puts("restarting pianobar...");
stop_pianobar();
return start_pianobar();
}

canonical_decompiled_code:
int func11()
{
puts("restarting pianobar...");
func10();
return func9();
}

original_code:
void restart_pianobar(){
    printf("restarting pianobar...\n");
    stop_pianobar();
    start_pianobar();
}


decompiled_code:
int __fastcall handle_daemon_control(const char *a1)
{
int v1; // eax

if ( !strcmp(a1, "start") )
return start_pianobar();
v1 = *(unsigned __int8 *)a1;
if ( v1 == 103 && !a1[1] )
return start_pianobar();
if ( !strcmp(a1, "restart") || *a1 == 114 && a1[1] == 101 && !a1[2] )
return restart_pianobar();
if ( !strcmp(a1, "stop") || v1 == 113 && !a1[1] )
return stop_pianobar();
return fprintf(stderr, "Error: could not recognize daemon control string: '%s'\n", a1);
}

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

if ( !strcmp(a1, "start") )
return func9();
v1 = *(unsigned __int8 *)a1;
if ( v1 == 103 && !a1[1] )
return func9();
if ( !strcmp(a1, "restart") || *a1 == 114 && a1[1] == 101 && !a1[2] )
return func11();
if ( !strcmp(a1, "stop") || v1 == 113 && !a1[1] )
return func10();
return fprintf(stderr, "Error: could not recognize daemon control string: '%s'\n", a1);
}

original_code:
void handle_daemon_control(char *in){
  if(strcmp(in, "start") == 0 || strcmp(in, "g") == 0)
    start_pianobar();
  else if(strcmp(in, "restart") == 0 || strcmp(in, "re") == 0)
    restart_pianobar();
  else if(strcmp(in, "stop") == 0 || strcmp(in, "q") == 0)
    stop_pianobar();
  else
    fprintf(stderr, "Error: could not recognize daemon control string: '%s'\n", in);
}

variable_types:
in
char *


decompiled_code:
int __fastcall handle_piano_control(void *buf)
{
size_t v2; // rax

if ( *(_BYTE *)buf == 113 && !*((_BYTE *)buf + 1) )
return stop_pianobar();
if ( !pianobar_pid )
return fwrite("Error: pianobar is not running... command will be dropped..\n", 1uLL, 0x3CuLL, stderr);
v2 = strlen((const char *)buf);
return write(pianobar_stdin, buf, v2);
}

canonical_decompiled_code:
int __fastcall func13(void *buf)
{
size_t v2; // rax

if ( *(_BYTE *)buf == 113 && !*((_BYTE *)buf + 1) )
return func10();
if ( !pianobar_pid )
return fwrite("Error: pianobar is not running... command will be dropped..\n", 1uLL, 0x3CuLL, stderr);
v2 = strlen((const char *)buf);
return write(pianobar_stdin, buf, v2);
}

original_code:
void handle_piano_control(char *in){
  if(strcmp(in, "q") == 0){
    stop_pianobar();
    return;
  }
  if(!(pianobar_pid)){
    fprintf(stderr, "Error: pianobar is not running... command will be dropped..\n");
    return;
  }
  write(pianobar_stdin, in, strlen(in));
}


decompiled_code:
int __fastcall handle_input(void *buf)
{
int result; // eax

result = strlen((const char *)buf);
if ( result )
{
if ( *(_BYTE *)buf == 37 )
result = handle_daemon_control((const char *)buf + 1);
else
result = handle_piano_control(buf);
}
return result;
}

canonical_decompiled_code:
int __fastcall func14(void *buf)
{
int result; // eax

result = strlen((const char *)buf);
if ( result )
{
if ( *(_BYTE *)buf == 37 )
result = func12((const char *)buf + 1);
else
result = func13(buf);
}
return result;
}

original_code:
void handle_input(char *in){
  int len = strlen(in);
  if(!len) return;
  if(in[0] == '%')
    handle_daemon_control(in+1);
  else
    handle_piano_control(in);
}

variable_types: len int


decompiled_code:
void __fastcall str_toupper(char *a1)
{
__int64 v1; // rbx
char *v2; // rbp
const __int32_t **v3; // rdx

v1 = *a1;
if ( (_BYTE)v1 )
{
v2 = a1;
v3 = __ctype_toupper_loc();
do
{
*v2++ = (*v3)[v1];
v1 = *v2;
}
while ( (_BYTE)v1 );
}
}

canonical_decompiled_code:
void __fastcall func15(char *a1)
{
__int64 v1; // rbx
char *v2; // rbp
const __int32_t **v3; // rdx

v1 = *a1;
if ( (_BYTE)v1 )
{
v2 = a1;
v3 = __ctype_toupper_loc();
do
{
*v2++ = (*v3)[v1];
v1 = *v2;
}
while ( (_BYTE)v1 );
}
}

original_code:
void str_toupper(char *str){
  for (; *str; ++str)
      *str = toupper(*str);
}

variable_types:
str
char *


repo: ajdawson/parallel

decompiled_code:
void __fastcall dealloc_array2d(void *ptr)
{
free(*(void **)ptr);
free(ptr);
}

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

original_code:
void dealloc_array2d(double **array)
{
    free(array[0]);
    free(array);
}

variable_types:
array
double **


decompiled_code:
int __fastcall print_double_array(int a1, int a2, _QWORD *a3)
{
_QWORD *v3; // r14
__int64 v4; // r13
__int64 v5; // rbx
double v6; // xmm0_8
int result; // eax

if ( a1 > 0 )
{
v3 = a3;
v4 = (__int64)&a3[(unsigned int)(a1 - 1) + 1];
do
{
v5 = 0LL;
if ( a2 > 0 )
{
do
{
v6 = *(double *)(*v3 + v5);
v5 += 8LL;
printf("%4.1f ", v6);
}
while ( 8LL * (unsigned int)(a2 - 1) + 8 != v5 );
}
++v3;
result = putchar(10);
}
while ( v3 != (_QWORD *)v4 );
}
return result;
}

canonical_decompiled_code:
int __fastcall func9(int a1, int a2, _QWORD *a3)
{
_QWORD *v3; // r14
__int64 v4; // r13
__int64 v5; // rbx
double v6; // xmm0_8
int result; // eax

if ( a1 > 0 )
{
v3 = a3;
v4 = (__int64)&a3[(unsigned int)(a1 - 1) + 1];
do
{
v5 = 0LL;
if ( a2 > 0 )
{
do
{
v6 = *(double *)(*v3 + v5);
v5 += 8LL;
printf("%4.1f ", v6);
}
while ( 8LL * (unsigned int)(a2 - 1) + 8 != v5 );
}
++v3;
result = putchar(10);
}
while ( v3 != (_QWORD *)v4 );
}
return result;
}

original_code:
void print_double_array(int nrows, int ncols, double **array)
{
    int i, j;
    for (i=0; i<nrows; i++) {
        for (j=0; j<ncols; j++) {
            printf("%4.1f ", array[i][j]);
        }
        printf("\n");
    }
    return;
}

canonical_original_code:
void print_double_array(int nrows, int ncols, double **array)
{
    int i; int j;
    for (i=0; i<nrows; i++) {
        for (j=0; j<ncols; j++) {
            printf("%4.1f ", array[i][j]);
        }
        printf("\n");
    }
    return;
}

variable_types: nrows int

variable_types: ncols int

variable_types: i int

variable_types: j int


repo: ajdiaz/libcalby

variable_types: struct _cal_datetime_s { long year; long mon; long day; long hour; long min; long sec; long off; } *

variable_types: m long

variable_types: y long

variable_types: d long


decompiled_code:
__int64 __fastcall cal_leapsecs_load(int fd)
{
__off_t v1; // r13
char *v2; // rax
char *v3; // r12
int v4; // eax
__int64 v5; // rdx
int v6; // eax
char *v7; // rbx
__int64 v8; // rbp
unsigned __int8 *v9; // rdi
void *v10; // rdi
unsigned __int64 v12; // [rsp+8h] [rbp-C0h] BYREF
struct stat buf; // [rsp+10h] [rbp-B8h] BYREF

if ( fstat(fd, &buf) == -1 )
return 0xFFFFFFFFLL;
v1 = buf.st_size;
v2 = (char *)malloc(buf.st_size);
v3 = v2;
if ( !v2 )
return 0xFFFFFFFFLL;
v4 = read(fd, v2, v1);
if ( v4 != buf.st_size )
{
free(v3);
return 0xFFFFFFFFLL;
}
v5 = (__int64)v4 >> 3;
cal_leapsecs = v5;
v6 = ((unsigned __int64)v4 >> 3) - 1;
if ( v6 >= 0 )
{
v7 = &v3[8 * v6];
v8 = (__int64)&v3[8 * v5 - 16 + -8 * (unsigned int)v6];
do
{
v9 = (unsigned __int8 *)v7;
v7 -= 8;
cal_tai_unpack(v9, &v12);
*((_QWORD *)v7 + 1) = v12;
}
while ( v7 != (char *)v8 );
}
v10 = (void *)*((_QWORD *)&cal_leapsecs + 1);
if ( v10 )
free(v10);
*((_QWORD *)&cal_leapsecs + 1) = v3;
return cal_leapsecs;
}

canonical_decompiled_code:
__int64 __fastcall func4(int fd)
{
__off_t v1; // r13
char *v2; // rax
char *v3; // r12
int v4; // eax
__int64 v5; // rdx
int v6; // eax
char *v7; // rbx
__int64 v8; // rbp
unsigned __int8 *v9; // rdi
void *v10; // rdi
unsigned __int64 v12; // [rsp+8h] [rbp-C0h] BYREF
struct stat buf; // [rsp+10h] [rbp-B8h] BYREF

if ( fstat(fd, &buf) == -1 )
return 0xFFFFFFFFLL;
v1 = buf.st_size;
v2 = (char *)malloc(buf.st_size);
v3 = v2;
if ( !v2 )
return 0xFFFFFFFFLL;
v4 = read(fd, v2, v1);
if ( v4 != buf.st_size )
{
free(v3);
return 0xFFFFFFFFLL;
}
v5 = (__int64)v4 >> 3;
cal_leapsecs = v5;
v6 = ((unsigned __int64)v4 >> 3) - 1;
if ( v6 >= 0 )
{
v7 = &v3[8 * v6];
v8 = (__int64)&v3[8 * v5 - 16 + -8 * (unsigned int)v6];
do
{
v9 = (unsigned __int8 *)v7;
v7 -= 8;
func2(v9, &v12);
*((_QWORD *)v7 + 1) = v12;
}
while ( v7 != (char *)v8 );
}
v10 = (void *)*((_QWORD *)&cal_leapsecs + 1);
if ( v10 )
free(v10);
*((_QWORD *)&cal_leapsecs + 1) = v3;
return cal_leapsecs;
}

original_code:
int
cal_leapsecs_load(int fd)
{
    struct stat st;
    _uint64_t *t, u;
    int n;
    if (fstat(fd,&st) == -1) return -1;
    if ((t = (_uint64_t *) malloc (st.st_size)) == ((void *)0))
        return -1;
    if ((n = read(fd,(char *)t,st.st_size)) != st.st_size)
    {
        free(t);
        return -1;
    }
    n /= sizeof(_uint64_t);
    cal_leapsecs.count = n;
    while (--n >= 0)
    {
        cal_tai_unpack((char *)&t[n],&u);
        t[n] = u;
    }
    if (cal_leapsecs.list != ((void *)0))
        free(cal_leapsecs.list);
    cal_leapsecs.list = t;
    return (int)cal_leapsecs.count;
}

canonical_original_code:
int cal_leapsecs_load(int fd)
{
    struct stat st;
    unsigned long long *t; unsigned long long u;
    int n;
    if (fstat(fd,&st) == -1) return -1;
    if ((t = (unsigned long long *) malloc (st.st_size)) == ((void *)0))
        return -1;
    if ((n = read(fd,(char *)t,st.st_size)) != st.st_size)
    {
        free(t);
        return -1;
    }
    n /= sizeof(_uint64_t);
    cal_leapsecs.count = n;
    while (--n >= 0)
    {
        cal_tai_unpack((char *)&t[n],&u);
        t[n] = u;
    }
    if (cal_leapsecs.list != ((void *)0))
        free(cal_leapsecs.list);
    cal_leapsecs.list = t;
    return (int)cal_leapsecs.count;
}

variable_types: fd int

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; struct timespec { long tv_sec; long tv_nsec; } st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }

variable_types:
t
unsigned long long *

variable_types:
u
unsigned long long

variable_types: n int

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; struct timespec st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }


decompiled_code:
__int64 cal_leapsecs_init()
{
unsigned int v0; // er12
int v2; // eax
int v3; // ebp
unsigned int v4; // er12

v0 = cal_leapsecs;
if ( *(_QWORD *)&cal_leapsecs )
return v0;
v2 = open("/etc/leapsecs.dat", 0);
v3 = v2;
if ( v2 == -1 )
return (unsigned int)-1;
v4 = cal_leapsecs_load(v2);
close(v3);
return v4;
}

canonical_decompiled_code:
__int64 func5()
{
unsigned int v0; // er12
int v2; // eax
int v3; // ebp
unsigned int v4; // er12

v0 = cal_leapsecs;
if ( *(_QWORD *)&cal_leapsecs )
return v0;
v2 = open("/etc/leapsecs.dat", 0);
v3 = v2;
if ( v2 == -1 )
return (unsigned int)-1;
v4 = func4(v2);
close(v3);
return v4;
}

original_code:
int
cal_leapsecs_init(void)
{
    int ret = -1;
    int fd;
    if (cal_leapsecs.count)
        return cal_leapsecs.count;
    if ((fd = open("/etc/leapsecs.dat",00)) == -1)
        return -1;
    ret = cal_leapsecs_load(fd);
    close(fd);
    return ret;
}

canonical_original_code:
int cal_leapsecs_init()
{
    int ret = -1;
    int fd;
    if (cal_leapsecs.count)
        return cal_leapsecs.count;
    if ((fd = open("/etc/leapsecs.dat",00)) == -1)
        return -1;
    ret = cal_leapsecs_load(fd);
    close(fd);
    return ret;
}

variable_types: ret int


decompiled_code:
__int64 __fastcall cal_leapsecs_sub(unsigned __int64 *a1)
{
unsigned __int64 v1; // rdx
__int64 v2; // rax
unsigned int v3; // er8

if ( (unsigned int)cal_leapsecs_init() == -1 )
return (unsigned int)-1;
v1 = *a1;
if ( *(_QWORD *)&cal_leapsecs )
{
v2 = 0LL;
do
{
v3 = v2;
if ( *(_QWORD *)(*((_QWORD *)&cal_leapsecs + 1) + 8 * v2) > v1 )
{
v1 -= v2;
goto LABEL_7;
}
v3 = ++v2;
}
while ( *(_QWORD *)&cal_leapsecs != v2 );
v1 -= *(_QWORD *)&cal_leapsecs;
}
else
{
v3 = 0;
}
LABEL_7:
*a1 = v1;
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned __int64 *a1)
{
unsigned __int64 v1; // rdx
__int64 v2; // rax
unsigned int v3; // er8

if ( (unsigned int)func5() == -1 )
return (unsigned int)-1;
v1 = *a1;
if ( *(_QWORD *)&cal_leapsecs )
{
v2 = 0LL;
do
{
v3 = v2;
if ( *(_QWORD *)(*((_QWORD *)&cal_leapsecs + 1) + 8 * v2) > v1 )
{
v1 -= v2;
goto LABEL_7;
}
v3 = ++v2;
}
while ( *(_QWORD *)&cal_leapsecs != v2 );
v1 -= *(_QWORD *)&cal_leapsecs;
}
else
{
v3 = 0;
}
LABEL_7:
*a1 = v1;
return v3;
}

original_code:
int
cal_leapsecs_sub(_uint64_t *tai)
{
    int i,r;
    if (cal_leapsecs_init() == -1)
        return -1;
    for (i=0,r=0;i<cal_leapsecs.count;i++,r++)
        if (*tai < cal_leapsecs.list[i]) break;
    *tai -= r;
    return r;
}

canonical_original_code:
int cal_leapsecs_sub(unsigned long long *tai)
{
    int i; int r;
    if (cal_leapsecs_init() == -1)
        return -1;
    for (i=0,r=0;i<cal_leapsecs.count;i++,r++)
        if (*tai < cal_leapsecs.list[i]) break;
    *tai -= r;
    return r;
}

variable_types:
tai
unsigned long long *

variable_types: r int


decompiled_code:
__int64 __fastcall cal_leapsecs_add(unsigned __int64 *a1)
{
unsigned __int64 v2; // rcx
__int64 v3; // rdi
int v4; // er8
__int64 v5; // rax
bool v6; // zf

if ( (unsigned int)cal_leapsecs_init() == -1 )
{
v4 = -1;
}
else
{
v2 = *a1;
if ( *(_QWORD *)&cal_leapsecs )
{
v3 = *((_QWORD *)&cal_leapsecs + 1);
v4 = 0;
v5 = 0LL;
do
{
v6 = *(_QWORD *)(v3 + 8 * v5) == v2;
if ( *(_QWORD *)(v3 + 8 * v5) > v2 )
break;
++v5;
v4 += !v6;
}
while ( *(_QWORD *)&cal_leapsecs != v5 );
v2 += v4;
}
else
{
v4 = 0;
}
*a1 = v2;
}
return (unsigned int)v4;
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned __int64 *a1)
{
unsigned __int64 v2; // rcx
__int64 v3; // rdi
int v4; // er8
__int64 v5; // rax
bool v6; // zf

if ( (unsigned int)func5() == -1 )
{
v4 = -1;
}
else
{
v2 = *a1;
if ( *(_QWORD *)&cal_leapsecs )
{
v3 = *((_QWORD *)&cal_leapsecs + 1);
v4 = 0;
v5 = 0LL;
do
{
v6 = *(_QWORD *)(v3 + 8 * v5) == v2;
if ( *(_QWORD *)(v3 + 8 * v5) > v2 )
break;
++v5;
v4 += !v6;
}
while ( *(_QWORD *)&cal_leapsecs != v5 );
v2 += v4;
}
else
{
v4 = 0;
}
*a1 = v2;
}
return (unsigned int)v4;
}

original_code:
int
cal_leapsecs_add(_uint64_t *tai)
{
    int i,r;
    if (cal_leapsecs_init() == -1)
        return -1;
    for (r=0,i=0;i<cal_leapsecs.count;i++,r++)
        if (*tai < cal_leapsecs.list[i]) break;
        else if (*tai == cal_leapsecs.list[i]) r--;
    *tai += r;
    return r;
}

canonical_original_code:
int cal_leapsecs_add(unsigned long long *tai)
{
    int i; int r;
    if (cal_leapsecs_init() == -1)
        return -1;
    for (r=0,i=0;i<cal_leapsecs.count;i++,r++)
        if (*tai < cal_leapsecs.list[i]) break;
        else if (*tai == cal_leapsecs.list[i]) r--;
    *tai += r;
    return r;
}


decompiled_code:
__int64 __fastcall cal_isleapsec(unsigned __int64 a1)
{
__int64 result; // rax
__int64 v2; // rcx
__int64 v3; // rax

result = cal_leapsecs_init();
if ( (_DWORD)result != -1 )
{
if ( *(_QWORD *)&cal_leapsecs )
{
v2 = *((_QWORD *)&cal_leapsecs + 1);
v3 = 0LL;
while ( *(_QWORD *)(v2 + 8 * v3) <= a1 )
{
if ( *(_QWORD *)(v2 + 8 * v3) == a1 )
return 1LL;
if ( ++v3 == *(_QWORD *)&cal_leapsecs )
break;
}
}
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(unsigned __int64 a1)
{
__int64 result; // rax
__int64 v2; // rcx
__int64 v3; // rax

result = func5();
if ( (_DWORD)result != -1 )
{
if ( *(_QWORD *)&cal_leapsecs )
{
v2 = *((_QWORD *)&cal_leapsecs + 1);
v3 = 0LL;
while ( *(_QWORD *)(v2 + 8 * v3) <= a1 )
{
if ( *(_QWORD *)(v2 + 8 * v3) == a1 )
return 1LL;
if ( ++v3 == *(_QWORD *)&cal_leapsecs )
break;
}
}
result = 0LL;
}
return result;
}

original_code:
int
cal_isleapsec(_uint64_t tai)
{
    int i;
    if (cal_leapsecs_init() == -1)
        return -1;
    for (i=0;i<cal_leapsecs.count;i++)
    {
        if (tai < cal_leapsecs.list[i]) return 0;
        if (tai == cal_leapsecs.list[i])
            return 1;
    }
    return 0;
}

canonical_original_code:
int cal_isleapsec(unsigned long long tai)
{
    int i;
    if (cal_leapsecs_init() == -1)
        return -1;
    for (i=0;i<cal_leapsecs.count;i++)
    {
        if (tai < cal_leapsecs.list[i]) return 0;
        if (tai == cal_leapsecs.list[i])
            return 1;
    }
    return 0;
}

variable_types:
tai
unsigned long long


decompiled_code:
__int64 __fastcall cal_leapsecs_get(unsigned __int64 a1)
{
unsigned int v1; // er8
__int64 v2; // rax

v1 = cal_leapsecs_init();
if ( v1 != -1 )
{
if ( *(_QWORD *)&cal_leapsecs )
{
v2 = 0LL;
do
{
v1 = v2;
if ( *(_QWORD *)(*((_QWORD *)&cal_leapsecs + 1) + 8 * v2) > a1 )
break;
v1 = ++v2;
}
while ( *(_QWORD *)&cal_leapsecs != v2 );
}
else
{
v1 = 0;
}
}
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func9(unsigned __int64 a1)
{
unsigned int v1; // er8
__int64 v2; // rax

v1 = func5();
if ( v1 != -1 )
{
if ( *(_QWORD *)&cal_leapsecs )
{
v2 = 0LL;
do
{
v1 = v2;
if ( *(_QWORD *)(*((_QWORD *)&cal_leapsecs + 1) + 8 * v2) > a1 )
break;
v1 = ++v2;
}
while ( *(_QWORD *)&cal_leapsecs != v2 );
}
else
{
v1 = 0;
}
}
return v1;
}

original_code:
int
cal_leapsecs_get(_uint64_t tai)
{
    int i,r=0;
    if (cal_leapsecs_init() == -1)
        return -1;
    for (i=0;i<cal_leapsecs.count;i++,r++)
        if (tai < cal_leapsecs.list[i]) break;
    return r;
}

canonical_original_code:
int cal_leapsecs_get(unsigned long long tai)
{
    int i; int r = 0;
    if (cal_leapsecs_init() == -1)
        return -1;
    for (i=0;i<cal_leapsecs.count;i++,r++)
        if (tai < cal_leapsecs.list[i]) break;
    return r;
}


return_type: double

user_defined_types: struct _cal_datetime_s { long year; long mon; long day; long hour; long min; long sec; long off; }


decompiled_code:
__int64 __fastcall cal_tai(_QWORD *a1)
{
return 86400LL * (unsigned int)(int)cal_mjd((__int64)a1)
+ a1[5]
+ 60 * (a1[4] + 60LL * a1[3] - a1[6])
+ 0x3FFFFFFF2EFBBF8ALL;
}

canonical_decompiled_code:
__int64 __fastcall func11(_QWORD *a1)
{
return 86400LL * (unsigned int)(int)func10((__int64)a1)
+ a1[5]
+ 60 * (a1[4] + 60LL * a1[3] - a1[6])
+ 0x3FFFFFFF2EFBBF8ALL;
}

original_code:
_uint64_t
cal_tai(const cal_datetime_t *t)
{
    long d,s;
    _uint64_t x;
    d = (long) cal_mjd(t);
    s = t->hour * 60 + t->min;
    s = (s - t->off) * 60 + t->sec;
    x = d * 86400ULL + 4611686014920671114ULL + (long long) s;
    return x;
}

canonical_original_code:
unsigned long long cal_tai(struct _cal_datetime_s *t)
{
    long d; long s;
    unsigned long long x;
    d = (long) cal_mjd(t);
    s = t->hour * 60 + t->min;
    s = (s - t->off) * 60 + t->sec;
    x = d * 86400ULL + 4611686014920671114ULL + (long long) s;
    return x;
}

variable_types: s long

variable_types:
x
unsigned long long

return_type: unsigned long long


repo: ajdunlap/othello

decompiled_code:
__int64 __fastcall learning_static_eval(__int64 a1)
{
_BYTE v2[72]; // [rsp+0h] [rbp-48h] BYREF

compute_board_counts(v2, a1);
return weight_board_counts(&weights, v2);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
_BYTE v2[72]; // [rsp+0h] [rbp-48h] BYREF

compute_board_counts(v2, a1);
return weight_board_counts(&weights, v2);
}

original_code:
double learning_static_eval (othello_bd *bd) {
  board_counts cts = compute_board_counts(bd);
  return weight_board_counts(&weights,&cts);
}

canonical_original_code:
double learning_static_eval(struct othello_bd *bd) {
  struct board_counts cts = compute_board_counts(bd);
  return weight_board_counts(&weights,&cts);
}

variable_types: struct othello_bd { char board[8][8]; char turn; char just_passed; } *

variable_types: struct board_counts { int turn; int squares_filled; int score; int counts[10]; }


decompiled_code:
bool __fastcall play_human_turn_is_game_over(__int64 a1, _DWORD *a2, _DWORD *a3)
{
bool result; // al

if ( (unsigned int)have_legal_moves() )
{
while ( 1 )
{
while ( 1 )
{
printf("Move for player %d? (type row column) > ", (unsigned int)*(char *)(a1 + 64));
if ( (unsigned int)_isoc99_scanf("%d %d", a2, a3) == 2 )
break;
while ( getchar() != 10 )
;
puts("Bad move format; enter row column.");
}
if ( (unsigned int)play_piece_if_legal(a1, (unsigned int)*a2, (unsigned int)*a3) )
break;
puts("Illegal move");
}
result = 0;
}
else
{
printf("Move for player %d? > (PASS)\n", (unsigned int)*(char *)(a1 + 64));
*a3 = -1;
*a2 = -1;
result = (unsigned int)pass_turn_is_game_over(a1) != 0;
}
return result;
}

canonical_decompiled_code:
bool __fastcall func1(__int64 a1, _DWORD *a2, _DWORD *a3)
{
bool result; // al

if ( (unsigned int)have_legal_moves() )
{
while ( 1 )
{
while ( 1 )
{
printf("Move for player %d? (type row column) > ", (unsigned int)*(char *)(a1 + 64));
if ( (unsigned int)_isoc99_scanf("%d %d", a2, a3) == 2 )
break;
while ( getchar() != 10 )
;
puts("Bad move format; enter row column.");
}
if ( (unsigned int)play_piece_if_legal(a1, (unsigned int)*a2, (unsigned int)*a3) )
break;
puts("Illegal move");
}
result = 0;
}
else
{
printf("Move for player %d? > (PASS)\n", (unsigned int)*(char *)(a1 + 64));
*a3 = -1;
*a2 = -1;
result = (unsigned int)pass_turn_is_game_over(a1) != 0;
}
return result;
}

original_code:
_Bool play_human_turn_is_game_over(othello_bd *bd, int *x, int *y, int opp_x, int opp_y, int depth) {
  if (have_legal_moves(bd)) {
    while (1) {
      printf("Move for player %d? (type row column) > ",bd->turn);
      if (scanf("%d %d",x,y) != 2) {
        while (getchar() != '\n');
        printf("Bad move format; enter row column.\n");
      } else if (!play_piece_if_legal(bd,*x,*y)) {
        printf("Illegal move\n");
      } else {
        return 0;
      }
    }
  } else {
    printf("Move for player %d? > (PASS)\n",bd->turn);
    *x = *y = -1;
    return pass_turn_is_game_over(bd);
  }
}

canonical_original_code:
_Bool play_human_turn_is_game_over(struct othello_bd *bd, int *x, int *y, int opp_x, int opp_y, int depth) {
  if (have_legal_moves(bd)) {
    while (1) {
      printf("Move for player %d? (type row column) > ",bd->turn);
      if (scanf("%d %d",x,y) != 2) {
        while (getchar() != '\n');
        printf("Bad move format; enter row column.\n");
      } else if (!play_piece_if_legal(bd,*x,*y)) {
        printf("Illegal move\n");
      } else {
        return 0;
      }
    }
  } else {
    printf("Move for player %d? > (PASS)\n",bd->turn);
    *x = *y = -1;
    return pass_turn_is_game_over(bd);
  }
}

variable_types:
x
int *

variable_types:
y
int *

variable_types: depth int

user_defined_types: struct othello_bd { char board[8][8]; char turn; char just_passed; }


decompiled_code:
bool __fastcall play_random_turn_is_game_over(__int64 a1, _DWORD *a2, _DWORD *a3)
{
__int64 v5; // rsi
bool result; // al

random_move();
v5 = (unsigned int)*a2;
if ( (_DWORD)v5 == -1 )
{
*a3 = -1;
*a2 = -1;
result = (unsigned int)pass_turn_is_game_over(a1) != 0;
}
else
{
if ( !(unsigned int)play_piece_if_legal(a1, v5, (unsigned int)*a3) )
_assert_fail("play_piece_if_legal(bd,*x,*y)", "othello.c", 0x36u, "play_random_turn_is_game_over");
result = 0;
}
return result;
}

canonical_decompiled_code:
bool __fastcall func2(__int64 a1, _DWORD *a2, _DWORD *a3)
{
__int64 v5; // rsi
bool result; // al

random_move();
v5 = (unsigned int)*a2;
if ( (_DWORD)v5 == -1 )
{
*a3 = -1;
*a2 = -1;
result = (unsigned int)pass_turn_is_game_over(a1) != 0;
}
else
{
if ( !(unsigned int)play_piece_if_legal(a1, v5, (unsigned int)*a3) )
_assert_fail("play_piece_if_legal(bd,*x,*y)", "othello.c", 0x36u, "play_random_turn_is_game_over");
result = 0;
}
return result;
}

original_code:
_Bool play_random_turn_is_game_over(othello_bd *bd, int *x, int *y, int opp_x, int opp_y, int depth) {
  random_move(bd,x,y);
  if (*x != -1) {
    ((play_piece_if_legal(bd,*x,*y)) ? (void) (0) : __assert_fail ("play_piece_if_legal(bd,*x,*y)", "othello.c", 54, __extension__ __PRETTY_FUNCTION__));
    return 0;
  } else {
    *x = *y = -1;
    return pass_turn_is_game_over(bd);
  }
}

canonical_original_code:
_Bool play_random_turn_is_game_over(struct othello_bd *bd, int *x, int *y, int opp_x, int opp_y, int depth) {
  random_move(bd,x,y);
  if (*x != -1) {
    ((play_piece_if_legal(bd,*x,*y)) ? (void) (0) : __assert_fail ("play_piece_if_legal(bd,*x,*y)", "othello.c", 54, __extension__ __PRETTY_FUNCTION__));
    return 0;
  } else {
    *x = *y = -1;
    return pass_turn_is_game_over(bd);
  }
}


decompiled_code:
__int64 __fastcall play_minimax_ai_turn_is_game_over(__int64 a1, _DWORD *a2, _DWORD *a3, unsigned int a4, unsigned int a5, unsigned int a6, __int64 a7)
{
__int64 v10; // rbx
__int64 v11; // rdi
_QWORD *v12; // rax
_QWORD *v13; // rax

v10 = (*(char *)(a1 + 64) + 1) >> 1;
v11 = trees[v10];
if ( v11 )
{
v12 = (_QWORD *)cut_tree_for_move(v11, a4, a5);
trees[v10] = (__int64)v12;
v11 = (__int64)v12;
if ( v12 )
{
if ( !(unsigned __int8)boards_equal(*v12, a1) )
_assert_fail(
"!trees[i] || boards_equal(trees[i]->bd,bd)",
"othello.c",
0x46u,
"play_minimax_ai_turn_is_game_over");
v11 = trees[v10];
}
}
trees[v10] = build_minimax_tree(a7, v11, 0LL, a1, a6);
if ( (unsigned int)have_legal_moves(a1) )
{
best_move(trees[v10], a2, a3);
if ( !(unsigned int)play_piece_if_legal(a1, (unsigned int)*a2, (unsigned int)*a3) )
_assert_fail("result", "othello.c", 0x4Cu, "play_minimax_ai_turn_is_game_over");
}
else
{
*a3 = -1;
*a2 = -1;
if ( (unsigned int)pass_turn_is_game_over(a1) )
return 1LL;
}
v13 = (_QWORD *)cut_tree_for_move(trees[v10], (unsigned int)*a2, (unsigned int)*a3);
trees[v10] = (__int64)v13;
if ( v13 )
{
if ( !(unsigned __int8)boards_equal(*v13, a1) )
_assert_fail(
"!trees[i] || boards_equal(trees[i]->bd,bd)",
"othello.c",
0x54u,
"play_minimax_ai_turn_is_game_over");
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, _DWORD *a2, _DWORD *a3, unsigned int a4, unsigned int a5, unsigned int a6, __int64 a7)
{
__int64 v10; // rbx
__int64 v11; // rdi
_QWORD *v12; // rax
_QWORD *v13; // rax

v10 = (*(char *)(a1 + 64) + 1) >> 1;
v11 = trees[v10];
if ( v11 )
{
v12 = (_QWORD *)cut_tree_for_move(v11, a4, a5);
trees[v10] = (__int64)v12;
v11 = (__int64)v12;
if ( v12 )
{
if ( !(unsigned __int8)boards_equal(*v12, a1) )
_assert_fail(
"!trees[i] || boards_equal(trees[i]->bd,bd)",
"othello.c",
0x46u,
"play_minimax_ai_turn_is_game_over");
v11 = trees[v10];
}
}
trees[v10] = build_minimax_tree(a7, v11, 0LL, a1, a6);
if ( (unsigned int)have_legal_moves(a1) )
{
best_move(trees[v10], a2, a3);
if ( !(unsigned int)play_piece_if_legal(a1, (unsigned int)*a2, (unsigned int)*a3) )
_assert_fail("result", "othello.c", 0x4Cu, "play_minimax_ai_turn_is_game_over");
}
else
{
*a3 = -1;
*a2 = -1;
if ( (unsigned int)pass_turn_is_game_over(a1) )
return 1LL;
}
v13 = (_QWORD *)cut_tree_for_move(trees[v10], (unsigned int)*a2, (unsigned int)*a3);
trees[v10] = (__int64)v13;
if ( v13 )
{
if ( !(unsigned __int8)boards_equal(*v13, a1) )
_assert_fail(
"!trees[i] || boards_equal(trees[i]->bd,bd)",
"othello.c",
0x54u,
"play_minimax_ai_turn_is_game_over");
}
return 0LL;
}

original_code:
_Bool play_minimax_ai_turn_is_game_over(othello_bd *bd, int *x, int *y, int opp_x, int opp_y, int depth, double (*static_eval)(othello_bd*)) {
  _Bool game_over;
  int i = (1+bd->turn)>>1;
  if (trees[i]) {
    trees[i] = cut_tree_for_move(trees[i],opp_x,opp_y);
    ((!trees[i] || boards_equal(trees[i]->bd,bd)) ? (void) (0) : __assert_fail ("!trees[i] || boards_equal(trees[i]->bd,bd)", "othello.c", 70, __extension__ __PRETTY_FUNCTION__));
  }
  trees[i] = build_minimax_tree(static_eval,trees[i],0,bd,depth);
  if (have_legal_moves(bd)) {
    best_move(trees[i],x,y);
    int result = play_piece_if_legal(bd,*x,*y);
    ((result) ? (void) (0) : __assert_fail ("result", "othello.c", 76, __extension__ __PRETTY_FUNCTION__));
    game_over = 0;
  } else {
    *x = *y = -1;
    game_over = pass_turn_is_game_over(bd);
  }
  if (!game_over) {
    trees[i] = cut_tree_for_move(trees[i],*x,*y);
    ((!trees[i] || boards_equal(trees[i]->bd,bd)) ? (void) (0) : __assert_fail ("!trees[i] || boards_equal(trees[i]->bd,bd)", "othello.c", 84, __extension__ __PRETTY_FUNCTION__));
  }
  return game_over;
}

canonical_original_code:
_Bool play_minimax_ai_turn_is_game_over(struct othello_bd *bd, int *x, int *y, int opp_x, int opp_y, int depth, double (*static_eval)(struct othello_bd *)) {
  _Bool game_over;
  int i = (1+bd->turn)>>1;
  if (trees[i]) {
    trees[i] = cut_tree_for_move(trees[i],opp_x,opp_y);
    ((!trees[i] || boards_equal(trees[i]->bd,bd)) ? (void) (0) : __assert_fail ("!trees[i] || boards_equal(trees[i]->bd,bd)", "othello.c", 70, __extension__ __PRETTY_FUNCTION__));
  }
  trees[i] = build_minimax_tree(static_eval,trees[i],0,bd,depth);
  if (have_legal_moves(bd)) {
    best_move(trees[i],x,y);
    int result = play_piece_if_legal(bd,*x,*y);
    ((result) ? (void) (0) : __assert_fail ("result", "othello.c", 76, __extension__ __PRETTY_FUNCTION__));
    game_over = 0;
  } else {
    *x = *y = -1;
    game_over = pass_turn_is_game_over(bd);
  }
  if (!game_over) {
    trees[i] = cut_tree_for_move(trees[i],*x,*y);
    ((!trees[i] || boards_equal(trees[i]->bd,bd)) ? (void) (0) : __assert_fail ("!trees[i] || boards_equal(trees[i]->bd,bd)", "othello.c", 84, __extension__ __PRETTY_FUNCTION__));
  }
  return game_over;
}

variable_types: i int

variable_types: result int


decompiled_code:
__int64 __fastcall play_hand_minimax_ai_turn_is_game_over(__int64 a1, _DWORD *a2, _DWORD *a3, unsigned int a4, unsigned int a5, unsigned int a6)
{
return play_minimax_ai_turn_is_game_over(a1, a2, a3, a4, a5, a6, (__int64)&hand_static_eval);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, _DWORD *a2, _DWORD *a3, unsigned int a4, unsigned int a5, unsigned int a6)
{
return func3(a1, a2, a3, a4, a5, a6, (__int64)&hand_static_eval);
}

original_code:
_Bool play_hand_minimax_ai_turn_is_game_over(othello_bd *bd, int *x, int *y, int opp_x, int opp_y, int depth) {
  return play_minimax_ai_turn_is_game_over(bd, x, y, opp_x, opp_y, depth, hand_static_eval);
}

canonical_original_code:
_Bool play_hand_minimax_ai_turn_is_game_over(struct othello_bd *bd, int *x, int *y, int opp_x, int opp_y, int depth) {
  return play_minimax_ai_turn_is_game_over(bd, x, y, opp_x, opp_y, depth, hand_static_eval);
}


decompiled_code:
__int64 __fastcall play_learning_minimax_ai_turn_is_game_over(__int64 a1, _DWORD *a2, _DWORD *a3, unsigned int a4, unsigned int a5, unsigned int a6)
{
return play_minimax_ai_turn_is_game_over(a1, a2, a3, a4, a5, a6, (__int64)learning_static_eval);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, _DWORD *a2, _DWORD *a3, unsigned int a4, unsigned int a5, unsigned int a6)
{
return func3(a1, a2, a3, a4, a5, a6, (__int64)learning_static_eval);
}

original_code:
_Bool play_learning_minimax_ai_turn_is_game_over(othello_bd *bd, int *x, int *y, int opp_x, int opp_y, int depth) {
  return play_minimax_ai_turn_is_game_over(bd, x, y, opp_x, opp_y, depth, learning_static_eval);
}

canonical_original_code:
_Bool play_learning_minimax_ai_turn_is_game_over(struct othello_bd *bd, int *x, int *y, int opp_x, int opp_y, int depth) {
  return play_minimax_ai_turn_is_game_over(bd, x, y, opp_x, opp_y, depth, learning_static_eval);
}


decompiled_code:
__int64 __fastcall play_naive_minimax_ai_turn_is_game_over(__int64 a1, _DWORD *a2, _DWORD *a3, unsigned int a4, unsigned int a5, unsigned int a6)
{
return play_minimax_ai_turn_is_game_over(a1, a2, a3, a4, a5, a6, (__int64)&naive_static_eval);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, _DWORD *a2, _DWORD *a3, unsigned int a4, unsigned int a5, unsigned int a6)
{
return func3(a1, a2, a3, a4, a5, a6, (__int64)&naive_static_eval);
}

original_code:
_Bool play_naive_minimax_ai_turn_is_game_over(othello_bd *bd, int *x, int *y, int opp_x, int opp_y, int depth) {
  return play_minimax_ai_turn_is_game_over(bd, x, y, opp_x, opp_y, depth, naive_static_eval);
}

canonical_original_code:
_Bool play_naive_minimax_ai_turn_is_game_over(struct othello_bd *bd, int *x, int *y, int opp_x, int opp_y, int depth) {
  return play_minimax_ai_turn_is_game_over(bd, x, y, opp_x, opp_y, depth, naive_static_eval);
}


usage

decompiled_code:
size_t usage()
{
return fwrite(
"Usage: othello [-d DEPTH|DEPTH1,DEPTH2] [-n NGAMES] [-q] [PLAYER1 PLAYER2]\n"
"PLAYER1 and PLAYER2 can be any of human, hand-ai, naive-ai, learning-ai, random.\n"
"If PLAYER1 and PLAYER2 are omitted, PLAYER1=human, PLAYER2=hand-ai is assumed.\n"
"Options:\n"
" -d [DEPTH|DEPTH1,DEPTH2] : specify depth of minimax tree search\n"
" DEPTH can be either a single integer or two comma-separated integers\n"
" to specify the depth for each player\n"
" -h : print this help\n"
" -n NGAMES : play n games\n"
" -q : don't print out boards, just winners of each game (for AI-vs-AI play)\n",
1uLL,
0x29AuLL,
stderr);
}

canonical_decompiled_code:
size_t func7()
{
return fwrite(
"Usage: othello [-d DEPTH|DEPTH1,DEPTH2] [-n NGAMES] [-q] [PLAYER1 PLAYER2]\n"
"PLAYER1 and PLAYER2 can be any of human, hand-ai, naive-ai, learning-ai, random.\n"
"If PLAYER1 and PLAYER2 are omitted, PLAYER1=human, PLAYER2=hand-ai is assumed.\n"
"Options:\n"
" -d [DEPTH|DEPTH1,DEPTH2] : specify depth of minimax tree search\n"
" DEPTH can be either a single integer or two comma-separated integers\n"
" to specify the depth for each player\n"
" -h : print this help\n"
" -n NGAMES : play n games\n"
" -q : don't print out boards, just winners of each game (for AI-vs-AI play)\n",
1uLL,
0x29AuLL,
stderr);
}

original_code:
void usage () {
  fprintf(stderr,"Usage: othello [-d DEPTH|DEPTH1,DEPTH2] [-n NGAMES] [-q] [PLAYER1 PLAYER2]\n"
                 "PLAYER1 and PLAYER2 can be any of human, hand-ai, naive-ai, learning-ai, random.\n"
                 "If PLAYER1 and PLAYER2 are omitted, PLAYER1=human, PLAYER2=hand-ai is assumed.\n"
                 "Options:\n"
                 "  -d [DEPTH|DEPTH1,DEPTH2]  : specify depth of minimax tree search\n"
                 "                              DEPTH can be either a single integer or two comma-separated integers\n"
                 "                              to specify the depth for each player\n"
                 "  -h                        : print this help\n"
                 "  -n NGAMES                 : play n games\n"
                 "  -q                        : don't print out boards, just winners of each game (for AI-vs-AI play)\n");
}

canonical_original_code:
void usage() {
  fprintf(stderr,"Usage: othello [-d DEPTH|DEPTH1,DEPTH2] [-n NGAMES] [-q] [PLAYER1 PLAYER2]\n"
                 "PLAYER1 and PLAYER2 can be any of human, hand-ai, naive-ai, learning-ai, random.\n"
                 "If PLAYER1 and PLAYER2 are omitted, PLAYER1=human, PLAYER2=hand-ai is assumed.\n"
                 "Options:\n"
                 "  -d [DEPTH|DEPTH1,DEPTH2]  : specify depth of minimax tree search\n"
                 "                              DEPTH can be either a single integer or two comma-separated integers\n"
                 "                              to specify the depth for each player\n"
                 "  -h                        : print this help\n"
                 "  -n NGAMES                 : play n games\n"
                 "  -q                        : don't print out boards, just winners of each game (for AI-vs-AI play)\n");
}