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

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

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

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

original_code:
static char *copyLongevity_ShouldReturnFalseIfPlayerNotFound_GivenTwoPlayersFiles()
{
     fileplayer_s *players_data1 = buildFilePlayers();
     fileplayer_s players_data2[(((25 * 8) * 2) * 2)] = { 0 };
     do { int __expected__ = (bl_False); 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_ShouldReturnFalseIfPlayerNotFound_GivenTwoPlayersFiles()
{
     struct fileplayer_s *players_data1 = buildFilePlayers();
     struct fileplayer_s players_data2[-1] = { 0 };
     do { int __expected__ = (bl_False); 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; } *


clearLongevity

repo: zjentohlauedy/MBA

decompiled_code:
__int64 __fastcall clearLongevity(__int64 a1)
{
_BYTE *v1; // rbx
__int64 result; // rax

v1 = (_BYTE *)(a1 + 50);
do
{
result = nibble((unsigned __int8)*(v1 - 3), 1LL);
if ( (_DWORD)result )
*v1 &= 0xF0u;
v1 += 112;
}
while ( v1 != (_BYTE *)(a1 + 89650) );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
_BYTE *v1; // rbx
__int64 result; // rax

v1 = (_BYTE *)(a1 + 50);
do
{
result = nibble((unsigned __int8)*(v1 - 3), 1LL);
if ( (_DWORD)result )
*v1 &= 0xF0u;
v1 += 112;
}
while ( v1 != (_BYTE *)(a1 + 89650) );
return result;
}

original_code:
static void clearLongevity( fileplayer_s *players_data )
{
     for ( int i = 0; i < (((25 * 8) * 2) * 2); ++i )
     {
          int pos = nibble( players_data[i].position[0], n_High );
          if ( pos != fpos_Pitcher )
          {
               players_data[i].filestats.filebatting.ratings[2] &= 0xF0;
          }
     }
}

canonical_original_code:
static void clearLongevity(struct fileplayer_s *players_data)
{
     for ( int i = 0; i < (((25 * 8) * 2) * 2); ++i )
     {
          int pos = nibble( players_data[i].position[0], n_High );
          if ( pos != fpos_Pitcher )
          {
               players_data[i].filestats.filebatting.ratings[2] &= 0xF0;
          }
     }
}

variable_types: i int

variable_types: pos int

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

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

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

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

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

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


getLongevity

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

if ( (unsigned int)nibble(*(unsigned __int8 *)(a1 + 47), 1LL) )
result = nibble(*(unsigned __int8 *)(a1 + 50), 0LL);
else
result = 0LL;
return result;
}

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

if ( (unsigned int)nibble(*(unsigned __int8 *)(a1 + 47), 1LL) )
result = nibble(*(unsigned __int8 *)(a1 + 50), 0LL);
else
result = 0LL;
return result;
}

original_code:
static int getLongevity( fileplayer_s *players_data )
{
     int pos = nibble( players_data->position[0], n_High );
     if ( pos != fpos_Pitcher )
     {
          return nibble( players_data->filestats.filebatting.ratings[2], n_Low );
     }
     return 0;
}

canonical_original_code:
static int getLongevity(struct fileplayer_s *players_data)
{
     int pos = nibble( players_data->position[0], n_High );
     if ( pos != fpos_Pitcher )
     {
          return nibble( players_data->filestats.filebatting.ratings[2], n_Low );
     }
     return 0;
}

return_type: int


decompiled_code:
char *copyLongevity_ShouldCopyLongevityBetweenBatters_GivenTwoPlayersFiles()
{
char *v0; // r12
char *v1; // rbx
const void *v2; // r13
unsigned int v3; // eax
__int64 v4; // r8
__int64 v5; // rcx
const char *v6; // rdx
__int64 v8; // rbx
unsigned int v9; // eax
unsigned int v10; // er13
unsigned int v11; // eax
_BYTE v12[89600]; // [rsp+0h] [rbp-15E28h] BYREF
char v13[40]; // [rsp+15E00h] [rbp-28h] BYREF

v0 = v12;
v1 = v12;
memset(v12, 0, sizeof(v12));
v2 = (const void *)buildFilePlayers();
memcpy(v12, v2, sizeof(v12));
clearLongevity((__int64)v12);
do
{
v3 = getLongevity((__int64)v1);
if ( v3 )
{
v4 = v3;
v5 = 0LL;
LABEL_5:
v6 = "getLongevity( &players_data1[i] )";
goto LABEL_6;
}
v1 += 112;
}
while ( v1 != v13 );
v8 = (__int64)v2;
v9 = copyLongevity(v12, v2);
if ( v9 != 1 )
{
v4 = v9;
v5 = 1LL;
v6 = "copyLongevity( players_data1, players_data2 )";
LABEL_6:
sprintf(_unit_test_msgbuf__, "\x1B[0;31mFailed: %s; expected: %d, actual: %d\x1B[0m", v6, v5, v4);
return _unit_test_msgbuf__;
}
do
{
v10 = getLongevity(v8);
v11 = getLongevity((__int64)v0);
if ( v10 != v11 )
{
v4 = v11;
v5 = v10;
goto LABEL_5;
}
v0 += 112;
v8 += 112LL;
}
while ( v0 != v13 );
return 0LL;
}

canonical_decompiled_code:
char *func4()
{
char *v0; // r12
char *v1; // rbx
const void *v2; // r13
unsigned int v3; // eax
__int64 v4; // r8
__int64 v5; // rcx
const char *v6; // rdx
__int64 v8; // rbx
unsigned int v9; // eax
unsigned int v10; // er13
unsigned int v11; // eax
_BYTE v12[89600]; // [rsp+0h] [rbp-15E28h] BYREF
char v13[40]; // [rsp+15E00h] [rbp-28h] BYREF

v0 = v12;
v1 = v12;
memset(v12, 0, sizeof(v12));
v2 = (const void *)buildFilePlayers();
memcpy(v12, v2, sizeof(v12));
func2((__int64)v12);
do
{
v3 = func3((__int64)v1);
if ( v3 )
{
v4 = v3;
v5 = 0LL;
LABEL_5:
v6 = "getLongevity( &players_data1[i] )";
goto LABEL_6;
}
v1 += 112;
}
while ( v1 != v13 );
v8 = (__int64)v2;
v9 = copyLongevity(v12, v2);
if ( v9 != 1 )
{
v4 = v9;
v5 = 1LL;
v6 = "copyLongevity( players_data1, players_data2 )";
LABEL_6:
sprintf(_unit_test_msgbuf__, "\x1B[0;31mFailed: %s; expected: %d, actual: %d\x1B[0m", v6, v5, v4);
return _unit_test_msgbuf__;
}
do
{
v10 = func3(v8);
v11 = func3((__int64)v0);
if ( v10 != v11 )
{
v4 = v11;
v5 = v10;
goto LABEL_5;
}
v0 += 112;
v8 += 112LL;
}
while ( v0 != v13 );
return 0LL;
}

original_code:
static char *copyLongevity_ShouldCopyLongevityBetweenBatters_GivenTwoPlayersFiles()
{
     fileplayer_s players_data1[(((25 * 8) * 2) * 2)] = { 0 };
     fileplayer_s *players_data2 = buildFilePlayers();
     memcpy( players_data1, players_data2, sizeof(players_data1) );
     clearLongevity( players_data1 );
     for ( int i = 0; i < (((25 * 8) * 2) * 2); ++i ) do { int __expected__ = (0); int __actual__ = (getLongevity( &players_data1[i] )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "getLongevity( &players_data1[i] )", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 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 );
     for ( int i = 0; i < (((25 * 8) * 2) * 2); ++i ) do { int __expected__ = (getLongevity( &players_data2[i] )); int __actual__ = (getLongevity( &players_data1[i] )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "getLongevity( &players_data1[i] )", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     return ((void *)0);
}

canonical_original_code:
static char *copyLongevity_ShouldCopyLongevityBetweenBatters_GivenTwoPlayersFiles()
{
     struct fileplayer_s players_data1[-1] = { 0 };
     struct fileplayer_s *players_data2 = buildFilePlayers();
     memcpy( players_data1, players_data2, sizeof(players_data1) );
     clearLongevity( players_data1 );
     for ( int i = 0; i < (((25 * 8) * 2) * 2); ++i ) do { int __expected__ = (0); int __actual__ = (getLongevity( &players_data1[i] )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "getLongevity( &players_data1[i] )", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 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 );
     for ( int i = 0; i < (((25 * 8) * 2) * 2); ++i ) do { int __expected__ = (getLongevity( &players_data2[i] )); int __actual__ = (getLongevity( &players_data1[i] )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "getLongevity( &players_data1[i] )", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     return ((void *)0);
}

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

return_type: char *


decompiled_code:
char *copyPlayerIds_ShouldReturnTrueOnSuccess_GivenTwoPlayerFiles()
{
__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)copyPlayerIds(v2, s);
result = 0LL;
if ( (_DWORD)v0 != 1 )
{
sprintf(
_unit_test_msgbuf__,
"\x1B[0;31mFailed: %s; expected: %d, actual: %d\x1B[0m",
"copyPlayerIds( players_file1, players_file2 )",
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)copyPlayerIds(v2, s);
result = 0LL;
if ( (_DWORD)v0 != 1 )
{
sprintf(
_unit_test_msgbuf__,
"\x1B[0;31mFailed: %s; expected: %d, actual: %d\x1B[0m",
"copyPlayerIds( players_file1, players_file2 )",
1LL,
v0);
result = _unit_test_msgbuf__;
}
return result;
}

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

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


decompiled_code:
char *copyPlayerIds_ShouldReturnFalseOnError_GivenTwoPlayerFiles()
{
__int64 v0; // rbp
__int64 v1; // rax
__int64 v2; // r8
char *result; // rax

v0 = buildFilePlayers();
v1 = buildFilePlayers();
v2 = (unsigned int)copyPlayerIds(v0, v1);
result = 0LL;
if ( (_DWORD)v2 )
{
sprintf(
_unit_test_msgbuf__,
"\x1B[0;31mFailed: %s; expected: %d, actual: %d\x1B[0m",
"copyPlayerIds( players_file1, players_file2 )",
0LL,
v2);
result = _unit_test_msgbuf__;
}
return result;
}

canonical_decompiled_code:
char *func1()
{
__int64 v0; // rbp
__int64 v1; // rax
__int64 v2; // r8
char *result; // rax

v0 = buildFilePlayers();
v1 = buildFilePlayers();
v2 = (unsigned int)copyPlayerIds(v0, v1);
result = 0LL;
if ( (_DWORD)v2 )
{
sprintf(
_unit_test_msgbuf__,
"\x1B[0;31mFailed: %s; expected: %d, actual: %d\x1B[0m",
"copyPlayerIds( players_file1, players_file2 )",
0LL,
v2);
result = _unit_test_msgbuf__;
}
return result;
}

original_code:
static char *copyPlayerIds_ShouldReturnFalseOnError_GivenTwoPlayerFiles()
{
     fileplayer_s *players_file1 = buildFilePlayers();
     fileplayer_s *players_file2 = buildFilePlayers();
     do { int __expected__ = (bl_False); int __actual__ = (copyPlayerIds( players_file1, players_file2 )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "copyPlayerIds( players_file1, players_file2 )", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     return ((void *)0);
}

canonical_original_code:
static char *copyPlayerIds_ShouldReturnFalseOnError_GivenTwoPlayerFiles()
{
     struct fileplayer_s *players_file1 = buildFilePlayers();
     struct fileplayer_s *players_file2 = buildFilePlayers();
     do { int __expected__ = (bl_False); int __actual__ = (copyPlayerIds( players_file1, players_file2 )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "copyPlayerIds( players_file1, players_file2 )", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     return ((void *)0);
}


decompiled_code:
char *copyPlayerIds_ShouldCopyThePlayerIdFromOneFileToAnotherBasedOnName_GivenTwoPlayerFiles()
{
char *v0; // r12
__int64 v1; // r13
__int64 v2; // r8
int *v3; // r12
char *v4; // rcx
int *v5; // rdx
__int64 v6; // rsi
const __m128i *v7; // rax
__int64 v8; // r13
unsigned int v9; // eax
unsigned int v10; // er14
unsigned int v11; // eax
__int64 v13; // r8
__int64 v14; // rcx
const char *v15; // rdx
char v16; // [rsp+28h] [rbp-FFD8h] BYREF
int s[22410]; // [rsp+30h] [rbp-FFD0h] BYREF

memset(s, 0, 0x15E00uLL);
v0 = (char *)&s[16372];
v1 = buildFilePlayersWithoutIds();
do
{
v0 += 4;
*((_DWORD *)v0 - 1) = rand() % 800;
}
while ( v0 != &v16 );
v3 = s;
v4 = (char *)&s[16372];
v5 = s;
do
{
v6 = *(int *)v4;
v4 += 4;
v5 += 28;
v7 = (const __m128i *)(v1 + 112 * v6);
*((__m128i *)v5 - 7) = _mm_loadu_si128(v7);
*((__m128i *)v5 - 6) = _mm_loadu_si128(v7 + 1);
*((__m128i *)v5 - 5) = _mm_loadu_si128(v7 + 2);
*((__m128i *)v5 - 4) = _mm_loadu_si128(v7 + 3);
*((__m128i *)v5 - 3) = _mm_loadu_si128(v7 + 4);
*((__m128i *)v5 - 2) = _mm_loadu_si128(v7 + 5);
*((__m128i *)v5 - 1) = _mm_loadu_si128(v7 + 6);
}
while ( v4 != &v16 );
v8 = buildFilePlayers(s, v6, v5, v4, v2);
v9 = copyPlayerIds(s, v8);
if ( v9 == 1 )
{
while ( 1 )
{
v10 = getPlayerId(v8 + 112LL * s[16372]);
v11 = getPlayerId(v3);
if ( v10 != v11 )
break;
v3 += 28;
if ( &s[16372] == (int *)&v16 )
return 0LL;
}
v13 = v11;
v14 = v10;
v15 = "getPlayerId( &players_file1[i] )";
}
else
{
v13 = v9;
v14 = 1LL;
v15 = "copyPlayerIds( players_file1, players_file3 )";
}
sprintf(_unit_test_msgbuf__, "\x1B[0;31mFailed: %s; expected: %d, actual: %d\x1B[0m", v15, v14, v13);
return _unit_test_msgbuf__;
}

original_code:
static char *copyPlayerIds_ShouldCopyThePlayerIdFromOneFileToAnotherBasedOnName_GivenTwoPlayerFiles()
{
     fileplayer_s players_file1[(((25 * 8) * 2) * 2)] = { 0 };
     fileplayer_s *players_file2 = buildFilePlayersWithoutIds();
     int players[10] = { 0 };
     for ( int i = 0; i < 10; ++i ) players[i] = rand() % 800;
     for ( int i = 0; i < 10; ++i ) memcpy( &players_file1[i], &players_file2[players[i]], sizeof(fileplayer_s) );
     fileplayer_s *players_file3 = buildFilePlayers();
     do { int __expected__ = (bl_True); int __actual__ = (copyPlayerIds( players_file1, players_file3 )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "copyPlayerIds( players_file1, players_file3 )", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     for ( int i = 0; i < 10; ++i ) do { int __expected__ = (getPlayerId( &players_file3[players[i]] )); int __actual__ = (getPlayerId( &players_file1[i] )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "getPlayerId( &players_file1[i] )", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     return ((void *)0);
}

canonical_original_code:
static char *copyPlayerIds_ShouldCopyThePlayerIdFromOneFileToAnotherBasedOnName_GivenTwoPlayerFiles()
{
     struct fileplayer_s players_file1[-1] = { 0 };
     struct fileplayer_s *players_file2 = buildFilePlayersWithoutIds();
     int players[10] = { 0 };
     for ( int i = 0; i < 10; ++i ) players[i] = rand() % 800;
     for ( int i = 0; i < 10; ++i ) memcpy( &players_file1[i], &players_file2[players[i]], sizeof(fileplayer_s) );
     struct fileplayer_s *players_file3 = buildFilePlayers();
     do { int __expected__ = (bl_True); int __actual__ = (copyPlayerIds( players_file1, players_file3 )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "copyPlayerIds( players_file1, players_file3 )", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     for ( int i = 0; i < 10; ++i ) do { int __expected__ = (getPlayerId( &players_file3[players[i]] )); int __actual__ = (getPlayerId( &players_file1[i] )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "getPlayerId( &players_file1[i] )", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     return ((void *)0);
}

variable_types:
players
int [10]


printPlayers

decompiled_code:
int __fastcall printPlayers(__int64 a1)
{
__int64 v1; // rbx
__int64 v2; // rax
int result; // eax
__int64 v4; // [rsp+Eh] [rbp-2Ah] BYREF
__int64 v5; // [rsp+16h] [rbp-22h] BYREF
__int16 v6; // [rsp+1Eh] [rbp-1Ah]

v1 = a1;
do
{
v2 = *(_QWORD *)(v1 + 10);
v1 += 112LL;
v4 = v2;
v5 = *(_QWORD *)(v1 - 112);
v6 = *(_WORD *)(v1 - 104);
untermName(&v4, 8LL);
untermName(&v5, 10LL);
result = printf("%.*s, %.*s\n", 10, (const char *)&v5, 8, (const char *)&v4);
}
while ( v1 != a1 + 89600 );
return result;
}

canonical_decompiled_code:
int __fastcall func0(__int64 a1)
{
__int64 v1; // rbx
__int64 v2; // rax
int result; // eax
__int64 v4; // [rsp+Eh] [rbp-2Ah] BYREF
__int64 v5; // [rsp+16h] [rbp-22h] BYREF
__int16 v6; // [rsp+1Eh] [rbp-1Ah]

v1 = a1;
do
{
v2 = *(_QWORD *)(v1 + 10);
v1 += 112LL;
v4 = v2;
v5 = *(_QWORD *)(v1 - 112);
v6 = *(_WORD *)(v1 - 104);
untermName(&v4, 8LL);
untermName(&v5, 10LL);
result = printf("%.*s, %.*s\n", 10, (const char *)&v5, 8, (const char *)&v4);
}
while ( v1 != a1 + 89600 );
return result;
}

original_code:
static void printPlayers( fileplayer_s *playerFile )
{
     for ( int idx = 0; idx < (((25 * 8) * 2) * 2); ++idx )
     {
          const fileplayer_s *player = playerFile + idx;
          char first_name [sizeof(player->first_name)];
          char last_name [sizeof(player->last_name) ];
          memcpy( first_name, player->first_name, sizeof(player->first_name) );
          memcpy( last_name, player->last_name, sizeof(player->last_name) );
          untermName( first_name, sizeof(player->first_name) );
          untermName( last_name, sizeof(player->last_name) );
          printf( "%.*s, %.*s\n", sizeof(player->last_name), last_name, sizeof(player->first_name), first_name );
     }
}

canonical_original_code:
static void printPlayers(struct fileplayer_s *playerFile)
{
     for ( int idx = 0; idx < (((25 * 8) * 2) * 2); ++idx )
     {
          struct fileplayer_s *player = playerFile + idx;
          char first_name[-1];
          char last_name[-1];
          memcpy( first_name, player->first_name, sizeof(player->first_name) );
          memcpy( last_name, player->last_name, sizeof(player->last_name) );
          untermName( first_name, sizeof(player->first_name) );
          untermName( last_name, sizeof(player->last_name) );
          printf( "%.*s, %.*s\n", sizeof(player->last_name), last_name, sizeof(player->first_name), first_name );
     }
}

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

variable_types: idx int

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

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

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


main

canonical_name: main

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

if ( argc <= 1 )
{
printf("Usage: %s <playerfile>\n", *argv);
result = 0;
}
else
{
v3 = readPlayersFile(argv[1]);
v4 = (void *)v3;
if ( v3 )
{
printPlayers(v3);
free(v4);
result = 0;
}
else
{
printf("Cannot load players file.");
result = 1;
}
}
return result;
}

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

if ( argc <= 1 )
{
printf("Usage: %s <playerfile>\n", *argv);
result = 0;
}
else
{
v3 = readPlayersFile(argv[1]);
v4 = (void *)v3;
if ( v3 )
{
func0(v3);
free(v4);
result = 0;
}
else
{
printf("Cannot load players file.");
result = 1;
}
}
return result;
}

original_code:
int main( const int argc, const char *argv[] )
{
     fileplayer_s *playerFile;
     if ( argc < 2 )
     {
   printf( "Usage: %s <playerfile>\n", argv[0] );
   return 0;
     }
     if ( (playerFile = readPlayersFile( argv[1] )) == ((void *)0) )
     {
          printf( "Cannot load players file." );
          return 1;
     }
     printPlayers( playerFile );
     free( playerFile );
     return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
     struct fileplayer_s *playerFile;
     if ( argc < 2 )
     {
   printf( "Usage: %s <playerfile>\n", argv[0] );
   return 0;
     }
     if ( (playerFile = readPlayersFile( argv[1] )) == ((void *)0) )
     {
          printf( "Cannot load players file." );
          return 1;
     }
     printPlayers( playerFile );
     free( playerFile );
     return 0;
}

variable_types: argc int

variable_types:
argv
char *[]


decompiled_code:
char *parseCSV_ShouldReturnTrueOnSuccess_GivenACSVLineToParse()
{
__int64 v0; // r8
char *result; // rax
__int128 v2; // [rsp+0h] [rbp-18h] BYREF

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

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

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

original_code:
static char *parseCSV_ShouldReturnTrueOnSuccess_GivenACSVLineToParse()
{
     data_list_s list = { 0 };
     do { int __expected__ = (bl_True); int __actual__ = (parseCSV( &list, "" )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "parseCSV( &list, \"\" )", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     return ((void *)0);
}

canonical_original_code:
static char *parseCSV_ShouldReturnTrueOnSuccess_GivenACSVLineToParse()
{
     struct data_list_s list = { 0 };
     do { int __expected__ = (bl_True); int __actual__ = (parseCSV( &list, "" )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "parseCSV( &list, \"\" )", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     return ((void *)0);
}

variable_types: struct data_list_s { int __max; int count; void *data; }


decompiled_code:
char *parseCSV_ShouldReturnAFieldIfTheLineEndsWithAComma_GivenACSVLineToParse()
{
unsigned int v0; // eax
char *result; // rax
__int128 v2; // [rsp+0h] [rbp-18h] BYREF

v2 = 0LL;
v0 = parseCSV(&v2, ",,,,");
if ( v0 == 1 )
{
result = 0LL;
if ( DWORD1(v2) != 5 )
{
sprintf(
_unit_test_msgbuf__,
"\x1B[0;31mFailed: %s; expected: %d, actual: %d\x1B[0m",
"list.count",
5LL,
DWORD1(v2));
result = _unit_test_msgbuf__;
}
}
else
{
sprintf(
_unit_test_msgbuf__,
"\x1B[0;31mFailed: %s; expected: %d, actual: %d\x1B[0m",
"parseCSV( &list, \",,,,\" )",
1LL,
v0);
result = _unit_test_msgbuf__;
}
return result;
}

canonical_decompiled_code:
char *func1()
{
unsigned int v0; // eax
char *result; // rax
__int128 v2; // [rsp+0h] [rbp-18h] BYREF

v2 = 0LL;
v0 = parseCSV(&v2, ",,,,");
if ( v0 == 1 )
{
result = 0LL;
if ( DWORD1(v2) != 5 )
{
sprintf(
_unit_test_msgbuf__,
"\x1B[0;31mFailed: %s; expected: %d, actual: %d\x1B[0m",
"list.count",
5LL,
DWORD1(v2));
result = _unit_test_msgbuf__;
}
}
else
{
sprintf(
_unit_test_msgbuf__,
"\x1B[0;31mFailed: %s; expected: %d, actual: %d\x1B[0m",
"parseCSV( &list, \",,,,\" )",
1LL,
v0);
result = _unit_test_msgbuf__;
}
return result;
}

original_code:
static char *parseCSV_ShouldReturnAFieldIfTheLineEndsWithAComma_GivenACSVLineToParse()
{
     data_list_s list = { 0 };
     do { int __expected__ = (bl_True); int __actual__ = (parseCSV( &list, ",,,," )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "parseCSV( &list, \",,,,\" )", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     do { int __expected__ = (5); int __actual__ = (list.count); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "list.count", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     return ((void *)0);
}

canonical_original_code:
static char *parseCSV_ShouldReturnAFieldIfTheLineEndsWithAComma_GivenACSVLineToParse()
{
     struct data_list_s list = { 0 };
     do { int __expected__ = (bl_True); int __actual__ = (parseCSV( &list, ",,,," )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "parseCSV( &list, \",,,,\" )", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     do { int __expected__ = (5); int __actual__ = (list.count); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "list.count", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     return ((void *)0);
}

user_defined_types: struct data_list_s { int __max; int count; void *data; }


decompiled_code:
char *parseCSV_ShouldTreatNewlineAsEndOfCSV_GivenACSVLineWithNewlineToParse()
{
unsigned int v0; // eax
char *result; // rax
__int128 v2; // [rsp+0h] [rbp-18h] BYREF

v2 = 0LL;
v0 = parseCSV(&v2, ",,,,\n,,");
if ( v0 == 1 )
{
result = 0LL;
if ( DWORD1(v2) != 5 )
{
sprintf(
_unit_test_msgbuf__,
"\x1B[0;31mFailed: %s; expected: %d, actual: %d\x1B[0m",
"list.count",
5LL,
DWORD1(v2));
result = _unit_test_msgbuf__;
}
}
else
{
sprintf(
_unit_test_msgbuf__,
"\x1B[0;31mFailed: %s; expected: %d, actual: %d\x1B[0m",
"parseCSV( &list, \",,,,\\n,,\" )",
1LL,
v0);
result = _unit_test_msgbuf__;
}
return result;
}

canonical_decompiled_code:
char *func2()
{
unsigned int v0; // eax
char *result; // rax
__int128 v2; // [rsp+0h] [rbp-18h] BYREF

v2 = 0LL;
v0 = parseCSV(&v2, ",,,,\n,,");
if ( v0 == 1 )
{
result = 0LL;
if ( DWORD1(v2) != 5 )
{
sprintf(
_unit_test_msgbuf__,
"\x1B[0;31mFailed: %s; expected: %d, actual: %d\x1B[0m",
"list.count",
5LL,
DWORD1(v2));
result = _unit_test_msgbuf__;
}
}
else
{
sprintf(
_unit_test_msgbuf__,
"\x1B[0;31mFailed: %s; expected: %d, actual: %d\x1B[0m",
"parseCSV( &list, \",,,,\\n,,\" )",
1LL,
v0);
result = _unit_test_msgbuf__;
}
return result;
}

original_code:
static char *parseCSV_ShouldTreatNewlineAsEndOfCSV_GivenACSVLineWithNewlineToParse()
{
     data_list_s list = { 0 };
     do { int __expected__ = (bl_True); int __actual__ = (parseCSV( &list, ",,,,\n,," )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "parseCSV( &list, \",,,,\\n,,\" )", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     do { int __expected__ = (5); int __actual__ = (list.count); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "list.count", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     return ((void *)0);
}

canonical_original_code:
static char *parseCSV_ShouldTreatNewlineAsEndOfCSV_GivenACSVLineWithNewlineToParse()
{
     struct data_list_s list = { 0 };
     do { int __expected__ = (bl_True); int __actual__ = (parseCSV( &list, ",,,,\n,," )); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "parseCSV( &list, \",,,,\\n,,\" )", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     do { int __expected__ = (5); int __actual__ = (list.count); if ( __expected__ != __actual__ ) { sprintf( __unit_test_msgbuf__, "\033[0;31mFailed: %s; expected: %d, actual: %d\033[0m", "list.count", __expected__, __actual__ ); return __unit_test_msgbuf__; } } while ( 0 );
     return ((void *)0);
}


clearErrorMessage

decompiled_code:
void clearErrorMessage()
{
error_message = 0;
}

canonical_decompiled_code:
void func0()
{
error_message = 0;
}

original_code:
static void clearErrorMessage( void )
{
     error_message[0] = '\0';
}

canonical_original_code:
static void clearErrorMessage()
{
     error_message[0] = '\0';
}


getFormatDosToAmigaError

decompiled_code:
char *getFormatDosToAmigaError()
{
return &error_message;
}

canonical_decompiled_code:
char *func1()
{
return &error_message;
}

original_code:
char *getFormatDosToAmigaError( void )
{
     return error_message;
}

canonical_original_code:
char *getFormatDosToAmigaError()
{
     return error_message;
}


original_code:
int add_to_data_list( data_list_s *data_list, const void *data_item, const int data_size, const int increment )
{
     if ( data_list->count == data_list->__max )
     {
          void *new_block = ((void *)0);
          data_list->__max += increment;
          new_block = realloc( data_list->data, data_size * data_list->__max );
          if ( new_block == ((void *)0) )
          {
               free( data_list->data );
               data_list->count = 0;
               data_list->__max = 0;
               data_list->data = ((void *)0);
               return -1;
          }
          memset( new_block + (data_size * data_list->count), '\0', data_size * (data_list->__max - data_list->count) );
          data_list->data = new_block;
     }
     memcpy( data_list->data + (data_size * data_list->count), data_item, data_size );
     data_list->count++;
     return 0;
}

canonical_original_code:
int add_to_data_list(struct data_list_s *data_list, void *data_item, int data_size, int increment)
{
     if ( data_list->count == data_list->__max )
     {
          void *new_block = ((void *)0);
          data_list->__max += increment;
          new_block = realloc( data_list->data, data_size * data_list->__max );
          if ( new_block == ((void *)0) )
          {
               free( data_list->data );
               data_list->count = 0;
               data_list->__max = 0;
               data_list->data = ((void *)0);
               return -1;
          }
          memset( new_block + (data_size * data_list->count), '\0', data_size * (data_list->__max - data_list->count) );
          data_list->data = new_block;
     }
     memcpy( data_list->data + (data_size * data_list->count), data_item, data_size );
     data_list->count++;
     return 0;
}

variable_types: struct data_list_s { int __max; int count; void *data; } *

variable_types: increment int


decompiled_code:
void __fastcall clear_data_list(_QWORD *a1)
{
void *v2; // rdi

v2 = (void *)a1[1];
if ( v2 )
free(v2);
*a1 = 0LL;
a1[1] = 0LL;
}

canonical_decompiled_code:
void __fastcall func1(_QWORD *a1)
{
void *v2; // rdi

v2 = (void *)a1[1];
if ( v2 )
free(v2);
*a1 = 0LL;
a1[1] = 0LL;
}

original_code:
void clear_data_list( data_list_s *data_list )
{
     if ( data_list->data != ((void *)0) ) free( data_list->data );
     data_list->data = ((void *)0);
     data_list->__max = 0;
     data_list->count = 0;
}

canonical_original_code:
void clear_data_list(struct data_list_s *data_list)
{
     if ( data_list->data != ((void *)0) ) free( data_list->data );
     data_list->data = ((void *)0);
     data_list->__max = 0;
     data_list->count = 0;
}


printPlayer

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

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

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

result = *(_DWORD *)(a1 + 8);
if ( !result )
return func0(a1);
if ( result == 1 )
result = func1(a1);
return result;
}

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

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

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

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

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

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


printInjuries

original_code:
static void printInjuries( const league_s *leagues )
{
     boolean_e printTeam = bl_False;
     int leag;
     int div;
     int team;
     int plyr;
     for ( leag = 0; leag < 2; ++leag )
     {
   for ( div = 0; div < 2; ++div )
   {
        for ( team = 0; team < 8; ++team )
        {
                    printTeam = bl_True;
      for ( plyr = 0; plyr < 25; ++plyr )
      {
    const player_s *pl = &leagues[leag].divisions[div].teams[team].players[plyr];
                         if ( pl->injury_days <= 0 ) continue;
                         if ( print_pitcher_rest == bl_False &&
                              pl->type == pt_Pitcher &&
                              pl->injury_days <= 4 ) continue;
                         if ( printTeam )
                         {
                              printf( "%s:\n", leagues[leag].divisions[div].teams[team].name );
                              printTeam = bl_False;
                         }
                         printPlayer( pl );
      }
                    if ( ! printTeam ) printf( "\n" );
        }
   }
     }
}

canonical_original_code:
static void printInjuries(struct league_s *leagues)
{
     enum boolean_e printTeam = bl_False;
     int leag;
     int div;
     int team;
     int plyr;
     for ( leag = 0; leag < 2; ++leag )
     {
   for ( div = 0; div < 2; ++div )
   {
        for ( team = 0; team < 8; ++team )
        {
                    printTeam = bl_True;
      for ( plyr = 0; plyr < 25; ++plyr )
      {
    struct player_s *pl = &leagues[leag].divisions[div].teams[team].players[plyr];
                         if ( pl->injury_days <= 0 ) continue;
                         if ( print_pitcher_rest == bl_False &&
                              pl->type == pt_Pitcher &&
                              pl->injury_days <= 4 ) continue;
                         if ( printTeam )
                         {
                              printf( "%s:\n", leagues[leag].divisions[div].teams[team].name );
                              printTeam = bl_False;
                         }
                         printPlayer( pl );
      }
                    if ( ! printTeam ) printf( "\n" );
        }
   }
     }
}

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

variable_types: enum boolean_e { bl_False=0, bl_True=1 }

variable_types: leag int

variable_types: div int

variable_types: team int

variable_types: plyr int

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

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

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


convertDivisionStats

decompiled_code:
__int64 __fastcall convertDivisionStats(__int64 a1)
{
int v1; // er8
__int64 result; // rax
__int128 v3; // [rsp+0h] [rbp-58h] BYREF
__int64 v4[6]; // [rsp+10h] [rbp-48h] BYREF
int v5; // [rsp+40h] [rbp-18h]

v3 = 0LL;
v4[0] = -1LL;
v4[1] = 0xFFFFFFFF00000000LL;
v4[2] = -1LL;
v4[3] = -1LL;
v4[4] = -1LL;
v4[5] = -1LL;
v5 = -1;
v1 = add_to_data_list(&v3, a1, 52LL, 5LL);
result = 0LL;
if ( v1 >= 0 )
{
add_to_data_list(&v3, v4, 52LL, 5LL);
result = *((_QWORD *)&v3 + 1);
}
return result;
}

original_code:
static division_stats_s *convertDivisionStats( division_stats_s *division_stats )
{
     data_list_s list = { 0 };
     division_stats_s sentinel = { -1, -1, sp_None, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
     if ( add_to_data_list( &list, division_stats, sizeof(division_stats_s), 5 ) < 0 ) return ((void *)0);
          add_to_data_list( &list, &sentinel, sizeof(division_stats_s), 5 );
     return list.data;
}

canonical_original_code:
static struct division_stats_s *convertDivisionStats(struct division_stats_s *division_stats)
{
     struct data_list_s list = { 0 };
     struct division_stats_s sentinel = { -1, -1, sp_None, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
     if ( add_to_data_list( &list, division_stats, sizeof(division_stats_s), 5 ) < 0 ) return ((void *)0);
          add_to_data_list( &list, &sentinel, sizeof(division_stats_s), 5 );
     return list.data;
}

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

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


addDivisionToList

decompiled_code:
_BOOL8 __fastcall addDivisionToList(__int64 a1, int a2, int *a3)
{
int v3; // eax
int v5[2]; // [rsp+0h] [rbp-18h] BYREF
int *v6; // [rsp+8h] [rbp-10h]

v3 = *a3;
v5[0] = a2;
v6 = a3;
v5[1] = v3;
return (int)add_to_data_list(a1, v5, 16LL, 5LL) >= 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(__int64 a1, int a2, int *a3)
{
int v3; // eax
int v5[2]; // [rsp+0h] [rbp-18h] BYREF
int *v6; // [rsp+8h] [rbp-10h]

v3 = *a3;
v5[0] = a2;
v6 = a3;
v5[1] = v3;
return (int)add_to_data_list(a1, v5, 16LL, 5LL) >= 0;
}

original_code:
static boolean_e addDivisionToList( data_list_s *list, const int league_id, division_s *division )
{
     league_division_s league_division = { 0 };
     league_division.league_id = league_id;
     league_division.division_id = division->division_id;
     league_division.division = division;
     if ( add_to_data_list( list, &league_division, sizeof(league_division_s), 5 ) < 0 ) return bl_False;
     return bl_True;
}

canonical_original_code:
static enum boolean_e addDivisionToList(struct data_list_s *list, int league_id, struct division_s *division)
{
     struct league_division_s league_division = { 0 };
     league_division.league_id = league_id;
     league_division.division_id = division->division_id;
     league_division.division = division;
     if ( add_to_data_list( list, &league_division, sizeof(league_division_s), 5 ) < 0 ) return bl_False;
     return bl_True;
}

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

return_type: enum boolean_e { bl_False=0, bl_True=1 }

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

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_accolade_s { int division_id; int season; enum division_accolade_e accolade; }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


createDivision

decompiled_code:
char *__fastcall createDivision(int a1, const char *a2)
{
char *v2; // rax
char *v3; // r12

v2 = (char *)calloc(0x38uLL, 1uLL);
v3 = v2;
if ( v2 )
{
*(_DWORD *)v2 = a1;
strcpy(v2 + 4, a2);
}
return v3;
}

canonical_decompiled_code:
char *__fastcall func2(int a1, const char *a2)
{
char *v2; // rax
char *v3; // r12

v2 = (char *)calloc(0x38uLL, 1uLL);
v3 = v2;
if ( v2 )
{
*(_DWORD *)v2 = a1;
strcpy(v2 + 4, a2);
}
return v3;
}

original_code:
static division_s *createDivision( const int division_id, const char *name )
{
     division_s *division = ((void *)0);
     if ( (division = malloc( sizeof(division_s) )) == ((void *)0) ) return ((void *)0);
     memset( division, '\0', sizeof(division_s) );
             division->division_id = division_id;
     strcpy( division->name, name );
     return division;
}

canonical_original_code:
static struct division_s *createDivision(int division_id, char *name)
{
     struct division_s *division = ((void *)0);
     if ( (division = malloc( sizeof(division_s) )) == ((void *)0) ) return ((void *)0);
     memset( division, '\0', sizeof(division_s) );
             division->division_id = division_id;
     strcpy( division->name, name );
     return division;
}

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


convertDivisions

original_code:
league_division_s *convertDivisions( const org_data_s *org_data, const int league_id, const int league_idx )
{
     data_list_s list = { 0 };
     league_division_s sentinel = { -1, -1 };
     division_s *divisions[2] = { 0 };
     int idx = league_idx * 2;
     for ( int i = 0; i < 2; ++i )
     {
          int division_idx = idx + i;
          int division_id = idx + i + 1;
          if ( (divisions[i] = createDivision( division_id, org_data->league_data->divisions[division_idx].name )) == ((void *)0) )
          {
               freeDivisions( divisions, 2 );
               return ((void *)0);
          }
          if ( (divisions[i]->teams = convertDivisionTeams( org_data, division_id, division_idx )) == ((void *)0) )
          {
               freeDivisions( divisions, 2 );
               return ((void *)0);
          }
          if ( (divisions[i]->stats = convertDivisionStats( &(org_data->records->divisions[division_idx]) )) == ((void *)0) )
          {
               freeDivisions( divisions, 2 );
               return ((void *)0);
          }
          if ( addDivisionToList( &list, league_id, divisions[i] ) != bl_True )
          {
               freeDivisions( divisions, 2 );
               return ((void *)0);
          }
     }
     add_to_data_list( &list, &sentinel, sizeof(league_division_s), 5 );
     return list.data;
}

canonical_original_code:
struct league_division_s *convertDivisions(struct org_data_s *org_data, int league_id, int league_idx)
{
     struct data_list_s list = { 0 };
     struct league_division_s sentinel = { -1, -1 };
     struct division_s *divisions[2] = { 0 };
     int idx = league_idx * 2;
     for ( int i = 0; i < 2; ++i )
     {
          int division_idx = idx + i;
          int division_id = idx + i + 1;
          if ( (divisions[i] = createDivision( division_id, org_data->league_data->divisions[division_idx].name )) == ((void *)0) )
          {
               freeDivisions( divisions, 2 );
               return ((void *)0);
          }
          if ( (divisions[i]->teams = convertDivisionTeams( org_data, division_id, division_idx )) == ((void *)0) )
          {
               freeDivisions( divisions, 2 );
               return ((void *)0);
          }
          if ( (divisions[i]->stats = convertDivisionStats( &(org_data->records->divisions[division_idx]) )) == ((void *)0) )
          {
               freeDivisions( divisions, 2 );
               return ((void *)0);
          }
          if ( addDivisionToList( &list, league_id, divisions[i] ) != bl_True )
          {
               freeDivisions( divisions, 2 );
               return ((void *)0);
          }
     }
     add_to_data_list( &list, &sentinel, sizeof(league_division_s), 5 );
     return list.data;
}

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

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

variable_types: i int

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

user_defined_types: struct data_list_s { int __max; int count; void *data; }

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

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

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

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

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 records_s { struct league_stats_s *leagues; struct division_stats_s *divisions; struct team_stats_s *teams; struct team_versus_stats_s *versus[-1]; }

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

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

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

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

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


displayAvg

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

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

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

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

variable_types: avg double

variable_types:
buffer
char [-1]


printPlayer

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

result = a1[2];
if ( !result )
return printPitcher(a1);
if ( result == 1 )
result = printHitter(a1);
return result;
}

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

result = a1[2];
if ( !result )
return func9(a1);
if ( result == 1 )
result = func7(a1);
return result;
}

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

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

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

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

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

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

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

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