//
// GameStatsManager::getNextVideoAdReward from 0x7a59c4 to 0x7a6010 (1612 bytes)
//
// 6 xrefs:
// > GameManager::rewardedVideoHidden @ 0x5e846c
// > GameManager::canShowRewardedVideo @ 0x5eb0c4
// > GJGarageLayer::onRewardedVideo @ 0x79050c
// > RetryLevelLayer::onRewardedVideo @ 0x7ee780
// > FollowRewardPage::onRewardedVideo @ 0x9634cc
// > ??> @ 0x368b8
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
__int64 *__usercall GameStatsManager::getNextVideoAdReward@(
__int64 *__return_ptr a1@,
GameStatsManager *this@)
{
int isSpecialChestUnlocked; // w26
char *v5; // x0
int v6; // w26
char *v7; // x0
int v8; // w26
char *v9; // x0
int v10; // w26
char *v11; // x0
int v12; // w26
char *v13; // x0
int v14; // w26
char *v15; // x0
int v16; // w26
char *v17; // x0
int v18; // w26
char *v19; // x0
int v20; // w26
int v21; // w22
unsigned int *v23; // x1
int v24; // w2
unsigned int *v25; // x1
int v26; // w2
unsigned int *v27; // x1
int v28; // w2
unsigned int *v29; // x1
int v30; // w2
unsigned int *v31; // x1
int v32; // w2
unsigned int *v33; // x1
int v34; // w2
unsigned int *v35; // x1
int v36; // w2
unsigned int *v37; // x1
int v38; // w2
char *v39; // [xsp+60h] [xbp+60h] BYREF
sub_D153B8((int)&v39, "0012");
isSpecialChestUnlocked = (unsigned __int8)GameStatsManager::isSpecialChestUnlocked((__int64)this, &v39);
v5 = v39 - 24;
if ( v39 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v23 = (unsigned int *)(v39 - 8);
do
v24 = __ldaxr(v23);
while ( __stlxr(v24 - 1, v23) );
}
else
{
v24 = *((_DWORD *)v39 - 2);
*((_DWORD *)v39 - 2) = v24 - 1;
}
if ( v24 <= 0 )
operator delete(v5);
}
if ( !isSpecialChestUnlocked )
{
sub_D153B8((int)a1, "0012");
return a1;
}
sub_D153B8((int)&v39, "0013");
v6 = (unsigned __int8)GameStatsManager::isSpecialChestUnlocked((__int64)this, &v39);
v7 = v39 - 24;
if ( v39 - 24 == (char *)&qword_124B6B0 )
goto LABEL_4;
if ( &pthread_create )
{
v25 = (unsigned int *)(v39 - 8);
do
v26 = __ldaxr(v25);
while ( __stlxr(v26 - 1, v25) );
}
else
{
v26 = *((_DWORD *)v39 - 2);
*((_DWORD *)v39 - 2) = v26 - 1;
}
if ( v26 > 0 )
{
LABEL_4:
if ( !v6 )
{
LABEL_24:
sub_D153B8((int)a1, "0013");
return a1;
}
}
else
{
operator delete(v7);
if ( !v6 )
goto LABEL_24;
}
sub_D153B8((int)&v39, "0014");
v8 = (unsigned __int8)GameStatsManager::isSpecialChestUnlocked((__int64)this, &v39);
v9 = v39 - 24;
if ( v39 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v27 = (unsigned int *)(v39 - 8);
do
v28 = __ldaxr(v27);
while ( __stlxr(v28 - 1, v27) );
}
else
{
v28 = *((_DWORD *)v39 - 2);
*((_DWORD *)v39 - 2) = v28 - 1;
}
if ( v28 <= 0 )
operator delete(v9);
}
if ( !v8 )
{
sub_D153B8((int)a1, "0014");
return a1;
}
sub_D153B8((int)&v39, "0015");
v10 = (unsigned __int8)GameStatsManager::isSpecialChestUnlocked((__int64)this, &v39);
v11 = v39 - 24;
if ( v39 - 24 == (char *)&qword_124B6B0 )
goto LABEL_8;
if ( &pthread_create )
{
v29 = (unsigned int *)(v39 - 8);
do
v30 = __ldaxr(v29);
while ( __stlxr(v30 - 1, v29) );
}
else
{
v30 = *((_DWORD *)v39 - 2);
*((_DWORD *)v39 - 2) = v30 - 1;
}
if ( v30 > 0 )
{
LABEL_8:
if ( !v10 )
{
LABEL_32:
sub_D153B8((int)a1, "0015");
return a1;
}
}
else
{
operator delete(v11);
if ( !v10 )
goto LABEL_32;
}
sub_D153B8((int)&v39, "0016");
v12 = (unsigned __int8)GameStatsManager::isSpecialChestUnlocked((__int64)this, &v39);
v13 = v39 - 24;
if ( v39 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v31 = (unsigned int *)(v39 - 8);
do
v32 = __ldaxr(v31);
while ( __stlxr(v32 - 1, v31) );
}
else
{
v32 = *((_DWORD *)v39 - 2);
*((_DWORD *)v39 - 2) = v32 - 1;
}
if ( v32 <= 0 )
operator delete(v13);
}
if ( !v12 )
{
sub_D153B8((int)a1, "0016");
return a1;
}
sub_D153B8((int)&v39, "0017");
v14 = (unsigned __int8)GameStatsManager::isSpecialChestUnlocked((__int64)this, &v39);
v15 = v39 - 24;
if ( v39 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v33 = (unsigned int *)(v39 - 8);
do
v34 = __ldaxr(v33);
while ( __stlxr(v34 - 1, v33) );
}
else
{
v34 = *((_DWORD *)v39 - 2);
*((_DWORD *)v39 - 2) = v34 - 1;
}
if ( v34 <= 0 )
operator delete(v15);
}
if ( !v14 )
{
sub_D153B8((int)a1, "0017");
return a1;
}
sub_D153B8((int)&v39, "0018");
v16 = (unsigned __int8)GameStatsManager::isSpecialChestUnlocked((__int64)this, &v39);
v17 = v39 - 24;
if ( v39 - 24 == (char *)&qword_124B6B0 )
goto LABEL_14;
if ( &pthread_create )
{
v35 = (unsigned int *)(v39 - 8);
do
v36 = __ldaxr(v35);
while ( __stlxr(v36 - 1, v35) );
}
else
{
v36 = *((_DWORD *)v39 - 2);
*((_DWORD *)v39 - 2) = v36 - 1;
}
if ( v36 > 0 )
{
LABEL_14:
if ( !v16 )
{
LABEL_52:
sub_D153B8((int)a1, "0018");
return a1;
}
}
else
{
operator delete(v17);
if ( !v16 )
goto LABEL_52;
}
sub_D153B8((int)&v39, "0019");
v18 = (unsigned __int8)GameStatsManager::isSpecialChestUnlocked((__int64)this, &v39);
v19 = v39 - 24;
if ( v39 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v37 = (unsigned int *)(v39 - 8);
do
v38 = __ldaxr(v37);
while ( __stlxr(v38 - 1, v37) );
}
else
{
v38 = *((_DWORD *)v39 - 2);
*((_DWORD *)v39 - 2) = v38 - 1;
}
if ( v38 <= 0 )
operator delete(v19);
}
if ( v18 )
{
sub_D153B8((int)&v39, "0020");
v20 = (unsigned __int8)GameStatsManager::isSpecialChestUnlocked((__int64)this, &v39);
if ( v39 - 24 != (char *)&qword_124B6B0 )
sub_7A1200(v39 - 24);
if ( v20 )
{
sub_D153B8((int)&v39, "0021");
v21 = (unsigned __int8)GameStatsManager::isSpecialChestUnlocked((__int64)this, &v39);
if ( v39 - 24 != (char *)&qword_124B6B0 )
sub_7A1200(v39 - 24);
if ( v21 )
sub_D153B8((int)a1, &byte_F288A0);
else
sub_D153B8((int)a1, "0021");
}
else
{
sub_D153B8((int)a1, "0020");
}
}
else
{
sub_D153B8((int)a1, "0019");
}
return a1;
}