//
// GameLevelManager::getNextLevelName from 0x6f087c to 0x6f0ea0 (1572 bytes)
//
// 2 xrefs:
// > GJGameLevel::copyLevelInfo @ 0x70ba64
// > ??> @ 0x89e68
//
// 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
//
const char **__usercall GameLevelManager::getNextLevelName@(const char **a1@, const char **a2@)
{
const char *v2; // x23
__int64 v4; // x2
unsigned __int64 v5; // x19
unsigned __int64 v6; // x21
int v7; // w22
unsigned __int64 v8; // x2
LocalLevelManager *v9; // x0
cocos2d::CCDictionary *AllLevelsInDict; // x28
unsigned __int64 v11; // x3
unsigned __int64 v12; // x2
int v13; // w25
cocos2d::CCString *v14; // x0
char *CString; // x0
unsigned __int64 v16; // x19
char *v17; // x0
__int64 v18; // x19
char *v19; // x0
char *v20; // x0
void *v21; // x0
unsigned int *v22; // x1
int v23; // w2
unsigned int *v24; // x1
int v25; // w2
char *v26; // x1
char *v27; // x0
void *v28; // x0
char *v29; // x0
unsigned int *v30; // x19
int v31; // w1
unsigned int *v32; // x1
int v33; // w2
unsigned int *v34; // x1
int v35; // w2
size_t v36; // x0
const char *v37; // x1
cocos2d::CCString *v39; // x0
size_t v40; // x0
unsigned int *v41; // x1
int v42; // w2
unsigned int *v43; // x1
int v44; // w2
__int64 v45; // [xsp+0h] [xbp+0h] BYREF
const char **v46; // [xsp+60h] [xbp+60h]
char *v47; // [xsp+68h] [xbp+68h]
int v48; // [xsp+74h] [xbp+74h]
char *v49; // [xsp+78h] [xbp+78h]
char v50; // [xsp+88h] [xbp+88h] BYREF
char *v51; // [xsp+98h] [xbp+98h] BYREF
__int64 v52; // [xsp+A0h] [xbp+A0h] BYREF
char *v53; // [xsp+A8h] [xbp+A8h] BYREF
std::string v54; // [xsp+B0h] [xbp+B0h] BYREF
v2 = *a1;
v4 = *((_QWORD *)*a1 - 3);
v46 = a2;
if ( !v4 )
goto LABEL_54;
v5 = v4 - 1;
v6 = 1;
v7 = 0;
while ( 1 )
{
if ( (*((_DWORD *)v2 - 2) & 0x80000000) == 0 )
{
sub_D176A8(a1);
v2 = *a1;
}
if ( (unsigned int)(unsigned __int8)v2[v5] - 48 > 9 )
break;
v8 = *((_QWORD *)v2 - 3);
++v7;
if ( v6 >= v8 )
{
v7 = v6;
break;
}
v5 = v8 - 1 - v6++;
if ( v5 >= v8 )
sub_D13C5C("basic_string::at: __n (which is %zu) >= this->size() (which is %zu)", v5, v8);
}
if ( v7 )
{
v9 = LocalLevelManager::sharedState();
AllLevelsInDict = LocalLevelManager::getAllLevelsInDict(v9);
v11 = *((_QWORD *)*a1 - 3);
v12 = v11 - v7;
if ( v12 > v11 )
sub_D13C5C("%s: __pos (which is %zu) > this->size() (which is %zu)", "basic_string::substr", v12, v11);
sub_D14F84(&v51, a1, v12, v11);
v49 = &v50;
v13 = atoi(v51);
v48 = v13 + 1000;
v47 = &byte_F288A0;
while ( 1 )
{
v14 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i",
(const char *)(unsigned int)++v13);
CString = (char *)cocos2d::CCString::getCString(v14);
sub_D153B8((unsigned int)&v45 + 160, CString);
if ( (unsigned __int64)v7 > *(_QWORD *)(v52 - 24) )
{
sub_D153B8((int)&v54, v47);
v16 = 1;
if ( v7 != *(_QWORD *)(v52 - 24) )
{
while ( 1 )
{
sub_D15FD4(&v54, "0", 1);
if ( v16 >= v7 - *(_QWORD *)(v52 - 24) )
break;
++v16;
}
}
sub_D15E14(&v54, &v52);
sub_D18EA8(&v52, &v54);
v17 = (char *)v54.m_data.m_data - 24;
if ( (__int64 *)v54.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v34 = (unsigned int *)((char *)v54.m_data.m_data - 8);
do
v35 = __ldaxr(v34);
while ( __stlxr(v35 - 1, v34) );
}
else
{
v35 = *((_DWORD *)v54.m_data.m_data - 2);
*((_DWORD *)v54.m_data.m_data - 2) = v35 - 1;
}
if ( v35 <= 0 )
operator delete(v17);
}
}
sub_D14F84(&v53, a1, 0, *((_QWORD *)*a1 - 3) - v7);
sub_D15E14(&v53, &v52);
sub_D153B8((int)&v54, v53);
v18 = cocos2d::CCDictionary::objectForKey(AllLevelsInDict, &v54);
v19 = (char *)v54.m_data.m_data - 24;
if ( (__int64 *)v54.m_data.m_data - 3 == &qword_124B6B0 )
goto LABEL_18;
if ( &pthread_create )
{
v24 = (unsigned int *)((char *)v54.m_data.m_data - 8);
do
v25 = __ldaxr(v24);
while ( __stlxr(v25 - 1, v24) );
}
else
{
v25 = *((_DWORD *)v54.m_data.m_data - 2);
*((_DWORD *)v54.m_data.m_data - 2) = v25 - 1;
}
if ( v25 > 0 )
{
LABEL_18:
if ( !v18 )
goto LABEL_32;
}
else
{
operator delete(v19);
if ( !v18 )
{
LABEL_32:
*v46 = v53;
v26 = &byte_124B6C8;
v53 = &byte_124B6C8;
goto LABEL_33;
}
}
if ( v13 == v48 )
break;
v20 = v53 - 24;
if ( v53 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v32 = (unsigned int *)(v53 - 8);
do
v33 = __ldaxr(v32);
while ( __stlxr(v33 - 1, v32) );
}
else
{
v33 = *((_DWORD *)v53 - 2);
*((_DWORD *)v53 - 2) = v33 - 1;
}
if ( v33 <= 0 )
operator delete(v20);
}
v21 = (void *)(v52 - 24);
if ( (__int64 *)(v52 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v22 = (unsigned int *)(v52 - 8);
do
v23 = __ldaxr(v22);
while ( __stlxr(v23 - 1, v22) );
}
else
{
v23 = *(_DWORD *)(v52 - 8);
*(_DWORD *)(v52 - 8) = v23 - 1;
}
if ( v23 <= 0 )
operator delete(v21);
}
}
*v46 = *a1;
v26 = v53;
*a1 = &byte_124B6C8;
LABEL_33:
v27 = v26 - 24;
if ( v26 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v43 = (unsigned int *)(v26 - 8);
do
v44 = __ldaxr(v43);
while ( __stlxr(v44 - 1, v43) );
}
else
{
v44 = *((_DWORD *)v26 - 2);
*((_DWORD *)v26 - 2) = v44 - 1;
}
if ( v44 <= 0 )
operator delete(v27);
}
v28 = (void *)(v52 - 24);
if ( (__int64 *)(v52 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v41 = (unsigned int *)(v52 - 8);
do
v42 = __ldaxr(v41);
while ( __stlxr(v42 - 1, v41) );
}
else
{
v42 = *(_DWORD *)(v52 - 8);
*(_DWORD *)(v52 - 8) = v42 - 1;
}
if ( v42 <= 0 )
operator delete(v28);
}
v29 = v51 - 24;
if ( v51 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v30 = (unsigned int *)(v51 - 8);
do
v31 = __ldaxr(v30);
while ( __stlxr(v31 - 1, v30) );
}
else
{
v31 = *((_DWORD *)v51 - 2);
*((_DWORD *)v51 - 2) = v31 - 1;
}
if ( v31 <= 0 )
operator delete(v29);
}
}
else
{
LABEL_54:
v36 = strlen(v2);
v37 = v2;
if ( v36 <= 0x12 )
{
v39 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%s 2", v2);
v49 = (char *)cocos2d::CCString::getCString(v39);
v40 = strlen(v49);
sub_D1798C(a1, v49, v40);
v37 = *a1;
}
*v46 = v37;
*a1 = &byte_124B6C8;
}
return v46;
}