//
// GJLevelList::getListLevelsArray from 0x730c7c to 0x7311ac (1328 bytes)
//
// 3 xrefs:
// > GJLevelList::duplicateListLevels @ 0x736704
// > LevelListLayer::updateResultArray @ 0xa72178
// > ??> @ 0x38820
//
// 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 *GJLevelList::getListLevelsArray(GJLevelList *a1, cocos2d::CCArray *a2)
{
unsigned __int64 v4; // x0
__int64 *v5; // x20
__int64 num; // x0
cocos2d::ccArray *data; // x1
__int64 v8; // x0
int *m_finish; // x28
cocos2d::CCArray *v10; // x27
int *m_start; // x19
int v12; // w21
int v13; // w6
unsigned __int64 v14; // x22
unsigned __int64 v15; // x20
__int64 **v16; // x0
__int64 *v17; // x1
int v18; // w0
__int64 v19; // x5
GameLevelManager *v20; // x0
__int64 SavedLevel; // x22
cocos2d::CCDictionary *v22; // x20
cocos2d::CCObject *v23; // x20
GJGameLevel *v24; // x0
_QWORD *v26; // x0
__int64 v27; // x1
GJGameLevel **v28; // x0
GJGameLevel *v29; // x20
cocos2d::CCDictionary *m_levelsDict; // x24
GJGameLevel *ListSnapshot; // x22
void *v32; // x0
unsigned int *v33; // x2
int v34; // w1
unsigned int *v35; // x1
int v36; // w2
__int64 v37; // x0
int v38; // w22
float v39; // s0
void *v40; // x0
unsigned int *v41; // x22
int v42; // w1
__int64 v43; // x0
int v44; // w6
cocos2d::CCObject **arr; // x22
char *v46; // x24
cocos2d::CCObject *i; // x20
int v48; // w19
unsigned __int64 v49; // x21
__int64 *v50; // x0
__int64 v51; // x1
__int64 v52; // x0
__int64 v53; // [xsp+70h] [xbp+70h]
__int64 v54; // [xsp+88h] [xbp+88h] BYREF
std::string v55; // [xsp+90h] [xbp+90h] BYREF
__int64 v56; // [xsp+98h] [xbp+98h] BYREF
char *v57; // [xsp+A0h] [xbp+A0h] BYREF
unsigned __int64 v58; // [xsp+A8h] [xbp+A8h]
__int64 v59; // [xsp+B0h] [xbp+B0h]
__int64 v60; // [xsp+B8h] [xbp+B8h]
float v61; // [xsp+C0h] [xbp+C0h] BYREF
__int64 v62; // [xsp+C8h] [xbp+C8h]
__int64 v63; // [xsp+D0h] [xbp+D0h] BYREF
v59 = 0;
v60 = 0;
v61 = 1.0;
v62 = 0;
v4 = sub_D146DC(&v61, 10);
v58 = v4;
if ( v4 == 1 )
{
num = (__int64)&v57;
v63 = 0;
v5 = &v63;
}
else
{
if ( v4 > 0x1FFFFFFFFFFFFFFFLL )
sub_D1383C();
v53 = 8 * v4;
v5 = (__int64 *)operator new(8 * v4);
num = (__int64)memset(v5, 0, v53);
}
v57 = (char *)v5;
if ( a2 )
{
data = a2->data;
num = data->num;
if ( (_DWORD)num )
{
arr = data->arr;
num = 8LL * (unsigned int)num - 8;
v46 = (char *)arr + num;
if ( arr <= (cocos2d::CCObject **)((char *)arr + num) )
{
for ( i = *arr; *arr; i = *arr )
{
v48 = i[5].m_uOrderOfArrival - i[5].m_unknown5;
LODWORD(v56) = v48;
v49 = v48 % v58;
v50 = sub_6EE264(&v57, v49, (int *)&v56);
if ( !v50 || (v51 = *v50, num = *v50 + 16, !v51) )
{
v52 = operator new(0x18u);
*(_QWORD *)v52 = 0;
*(_DWORD *)(v52 + 8) = v48;
*(_QWORD *)(v52 + 16) = 0;
num = (__int64)(std::_Hashtable,std::allocator>,std::__detail::_Select1st,std::equal_to,std::hash,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits>::_M_insert_unique_node(
&v57,
v49,
v48,
(char *)v52)
+ 16);
}
++arr;
*(_QWORD *)num = i;
if ( v46 < (char *)arr )
break;
}
}
}
}
v8 = cocos2d::CCArray::create((cocos2d::CCArray *)num);
m_finish = a1->m_levels.m_finish;
v10 = (cocos2d::CCArray *)v8;
m_start = a1->m_levels.m_start;
v12 = 1;
if ( m_start == m_finish )
goto LABEL_21;
do
{
v13 = *m_start;
v14 = *m_start;
v15 = v14 % v58;
v16 = *(__int64 ***)&v57[8 * (v14 % v58)];
if ( !v16 )
goto LABEL_16;
v17 = *v16;
if ( !*v16 )
goto LABEL_16;
v18 = *((_DWORD *)v17 + 2);
v19 = 0;
while ( v18 == v13 )
{
v17 = (__int64 *)*v17;
++v19;
if ( !v17 )
goto LABEL_15;
LABEL_12:
v18 = *((_DWORD *)v17 + 2);
if ( v15 != v18 % v58 )
goto LABEL_15;
}
if ( v19 )
goto LABEL_22;
v17 = (__int64 *)*v17;
if ( v17 )
goto LABEL_12;
LABEL_15:
if ( !v19 )
goto LABEL_16;
LABEL_22:
v26 = sub_6EE264(&v57, v13 % v58, m_start);
if ( !v26 || (v27 = *v26, v28 = (GJGameLevel **)(*v26 + 16LL), !v27) )
{
v43 = operator new(0x18u);
v44 = *m_start;
*(_QWORD *)v43 = 0;
*(_DWORD *)(v43 + 8) = v44;
*(_QWORD *)(v43 + 16) = 0;
v28 = (GJGameLevel **)(std::_Hashtable,std::allocator>,std::__detail::_Select1st,std::equal_to,std::hash,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits>::_M_insert_unique_node(
&v57,
v15,
v14,
(char *)v43)
+ 16);
}
v29 = *v28;
m_levelsDict = a1->m_levelsDict;
ListSnapshot = GJGameLevel::getListSnapshot(*v28);
GameToolbox::intToString(&v54, (GameToolbox *)(unsigned int)(v29->m_levelID.random - v29->m_levelID.seed));
cocos2d::CCDictionary::setObject((int)m_levelsDict, ListSnapshot);
v32 = (void *)(v54 - 24);
if ( (__int64 *)(v54 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v33 = (unsigned int *)(v54 - 8);
do
v34 = __ldaxr(v33);
while ( __stlxr(v34 - 1, v33) );
}
else
{
v34 = *(_DWORD *)(v54 - 8);
*(_DWORD *)(v54 - 8) = v34 - 1;
}
if ( v34 <= 0 )
operator delete(v32);
}
LABEL_16:
v20 = GameLevelManager::sharedState();
SavedLevel = GameLevelManager::getSavedLevel(v20, *m_start);
v22 = a1->m_levelsDict;
GameToolbox::intToString((__int64 *)&v55, (GameToolbox *)(unsigned int)*m_start);
v23 = (cocos2d::CCObject *)cocos2d::CCDictionary::objectForKey(v22, &v55);
v24 = (GJGameLevel *)((char *)v55.m_data.m_data - 24);
if ( (__int64 *)v55.m_data.m_data - 3 == &qword_124B6B0 )
goto LABEL_17;
if ( &pthread_create )
{
v35 = (unsigned int *)((char *)v55.m_data.m_data - 8);
do
v36 = __ldaxr(v35);
while ( __stlxr(v36 - 1, v35) );
}
else
{
v36 = *((_DWORD *)v55.m_data.m_data - 2);
*((_DWORD *)v55.m_data.m_data - 2) = v36 - 1;
}
if ( v36 > 0 )
{
LABEL_17:
if ( SavedLevel )
goto LABEL_18;
LABEL_35:
if ( !v23 )
{
v37 = GJGameLevel::create(v24);
v38 = *m_start;
v23 = (cocos2d::CCObject *)v37;
*(_DWORD *)(v37 + 336) = *m_start;
v39 = (float)((float)rand() * 4.6566e-10) * 1000.0;
v23[5].m_unknown5 = (int)v39;
v23[5].m_uOrderOfArrival = v38 + (int)v39;
GameToolbox::intToString(&v56, (GameToolbox *)(unsigned int)*m_start);
sub_D18EA8(&v23[6].m_uID, &v56);
v40 = (void *)(v56 - 24);
if ( (__int64 *)(v56 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v41 = (unsigned int *)(v56 - 8);
do
v42 = __ldaxr(v41);
while ( __stlxr(v42 - 1, v41) );
}
else
{
v42 = *(_DWORD *)(v56 - 8);
*(_DWORD *)(v56 - 8) = v42 - 1;
}
if ( v42 <= 0 )
operator delete(v40);
}
}
}
else
{
operator delete(v24);
if ( !SavedLevel )
goto LABEL_35;
LABEL_18:
if ( *(_BYTE *)(SavedLevel + 833) )
{
if ( !v23 )
v23 = (cocos2d::CCObject *)SavedLevel;
}
else
{
v23 = (cocos2d::CCObject *)SavedLevel;
}
}
v23[16].m_uReference = v12++;
cocos2d::CCArray::addObject(v10, v23);
++m_start;
}
while ( m_finish != m_start );
LABEL_21:
std::_Hashtable,std::allocator>,std::__detail::_Select1st,std::equal_to,std::hash,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits>::~_Hashtable((__int64)&v57);
return v10;
}