createOrg

decompiled_code:
void *createOrg()
{
return calloc(8uLL, 1uLL);
}

canonical_decompiled_code:
void *func0()
{
return calloc(8uLL, 1uLL);
}

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_stats_s { int division_id; int season; enum season_phase_e season_phase; int wins; int losses; int home_wins; int home_losses; int road_wins; int road_losses; int league_wins; int league_losses; int runs_scored; int runs_allowed; }

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

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

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

user_defined_types: struct team_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

repo: zjentohlauedy/MBA

decompiled_code:
void __fastcall setLongevity(_BYTE *a1)
{
_BYTE *v1; // rbx
_BYTE *v2; // rbp
unsigned int v3; // eax
int v4; // eax
char v5; // cl

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

canonical_decompiled_code:
void __fastcall func0(_BYTE *a1)
{
_BYTE *v1; // rbx
_BYTE *v2; // rbp
unsigned int v3; // eax
int v4; // eax
char v5; // cl

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

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: 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: idx int

variable_types: pos 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

return_type: void

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


getWindPercentage

decompiled_code:
__int64 __fastcall getWindPercentage(int a1)
{
return (unsigned int)CSWTCH_1[a1];
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
return (unsigned int)CSWTCH_1[a1];
}

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

return_type: int


getWindDirection

decompiled_code:
char *__fastcall getWindDirection(int a1)
{
return CSWTCH_3[a1];
}

canonical_decompiled_code:
char *__fastcall func1(int a1)
{
return CSWTCH_3[a1];
}

original_code:
static char *getWindDirection( const int direction )
{
     switch ( direction )
     {
     case 0: return "Normal";
     case 1: return "Out";
     case 2: return "In";
     case 3: return "Across";
     }
     return "Unknown";
}

canonical_original_code:
static char *getWindDirection(int direction)
{
     switch ( direction )
     {
     case 0: return "Normal";
     case 1: return "Out";
     case 2: return "In";
     case 3: return "Across";
     }
     return "Unknown";
}

variable_types: direction int

return_type: char *


getCapacity

decompiled_code:
__int64 __fastcall getCapacity(int a1)
{
return (unsigned int)CSWTCH_5[a1];
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1)
{
return (unsigned int)CSWTCH_5[a1];
}

original_code:
static int getCapacity( const int value )
{
     switch ( value )
     {
     case 0: return 35000;
     case 1: return 43000;
     case 2: return 50000;
     case 3: return 56000;
     }
     return -1;
}

canonical_original_code:
static int getCapacity(int value)
{
     switch ( value )
     {
     case 0: return 35000;
     case 1: return 43000;
     case 2: return 50000;
     case 3: return 56000;
     }
     return -1;
}


decompiled_code:
int __fastcall print_park_details(char *a1)
{
char *v1; // rbp
char v2; // al
const char *v3; // rax
int v4; // ebx
char *v5; // rax
char *v6; // r12
__int64 v7; // rcx
unsigned int v8; // eax
__int16 v9; // bx
__int16 v10; // ax
double v11; // xmm0_8
double v12; // xmm0_8
double v13; // xmm0_8

if ( *a1 < 0 )
printf("Inside ");
else
printf("Outside ");
if ( (*a1 & 0x40) != 0 )
printf("Artificial ");
else
printf("Natural ");
v1 = a1 + 24;
v2 = nibble((unsigned __int8)*a1, 0LL);
v3 = (const char *)getParkColorName(v2 & 7);
printf("Color: %s\n", v3);
puts("Bleachers:");
printf(" Left: %d\n", (unsigned __int8)(((unsigned __int8)a1[1] >> 6) + 1));
printf(" Left-Center: %d\n", (((int)(unsigned __int8)a1[1] >> 2) & 3u) + 1);
printf(" Right-Center: %d\n", (a1[1] & 3u) + 1);
printf(" Right: %d\n", (((int)(unsigned __int8)a1[1] >> 4) & 3u) + 1);
v4 = word2int(a1 + 2);
getWindPercentage((v4 >> 4) & 0x1F);
v5 = getWindDirection((v4 >> 9) & 3);
v6 = a1 + 64;
printf("Wind Speed: %d %s %d%%\n", (v4 >> 11) & 0x1F, v5, v7);
v8 = getCapacity(v4 & 3);
printf("Capacity: %dk\n", v8);
printf(
"Heights: %2d %2d %2d %2d %2d %2d %2d %2d %2d\n",
(unsigned __int8)*(v6 - 50),
(unsigned __int8)*(v6 - 49),
(unsigned __int8)*(v6 - 48),
(unsigned __int8)*(v6 - 47),
(unsigned __int8)*(v6 - 46),
(unsigned __int8)*(v6 - 45),
(unsigned __int8)*(v6 - 44),
(unsigned __int8)*(v6 - 43),
(unsigned __int8)*(v6 - 42));
printf("Distances:");
do
{
v9 = word2int(v1);
v10 = word2int(v1 + 2);
v11 = (double)v9 * (double)v9 + (double)v10 * (double)v10;
if ( v11 < 0.0 )
v12 = sqrt(v11);
else
v12 = sqrt(v11);
v13 = round(v12);
v1 += 4;
printf(" %3d", (unsigned int)(int)v13);
}
while ( v6 != v1 );
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func3(char *a1)
{
char *v1; // rbp
char v2; // al
const char *v3; // rax
int v4; // ebx
char *v5; // rax
char *v6; // r12
__int64 v7; // rcx
unsigned int v8; // eax
__int16 v9; // bx
__int16 v10; // ax
double v11; // xmm0_8
double v12; // xmm0_8
double v13; // xmm0_8

if ( *a1 < 0 )
printf("Inside ");
else
printf("Outside ");
if ( (*a1 & 0x40) != 0 )
printf("Artificial ");
else
printf("Natural ");
v1 = a1 + 24;
v2 = nibble((unsigned __int8)*a1, 0LL);
v3 = (const char *)getParkColorName(v2 & 7);
printf("Color: %s\n", v3);
puts("Bleachers:");
printf(" Left: %d\n", (unsigned __int8)(((unsigned __int8)a1[1] >> 6) + 1));
printf(" Left-Center: %d\n", (((int)(unsigned __int8)a1[1] >> 2) & 3u) + 1);
printf(" Right-Center: %d\n", (a1[1] & 3u) + 1);
printf(" Right: %d\n", (((int)(unsigned __int8)a1[1] >> 4) & 3u) + 1);
v4 = word2int(a1 + 2);
func0((v4 >> 4) & 0x1F);
v5 = func1((v4 >> 9) & 3);
v6 = a1 + 64;
printf("Wind Speed: %d %s %d%%\n", (v4 >> 11) & 0x1F, v5, v7);
v8 = func2(v4 & 3);
printf("Capacity: %dk\n", v8);
printf(
"Heights: %2d %2d %2d %2d %2d %2d %2d %2d %2d\n",
(unsigned __int8)*(v6 - 50),
(unsigned __int8)*(v6 - 49),
(unsigned __int8)*(v6 - 48),
(unsigned __int8)*(v6 - 47),
(unsigned __int8)*(v6 - 46),
(unsigned __int8)*(v6 - 45),
(unsigned __int8)*(v6 - 44),
(unsigned __int8)*(v6 - 43),
(unsigned __int8)*(v6 - 42));
printf("Distances:");
do
{
v9 = word2int(v1);
v10 = word2int(v1 + 2);
v11 = (double)v9 * (double)v9 + (double)v10 * (double)v10;
if ( v11 < 0.0 )
v12 = sqrt(v11);
else
v12 = sqrt(v11);
v13 = round(v12);
v1 += 4;
printf(" %3d", (unsigned int)(int)v13);
}
while ( v6 != v1 );
return putchar(10);
}

original_code:
static void print_park_details( const park_details_s *details )
{
     if ( details->details1[0] & 0x80 ) printf( "Inside " );
     else printf( "Outside " );
     if ( details->details1[0] & 0x40 ) printf( "Artificial " );
     else printf( "Natural " );
     printf( "Color: %s\n", getParkColorName( nibble( details->details1[0], n_Low ) & 0x07 ) );
     printf( "Bleachers:\n" );
     printf( "  Left:         %d\n", 1 + ((details->bleachers[0] & 0xC0) >> 6) );
     printf( "  Left-Center:  %d\n", 1 + ((details->bleachers[0] & 0x0C) >> 2) );
     printf( "  Right-Center: %d\n", 1 + ((details->bleachers[0] & 0x03) >> 0) );
     printf( "  Right:        %d\n", 1 + ((details->bleachers[0] & 0x30) >> 4) );
     const int details2 = word2int( details->details2 );
     printf( "Wind Speed: %d %s %d%%\n", (details2 & 0xF800) >> 11, getWindDirection( (details2 & 0x0600) >> 9 ), getWindPercentage( (details2 & 0x1F0) >> 4 ) );
     printf( "Capacity: %dk\n", getCapacity( details2 & 0x0003 ) );
     const heights_s *heights = &(details->heights);
     printf( "Heights:       %2d   %2d   %2d   %2d   %2d   %2d   %2d   %2d   %2d\n",
             heights->left1[0],
             heights->left2[0],
             heights->left3[0],
             heights->left4[0],
             heights->center[0],
             heights->right4[0],
             heights->right3[0],
             heights->right2[0],
             heights->right1[0] );
     printf( "Distances:" );
     for ( int i = 0; i < 10; ++i )
     {
          const short x = (short)word2int( details->outfield[i].x );
          const short y = (short)word2int( details->outfield[i].y );
          printf( "  %3d", (int)round( sqrt( pow((double)x, 2.0) + pow((double)y, 2.0) ) ) );
     }
     printf( "\n" );
}

canonical_original_code:
static void print_park_details(struct park_details_s *details)
{
     if ( details->details1[0] & 0x80 ) printf( "Inside " );
     else printf( "Outside " );
     if ( details->details1[0] & 0x40 ) printf( "Artificial " );
     else printf( "Natural " );
     printf( "Color: %s\n", getParkColorName( nibble( details->details1[0], n_Low ) & 0x07 ) );
     printf( "Bleachers:\n" );
     printf( "  Left:         %d\n", 1 + ((details->bleachers[0] & 0xC0) >> 6) );
     printf( "  Left-Center:  %d\n", 1 + ((details->bleachers[0] & 0x0C) >> 2) );
     printf( "  Right-Center: %d\n", 1 + ((details->bleachers[0] & 0x03) >> 0) );
     printf( "  Right:        %d\n", 1 + ((details->bleachers[0] & 0x30) >> 4) );
     int details2 = word2int( details->details2 );
     printf( "Wind Speed: %d %s %d%%\n", (details2 & 0xF800) >> 11, getWindDirection( (details2 & 0x0600) >> 9 ), getWindPercentage( (details2 & 0x1F0) >> 4 ) );
     printf( "Capacity: %dk\n", getCapacity( details2 & 0x0003 ) );
     struct heights_s *heights = &(details->heights);
     printf( "Heights:       %2d   %2d   %2d   %2d   %2d   %2d   %2d   %2d   %2d\n",
             heights->left1[0],
             heights->left2[0],
             heights->left3[0],
             heights->left4[0],
             heights->center[0],
             heights->right4[0],
             heights->right3[0],
             heights->right2[0],
             heights->right1[0] );
     printf( "Distances:" );
     for ( int i = 0; i < 10; ++i )
     {
          short x = (short)word2int( details->outfield[i].x );
          short y = (short)word2int( details->outfield[i].y );
          printf( "  %3d", (int)round( sqrt( pow((double)x, 2.0) + pow((double)y, 2.0) ) ) );
     }
     printf( "\n" );
}

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

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

variable_types: i int

variable_types: x short

variable_types: y short

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


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rax
char *v4; // rbp
void *v5; // r13
const char *v6; // rbx
__int64 v7; // r12
const char *v8; // rdi
char *v9; // rdi
int result; // eax

if ( argc <= 1 )
{
printf("Usage: %s <input file>\n", *argv);
result = 0;
}
else
{
v3 = readParksFile(argv[1]);
v4 = (char *)(v3 + 564);
v5 = (void *)v3;
v6 = (const char *)(v3 + 52);
v7 = v3 + 564;
if ( v3 )
{
do
{
v8 = v6;
v6 += 16;
puts(v8);
v9 = v4;
v4 += 128;
print_park_details(v9);
putchar(10);
}
while ( v6 != (const char *)v7 );
free(v5);
result = 0;
}
else
{
printf("Cannot load parks file.");
result = 1;
}
}
return result;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rax
char *v4; // rbp
void *v5; // r13
const char *v6; // rbx
__int64 v7; // r12
const char *v8; // rdi
char *v9; // rdi
int result; // eax

if ( argc <= 1 )
{
printf("Usage: %s <input file>\n", *argv);
result = 0;
}
else
{
v3 = readParksFile(argv[1]);
v4 = (char *)(v3 + 564);
v5 = (void *)v3;
v6 = (const char *)(v3 + 52);
v7 = v3 + 564;
if ( v3 )
{
do
{
v8 = v6;
v6 += 16;
puts(v8);
v9 = v4;
v4 += 128;
func3(v9);
putchar(10);
}
while ( v6 != (const char *)v7 );
free(v5);
result = 0;
}
else
{
printf("Cannot load parks file.");
result = 1;
}
}
return result;
}

original_code:
int main( const int argc, const char *argv[] )
{
     fileparks_s *parksFile;
     if ( argc < 2 )
     {
   printf( "Usage: %s <input file>\n", argv[0] );
   return 0;
     }
     if ( (parksFile = readParksFile( argv[1] )) == ((void *)0) )
     {
          printf( "Cannot load parks file." );
          return 1;
     }
     for ( int i = 0; i < 32; ++i )
     {
          printf( "%s\n", parksFile->park_names[i].text );
          print_park_details( &parksFile->park_details[i] );
          printf( "\n" );
     }
     free( parksFile );
     return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
     struct fileparks_s *parksFile;
     if ( argc < 2 )
     {
   printf( "Usage: %s <input file>\n", argv[0] );
   return 0;
     }
     if ( (parksFile = readParksFile( argv[1] )) == ((void *)0) )
     {
          printf( "Cannot load parks file." );
          return 1;
     }
     for ( int i = 0; i < 32; ++i )
     {
          printf( "%s\n", parksFile->park_names[i].text );
          print_park_details( &parksFile->park_details[i] );
          printf( "\n" );
     }
     free( parksFile );
     return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

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

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


decompiled_code:
char *divisions_t_create__ShouldGiveAnErrorIfDivisionIdAlreadyExists()
{
unsigned int v0; // eax
__int64 v1; // rcx
__int64 v2; // r8
unsigned int v3; // eax
int v5; // [rsp+0h] [rbp-48h] BYREF
char v6[12]; // [rsp+4h] [rbp-44h] BYREF
_OWORD v7[2]; // [rsp+10h] [rbp-38h] BYREF
__int64 v8; // [rsp+30h] [rbp-18h]

qmemcpy(v6, "DivisionName", sizeof(v6));
v7[0] = 0LL;
v8 = 0LL;
v5 = 5;
strcpy((char *)v7, "1");
v7[1] = 0LL;
v0 = divisions_t_create(db, &v5);
v1 = 0LL;
v2 = v0;
if ( !v0 )
{
strcpy(v6, "DivisionName2");
v3 = divisions_t_create(db, &v5);
v2 = v3;
if ( v3 == 19 )
{
sqlite3_exec(db, "delete from divisions_t", 0LL, 0LL, 0LL);
return 0LL;
}
v1 = 19LL;
}
sprintf(
_unit_test_msgbuf__,
"\x1B[0;31mFailed: %s; expected: %d, actual: %d\x1B[0m",
"divisions_t_create( db, &expected )",
v1,
v2);
return _unit_test_msgbuf__;
}

canonical_decompiled_code:
char *func0()
{
unsigned int v0; // eax
__int64 v1; // rcx
__int64 v2; // r8
unsigned int v3; // eax
int v5; // [rsp+0h] [rbp-48h] BYREF
char v6[12]; // [rsp+4h] [rbp-44h] BYREF
_OWORD v7[2]; // [rsp+10h] [rbp-38h] BYREF
__int64 v8; // [rsp+30h] [rbp-18h]

qmemcpy(v6, "DivisionName", sizeof(v6));
v7[0] = 0LL;
v8 = 0LL;
v5 = 5;
strcpy((char *)v7, "1");
v7[1] = 0LL;
v0 = divisions_t_create(db, &v5);
v1 = 0LL;
v2 = v0;
if ( !v0 )
{
strcpy(v6, "DivisionName2");
v3 = divisions_t_create(db, &v5);
v2 = v3;
if ( v3 == 19 )
{
sqlite3_exec(db, "delete from divisions_t", 0LL, 0LL, 0LL);
return 0LL;
}
v1 = 19LL;
}
sprintf(
_unit_test_msgbuf__,
"\x1B[0;31mFailed: %s; expected: %d, actual: %d\x1B[0m",
"divisions_t_create( db, &expected )",
v1,
v2);
return _unit_test_msgbuf__;
}

original_code:
static char *divisions_t_create__ShouldGiveAnErrorIfDivisionIdAlreadyExists()
{
     division_s expected = { 0 };
             expected.division_id = 5;
     strcpy( expected.name, "DivisionName1" );
     do { int __expected__ = (0); int __actual__ = (divisions_t_create( db, &expected )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "divisions_t_create( db, &expected )", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     strcpy( expected.name, "DivisionName2" );
     do { int __expected__ = (19); int __actual__ = (divisions_t_create( db, &expected )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "divisions_t_create( db, &expected )", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     sqlite3_exec( db, "delete from divisions_t", ((void *)0), ((void *)0), ((void *)0) );
     return ((void *)0);
}

canonical_original_code:
static char *divisions_t_create__ShouldGiveAnErrorIfDivisionIdAlreadyExists()
{
     struct division_s expected = { 0 };
             expected.division_id = 5;
     strcpy( expected.name, "DivisionName1" );
     do { int __expected__ = (0); int __actual__ = (divisions_t_create( db, &expected )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "divisions_t_create( db, &expected )", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     strcpy( expected.name, "DivisionName2" );
     do { int __expected__ = (19); int __actual__ = (divisions_t_create( db, &expected )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "divisions_t_create( db, &expected )", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     sqlite3_exec( db, "delete from divisions_t", ((void *)0), ((void *)0), ((void *)0) );
     return ((void *)0);
}

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

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

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

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

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

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

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

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

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


decompiled_code:
__int64 __fastcall get_a_division(unsigned int a1)
{
__int64 v2; // [rsp+8h] [rbp-400h] BYREF
char s[1016]; // [rsp+10h] [rbp-3F8h] BYREF

v2 = 0LL;
snprintf(s, 0x3E8uLL, "select * from divisions_t where division_id = %d", a1);
sqlite3_exec(db, s, load_division_data, &v2, 0LL);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int a1)
{
__int64 v2; // [rsp+8h] [rbp-400h] BYREF
char s[1016]; // [rsp+10h] [rbp-3F8h] BYREF

v2 = 0LL;
snprintf(s, 0x3E8uLL, "select * from divisions_t where division_id = %d", a1);
sqlite3_exec(db, s, load_division_data, &v2, 0LL);
return v2;
}

original_code:
static division_s *get_a_division( int division_id )
{
     division_s *division = ((void *)0);
     char query[999+1];
     snprintf( query, sizeof(query), "select * from divisions_t where division_id = %d", division_id );
     sqlite3_exec( db, query, load_division_data, &division, ((void *)0) );
     return division;
}

canonical_original_code:
static struct division_s *get_a_division(int division_id)
{
     struct division_s *division = ((void *)0);
     char query[-1];
     snprintf( query, sizeof(query), "select * from divisions_t where division_id = %d", division_id );
     sqlite3_exec( db, query, load_division_data, &division, ((void *)0) );
     return division;
}

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

variable_types:
query
char [-1]

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

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


decompiled_code:
__int64 __fastcall insert_a_division(const char *a1)
{
char v2[1016]; // [rsp+0h] [rbp-3F8h] BYREF

snprintf(v2, 0x3E8uLL, "insert into divisions_t (division_id, name)values (%d, '%s')", *(unsigned int *)a1, a1 + 4);
return sqlite3_exec(db, v2, 0LL, 0LL, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func3(const char *a1)
{
char v2[1016]; // [rsp+0h] [rbp-3F8h] BYREF

snprintf(v2, 0x3E8uLL, "insert into divisions_t (division_id, name)values (%d, '%s')", *(unsigned int *)a1, a1 + 4);
return sqlite3_exec(db, v2, 0LL, 0LL, 0LL);
}

original_code:
static void insert_a_division( division_s *division )
{
     char query[999+1];
     snprintf( query, sizeof(query), "insert into divisions_t (division_id, name)"
               "values (%d, '%s')",
               division->division_id,
               division->name );
     sqlite3_exec( db, query, ((void *)0), ((void *)0), ((void *)0) );
}

canonical_original_code:
static void insert_a_division(struct division_s *division)
{
     char query[-1];
     snprintf( query, sizeof(query), "insert into divisions_t (division_id, name)"
               "values (%d, '%s')",
               division->division_id,
               division->name );
     sqlite3_exec( db, query, ((void *)0), ((void *)0), ((void *)0) );
}

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

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

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 }


decompiled_code:
__int64 __fastcall load_division_data(_QWORD *a1, int a2, const char **a3)
{
int v4; // eax
const char *v5; // rsi

if ( a2 <= 1 )
return 1LL;
division_0 = 0LL;
xmmword_850 = 0LL;
xmmword_860 = 0LL;
qword_870 = 0LL;
v4 = atoi(*a3);
v5 = a3[1];
LODWORD(division_0) = v4;
strcpy((char *)&division_0 + 4, v5);
*a1 = &division_0;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(_QWORD *a1, int a2, const char **a3)
{
int v4; // eax
const char *v5; // rsi

if ( a2 <= 1 )
return 1LL;
division_0 = 0LL;
xmmword_850 = 0LL;
xmmword_860 = 0LL;
qword_870 = 0LL;
v4 = atoi(*a3);
v5 = a3[1];
LODWORD(division_0) = v4;
strcpy((char *)&division_0 + 4, v5);
*a1 = &division_0;
return 0LL;
}

original_code:
static int load_division_data( void *output, int cols, char *data[], char *names[] )
{
     static division_s division;
     division_s **d = (division_s **)output;
     if ( cols < 2 ) return 1;
     memset( &division, '\0', sizeof(division_s) );
             division.division_id = atoi( data[0] );
     strcpy( division.name, data[1] );
     *d = &division;
     return 0;
}

canonical_original_code:
static int load_division_data(void *output, int cols, char *data[], char *names[])
{
     static struct division_s division;
     struct division_s **d = (division_s **)output;
     if ( cols < 2 ) return 1;
     memset( &division, '\0', sizeof(division_s) );
             division.division_id = atoi( data[0] );
     strcpy( division.name, data[1] );
     *d = &division;
     return 0;
}

variable_types:
output
void *

variable_types: cols int

variable_types:
data
char *[]

variable_types:
names
char *[]

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


decompiled_code:
char *divisions_t_delete__ShouldDeleteMatchingRecord_GivenTheDivisionId()
{
unsigned int v0; // eax
char *v1; // r12
unsigned int v3; // [rsp+0h] [rbp-48h] BYREF
_BYTE v4[12]; // [rsp+4h] [rbp-44h] BYREF
__int128 v5; // [rsp+10h] [rbp-38h]
__int128 v6; // [rsp+20h] [rbp-28h]
__int64 v7; // [rsp+30h] [rbp-18h]

qmemcpy(v4, "DivisionName", sizeof(v4));
v5 = 0LL;
v7 = 0LL;
v3 = 5;
LOWORD(v5) = 49;
v6 = 0LL;
insert_a_division((const char *)&v3);
v0 = divisions_t_delete(db, &v3);
if ( v0 )
{
v1 = _unit_test_msgbuf__;
sprintf(
_unit_test_msgbuf__,
"\x1B[0;31mFailed: %s; expected: %d, actual: %d\x1B[0m",
"divisions_t_delete( db, &expected )",
0LL,
v0);
}
else
{
v1 = (char *)get_a_division(v3);
if ( v1 )
{
sprintf(
_unit_test_msgbuf__,
"\x1B[0;31mFailed: %s; expected to be NULL but was not\x1B[0m",
"get_a_division( expected.division_id )");
v1 = _unit_test_msgbuf__;
}
else
{
sqlite3_exec(db, "delete from divisions_t", 0LL, 0LL, 0LL);
}
}
return v1;
}

canonical_decompiled_code:
char *func7()
{
unsigned int v0; // eax
char *v1; // r12
unsigned int v3; // [rsp+0h] [rbp-48h] BYREF
_BYTE v4[12]; // [rsp+4h] [rbp-44h] BYREF
__int128 v5; // [rsp+10h] [rbp-38h]
__int128 v6; // [rsp+20h] [rbp-28h]
__int64 v7; // [rsp+30h] [rbp-18h]

qmemcpy(v4, "DivisionName", sizeof(v4));
v5 = 0LL;
v7 = 0LL;
v3 = 5;
LOWORD(v5) = 49;
v6 = 0LL;
func3((const char *)&v3);
v0 = divisions_t_delete(db, &v3);
if ( v0 )
{
v1 = _unit_test_msgbuf__;
sprintf(
_unit_test_msgbuf__,
"\x1B[0;31mFailed: %s; expected: %d, actual: %d\x1B[0m",
"divisions_t_delete( db, &expected )",
0LL,
v0);
}
else
{
v1 = (char *)func1(v3);
if ( v1 )
{
sprintf(
_unit_test_msgbuf__,
"\x1B[0;31mFailed: %s; expected to be NULL but was not\x1B[0m",
"get_a_division( expected.division_id )");
v1 = _unit_test_msgbuf__;
}
else
{
sqlite3_exec(db, "delete from divisions_t", 0LL, 0LL, 0LL);
}
}
return v1;
}

original_code:
static char *divisions_t_delete__ShouldDeleteMatchingRecord_GivenTheDivisionId()
{
     division_s expected = { 0 };
             expected.division_id = 5;
     strcpy( expected.name, "DivisionName1" );
     insert_a_division( &expected );
     do { int __expected__ = (0); int __actual__ = (divisions_t_delete( db, &expected )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "divisions_t_delete( db, &expected )", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     do { if ( (get_a_division( expected.division_id )) != ((void *)0) ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected to be NULL but was not\033[0m", "get_a_division( expected.division_id )" ); return __unit_test_msgbuf__; } } while ( 0 );
     sqlite3_exec( db, "delete from divisions_t", ((void *)0), ((void *)0), ((void *)0) );
     return ((void *)0);
}

canonical_original_code:
static char *divisions_t_delete__ShouldDeleteMatchingRecord_GivenTheDivisionId()
{
     struct division_s expected = { 0 };
             expected.division_id = 5;
     strcpy( expected.name, "DivisionName1" );
     insert_a_division( &expected );
     do { int __expected__ = (0); int __actual__ = (divisions_t_delete( db, &expected )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "divisions_t_delete( db, &expected )", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     do { if ( (get_a_division( expected.division_id )) != ((void *)0) ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected to be NULL but was not\033[0m", "get_a_division( expected.division_id )" ); return __unit_test_msgbuf__; } } while ( 0 );
     sqlite3_exec( db, "delete from divisions_t", ((void *)0), ((void *)0), ((void *)0) );
     return ((void *)0);
}

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

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

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 }


decompiled_code:
int check_sqlite_error()
{
int result; // eax
const char *v1; // rax

result = sqlite3_errcode(db);
if ( result )
{
v1 = (const char *)sqlite3_errmsg(db);
result = printf("sqlite3 error message: %s\n", v1);
}
return result;
}

canonical_decompiled_code:
int func8()
{
int result; // eax
const char *v1; // rax

result = sqlite3_errcode(db);
if ( result )
{
v1 = (const char *)sqlite3_errmsg(db);
result = printf("sqlite3 error message: %s\n", v1);
}
return result;
}

original_code:
static void check_sqlite_error()
{
     if ( sqlite3_errcode( db ) != 0 )
     {
          printf( "sqlite3 error message: %s\n", sqlite3_errmsg( db ) );
     }
}


shuffle

decompiled_code:
int *__fastcall shuffle(__int64 a1, int a2)
{
__int64 v2; // rbx
int *result; // rax
int v4; // edx

v2 = a2;
do
{
result = (int *)(a1 + 4LL * (rand() % ((int)v2 - 1)));
v4 = *result;
*result = *(_DWORD *)(a1 + 4 * v2 - 4);
*(_DWORD *)(a1 + 4 * v2-- - 4) = v4;
}
while ( (int)v2 > 1 );
return result;
}

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

v2 = a2;
do
{
result = (int *)(a1 + 4LL * (rand() % ((int)v2 - 1)));
v4 = *result;
*result = *(_DWORD *)(a1 + 4 * v2 - 4);
*(_DWORD *)(a1 + 4 * v2-- - 4) = v4;
}
while ( (int)v2 > 1 );
return result;
}

original_code:
static void shuffle( int list[], int length )
{
     int i;
     for( i = length; i > 1; --i )
     {
          int n = rand() % (i - 1);
          int x;
          x = list[n ];
          list[n ] = list[i - 1];
          list[i - 1] = x;
     }
}

canonical_original_code:
static void shuffle(int list[], int length)
{
     int i;
     for( i = length; i > 1; --i )
     {
          int n = rand() % (i - 1);
          int x;
          x = list[n ];
          list[n ] = list[i - 1];
          list[i - 1] = x;
     }
}

variable_types:
list
int []

variable_types: length int

variable_types: n int

variable_types: x int


decompiled_code:
void __fastcall free_team_players(void *ptr)
{
_DWORD *v1; // rbx
int v2; // eax

if ( *(int *)ptr >= 0 )
{
v1 = (char *)ptr + 24;
do
{
if ( *((_QWORD *)v1 - 1) )
free_player();
v2 = *v1;
v1 += 6;
}
while ( v2 >= 0 );
}
free(ptr);
}

canonical_decompiled_code:
void __fastcall func0(void *ptr)
{
_DWORD *v1; // rbx
int v2; // eax

if ( *(int *)ptr >= 0 )
{
v1 = (char *)ptr + 24;
do
{
if ( *((_QWORD *)v1 - 1) )
free_player();
v2 = *v1;
v1 += 6;
}
while ( v2 >= 0 );
}
free(ptr);
}

original_code:
void free_team_players( team_player_s *team_players )
{
     for ( int i = 0; team_players[i].team_id >= 0; ++i )
     {
          if ( team_players[i].player != ((void *)0) ) free_player( team_players[i].player );
     }
     free( team_players );
}

canonical_original_code:
void free_team_players(struct team_player_s *team_players)
{
     for ( int i = 0; team_players[i].team_id >= 0; ++i )
     {
          if ( team_players[i].player != ((void *)0) ) free_player( team_players[i].player );
     }
     free( team_players );
}

variable_types: 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; } *

variable_types: i int

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

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


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

v2 = (void *)*((_QWORD *)ptr + 7);
if ( v2 )
free(v2);
v3 = (void *)*((_QWORD *)ptr + 8);
if ( v3 )
free(v3);
v4 = (void *)*((_QWORD *)ptr + 9);
if ( v4 )
free(v4);
v5 = (void *)*((_QWORD *)ptr + 10);
if ( v5 )
free(v5);
v6 = (void *)*((_QWORD *)ptr + 11);
if ( v6 )
free(v6);
v7 = (void *)*((_QWORD *)ptr + 12);
if ( v7 )
free(v7);
free(ptr);
}

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

v2 = (void *)*((_QWORD *)ptr + 7);
if ( v2 )
free(v2);
v3 = (void *)*((_QWORD *)ptr + 8);
if ( v3 )
free(v3);
v4 = (void *)*((_QWORD *)ptr + 9);
if ( v4 )
free(v4);
v5 = (void *)*((_QWORD *)ptr + 10);
if ( v5 )
free(v5);
v6 = (void *)*((_QWORD *)ptr + 11);
if ( v6 )
free(v6);
v7 = (void *)*((_QWORD *)ptr + 12);
if ( v7 )
free(v7);
free(ptr);
}

original_code:
void free_team( team_s *team )
{
     if ( team->players != ((void *)0) ) free( team->players );
     if ( team->stats != ((void *)0) ) free( team->stats );
     if ( team->versus_stats != ((void *)0) ) free( team->versus_stats );
     if ( team->pitching_stats != ((void *)0) ) free( team->pitching_stats );
     if ( team->batting_stats != ((void *)0) ) free( team->batting_stats );
     if ( team->accolades != ((void *)0) ) free( team->accolades );
     free( team );
}

canonical_original_code:
void free_team(struct team_s *team)
{
     if ( team->players != ((void *)0) ) free( team->players );
     if ( team->stats != ((void *)0) ) free( team->stats );
     if ( team->versus_stats != ((void *)0) ) free( team->versus_stats );
     if ( team->pitching_stats != ((void *)0) ) free( team->pitching_stats );
     if ( team->batting_stats != ((void *)0) ) free( team->batting_stats );
     if ( team->accolades != ((void *)0) ) free( team->accolades );
     free( team );
}

variable_types: 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; } *

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


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

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

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

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

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

canonical_original_code:
static char *copyLongevity_ShouldReturnTrueOnSuccess_GivenTwoPlayersFiles()
{
     struct fileplayer_s players_data1[-1] = { 0 };
     struct fileplayer_s players_data2[-1] = { 0 };
     do { int __expected__ = (bl_True); int __actual__ = (copyLongevity( players_data1, players_data2 )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "copyLongevity( players_data1, players_data2 )", __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; } [-1]

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