//
// GameLevelManager::getNextLevelName from 0x10052c8f0 to 0x10052cecd (1501 bytes)
//
// 1 xrefs:
// > GJGameLevel::copyLevelInfo @ 0x10055d101
//
// 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
//
std::string *__fastcall GameLevelManager::getNextLevelName(std::string *a1, double a2, __int64 a3, std::string *a4)
{
__int64 v5; // rbx
char v6; // r14
std::string::size_type v7; // r15
unsigned int v8; // esi
std::string::size_type i; // rsi
__int64 v10; // rax
LocalLevelManager *v11; // rax
unsigned int v12; // ebx
__int64 v13; // rbx
char *v14; // rbx
size_t v15; // r12
char *v16; // r14
unsigned __int64 size; // rbx
const char *v18; // rdi
int v19; // esi
cocos2d::CCString *v20; // rax
const char *v21; // r14
size_t v22; // rax
std::string::size_type v23; // r13
char *data; // r12
unsigned int v25; // eax
unsigned __int64 v26; // rax
size_t v27; // rbx
std::string *v28; // r14
std::string::size_type v29; // rbx
std::string::size_type v30; // rdx
const std::string::value_type *v31; // rsi
unsigned int v32; // eax
unsigned __int64 v33; // rax
std::string::pointer v34; // r14
std::string::size_type v35; // r13
char *v36; // r12
unsigned int v37; // edx
const std::string::value_type *v38; // rsi
std::string::size_type v39; // rdx
size_t v40; // rbx
const char *v41; // r14
size_t v42; // rax
size_t v43; // r13
char *v44; // r12
size_t v45; // rbx
__int64 v46; // rbx
std::string *v47; // r13
std::string *v48; // rcx
char v49; // bl
std::string *result; // rax
cocos2d::CCString *v51; // rax
const char *CString; // rax
char v53; // [rsp+0h] [rbp-C0h]
cocos2d::CCDictionary *AllLevelsInDict; // [rsp+8h] [rbp-B8h]
char *__src; // [rsp+10h] [rbp-B0h]
_QWORD v56[2]; // [rsp+18h] [rbp-A8h] BYREF
void *__p; // [rsp+28h] [rbp-98h]
int v58; // [rsp+34h] [rbp-8Ch]
char v59[8]; // [rsp+38h] [rbp-88h] BYREF
__int64 v60; // [rsp+40h] [rbp-80h]
void *v61; // [rsp+48h] [rbp-78h]
std::string *v62; // [rsp+50h] [rbp-70h]
std::string *v63; // [rsp+58h] [rbp-68h]
int v64; // [rsp+64h] [rbp-5Ch]
std::string __dst; // [rsp+68h] [rbp-58h] BYREF
std::string __str; // [rsp+80h] [rbp-40h] BYREF
v63 = a1;
v5 = -1;
v6 = 0;
v7 = 0;
v8 = (unsigned int)a4->__r_.__value_.__l.0;
if ( (v8 & 1) != 0 )
goto LABEL_4;
LABEL_2:
for ( i = v8 >> 1; i > v7; i = a4->__r_.__value_.__l.__size_ )
{
v10 = *std::string::at(a4, v5 + i);
if ( v10 < 0 || (_DefaultRuneLocale.__runetype[v10] & 0x400) == 0 )
break;
++v7;
v6 += 2;
--v5;
v8 = (unsigned int)a4->__r_.__value_.__l.0;
if ( (v8 & 1) == 0 )
goto LABEL_2;
LABEL_4:
;
}
if ( !(_DWORD)v7 )
{
if ( (*(_BYTE *)&a4->__r_.__value_.__s.0 & 1) != 0 )
{
if ( strlen(a4->__r_.__value_.__l.__data_) > 0x12 )
{
LABEL_89:
result = v63;
v63->__r_.__value_.__r.__words[2] = a4->__r_.__value_.__r.__words[2];
*(_OWORD *)&result->__r_.__value_.__l.0 = *(_OWORD *)&a4->__r_.__value_.__l.0;
*(_OWORD *)&a4->__r_.__value_.__l.0 = 0;
a4->__r_.__value_.__r.__words[2] = 0;
return result;
}
}
else if ( strlen(a4->__r_.__value_.__s.__data_) >= 0x13 )
{
goto LABEL_89;
}
v51 = (cocos2d::CCString *)sub_1007AB580("%s 2", v53);
CString = cocos2d::CCString::getCString(v51);
std::string::assign(a4, CString);
goto LABEL_89;
}
v11 = LocalLevelManager::sharedState();
AllLevelsInDict = LocalLevelManager::getAllLevelsInDict(v11);
v12 = (unsigned int)a4->__r_.__value_.__l.0;
if ( (v12 & 1) != 0 )
{
size = a4->__r_.__value_.__l.__size_;
if ( size >= (unsigned int)v7 )
{
v14 = (char *)(a4->__r_.__value_.__r.__words[2] + size - (unsigned int)v7);
if ( (unsigned int)v7 >= 0x17uLL )
goto LABEL_13;
goto LABEL_21;
}
LABEL_93:
sub_1000547C0();
}
v13 = v12 >> 1;
if ( (unsigned int)v7 > (unsigned int)v13 )
goto LABEL_93;
v14 = (char *)&a4->__r_.__value_.__l.0 + v13 - (unsigned int)v7 + 1;
if ( (unsigned int)v7 >= 0x17uLL )
{
LABEL_13:
v15 = 26;
if ( ((unsigned int)v7 | 7LL) != 0x17 )
v15 = ((unsigned int)v7 | 7LL) + 1;
v16 = (char *)operator new(v15);
v61 = v16;
*(_QWORD *)v59 = v15 + 1;
v60 = (unsigned int)v7;
goto LABEL_22;
}
LABEL_21:
v59[0] = v6;
v16 = &v59[1];
LABEL_22:
memmove(v16, v14, (unsigned int)v7);
v16[(unsigned int)v7] = 0;
if ( (v59[0] & 1) != 0 )
v18 = (const char *)v61;
else
v18 = &v59[1];
v19 = atoi(v18);
__src = a4->__r_.__value_.__s.__data_;
v64 = 0;
v62 = a4;
do
{
v58 = v19 + 1;
v20 = (cocos2d::CCString *)sub_1007AB580("%i", v53);
v21 = cocos2d::CCString::getCString(v20);
v22 = strlen(v21);
if ( v22 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(a2);
v23 = v22;
if ( v22 >= 0x17 )
{
v27 = (v22 | 7) + 1;
if ( (v22 | 7) == 0x17 )
v27 = 26;
data = (char *)operator new(v27);
__dst.__r_.__value_.__r.__words[2] = (std::string::size_type)data;
__dst.__r_.__value_.__r.__words[0] = v27 | 1;
__dst.__r_.__value_.__l.__size_ = v23;
}
else
{
__dst.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v22);
data = __dst.__r_.__value_.__s.__data_;
if ( !v22 )
{
__dst.__r_.__value_.__s.__data_[0] = 0;
v25 = (unsigned int)__dst.__r_.__value_.__l.0;
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) != 0 )
goto LABEL_31;
goto LABEL_36;
}
}
memmove(data, v21, v23);
data[v23] = 0;
v25 = (unsigned int)__dst.__r_.__value_.__l.0;
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) != 0 )
{
LABEL_31:
v26 = __dst.__r_.__value_.__l.__size_;
goto LABEL_37;
}
LABEL_36:
v26 = v25 >> 1;
LABEL_37:
v28 = v62;
if ( v26 < (unsigned int)v7 )
{
*(_WORD *)&__str.__r_.__value_.__l.0 = 0;
v29 = 0;
do
{
std::string::append(&__str, "0");
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) != 0 )
v30 = __dst.__r_.__value_.__l.__size_;
else
v30 = *(_BYTE *)&__dst.__r_.__value_.__l.0 >> 1;
++v29;
}
while ( (unsigned int)v7 - v30 > v29 );
v31 = __dst.__r_.__value_.__s.__data_;
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) != 0 )
v31 = __dst.__r_.__value_.__l.__data_;
std::string::append(&__str, v31, v30);
std::string::operator=(&__dst, &__str);
if ( (*(_BYTE *)&__str.__r_.__value_.__s.0 & 1) != 0 )
operator delete(__str.__r_.__value_.__l.__data_);
}
v32 = (unsigned int)v28->__r_.__value_.__l.0;
if ( (v32 & 1) != 0 )
{
v33 = v28->__r_.__value_.__l.__size_;
v34 = v28->__r_.__value_.__l.__data_;
}
else
{
v33 = v32 >> 1;
v34 = __src;
}
v35 = v33 - (unsigned int)v7;
if ( v33 < (unsigned int)v7 )
v35 = v33;
if ( v35 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(a2);
if ( v35 >= 0x17 )
{
v40 = (v35 | 7) + 1;
if ( (v35 | 7) == 0x17 )
v40 = 26;
v36 = (char *)operator new(v40);
__str.__r_.__value_.__r.__words[2] = (std::string::size_type)v36;
__str.__r_.__value_.__r.__words[0] = v40 | 1;
__str.__r_.__value_.__l.__size_ = v35;
}
else
{
__str.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v35);
v36 = __str.__r_.__value_.__s.__data_;
if ( !v35 )
{
__str.__r_.__value_.__s.__data_[0] = 0;
v37 = (unsigned int)__dst.__r_.__value_.__l.0;
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) != 0 )
goto LABEL_56;
goto LABEL_61;
}
}
memmove(v36, v34, v35);
v36[v35] = 0;
v37 = (unsigned int)__dst.__r_.__value_.__l.0;
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) != 0 )
{
LABEL_56:
v38 = __dst.__r_.__value_.__l.__data_;
v39 = __dst.__r_.__value_.__l.__size_;
goto LABEL_62;
}
LABEL_61:
v39 = v37 >> 1;
v38 = __dst.__r_.__value_.__s.__data_;
LABEL_62:
std::string::append(&__str, v38, v39);
v41 = __str.__r_.__value_.__s.__data_;
if ( (*(_BYTE *)&__str.__r_.__value_.__s.0 & 1) != 0 )
v41 = __str.__r_.__value_.__l.__data_;
v42 = strlen(v41);
if ( v42 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(a2);
v43 = v42;
if ( v42 >= 0x17 )
{
v45 = (v42 | 7) + 1;
if ( (v42 | 7) == 0x17 )
v45 = 26;
v44 = (char *)operator new(v45);
__p = v44;
v56[0] = v45 | 1;
v56[1] = v43;
LABEL_71:
memmove(v44, v41, v43);
goto LABEL_72;
}
LOBYTE(v56[0]) = 2 * v42;
v44 = (char *)v56 + 1;
if ( v42 )
goto LABEL_71;
LABEL_72:
v44[v43] = 0;
v46 = cocos2d::CCDictionary::objectForKey_1((__int64)AllLevelsInDict, (char *)v56);
v47 = v62;
if ( (v56[0] & 1) != 0 )
operator delete(__p);
if ( !v46 )
{
*v63 = __str;
a2 = 0.0;
memset(&__str, 0, sizeof(__str));
v49 = 0;
goto LABEL_80;
}
if ( v64 < 999 )
{
++v64;
v49 = 1;
if ( (*(_BYTE *)&__str.__r_.__value_.__s.0 & 1) != 0 )
LABEL_79:
operator delete(__str.__r_.__value_.__l.__data_);
}
else
{
v48 = v63;
v63->__r_.__value_.__r.__words[2] = v47->__r_.__value_.__r.__words[2];
*(_OWORD *)&v48->__r_.__value_.__l.0 = *(_OWORD *)&v47->__r_.__value_.__l.0;
a2 = 0.0;
*(_OWORD *)&v47->__r_.__value_.__l.0 = 0;
v47->__r_.__value_.__r.__words[2] = 0;
v49 = 0;
if ( (*(_BYTE *)&__str.__r_.__value_.__s.0 & 1) != 0 )
goto LABEL_79;
}
LABEL_80:
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) != 0 )
operator delete(__dst.__r_.__value_.__l.__data_);
v19 = v58;
}
while ( v49 );
if ( (v59[0] & 1) != 0 )
operator delete(v61);
return v63;
}