decompiled_code:
int __fastcall print_program(int *a1, int a2)
{
int v3; // eax
__int64 v4; // rdi
__int64 v5; // rdi

fputc(10, stderr);
print_spaces(a2);
v3 = *a1;
if ( *a1 == 258 )
{
fwrite("PROGRAM: \n", 1uLL, 0xAuLL, stderr);
}
else if ( v3 == 261 )
{
fwrite("FUNCTION: \n", 1uLL, 0xBuLL, stderr);
}
else if ( v3 == 262 )
{
fwrite("PROCEDURE:\n", 1uLL, 0xBuLL, stderr);
}
print_spaces(a2);
fwrite("\tNAME: ", 1uLL, 7uLL, stderr);
print_ident(*((_QWORD *)a1 + 1));
print_spaces(a2);
fwrite("\tARGS: ", 1uLL, 7uLL, stderr);
v4 = *((_QWORD *)a1 + 2);
if ( v4 )
print_ident(v4);
else
fwrite("NONE\n", 1uLL, 5uLL, stderr);
print_spaces(a2);
fwrite("\tDECS: ", 1uLL, 7uLL, stderr);
v5 = *((_QWORD *)a1 + 3);
if ( v5 )
print_ident(v5);
else
fwrite("NONE\n", 1uLL, 5uLL, stderr);
print_spaces(a2);
fwrite("\tSPGS: ", 1uLL, 7uLL, stderr);
if ( *((_QWORD *)a1 + 4) )
{
fputc(10, stderr);
print_program(*((_QWORD *)a1 + 4), (unsigned int)(a2 + 16));
}
else
{
fwrite("NONE\n", 1uLL, 5uLL, stderr);
}
print_spaces(a2);
fwrite("\tSTTS: ", 1uLL, 7uLL, stderr);
if ( *((_QWORD *)a1 + 5) )
{
fputc(10, stderr);
print_spaces(a2);
print_statement(*((__int64 **)a1 + 5), a2 + 16);
}
else
{
fwrite("NONE\n", 1uLL, 5uLL, stderr);
}
return fputc(10, stderr);
}

canonical_decompiled_code:
int __fastcall func8(int *a1, int a2)
{
int v3; // eax
__int64 v4; // rdi
__int64 v5; // rdi

fputc(10, stderr);
func7(a2);
v3 = *a1;
if ( *a1 == 258 )
{
fwrite("PROGRAM: \n", 1uLL, 0xAuLL, stderr);
}
else if ( v3 == 261 )
{
fwrite("FUNCTION: \n", 1uLL, 0xBuLL, stderr);
}
else if ( v3 == 262 )
{
fwrite("PROCEDURE:\n", 1uLL, 0xBuLL, stderr);
}
func7(a2);
fwrite("\tNAME: ", 1uLL, 7uLL, stderr);
func6(*((_QWORD *)a1 + 1));
func7(a2);
fwrite("\tARGS: ", 1uLL, 7uLL, stderr);
v4 = *((_QWORD *)a1 + 2);
if ( v4 )
func6(v4);
else
fwrite("NONE\n", 1uLL, 5uLL, stderr);
func7(a2);
fwrite("\tDECS: ", 1uLL, 7uLL, stderr);
v5 = *((_QWORD *)a1 + 3);
if ( v5 )
func6(v5);
else
fwrite("NONE\n", 1uLL, 5uLL, stderr);
func7(a2);
fwrite("\tSPGS: ", 1uLL, 7uLL, stderr);
if ( *((_QWORD *)a1 + 4) )
{
fputc(10, stderr);
func8(*((_QWORD *)a1 + 4), (unsigned int)(a2 + 16));
}
else
{
fwrite("NONE\n", 1uLL, 5uLL, stderr);
}
func7(a2);
fwrite("\tSTTS: ", 1uLL, 7uLL, stderr);
if ( *((_QWORD *)a1 + 5) )
{
fputc(10, stderr);
func7(a2);
func5(*((__int64 **)a1 + 5), a2 + 16);
}
else
{
fwrite("NONE\n", 1uLL, 5uLL, stderr);
}
return fputc(10, stderr);
}

original_code:
void print_program( program_n *ptr, int spaces ) {
 fprintf( stderr, "\n" );
 print_spaces( spaces );
 if( ptr->type == 258 ) fprintf( stderr, "PROGRAM: \n" );
 else if( ptr->type == 261 ) fprintf( stderr, "FUNCTION: \n" );
 else if( ptr->type == 262 ) fprintf( stderr, "PROCEDURE:\n" );
 print_spaces( spaces );
 fprintf( stderr, "\tNAME: " );
 print_ident( ptr->p_name );
 print_spaces( spaces );
 fprintf( stderr, "\tARGS: " );
 if( ptr->p_ilist == ((void *)0) )
  fprintf( stderr, "NONE\n" );
 else
  print_ident( ptr->p_ilist );
 print_spaces( spaces );
 fprintf( stderr, "\tDECS: " );
 if( ptr->p_declarations == ((void *)0) )
  fprintf( stderr, "NONE\n" );
 else
  print_ident( ptr->p_declarations );
 print_spaces( spaces );
 fprintf( stderr, "\tSPGS: " );
 if( ptr->p_sprograms == ((void *)0) )
  fprintf( stderr, "NONE\n" );
 else {
  fprintf( stderr, "\n" );
  print_program( ptr->p_sprograms, spaces+16 );
 }
 print_spaces( spaces );
 fprintf( stderr, "\tSTTS: " );
 if( ptr->p_statements == ((void *)0) )
  fprintf( stderr, "NONE\n" );
 else {
  fprintf( stderr, "\n" );
  print_spaces( spaces );
  print_statement( ptr->p_statements, spaces+16 );
 }
 fprintf( stderr, "\n" );
}

canonical_original_code:
void print_program(struct program_n *ptr, int spaces) {
 fprintf( stderr, "\n" );
 print_spaces( spaces );
 if( ptr->type == 258 ) fprintf( stderr, "PROGRAM: \n" );
 else if( ptr->type == 261 ) fprintf( stderr, "FUNCTION: \n" );
 else if( ptr->type == 262 ) fprintf( stderr, "PROCEDURE:\n" );
 print_spaces( spaces );
 fprintf( stderr, "\tNAME: " );
 print_ident( ptr->p_name );
 print_spaces( spaces );
 fprintf( stderr, "\tARGS: " );
 if( ptr->p_ilist == ((void *)0) )
  fprintf( stderr, "NONE\n" );
 else
  print_ident( ptr->p_ilist );
 print_spaces( spaces );
 fprintf( stderr, "\tDECS: " );
 if( ptr->p_declarations == ((void *)0) )
  fprintf( stderr, "NONE\n" );
 else
  print_ident( ptr->p_declarations );
 print_spaces( spaces );
 fprintf( stderr, "\tSPGS: " );
 if( ptr->p_sprograms == ((void *)0) )
  fprintf( stderr, "NONE\n" );
 else {
  fprintf( stderr, "\n" );
  print_program( ptr->p_sprograms, spaces+16 );
 }
 print_spaces( spaces );
 fprintf( stderr, "\tSTTS: " );
 if( ptr->p_statements == ((void *)0) )
  fprintf( stderr, "NONE\n" );
 else {
  fprintf( stderr, "\n" );
  print_spaces( spaces );
  print_statement( ptr->p_statements, spaces+16 );
 }
 fprintf( stderr, "\n" );
}


yyparse

original_code:
int
yyparse (void)
{
    int yystate;
    int yyerrstatus;
    yytype_int16 yyssa[200];
    yytype_int16 *yyss;
    yytype_int16 *yyssp;
    YYSTYPE yyvsa[200];
    YYSTYPE *yyvs;
    YYSTYPE *yyvsp;
    long unsigned int yystacksize;
  int yyn;
  int yyresult;
  int yytoken = 0;
  YYSTYPE yyval;
  int yylen = 0;
  yyssp = yyss = yyssa;
  yyvsp = yyvs = yyvsa;
  yystacksize = 200;
  ;
  yystate = 0;
  yyerrstatus = 0;
  yynerrs = 0;
  yychar = (-2);
  goto yysetstate;
yynewstate:
  yyssp++;
yysetstate:
  *yyssp = (yytype_int16) yystate;
  if (yyss + yystacksize - 1 <= yyssp)
    {
      long unsigned int yysize = (long unsigned int) (yyssp - yyss + 1);
      if (10000 <= yystacksize)
        goto yyexhaustedlab;
      yystacksize *= 2;
      if (10000 < yystacksize)
        yystacksize = 10000;
      {
        yytype_int16 *yyss1 = yyss;
        union yyalloc *yyptr =
          (union yyalloc *) malloc (((yystacksize) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) + (sizeof (union yyalloc) - 1)));
        if (! yyptr)
          goto yyexhaustedlab;
        do { long unsigned int yynewbytes; __builtin_memcpy (&yyptr->yyss_alloc, yyss, (yysize) * sizeof (*(yyss))); yyss = &yyptr->yyss_alloc; yynewbytes = yystacksize * sizeof (*yyss) + (sizeof (union yyalloc) - 1); yyptr += yynewbytes / sizeof (*yyptr); } while (0);
        do { long unsigned int yynewbytes; __builtin_memcpy (&yyptr->yyvs_alloc, yyvs, (yysize) * sizeof (*(yyvs))); yyvs = &yyptr->yyvs_alloc; yynewbytes = yystacksize * sizeof (*yyvs) + (sizeof (union yyalloc) - 1); yyptr += yynewbytes / sizeof (*yyptr); } while (0);
        if (yyss1 != yyssa)
          free (yyss1);
      }
      yyssp = yyss + yysize - 1;
      yyvsp = yyvs + yysize - 1;
      ;
      if (yyss + yystacksize - 1 <= yyssp)
        goto yyabortlab;
    }
  ;
  if (yystate == 6)
    goto yyacceptlab;
  goto yybackup;
yybackup:
  yyn = yypact[yystate];
  if ((!!((yyn) == (-10))))
    goto yydefault;
  if (yychar == (-2))
    {
      ;
      yychar = yylex ();
    }
  if (yychar <= 0)
    {
      yychar = yytoken = 0;
      ;
    }
  else
    {
      yytoken = ((unsigned) (yychar) <= 260 ? yytranslate[yychar] : 2);
      ;
    }
  yyn += yytoken;
  if (yyn < 0 || 35 < yyn || yycheck[yyn] != yytoken)
    goto yydefault;
  yyn = yytable[yyn];
  if (yyn <= 0)
    {
      if (0)
        goto yyerrlab;
      yyn = -yyn;
      goto yyreduce;
    }
  if (yyerrstatus)
    yyerrstatus--;
  ;
  yychar = (-2);
  yystate = yyn;

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yyvsp = yylval;

#pragma GCC diagnostic pop

  goto yynewstate;
yydefault:
  yyn = yydefact[yystate];
  if (yyn == 0)
    goto yyerrlab;
  goto yyreduce;
yyreduce:
  yylen = yyr2[yyn];
  yyval = yyvsp[1-yylen];
  ;
  switch (yyn)
    {
        case 2:
    { ; }
    break;
  case 3:
    { sptr = push_scope( sptr ); }
    break;
  case 4:
    {
     sptr = pop_scope( sptr );
    }
    break;
  case 5:
    { ; }
    break;
  case 6:
    {;}
    break;
  case 7:
    { (yyval.tval) = (yyvsp[-1].tval); }
    break;
  case 8:
    {;}
    break;
  case 9:
    {;}
    break;
  case 10:
    {
          eptr = find_entry( sptr, (yyvsp[-2].sval) );
     if( eptr == ((void *)0) )
           eptr = new_entry( sptr, (yyvsp[-2].sval) );
     tptr = new_node( id, ((void *)0), ((void *)0) );
     tptr->attr.id = eptr;
     tptr2 = new_node( op, tptr, (yyvsp[0].tval) );
     tptr2->attr.oval = '=';
     (yyval.tval) = tptr2;
     eval_stmt( (yyval.tval) );
     print_tree( (yyval.tval), 0 );
    }
    break;
  case 11:
    {
     tptr = new_node( op, (yyvsp[0].tval), ((void *)0) );
     tptr->attr.oval = 'p';
     (yyval.tval) = tptr;
     fprintf( stderr, "\tValue >> %d\n", eval_stmt( (yyval.tval) ) );
    }
    break;
  case 12:
    { sptr = push_scope( sptr ); }
    break;
  case 13:
    {
     sptr = pop_scope( sptr );
    }
    break;
  case 14:
    {
     print_tree( (yyvsp[0].tval), 0 );
    }
    break;
  case 15:
    {
          tptr = new_node( op, (yyvsp[-2].tval), (yyvsp[0].tval) );
     tptr->attr.oval = '+';
     (yyval.tval) = tptr;
    }
    break;
  case 16:
    {
     tptr = new_node( op, (yyvsp[-2].tval), (yyvsp[0].tval) );
     tptr->attr.oval = '-';
     (yyval.tval) = tptr;
    }
    break;
  case 17:
    {
     tptr = new_node( op, (yyvsp[-2].tval), (yyvsp[0].tval) );
     tptr->attr.oval = '*';
     (yyval.tval) = tptr;
    }
    break;
  case 18:
    { (yyval.tval) = (yyvsp[-1].tval); }
    break;
  case 19:
    {
     eptr = find_entry( sptr, (yyvsp[0].sval) );
     ((void) sizeof ((eptr != ((void *)0)) ? 1 : 0), __extension__ ({ if (eptr != ((void *)0)) ; else __assert_fail ("eptr != NULL", "ldragon.y", 118, __extension__ __PRETTY_FUNCTION__); }));
     tptr = new_node( id, ((void *)0), ((void *)0) );
     tptr->attr.id = eptr;
     (yyval.tval) = tptr;
    }
    break;
  case 20:
    {
     tptr = new_node( num, ((void *)0), ((void *)0) );
     tptr->attr.ival = (yyvsp[0].ival);
     (yyval.tval) = tptr;
    }
    break;
      default: break;
    }
  ;
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  ;
  *++yyvsp = yyval;
  {
    const int yylhs = yyr1[yyn] - 15;
    const int yyi = yypgoto[yylhs] + *yyssp;
    yystate = (0 <= yyi && yyi <= 35 && yycheck[yyi] == *yyssp
               ? yytable[yyi]
               : yydefgoto[yylhs]);
  }
  goto yynewstate;
yyerrlab:
  yytoken = yychar == (-2) ? (-2) : ((unsigned) (yychar) <= 260 ? yytranslate[yychar] : 2);
  if (!yyerrstatus)
    {
      ++yynerrs;
      yyerror ("syntax error");
    }
  if (yyerrstatus == 3)
    {
      if (yychar <= 0)
        {
          if (yychar == 0)
            goto yyabortlab;
        }
      else
        {
          yydestruct ("Error: discarding",
                      yytoken, &yylval);
          yychar = (-2);
        }
    }
  goto yyerrlab1;
yyerrorlab:
  if (0)
    goto yyerrorlab;
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  ;
  yystate = *yyssp;
  goto yyerrlab1;
