//
// GameLevelManager::getNextLevelName from 0x4bbbf0 to 0x4bbea6 (694 bytes)
//
// 1 xrefs:
// > GJGameLevel::copyLevelInfo @ 0x4c0ad4
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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 11:50:17 +0000
//
int *__fastcall GameLevelManager::getNextLevelName(int *a1, int a2, unsigned __int8 *a3)
{
int v4; // r11
int v6; // r8
unsigned int v7; // r7
unsigned int i; // r5
unsigned int v9; // r2
unsigned int v10; // r3
unsigned __int8 *v11; // r2
LocalLevelManager *v12; // r0
int AllLevelsInDict; // r0
int v14; // r3
int v15; // r2
unsigned int v16; // r2
size_t v17; // r3
const char *v18; // r0
int v19; // r0
int v20; // r8
cocos2d::CCString *v21; // r0
const char *v22; // r7
size_t v23; // r0
unsigned int v24; // r3
unsigned int j; // r11
int v26; // r3
char *v27; // r1
size_t v28; // r2
int v29; // r3
int v30; // r3
char *v31; // r1
size_t v32; // r2
char *v33; // r1
size_t v34; // r0
int v35; // r0
int v36; // r1
char *v37; // r2
int v38; // r1
int v39; // r2
const char *v40; // r0
cocos2d::CCString *v41; // r0
char *CString; // r0
int v43; // r1
int v44; // r2
int v46; // [sp+Ch] [bp-58h]
int v47; // [sp+10h] [bp-54h]
char *v48; // [sp+24h] [bp-40h]
int v49; // [sp+24h] [bp-40h]
int v50[3]; // [sp+2Ch] [bp-38h] BYREF
int v51; // [sp+38h] [bp-2Ch] BYREF
int v52; // [sp+3Ch] [bp-28h]
char *v53; // [sp+40h] [bp-24h]
int v54; // [sp+44h] [bp-20h] BYREF
int v55; // [sp+48h] [bp-1Ch]
char *v56; // [sp+4Ch] [bp-18h]
int v57; // [sp+50h] [bp-14h] BYREF
int v58; // [sp+54h] [bp-10h]
int v59; // [sp+58h] [bp-Ch]
v4 = *a3;
v6 = v4 & 1;
v7 = v4 >> 1;
for ( i = 0; ; ++i )
{
if ( (v4 & 1) != 0 )
{
v9 = *((_DWORD *)a3 + 1);
if ( i >= v9 )
{
if ( !i )
goto LABEL_57;
goto LABEL_18;
}
}
else
{
if ( i >= v7 )
{
if ( !i )
goto LABEL_59;
goto LABEL_18;
}
v9 = v4 >> 1;
}
v10 = ~i + v9;
if ( (v4 & 1) != 0 )
{
if ( v10 >= *((_DWORD *)a3 + 1) )
goto LABEL_8;
v11 = *((unsigned __int8 **)a3 + 2);
}
else
{
if ( v10 >= v7 )
LABEL_8:
sub_387F30();
v11 = a3 + 1;
}
if ( (unsigned int)v11[v10] - 48 > 9 )
break;
}
if ( !i )
{
if ( (v4 & 1) != 0 )
{
LABEL_57:
v40 = *((const char **)a3 + 2);
LABEL_60:
if ( strlen(v40) <= 0x12 )
{
if ( v6 )
v41 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%s 2",
*((const char **)a3 + 2));
else
v41 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%s 2",
(const char *)a3 + 1);
CString = (char *)cocos2d::CCString::getCString(v41);
std::string::assign((int *)a3, CString);
}
v43 = *((_DWORD *)a3 + 1);
v44 = *((_DWORD *)a3 + 2);
*a1 = *(_DWORD *)a3;
a1[1] = v43;
a1[2] = v44;
*(_DWORD *)a3 = 0;
*((_DWORD *)a3 + 1) = 0;
*((_DWORD *)a3 + 2) = 0;
return a1;
}
LABEL_59:
v40 = (const char *)(a3 + 1);
v6 = 0;
goto LABEL_60;
}
LABEL_18:
v12 = (LocalLevelManager *)LocalLevelManager::sharedState((LocalLevelManager *)a1);
AllLevelsInDict = LocalLevelManager::getAllLevelsInDict(v12);
v14 = *a3;
if ( (v14 & 1) != 0 )
v15 = *((_DWORD *)a3 + 1);
else
v15 = v14 >> 1;
v46 = AllLevelsInDict;
v16 = v15 - i;
if ( (v14 & 1) != 0 )
v17 = *((_DWORD *)a3 + 1);
else
v17 = v14 >> 1;
std::string::basic_string(v50, a3, v16, v17);
if ( (v50[0] & 1) != 0 )
v18 = (const char *)v50[2];
else
v18 = (char *)v50 + 1;
v19 = atoi(v18);
v47 = v19 + 1000;
v20 = v19;
while ( 1 )
{
v21 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", (const char *)++v20);
v22 = (const char *)cocos2d::CCString::getCString(v21);
v51 = 0;
v52 = 0;
v53 = nullptr;
v23 = strlen(v22);
std::string::__init(&v51, v22, v23);
if ( (v51 & 1) != 0 )
v24 = v52;
else
v24 = (int)(unsigned __int8)v51 >> 1;
if ( v24 < i )
{
v57 = 0;
v58 = 0;
v59 = 0;
std::string::__init(&v57, &unk_B6B226, 0);
for ( j = 0; ; ++j )
{
v26 = (v51 & 1) != 0 ? v52 : (int)(unsigned __int8)v51 >> 1;
if ( j >= i - v26 )
break;
std::string::append(&v57, "0");
}
if ( (v51 & 1) != 0 )
{
v27 = v53;
v28 = v52;
}
else
{
v28 = (int)(unsigned __int8)v51 >> 1;
v27 = (char *)&v51 + 1;
}
std::string::append(&v57, v27, v28);
std::string::operator=((unsigned __int8 *)&v51, (unsigned __int8 *)&v57);
std::string::~string((int)&v57);
}
v29 = *a3;
if ( (v29 & 1) != 0 )
v30 = *((_DWORD *)a3 + 1);
else
v30 = v29 >> 1;
std::string::basic_string(&v54, a3, 0, v30 - i);
if ( (v51 & 1) != 0 )
{
v31 = v53;
v32 = v52;
}
else
{
v32 = (int)(unsigned __int8)v51 >> 1;
v31 = (char *)&v51 + 1;
}
std::string::append(&v54, v31, v32);
if ( (v54 & 1) == 0 )
v33 = (char *)&v54 + 1;
v57 = 0;
if ( (v54 & 1) != 0 )
v33 = v56;
v58 = 0;
v59 = 0;
v48 = v33;
v34 = strlen(v33);
std::string::__init(&v57, v48, v34);
v49 = cocos2d::CCDictionary::objectForKey(v46, &v57);
std::string::~string((int)&v57);
if ( !v49 )
{
v35 = v54;
v36 = v55;
v37 = v56;
v54 = 0;
v55 = 0;
v56 = nullptr;
*a1 = v35;
a1[1] = v36;
a1[2] = (int)v37;
goto LABEL_55;
}
if ( v20 == v47 )
break;
std::string::~string((int)&v54);
std::string::~string((int)&v51);
}
v38 = *((_DWORD *)a3 + 1);
v39 = *((_DWORD *)a3 + 2);
*a1 = *(_DWORD *)a3;
a1[1] = v38;
a1[2] = v39;
*(_DWORD *)a3 = 0;
*((_DWORD *)a3 + 1) = 0;
*((_DWORD *)a3 + 2) = 0;
LABEL_55:
std::string::~string((int)&v54);
std::string::~string((int)&v51);
std::string::~string((int)v50);
return a1;
}