//
// GameLevelManager::updateLevelOrders from 0x14021f1d0 to 0x14021f3ab (475 bytes)
//
// 3 xrefs:
// > GameLevelManager::encodeDataTo @ 0x140224ba4
// > GameLevelManager::encodeDataTo @ 0x140224bac
// > ??> @ 0x14091bb24
//
// 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 11:28:24 +0000
//
// Hidden C++ exception states: #wind=1
int __fastcall GameLevelManager::updateLevelOrders(__int64 a1)
{
cocos2d::CCArray *v2; // rbp
cocos2d::CCArray *v3; // r14
signed int v4; // ebx
unsigned int v5; // esi
__m128i si128; // xmm6
unsigned int v7; // eax
cocos2d::CCString *v8; // rax
const char *CString; // rax
size_t v10; // r8
__int64 v11; // rdi
void *v12; // rcx
struct cocos2d::CCObject *v13; // rax
signed int v14; // esi
int v15; // edi
__int128 v17; // [rsp+30h] [rbp-58h] BYREF
__m128i v18; // [rsp+40h] [rbp-48h]
v2 = (cocos2d::CCArray *)cocos2d::CCArray::create(a1);
v3 = cocos2d::CCDictionary::allKeys(*(cocos2d::CCDictionary **)(a1 + 856));
v4 = 0;
v5 = 0;
if ( cocos2d::CCArray::count(v3) )
{
si128 = _mm_load_si128((const __m128i *)&Size);
do
{
v7 = cocos2d::CCArray::count(v3);
v8 = cocos2d::CCArray::objectAtIndex(v3, v7 + ~v5);
CString = cocos2d::CCString::getCString(v8);
v17 = 0;
v18 = 0;
v10 = -1;
do
++v10;
while ( CString[v10] );
sub_14003D230(&v17, CString, v10);
v11 = cocos2d::CCDictionary::objectForKey(*(_QWORD *)(a1 + 856), &v17);
if ( v18.m128i_i64[1] > 0xFuLL )
{
v12 = (void *)v17;
if ( (unsigned __int64)(v18.m128i_i64[1] + 1) >= 0x1000 )
{
v12 = *(void **)(v17 - 8);
if ( (unsigned __int64)(v17 - (_QWORD)v12 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v12);
}
v18 = si128;
LOBYTE(v17) = 0;
if ( *(_BYTE *)(v11 + 1185) )
*(_DWORD *)(v11 + 704) = 0;
else
cocos2d::CCArray::addObject(v2, (struct cocos2d::CCObject *)v11);
++v5;
}
while ( v5 < cocos2d::CCArray::count(v3) );
}
if ( cocos2d::CCArray::count(v2) )
qsort(
*(void **)(*((_QWORD *)v2 + 7) + 16LL),
**((unsigned int **)v2 + 7),
8u,
(_CoreCrtNonSecureSearchSortCompareFunction)sub_140219080);
LODWORD(v13) = cocos2d::CCArray::count(v2);
v14 = (int)v13;
if ( (int)v13 > 0 )
{
v15 = (int)v13;
do
{
v13 = cocos2d::CCArray::objectAtIndex(v2, v4);
*((_DWORD *)v13 + 176) = v15;
++v4;
--v15;
}
while ( v4 < v14 );
}
return (int)v13;
}