yyparse

decompiled_code:
__int64 yyparse()
{
__int64 v0; // r12
unsigned __int64 v1; // rbx
char *v2; // r11
__int16 *v3; // rbp
__int16 *v4; // r15
unsigned int v5; // er13
unsigned int v6; // er14
int v7; // eax
int v8; // eax
char v9; // al
__int64 v10; // r13
unsigned __int8 v11; // r14
int v12; // er12
char *v13; // r11
int v14; // eax
int v15; // edi
char *v16; // rdx
__int64 v17; // rax
unsigned int v18; // ecx
unsigned __int64 v19; // rsi
__int16 *v20; // rax
signed __int64 v21; // rbp
__int64 v22; // r13
__int16 *v23; // rax
__int16 *v24; // r14
void *v25; // rax
size_t v26; // rdx
size_t v27; // r10
unsigned int v28; // er13
__int64 v29; // rax
unsigned int v30; // er13
__int64 v32; // rsi
int v33; // [rsp+8h] [rbp-500h]
char *v34; // [rsp+8h] [rbp-500h]
char *v35; // [rsp+10h] [rbp-4F8h]
void *v36; // [rsp+10h] [rbp-4F8h]
size_t v37; // [rsp+18h] [rbp-4F0h]
__int16 src[200]; // [rsp+20h] [rbp-4E8h] BYREF
char v39[856]; // [rsp+1B0h] [rbp-358h] BYREF

v0 = 0LL;
v1 = 200LL;
yynerrs = 0;
v2 = v39;
src[0] = 0;
v3 = src;
yychar = -2;
v4 = src;
v33 = 0;
v35 = v39;
while ( 1 )
{
v5 = yypact[v0];
v6 = v5;
if ( v5 == -7 )
goto LABEL_8;
v7 = yychar;
if ( yychar == -2 )
{
v37 = (size_t)v2;
v7 = yylex();
v2 = (char *)v37;
yychar = v7;
}
if ( v7 <= 0 )
{
yychar = 0;
v8 = 0;
goto LABEL_25;
}
if ( v7 > 259 )
{
v6 = v5 + 2;
v8 = 2;
LABEL_25:
if ( v6 > 0x23 )
goto LABEL_8;
goto LABEL_26;
}
v8 = (unsigned __int8)yytranslate[v7];
v6 = v5 + v8;
if ( v5 + v8 > 0x23 )
goto LABEL_8;
LABEL_26:
if ( yycheck[v6] == v8 )
{
v0 = (unsigned __int8)yytable[v6];
if ( yytable[v6] )
{
v16 = v2 + 4;
yychar = -2;
v33 = (v33 == 0) + v33 - 1;
*((_DWORD *)v2 + 1) = yylval;
goto LABEL_13;
}
LABEL_28:
if ( !v33 )
{
v34 = v2;
++yynerrs;
yyerror("syntax error");
v2 = v34;
goto LABEL_36;
}
if ( v33 == 3 )
{
if ( yychar > 0 )
{
yychar = -2;
goto LABEL_36;
}
if ( !yychar )
{
v3 = v4;
v28 = 1;
goto LABEL_41;
}
}
while ( 1 )
{
LABEL_36:
if ( v5 == -7 )
goto LABEL_34;
v30 = v5 + 1;
if ( v30 > 0x23 )
goto LABEL_34;
if ( yycheck[v30] == 1 )
break;
if ( v3 == v4 )
{
LABEL_40:
v28 = 1;
goto LABEL_41;
}
LABEL_35:
v29 = *--v3;
v2 -= 4;
v5 = yypact[v29];
}
v0 = (unsigned __int8)yytable[v30];
if ( yytable[v30] )
{
v33 = 3;
v16 = v2 + 4;
*((_DWORD *)v2 + 1) = yylval;
goto LABEL_13;
}
LABEL_34:
if ( v3 == v4 )
goto LABEL_40;
goto LABEL_35;
}
LABEL_8:
v9 = yydefact[v0];
if ( !v9 )
goto LABEL_28;
v10 = (unsigned __int8)yydefact[v0];
v11 = yyr2[v10];
v12 = *(_DWORD *)&v2[4 * (1 - v11)];
switch ( v9 )
{
case 5:
v32 = *(unsigned int *)v2;
v37 = (size_t)v2;
printf("\t%d\n\n", v32);
v2 = (char *)v37;
break;
case 7:
v12 = *(_DWORD *)v2 + 10 * *((_DWORD *)v2 - 1);
break;
case 9:
v12 = *((_DWORD *)v2 - 1);
break;
case 11:
v12 = reg[*(int *)v2];
break;
case 13:
v12 = -*(_DWORD *)v2;
break;
case 14:
case 17:
v12 = *(_DWORD *)v2;
break;
case 15:
v12 = *(_DWORD *)v2 * *((_DWORD *)v2 - 2);
break;
case 16:
v12 = *((_DWORD *)v2 - 2) / *(_DWORD *)v2;
break;
case 18:
v12 = *((_DWORD *)v2 - 2) + *(_DWORD *)v2;
break;
case 19:
v12 = *((_DWORD *)v2 - 2) - *(_DWORD *)v2;
break;
case 20:
reg[*((int *)v2 - 2)] = *(_DWORD *)v2;
break;
default:
break;
}
v13 = &v2[-4 * v11];
v14 = (unsigned __int8)yyr1[v10];
v3 -= v11;
v15 = *v3;
*((_DWORD *)v13 + 1) = v12;
v16 = v13 + 4;
v17 = v14 - 13;
v18 = v15 + yypgoto[v17];
if ( v18 <= 0x23 && (_WORD)v15 == yycheck[v18] )
v0 = (unsigned __int8)yytable[v18];
else
v0 = yydefgoto[v17];
LABEL_13:
v19 = 2 * v1;
v20 = v3 + 1;
v3[1] = v0;
if ( v3 + 1 < &v4[v1 - 1] )
{
v2 = v16;
++v3;
goto LABEL_22;
}
v21 = (char *)v20 - (char *)v4;
v37 = v20 - v4 + 1;
if ( v1 > 0x270F )
break;
v1 = 10000LL;
if ( v19 <= 0x2710 )
v1 = v19;
v22 = v1;
v23 = (__int16 *)malloc(6 * v1 + 3);
v24 = v23;
if ( !v23 )
break;
memcpy(v23, v4, v21 + 2);
v37 *= 4LL;
v25 = memcpy((char *)v24 + ((v22 * 2 + 3) & 0xFFFFFFFFFFFFFFFCLL), v35, v37);
v26 = v37;
v27 = (size_t)v25;
if ( v4 != src )
{
v37 = (size_t)v25;
v36 = (void *)v26;
free(v4);
v27 = v37;
v26 = (size_t)v36;
}
v3 = (__int16 *)((char *)v24 + v21);
v2 = (char *)(v27 + v26 - 4);
if ( v3 >= &v24[v22 - 1] )
{
v3 = v24;
v28 = 1;
goto LABEL_42;
}
v35 = (char *)v27;
v4 = v24;
LABEL_22:
if ( (_DWORD)v0 == 18 )
{
v3 = v4;
v28 = 0;
goto LABEL_41;
}
}
v3 = v4;
v28 = 2;
yyerror("memory exhausted");
LABEL_41:
if ( v3 != src )
LABEL_42:
free(v3);
return v28;
}

canonical_decompiled_code:
__int64 func9()
{
__int64 v0; // r12
unsigned __int64 v1; // rbx
char *v2; // r11
__int16 *v3; // rbp
__int16 *v4; // r15
unsigned int v5; // er13
unsigned int v6; // er14
int v7; // eax
int v8; // eax
char v9; // al
__int64 v10; // r13
unsigned __int8 v11; // r14
int v12; // er12
char *v13; // r11
int v14; // eax
int v15; // edi
char *v16; // rdx
__int64 v17; // rax
unsigned int v18; // ecx
unsigned __int64 v19; // rsi
__int16 *v20; // rax
signed __int64 v21; // rbp
__int64 v22; // r13
__int16 *v23; // rax
__int16 *v24; // r14
void *v25; // rax
size_t v26; // rdx
size_t v27; // r10
unsigned int v28; // er13
__int64 v29; // rax
unsigned int v30; // er13
__int64 v32; // rsi
int v33; // [rsp+8h] [rbp-500h]
char *v34; // [rsp+8h] [rbp-500h]
char *v35; // [rsp+10h] [rbp-4F8h]
void *v36; // [rsp+10h] [rbp-4F8h]
size_t v37; // [rsp+18h] [rbp-4F0h]
__int16 src[200]; // [rsp+20h] [rbp-4E8h] BYREF
char v39[856]; // [rsp+1B0h] [rbp-358h] BYREF

v0 = 0LL;
v1 = 200LL;
yynerrs = 0;
v2 = v39;
src[0] = 0;
v3 = src;
yychar = -2;
v4 = src;
v33 = 0;
v35 = v39;
while ( 1 )
{
v5 = yypact[v0];
v6 = v5;
if ( v5 == -7 )
goto LABEL_8;
v7 = yychar;
if ( yychar == -2 )
{
v37 = (size_t)v2;
v7 = func7();
v2 = (char *)v37;
yychar = v7;
}
if ( v7 <= 0 )
{
yychar = 0;
v8 = 0;
goto LABEL_25;
}
if ( v7 > 259 )
{
v6 = v5 + 2;
v8 = 2;
LABEL_25:
if ( v6 > 0x23 )
goto LABEL_8;
goto LABEL_26;
}
v8 = (unsigned __int8)yytranslate[v7];
v6 = v5 + v8;
if ( v5 + v8 > 0x23 )
goto LABEL_8;
LABEL_26:
if ( yycheck[v6] == v8 )
{
v0 = (unsigned __int8)yytable[v6];
if ( yytable[v6] )
{
v16 = v2 + 4;
yychar = -2;
v33 = (v33 == 0) + v33 - 1;
*((_DWORD *)v2 + 1) = yylval;
goto LABEL_13;
}
LABEL_28:
if ( !v33 )
{
v34 = v2;
++yynerrs;
func8("syntax error");
v2 = v34;
goto LABEL_36;
}
if ( v33 == 3 )
{
if ( yychar > 0 )
{
yychar = -2;
goto LABEL_36;
}
if ( !yychar )
{
v3 = v4;
v28 = 1;
goto LABEL_41;
}
}
while ( 1 )
{
LABEL_36:
if ( v5 == -7 )
goto LABEL_34;
v30 = v5 + 1;
if ( v30 > 0x23 )
goto LABEL_34;
if ( yycheck[v30] == 1 )
break;
if ( v3 == v4 )
{
LABEL_40:
v28 = 1;
goto LABEL_41;
}
LABEL_35:
v29 = *--v3;
v2 -= 4;
v5 = yypact[v29];
}
v0 = (unsigned __int8)yytable[v30];
if ( yytable[v30] )
{
v33 = 3;
v16 = v2 + 4;
*((_DWORD *)v2 + 1) = yylval;
goto LABEL_13;
}
LABEL_34:
if ( v3 == v4 )
goto LABEL_40;
goto LABEL_35;
}
LABEL_8:
v9 = yydefact[v0];
if ( !v9 )
goto LABEL_28;
v10 = (unsigned __int8)yydefact[v0];
v11 = yyr2[v10];
v12 = *(_DWORD *)&v2[4 * (1 - v11)];
switch ( v9 )
{
case 5:
v32 = *(unsigned int *)v2;
v37 = (size_t)v2;
printf("\t%d\n\n", v32);
v2 = (char *)v37;
break;
case 7:
v12 = *(_DWORD *)v2 + 10 * *((_DWORD *)v2 - 1);
break;
case 9:
v12 = *((_DWORD *)v2 - 1);
break;
case 11:
v12 = reg[*(int *)v2];
break;
case 13:
v12 = -*(_DWORD *)v2;
break;
case 14:
case 17:
v12 = *(_DWORD *)v2;
break;
case 15:
v12 = *(_DWORD *)v2 * *((_DWORD *)v2 - 2);
break;
case 16:
v12 = *((_DWORD *)v2 - 2) / *(_DWORD *)v2;
break;
case 18:
v12 = *((_DWORD *)v2 - 2) + *(_DWORD *)v2;
break;
case 19:
v12 = *((_DWORD *)v2 - 2) - *(_DWORD *)v2;
break;
case 20:
reg[*((int *)v2 - 2)] = *(_DWORD *)v2;
break;
default:
break;
}
v13 = &v2[-4 * v11];
v14 = (unsigned __int8)yyr1[v10];
v3 -= v11;
v15 = *v3;
*((_DWORD *)v13 + 1) = v12;
v16 = v13 + 4;
v17 = v14 - 13;
v18 = v15 + yypgoto[v17];
if ( v18 <= 0x23 && (_WORD)v15 == yycheck[v18] )
v0 = (unsigned __int8)yytable[v18];
else
v0 = yydefgoto[v17];
LABEL_13:
v19 = 2 * v1;
v20 = v3 + 1;
v3[1] = v0;
if ( v3 + 1 < &v4[v1 - 1] )
{
v2 = v16;
++v3;
goto LABEL_22;
}
v21 = (char *)v20 - (char *)v4;
v37 = v20 - v4 + 1;
if ( v1 > 0x270F )
break;
v1 = 10000LL;
if ( v19 <= 0x2710 )
v1 = v19;
v22 = v1;
v23 = (__int16 *)malloc(6 * v1 + 3);
v24 = v23;
if ( !v23 )
break;
memcpy(v23, v4, v21 + 2);
v37 *= 4LL;
v25 = memcpy((char *)v24 + ((v22 * 2 + 3) & 0xFFFFFFFFFFFFFFFCLL), v35, v37);
v26 = v37;
v27 = (size_t)v25;
if ( v4 != src )
{
v37 = (size_t)v25;
v36 = (void *)v26;
free(v4);
v27 = v37;
v26 = (size_t)v36;
}
v3 = (__int16 *)((char *)v24 + v21);
v2 = (char *)(v27 + v26 - 4);
if ( v3 >= &v24[v22 - 1] )
{
v3 = v24;
v28 = 1;
goto LABEL_42;
}
v35 = (char *)v27;
v4 = v24;
LABEL_22:
if ( (_DWORD)v0 == 18 )
{
v3 = v4;
v28 = 0;
goto LABEL_41;
}
}
v3 = v4;
v28 = 2;
func8("memory exhausted");
LABEL_41:
if ( v3 != src )
LABEL_42:
free(v3);
return v28;
}

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;
  YYSTYPE yyval;
  int yylen = 0;
  yytoken = 0;
  yyss = yyssa;
  yyvs = yyvsa;
  yystacksize = 200;
  ;
  yystate = 0;
  yyerrstatus = 0;
  yynerrs = 0;
  yychar = (-2);
  yyssp = yyss;
  yyvsp = yyvs;
  goto yysetstate;
 yynewstate:
  yyssp++;
 yysetstate:
  *yyssp = yystate;
  if (yyss + yystacksize - 1 <= yyssp)
    {
      long unsigned int yysize = 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;
      ;
      if (yyss + yystacksize - 1 <= yyssp)
 goto yyabortlab;
    }
  ;
  if (yystate == 18)
    goto yyacceptlab;
  goto yybackup;
yybackup:
  yyn = yypact[yystate];
  if (yyn == -7)
    goto yydefault;
  if (yychar == (-2))
    {
      ;
      yychar = yylex ();
    }
  if (yychar <= 0)
    {
      yychar = yytoken = 0;
      ;
    }
  else
    {
      yytoken = ((unsigned int) (yychar) <= 259 ? yytranslate[yychar] : 2);
      ;
    }
  yyn += yytoken;
  if (yyn < 0 || 35 < yyn || yycheck[yyn] != yytoken)
    goto yydefault;
  yyn = yytable[yyn];
  if (yyn <= 0)
    {
      if (yyn == 0 || yyn == -1)
 goto yyerrlab;
      yyn = -yyn;
      goto yyreduce;
    }
  if (yyerrstatus)
    yyerrstatus--;
  ;
  yychar = (-2);
  yystate = yyn;
  *++yyvsp = yylval;
  goto yynewstate;
