//
// GameLevelManager::updateLevelOrders from 0x100534ea0 to 0x10053508c (492 bytes)
//
// 2 xrefs:
// > GameLevelManager::encodeDataTo @ 0x10053af6a
// > GameLevelManager::encodeDataTo @ 0x10053af72
//
// 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
//
void __fastcall GameLevelManager::updateLevelOrders(GameLevelManager *a1)
{
__int64 v1; // rsi
double v2; // xmm0_8
__int64 v3; // r15
cocos2d::CCArray *v4; // rbx
unsigned int v5; // r14d
int v6; // r12d
int v7; // eax
cocos2d::CCString *v8; // rax
const char *CString; // r14
cocos2d::CCDictionary *m_onlineLevels; // r13
size_t v11; // rax
size_t v12; // r12
char *v13; // rbx
__int64 v14; // rax
size_t v15; // r15
__int64 v16; // rbx
unsigned int v17; // r14d
int v18; // eax
int v19; // r14d
unsigned int v20; // ebx
int v21; // [rsp+8h] [rbp-68h]
cocos2d::CCArray *v22; // [rsp+18h] [rbp-58h]
__int64 v23; // [rsp+20h] [rbp-50h]
_QWORD __dst[2]; // [rsp+28h] [rbp-48h] BYREF
void *__p; // [rsp+38h] [rbp-38h]
unsigned int v26; // [rsp+44h] [rbp-2Ch]
v3 = sub_10071F9E0(a1, v1);
v4 = cocos2d::CCDictionary::allKeys(a1->m_onlineLevels);
if ( (unsigned int)sub_100720070(v4) )
{
v5 = 0;
v6 = -1;
v22 = v4;
v23 = v3;
do
{
v26 = v5;
v7 = sub_100720070(v4);
v21 = v6;
v8 = (cocos2d::CCString *)sub_1007200C0(v4, (unsigned int)(v7 + v6));
CString = cocos2d::CCString::getCString(v8);
m_onlineLevels = a1->m_onlineLevels;
v11 = strlen(CString);
if ( v11 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(v2);
v12 = v11;
if ( v11 >= 0x17 )
{
v14 = v11 | 7;
v15 = 26;
if ( (v12 | 7) != 0x17 )
v15 = v14 + 1;
v13 = (char *)operator new(v15);
__p = v13;
__dst[0] = v15 + 1;
__dst[1] = v12;
v3 = v23;
}
else
{
LOBYTE(__dst[0]) = 2 * v11;
v13 = (char *)__dst + 1;
if ( !v11 )
goto LABEL_13;
}
memmove(v13, CString, v12);
LABEL_13:
v13[v12] = 0;
v16 = cocos2d::CCDictionary::objectForKey_1((__int64)m_onlineLevels, (char *)__dst);
v17 = v26;
if ( (__dst[0] & 1) != 0 )
operator delete(__p);
if ( *(_BYTE *)(v16 + 993) )
*(_DWORD *)(v16 + 624) = 0;
else
sub_10071FCD0(v3, v16);
v5 = v17 + 1;
v4 = v22;
v6 = v21 - 1;
}
while ( v5 < (unsigned int)sub_100720070(v22) );
}
if ( (unsigned int)sub_100720070(v3) )
qsort(
*(void **)(*(_QWORD *)(v3 + 56) + 16LL),
**(unsigned int **)(v3 + 56),
8u,
(int (__cdecl *)(const void *, const void *))sub_10051A850);
v18 = sub_100720070(v3);
if ( v18 > 0 )
{
v19 = v18;
v20 = 0;
do
*(_DWORD *)(sub_1007200C0(v3, v20++) + 624) = v19--;
while ( v19 );
}
}