//
// GameStatsManager::preSaveGameStats from 0x7b3b28 to 0x7b3d58 (560 bytes)
//
// 3 xrefs:
// > GameStatsManager::encodeDataTo @ 0x7b3d6c
// > GJAccountManager::onSyncAccountCompleted @ 0x84889c
// > ??> @ 0x4dec8
//
// 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
//
void GameStatsManager::preSaveGameStats(GameStatsManager *a1)
{
unsigned int v2; // w20
char *v3; // x1
char *v4; // x0
cocos2d::CCString *v5; // x0
char *CString; // x0
cocos2d::CCDictionary *m_playerStats; // x26
unsigned int Stat; // w0
cocos2d::CCObject *v9; // x25
void *v10; // x0
unsigned int *v11; // x1
int v12; // w2
unsigned int *v13; // x1
int v14; // w2
bool m_dontNotify; // [xsp+6Ch] [xbp+6Ch]
char *v16; // [xsp+88h] [xbp+88h] BYREF
__int64 v17; // [xsp+90h] [xbp+90h] BYREF
v2 = 1;
m_dontNotify = AchievementManager::sharedState()->m_dontNotify;
AchievementManager::sharedState()->m_dontNotify = 1;
do
{
while ( 1 )
{
v5 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", (const char *)v2);
CString = (char *)cocos2d::CCString::getCString(v5);
sub_D153B8((int)&v16, CString);
m_playerStats = a1->m_playerStats;
Stat = GameStatsManager::getStat(a1, v16);
v9 = (cocos2d::CCObject *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", (const char *)Stat);
sub_D153B8((int)&v17, v16);
cocos2d::CCDictionary::setObject((int)m_playerStats, v9);
v10 = (void *)(v17 - 24);
if ( (__int64 *)(v17 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v11 = (unsigned int *)(v17 - 8);
do
v12 = __ldaxr(v11);
while ( __stlxr(v12 - 1, v11) );
}
else
{
v12 = *(_DWORD *)(v17 - 8);
*(_DWORD *)(v17 - 8) = v12 - 1;
}
if ( v12 <= 0 )
break;
}
v3 = v16;
v4 = v16 - 24;
if ( v16 - 24 != (char *)&qword_124B6B0 )
goto LABEL_10;
LABEL_3:
if ( ++v2 == 44 )
goto LABEL_15;
}
operator delete(v10);
v3 = v16;
v4 = v16 - 24;
if ( v16 - 24 == (char *)&qword_124B6B0 )
goto LABEL_3;
LABEL_10:
if ( &pthread_create )
{
v13 = (unsigned int *)(v3 - 8);
do
v14 = __ldaxr(v13);
while ( __stlxr(v14 - 1, v13) );
}
else
{
v14 = *((_DWORD *)v3 - 2);
*((_DWORD *)v3 - 2) = v14 - 1;
}
if ( v14 > 0 )
goto LABEL_3;
++v2;
operator delete(v4);
}
while ( v2 != 44 );
LABEL_15:
AchievementManager::sharedState()->m_dontNotify = m_dontNotify;
}