yydefault:
  yyn = yydefact[yystate];
  if (yyn == 0)
    goto yyerrlab;
  goto yyreduce;
yyreduce:
  yylen = yyr2[yyn];
  yyval = yyvsp[1-yylen];
  ;
  switch (yyn)
    {
        case 5:
    {printf("\t%d\n\n",(yyvsp[(1) - (1)]));}
    break;
  case 7:
    {(yyval)=(yyvsp[(1) - (2)])*10+(yyvsp[(2) - (2)]);}
    break;
  case 9:
    {(yyval)=(yyvsp[(2) - (3)]);}
    break;
  case 11:
    {(yyval)=reg[(yyvsp[(1) - (1)])];}
    break;
  case 13:
    {(yyval)=-(yyvsp[(2) - (2)]);}
    break;
  case 14:
    {(yyval)=(yyvsp[(1) - (1)]);}
    break;
  case 15:
    {(yyval)=(yyvsp[(1) - (3)])*(yyvsp[(3) - (3)]);}
    break;
  case 16:
    {(yyval)=(yyvsp[(1) - (3)])/(yyvsp[(3) - (3)]);}
    break;
  case 17:
    {(yyval)=(yyvsp[(1) - (1)]);}
    break;
  case 18:
    {(yyval)=(yyvsp[(1) - (3)])+(yyvsp[(3) - (3)]);}
    break;
  case 19:
    {(yyval)=(yyvsp[(1) - (3)])-(yyvsp[(3) - (3)]);}
    break;
  case 20:
    {reg[(yyvsp[(1) - (3)])]=(yyvsp[(3) - (3)]);}
    break;
      default: break;
    }
  ;
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  ;
  *++yyvsp = yyval;
  yyn = yyr1[yyn];
  yystate = yypgoto[yyn - 13] + *yyssp;
  if (0 <= yystate && yystate <= 35 && yycheck[yystate] == *yyssp)
    yystate = yytable[yystate];
  else
    yystate = yydefgoto[yyn - 13];
  goto yynewstate;
yyerrlab:
  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;
  ;
  yystate = *yyssp;
  goto yyerrlab1;
yyerrlab1:
  yyerrstatus = 3;
  for (;;)
    {
      yyn = yypact[yystate];
      if (yyn != -7)
 {
   yyn += 1;
   if (0 <= yyn && yyn <= 35 && 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;
      ;
    }
  *++yyvsp = yylval;
  ;
  yystate = yyn;
  goto yynewstate;
yyacceptlab:
  yyresult = 0;
  goto yyreturn;
yyabortlab:
  yyresult = 1;
  goto yyreturn;
yyexhaustedlab:
  yyerror ("memory exhausted");
  yyresult = 2;
yyreturn:
  if (yychar != (-2))
     yydestruct ("Cleanup: discarding lookahead",
   yytoken, &yylval);
  (yyvsp -= (yylen), yyssp -= (yylen));
  ;
  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;
    int yyvsa[200];
    int *yyvs;
    int *yyvsp;
    unsigned long yystacksize;
  int yyn;
  int yyresult;
  int yytoken;
  int yyval;
  int yylen = 0;
  yytoken = 0;
  yyss = yyssa;
  yyvs = yyvsa;
  yystacksize = 200;
  ;
  yystate = 0;
  yyerrstatus = 0;
  yynerrs = 0;
  yychar = (-2);
  yyssp = yyss;
  yyvsp = yyvs;
  goto yysetstate;
 yynewstate:
  yyssp++;
 yysetstate:
  *yyssp = yystate;
  if (yyss + yystacksize - 1 <= yyssp)
    {
      unsigned long yysize = 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;
      ;
      if (yyss + yystacksize - 1 <= yyssp)
 goto yyabortlab;
    }
  ;
  if (yystate == 18)
    goto yyacceptlab;
  goto yybackup;
yybackup:
  yyn = yypact[yystate];
  if (yyn == -7)
    goto yydefault;
  if (yychar == (-2))
    {
      ;
      yychar = yylex ();
    }
  if (yychar <= 0)
    {
      yychar = yytoken = 0;
      ;
    }
  else
    {
      yytoken = ((unsigned int) (yychar) <= 259 ? yytranslate[yychar] : 2);
      ;
    }
  yyn += yytoken;
  if (yyn < 0 || 35 < yyn || yycheck[yyn] != yytoken)
    goto yydefault;
  yyn = yytable[yyn];
  if (yyn <= 0)
    {
      if (yyn == 0 || yyn == -1)
 goto yyerrlab;
      yyn = -yyn;
      goto yyreduce;
    }
  if (yyerrstatus)
    yyerrstatus--;
  ;
  yychar = (-2);
  yystate = yyn;
  *++yyvsp = yylval;
  goto yynewstate;
yydefault:
  yyn = yydefact[yystate];
  if (yyn == 0)
    goto yyerrlab;
  goto yyreduce;
yyreduce:
  yylen = yyr2[yyn];
  yyval = yyvsp[1-yylen];
  ;
  switch (yyn)
    {
        case 5:
    {printf("\t%d\n\n",(yyvsp[(1) - (1)]));}
    break;
  case 7:
    {(yyval)=(yyvsp[(1) - (2)])*10+(yyvsp[(2) - (2)]);}
    break;
  case 9:
    {(yyval)=(yyvsp[(2) - (3)]);}
    break;
  case 11:
    {(yyval)=reg[(yyvsp[(1) - (1)])];}
    break;
  case 13:
    {(yyval)=-(yyvsp[(2) - (2)]);}
    break;
  case 14:
    {(yyval)=(yyvsp[(1) - (1)]);}
    break;
  case 15:
    {(yyval)=(yyvsp[(1) - (3)])*(yyvsp[(3) - (3)]);}
    break;
  case 16:
    {(yyval)=(yyvsp[(1) - (3)])/(yyvsp[(3) - (3)]);}
    break;
  case 17:
    {(yyval)=(yyvsp[(1) - (1)]);}
    break;
  case 18:
    {(yyval)=(yyvsp[(1) - (3)])+(yyvsp[(3) - (3)]);}
    break;
  case 19:
    {(yyval)=(yyvsp[(1) - (3)])-(yyvsp[(3) - (3)]);}
    break;
  case 20:
    {reg[(yyvsp[(1) - (3)])]=(yyvsp[(3) - (3)]);}
    break;
      default: break;
    }
  ;
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  ;
  *++yyvsp = yyval;
  yyn = yyr1[yyn];
  yystate = yypgoto[yyn - 13] + *yyssp;
  if (0 <= yystate && yystate <= 35 && yycheck[yystate] == *yyssp)
    yystate = yytable[yystate];
  else
    yystate = yydefgoto[yyn - 13];
  goto yynewstate;
yyerrlab:
  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;
  ;
  yystate = *yyssp;
  goto yyerrlab1;
yyerrlab1:
  yyerrstatus = 3;
  for (;;)
    {
      yyn = yypact[yystate];
      if (yyn != -7)
 {
   yyn += 1;
   if (0 <= yyn && yyn <= 35 && 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;
      ;
    }
  *++yyvsp = yylval;
  ;
  yystate = yyn;
  goto yynewstate;
yyacceptlab:
  yyresult = 0;
  goto yyreturn;
yyabortlab:
  yyresult = 1;
  goto yyreturn;
yyexhaustedlab:
  yyerror ("memory exhausted");
  yyresult = 2;
yyreturn:
  if (yychar != (-2))
     yydestruct ("Cleanup: discarding lookahead",
   yytoken, &yylval);
  (yyvsp -= (yylen), yyssp -= (yylen));
  ;
  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
int [200]

variable_types:
yyvs
int *

variable_types:
yyvsp
int *

variable_types:
yystacksize
unsigned long

variable_types: yyn int

variable_types: yyresult int

variable_types: yytoken int

variable_types: yyval int

variable_types: yylen int

variable_types:
yysize
unsigned long

variable_types: union yyalloc { short yyss_alloc; int yyvs_alloc; } *

variable_types:
yynewbytes
unsigned long


main

canonical_name: main

repo: NosicLin/Codger

decompiled_code:
// attributes: thunk
int __cdecl main(int argc, const char **argv, const char **envp)
{
return yyparse(argc, argv, envp);
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
return func9(argc, argv, envp);
}

original_code:
int main()
{
 return yyparse();
}

canonical_original_code:
int main()
{
 return yyparse();
}

return_type: int


yylex

decompiled_code:
int yylex()
{
const unsigned __int16 **v0; // rbx
int result; // eax
unsigned __int16 v2; // dx

v0 = __ctype_b_loc();
for ( result = 32; ; result = fgetc(_bss_start) )
{
v2 = (*v0)[result];
if ( (v2 & 0x2000) == 0 || result == 10 )
break;
}
if ( (v2 & 0x800) != 0 )
{
yylval = result - 48;
result = 258;
}
else if ( (v2 & 0x400) != 0 )
{
yylval = result - 97;
result = 259;
}
return result;
}

canonical_decompiled_code:
int func7()
{
const unsigned __int16 **v0; // rbx
int result; // eax
unsigned __int16 v2; // dx

v0 = __ctype_b_loc();
for ( result = 32; ; result = fgetc(_bss_start) )
{
v2 = (*v0)[result];
if ( (v2 & 0x2000) == 0 || result == 10 )
break;
}
if ( (v2 & 0x800) != 0 )
{
yylval = result - 48;
result = 258;
}
else if ( (v2 & 0x400) != 0 )
{
yylval = result - 97;
result = 259;
}
return result;
}

original_code:
int yylex(int a)
{
 int ch=' ';
 while(((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short int) _ISspace)&&ch!='\n')
   ch=fgetc(stdin);
 if(((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short int) _ISdigit))
 {
  yylval=ch-'0';
  return 258;
 }
 if(((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short int) _ISalpha))
 {
  yylval=ch-'a';
  return 259;
 }
 return ch;
}

canonical_original_code:
int yylex(int a)
{
 int ch = ' ';
 while(((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short) _ISspace)&&ch!='\n')
   ch=fgetc(stdin);
 if(((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short) _ISdigit))
 {
  yylval=ch-'0';
  return 258;
 }
 if(((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short) _ISalpha))
 {
  yylval=ch-'a';
  return 259;
 }
 return ch;
}

variable_types: a int

variable_types: ch int


yyerror

decompiled_code:
int __fastcall yyerror(const char *a1)
{
return fprintf(stderr, "%s\n", a1);
}

canonical_decompiled_code:
int __fastcall func8(const char *a1)
{
return fprintf(stderr, "%s\n", a1);
}

original_code:
int yyerror(char* s)
{
 fprintf(stderr,"%s\n",s);
}

canonical_original_code:
int yyerror(char *s)
{
 fprintf(stderr,"%s\n",s);
}

variable_types:
s
char *


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

result = 1LL;
if ( (unsigned __int8)(a1 - 48) > 3u )
{
result = 2LL;
if ( (unsigned __int8)(a1 - 52) > 3u )
result = 3 * (unsigned int)(a1 == 56);
}
return result;
}

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

result = 1LL;
if ( (unsigned __int8)(a1 - 48) > 3u )
{
result = 2LL;
if ( (unsigned __int8)(a1 - 52) > 3u )
result = 3 * (unsigned int)(a1 == 56);
}
return result;
}

original_code:
int input_map_cbegin(char c)
{
 if(c>='0'&&c<='3') return 1;
 else if(c>='4'&&c<='7') return 2;
 else if(c>='8'&&c<'9') return 3;
 else return 0;
}

variable_types: c char


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

result = 1LL;
if ( (unsigned __int8)(a1 - 48) > 3u )
{
result = 2LL;
if ( (unsigned __int8)(a1 - 52) > 3u )
{
if ( a1 == 56 )
result = 3LL;
else
result = 4 * (unsigned int)(a1 == 97);
}
}
return result;
}

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

result = 1LL;
if ( (unsigned __int8)(a1 - 48) > 3u )
{
result = 2LL;
if ( (unsigned __int8)(a1 - 52) > 3u )
{
if ( a1 == 56 )
result = 3LL;
else
result = 4 * (unsigned int)(a1 == 97);
}
}
return result;
}

original_code:
int input_map_c1(char c)
{
 if(c>='0'&&c<='3') return 1;
 else if(c>='4'&&c<='7') return 2;
 else if(c>='8'&&c<'9') return 3;
 else if(c=='a') return 4;
 else return 0;
}


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

result = 1LL;
if ( a1 != 98 )
result = 2 * (unsigned int)(a1 == 99);
return result;
}

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

result = 1LL;
if ( a1 != 98 )
result = 2 * (unsigned int)(a1 == 99);
return result;
}

original_code:
int input_map_c2(char c)
{
 if(c=='b') return 1;
 else if(c=='c') return 2;
 else return 0;
}


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

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

original_code:
int input_map_other(char c)
{
 return 0;
}


decompiled_code:
_BOOL8 __fastcall input_map_bbegin(char a1)
{
return (unsigned __int8)(a1 - 52) <= 5u;
}

canonical_decompiled_code:
_BOOL8 __fastcall func13(char a1)
{
return (unsigned __int8)(a1 - 52) <= 5u;
}

original_code:
int input_map_bbegin(char c)
{
 if(c>='4'&&c<='9')return 1;
 else return 0;
}


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

result = 1LL;
if ( a1 != 97 )
result = 2 * (unsigned int)((unsigned __int8)(a1 - 52) < 6u);
return result;
}

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

result = 1LL;
if ( a1 != 97 )
result = 2 * (unsigned int)((unsigned __int8)(a1 - 52) < 6u);
return result;
}

original_code:
int input_map_b1(char c)
{
 if(c=='a')return 1;
 if(c>='4'&&c<='9') return 2;
 else return 0;
}


decompiled_code:
_BOOL8 __fastcall input_map_b2(char a1)
{
return a1 == 99;
}

canonical_decompiled_code:
_BOOL8 __fastcall func15(char a1)
{
return a1 == 99;
}

original_code:
int input_map_b2(char c)
{
 if(c=='c')return 1;
 else return 0;
}


decompiled_code:
_BOOL8 __fastcall input_map_b3(char a1)
{
return a1 == 100;
}

canonical_decompiled_code:
_BOOL8 __fastcall func16(char a1)
{
return a1 == 100;
}

original_code:
int input_map_b3(char c)
{
 if(c=='d')return 1;
 else return 0;
}


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

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

original_code:
int input_map_b4(char c)
{
 return 0;
}

canonical_original_code:
int input_map_b4(char c)
{
 return 0;
}


decompiled_code:
_BOOL8 __fastcall input_map_abegin(char a1)
{
return (unsigned __int8)(a1 - 48) <= 7u;
}

canonical_decompiled_code:
_BOOL8 __fastcall func18(char a1)
{
return (unsigned __int8)(a1 - 48) <= 7u;
}

original_code:
int input_map_abegin(char c)
{
 if(c>='0'&&c<='7') return 1;
 else return 0;
}


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

result = 1LL;
if ( a1 != 97 )
result = 2 * (unsigned int)((unsigned __int8)(a1 - 48) < 8u);
return result;
}

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

result = 1LL;
if ( a1 != 97 )
result = 2 * (unsigned int)((unsigned __int8)(a1 - 48) < 8u);
return result;
}

original_code:
int input_map_a1(char c)
{
 if(c=='a')return 1;
 if(c>='0'&&c<='7') return 2;
 else return 0;
}


