freeOrgLeagues

decompiled_code:
void __fastcall freeOrgLeagues(void *ptr)
{
char *v1; // rbx

if ( *(_QWORD *)ptr )
{
v1 = (char *)ptr + 8;
do
{
free_league();
v1 += 8;
}
while ( *((_QWORD *)v1 - 1) );
}
free(ptr);
}

canonical_decompiled_code:
void __fastcall func11(void *ptr)
{
char *v1; // rbx

if ( *(_QWORD *)ptr )
{
v1 = (char *)ptr + 8;
do
{
free_league();
v1 += 8;
}
while ( *((_QWORD *)v1 - 1) );
}
free(ptr);
}

original_code:
void freeOrgLeagues( org_league_s *org_leagues )
{
     for ( int i = 0; org_leagues[i].league != ((void *)0); ++i )
     {
          free_league( org_leagues[i].league );
     }
     free( org_leagues );
}

canonical_original_code:
void freeOrgLeagues(struct org_league_s *org_leagues)
{
     for ( int i = 0; org_leagues[i].league != ((void *)0); ++i )
     {
          free_league( org_leagues[i].league );
     }
     free( org_leagues );
}

user_defined_types: struct league_team_s { int league_id; int team_id; struct team_s *team; }

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: enum season_phase_e { sp_None=0, sp_Regular=1, sp_Playoff=2, sp_Allstar=3 }

user_defined_types: enum league_accolade_e { lacc_None=0, lacc_World_Title=1, lacc_Best_Record=2, lacc_All_Star_Champion=3 }

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_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: enum division_accolade_e { dacc_None=0, dacc_World_Title=1, dacc_League_Title=2, dacc_Best_Record=3 }

user_defined_types: 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 }

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: 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 }

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: enum skin_tone_e { st_None=0, st_Light=1, st_Dark=2 }

user_defined_types: enum handedness_e { hnd_None=0, hnd_Right=1, hnd_Left=2, hnd_Switch=3 }

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

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

user_defined_types: 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 }

user_defined_types: 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 }

user_defined_types: struct innings_s { int innings; int outs; }

user_defined_types: 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 }

user_defined_types: 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 }


freeOrg

repo: zjentohlauedy/MBA

decompiled_code:
void __fastcall freeOrg(void *ptr)
{
void *v2; // rdi

v2 = *(void **)ptr;
if ( v2 )
freeOrgLeagues(v2);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func12(void *ptr)
{
void *v2; // rdi

v2 = *(void **)ptr;
if ( v2 )
func11(v2);
free(ptr);
}

original_code:
void freeOrg( org_s *org )
{
     if ( org->leagues != ((void *)0) )
     {
          freeOrgLeagues( org->leagues );
     }
     free( org );
}

canonical_original_code:
void freeOrg(struct org_s *org)
{
     if ( org->leagues != ((void *)0) )
     {
          freeOrgLeagues( org->leagues );
     }
     free( org );
}

variable_types: struct org_s { struct org_league_s { struct league_s { int league_id; char name[-1]; struct league_division_s { int league_id; int division_id; 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; } *division; } *divisions; struct league_team_s { int league_id; int team_id; struct team_s *team; } *teams; 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; } *stats; struct league_accolade_s { int league_id; int season; enum league_accolade_e { lacc_None=0, lacc_World_Title=1, lacc_Best_Record=2, lacc_All_Star_Champion=3 } accolade; } *accolades; } *league; } *leagues; } *

return_type: void

user_defined_types: struct org_s { struct org_league_s *leagues; }

user_defined_types: struct org_league_s { struct league_s *league; }

user_defined_types: struct league_s { int league_id; char name[-1]; struct league_division_s *divisions; struct league_team_s *teams; struct league_stats_s *stats; struct league_accolade_s *accolades; }

user_defined_types: struct league_division_s { int league_id; int division_id; struct division_s *division; }

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 league_accolade_s { int league_id; int season; enum league_accolade_e accolade; }

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 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_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 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; }


decompiled_code:
void __fastcall free_league_divisions(void *ptr)
{
char *v1; // rbx

if ( *(int *)ptr >= 0 )
{
v1 = (char *)ptr + 16;
do
{
if ( *((_QWORD *)v1 - 1) )
free_division();
v1 += 16;
}
while ( *((int *)v1 - 4) >= 0 );
}
free(ptr);
}

canonical_decompiled_code:
void __fastcall func17(void *ptr)
{
char *v1; // rbx

if ( *(int *)ptr >= 0 )
{
v1 = (char *)ptr + 16;
do
{
if ( *((_QWORD *)v1 - 1) )
free_division();
v1 += 16;
}
while ( *((int *)v1 - 4) >= 0 );
}
free(ptr);
}

original_code:
void free_league_divisions( league_division_s *league_divisions )
{
     for ( int i = 0; league_divisions[i].league_id >= 0; ++i )
     {
          if ( league_divisions[i].division != ((void *)0) ) free_division( league_divisions[i].division );
     }
     free( league_divisions );
}

canonical_original_code:
void free_league_divisions(struct league_division_s *league_divisions)
{
     for ( int i = 0; league_divisions[i].league_id >= 0; ++i )
     {
          if ( league_divisions[i].division != ((void *)0) ) free_division( league_divisions[i].division );
     }
     free( league_divisions );
}

variable_types: struct league_division_s { int league_id; int division_id; 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; } *division; } *

variable_types: i int

user_defined_types: struct league_division_s { int league_id; int division_id; struct division_s *division; }

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

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


decompiled_code:
void __fastcall free_league_teams(void *ptr)
{
char *v1; // rbx

if ( *(int *)ptr >= 0 )
{
v1 = (char *)ptr + 16;
do
{
if ( *((_QWORD *)v1 - 1) )
free_team();
v1 += 16;
}
while ( *((int *)v1 - 4) >= 0 );
}
free(ptr);
}

canonical_decompiled_code:
void __fastcall func18(void *ptr)
{
char *v1; // rbx

if ( *(int *)ptr >= 0 )
{
v1 = (char *)ptr + 16;
do
{
if ( *((_QWORD *)v1 - 1) )
free_team();
v1 += 16;
}
while ( *((int *)v1 - 4) >= 0 );
}
free(ptr);
}

original_code:
void free_league_teams( league_team_s *league_teams )
{
     for ( int i = 0; league_teams[i].league_id >= 0; ++i )
     {
          if ( league_teams[i].team != ((void *)0) ) free_team( league_teams[i].team );
     }
     free( league_teams );
}

canonical_original_code:
void free_league_teams(struct league_team_s *league_teams)
{
     for ( int i = 0; league_teams[i].league_id >= 0; ++i )
     {
          if ( league_teams[i].team != ((void *)0) ) free_team( league_teams[i].team );
     }
     free( league_teams );
}

variable_types: struct league_team_s { int league_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; } *

user_defined_types: struct league_team_s { int league_id; int team_id; struct team_s *team; }

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


