//
// GJBaseGameLayer::processItems from 0x14031d760 to 0x14031dc13 (1203 bytes)
//
// 2 xrefs:
// > PlayLayer::levelComplete @ 0x140506d74
// > ??> @ 0x14091ec74
//
// 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:30:21 +0000
//
// Hidden C++ exception states: #wind=9
unsigned int __fastcall GJBaseGameLayer::processItems(__int64 a1)
{
cocos2d::CCArray *v2; // r15
unsigned int v3; // esi
unsigned int result; // eax
cocos2d::CCString *v5; // rax
const char *CString; // rax
size_t v7; // r8
unsigned int *v8; // rbx
void *v9; // rcx
int v10; // eax
char *CoinKey; // rbx
__int64 v12; // rcx
__int64 v13; // rcx
__int64 v14; // rcx
const char *v15; // rdx
__int64 v16; // rdi
size_t v17; // r8
void *v18; // rcx
const char *v19; // rbx
__int64 v20; // rcx
__int64 v21; // rcx
void *v22; // [rsp+30h] [rbp-39h]
void *v23; // [rsp+38h] [rbp-31h]
void *v24; // [rsp+40h] [rbp-29h]
void *v25; // [rsp+48h] [rbp-21h]
void *v26; // [rsp+50h] [rbp-19h]
void *v27; // [rsp+58h] [rbp-11h]
void *v28; // [rsp+60h] [rbp-9h]
void *v29; // [rsp+68h] [rbp-1h]
__int128 v30; // [rsp+70h] [rbp+7h] BYREF
__int64 v31; // [rsp+80h] [rbp+17h]
unsigned __int64 v32; // [rsp+88h] [rbp+1Fh]
v2 = cocos2d::CCDictionary::allKeys(*(cocos2d::CCDictionary **)(a1 + 13064));
v3 = 0;
result = cocos2d::CCArray::count(v2);
if ( result )
{
while ( 1 )
{
v5 = cocos2d::CCArray::objectAtIndex(v2, v3);
CString = cocos2d::CCString::getCString(v5);
v30 = 0;
v31 = 0;
v32 = 0;
v7 = -1;
do
++v7;
while ( CString[v7] );
sub_14003D230(&v30, CString, v7);
v8 = (unsigned int *)cocos2d::CCDictionary::objectForKey(*(_QWORD *)(a1 + 13064), &v30);
if ( v32 > 0xF )
{
v9 = (void *)v30;
if ( v32 + 1 >= 0x1000 )
{
v9 = *(void **)(v30 - 8);
if ( (unsigned __int64)(v30 - (_QWORD)v9 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v9);
}
v31 = 0;
v32 = 15;
LOBYTE(v30) = 0;
v10 = (*(__int64 (__fastcall **)(unsigned int *))(*(_QWORD *)v8 + 1648LL))(v8);
if ( v10 == 22 )
break;
if ( v10 == 31 )
{
CoinKey = (char *)GJGameLevel::getCoinKey(
*(_QWORD *)(a1 + 2168),
v8[452],
*(_DWORD *)(*(_QWORD *)(a1 + 2168) + 992LL) - *(_DWORD *)(*(_QWORD *)(a1 + 2168) + 996LL));
v12 = qword_14090BFE0;
if ( *(_DWORD *)(*(_QWORD *)(a1 + 2168) + 1040LL) == *(_DWORD *)(*(_QWORD *)(a1 + 2168) + 1044LL) )
{
if ( !qword_14090BFE0 )
{
v25 = operator new(0x3E8u);
qword_14090BFE0 = sub_1402D6480((__int64)v25);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFE0 + 72LL))(qword_14090BFE0);
v12 = qword_14090BFE0;
}
if ( !GameStatsManager::hasPendingUserCoin(v12, CoinKey) )
{
v16 = qword_14090BFE0;
if ( !qword_14090BFE0 )
{
v26 = operator new(0x3E8u);
qword_14090BFE0 = sub_1402D6480((__int64)v26);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFE0 + 72LL))(qword_14090BFE0);
v16 = qword_14090BFE0;
}
v30 = 0;
v31 = 0;
v32 = 0;
v17 = -1;
do
++v17;
while ( CoinKey[v17] );
sub_14003D230(&v30, CoinKey, v17);
cocos2d::CCDictionary::setObject(*(_QWORD *)(v16 + 728), *(_QWORD *)(v16 + 328), &v30);
if ( v32 > 0xF )
{
v18 = (void *)v30;
if ( v32 + 1 >= 0x1000 )
{
v18 = *(void **)(v30 - 8);
if ( (unsigned __int64)(v30 - (_QWORD)v18 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v18);
}
}
goto LABEL_39;
}
if ( !qword_14090BFE0 )
{
v22 = operator new(0x3E8u);
qword_14090BFE0 = sub_1402D6480((__int64)v22);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFE0 + 72LL))(qword_14090BFE0);
v12 = qword_14090BFE0;
}
if ( !GameStatsManager::hasUserCoin(v12, CoinKey) )
{
v13 = qword_14090BFE0;
if ( !qword_14090BFE0 )
{
v23 = operator new(0x3E8u);
qword_14090BFE0 = sub_1402D6480((__int64)v23);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFE0 + 72LL))(qword_14090BFE0);
v13 = qword_14090BFE0;
}
GameStatsManager::storeUserCoin(v13, CoinKey);
v14 = qword_14090BFE0;
if ( !qword_14090BFE0 )
{
v24 = operator new(0x3E8u);
qword_14090BFE0 = sub_1402D6480((__int64)v24);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFE0 + 72LL))(qword_14090BFE0);
v14 = qword_14090BFE0;
}
v15 = "12";
LABEL_38:
GameStatsManager::incrementStat(v14, v15, 1u);
}
}
LABEL_39:
++v3;
result = cocos2d::CCArray::count(v2);
if ( v3 >= result )
return result;
}
v19 = GJGameLevel::getCoinKey(
*(_QWORD *)(a1 + 2168),
v8[452],
*(_DWORD *)(*(_QWORD *)(a1 + 2168) + 992LL) - *(_DWORD *)(*(_QWORD *)(a1 + 2168) + 996LL));
v20 = qword_14090BFE0;
if ( !qword_14090BFE0 )
{
v27 = operator new(0x3E8u);
qword_14090BFE0 = sub_1402D6480((__int64)v27);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFE0 + 72LL))(qword_14090BFE0);
v20 = qword_14090BFE0;
}
if ( GameStatsManager::hasSecretCoin(v20, v19) )
goto LABEL_39;
v21 = qword_14090BFE0;
if ( !qword_14090BFE0 )
{
v28 = operator new(0x3E8u);
qword_14090BFE0 = sub_1402D6480((__int64)v28);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFE0 + 72LL))(qword_14090BFE0);
v21 = qword_14090BFE0;
}
GameStatsManager::storeSecretCoin(v21, v19);
v14 = qword_14090BFE0;
if ( !qword_14090BFE0 )
{
v29 = operator new(0x3E8u);
qword_14090BFE0 = sub_1402D6480((__int64)v29);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFE0 + 72LL))(qword_14090BFE0);
v14 = qword_14090BFE0;
}
v15 = (const char *)&word_14070D038;
goto LABEL_38;
}
return result;
}