//
// GameLevelManager::getNextLevelName from 0x81d390 to 0x81d870 (1248 bytes)
//
// 2 xrefs:
// > GJGameLevel::copyLevelInfo @ 0x82d19c
// > ??> @ 0xffac0
//
// 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:54:59 +0000
//
__int64 *__usercall GameLevelManager::getNextLevelName@(__int64 a1@, __int64 *a2@)
{
LocalLevelManager *v2; // x0
unsigned __int64 v4; // x5
int v5; // w4
unsigned __int64 v6; // x2
unsigned __int64 v7; // x3
unsigned __int64 v8; // x1
unsigned __int64 v9; // x22
unsigned __int64 v10; // x1
LocalLevelManager *v11; // x0
__int64 AllLevelsInDict; // x26
size_t v13; // x3
char *v14; // x0
int v15; // w25
int v16; // w28
cocos2d::CCString *v17; // x0
const char *v18; // x0
size_t v19; // x0
size_t v20; // x1
__int64 v21; // x3
char *v22; // x1
size_t v23; // x2
const char *v24; // x1
size_t v25; // x0
__int64 v26; // x1
__int64 v27; // x0
__int64 v28; // x1
void *v29; // x2
unsigned __int64 i; // x20
size_t v31; // x0
char *v32; // x1
size_t v33; // x2
char *v34; // x1
size_t v35; // x2
const char *v36; // x19
__int64 v37; // x1
cocos2d::CCString *v39; // x0
char *CString; // x0
__int64 v41; // x1
char v42; // w0
char *v44; // [xsp+78h] [xbp+78h]
char *v45; // [xsp+78h] [xbp+78h]
__int64 v46; // [xsp+78h] [xbp+78h]
__int64 v47[2]; // [xsp+88h] [xbp+88h] BYREF
char *v48; // [xsp+98h] [xbp+98h]
__int64 v49; // [xsp+A0h] [xbp+A0h] BYREF
size_t v50; // [xsp+A8h] [xbp+A8h]
void *v51; // [xsp+B0h] [xbp+B0h]
__int64 v52; // [xsp+B8h] [xbp+B8h] BYREF
__int64 v53; // [xsp+C0h] [xbp+C0h]
void *v54; // [xsp+C8h] [xbp+C8h]
__int64 v55; // [xsp+D0h] [xbp+D0h] BYREF
size_t v56; // [xsp+D8h] [xbp+D8h]
void *v57; // [xsp+E0h] [xbp+E0h]
v2 = nullptr;
v4 = *(_BYTE *)a1 >> 1;
v5 = *(_BYTE *)a1 & 1;
v6 = v4 - 1;
while ( 1 )
{
while ( 1 )
{
v9 = (int)v2;
if ( v5 )
break;
if ( (unsigned __int64)v2 >= v4 )
{
if ( !(_DWORD)v2 )
goto LABEL_52;
goto LABEL_10;
}
if ( v6 >= v4 )
LABEL_63:
sub_7FE970();
v10 = v6;
v2 = (LocalLevelManager *)((char *)v2 + 1);
--v6;
if ( (unsigned int)*(unsigned __int8 *)(a1 + 1 + v10) - 48 > 9 )
{
LABEL_9:
if ( (_DWORD)v9 )
goto LABEL_10;
if ( !v5 )
{
LABEL_52:
v36 = (const char *)(a1 + 1);
if ( strlen((const char *)(a1 + 1)) > 0x12 )
{
LABEL_53:
v37 = *(_QWORD *)(a1 + 8);
*a2 = *(_QWORD *)a1;
a2[1] = v37;
a2[2] = *(_QWORD *)(a1 + 16);
*(_QWORD *)a1 = 0;
*(_QWORD *)(a1 + 8) = 0;
*(_QWORD *)(a1 + 16) = 0;
return a2;
}
LABEL_57:
v39 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%s 2", v36);
CString = (char *)cocos2d::CCString::getCString(v39);
std::string::assign((__int64 *)a1, CString);
goto LABEL_53;
}
LABEL_56:
v36 = *(const char **)(a1 + 16);
if ( strlen(v36) > 0x12 )
goto LABEL_53;
goto LABEL_57;
}
}
v7 = *(_QWORD *)(a1 + 8);
if ( (unsigned __int64)v2 >= v7 )
break;
v8 = v7 - 1 - (_QWORD)v2;
if ( v7 <= v8 )
goto LABEL_63;
v2 = (LocalLevelManager *)((char *)v2 + 1);
--v6;
if ( (unsigned int)*(unsigned __int8 *)(*(_QWORD *)(a1 + 16) + v8) - 48 > 9 )
goto LABEL_9;
}
if ( !(_DWORD)v2 )
goto LABEL_56;
LABEL_10:
v11 = (LocalLevelManager *)LocalLevelManager::sharedState(v2);
AllLevelsInDict = LocalLevelManager::getAllLevelsInDict(v11);
if ( (*(_BYTE *)a1 & 1) != 0 )
v13 = *(_QWORD *)(a1 + 8);
else
v13 = *(_BYTE *)a1 >> 1;
std::string::basic_string(v47, a1, v13 - v9, v13);
v14 = (char *)v47 + 1;
if ( (v47[0] & 1) != 0 )
v14 = v48;
v15 = atoi(v14);
v16 = v15 + 1000;
while ( 1 )
{
v17 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i",
(const char *)(unsigned int)++v15);
v18 = (const char *)cocos2d::CCString::getCString(v17);
v49 = 0;
v50 = 0;
v51 = nullptr;
v44 = (char *)v18;
v19 = strlen(v18);
std::string::__init(&v49, v44, v19);
v20 = (unsigned __int8)v49 >> 1;
if ( (v49 & 1) != 0 )
v20 = v50;
if ( v20 < v9 )
{
v55 = 0;
v56 = 0;
v57 = nullptr;
std::string::__init(&v55, &byte_11B8890, 0);
for ( i = 0; ; ++i )
{
v31 = (unsigned __int8)v49 >> 1;
if ( (v49 & 1) != 0 )
v31 = v50;
if ( i >= v9 - v31 )
break;
std::string::append((__int64)&v55, "0", 1u);
}
if ( (v49 & 1) != 0 )
{
v32 = (char *)v51;
v33 = v50;
}
else
{
v33 = (unsigned __int8)v49 >> 1;
v32 = (char *)&v49 + 1;
}
std::string::append((__int64)&v55, v32, v33);
if ( (v55 & 1) != 0 )
{
v34 = (char *)v57;
v35 = v56;
}
else
{
v35 = (unsigned __int8)v55 >> 1;
v34 = (char *)&v55 + 1;
}
std::string::assign(&v49, v34, v35);
if ( (v55 & 1) != 0 )
operator delete(v57);
}
v21 = *(_BYTE *)a1 >> 1;
if ( (*(_BYTE *)a1 & 1) != 0 )
v21 = *(_QWORD *)(a1 + 8);
std::string::basic_string(&v52, a1, 0, v21 - v9);
if ( (v49 & 1) != 0 )
{
v22 = (char *)v51;
v23 = v50;
}
else
{
v23 = (unsigned __int8)v49 >> 1;
v22 = (char *)&v49 + 1;
}
std::string::append((__int64)&v52, v22, v23);
v24 = (char *)&v52 + 1;
if ( (v52 & 1) != 0 )
v24 = (const char *)v54;
v45 = (char *)v24;
v55 = 0;
v56 = 0;
v57 = nullptr;
v25 = strlen(v24);
std::string::__init(&v55, v45, v25);
v26 = cocos2d::CCDictionary::objectForKey(AllLevelsInDict, &v55);
if ( (v55 & 1) != 0 )
{
v46 = v26;
operator delete(v57);
if ( !v46 )
{
LABEL_32:
v27 = v52;
v28 = v53;
v52 = 0;
v29 = v54;
*a2 = v27;
a2[1] = v28;
LOBYTE(v27) = v52;
a2[2] = (__int64)v29;
v53 = 0;
v54 = nullptr;
if ( (v27 & 1) == 0 )
goto LABEL_33;
goto LABEL_61;
}
}
else if ( !v26 )
{
goto LABEL_32;
}
if ( v15 == v16 )
break;
if ( (v52 & 1) != 0 )
operator delete(v54);
if ( (v49 & 1) != 0 )
operator delete(v51);
}
v41 = *(_QWORD *)(a1 + 8);
*a2 = *(_QWORD *)a1;
a2[1] = v41;
a2[2] = *(_QWORD *)(a1 + 16);
v42 = v52;
*(_QWORD *)a1 = 0;
*(_QWORD *)(a1 + 8) = 0;
*(_QWORD *)(a1 + 16) = 0;
if ( (v42 & 1) == 0 )
{
LABEL_33:
if ( (v49 & 1) == 0 )
goto LABEL_34;
goto LABEL_62;
}
LABEL_61:
operator delete(v54);
if ( (v49 & 1) == 0 )
goto LABEL_34;
LABEL_62:
operator delete(v51);
LABEL_34:
if ( (v47[0] & 1) != 0 )
operator delete(v48);
return a2;
}