//
// GameStatsManager::recountSpecialStats from 0x8ebab8 to 0x8ec49c (2532 bytes)
//
// 2 xrefs:
// > GameManager::dataLoaded @ 0x727a58
// > ??> @ 0xfbb90
//
// 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:56 +0000
//
__int64 __fastcall GameStatsManager::recountSpecialStats(cocos2d::CCDictionary **this)
{
GameStatsManager *TotalCollectedCurrency; // x0
int v3; // w24
GameStatsManager *v4; // x0
GameStatsManager *Stat; // x0
GameStatsManager *v6; // x0
int v7; // w20
unsigned int v8; // w28
unsigned int TotalCollectedDiamonds; // w26
unsigned int v10; // w27
signed int v11; // w25
int v12; // w1
__int64 v13; // x0
__int64 v14; // x0
__int64 i; // x21
__int64 v16; // x19
__int64 v17; // x0
__int64 v18; // x0
__int64 j; // x20
int v20; // w0
__int64 v21; // x0
unsigned int *v22; // x1
cocos2d::CCString *v23; // x0
const char *CString; // x0
size_t v25; // x0
const char *v26; // x0
int v27; // w19
signed int v28; // w0
cocos2d::CCArray *v29; // x20
unsigned int v30; // w19
__int64 v31; // x0
cocos2d::CCString **v32; // x0
__int64 v33; // x0
unsigned int *v34; // x1
cocos2d::CCString **v35; // x22
cocos2d::CCString *v36; // x0
const char *v37; // x0
size_t v38; // x0
const char *v39; // x0
__int64 StoreItem; // x20
cocos2d::CCString *v41; // x0
int v42; // w19
__int64 k; // x0
unsigned int *v44; // x1
__int64 *v45; // x19
char *v46; // x20
const char *v47; // x0
size_t v48; // x0
cocos2d::CCString *v49; // x0
int v50; // w0
AchievementManager *v51; // x0
char v52; // w22
char v53; // w21
unsigned int v54; // w19
__int64 isItemUnlocked; // x0
__int64 v56; // x0
cocos2d::CCString *v57; // x0
const char *v58; // x0
size_t v59; // x0
GameManager *v60; // x0
GameManager *v61; // x0
char *v62; // x1
int v63; // w19
unsigned int v64; // w20
GameStatsManager *v65; // x0
unsigned int v66; // w1
GameStatsManager *v67; // x0
GameStatsManager *v68; // x0
GameStatsManager *v69; // x0
GameManager *v70; // x0
GameManager *v71; // x0
AchievementManager *v72; // x0
char *v74; // [xsp+60h] [xbp+60h]
int v75; // [xsp+60h] [xbp+60h]
char *v76; // [xsp+68h] [xbp+68h]
cocos2d::CCString **v77; // [xsp+68h] [xbp+68h]
cocos2d::CCString **v78; // [xsp+70h] [xbp+70h]
char *v79; // [xsp+70h] [xbp+70h]
int v80; // [xsp+70h] [xbp+70h]
char *v81; // [xsp+70h] [xbp+70h]
signed int v82; // [xsp+78h] [xbp+78h]
unsigned int v83; // [xsp+7Ch] [xbp+7Ch]
char *v84; // [xsp+80h] [xbp+80h]
unsigned int v85; // [xsp+88h] [xbp+88h]
unsigned int v86; // [xsp+8Ch] [xbp+8Ch]
unsigned int v87; // [xsp+90h] [xbp+90h]
unsigned int v88; // [xsp+94h] [xbp+94h]
unsigned int v89; // [xsp+98h] [xbp+98h]
char *v90; // [xsp+98h] [xbp+98h]
char *v91; // [xsp+98h] [xbp+98h]
__int64 v92; // [xsp+A0h] [xbp+A0h] BYREF
__int64 v93; // [xsp+A8h] [xbp+A8h]
void *v94; // [xsp+B0h] [xbp+B0h]
TotalCollectedCurrency = (GameStatsManager *)GameStatsManager::getTotalCollectedCurrency(this);
v3 = (int)TotalCollectedCurrency;
v4 = (GameStatsManager *)GameStatsManager::sharedState(TotalCollectedCurrency);
Stat = (GameStatsManager *)GameStatsManager::getStat(v4, "22");
if ( v3 != (_DWORD)Stat )
{
v6 = (GameStatsManager *)GameStatsManager::sharedState(Stat);
GameStatsManager::setStat(v6, "22", (char *)(unsigned int)v3);
}
v82 = 0;
v7 = 0;
v8 = 0;
v83 = 0;
TotalCollectedDiamonds = GameStatsManager::getTotalCollectedDiamonds((GameStatsManager *)this);
v84 = nullptr;
v10 = 0;
v85 = 0;
v86 = 0;
v87 = 0;
v88 = 0;
v89 = 0;
v11 = vcvtms_s32_f32((float)v3 / 500.0);
*((_DWORD *)this + 194) = v11;
v12 = (int)(float)((float)((float)rand() * 4.6566e-10) * 1000.0);
*((_DWORD *)this + 193) = v12;
*((_DWORD *)this + 192) = v11 + v12;
GameStatsManager::removeErrorFromSpecialChests(this);
do
{
if ( v7 == 1 )
{
v13 = (__int64)*(this + 98);
}
else if ( v7 == 2 )
{
v13 = (__int64)*(this + 92);
}
else
{
v13 = (__int64)*(this + 60);
}
if ( v13 )
{
v14 = *(_QWORD *)(v13 + 56);
if ( v14 )
{
for ( i = *(_QWORD *)(v14 + 288); ; i = *(_QWORD *)(i + 288) )
{
v16 = *(_QWORD *)(v14 + 264);
v3 += GJRewardItem::getRewardCount(v16, 7);
TotalCollectedDiamonds += GJRewardItem::getRewardCount(v16, 8);
v89 += GJRewardItem::getRewardCount(v16, 1);
v88 += GJRewardItem::getRewardCount(v16, 2);
v87 += GJRewardItem::getRewardCount(v16, 3);
v86 += GJRewardItem::getRewardCount(v16, 4);
v85 += GJRewardItem::getRewardCount(v16, 5);
HIDWORD(v84) += GJRewardItem::getRewardCount(v16, 10);
LODWORD(v84) = (_DWORD)v84 + GJRewardItem::getRewardCount(v16, 11);
v83 += GJRewardItem::getRewardCount(v16, 12);
v10 += GJRewardItem::getRewardCount(v16, 13);
v8 += GJRewardItem::getRewardCount(v16, 14);
v11 += GJRewardItem::getRewardCount(v16, 6);
v82 += GJRewardItem::getRewardCount(v16, 15);
if ( !i )
break;
v14 = i;
}
}
}
++v7;
}
while ( v7 != 3 );
v17 = (__int64)*(this + 61);
if ( v17 )
{
v18 = *(_QWORD *)(v17 + 56);
if ( v18 )
{
for ( j = *(_QWORD *)(v18 + 288); ; j = *(_QWORD *)(j + 288) )
{
v20 = cocos2d::CCString::intValue(*(cocos2d::CCString **)(v18 + 264));
if ( v20 > 200 )
v20 = 200;
v3 += v20;
if ( !j )
break;
v18 = j;
}
}
}
v21 = cocos2d::CCDictionary::allKeys(*(this + 95));
if ( v21 )
{
v22 = *(unsigned int **)(v21 + 56);
if ( *v22 )
{
v78 = *((cocos2d::CCString ***)v22 + 2);
v74 = (char *)&v78[*v22 - 1];
if ( v78 <= (cocos2d::CCString **)v74 )
{
v23 = *v78;
if ( *v78 )
{
while ( 1 )
{
CString = (const char *)cocos2d::CCString::getCString(v23);
v92 = 0;
v93 = 0;
v94 = nullptr;
v76 = (char *)CString;
v25 = strlen(CString);
std::string::__init(&v92, v76, v25);
v26 = (v92 & 1) != 0 ? (const char *)v94 : (char *)&v92 + 1;
v27 = atoi(v26);
v28 = GameStatsManager::keyCostForSecretChest((GameStatsManager *)this, v27);
if ( v82 >= v28 && v27 > 6000 )
break;
if ( (v11 >= v28) > (unsigned int)(v27 > 6000) )
{
v11 -= v28;
LABEL_29:
v29 = *(cocos2d::CCArray **)(cocos2d::CCDictionary::objectForKey(*(this + 95), &v92) + 72);
if ( v29 )
{
v30 = 0;
while ( v30 < (unsigned int)cocos2d::CCArray::count(v29) )
{
v31 = cocos2d::CCArray::objectAtIndex(v29, v30);
switch ( *(_DWORD *)(v31 + 56) )
{
case 1:
++v30;
v89 += *(_DWORD *)(v31 + 68);
break;
case 2:
++v30;
v88 += *(_DWORD *)(v31 + 68);
break;
case 3:
++v30;
v87 += *(_DWORD *)(v31 + 68);
break;
case 4:
++v30;
v86 += *(_DWORD *)(v31 + 68);
break;
case 5:
++v30;
v85 += *(_DWORD *)(v31 + 68);
break;
case 7:
++v30;
v3 += *(_DWORD *)(v31 + 68);
break;
case 8:
++v30;
TotalCollectedDiamonds += *(_DWORD *)(v31 + 68);
break;
case 0xA:
++v30;
HIDWORD(v84) += *(_DWORD *)(v31 + 68);
break;
case 0xB:
++v30;
LODWORD(v84) = (_DWORD)v84 + *(_DWORD *)(v31 + 68);
break;
case 0xC:
++v30;
v83 += *(_DWORD *)(v31 + 68);
break;
case 0xD:
++v30;
v10 += *(_DWORD *)(v31 + 68);
break;
case 0xE:
v8 += *(_DWORD *)(v31 + 68);
goto LABEL_81;
default:
LABEL_81:
++v30;
break;
}
}
}
goto LABEL_34;
}
cocos2d::CCDictionary::removeObjectForKey(*(this + 95), &v92);
LABEL_34:
if ( (v92 & 1) != 0 )
operator delete(v94);
v32 = v78 + 1;
v78 = v32;
if ( v74 >= (char *)v32 )
{
v23 = *v32;
if ( v23 )
continue;
}
goto LABEL_38;
}
v82 -= v28;
goto LABEL_29;
}
}
}
}
LABEL_38:
v33 = cocos2d::CCDictionary::allKeys(*(this + 79));
if ( v33
&& (v34 = *(unsigned int **)(v33 + 56), *v34)
&& (v35 = *((cocos2d::CCString ***)v34 + 2), v77 = &v35[*v34 - 1], v35 <= v77) )
{
v36 = *v35;
v75 = TotalCollectedDiamonds;
if ( *v35 )
{
while ( 1 )
{
v37 = (const char *)cocos2d::CCString::getCString(v36);
v92 = 0;
v93 = 0;
v94 = nullptr;
v79 = (char *)v37;
v38 = strlen(v37);
std::string::__init(&v92, v79, v38);
v39 = (v92 & 1) != 0 ? (const char *)v94 : (char *)&v92 + 1;
v80 = atoi(v39);
StoreItem = GameStatsManager::getStoreItem(this, v80);
v41 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(*(this + 79), &v92);
v42 = cocos2d::CCString::intValue(v41);
if ( v42 <= 0 )
break;
if ( StoreItem )
v42 = *(_DWORD *)(StoreItem + 352) - *(_DWORD *)(StoreItem + 356);
if ( (unsigned int)GameStatsManager::shopTypeForItemID(this, v80) == 4 )
{
if ( v42 > v75 )
break;
v75 -= v42;
}
else
{
if ( v42 > v3 )
break;
v3 -= v42;
}
if ( (v92 & 1) == 0 )
goto LABEL_51;
LABEL_94:
operator delete(v94);
LABEL_51:
if ( v77 >= ++v35 )
{
v36 = *v35;
if ( *v35 )
continue;
}
goto LABEL_55;
}
cocos2d::CCDictionary::removeObjectForKey(*(this + 79), &v92);
if ( (v92 & 1) == 0 )
goto LABEL_51;
goto LABEL_94;
}
}
else
{
v75 = TotalCollectedDiamonds;
}
LABEL_55:
k = cocos2d::CCDictionary::allKeys(*(this + 94));
if ( k )
{
v44 = *(unsigned int **)(k + 56);
k = *v44;
if ( (_DWORD)k )
{
v45 = *((__int64 **)v44 + 2);
k = 8LL * (unsigned int)k - 8;
v46 = (char *)v45 + k;
if ( v45 <= (__int64 *)((char *)v45 + k) )
{
for ( k = *v45; *v45; k = *v45 )
{
v47 = (const char *)cocos2d::CCString::getCString((cocos2d::CCString *)k);
v92 = 0;
v93 = 0;
v94 = nullptr;
v81 = (char *)v47;
v48 = strlen(v47);
std::string::__init(&v92, v81, v48);
v49 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(*(this + 94), &v92);
v50 = cocos2d::CCString::intValue(v49);
if ( v11 < v50 || v50 <= 0 )
cocos2d::CCDictionary::removeObjectForKey(*(this + 94), &v92);
else
v11 -= v50;
k = (unsigned __int8)v92;
if ( (v92 & 1) != 0 )
operator delete(v94);
if ( v46 < (char *)++v45 )
break;
}
}
}
}
v51 = (AchievementManager *)AchievementManager::sharedState((AchievementManager *)k);
v52 = *((_BYTE *)this + 808);
v53 = *((_BYTE *)v51 + 360);
*(_BYTE *)(AchievementManager::sharedState(v51) + 360) = 1;
*((_BYTE *)this + 808) = 1;
v54 = 6;
GameStatsManager::resetSpecialStatAchievements((GameStatsManager *)this);
GameStatsManager::setStat((GameStatsManager *)this, (char *)&word_1217DE8, (char *)(unsigned int)v3);
GameStatsManager::setStat((GameStatsManager *)this, "13", (char *)TotalCollectedDiamonds);
GameStatsManager::setStat((GameStatsManager *)this, "29", (char *)(unsigned int)v75);
GameStatsManager::setStat((GameStatsManager *)this, "21", (char *)(unsigned int)v11);
GameStatsManager::setStat((GameStatsManager *)this, "43", (char *)(unsigned int)v82);
GameStatsManager::setStat((GameStatsManager *)this, "18", (char *)v89);
GameStatsManager::setStat((GameStatsManager *)this, "19", (char *)v88);
GameStatsManager::setStat((GameStatsManager *)this, "17", (char *)v87);
GameStatsManager::setStat((GameStatsManager *)this, "16", (char *)v86);
GameStatsManager::setStat((GameStatsManager *)this, "20", (char *)v85);
GameStatsManager::setStat((GameStatsManager *)this, "23", (char *)HIDWORD(v84));
GameStatsManager::setStat((GameStatsManager *)this, "24", (char *)(unsigned int)v84);
GameStatsManager::setStat((GameStatsManager *)this, "25", (char *)v83);
GameStatsManager::setStat((GameStatsManager *)this, "26", (char *)v10);
isItemUnlocked = GameStatsManager::setStat((GameStatsManager *)this, "27", (char *)v8);
do
{
while ( 1 )
{
v56 = GameStatsManager::sharedState((GameStatsManager *)isItemUnlocked);
isItemUnlocked = (unsigned __int8)GameStatsManager::isItemUnlocked(v56, 0xCu, v54);
if ( (_BYTE)isItemUnlocked )
{
v57 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"geometry.ach.path%02d.00",
(const char *)(v54 - 5));
v58 = (const char *)cocos2d::CCString::getCString(v57);
v92 = 0;
v93 = 0;
v94 = nullptr;
v90 = (char *)v58;
v59 = strlen(v58);
v60 = (GameManager *)std::string::__init(&v92, v90, v59);
v61 = (GameManager *)GameManager::sharedState(v60);
v62 = (char *)&v92 + 1;
if ( (v92 & 1) != 0 )
v62 = (char *)v94;
GameManager::reportAchievementWithID(v61, v62, 100, 0);
isItemUnlocked = (unsigned __int8)v92;
if ( (v92 & 1) != 0 )
break;
}
if ( ++v54 == 16 )
goto LABEL_73;
}
++v54;
operator delete(v94);
}
while ( v54 != 16 );
LABEL_73:
v63 = 1;
v64 = 0;
do
{
v65 = (GameStatsManager *)GameStatsManager::sharedState((GameStatsManager *)isItemUnlocked);
v66 = v63++;
isItemUnlocked = GameStatsManager::isGauntletChestUnlocked(v65, v66);
if ( (_BYTE)isItemUnlocked )
++v64;
}
while ( v63 != 63 );
v67 = (GameStatsManager *)GameStatsManager::sharedState((GameStatsManager *)isItemUnlocked);
GameStatsManager::setStat(v67, "40", (char *)v64);
v68 = (GameStatsManager *)cocos2d::CCDictionary::count(*(this + 91));
v91 = (char *)(unsigned int)v68;
v69 = (GameStatsManager *)GameStatsManager::sharedState(v68);
v70 = (GameManager *)GameStatsManager::setStat(v69, "41", v91);
v71 = (GameManager *)GameManager::sharedState(v70);
v72 = (AchievementManager *)GameManager::checkUsedIcons(v71);
*(_BYTE *)(AchievementManager::sharedState(v72) + 360) = v53;
*((_BYTE *)this + 808) = v52;
return _stack_chk_guard;
}