decompiled_code:
_BOOL8 __fastcall input_map_a2(char a1)
{
return a1 == 98;
}

canonical_decompiled_code:
_BOOL8 __fastcall func20(char a1)
{
return a1 == 98;
}

original_code:
int input_map_a2(char c)
{
 if(c=='b')return 1;
 else return 0;
}


decompiled_code:
_BOOL8 __fastcall input_map_a3(char a1)
{
return a1 == 102;
}

canonical_decompiled_code:
_BOOL8 __fastcall func21(char a1)
{
return a1 == 102;
}

original_code:
int input_map_a3(char c)
{
 if(c=='f')return 1;
 else return 0;
}


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

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

original_code:
int input_map_a4(char c)
{
 return 0;
}

canonical_original_code:
int input_map_a4(char c)
{
 return 0;
}


decompiled_code:
int __fastcall print_automaton(__int64 a1)
{
int v1; // ebp
int v2; // eax
int i; // ebx
int v4; // eax

puts("automaton{");
printf("\tstates:%d\n", (unsigned int)am_float);
printf("\tinput_type:%d\n", (unsigned int)dword_404084);
puts("\tstate_martix{");
if ( *(int *)a1 > 0 )
{
v1 = 0;
do
{
printf("\t\t");
v2 = *(_DWORD *)(a1 + 4);
if ( v2 > 0 )
{
for ( i = 0; i < v2; ++i )
{
v4 = i + v1 * v2;
printf("%d\t", *(unsigned int *)(*(_QWORD *)(a1 + 24) + 4LL * v4));
v2 = *(_DWORD *)(a1 + 4);
}
}
++v1;
putchar(10);
}
while ( *(_DWORD *)a1 > v1 );
}
puts("\t}");
return puts("}");
}

canonical_decompiled_code:
int __fastcall func7(__int64 a1)
{
int v1; // ebp
int v2; // eax
int i; // ebx
int v4; // eax

puts("automaton{");
printf("\tstates:%d\n", (unsigned int)am_float);
printf("\tinput_type:%d\n", (unsigned int)dword_404084);
puts("\tstate_martix{");
if ( *(int *)a1 > 0 )
{
v1 = 0;
do
{
printf("\t\t");
v2 = *(_DWORD *)(a1 + 4);
if ( v2 > 0 )
{
for ( i = 0; i < v2; ++i )
{
v4 = i + v1 * v2;
printf("%d\t", *(unsigned int *)(*(_QWORD *)(a1 + 24) + 4LL * v4));
v2 = *(_DWORD *)(a1 + 4);
}
}
++v1;
putchar(10);
}
while ( *(_DWORD *)a1 > v1 );
}
puts("\t}");
return puts("}");
}

original_code:
void print_automaton(struct automaton* am)
{
 printf("automaton{\n");
 printf("\tstates:%d\n",am_float.states_num);
 printf("\tinput_type:%d\n",am_float.inputs_num);
 printf("\tstate_martix{\n");
 int i,j;
 for(i=0;i<am->states_num;i++)
 {
  printf("\t\t");
  for(j=0;j<am->inputs_num;j++)
  {
   printf("%d\t",am->states_matrix[i*am->inputs_num+j]);
  }
  printf("\n");
 }
 printf("\t}\n");
 printf("}\n");
}

canonical_original_code:
void print_automaton(struct automaton *am)
{
 printf("automaton{\n");
 printf("\tstates:%d\n",am_float.states_num);
 printf("\tinput_type:%d\n",am_float.inputs_num);
 printf("\tstate_martix{\n");
 int i; int j;
 for(i=0;i<am->states_num;i++)
 {
  printf("\t\t");
  for(j=0;j<am->inputs_num;j++)
  {
   printf("%d\t",am->states_matrix[i*am->inputs_num+j]);
  }
  printf("\n");
 }
 printf("\t}\n");
 printf("}\n");
}

variable_types: struct automaton { int states_num; int inputs_num; char *type_map; int begin_state; int *states_matrix; struct state { char *name; int type; int final; } *states_info; } *

variable_types: i int

variable_types: j int

return_type: void

user_defined_types: struct automaton { int states_num; int inputs_num; char *type_map; int begin_state; int *states_matrix; struct state *states_info; }


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // eax
size_t v4; // rbx
const char *v5; // rsi
const char *v7; // [rsp+0h] [rbp-1028h] BYREF
__int64 src; // [rsp+10h] [rbp-1018h] BYREF
char v9; // [rsp+18h] [rbp-1010h]
char dest[2072]; // [rsp+810h] [rbp-818h] BYREF

print_automaton(&am_float, argv, envp);
puts("input:__quit__ exit");
printf("input:");
__isoc99_scanf();
while ( src != 0x5F5F746975715F5FLL || v9 )
{
v3 = driver(&am_float, &src, &v7);
if ( v3 == -1 )
{
puts("Sorry,Not Float");
}
else
{
v4 = v3 + 1;
memcpy(dest, &src, v4);
v5 = v7;
dest[v4] = 0;
printf("%s: %s\n", v5, dest);
if ( v4 == strlen((const char *)&src) )
printf("It's %s\n", v7);
else
puts("It's Not Float");
}
printf("\ninput:");
__isoc99_scanf();
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // eax
size_t v4; // rbx
const char *v5; // rsi
const char *v7; // [rsp+0h] [rbp-1028h] BYREF
__int64 src; // [rsp+10h] [rbp-1018h] BYREF
char v9; // [rsp+18h] [rbp-1010h]
char dest[2072]; // [rsp+810h] [rbp-818h] BYREF

func7(&am_float, argv, envp);
puts("input:__quit__ exit");
printf("input:");
__isoc99_scanf();
while ( src != 0x5F5F746975715F5FLL || v9 )
{
v3 = func8(&am_float, &src, &v7);
if ( v3 == -1 )
{
puts("Sorry,Not Float");
}
else
{
v4 = v3 + 1;
memcpy(dest, &src, v4);
v5 = v7;
dest[v4] = 0;
printf("%s: %s\n", v5, dest);
if ( v4 == strlen((const char *)&src) )
printf("It's %s\n", v7);
else
puts("It's Not Float");
}
printf("\ninput:");
__isoc99_scanf();
}
return 0;
}

original_code:
int main()
{
 char buf[2048];
 char buf_copy[2048];
 print_automaton(&am_float);
 printf("input:__quit__ exit\n");
 printf("input:");
 scanf("%s",buf);
 struct state s;
 while(strcmp(buf,"__quit__")!=0)
 {
  int ret=driver(&am_float,buf,&s);
  if(ret==-1)
  {
   printf("Sorry,Not Float\n");
  }
  else
  {
   memcpy(buf_copy,buf,ret+1);
   buf_copy[ret+1]='\0';
   printf("%s: %s\n",s.name,buf_copy);
   if(ret+1==strlen(buf))
   {
    printf("It's %s\n",s.name);
   }
   else
   {
    printf("It's Not Float\n");
   }
  }
  printf("\ninput:");
  scanf("%s",buf);
 }
 return 0;
}

canonical_original_code:
int main()
{
 char buf[2048];
 char buf_copy[2048];
 print_automaton(&am_float);
 printf("input:__quit__ exit\n");
 printf("input:");
 scanf("%s",buf);
 struct state s;
 while(strcmp(buf,"__quit__")!=0)
 {
  int ret = driver(&am_float,buf,&s);
  if(ret==-1)
  {
   printf("Sorry,Not Float\n");
  }
  else
  {
   memcpy(buf_copy,buf,ret+1);
   buf_copy[ret+1]='\0';
   printf("%s: %s\n",s.name,buf_copy);
   if(ret+1==strlen(buf))
   {
    printf("It's %s\n",s.name);
   }
   else
   {
    printf("It's Not Float\n");
   }
  }
  printf("\ninput:");
  scanf("%s",buf);
 }
 return 0;
}

variable_types:
buf
char [2048]

variable_types: struct state { char *name; int type; int final; }

variable_types: ret int


driver

original_code:
int driver(struct automaton* am,char* str,struct state* s)
{
 int length=strlen(str);
 int i;
 int cur_state=am->begin_state;
 int last_final=-1;
 for(i=0;i<length;i++)
 {
  int input_type=am->type_map[str[i]];
  int next_state=am->states_matrix[cur_state*am->inputs_num+input_type];
  if(next_state==-1)
  {
   return last_final;
  }
  else
  {
   cur_state=next_state;
   if(am->states_info[cur_state].final==1)
   {
    last_final=i;
    *s=am->states_info[cur_state];
   }
  }
 }
 return last_final;
}

canonical_original_code:
int driver(struct automaton *am, char *str, struct state *s)
{
 int length = strlen(str);
 int i;
 int cur_state = am->begin_state;
 int last_final = -1;
 for(i=0;i<length;i++)
 {
  int input_type = am->type_map[str[i]];
  int next_state = am->states_matrix[cur_state*am->inputs_num+input_type];
  if(next_state==-1)
  {
   return last_final;
  }
  else
  {
   cur_state=next_state;
   if(am->states_info[cur_state].final==1)
   {
    last_final=i;
    *s=am->states_info[cur_state];
   }
  }
 }
 return last_final;
}

variable_types:
str
char *

variable_types:
s
struct state *

variable_types: length int

user_defined_types: struct state { char *name; int type; int final; }


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

result = 1LL;
if ( a1 != 61 )
result = 2 * (unsigned int)(a1 == 62);
return result;
}

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

result = 1LL;
if ( a1 != 61 )
result = 2 * (unsigned int)(a1 == 62);
return result;
}

original_code:
int op_input_map_greater_than(char c)
{
 if(c=='=') return 1;
 else if(c=='>') return 2;
 else return 0;
}


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

result = 1LL;
if ( a1 != 61 )
result = 2 * (unsigned int)(a1 == 60);
return result;
}

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

result = 1LL;
if ( a1 != 61 )
result = 2 * (unsigned int)(a1 == 60);
return result;
}

original_code:
int op_input_map_less_than(char c)
{
 if(c=='=') return 1;
 else if (c=='<') return 2;
 else return 0;
}


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

v2 = *(_QWORD *)(a1 + 16);
if ( v2 )
result = *(_QWORD *)(*(_QWORD *)(a1 + 32) + 8LL * *(char *)(v2 + a2));
else
result = *(_QWORD *)(*(_QWORD *)(a1 + 32) + 8LL * (*(int (__fastcall **)(_QWORD))(a1 + 24))((unsigned int)a2));
return result;
}

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

v2 = *(_QWORD *)(a1 + 16);
if ( v2 )
result = *(_QWORD *)(*(_QWORD *)(a1 + 32) + 8LL * *(char *)(v2 + a2));
else
result = *(_QWORD *)(*(_QWORD *)(a1 + 32) + 8LL * (*(int (__fastcall **)(_QWORD))(a1 + 24))((unsigned int)a2));
return result;
}

original_code:
static inline struct state* state_next(struct state* s,char c)
{
 int input_type;
 if(s->s_input_map)
 {
  input_type=s->s_input_map[c];
 }
 else
 {
  input_type=s->s_input_func(c);
 }
 return s->s_targets[input_type];
}

canonical_original_code:
static inline struct state *state_next(struct state *s, char c)
{
 int input_type;
 if(s->s_input_map)
 {
  input_type=s->s_input_map[c];
 }
 else
 {
  input_type=s->s_input_func(c);
 }
 return s->s_targets[input_type];
}

return_type: struct state { char *s_name; int s_token; int s_inputs_num; char *s_input_map; int (*s_input_func)(char); struct state **s_targets; int s_final; } *


original_code:
static size_t gs_str_hash(const char* str)
{
 size_t hash = 1315423911;
 while (*str)
 {
  hash ^= ((hash << 5) + (*str++) + (hash >> 2));
 }
 return hash ;
}

canonical_original_code:
static unsigned long gs_str_hash(char *str)
{
 unsigned long hash = 1315423911;
 while (*str)
 {
  hash ^= ((hash << 5) + (*str++) + (hash >> 2));
 }
 return hash ;
}

variable_types:
hash
unsigned long

return_type: unsigned long


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

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

original_code:
int GrModule_StringExit()
{
 return 0;
}

canonical_original_code:
int GrModule_StringExit()
{
 return 0;
}


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

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

original_code:
int GrModule_ConstsExit()
{
 return 0;
}

canonical_original_code:
int GrModule_ConstsExit()
{
 return 0;
}


repo: Noxbru/Rands

decompiled_code:
__int64 __fastcall well_x64_srand(unsigned int a1)
{
__int64 *v1; // rbp
__int64 v2; // rbx
__int64 result; // rax

v1 = &well_x64_default_state;
srand(a1);
do
{
++v1;
v2 = (unsigned int)rand();
result = rand();
*(v1 - 1) = (int)result + (v2 << 32);
}
while ( v1 != &well_x64_default_state + 16 );
*((_BYTE *)&well_x64_default_state + 128) = 0;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1)
{
__int64 *v1; // rbp
__int64 v2; // rbx
__int64 result; // rax

v1 = &well_x64_default_state;
srand(a1);
do
{
++v1;
v2 = (unsigned int)rand();
result = rand();
*(v1 - 1) = (int)result + (v2 << 32);
}
while ( v1 != &well_x64_default_state + 16 );
*((_BYTE *)&well_x64_default_state + 128) = 0;
return result;
}

original_code:
void well_x64_srand(unsigned long seed)
{
    unsigned char i;
    unsigned long int r;
    srand(seed);
    for(i = 0; i < 16; i++)
    {
        r=rand();
        well_x64_default_state.wheel[i]=(r<<32)+rand();
    }
    well_x64_default_state.index=0;
}

canonical_original_code:
void well_x64_srand(unsigned long seed)
{
    unsigned char i;
    unsigned long r;
    srand(seed);
    for(i = 0; i < 16; i++)
    {
        r=rand();
        well_x64_default_state.wheel[i]=(r<<32)+rand();
    }
    well_x64_default_state.index=0;
}

variable_types:
seed
unsigned long

variable_types:
i
unsigned char

variable_types:
r
unsigned long


decompiled_code:
unsigned __int64 well_x64_rand()
{
unsigned __int8 v0; // cl
__int64 v1; // r8
__int64 v2; // r10
__int64 v3; // r9
unsigned __int64 v4; // rax
__int64 v5; // rdx
unsigned __int64 v6; // rdi
unsigned __int64 v7; // rsi
__int64 v8; // rcx
__int64 v9; // rdi
unsigned __int64 result; // rax

v0 = well_x64_default_state[16];
v1 = v0;
v2 = well_x64_default_state[v0];
v3 = well_x64_default_state[(v0 + 13) & 0xF];
v4 = well_x64_default_state[(v0 + 9) & 0xF];
LOBYTE(well_x64_default_state[16]) = (v0 + 15) & 0xF;
v5 = (v0 + 15) & 0xF;
v6 = v2 ^ v3 ^ (v2 << 16) & 0xFFFF0000FFFF0000LL ^ (v3 << 15) & 0xFFFF8000FFFF8000LL;
v7 = v6 << 18;
v8 = v4 ^ (v4 >> 11) & 0x1FFFFF001FFFFFLL;
v9 = v8 ^ v6;
well_x64_default_state[v1] = v9;
result = (32 * v9) & 0xDA442D20DA442D20LL ^ (v8 << 28) & 0xF0000000F0000000LL ^ v7 & 0xFFFC0000FFFC0000LL ^ v8 ^ well_x64_default_state[v5] ^ (4 * well_x64_default_state[v5]) & 0xFFFFFFFCFFFFFFFCLL;
well_x64_default_state[v5] = result;
return result;
}

