//
// GameStatsManager::preSaveGameStats from 0x8dd268 to 0x8dd41c (436 bytes)
//
// 3 xrefs:
// > GameStatsManager::encodeDataTo @ 0x8dd430
// > GJAccountManager::onSyncAccountCompleted @ 0x989d94
// > ??> @ 0x6d258
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:56:48 +0000
//
__int64 __fastcall GameStatsManager::preSaveGameStats(GameStatsManager *this)
{
unsigned int v2; // w21
AchievementManager *v3; // x0
char v4; // w25
AchievementManager *v5; // x0
cocos2d::CCString *v6; // x0
const char *CString; // x0
size_t v8; // x0
__int64 v9; // x26
const char *v10; // x1
unsigned int Stat; // w0
cocos2d::CCObject *v12; // x27
const char *v13; // x1
size_t v14; // x0
char *v16; // [xsp+68h] [xbp+68h]
char *v17; // [xsp+68h] [xbp+68h]
__int64 v18[2]; // [xsp+78h] [xbp+78h] BYREF
void *v19; // [xsp+88h] [xbp+88h]
__int64 v20[2]; // [xsp+90h] [xbp+90h] BYREF
void *v21; // [xsp+A0h] [xbp+A0h]
v2 = 1;
v3 = (AchievementManager *)AchievementManager::sharedState(_stack_chk_guard);
v4 = *((_BYTE *)v3 + 360);
*(_BYTE *)(AchievementManager::sharedState(v3) + 360) = 1;
do
{
while ( 1 )
{
v6 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", (const char *)v2);
CString = (const char *)cocos2d::CCString::getCString(v6);
v18[0] = 0;
v18[1] = 0;
v19 = nullptr;
v16 = (char *)CString;
v8 = strlen(CString);
std::string::__init(v18, v16, v8);
v9 = *((_QWORD *)this + 65);
v10 = (char *)v18 + 1;
if ( (v18[0] & 1) != 0 )
v10 = (const char *)v19;
Stat = GameStatsManager::getStat(this, v10);
v12 = (cocos2d::CCObject *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", (const char *)Stat);
v13 = (char *)v18 + 1;
if ( (v18[0] & 1) != 0 )
v13 = (const char *)v19;
v17 = (char *)v13;
v20[0] = 0;
v20[1] = 0;
v21 = nullptr;
v14 = strlen(v13);
std::string::__init(v20, v17, v14);
cocos2d::CCDictionary::setObject(v9, v12);
if ( (v20[0] & 1) != 0 )
break;
v5 = (AchievementManager *)LOBYTE(v18[0]);
if ( (v18[0] & 1) != 0 )
goto LABEL_10;
LABEL_3:
if ( ++v2 == 45 )
goto LABEL_11;
}
operator delete(v21);
v5 = (AchievementManager *)LOBYTE(v18[0]);
if ( (v18[0] & 1) == 0 )
goto LABEL_3;
LABEL_10:
++v2;
operator delete(v19);
}
while ( v2 != 45 );
LABEL_11:
*(_BYTE *)(AchievementManager::sharedState(v5) + 360) = v4;
return _stack_chk_guard;
}