//
// GameLevelManager::getSavedLevels from 0x1005466f0 to 0x1005468c0 (464 bytes)
//
// 5 xrefs:
// > LevelBrowserLayer::loadPage @ 0x100484878
// > LevelBrowserLayer::FLAlert_Clicked @ 0x1004880c6
// > LevelBrowserLayer::FLAlert_Clicked @ 0x100488182
// > GameLevelManager::limitSavedLevels @ 0x10054b5bb
// > sub_100940480 @ 0x1009404f7
//
// 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::getSavedLevels(__int64 a1, int a2, int a3)
{
__int64 v3; // r13
__int64 v4; // r14
unsigned int v5; // r12d
int v6; // ebx
int v7; // eax
__int64 v8; // rax
const char *CString; // r14
__int64 v10; // r15
size_t v11; // rax
size_t v12; // rbx
char *v13; // r12
__int64 v14; // rax
size_t v15; // r13
__int64 v16; // rbx
unsigned int v17; // r12d
int v19; // [rsp+0h] [rbp-70h]
__int64 v20; // [rsp+8h] [rbp-68h]
__int64 v21; // [rsp+18h] [rbp-58h]
_QWORD __dst[2]; // [rsp+20h] [rbp-50h] BYREF
void *__p; // [rsp+30h] [rbp-40h]
unsigned int v24; // [rsp+3Ch] [rbp-34h]
int v25; // [rsp+40h] [rbp-30h]
int v26; // [rsp+44h] [rbp-2Ch]
v26 = a3;
v25 = a2;
v3 = a1;
v21 = sub_1007FE900(a1);
v4 = cocos2d::CCDictionary::allKeys(*(_QWORD *)(a1 + 760));
if ( (unsigned int)sub_1007FEF90(v4) )
{
v5 = 0;
v6 = -1;
v20 = v4;
do
{
v7 = sub_1007FEF90(v4);
v19 = v6;
v8 = sub_1007FEFE0(v4, (unsigned int)(v7 + v6));
CString = (const char *)cocos2d::CCString::getCString(v8);
v10 = *(_QWORD *)(v3 + 760);
v11 = strlen(CString);
if ( v11 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
v12 = v11;
v24 = v5;
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 = a1;
}
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(v10, (char *)__dst);
v4 = v20;
v17 = v24;
if ( (__dst[0] & 1) != 0 )
operator delete(__p);
if ( !*(_BYTE *)(v16 + 1105)
&& (!(_BYTE)v25 || *(_BYTE *)(v16 + 912) == 1)
&& (v26 <= 0 || *(_DWORD *)(v16 + 916) == v26) )
{
sub_1007FEBF0(v21, v16);
}
v5 = v17 + 1;
v6 = v19 - 1;
}
while ( v5 < (unsigned int)sub_1007FEF90(v20) );
}
if ( (unsigned int)sub_1007FEF90(v21) )
qsort(
*(void **)(*(_QWORD *)(v21 + 56) + 16LL),
**(unsigned int **)(v21 + 56),
8u,
(int (__cdecl *)(const void *, const void *))sub_10051B920);
return v21;
}