main

original_code:
int main( const int argc, const char *argv[] )
{
     fileparks_s *parksFile;
     struct
     {
          int left_line;
          int left_lc;
          int left_ctr;
          int ctr_cl;
          int ctr_left;
          int ctr_right;
          int ctr_rl;
          int right_ctr;
          int right_rc;
          int right_line;
     }
     totals = { 0 };
     struct
     {
          int left1;
          int left2;
          int left3;
          int left4;
          int center;
          int right4;
          int right3;
          int right2;
          int right1;
     }
     total_heights = { 0 };
     if ( argc < 2 )
     {
   printf( "Usage: %s <input file>\n", argv[0] );
   return 0;
     }
     if ( (parksFile = readParksFile( argv[1] )) == ((void *)0) )
     {
          printf( "Cannot load parks file." );
          return 1;
     }
     for ( int i = 0; i < 32; ++i )
     {
          coords_s *outfield = parksFile->park_details[i].outfield;
          totals.left_line += hyp( (short)word2int( outfield[0].x ), (short)word2int( outfield[0].y ) );
          totals.left_lc += hyp( (short)word2int( outfield[1].x ), (short)word2int( outfield[1].y ) );
          totals.left_ctr += hyp( (short)word2int( outfield[2].x ), (short)word2int( outfield[2].y ) );
          totals.ctr_cl += hyp( (short)word2int( outfield[3].x ), (short)word2int( outfield[3].y ) );
          totals.ctr_left += hyp( (short)word2int( outfield[4].x ), (short)word2int( outfield[4].y ) );
          totals.ctr_right += hyp( (short)word2int( outfield[5].x ), (short)word2int( outfield[5].y ) );
          totals.ctr_rl += hyp( (short)word2int( outfield[6].x ), (short)word2int( outfield[6].y ) );
          totals.right_ctr += hyp( (short)word2int( outfield[7].x ), (short)word2int( outfield[7].y ) );
          totals.right_rc += hyp( (short)word2int( outfield[8].x ), (short)word2int( outfield[8].y ) );
          totals.right_line += hyp( (short)word2int( outfield[9].x ), (short)word2int( outfield[9].y ) );
          heights_s *heights = &(parksFile->park_details[i].heights);
          total_heights.left1 += heights->left1[0];
          total_heights.left2 += heights->left2[0];
          total_heights.left3 += heights->left3[0];
          total_heights.left4 += heights->left4[0];
          total_heights.center += heights->center[0];
          total_heights.right4 += heights->right4[0];
          total_heights.right3 += heights->right3[0];
          total_heights.right2 += heights->right2[0];
          total_heights.right1 += heights->right1[0];
     }
     free( parksFile );
     printf( "   %2d   %2d   %2d   %2d   %2d   %2d   %2d   %2d   %2d\n",
             (int)round( (double)total_heights.left1 / 32.0 ),
             (int)round( (double)total_heights.left2 / 32.0 ),
             (int)round( (double)total_heights.left3 / 32.0 ),
             (int)round( (double)total_heights.left4 / 32.0 ),
             (int)round( (double)total_heights.center / 32.0 ),
             (int)round( (double)total_heights.right4 / 32.0 ),
             (int)round( (double)total_heights.right3 / 32.0 ),
             (int)round( (double)total_heights.right2 / 32.0 ),
             (int)round( (double)total_heights.right1 / 32.0 ) );
     printf( "%3d  %3d  %3d  %3d  %3d  %3d  %3d  %3d  %3d  %3d\n",
             (int)round( (double)totals.left_line / 32.0 ),
             (int)round( (double)totals.left_lc / 32.0 ),
             (int)round( (double)totals.left_ctr / 32.0 ),
             (int)round( (double)totals.ctr_cl / 32.0 ),
             (int)round( (double)totals.ctr_left / 32.0 ),
             (int)round( (double)totals.ctr_right / 32.0 ),
             (int)round( (double)totals.ctr_rl / 32.0 ),
             (int)round( (double)totals.right_ctr / 32.0 ),
             (int)round( (double)totals.right_rc / 32.0 ),
             (int)round( (double)totals.right_line / 32.0 ) );
     return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
     struct fileparks_s *parksFile;
     struct { int left_line; int left_lc; int left_ctr; int ctr_cl; int ctr_left; int ctr_right; int ctr_rl; int right_ctr; int right_rc; int right_line; } totals = { 0 };
     struct { int left1; int left2; int left3; int left4; int center; int right4; int right3; int right2; int right1; } total_heights = { 0 };
     if ( argc < 2 )
     {
   printf( "Usage: %s <input file>\n", argv[0] );
   return 0;
     }
     if ( (parksFile = readParksFile( argv[1] )) == ((void *)0) )
     {
          printf( "Cannot load parks file." );
          return 1;
     }
     for ( int i = 0; i < 32; ++i )
     {
          struct coords_s *outfield = parksFile->park_details[i].outfield;
          totals.left_line += hyp( (short)word2int( outfield[0].x ), (short)word2int( outfield[0].y ) );
          totals.left_lc += hyp( (short)word2int( outfield[1].x ), (short)word2int( outfield[1].y ) );
          totals.left_ctr += hyp( (short)word2int( outfield[2].x ), (short)word2int( outfield[2].y ) );
          totals.ctr_cl += hyp( (short)word2int( outfield[3].x ), (short)word2int( outfield[3].y ) );
          totals.ctr_left += hyp( (short)word2int( outfield[4].x ), (short)word2int( outfield[4].y ) );
          totals.ctr_right += hyp( (short)word2int( outfield[5].x ), (short)word2int( outfield[5].y ) );
          totals.ctr_rl += hyp( (short)word2int( outfield[6].x ), (short)word2int( outfield[6].y ) );
          totals.right_ctr += hyp( (short)word2int( outfield[7].x ), (short)word2int( outfield[7].y ) );
          totals.right_rc += hyp( (short)word2int( outfield[8].x ), (short)word2int( outfield[8].y ) );
          totals.right_line += hyp( (short)word2int( outfield[9].x ), (short)word2int( outfield[9].y ) );
          struct heights_s *heights = &(parksFile->park_details[i].heights);
          total_heights.left1 += heights->left1[0];
          total_heights.left2 += heights->left2[0];
          total_heights.left3 += heights->left3[0];
          total_heights.left4 += heights->left4[0];
          total_heights.center += heights->center[0];
          total_heights.right4 += heights->right4[0];
          total_heights.right3 += heights->right3[0];
          total_heights.right2 += heights->right2[0];
          total_heights.right1 += heights->right1[0];
     }
     free( parksFile );
     printf( "   %2d   %2d   %2d   %2d   %2d   %2d   %2d   %2d   %2d\n",
             (int)round( (double)total_heights.left1 / 32.0 ),
             (int)round( (double)total_heights.left2 / 32.0 ),
             (int)round( (double)total_heights.left3 / 32.0 ),
             (int)round( (double)total_heights.left4 / 32.0 ),
             (int)round( (double)total_heights.center / 32.0 ),
             (int)round( (double)total_heights.right4 / 32.0 ),
             (int)round( (double)total_heights.right3 / 32.0 ),
             (int)round( (double)total_heights.right2 / 32.0 ),
             (int)round( (double)total_heights.right1 / 32.0 ) );
     printf( "%3d  %3d  %3d  %3d  %3d  %3d  %3d  %3d  %3d  %3d\n",
             (int)round( (double)totals.left_line / 32.0 ),
             (int)round( (double)totals.left_lc / 32.0 ),
             (int)round( (double)totals.left_ctr / 32.0 ),
             (int)round( (double)totals.ctr_cl / 32.0 ),
             (int)round( (double)totals.ctr_left / 32.0 ),
             (int)round( (double)totals.ctr_right / 32.0 ),
             (int)round( (double)totals.ctr_rl / 32.0 ),
             (int)round( (double)totals.right_ctr / 32.0 ),
             (int)round( (double)totals.right_rc / 32.0 ),
             (int)round( (double)totals.right_line / 32.0 ) );
     return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: struct fileparks_s { unsigned char filler[52]; struct park_name_s { unsigned char text[16]; } park_names[32]; struct park_details_s { unsigned char details1[1]; unsigned char bleachers[1]; unsigned char details2[2]; struct distances_s { unsigned char left_line[2]; unsigned char left_center[2]; unsigned char center[2]; unsigned char right_center[2]; unsigned char right_line[2]; } distances; struct heights_s { unsigned char left1[1]; unsigned char left2[1]; unsigned char left3[1]; unsigned char left4[1]; unsigned char center[1]; unsigned char right4[1]; unsigned char right3[1]; unsigned char right2[1]; unsigned char right1[1]; } heights; unsigned char empty[1]; struct coords_s { char x[2]; char y[2]; } outfield[10]; struct coords_s infield1[8]; struct coords_s infield2[8]; } park_details[32]; } *

variable_types: struct coords_s { char x[2]; char y[2]; } *

variable_types: struct heights_s { unsigned char left1[1]; unsigned char left2[1]; unsigned char left3[1]; unsigned char left4[1]; unsigned char center[1]; unsigned char right4[1]; unsigned char right3[1]; unsigned char right2[1]; unsigned char right1[1]; } *

user_defined_types: struct fileparks_s { unsigned char filler[52]; struct park_name_s park_names[32]; struct park_details_s park_details[32]; }

user_defined_types: struct park_details_s { unsigned char details1[1]; unsigned char bleachers[1]; unsigned char details2[2]; struct distances_s distances; struct heights_s heights; unsigned char empty[1]; struct coords_s outfield[10]; struct coords_s infield1[8]; struct coords_s infield2[8]; }


repo: zjentohlauedy/MBA

decompiled_code:
char *setLongevity_ShouldSetBatterLongevity_GivenAPlayersFile()
{
int v0; // edx
char *result; // rax
char v2[89608]; // [rsp+0h] [rbp-15E08h] BYREF

memset(v2, 0, 0x15E00uLL);
strcpy(v2, "Name");
v2[47] = 80;
setLongevity(v2);
v0 = nibble((unsigned __int8)v2[50], 0LL);
result = 0LL;
if ( !v0 )
{
sprintf(
_unit_test_msgbuf__,
"\x1B[0;31mFailed: %s; expected to not be zero but was zero\x1B[0m",
"nibble( players_data[0].filestats.filebatting.ratings[2], n_Low )");
result = _unit_test_msgbuf__;
}
return result;
}

canonical_decompiled_code:
char *func0()
{
int v0; // edx
char *result; // rax
char v2[89608]; // [rsp+0h] [rbp-15E08h] BYREF

memset(v2, 0, 0x15E00uLL);
strcpy(v2, "Name");
v2[47] = 80;
setLongevity(v2);
v0 = nibble((unsigned __int8)v2[50], 0LL);
result = 0LL;
if ( !v0 )
{
sprintf(
_unit_test_msgbuf__,
"\x1B[0;31mFailed: %s; expected to not be zero but was zero\x1B[0m",
"nibble( players_data[0].filestats.filebatting.ratings[2], n_Low )");
result = _unit_test_msgbuf__;
}
return result;
}

original_code:
static char *setLongevity_ShouldSetBatterLongevity_GivenAPlayersFile()
{
     fileplayer_s players_data[(((25 * 8) * 2) * 2)] = { 0 };
     strcpy( players_data[0].last_name, "Name" );
     players_data[0].position[0] = 0x50;
     setLongevity( players_data );
     do { if ( (nibble( players_data[0].filestats.filebatting.ratings[2], n_Low )) == 0 ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected to not be zero but was zero\033[0m", "nibble( players_data[0].filestats.filebatting.ratings[2], n_Low )" ); return __unit_test_msgbuf__; } } while ( 0 );
     return ((void *)0);
}

canonical_original_code:
static char *setLongevity_ShouldSetBatterLongevity_GivenAPlayersFile()
{
     struct fileplayer_s players_data[-1] = { 0 };
     strcpy( players_data[0].last_name, "Name" );
     players_data[0].position[0] = 0x50;
     setLongevity( players_data );
     do { if ( (nibble( players_data[0].filestats.filebatting.ratings[2], n_Low )) == 0 ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected to not be zero but was zero\033[0m", "nibble( players_data[0].filestats.filebatting.ratings[2], n_Low )" ); return __unit_test_msgbuf__; } } while ( 0 );
     return ((void *)0);
}

variable_types: struct fileplayer_s { char last_name[10]; char first_name[8]; char last_phoen[14]; char first_phoen[12]; unsigned char real_avg[2]; unsigned char year[1]; unsigned char position[1]; union { struct filebatting_s { unsigned char ratings[4]; unsigned char real_games[1]; unsigned char real_runs[1]; unsigned char real_rbi[1]; unsigned char real_sb[1]; unsigned char real_cs[1]; unsigned char real_sh[1]; unsigned char vl_ab[2]; unsigned char vl_hits[2]; unsigned char vl_2b[1]; unsigned char vl_3b[1]; unsigned char vl_hr[1]; unsigned char vl_bb[1]; unsigned char vl_so[1]; unsigned char real_fa2[1]; unsigned char vr_ab[2]; unsigned char vr_hits[2]; unsigned char vr_2b[1]; unsigned char vr_3b[1]; unsigned char vr_hr[1]; unsigned char vr_bb[1]; unsigned char vr_so[1]; unsigned char real_err[1]; unsigned char real_po[2]; unsigned char real_as[2]; unsigned char injury_days[1]; unsigned char color[1]; } filebatting; struct filepitching_s { unsigned char ratings[2]; unsigned char real_wins[1]; unsigned char real_losses[1]; unsigned char real_games[1]; unsigned char real_starts[1]; unsigned char real_cg[1]; unsigned char real_saves[1]; unsigned char real_inn[2]; unsigned char vl_ab[2]; unsigned char vl_hits[2]; unsigned char vl_hr[1]; unsigned char vl_bb[1]; unsigned char vl_so[2]; unsigned char real_er[1]; unsigned char real_fa[1]; unsigned char vr_ab[2]; unsigned char vr_hits[2]; unsigned char vr_hr[1]; unsigned char vr_bb[1]; unsigned char vr_so[2]; unsigned char real_hb[1]; unsigned char real_balk[1]; unsigned char real_ab[1]; unsigned char real_hits[1]; unsigned char real_hr[1]; unsigned char real_sh[1]; unsigned char injury_days[1]; unsigned char color[1]; } filepitching; } filestats; struct acc_stats_s { union acc_stats_u { struct acc_pch_stats_s { unsigned char acc_wins[1]; unsigned char acc_losses[1]; unsigned char acc_starts[1]; unsigned char acc_saves[1]; unsigned char acc_innings[2]; unsigned char acc_hits[2]; unsigned char acc_er[2]; unsigned char acc_hr[1]; unsigned char acc_bb[1]; unsigned char acc_so[2]; } pitching; struct acc_bat_stats_s { unsigned char acc_ab[2]; unsigned char acc_hits[2]; unsigned char acc_2b[1]; unsigned char acc_3b[1]; unsigned char acc_hr[1]; unsigned char acc_bb[1]; unsigned char acc_so[1]; unsigned char acc_games[1]; unsigned char acc_runs[1]; unsigned char acc_rbi[1]; unsigned char acc_sb[1]; unsigned char acc_err[1]; } batting; struct acc_player_id_s { unsigned char player_id[2]; unsigned char checksum[1]; unsigned char filler[11]; } id_info; } action; union acc_stats_u simulated; } acc_stats; } [-1]

return_type: char *

user_defined_types: struct fileplayer_s { char last_name[10]; char first_name[8]; char last_phoen[14]; char first_phoen[12]; unsigned char real_avg[2]; unsigned char year[1]; unsigned char position[1]; union { struct filebatting_s filebatting; struct filepitching_s filepitching; } filestats; struct acc_stats_s acc_stats; }

user_defined_types: struct acc_stats_s { union acc_stats_u action; union acc_stats_u simulated; }

user_defined_types: union acc_stats_u { struct acc_pch_stats_s pitching; struct acc_bat_stats_s batting; struct acc_player_id_s id_info; }


buildIntoPlayer

original_code:
void buildIntoPlayer( player_s *player, const int player_id )
{
     player->player_id = player_id;
     player->skin_tone = (rand() % 2) + 1;
     player->handedness = (rand() % 3) + 1;
     player->player_type = (rand() % 2) + 1;
     player->rookie_season = (rand() % 25) + 1;
     player->longevity = (rand() % 10) + 1;
     sprintf( player->first_name, "Fname%d", player_id );
     sprintf( player->last_name, "Lname%d", player_id );
     sprintf( player->first_phoenetic, "Fphoen%d", player_id );
     sprintf( player->last_phoenetic, "Lphoen%d", player_id );
}

canonical_original_code:
void buildIntoPlayer(struct player_s *player, int player_id)
{
     player->player_id = player_id;
     player->skin_tone = (rand() % 2) + 1;
     player->handedness = (rand() % 3) + 1;
     player->player_type = (rand() % 2) + 1;
     player->rookie_season = (rand() % 25) + 1;
     player->longevity = (rand() % 10) + 1;
     sprintf( player->first_name, "Fname%d", player_id );
     sprintf( player->last_name, "Lname%d", player_id );
     sprintf( player->first_phoenetic, "Fphoen%d", player_id );
     sprintf( player->last_phoenetic, "Lphoen%d", player_id );
}

variable_types: struct player_s { int player_id; char first_name[-1]; char last_name[-1]; char first_phoenetic[-1]; char last_phoenetic[-1]; enum skin_tone_e { st_None=0, st_Light=1, st_Dark=2 } skin_tone; enum handedness_e { hnd_None=0, hnd_Right=1, hnd_Left=2, hnd_Switch=3 } handedness; enum playertype_e { pt_None=0, pt_Pitcher=1, pt_Batter=2 } player_type; int rookie_season; int longevity; struct player_accolade_s { int player_id; int season; enum accolade_e { acc_None=0, acc_All_Star=1, acc_World_Title=2, acc_League_Title=3, acc_Division_Title=4, acc_Best_Record=5, acc_World_Series_MVP=6, acc_All_Star_Champion=7, acc_All_Star_MVP=8 } accolade; } *accolades; union { struct pitcher_s { int player_id; int speed; int control; int bunt; int fatigue; struct pitcher_stats_s { int player_id; int season; enum season_phase_e { sp_None=0, sp_Regular=1, sp_Playoff=2, sp_Allstar=3 } season_phase; int wins; int losses; int games; int saves; struct innings_s { int innings; int outs; } innings; int hits; int earned_runs; int home_runs; int walks; int strike_outs; } *stats; struct pitcher_accolade_s { int player_id; int season; enum pitching_accolade_e { pacc_None=0, pacc_Pitcher_of_the_Year=1, pacc_Global_Pitcher_of_the_Year=2, pacc_World_Pitcher_of_the_Year=3, pacc_Atlantic_Pitcher_of_the_Year=4, pacc_North_Pitcher_of_the_Year=5, pacc_Pacific_Pitcher_of_the_Year=6, pacc_South_Pitcher_of_the_Year=7, pacc_Most_Wins=8, pacc_Best_Win_Loss_Ratio=9, pacc_Best_Win_Percentage=10, pacc_Best_Earned_Run_Average=11, pacc_Best_vs_Batting_Average=12, pacc_Most_Saves=13, pacc_Most_Strike_Outs=14, pacc_Most_Innings_per_Game=15, pacc_Best_Walks_Hits_Per_Inning=16, pacc_Most_Strike_Outs_per_Nine=17, pacc_Best_Home_Runs_per_Nine=18, pacc_Best_Efficiency=19, pacc_Pitching_Rookie_of_the_Year=20 } accolade; } *accolades; } *pitching; struct batter_s { int player_id; int power; int hit_n_run; int bunt; int running; int range; int arm; enum position_e { pos_None=0, pos_Catcher=1, pos_FirstBase=2, pos_SecondBase=3, pos_ThirdBase=4, pos_ShortStop=5, pos_LeftField=6, pos_CenterField=7, pos_RightField=8, pos_Infield=9, pos_Outfield=10 } primary_position; enum position_e { pos_None=0, pos_Catcher=1, pos_FirstBase=2, pos_SecondBase=3, pos_ThirdBase=4, pos_ShortStop=5, pos_LeftField=6, pos_CenterField=7, pos_RightField=8, pos_Infield=9, pos_Outfield=10 } secondary_position; struct batter_stats_s { int player_id; int season; enum season_phase_e { sp_None=0, sp_Regular=1, sp_Playoff=2, sp_Allstar=3 } season_phase; int games; int at_bats; int runs; int hits; int doubles; int triples; int home_runs; int runs_batted_in; int walks; int strike_outs; int steals; int errors; } *stats; struct batter_accolade_s { int player_id; int season; enum batting_accolade_e { bacc_None=0, bacc_Batter_of_the_Year=1, bacc_Global_Batter_of_the_Year=2, bacc_World_Batter_of_the_Year=3, bacc_Atlantic_Batter_of_the_Year=4, bacc_North_Batter_of_the_Year=5, bacc_Pacific_Batter_of_the_Year=6, bacc_South_Batter_of_the_Year=7, bacc_Best_Batting_Average=8, bacc_Most_Doubles=9, bacc_Most_Triples=10, bacc_Most_Home_Runs=11, bacc_Most_Runs=12, bacc_Most_Runs_Batted_In=13, bacc_Most_Stolen_Bases=14, bacc_Most_Walks=15, bacc_Best_Slugging_Average=16, bacc_Best_On_Base_Percentage=17, bacc_Best_Strike_Out_Average=18, bacc_Best_Runs_per_Game=19, bacc_Batting_Rookie_of_the_Year=20 } accolade; } *accolades; } *batting; } details; } *

return_type: void

user_defined_types: struct player_s { int player_id; char first_name[-1]; char last_name[-1]; char first_phoenetic[-1]; char last_phoenetic[-1]; enum skin_tone_e skin_tone; enum handedness_e handedness; enum playertype_e player_type; int rookie_season; int longevity; struct player_accolade_s *accolades; union { struct pitcher_s *pitching; struct batter_s *batting; } details; }

user_defined_types: struct player_accolade_s { int player_id; int season; enum accolade_e accolade; }

user_defined_types: struct pitcher_s { int player_id; int speed; int control; int bunt; int fatigue; struct pitcher_stats_s *stats; struct pitcher_accolade_s *accolades; }

user_defined_types: struct batter_s { int player_id; int power; int hit_n_run; int bunt; int running; int range; int arm; enum position_e primary_position; enum position_e secondary_position; struct batter_stats_s *stats; struct batter_accolade_s *accolades; }

user_defined_types: struct pitcher_stats_s { int player_id; int season; enum season_phase_e season_phase; int wins; int losses; int games; int saves; struct innings_s innings; int hits; int earned_runs; int home_runs; int walks; int strike_outs; }

user_defined_types: struct pitcher_accolade_s { int player_id; int season; enum pitching_accolade_e accolade; }

user_defined_types: struct batter_stats_s { int player_id; int season; enum season_phase_e season_phase; int games; int at_bats; int runs; int hits; int doubles; int triples; int home_runs; int runs_batted_in; int walks; int strike_outs; int steals; int errors; }

user_defined_types: struct batter_accolade_s { int player_id; int season; enum batting_accolade_e accolade; }


buildPlayer

decompiled_code:
void *__fastcall buildPlayer(unsigned int a1)
{
void *v1; // rbx

v1 = malloc(0x80uLL);
if ( v1 )
{
memset(v1, 0, 0x80uLL);
buildIntoPlayer((__int64)v1, a1);
}
return v1;
}

canonical_decompiled_code:
void *__fastcall func1(unsigned int a1)
{
void *v1; // rbx

v1 = malloc(0x80uLL);
if ( v1 )
{
memset(v1, 0, 0x80uLL);
func0((__int64)v1, a1);
}
return v1;
}

original_code:
player_s *buildPlayer( const int player_id )
{
     player_s *player = ((void *)0);
     if ( (player = malloc( sizeof(player_s) )) == ((void *)0) ) return ((void *)0);
     memset( player, '\0', sizeof(player_s) );
     buildIntoPlayer( player, player_id );
     return player;
}

canonical_original_code:
struct player_s *buildPlayer(int player_id)
{
     struct player_s *player = ((void *)0);
     if ( (player = malloc( sizeof(player_s) )) == ((void *)0) ) return ((void *)0);
     memset( player, '\0', sizeof(player_s) );
     buildIntoPlayer( player, player_id );
     return player;
}

return_type: struct player_s { int player_id; char first_name[-1]; char last_name[-1]; char first_phoenetic[-1]; char last_phoenetic[-1]; enum skin_tone_e { st_None=0, st_Light=1, st_Dark=2 } skin_tone; enum handedness_e { hnd_None=0, hnd_Right=1, hnd_Left=2, hnd_Switch=3 } handedness; enum playertype_e { pt_None=0, pt_Pitcher=1, pt_Batter=2 } player_type; int rookie_season; int longevity; struct player_accolade_s { int player_id; int season; enum accolade_e { acc_None=0, acc_All_Star=1, acc_World_Title=2, acc_League_Title=3, acc_Division_Title=4, acc_Best_Record=5, acc_World_Series_MVP=6, acc_All_Star_Champion=7, acc_All_Star_MVP=8 } accolade; } *accolades; union { struct pitcher_s { int player_id; int speed; int control; int bunt; int fatigue; struct pitcher_stats_s { int player_id; int season; enum season_phase_e { sp_None=0, sp_Regular=1, sp_Playoff=2, sp_Allstar=3 } season_phase; int wins; int losses; int games; int saves; struct innings_s { int innings; int outs; } innings; int hits; int earned_runs; int home_runs; int walks; int strike_outs; } *stats; struct pitcher_accolade_s { int player_id; int season; enum pitching_accolade_e { pacc_None=0, pacc_Pitcher_of_the_Year=1, pacc_Global_Pitcher_of_the_Year=2, pacc_World_Pitcher_of_the_Year=3, pacc_Atlantic_Pitcher_of_the_Year=4, pacc_North_Pitcher_of_the_Year=5, pacc_Pacific_Pitcher_of_the_Year=6, pacc_South_Pitcher_of_the_Year=7, pacc_Most_Wins=8, pacc_Best_Win_Loss_Ratio=9, pacc_Best_Win_Percentage=10, pacc_Best_Earned_Run_Average=11, pacc_Best_vs_Batting_Average=12, pacc_Most_Saves=13, pacc_Most_Strike_Outs=14, pacc_Most_Innings_per_Game=15, pacc_Best_Walks_Hits_Per_Inning=16, pacc_Most_Strike_Outs_per_Nine=17, pacc_Best_Home_Runs_per_Nine=18, pacc_Best_Efficiency=19, pacc_Pitching_Rookie_of_the_Year=20 } accolade; } *accolades; } *pitching; struct batter_s { int player_id; int power; int hit_n_run; int bunt; int running; int range; int arm; enum position_e { pos_None=0, pos_Catcher=1, pos_FirstBase=2, pos_SecondBase=3, pos_ThirdBase=4, pos_ShortStop=5, pos_LeftField=6, pos_CenterField=7, pos_RightField=8, pos_Infield=9, pos_Outfield=10 } primary_position; enum position_e { pos_None=0, pos_Catcher=1, pos_FirstBase=2, pos_SecondBase=3, pos_ThirdBase=4, pos_ShortStop=5, pos_LeftField=6, pos_CenterField=7, pos_RightField=8, pos_Infield=9, pos_Outfield=10 } secondary_position; struct batter_stats_s { int player_id; int season; enum season_phase_e { sp_None=0, sp_Regular=1, sp_Playoff=2, sp_Allstar=3 } season_phase; int games; int at_bats; int runs; int hits; int doubles; int triples; int home_runs; int runs_batted_in; int walks; int strike_outs; int steals; int errors; } *stats; struct batter_accolade_s { int player_id; int season; enum batting_accolade_e { bacc_None=0, bacc_Batter_of_the_Year=1, bacc_Global_Batter_of_the_Year=2, bacc_World_Batter_of_the_Year=3, bacc_Atlantic_Batter_of_the_Year=4, bacc_North_Batter_of_the_Year=5, bacc_Pacific_Batter_of_the_Year=6, bacc_South_Batter_of_the_Year=7, bacc_Best_Batting_Average=8, bacc_Most_Doubles=9, bacc_Most_Triples=10, bacc_Most_Home_Runs=11, bacc_Most_Runs=12, bacc_Most_Runs_Batted_In=13, bacc_Most_Stolen_Bases=14, bacc_Most_Walks=15, bacc_Best_Slugging_Average=16, bacc_Best_On_Base_Percentage=17, bacc_Best_Strike_Out_Average=18, bacc_Best_Runs_per_Game=19, bacc_Batting_Rookie_of_the_Year=20 } accolade; } *accolades; } *batting; } details; } *


mapSeasonPhase

decompiled_code:
__int64 __fastcall mapSeasonPhase(const char *a1)
{
size_t v1; // rdx
__int64 result; // rax
char v3; // al

v1 = strlen(a1);
result = 0LL;
if ( v1 <= 1 )
{
v3 = *a1;
if ( *a1 == 80 )
{
result = 2LL;
}
else if ( v3 == 82 )
{
result = 1LL;
}
else
{
result = 3 * (unsigned int)(v3 == 65);
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1)
{
size_t v1; // rdx
__int64 result; // rax
char v3; // al

v1 = strlen(a1);
result = 0LL;
if ( v1 <= 1 )
{
v3 = *a1;
if ( *a1 == 80 )
{
result = 2LL;
}
else if ( v3 == 82 )
{
result = 1LL;
}
else
{
result = 3 * (unsigned int)(v3 == 65);
}
}
return result;
}

original_code:
static season_phase_e mapSeasonPhase( char *phase )
{
     if ( strlen( phase ) > 1 ) return sp_None;
     switch ( *phase )
     {
     case 'A': return sp_Allstar;
     case 'R': return sp_Regular;
     case 'P': return sp_Playoff;
     }
     return sp_None;
}

canonical_original_code:
static enum season_phase_e mapSeasonPhase(char *phase)
{
     if ( strlen( phase ) > 1 ) return sp_None;
     switch ( *phase )
     {
     case 'A': return sp_Allstar;
     case 'R': return sp_Regular;
     case 'P': return sp_Playoff;
     }
     return sp_None;
}

variable_types:
phase
char *

return_type: enum season_phase_e { sp_None=0, sp_Regular=1, sp_Playoff=2, sp_Allstar=3 }


freeOrgData

decompiled_code:
void __fastcall freeOrgData(__int64 a1)
{
void *v2; // rdi
void *v3; // rdi
void *v4; // rdi

v2 = *(void **)a1;
if ( v2 )
free(v2);
v3 = *(void **)(a1 + 8);
if ( v3 )
free(v3);
v4 = *(void **)(a1 + 16);
if ( v4 )
free(v4);
if ( *(_QWORD *)(a1 + 24) )
freeRecords();
}

canonical_decompiled_code:
void __fastcall func1(__int64 a1)
{
void *v2; // rdi
void *v3; // rdi
void *v4; // rdi

v2 = *(void **)a1;
if ( v2 )
free(v2);
v3 = *(void **)(a1 + 8);
if ( v3 )
free(v3);
v4 = *(void **)(a1 + 16);
if ( v4 )
free(v4);
if ( *(_QWORD *)(a1 + 24) )
freeRecords();
}

original_code:
static void freeOrgData( org_data_s *org_data )
{
     if ( org_data->league_data != ((void *)0) ) free( org_data->league_data );
     if ( org_data->parks_data != ((void *)0) ) free( org_data->parks_data );
     if ( org_data->players_data != ((void *)0) ) free( org_data->players_data );
     if ( org_data->records != ((void *)0) ) freeRecords( org_data->records );
}

canonical_original_code:
static void freeOrgData(struct org_data_s *org_data)
{
     if ( org_data->league_data != ((void *)0) ) free( org_data->league_data );
     if ( org_data->parks_data != ((void *)0) ) free( org_data->parks_data );
     if ( org_data->players_data != ((void *)0) ) free( org_data->players_data );
     if ( org_data->records != ((void *)0) ) freeRecords( org_data->records );
}

variable_types: struct org_data_s { struct fileleagname_s { unsigned char header[52]; struct fileleague_s { unsigned char name[12]; } leagues[2]; struct filedivision_s { unsigned char name[12]; } divisions[-1]; struct fileteam_s { unsigned char name[11]; unsigned char stadium[1]; unsigned char color[1]; unsigned char wins[1]; unsigned char losses[1]; unsigned char team_id[1]; } teams[-1]; } *league_data; struct fileparks_s { unsigned char filler[52]; struct park_name_s { unsigned char text[16]; } park_names[32]; struct park_details_s { unsigned char details1[1]; unsigned char bleachers[1]; unsigned char details2[2]; struct distances_s { unsigned char left_line[2]; unsigned char left_center[2]; unsigned char center[2]; unsigned char right_center[2]; unsigned char right_line[2]; } distances; struct heights_s { unsigned char left1[1]; unsigned char left2[1]; unsigned char left3[1]; unsigned char left4[1]; unsigned char center[1]; unsigned char right4[1]; unsigned char right3[1]; unsigned char right2[1]; unsigned char right1[1]; } heights; unsigned char empty[1]; struct coords_s { char x[2]; char y[2]; } outfield[10]; struct coords_s infield1[8]; struct coords_s infield2[8]; } park_details[32]; } *parks_data; struct fileplayer_s { char last_name[10]; char first_name[8]; char last_phoen[14]; char first_phoen[12]; unsigned char real_avg[2]; unsigned char year[1]; unsigned char position[1]; union { struct filebatting_s { unsigned char ratings[4]; unsigned char real_games[1]; unsigned char real_runs[1]; unsigned char real_rbi[1]; unsigned char real_sb[1]; unsigned char real_cs[1]; unsigned char real_sh[1]; unsigned char vl_ab[2]; unsigned char vl_hits[2]; unsigned char vl_2b[1]; unsigned char vl_3b[1]; unsigned char vl_hr[1]; unsigned char vl_bb[1]; unsigned char vl_so[1]; unsigned char real_fa2[1]; unsigned char vr_ab[2]; unsigned char vr_hits[2]; unsigned char vr_2b[1]; unsigned char vr_3b[1]; unsigned char vr_hr[1]; unsigned char vr_bb[1]; unsigned char vr_so[1]; unsigned char real_err[1]; unsigned char real_po[2]; unsigned char real_as[2]; unsigned char injury_days[1]; unsigned char color[1]; } filebatting; struct filepitching_s { unsigned char ratings[2]; unsigned char real_wins[1]; unsigned char real_losses[1]; unsigned char real_games[1]; unsigned char real_starts[1]; unsigned char real_cg[1]; unsigned char real_saves[1]; unsigned char real_inn[2]; unsigned char vl_ab[2]; unsigned char vl_hits[2]; unsigned char vl_hr[1]; unsigned char vl_bb[1]; unsigned char vl_so[2]; unsigned char real_er[1]; unsigned char real_fa[1]; unsigned char vr_ab[2]; unsigned char vr_hits[2]; unsigned char vr_hr[1]; unsigned char vr_bb[1]; unsigned char vr_so[2]; unsigned char real_hb[1]; unsigned char real_balk[1]; unsigned char real_ab[1]; unsigned char real_hits[1]; unsigned char real_hr[1]; unsigned char real_sh[1]; unsigned char injury_days[1]; unsigned char color[1]; } filepitching; } filestats; struct acc_stats_s { union acc_stats_u { struct acc_pch_stats_s { unsigned char acc_wins[1]; unsigned char acc_losses[1]; unsigned char acc_starts[1]; unsigned char acc_saves[1]; unsigned char acc_innings[2]; unsigned char acc_hits[2]; unsigned char acc_er[2]; unsigned char acc_hr[1]; unsigned char acc_bb[1]; unsigned char acc_so[2]; } pitching; struct acc_bat_stats_s { unsigned char acc_ab[2]; unsigned char acc_hits[2]; unsigned char acc_2b[1]; unsigned char acc_3b[1]; unsigned char acc_hr[1]; unsigned char acc_bb[1]; unsigned char acc_so[1]; unsigned char acc_games[1]; unsigned char acc_runs[1]; unsigned char acc_rbi[1]; unsigned char acc_sb[1]; unsigned char acc_err[1]; } batting; struct acc_player_id_s { unsigned char player_id[2]; unsigned char checksum[1]; unsigned char filler[11]; } id_info; } action; union acc_stats_u simulated; } acc_stats; } *players_data; struct records_s { struct league_stats_s { int league_id; int season; enum season_phase_e { sp_None=0, sp_Regular=1, sp_Playoff=2, sp_Allstar=3 } season_phase; int wins; int losses; int home_wins; int home_losses; int road_wins; int road_losses; int runs_scored; int runs_allowed; } *leagues; struct division_stats_s { int division_id; int season; enum season_phase_e { sp_None=0, sp_Regular=1, sp_Playoff=2, sp_Allstar=3 } season_phase; int wins; int losses; int home_wins; int home_losses; int road_wins; int road_losses; int league_wins; int league_losses; int runs_scored; int runs_allowed; } *divisions; struct team_stats_s { int team_id; int season; enum season_phase_e { sp_None=0, sp_Regular=1, sp_Playoff=2, sp_Allstar=3 } season_phase; int wins; int losses; int home_wins; int home_losses; int road_wins; int road_losses; int division_wins; int division_losses; int league_wins; int league_losses; int runs_scored; int runs_allowed; } *teams; struct team_versus_stats_s { int team_id; int season; enum season_phase_e { sp_None=0, sp_Regular=1, sp_Playoff=2, sp_Allstar=3 } season_phase; int opponent; int wins; int losses; int runs_scored; int runs_allowed; } *versus[-1]; } *records; int season; enum season_phase_e { sp_None=0, sp_Regular=1, sp_Playoff=2, sp_Allstar=3 } season_phase; } *

user_defined_types: struct org_data_s { struct fileleagname_s *league_data; struct fileparks_s *parks_data; struct fileplayer_s *players_data; struct records_s *records; int season; enum season_phase_e season_phase; }

user_defined_types: struct fileleagname_s { unsigned char header[52]; struct fileleague_s leagues[2]; struct filedivision_s divisions[-1]; struct fileteam_s teams[-1]; }

user_defined_types: struct records_s { struct league_stats_s *leagues; struct division_stats_s *divisions; struct team_stats_s *teams; struct team_versus_stats_s *versus[-1]; }

user_defined_types: struct league_stats_s { int league_id; int season; enum season_phase_e season_phase; int wins; int losses; int home_wins; int home_losses; int road_wins; int road_losses; int runs_scored; int runs_allowed; }

user_defined_types: struct division_stats_s { int division_id; int season; enum season_phase_e season_phase; int wins; int losses; int home_wins; int home_losses; int road_wins; int road_losses; int league_wins; int league_losses; int runs_scored; int runs_allowed; }

user_defined_types: struct team_stats_s { int team_id; int season; enum season_phase_e season_phase; int wins; int losses; int home_wins; int home_losses; int road_wins; int road_losses; int division_wins; int division_losses; int league_wins; int league_losses; int runs_scored; int runs_allowed; }

user_defined_types: struct team_versus_stats_s { int team_id; int season; enum season_phase_e season_phase; int opponent; int wins; int losses; int runs_scored; int runs_allowed; }


decompiled_code:
int __fastcall print_results(__int64 a1)
{
int result; // eax
int *v2; // rbx
unsigned int i; // ebp
const char *v4; // rax
int v5; // er12
int v6; // er13
int v7; // er14
int v8; // eax
int v9; // ecx
__int64 v10; // r15
double v11; // [rsp+8h] [rbp-60h]
double v12; // [rsp+10h] [rbp-58h]
double v13; // [rsp+18h] [rbp-50h]
double v14; // [rsp+20h] [rbp-48h]
double v15; // [rsp+28h] [rbp-40h]

result = puts("Pos # G PO(/Game) AS(/Game) E AVG");
v2 = (int *)(a1 + 20);
for ( i = 1; i != 16; ++i )
{
v5 = *v2;
if ( *v2 )
{
v6 = v2[2];
v7 = v2[3];
v8 = v2[4];
v9 = v6 + v7 + v8;
v10 = 0LL;
if ( v9 > 0 )
v10 = (unsigned int)(int)((float)((float)(v6 + v7) / (float)v9) * 1000.0);
v13 = round((double)v8 / (double)v5);
v12 = (double)v2[1];
v14 = round((double)v7 / (double)v5);
v15 = round((double)v6 / (double)v5);
v11 = round(v12 / (double)v5);
v4 = (const char *)positionName(i);
result = printf(
"%2s: %2d %3d %4d(%5.2f) %3d(%5.2f) %2d .%03d\n",
v4,
(unsigned int)v5,
(unsigned int)(int)v11,
(unsigned int)(int)v15,
(double)v6 / v12,
(unsigned int)(int)v14,
(double)v7 / v12,
(unsigned int)(int)v13,
v10);
}
v2 += 5;
}
return result;
}

canonical_decompiled_code:
int __fastcall func0(__int64 a1)
{
int result; // eax
int *v2; // rbx
unsigned int i; // ebp
const char *v4; // rax
int v5; // er12
int v6; // er13
int v7; // er14
int v8; // eax
int v9; // ecx
__int64 v10; // r15
double v11; // [rsp+8h] [rbp-60h]
double v12; // [rsp+10h] [rbp-58h]
double v13; // [rsp+18h] [rbp-50h]
double v14; // [rsp+20h] [rbp-48h]
double v15; // [rsp+28h] [rbp-40h]

result = puts("Pos # G PO(/Game) AS(/Game) E AVG");
v2 = (int *)(a1 + 20);
for ( i = 1; i != 16; ++i )
{
v5 = *v2;
if ( *v2 )
{
v6 = v2[2];
v7 = v2[3];
v8 = v2[4];
v9 = v6 + v7 + v8;
v10 = 0LL;
if ( v9 > 0 )
v10 = (unsigned int)(int)((float)((float)(v6 + v7) / (float)v9) * 1000.0);
v13 = round((double)v8 / (double)v5);
v12 = (double)v2[1];
v14 = round((double)v7 / (double)v5);
v15 = round((double)v6 / (double)v5);
v11 = round(v12 / (double)v5);
v4 = (const char *)positionName(i);
result = printf(
"%2s: %2d %3d %4d(%5.2f) %3d(%5.2f) %2d .%03d\n",
v4,
(unsigned int)v5,
(unsigned int)(int)v11,
(unsigned int)(int)v15,
(double)v6 / v12,
(unsigned int)(int)v14,
(double)v7 / v12,
(unsigned int)(int)v13,
v10);
}
v2 += 5;
}
return result;
}

original_code:
static void print_results( const fielding_s *results )
{
     printf( "Pos   #   G   PO(/Game)   AS(/Game)   E   AVG\n" );
     for ( int i = 1; i < 16; ++i )
     {
          const fielding_s *f = &results[i];
   if ( f->count > 0 )
   {
               int total = f->put_outs + f->assists + f->errors;
        printf( "%2s:  %2d %3d %4d(%5.2f)  %3d(%5.2f)  %2d  .%03d\n",
         positionName( i ),
         f->count,
                       (int)round((double)f->games / (double)f->count),
         (int)round((double)f->put_outs / (double)f->count),
                       (double)f->put_outs / (double)f->games,
         (int)round((double)f->assists / (double)f->count),
                       (double)f->assists / (double)f->games,
         (int)round((double)f->errors / (double)f->count),
         total > 0 ? (int)((float)(f->put_outs + f->assists) / (float)(total) * 1000.0) : 0
      );
   }
     }
}

canonical_original_code:
static void print_results(struct fielding_s *results)
{
     printf( "Pos   #   G   PO(/Game)   AS(/Game)   E   AVG\n" );
     for ( int i = 1; i < 16; ++i )
     {
          struct fielding_s *f = &results[i];
   if ( f->count > 0 )
   {
               int total = f->put_outs + f->assists + f->errors;
        printf( "%2s:  %2d %3d %4d(%5.2f)  %3d(%5.2f)  %2d  .%03d\n",
         positionName( i ),
         f->count,
                       (int)round((double)f->games / (double)f->count),
         (int)round((double)f->put_outs / (double)f->count),
                       (double)f->put_outs / (double)f->games,
         (int)round((double)f->assists / (double)f->count),
                       (double)f->assists / (double)f->games,
         (int)round((double)f->errors / (double)f->count),
         total > 0 ? (int)((float)(f->put_outs + f->assists) / (float)(total) * 1000.0) : 0
      );
   }
     }
}

variable_types: struct fielding_s { unsigned int count; unsigned int games; unsigned int put_outs; unsigned int assists; unsigned int errors; } *

variable_types: i int

variable_types: total int


main

canonical_name: main

original_code:
int main( const int argc, const char *argv[] )
{
     fielding_s totals[16] = { 0 };
     fielding_s maxpo[16] = { 0 };
     fielding_s maxas[16] = { 0 };
     fielding_s minpo[16] = { 0 };
     fielding_s minas[16] = { 0 };
     fielding_s maxer[16] = { 0 };
     fileplayer_s *playersFile;
     int i;
     if ( argc < 2 )
     {
   printf( "Must supply filename.\n" );
   return 0;
     }
     if ( (playersFile = readPlayersFile( argv[1] )) == ((void *)0) )
     {
          printf( "Cannot load players file." );
          return 1;
     }
     for ( i = 0; i < (((25 * 8) * 2) * 2); ++i )
     {
   if ( playersFile[i].last_name[0] == '\0' ) continue;
   unsigned int pos = playersFile[i].position[0]>>4;
   if ( pos == pos_Pitcher ) continue;
          struct batting_s *batting = &(playersFile[i].filestats.filebatting);
          int ab = word2int( batting->vl_ab ) + word2int( batting->vr_ab );
          if ( ab < 300 ) continue;
          unsigned int g = batting->real_games[0];
          unsigned int po = (batting->real_po[0]<<8) + batting->real_po[1];
          unsigned int as = (batting->real_as[0]<<8) + batting->real_as[1];
          unsigned int err = batting->real_err[0];
          totals[pos].count++;
          totals[pos].games += g;
          totals[pos].put_outs += po;
          totals[pos].assists += as;
          totals[pos].errors += err;
          if ( maxpo[pos].put_outs < po )
          {
               maxpo[pos].count = 1;
               maxpo[pos].games = g;
               maxpo[pos].put_outs = po;
               maxpo[pos].assists = as;
               maxpo[pos].errors = err;
          }
          if ( maxas[pos].assists < as )
          {
               maxas[pos].count = 1;
               maxas[pos].games = g;
               maxas[pos].put_outs = po;
               maxas[pos].assists = as;
               maxas[pos].errors = err;
          }
          if ( minpo[pos].put_outs == 0 || minpo[pos].put_outs > po )
          {
               minpo[pos].count = 1;
               minpo[pos].games = g;
               minpo[pos].put_outs = po;
               minpo[pos].assists = as;
               minpo[pos].errors = err;
          }
          if ( minas[pos].assists == 0 || minas[pos].assists > as )
          {
               minas[pos].count = 1;
               minas[pos].games = g;
               minas[pos].put_outs = po;
               minas[pos].assists = as;
               minas[pos].errors = err;
          }
          if ( maxer[pos].errors < err )
          {
               maxer[pos].count = 1;
               maxer[pos].games = g;
               maxer[pos].put_outs = po;
               maxer[pos].assists = as;
               maxer[pos].errors = err;
          }
     }
     free( playersFile );
     printf( "Averages:\n" );
     print_results( totals );
     printf( "\n" );
     printf( "Max Put Outs:\n" );
     print_results( maxpo );
     printf( "\n" );
     printf( "Min Put Outs:\n" );
     print_results( minpo );
     printf( "\n" );
     printf( "Max Assists:\n" );
     print_results( maxas );
     printf( "\n" );
     printf( "Min Assists:\n" );
     print_results( minas );
     printf( "\n" );
     printf( "Max Errors:\n" );
     print_results( maxer );
     printf( "\n" );
     return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
     struct fielding_s totals[16] = { 0 };
     struct fielding_s maxpo[16] = { 0 };
     struct fielding_s maxas[16] = { 0 };
     struct fielding_s minpo[16] = { 0 };
     struct fielding_s minas[16] = { 0 };
     struct fielding_s maxer[16] = { 0 };
     struct fileplayer_s *playersFile;
     int i;
     if ( argc < 2 )
     {
   printf( "Must supply filename.\n" );
   return 0;
     }
     if ( (playersFile = readPlayersFile( argv[1] )) == ((void *)0) )
     {
          printf( "Cannot load players file." );
          return 1;
     }
     for ( i = 0; i < (((25 * 8) * 2) * 2); ++i )
     {
   if ( playersFile[i].last_name[0] == '\0' ) continue;
   unsigned int pos = playersFile[i].position[0]>>4;
   if ( pos == pos_Pitcher ) continue;
          struct batting_s *batting = &(playersFile[i].filestats.filebatting);
          int ab = word2int( batting->vl_ab ) + word2int( batting->vr_ab );
          if ( ab < 300 ) continue;
          unsigned int g = batting->real_games[0];
          unsigned int po = (batting->real_po[0]<<8) + batting->real_po[1];
          unsigned int as = (batting->real_as[0]<<8) + batting->real_as[1];
          unsigned int err = batting->real_err[0];
          totals[pos].count++;
          totals[pos].games += g;
          totals[pos].put_outs += po;
          totals[pos].assists += as;
          totals[pos].errors += err;
          if ( maxpo[pos].put_outs < po )
          {
               maxpo[pos].count = 1;
               maxpo[pos].games = g;
               maxpo[pos].put_outs = po;
               maxpo[pos].assists = as;
               maxpo[pos].errors = err;
          }
          if ( maxas[pos].assists < as )
          {
               maxas[pos].count = 1;
               maxas[pos].games = g;
               maxas[pos].put_outs = po;
               maxas[pos].assists = as;
               maxas[pos].errors = err;
          }
          if ( minpo[pos].put_outs == 0 || minpo[pos].put_outs > po )
          {
               minpo[pos].count = 1;
               minpo[pos].games = g;
               minpo[pos].put_outs = po;
               minpo[pos].assists = as;
               minpo[pos].errors = err;
          }
          if ( minas[pos].assists == 0 || minas[pos].assists > as )
          {
               minas[pos].count = 1;
               minas[pos].games = g;
               minas[pos].put_outs = po;
               minas[pos].assists = as;
               minas[pos].errors = err;
          }
          if ( maxer[pos].errors < err )
          {
               maxer[pos].count = 1;
               maxer[pos].games = g;
               maxer[pos].put_outs = po;
               maxer[pos].assists = as;
               maxer[pos].errors = err;
          }
     }
     free( playersFile );
     printf( "Averages:\n" );
     print_results( totals );
     printf( "\n" );
     printf( "Max Put Outs:\n" );
     print_results( maxpo );
     printf( "\n" );
     printf( "Min Put Outs:\n" );
     print_results( minpo );
     printf( "\n" );
     printf( "Max Assists:\n" );
     print_results( maxas );
     printf( "\n" );
     printf( "Min Assists:\n" );
     print_results( minas );
     printf( "\n" );
     printf( "Max Errors:\n" );
     print_results( maxer );
     printf( "\n" );
     return 0;
}

variable_types: struct fielding_s { unsigned int count; unsigned int games; unsigned int put_outs; unsigned int assists; unsigned int errors; } [16]

variable_types: struct fileplayer_s { char last_name[10]; char first_name[8]; char last_phoen[14]; char first_phoen[12]; unsigned char real_avg[2]; unsigned char year[1]; unsigned char position[1]; union { struct batting_s { unsigned char ratings[4]; unsigned char real_games[1]; unsigned char real_runs[1]; unsigned char real_rbi[1]; unsigned char real_sb[1]; unsigned char real_cs[1]; unsigned char real_sh[1]; unsigned char vl_ab[2]; unsigned char vl_hits[2]; unsigned char vl_2b[1]; unsigned char vl_3b[1]; unsigned char vl_hr[1]; unsigned char vl_bb[1]; unsigned char vl_so[1]; unsigned char real_fa2[1]; unsigned char vr_ab[2]; unsigned char vr_hits[2]; unsigned char vr_2b[1]; unsigned char vr_3b[1]; unsigned char vr_hr[1]; unsigned char vr_bb[1]; unsigned char vr_so[1]; unsigned char real_err[1]; unsigned char real_po[2]; unsigned char real_as[2]; unsigned char injury_days[1]; unsigned char color[1]; struct acc_bat_stats_s { unsigned char acc_ab[2]; unsigned char acc_hits[2]; unsigned char acc_2b[1]; unsigned char acc_3b[1]; unsigned char acc_hr[1]; unsigned char acc_bb[1]; unsigned char acc_so[1]; unsigned char acc_games[1]; unsigned char acc_runs[1]; unsigned char acc_rbi[1]; unsigned char acc_sb[1]; unsigned char acc_err[1]; } action; struct acc_bat_stats_s simulated; } filebatting; struct pitching_s { unsigned char ratings[2]; unsigned char real_wins[1]; unsigned char real_losses[1]; unsigned char real_games[1]; unsigned char real_starts[1]; unsigned char real_cg[1]; unsigned char real_saves[1]; unsigned char real_inn[2]; unsigned char vl_ab[2]; unsigned char vl_hits[2]; unsigned char vl_hr[1]; unsigned char vl_bb[1]; unsigned char vl_so[2]; unsigned char real_er[1]; unsigned char real_fa[1]; unsigned char vr_ab[2]; unsigned char vr_hits[2]; unsigned char vr_hr[1]; unsigned char vr_bb[1]; unsigned char vr_so[2]; unsigned char real_hb[1]; unsigned char real_balk[1]; unsigned char real_ab[1]; unsigned char real_hits[1]; unsigned char real_hr[1]; unsigned char real_sh[1]; unsigned char injury_days[1]; unsigned char color[1]; struct acc_pch_stats_s { unsigned char acc_wins[1]; unsigned char acc_losses[1]; unsigned char acc_starts[1]; unsigned char acc_saves[1]; unsigned char acc_innings[2]; unsigned char acc_hits[2]; unsigned char acc_er[2]; unsigned char acc_hr[1]; unsigned char acc_bb[1]; unsigned char acc_so[2]; } action; struct acc_pch_stats_s simulated; } filepitching; } filestats; } *

variable_types:
pos
unsigned int

variable_types: struct batting_s { unsigned char ratings[4]; unsigned char real_games[1]; unsigned char real_runs[1]; unsigned char real_rbi[1]; unsigned char real_sb[1]; unsigned char real_cs[1]; unsigned char real_sh[1]; unsigned char vl_ab[2]; unsigned char vl_hits[2]; unsigned char vl_2b[1]; unsigned char vl_3b[1]; unsigned char vl_hr[1]; unsigned char vl_bb[1]; unsigned char vl_so[1]; unsigned char real_fa2[1]; unsigned char vr_ab[2]; unsigned char vr_hits[2]; unsigned char vr_2b[1]; unsigned char vr_3b[1]; unsigned char vr_hr[1]; unsigned char vr_bb[1]; unsigned char vr_so[1]; unsigned char real_err[1]; unsigned char real_po[2]; unsigned char real_as[2]; unsigned char injury_days[1]; unsigned char color[1]; struct acc_bat_stats_s { unsigned char acc_ab[2]; unsigned char acc_hits[2]; unsigned char acc_2b[1]; unsigned char acc_3b[1]; unsigned char acc_hr[1]; unsigned char acc_bb[1]; unsigned char acc_so[1]; unsigned char acc_games[1]; unsigned char acc_runs[1]; unsigned char acc_rbi[1]; unsigned char acc_sb[1]; unsigned char acc_err[1]; } action; struct acc_bat_stats_s simulated; } *

variable_types: ab int

variable_types:
g
unsigned int

variable_types:
po
unsigned int

variable_types:
as
unsigned int

variable_types:
err
unsigned int

return_type: int

user_defined_types: struct fileplayer_s { char last_name[10]; char first_name[8]; char last_phoen[14]; char first_phoen[12]; unsigned char real_avg[2]; unsigned char year[1]; unsigned char position[1]; union { struct batting_s filebatting; struct pitching_s filepitching; } filestats; }

user_defined_types: struct batting_s { unsigned char ratings[4]; unsigned char real_games[1]; unsigned char real_runs[1]; unsigned char real_rbi[1]; unsigned char real_sb[1]; unsigned char real_cs[1]; unsigned char real_sh[1]; unsigned char vl_ab[2]; unsigned char vl_hits[2]; unsigned char vl_2b[1]; unsigned char vl_3b[1]; unsigned char vl_hr[1]; unsigned char vl_bb[1]; unsigned char vl_so[1]; unsigned char real_fa2[1]; unsigned char vr_ab[2]; unsigned char vr_hits[2]; unsigned char vr_2b[1]; unsigned char vr_3b[1]; unsigned char vr_hr[1]; unsigned char vr_bb[1]; unsigned char vr_so[1]; unsigned char real_err[1]; unsigned char real_po[2]; unsigned char real_as[2]; unsigned char injury_days[1]; unsigned char color[1]; struct acc_bat_stats_s action; struct acc_bat_stats_s simulated; }

user_defined_types: struct pitching_s { unsigned char ratings[2]; unsigned char real_wins[1]; unsigned char real_losses[1]; unsigned char real_games[1]; unsigned char real_starts[1]; unsigned char real_cg[1]; unsigned char real_saves[1]; unsigned char real_inn[2]; unsigned char vl_ab[2]; unsigned char vl_hits[2]; unsigned char vl_hr[1]; unsigned char vl_bb[1]; unsigned char vl_so[2]; unsigned char real_er[1]; unsigned char real_fa[1]; unsigned char vr_ab[2]; unsigned char vr_hits[2]; unsigned char vr_hr[1]; unsigned char vr_bb[1]; unsigned char vr_so[2]; unsigned char real_hb[1]; unsigned char real_balk[1]; unsigned char real_ab[1]; unsigned char real_hits[1]; unsigned char real_hr[1]; unsigned char real_sh[1]; unsigned char injury_days[1]; unsigned char color[1]; struct acc_pch_stats_s action; struct acc_pch_stats_s simulated; }


decompiled_code:
char *genPlayerIds_ShouldReturnTrueIfSuccessful_GivenAPlayersFile()
{
__int64 v0; // r8
char *result; // rax
_BYTE v2[89608]; // [rsp+0h] [rbp-15E08h] BYREF

memset(v2, 0, 0x15E00uLL);
v0 = (unsigned int)genPlayerIds(v2);
result = 0LL;
if ( (_DWORD)v0 != 1 )
{
sprintf(
_unit_test_msgbuf__,
"\x1B[0;31mFailed: %s; expected: %d, actual: %d\x1B[0m",
"genPlayerIds( players_file )",
1LL,
v0);
result = _unit_test_msgbuf__;
}
return result;
}

canonical_decompiled_code:
char *func0()
{
__int64 v0; // r8
char *result; // rax
_BYTE v2[89608]; // [rsp+0h] [rbp-15E08h] BYREF

memset(v2, 0, 0x15E00uLL);
v0 = (unsigned int)genPlayerIds(v2);
result = 0LL;
if ( (_DWORD)v0 != 1 )
{
sprintf(
_unit_test_msgbuf__,
"\x1B[0;31mFailed: %s; expected: %d, actual: %d\x1B[0m",
"genPlayerIds( players_file )",
1LL,
v0);
result = _unit_test_msgbuf__;
}
return result;
}

original_code:
static char *genPlayerIds_ShouldReturnTrueIfSuccessful_GivenAPlayersFile()
{
     fileplayer_s players_file[(((25 * 8) * 2) * 2)] = { 0 };
     do { int __expected__ = (bl_True); int __actual__ = (genPlayerIds( players_file )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "genPlayerIds( players_file )", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     return ((void *)0);
}

canonical_original_code:
static char *genPlayerIds_ShouldReturnTrueIfSuccessful_GivenAPlayersFile()
{
     struct fileplayer_s players_file[-1] = { 0 };
     do { int __expected__ = (bl_True); int __actual__ = (genPlayerIds( players_file )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "genPlayerIds( players_file )", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     return ((void *)0);
}

user_defined_types: struct fileplayer_s { char last_name[10]; char first_name[8]; char last_phoen[14]; char first_phoen[12]; unsigned char real_avg[2]; unsigned char year[1]; unsigned char position[1]; union { struct filebatting_s filebatting; struct filepitching_s filepitching; } filestats; struct acc_stats_s acc_stats; }

user_defined_types: struct acc_stats_s { union acc_stats_u action; union acc_stats_u simulated; }

user_defined_types: struct filebatting_s { unsigned char ratings[4]; unsigned char real_games[1]; unsigned char real_runs[1]; unsigned char real_rbi[1]; unsigned char real_sb[1]; unsigned char real_cs[1]; unsigned char real_sh[1]; unsigned char vl_ab[2]; unsigned char vl_hits[2]; unsigned char vl_2b[1]; unsigned char vl_3b[1]; unsigned char vl_hr[1]; unsigned char vl_bb[1]; unsigned char vl_so[1]; unsigned char real_fa2[1]; unsigned char vr_ab[2]; unsigned char vr_hits[2]; unsigned char vr_2b[1]; unsigned char vr_3b[1]; unsigned char vr_hr[1]; unsigned char vr_bb[1]; unsigned char vr_so[1]; unsigned char real_err[1]; unsigned char real_po[2]; unsigned char real_as[2]; unsigned char injury_days[1]; unsigned char color[1]; }

user_defined_types: struct filepitching_s { unsigned char ratings[2]; unsigned char real_wins[1]; unsigned char real_losses[1]; unsigned char real_games[1]; unsigned char real_starts[1]; unsigned char real_cg[1]; unsigned char real_saves[1]; unsigned char real_inn[2]; unsigned char vl_ab[2]; unsigned char vl_hits[2]; unsigned char vl_hr[1]; unsigned char vl_bb[1]; unsigned char vl_so[2]; unsigned char real_er[1]; unsigned char real_fa[1]; unsigned char vr_ab[2]; unsigned char vr_hits[2]; unsigned char vr_hr[1]; unsigned char vr_bb[1]; unsigned char vr_so[2]; unsigned char real_hb[1]; unsigned char real_balk[1]; unsigned char real_ab[1]; unsigned char real_hits[1]; unsigned char real_hr[1]; unsigned char real_sh[1]; unsigned char injury_days[1]; unsigned char color[1]; }

user_defined_types: union acc_stats_u { struct acc_pch_stats_s pitching; struct acc_bat_stats_s batting; struct acc_player_id_s id_info; }

user_defined_types: struct acc_pch_stats_s { unsigned char acc_wins[1]; unsigned char acc_losses[1]; unsigned char acc_starts[1]; unsigned char acc_saves[1]; unsigned char acc_innings[2]; unsigned char acc_hits[2]; unsigned char acc_er[2]; unsigned char acc_hr[1]; unsigned char acc_bb[1]; unsigned char acc_so[2]; }

user_defined_types: struct acc_bat_stats_s { unsigned char acc_ab[2]; unsigned char acc_hits[2]; unsigned char acc_2b[1]; unsigned char acc_3b[1]; unsigned char acc_hr[1]; unsigned char acc_bb[1]; unsigned char acc_so[1]; unsigned char acc_games[1]; unsigned char acc_runs[1]; unsigned char acc_rbi[1]; unsigned char acc_sb[1]; unsigned char acc_err[1]; }

user_defined_types: struct acc_player_id_s { unsigned char player_id[2]; unsigned char checksum[1]; unsigned char filler[11]; }


decompiled_code:
char *genPlayerIds_ShouldReturnFalseIfDataAlreadyExistsInPlayerIdField_GivenAPlayersFile()
{
__int64 v0; // r8
char *result; // rax
char v2[89608]; // [rsp+0h] [rbp-15E08h] BYREF

memset(v2, 0, 0x15E00uLL);
strcpy(v2, "Test");
v2[84] = 1;
v0 = (unsigned int)genPlayerIds(v2);
result = 0LL;
if ( (_DWORD)v0 )
{
sprintf(
_unit_test_msgbuf__,
"\x1B[0;31mFailed: %s; expected: %d, actual: %d\x1B[0m",
"genPlayerIds( players_file )",
0LL,
v0);
result = _unit_test_msgbuf__;
}
return result;
}

canonical_decompiled_code:
char *func1()
{
__int64 v0; // r8
char *result; // rax
char v2[89608]; // [rsp+0h] [rbp-15E08h] BYREF

memset(v2, 0, 0x15E00uLL);
strcpy(v2, "Test");
v2[84] = 1;
v0 = (unsigned int)genPlayerIds(v2);
result = 0LL;
if ( (_DWORD)v0 )
{
sprintf(
_unit_test_msgbuf__,
"\x1B[0;31mFailed: %s; expected: %d, actual: %d\x1B[0m",
"genPlayerIds( players_file )",
0LL,
v0);
result = _unit_test_msgbuf__;
}
return result;
}

original_code:
static char *genPlayerIds_ShouldReturnFalseIfDataAlreadyExistsInPlayerIdField_GivenAPlayersFile()
{
     fileplayer_s players_file[(((25 * 8) * 2) * 2)] = { 0 };
     strcpy( players_file[0].last_name, "Test" );
     players_file[0].acc_stats.action.pitching.acc_wins[0] = 1;
     do { int __expected__ = (bl_False); int __actual__ = (genPlayerIds( players_file )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "genPlayerIds( players_file )", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     return ((void *)0);
}

canonical_original_code:
static char *genPlayerIds_ShouldReturnFalseIfDataAlreadyExistsInPlayerIdField_GivenAPlayersFile()
{
     struct fileplayer_s players_file[-1] = { 0 };
     strcpy( players_file[0].last_name, "Test" );
     players_file[0].acc_stats.action.pitching.acc_wins[0] = 1;
     do { int __expected__ = (bl_False); int __actual__ = (genPlayerIds( players_file )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "genPlayerIds( players_file )", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     return ((void *)0);
}


decompiled_code:
char *genPlayerIds_ShouldSetThePlayerIdsOnPlayers_GivenAPlayersFile()
{
__int64 v0; // rbp
__int64 v1; // r8
int v2; // eax
unsigned int v3; // ebx
char *result; // rax

v0 = buildFilePlayersWithoutIds();
v1 = (unsigned int)genPlayerIds(v0);
v2 = 0;
if ( (_DWORD)v1 == 1 )
{
while ( 1 )
{
v3 = v2 + 1;
v2 = getPlayerId(v0 + 112LL * v2);
if ( v3 != v2 )
break;
if ( v2 > 799 )
return 0LL;
}
sprintf(
_unit_test_msgbuf__,
"\x1B[0;31mFailed: %s; expected: %d, actual: %d\x1B[0m",
"getPlayerId( &players_file[i] )",
v3,
(unsigned int)v2);
result = _unit_test_msgbuf__;
}
else
{
sprintf(
_unit_test_msgbuf__,
"\x1B[0;31mFailed: %s; expected: %d, actual: %d\x1B[0m",
"genPlayerIds( players_file )",
1LL,
v1);
result = _unit_test_msgbuf__;
}
return result;
}

canonical_decompiled_code:
char *func2()
{
__int64 v0; // rbp
__int64 v1; // r8
int v2; // eax
unsigned int v3; // ebx
char *result; // rax

v0 = buildFilePlayersWithoutIds();
v1 = (unsigned int)genPlayerIds(v0);
v2 = 0;
if ( (_DWORD)v1 == 1 )
{
while ( 1 )
{
v3 = v2 + 1;
v2 = getPlayerId(v0 + 112LL * v2);
if ( v3 != v2 )
break;
if ( v2 > 799 )
return 0LL;
}
sprintf(
_unit_test_msgbuf__,
"\x1B[0;31mFailed: %s; expected: %d, actual: %d\x1B[0m",
"getPlayerId( &players_file[i] )",
v3,
(unsigned int)v2);
result = _unit_test_msgbuf__;
}
else
{
sprintf(
_unit_test_msgbuf__,
"\x1B[0;31mFailed: %s; expected: %d, actual: %d\x1B[0m",
"genPlayerIds( players_file )",
1LL,
v1);
result = _unit_test_msgbuf__;
}
return result;
}

original_code:
static char *genPlayerIds_ShouldSetThePlayerIdsOnPlayers_GivenAPlayersFile()
{
     fileplayer_s *players_file = buildFilePlayersWithoutIds();
     do { int __expected__ = (bl_True); int __actual__ = (genPlayerIds( players_file )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "genPlayerIds( players_file )", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     for ( int i = 0; i < (((25 * 8) * 2) * 2); ++i )
     {
          do { int __expected__ = (i + 1); int __actual__ = (getPlayerId( &players_file[i] )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "getPlayerId( &players_file[i] )", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     }
     return ((void *)0);
}

canonical_original_code:
static char *genPlayerIds_ShouldSetThePlayerIdsOnPlayers_GivenAPlayersFile()
{
     struct fileplayer_s *players_file = buildFilePlayersWithoutIds();
     do { int __expected__ = (bl_True); int __actual__ = (genPlayerIds( players_file )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "genPlayerIds( players_file )", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     for ( int i = 0; i < (((25 * 8) * 2) * 2); ++i )
     {
          do { int __expected__ = (i + 1); int __actual__ = (getPlayerId( &players_file[i] )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "getPlayerId( &players_file[i] )", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     }
     return ((void *)0);
}

variable_types: struct fileplayer_s { char last_name[10]; char first_name[8]; char last_phoen[14]; char first_phoen[12]; unsigned char real_avg[2]; unsigned char year[1]; unsigned char position[1]; union { struct filebatting_s { unsigned char ratings[4]; unsigned char real_games[1]; unsigned char real_runs[1]; unsigned char real_rbi[1]; unsigned char real_sb[1]; unsigned char real_cs[1]; unsigned char real_sh[1]; unsigned char vl_ab[2]; unsigned char vl_hits[2]; unsigned char vl_2b[1]; unsigned char vl_3b[1]; unsigned char vl_hr[1]; unsigned char vl_bb[1]; unsigned char vl_so[1]; unsigned char real_fa2[1]; unsigned char vr_ab[2]; unsigned char vr_hits[2]; unsigned char vr_2b[1]; unsigned char vr_3b[1]; unsigned char vr_hr[1]; unsigned char vr_bb[1]; unsigned char vr_so[1]; unsigned char real_err[1]; unsigned char real_po[2]; unsigned char real_as[2]; unsigned char injury_days[1]; unsigned char color[1]; } filebatting; struct filepitching_s { unsigned char ratings[2]; unsigned char real_wins[1]; unsigned char real_losses[1]; unsigned char real_games[1]; unsigned char real_starts[1]; unsigned char real_cg[1]; unsigned char real_saves[1]; unsigned char real_inn[2]; unsigned char vl_ab[2]; unsigned char vl_hits[2]; unsigned char vl_hr[1]; unsigned char vl_bb[1]; unsigned char vl_so[2]; unsigned char real_er[1]; unsigned char real_fa[1]; unsigned char vr_ab[2]; unsigned char vr_hits[2]; unsigned char vr_hr[1]; unsigned char vr_bb[1]; unsigned char vr_so[2]; unsigned char real_hb[1]; unsigned char real_balk[1]; unsigned char real_ab[1]; unsigned char real_hits[1]; unsigned char real_hr[1]; unsigned char real_sh[1]; unsigned char injury_days[1]; unsigned char color[1]; } filepitching; } filestats; struct acc_stats_s { union acc_stats_u { struct acc_pch_stats_s { unsigned char acc_wins[1]; unsigned char acc_losses[1]; unsigned char acc_starts[1]; unsigned char acc_saves[1]; unsigned char acc_innings[2]; unsigned char acc_hits[2]; unsigned char acc_er[2]; unsigned char acc_hr[1]; unsigned char acc_bb[1]; unsigned char acc_so[2]; } pitching; struct acc_bat_stats_s { unsigned char acc_ab[2]; unsigned char acc_hits[2]; unsigned char acc_2b[1]; unsigned char acc_3b[1]; unsigned char acc_hr[1]; unsigned char acc_bb[1]; unsigned char acc_so[1]; unsigned char acc_games[1]; unsigned char acc_runs[1]; unsigned char acc_rbi[1]; unsigned char acc_sb[1]; unsigned char acc_err[1]; } batting; struct acc_player_id_s { unsigned char player_id[2]; unsigned char checksum[1]; unsigned char filler[11]; } id_info; } action; union acc_stats_u simulated; } acc_stats; } *


updatePitchingTotals

original_code:
static void updatePitchingTotals( pitching_s *totals, const pitching_s *player )
{
     totals->wins += player->wins;
     totals->losses += player->losses;
     totals->games += player->games;
     totals->saves += player->saves;
     totals->innings += player->innings;
     totals->at_bats += player->at_bats;
     totals->hits += player->hits;
     totals->earned_runs += player->earned_runs;
     totals->home_runs += player->home_runs;
     totals->walks += player->walks;
     totals->strike_outs += player->strike_outs;
}

canonical_original_code:
static void updatePitchingTotals(struct pitching_s *totals, struct pitching_s *player)
{
     totals->wins += player->wins;
     totals->losses += player->losses;
     totals->games += player->games;
     totals->saves += player->saves;
     totals->innings += player->innings;
     totals->at_bats += player->at_bats;
     totals->hits += player->hits;
     totals->earned_runs += player->earned_runs;
     totals->home_runs += player->home_runs;
     totals->walks += player->walks;
     totals->strike_outs += player->strike_outs;
}

variable_types: struct pitching_s { int wins; int losses; int games; int games_started; int games_completed; int saves; float innings; int at_bats; int hits; int earned_runs; int home_runs; int walks; int strike_outs; } *

variable_types:
player
struct pitching_s *


updateTeamTotals

decompiled_code:
__int64 __fastcall updateTeamTotals(__int64 a1, unsigned int *a2)
{
__int64 result; // rax

result = a2[2];
if ( (_DWORD)result )
{
if ( (_DWORD)result == 1 )
{
updateHittingTotals((_DWORD *)(a1 + 100), a2 + 25);
result = updateHittingTotals((_DWORD *)(a1 + 148), a2 + 37);
}
}
else
{
updatePitchingTotals(a1 + 92, (__int64)(a2 + 23));
result = updatePitchingTotals(a1 + 144, (__int64)(a2 + 36));
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, unsigned int *a2)
{
__int64 result; // rax

result = a2[2];
if ( (_DWORD)result )
{
if ( (_DWORD)result == 1 )
{
func0((_DWORD *)(a1 + 100), a2 + 25);
result = func0((_DWORD *)(a1 + 148), a2 + 37);
}
}
else
{
func1(a1 + 92, (__int64)(a2 + 23));
result = func1(a1 + 144, (__int64)(a2 + 36));
}
return result;
}

original_code:
static void updateTeamTotals( player_s *totals, const player_s *player )
{
     if ( player->type == pt_Pitcher )
     {
          updatePitchingTotals( &(totals->data.pitcher.potential), &(player->data.pitcher.potential) );
          updatePitchingTotals( &(totals->data.pitcher.simulated), &(player->data.pitcher.simulated) );
     }
     else if ( player->type == pt_Hitter )
     {
          updateHittingTotals( &(totals->data.batter.potential), &(player->data.batter.potential) );
          updateHittingTotals( &(totals->data.batter.simulated), &(player->data.batter.simulated) );
     }
}

canonical_original_code:
static void updateTeamTotals(struct player_s *totals, struct player_s *player)
{
     if ( player->type == pt_Pitcher )
     {
          updatePitchingTotals( &(totals->data.pitcher.potential), &(player->data.pitcher.potential) );
          updatePitchingTotals( &(totals->data.pitcher.simulated), &(player->data.pitcher.simulated) );
     }
     else if ( player->type == pt_Hitter )
     {
          updateHittingTotals( &(totals->data.batter.potential), &(player->data.batter.potential) );
          updateHittingTotals( &(totals->data.batter.simulated), &(player->data.batter.simulated) );
     }
}

variable_types: struct player_s { int player_id; int hand; enum playertype_e { pt_Pitcher=0, pt_Hitter=1, pt_None=2 } type; int injury_days; union { struct pitcher_s { char first_name[-1]; char last_name[-1]; int year; enum position_e { pos_Pitcher=0, pos_Catcher=1, pos_FirstBase=2, pos_SecondBase=3, pos_ThirdBase=4, pos_ShortStop=5, pos_Infield=6, pos_LeftField=7, pos_CenterField=8, pos_RightField=9, pos_Outfield=10, pos_Unknown=11, pos_Designate=12 } primary_pos; enum position_e { pos_Pitcher=0, pos_Catcher=1, pos_FirstBase=2, pos_SecondBase=3, pos_ThirdBase=4, pos_ShortStop=5, pos_Infield=6, pos_LeftField=7, pos_CenterField=8, pos_RightField=9, pos_Outfield=10, pos_Unknown=11, pos_Designate=12 } secondary_pos; int speed; int control; int fatigue; int bunt; int longevity; struct pitching_s { int wins; int losses; int games; int games_started; int games_completed; int saves; float innings; int at_bats; int hits; int earned_runs; int home_runs; int walks; int strike_outs; } potential; struct pitching_s simulated; float fielding_avg; } pitcher; struct batter_s { char first_name[-1]; char last_name[-1]; int year; enum position_e { pos_Pitcher=0, pos_Catcher=1, pos_FirstBase=2, pos_SecondBase=3, pos_ThirdBase=4, pos_ShortStop=5, pos_Infield=6, pos_LeftField=7, pos_CenterField=8, pos_RightField=9, pos_Outfield=10, pos_Unknown=11, pos_Designate=12 } primary_pos; enum position_e { pos_Pitcher=0, pos_Catcher=1, pos_FirstBase=2, pos_SecondBase=3, pos_ThirdBase=4, pos_ShortStop=5, pos_Infield=6, pos_LeftField=7, pos_CenterField=8, pos_RightField=9, pos_Outfield=10, pos_Unknown=11, pos_Designate=12 } secondary_pos; int power; int hit_n_run; int bunt; int running; int range; int arm; int longevity; struct hitting_s { int games; int at_bats; int runs; int hits; int doubles; int triples; int home_runs; int rbi; int walks; int strike_outs; int stolen_bases; int errors; } potential; struct hitting_s simulated; struct fielding_s { int put_outs; int assists; int errors; float secondary_avg; } fielding; } batter; } data; } *

variable_types:
player
struct player_s *

user_defined_types: struct player_s { int player_id; int hand; enum playertype_e type; int injury_days; union { struct pitcher_s pitcher; struct batter_s batter; } data; }

user_defined_types: struct pitcher_s { char first_name[-1]; char last_name[-1]; int year; enum position_e primary_pos; enum position_e secondary_pos; int speed; int control; int fatigue; int bunt; int longevity; struct pitching_s potential; struct pitching_s simulated; float fielding_avg; }

user_defined_types: struct batter_s { char first_name[-1]; char last_name[-1]; int year; enum position_e primary_pos; enum position_e secondary_pos; int power; int hit_n_run; int bunt; int running; int range; int arm; int longevity; struct hitting_s potential; struct hitting_s simulated; struct fielding_s fielding; }


displayAvg

decompiled_code:
char *__fastcall displayAvg(double a1)
{
sprintf(&buffer_0, "%5.3f", a1);
if ( buffer_0 == 48 )
buffer_0 = 32;
return &buffer_0;
}

canonical_decompiled_code:
char *__fastcall func5(double a1)
{
sprintf(&buffer_0, "%5.3f", a1);
if ( buffer_0 == 48 )
buffer_0 = 32;
return &buffer_0;
}

original_code:
static char *displayAvg( const double avg )
{
     static char buffer[5 + 1];
     sprintf( buffer, "%5.3f", avg );
     if ( buffer[0] == '0' ) buffer[0] = ' ';
     return buffer;
}

canonical_original_code:
static char *displayAvg(double avg)
{
     static char buffer[-1];
     sprintf( buffer, "%5.3f", avg );
     if ( buffer[0] == '0' ) buffer[0] = ' ';
     return buffer;
}

variable_types: avg double

variable_types:
buffer
char [-1]


printPlayer

decompiled_code:
int __fastcall printPlayer(__int64 a1)
{
int result; // eax

result = *(_DWORD *)(a1 + 8);
if ( !result )
return printPitcher(a1);
if ( result == 1 )
result = printHitter(a1);
return result;
}

canonical_decompiled_code:
int __fastcall func10(__int64 a1)
{
int result; // eax

result = *(_DWORD *)(a1 + 8);
if ( !result )
return func7(a1);
if ( result == 1 )
result = func9(a1);
return result;
}

original_code:
static void printPlayer( const player_s *player )
{
     if ( player->type == pt_Pitcher ) printPitcher( player );
     else if ( player->type == pt_Hitter ) printHitter( player );
}

canonical_original_code:
static void printPlayer(struct player_s *player)
{
     if ( player->type == pt_Pitcher ) printPitcher( player );
     else if ( player->type == pt_Hitter ) printHitter( player );
}

user_defined_types: enum playertype_e { pt_Pitcher=0, pt_Hitter=1, pt_None=2 }

user_defined_types: enum position_e { pos_Pitcher=0, pos_Catcher=1, pos_FirstBase=2, pos_SecondBase=3, pos_ThirdBase=4, pos_ShortStop=5, pos_Infield=6, pos_LeftField=7, pos_CenterField=8, pos_RightField=9, pos_Outfield=10, pos_Unknown=11, pos_Designate=12 }

user_defined_types: struct pitching_s { int wins; int losses; int games; int games_started; int games_completed; int saves; float innings; int at_bats; int hits; int earned_runs; int home_runs; int walks; int strike_outs; }

user_defined_types: struct hitting_s { int games; int at_bats; int runs; int hits; int doubles; int triples; int home_runs; int rbi; int walks; int strike_outs; int stolen_bases; int errors; }

user_defined_types: struct fielding_s { int put_outs; int assists; int errors; float secondary_avg; }


printTeamTotals

decompiled_code:
const char *__fastcall printTeamTotals(const char *a1, int a2)
{
unsigned int *v2; // rbx
unsigned int *v3; // rbp
__int64 i; // r14
const char *result; // rax
__int64 v6; // [rsp+10h] [rbp-138h]
char *s; // [rsp+18h] [rbp-130h]
const char *v8; // [rsp+20h] [rbp-128h]
int v9[70]; // [rsp+30h] [rbp-118h] BYREF

v8 = a1;
do
{
printf("%s League\n", v8);
putchar(10);
s = (char *)(v8 + 24);
v6 = 0LL;
puts(v8 + 24);
while ( 1 )
{
putchar(10);
if ( a2 )
printHittingHeader();
else
printPitchingHeader();
v3 = (unsigned int *)(s + 5360);
for ( i = 0LL; i != 42688; i += 5336LL )
{
memset(v9, 0, 0xD0uLL);
v9[52] = 0;
v9[2] = a2;
strcpy((char *)&v9[4], &v8[v6 + 48 + i]);
v2 = v3 - 1325;
do
{
if ( v2[2] == a2 )
updateTeamTotals((__int64)v9, v2);
v2 += 53;
}
while ( v2 != v3 );
printPlayer((__int64)v9);
v3 += 1334;
}
putchar(10);
s += 42712;
v6 += 42712LL;
if ( v6 == 85424 )
break;
puts(s);
}
v8 += 85448;
result = v8;
}
while ( v8 != a1 + 170896 );
return result;
}

original_code:
static void printTeamTotals( const league_s *leagues, const playertype_e type )
{
     int pitchingHeader = 0;
     int hittingHeader = 0;
     int leag;
     int div;
     int team;
     int plyr;
     for ( leag = 0; leag < 2; ++leag )
     {
   printf( "%s League\n", leagues[leag].name );
   printf( "\n" );
   for ( div = 0; div < 2; ++div )
   {
        printf( "%s\n", leagues[leag].divisions[div].name );
        printf( "\n" );
               if ( type == pt_Pitcher ) printPitchingHeader();
               else printHittingHeader();
        for ( team = 0; team < 8; ++team )
        {
                    player_s totals;
                    memset( &totals, '\0', sizeof(player_s) );
                    totals.type = type;
                    strcpy( totals.data.pitcher.first_name, leagues[leag].divisions[div].teams[team].name );
      for ( plyr = 0; plyr < 25; ++plyr )
      {
    const player_s *pl = &leagues[leag].divisions[div].teams[team].players[plyr];
    if ( pl->type == type )
    {
                              updateTeamTotals( &totals, pl );
    }
      }
                    printPlayer( &totals );
        }
               printf( "\n" );
   }
     }
}

canonical_original_code:
static void printTeamTotals(struct league_s *leagues, enum playertype_e type)
{
     int pitchingHeader = 0;
     int hittingHeader = 0;
     int leag;
     int div;
     int team;
     int plyr;
     for ( leag = 0; leag < 2; ++leag )
     {
   printf( "%s League\n", leagues[leag].name );
   printf( "\n" );
   for ( div = 0; div < 2; ++div )
   {
        printf( "%s\n", leagues[leag].divisions[div].name );
        printf( "\n" );
               if ( type == pt_Pitcher ) printPitchingHeader();
               else printHittingHeader();
        for ( team = 0; team < 8; ++team )
        {
                    struct player_s totals;
                    memset( &totals, '\0', sizeof(player_s) );
                    totals.type = type;
                    strcpy( totals.data.pitcher.first_name, leagues[leag].divisions[div].teams[team].name );
      for ( plyr = 0; plyr < 25; ++plyr )
      {
    struct player_s *pl = &leagues[leag].divisions[div].teams[team].players[plyr];
    if ( pl->type == type )
    {
                              updateTeamTotals( &totals, pl );
    }
      }
                    printPlayer( &totals );
        }
               printf( "\n" );
   }
     }
}

variable_types: struct league_s { char name[-1]; struct division_s { char name[-1]; struct team_s { char name[-1]; int wins; int losses; enum color_e { cl_LtBlue=0, cl_Blue=1, cl_DkRed=2, cl_Red=3, cl_Gold=4, cl_Black=5, cl_Brown=6, cl_Green=7 } color; struct player_s { int player_id; int hand; enum playertype_e { pt_Pitcher=0, pt_Hitter=1, pt_None=2 } type; int injury_days; union { struct pitcher_s { char first_name[-1]; char last_name[-1]; int year; enum position_e { pos_Pitcher=0, pos_Catcher=1, pos_FirstBase=2, pos_SecondBase=3, pos_ThirdBase=4, pos_ShortStop=5, pos_Infield=6, pos_LeftField=7, pos_CenterField=8, pos_RightField=9, pos_Outfield=10, pos_Unknown=11, pos_Designate=12 } primary_pos; enum position_e { pos_Pitcher=0, pos_Catcher=1, pos_FirstBase=2, pos_SecondBase=3, pos_ThirdBase=4, pos_ShortStop=5, pos_Infield=6, pos_LeftField=7, pos_CenterField=8, pos_RightField=9, pos_Outfield=10, pos_Unknown=11, pos_Designate=12 } secondary_pos; int speed; int control; int fatigue; int bunt; int longevity; struct pitching_s { int wins; int losses; int games; int games_started; int games_completed; int saves; float innings; int at_bats; int hits; int earned_runs; int home_runs; int walks; int strike_outs; } potential; struct pitching_s simulated; float fielding_avg; } pitcher; struct batter_s { char first_name[-1]; char last_name[-1]; int year; enum position_e { pos_Pitcher=0, pos_Catcher=1, pos_FirstBase=2, pos_SecondBase=3, pos_ThirdBase=4, pos_ShortStop=5, pos_Infield=6, pos_LeftField=7, pos_CenterField=8, pos_RightField=9, pos_Outfield=10, pos_Unknown=11, pos_Designate=12 } primary_pos; enum position_e { pos_Pitcher=0, pos_Catcher=1, pos_FirstBase=2, pos_SecondBase=3, pos_ThirdBase=4, pos_ShortStop=5, pos_Infield=6, pos_LeftField=7, pos_CenterField=8, pos_RightField=9, pos_Outfield=10, pos_Unknown=11, pos_Designate=12 } secondary_pos; int power; int hit_n_run; int bunt; int running; int range; int arm; int longevity; struct hitting_s { int games; int at_bats; int runs; int hits; int doubles; int triples; int home_runs; int rbi; int walks; int strike_outs; int stolen_bases; int errors; } potential; struct hitting_s simulated; struct fielding_s { int put_outs; int assists; int errors; float secondary_avg; } fielding; } batter; } data; } players[25]; } teams[8]; } divisions[2]; } *

variable_types: pitchingHeader int

variable_types: hittingHeader int

variable_types: leag int

variable_types: div int

variable_types: team int

variable_types: plyr int

user_defined_types: struct league_s { char name[-1]; struct division_s divisions[2]; }

user_defined_types: struct division_s { char name[-1]; struct team_s teams[8]; }

user_defined_types: struct team_s { char name[-1]; int wins; int losses; enum color_e color; struct player_s players[25]; }


playercmp

decompiled_code:
int __fastcall playercmp(const void *a1, const void *a2)
{
int result; // eax

if ( !*(_BYTE *)a1 )
return *(_BYTE *)a2 != 0;
if ( !*(_BYTE *)a2 )
return -1;
result = strncmp((const char *)a1, (const char *)a2, 0xAuLL);
if ( !result )
result = strncmp((const char *)a1 + 10, (const char *)a2 + 10, 8uLL);
return result;
}

canonical_decompiled_code:
int __fastcall func0(const void *a1, const void *a2)
{
int result; // eax

if ( !*(_BYTE *)a1 )
return *(_BYTE *)a2 != 0;
if ( !*(_BYTE *)a2 )
return -1;
result = strncmp((const char *)a1, (const char *)a2, 0xAuLL);
if ( !result )
result = strncmp((const char *)a1 + 10, (const char *)a2 + 10, 8uLL);
return result;
}

original_code:
static int playercmp( const void *arg1, const void *arg2 )
{
     const fileplayer_s *p1 = (fileplayer_s *)arg1;
     const fileplayer_s *p2 = (fileplayer_s *)arg2;
           int cmp;
     if ( p1->last_name[0] == '\0' )
     {
          if ( p2->last_name[0] == '\0' ) return 0;
          return 1;
     }
     if ( p2->last_name[0] == '\0' ) return -1;
     if ( (cmp = strncmp( p1->last_name, p2->last_name, sizeof(p1->last_name) )) != 0 ) return cmp;
     return strncmp( p1->first_name, p2->first_name, sizeof(p1->first_name) );
}

canonical_original_code:
static int playercmp(void *arg1, void *arg2)
{
     struct fileplayer_s *p1 = (fileplayer_s *)arg1;
     struct fileplayer_s *p2 = (fileplayer_s *)arg2;
           int cmp;
     if ( p1->last_name[0] == '\0' )
     {
          if ( p2->last_name[0] == '\0' ) return 0;
          return 1;
     }
     if ( p2->last_name[0] == '\0' ) return -1;
     if ( (cmp = strncmp( p1->last_name, p2->last_name, sizeof(p1->last_name) )) != 0 ) return cmp;
     return strncmp( p1->first_name, p2->first_name, sizeof(p1->first_name) );
}

variable_types: struct fileplayer_s { char last_name[10]; char first_name[8]; char last_phoen[14]; char first_phoen[12]; unsigned char real_avg[2]; unsigned char year[1]; unsigned char position[1]; union { struct batting_s { unsigned char ratings[4]; unsigned char real_games[1]; unsigned char real_runs[1]; unsigned char real_rbi[1]; unsigned char real_sb[1]; unsigned char real_cs[1]; unsigned char real_sh[1]; unsigned char vl_ab[2]; unsigned char vl_hits[2]; unsigned char vl_2b[1]; unsigned char vl_3b[1]; unsigned char vl_hr[1]; unsigned char vl_bb[1]; unsigned char vl_so[1]; unsigned char real_fa2[1]; unsigned char vr_ab[2]; unsigned char vr_hits[2]; unsigned char vr_2b[1]; unsigned char vr_3b[1]; unsigned char vr_hr[1]; unsigned char vr_bb[1]; unsigned char vr_so[1]; unsigned char real_err[1]; unsigned char real_po[2]; unsigned char real_as[2]; unsigned char injury_days[1]; unsigned char color[1]; struct acc_bat_stats_s { unsigned char acc_ab[2]; unsigned char acc_hits[2]; unsigned char acc_2b[1]; unsigned char acc_3b[1]; unsigned char acc_hr[1]; unsigned char acc_bb[1]; unsigned char acc_so[1]; unsigned char acc_games[1]; unsigned char acc_runs[1]; unsigned char acc_rbi[1]; unsigned char acc_sb[1]; unsigned char acc_err[1]; } action; struct acc_bat_stats_s simulated; } filebatting; struct pitching_s { unsigned char ratings[2]; unsigned char real_wins[1]; unsigned char real_losses[1]; unsigned char real_games[1]; unsigned char real_starts[1]; unsigned char real_cg[1]; unsigned char real_saves[1]; unsigned char real_inn[2]; unsigned char vl_ab[2]; unsigned char vl_hits[2]; unsigned char vl_hr[1]; unsigned char vl_bb[1]; unsigned char vl_so[2]; unsigned char real_er[1]; unsigned char real_fa[1]; unsigned char vr_ab[2]; unsigned char vr_hits[2]; unsigned char vr_hr[1]; unsigned char vr_bb[1]; unsigned char vr_so[2]; unsigned char real_hb[1]; unsigned char real_balk[1]; unsigned char real_ab[1]; unsigned char real_hits[1]; unsigned char real_hr[1]; unsigned char real_sh[1]; unsigned char injury_days[1]; unsigned char color[1]; struct acc_pch_stats_s { unsigned char acc_wins[1]; unsigned char acc_losses[1]; unsigned char acc_starts[1]; unsigned char acc_saves[1]; unsigned char acc_innings[2]; unsigned char acc_hits[2]; unsigned char acc_er[2]; unsigned char acc_hr[1]; unsigned char acc_bb[1]; unsigned char acc_so[2]; } action; struct acc_pch_stats_s simulated; } filepitching; } filestats; } *

variable_types: cmp int

user_defined_types: struct fileplayer_s { char last_name[10]; char first_name[8]; char last_phoen[14]; char first_phoen[12]; unsigned char real_avg[2]; unsigned char year[1]; unsigned char position[1]; union { struct batting_s filebatting; struct pitching_s filepitching; } filestats; }

user_defined_types: struct batting_s { unsigned char ratings[4]; unsigned char real_games[1]; unsigned char real_runs[1]; unsigned char real_rbi[1]; unsigned char real_sb[1]; unsigned char real_cs[1]; unsigned char real_sh[1]; unsigned char vl_ab[2]; unsigned char vl_hits[2]; unsigned char vl_2b[1]; unsigned char vl_3b[1]; unsigned char vl_hr[1]; unsigned char vl_bb[1]; unsigned char vl_so[1]; unsigned char real_fa2[1]; unsigned char vr_ab[2]; unsigned char vr_hits[2]; unsigned char vr_2b[1]; unsigned char vr_3b[1]; unsigned char vr_hr[1]; unsigned char vr_bb[1]; unsigned char vr_so[1]; unsigned char real_err[1]; unsigned char real_po[2]; unsigned char real_as[2]; unsigned char injury_days[1]; unsigned char color[1]; struct acc_bat_stats_s action; struct acc_bat_stats_s simulated; }

user_defined_types: struct pitching_s { unsigned char ratings[2]; unsigned char real_wins[1]; unsigned char real_losses[1]; unsigned char real_games[1]; unsigned char real_starts[1]; unsigned char real_cg[1]; unsigned char real_saves[1]; unsigned char real_inn[2]; unsigned char vl_ab[2]; unsigned char vl_hits[2]; unsigned char vl_hr[1]; unsigned char vl_bb[1]; unsigned char vl_so[2]; unsigned char real_er[1]; unsigned char real_fa[1]; unsigned char vr_ab[2]; unsigned char vr_hits[2]; unsigned char vr_hr[1]; unsigned char vr_bb[1]; unsigned char vr_so[2]; unsigned char real_hb[1]; unsigned char real_balk[1]; unsigned char real_ab[1]; unsigned char real_hits[1]; unsigned char real_hr[1]; unsigned char real_sh[1]; unsigned char injury_days[1]; unsigned char color[1]; struct acc_pch_stats_s action; struct acc_pch_stats_s simulated; }


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
void *v3; // rax
void *v4; // rbp
int v5; // edx
int result; // eax

if ( argc <= 2 )
{
printf("Usage: %s <input file> <output file>\n", *argv);
result = 0;
}
else
{
v3 = (void *)readPlayersFile(argv[1]);
v4 = v3;
if ( v3 )
{
qsort(v3, 0x320uLL, 0x70uLL, playercmp);
v5 = writePlayersFile(argv[2], v4);
result = 0;
if ( !v5 )
{
puts("Cannot save player changes.");
result = 1;
}
}
else
{
printf("Unable to load players file <%s>.\n", argv[1]);
result = 0;
}
}
return result;
}

original_code:
int main( const int argc, const char *argv[] )
{
     fileplayer_s *playersFile;
     int idx;
     if ( argc < 3 )
     {
   printf( "Usage: %s <input file> <output file>\n", argv[0] );
   return 0;
     }
     if ( (playersFile = readPlayersFile( argv[1] )) == ((void *)0) )
     {
          printf( "Unable to load players file <%s>.\n", argv[1] );
          return 0;
     }
     qsort( playersFile, (((25 * 8) * 2) * 2), sizeof(fileplayer_s), playercmp );
     if ( ! writePlayersFile( argv[2], playersFile ) )
     {
          printf( "Cannot save player changes.\n" );
          return 1;
     }
     return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
     struct fileplayer_s *playersFile;
     int idx;
     if ( argc < 3 )
     {
   printf( "Usage: %s <input file> <output file>\n", argv[0] );
   return 0;
     }
     if ( (playersFile = readPlayersFile( argv[1] )) == ((void *)0) )
     {
          printf( "Unable to load players file <%s>.\n", argv[1] );
          return 0;
     }
     qsort( playersFile, (((25 * 8) * 2) * 2), sizeof(fileplayer_s), playercmp );
     if ( ! writePlayersFile( argv[2], playersFile ) )
     {
          printf( "Cannot save player changes.\n" );
          return 1;
     }
     return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: idx int

user_defined_types: struct acc_pch_stats_s { unsigned char acc_wins[1]; unsigned char acc_losses[1]; unsigned char acc_starts[1]; unsigned char acc_saves[1]; unsigned char acc_innings[2]; unsigned char acc_hits[2]; unsigned char acc_er[2]; unsigned char acc_hr[1]; unsigned char acc_bb[1]; unsigned char acc_so[2]; }


buildIntoDivision

decompiled_code:
int __fastcall buildIntoDivision(__int64 a1, unsigned int a2)
{
*(_DWORD *)a1 = a2;
return sprintf((char *)(a1 + 4), "Division%d", a2);
}

canonical_decompiled_code:
int __fastcall func0(__int64 a1, unsigned int a2)
{
*(_DWORD *)a1 = a2;
return sprintf((char *)(a1 + 4), "Division%d", a2);
}

original_code:
void buildIntoDivision( division_s *division, const int division_id )
{
     division->division_id = division_id;
     sprintf( division->name, "Division%d", division_id );
}

canonical_original_code:
void buildIntoDivision(struct division_s *division, int division_id)
{
     division->division_id = division_id;
     sprintf( division->name, "Division%d", division_id );
}

variable_types: struct division_s { int division_id; char name[-1]; struct division_team_s { int division_id; int team_id; struct team_s { int team_id; char name[-1]; char location[-1]; enum color_e { cl_None=0, cl_LtBlue=1, cl_Blue=2, cl_DkRed=3, cl_Red=4, cl_Gold=5, cl_Black=6, cl_Brown=7, cl_Green=8 } primary_color; enum color_e { cl_None=0, cl_LtBlue=1, cl_Blue=2, cl_DkRed=3, cl_Red=4, cl_Gold=5, cl_Black=6, cl_Brown=7, cl_Green=8 } secondary_color; struct team_player_s { int team_id; int season; int player_id; struct player_s { int player_id; char first_name[-1]; char last_name[-1]; char first_phoenetic[-1]; char last_phoenetic[-1]; enum skin_tone_e { st_None=0, st_Light=1, st_Dark=2 } skin_tone; enum handedness_e { hnd_None=0, hnd_Right=1, hnd_Left=2, hnd_Switch=3 } handedness; enum playertype_e { pt_None=0, pt_Pitcher=1, pt_Batter=2 } player_type; int rookie_season; int longevity; struct player_accolade_s { int player_id; int season; enum accolade_e { acc_None=0, acc_All_Star=1, acc_World_Title=2, acc_League_Title=3, acc_Division_Title=4, acc_Best_Record=5, acc_World_Series_MVP=6, acc_All_Star_Champion=7, acc_All_Star_MVP=8 } accolade; } *accolades; union { struct pitcher_s { int player_id; int speed; int control; int bunt; int fatigue; struct pitcher_stats_s { int player_id; int season; enum season_phase_e { sp_None=0, sp_Regular=1, sp_Playoff=2, sp_Allstar=3 } season_phase; int wins; int losses; int games; int saves; struct innings_s { int innings; int outs; } innings; int hits; int earned_runs; int home_runs; int walks; int strike_outs; } *stats; struct pitcher_accolade_s { int player_id; int season; enum pitching_accolade_e { pacc_None=0, pacc_Pitcher_of_the_Year=1, pacc_Global_Pitcher_of_the_Year=2, pacc_World_Pitcher_of_the_Year=3, pacc_Atlantic_Pitcher_of_the_Year=4, pacc_North_Pitcher_of_the_Year=5, pacc_Pacific_Pitcher_of_the_Year=6, pacc_South_Pitcher_of_the_Year=7, pacc_Most_Wins=8, pacc_Best_Win_Loss_Ratio=9, pacc_Best_Win_Percentage=10, pacc_Best_Earned_Run_Average=11, pacc_Best_vs_Batting_Average=12, pacc_Most_Saves=13, pacc_Most_Strike_Outs=14, pacc_Most_Innings_per_Game=15, pacc_Best_Walks_Hits_Per_Inning=16, pacc_Most_Strike_Outs_per_Nine=17, pacc_Best_Home_Runs_per_Nine=18, pacc_Best_Efficiency=19, pacc_Pitching_Rookie_of_the_Year=20 } accolade; } *accolades; } *pitching; struct batter_s { int player_id; int power; int hit_n_run; int bunt; int running; int range; int arm; enum position_e { pos_None=0, pos_Catcher=1, pos_FirstBase=2, pos_SecondBase=3, pos_ThirdBase=4, pos_ShortStop=5, pos_LeftField=6, pos_CenterField=7, pos_RightField=8, pos_Infield=9, pos_Outfield=10 } primary_position; enum position_e { pos_None=0, pos_Catcher=1, pos_FirstBase=2, pos_SecondBase=3, pos_ThirdBase=4, pos_ShortStop=5, pos_LeftField=6, pos_CenterField=7, pos_RightField=8, pos_Infield=9, pos_Outfield=10 } secondary_position; struct batter_stats_s { int player_id; int season; enum season_phase_e { sp_None=0, sp_Regular=1, sp_Playoff=2, sp_Allstar=3 } season_phase; int games; int at_bats; int runs; int hits; int doubles; int triples; int home_runs; int runs_batted_in; int walks; int strike_outs; int steals; int errors; } *stats; struct batter_accolade_s { int player_id; int season; enum batting_accolade_e { bacc_None=0, bacc_Batter_of_the_Year=1, bacc_Global_Batter_of_the_Year=2, bacc_World_Batter_of_the_Year=3, bacc_Atlantic_Batter_of_the_Year=4, bacc_North_Batter_of_the_Year=5, bacc_Pacific_Batter_of_the_Year=6, bacc_South_Batter_of_the_Year=7, bacc_Best_Batting_Average=8, bacc_Most_Doubles=9, bacc_Most_Triples=10, bacc_Most_Home_Runs=11, bacc_Most_Runs=12, bacc_Most_Runs_Batted_In=13, bacc_Most_Stolen_Bases=14, bacc_Most_Walks=15, bacc_Best_Slugging_Average=16, bacc_Best_On_Base_Percentage=17, bacc_Best_Strike_Out_Average=18, bacc_Best_Runs_per_Game=19, bacc_Batting_Rookie_of_the_Year=20 } accolade; } *accolades; } *batting; } details; } *player; } *players; struct team_stats_s { int team_id; int season; enum season_phase_e { sp_None=0, sp_Regular=1, sp_Playoff=2, sp_Allstar=3 } season_phase; int wins; int losses; int home_wins; int home_losses; int road_wins; int road_losses; int division_wins; int division_losses; int league_wins; int league_losses; int runs_scored; int runs_allowed; } *stats; struct team_versus_stats_s { int team_id; int season; enum season_phase_e { sp_None=0, sp_Regular=1, sp_Playoff=2, sp_Allstar=3 } season_phase; int opponent; int wins; int losses; int runs_scored; int runs_allowed; } *versus_stats; struct team_pitching_stats_s { int team_id; int season; enum season_phase_e { sp_None=0, sp_Regular=1, sp_Playoff=2, sp_Allstar=3 } season_phase; int wins; int losses; int games; int saves; struct innings_s innings; int hits; int earned_runs; int home_runs; int walks; int strike_outs; } *pitching_stats; struct team_batting_stats_s { int team_id; int season; enum season_phase_e { sp_None=0, sp_Regular=1, sp_Playoff=2, sp_Allstar=3 } season_phase; int games; int at_bats; int runs; int hits; int doubles; int triples; int home_runs; int runs_batted_in; int walks; int strike_outs; int steals; int errors; } *batting_stats; struct team_accolade_s { int team_id; int season; enum team_accolade_e { tacc_None=0, tacc_World_Title=1, tacc_League_Title=2, tacc_Division_Title=3, tacc_Best_Record=4, tacc_All_Star_Champion=5 } accolade; } *accolades; } *team; } *teams; struct division_stats_s { int division_id; int season; enum season_phase_e { sp_None=0, sp_Regular=1, sp_Playoff=2, sp_Allstar=3 } season_phase; int wins; int losses; int home_wins; int home_losses; int road_wins; int road_losses; int league_wins; int league_losses; int runs_scored; int runs_allowed; } *stats; struct division_accolade_s { int division_id; int season; enum division_accolade_e { dacc_None=0, dacc_World_Title=1, dacc_League_Title=2, dacc_Best_Record=3 } accolade; } *accolades; } *

user_defined_types: struct division_s { int division_id; char name[-1]; struct division_team_s *teams; struct division_stats_s *stats; struct division_accolade_s *accolades; }

user_defined_types: struct division_team_s { int division_id; int team_id; struct team_s *team; }

user_defined_types: struct division_stats_s { int division_id; int season; enum season_phase_e season_phase; int wins; int losses; int home_wins; int home_losses; int road_wins; int road_losses; int league_wins; int league_losses; int runs_scored; int runs_allowed; }

user_defined_types: struct division_accolade_s { int division_id; int season; enum division_accolade_e accolade; }

user_defined_types: struct team_s { int team_id; char name[-1]; char location[-1]; enum color_e primary_color; enum color_e secondary_color; struct team_player_s *players; struct team_stats_s *stats; struct team_versus_stats_s *versus_stats; struct team_pitching_stats_s *pitching_stats; struct team_batting_stats_s *batting_stats; struct team_accolade_s *accolades; }

user_defined_types: struct team_player_s { int team_id; int season; int player_id; struct player_s *player; }

user_defined_types: struct team_stats_s { int team_id; int season; enum season_phase_e season_phase; int wins; int losses; int home_wins; int home_losses; int road_wins; int road_losses; int division_wins; int division_losses; int league_wins; int league_losses; int runs_scored; int runs_allowed; }

user_defined_types: struct team_versus_stats_s { int team_id; int season; enum season_phase_e season_phase; int opponent; int wins; int losses; int runs_scored; int runs_allowed; }

user_defined_types: struct team_pitching_stats_s { int team_id; int season; enum season_phase_e season_phase; int wins; int losses; int games; int saves; struct innings_s innings; int hits; int earned_runs; int home_runs; int walks; int strike_outs; }

user_defined_types: struct team_batting_stats_s { int team_id; int season; enum season_phase_e season_phase; int games; int at_bats; int runs; int hits; int doubles; int triples; int home_runs; int runs_batted_in; int walks; int strike_outs; int steals; int errors; }

user_defined_types: struct team_accolade_s { int team_id; int season; enum team_accolade_e accolade; }

user_defined_types: struct player_s { int player_id; char first_name[-1]; char last_name[-1]; char first_phoenetic[-1]; char last_phoenetic[-1]; enum skin_tone_e skin_tone; enum handedness_e handedness; enum playertype_e player_type; int rookie_season; int longevity; struct player_accolade_s *accolades; union { struct pitcher_s *pitching; struct batter_s *batting; } details; }

user_defined_types: struct player_accolade_s { int player_id; int season; enum accolade_e accolade; }

user_defined_types: struct pitcher_s { int player_id; int speed; int control; int bunt; int fatigue; struct pitcher_stats_s *stats; struct pitcher_accolade_s *accolades; }

user_defined_types: struct batter_s { int player_id; int power; int hit_n_run; int bunt; int running; int range; int arm; enum position_e primary_position; enum position_e secondary_position; struct batter_stats_s *stats; struct batter_accolade_s *accolades; }

user_defined_types: struct pitcher_stats_s { int player_id; int season; enum season_phase_e season_phase; int wins; int losses; int games; int saves; struct innings_s innings; int hits; int earned_runs; int home_runs; int walks; int strike_outs; }

user_defined_types: struct pitcher_accolade_s { int player_id; int season; enum pitching_accolade_e accolade; }

user_defined_types: struct batter_stats_s { int player_id; int season; enum season_phase_e season_phase; int games; int at_bats; int runs; int hits; int doubles; int triples; int home_runs; int runs_batted_in; int walks; int strike_outs; int steals; int errors; }

user_defined_types: struct batter_accolade_s { int player_id; int season; enum batting_accolade_e accolade; }