canonical_decompiled_code:
unsigned __int64 func1()
{
unsigned __int8 v0; // cl
__int64 v1; // r8
__int64 v2; // r10
__int64 v3; // r9
unsigned __int64 v4; // rax
__int64 v5; // rdx
unsigned __int64 v6; // rdi
unsigned __int64 v7; // rsi
__int64 v8; // rcx
__int64 v9; // rdi
unsigned __int64 result; // rax

v0 = well_x64_default_state[16];
v1 = v0;
v2 = well_x64_default_state[v0];
v3 = well_x64_default_state[(v0 + 13) & 0xF];
v4 = well_x64_default_state[(v0 + 9) & 0xF];
LOBYTE(well_x64_default_state[16]) = (v0 + 15) & 0xF;
v5 = (v0 + 15) & 0xF;
v6 = v2 ^ v3 ^ (v2 << 16) & 0xFFFF0000FFFF0000LL ^ (v3 << 15) & 0xFFFF8000FFFF8000LL;
v7 = v6 << 18;
v8 = v4 ^ (v4 >> 11) & 0x1FFFFF001FFFFFLL;
v9 = v8 ^ v6;
well_x64_default_state[v1] = v9;
result = (32 * v9) & 0xDA442D20DA442D20LL ^ (v8 << 28) & 0xF0000000F0000000LL ^ v7 & 0xFFFC0000FFFC0000LL ^ v8 ^ well_x64_default_state[v5] ^ (4 * well_x64_default_state[v5]) & 0xFFFFFFFCFFFFFFFCLL;
well_x64_default_state[v5] = result;
return result;
}

original_code:
unsigned long int well_x64_rand()
{
    unsigned long int a,b,c,d;
    a=well_x64_default_state.wheel[well_x64_default_state.index];
    b=well_x64_default_state.wheel[(well_x64_default_state.index+13)&15];
    c=well_x64_default_state.wheel[(well_x64_default_state.index+9)&15];
    b=(a^((a<<16)&0xFFFF0000FFFF0000UL))^(b^((b<<15)&0xFFFF8000FFFF8000UL));
    c^=((c>>11)&0x001FFFFF001FFFFFUL);
    well_x64_default_state.wheel[well_x64_default_state.index]=d=b^c;
    well_x64_default_state.index=(well_x64_default_state.index+15)&15;
    a=well_x64_default_state.wheel[well_x64_default_state.index];
    d=d^(((d<<5)&0xFFFFFFE0FFFFFFE0UL)&0xDA442D24DA442D24UL);
    well_x64_default_state.wheel[well_x64_default_state.index]=a^((a<<2)&0xFFFFFFFCFFFFFFFCUL)^b^((b<<18)&0xFFFC0000FFFC0000UL)^((c<<28)&0xF0000000F0000000UL)^d;
    return well_x64_default_state.wheel[well_x64_default_state.index];
}

canonical_original_code:
unsigned long well_x64_rand()
{
    unsigned long a; unsigned long b; unsigned long c; unsigned long d;
    a=well_x64_default_state.wheel[well_x64_default_state.index];
    b=well_x64_default_state.wheel[(well_x64_default_state.index+13)&15];
    c=well_x64_default_state.wheel[(well_x64_default_state.index+9)&15];
    b=(a^((a<<16)&0xFFFF0000FFFF0000UL))^(b^((b<<15)&0xFFFF8000FFFF8000UL));
    c^=((c>>11)&0x001FFFFF001FFFFFUL);
    well_x64_default_state.wheel[well_x64_default_state.index]=d=b^c;
    well_x64_default_state.index=(well_x64_default_state.index+15)&15;
    a=well_x64_default_state.wheel[well_x64_default_state.index];
    d=d^(((d<<5)&0xFFFFFFE0FFFFFFE0UL)&0xDA442D24DA442D24UL);
    well_x64_default_state.wheel[well_x64_default_state.index]=a^((a<<2)&0xFFFFFFFCFFFFFFFCUL)^b^((b<<18)&0xFFFC0000FFFC0000UL)^((c<<28)&0xF0000000F0000000UL)^d;
    return well_x64_default_state.wheel[well_x64_default_state.index];
}

variable_types:
a
unsigned long

variable_types:
b
unsigned long

variable_types:
c
unsigned long

variable_types:
d
unsigned long


decompiled_code:
// attributes: thunk
void well_x64_clear_st(void *ptr)
{
free(ptr);
}

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

original_code:
inline void well_x64_clear_st(well_x64_state *st)
{
    free(st);
}

canonical_original_code:
inline void well_x64_clear_st(struct _well_x64_state *st)
{
    free(st);
}

variable_types: struct _well_x64_state { unsigned long wheel[16]; unsigned char index; } *


decompiled_code:
__int64 __fastcall well_x64_srand_st(__int64 a1, unsigned int a2)
{
__int64 v2; // r13
__int64 v3; // rbx
__int64 result; // rax

v2 = a1;
srand(a2);
do
{
v2 += 8LL;
v3 = (unsigned int)rand();
result = rand();
*(_QWORD *)(v2 - 8) = (int)result + (v3 << 32);
}
while ( v2 != a1 + 128 );
*(_BYTE *)(a1 + 128) = 0;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, unsigned int a2)
{
__int64 v2; // r13
__int64 v3; // rbx
__int64 result; // rax

v2 = a1;
srand(a2);
do
{
v2 += 8LL;
v3 = (unsigned int)rand();
result = rand();
*(_QWORD *)(v2 - 8) = (int)result + (v3 << 32);
}
while ( v2 != a1 + 128 );
*(_BYTE *)(a1 + 128) = 0;
return result;
}

original_code:
void well_x64_srand_st(well_x64_state *st, unsigned long seed)
{
    unsigned char i;
    unsigned long int r;
    srand(seed);
    for(i = 0; i < 16; i++)
    {
        r=rand();
        st->wheel[i]=(r<<32)+rand();
    }
    st->index=0;
}

canonical_original_code:
void well_x64_srand_st(struct _well_x64_state *st, unsigned long seed)
{
    unsigned char i;
    unsigned long r;
    srand(seed);
    for(i = 0; i < 16; i++)
    {
        r=rand();
        st->wheel[i]=(r<<32)+rand();
    }
    st->index=0;
}

user_defined_types: struct _well_x64_state { unsigned long wheel[16]; unsigned char index; }


original_code:
unsigned long int well_x64_rand_st(well_x64_state *st)
{
    unsigned long int a,b,c,d;
    a=st->wheel[st->index];
    b=st->wheel[(st->index+13)&15];
    c=st->wheel[(st->index+9)&15];
    b=(a^((a<<16)&0xFFFF0000FFFF0000UL))^(b^((b<<15)&0xFFFF8000FFFF8000UL));
    c^=((c>>11)&0x001FFFFF001FFFFFUL);
    st->wheel[st->index]=d=b^c;
    st->index=(st->index+15)&15;
    a=st->wheel[st->index];
    d=d^(((d<<5)&0xFFFFFFE0FFFFFFE0UL)&0xDA442D24DA442D24UL);
    st->wheel[st->index]=a^((a<<2)&0xFFFFFFFCFFFFFFFCUL)^b^((b<<18)&0xFFFC0000FFFC0000UL)^((c<<28)&0xF0000000F0000000UL)^d;
    return st->wheel[st->index];
}

canonical_original_code:
unsigned long well_x64_rand_st(struct _well_x64_state *st)
{
    unsigned long a; unsigned long b; unsigned long c; unsigned long d;
    a=st->wheel[st->index];
    b=st->wheel[(st->index+13)&15];
    c=st->wheel[(st->index+9)&15];
    b=(a^((a<<16)&0xFFFF0000FFFF0000UL))^(b^((b<<15)&0xFFFF8000FFFF8000UL));
    c^=((c>>11)&0x001FFFFF001FFFFFUL);
    st->wheel[st->index]=d=b^c;
    st->index=(st->index+15)&15;
    a=st->wheel[st->index];
    d=d^(((d<<5)&0xFFFFFFE0FFFFFFE0UL)&0xDA442D24DA442D24UL);
    st->wheel[st->index]=a^((a<<2)&0xFFFFFFFCFFFFFFFCUL)^b^((b<<18)&0xFFFC0000FFFC0000UL)^((c<<28)&0xF0000000F0000000UL)^d;
    return st->wheel[st->index];
}


decompiled_code:
int __fastcall well_srand(unsigned int a1)
{
int *v1; // rbx
int result; // eax

v1 = &well_default_state;
srand(a1);
do
{
result = rand();
*v1++ = result;
}
while ( v1 != &well_default_state + 16 );
*((_BYTE *)&well_default_state + 64) = 0;
return result;
}

canonical_decompiled_code:
int __fastcall func0(unsigned int a1)
{
int *v1; // rbx
int result; // eax

v1 = &well_default_state;
srand(a1);
do
{
result = rand();
*v1++ = result;
}
while ( v1 != &well_default_state + 16 );
*((_BYTE *)&well_default_state + 64) = 0;
return result;
}

original_code:
void well_srand(unsigned long seed)
{
    unsigned char i;
    srand(seed);
    for(i = 0; i < 16; i++)
        well_default_state.wheel[i]=rand();
    well_default_state.index=0;
}


decompiled_code:
__int64 well_rand()
{
unsigned __int8 v0; // si
__int64 v1; // r8
int v2; // er9
unsigned int v3; // eax
int v4; // edi
__int64 v5; // rdx
int v6; // esi
int v7; // edi
int v8; // ecx
int v9; // edi
__int64 result; // rax

v0 = well_default_state[16];
v1 = v0;
v2 = well_default_state[v0];
v3 = well_default_state[(v0 + 9) & 0xF];
v4 = well_default_state[(v0 + 13) & 0xF];
LOBYTE(well_default_state[16]) = (v0 + 15) & 0xF;
v5 = (v0 + 15) & 0xF;
v6 = v3 ^ (v3 >> 11);
v7 = (v4 << 15) ^ v4 ^ v2 ^ (v2 << 16);
v8 = v7 << 18;
v9 = v6 ^ v7;
well_default_state[v1] = v9;
result = (32 * v9) & 0xDA442D24 ^ (v6 << 28) ^ v8 ^ v6 ^ well_default_state[v5] ^ (4 * well_default_state[v5]);
well_default_state[v5] = result;
return result;
}

canonical_decompiled_code:
__int64 func1()
{
unsigned __int8 v0; // si
__int64 v1; // r8
int v2; // er9
unsigned int v3; // eax
int v4; // edi
__int64 v5; // rdx
int v6; // esi
int v7; // edi
int v8; // ecx
int v9; // edi
__int64 result; // rax

v0 = well_default_state[16];
v1 = v0;
v2 = well_default_state[v0];
v3 = well_default_state[(v0 + 9) & 0xF];
v4 = well_default_state[(v0 + 13) & 0xF];
LOBYTE(well_default_state[16]) = (v0 + 15) & 0xF;
v5 = (v0 + 15) & 0xF;
v6 = v3 ^ (v3 >> 11);
v7 = (v4 << 15) ^ v4 ^ v2 ^ (v2 << 16);
v8 = v7 << 18;
v9 = v6 ^ v7;
well_default_state[v1] = v9;
result = (32 * v9) & 0xDA442D24 ^ (v6 << 28) ^ v8 ^ v6 ^ well_default_state[v5] ^ (4 * well_default_state[v5]);
well_default_state[v5] = result;
return result;
}

original_code:
unsigned int well_rand()
{
    unsigned int a,b,c,d;
    a=well_default_state.wheel[well_default_state.index];
    b=well_default_state.wheel[(well_default_state.index+13)&15];
    c=well_default_state.wheel[(well_default_state.index+9)&15];
    b=a^(a<<16)^b^(b<<15);
    c^=(c>>11);
    well_default_state.wheel[well_default_state.index]=d=b^c;
    well_default_state.index=(well_default_state.index+15)&15;
    a=well_default_state.wheel[well_default_state.index];
    d=d^((d<<5)&0xDA442D24UL);
    well_default_state.wheel[well_default_state.index]=a^(a<<2)^b^(b<<18)^(c<<28)^d;
    return well_default_state.wheel[well_default_state.index];
}

canonical_original_code:
unsigned int well_rand()
{
    unsigned int a; unsigned int b; unsigned int c; unsigned int d;
    a=well_default_state.wheel[well_default_state.index];
    b=well_default_state.wheel[(well_default_state.index+13)&15];
    c=well_default_state.wheel[(well_default_state.index+9)&15];
    b=a^(a<<16)^b^(b<<15);
    c^=(c>>11);
    well_default_state.wheel[well_default_state.index]=d=b^c;
    well_default_state.index=(well_default_state.index+15)&15;
    a=well_default_state.wheel[well_default_state.index];
    d=d^((d<<5)&0xDA442D24UL);
    well_default_state.wheel[well_default_state.index]=a^(a<<2)^b^(b<<18)^(c<<28)^d;
    return well_default_state.wheel[well_default_state.index];
}

variable_types:
a
unsigned int

variable_types:
b
unsigned int

variable_types:
c
unsigned int

variable_types:
d
unsigned int

return_type: unsigned int


decompiled_code:
// attributes: thunk
void well_clear_st(void *ptr)
{
free(ptr);
}

original_code:
inline void well_clear_st(well_state *st)
{
    free(st);
}

canonical_original_code:
inline void well_clear_st(struct _well_state *st)
{
    free(st);
}

variable_types: struct _well_state { unsigned int wheel[16]; unsigned char index; } *


decompiled_code:
int __fastcall well_srand_st(__int64 a1, unsigned int a2)
{
__int64 v2; // rbx
int result; // eax

v2 = a1;
srand(a2);
do
{
result = rand();
v2 += 4LL;
*(_DWORD *)(v2 - 4) = result;
}
while ( v2 != a1 + 64 );
*(_BYTE *)(a1 + 64) = 0;
return result;
}

canonical_decompiled_code:
int __fastcall func4(__int64 a1, unsigned int a2)
{
__int64 v2; // rbx
int result; // eax

v2 = a1;
srand(a2);
do
{
result = rand();
v2 += 4LL;
*(_DWORD *)(v2 - 4) = result;
}
while ( v2 != a1 + 64 );
*(_BYTE *)(a1 + 64) = 0;
return result;
}

original_code:
void well_srand_st(well_state *st, unsigned long seed)
{
    unsigned char i;
    srand(seed);
    for(i = 0; i < 16; i++)
        st->wheel[i]=rand();
    st->index=0;
}

canonical_original_code:
void well_srand_st(struct _well_state *st, unsigned long seed)
{
    unsigned char i;
    srand(seed);
    for(i = 0; i < 16; i++)
        st->wheel[i]=rand();
    st->index=0;
}

user_defined_types: struct _well_state { unsigned int wheel[16]; unsigned char index; }


original_code:
unsigned int well_rand_st(well_state *st)
{
    unsigned int a,b,c,d;
    a=st->wheel[st->index];
    b=st->wheel[(st->index+13)&15];
    c=st->wheel[(st->index+9)&15];
    b=a^(a<<16)^b^(b<<15);
    c^=(c>>11);
    st->wheel[st->index]=d=b^c;
    st->index=(st->index+15)&15;
    a=st->wheel[st->index];
    d=d^((d<<5)&0xDA442D24UL);
    st->wheel[st->index]=a^(a<<2)^b^(b<<18)^(c<<28)^d;
    return st->wheel[st->index];
}

canonical_original_code:
unsigned int well_rand_st(struct _well_state *st)
{
    unsigned int a; unsigned int b; unsigned int c; unsigned int d;
    a=st->wheel[st->index];
    b=st->wheel[(st->index+13)&15];
    c=st->wheel[(st->index+9)&15];
    b=a^(a<<16)^b^(b<<15);
    c^=(c>>11);
    st->wheel[st->index]=d=b^c;
    st->index=(st->index+15)&15;
    a=st->wheel[st->index];
    d=d^((d<<5)&0xDA442D24UL);
    st->wheel[st->index]=a^(a<<2)^b^(b<<18)^(c<<28)^d;
    return st->wheel[st->index];
}


