//
// GameStatsManager::getTotalCollectedCurrency from 0x1401e3880 to 0x1401e4141 (2241 bytes)
//
// 2 xrefs:
// > GameStatsManager::recountSpecialStats @ 0x1401e44af
// > ??> @ 0x1406cc5c4
//
// 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
//
// Hidden C++ exception states: #wind=8
int GameStatsManager::getTotalCollectedCurrency(GameStatsManager *a1)
{
float v2; // xmm6_4
int v3; // edi
int i; // ebx
GameLevelManager *v5; // rcx
GJGameLevel *MainLevel; // rax
cocos2d::CCString *v7; // rax
const char *CString; // rax
size_t v9; // r8
__int128 *v10; // rdx
size_t v11; // r8
int j; // ebx
GameLevelManager *v13; // rcx
GJGameLevel *v14; // rax
cocos2d::CCString *v15; // rax
const char *v16; // rax
size_t v17; // r8
__int128 *v18; // rdx
size_t v19; // r8
void *v20; // rcx
GameLevelManager *v21; // rcx
GJGameLevel *v22; // rax
cocos2d::CCString *v23; // rax
const char *v24; // rax
size_t v25; // r8
__int128 *v26; // rdx
size_t v27; // r8
void *v28; // rcx
cocos2d::CCArray *v29; // rsi
unsigned int k; // ebx
cocos2d::CCString *v31; // rax
int v32; // edi
GameLevelManager *v33; // rcx
GJGameLevel *SavedLevel; // rax
cocos2d::CCString *v35; // rax
const char *v36; // rax
size_t v37; // r8
__int128 *v38; // rdx
size_t v39; // r8
cocos2d::CCArray *v40; // rsi
unsigned int m; // ebx
cocos2d::CCString *v42; // rax
int v43; // edi
GameLevelManager *v44; // rcx
GJGameLevel *SavedGauntletLevel; // rax
cocos2d::CCString *v46; // rax
const char *v47; // rax
size_t v48; // r8
__int128 *v49; // rdx
size_t v50; // r8
cocos2d::CCArray *v51; // rsi
unsigned int n; // edi
cocos2d::CCString *v53; // rax
int v54; // ebx
GameLevelManager *v55; // rcx
GJGameLevel *SavedDailyLevel; // rax
cocos2d::CCString *v57; // rax
const char *v58; // rax
size_t v59; // r8
__int128 *v60; // rdx
size_t v61; // r8
__int128 *v62; // rdx
size_t v63; // r8
void *v65; // [rsp+20h] [rbp-60h]
void *v66; // [rsp+20h] [rbp-60h]
void *v67; // [rsp+20h] [rbp-60h]
void *v68; // [rsp+20h] [rbp-60h]
void *v69; // [rsp+20h] [rbp-60h]
void *v70; // [rsp+20h] [rbp-60h]
__int128 v71; // [rsp+28h] [rbp-58h] BYREF
__int64 v72; // [rsp+38h] [rbp-48h]
unsigned __int64 v73; // [rsp+40h] [rbp-40h]
__int128 v74; // [rsp+48h] [rbp-38h] BYREF
__int64 v75; // [rsp+58h] [rbp-28h]
unsigned __int64 v76; // [rsp+60h] [rbp-20h]
v2 = 0.0;
v3 = 1;
for ( i = 1; i <= 22; ++i )
{
v5 = (GameLevelManager *)qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v65 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v65);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v5 = (GameLevelManager *)qword_1406C2EC0;
}
MainLevel = GameLevelManager::getMainLevel(v5, i, 1);
if ( MainLevel )
{
v2 = v2 + (float)GameStatsManager::getAwardedCurrencyForLevel(a1, MainLevel);
}
else
{
v7 = cocos2d::CCString::createWithFormat("%i", MEMORY[0x148] - MEMORY[0x14C]);
CString = cocos2d::CCString::getCString(v7);
v71 = 0;
v72 = 0;
v73 = 0;
v9 = -1;
do
++v9;
while ( CString[v9] );
sub_14003A930(&v71, CString, v9);
v10 = &v71;
if ( v73 > 0xF )
v10 = (__int128 *)v71;
v74 = 0;
v75 = 0;
v76 = 0;
v11 = -1;
do
++v11;
while ( *((_BYTE *)v10 + v11) );
sub_14003A930(&v74, v10, v11);
cocos2d::CCDictionary::removeObjectForKey(a1->m_mainCurrencyScores, &v74);
sub_14003A830((__int64)&v74);
sub_14003A830((__int64)&v71);
}
}
for ( j = 1; j <= 4; ++j )
{
v13 = (GameLevelManager *)qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v66 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v66);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v13 = (GameLevelManager *)qword_1406C2EC0;
}
v14 = GameLevelManager::getMainLevel(v13, j + 5000, 1);
if ( v14 )
{
v2 = v2 + (float)GameStatsManager::getAwardedCurrencyForLevel(a1, v14);
}
else
{
v15 = cocos2d::CCString::createWithFormat("%i", MEMORY[0x148] - MEMORY[0x14C]);
v16 = cocos2d::CCString::getCString(v15);
v71 = 0;
v72 = 0;
v73 = 0;
v17 = -1;
do
++v17;
while ( v16[v17] );
sub_14003A930(&v71, v16, v17);
v18 = &v71;
if ( v73 > 0xF )
v18 = (__int128 *)v71;
v74 = 0;
v75 = 0;
v76 = 0;
v19 = -1;
do
++v19;
while ( *((_BYTE *)v18 + v19) );
sub_14003A930(&v74, v18, v19);
cocos2d::CCDictionary::removeObjectForKey(a1->m_mainCurrencyScores, &v74);
if ( v76 > 0xF )
{
v20 = (void *)v74;
if ( v76 + 1 >= 0x1000 )
{
v20 = *(void **)(v74 - 8);
if ( (unsigned __int64)(v74 - (_QWORD)v20 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v20);
}
sub_14003A830((__int64)&v71);
}
}
do
{
v21 = (GameLevelManager *)qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v67 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v67);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v21 = (GameLevelManager *)qword_1406C2EC0;
}
v22 = GameLevelManager::getMainLevel(v21, v3 + 2000, 1);
if ( v22 )
{
v2 = v2 + (float)GameStatsManager::getAwardedCurrencyForLevel(a1, v22);
}
else
{
v23 = cocos2d::CCString::createWithFormat("%i", MEMORY[0x148] - MEMORY[0x14C]);
v24 = cocos2d::CCString::getCString(v23);
v71 = 0;
v72 = 0;
v73 = 0;
v25 = -1;
do
++v25;
while ( v24[v25] );
sub_14003A930(&v71, v24, v25);
v26 = &v71;
if ( v73 > 0xF )
v26 = (__int128 *)v71;
v74 = 0;
v75 = 0;
v76 = 0;
v27 = -1;
do
++v27;
while ( *((_BYTE *)v26 + v27) );
sub_14003A930(&v74, v26, v27);
cocos2d::CCDictionary::removeObjectForKey(a1->m_mainCurrencyScores, &v74);
if ( v76 > 0xF )
{
v28 = (void *)v74;
if ( v76 + 1 >= 0x1000 )
{
v28 = *(void **)(v74 - 8);
if ( (unsigned __int64)(v74 - (_QWORD)v28 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v28);
}
sub_14003A830((__int64)&v71);
}
++v3;
}
while ( v3 <= 10 );
v29 = cocos2d::CCDictionary::allKeys(a1->m_onlineCurrencyScores);
for ( k = 0; k < cocos2d::CCArray::count(v29); ++k )
{
v31 = cocos2d::CCArray::stringAtIndex(v29, k);
v32 = cocos2d::CCString::intValue(v31);
v33 = (GameLevelManager *)qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v68 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v68);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v33 = (GameLevelManager *)qword_1406C2EC0;
}
SavedLevel = GameLevelManager::getSavedLevel(v33, v32);
if ( SavedLevel )
{
v2 = v2 + (float)GameStatsManager::getAwardedCurrencyForLevel(a1, SavedLevel);
}
else
{
v35 = cocos2d::CCString::createWithFormat("%i", v32);
v36 = cocos2d::CCString::getCString(v35);
v71 = 0;
v72 = 0;
v73 = 0;
v37 = -1;
do
++v37;
while ( v36[v37] );
sub_14003A930(&v71, v36, v37);
v38 = &v71;
if ( v73 > 0xF )
v38 = (__int128 *)v71;
v74 = 0;
v75 = 0;
v76 = 0;
v39 = -1;
do
++v39;
while ( *((_BYTE *)v38 + v39) );
sub_14003A930(&v74, v38, v39);
cocos2d::CCDictionary::removeObjectForKey(a1->m_onlineCurrencyScores, &v74);
sub_14003A830((__int64)&v74);
sub_14003A830((__int64)&v71);
}
}
v40 = cocos2d::CCDictionary::allKeys(a1->m_gauntletCurrencyScores);
for ( m = 0; m < cocos2d::CCArray::count(v40); ++m )
{
v42 = cocos2d::CCArray::stringAtIndex(v40, m);
v43 = cocos2d::CCString::intValue(v42);
v44 = (GameLevelManager *)qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v69 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v69);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v44 = (GameLevelManager *)qword_1406C2EC0;
}
SavedGauntletLevel = GameLevelManager::getSavedGauntletLevel(v44, v43);
if ( SavedGauntletLevel )
{
v2 = v2 + (float)GameStatsManager::getAwardedCurrencyForLevel(a1, SavedGauntletLevel);
}
else
{
v46 = cocos2d::CCString::createWithFormat("%i", v43);
v47 = cocos2d::CCString::getCString(v46);
v71 = 0;
v72 = 0;
v73 = 0;
v48 = -1;
do
++v48;
while ( v47[v48] );
sub_14003A930(&v71, v47, v48);
v49 = &v71;
if ( v73 > 0xF )
v49 = (__int128 *)v71;
v74 = 0;
v75 = 0;
v76 = 0;
v50 = -1;
do
++v50;
while ( *((_BYTE *)v49 + v50) );
sub_14003A930(&v74, v49, v50);
cocos2d::CCDictionary::removeObjectForKey(a1->m_gauntletCurrencyScores, &v74);
sub_14003A830((__int64)&v74);
sub_14003A830((__int64)&v71);
}
}
v51 = cocos2d::CCDictionary::allKeys(a1->m_timelyCurrencyScores);
for ( n = 0; n < cocos2d::CCArray::count(v51); ++n )
{
v53 = cocos2d::CCArray::stringAtIndex(v51, n);
v54 = cocos2d::CCString::intValue(v53);
v55 = (GameLevelManager *)qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v70 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v70);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v55 = (GameLevelManager *)qword_1406C2EC0;
}
SavedDailyLevel = GameLevelManager::getSavedDailyLevel(v55, v54);
if ( SavedDailyLevel )
{
v2 = v2 + (float)GameStatsManager::getAwardedCurrencyForLevel(a1, SavedDailyLevel);
}
else
{
v57 = cocos2d::CCString::createWithFormat("%i", v54);
v58 = cocos2d::CCString::getCString(v57);
v71 = 0;
v72 = 0;
v73 = 0;
v59 = -1;
do
++v59;
while ( v58[v59] );
sub_14003A930(&v71, v58, v59);
v60 = &v71;
if ( v73 > 0xF )
v60 = (__int128 *)v71;
v74 = 0;
v75 = 0;
v76 = 0;
v61 = -1;
do
++v61;
while ( *((_BYTE *)v60 + v61) );
sub_14003A930(&v74, v60, v61);
cocos2d::CCDictionary::removeObjectForKey(a1->m_timelyCurrencyScores, &v74);
sub_14003A830((__int64)&v74);
v62 = &v71;
if ( v73 > 0xF )
v62 = (__int128 *)v71;
v74 = 0;
v75 = 0;
v76 = 0;
v63 = -1;
do
++v63;
while ( *((_BYTE *)v62 + v63) );
sub_14003A930(&v74, v62, v63);
cocos2d::CCDictionary::removeObjectForKey(a1->m_timelyStars, &v74);
sub_14003A830((__int64)&v74);
sub_14003A830((__int64)&v71);
}
}
return (int)v2;
}