//
// GJLevelList::getListLevelsArray from 0x140177170 to 0x140177753 (1507 bytes)
//
// 3 xrefs:
// > LevelListLayer::updateResultArray @ 0x140307127
// > LevelListLayer::cloneList @ 0x140308333
// > ??> @ 0x1406cafd4
//
// 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
//
// Hidden C++ exception states: #wind=9
cocos2d::CCArray *GJLevelList::getListLevelsArray(GJLevelList *a1, cocos2d::CCArray *a2)
{
_QWORD *v4; // rdi
_QWORD *v5; // rbx
__int64 v6; // rcx
_QWORD *v7; // rax
cocos2d::ccArray *data; // rdi
__int64 num; // rax
cocos2d::CCObject **arr; // rdi
cocos2d::CCObject **i; // rsi
cocos2d::CCObject *v12; // rbx
__int64 v13; // rax
cocos2d::CCArray *v14; // r12
int v15; // r15d
unsigned __int8 *Myfirst; // r14
__int64 v17; // rcx
GJGameLevel *v18; // rdi
unsigned int v19; // ebx
_BYTE *v20; // rax
size_t v21; // r8
GJGameLevel *ListSnapshot; // rax
void *v23; // rcx
GameLevelManager *v24; // rcx
GJGameLevel *SavedLevel; // rdi
unsigned int v26; // ebx
_BYTE *v27; // rax
size_t v28; // r8
__int64 v29; // rbx
void *v30; // rcx
GJGameLevel *v31; // rax
int v32; // ebx
float v33; // xmm0_4
unsigned int v34; // ebx
_BYTE *v35; // rax
size_t v36; // r8
_QWORD *v37; // rdx
_QWORD Src[3]; // [rsp+28h] [rbp-E0h] BYREF
size_t Size; // [rsp+40h] [rbp-C8h]
unsigned __int64 v41; // [rsp+48h] [rbp-C0h]
__int64 v42; // [rsp+58h] [rbp-B0h] BYREF
void *v43[2]; // [rsp+60h] [rbp-A8h] BYREF
void *Block[2]; // [rsp+70h] [rbp-98h] BYREF
_QWORD *v45; // [rsp+80h] [rbp-88h]
__int64 v46; // [rsp+88h] [rbp-80h]
__int64 v47; // [rsp+90h] [rbp-78h]
_QWORD *v48; // [rsp+98h] [rbp-70h] BYREF
void *v49; // [rsp+A8h] [rbp-60h]
GJGameLevel *v50; // [rsp+B0h] [rbp-58h]
char v51[16]; // [rsp+B8h] [rbp-50h] BYREF
__int128 v52; // [rsp+C8h] [rbp-40h] BYREF
__int64 v53; // [rsp+D8h] [rbp-30h]
unsigned __int64 v54; // [rsp+E0h] [rbp-28h]
__int128 v55; // [rsp+E8h] [rbp-20h] BYREF
__int64 v56; // [rsp+F8h] [rbp-10h]
unsigned __int64 v57; // [rsp+100h] [rbp-8h]
_BYTE v58[528]; // [rsp+108h] [rbp+0h] BYREF
v43[1] = nullptr;
v4 = operator new(0x20u);
*v4 = v4;
v4[1] = v4;
v43[0] = v4;
v46 = 7;
v47 = 8;
LODWORD(v42) = 1065353216;
v5 = operator new(0x80u);
v6 = 0;
Block[0] = v5;
v7 = v5 + 16;
Block[1] = v5 + 16;
v45 = v5 + 16;
do
*v5++ = v4;
while ( v5 != v7 );
if ( a2 )
{
data = a2->data;
num = data->num;
if ( (_DWORD)num )
{
arr = data->arr;
for ( i = &arr[num - 1]; arr <= i; ++arr )
{
v12 = *arr;
if ( !*arr )
break;
LODWORD(Src[0]) = v12[5].m_uOrderOfArrival - v12[5].m_unknown5;
v13 = sub_140178FC0(&v42, &v48, Src);
v6 = *(_QWORD *)v13;
*(_QWORD *)(*(_QWORD *)v13 + 24LL) = v12;
}
}
}
v14 = (cocos2d::CCArray *)cocos2d::CCArray::create(v6);
v15 = 1;
Myfirst = (unsigned __int8 *)a1->m_levels._Mypair._Myval2._Myfirst;
Src[0] = a1->m_levels._Mypair._Myval2._Mylast;
if ( Myfirst != (unsigned __int8 *)Src[0] )
{
while ( 1 )
{
v17 = *((_QWORD *)Block[0]
+ 2
* ((0x100000001B3LL
* (Myfirst[3]
^ (0x100000001B3LL
* (Myfirst[2] ^ (0x100000001B3LL * (Myfirst[1] ^ (0x100000001B3LL * (*Myfirst ^ 0xCBF29CE484222325uLL))))))))
& v46)
+ 1);
if ( (void *)v17 == v43[0] )
goto LABEL_14;
if ( *(_DWORD *)Myfirst != *(_DWORD *)(v17 + 16) )
break;
LABEL_15:
if ( v17 )
{
v18 = *(GJGameLevel **)(*(_QWORD *)sub_140060FD0((__int64)&v42, (__int64)v51, Myfirst) + 24LL);
v19 = v18->m_levelID.random - v18->m_levelID.seed;
fmt::BasicWriter::BasicWriter(v58);
fmt::BasicWriter::operator<<(v58, v19);
v20 = (_BYTE *)fmt::BasicWriter::c_str(v58);
v52 = 0;
v53 = 0;
v54 = 0;
v21 = -1;
do
++v21;
while ( v20[v21] );
sub_14003A930(&v52, v20, v21);
fmt::BasicWriter::~BasicWriter(v58);
ListSnapshot = GJGameLevel::getListSnapshot(v18);
cocos2d::CCDictionary::setObject(a1->m_levelsDict, ListSnapshot, &v52);
if ( v54 > 0xF )
{
v23 = (void *)v52;
if ( v54 + 1 >= 0x1000 )
{
v23 = *(void **)(v52 - 8);
if ( (unsigned __int64)(v52 - (_QWORD)v23 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v23);
}
v53 = 0;
v54 = 15;
LOBYTE(v52) = 0;
}
v24 = (GameLevelManager *)qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v49 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v49);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v24 = (GameLevelManager *)qword_1406C2EC0;
}
SavedLevel = GameLevelManager::getSavedLevel(v24, *(_DWORD *)Myfirst);
v26 = *(_DWORD *)Myfirst;
fmt::BasicWriter::BasicWriter(v58);
fmt::BasicWriter::operator<<(v58, v26);
v27 = (_BYTE *)fmt::BasicWriter::c_str(v58);
v55 = 0;
v56 = 0;
v57 = 0;
v28 = -1;
do
++v28;
while ( v27[v28] );
sub_14003A930(&v55, v27, v28);
fmt::BasicWriter::~BasicWriter(v58);
v29 = cocos2d::CCDictionary::objectForKey(a1->m_levelsDict, &v55);
if ( v57 > 0xF )
{
v30 = (void *)v55;
if ( v57 + 1 >= 0x1000 )
{
v30 = *(void **)(v55 - 8);
if ( (unsigned __int64)(v55 - (_QWORD)v30 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v30);
}
v56 = 0;
v57 = 15;
LOBYTE(v55) = 0;
if ( !SavedLevel || SavedLevel->m_levelNotDownloaded )
{
if ( v29 )
{
SavedLevel = (GJGameLevel *)v29;
}
else if ( !SavedLevel )
{
v50 = (GJGameLevel *)operator new(0x5C8u);
v31 = GJGameLevel::GJGameLevel(v50);
SavedLevel = v31;
if ( v31 )
{
if ( v31->init(v31) )
{
cocos2d::CCObject::autorelease(SavedLevel);
}
else
{
((void (__fastcall *)(GJGameLevel *, __int64))SavedLevel->~GJGameLevel)(SavedLevel, 1);
SavedLevel = nullptr;
}
}
v32 = *(_DWORD *)Myfirst;
SavedLevel->m_levelID.value = *(_DWORD *)Myfirst;
v33 = (float)((float)rand() / 32767.0) * 1000.0;
SavedLevel->m_levelID.seed = (int)v33;
SavedLevel->m_levelID.random = v32 + (int)v33;
v34 = *(_DWORD *)Myfirst;
fmt::BasicWriter::BasicWriter(v58);
fmt::BasicWriter::operator<<(v58, v34);
v35 = (_BYTE *)fmt::BasicWriter::c_str(v58);
*(_OWORD *)&Src[1] = 0;
Size = 0;
v41 = 0;
v36 = -1;
do
++v36;
while ( v35[v36] );
sub_14003A930(&Src[1], v35, v36);
fmt::BasicWriter::~BasicWriter(v58);
v48 = &Src[1];
if ( &SavedLevel->m_levelName != (std::string *)&Src[1] )
{
v37 = &Src[1];
if ( v41 > 0xF )
v37 = (_QWORD *)Src[1];
sub_14003CCE0((void **)&SavedLevel->m_levelName, v37, Size);
}
sub_14003A830((__int64)&Src[1]);
}
}
SavedLevel->m_listPosition = v15++;
cocos2d::CCArray::addObject(v14, SavedLevel);
Myfirst += 4;
if ( Myfirst == (unsigned __int8 *)Src[0] )
goto LABEL_48;
}
while ( v17 != *((_QWORD *)Block[0]
+ 2
* ((0x100000001B3LL
* (Myfirst[3]
^ (0x100000001B3LL
* (Myfirst[2]
^ (0x100000001B3LL * (Myfirst[1] ^ (0x100000001B3LL * (*Myfirst ^ 0xCBF29CE484222325uLL))))))))
& v46)) )
{
v17 = *(_QWORD *)(v17 + 8);
if ( *(_DWORD *)Myfirst == *(_DWORD *)(v17 + 16) )
goto LABEL_15;
}
LABEL_14:
v17 = 0;
goto LABEL_15;
}
LABEL_48:
sub_14005D100((__int64)Block);
sub_14005D350(v43);
return v14;
}