decompiled_code:
__int64 __fastcall isaac_x64_srand(unsigned int a1)
{
__int64 *v1; // rbp
__int64 v2; // rbx
__int64 result; // rax

v1 = &isaac_x64_default_state;
srand(a1);
do
{
++v1;
v2 = (unsigned int)rand();
*(v1 - 1) = rand() + (v2 << 32);
}
while ( v1 != &isaac_x64_default_state + 256 );
*(&isaac_x64_default_state + 512) = 0LL;
result = 0LL;
*(&isaac_x64_default_state + 513) = 0LL;
*((_WORD *)&isaac_x64_default_state + 2056) = 0;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1)
{
__int64 *v1; // rbp
__int64 v2; // rbx
__int64 result; // rax

v1 = &isaac_x64_default_state;
srand(a1);
do
{
++v1;
v2 = (unsigned int)rand();
*(v1 - 1) = rand() + (v2 << 32);
}
while ( v1 != &isaac_x64_default_state + 256 );
*(&isaac_x64_default_state + 512) = 0LL;
result = 0LL;
*(&isaac_x64_default_state + 513) = 0LL;
*((_WORD *)&isaac_x64_default_state + 2056) = 0;
return result;
}

original_code:
void isaac_x64_srand(unsigned long int seed)
{
    unsigned int i;
    unsigned long int r;
    srand(seed);
    for(i = 0; i < 256; i++)
    {
        r=rand();
        isaac_x64_default_state.wheel[i]=(r<<32)+rand();
    }
    isaac_x64_default_state.a=0;
    isaac_x64_default_state.b=0;
    isaac_x64_default_state.c=0;
    isaac_x64_default_state.index=0;
}

canonical_original_code:
void isaac_x64_srand(unsigned long seed)
{
    unsigned int i;
    unsigned long r;
    srand(seed);
    for(i = 0; i < 256; i++)
    {
        r=rand();
        isaac_x64_default_state.wheel[i]=(r<<32)+rand();
    }
    isaac_x64_default_state.a=0;
    isaac_x64_default_state.b=0;
    isaac_x64_default_state.c=0;
    isaac_x64_default_state.index=0;
}

variable_types:
i
unsigned int


decompiled_code:
__int64 isaac_x64_calc()
{
__int64 v0; // rdi
unsigned __int8 v1; // al
__int64 v2; // rsi
__int64 result; // rax
__int64 v4; // r8
__int64 v5; // rcx
unsigned __int64 v6; // rdx
unsigned __int64 v7; // rsi
__int64 v8; // rcx
__int64 v9; // rsi
__int64 v10; // rdi
unsigned __int64 v11; // rcx
__int64 v12; // rsi
__int64 v13; // rcx
unsigned __int64 v14; // rdi
unsigned __int64 v15; // rsi
__int64 v16; // rcx
__int64 v17; // rsi
unsigned __int64 v18; // rcx
__int64 v19; // rsi

v0 = isaac_x64_default_state[512];
v1 = LOBYTE(isaac_x64_default_state[514]) + 1;
v2 = isaac_x64_default_state[513] + v1;
LOBYTE(isaac_x64_default_state[514]) = v1;
result = 0LL;
v4 = v2;
do
{
v5 = isaac_x64_default_state[result];
v6 = isaac_x64_default_state[(unsigned __int8)(result + 0x80)] + ~(v0 ^ (v0 << 21));
v7 = v4 + v6 + *(__int64 *)((char *)isaac_x64_default_state + (v5 & 0x7F8));
isaac_x64_default_state[result] = v7;
v8 = isaac_x64_default_state[(unsigned __int8)(v7 >> 11)] + v5;
v9 = isaac_x64_default_state[result + 1];
isaac_x64_default_state[result + 256] = v8;
v10 = isaac_x64_default_state[(unsigned __int8)(result - 127)] + ((v6 >> 5) ^ v6);
v11 = v8 + v10 + *(__int64 *)((char *)isaac_x64_default_state + (v9 & 0x7F8));
isaac_x64_default_state[result + 1] = v11;
v12 = isaac_x64_default_state[(unsigned __int8)(v11 >> 11)] + v9;
v13 = isaac_x64_default_state[result + 2];
isaac_x64_default_state[result + 257] = v12;
v14 = isaac_x64_default_state[(unsigned __int8)(result - 126)] + (v10 ^ (v10 << 12));
v15 = v12 + v14 + *(__int64 *)((char *)isaac_x64_default_state + (v13 & 0x7F8));
isaac_x64_default_state[result + 2] = v15;
v16 = isaac_x64_default_state[(unsigned __int8)(v15 >> 11)] + v13;
v17 = isaac_x64_default_state[result + 3];
isaac_x64_default_state[result + 258] = v16;
v0 = (v14 ^ (v14 >> 33)) + isaac_x64_default_state[(unsigned __int8)(result - 125)];
v18 = v16 + v0 + *(__int64 *)((char *)isaac_x64_default_state + (v17 & 0x7F8));
isaac_x64_default_state[result + 3] = v18;
v19 = isaac_x64_default_state[(unsigned __int8)(v18 >> 11)] + v17;
isaac_x64_default_state[result + 259] = v19;
result += 4LL;
v4 = v19;
}
while ( result != 256 );
isaac_x64_default_state[512] = v0;
isaac_x64_default_state[513] = v19;
return result;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 v0; // rdi
unsigned __int8 v1; // al
__int64 v2; // rsi
__int64 result; // rax
__int64 v4; // r8
__int64 v5; // rcx
unsigned __int64 v6; // rdx
unsigned __int64 v7; // rsi
__int64 v8; // rcx
__int64 v9; // rsi
__int64 v10; // rdi
unsigned __int64 v11; // rcx
__int64 v12; // rsi
__int64 v13; // rcx
unsigned __int64 v14; // rdi
unsigned __int64 v15; // rsi
__int64 v16; // rcx
__int64 v17; // rsi
unsigned __int64 v18; // rcx
__int64 v19; // rsi

v0 = isaac_x64_default_state[512];
v1 = LOBYTE(isaac_x64_default_state[514]) + 1;
v2 = isaac_x64_default_state[513] + v1;
LOBYTE(isaac_x64_default_state[514]) = v1;
result = 0LL;
v4 = v2;
do
{
v5 = isaac_x64_default_state[result];
v6 = isaac_x64_default_state[(unsigned __int8)(result + 0x80)] + ~(v0 ^ (v0 << 21));
v7 = v4 + v6 + *(__int64 *)((char *)isaac_x64_default_state + (v5 & 0x7F8));
isaac_x64_default_state[result] = v7;
v8 = isaac_x64_default_state[(unsigned __int8)(v7 >> 11)] + v5;
v9 = isaac_x64_default_state[result + 1];
isaac_x64_default_state[result + 256] = v8;
v10 = isaac_x64_default_state[(unsigned __int8)(result - 127)] + ((v6 >> 5) ^ v6);
v11 = v8 + v10 + *(__int64 *)((char *)isaac_x64_default_state + (v9 & 0x7F8));
isaac_x64_default_state[result + 1] = v11;
v12 = isaac_x64_default_state[(unsigned __int8)(v11 >> 11)] + v9;
v13 = isaac_x64_default_state[result + 2];
isaac_x64_default_state[result + 257] = v12;
v14 = isaac_x64_default_state[(unsigned __int8)(result - 126)] + (v10 ^ (v10 << 12));
v15 = v12 + v14 + *(__int64 *)((char *)isaac_x64_default_state + (v13 & 0x7F8));
isaac_x64_default_state[result + 2] = v15;
v16 = isaac_x64_default_state[(unsigned __int8)(v15 >> 11)] + v13;
v17 = isaac_x64_default_state[result + 3];
isaac_x64_default_state[result + 258] = v16;
v0 = (v14 ^ (v14 >> 33)) + isaac_x64_default_state[(unsigned __int8)(result - 125)];
v18 = v16 + v0 + *(__int64 *)((char *)isaac_x64_default_state + (v17 & 0x7F8));
isaac_x64_default_state[result + 3] = v18;
v19 = isaac_x64_default_state[(unsigned __int8)(v18 >> 11)] + v17;
isaac_x64_default_state[result + 259] = v19;
result += 4LL;
v4 = v19;
}
while ( result != 256 );
isaac_x64_default_state[512] = v0;
isaac_x64_default_state[513] = v19;
return result;
}

original_code:
void isaac_x64_calc()
{
    unsigned int i;
    unsigned long int x,y;
    unsigned long int a,b;
    isaac_x64_default_state.c++;
    a=isaac_x64_default_state.a;
    b=isaac_x64_default_state.b+isaac_x64_default_state.c;
    for(i = 0; i < 256; i++)
    {
        x = isaac_x64_default_state.wheel[i];
        a =~(a^(a<<21)) + isaac_x64_default_state.wheel[(i+128)%256];
        isaac_x64_default_state.wheel[i]= y = a+b+isaac_x64_default_state.wheel[(x>>3)%256];
        isaac_x64_default_state.wheel2[i]=b = x + isaac_x64_default_state.wheel[(y>>11)%256];
        i++;
        x = isaac_x64_default_state.wheel[i];
        a = (a^(a>>5)) + isaac_x64_default_state.wheel[(i+128)%256];
        isaac_x64_default_state.wheel[i]= y = a+b+isaac_x64_default_state.wheel[(x>>3)%256];
        isaac_x64_default_state.wheel2[i]=b = x + isaac_x64_default_state.wheel[(y>>11)%256];
        i++;
        x=isaac_x64_default_state.wheel[i];
        a= (a^(a<<12)) + isaac_x64_default_state.wheel[(i+128)%256];
        isaac_x64_default_state.wheel[i]= y = a+b+isaac_x64_default_state.wheel[(x>>3)%256];
        isaac_x64_default_state.wheel2[i]=b = x + isaac_x64_default_state.wheel[(y>>11)%256];
        i++;
        x=isaac_x64_default_state.wheel[i];
        a= (a^(a>>33)) + isaac_x64_default_state.wheel[(i+128)%256];
        isaac_x64_default_state.wheel[i]= y = a+b+isaac_x64_default_state.wheel[(x>>3)%256];
        isaac_x64_default_state.wheel2[i]=b = x + isaac_x64_default_state.wheel[(y>>11)%256];
    }
    isaac_x64_default_state.a=a;
    isaac_x64_default_state.b=b;
}

canonical_original_code:
void isaac_x64_calc()
{
    unsigned int i;
    unsigned long x; unsigned long y;
    unsigned long a; unsigned long b;
    isaac_x64_default_state.c++;
    a=isaac_x64_default_state.a;
    b=isaac_x64_default_state.b+isaac_x64_default_state.c;
    for(i = 0; i < 256; i++)
    {
        x = isaac_x64_default_state.wheel[i];
        a =~(a^(a<<21)) + isaac_x64_default_state.wheel[(i+128)%256];
        isaac_x64_default_state.wheel[i]= y = a+b+isaac_x64_default_state.wheel[(x>>3)%256];
        isaac_x64_default_state.wheel2[i]=b = x + isaac_x64_default_state.wheel[(y>>11)%256];
        i++;
        x = isaac_x64_default_state.wheel[i];
        a = (a^(a>>5)) + isaac_x64_default_state.wheel[(i+128)%256];
        isaac_x64_default_state.wheel[i]= y = a+b+isaac_x64_default_state.wheel[(x>>3)%256];
        isaac_x64_default_state.wheel2[i]=b = x + isaac_x64_default_state.wheel[(y>>11)%256];
        i++;
        x=isaac_x64_default_state.wheel[i];
        a= (a^(a<<12)) + isaac_x64_default_state.wheel[(i+128)%256];
        isaac_x64_default_state.wheel[i]= y = a+b+isaac_x64_default_state.wheel[(x>>3)%256];
        isaac_x64_default_state.wheel2[i]=b = x + isaac_x64_default_state.wheel[(y>>11)%256];
        i++;
        x=isaac_x64_default_state.wheel[i];
        a= (a^(a>>33)) + isaac_x64_default_state.wheel[(i+128)%256];
        isaac_x64_default_state.wheel[i]= y = a+b+isaac_x64_default_state.wheel[(x>>3)%256];
        isaac_x64_default_state.wheel2[i]=b = x + isaac_x64_default_state.wheel[(y>>11)%256];
    }
    isaac_x64_default_state.a=a;
    isaac_x64_default_state.b=b;
}

variable_types:
x
unsigned long

variable_types:
y
unsigned long


decompiled_code:
// attributes: thunk
void isaac_x64_clear_st(void *ptr)
{
free(ptr);
}

original_code:
inline void isaac_x64_clear_st(isaac_x64_state *st)
{
    free(st);
}

canonical_original_code:
inline void isaac_x64_clear_st(struct _isaac_x64_state *st)
{
    free(st);
}

variable_types: struct _isaac_x64_state { unsigned long wheel[256]; unsigned long wheel2[256]; unsigned long a; unsigned char c; unsigned char index; } *


original_code:
void isaac_x64_srand_st(isaac_x64_state *st, unsigned long int seed)
{
    unsigned int i;
    unsigned long int r;
    srand(seed);
    for(i = 0; i < 256; i++)
    {
        r=rand();
        st->wheel[i]=(r<<32)+rand();
    }
    st->a=0;
    st->b=0;
    st->c=0;
    st->index=0;
}

canonical_original_code:
void isaac_x64_srand_st(struct _isaac_x64_state *st, unsigned long seed)
{
    unsigned int i;
    unsigned long r;
    srand(seed);
    for(i = 0; i < 256; i++)
    {
        r=rand();
        st->wheel[i]=(r<<32)+rand();
    }
    st->a=0;
    st->b=0;
    st->c=0;
    st->index=0;
}

variable_types:
seed
unsigned long

user_defined_types: struct _isaac_x64_state { unsigned long wheel[256]; unsigned long wheel2[256]; unsigned long a; unsigned char c; unsigned char index; }


decompiled_code:
int __fastcall xor_srand(unsigned int a1)
{
int result; // eax

srand(a1);
xor_default_state = rand();
*(&xor_default_state + 1) = rand();
*(&xor_default_state + 2) = rand();
result = rand();
*(&xor_default_state + 3) = result;
return result;
}

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

srand(a1);
xor_default_state = rand();
*(&xor_default_state + 1) = rand();
*(&xor_default_state + 2) = rand();
result = rand();
*(&xor_default_state + 3) = result;
return result;
}

original_code:
void xor_srand(unsigned long int seed)
{
    srand(seed);
    xor_default_state.wheel[0]=rand();
    xor_default_state.wheel[1]=rand();
    xor_default_state.wheel[2]=rand();
    xor_default_state.wheel[3]=rand();
}

canonical_original_code:
void xor_srand(unsigned long seed)
{
    srand(seed);
    xor_default_state.wheel[0]=rand();
    xor_default_state.wheel[1]=rand();
    xor_default_state.wheel[2]=rand();
    xor_default_state.wheel[3]=rand();
}


decompiled_code:
__int64 xor_rand()
{
unsigned int v0; // ecx
unsigned int v1; // edx
int v2; // eax
__int64 result; // rax

v0 = *(&xor_default_state + 3);
v1 = xor_default_state ^ (xor_default_state << 11);
xor_default_state = *(&xor_default_state + 1);
v2 = *(&xor_default_state + 2);
*(&xor_default_state + 2) = v0;
*(&xor_default_state + 1) = v2;
result = (v1 >> 8) ^ v1 ^ v0 ^ (v0 >> 19);
*(&xor_default_state + 3) = result;
return result;
}

