//
// cocos2d::CCDictionary::randomObject from 0xad1544 to 0xad1654 (272 bytes)
//
// 1 xrefs:
// > ??> @ 0x85ff8
//
// 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
//
cocos2d::CCObject *cocos2d::CCDictionary::randomObject(cocos2d::CCDictionary *a1)
{
cocos2d::CCArray *v2; // x0
__int64 v3; // x0
cocos2d::CCDictionary::CCDictType m_eDictType; // w1
char *CString; // x0
cocos2d::CCObject *v6; // x20
char *v7; // x0
unsigned int *v8; // x2
int v9; // w1
const char *v11; // [xsp+40h] [xbp+40h] BYREF
if ( a1->m_eDictType == kCCDictUnknown )
return nullptr;
v2 = cocos2d::CCDictionary::allKeys(a1);
v3 = cocos2d::CCArray::randomObject(v2);
m_eDictType = a1->m_eDictType;
if ( m_eDictType == kCCDictInt )
return cocos2d::CCDictionary::objectForKey(a1, *(int *)(v3 + 56));
if ( m_eDictType != kCCDictStr )
return nullptr;
CString = (char *)cocos2d::CCString::getCString((cocos2d::CCString *)v3);
sub_D153B8((int)&v11, CString);
v6 = (cocos2d::CCObject *)cocos2d::CCDictionary::objectForKey((__int64)a1, &v11);
v7 = (char *)(v11 - 24);
if ( v11 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v8 = (unsigned int *)(v11 - 8);
do
v9 = __ldaxr(v8);
while ( __stlxr(v9 - 1, v8) );
}
else
{
v9 = *((_DWORD *)v11 - 2);
*((_DWORD *)v11 - 2) = v9 - 1;
}
if ( v9 <= 0 )
operator delete(v7);
}
return v6;
}