//
// GameLevelManager::updateLevelOrders from 0x1401476c0 to 0x140147897 (471 bytes)
//
// 3 xrefs:
// > GameLevelManager::encodeDataTo @ 0x14014af44
// > GameLevelManager::encodeDataTo @ 0x14014af4c
// > ??> @ 0x1406ca614
//
// 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
//
// Hidden C++ exception states: #wind=1
void GameLevelManager::updateLevelOrders(GameLevelManager *a1)
{
cocos2d::CCArray *v2; // rbp
cocos2d::CCArray *v3; // r14
signed int v4; // ebx
unsigned int i; // esi
unsigned int v6; // eax
cocos2d::CCString *v7; // rax
const char *CString; // rax
size_t v9; // r8
__int64 v10; // rdi
void *v11; // rcx
int v12; // eax
signed int v13; // esi
unsigned int v14; // edi
__int128 v15; // [rsp+20h] [rbp-48h] BYREF
__int64 v16; // [rsp+30h] [rbp-38h]
unsigned __int64 v17; // [rsp+38h] [rbp-30h]
v2 = (cocos2d::CCArray *)cocos2d::CCArray::create(a1);
v3 = cocos2d::CCDictionary::allKeys(a1->m_onlineLevels);
v4 = 0;
for ( i = 0; i < cocos2d::CCArray::count(v3); ++i )
{
v6 = cocos2d::CCArray::count(v3);
v7 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v3, v6 + -1 - i);
CString = cocos2d::CCString::getCString(v7);
v15 = 0;
v16 = 0;
v17 = 0;
v9 = -1;
do
++v9;
while ( CString[v9] );
sub_14003A930(&v15, CString, v9);
v10 = cocos2d::CCDictionary::objectForKey(a1->m_onlineLevels, &v15);
if ( v17 > 0xF )
{
v11 = (void *)v15;
if ( v17 + 1 >= 0x1000 )
{
v11 = *(void **)(v15 - 8);
if ( (unsigned __int64)(v15 - (_QWORD)v11 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v11);
}
v16 = 0;
v17 = 15;
LOBYTE(v15) = 0;
if ( *(_BYTE *)(v10 + 1073) )
*(_DWORD *)(v10 + 696) = 0;
else
cocos2d::CCArray::addObject(v2, (struct cocos2d::CCObject *)v10);
}
if ( cocos2d::CCArray::count(v2) )
qsort(v2->data->arr, v2->data->num, 8u, (_CoreCrtNonSecureSearchSortCompareFunction)sub_140142B30);
v12 = cocos2d::CCArray::count(v2);
v13 = v12;
if ( v12 > 0 )
{
v14 = v12;
do
cocos2d::CCArray::objectAtIndex(v2, v4++)[12].m_uAutoReleaseCount = v14--;
while ( v4 < v13 );
}
}