canonical_decompiled_code:
__int64 func1()
{
unsigned int v0; // ecx
unsigned int v1; // edx
int v2; // eax
__int64 result; // rax

v0 = *(&xor_default_state + 3);
v1 = xor_default_state ^ (xor_default_state << 11);
xor_default_state = *(&xor_default_state + 1);
v2 = *(&xor_default_state + 2);
*(&xor_default_state + 2) = v0;
*(&xor_default_state + 1) = v2;
result = (v1 >> 8) ^ v1 ^ v0 ^ (v0 >> 19);
*(&xor_default_state + 3) = result;
return result;
}

original_code:
unsigned int xor_rand()
{
    unsigned int t=xor_default_state.wheel[0]^(xor_default_state.wheel[0]<<11);
    unsigned int a=xor_default_state.wheel[3]^(xor_default_state.wheel[3]>>19);
    xor_default_state.wheel[0]=xor_default_state.wheel[1];
    xor_default_state.wheel[1]=xor_default_state.wheel[2];
    xor_default_state.wheel[2]=xor_default_state.wheel[3];
    xor_default_state.wheel[3]=a ^ (t^(t>>8));
    return xor_default_state.wheel[3];
}

canonical_original_code:
unsigned int xor_rand()
{
    unsigned int t = xor_default_state.wheel[0]^(xor_default_state.wheel[0]<<11);
    unsigned int a = xor_default_state.wheel[3]^(xor_default_state.wheel[3]>>19);
    xor_default_state.wheel[0]=xor_default_state.wheel[1];
    xor_default_state.wheel[1]=xor_default_state.wheel[2];
    xor_default_state.wheel[2]=xor_default_state.wheel[3];
    xor_default_state.wheel[3]=a ^ (t^(t>>8));
    return xor_default_state.wheel[3];
}

variable_types:
t
unsigned int


decompiled_code:
// attributes: thunk
void xor_clear_st(void *ptr)
{
free(ptr);
}

original_code:
inline void xor_clear_st(xor_state *st)
{
    free(st);
}

canonical_original_code:
inline void xor_clear_st(struct _xor_state *st)
{
    free(st);
}

variable_types: struct _xor_state { unsigned int wheel[4]; } *


decompiled_code:
int __fastcall xor_srand_st(int *a1, unsigned int a2)
{
int result; // eax

srand(a2);
*a1 = rand();
a1[1] = rand();
a1[2] = rand();
result = rand();
a1[3] = result;
return result;
}

canonical_decompiled_code:
int __fastcall func4(int *a1, unsigned int a2)
{
int result; // eax

srand(a2);
*a1 = rand();
a1[1] = rand();
a1[2] = rand();
result = rand();
a1[3] = result;
return result;
}

original_code:
void xor_srand_st(xor_state *st, unsigned long int seed)
{
    srand(seed);
    st->wheel[0]=rand();
    st->wheel[1]=rand();
    st->wheel[2]=rand();
    st->wheel[3]=rand();
}

canonical_original_code:
void xor_srand_st(struct _xor_state *st, unsigned long seed)
{
    srand(seed);
    st->wheel[0]=rand();
    st->wheel[1]=rand();
    st->wheel[2]=rand();
    st->wheel[3]=rand();
}

user_defined_types: struct _xor_state { unsigned int wheel[4]; }


decompiled_code:
__int64 __fastcall xor_rand_st(_DWORD *a1)
{
unsigned int v1; // ecx
unsigned int v2; // edx
int v3; // eax
__int64 result; // rax

v1 = a1[3];
v2 = *a1 ^ (*a1 << 11);
*a1 = a1[1];
v3 = a1[2];
a1[2] = v1;
a1[1] = v3;
result = (v2 >> 8) ^ v2 ^ v1 ^ (v1 >> 19);
a1[3] = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(_DWORD *a1)
{
unsigned int v1; // ecx
unsigned int v2; // edx
int v3; // eax
__int64 result; // rax

v1 = a1[3];
v2 = *a1 ^ (*a1 << 11);
*a1 = a1[1];
v3 = a1[2];
a1[2] = v1;
a1[1] = v3;
result = (v2 >> 8) ^ v2 ^ v1 ^ (v1 >> 19);
a1[3] = result;
return result;
}

original_code:
unsigned int xor_rand_st(xor_state *st)
{
    unsigned int t=st->wheel[0]^(st->wheel[0]<<11);
    unsigned int a=st->wheel[3]^(st->wheel[3]>>19);
    st->wheel[0]=st->wheel[1];
    st->wheel[1]=st->wheel[2];
    st->wheel[2]=st->wheel[3];
    st->wheel[3]=a ^ (t^(t>>8));
    return st->wheel[3];
}

canonical_original_code:
unsigned int xor_rand_st(struct _xor_state *st)
{
    unsigned int t = st->wheel[0]^(st->wheel[0]<<11);
    unsigned int a = st->wheel[3]^(st->wheel[3]>>19);
    st->wheel[0]=st->wheel[1];
    st->wheel[1]=st->wheel[2];
    st->wheel[2]=st->wheel[3];
    st->wheel[3]=a ^ (t^(t>>8));
    return st->wheel[3];
}


decompiled_code:
int __fastcall mt_srand(unsigned int a1)
{
int *v1; // rbx
int result; // eax

v1 = mt_default_state;
srand(a1);
do
{
result = rand();
*v1++ = result;
}
while ( v1 != &mt_default_state[624] );
mt_default_state[1248] = 0;
return result;
}

canonical_decompiled_code:
int __fastcall func0(unsigned int a1)
{
int *v1; // rbx
int result; // eax

v1 = mt_default_state;
srand(a1);
do
{
result = rand();
*v1++ = result;
}
while ( v1 != &mt_default_state[624] );
mt_default_state[1248] = 0;
return result;
}

original_code:
void mt_srand(unsigned long int seed)
{
    unsigned int i;
    srand(seed);
    for(i = 0; i < 624; i++)
        mt_default_state.wheel[i]=rand();
    mt_default_state.index=0;
}

canonical_original_code:
void mt_srand(unsigned long seed)
{
    unsigned int i;
    srand(seed);
    for(i = 0; i < 624; i++)
        mt_default_state.wheel[i]=rand();
    mt_default_state.index=0;
}


decompiled_code:
__int64 mt_calc()
{
__int64 i; // rdx
unsigned int v1; // eax
unsigned int v2; // eax
unsigned int v3; // ecx
__int64 result; // rax

for ( i = 1LL; i != 625; ++i )
{
v1 = mt_default_state[i - 1] & 0x80000000 | mt_default_state[(unsigned int)i % 0x270] & 0x7FFFFFFF;
v2 = mt_magic_1[v1 & 1] ^ mt_default_state[((int)i + 396) % 0x270u] ^ (v1 >> 1);
mt_default_state[i - 1] = v2;
v3 = v2 ^ (v2 >> 11) ^ ((v2 ^ (v2 >> 11)) << 7) & 0x9D2C5680;
result = ((v3 ^ (v3 << 15) & 0xEFC60000) >> 18) ^ v3 ^ (v3 << 15) & 0xEFC60000;
mt_default_state[i + 623] = result;
}
mt_default_state[1248] = 0;
return result;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 i; // rdx
unsigned int v1; // eax
unsigned int v2; // eax
unsigned int v3; // ecx
__int64 result; // rax

for ( i = 1LL; i != 625; ++i )
{
v1 = mt_default_state[i - 1] & 0x80000000 | mt_default_state[(unsigned int)i % 0x270] & 0x7FFFFFFF;
v2 = mt_magic_1[v1 & 1] ^ mt_default_state[((int)i + 396) % 0x270u] ^ (v1 >> 1);
mt_default_state[i - 1] = v2;
v3 = v2 ^ (v2 >> 11) ^ ((v2 ^ (v2 >> 11)) << 7) & 0x9D2C5680;
result = ((v3 ^ (v3 << 15) & 0xEFC60000) >> 18) ^ v3 ^ (v3 << 15) & 0xEFC60000;
mt_default_state[i + 623] = result;
}
mt_default_state[1248] = 0;
return result;
}

original_code:
void mt_calc()
{
    unsigned int i,y;
    static unsigned int mt_magic[2] = {0,0x9908b0df};
    for(i = 0; i < 624; i++)
    {
        y = (mt_default_state.wheel[i] & 0x80000000) | (mt_default_state.wheel[(i+1)%624] & 0x7fffffff);
        mt_default_state.wheel[i] = mt_default_state.wheel[(i+397)%624] ^ (y>>1) ^ mt_magic[y&1];
        y = mt_default_state.wheel[i];
        y^= (y>>11);
        y^= ((y<<7)&0x9d2c5680);
        y^= ((y<<15)&0xefc60000);
        y^= (y>>18);
        mt_default_state.wheel2[i] = y;
    }
    mt_default_state.index = 0;
}

canonical_original_code:
void mt_calc()
{
    unsigned int i; unsigned int y;
    static unsigned int mt_magic[2] = {0,0x9908b0df};
    for(i = 0; i < 624; i++)
    {
        y = (mt_default_state.wheel[i] & 0x80000000) | (mt_default_state.wheel[(i+1)%624] & 0x7fffffff);
        mt_default_state.wheel[i] = mt_default_state.wheel[(i+397)%624] ^ (y>>1) ^ mt_magic[y&1];
        y = mt_default_state.wheel[i];
        y^= (y>>11);
        y^= ((y<<7)&0x9d2c5680);
        y^= ((y<<15)&0xefc60000);
        y^= (y>>18);
        mt_default_state.wheel2[i] = y;
    }
    mt_default_state.index = 0;
}

variable_types:
y
unsigned int


decompiled_code:
__int64 mt_rand()
{
int v0; // eax
unsigned int v1; // edx
__int64 result; // rax

v0 = mt_default_state[1248];
if ( !v0 )
{
mt_calc();
v0 = mt_default_state[1248];
}
v1 = (v0 + 1) % 0x270u;
result = (unsigned int)mt_default_state[v0 + 624];
mt_default_state[1248] = v1;
return result;
}

canonical_decompiled_code:
__int64 func2()
{
int v0; // eax
unsigned int v1; // edx
__int64 result; // rax

v0 = mt_default_state[1248];
if ( !v0 )
{
func1();
v0 = mt_default_state[1248];
}
v1 = (v0 + 1) % 0x270u;
result = (unsigned int)mt_default_state[v0 + 624];
mt_default_state[1248] = v1;
return result;
}

original_code:
unsigned int mt_rand()
{
    unsigned int r;
    if(!mt_default_state.index)
        mt_calc();
    r = mt_default_state.wheel2[mt_default_state.index];
    mt_default_state.index = (mt_default_state.index + 1)%624;
    return r;
}

variable_types:
r
unsigned int


decompiled_code:
// attributes: thunk
void mt_clear_st(void *ptr)
{
free(ptr);
}

canonical_decompiled_code:
void func4(void *ptr)
{
free(ptr);
}

original_code:
inline void mt_clear_st(mt_state *st)
{
    free(st);
}

canonical_original_code:
inline void mt_clear_st(struct _mt_state *st)
{
    free(st);
}

variable_types: struct _mt_state { unsigned int wheel[624]; unsigned int wheel2[624]; unsigned int index; } *


decompiled_code:
int __fastcall mt_srand_st(__int64 a1, unsigned int a2)
{
__int64 v2; // rbx
int result; // eax

v2 = a1;
srand(a2);
do
{
result = rand();
v2 += 4LL;
*(_DWORD *)(v2 - 4) = result;
}
while ( v2 != a1 + 2496 );
*(_DWORD *)(a1 + 4992) = 0;
return result;
}

canonical_decompiled_code:
int __fastcall func5(__int64 a1, unsigned int a2)
{
__int64 v2; // rbx
int result; // eax

v2 = a1;
srand(a2);
do
{
result = rand();
v2 += 4LL;
*(_DWORD *)(v2 - 4) = result;
}
while ( v2 != a1 + 2496 );
*(_DWORD *)(a1 + 4992) = 0;
return result;
}

original_code:
void mt_srand_st(mt_state *st, unsigned long int seed)
{
    unsigned int i;
    srand(seed);
    for(i = 0; i < 624; i++)
        st->wheel[i]=rand();
    st->index=0;
}

canonical_original_code:
void mt_srand_st(struct _mt_state *st, unsigned long seed)
{
    unsigned int i;
    srand(seed);
    for(i = 0; i < 624; i++)
        st->wheel[i]=rand();
    st->index=0;
}

user_defined_types: struct _mt_state { unsigned int wheel[624]; unsigned int wheel2[624]; unsigned int index; }


decompiled_code:
__int64 __fastcall mt_rand_st(__int64 a1)
{
unsigned int v1; // eax
unsigned int v2; // edx
__int64 result; // rax

v1 = *(_DWORD *)(a1 + 4992);
if ( !v1 )
{
mt_calc_st(a1);
v1 = *(_DWORD *)(a1 + 4992);
}
v2 = (v1 + 1) % 0x270;
result = *(unsigned int *)(a1 + 4LL * v1 + 2496);
*(_DWORD *)(a1 + 4992) = v2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
unsigned int v1; // eax
unsigned int v2; // edx
__int64 result; // rax

v1 = *(_DWORD *)(a1 + 4992);
if ( !v1 )
{
func6(a1);
v1 = *(_DWORD *)(a1 + 4992);
}
v2 = (v1 + 1) % 0x270;
result = *(unsigned int *)(a1 + 4LL * v1 + 2496);
*(_DWORD *)(a1 + 4992) = v2;
return result;
}

original_code:
unsigned int mt_rand_st(mt_state *st)
{
    unsigned int r;
    if(!st->index)
        mt_calc_st(st);
    r = st->wheel2[st->index];
    st->index = (st->index + 1)%624;
    return r;
}

canonical_original_code:
unsigned int mt_rand_st(struct _mt_state *st)
{
    unsigned int r;
    if(!st->index)
        mt_calc_st(st);
    r = st->wheel2[st->index];
    st->index = (st->index + 1)%624;
    return r;
}


decompiled_code:
int __fastcall pr_srand(unsigned int a1)
{
int *v1; // rbx
int result; // eax

v1 = &pr_default_state;
srand(a1);
*((_BYTE *)&pr_default_state + 1024) = 0;
do
*v1++ = rand();
while ( v1 != &pr_default_state + 255 );
result = rand();
*(&pr_default_state + 255) = result;
return result;
}

canonical_decompiled_code:
int __fastcall func0(unsigned int a1)
{
int *v1; // rbx
int result; // eax

v1 = &pr_default_state;
srand(a1);
*((_BYTE *)&pr_default_state + 1024) = 0;
do
*v1++ = rand();
while ( v1 != &pr_default_state + 255 );
result = rand();
*(&pr_default_state + 255) = result;
return result;
}

original_code:
void pr_srand(unsigned long int seed)
{
    srand(seed);
    unsigned char i;
    pr_default_state.index=0;
    for(i = 0; i != 255; i++)
        pr_default_state.wheel[i]=rand();
    pr_default_state.wheel[255]=rand();
}

canonical_original_code:
void pr_srand(unsigned long seed)
{
    srand(seed);
    unsigned char i;
    pr_default_state.index=0;
    for(i = 0; i != 255; i++)
        pr_default_state.wheel[i]=rand();
    pr_default_state.wheel[255]=rand();
}

variable_types:
i
unsigned char


decompiled_code:
__int64 pr_rand()
{
unsigned __int8 v0; // al
int v1; // edx

v0 = pr_default_state[256];
v1 = pr_default_state[(unsigned __int8)(v0 - 24)] + pr_default_state[(unsigned __int8)(v0 - 55)];
pr_default_state[v0] = v1;
LOBYTE(pr_default_state[256]) = v0 + 1;
return pr_default_state[(unsigned __int8)(v0 - 61)] ^ (unsigned int)v1;
}

canonical_decompiled_code:
__int64 func1()
{
unsigned __int8 v0; // al
int v1; // edx

v0 = pr_default_state[256];
v1 = pr_default_state[(unsigned __int8)(v0 - 24)] + pr_default_state[(unsigned __int8)(v0 - 55)];
pr_default_state[v0] = v1;
LOBYTE(pr_default_state[256]) = v0 + 1;
return pr_default_state[(unsigned __int8)(v0 - 61)] ^ (unsigned int)v1;
}

original_code:
unsigned int pr_rand()
{
    unsigned int r;
    pr_default_state.wheel[pr_default_state.index]=pr_default_state.wheel[(unsigned char)(pr_default_state.index-24)]+ pr_default_state.wheel[(unsigned char)(pr_default_state.index-55)];
    r=(pr_default_state.wheel[pr_default_state.index]^(pr_default_state.wheel[(unsigned char)(pr_default_state.index-61)]));
    pr_default_state.index++;
    return r;
}


decompiled_code:
// attributes: thunk
void pr_clear_st(void *ptr)
{
free(ptr);
}

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

original_code:
inline void pr_clear_st(pr_state *st)
{
    free(st);
}

canonical_original_code:
inline void pr_clear_st(struct _pr_state *st)
{
    free(st);
}

variable_types: struct _pr_state { unsigned int wheel[256]; unsigned char index; } *


decompiled_code:
int __fastcall pr_srand_st(__int64 a1, unsigned int a2)
{
__int64 v2; // rbx
int result; // eax

v2 = a1;
srand(a2);
*(_BYTE *)(a1 + 1024) = 0;
do
{
v2 += 4LL;
*(_DWORD *)(v2 - 4) = rand();
}
while ( v2 != a1 + 1020 );
result = rand();
*(_DWORD *)(a1 + 1020) = result;
return result;
}

canonical_decompiled_code:
int __fastcall func4(__int64 a1, unsigned int a2)
{
__int64 v2; // rbx
int result; // eax

v2 = a1;
srand(a2);
*(_BYTE *)(a1 + 1024) = 0;
do
{
v2 += 4LL;
*(_DWORD *)(v2 - 4) = rand();
}
while ( v2 != a1 + 1020 );
result = rand();
*(_DWORD *)(a1 + 1020) = result;
return result;
}

original_code:
void pr_srand_st(pr_state *st, unsigned long int seed)
{
    srand(seed);
    unsigned char i;
    st->index=0;
    for(i = 0; i != 255; i++)
        st->wheel[i]=rand();
    st->wheel[255]=rand();
}

canonical_original_code:
void pr_srand_st(struct _pr_state *st, unsigned long seed)
{
    srand(seed);
    unsigned char i;
    st->index=0;
    for(i = 0; i != 255; i++)
        st->wheel[i]=rand();
    st->wheel[255]=rand();
}

user_defined_types: struct _pr_state { unsigned int wheel[256]; unsigned char index; }


original_code:
unsigned int pr_rand_st(pr_state *st)
{
    unsigned int r;
    st->wheel[st->index]=st->wheel[(unsigned char)(st->index-24)]+ st->wheel[(unsigned char)(st->index-55)];
    r=(st->wheel[st->index]^(st->wheel[(unsigned char)(st->index-61)]));
    st->index++;
    return r;
}

canonical_original_code:
unsigned int pr_rand_st(struct _pr_state *st)
{
    unsigned int r;
    st->wheel[st->index]=st->wheel[(unsigned char)(st->index-24)]+ st->wheel[(unsigned char)(st->index-55)];
    r=(st->wheel[st->index]^(st->wheel[(unsigned char)(st->index-61)]));
    st->index++;
    return r;
}


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

v1 = &isaac_default_state;
srand(a1);
do
*v1++ = rand();
while ( v1 != &isaac_default_state + 256 );
*((_QWORD *)&isaac_default_state + 256) = 0LL;
result = 0LL;
*((_WORD *)&isaac_default_state + 1028) = 0;
return result;
}

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