decompiled_code:
void __fastcall free_league(void *ptr)
{
void *v2; // rdi
void *v3; // rdi
void *v4; // rdi
void *v5; // rdi

v2 = (void *)*((_QWORD *)ptr + 4);
if ( v2 )
free_league_divisions(v2);
v3 = (void *)*((_QWORD *)ptr + 5);
if ( v3 )
free_league_teams(v3);
v4 = (void *)*((_QWORD *)ptr + 6);
if ( v4 )
free(v4);
v5 = (void *)*((_QWORD *)ptr + 7);
if ( v5 )
free(v5);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func19(void *ptr)
{
void *v2; // rdi
void *v3; // rdi
void *v4; // rdi
void *v5; // rdi

v2 = (void *)*((_QWORD *)ptr + 4);
if ( v2 )
func17(v2);
v3 = (void *)*((_QWORD *)ptr + 5);
if ( v3 )
func18(v3);
v4 = (void *)*((_QWORD *)ptr + 6);
if ( v4 )
free(v4);
v5 = (void *)*((_QWORD *)ptr + 7);
if ( v5 )
free(v5);
free(ptr);
}

original_code:
void free_league( league_s *league )
{
     if ( league->divisions != ((void *)0) ) free_league_divisions( league->divisions );
     if ( league->teams != ((void *)0) ) free_league_teams( league->teams );
     if ( league->stats != ((void *)0) ) free( league->stats );
     if ( league->accolades != ((void *)0) ) free( league->accolades );
     free( league );
}

canonical_original_code:
void free_league(struct league_s *league)
{
     if ( league->divisions != ((void *)0) ) free_league_divisions( league->divisions );
     if ( league->teams != ((void *)0) ) free_league_teams( league->teams );
     if ( league->stats != ((void *)0) ) free( league->stats );
     if ( league->accolades != ((void *)0) ) free( league->accolades );
     free( league );
}

variable_types: struct league_s { int league_id; char name[-1]; struct league_division_s { int league_id; int division_id; 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; } *division; } *divisions; struct league_team_s { int league_id; int team_id; struct team_s *team; } *teams; 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; } *stats; struct league_accolade_s { int league_id; int season; enum league_accolade_e { lacc_None=0, lacc_World_Title=1, lacc_Best_Record=2, lacc_All_Star_Champion=3 } accolade; } *accolades; } *

user_defined_types: struct league_s { int league_id; char name[-1]; struct league_division_s *divisions; struct league_team_s *teams; struct league_stats_s *stats; struct league_accolade_s *accolades; }

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 league_accolade_s { int league_id; int season; enum league_accolade_e accolade; }

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 team_player_s { int team_id; int season; int player_id; struct player_s *player; }

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


uniqueColors

