//
// GameStatsManager::recountUserCoins from 0x1402e2d10 to 0x1402e354b (2107 bytes)
//
// 3 xrefs:
// > GameStatsManager::verifyUserCoins @ 0x1402e3588
// > GameStatsManager::verifyUserCoins @ 0x1402e3603
// > ??> @ 0x14091dedc
//
// This function is hookable on this platform (idp: pc, 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 11:29:49 +0000
//
// Hidden C++ exception states: #wind=14
int __fastcall GameStatsManager::recountUserCoins(__int64 a1, char a2)
{
int Stat; // ebx
__int64 v5; // rax
signed int v6; // esi
int i; // ebx
cocos2d::CCString *v8; // rax
const char *CString; // rax
size_t v10; // r8
__int64 v11; // rcx
__int64 v12; // rcx
__int64 v13; // rcx
__int64 v14; // rcx
__int64 v15; // rcx
__int64 v16; // rcx
__int64 v17; // rcx
__int64 v18; // rcx
__int64 v19; // rcx
__int64 v20; // rcx
__int64 v21; // rcx
__int64 v22; // rcx
__int64 v23; // rcx
__int64 v24; // rdx
__int64 v25; // rcx
__int64 v26; // r8
char v27; // bl
__int64 v28; // rdx
__int64 v29; // rcx
__int64 v30; // r8
__int64 v31; // rdx
__int64 v32; // rcx
__int64 v33; // r8
__int128 v35; // [rsp+20h] [rbp-60h] BYREF
__int64 v36; // [rsp+30h] [rbp-50h]
__int64 v37; // [rsp+38h] [rbp-48h]
__int128 v38; // [rsp+40h] [rbp-40h] BYREF
__int64 v39; // [rsp+50h] [rbp-30h]
__int64 v40; // [rsp+58h] [rbp-28h]
__int128 v41; // [rsp+60h] [rbp-20h] BYREF
__int64 v42; // [rsp+70h] [rbp-10h]
__int64 v43; // [rsp+78h] [rbp-8h]
void *v44; // [rsp+A0h] [rbp+20h]
void *v45; // [rsp+B0h] [rbp+30h]
void *v46; // [rsp+B0h] [rbp+30h]
void *v47; // [rsp+B0h] [rbp+30h]
void *v48; // [rsp+B0h] [rbp+30h]
void *v49; // [rsp+B0h] [rbp+30h]
void *v50; // [rsp+B0h] [rbp+30h]
void *v51; // [rsp+B0h] [rbp+30h]
void *v52; // [rsp+B0h] [rbp+30h]
void *v53; // [rsp+B0h] [rbp+30h]
void *v54; // [rsp+B0h] [rbp+30h]
void *v55; // [rsp+B0h] [rbp+30h]
void *v56; // [rsp+B0h] [rbp+30h]
Stat = GameStatsManager::getStat(a1, "12");
LODWORD(v5) = cocos2d::CCDictionary::count(*(cocos2d::CCDictionary **)(a1 + 720));
v6 = v5;
if ( Stat > (int)v5 || a2 )
{
for ( i = 1; i <= 21; ++i )
{
v8 = cocos2d::CCString::createWithFormat("geometry.ach.usercoins%02d", i);
CString = cocos2d::CCString::getCString(v8);
v41 = 0;
v42 = 0;
v43 = 0;
v10 = -1;
do
++v10;
while ( CString[v10] );
sub_14003D230(&v41, CString, v10);
v11 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v45 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v45);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v11 = qword_14090BFD0;
}
GameManager::resetAchievement(v11, (__int64 *)&v41);
}
if ( v6 < 10 )
{
v35 = 0;
*(_QWORD *)&v35 = sub_14003D460(0x20u);
v36 = 21;
v37 = 31;
strcpy((char *)v35, "geometry.ach.secret05");
v12 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v46 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v46);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v12 = qword_14090BFD0;
}
GameManager::resetAchievement(v12, (__int64 *)&v35);
v38 = 0;
v39 = 0;
v40 = 0;
*(_QWORD *)&v38 = sub_14003D460(0x20u);
v39 = 21;
v40 = 31;
strcpy((char *)v38, "geometry.ach.secret06");
v13 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v47 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v47);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v13 = qword_14090BFD0;
}
GameManager::resetAchievement(v13, (__int64 *)&v38);
v35 = 0;
v36 = 0;
v37 = 0;
*(_QWORD *)&v35 = sub_14003D460(0x20u);
v36 = 21;
v37 = 31;
strcpy((char *)v35, "geometry.ach.secret07");
v14 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v48 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v48);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v14 = qword_14090BFD0;
}
GameManager::resetAchievement(v14, (__int64 *)&v35);
v38 = 0;
v39 = 0;
v40 = 0;
*(_QWORD *)&v38 = sub_14003D460(0x20u);
v39 = 21;
v40 = 31;
strcpy((char *)v38, "geometry.ach.secret08");
v15 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v49 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v49);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v15 = qword_14090BFD0;
}
GameManager::resetAchievement(v15, (__int64 *)&v38);
v35 = 0;
v36 = 0;
v37 = 0;
*(_QWORD *)&v35 = sub_14003D460(0x20u);
v36 = 21;
v37 = 31;
strcpy((char *)v35, "geometry.ach.secret09");
v16 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v50 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v50);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v16 = qword_14090BFD0;
}
GameManager::resetAchievement(v16, (__int64 *)&v35);
v38 = 0;
v39 = 0;
v40 = 0;
*(_QWORD *)&v38 = sub_14003D460(0x20u);
v39 = 21;
v40 = 31;
strcpy((char *)v38, "geometry.ach.secret10");
v17 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v51 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v51);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v17 = qword_14090BFD0;
}
GameManager::resetAchievement(v17, (__int64 *)&v38);
v35 = 0;
v36 = 0;
v37 = 0;
*(_QWORD *)&v35 = sub_14003D460(0x20u);
v36 = 21;
v37 = 31;
strcpy((char *)v35, "geometry.ach.secret13");
v18 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v52 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v52);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v18 = qword_14090BFD0;
}
GameManager::resetAchievement(v18, (__int64 *)&v35);
v38 = 0;
v39 = 0;
v40 = 0;
*(_QWORD *)&v38 = sub_14003D460(0x20u);
v39 = 21;
v40 = 31;
strcpy((char *)v38, "geometry.ach.secret14");
v19 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v53 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v53);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v19 = qword_14090BFD0;
}
GameManager::resetAchievement(v19, (__int64 *)&v38);
v35 = 0;
v36 = 0;
v37 = 0;
*(_QWORD *)&v35 = sub_14003D460(0x20u);
v36 = 21;
v37 = 31;
strcpy((char *)v35, "geometry.ach.secret15");
v20 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v54 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v54);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v20 = qword_14090BFD0;
}
GameManager::resetAchievement(v20, (__int64 *)&v35);
v38 = 0;
v39 = 0;
v40 = 0;
*(_QWORD *)&v38 = sub_14003D460(0x20u);
v39 = 21;
v40 = 31;
strcpy((char *)v38, "geometry.ach.secret16");
v21 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v55 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v55);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v21 = qword_14090BFD0;
}
GameManager::resetAchievement(v21, (__int64 *)&v38);
v35 = 0;
v36 = 0;
v37 = 0;
*(_QWORD *)&v35 = sub_14003D460(0x20u);
v36 = 21;
v37 = 31;
strcpy((char *)v35, "geometry.ach.secret17");
v22 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v56 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v56);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v22 = qword_14090BFD0;
}
GameManager::resetAchievement(v22, (__int64 *)&v35);
}
v23 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v44 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v44);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v23 = qword_14090BFD0;
}
GameManager::checkUsedIcons(v23);
v27 = *(_BYTE *)(AchievementManager::sharedState(v25, v24, v26) + 360);
*(_BYTE *)(AchievementManager::sharedState(v29, v28, v30) + 360) = 1;
GameStatsManager::setStat(a1, "12", v6);
v5 = AchievementManager::sharedState(v32, v31, v33);
*(_BYTE *)(v5 + 360) = v27;
}
return v5;
}