v1 = &isaac_default_state;
srand(a1);
do
*v1++ = rand();
while ( v1 != &isaac_default_state + 256 );
*((_QWORD *)&isaac_default_state + 256) = 0LL;
result = 0LL;
*((_WORD *)&isaac_default_state + 1028) = 0;
return result;
}

original_code:
void isaac_srand(unsigned long int seed)
{
    unsigned int i;
    srand(seed);
    for(i = 0; i < 256; i++)
        isaac_default_state.wheel[i]=rand();
    isaac_default_state.a=0;
    isaac_default_state.b=0;
    isaac_default_state.c=0;
    isaac_default_state.index=0;
}

canonical_original_code:
void isaac_srand(unsigned long seed)
{
    unsigned int i;
    srand(seed);
    for(i = 0; i < 256; i++)
        isaac_default_state.wheel[i]=rand();
    isaac_default_state.a=0;
    isaac_default_state.b=0;
    isaac_default_state.c=0;
    isaac_default_state.index=0;
}


decompiled_code:
__int64 isaac_calc()
{
int v0; // esi
unsigned __int8 v1; // al
int v2; // ecx
__int64 result; // rax
int v4; // er8
unsigned int v5; // edx
unsigned int v6; // esi
unsigned int v7; // ecx
int v8; // edx
unsigned int v9; // ecx
int v10; // edi
unsigned int v11; // edx
int v12; // ecx
unsigned int v13; // edx
unsigned int v14; // edi
unsigned int v15; // ecx
int v16; // edx
unsigned int v17; // ecx
unsigned int v18; // edx
int v19; // ecx

v0 = isaac_default_state[512];
v1 = LOBYTE(isaac_default_state[514]) + 1;
v2 = isaac_default_state[513] + v1;
LOBYTE(isaac_default_state[514]) = v1;
result = 0LL;
v4 = v2;
do
{
v5 = isaac_default_state[result];
v6 = isaac_default_state[(unsigned __int8)(result + 0x80)] + ((v0 << 13) ^ v0);
v7 = v4 + v6 + isaac_default_state[(unsigned __int8)(v5 >> 2)];
isaac_default_state[result] = v7;
v8 = isaac_default_state[(unsigned __int8)(v7 >> 10)] + v5;
v9 = isaac_default_state[result + 1];
isaac_default_state[result + 256] = v8;
v10 = isaac_default_state[(unsigned __int8)(result - 127)] + (v6 ^ (v6 >> 6));
v11 = v8 + v10 + isaac_default_state[(unsigned __int8)(v9 >> 2)];
isaac_default_state[result + 1] = v11;
v12 = isaac_default_state[(unsigned __int8)(v11 >> 10)] + v9;
v13 = isaac_default_state[result + 2];
isaac_default_state[result + 257] = v12;
v14 = isaac_default_state[(unsigned __int8)(result - 126)] + (v10 ^ (4 * v10));
v15 = v12 + isaac_default_state[(unsigned __int8)(v13 >> 2)] + v14;
isaac_default_state[result + 2] = v15;
v16 = isaac_default_state[(unsigned __int8)(v15 >> 10)] + v13;
v17 = isaac_default_state[result + 3];
isaac_default_state[result + 258] = v16;
v0 = isaac_default_state[(unsigned __int8)(result - 125)] + (v14 ^ HIWORD(v14));
v18 = v16 + v0 + isaac_default_state[(unsigned __int8)(v17 >> 2)];
isaac_default_state[result + 3] = v18;
v19 = isaac_default_state[(unsigned __int8)(v18 >> 10)] + v17;
isaac_default_state[result + 259] = v19;
result += 4LL;
v4 = v19;
}
while ( result != 256 );
isaac_default_state[512] = v0;
isaac_default_state[513] = v19;
return result;
}

canonical_decompiled_code:
__int64 func1()
{
int v0; // esi
unsigned __int8 v1; // al
int v2; // ecx
__int64 result; // rax
int v4; // er8
unsigned int v5; // edx
unsigned int v6; // esi
unsigned int v7; // ecx
int v8; // edx
unsigned int v9; // ecx
int v10; // edi
unsigned int v11; // edx
int v12; // ecx
unsigned int v13; // edx
unsigned int v14; // edi
unsigned int v15; // ecx
int v16; // edx
unsigned int v17; // ecx
unsigned int v18; // edx
int v19; // ecx

v0 = isaac_default_state[512];
v1 = LOBYTE(isaac_default_state[514]) + 1;
v2 = isaac_default_state[513] + v1;
LOBYTE(isaac_default_state[514]) = v1;
result = 0LL;
v4 = v2;
do
{
v5 = isaac_default_state[result];
v6 = isaac_default_state[(unsigned __int8)(result + 0x80)] + ((v0 << 13) ^ v0);
v7 = v4 + v6 + isaac_default_state[(unsigned __int8)(v5 >> 2)];
isaac_default_state[result] = v7;
v8 = isaac_default_state[(unsigned __int8)(v7 >> 10)] + v5;
v9 = isaac_default_state[result + 1];
isaac_default_state[result + 256] = v8;
v10 = isaac_default_state[(unsigned __int8)(result - 127)] + (v6 ^ (v6 >> 6));
v11 = v8 + v10 + isaac_default_state[(unsigned __int8)(v9 >> 2)];
isaac_default_state[result + 1] = v11;
v12 = isaac_default_state[(unsigned __int8)(v11 >> 10)] + v9;
v13 = isaac_default_state[result + 2];
isaac_default_state[result + 257] = v12;
v14 = isaac_default_state[(unsigned __int8)(result - 126)] + (v10 ^ (4 * v10));
v15 = v12 + isaac_default_state[(unsigned __int8)(v13 >> 2)] + v14;
isaac_default_state[result + 2] = v15;
v16 = isaac_default_state[(unsigned __int8)(v15 >> 10)] + v13;
v17 = isaac_default_state[result + 3];
isaac_default_state[result + 258] = v16;
v0 = isaac_default_state[(unsigned __int8)(result - 125)] + (v14 ^ HIWORD(v14));
v18 = v16 + v0 + isaac_default_state[(unsigned __int8)(v17 >> 2)];
isaac_default_state[result + 3] = v18;
v19 = isaac_default_state[(unsigned __int8)(v18 >> 10)] + v17;
isaac_default_state[result + 259] = v19;
result += 4LL;
v4 = v19;
}
while ( result != 256 );
isaac_default_state[512] = v0;
isaac_default_state[513] = v19;
return result;
}

original_code:
void isaac_calc()
{
    unsigned int i,x,y;
    unsigned int a,b;
    isaac_default_state.c++;
    a=isaac_default_state.a;
    b=isaac_default_state.b+isaac_default_state.c;
    for(i = 0; i < 256; i++)
    {
        x = isaac_default_state.wheel[i];
        a = (a^(a<<13)) + isaac_default_state.wheel[(i+128)%256];
        isaac_default_state.wheel[i]= y = a+b+isaac_default_state.wheel[(x>>2)%256];
        isaac_default_state.wheel2[i]=b = x + isaac_default_state.wheel[(y>>10)%256];
        i++;
        x = isaac_default_state.wheel[i];
        a = (a^(a>>6)) + isaac_default_state.wheel[(i+128)%256];
        isaac_default_state.wheel[i]= y = a+b+isaac_default_state.wheel[(x>>2)%256];
        isaac_default_state.wheel2[i]=b = x + isaac_default_state.wheel[(y>>10)%256];
        i++;
        x=isaac_default_state.wheel[i];
        a= (a^(a<<2)) + isaac_default_state.wheel[(i+128)%256];
        isaac_default_state.wheel[i]= y = a+b+isaac_default_state.wheel[(x>>2)%256];
        isaac_default_state.wheel2[i]=b = x + isaac_default_state.wheel[(y>>10)%256];
        i++;
        x=isaac_default_state.wheel[i];
        a= (a^(a>>16)) + isaac_default_state.wheel[(i+128)%256];
        isaac_default_state.wheel[i]= y = a+b+isaac_default_state.wheel[(x>>2)%256];
        isaac_default_state.wheel2[i]=b = x + isaac_default_state.wheel[(y>>10)%256];
    }
    isaac_default_state.a=a;
    isaac_default_state.b=b;
}

canonical_original_code:
void isaac_calc()
{
    unsigned int i; unsigned int x; unsigned int y;
    unsigned int a; unsigned int b;
    isaac_default_state.c++;
    a=isaac_default_state.a;
    b=isaac_default_state.b+isaac_default_state.c;
    for(i = 0; i < 256; i++)
    {
        x = isaac_default_state.wheel[i];
        a = (a^(a<<13)) + isaac_default_state.wheel[(i+128)%256];
        isaac_default_state.wheel[i]= y = a+b+isaac_default_state.wheel[(x>>2)%256];
        isaac_default_state.wheel2[i]=b = x + isaac_default_state.wheel[(y>>10)%256];
        i++;
        x = isaac_default_state.wheel[i];
        a = (a^(a>>6)) + isaac_default_state.wheel[(i+128)%256];
        isaac_default_state.wheel[i]= y = a+b+isaac_default_state.wheel[(x>>2)%256];
        isaac_default_state.wheel2[i]=b = x + isaac_default_state.wheel[(y>>10)%256];
        i++;
        x=isaac_default_state.wheel[i];
        a= (a^(a<<2)) + isaac_default_state.wheel[(i+128)%256];
        isaac_default_state.wheel[i]= y = a+b+isaac_default_state.wheel[(x>>2)%256];
        isaac_default_state.wheel2[i]=b = x + isaac_default_state.wheel[(y>>10)%256];
        i++;
        x=isaac_default_state.wheel[i];
        a= (a^(a>>16)) + isaac_default_state.wheel[(i+128)%256];
        isaac_default_state.wheel[i]= y = a+b+isaac_default_state.wheel[(x>>2)%256];
        isaac_default_state.wheel2[i]=b = x + isaac_default_state.wheel[(y>>10)%256];
    }
    isaac_default_state.a=a;
    isaac_default_state.b=b;
}

variable_types:
x
unsigned int

variable_types:
a
unsigned int


decompiled_code:
// attributes: thunk
void isaac_clear_st(void *ptr)
{
free(ptr);
}

original_code:
inline void isaac_clear_st(isaac_state *st)
{
    free(st);
}

canonical_original_code:
inline void isaac_clear_st(struct _isaac_state *st)
{
    free(st);
}

variable_types: struct _isaac_state { unsigned int wheel[256]; unsigned int wheel2[256]; unsigned int a; unsigned char c; unsigned char index; } *


decompiled_code:
__int64 __fastcall isaac_srand_st(__int64 a1, unsigned int a2)
{
__int64 v2; // rbx
__int64 result; // rax

v2 = a1;
srand(a2);
do
{
v2 += 4LL;
*(_DWORD *)(v2 - 4) = rand();
}
while ( v2 != a1 + 1024 );
*(_QWORD *)(a1 + 2048) = 0LL;
result = 0LL;
*(_WORD *)(a1 + 2056) = 0;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, unsigned int a2)
{
__int64 v2; // rbx
__int64 result; // rax

v2 = a1;
srand(a2);
do
{
v2 += 4LL;
*(_DWORD *)(v2 - 4) = rand();
}
while ( v2 != a1 + 1024 );
*(_QWORD *)(a1 + 2048) = 0LL;
result = 0LL;
*(_WORD *)(a1 + 2056) = 0;
return result;
}

original_code:
void isaac_srand_st(isaac_state *st, unsigned long int seed)
{
    unsigned int i;
    srand(seed);
    for(i = 0; i < 256; i++)
        st->wheel[i]=rand();
    st->a=0;
    st->b=0;
    st->c=0;
    st->index=0;
}

canonical_original_code:
void isaac_srand_st(struct _isaac_state *st, unsigned long seed)
{
    unsigned int i;
    srand(seed);
    for(i = 0; i < 256; i++)
        st->wheel[i]=rand();
    st->a=0;
    st->b=0;
    st->c=0;
    st->index=0;
}

