//
// GameManager::switchCustomObjects from 0x5ed2d0 to 0x5ed5e0 (784 bytes)
//
// 2 xrefs:
// > GameManager::reorderKey @ 0x5ed9f0
// > ??> @ 0xa08d8
//
// 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
//
// local variable allocation has failed, the output may be wrong!
void GameManager::switchCustomObjects(GameManager *a1, int a2, int a3)
{
cocos2d::CCDictionary *m_customObjectDict; // x20
cocos2d::CCString *v7; // x0
char *CString; // x0
cocos2d::CCObject *v9; // x25
char *v10; // x0
cocos2d::CCDictionary *v11; // x27
cocos2d::CCString *v12; // x0
char *v13; // x0
cocos2d::CCObject *v14; // x27
char *v15; // x0
cocos2d::CCString *v16; // x0
char *v17; // x0
char *v18; // x0
cocos2d::CCDictionary *v19; // x23
cocos2d::CCString *v20; // x0
char *v21; // x0
char *v22; // x0
unsigned int *v23; // x1
int v24; // w2
unsigned int *v25; // x1
int v26; // w2
unsigned int *v27; // x1
int v28; // w2
unsigned int *v29; // x19
int v30; // w1
cocos2d::CCDictionary *v31; // [xsp+68h] [xbp+68h]
std::string v32; // [xsp+80h] [xbp+80h] BYREF
m_customObjectDict = a1->m_customObjectDict;
v7 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", *(const char **)&a2);
CString = (char *)cocos2d::CCString::getCString(v7);
sub_D153B8((int)&v32, CString);
v9 = (cocos2d::CCObject *)cocos2d::CCDictionary::objectForKey(m_customObjectDict, &v32);
v10 = (char *)v32.m_data.m_data - 24;
if ( (__int64 *)v32.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v23 = (unsigned int *)((char *)v32.m_data.m_data - 8);
do
v24 = __ldaxr(v23);
while ( __stlxr(v24 - 1, v23) );
}
else
{
v24 = *((_DWORD *)v32.m_data.m_data - 2);
*((_DWORD *)v32.m_data.m_data - 2) = v24 - 1;
}
if ( v24 <= 0 )
operator delete(v10);
}
v11 = a1->m_customObjectDict;
v12 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i",
(const char *)(unsigned int)a3);
v13 = (char *)cocos2d::CCString::getCString(v12);
sub_D153B8((int)&v32, v13);
v14 = (cocos2d::CCObject *)cocos2d::CCDictionary::objectForKey(v11, &v32);
v15 = (char *)v32.m_data.m_data - 24;
if ( (__int64 *)v32.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v25 = (unsigned int *)((char *)v32.m_data.m_data - 8);
do
v26 = __ldaxr(v25);
while ( __stlxr(v26 - 1, v25) );
}
else
{
v26 = *((_DWORD *)v32.m_data.m_data - 2);
*((_DWORD *)v32.m_data.m_data - 2) = v26 - 1;
}
if ( v26 <= 0 )
operator delete(v15);
}
cocos2d::CCObject::retain(v9);
v31 = a1->m_customObjectDict;
v16 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i",
(const char *)(unsigned int)a2);
v17 = (char *)cocos2d::CCString::getCString(v16);
sub_D153B8((int)&v32, v17);
cocos2d::CCDictionary::setObject((int)v31, v14);
v18 = (char *)v32.m_data.m_data - 24;
if ( (__int64 *)v32.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v27 = (unsigned int *)((char *)v32.m_data.m_data - 8);
do
v28 = __ldaxr(v27);
while ( __stlxr(v28 - 1, v27) );
}
else
{
v28 = *((_DWORD *)v32.m_data.m_data - 2);
*((_DWORD *)v32.m_data.m_data - 2) = v28 - 1;
}
if ( v28 <= 0 )
operator delete(v18);
}
v19 = a1->m_customObjectDict;
v20 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i",
(const char *)(unsigned int)a3);
v21 = (char *)cocos2d::CCString::getCString(v20);
sub_D153B8((int)&v32, v21);
cocos2d::CCDictionary::setObject((int)v19, v9);
v22 = (char *)v32.m_data.m_data - 24;
if ( (__int64 *)v32.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v29 = (unsigned int *)((char *)v32.m_data.m_data - 8);
do
v30 = __ldaxr(v29);
while ( __stlxr(v30 - 1, v29) );
}
else
{
v30 = *((_DWORD *)v32.m_data.m_data - 2);
*((_DWORD *)v32.m_data.m_data - 2) = v30 - 1;
}
if ( v30 <= 0 )
operator delete(v22);
}
cocos2d::CCObject::release(v9);
}