//
// GJLevelList::getListLevelsArray from 0x850a60 to 0x850e18 (952 bytes)
//
// 3 xrefs:
// > GJLevelList::duplicateListLevels @ 0x857860
// > LevelListLayer::updateResultArray @ 0xba8b94
// > ??> @ 0x52660
//
// This function is hookable on this platform (idp: arm, 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:55:26 +0000
//
cocos2d::CCArray *__fastcall GJLevelList::getListLevelsArray(GJLevelList *this, cocos2d::CCArray *a2)
{
__int64 v3; // x0
unsigned int *v4; // x1
__int64 v5; // x0
int *v6; // x27
cocos2d::CCArray *v7; // x28
int *v8; // x19
int v9; // w20
unsigned __int64 *v10; // x0
int v11; // w4
unsigned __int64 v12; // x7
unsigned __int64 v13; // x5
unsigned __int64 v14; // x1
unsigned __int64 v15; // x1
GameLevelManager *v16; // x0
__int64 SavedLevel; // x25
__int64 v18; // x22
__int64 v19; // x22
GJGameLevel *v20; // x0
_QWORD *v21; // x0
_QWORD *v22; // x19
void *v23; // x0
GJGameLevel *v25; // x22
__int64 v26; // x26
cocos2d::CCObject *ListSnapshot; // x25
__int64 v28; // x0
int v29; // w25
float v30; // s0
char *v31; // x1
size_t v32; // x2
char *v33; // x20
char *v34; // x21
__int64 i; // x19
int v36; // [xsp+84h] [xbp+84h] BYREF
unsigned __int64 v37[3]; // [xsp+88h] [xbp+88h] BYREF
unsigned __int64 v38[3]; // [xsp+A0h] [xbp+A0h] BYREF
unsigned __int64 v39[2]; // [xsp+B8h] [xbp+B8h] BYREF
void *v40; // [xsp+C8h] [xbp+C8h]
void *v41; // [xsp+D0h] [xbp+D0h] BYREF
unsigned __int64 v42; // [xsp+D8h] [xbp+D8h]
void *v43; // [xsp+E0h] [xbp+E0h]
__int64 v44; // [xsp+E8h] [xbp+E8h]
float v45; // [xsp+F0h] [xbp+F0h]
v41 = nullptr;
v3 = _stack_chk_guard;
v42 = 0;
v43 = nullptr;
v44 = 0;
v45 = 1.0;
if ( a2 )
{
v4 = *((unsigned int **)a2 + 7);
v3 = *v4;
if ( (_DWORD)v3 )
{
v33 = *((char **)v4 + 2);
v3 = 8LL * (unsigned int)v3 - 8;
v34 = &v33[v3];
if ( v33 <= &v33[v3] )
{
for ( i = *(_QWORD *)v33; *(_QWORD *)v33; i = *(_QWORD *)v33 )
{
v36 = *(_DWORD *)(i + 328) - *(_DWORD *)(i + 332);
v3 = std::unordered_map::operator[]((unsigned __int64)&v41, &v36);
v33 += 8;
*(_QWORD *)v3 = i;
if ( v34 < v33 )
break;
}
}
}
}
v5 = cocos2d::CCArray::create((cocos2d::CCArray *)v3);
v6 = *((int **)this + 41);
v7 = (cocos2d::CCArray *)v5;
v8 = *((int **)this + 40);
v9 = 1;
if ( v8 != v6 )
{
v10 = v39;
do
{
v11 = *v8;
if ( v42 )
{
v12 = v42 - 1;
v13 = ((v42 - 1) & v42) != 0 ? v11 % v42 : v11 & v12;
v10 = *((unsigned __int64 **)v41 + v13);
if ( v10 )
{
while ( 1 )
{
v10 = (unsigned __int64 *)*v10;
if ( !v10 )
break;
v14 = v10[1];
v15 = ((v42 - 1) & v42) != 0 ? v14 % v42 : v12 & v14;
if ( v13 != v15 )
break;
if ( v11 == *((_DWORD *)v10 + 4) )
{
v25 = *(GJGameLevel **)std::unordered_map::operator[]((unsigned __int64)&v41, v8);
v26 = *((_QWORD *)this + 67);
ListSnapshot = (cocos2d::CCObject *)GJGameLevel::getListSnapshot(v25);
GameToolbox::intToString(
v37,
(GameToolbox *)(unsigned int)(*((_DWORD *)v25 + 82) - *((_DWORD *)v25 + 83)));
cocos2d::CCDictionary::setObject(v26, ListSnapshot);
v10 = (unsigned __int64 *)LOBYTE(v37[0]);
if ( (v37[0] & 1) != 0 )
operator delete((void *)v37[2]);
break;
}
}
}
}
v16 = (GameLevelManager *)GameLevelManager::sharedState((GameLevelManager *)v10);
SavedLevel = GameLevelManager::getSavedLevel(v16, (const char *)(unsigned int)*v8);
v18 = *((_QWORD *)this + 67);
GameToolbox::intToString(v38, (GameToolbox *)(unsigned int)*v8);
v19 = cocos2d::CCDictionary::objectForKey(v18, v38);
v20 = (GJGameLevel *)LOBYTE(v38[0]);
if ( (v38[0] & 1) != 0 )
{
operator delete((void *)v38[2]);
if ( !SavedLevel )
{
LABEL_27:
if ( !v19 )
{
v28 = GJGameLevel::create(v20);
v29 = *v8;
v19 = v28;
*(_DWORD *)(v28 + 336) = *v8;
v30 = (float)((float)rand() * 4.6566e-10) * 1000.0;
*(_DWORD *)(v19 + 332) = (int)v30;
*(_DWORD *)(v19 + 328) = v29 + (int)v30;
GameToolbox::intToString(v39, (GameToolbox *)(unsigned int)*v8);
if ( (unsigned __int64 *)(v19 + 344) != v39 )
{
if ( (v39[0] & 1) != 0 )
{
v31 = (char *)v40;
v32 = v39[1];
}
else
{
v32 = LOBYTE(v39[0]) >> 1;
v31 = (char *)v39 + 1;
}
std::string::assign((__int64 *)(v19 + 344), v31, v32);
}
if ( (v39[0] & 1) != 0 )
operator delete(v40);
}
goto LABEL_17;
}
}
else if ( !SavedLevel )
{
goto LABEL_27;
}
if ( *(_BYTE *)(SavedLevel + 1105) )
{
if ( !v19 )
v19 = SavedLevel;
}
else
{
v19 = SavedLevel;
}
LABEL_17:
*(_DWORD *)(v19 + 1236) = v9++;
v10 = (unsigned __int64 *)cocos2d::CCArray::addObject(v7, (cocos2d::CCObject *)v19);
++v8;
}
while ( v6 != v8 );
}
v21 = v43;
if ( v43 )
{
do
{
v22 = (_QWORD *)*v21;
operator delete(v21);
v21 = v22;
}
while ( v22 );
}
v23 = v41;
v41 = nullptr;
if ( v23 )
operator delete(v23);
return v7;
}