user_defined_types: struct _isaac_state { unsigned int wheel[256]; unsigned int wheel2[256]; unsigned int a; unsigned char c; unsigned char index; }


decompiled_code:
unsigned int *__fastcall isaac_calc_st(__int64 a1)
{
int v1; // er8
int v2; // esi
unsigned __int8 v3; // al
int v4; // ecx
unsigned int *result; // rax
int v6; // er10
unsigned int v7; // edx
unsigned int v8; // er9
unsigned int v9; // ecx
unsigned int v10; // edx
unsigned int v11; // ecx
int v12; // er9
unsigned int v13; // edx
unsigned int v14; // ecx
unsigned int v15; // edx
unsigned int v16; // er8
unsigned int v17; // ecx
unsigned int v18; // edx
unsigned int v19; // ecx
unsigned int v20; // edx
int v21; // ecx

v1 = *(_DWORD *)(a1 + 2048);
v2 = 128;
v3 = *(_BYTE *)(a1 + 2056) + 1;
v4 = *(_DWORD *)(a1 + 2052) + v3;
*(_BYTE *)(a1 + 2056) = v3;
result = (unsigned int *)a1;
v6 = v4;
do
{
v7 = *result;
result += 4;
v8 = ((v1 << 13) ^ v1) + *(_DWORD *)(a1 + 4LL * (unsigned __int8)v2);
v9 = v6 + v8 + *(_DWORD *)(a1 + 4LL * (unsigned __int8)(v7 >> 2));
*(result - 4) = v9;
v10 = *(_DWORD *)(a1 + 4LL * (unsigned __int8)(v9 >> 10)) + v7;
v11 = *(result - 3);
result[252] = v10;
v12 = (v8 ^ (v8 >> 6)) + *(_DWORD *)(a1 + 4LL * (unsigned __int8)(v2 + 1));
v13 = v10 + v12 + *(_DWORD *)(a1 + 4LL * (unsigned __int8)(v11 >> 2));
*(result - 3) = v13;
v14 = *(_DWORD *)(a1 + 4LL * (unsigned __int8)(v13 >> 10)) + v11;
v15 = *(result - 2);
result[253] = v14;
v16 = *(_DWORD *)(a1 + 4LL * (unsigned __int8)(v2 + 2)) + (v12 ^ (4 * v12));
v17 = v14 + v16 + *(_DWORD *)(a1 + 4LL * (unsigned __int8)(v15 >> 2));
*(result - 2) = v17;
v18 = *(_DWORD *)(a1 + 4LL * (unsigned __int8)(v17 >> 10)) + v15;
v19 = *(result - 1);
result[254] = v18;
v1 = *(_DWORD *)(a1 + 4LL * (unsigned __int8)(v2 + 3)) + (HIWORD(v16) ^ v16);
v20 = v18 + v1 + *(_DWORD *)(a1 + 4LL * (unsigned __int8)(v19 >> 2));
*(result - 1) = v20;
v21 = *(_DWORD *)(a1 + 4LL * (unsigned __int8)(v20 >> 10)) + v19;
result[255] = v21;
v2 += 4;
v6 = v21;
}
while ( v2 != 384 );
*(_DWORD *)(a1 + 2048) = v1;
*(_DWORD *)(a1 + 2052) = v21;
return result;
}

variable_types:
b
unsigned int


SocketOpen

repo: NpoSaut/cSocketCanLib

decompiled_code:
__int64 __fastcall SocketOpen(char *src, int a2, int a3)
{
int v3; // eax
unsigned int v4; // er12
char *v5; // rax
int v7; // [rsp+8h] [rbp-80h] BYREF
int v8[4]; // [rsp+Ch] [rbp-7Ch] BYREF
int optval; // [rsp+1Ch] [rbp-6Ch] BYREF
int v10; // [rsp+20h] [rbp-68h] BYREF
int v11; // [rsp+24h] [rbp-64h] BYREF
int v12; // [rsp+28h] [rbp-60h] BYREF
int v13; // [rsp+2Ch] [rbp-5Ch] BYREF
struct sockaddr addr; // [rsp+30h] [rbp-58h] BYREF
char dest[16]; // [rsp+40h] [rbp-48h] BYREF
int v16; // [rsp+50h] [rbp-38h]

v8[0] = a2;
v7 = a3;
v3 = socket(29, 3, 1);
if ( v3 < 0 )
return (unsigned int)(-100 * *_errno_location());
v4 = v3;
v5 = strcpy(dest, src);
ioctl(v4, 0x8933uLL, v5);
if ( v16 < 0 )
return (unsigned int)(-10000 * *_errno_location());
optval = 1;
setsockopt(v4, 101, 4, &optval, 4u);
v10 = 1;
if ( setsockopt(v4, 1, 37, &v10, 4u) < 0 )
{
v4 = -9;
perror("setsockopt SO_TIMESTAMPING");
}
else
{
v11 = 1;
if ( setsockopt(v4, 1, 29, &v11, 4u) < 0 )
{
v4 = -10;
perror("setsockopt SO_TIMESTAMP");
}
else
{
v12 = 511;
if ( setsockopt(v4, 101, 2, &v12, 4u) < 0 )
{
v4 = -11;
perror("setsockopt CAN_RAW_ERR_FILTER");
}
else
{
v8[0] *= 352;
v7 *= 352;
if ( setsockopt(v4, 1, 7, v8, 4u) < 0 )
{
v4 = -12;
perror("setsockopt SO_SNDBUF");
}
else if ( setsockopt(v4, 1, 8, &v7, 4u) < 0 )
{
v4 = -13;
perror("setsockopt SO_RCVBUF");
}
else
{
v13 = 1;
if ( setsockopt(v4, 1, 40, &v13, 4u) < 0 )
{
v4 = -14;
perror("setsockopt SO_RXQ_OVFL");
}
else
{
addr = 0LL;
addr.sa_family = 29;
*(_DWORD *)&addr.sa_data[2] = v16;
if ( bind(v4, &addr, 0x10u) )
return (unsigned int)(-1000000 * *_errno_location());
}
}
}
}
}
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *src, int a2, int a3)
{
int v3; // eax
unsigned int v4; // er12
char *v5; // rax
int v7; // [rsp+8h] [rbp-80h] BYREF
int v8[4]; // [rsp+Ch] [rbp-7Ch] BYREF
int optval; // [rsp+1Ch] [rbp-6Ch] BYREF
int v10; // [rsp+20h] [rbp-68h] BYREF
int v11; // [rsp+24h] [rbp-64h] BYREF
int v12; // [rsp+28h] [rbp-60h] BYREF
int v13; // [rsp+2Ch] [rbp-5Ch] BYREF
struct sockaddr addr; // [rsp+30h] [rbp-58h] BYREF
char dest[16]; // [rsp+40h] [rbp-48h] BYREF
int v16; // [rsp+50h] [rbp-38h]

v8[0] = a2;
v7 = a3;
v3 = socket(29, 3, 1);
if ( v3 < 0 )
return (unsigned int)(-100 * *_errno_location());
v4 = v3;
v5 = strcpy(dest, src);
ioctl(v4, 0x8933uLL, v5);
if ( v16 < 0 )
return (unsigned int)(-10000 * *_errno_location());
optval = 1;
setsockopt(v4, 101, 4, &optval, 4u);
v10 = 1;
if ( setsockopt(v4, 1, 37, &v10, 4u) < 0 )
{
v4 = -9;
perror("setsockopt SO_TIMESTAMPING");
}
else
{
v11 = 1;
if ( setsockopt(v4, 1, 29, &v11, 4u) < 0 )
{
v4 = -10;
perror("setsockopt SO_TIMESTAMP");
}
else
{
v12 = 511;
if ( setsockopt(v4, 101, 2, &v12, 4u) < 0 )
{
v4 = -11;
perror("setsockopt CAN_RAW_ERR_FILTER");
}
else
{
v8[0] *= 352;
v7 *= 352;
if ( setsockopt(v4, 1, 7, v8, 4u) < 0 )
{
v4 = -12;
perror("setsockopt SO_SNDBUF");
}
else if ( setsockopt(v4, 1, 8, &v7, 4u) < 0 )
{
v4 = -13;
perror("setsockopt SO_RCVBUF");
}
else
{
v13 = 1;
if ( setsockopt(v4, 1, 40, &v13, 4u) < 0 )
{
v4 = -14;
perror("setsockopt SO_RXQ_OVFL");
}
else
{
addr = 0LL;
addr.sa_family = 29;
*(_DWORD *)&addr.sa_data[2] = v16;
if ( bind(v4, &addr, 0x10u) )
return (unsigned int)(-1000000 * *_errno_location());
}
}
}
}
}
return v4;
}

original_code:
int SocketOpen (const char *InterfaceName, int TxBuffSize, int RxBuffSize)
{
    int number;
    number = socket(29, SOCK_RAW, 1);
    if(number < 0)
    {
 int errsv = (*__errno_location ());
 return -100*errsv;
    }
    struct ifreq ifr;
    strcpy(ifr.ifr_ifrn.ifrn_name, InterfaceName);
    ioctl(number, 0x8933, &ifr);
    if(ifr.ifr_ifru.ifru_ivalue < 0)
    {
 int errsv = (*__errno_location ());
 return -10000*errsv;
    }
    int recv_own_msgs = 1;
    setsockopt(number, (100 + 1), CAN_RAW_RECV_OWN_MSGS,
       &recv_own_msgs, sizeof(recv_own_msgs));
    const int timestamping_on = 1;
    if (setsockopt(number, 1, 37,
      &timestamping_on, sizeof(timestamping_on)) < 0) {
      perror("setsockopt SO_TIMESTAMPING");
      return -9;
    }
    const int timestamp_on = 1;
    if (setsockopt(number, 1, 29,
      &timestamp_on, sizeof(timestamp_on)) < 0) {
      perror("setsockopt SO_TIMESTAMP");
      return -10;
    }
    can_err_mask_t err_mask = ( 0x00000001U | 0x00000002U | 0x00000004U | 0x00000008U | 0x00000010U | 0x00000020U
    | 0x00000040U | 0x00000080U | 0x00000100U );
    if (setsockopt(number, (100 + 1), CAN_RAW_ERR_FILTER,
  &err_mask, sizeof(err_mask)) < 0) {
 perror("setsockopt CAN_RAW_ERR_FILTER");
 return -11;
    }
    TxBuffSize = 352*TxBuffSize;
    RxBuffSize = 352*RxBuffSize;
    if (setsockopt(number, 1, 7,
      &TxBuffSize, sizeof(TxBuffSize)) < 0) {
      perror("setsockopt SO_SNDBUF");
      return -12;
    }
    if (setsockopt(number, 1, 8,
      &RxBuffSize, sizeof(RxBuffSize)) < 0) {
      perror("setsockopt SO_RCVBUF");
      return -13;
    }
    const int dropmonitor_on = 1;
    if (setsockopt(number, 1, 40,
      &dropmonitor_on, sizeof(dropmonitor_on)) < 0) {
      perror("setsockopt SO_RXQ_OVFL");
      return -14;
    }
    struct sockaddr_can addr;
    memset(&addr, 0, sizeof(addr));
    addr.can_family = 29;
    addr.can_ifindex = ifr.ifr_ifru.ifru_ivalue;
    if ( bind(number, (const struct sockaddr*)&addr, sizeof(addr)) != 0 )
    {
 int errsv = (*__errno_location ());
 return -1000000*errsv;
    }
    return number;
}

canonical_original_code:
int SocketOpen(char *InterfaceName, int TxBuffSize, int RxBuffSize)
{
    int number;
    number = socket(29, SOCK_RAW, 1);
    if(number < 0)
    {
 int errsv = (*__errno_location ());
 return -100*errsv;
    }
    struct ifreq ifr;
    strcpy(ifr.ifr_ifrn.ifrn_name, InterfaceName);
    ioctl(number, 0x8933, &ifr);
    if(ifr.ifr_ifru.ifru_ivalue < 0)
    {
 int errsv = (*__errno_location ());
 return -10000*errsv;
    }
    int recv_own_msgs = 1;
    setsockopt(number, (100 + 1), CAN_RAW_RECV_OWN_MSGS,
       &recv_own_msgs, sizeof(recv_own_msgs));
    int timestamping_on = 1;
    if (setsockopt(number, 1, 37,
      &timestamping_on, sizeof(timestamping_on)) < 0) {
      perror("setsockopt SO_TIMESTAMPING");
      return -9;
    }
    int timestamp_on = 1;
    if (setsockopt(number, 1, 29,
      &timestamp_on, sizeof(timestamp_on)) < 0) {
      perror("setsockopt SO_TIMESTAMP");
      return -10;
    }
    unsigned int err_mask = ( 0x00000001U | 0x00000002U | 0x00000004U | 0x00000008U | 0x00000010U | 0x00000020U
    | 0x00000040U | 0x00000080U | 0x00000100U );
    if (setsockopt(number, (100 + 1), CAN_RAW_ERR_FILTER,
  &err_mask, sizeof(err_mask)) < 0) {
 perror("setsockopt CAN_RAW_ERR_FILTER");
 return -11;
    }
    TxBuffSize = 352*TxBuffSize;
    RxBuffSize = 352*RxBuffSize;
    if (setsockopt(number, 1, 7,
      &TxBuffSize, sizeof(TxBuffSize)) < 0) {
      perror("setsockopt SO_SNDBUF");
      return -12;
    }
    if (setsockopt(number, 1, 8,
      &RxBuffSize, sizeof(RxBuffSize)) < 0) {
      perror("setsockopt SO_RCVBUF");
      return -13;
    }
    int dropmonitor_on = 1;
    if (setsockopt(number, 1, 40,
      &dropmonitor_on, sizeof(dropmonitor_on)) < 0) {
      perror("setsockopt SO_RXQ_OVFL");
      return -14;
    }
    struct sockaddr_can addr;
    memset(&addr, 0, sizeof(addr));
    addr.can_family = 29;
    addr.can_ifindex = ifr.ifr_ifru.ifru_ivalue;
    if ( bind(number, (struct sockaddr *)&addr, sizeof(addr)) != 0 )
    {
 int errsv = (*__errno_location ());
 return -1000000*errsv;
    }
    return number;
}

variable_types:
InterfaceName
char *

variable_types: TxBuffSize int

variable_types: RxBuffSize int

variable_types: number int

variable_types: errsv int

variable_types: struct ifreq { union { char ifrn_name[16]; } ifr_ifrn; union { struct sockaddr { unsigned short sa_family; char sa_data[14]; } ifru_addr; struct sockaddr ifru_dstaddr; struct sockaddr ifru_broadaddr; struct sockaddr ifru_netmask; struct sockaddr ifru_hwaddr; short ifru_flags; int ifru_ivalue; int ifru_mtu; struct ifmap { unsigned long mem_start; unsigned long mem_end; unsigned short base_addr; unsigned char irq; unsigned char dma; unsigned char port; } ifru_map; char ifru_slave[16]; char ifru_newname[16]; char *ifru_data; } ifr_ifru; }

variable_types: struct sockaddr_can { unsigned short can_family; int can_ifindex; union { struct { unsigned int rx_id; } tp; } can_addr; }

user_defined_types: struct ifreq { union { char ifrn_name[16]; } ifr_ifrn; union { struct sockaddr ifru_addr; struct sockaddr ifru_dstaddr; struct sockaddr ifru_broadaddr; struct sockaddr ifru_netmask; struct sockaddr ifru_hwaddr; short ifru_flags; int ifru_ivalue; int ifru_mtu; struct ifmap ifru_map; char ifru_slave[16]; char ifru_newname[16]; char *ifru_data; } ifr_ifru; }