//
// GJBaseGameLayer::processItems from 0x140216290 to 0x1402166fa (1130 bytes)
//
// 2 xrefs:
// > PlayLayer::levelComplete @ 0x1403a858d
// > ??> @ 0x1406cd128
//
// 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=9
void GJBaseGameLayer::processItems(GJBaseGameLayer *a1)
{
cocos2d::CCArray *v2; // r15
unsigned int v3; // esi
cocos2d::CCString *v4; // rax
const char *CString; // rax
size_t v6; // r8
int *v7; // rbx
void *v8; // rcx
int v9; // eax
const char *CoinKey; // rbx
GameStatsManager *v11; // rcx
GameStatsManager *v12; // rcx
GameStatsManager *v13; // rcx
const char *v14; // rdx
__int64 v15; // rdi
size_t v16; // r8
void *v17; // rcx
const char *v18; // rbx
GameStatsManager *v19; // rcx
GameStatsManager *v20; // rcx
void *v21; // [rsp+20h] [rbp-39h]
void *v22; // [rsp+28h] [rbp-31h]
void *v23; // [rsp+30h] [rbp-29h]
void *v24; // [rsp+38h] [rbp-21h]
void *v25; // [rsp+40h] [rbp-19h]
void *v26; // [rsp+48h] [rbp-11h]
void *v27; // [rsp+50h] [rbp-9h]
void *v28; // [rsp+58h] [rbp-1h]
__int128 v29; // [rsp+60h] [rbp+7h] BYREF
__int64 v30; // [rsp+70h] [rbp+17h]
unsigned __int64 v31; // [rsp+78h] [rbp+1Fh]
v2 = cocos2d::CCDictionary::allKeys(a1->m_collectedItems);
v3 = 0;
if ( cocos2d::CCArray::count(v2) )
{
while ( 1 )
{
v4 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v2, v3);
CString = cocos2d::CCString::getCString(v4);
v29 = 0;
v30 = 0;
v31 = 0;
v6 = -1;
do
++v6;
while ( CString[v6] );
sub_14003A930(&v29, CString, v6);
v7 = (int *)cocos2d::CCDictionary::objectForKey(a1->m_collectedItems, &v29);
if ( v31 > 0xF )
{
v8 = (void *)v29;
if ( v31 + 1 >= 0x1000 )
{
v8 = *(void **)(v29 - 8);
if ( (unsigned __int64)(v29 - (_QWORD)v8 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v8);
}
v30 = 0;
v31 = 15;
LOBYTE(v29) = 0;
v9 = (*(__int64 (__fastcall **)(int *))(*(_QWORD *)v7 + 1632LL))(v7);
if ( v9 == 22 )
break;
if ( v9 == 31 )
{
CoinKey = GJGameLevel::getCoinKey(a1->m_level, v7[452]);
v11 = (GameStatsManager *)qword_1406C2EE8;
if ( a1->m_level->m_coinsVerified.random == a1->m_level->m_coinsVerified.seed )
{
if ( !qword_1406C2EE8 )
{
v24 = operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0((__int64)v24);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v11 = (GameStatsManager *)qword_1406C2EE8;
}
if ( !GameStatsManager::hasPendingUserCoin(v11, CoinKey) )
{
v15 = qword_1406C2EE8;
if ( !qword_1406C2EE8 )
{
v25 = operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0((__int64)v25);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v15 = qword_1406C2EE8;
}
v29 = 0;
v30 = 0;
v31 = 0;
v16 = -1;
do
++v16;
while ( CoinKey[v16] );
sub_14003A930(&v29, CoinKey, v16);
cocos2d::CCDictionary::setObject(*(_QWORD *)(v15 + 728), *(_QWORD *)(v15 + 328), &v29);
if ( v31 > 0xF )
{
v17 = (void *)v29;
if ( v31 + 1 >= 0x1000 )
{
v17 = *(void **)(v29 - 8);
if ( (unsigned __int64)(v29 - (_QWORD)v17 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v17);
}
}
goto LABEL_39;
}
if ( !qword_1406C2EE8 )
{
v21 = operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0((__int64)v21);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v11 = (GameStatsManager *)qword_1406C2EE8;
}
if ( !GameStatsManager::hasUserCoin(v11, CoinKey) )
{
v12 = (GameStatsManager *)qword_1406C2EE8;
if ( !qword_1406C2EE8 )
{
v22 = operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0((__int64)v22);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v12 = (GameStatsManager *)qword_1406C2EE8;
}
GameStatsManager::storeUserCoin(v12, CoinKey);
v13 = (GameStatsManager *)qword_1406C2EE8;
if ( !qword_1406C2EE8 )
{
v23 = operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0((__int64)v23);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v13 = (GameStatsManager *)qword_1406C2EE8;
}
v14 = "12";
LABEL_38:
GameStatsManager::incrementStat(v13, v14, 1);
}
}
LABEL_39:
if ( ++v3 >= cocos2d::CCArray::count(v2) )
return;
}
v18 = GJGameLevel::getCoinKey(a1->m_level, v7[452]);
v19 = (GameStatsManager *)qword_1406C2EE8;
if ( !qword_1406C2EE8 )
{
v26 = operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0((__int64)v26);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v19 = (GameStatsManager *)qword_1406C2EE8;
}
if ( GameStatsManager::hasSecretCoin(v19, v18) )
goto LABEL_39;
v20 = (GameStatsManager *)qword_1406C2EE8;
if ( !qword_1406C2EE8 )
{
v27 = operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0((__int64)v27);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v20 = (GameStatsManager *)qword_1406C2EE8;
}
GameStatsManager::storeSecretCoin(v20, v18);
v13 = (GameStatsManager *)qword_1406C2EE8;
if ( !qword_1406C2EE8 )
{
v28 = operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0((__int64)v28);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v13 = (GameStatsManager *)qword_1406C2EE8;
}
v14 = "8";
goto LABEL_38;
}
}