//
// GameStatsManager::checkCoinAchievement from 0x1402e0880 to 0x1402e1470 (3056 bytes)
//
// 5 xrefs:
// > GameManager::dataLoaded @ 0x1402846fc
// > GameManager::dataLoaded @ 0x140284790
// > GameManager::dataLoaded @ 0x140284824
// > PlayLayer::levelComplete @ 0x140506e08
// > ??> @ 0x14091de10
//
// 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:48 +0000
//
// Hidden C++ exception states: #wind=8
void __fastcall GameStatsManager::checkCoinAchievement(__int64 a1, _DWORD *a2)
{
int v2; // r8d
int v3; // eax
__int64 v4; // rdx
__int64 v5; // rcx
__int64 v6; // r8
int v7; // r14d
__int64 v8; // rsi
__int64 v9; // rbx
cocos2d::CCString *v10; // rax
__int64 v11; // rcx
int v12; // ebx
__int64 v13; // r8
unsigned __int64 v14; // rdx
void *v15; // r8
__int64 v16; // rax
const char *v17; // rdx
int v18; // eax
__int64 v19; // rdx
__int64 v20; // rcx
__int64 v21; // r8
__int64 v22; // rsi
__int64 v23; // rbx
cocos2d::CCString *v24; // rax
__int64 v25; // rcx
int v26; // ebx
__int64 v27; // r8
unsigned __int64 v28; // rdx
void *v29; // r8
int v30; // eax
__int64 v31; // rdx
__int64 v32; // rcx
__int64 v33; // r8
__int64 v34; // rsi
__int64 v35; // rbx
cocos2d::CCString *v36; // rax
__int64 v37; // rcx
int v38; // ebx
__int64 v39; // r8
unsigned __int64 v40; // rdx
void *v41; // r8
int v42; // ebx
__int64 v43; // rsi
__int64 v44; // rdx
__int64 v45; // rcx
__int64 v46; // r8
__int64 v47; // rbx
cocos2d::CCString *v48; // rax
__int64 v49; // rcx
int v50; // ebx
__int64 v51; // r8
unsigned __int64 v52; // rdx
void *v53; // r8
int v54; // r8d
int v55; // r8d
int CollectedCoinsForLevel; // ebx
__int64 v57; // rsi
__int64 v58; // rdx
__int64 v59; // rcx
__int64 v60; // r8
__int64 v61; // rbx
cocos2d::CCString *v62; // rax
__int64 v63; // rcx
int v64; // ebx
__int64 v65; // r8
unsigned __int64 v66; // rdx
void *v67; // r8
int v68; // ebx
__int64 v69; // rsi
__int64 v70; // rdx
__int64 v71; // rcx
__int64 v72; // r8
__int64 v73; // rbx
cocos2d::CCString *v74; // rax
__int64 v75; // rcx
int v76; // ebx
__int64 v77; // r8
unsigned __int64 v78; // rdx
void *v79; // r8
int v80; // ebx
__int64 v81; // rsi
__int64 v82; // rdx
__int64 v83; // rcx
__int64 v84; // r8
__int64 v85; // rbx
cocos2d::CCString *v86; // rax
__int64 v87; // rcx
int v88; // ebx
__int64 v89; // r8
unsigned __int64 v90; // rdx
void *v91; // r8
void *v92; // [rsp+30h] [rbp-40h]
void *v93; // [rsp+30h] [rbp-40h]
void *v94; // [rsp+30h] [rbp-40h]
void *v95; // [rsp+30h] [rbp-40h]
void *v96; // [rsp+30h] [rbp-40h]
void *v97; // [rsp+30h] [rbp-40h]
void *v98; // [rsp+30h] [rbp-40h]
void *Block[2]; // [rsp+38h] [rbp-38h] BYREF
__int64 v100; // [rsp+48h] [rbp-28h]
unsigned __int64 v101; // [rsp+50h] [rbp-20h]
if ( a2[305] == 1 )
{
v2 = a2[82] - a2[83];
if ( v2 > 5001 )
{
v54 = v2 - 5002;
if ( v54 )
{
v55 = v54 - 1;
if ( v55 )
{
if ( v55 == 1 )
{
CollectedCoinsForLevel = GameStatsManager::getCollectedCoinsForLevel();
v57 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v96 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v96);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v57 = qword_14090BFD0;
}
v7 = (int)floorf((float)((float)CollectedCoinsForLevel / 3.0) * 100.0);
v61 = AchievementManager::sharedState(v59, v58, v60);
*(_OWORD *)Block = 0;
Block[0] = sub_14003D460(0x20u);
v100 = 24;
v101 = 31;
strcpy((char *)Block[0], "geometry.ach.tower04Coin");
v62 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(*(_QWORD *)(v61 + 352), Block);
v64 = cocos2d::CCString::intValue(v62);
v66 = v101;
if ( v101 > 0xF )
{
v67 = Block[0];
if ( v101 + 1 >= 0x1000 )
{
v67 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v67 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v67);
}
if ( v64 < 100 )
{
if ( v7 >= 100 )
{
*(_OWORD *)Block = 0;
v100 = 0;
v101 = 0;
Block[0] = sub_14003D460(0x20u);
v100 = 24;
v101 = 31;
strcpy((char *)Block[0], "geometry.ach.tower04Coin");
GameManager::completedAchievement(v57, (__int64)Block);
}
v16 = AchievementManager::sharedState(v63, v66, v65);
v17 = "geometry.ach.tower04Coin";
goto LABEL_87;
}
}
}
else
{
v68 = GameStatsManager::getCollectedCoinsForLevel();
v69 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v97 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v97);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v69 = qword_14090BFD0;
}
v7 = (int)floorf((float)((float)v68 / 3.0) * 100.0);
v73 = AchievementManager::sharedState(v71, v70, v72);
*(_OWORD *)Block = 0;
Block[0] = sub_14003D460(0x20u);
v100 = 24;
v101 = 31;
strcpy((char *)Block[0], "geometry.ach.tower03Coin");
v74 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(*(_QWORD *)(v73 + 352), Block);
v76 = cocos2d::CCString::intValue(v74);
v78 = v101;
if ( v101 > 0xF )
{
v79 = Block[0];
if ( v101 + 1 >= 0x1000 )
{
v79 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v79 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v79);
}
if ( v76 < 100 )
{
if ( v7 >= 100 )
{
*(_OWORD *)Block = 0;
v100 = 0;
v101 = 0;
Block[0] = sub_14003D460(0x20u);
v100 = 24;
v101 = 31;
strcpy((char *)Block[0], "geometry.ach.tower03Coin");
GameManager::completedAchievement(v69, (__int64)Block);
}
v16 = AchievementManager::sharedState(v75, v78, v77);
v17 = "geometry.ach.tower03Coin";
goto LABEL_87;
}
}
}
else
{
v80 = GameStatsManager::getCollectedCoinsForLevel();
v81 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v98 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v98);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v81 = qword_14090BFD0;
}
v7 = (int)floorf((float)((float)v80 / 3.0) * 100.0);
v85 = AchievementManager::sharedState(v83, v82, v84);
*(_OWORD *)Block = 0;
Block[0] = sub_14003D460(0x20u);
v100 = 24;
v101 = 31;
strcpy((char *)Block[0], "geometry.ach.tower02Coin");
v86 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(*(_QWORD *)(v85 + 352), Block);
v88 = cocos2d::CCString::intValue(v86);
v90 = v101;
if ( v101 > 0xF )
{
v91 = Block[0];
if ( v101 + 1 >= 0x1000 )
{
v91 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v91 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v91);
}
if ( v88 < 100 )
{
if ( v7 >= 100 )
{
*(_OWORD *)Block = 0;
v100 = 0;
v101 = 0;
Block[0] = sub_14003D460(0x20u);
v100 = 24;
v101 = 31;
strcpy((char *)Block[0], "geometry.ach.tower02Coin");
GameManager::completedAchievement(v81, (__int64)Block);
}
v16 = AchievementManager::sharedState(v87, v90, v89);
v17 = "geometry.ach.tower02Coin";
goto LABEL_87;
}
}
}
else
{
switch ( v2 )
{
case 5001:
v42 = GameStatsManager::getCollectedCoinsForLevel();
v43 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v95 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v95);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v43 = qword_14090BFD0;
}
v7 = (int)floorf((float)((float)v42 / 3.0) * 100.0);
v47 = AchievementManager::sharedState(v45, v44, v46);
*(_OWORD *)Block = 0;
Block[0] = sub_14003D460(0x20u);
v100 = 24;
v101 = 31;
strcpy((char *)Block[0], "geometry.ach.tower01Coin");
v48 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(*(_QWORD *)(v47 + 352), Block);
v50 = cocos2d::CCString::intValue(v48);
v52 = v101;
if ( v101 > 0xF )
{
v53 = Block[0];
if ( v101 + 1 >= 0x1000 )
{
v53 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v53 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v53);
}
if ( v50 < 100 )
{
if ( v7 >= 100 )
{
*(_OWORD *)Block = 0;
v100 = 0;
v101 = 0;
Block[0] = sub_14003D460(0x20u);
v100 = 24;
v101 = 31;
strcpy((char *)Block[0], "geometry.ach.tower01Coin");
GameManager::completedAchievement(v43, (__int64)Block);
}
v16 = AchievementManager::sharedState(v49, v52, v51);
v17 = "geometry.ach.tower01Coin";
goto LABEL_87;
}
break;
case 14:
v30 = GameStatsManager::getCollectedCoinsForLevel();
v7 = (int)fminf(100.0, floorf((float)((float)v30 / 3.0) * 100.0));
v34 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v94 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v94);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v34 = qword_14090BFD0;
}
v35 = AchievementManager::sharedState(v32, v31, v33);
*(_OWORD *)Block = 0;
Block[0] = sub_14003D460(0x20u);
v100 = 24;
v101 = 31;
strcpy((char *)Block[0], "geometry.ach.demoncoin01");
v36 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(*(_QWORD *)(v35 + 352), Block);
v38 = cocos2d::CCString::intValue(v36);
v40 = v101;
if ( v101 > 0xF )
{
v41 = Block[0];
if ( v101 + 1 >= 0x1000 )
{
v41 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v41 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v41);
}
if ( v38 < 100 )
{
if ( v7 >= 100 )
{
*(_OWORD *)Block = 0;
v100 = 0;
v101 = 0;
Block[0] = sub_14003D460(0x20u);
v100 = 24;
v101 = 31;
strcpy((char *)Block[0], "geometry.ach.demoncoin01");
GameManager::completedAchievement(v34, (__int64)Block);
}
v16 = AchievementManager::sharedState(v37, v40, v39);
v17 = "geometry.ach.demoncoin01";
goto LABEL_87;
}
break;
case 18:
v18 = GameStatsManager::getCollectedCoinsForLevel();
v7 = (int)fminf(100.0, floorf((float)((float)v18 / 3.0) * 100.0));
v22 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v93 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v93);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v22 = qword_14090BFD0;
}
v23 = AchievementManager::sharedState(v20, v19, v21);
*(_OWORD *)Block = 0;
Block[0] = sub_14003D460(0x20u);
v100 = 24;
v101 = 31;
strcpy((char *)Block[0], "geometry.ach.demoncoin02");
v24 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(*(_QWORD *)(v23 + 352), Block);
v26 = cocos2d::CCString::intValue(v24);
v28 = v101;
if ( v101 > 0xF )
{
v29 = Block[0];
if ( v101 + 1 >= 0x1000 )
{
v29 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v29 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v29);
}
if ( v26 < 100 )
{
if ( v7 >= 100 )
{
*(_OWORD *)Block = 0;
v100 = 0;
v101 = 0;
Block[0] = sub_14003D460(0x20u);
v100 = 24;
v101 = 31;
strcpy((char *)Block[0], "geometry.ach.demoncoin02");
GameManager::completedAchievement(v22, (__int64)Block);
}
v16 = AchievementManager::sharedState(v25, v28, v27);
v17 = "geometry.ach.demoncoin02";
goto LABEL_87;
}
break;
case 20:
v3 = GameStatsManager::getCollectedCoinsForLevel();
v7 = (int)fminf(100.0, floorf((float)((float)v3 / 3.0) * 100.0));
v8 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v92 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v92);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v8 = qword_14090BFD0;
}
v9 = AchievementManager::sharedState(v5, v4, v6);
*(_OWORD *)Block = 0;
Block[0] = sub_14003D460(0x20u);
v100 = 24;
v101 = 31;
strcpy((char *)Block[0], "geometry.ach.demoncoin03");
v10 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(*(_QWORD *)(v9 + 352), Block);
v12 = cocos2d::CCString::intValue(v10);
v14 = v101;
if ( v101 > 0xF )
{
v15 = Block[0];
if ( v101 + 1 >= 0x1000 )
{
v15 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v15 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v15);
}
if ( v12 < 100 )
{
if ( v7 >= 100 )
{
*(_OWORD *)Block = 0;
v100 = 0;
v101 = 0;
Block[0] = sub_14003D460(0x20u);
v100 = 24;
v101 = 31;
strcpy((char *)Block[0], "geometry.ach.demoncoin03");
GameManager::completedAchievement(v8, (__int64)Block);
}
v16 = AchievementManager::sharedState(v11, v14, v13);
v17 = "geometry.ach.demoncoin03";
LABEL_87:
AchievementManager::reportAchievementWithID(v16, (__int64)v17, v7);
}
break;
}
}
}
}