//
// GameStatsManager::linkSpecialChestUnlocks from 0x7bd0ac to 0x7bd244 (408 bytes)
//
// 4 xrefs:
// > GameStatsManager::processOnlineChests @ 0x7bd2f0
// > GameStatsManager::createSpecialChestItems @ 0x7c2efc
// > GameStatsManager::unlockOnlineChest @ 0x7c599c
// > ??> @ 0x61b48
//
// 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
//
__int64 __fastcall GameStatsManager::linkSpecialChestUnlocks(GameStatsManager *a1, __int64 a2, cocos2d::CCString *a3)
{
cocos2d::CCArray *v5; // x20
unsigned int v6; // w19
_DWORD *v7; // x2
cocos2d::CCDictionary *m_allSpecialChestItems; // x24
const std::string *v10; // x1
cocos2d::CCObject *v11; // x0
_QWORD *v12; // x0
char *v13; // x0
unsigned int *v14; // x1
int v15; // w2
_DWORD *v16; // [xsp+80h] [xbp+80h] BYREF
if ( a2 )
{
v5 = *(cocos2d::CCArray **)(a2 + 72);
v6 = 0;
if ( v5 )
{
if ( (unsigned int)cocos2d::CCArray::count(v5) )
{
do
{
v7 = (_DWORD *)cocos2d::CCArray::objectAtIndex(v5, v6);
if ( v7[14] != 9 )
goto LABEL_5;
GameStatsManager::getItemKey(a1, v7[16], v7[15], (__int64)&v16);
m_allSpecialChestItems = a1->m_allSpecialChestItems;
v11 = (cocos2d::CCObject *)cocos2d::CCString::create(a3, v10);
cocos2d::CCDictionary::setObject((int)m_allSpecialChestItems, v11);
v12 = std::__detail::_Map_base,std::allocator>,std::__detail::_Select1st,std::equal_to,std::hash,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits,true>::operator[](
&a1->m_createSpecialChestItemsMap._M_h._M_buckets,
(const void **)&v16);
sub_D18EA8(v12, a3);
v13 = (char *)(v16 - 6);
if ( v16 - 6 == (_DWORD *)&qword_124B6B0 )
goto LABEL_5;
if ( &pthread_create )
{
v14 = v16 - 2;
do
v15 = __ldaxr(v14);
while ( __stlxr(v15 - 1, v14) );
}
else
{
v15 = *(v16 - 2);
*(v16 - 2) = v15 - 1;
}
if ( v15 > 0 )
{
LABEL_5:
++v6;
}
else
{
++v6;
operator delete(v13);
}
}
while ( v6 < (unsigned int)cocos2d::CCArray::count(v5) );
}
}
}
return _stack_chk_guard;
}