//
// GJLevelList::getListLevelsArray from 0x100561ff0 to 0x1005625f9 (1545 bytes)
//
// 2 xrefs:
// > LevelListLayer::updateResultArray @ 0x10035fafc
// > GJLevelList::duplicateListLevels @ 0x100561f95
//
// 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
//
cocos2d::CCArray *__fastcall GJLevelList::getListLevelsArray(GJLevelList *a1, cocos2d::CCArray *a2)
{
double v2; // xmm0_8
cocos2d::ccArray *data; // rax
cocos2d::CCObject **arr; // r15
unsigned __int64 v5; // r12
cocos2d::CCObject *v6; // r13
int *begin; // r15
int v8; // r12d
unsigned __int64 v9; // rcx
unsigned __int64 v10; // r9
unsigned __int64 v11; // rsi
__int64 **v12; // rax
__int64 *v13; // r8
unsigned __int64 v14; // rax
unsigned __int64 v15; // rax
GJGameLevel *v16; // r14
__int64 m_levelsDict; // rbx
GJGameLevel *ListSnapshot; // r13
GameLevelManager *v19; // rdi
char *v20; // r13
char *SavedLevel; // r13
__int64 v22; // rbx
__int64 v23; // rbx
int v24; // ebx
_QWORD *v25; // rdi
_QWORD *v26; // rbx
void *v27; // rdi
std::string __str; // [rsp+0h] [rbp-A0h] BYREF
int *end; // [rsp+18h] [rbp-88h]
void *v31[2]; // [rsp+20h] [rbp-80h] BYREF
void *v32[2]; // [rsp+30h] [rbp-70h]
int v33; // [rsp+40h] [rbp-60h]
cocos2d::CCArray *v34; // [rsp+48h] [rbp-58h]
GJLevelList *v35; // [rsp+50h] [rbp-50h]
size_t v36[2]; // [rsp+58h] [rbp-48h] BYREF
void *__p; // [rsp+68h] [rbp-38h]
int v38; // [rsp+70h] [rbp-30h] BYREF
char v39[41]; // [rsp+77h] [rbp-29h] BYREF
v35 = a1;
v2 = 0.0;
*(_OWORD *)v32 = 0;
*(_OWORD *)v31 = 0;
v33 = 1065353216;
if ( a2 )
{
data = a2->data;
if ( data->num )
{
arr = data->arr;
v5 = (unsigned __int64)&arr[data->num - 1];
do
{
v6 = *arr;
if ( !*arr )
break;
v38 = v6[5].m_uOrderOfArrival - v6[5].m_unknown5;
v36[0] = (size_t)&v38;
a1 = (GJLevelList *)v31;
a2 = (cocos2d::CCArray *)&v38;
*(_QWORD *)(sub_100565B30(v31, &v38, &unk_10081E77F, v36, v39) + 24) = v6;
++arr;
}
while ( (unsigned __int64)arr <= v5 );
}
}
v34 = (cocos2d::CCArray *)sub_10071F9E0(a1, a2);
begin = v35->m_levels.__begin_;
end = v35->m_levels.__end_;
if ( begin == end )
goto LABEL_51;
v8 = 1;
do
{
if ( !v31[1] )
goto LABEL_37;
v9 = *begin;
v10 = (0x101010101010101LL
* (((((unsigned __int64)v31[1] - (((unsigned __int64)v31[1] >> 1) & 0x5555555555555555LL))
& 0x3333333333333333LL)
+ ((((unsigned __int64)v31[1] - (((unsigned __int64)v31[1] >> 1) & 0x5555555555555555LL)) >> 2)
& 0x3333333333333333LL)
+ (((((unsigned __int64)v31[1] - (((unsigned __int64)v31[1] >> 1) & 0x5555555555555555LL))
& 0x3333333333333333LL)
+ ((((unsigned __int64)v31[1] - (((unsigned __int64)v31[1] >> 1) & 0x5555555555555555LL)) >> 2)
& 0x3333333333333333LL)) >> 4))
& 0xF0F0F0F0F0F0F0FLL)) >> 56;
if ( v10 <= 1 )
{
v11 = v9 & ((unsigned __int64)v31[1] - 1);
v12 = *((__int64 ***)v31[0] + v11);
if ( !v12 )
goto LABEL_37;
goto LABEL_16;
}
v11 = *begin;
if ( v31[1] <= (void *)v9 )
{
if ( !(((unsigned __int64)v31[1] | v9) >> 32) )
{
v11 = (unsigned int)v9 % LODWORD(v31[1]);
v12 = *((__int64 ***)v31[0] + v11);
if ( !v12 )
goto LABEL_37;
goto LABEL_16;
}
v11 = v9 % (unsigned __int64)v31[1];
}
v12 = *((__int64 ***)v31[0] + v11);
if ( !v12 )
goto LABEL_37;
LABEL_16:
v13 = *v12;
if ( !*v12 )
goto LABEL_37;
if ( (unsigned int)v10 < 2 )
{
while ( 1 )
{
v14 = v13[1];
if ( v14 == v9 )
{
if ( *((_DWORD *)v13 + 4) == (_DWORD)v9 )
goto LABEL_34;
}
else if ( (((unsigned __int64)v31[1] - 1) & v14) != v11 )
{
goto LABEL_37;
}
v13 = (__int64 *)*v13;
if ( !v13 )
goto LABEL_37;
}
}
while ( 1 )
{
v15 = v13[1];
if ( v15 == v9 )
break;
if ( (void *)v15 < v31[1] )
goto LABEL_30;
if ( ((unsigned __int64)v31[1] | v15) >> 32 )
{
v15 %= (unsigned __int64)v31[1];
LABEL_30:
if ( v15 != v11 )
goto LABEL_37;
goto LABEL_25;
}
if ( (unsigned int)v15 % LODWORD(v31[1]) != v11 )
goto LABEL_37;
LABEL_25:
v13 = (__int64 *)*v13;
if ( !v13 )
goto LABEL_37;
}
if ( *((_DWORD *)v13 + 4) != (_DWORD)v9 )
goto LABEL_25;
LABEL_34:
v36[0] = (size_t)begin;
v16 = *(GJGameLevel **)(sub_100565FD0(v31, begin, &unk_10081E77F, v36, &v38) + 24);
m_levelsDict = (__int64)v35->m_levelsDict;
ListSnapshot = GJGameLevel::getListSnapshot(v16);
GameToolbox::intToString(v36, v16->m_levelID.random - v16->m_levelID.seed, v2);
cocos2d::CCDictionary::setObject_1(m_levelsDict, ListSnapshot, (char *)v36);
if ( (v36[0] & 1) != 0 )
operator delete(__p);
LABEL_37:
v19 = (GameLevelManager *)qword_1009A28E0;
if ( !qword_1009A28E0 )
{
v20 = (char *)operator new(0x3C8u);
cocos2d::CCNode::CCNode((__int64)v20);
*(_QWORD *)v20 = off_100960890;
v2 = 0.0;
*(_OWORD *)(v20 + 328) = 0;
*((_QWORD *)v20 + 40) = v20 + 328;
*((_QWORD *)v20 + 62) = 0;
*((_OWORD *)v20 + 32) = 0;
*(_OWORD *)(v20 + 344) = 0;
*(_OWORD *)(v20 + 360) = 0;
*(_OWORD *)(v20 + 376) = 0;
*(_OWORD *)(v20 + 392) = 0;
*(_OWORD *)(v20 + 408) = 0;
*(_OWORD *)(v20 + 424) = 0;
*(_OWORD *)(v20 + 440) = 0;
*(_OWORD *)(v20 + 456) = 0;
*(_OWORD *)(v20 + 472) = 0;
*((_DWORD *)v20 + 122) = 0;
*((_QWORD *)v20 + 63) = v20 + 512;
*((_OWORD *)v20 + 33) = 0;
*((_OWORD *)v20 + 34) = 0;
*((_OWORD *)v20 + 35) = 0;
*((_OWORD *)v20 + 36) = 0;
*(_OWORD *)(v20 + 696) = 0;
*(_OWORD *)(v20 + 680) = 0;
*(_OWORD *)(v20 + 664) = 0;
*(_OWORD *)(v20 + 648) = 0;
*(_OWORD *)(v20 + 632) = 0;
*(_OWORD *)(v20 + 616) = 0;
*(_OWORD *)(v20 + 600) = 0;
v20[712] = 0;
*((_OWORD *)v20 + 48) = 0;
*((_OWORD *)v20 + 47) = 0;
*((_OWORD *)v20 + 46) = 0;
*((_OWORD *)v20 + 45) = 0;
*(_OWORD *)(v20 + 945) = 0;
*(_OWORD *)(v20 + 936) = 0;
*(_OWORD *)(v20 + 920) = 0;
*(_OWORD *)(v20 + 904) = 0;
*(_OWORD *)(v20 + 888) = 0;
*(_OWORD *)(v20 + 872) = 0;
*(_OWORD *)(v20 + 856) = 0;
*(_OWORD *)(v20 + 840) = 0;
*(_OWORD *)(v20 + 824) = 0;
*(_OWORD *)(v20 + 808) = 0;
*(_OWORD *)(v20 + 792) = 0;
qword_1009A28E0 = (__int64)v20;
GameLevelManager::init((GameLevelManager *)v20);
v19 = (GameLevelManager *)qword_1009A28E0;
}
SavedLevel = (char *)GameLevelManager::getSavedLevel(v19, *begin);
v22 = (__int64)v35->m_levelsDict;
GameToolbox::intToString(v36, *begin, v2);
v23 = cocos2d::CCDictionary::objectForKey_1(v22, (char *)v36);
if ( (v36[0] & 1) != 0 )
operator delete(__p);
if ( SavedLevel )
{
if ( ((v23 != 0) & (unsigned __int8)SavedLevel[993]) != 0 )
SavedLevel = (char *)v23;
}
else
{
SavedLevel = (char *)v23;
if ( !v23 )
{
SavedLevel = (char *)operator new(0x530u);
GJGameLevel::GJGameLevel((GJGameLevel *)SavedLevel);
if ( (*(unsigned __int8 (__fastcall **)(char *))(*(_QWORD *)SavedLevel + 80LL))(SavedLevel) )
{
cocos2d::CCObject::autorelease((cocos2d::CCObject *)SavedLevel);
}
else
{
(*(void (__fastcall **)(char *))(*(_QWORD *)SavedLevel + 16LL))(SavedLevel);
SavedLevel = nullptr;
}
v24 = *begin;
*((_DWORD *)SavedLevel + 84) = *begin;
*(float *)&v2 = (float)((float)rand() * 4.6566129e-10) * 1000.0;
*((_DWORD *)SavedLevel + 83) = (int)*(float *)&v2;
*((_DWORD *)SavedLevel + 82) = (int)*(float *)&v2 + v24;
GameToolbox::intToString((size_t *)&__str, *begin, v2);
std::string::operator=((std::string *)(SavedLevel + 344), &__str);
if ( (*(_BYTE *)&__str.__r_.__value_.__s.0 & 1) != 0 )
operator delete(__str.__r_.__value_.__l.__data_);
}
}
*((_DWORD *)SavedLevel + 281) = v8;
sub_10071FCD0(v34, SavedLevel);
++v8;
++begin;
}
while ( begin != end );
LABEL_51:
v25 = v32[0];
if ( v32[0] )
{
do
{
v26 = (_QWORD *)*v25;
operator delete(v25);
v25 = v26;
}
while ( v26 );
}
v27 = v31[0];
v31[0] = nullptr;
if ( v27 )
operator delete(v27);
return v34;
}