//
// GameLevelManager::updateLevelOrders from 0x100546a30 to 0x100546c1c (492 bytes)
//
// 2 xrefs:
// > GameLevelManager::encodeDataTo @ 0x10054f4ea
// > GameLevelManager::encodeDataTo @ 0x10054f4f2
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:31:59 +0000
//
__int64 __fastcall GameLevelManager::updateLevelOrders(__int64 a1)
{
__int64 v1; // r15
__int64 v2; // rbx
unsigned int v3; // r14d
int v4; // r12d
int v5; // eax
__int64 v6; // rax
const char *CString; // r14
__int64 v8; // r13
size_t v9; // rax
size_t v10; // r12
char *v11; // rbx
__int64 v12; // rax
size_t v13; // r15
__int64 v14; // rbx
unsigned int v15; // r14d
__int64 result; // rax
int v17; // r14d
unsigned int v18; // ebx
int v19; // [rsp+8h] [rbp-68h]
__int64 v20; // [rsp+18h] [rbp-58h]
__int64 v21; // [rsp+20h] [rbp-50h]
_QWORD __dst[2]; // [rsp+28h] [rbp-48h] BYREF
void *__p; // [rsp+38h] [rbp-38h]
unsigned int v24; // [rsp+44h] [rbp-2Ch]
v1 = sub_1007FE900(a1);
v2 = cocos2d::CCDictionary::allKeys(*(_QWORD *)(a1 + 760));
if ( (unsigned int)sub_1007FEF90(v2) )
{
v3 = 0;
v4 = -1;
v20 = v2;
v21 = v1;
do
{
v24 = v3;
v5 = sub_1007FEF90(v2);
v19 = v4;
v6 = sub_1007FEFE0(v2, (unsigned int)(v5 + v4));
CString = (const char *)cocos2d::CCString::getCString(v6);
v8 = *(_QWORD *)(a1 + 760);
v9 = strlen(CString);
if ( v9 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
v10 = v9;
if ( v9 >= 0x17 )
{
v12 = v9 | 7;
v13 = 26;
if ( (v10 | 7) != 0x17 )
v13 = v12 + 1;
v11 = (char *)operator new(v13);
__p = v11;
__dst[0] = v13 + 1;
__dst[1] = v10;
v1 = v21;
}
else
{
LOBYTE(__dst[0]) = 2 * v9;
v11 = (char *)__dst + 1;
if ( !v9 )
goto LABEL_13;
}
memmove(v11, CString, v10);
LABEL_13:
v11[v10] = 0;
v14 = cocos2d::CCDictionary::objectForKey(v8, (char *)__dst);
v15 = v24;
if ( (__dst[0] & 1) != 0 )
operator delete(__p);
if ( *(_BYTE *)(v14 + 1105) )
*(_DWORD *)(v14 + 632) = 0;
else
sub_1007FEBF0(v1, v14);
v3 = v15 + 1;
v2 = v20;
v4 = v19 - 1;
}
while ( v3 < (unsigned int)sub_1007FEF90(v20) );
}
if ( (unsigned int)sub_1007FEF90(v1) )
qsort(
*(void **)(*(_QWORD *)(v1 + 56) + 16LL),
**(unsigned int **)(v1 + 56),
8u,
(int (__cdecl *)(const void *, const void *))sub_10051B920);
result = sub_1007FEF90(v1);
if ( (int)result > 0 )
{
v17 = result;
v18 = 0;
do
{
result = sub_1007FEFE0(v1, v18);
*(_DWORD *)(result + 632) = v17;
++v18;
--v17;
}
while ( v17 );
}
return result;
}