decompiled_code:
_BOOL8 __fastcall uniqueColors(int a1, int a2)
{
char v2; // cl
char v3; // dl
_BOOL8 result; // rax

v2 = colors[8 * a1];
v3 = colors[8 * a2];
result = 0LL;
if ( v2 != v3 )
result = v3 != byte_4E1[8 * a1] && byte_4E1[8 * a1] != byte_4E1[8 * a2] && v2 != byte_4E1[8 * a2];
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(int a1, int a2)
{
char v2; // cl
char v3; // dl
_BOOL8 result; // rax

v2 = colors[8 * a1];
v3 = colors[8 * a2];
result = 0LL;
if ( v2 != v3 )
result = v3 != byte_4E1[8 * a1] && byte_4E1[8 * a1] != byte_4E1[8 * a2] && v2 != byte_4E1[8 * a2];
return result;
}

original_code:
static int uniqueColors( const int t1, const int t2 )
{
     if ( colors[t1].color1 == colors[t2].color1 ) return 0;
     if ( colors[t1].color2 == colors[t2].color2 ) return 0;
     if ( colors[t1].color1 == colors[t2].color2 ) return 0;
     if ( colors[t1].color2 == colors[t2].color1 ) return 0;
     return 1;
}

canonical_original_code:
static int uniqueColors(int t1, int t2)
{
     if ( colors[t1].color1 == colors[t2].color1 ) return 0;
     if ( colors[t1].color2 == colors[t2].color2 ) return 0;
     if ( colors[t1].color1 == colors[t2].color2 ) return 0;
     if ( colors[t1].color2 == colors[t2].color1 ) return 0;
     return 1;
}

return_type: int


getFileTeam

decompiled_code:
__int64 __fastcall getFileTeam(void *s1, void *s2)
{
size_t v3; // rax
size_t v4; // r12
unsigned int i; // ebp

v3 = strlen((const char *)s2);
v4 = 12LL;
if ( v3 <= 0xC )
v4 = v3;
for ( i = 0; i != 32; ++i )
{
if ( !memcmp(s1, s2, v4) )
break;
s1 = (char *)s1 + 16;
}
return i;
}

canonical_decompiled_code:
__int64 __fastcall func1(void *s1, void *s2)
{
size_t v3; // rax
size_t v4; // r12
unsigned int i; // ebp

v3 = strlen((const char *)s2);
v4 = 12LL;
if ( v3 <= 0xC )
v4 = v3;
for ( i = 0; i != 32; ++i )
{
if ( !memcmp(s1, s2, v4) )
break;
s1 = (char *)s1 + 16;
}
return i;
}

original_code:
static int getFileTeam( const fileteam_s *teams, const char *team )
{
     int i;
     for ( i = 0; i < ((8 * 2) * 2); ++i )
     {
   if ( memcmp( teams[i].name, team, ((strlen(team)) < (sizeof(teams[i].name))) ? (strlen(team)) : (sizeof(teams[i].name)) ) == 0 ) return i;
     }
}

canonical_original_code:
static int getFileTeam(struct fileteam_s *teams, char *team)
{
     int i;
     for ( i = 0; i < ((8 * 2) * 2); ++i )
     {
   if ( memcmp( teams[i].name, team, ((strlen(team)) < (sizeof(teams[i].name))) ? (strlen(team)) : (sizeof(teams[i].name)) ) == 0 ) return i;
     }
}

variable_types: struct fileteam_s { unsigned char name[12]; unsigned char color[1]; unsigned char wins[1]; unsigned char losses[1]; unsigned char term[1]; } *

variable_types:
team
char *


setColors

decompiled_code:
__int64 __fastcall setColors(void *s1, void *a2, void *a3)
{
int v4; // ebp
int v5; // er12
char *v6; // r13
char v7; // r14
char *v8; // rbx
char v9; // r15
__int64 result; // rax
char v11; // al

v4 = getFileTeam(s1, a2);
v5 = getFileTeam(s1, a3);
v6 = (char *)s1 + 16 * v4;
v7 = colors[8 * v4];
v6[12] = v7;
v8 = (char *)s1 + 16 * v5;
v9 = colors[8 * v5];
v8[12] = v9;
if ( v9 == v6[12] )
{
v11 = byte_4E1[8 * v4];
v6[12] = v11;
if ( v11 == v8[12] )
v8[12] = byte_4E1[8 * v5];
}
if ( !dword_4E4[2 * v4] )
{
result = v5;
if ( !dword_4E4[2 * v5] )
return result;
result = uniqueColors(v4, v5);
if ( !(_DWORD)result )
return result;
LABEL_14:
result = roll(100);
if ( (int)result > 49 )
{
result = (unsigned __int8)byte_4E1[8 * v5];
v8[12] = result;
}
else
{
v8[12] = v9;
}
return result;
}
result = uniqueColors(v4, v5);
if ( (_DWORD)result )
{
v6[12] = (int)roll(100) > 49 ? byte_4E1[8 * v4] : v7;
result = v5;
if ( dword_4E4[2 * v5] )
goto LABEL_14;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(void *s1, void *a2, void *a3)
{
int v4; // ebp
int v5; // er12
char *v6; // r13
char v7; // r14
char *v8; // rbx
char v9; // r15
__int64 result; // rax
char v11; // al

v4 = func1(s1, a2);
v5 = func1(s1, a3);
v6 = (char *)s1 + 16 * v4;
v7 = colors[8 * v4];
v6[12] = v7;
v8 = (char *)s1 + 16 * v5;
v9 = colors[8 * v5];
v8[12] = v9;
if ( v9 == v6[12] )
{
v11 = byte_4E1[8 * v4];
v6[12] = v11;
if ( v11 == v8[12] )
v8[12] = byte_4E1[8 * v5];
}
if ( !dword_4E4[2 * v4] )
{
result = v5;
if ( !dword_4E4[2 * v5] )
return result;
result = func0(v4, v5);
if ( !(_DWORD)result )
return result;
LABEL_14:
result = func2(100);
if ( (int)result > 49 )
{
result = (unsigned __int8)byte_4E1[8 * v5];
v8[12] = result;
}
else
{
v8[12] = v9;
}
return result;
}
result = func0(v4, v5);
if ( (_DWORD)result )
{
v6[12] = (int)func2(100) > 49 ? byte_4E1[8 * v4] : v7;
result = v5;
if ( dword_4E4[2 * v5] )
goto LABEL_14;
}
return result;
}

original_code:
static void setColors( fileteam_s *teams, const char *road, const char *home )
{
     int road_idx = getFileTeam( teams, road );
     int home_idx = getFileTeam( teams, home );
     teams[road_idx].color[0] = colors[road_idx].color1;
     teams[home_idx].color[0] = colors[home_idx].color1;
     if ( teams[road_idx].color[0] == teams[home_idx].color[0] )
     {
   teams[road_idx].color[0] = colors[road_idx].color2;
   if ( teams[road_idx].color[0] == teams[home_idx].color[0] )
   {
        teams[home_idx].color[0] = colors[home_idx].color2;
   }
     }
     if ( colors[road_idx].alternate && uniqueColors( road_idx, home_idx ) )
     {
   if ( roll( 100 ) < 50 ) teams[road_idx].color[0] = colors[road_idx].color1;
   else teams[road_idx].color[0] = colors[road_idx].color2;
     }
     if ( colors[home_idx].alternate && uniqueColors( road_idx, home_idx ) )
     {
   if ( roll( 100 ) < 50 ) teams[home_idx].color[0] = colors[home_idx].color1;
   else teams[home_idx].color[0] = colors[home_idx].color2;
     }
}

canonical_original_code:
static void setColors(struct fileteam_s *teams, char *road, char *home)
{
     int road_idx = getFileTeam( teams, road );
     int home_idx = getFileTeam( teams, home );
     teams[road_idx].color[0] = colors[road_idx].color1;
     teams[home_idx].color[0] = colors[home_idx].color1;
     if ( teams[road_idx].color[0] == teams[home_idx].color[0] )
     {
   teams[road_idx].color[0] = colors[road_idx].color2;
   if ( teams[road_idx].color[0] == teams[home_idx].color[0] )
   {
        teams[home_idx].color[0] = colors[home_idx].color2;
   }
     }
     if ( colors[road_idx].alternate && uniqueColors( road_idx, home_idx ) )
     {
   if ( roll( 100 ) < 50 ) teams[road_idx].color[0] = colors[road_idx].color1;
   else teams[road_idx].color[0] = colors[road_idx].color2;
     }
     if ( colors[home_idx].alternate && uniqueColors( road_idx, home_idx ) )
     {
   if ( roll( 100 ) < 50 ) teams[home_idx].color[0] = colors[home_idx].color1;
   else teams[home_idx].color[0] = colors[home_idx].color2;
     }
}

variable_types:
road
char *

variable_types:
home
char *

user_defined_types: struct fileteam_s { unsigned char name[12]; unsigned char color[1]; unsigned char wins[1]; unsigned char losses[1]; unsigned char term[1]; }


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
char *v4; // rbp
char *v5; // rax
char *v6; // r15
size_t v7; // rbx
int result; // eax
char *v9; // rbx
char *v10; // rbp
unsigned __int8 v11; // r12
unsigned __int8 v12; // di
const char *v13; // r13
const char *v14; // rax
char s[32]; // [rsp+10h] [rbp-2F8h] BYREF
char v16[32]; // [rsp+30h] [rbp-2D8h] BYREF
char v17[648]; // [rsp+50h] [rbp-2B8h] BYREF
char v18; // [rsp+2D8h] [rbp-30h] BYREF

v3 = time(0LL);
srand(v3);
if ( argc <= 2 )
{
printf("Usage: %s <input file> <output file>\n", *argv);
result = 0;
}
else
{
v4 = getenv("GAMES");
if ( v4 )
{
v5 = (char *)readLeagueFile(argv[1]);
v6 = v5;
if ( v5 )
{
qmemcpy(v17, v5, 0x27CuLL);
while ( (unsigned int)_isoc99_sscanf(v4, "%s %s ", s, v16) != -1 )
{
setColors(v6 + 124, s, v16);
v7 = strlen(s);
v4 += v7 + strlen(v16) + 2;
}
v9 = &v17[136];
v10 = v6 + 124;
do
{
v11 = *v9;
v12 = v10[12];
if ( *v9 != v12 )
{
v13 = (const char *)getColorName(v12);
v14 = (const char *)getColorName(v11);
printf("%s changed from %s to %s uniforms.\n", v10, v14, v13);
}
v9 += 16;
v10 += 16;
}
while ( v9 != &v18 );
if ( (unsigned int)writeLeagueFile(argv[2], v6) )
{
free(v6);
result = 0;
}
else
{
puts("Cannot save league changes.");
free(v6);
result = 1;
}
}
else
{
printf("Cannot load league file.");
result = 1;
}
}
else
{
puts("Environment variable GAMES not found.");
result = 1;
}
}
return result;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
char *v4; // rbp
char *v5; // rax
char *v6; // r15
size_t v7; // rbx
int result; // eax
char *v9; // rbx
char *v10; // rbp
unsigned __int8 v11; // r12
unsigned __int8 v12; // di
const char *v13; // r13
const char *v14; // rax
char s[32]; // [rsp+10h] [rbp-2F8h] BYREF
char v16[32]; // [rsp+30h] [rbp-2D8h] BYREF
char v17[648]; // [rsp+50h] [rbp-2B8h] BYREF
char v18; // [rsp+2D8h] [rbp-30h] BYREF

v3 = time(0LL);
srand(v3);
if ( argc <= 2 )
{
printf("Usage: %s <input file> <output file>\n", *argv);
result = 0;
}
else
{
v4 = getenv("GAMES");
if ( v4 )
{
v5 = (char *)readLeagueFile(argv[1]);
v6 = v5;
if ( v5 )
{
qmemcpy(v17, v5, 0x27CuLL);
while ( (unsigned int)_isoc99_sscanf(v4, "%s %s ", s, v16) != -1 )
{
func3(v6 + 124, s, v16);
v7 = strlen(s);
v4 += v7 + strlen(v16) + 2;
}
v9 = &v17[136];
v10 = v6 + 124;
do
{
v11 = *v9;
v12 = v10[12];
if ( *v9 != v12 )
{
v13 = (const char *)getColorName(v12);
v14 = (const char *)getColorName(v11);
printf("%s changed from %s to %s uniforms.\n", v10, v14, v13);
}
v9 += 16;
v10 += 16;
}
while ( v9 != &v18 );
if ( (unsigned int)writeLeagueFile(argv[2], v6) )
{
free(v6);
result = 0;
}
else
{
puts("Cannot save league changes.");
free(v6);
result = 1;
}
}
else
{
printf("Cannot load league file.");
result = 1;
}
}
else
{
puts("Environment variable GAMES not found.");
result = 1;
}
}
return result;
}

original_code:
int main( const int argc, const char *argv[] )
{
     fileleague_s *leagueFile;
     fileleague_s before;
     char *games;
     char home[20];
     char road[20];
     int i;
     srand( time( ((void *)0) ) );
     if ( argc < 3 )
     {
   printf( "Usage: %s <input file> <output file>\n", argv[0] );
   return 0;
     }
     if ( (games = getenv( "GAMES" )) == ((void *)0) )
     {
   printf( "Environment variable GAMES not found.\n" );
   return 1;
     }
     if ( (leagueFile = readLeagueFile( argv[1] )) == ((void *)0) )
     {
          printf( "Cannot load league file." );
          return 1;
     }
     before = *leagueFile;
     while ( sscanf( games, "%s %s ", road, home ) != (-1) )
     {
   setColors( leagueFile->teams, road, home );
   games += strlen(road) + strlen(home) + 2;
     }
     for ( i = 0; i < ((8 * 2) * 2); ++i )
     {
   if ( before.teams[i].color[0] != leagueFile->teams[i].color[0] )
   {
        printf( "%s changed from %s to %s uniforms.\n",
         leagueFile->teams[i].name,
         getColorName( before.teams[i].color[0] ),
         getColorName( leagueFile->teams[i].color[0] ) );
   }
     }
     if ( ! writeLeagueFile( argv[2], leagueFile ) )
     {
          printf( "Cannot save league changes.\n" );
          free( leagueFile );
          return 1;
     }
     free( leagueFile );
     return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
     struct fileleague_s *leagueFile;
     struct fileleague_s before;
     char *games;
     char home[20];
     char road[20];
     int i;
     srand( time( ((void *)0) ) );
     if ( argc < 3 )
     {
   printf( "Usage: %s <input file> <output file>\n", argv[0] );
   return 0;
     }
     if ( (games = getenv( "GAMES" )) == ((void *)0) )
     {
   printf( "Environment variable GAMES not found.\n" );
   return 1;
     }
     if ( (leagueFile = readLeagueFile( argv[1] )) == ((void *)0) )
     {
          printf( "Cannot load league file." );
          return 1;
     }
     before = *leagueFile;
     while ( sscanf( games, "%s %s ", road, home ) != (-1) )
     {
   setColors( leagueFile->teams, road, home );
   games += strlen(road) + strlen(home) + 2;
     }
     for ( i = 0; i < ((8 * 2) * 2); ++i )
     {
   if ( before.teams[i].color[0] != leagueFile->teams[i].color[0] )
   {
        printf( "%s changed from %s to %s uniforms.\n",
         leagueFile->teams[i].name,
         getColorName( before.teams[i].color[0] ),
         getColorName( leagueFile->teams[i].color[0] ) );
   }
     }
     if ( ! writeLeagueFile( argv[2], leagueFile ) )
     {
          printf( "Cannot save league changes.\n" );
          free( leagueFile );
          return 1;
     }
     free( leagueFile );
     return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: struct fileleague_s { unsigned char header[52]; unsigned char league1[12]; unsigned char league2[12]; unsigned char division1[12]; unsigned char division2[12]; unsigned char division3[12]; unsigned char division4[12]; struct fileteam_s { unsigned char name[12]; unsigned char color[1]; unsigned char wins[1]; unsigned char losses[1]; unsigned char term[1]; } teams[32]; } *

variable_types:
games
char *

variable_types:
home
char [20]

variable_types:
road
char [20]

user_defined_types: struct fileleague_s { unsigned char header[52]; unsigned char league1[12]; unsigned char league2[12]; unsigned char division1[12]; unsigned char division2[12]; unsigned char division3[12]; unsigned char division4[12]; struct fileteam_s teams[32]; }


decompiled_code:
char *formatAmigaToDos_ShouldMovePitcherSimulatedStartsToActionGames_GivenAPlayersFile()
{
__int64 v0; // r12
__int64 v1; // rbx
int v2; // ebp
unsigned int v3; // ebx
__int64 v4; // r8
char *result; // rax

v0 = buildFilePlayers();
v1 = v0;
v2 = 0;
while ( (unsigned int)nibble(*(unsigned __int8 *)(v1 + 47), 1LL) )
{
++v2;
v1 += 112LL;
if ( v2 == 800 )
{
v2 = 0;
v3 = 0;
goto LABEL_6;
}
}
v3 = byte2int(v1 + 100);
LABEL_6:
formatAmigaToDos(v0);
v4 = (unsigned int)byte2int(v0 + 112LL * v2 + 93);
result = 0LL;
if ( v3 != (_DWORD)v4 )
{
sprintf(
_unit_test_msgbuf__,
"\x1B[0;31mFailed: %s; expected: %d, actual: %d\x1B[0m",
"byte2int( act->acc_games )",
v3,
v4);
result = _unit_test_msgbuf__;
}
return result;
}

canonical_decompiled_code:
char *func0()
{
__int64 v0; // r12
__int64 v1; // rbx
int v2; // ebp
unsigned int v3; // ebx
__int64 v4; // r8
char *result; // rax

v0 = buildFilePlayers();
v1 = v0;
v2 = 0;
while ( (unsigned int)nibble(*(unsigned __int8 *)(v1 + 47), 1LL) )
{
++v2;
v1 += 112LL;
if ( v2 == 800 )
{
v2 = 0;
v3 = 0;
goto LABEL_6;
}
}
v3 = byte2int(v1 + 100);
LABEL_6:
formatAmigaToDos(v0);
v4 = (unsigned int)byte2int(v0 + 112LL * v2 + 93);
result = 0LL;
if ( v3 != (_DWORD)v4 )
{
sprintf(
_unit_test_msgbuf__,
"\x1B[0;31mFailed: %s; expected: %d, actual: %d\x1B[0m",
"byte2int( act->acc_games )",
v3,
v4);
result = _unit_test_msgbuf__;
}
return result;
}

original_code:
static char *formatAmigaToDos_ShouldMovePitcherSimulatedStartsToActionGames_GivenAPlayersFile()
{
     fileplayer_s *players_file = buildFilePlayers();
     int expected_games = 0;
     int player_idx = 0;
     for ( int i = 0; i < (((25 * 8) * 2) * 2); ++i )
     {
          int pos = nibble( players_file[i].position[0], n_High );
          if ( pos == fpos_Pitcher )
          {
               acc_pch_stats_s *sim = &(players_file[i].acc_stats.simulated.pitching);
               expected_games = byte2int( sim->acc_starts );
               player_idx = i;
               break;
          }
     }
     formatAmigaToDos( players_file );
     acc_bat_stats_s *act = &(players_file[player_idx].acc_stats.action.batting);
     do { int __expected__ = (expected_games); int __actual__ = (byte2int( act->acc_games )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "byte2int( act->acc_games )", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     return ((void *)0);
}

canonical_original_code:
static char *formatAmigaToDos_ShouldMovePitcherSimulatedStartsToActionGames_GivenAPlayersFile()
{
     struct fileplayer_s *players_file = buildFilePlayers();
     int expected_games = 0;
     int player_idx = 0;
     for ( int i = 0; i < (((25 * 8) * 2) * 2); ++i )
     {
          int pos = nibble( players_file[i].position[0], n_High );
          if ( pos == fpos_Pitcher )
          {
               struct acc_pch_stats_s *sim = &(players_file[i].acc_stats.simulated.pitching);
               expected_games = byte2int( sim->acc_starts );
               player_idx = i;
               break;
          }
     }
     formatAmigaToDos( players_file );
     struct acc_bat_stats_s *act = &(players_file[player_idx].acc_stats.action.batting);
     do { int __expected__ = (expected_games); int __actual__ = (byte2int( act->acc_games )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "byte2int( act->acc_games )", __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; } *

variable_types: pos int

variable_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]; } *

variable_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]; } *

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


decompiled_code:
__int64 formatAmigaToDos_ShouldSwapBatterSimulatedWithAction_GivenAPlayersFile()
{
__int64 v0; // r12
unsigned __int8 *v1; // rbx
int i; // ebp
__int64 v3; // r12
__int64 result; // rax
_BYTE v5[14]; // [rsp+4h] [rbp-44h] BYREF
__int64 v6[6]; // [rsp+12h] [rbp-36h] BYREF

v0 = buildFilePlayers();
v6[0] = 0LL;
LODWORD(v6[1]) = 0;
WORD2(v6[1]) = 0;
*(_QWORD *)v5 = 0LL;
*(_DWORD *)&v5[8] = 0;
*(_WORD *)&v5[12] = 0;
v1 = (unsigned __int8 *)v0;
for ( i = 0; i != 800; ++i )
{
if ( (unsigned int)nibble(v1[47], 1LL) && (int)byte2int(v1 + 109) <= 224 && (int)byte2int(v1 + 106) <= 224 )
{
qmemcpy(v5, v1 + 98, sizeof(v5));
qmemcpy(v6, v1 + 84, 0xEuLL);
goto LABEL_8;
}
v1 += 112;
}
i = 0;
LABEL_8:
formatAmigaToDos(v0);
v3 = 112LL * i + v0;
result = compareBattingStats(v5, v3 + 84);
if ( !result )
result = compareBattingStats(v6, v3 + 98);
return result;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 v0; // r12
unsigned __int8 *v1; // rbx
int i; // ebp
__int64 v3; // r12
__int64 result; // rax
_BYTE v5[14]; // [rsp+4h] [rbp-44h] BYREF
__int64 v6[6]; // [rsp+12h] [rbp-36h] BYREF

v0 = buildFilePlayers();
v6[0] = 0LL;
LODWORD(v6[1]) = 0;
WORD2(v6[1]) = 0;
*(_QWORD *)v5 = 0LL;
*(_DWORD *)&v5[8] = 0;
*(_WORD *)&v5[12] = 0;
v1 = (unsigned __int8 *)v0;
for ( i = 0; i != 800; ++i )
{
if ( (unsigned int)nibble(v1[47], 1LL) && (int)byte2int(v1 + 109) <= 224 && (int)byte2int(v1 + 106) <= 224 )
{
qmemcpy(v5, v1 + 98, sizeof(v5));
qmemcpy(v6, v1 + 84, 0xEuLL);
goto LABEL_8;
}
v1 += 112;
}
i = 0;
LABEL_8:
formatAmigaToDos(v0);
v3 = 112LL * i + v0;
result = compareBattingStats(v5, v3 + 84);
if ( !result )
result = compareBattingStats(v6, v3 + 98);
return result;
}

original_code:
static char *formatAmigaToDos_ShouldSwapBatterSimulatedWithAction_GivenAPlayersFile()
{
     fileplayer_s *players_file = buildFilePlayers();
     acc_bat_stats_s expected_sim = { 0 };
     acc_bat_stats_s expected_act = { 0 };
     int player_idx = 0;
     for ( int i = 0; i < (((25 * 8) * 2) * 2); ++i )
     {
          int pos = nibble( players_file[i].position[0], n_High );
          if ( pos != fpos_Pitcher )
          {
               if ( byte2int( players_file[i].acc_stats.simulated.batting.acc_rbi ) < 225 &&
                    byte2int( players_file[i].acc_stats.simulated.batting.acc_so ) < 225 )
               {
                    expected_act = players_file[i].acc_stats.simulated.batting;
                    expected_sim = players_file[i].acc_stats.action.batting;
                    player_idx = i;
                    break;
               }
          }
     }
     formatAmigaToDos( players_file );
     do { char *ret; if ( (ret = _compareBattingStats( (&expected_act), (&(players_file[player_idx].acc_stats.action.batting)) )) != ((void *)0) ) return ret; } while ( 0 );
     do { char *ret; if ( (ret = _compareBattingStats( (&expected_sim), (&(players_file[player_idx].acc_stats.simulated.batting)) )) != ((void *)0) ) return ret; } while ( 0 );
     return ((void *)0);
}

canonical_original_code:
static char *formatAmigaToDos_ShouldSwapBatterSimulatedWithAction_GivenAPlayersFile()
{
     struct fileplayer_s *players_file = buildFilePlayers();
     struct acc_bat_stats_s expected_sim = { 0 };
     struct acc_bat_stats_s expected_act = { 0 };
     int player_idx = 0;
     for ( int i = 0; i < (((25 * 8) * 2) * 2); ++i )
     {
          int pos = nibble( players_file[i].position[0], n_High );
          if ( pos != fpos_Pitcher )
          {
               if ( byte2int( players_file[i].acc_stats.simulated.batting.acc_rbi ) < 225 &&
                    byte2int( players_file[i].acc_stats.simulated.batting.acc_so ) < 225 )
               {
                    expected_act = players_file[i].acc_stats.simulated.batting;
                    expected_sim = players_file[i].acc_stats.action.batting;
                    player_idx = i;
                    break;
               }
          }
     }
     formatAmigaToDos( players_file );
     do { char *ret; if ( (ret = _compareBattingStats( (&expected_act), (&(players_file[player_idx].acc_stats.action.batting)) )) != ((void *)0) ) return ret; } while ( 0 );
     do { char *ret; if ( (ret = _compareBattingStats( (&expected_sim), (&(players_file[player_idx].acc_stats.simulated.batting)) )) != ((void *)0) ) return ret; } while ( 0 );
     return ((void *)0);
}

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

variable_types: i int

variable_types:
ret
char *

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: 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_player_id_s { unsigned char player_id[2]; unsigned char checksum[1]; unsigned char filler[11]; }


decompiled_code:
char *formatAmigaToDos_ShouldCapRBIAndMoveExcessFromSimulatedToAction_GivenAPlayersFile()
{
__int64 v0; // r12
__int64 v1; // rbx
int v2; // ebp
__int64 v3; // r12
unsigned int v4; // eax
char *result; // rax
__int64 v6; // r8

v0 = buildFilePlayers();
v1 = v0;
v2 = 0;
while ( !(unsigned int)nibble(*(unsigned __int8 *)(v1 + 47), 1LL) )
{
++v2;
v1 += 112LL;
if ( v2 == 800 )
{
v2 = 0;
goto LABEL_6;
}
}
int2byte(v1 + 109, 247LL);
int2byte(v1 + 95, 0LL);
LABEL_6:
formatAmigaToDos(v0);
v3 = 112LL * v2 + v0;
v4 = byte2int(v3 + 95);
if ( v4 == 225 )
{
v6 = (unsigned int)byte2int(v3 + 109);
result = 0LL;
if ( (_DWORD)v6 != 22 )
{
sprintf(
_unit_test_msgbuf__,
"\x1B[0;31mFailed: %s; expected: %d, actual: %d\x1B[0m",
"byte2int( players_file[player_idx].acc_stats.simulated.batting.acc_rbi )",
22LL,
v6);
result = _unit_test_msgbuf__;
}
}
else
{
sprintf(
_unit_test_msgbuf__,
"\x1B[0;31mFailed: %s; expected: %d, actual: %d\x1B[0m",
"byte2int( players_file[player_idx].acc_stats.action.batting.acc_rbi )",
225LL,
v4);
result = _unit_test_msgbuf__;
}
return result;
}

canonical_decompiled_code:
char *func2()
{
__int64 v0; // r12
__int64 v1; // rbx
int v2; // ebp
__int64 v3; // r12
unsigned int v4; // eax
char *result; // rax
__int64 v6; // r8

v0 = buildFilePlayers();
v1 = v0;
v2 = 0;
while ( !(unsigned int)nibble(*(unsigned __int8 *)(v1 + 47), 1LL) )
{
++v2;
v1 += 112LL;
if ( v2 == 800 )
{
v2 = 0;
goto LABEL_6;
}
}
int2byte(v1 + 109, 247LL);
int2byte(v1 + 95, 0LL);
LABEL_6:
formatAmigaToDos(v0);
v3 = 112LL * v2 + v0;
v4 = byte2int(v3 + 95);
if ( v4 == 225 )
{
v6 = (unsigned int)byte2int(v3 + 109);
result = 0LL;
if ( (_DWORD)v6 != 22 )
{
sprintf(
_unit_test_msgbuf__,
"\x1B[0;31mFailed: %s; expected: %d, actual: %d\x1B[0m",
"byte2int( players_file[player_idx].acc_stats.simulated.batting.acc_rbi )",
22LL,
v6);
result = _unit_test_msgbuf__;
}
}
else
{
sprintf(
_unit_test_msgbuf__,
"\x1B[0;31mFailed: %s; expected: %d, actual: %d\x1B[0m",
"byte2int( players_file[player_idx].acc_stats.action.batting.acc_rbi )",
225LL,
v4);
result = _unit_test_msgbuf__;
}
return result;
}

original_code:
static char *formatAmigaToDos_ShouldCapRBIAndMoveExcessFromSimulatedToAction_GivenAPlayersFile()
{
     fileplayer_s *players_file = buildFilePlayers();
     int player_idx = 0;
     for ( int i = 0; i < (((25 * 8) * 2) * 2); ++i )
     {
          int pos = nibble( players_file[i].position[0], n_High );
          if ( pos != fpos_Pitcher )
          {
               int2byte( players_file[i].acc_stats.simulated.batting.acc_rbi, 247 );
               int2byte( players_file[i].acc_stats.action.batting.acc_rbi, 0 );
               player_idx = i;
               break;
          }
     }
     formatAmigaToDos( players_file );
     do { int __expected__ = (225); int __actual__ = (byte2int( players_file[player_idx].acc_stats.action.batting.acc_rbi )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "byte2int( players_file[player_idx].acc_stats.action.batting.acc_rbi )", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     do { int __expected__ = (22); int __actual__ = (byte2int( players_file[player_idx].acc_stats.simulated.batting.acc_rbi )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "byte2int( players_file[player_idx].acc_stats.simulated.batting.acc_rbi )", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     return ((void *)0);
}

canonical_original_code:
static char *formatAmigaToDos_ShouldCapRBIAndMoveExcessFromSimulatedToAction_GivenAPlayersFile()
{
     struct fileplayer_s *players_file = buildFilePlayers();
     int player_idx = 0;
     for ( int i = 0; i < (((25 * 8) * 2) * 2); ++i )
     {
          int pos = nibble( players_file[i].position[0], n_High );
          if ( pos != fpos_Pitcher )
          {
               int2byte( players_file[i].acc_stats.simulated.batting.acc_rbi, 247 );
               int2byte( players_file[i].acc_stats.action.batting.acc_rbi, 0 );
               player_idx = i;
               break;
          }
     }
     formatAmigaToDos( players_file );
     do { int __expected__ = (225); int __actual__ = (byte2int( players_file[player_idx].acc_stats.action.batting.acc_rbi )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "byte2int( players_file[player_idx].acc_stats.action.batting.acc_rbi )", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     do { int __expected__ = (22); int __actual__ = (byte2int( players_file[player_idx].acc_stats.simulated.batting.acc_rbi )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "byte2int( players_file[player_idx].acc_stats.simulated.batting.acc_rbi )", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     return ((void *)0);
}

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


decompiled_code:
char *formatAmigaToDos_ShouldCapStrikeOutsAndMoveExcessFromSimulatedToAction_GivenAPlayersFile()
{
__int64 v0; // r12
__int64 v1; // rbx
int v2; // ebp
__int64 v3; // r12
unsigned int v4; // eax
char *result; // rax
__int64 v6; // r8

v0 = buildFilePlayers();
v1 = v0;
v2 = 0;
while ( !(unsigned int)nibble(*(unsigned __int8 *)(v1 + 47), 1LL) )
{
++v2;
v1 += 112LL;
if ( v2 == 800 )
{
v2 = 0;
goto LABEL_6;
}
}
int2byte(v1 + 106, 229LL);
int2byte(v1 + 92, 0LL);
LABEL_6:
formatAmigaToDos(v0);
v3 = 112LL * v2 + v0;
v4 = byte2int(v3 + 92);
if ( v4 == 225 )
{
v6 = (unsigned int)byte2int(v3 + 106);
result = 0LL;
if ( (_DWORD)v6 != 4 )
{
sprintf(
_unit_test_msgbuf__,
"\x1B[0;31mFailed: %s; expected: %d, actual: %d\x1B[0m",
"byte2int( players_file[player_idx].acc_stats.simulated.batting.acc_so )",
4LL,
v6);
result = _unit_test_msgbuf__;
}
}
else
{
sprintf(
_unit_test_msgbuf__,
"\x1B[0;31mFailed: %s; expected: %d, actual: %d\x1B[0m",
"byte2int( players_file[player_idx].acc_stats.action.batting.acc_so )",
225LL,
v4);
result = _unit_test_msgbuf__;
}
return result;
}

canonical_decompiled_code:
char *func3()
{
__int64 v0; // r12
__int64 v1; // rbx
int v2; // ebp
__int64 v3; // r12
unsigned int v4; // eax
char *result; // rax
__int64 v6; // r8

v0 = buildFilePlayers();
v1 = v0;
v2 = 0;
while ( !(unsigned int)nibble(*(unsigned __int8 *)(v1 + 47), 1LL) )
{
++v2;
v1 += 112LL;
if ( v2 == 800 )
{
v2 = 0;
goto LABEL_6;
}
}
int2byte(v1 + 106, 229LL);
int2byte(v1 + 92, 0LL);
LABEL_6:
formatAmigaToDos(v0);
v3 = 112LL * v2 + v0;
v4 = byte2int(v3 + 92);
if ( v4 == 225 )
{
v6 = (unsigned int)byte2int(v3 + 106);
result = 0LL;
if ( (_DWORD)v6 != 4 )
{
sprintf(
_unit_test_msgbuf__,
"\x1B[0;31mFailed: %s; expected: %d, actual: %d\x1B[0m",
"byte2int( players_file[player_idx].acc_stats.simulated.batting.acc_so )",
4LL,
v6);
result = _unit_test_msgbuf__;
}
}
else
{
sprintf(
_unit_test_msgbuf__,
"\x1B[0;31mFailed: %s; expected: %d, actual: %d\x1B[0m",
"byte2int( players_file[player_idx].acc_stats.action.batting.acc_so )",
225LL,
v4);
result = _unit_test_msgbuf__;
}
return result;
}

original_code:
static char *formatAmigaToDos_ShouldCapStrikeOutsAndMoveExcessFromSimulatedToAction_GivenAPlayersFile()
{
     fileplayer_s *players_file = buildFilePlayers();
     int player_idx = 0;
     for ( int i = 0; i < (((25 * 8) * 2) * 2); ++i )
     {
          int pos = nibble( players_file[i].position[0], n_High );
          if ( pos != fpos_Pitcher )
          {
               int2byte( players_file[i].acc_stats.simulated.batting.acc_so, 229 );
               int2byte( players_file[i].acc_stats.action.batting.acc_so, 0 );
               player_idx = i;
               break;
          }
     }
     formatAmigaToDos( players_file );
     do { int __expected__ = (225); int __actual__ = (byte2int( players_file[player_idx].acc_stats.action.batting.acc_so )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "byte2int( players_file[player_idx].acc_stats.action.batting.acc_so )", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     do { int __expected__ = (4); int __actual__ = (byte2int( players_file[player_idx].acc_stats.simulated.batting.acc_so )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "byte2int( players_file[player_idx].acc_stats.simulated.batting.acc_so )", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     return ((void *)0);
}

canonical_original_code:
static char *formatAmigaToDos_ShouldCapStrikeOutsAndMoveExcessFromSimulatedToAction_GivenAPlayersFile()
{
     struct fileplayer_s *players_file = buildFilePlayers();
     int player_idx = 0;
     for ( int i = 0; i < (((25 * 8) * 2) * 2); ++i )
     {
          int pos = nibble( players_file[i].position[0], n_High );
          if ( pos != fpos_Pitcher )
          {
               int2byte( players_file[i].acc_stats.simulated.batting.acc_so, 229 );
               int2byte( players_file[i].acc_stats.action.batting.acc_so, 0 );
               player_idx = i;
               break;
          }
     }
     formatAmigaToDos( players_file );
     do { int __expected__ = (225); int __actual__ = (byte2int( players_file[player_idx].acc_stats.action.batting.acc_so )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "byte2int( players_file[player_idx].acc_stats.action.batting.acc_so )", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     do { int __expected__ = (4); int __actual__ = (byte2int( players_file[player_idx].acc_stats.simulated.batting.acc_so )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "byte2int( players_file[player_idx].acc_stats.simulated.batting.acc_so )", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     return ((void *)0);
}


createOrg

decompiled_code:
_QWORD *createOrg()
{
_QWORD *result; // rax

result = malloc(8uLL);
if ( result )
*result = 0LL;
return result;
}

canonical_decompiled_code:
_QWORD *func0()
{
_QWORD *result; // rax

result = malloc(8uLL);
if ( result )
*result = 0LL;
return result;
}

original_code:
static org_s *createOrg( void )
{
     org_s *org = ((void *)0);
     if ( (org = malloc( sizeof(org_s) )) == ((void *)0) ) return ((void *)0);
     memset( org, '\0', sizeof(org_s) );
     return org;
}

canonical_original_code:
static struct org_s *createOrg()
{
     struct org_s *org = ((void *)0);
     if ( (org = malloc( sizeof(org_s) )) == ((void *)0) ) return ((void *)0);
     memset( org, '\0', sizeof(org_s) );
     return org;
}

variable_types: struct org_s { struct org_league_s { struct league_s { int league_id; char name[-1]; struct league_division_s { int league_id; int division_id; 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; } *division; } *divisions; struct league_team_s { int league_id; int team_id; struct team_s *team; } *teams; 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; } *stats; struct league_accolade_s { int league_id; int season; enum league_accolade_e { lacc_None=0, lacc_World_Title=1, lacc_Best_Record=2, lacc_All_Star_Champion=3 } accolade; } *accolades; } *league; } *leagues; } *

user_defined_types: struct org_s { struct org_league_s *leagues; }

user_defined_types: struct org_league_s { struct league_s *league; }

user_defined_types: struct league_s { int league_id; char name[-1]; struct league_division_s *divisions; struct league_team_s *teams; struct league_stats_s *stats; struct league_accolade_s *accolades; }

user_defined_types: struct league_division_s { int league_id; int division_id; struct division_s *division; }

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_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_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_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; }


setLongevity

decompiled_code:
void __fastcall setLongevity(_BYTE *a1)
{
unsigned int v1; // eax
_BYTE *v2; // rbx

v1 = time(0LL);
srand(v1);
v2 = a1;
do
{
if ( *v2 )
{
if ( (unsigned int)nibble((unsigned __int8)v2[47], 1LL) )
v2[50] += rand() % 10 + 1;
}
v2 += 112;
}
while ( v2 != a1 + 89600 );
}

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

v1 = time(0LL);
srand(v1);
v2 = a1;
do
{
if ( *v2 )
{
if ( (unsigned int)nibble((unsigned __int8)v2[47], 1LL) )
v2[50] += rand() % 10 + 1;
}
v2 += 112;
}
while ( v2 != a1 + 89600 );
}

original_code:
void setLongevity( fileplayer_s *players_file )
{
     srand( time( ((void *)0) ) );
     for ( int player_id = 1, idx = 0; idx < (((25 * 8) * 2) * 2); ++idx )
     {
          if ( (players_file[idx].last_name)[0] == '\0' ) continue;
          int pos = nibble( players_file[idx].position[0], n_High );
          acc_player_id_s *id_info = ((void *)0);
          if ( pos != fpos_Pitcher )
          {
               filebatting_s *batting = &(players_file[idx].filestats.filebatting);
               unsigned char longevity = (rand() % 10) + 1;
               batting->ratings[2] += longevity;
          }
     }
}

canonical_original_code:
void setLongevity(struct fileplayer_s *players_file)
{
     srand( time( ((void *)0) ) );
     for ( int player_id = 1; int idx = 0; idx < (((25 * 8) * 2) * 2); ++idx )
     {
          if ( (players_file[idx].last_name)[0] == '\0' ) continue;
          int pos = nibble( players_file[idx].position[0], n_High );
          struct acc_player_id_s *id_info = ((void *)0);
          if ( pos != fpos_Pitcher )
          {
               struct filebatting_s *batting = &(players_file[idx].filestats.filebatting);
               unsigned char longevity = (rand() % 10) + 1;
               batting->ratings[2] += longevity;
          }
     }
}

variable_types: idx int

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

variable_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]; } *

variable_types:
longevity
unsigned 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: 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]; }


getWindPercentage

decompiled_code:
__int64 __fastcall getWindPercentage(unsigned int a1)
{
__int64 result; // rax

switch ( a1 )
{
case 0u:
result = a1;
break;
case 1u:
result = 98LL;
break;
case 2u:
result = 97LL;
break;
case 3u:
result = 95LL;
break;
case 4u:
result = 94LL;
break;
case 5u:
result = 92LL;
break;
case 6u:
result = 91LL;
break;
case 7u:
result = 89LL;
break;
case 8u:
result = 88LL;
break;
case 9u:
result = 86LL;
break;
case 0xAu:
result = 84LL;
break;
case 0xBu:
result = 83LL;
break;
case 0xCu:
result = 81LL;
break;
case 0xDu:
result = 80LL;
break;
case 0xEu:
result = 78LL;
break;
case 0xFu:
result = 77LL;
break;
case 0x10u:
result = 75LL;
break;
case 0x11u:
result = 73LL;
break;
case 0x12u:
result = 72LL;
break;
case 0x13u:
result = 70LL;
break;
case 0x14u:
result = 69LL;
break;
case 0x15u:
result = 67LL;
break;
case 0x16u:
result = 66LL;
break;
case 0x17u:
result = 64LL;
break;
case 0x18u:
result = 63LL;
break;
case 0x19u:
result = 61LL;
break;
case 0x1Au:
result = 59LL;
break;
case 0x1Bu:
result = 58LL;
break;
case 0x1Cu:
result = 56LL;
break;
case 0x1Du:
result = 55LL;
break;
case 0x1Eu:
result = 53LL;
break;
case 0x1Fu:
result = 52LL;
break;
default:
result = 0xFFFFFFFFLL;
break;
}
return result;
}

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

switch ( a1 )
{
case 0u:
result = a1;
break;
case 1u:
result = 98LL;
break;
case 2u:
result = 97LL;
break;
case 3u:
result = 95LL;
break;
case 4u:
result = 94LL;
break;
case 5u:
result = 92LL;
break;
case 6u:
result = 91LL;
break;
case 7u:
result = 89LL;
break;
case 8u:
result = 88LL;
break;
case 9u:
result = 86LL;
break;
case 0xAu:
result = 84LL;
break;
case 0xBu:
result = 83LL;
break;
case 0xCu:
result = 81LL;
break;
case 0xDu:
result = 80LL;
break;
case 0xEu:
result = 78LL;
break;
case 0xFu:
result = 77LL;
break;
case 0x10u:
result = 75LL;
break;
case 0x11u:
result = 73LL;
break;
case 0x12u:
result = 72LL;
break;
case 0x13u:
result = 70LL;
break;
case 0x14u:
result = 69LL;
break;
case 0x15u:
result = 67LL;
break;
case 0x16u:
result = 66LL;
break;
case 0x17u:
result = 64LL;
break;
case 0x18u:
result = 63LL;
break;
case 0x19u:
result = 61LL;
break;
case 0x1Au:
result = 59LL;
break;
case 0x1Bu:
result = 58LL;
break;
case 0x1Cu:
result = 56LL;
break;
case 0x1Du:
result = 55LL;
break;
case 0x1Eu:
result = 53LL;
break;
case 0x1Fu:
result = 52LL;
break;
default:
result = 0xFFFFFFFFLL;
break;
}
return result;
}

original_code:
static int getWindPercentage( const int value )
{
     switch ( value )
     {
     case 0: return 0;
     case 1: return 98;
     case 2: return 97;
     case 3: return 95;
     case 4: return 94;
     case 5: return 92;
     case 6: return 91;
     case 7: return 89;
     case 8: return 88;
     case 9: return 86;
     case 10: return 84;
     case 11: return 83;
     case 12: return 81;
     case 13: return 80;
     case 14: return 78;
     case 15: return 77;
     case 16: return 75;
     case 17: return 73;
     case 18: return 72;
     case 19: return 70;
     case 20: return 69;
     case 21: return 67;
     case 22: return 66;
     case 23: return 64;
     case 24: return 63;
     case 25: return 61;
     case 26: return 59;
     case 27: return 58;
     case 28: return 56;
     case 29: return 55;
     case 30: return 53;
     case 31: return 52;
     }
     return -1;
}

canonical_original_code:
static int getWindPercentage(int value)
{
     switch ( value )
     {
     case 0: return 0;
     case 1: return 98;
     case 2: return 97;
     case 3: return 95;
     case 4: return 94;
     case 5: return 92;
     case 6: return 91;
     case 7: return 89;
     case 8: return 88;
     case 9: return 86;
     case 10: return 84;
     case 11: return 83;
     case 12: return 81;
     case 13: return 80;
     case 14: return 78;
     case 15: return 77;
     case 16: return 75;
     case 17: return 73;
     case 18: return 72;
     case 19: return 70;
     case 20: return 69;
     case 21: return 67;
     case 22: return 66;
     case 23: return 64;
     case 24: return 63;
     case 25: return 61;
     case 26: return 59;
     case 27: return 58;
     case 28: return 56;
     case 29: return 55;
     case 30: return 53;
     case 31: return 52;
     }
     return -1;
}

variable_types: value int