//
// GameLevelManager::getSavedLevels from 0x100534b60 to 0x100534d30 (464 bytes)
//
// 4 xrefs:
// > LevelBrowserLayer::loadPage @ 0x10048e812
// > LevelBrowserLayer::FLAlert_Clicked @ 0x100491861
// > LevelBrowserLayer::FLAlert_Clicked @ 0x10049191a
// > GameLevelManager::limitSavedLevels @ 0x10053978c
//
// 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
//
// local variable allocation has failed, the output may be wrong!
cocos2d::CCArray *__fastcall GameLevelManager::getSavedLevels(GameLevelManager *a1, bool a2, int a3)
{
double v3; // xmm0_8
GameLevelManager *v4; // r13
cocos2d::CCArray *v5; // r14
unsigned int v6; // r12d
int v7; // ebx
int v8; // eax
cocos2d::CCString *v9; // rax
const char *CString; // r14
__int64 m_onlineLevels; // r15
size_t v12; // rax
size_t v13; // rbx
char *v14; // r12
__int64 v15; // rax
size_t v16; // r13
__int64 v17; // rbx
unsigned int v18; // r12d
int v20; // [rsp+0h] [rbp-70h]
cocos2d::CCArray *v21; // [rsp+8h] [rbp-68h]
cocos2d::CCArray *v22; // [rsp+18h] [rbp-58h]
_QWORD __dst[2]; // [rsp+20h] [rbp-50h] BYREF
void *__p; // [rsp+30h] [rbp-40h]
unsigned int v25; // [rsp+3Ch] [rbp-34h]
_BOOL4 v26; // [rsp+40h] [rbp-30h]
int v27; // [rsp+44h] [rbp-2Ch]
v27 = a3;
v26 = a2;
v4 = a1;
v22 = (cocos2d::CCArray *)sub_10071F9E0(a1, a2);
v5 = cocos2d::CCDictionary::allKeys(a1->m_onlineLevels);
if ( (unsigned int)sub_100720070(v5) )
{
v6 = 0;
v7 = -1;
v21 = v5;
do
{
v8 = sub_100720070(v5);
v20 = v7;
v9 = (cocos2d::CCString *)sub_1007200C0(v5, (unsigned int)(v8 + v7));
CString = cocos2d::CCString::getCString(v9);
m_onlineLevels = (__int64)v4->m_onlineLevels;
v12 = strlen(CString);
if ( v12 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(v3);
v13 = v12;
v25 = v6;
if ( v12 >= 0x17 )
{
v15 = v12 | 7;
v16 = 26;
if ( (v13 | 7) != 0x17 )
v16 = v15 + 1;
v14 = (char *)operator new(v16);
__p = v14;
__dst[0] = v16 + 1;
__dst[1] = v13;
v4 = a1;
}
else
{
LOBYTE(__dst[0]) = 2 * v12;
v14 = (char *)__dst + 1;
if ( !v12 )
goto LABEL_13;
}
memmove(v14, CString, v13);
LABEL_13:
v14[v13] = 0;
v17 = cocos2d::CCDictionary::objectForKey_1(m_onlineLevels, (char *)__dst);
v5 = v21;
v18 = v25;
if ( (__dst[0] & 1) != 0 )
operator delete(__p);
if ( !*(_BYTE *)(v17 + 993) && (!v26 || *(_BYTE *)(v17 + 796) == 1) && (v27 <= 0 || *(_DWORD *)(v17 + 800) == v27) )
sub_10071FCD0(v22, v17);
v6 = v18 + 1;
v7 = v20 - 1;
}
while ( v6 < (unsigned int)sub_100720070(v21) );
}
if ( (unsigned int)sub_100720070(v22) )
qsort(v22->data->arr, v22->data->num, 8u, (int (__cdecl *)(const void *, const void *))sub_10051A850);
return v22;
}