yyerrlab1:
  yyerrstatus = 3;
  for (;;)
    {
      yyn = yypact[yystate];
      if (!(!!((yyn) == (-10))))
        {
          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;
      ;
    }

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yyvsp = yylval;

#pragma GCC diagnostic pop

  ;
  yystate = yyn;
  goto yynewstate;
yyacceptlab:
  yyresult = 0;
  goto yyreturn;
yyabortlab:
  yyresult = 1;
  goto yyreturn;
yyexhaustedlab:
  yyerror ("memory exhausted");
  yyresult = 2;
yyreturn:
  if (yychar != (-2))
    {
      yytoken = ((unsigned) (yychar) <= 260 ? yytranslate[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;
    union YYSTYPE yyvsa[200];
    union YYSTYPE *yyvs;
    union YYSTYPE *yyvsp;
    unsigned long yystacksize;
  int yyn;
  int yyresult;
  int yytoken = 0;
  union YYSTYPE yyval;
  int yylen = 0;
  yyssp = yyss = yyssa;
  yyvsp = yyvs = yyvsa;
  yystacksize = 200;
  ;
  yystate = 0;
  yyerrstatus = 0;
  yynerrs = 0;
  yychar = (-2);
  goto yysetstate;
yynewstate:
  yyssp++;
yysetstate:
  *yyssp = (short) yystate;
  if (yyss + yystacksize - 1 <= yyssp)
    {
      unsigned long yysize = (long unsigned int) (yyssp - yyss + 1);
      if (10000 <= yystacksize)
        goto yyexhaustedlab;
      yystacksize *= 2;
      if (10000 < yystacksize)
        yystacksize = 10000;
      {
        short *yyss1 = yyss;
        union yyalloc *yyptr = (union yyalloc *) malloc (((yystacksize) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) + (sizeof (union yyalloc) - 1)));
        if (! yyptr)
          goto yyexhaustedlab;
        do { unsigned long yynewbytes; __builtin_memcpy (&yyptr->yyss_alloc, yyss, (yysize) * sizeof (*(yyss))); yyss = &yyptr->yyss_alloc; yynewbytes = yystacksize * sizeof (*yyss) + (sizeof (union yyalloc) - 1); yyptr += yynewbytes / sizeof (*yyptr); } while (0);
        do { unsigned long yynewbytes; __builtin_memcpy (&yyptr->yyvs_alloc, yyvs, (yysize) * sizeof (*(yyvs))); yyvs = &yyptr->yyvs_alloc; yynewbytes = yystacksize * sizeof (*yyvs) + (sizeof (union yyalloc) - 1); yyptr += yynewbytes / sizeof (*yyptr); } while (0);
        if (yyss1 != yyssa)
          free (yyss1);
      }
      yyssp = yyss + yysize - 1;
      yyvsp = yyvs + yysize - 1;
      ;
      if (yyss + yystacksize - 1 <= yyssp)
        goto yyabortlab;
    }
  ;
  if (yystate == 6)
    goto yyacceptlab;
  goto yybackup;
yybackup:
  yyn = yypact[yystate];
  if ((!!((yyn) == (-10))))
    goto yydefault;
  if (yychar == (-2))
    {
      ;
      yychar = yylex ();
    }
  if (yychar <= 0)
    {
      yychar = yytoken = 0;
      ;
    }
  else
    {
      yytoken = ((unsigned int) (yychar) <= 260 ? yytranslate[yychar] : 2);
      ;
    }
  yyn += yytoken;
  if (yyn < 0 || 35 < yyn || yycheck[yyn] != yytoken)
    goto yydefault;
  yyn = yytable[yyn];
  if (yyn <= 0)
    {
      if (0)
        goto yyerrlab;
      yyn = -yyn;
      goto yyreduce;
    }
  if (yyerrstatus)
    yyerrstatus--;
  ;
  yychar = (-2);
  yystate = yyn;

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yyvsp = yylval;

#pragma GCC diagnostic pop

  goto yynewstate;
yydefault:
  yyn = yydefact[yystate];
  if (yyn == 0)
    goto yyerrlab;
  goto yyreduce;
yyreduce:
  yylen = yyr2[yyn];
  yyval = yyvsp[1-yylen];
  ;
  switch (yyn)
    {
        case 2:
    { ; }
    break;
  case 3:
    { sptr = push_scope( sptr ); }
    break;
  case 4:
    {
     sptr = pop_scope( sptr );
    }
    break;
  case 5:
    { ; }
    break;
  case 6:
    {;}
    break;
  case 7:
    { (yyval.tval) = (yyvsp[-1].tval); }
    break;
  case 8:
    {;}
    break;
  case 9:
    {;}
    break;
  case 10:
    {
          eptr = find_entry( sptr, (yyvsp[-2].sval) );
     if( eptr == ((void *)0) )
           eptr = new_entry( sptr, (yyvsp[-2].sval) );
     tptr = new_node( id, ((void *)0), ((void *)0) );
     tptr->attr.id = eptr;
     tptr2 = new_node( op, tptr, (yyvsp[0].tval) );
     tptr2->attr.oval = '=';
     (yyval.tval) = tptr2;
     eval_stmt( (yyval.tval) );
     print_tree( (yyval.tval), 0 );
    }
    break;
  case 11:
    {
     tptr = new_node( op, (yyvsp[0].tval), ((void *)0) );
     tptr->attr.oval = 'p';
     (yyval.tval) = tptr;
     fprintf( stderr, "\tValue >> %d\n", eval_stmt( (yyval.tval) ) );
    }
    break;
  case 12:
    { sptr = push_scope( sptr ); }
    break;
  case 13:
    {
     sptr = pop_scope( sptr );
    }
    break;
  case 14:
    {
     print_tree( (yyvsp[0].tval), 0 );
    }
    break;
  case 15:
    {
          tptr = new_node( op, (yyvsp[-2].tval), (yyvsp[0].tval) );
     tptr->attr.oval = '+';
     (yyval.tval) = tptr;
    }
    break;
  case 16:
    {
     tptr = new_node( op, (yyvsp[-2].tval), (yyvsp[0].tval) );
     tptr->attr.oval = '-';
     (yyval.tval) = tptr;
    }
    break;
  case 17:
    {
     tptr = new_node( op, (yyvsp[-2].tval), (yyvsp[0].tval) );
     tptr->attr.oval = '*';
     (yyval.tval) = tptr;
    }
    break;
  case 18:
    { (yyval.tval) = (yyvsp[-1].tval); }
    break;
  case 19:
    {
     eptr = find_entry( sptr, (yyvsp[0].sval) );
     ((void) sizeof ((eptr != ((void *)0)) ? 1 : 0), __extension__ ({ if (eptr != ((void *)0)) ; else __assert_fail ("eptr != NULL", "ldragon.y", 118, __extension__ __PRETTY_FUNCTION__); }));
     tptr = new_node( id, ((void *)0), ((void *)0) );
     tptr->attr.id = eptr;
     (yyval.tval) = tptr;
    }
    break;
  case 20:
    {
     tptr = new_node( num, ((void *)0), ((void *)0) );
     tptr->attr.ival = (yyvsp[0].ival);
     (yyval.tval) = tptr;
    }
    break;
      default: break;
    }
  ;
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  ;
  *++yyvsp = yyval;
  {
    int yylhs = yyr1[yyn] - 15;
    int yyi = yypgoto[yylhs] + *yyssp;
    yystate = (0 <= yyi && yyi <= 35 && yycheck[yyi] == *yyssp
               ? yytable[yyi]
               : yydefgoto[yylhs]);
  }
  goto yynewstate;
yyerrlab:
  yytoken = yychar == (-2) ? (-2) : ((unsigned int) (yychar) <= 260 ? yytranslate[yychar] : 2);
  if (!yyerrstatus)
    {
      ++yynerrs;
      yyerror ("syntax error");
    }
  if (yyerrstatus == 3)
    {
      if (yychar <= 0)
        {
          if (yychar == 0)
            goto yyabortlab;
        }
      else
        {
          yydestruct ("Error: discarding",
                      yytoken, &yylval);
          yychar = (-2);
        }
    }
  goto yyerrlab1;
yyerrorlab:
  if (0)
    goto yyerrorlab;
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  ;
  yystate = *yyssp;
  goto yyerrlab1;
yyerrlab1:
  yyerrstatus = 3;
  for (;;)
    {
      yyn = yypact[yystate];
      if (!(!!((yyn) == (-10))))
        {
          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;
      ;
    }

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yyvsp = yylval;

#pragma GCC diagnostic pop

  ;
  yystate = yyn;
  goto yynewstate;
yyacceptlab:
  yyresult = 0;
  goto yyreturn;
yyabortlab:
  yyresult = 1;
  goto yyreturn;
yyexhaustedlab:
  yyerror ("memory exhausted");
  yyresult = 2;
yyreturn:
  if (yychar != (-2))
    {
      yytoken = ((unsigned int) (yychar) <= 260 ? yytranslate[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: union YYSTYPE { int ival; struct t_node { enum node_type { num=0, op=1, id=2 } type; union { int ival; int oval; struct entry { char *name; int value; struct entry *next; } *id; } attr; int gcl; struct t_node *left; } *tval; char *sval; } [200]

variable_types: union YYSTYPE { int ival; struct t_node { enum node_type { num=0, op=1, id=2 } type; union { int ival; int oval; struct entry { char *name; int value; struct entry *next; } *id; } attr; int gcl; struct t_node *left; } *tval; char *sval; } *

variable_types:
yystacksize
unsigned long

variable_types: yyn int

variable_types: yyresult int

variable_types: yytoken int

variable_types: yylen int

variable_types:
yysize
unsigned long

variable_types: union yyalloc { short yyss_alloc; union YYSTYPE { int ival; struct t_node { enum node_type { num=0, op=1, id=2 } type; union { int ival; int oval; struct entry { char *name; int value; struct entry *next; } *id; } attr; int gcl; struct t_node *left; } *tval; char *sval; } yyvs_alloc; } *

variable_types:
yynewbytes
unsigned long

variable_types: yylhs int

variable_types: yyi int

return_type: int

user_defined_types: union YYSTYPE { int ival; struct t_node *tval; char *sval; }

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

user_defined_types: struct t_node { enum node_type type; union { int ival; int oval; struct entry *id; } attr; int gcl; struct t_node *left; }


yyerror

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

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

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

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

variable_types:
s
char *

return_type: void


main

canonical_name: main

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

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

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

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


decompiled_code:
void __fastcall destroy_rnode(void *a1)
{
if ( a1 )
free(a1);
}

canonical_decompiled_code:
void __fastcall func0(void *a1)
{
if ( a1 )
free(a1);
}

original_code:
void destroy_rnode( r_node *to_delete ) {
 if( to_delete == ((void *)0) )
  return;
 free( to_delete );
}

canonical_original_code:
void destroy_rnode(struct r_node *to_delete) {
 if( to_delete == ((void *)0) )
  return;
 free( to_delete );
}

variable_types: struct r_node { int number; struct r_node *next; } *


decompiled_code:
_QWORD *init_rstack()
{
return new_rnode(0);
}

canonical_decompiled_code:
_QWORD *func1()
{
return new_rnode(0);
}

original_code:
r_node *init_rstack( ) {
 r_node *ptr;
 ptr = new_rnode( 0 );
 return ptr;
}

canonical_original_code:
struct r_node *init_rstack() {
 struct r_node *ptr;
 ptr = new_rnode( 0 );
 return ptr;
}

return_type: struct r_node { int number; struct r_node *next; } *


decompiled_code:
void __fastcall destroy_rstack(_QWORD *a1)
{
if ( a1 )
{
destroy_rstack(a1[1]);
destroy_rnode(a1);
}
}

canonical_decompiled_code:
void __fastcall func2(_QWORD *a1)
{
if ( a1 )
{
func2(a1[1]);
func0(a1);
}
}

original_code:
void destroy_rstack( r_node *rstack ) {
 if( rstack == ((void *)0) )
  return;
 destroy_rstack( rstack->next );
 destroy_rnode( rstack );
}

canonical_original_code:
void destroy_rstack(struct r_node *rstack) {
 if( rstack == ((void *)0) )
  return;
 destroy_rstack( rstack->next );
 destroy_rnode( rstack );
}

user_defined_types: struct r_node { int number; struct r_node *next; }


push

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

if ( !a1 || (result = a2) == 0 )
_assert_fail("rstack != NULL && new_top != NULL", "gencode.c", 0x2Au, "push");
*(_QWORD *)(a2 + 8) = a1;
return result;
}

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

if ( !a1 || (result = a2) == 0 )
_assert_fail("rstack != NULL && new_top != NULL", "gencode.c", 0x2Au, "push");
*(_QWORD *)(a2 + 8) = a1;
return result;
}

original_code:
r_node *push( r_node *rstack, r_node *new_top ) {
 ((void) sizeof ((rstack != ((void *)0) && new_top != ((void *)0)) ? 1 : 0), __extension__ ({ if (rstack != ((void *)0) && new_top != ((void *)0)) ; else __assert_fail ("rstack != NULL && new_top != NULL", "gencode.c", 42, __extension__ __PRETTY_FUNCTION__); }));
 new_top->next = rstack;
 return new_top;
}

canonical_original_code:
struct r_node *push(struct r_node *rstack, struct r_node *new_top) {
 ((void) sizeof ((rstack != ((void *)0) && new_top != ((void *)0)) ? 1 : 0), __extension__ ({ if (rstack != ((void *)0) && new_top != ((void *)0)) ; else __assert_fail ("rstack != NULL && new_top != NULL", "gencode.c", 42, __extension__ __PRETTY_FUNCTION__); }));
 new_top->next = rstack;
 return new_top;
}

variable_types:
rstack
struct r_node *


decompiled_code:
size_t __fastcall print_rstack(unsigned int *a1)
{
unsigned int *i; // rbx

for ( i = a1; i; i = (unsigned int *)*((_QWORD *)i + 1) )
fprintf(stderr, "[ R%d ]\n", *i);
return fwrite("---------------------\n", 1uLL, 0x16uLL, stderr);
}

canonical_decompiled_code:
size_t __fastcall func4(unsigned int *a1)
{
unsigned int *i; // rbx

for ( i = a1; i; i = (unsigned int *)*((_QWORD *)i + 1) )
fprintf(stderr, "[ R%d ]\n", *i);
return fwrite("---------------------\n", 1uLL, 0x16uLL, stderr);
}

original_code:
void print_rstack( r_node *rstack ) {
 if( rstack == ((void *)0) )
  fprintf( stderr, "---------------------\n" );
 else {
  fprintf( stderr, "[ R%d ]\n", rstack->number );
  print_rstack( rstack->next );
 }
}

canonical_original_code:
void print_rstack(struct r_node *rstack) {
 if( rstack == ((void *)0) )
  fprintf( stderr, "---------------------\n" );
 else {
  fprintf( stderr, "[ R%d ]\n", rstack->number );
  print_rstack( rstack->next );
 }
}


moao

decompiled_code:
__int64 __fastcall moao(__int64 a1, __int64 a2)
{
__int64 result; // rax
int v3; // edx

result = *(unsigned int *)(a1 + 16);
v3 = *(_DWORD *)(a2 + 16);
if ( (_DWORD)result == v3 )
return (unsigned int)(result + 1);
if ( (int)result < v3 )
result = (unsigned int)v3;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2)
{
__int64 result; // rax
int v3; // edx

result = *(unsigned int *)(a1 + 16);
v3 = *(_DWORD *)(a2 + 16);
if ( (_DWORD)result == v3 )
return (unsigned int)(result + 1);
if ( (int)result < v3 )
result = (unsigned int)v3;
return result;
}

original_code:
int moao( t_node *left, t_node *right ) {
 if( left->gcl == right->gcl )
  return left->gcl + 1;
 else if( left->gcl > right->gcl )
  return left->gcl;
 else
  return right->gcl;
}

canonical_original_code:
int moao(struct t_node *left, struct t_node *right) {
 if( left->gcl == right->gcl )
  return left->gcl + 1;
 else if( left->gcl > right->gcl )
  return left->gcl;
 else
  return right->gcl;
}

variable_types: struct t_node { enum node_type { num=0, op=1, id=2 } type; union { int ival; int oval; struct entry { char *name; int value; struct entry *next; } *id; } attr; int gcl; struct t_node *left; } *

variable_types:
right
struct t_node *


label

original_code:
void label( t_node *root, int type ) {
 if( type == 0 ) {
  if( root->left == ((void *)0) && root->right == ((void *)0) )
   root->gcl = 0;
  else {
   label( root->left, 1 );
   label( root->right, 2 );
   root->gcl = moao( root->left, root->right );
  }
 }
 else if( type == 1 ) {
  if( root->left == ((void *)0) && root->right == ((void *)0) )
   root->gcl = 1;
  else {
   label( root->left, 1 );
   label( root->right, 2 );
   root->gcl = moao( root->left, root->right );
  }
 }
 else {
  if( root->left == ((void *)0) && root->right == ((void *)0) )
   root->gcl = 0;
  else {
   label( root->left, 1 );
   label( root->right, 2 );
   root->gcl = moao( root->left, root->right );
  }
 }
}

canonical_original_code:
void label(struct t_node *root, int type) {
 if( type == 0 ) {
  if( root->left == ((void *)0) && root->right == ((void *)0) )
   root->gcl = 0;
  else {
   label( root->left, 1 );
   label( root->right, 2 );
   root->gcl = moao( root->left, root->right );
  }
 }
 else if( type == 1 ) {
  if( root->left == ((void *)0) && root->right == ((void *)0) )
   root->gcl = 1;
  else {
   label( root->left, 1 );
   label( root->right, 2 );
   root->gcl = moao( root->left, root->right );
  }
 }
 else {
  if( root->left == ((void *)0) && root->right == ((void *)0) )
   root->gcl = 0;
  else {
   label( root->left, 1 );
   label( root->right, 2 );
   root->gcl = moao( root->left, root->right );
  }
 }
}

variable_types: type int

user_defined_types: struct entry { char *name; int value; struct entry *next; }


gencode

decompiled_code:
int __fastcall gencode(__int64 a1, unsigned int *a2, int a3)
{
__int64 v4; // rdi
__int64 v5; // rax
int v6; // eax
int v7; // edx
int v8; // eax
unsigned int *v9; // rbp
int v10; // eax
_QWORD *v11; // rax
__int64 v12; // rdi
unsigned int *v13; // rbp
int v14; // eax
__int64 v15; // rdx
__int64 v16; // rdx
__int64 v17; // rdx
__int64 v19[4]; // [rsp+8h] [rbp-20h] BYREF

v4 = *(_QWORD *)(a1 + 24);
v5 = *(_QWORD *)(a1 + 32);
v19[0] = (__int64)a2;
if ( v4 )
{
if ( v5 && *(_DWORD *)a1 == 1 )
{
v6 = *(_DWORD *)(v5 + 16);
if ( v6 )
{
v7 = *(_DWORD *)(v4 + 16);
if ( v7 > 0 && v6 > v7 )
{
v11 = swap(v19[0]);
v12 = *(_QWORD *)(a1 + 32);
v19[0] = (__int64)v11;
gencode(v12, v11, 1LL);
v13 = pop((__int64)v19);
gencode(*(_QWORD *)(a1 + 24), v19[0], 0LL);
v14 = *(_DWORD *)(a1 + 8);
switch ( v14 )
{
case '+':
fprintf(stderr, "ADD R%d, R%d\n", *v13, *(unsigned int *)v19[0]);
break;
case '-':
fprintf(stderr, "SUB R%d, R%d\n", *v13, *(unsigned int *)v19[0]);
break;
case '*':
fprintf(stderr, "MUL R%d, R%d\n", *v13, *(unsigned int *)v19[0]);
break;
default:
fwrite("Unrecognized op value in gencode : case 1\n", 1uLL, 0x2AuLL, stderr);
break;
}
v19[0] = push(v19[0], (__int64)v13);
LODWORD(v5) = (unsigned int)swap(v19[0]);
}
else if ( v6 > 0 && v6 <= v7 )
{
gencode(v4, v19[0], 0LL);
v9 = pop((__int64)v19);
gencode(*(_QWORD *)(a1 + 32), v19[0], 1LL);
v10 = *(_DWORD *)(a1 + 8);
switch ( v10 )
{
case '+':
fprintf(stderr, "ADD R%d, R%d\n", *(unsigned int *)v19[0], *v9);
break;
case '-':
fprintf(stderr, "SUB R%d, R%d\n", *(unsigned int *)v19[0], *v9);
break;
case '*':
fprintf(stderr, "MUL R%d, R%d\n", *(unsigned int *)v19[0], *v9);
break;
default:
fwrite("Unrecognized op value in gencode : case 1\n", 1uLL, 0x2AuLL, stderr);
break;
}
LODWORD(v5) = push(v19[0], (__int64)v9);
}
else
{
LODWORD(v5) = fwrite("shouldn't get to gencode : case 4\n", 1uLL, 0x22uLL, stderr);
}
}
else
{
gencode(v4, v19[0], 0LL);
v8 = *(_DWORD *)(a1 + 8);
switch ( v8 )
{
case '+':
v17 = *(_QWORD *)(a1 + 32);
LODWORD(v5) = *(_DWORD *)v17;
if ( *(_DWORD *)v17 )
{
if ( (_DWORD)v5 == 2 )
LODWORD(v5) = fprintf(stderr, "ADD %s, R%d\n", **(const char ***)(v17 + 8), *(unsigned int *)v19[0]);
}
else
{
LODWORD(v5) = fprintf(stderr, "ADD %d, R%d\n", *(unsigned int *)(v17 + 8), *(unsigned int *)v19[0]);
}
break;
case '-':
v16 = *(_QWORD *)(a1 + 32);
LODWORD(v5) = *(_DWORD *)v16;
if ( *(_DWORD *)v16 )
{
if ( (_DWORD)v5 == 2 )
LODWORD(v5) = fprintf(stderr, "SUB %s, R%d\n", **(const char ***)(v16 + 8), *(unsigned int *)v19[0]);
}
else
{
LODWORD(v5) = fprintf(stderr, "SUB %d, R%d\n", *(unsigned int *)(v16 + 8), *(unsigned int *)v19[0]);
}
break;
case '*':
v15 = *(_QWORD *)(a1 + 32);
LODWORD(v5) = *(_DWORD *)v15;
if ( *(_DWORD *)v15 )
{
if ( (_DWORD)v5 == 2 )
LODWORD(v5) = fprintf(stderr, "MUL %s, R%d\n", **(const char ***)(v15 + 8), *(unsigned int *)v19[0]);
}
else
{
LODWORD(v5) = fprintf(stderr, "MUL %d, R%d\n", *(unsigned int *)(v15 + 8), *(unsigned int *)v19[0]);
}
break;
default:
LODWORD(v5) = fwrite("Unrecognized op value in gencode : case 1\n", 1uLL, 0x2AuLL, stderr);
break;
}
}
}
}
else if ( !v5 && !a3 )
{
LODWORD(v5) = *(_DWORD *)a1;
if ( *(_DWORD *)a1 )
{
if ( (_DWORD)v5 == 2 )
LODWORD(v5) = fprintf(stderr, "MOV %s, R%d\n", **(const char ***)(a1 + 8), *(unsigned int *)v19[0]);
}
else
{
LODWORD(v5) = fprintf(stderr, "MOV %d, R%d\n", *(unsigned int *)(a1 + 8), *a2);
}
}
return v5;
}

canonical_decompiled_code:
int __fastcall func7(__int64 a1, unsigned int *a2, int a3)
{
__int64 v4; // rdi
__int64 v5; // rax
int v6; // eax
int v7; // edx
int v8; // eax
unsigned int *v9; // rbp
int v10; // eax
_QWORD *v11; // rax
__int64 v12; // rdi
unsigned int *v13; // rbp
int v14; // eax
__int64 v15; // rdx
__int64 v16; // rdx
__int64 v17; // rdx
__int64 v19[4]; // [rsp+8h] [rbp-20h] BYREF

v4 = *(_QWORD *)(a1 + 24);
v5 = *(_QWORD *)(a1 + 32);
v19[0] = (__int64)a2;
if ( v4 )
{
if ( v5 && *(_DWORD *)a1 == 1 )
{
v6 = *(_DWORD *)(v5 + 16);
if ( v6 )
{
v7 = *(_DWORD *)(v4 + 16);
if ( v7 > 0 && v6 > v7 )
{
v11 = swap(v19[0]);
v12 = *(_QWORD *)(a1 + 32);
v19[0] = (__int64)v11;
func7(v12, v11, 1LL);
v13 = pop((__int64)v19);
func7(*(_QWORD *)(a1 + 24), v19[0], 0LL);
v14 = *(_DWORD *)(a1 + 8);
switch ( v14 )
{
case '+':
fprintf(stderr, "ADD R%d, R%d\n", *v13, *(unsigned int *)v19[0]);
break;
case '-':
fprintf(stderr, "SUB R%d, R%d\n", *v13, *(unsigned int *)v19[0]);
break;
case '*':
fprintf(stderr, "MUL R%d, R%d\n", *v13, *(unsigned int *)v19[0]);
break;
default:
fwrite("Unrecognized op value in gencode : case 1\n", 1uLL, 0x2AuLL, stderr);
break;
}
v19[0] = func3(v19[0], (__int64)v13);
LODWORD(v5) = (unsigned int)swap(v19[0]);
}
else if ( v6 > 0 && v6 <= v7 )
{
func7(v4, v19[0], 0LL);
v9 = pop((__int64)v19);
func7(*(_QWORD *)(a1 + 32), v19[0], 1LL);
v10 = *(_DWORD *)(a1 + 8);
switch ( v10 )
{
case '+':
fprintf(stderr, "ADD R%d, R%d\n", *(unsigned int *)v19[0], *v9);
break;
case '-':
fprintf(stderr, "SUB R%d, R%d\n", *(unsigned int *)v19[0], *v9);
break;
case '*':
fprintf(stderr, "MUL R%d, R%d\n", *(unsigned int *)v19[0], *v9);
break;
default:
fwrite("Unrecognized op value in gencode : case 1\n", 1uLL, 0x2AuLL, stderr);
break;
}
LODWORD(v5) = func3(v19[0], (__int64)v9);
}
else
{
LODWORD(v5) = fwrite("shouldn't get to gencode : case 4\n", 1uLL, 0x22uLL, stderr);
}
}
else
{
func7(v4, v19[0], 0LL);
v8 = *(_DWORD *)(a1 + 8);
switch ( v8 )
{
case '+':
v17 = *(_QWORD *)(a1 + 32);
LODWORD(v5) = *(_DWORD *)v17;
if ( *(_DWORD *)v17 )
{
if ( (_DWORD)v5 == 2 )
LODWORD(v5) = fprintf(stderr, "ADD %s, R%d\n", **(const char ***)(v17 + 8), *(unsigned int *)v19[0]);
}
else
{
LODWORD(v5) = fprintf(stderr, "ADD %d, R%d\n", *(unsigned int *)(v17 + 8), *(unsigned int *)v19[0]);
}
break;
case '-':
v16 = *(_QWORD *)(a1 + 32);
LODWORD(v5) = *(_DWORD *)v16;
if ( *(_DWORD *)v16 )
{
if ( (_DWORD)v5 == 2 )
LODWORD(v5) = fprintf(stderr, "SUB %s, R%d\n", **(const char ***)(v16 + 8), *(unsigned int *)v19[0]);
}
else
{
LODWORD(v5) = fprintf(stderr, "SUB %d, R%d\n", *(unsigned int *)(v16 + 8), *(unsigned int *)v19[0]);
}
break;
case '*':
v15 = *(_QWORD *)(a1 + 32);
LODWORD(v5) = *(_DWORD *)v15;
if ( *(_DWORD *)v15 )
{
if ( (_DWORD)v5 == 2 )
LODWORD(v5) = fprintf(stderr, "MUL %s, R%d\n", **(const char ***)(v15 + 8), *(unsigned int *)v19[0]);
}
else
{
LODWORD(v5) = fprintf(stderr, "MUL %d, R%d\n", *(unsigned int *)(v15 + 8), *(unsigned int *)v19[0]);
}
break;
default:
LODWORD(v5) = fwrite("Unrecognized op value in gencode : case 1\n", 1uLL, 0x2AuLL, stderr);
break;
}
}
}
}
else if ( !v5 && !a3 )
{
LODWORD(v5) = *(_DWORD *)a1;
if ( *(_DWORD *)a1 )
{
if ( (_DWORD)v5 == 2 )
LODWORD(v5) = fprintf(stderr, "MOV %s, R%d\n", **(const char ***)(a1 + 8), *(unsigned int *)v19[0]);
}
else
{
LODWORD(v5) = fprintf(stderr, "MOV %d, R%d\n", *(unsigned int *)(a1 + 8), *a2);
}
}
return v5;
}

original_code:
void gencode( t_node *root, r_node *rstack, int type ) {
 if( root->left == ((void *)0) && root->right == ((void *)0) && type == 0 ) {
  if( root->type == num )
   fprintf( stderr, "MOV %d, R%d\n", root->attr.ival, rstack->number );
  else if( root->type == id )
   fprintf( stderr, "MOV %s, R%d\n", root->attr.id->name, rstack->number );
 }
 else if( root->left != ((void *)0) && root->right != ((void *)0) && root->type == op ) {
  if( root->right->gcl == 0 ) {
   gencode( root->left, rstack, 0 );
   switch( root->attr.oval ) {
   case '+':
    if( root->right->type == num )
     fprintf( stderr, "ADD %d, R%d\n", root->right->attr.ival, rstack->number );
    else if( root->right->type == id )
     fprintf( stderr, "ADD %s, R%d\n", root->right->attr.id->name, rstack->number );
    break;
   case '-':
    if( root->right->type == num )
     fprintf( stderr, "SUB %d, R%d\n", root->right->attr.ival, rstack->number );
    else if( root->right->type == id )
     fprintf( stderr, "SUB %s, R%d\n", root->right->attr.id->name, rstack->number );
    break;
   case '*':
    if( root->right->type == num )
     fprintf( stderr, "MUL %d, R%d\n", root->right->attr.ival, rstack->number );
    else if( root->right->type == id )
     fprintf( stderr, "MUL %s, R%d\n", root->right->attr.id->name, rstack->number );
    break;
   default:
    fprintf( stderr, "Unrecognized op value in gencode : case 1\n" );
   }
  }
  else if( 1 <= root->left->gcl && root->left->gcl < root->right->gcl ) {
   rstack = swap( rstack );
   gencode( root->right, rstack, 1 );
   r_node *R = pop( &rstack );
   gencode( root->left, rstack, 0 );
   switch( root->attr.oval ) {
   case '+':
    fprintf( stderr, "ADD R%d, R%d\n", R->number, rstack->number );
    break;
   case '-':
    fprintf( stderr, "SUB R%d, R%d\n", R->number, rstack->number );
    break;
   case '*':
    fprintf( stderr, "MUL R%d, R%d\n", R->number, rstack->number );
    break;
   default:
    fprintf( stderr, "Unrecognized op value in gencode : case 1\n" );
   }
   rstack = push( rstack, R );
   rstack = swap( rstack );
  }
  else if( 1 <= root->right->gcl && root->right->gcl <= root->left->gcl ) {
   gencode( root->left, rstack, 0 );
   r_node *R = pop( &rstack );
   gencode( root->right, rstack, 1 );
   switch( root->attr.oval ) {
   case '+':
    fprintf( stderr, "ADD R%d, R%d\n", rstack->number, R->number );
    break;
   case '-':
    fprintf( stderr, "SUB R%d, R%d\n", rstack->number, R->number );
    break;
   case '*':
    fprintf( stderr, "MUL R%d, R%d\n", rstack->number, R->number );
    break;
   default:
    fprintf( stderr, "Unrecognized op value in gencode : case 1\n" );
   }
   rstack = push( rstack, R );
  }
  else {
   fprintf( stderr, "shouldn't get to gencode : case 4\n" );
  }
 }
}

canonical_original_code:
void gencode(struct t_node *root, struct r_node *rstack, int type) {
 if( root->left == ((void *)0) && root->right == ((void *)0) && type == 0 ) {
  if( root->type == num )
   fprintf( stderr, "MOV %d, R%d\n", root->attr.ival, rstack->number );
  else if( root->type == id )
   fprintf( stderr, "MOV %s, R%d\n", root->attr.id->name, rstack->number );
 }
 else if( root->left != ((void *)0) && root->right != ((void *)0) && root->type == op ) {
  if( root->right->gcl == 0 ) {
   gencode( root->left, rstack, 0 );
   switch( root->attr.oval ) {
   case '+':
    if( root->right->type == num )
     fprintf( stderr, "ADD %d, R%d\n", root->right->attr.ival, rstack->number );
    else if( root->right->type == id )
     fprintf( stderr, "ADD %s, R%d\n", root->right->attr.id->name, rstack->number );
    break;
   case '-':
    if( root->right->type == num )
     fprintf( stderr, "SUB %d, R%d\n", root->right->attr.ival, rstack->number );
    else if( root->right->type == id )
     fprintf( stderr, "SUB %s, R%d\n", root->right->attr.id->name, rstack->number );
    break;
   case '*':
    if( root->right->type == num )
     fprintf( stderr, "MUL %d, R%d\n", root->right->attr.ival, rstack->number );
    else if( root->right->type == id )
     fprintf( stderr, "MUL %s, R%d\n", root->right->attr.id->name, rstack->number );
    break;
   default:
    fprintf( stderr, "Unrecognized op value in gencode : case 1\n" );
   }
  }
  else if( 1 <= root->left->gcl && root->left->gcl < root->right->gcl ) {
   rstack = swap( rstack );
   gencode( root->right, rstack, 1 );
   struct r_node *R = pop( &rstack );
   gencode( root->left, rstack, 0 );
   switch( root->attr.oval ) {
   case '+':
    fprintf( stderr, "ADD R%d, R%d\n", R->number, rstack->number );
    break;
   case '-':
    fprintf( stderr, "SUB R%d, R%d\n", R->number, rstack->number );
    break;
   case '*':
    fprintf( stderr, "MUL R%d, R%d\n", R->number, rstack->number );
    break;
   default:
    fprintf( stderr, "Unrecognized op value in gencode : case 1\n" );
   }
   rstack = push( rstack, R );
   rstack = swap( rstack );
  }
  else if( 1 <= root->right->gcl && root->right->gcl <= root->left->gcl ) {
   gencode( root->left, rstack, 0 );
   struct r_node *R = pop( &rstack );
   gencode( root->right, rstack, 1 );
   switch( root->attr.oval ) {
   case '+':
    fprintf( stderr, "ADD R%d, R%d\n", rstack->number, R->number );
    break;
   case '-':
    fprintf( stderr, "SUB R%d, R%d\n", rstack->number, R->number );
    break;
   case '*':
    fprintf( stderr, "MUL R%d, R%d\n", rstack->number, R->number );
    break;
   default:
    fprintf( stderr, "Unrecognized op value in gencode : case 1\n" );
   }
   rstack = push( rstack, R );
  }
  else {
   fprintf( stderr, "shouldn't get to gencode : case 4\n" );
  }
 }
}


decompiled_code:
void __fastcall destroy_entry(void *ptr)
{
if ( ptr )
{
destroy_entry(*((void **)ptr + 2));
free(*(void **)ptr);
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func0(void *ptr)
{
if ( ptr )
{
func0(*((void **)ptr + 2));
free(*(void **)ptr);
free(ptr);
}
}

original_code:
void destroy_entry( entry *to_delete ) {
 if( to_delete == ((void *)0) )
  return;
 else {
  destroy_entry( to_delete->next );
  free( to_delete->name );
  free( to_delete );
 }
}

canonical_original_code:
void destroy_entry(struct entry *to_delete) {
 if( to_delete == ((void *)0) )
  return;
 else {
  destroy_entry( to_delete->next );
  free( to_delete->name );
  free( to_delete );
 }
}

variable_types: struct entry { char *name; int value; struct entry *next; } *


decompiled_code:
__int64 __fastcall find_entry(__int64 *a1, const char *a2)
{
__int64 *v2; // r14
__int64 *v3; // r13
__int64 v4; // r12
size_t v6; // rbx

if ( a1 )
{
v2 = a1;
while ( 2 )
{
v3 = v2;
do
{
v4 = *v3;
if ( *v3 )
{
v6 = strlen(a2);
while ( strncmp(a2, *(const char **)v4, v6) )
{
v4 = *(_QWORD *)(v4 + 16);
if ( !v4 )
goto LABEL_5;
}
return v4;
}
LABEL_5:
++v3;
}
while ( v2 + 211 != v3 );
v2 = (__int64 *)v2[211];
if ( v2 )
continue;
break;
}
}
return 0LL;
}

original_code:
entry *find_entry( scope *stack, char *name ) {
 scope *s = stack;
 entry *ptr = ((void *)0);
 int i;
 while( s != ((void *)0) ) {
  for( i = 0; i < 211; i++ ) {
   if( s->sym_t[ i ] != ((void *)0) ) {
    ptr = s->sym_t[ i ];
    while( ptr != ((void *)0) ) {
     if( strncmp( name, ptr->name, strlen( name ) ) == 0 )
      return ptr;
     ptr = ptr->next;
    }
   }
  }
  s = s->parent;
 }
 return ((void *)0);
}

canonical_original_code:
struct entry *find_entry(struct scope *stack, char *name) {
 struct scope *s = stack;
 struct entry *ptr = ((void *)0);
 int i;
 while( s != ((void *)0) ) {
  for( i = 0; i < 211; i++ ) {
   if( s->sym_t[ i ] != ((void *)0) ) {
    ptr = s->sym_t[ i ];
    while( ptr != ((void *)0) ) {
     if( strncmp( name, ptr->name, strlen( name ) ) == 0 )
      return ptr;
     ptr = ptr->next;
    }
   }
  }
  s = s->parent;
 }
 return ((void *)0);
}

variable_types: struct scope { struct entry *sym_t[211]; struct scope *parent; } *

variable_types:
name
char *

variable_types: struct scope { struct entry { char *name; int value; struct entry *next; } *sym_t[211]; struct scope *parent; } *

variable_types: i int


decompiled_code:
__int64 __fastcall pop_scope(void *ptr)
{
__int64 v1; // r13
void **v2; // rbx

if ( !ptr )
return 0LL;
v1 = *((_QWORD *)ptr + 211);
v2 = (void **)ptr;
do
{
if ( *v2 )
destroy_entry(*v2);
++v2;
}
while ( v2 != (void **)((char *)ptr + 1688) );
free(ptr);
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func2(void *ptr)
{
__int64 v1; // r13
void **v2; // rbx

if ( !ptr )
return 0LL;
v1 = *((_QWORD *)ptr + 211);
v2 = (void **)ptr;
do
{
if ( *v2 )
func0(*v2);
++v2;
}
while ( v2 != (void **)((char *)ptr + 1688) );
free(ptr);
return v1;
}

original_code:
scope *pop_scope( scope *stack ) {
 scope *ptr;
 int i;
 if( stack == ((void *)0) )
  return ((void *)0);
 else {
  ptr = stack->parent;
  for( i = 0; i < 211; i++ ) {
   if( stack->sym_t[ i ] != ((void *)0) )
    destroy_entry( stack->sym_t[ i ] );
  }
  free( stack );
  return ptr;
 }
}

canonical_original_code:
struct scope *pop_scope(struct scope *stack) {
 struct scope *ptr;
 int i;
 if( stack == ((void *)0) )
  return ((void *)0);
 else {
  ptr = stack->parent;
  for( i = 0; i < 211; i++ ) {
   if( stack->sym_t[ i ] != ((void *)0) )
    destroy_entry( stack->sym_t[ i ] );
  }
  free( stack );
  return ptr;
 }
}

variable_types:
stack
struct scope *

return_type: struct scope { struct entry { char *name; int value; struct entry *next; } *sym_t[211]; struct scope *parent; } *

user_defined_types: struct scope { struct entry *sym_t[211]; struct scope *parent; }


hashpjw

decompiled_code:
__int64 __fastcall hashpjw(_BYTE *a1, int a2)
{
int v2; // edx
int v3; // eax

v2 = (char)*a1;
if ( !*a1 )
return 0LL;
v3 = 0;
do
{
v3 = v2 + 16 * v3;
if ( (v3 & 0xF0000000) != 0 )
v3 = ((int)(v3 & 0xF0000000) >> 24) ^ v3 & 0xFFFFFFF;
v2 = (char)*++a1;
}
while ( (_BYTE)v2 );
return (unsigned int)(v3 % a2);
}

original_code:
int hashpjw( const void *key, int tablesize ) {
 const char *ptr = key;
 int val = 0;
 while( *ptr != '\0' ) {
  int tmp;
  val = ( ( val << 4 ) + ( *ptr ) );
  if( ( tmp = ( val & 0xf0000000 ) ) ) {
   val = val ^ ( tmp >> 24 );
   val = val ^ tmp;
  }
  ptr++;
 }
 return val % tablesize;
}

canonical_original_code:
int hashpjw(void *key, int tablesize) {
 char *ptr = key;
 int val = 0;
 while( *ptr != '\0' ) {
  int tmp;
  val = ( ( val << 4 ) + ( *ptr ) );
  if( ( tmp = ( val & 0xf0000000 ) ) ) {
   val = val ^ ( tmp >> 24 );
   val = val ^ tmp;
  }
  ptr++;
 }
 return val % tablesize;
}

variable_types:
key
void *

variable_types: tablesize int

variable_types:
ptr
char *

variable_types: val int

variable_types: tmp int


decompiled_code:
size_t __fastcall print_symstack(__int64 *a1)
{
__int64 *v1; // r13
__int64 *v2; // rbp
__int64 *v3; // r12
__int64 v4; // rbx
size_t result; // rax

if ( a1 )
{
v1 = a1;
do
{
v2 = v1;
v3 = v1 + 211;
do
{
while ( 1 )
{
v4 = *v2;
if ( *v2 )
break;
if ( v3 == ++v2 )
goto LABEL_8;
}
do
{
fprintf(stderr, "[%s:%d]", *(const char **)v4, *(unsigned int *)(v4 + 8));
v4 = *(_QWORD *)(v4 + 16);
}
while ( v4 );
++v2;
fputc(10, stderr);
}
while ( v3 != v2 );
LABEL_8:
result = fwrite("---------------------\n", 1uLL, 0x16uLL, stderr);
v1 = (__int64 *)v1[211];
}
while ( v1 );
}
return result;
}

original_code:
void print_symstack( scope *stack ) {
 scope *s = stack;
 entry *e;
 int i;
 while( s != ((void *)0) ) {
  for( i = 0; i < 211; i++ ) {
   if( ( e = s->sym_t[ i ] ) != ((void *)0) ) {
    while( e != ((void *)0) ) {
     fprintf( stderr, "[%s:%d]", e->name, e->value );
     e = e->next;
    }
    fprintf( stderr, "\n" );
   }
  }
  fprintf( stderr, "---------------------\n" );
  s = s->parent;
 }
}

canonical_original_code:
void print_symstack(struct scope *stack) {
 struct scope *s = stack;
 struct entry *e;
 int i;
 while( s != ((void *)0) ) {
  for( i = 0; i < 211; i++ ) {
   if( ( e = s->sym_t[ i ] ) != ((void *)0) ) {
    while( e != ((void *)0) ) {
     fprintf( stderr, "[%s:%d]", e->name, e->value );
     e = e->next;
    }
    fprintf( stderr, "\n" );
   }
  }
  fprintf( stderr, "---------------------\n" );
  s = s->parent;
 }
}


decompiled_code:
__int64 __fastcall eval_tree(int *a1)
{
int *v1; // rbx
int v2; // ebp
int v3; // er12
int v4; // edx
int v6; // edx
int v7; // eax
int v8; // eax
int v9; // eax
int v10; // eax

if ( !a1 )
LABEL_12:
_assert_fail("ptr != NULL", "semantics.c", 0xBu, "eval_tree");
v1 = a1;
v2 = 1;
v3 = 0;
while ( 1 )
{
v4 = *v1;
if ( *v1 != 1 )
break;
v6 = v1[2];
switch ( v6 )
{
case '+':
v9 = eval_tree(*((_QWORD *)v1 + 3));
v1 = (int *)*((_QWORD *)v1 + 4);
v3 += v2 * v9;
if ( !v1 )
goto LABEL_12;
break;
case '-':
v7 = eval_tree(*((_QWORD *)v1 + 3));
v1 = (int *)*((_QWORD *)v1 + 4);
v8 = v2 * v7;
v2 = -v2;
v3 += v8;
if ( !v1 )
goto LABEL_12;
break;
case '*':
v10 = eval_tree(*((_QWORD *)v1 + 3));
v1 = (int *)*((_QWORD *)v1 + 4);
v2 *= v10;
if ( !v1 )
goto LABEL_12;
break;
default:
fprintf(stderr, "Unknown operator type: %d\n");
LABEL_8:
exit(1);
}
}
if ( v4 == 2 )
return (unsigned int)(v3 + v2 * *(_DWORD *)(*((_QWORD *)v1 + 1) + 8LL));
if ( v4 )
{
fprintf(stderr, "Unknown node type: %d\n");
goto LABEL_8;
}
return (unsigned int)(v3 + v2 * v1[2]);
}

canonical_decompiled_code:
__int64 __fastcall func0(int *a1)
{
int *v1; // rbx
int v2; // ebp
int v3; // er12
int v4; // edx
int v6; // edx
int v7; // eax
int v8; // eax
int v9; // eax
int v10; // eax

if ( !a1 )
LABEL_12:
_assert_fail("ptr != NULL", "semantics.c", 0xBu, "eval_tree");
v1 = a1;
v2 = 1;
v3 = 0;
while ( 1 )
{
v4 = *v1;
if ( *v1 != 1 )
break;
v6 = v1[2];
switch ( v6 )
{
case '+':
v9 = func0(*((_QWORD *)v1 + 3));
v1 = (int *)*((_QWORD *)v1 + 4);
v3 += v2 * v9;
if ( !v1 )
goto LABEL_12;
break;
case '-':
v7 = func0(*((_QWORD *)v1 + 3));
v1 = (int *)*((_QWORD *)v1 + 4);
v8 = v2 * v7;
v2 = -v2;
v3 += v8;
if ( !v1 )
goto LABEL_12;
break;
case '*':
v10 = func0(*((_QWORD *)v1 + 3));
v1 = (int *)*((_QWORD *)v1 + 4);
v2 *= v10;
if ( !v1 )
goto LABEL_12;
break;
default:
fprintf(stderr, "Unknown operator type: %d\n");
LABEL_8:
exit(1);
}
}
if ( v4 == 2 )
return (unsigned int)(v3 + v2 * *(_DWORD *)(*((_QWORD *)v1 + 1) + 8LL));
if ( v4 )
{
fprintf(stderr, "Unknown node type: %d\n");
goto LABEL_8;
}
return (unsigned int)(v3 + v2 * v1[2]);
}

original_code:
int eval_tree( t_node *ptr ) {
 ((void) sizeof ((ptr != ((void *)0)) ? 1 : 0), __extension__ ({ if (ptr != ((void *)0)) ; else __assert_fail ("ptr != NULL", "semantics.c", 11, __extension__ __PRETTY_FUNCTION__); }));
 switch( ptr->type ) {
 case op:
  switch( ptr->attr.oval ) {
  case '+':
   return eval_tree( ptr->left ) + eval_tree( ptr->right );
  case '*':
   return eval_tree( ptr->left ) * eval_tree( ptr->right );
  case '-':
   return eval_tree( ptr->left ) - eval_tree( ptr->right );
  default:
   fprintf( stderr, "Unknown operator type: %d\n", ptr->attr.oval );
   exit( 1 );
  }
 case num:
  return ptr->attr.ival;
 case id:
  return ptr->attr.id->value;
 default:
  fprintf( stderr, "Unknown node type: %d\n", ptr->type );
  exit( 1 );
 }
}

canonical_original_code:
int eval_tree(struct t_node *ptr) {
 ((void) sizeof ((ptr != ((void *)0)) ? 1 : 0), __extension__ ({ if (ptr != ((void *)0)) ; else __assert_fail ("ptr != NULL", "semantics.c", 11, __extension__ __PRETTY_FUNCTION__); }));
 switch( ptr->type ) {
 case op:
  switch( ptr->attr.oval ) {
  case '+':
   return eval_tree( ptr->left ) + eval_tree( ptr->right );
  case '*':
   return eval_tree( ptr->left ) * eval_tree( ptr->right );
  case '-':
   return eval_tree( ptr->left ) - eval_tree( ptr->right );
  default:
   fprintf( stderr, "Unknown operator type: %d\n", ptr->attr.oval );
   exit( 1 );
  }
 case num:
  return ptr->attr.ival;
 case id:
  return ptr->attr.id->value;
 default:
  fprintf( stderr, "Unknown node type: %d\n", ptr->type );
  exit( 1 );
 }
}


decompiled_code:
__int64 __fastcall eval_stmt(__int64 a1)
{
__int64 v1; // rdx
unsigned int v3; // er12
__int64 v4; // rbp
__int64 result; // rax
__int64 v6; // r13
int *v7; // rdi
unsigned int v8; // er12
__int64 v9; // rax
unsigned int *v10; // rbp

if ( !a1 )
_assert_fail("ptr != NULL", "semantics.c", 0x28u, "eval_stmt");
v1 = *(unsigned int *)(a1 + 8);
if ( (_DWORD)v1 == 61 )
{
v6 = *(_QWORD *)(a1 + 24);
if ( !v6 )
_assert_fail("id != NULL", "semantics.c", 0x2Du, "eval_stmt");
v7 = *(int **)(a1 + 32);
if ( !v7 )
_assert_fail("ptr->right != NULL", "semantics.c", 0x2Eu, "eval_stmt");
v8 = eval_tree(v7);
v9 = *(_QWORD *)(v6 + 8);
if ( !v9 )
_assert_fail("id->attr.id != NULL", "semantics.c", 0x30u, "eval_stmt");
*(_DWORD *)(v9 + 8) = v8;
v10 = (unsigned int *)init_rstack();
label(*(_QWORD *)(a1 + 32), 0LL);
gencode(*(_QWORD *)(a1 + 32), v10, 0LL);
fprintf(stderr, "MOV R%d, %s\n", *v10, **(const char ***)(v6 + 8));
destroy_rstack(v10);
result = v8;
}
else
{
if ( (_DWORD)v1 != 112 )
{
fprintf(stderr, "Unknown operator type: %d\n", v1);
exit(1);
}
v3 = eval_tree(*(int **)(a1 + 24));
v4 = init_rstack();
label(*(_QWORD *)(a1 + 24), 0LL);
gencode(*(_QWORD *)(a1 + 24), v4, 0LL);
result = v3;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
__int64 v1; // rdx
unsigned int v3; // er12
__int64 v4; // rbp
__int64 result; // rax
__int64 v6; // r13
int *v7; // rdi
unsigned int v8; // er12
__int64 v9; // rax
unsigned int *v10; // rbp

if ( !a1 )
_assert_fail("ptr != NULL", "semantics.c", 0x28u, "eval_stmt");
v1 = *(unsigned int *)(a1 + 8);
if ( (_DWORD)v1 == 61 )
{
v6 = *(_QWORD *)(a1 + 24);
if ( !v6 )
_assert_fail("id != NULL", "semantics.c", 0x2Du, "eval_stmt");
v7 = *(int **)(a1 + 32);
if ( !v7 )
_assert_fail("ptr->right != NULL", "semantics.c", 0x2Eu, "eval_stmt");
v8 = func0(v7);
v9 = *(_QWORD *)(v6 + 8);
if ( !v9 )
_assert_fail("id->attr.id != NULL", "semantics.c", 0x30u, "eval_stmt");
*(_DWORD *)(v9 + 8) = v8;
v10 = (unsigned int *)init_rstack();
label(*(_QWORD *)(a1 + 32), 0LL);
gencode(*(_QWORD *)(a1 + 32), v10, 0LL);
fprintf(stderr, "MOV R%d, %s\n", *v10, **(const char ***)(v6 + 8));
destroy_rstack(v10);
result = v8;
}
else
{
if ( (_DWORD)v1 != 112 )
{
fprintf(stderr, "Unknown operator type: %d\n", v1);
exit(1);
}
v3 = func0(*(int **)(a1 + 24));
v4 = init_rstack();
label(*(_QWORD *)(a1 + 24), 0LL);
gencode(*(_QWORD *)(a1 + 24), v4, 0LL);
result = v3;
}
return result;
}

original_code:
int eval_stmt( t_node *ptr ) {
 int value;
 t_node *id;
 r_node *rstack;
 ((void) sizeof ((ptr != ((void *)0)) ? 1 : 0), __extension__ ({ if (ptr != ((void *)0)) ; else __assert_fail ("ptr != NULL", "semantics.c", 40, __extension__ __PRETTY_FUNCTION__); }));
 switch( ptr->attr.oval ) {
 case '=':
  id = ptr->left;
  ((void) sizeof ((id != ((void *)0)) ? 1 : 0), __extension__ ({ if (id != ((void *)0)) ; else __assert_fail ("id != NULL", "semantics.c", 45, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((ptr->right != ((void *)0)) ? 1 : 0), __extension__ ({ if (ptr->right != ((void *)0)) ; else __assert_fail ("ptr->right != NULL", "semantics.c", 46, __extension__ __PRETTY_FUNCTION__); }));
  value = eval_tree( ptr->right );
  ((void) sizeof ((id->attr.id != ((void *)0)) ? 1 : 0), __extension__ ({ if (id->attr.id != ((void *)0)) ; else __assert_fail ("id->attr.id != NULL", "semantics.c", 48, __extension__ __PRETTY_FUNCTION__); }));
  id->attr.id->value = value;
  rstack = init_rstack( );
  label( ptr->right, 0 );
  gencode( ptr->right, rstack, 0 );
  fprintf( stderr, "MOV R%d, %s\n", rstack->number, id->attr.id->name );
  destroy_rstack( rstack );
  return value;
 case 'p':
  value = eval_tree( ptr->left );
  rstack = init_rstack( );
  label( ptr->left, 0 );
  gencode( ptr->left, rstack, 0 );
  return value;
 default:
  fprintf( stderr, "Unknown operator type: %d\n", ptr->attr.oval );
  exit( 1 );
 }
}

canonical_original_code:
int eval_stmt(struct t_node *ptr) {
 int value;
 struct t_node *id;
 struct r_node *rstack;
 ((void) sizeof ((ptr != ((void *)0)) ? 1 : 0), __extension__ ({ if (ptr != ((void *)0)) ; else __assert_fail ("ptr != NULL", "semantics.c", 40, __extension__ __PRETTY_FUNCTION__); }));
 switch( ptr->attr.oval ) {
 case '=':
  id = ptr->left;
  ((void) sizeof ((id != ((void *)0)) ? 1 : 0), __extension__ ({ if (id != ((void *)0)) ; else __assert_fail ("id != NULL", "semantics.c", 45, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((ptr->right != ((void *)0)) ? 1 : 0), __extension__ ({ if (ptr->right != ((void *)0)) ; else __assert_fail ("ptr->right != NULL", "semantics.c", 46, __extension__ __PRETTY_FUNCTION__); }));
  value = eval_tree( ptr->right );
  ((void) sizeof ((id->attr.id != ((void *)0)) ? 1 : 0), __extension__ ({ if (id->attr.id != ((void *)0)) ; else __assert_fail ("id->attr.id != NULL", "semantics.c", 48, __extension__ __PRETTY_FUNCTION__); }));
  id->attr.id->value = value;
  rstack = init_rstack( );
  label( ptr->right, 0 );
  gencode( ptr->right, rstack, 0 );
  fprintf( stderr, "MOV R%d, %s\n", rstack->number, id->attr.id->name );
  destroy_rstack( rstack );
  return value;
 case 'p':
  value = eval_tree( ptr->left );
  rstack = init_rstack( );
  label( ptr->left, 0 );
  gencode( ptr->left, rstack, 0 );
  return value;
 default:
  fprintf( stderr, "Unknown operator type: %d\n", ptr->attr.oval );
  exit( 1 );
 }
}

variable_types: value int


decompiled_code:
void __fastcall destroy_node(_QWORD *a1)
{
if ( a1[3] )
destroy_node();
if ( a1[4] )
destroy_node();
free(a1);
}

canonical_decompiled_code:
void __fastcall func0(_QWORD *a1)
{
if ( a1[3] )
func0();
if ( a1[4] )
func0();
free(a1);
}

original_code:
void destroy_node( t_node *to_delete ) {
 if( to_delete->left != ((void *)0) )
  destroy_node( to_delete->left );
 if( to_delete->right != ((void *)0) )
  destroy_node( to_delete->right );
 free( to_delete );
}

canonical_original_code:
void destroy_node(struct t_node *to_delete) {
 if( to_delete->left != ((void *)0) )
  destroy_node( to_delete->left );
 if( to_delete->right != ((void *)0) )
  destroy_node( to_delete->right );
 free( to_delete );
}


decompiled_code:
void __fastcall print_tree(const char ***a1, int a2)
{
const char ***v2; // r12
int v4; // ebx
int v5; // eax

if ( a1 )
{
v2 = a1;
do
{
v4 = 0;
if ( a2 > 0 )
{
do
{
++v4;
fputc(32, stderr);
}
while ( v4 != a2 );
}
v5 = *(_DWORD *)v2;
if ( *(_DWORD *)v2 == 1 )
{
fprintf(stderr, "[OP:%c|gcl=%d]", *((unsigned int *)v2 + 2), *((unsigned int *)v2 + 4));
}
else if ( v5 == 2 )
{
fprintf(stderr, "[ID:%s=%d|gcl=%d]", *v2[1], *((unsigned int *)v2[1] + 2), *((unsigned int *)v2 + 4));
}
else if ( v5 )
{
fwrite("[UNKNOWN]", 1uLL, 9uLL, stderr);
}
else
{
fprintf(stderr, "[NUM:%d|gcl=%d]", *((unsigned int *)v2 + 2), *((unsigned int *)v2 + 4));
}
a2 += 4;
fputc(10, stderr);
print_tree(v2[3], (unsigned int)a2);
v2 = (const char ***)v2[4];
}
while ( v2 );
}
}

canonical_decompiled_code:
void __fastcall func1(const char ***a1, int a2)
{
const char ***v2; // r12
int v4; // ebx
int v5; // eax

if ( a1 )
{
v2 = a1;
do
{
v4 = 0;
if ( a2 > 0 )
{
do
{
++v4;
fputc(32, stderr);
}
while ( v4 != a2 );
}
v5 = *(_DWORD *)v2;
if ( *(_DWORD *)v2 == 1 )
{
fprintf(stderr, "[OP:%c|gcl=%d]", *((unsigned int *)v2 + 2), *((unsigned int *)v2 + 4));
}
else if ( v5 == 2 )
{
fprintf(stderr, "[ID:%s=%d|gcl=%d]", *v2[1], *((unsigned int *)v2[1] + 2), *((unsigned int *)v2 + 4));
}
else if ( v5 )
{
fwrite("[UNKNOWN]", 1uLL, 9uLL, stderr);
}
else
{
fprintf(stderr, "[NUM:%d|gcl=%d]", *((unsigned int *)v2 + 2), *((unsigned int *)v2 + 4));
}
a2 += 4;
fputc(10, stderr);
func1(v2[3], (unsigned int)a2);
v2 = (const char ***)v2[4];
}
while ( v2 );
}
}

original_code:
void print_tree( t_node *root, int spaces ) {
 int i;
 if( root == ((void *)0) ) return;
 for( i = 0; i < spaces; i++ )
  fprintf( stderr, " " );
 switch( root->type ) {
 case op:
  fprintf( stderr, "[OP:%c|gcl=%d]", root->attr.oval, root->gcl );
  break;
 case num:
  fprintf( stderr, "[NUM:%d|gcl=%d]", root->attr.ival, root->gcl );
  break;
 case id:
  fprintf( stderr, "[ID:%s=%d|gcl=%d]", root->attr.id->name, root->attr.id->value, root->gcl );
  break;
 default:
  fprintf( stderr, "[UNKNOWN]" );
  break;
 }
 fprintf( stderr, "\n" );
 print_tree( root->left, spaces + 4 );
 print_tree( root->right, spaces + 4 );
}

canonical_original_code:
void print_tree(struct t_node *root, int spaces) {
 int i;
 if( root == ((void *)0) ) return;
 for( i = 0; i < spaces; i++ )
  fprintf( stderr, " " );
 switch( root->type ) {
 case op:
  fprintf( stderr, "[OP:%c|gcl=%d]", root->attr.oval, root->gcl );
  break;
 case num:
  fprintf( stderr, "[NUM:%d|gcl=%d]", root->attr.ival, root->gcl );
  break;
 case id:
  fprintf( stderr, "[ID:%s=%d|gcl=%d]", root->attr.id->name, root->attr.id->value, root->gcl );
  break;
 default:
  fprintf( stderr, "[UNKNOWN]" );
  break;
 }
 fprintf( stderr, "\n" );
 print_tree( root->left, spaces + 4 );
 print_tree( root->right, spaces + 4 );
}

variable_types: spaces int


main

repo: andrewkiluk/Basic-Web-Server

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned __int16 v3; // ax
const char *v4; // r12
unsigned __int16 v5; // bp
int v6; // ebx
socklen_t v7; // edx
char *v8; // rax
int v9; // ebp
socklen_t addr_len; // [rsp+Ch] [rbp-3Ch] BYREF
struct sockaddr v12; // [rsp+10h] [rbp-38h] BYREF
struct sockaddr addr; // [rsp+20h] [rbp-28h] BYREF

if ( signal(13, (__sighandler_t)1) == (__sighandler_t)-1LL )
DieWithError("signal() failed");
if ( argc != 3 )
{
fprintf(stderr, "Usage: %s <server-port> <web_root>\n", *argv);
exit(1);
}
v3 = atoi(argv[1]);
v4 = argv[2];
v5 = v3;
v6 = socket(2, 1, 6);
if ( v6 < 0 )
DieWithError("socket() failed");
*(_QWORD *)&v12.sa_data[6] = 0LL;
v12.sa_family = 2;
*(_QWORD *)&v12.sa_data[2] = (unsigned int)_bswap_32_constprop_0(v5, &v12, 16LL);
*(_WORD *)v12.sa_data = _bswap_16();
if ( bind(v6, &v12, v7) < 0 )
DieWithError("bind() failed");
if ( listen(v6, 5) < 0 )
DieWithError("listen() failed");
while ( 1 )
{
addr_len = 16;
v9 = accept(v6, &addr, &addr_len);
if ( v9 < 0 )
break;
v8 = inet_ntoa(*(struct in_addr *)&addr.sa_data[2]);
printf("%s ", v8);
HandleHTTPClient(v4, (unsigned int)v9);
}
fwrite("failed accept() attempt\n", 1uLL, 0x18uLL, stderr);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned __int16 v3; // ax
const char *v4; // r12
unsigned __int16 v5; // bp
int v6; // ebx
socklen_t v7; // edx
char *v8; // rax
int v9; // ebp
socklen_t addr_len; // [rsp+Ch] [rbp-3Ch] BYREF
struct sockaddr v12; // [rsp+10h] [rbp-38h] BYREF
struct sockaddr addr; // [rsp+20h] [rbp-28h] BYREF

if ( signal(13, (__sighandler_t)1) == (__sighandler_t)-1LL )
func8("signal() failed");
if ( argc != 3 )
{
fprintf(stderr, "Usage: %s <server-port> <web_root>\n", *argv);
exit(1);
}
v3 = atoi(argv[1]);
v4 = argv[2];
v5 = v3;
v6 = socket(2, 1, 6);
if ( v6 < 0 )
func8("socket() failed");
*(_QWORD *)&v12.sa_data[6] = 0LL;
v12.sa_family = 2;
*(_QWORD *)&v12.sa_data[2] = (unsigned int)func9(v5, &v12, 16LL);
*(_WORD *)v12.sa_data = func7();
if ( bind(v6, &v12, v7) < 0 )
func8("bind() failed");
if ( listen(v6, 5) < 0 )
func8("listen() failed");
while ( 1 )
{
addr_len = 16;
v9 = accept(v6, &addr, &addr_len);
if ( v9 < 0 )
break;
v8 = inet_ntoa(*(struct in_addr *)&addr.sa_data[2]);
printf("%s ", v8);
func11(v4, (unsigned int)v9);
}
fwrite("failed accept() attempt\n", 1uLL, 0x18uLL, stderr);
return 0;
}

original_code:
int main(int argc, char *argv[])
{
    int servSock;
    int clntSock;
    struct sockaddr_in ServAddr;
    struct sockaddr_in ClntAddr;
    unsigned short ServPort;
    unsigned int clntLen;
    if (signal(13, ((__sighandler_t) 1)) == ((__sighandler_t) -1))
      DieWithError("signal() failed");
    if (argc != 3)
    {
        fprintf(stderr, "Usage:  %s <server-port> <web_root>\n", argv[0]);
        exit(1);
    }
    ServPort = atoi(argv[1]);
    char *webRoot = argv[2];
    if ((servSock = socket(2, SOCK_STREAM, IPPROTO_TCP)) < 0)
        DieWithError("socket() failed");
    memset(&ServAddr, 0, sizeof(ServAddr));
    ServAddr.sin_family = 2;
    ServAddr.sin_addr.s_addr = htonl(((in_addr_t) 0x00000000));
    ServAddr.sin_port = htons(ServPort);
    if (bind(servSock, (struct sockaddr *) &ServAddr, sizeof(ServAddr)) < 0)
        DieWithError("bind() failed");
    if (listen(servSock, 5) < 0)
        DieWithError("listen() failed");
    for (;;)
    {
      clntLen = sizeof(ClntAddr);
      if ((clntSock = accept(servSock, (struct sockaddr *) &ClntAddr,
                             &clntLen)) < 0){
        fprintf(stderr,"failed accept() attempt\n");
        break;
      }
      printf("%s ", inet_ntoa(ClntAddr.sin_addr));
      HandleHTTPClient(webRoot, clntSock);
    }
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
    int servSock;
    int clntSock;
    struct sockaddr_in ServAddr;
    struct sockaddr_in ClntAddr;
    unsigned short ServPort;
    unsigned int clntLen;
    if (signal(13, ((void (*)(int)) 1)) == ((__sighandler_t) -1))
      DieWithError("signal() failed");
    if (argc != 3)
    {
        fprintf(stderr, "Usage:  %s <server-port> <web_root>\n", argv[0]);
        exit(1);
    }
    ServPort = atoi(argv[1]);
    char *webRoot = argv[2];
    if ((servSock = socket(2, SOCK_STREAM, IPPROTO_TCP)) < 0)
        DieWithError("socket() failed");
    memset(&ServAddr, 0, sizeof(ServAddr));
    ServAddr.sin_family = 2;
    ServAddr.sin_addr.s_addr = htonl(((unsigned int) 0x00000000));
    ServAddr.sin_port = htons(ServPort);
    if (bind(servSock, (struct sockaddr *) &ServAddr, sizeof(ServAddr)) < 0)
        DieWithError("bind() failed");
    if (listen(servSock, 5) < 0)
        DieWithError("listen() failed");
    for (;;)
    {
      clntLen = sizeof(ClntAddr);
      if ((clntSock = accept(servSock, (struct sockaddr *) &ClntAddr,
                             &clntLen)) < 0){
        fprintf(stderr,"failed accept() attempt\n");
        break;
      }
      printf("%s ", inet_ntoa(ClntAddr.sin_addr));
      HandleHTTPClient(webRoot, clntSock);
    }
    return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: servSock int

variable_types: clntSock int

variable_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; }

variable_types:
ServPort
unsigned short

variable_types:
clntLen
unsigned int

variable_types:
webRoot
char *

user_defined_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr sin_addr; unsigned char sin_zero[-1]; }

user_defined_types: struct sockaddr { unsigned short sa_family; char sa_data[14]; }


DieWithError

decompiled_code:
void __fastcall __noreturn DieWithError(const char *a1)
{
perror(a1);
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func8(const char *a1)
{
perror(a1);
exit(1);
}

original_code:
static void DieWithError(const char *message)
{
    perror(message);
    exit(1);
}

canonical_original_code:
static void DieWithError(char *message)
{
    perror(message);
    exit(1);
}

variable_types:
message
char *


decompiled_code:
__int64 __fastcall rl_max_size(__int64 a1)
{
return *(int *)(a1 + 12);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
return *(int *)(a1 + 12);
}

original_code:
size_t rl_max_size(RL* rl)
{
    return rl->bufsize;
}

canonical_original_code:
unsigned long rl_max_size(struct RL *rl)
{
    return rl->bufsize;
}

variable_types: struct RL { unsigned char *buf; int fildes; int bufsize; struct BR { int fildes; int bufsize; unsigned char *buf; int bufpos; int read_len; } *reader; int skipping; } *

return_type: unsigned long

user_defined_types: struct RL { unsigned char *buf; int fildes; int bufsize; struct BR *reader; int skipping; }


decompiled_code:
ssize_t __fastcall read_char(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rdx
ssize_t result; // rax
void *v4; // rsi
size_t v5; // rdx

v1 = *(int *)(a1 + 16);
if ( (_DWORD)v1 != *(_DWORD *)(a1 + 20) )
goto LABEL_2;
v4 = *(void **)(a1 + 8);
v5 = *(int *)(a1 + 4);
*(_DWORD *)(a1 + 16) = 0;
result = read(*(_DWORD *)a1, v4, v5);
*(_DWORD *)(a1 + 20) = result;
if ( !(_DWORD)result )
return 4294967294LL;
if ( (_DWORD)result != -1 )
{
v1 = *(int *)(a1 + 16);
LABEL_2:
v2 = *(_QWORD *)(a1 + 8);
*(_DWORD *)(a1 + 16) = v1 + 1;
result = *(unsigned __int8 *)(v2 + v1);
}
return result;
}

canonical_decompiled_code:
ssize_t __fastcall func7(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rdx
ssize_t result; // rax
void *v4; // rsi
size_t v5; // rdx

v1 = *(int *)(a1 + 16);
if ( (_DWORD)v1 != *(_DWORD *)(a1 + 20) )
goto LABEL_2;
v4 = *(void **)(a1 + 8);
v5 = *(int *)(a1 + 4);
*(_DWORD *)(a1 + 16) = 0;
result = read(*(_DWORD *)a1, v4, v5);
*(_DWORD *)(a1 + 20) = result;
if ( !(_DWORD)result )
return 4294967294LL;
if ( (_DWORD)result != -1 )
{
v1 = *(int *)(a1 + 16);
LABEL_2:
v2 = *(_QWORD *)(a1 + 8);
*(_DWORD *)(a1 + 16) = v1 + 1;
result = *(unsigned __int8 *)(v2 + v1);
}
return result;
}

original_code:
int read_char(BR* br)
{
    if (br->bufpos == br->read_len)
    {
        br->bufpos = 0;
        br->read_len = read(br->fildes, br->buf, br->bufsize);
        if (br->read_len == 0)
            return -2;
        if (br->read_len == -1)
            return -1;
    }
    return br->buf[br->bufpos++];
}

canonical_original_code:
int read_char(struct BR *br)
{
    if (br->bufpos == br->read_len)
    {
        br->bufpos = 0;
        br->read_len = read(br->fildes, br->buf, br->bufsize);
        if (br->read_len == 0)
            return -2;
        if (br->read_len == -1)
            return -1;
    }
    return br->buf[br->bufpos++];
}

variable_types: struct BR { int fildes; int bufsize; unsigned char *buf; int bufpos; int read_len; } *


decompiled_code:
__int64 __fastcall br_close(__int64 a1)
{
free(*(void **)(a1 + 8));
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
free(*(void **)(a1 + 8));
return 0LL;
}

original_code:
int br_close(BR* br)
{
    free(br->buf);
    return 0;
}

canonical_original_code:
int br_close(struct BR *br)
{
    free(br->buf);
    return 0;
}

user_defined_types: struct BR { int fildes; int bufsize; unsigned char *buf; int bufpos; int read_len; }


decompiled_code:
__int64 __fastcall rl_close(void *ptr)
{
br_close(*((_QWORD *)ptr + 2));
free(*(void **)ptr);
close(*((_DWORD *)ptr + 2));
free(ptr);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func9(void *ptr)
{
func8(*((_QWORD *)ptr + 2));
free(*(void **)ptr);
close(*((_DWORD *)ptr + 2));
free(ptr);
return 0LL;
}

original_code:
int rl_close(RL* rl)
{
    br_close(rl->reader);
    free(rl->buf);
    close(rl->fildes);
    free(rl);
    return 0;
}

canonical_original_code:
int rl_close(struct RL *rl)
{
    br_close(rl->reader);
    free(rl->buf);
    close(rl->fildes);
    free(rl);
    return 0;
}


decompiled_code:
__int64 __fastcall rl_readline(__int64 a1, void *a2)
{
size_t v2; // rbx
__int64 result; // rax
int v4; // er12

v2 = 0LL;
do
{
v4 = v2;
if ( rl_max_size(a1) <= v2 )
{
if ( rl_max_size(a1) != v2 )
goto LABEL_7;
goto LABEL_12;
}
result = read_char(*(_QWORD *)(a1 + 16));
if ( (_DWORD)result == -1 )
return result;
if ( (_DWORD)result == -2 )
return 0LL;
v4 = v2 + 1;
*(_BYTE *)(*(_QWORD *)a1 + v2++) = result;
}
while ( (_DWORD)result != 10 );
v2 = v4;
if ( rl_max_size(a1) != v4 )
goto LABEL_7;
LABEL_12:
if ( *(_BYTE *)(*(_QWORD *)a1 + v2 - 1) != 10 )
{
*(_DWORD *)(a1 + 24) = 1;
return 4294967293LL;
}
LABEL_7:
if ( *(_DWORD *)(a1 + 24) )
{
*(_DWORD *)(a1 + 24) = 0;
result = 4294967293LL;
}
else
{
memcpy(a2, *(const void **)a1, v2);
*((_BYTE *)a2 + v2) = 0;
result = (unsigned int)(v4 + 1);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, void *a2)
{
size_t v2; // rbx
__int64 result; // rax
int v4; // er12

v2 = 0LL;
do
{
v4 = v2;
if ( func6(a1) <= v2 )
{
if ( func6(a1) != v2 )
goto LABEL_7;
goto LABEL_12;
}
result = func7(*(_QWORD *)(a1 + 16));
if ( (_DWORD)result == -1 )
return result;
if ( (_DWORD)result == -2 )
return 0LL;
v4 = v2 + 1;
*(_BYTE *)(*(_QWORD *)a1 + v2++) = result;
}
while ( (_DWORD)result != 10 );
v2 = v4;
if ( func6(a1) != v4 )
goto LABEL_7;
LABEL_12:
if ( *(_BYTE *)(*(_QWORD *)a1 + v2 - 1) != 10 )
{
*(_DWORD *)(a1 + 24) = 1;
return 4294967293LL;
}
LABEL_7:
if ( *(_DWORD *)(a1 + 24) )
{
*(_DWORD *)(a1 + 24) = 0;
result = 4294967293LL;
}
else
{
memcpy(a2, *(const void **)a1, v2);
*((_BYTE *)a2 + v2) = 0;
result = (unsigned int)(v4 + 1);
}
return result;
}

original_code:
int rl_readline(RL *rl, char* buf, size_t buf_size)
{
    int len;
    for (len = 0; len < rl_max_size(rl); len++)
    {
        int next_char = read_char(rl->reader);
        if (next_char == -1)
            return -1;
        if (next_char == -2)
            return 0;
        rl->buf[len] = next_char;
        if (next_char == '\n')
        {
            len++;
            break;
        }
    }
    if (len == rl_max_size(rl) && rl->buf[len - 1] != '\n')
    {
        rl->skipping = 1;
        return -3;
    }
    else
    {
        if (rl->skipping)
        {
            rl->skipping = 0;
            return -3;
        }
        else
        {
            memcpy(buf, rl->buf, len);
            buf[len] = 0;
            return len + 1;
        }
    }
}

canonical_original_code:
int rl_readline(struct RL *rl, char *buf, unsigned long buf_size)
{
    int len;
    for (len = 0; len < rl_max_size(rl); len++)
    {
        int next_char = read_char(rl->reader);
        if (next_char == -1)
            return -1;
        if (next_char == -2)
            return 0;
        rl->buf[len] = next_char;
        if (next_char == '\n')
        {
            len++;
            break;
        }
    }
    if (len == rl_max_size(rl) && rl->buf[len - 1] != '\n')
    {
        rl->skipping = 1;
        return -3;
    }
    else
    {
        if (rl->skipping)
        {
            rl->skipping = 0;
            return -3;
        }
        else
        {
            memcpy(buf, rl->buf, len);
            buf[len] = 0;
            return len + 1;
        }
    }
}

variable_types:
buf
char *

variable_types: len int


runLoopGame

repo: andrsoze/gPng

decompiled_code:
__int64 runLoopGame()
{
if ( (unsigned int)updatePongGame(&gPngGame) > 1 )
goto LABEL_2;
flashScreen();
currentGPngState = gameChangeState(&gPngGame);
if ( currentGPngState )
{
resetPongGame(&gPngGame);
printScores(&gPngGame);
LABEL_2:
handlePlayerInput(&gPngGame, 1LL);
handlePlayerInput(&gPngGame, 0LL);
return gameRenderGame(&gPngGame);
}
setIntroNeedsRedraw(1LL);
return introDisplayInit();
}

canonical_decompiled_code:
__int64 func0()
{
if ( (unsigned int)updatePongGame(&gPngGame) > 1 )
goto LABEL_2;
flashScreen();
currentGPngState = gameChangeState(&gPngGame);
if ( currentGPngState )
{
resetPongGame(&gPngGame);
printScores(&gPngGame);
LABEL_2:
handlePlayerInput(&gPngGame, 1LL);
handlePlayerInput(&gPngGame, 0LL);
return gameRenderGame(&gPngGame);
}
setIntroNeedsRedraw(1LL);
return introDisplayInit();
}

original_code:
void runLoopGame(void) {
    GravPngScoreChange scoreChange;
    scoreChange = updatePongGame(&gPngGame);
    if(scoreChange == PLAYER_ONE_GOAL || scoreChange == PLAYER_TWO_GOAL) {
 flashScreen();
 currentGPngState = gameChangeState(&gPngGame);
 if(currentGPngState == MENU_STATE) {
     setIntroNeedsRedraw(1);
     introDisplayInit();
     return;
 } else {
     resetPongGame(&gPngGame);
     printScores(&gPngGame);
 }
    }
    handlePlayerInput(&gPngGame, 1);
    handlePlayerInput(&gPngGame, 0);
    gameRenderGame(&gPngGame);
}

canonical_original_code:
void runLoopGame() {
    enum GRAVPNG_GAME_SCORE_CHANGE scoreChange;
    scoreChange = updatePongGame(&gPngGame);
    if(scoreChange == PLAYER_ONE_GOAL || scoreChange == PLAYER_TWO_GOAL) {
 flashScreen();
 currentGPngState = gameChangeState(&gPngGame);
 if(currentGPngState == MENU_STATE) {
     setIntroNeedsRedraw(1);
     introDisplayInit();
     return;
 } else {
     resetPongGame(&gPngGame);
     printScores(&gPngGame);
 }
    }
    handlePlayerInput(&gPngGame, 1);
    handlePlayerInput(&gPngGame, 0);
    gameRenderGame(&gPngGame);
}

variable_types: enum GRAVPNG_GAME_SCORE_CHANGE { PLAYER_ONE_GOAL=0, PLAYER_TWO_GOAL=1, NO_GOAL=2 }


setupNewGame

decompiled_code:
__int64 __fastcall setupNewGame(unsigned int a1)
{
if ( a1 > 2 )
_assert_fail("numHumanPlayers >= 0 && numHumanPlayers < 3", "gPng.c", 0x89u, "setupNewGame");
gameDisplayInit();
resetPongGame(&gPngGame);
*((_DWORD *)&gPngGame + 11) = 0;
*(&gPngGame + 6) = 0x100000000LL;
*((_DWORD *)&gPngGame + 14) = a1 == 2;
return printScores(&gPngGame);
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int a1)
{
if ( a1 > 2 )
_assert_fail("numHumanPlayers >= 0 && numHumanPlayers < 3", "gPng.c", 0x89u, "setupNewGame");
gameDisplayInit();
resetPongGame(&gPngGame);
*((_DWORD *)&gPngGame + 11) = 0;
*(&gPngGame + 6) = 0x100000000LL;
*((_DWORD *)&gPngGame + 14) = a1 == 2;
return printScores(&gPngGame);
}

original_code:
void setupNewGame(int numHumanPlayers) {
    ((void) sizeof ((numHumanPlayers >= 0 && numHumanPlayers < 3) ? 1 : 0), __extension__ ({ if (numHumanPlayers >= 0 && numHumanPlayers < 3) ; else __assert_fail ("numHumanPlayers >= 0 && numHumanPlayers < 3", "gPng.c", 137, __extension__ __PRETTY_FUNCTION__); }));
    gameDisplayInit();
    resetPongGame(&gPngGame);
    gPngGame.pointsPlayerOne = 0;
    gPngGame.pointsPlayerTwo = 0;
    gPngGame.isPlayerOneHuman = 1;
    gPngGame.isPlayerTwoHuman = (numHumanPlayers == 2)?1:0;
    printScores(&gPngGame);
}

variable_types: numHumanPlayers int


changeState

decompiled_code:
__int64 __fastcall changeState(unsigned int a1)
{
__int64 result; // rax
_QWORD *v2; // rax
_QWORD *v3; // rax

currentGPngState = a1;
if ( a1 == 3 )
return setupNewGame(2u);
if ( a1 > 3 )
{
if ( a1 != 5 )
goto LABEL_10;
v2 = (_QWORD *)globalGameState;
*(_QWORD *)(globalGameState + 8) = &howDisplayInit;
v2[2] = &howHandleEvent;
v2[3] = &howUpdate;
v2[4] = &howRender;
v2[5] = &howClean;
v2[6] = &howChangeState;
result = howDisplayInit();
}
else
{
if ( a1 )
{
if ( a1 == 2 )
return setupNewGame(1u);
LABEL_10:
_assert_fail("0", "gPng.c", 0x84u, "changeState");
}
v3 = (_QWORD *)globalGameState;
*(_QWORD *)(globalGameState + 8) = &introDisplayInit;
v3[2] = &introHandleEvent;
v3[3] = &introUpdate;
v3[4] = &introRender;
v3[5] = &introClean;
v3[6] = &introChangeState;
result = introDisplayInit();
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1)
{
__int64 result; // rax
_QWORD *v2; // rax
_QWORD *v3; // rax

currentGPngState = a1;
if ( a1 == 3 )
return func1(2u);
if ( a1 > 3 )
{
if ( a1 != 5 )
goto LABEL_10;
v2 = (_QWORD *)globalGameState;
*(_QWORD *)(globalGameState + 8) = &howDisplayInit;
v2[2] = &howHandleEvent;
v2[3] = &howUpdate;
v2[4] = &howRender;
v2[5] = &howClean;
v2[6] = &howChangeState;
result = howDisplayInit();
}
else
{
if ( a1 )
{
if ( a1 == 2 )
return func1(1u);
LABEL_10:
_assert_fail("0", "gPng.c", 0x84u, "changeState");
}
v3 = (_QWORD *)globalGameState;
*(_QWORD *)(globalGameState + 8) = &introDisplayInit;
v3[2] = &introHandleEvent;
v3[3] = &introUpdate;
v3[4] = &introRender;
v3[5] = &introClean;
v3[6] = &introChangeState;
result = introDisplayInit();
}
return result;
}

original_code:
void changeState(GPngState newState) {
    currentGPngState = newState;
    switch (newState) {
    case GAME_STATE_SINGLE:
 setupNewGame(1);
 break;
    case GAME_STATE_DOUBLE:
 setupNewGame(2);
 break;
    case HOW_TO_PLAY_STATE:
 globalGameState->initFPtr = howDisplayInit;
 globalGameState->handleEventFPtr = howHandleEvent;
 globalGameState->updateFPtr = howUpdate;
 globalGameState->renderFPtr = howRender;
 globalGameState->clean = howClean;
 globalGameState->changeState = howChangeState;
 globalGameState->initFPtr();
 break;
    case MENU_STATE:
 globalGameState->initFPtr = introDisplayInit;
 globalGameState->handleEventFPtr = introHandleEvent;
 globalGameState->updateFPtr = introUpdate;
 globalGameState->renderFPtr = introRender;
 globalGameState->clean = introClean;
 globalGameState->changeState = introChangeState;
 globalGameState->initFPtr();
 break;
    default:
 ((void) sizeof ((0) ? 1 : 0), __extension__ ({ if (0) ; else __assert_fail ("0", "gPng.c", 132, __extension__ __PRETTY_FUNCTION__); }));
    }
}

canonical_original_code:
void changeState(enum PNG_STATE newState) {
    currentGPngState = newState;
    switch (newState) {
    case GAME_STATE_SINGLE:
 setupNewGame(1);
 break;
    case GAME_STATE_DOUBLE:
 setupNewGame(2);
 break;
    case HOW_TO_PLAY_STATE:
 globalGameState->initFPtr = howDisplayInit;
 globalGameState->handleEventFPtr = howHandleEvent;
 globalGameState->updateFPtr = howUpdate;
 globalGameState->renderFPtr = howRender;
 globalGameState->clean = howClean;
 globalGameState->changeState = howChangeState;
 globalGameState->initFPtr();
 break;
    case MENU_STATE:
 globalGameState->initFPtr = introDisplayInit;
 globalGameState->handleEventFPtr = introHandleEvent;
 globalGameState->updateFPtr = introUpdate;
 globalGameState->renderFPtr = introRender;
 globalGameState->clean = introClean;
 globalGameState->changeState = introChangeState;
 globalGameState->initFPtr();
 break;
    default:
 ((void) sizeof ((0) ? 1 : 0), __extension__ ({ if (0) ; else __assert_fail ("0", "gPng.c", 132, __extension__ __PRETTY_FUNCTION__); }));
    }
}

variable_types: enum PNG_STATE { MENU_STATE=0, HIGHSCORE_STATE=1, GAME_STATE_SINGLE=2, GAME_STATE_DOUBLE=3, TITLE_STATE=4, HOW_TO_PLAY_STATE=5 }


runLoop

decompiled_code:
void __noreturn runLoop()
{
unsigned int v0; // edi

v0 = currentGPngState;
while ( 1 )
{
if ( v0 - 2 <= 1 )
{
LABEL_5:
runLoopGame();
v0 = currentGPngState;
}
else
{
while ( 1 )
{
(*(void (**)(void))(globalGameState + 16))();
(*(void (**)(void))(globalGameState + 24))();
(*(void (**)(void))(globalGameState + 32))();
v0 = (*(__int64 (__fastcall **)(__int64 *))(globalGameState + 48))(&gPngGame);
if ( currentGPngState == v0 )
break;
changeState(v0);
if ( (unsigned int)(currentGPngState - 2) <= 1 )
goto LABEL_5;
}
}
}
}

canonical_decompiled_code:
void __noreturn func3()
{
unsigned int v0; // edi

v0 = currentGPngState;
while ( 1 )
{
if ( v0 - 2 <= 1 )
{
LABEL_5:
func0();
v0 = currentGPngState;
}
else
{
while ( 1 )
{
(*(void (**)(void))(globalGameState + 16))();
(*(void (**)(void))(globalGameState + 24))();
(*(void (**)(void))(globalGameState + 32))();
v0 = (*(__int64 (__fastcall **)(__int64 *))(globalGameState + 48))(&gPngGame);
if ( currentGPngState == v0 )
break;
func2(v0);
if ( (unsigned int)(currentGPngState - 2) <= 1 )
goto LABEL_5;
}
}
}
}

original_code:
void runLoop(void)
{
    GPngState newState;
    while(1) {
 if(currentGPngState == GAME_STATE_SINGLE ||
    currentGPngState == GAME_STATE_DOUBLE) {
     runLoopGame();
 } else {
     globalGameState->handleEventFPtr();
     globalGameState->updateFPtr();
     globalGameState->renderFPtr();
     newState = globalGameState->changeState(&gPngGame);
     if(currentGPngState != newState) {
  changeState(newState);
     }
 }
    }
}

canonical_original_code:
void runLoop()
{
    enum PNG_STATE newState;
    while(1) {
 if(currentGPngState == GAME_STATE_SINGLE ||
    currentGPngState == GAME_STATE_DOUBLE) {
     runLoopGame();
 } else {
     globalGameState->handleEventFPtr();
     globalGameState->updateFPtr();
     globalGameState->renderFPtr();
     newState = globalGameState->changeState(&gPngGame);
     if(currentGPngState != newState) {
  changeState(newState);
     }
 }
    }
}

user_defined_types: enum PNG_STATE { MENU_STATE=0, HIGHSCORE_STATE=1, GAME_STATE_SINGLE=2, GAME_STATE_DOUBLE=3, TITLE_STATE=4, HOW_TO_PLAY_STATE=5 }


assembleDefaultPongGame

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

result = 0x100020008LL;
*(&gPngGame + 2) = (__int64)&ball;
gPngGame = (__int64)&paddleOne;
*(&gPngGame + 1) = (__int64)&paddleTwo;
*(&gPngGame + 3) = (__int64)&court;
*(&gPngGame + 4) = 0x100020008LL;
*((_BYTE *)&gPngGame + 40) = 1;
*(__int64 *)((char *)&gPngGame + 44) = 0LL;
return result;
}

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

result = 0x100020008LL;
*(&gPngGame + 2) = (__int64)&ball;
gPngGame = (__int64)&paddleOne;
*(&gPngGame + 1) = (__int64)&paddleTwo;
*(&gPngGame + 3) = (__int64)&court;
*(&gPngGame + 4) = 0x100020008LL;
*((_BYTE *)&gPngGame + 40) = 1;
*(__int64 *)((char *)&gPngGame + 44) = 0LL;
return result;
}

original_code:
void assembleDefaultPongGame(void) {
    gPngGame.ball = &ball;
    gPngGame.paddleOne = &paddleOne;
    gPngGame.paddleTwo = &paddleTwo;
    gPngGame.court = &court;
    gPngGame.useGravity = 1;
    gPngGame.gravity = 1;
    gPngGame.epsilon = ((2<<(16))|8);
    gPngGame.pointsPlayerOne = 0;
    gPngGame.pointsPlayerTwo = 0;
}

canonical_original_code:
void assembleDefaultPongGame() {
    gPngGame.ball = &ball;
    gPngGame.paddleOne = &paddleOne;
    gPngGame.paddleTwo = &paddleTwo;
    gPngGame.court = &court;
    gPngGame.useGravity = 1;
    gPngGame.gravity = 1;
    gPngGame.epsilon = ((2<<(16))|8);
    gPngGame.pointsPlayerOne = 0;
    gPngGame.pointsPlayerTwo = 0;
}


main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
_QWORD *v3; // rax
__int64 v4; // rdx

v3 = malloc(0x38uLL);
v3[1] = &titleDisplayInit;
v3[2] = &titleHandleEvent;
v3[3] = &titleUpdate;
v3[4] = &titleRender;
v3[5] = &titleClean;
v3[6] = &titleChangeState;
globalGameState = (__int64)v3;
assembleDefaultPongGame(56LL, argv, v3);
(*(void (**)(void))(v4 + 8))();
runLoop();
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
_QWORD *v3; // rax
__int64 v4; // rdx

v3 = malloc(0x38uLL);
v3[1] = &titleDisplayInit;
v3[2] = &titleHandleEvent;
v3[3] = &titleUpdate;
v3[4] = &titleRender;
v3[5] = &titleClean;
v3[6] = &titleChangeState;
globalGameState = (__int64)v3;
func4(56LL, argv, v3);
(*(void (**)(void))(v4 + 8))();
func3();
}

original_code:
int main()
{
    globalGameState = malloc(sizeof(GameState));
    globalGameState->initFPtr = titleDisplayInit;
    globalGameState->handleEventFPtr = titleHandleEvent;
    globalGameState->updateFPtr = titleUpdate;
    globalGameState->renderFPtr = titleRender;
    globalGameState->clean = titleClean;
    globalGameState->changeState = titleChangeState;
    assembleDefaultPongGame();
    globalGameState->initFPtr();
    runLoop();
    while(1){
    }
    free(globalGameState);
    return 1;
}


moveMenuUp

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

result = (unsigned int)selectedAlternative;
if ( selectedAlternative == 2 )
{
selectedAlternative = 1;
}
else if ( selectedAlternative == 3 )
{
selectedAlternative = 2;
}
return result;
}

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

result = (unsigned int)selectedAlternative;
if ( selectedAlternative == 2 )
{
selectedAlternative = 1;
}
else if ( selectedAlternative == 3 )
{
selectedAlternative = 2;
}
return result;
}

original_code:
void moveMenuUp(void) {
    if (selectedAlternative == TwoPlayerGame) {
 selectedAlternative = OnePlayerGame;
    } else if (selectedAlternative == HowToPlay) {
 selectedAlternative = TwoPlayerGame;
    }
}

canonical_original_code:
void moveMenuUp() {
    if (selectedAlternative == TwoPlayerGame) {
 selectedAlternative = OnePlayerGame;
    } else if (selectedAlternative == HowToPlay) {
 selectedAlternative = TwoPlayerGame;
    }
}


moveMenuDown

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

result = (unsigned int)selectedAlternative;
if ( selectedAlternative == 1 )
{
selectedAlternative = 2;
}
else if ( selectedAlternative == 2 )
{
selectedAlternative = 3;
}
return result;
}

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

result = (unsigned int)selectedAlternative;
if ( selectedAlternative == 1 )
{
selectedAlternative = 2;
}
else if ( selectedAlternative == 2 )
{
selectedAlternative = 3;
}
return result;
}

original_code:
void moveMenuDown(void) {
    if (selectedAlternative == OnePlayerGame) {
 selectedAlternative = TwoPlayerGame;
    } else if (selectedAlternative == TwoPlayerGame) {
 selectedAlternative = HowToPlay;
    }
}

canonical_original_code:
void moveMenuDown() {
    if (selectedAlternative == OnePlayerGame) {
 selectedAlternative = TwoPlayerGame;
    } else if (selectedAlternative == TwoPlayerGame) {
 selectedAlternative = HowToPlay;
    }
}


introHandleEvent

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

result = (unsigned int)(unsigned __int8)count + 1;
if ( (char)(count + 1) <= 55 )
{
++count;
}
else
{
count = 0;
if ( (MEMORY[0xDC00] & 1) != 0 )
{
if ( (MEMORY[0xDC00] & 2) != 0 )
{
if ( (MEMORY[0xDC00] & 0x10) == 0 )
buttonPressed = 1;
}
else
{
result = moveMenuDown();
}
}
else
{
result = moveMenuUp();
}
}
return result;
}

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

result = (unsigned int)(unsigned __int8)count + 1;
if ( (char)(count + 1) <= 55 )
{
++count;
}
else
{
count = 0;
if ( (MEMORY[0xDC00] & 1) != 0 )
{
if ( (MEMORY[0xDC00] & 2) != 0 )
{
if ( (MEMORY[0xDC00] & 0x10) == 0 )
buttonPressed = 1;
}
else
{
result = func1();
}
}
else
{
result = func0();
}
}
return result;
}

original_code:
void introHandleEvent(void) {
    char joystickEvent;
    volatile char *dataPortA = (char*) 0xdc00;
    joystickEvent = *(dataPortA);
    if (++count < 56) {
 return;
    }
    count = 0;
    if (!(joystickEvent & 1)) {
 moveMenuUp();
    } else if (!(joystickEvent & 2)) {
 moveMenuDown();
    } else if (!(joystickEvent & 16)) {
 buttonPressed = 1;
    }
}

canonical_original_code:
void introHandleEvent() {
    char joystickEvent;
    char *dataPortA = (char*) 0xdc00;
    joystickEvent = *(dataPortA);
    if (++count < 56) {
 return;
    }
    count = 0;
    if (!(joystickEvent & 1)) {
 moveMenuUp();
    } else if (!(joystickEvent & 2)) {
 moveMenuDown();
    } else if (!(joystickEvent & 16)) {
 buttonPressed = 1;
    }
}

variable_types: joystickEvent char

variable_types:
dataPortA
char *


introUpdate

decompiled_code:
void introUpdate()
{
;
}

canonical_decompiled_code:
void func3()
{
;
}

original_code:
void introUpdate(void) {
}

canonical_original_code:
void introUpdate() {
}


setIntroNeedsRedraw

decompiled_code:
void __fastcall setIntroNeedsRedraw(char a1)
{
needsRedraw = a1;
}

canonical_decompiled_code:
void __fastcall func4(char a1)
{
needsRedraw = a1;
}

original_code:
void setIntroNeedsRedraw(unsigned char nextNeedsRedraw) {
    needsRedraw = nextNeedsRedraw;
}

variable_types:
nextNeedsRedraw
unsigned char


introClean

decompiled_code:
void introClean()
{
;
}

canonical_decompiled_code:
void func5()
{
;
}

original_code:
void introClean(void) {
}

canonical_original_code:
void introClean() {
}


setupIntroSpriteMemPtrs

decompiled_code:
void setupIntroSpriteMemPtrs()
{
MEMORY[0x7F8] = 13;
}

canonical_decompiled_code:
void func6()
{
MEMORY[0x7F8] = 13;
}

original_code:
void setupIntroSpriteMemPtrs(void) {
    char * pokePtr;
    pokePtr = (char *) 0x7F8;
    *(pokePtr) = 13;
}

canonical_original_code:
void setupIntroSpriteMemPtrs() {
    char *pokePtr;
    pokePtr = (char *) 0x7F8;
    *(pokePtr) = 13;
}

variable_types:
pokePtr
char *


fillIntroSpriteMem

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

result = 0xFFFFFFFFLL;
qword_370 = -1LL;
dword_378 = -1;
*(_WORD *)&count = -1;
MEMORY[0x37E] = -1;
menuAlternativeStrings = -1LL;
xmmword_350 = -1LL;
xmmword_360 = -1LL;
return result;
}

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

result = 0xFFFFFFFFLL;
qword_370 = -1LL;
dword_378 = -1;
*(_WORD *)&count = -1;
MEMORY[0x37E] = -1;
menuAlternativeStrings = -1LL;
xmmword_350 = -1LL;
xmmword_360 = -1LL;
return result;
}

original_code:
void fillIntroSpriteMem(void) {
    char * pokePtr;
    char i;
    for (i = 0; i < 63; i++) {
 pokePtr = (char *) 0x340;
 *(pokePtr + i) = 255;
    }
}

canonical_original_code:
void fillIntroSpriteMem() {
    char *pokePtr;
    char i;
    for (i = 0; i < 63; i++) {
 pokePtr = (char *) 0x340;
 *(pokePtr + i) = 255;
    }
}

variable_types: i char


drawSprite

decompiled_code:
__int64 drawSprite()
{
char v0; // bl
__int64 result; // rax

v0 = -124;
if ( selectedAlternative != 2 )
{
v0 = 92;
if ( selectedAlternative == 3 )
v0 = -84;
}
MEMORY[0xD027] = 1;
MEMORY[0xD000] = 26;
result = setMsb(0LL, 0LL);
MEMORY[0xD001] = v0;
MEMORY[0xD015] = 1;
return result;
}

canonical_decompiled_code:
__int64 func8()
{
char v0; // bl
__int64 result; // rax

v0 = -124;
if ( selectedAlternative != 2 )
{
v0 = 92;
if ( selectedAlternative == 3 )
v0 = -84;
}
MEMORY[0xD027] = 1;
MEMORY[0xD000] = 26;
result = setMsb(0LL, 0LL);
MEMORY[0xD001] = v0;
MEMORY[0xD015] = 1;
return result;
}

original_code:
void drawSprite(void) {
    unsigned int x, y;
    char *pokePtr;
    x = 26;
    y = ((6 + 1) * 8) + 36;
    if (selectedAlternative == TwoPlayerGame) {
 y += (5 * 8);
    } else if (selectedAlternative == HowToPlay) {
 y += ((5 * 2) * 8);
    }
    pokePtr = (char *)0xD027;
    (*pokePtr) = 1;
    pokePtr = (char *) 0xD000;
    *(pokePtr) = x;
    setMsb(0, 0);
    pokePtr = (char *) 0xD001;
    *(pokePtr) = y;
    pokePtr = (char *) 0xD015;
    *(pokePtr) = 1;
}

canonical_original_code:
void drawSprite() {
    unsigned int x; unsigned int y;
    char *pokePtr;
    x = 26;
    y = ((6 + 1) * 8) + 36;
    if (selectedAlternative == TwoPlayerGame) {
 y += (5 * 8);
    } else if (selectedAlternative == HowToPlay) {
 y += ((5 * 2) * 8);
    }
    pokePtr = (char *)0xD027;
    (*pokePtr) = 1;
    pokePtr = (char *) 0xD000;
    *(pokePtr) = x;
    setMsb(0, 0);
    pokePtr = (char *) 0xD001;
    *(pokePtr) = y;
    pokePtr = (char *) 0xD015;
    *(pokePtr) = 1;
}

variable_types:
x
unsigned int

variable_types:
y
unsigned int


introRender

decompiled_code:
// attributes: thunk
__int64 introRender()
{
return drawSprite();
}

canonical_decompiled_code:
__int64 func9()
{
return func8();
}

original_code:
void introRender(void) {
    drawSprite();
}

canonical_original_code:
void introRender() {
    drawSprite();
}


introDisplayInit

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

if ( needsRedraw )
{
fillIntroSpriteMem();
setupIntroSpriteMemPtrs();
drawSprite();
clearScreen();
printLine(4LL, 6LL, &menuAlternativeStrings, (unsigned int)menuAlternativeStringLengths[0]);
printLine(
4LL,
11LL,
(unsigned int)((_DWORD)&menuAlternativeStrings + 20),
(unsigned int)menuAlternativeStringLengths[1]);
result = printLine(
4LL,
16LL,
(unsigned int)((_DWORD)&menuAlternativeStrings + 40),
(unsigned int)menuAlternativeStringLengths[2]);
}
return result;
}

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

if ( needsRedraw )
{
func7();
func6();
func8();
clearScreen();
printLine(4LL, 6LL, &menuAlternativeStrings, (unsigned int)menuAlternativeStringLengths[0]);
printLine(
4LL,
11LL,
(unsigned int)((_DWORD)&menuAlternativeStrings + 20),
(unsigned int)menuAlternativeStringLengths[1]);
result = printLine(
4LL,
16LL,
(unsigned int)((_DWORD)&menuAlternativeStrings + 40),
(unsigned int)menuAlternativeStringLengths[2]);
}
return result;
}

original_code:
void introDisplayInit(void) {
    if (needsRedraw) {
 int i;
 fillIntroSpriteMem();
 setupIntroSpriteMemPtrs();
 drawSprite();
 clearScreen();
 for (i = 0; i < 3; i++) {
     printLine(4, 6 + (i * 5),
        menuAlternativeStrings[i], menuAlternativeStringLengths[i]);
 }
    }
}

canonical_original_code:
void introDisplayInit() {
    if (needsRedraw) {
 int i;
 fillIntroSpriteMem();
 setupIntroSpriteMemPtrs();
 drawSprite();
 clearScreen();
 for (i = 0; i < 3; i++) {
     printLine(4, 6 + (i * 5),
        menuAlternativeStrings[i], menuAlternativeStringLengths[i]);
 }
    }
}

variable_types: i int


initGameObjects

decompiled_code:
_BOOL8 __fastcall initGameObjects(int a1, __int64 a2)
{
_BOOL8 result; // rax

initDefaultBall(*(_QWORD *)(a2 + 16));
initDefaultCourt(*(_QWORD *)(a2 + 24));
initDefaultPaddleOne(*(_QWORD *)a2);
initDefaultPaddleTwo(*(_QWORD *)(a2 + 8));
*(_DWORD *)(a2 + 52) = 1;
result = a1 == 0;
*(_DWORD *)(a2 + 56) = result;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func11(int a1, __int64 a2)
{
_BOOL8 result; // rax

initDefaultBall(*(_QWORD *)(a2 + 16));
initDefaultCourt(*(_QWORD *)(a2 + 24));
initDefaultPaddleOne(*(_QWORD *)a2);
initDefaultPaddleTwo(*(_QWORD *)(a2 + 8));
*(_DWORD *)(a2 + 52) = 1;
result = a1 == 0;
*(_DWORD *)(a2 + 56) = result;
return result;
}

original_code:
void initGameObjects(int isOnePlayer, GPngGame *gPngGame)
{
    initDefaultBall(gPngGame->ball);
    initDefaultCourt(gPngGame->court);
    initDefaultPaddleOne(gPngGame->paddleOne);
    initDefaultPaddleTwo(gPngGame->paddleTwo);
    gPngGame->isPlayerOneHuman = 1;
    if(isOnePlayer) {
 gPngGame->isPlayerTwoHuman = 0;
    } else {
 gPngGame->isPlayerTwoHuman = 1;
    }
}

canonical_original_code:
void initGameObjects(int isOnePlayer, struct PONGGAME *gPngGame)
{
    initDefaultBall(gPngGame->ball);
    initDefaultCourt(gPngGame->court);
    initDefaultPaddleOne(gPngGame->paddleOne);
    initDefaultPaddleTwo(gPngGame->paddleTwo);
    gPngGame->isPlayerOneHuman = 1;
    if(isOnePlayer) {
 gPngGame->isPlayerTwoHuman = 0;
    } else {
 gPngGame->isPlayerTwoHuman = 1;
    }
}

variable_types: isOnePlayer int

variable_types: struct PONGGAME { struct PADDLE { int x; int y; int xVel; int yVel; int height; int width; int disabledCounter; unsigned char weight; } *paddleOne; struct PADDLE *paddleTwo; struct BALL { int x; int y; int xVel; int yVel; int height; int width; int disabledCounter; unsigned char weight; } *ball; struct COURT { int width; int height; int x; int y; int leftAccAreaX; int leftAccAreaWidth; int rightAccAreaX; int rightAccAreaWidth; } *court; int epsilon; int gravity; char useGravity; int pointsPlayerOne; int pointsPlayerTwo; int isPlayerOneHuman; int isPlayerTwoHuman; unsigned int hitCounter; enum GRAVITY_DIRECTION { noGravity=8, northGravity=2, northEastGravity=1, eastGravity=0, southEastGravity=7, southGravity=6, southWestGravity=5, westGravity=4, northWestGravity=3 } gravityDirection; int xGravity; int yGravity; } *

user_defined_types: struct PONGGAME { struct PADDLE *paddleOne; struct PADDLE *paddleTwo; struct BALL *ball; struct COURT *court; int epsilon; int gravity; char useGravity; int pointsPlayerOne; int pointsPlayerTwo; int isPlayerOneHuman; int isPlayerTwoHuman; unsigned int hitCounter; enum GRAVITY_DIRECTION gravityDirection; int xGravity; int yGravity; }