//
// GameManager::getNextUsedKey from 0x100384530 to 0x100384661 (305 bytes)
//
// 1 xrefs:
// > GameManager::reorderKey @ 0x10038499c
//
// 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
//
int __fastcall GameManager::getNextUsedKey(GameManager *a1, int a2, bool a3)
{
cocos2d::CCArray *v4; // rbx
int v5; // r15d
cocos2d::CCString *v6; // rax
int v7; // eax
unsigned int v8; // r12d
cocos2d::CCString *v9; // rax
int v10; // r13d
unsigned int v11; // eax
cocos2d::CCString *v13; // rax
unsigned int i; // r12d
cocos2d::CCString *v16; // rax
v4 = cocos2d::CCDictionary::allKeys(a1->m_customObjectDict);
if ( (unsigned int)sub_100720070(v4) )
qsort(v4->data->arr, v4->data->num, 8u, (int (__cdecl *)(const void *, const void *))sub_1003768B0);
v5 = 0;
if ( (unsigned int)sub_100720070(v4) )
{
if ( a3 )
{
v6 = cocos2d::CCArray::stringAtIndex(v4, 0);
v7 = cocos2d::CCString::intValue(v6);
if ( v7 != a2 )
{
for ( i = 1; ; ++i )
{
v5 = v7;
if ( i >= (unsigned int)sub_100720070(v4) )
break;
v16 = cocos2d::CCArray::stringAtIndex(v4, i);
v7 = cocos2d::CCString::intValue(v16);
if ( v7 == a2 )
return v5;
}
}
return 0;
}
else
{
v8 = 1;
while ( 1 )
{
v9 = cocos2d::CCArray::stringAtIndex(v4, v8 - 1);
v10 = cocos2d::CCString::intValue(v9);
v11 = sub_100720070(v4);
if ( v10 == a2 )
break;
if ( v8++ >= v11 )
return v5;
}
if ( v8 < v11 )
{
v13 = cocos2d::CCArray::stringAtIndex(v4, v8);
return cocos2d::CCString::intValue(v13);
}
}
}
return v5;
}