//
// GameLevelManager::getNextLevelName from 0x100092754 to 0x100092ab0 (860 bytes)
//
// 1 xrefs:
// > GJGameLevel::copyLevelInfo @ 0x1000ad7c8
//
// 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
//
__n128 __usercall GameLevelManager::getNextLevelName@(std::string *__s@, __int64 a2@)
{
std::string::size_type v4; // x21
__int64 i; // x22
std::string::size_type size; // x8
__int64 v7; // x8
unsigned __int64 v8; // x27
LocalLevelManager *v9; // x0
cocos2d::CCDictionary *AllLevelsInDict; // x21
std::string::size_type v11; // x3
std::string *v12; // x0
int v13; // w22
int v14; // w24
cocos2d::CCString *v15; // x0
char *v16; // x0
std::string::size_type v17; // x8
std::string::size_type v18; // x2
unsigned __int64 v19; // x8
std::string::size_type v20; // x26
std::string *v21; // x1
std::string::size_type v22; // x8
std::string *v23; // x1
std::string::size_type v24; // x2
std::string *v25; // x1
__int64 v26; // x0
__n128 result; // q0
__int64 v28; // x26
std::string *v29; // x21
cocos2d::CCString *v30; // x0
const char *CString; // x0
std::allocator v32[8]; // [xsp+10h] [xbp-B0h] BYREF
char v33; // [xsp+27h] [xbp-99h]
std::string __str; // [xsp+28h] [xbp-98h] BYREF
std::string __a; // [xsp+40h] [xbp-80h] BYREF
std::string v36; // [xsp+58h] [xbp-68h] BYREF
v4 = 0;
for ( i = -1; ; --i )
{
size = SHIBYTE(__s->__r_.__value_.__r.__words[2]);
if ( (size & 0x8000000000000000LL) != 0 )
{
size = __s->__r_.__value_.__l.__size_;
if ( size <= v4 )
break;
}
else if ( v4 >= size )
{
break;
}
v7 = *std::string::at(__s, size + i);
if ( v7 < 0 || (_DefaultRuneLocale.__runetype[v7] & 0x400) == 0 )
break;
++v4;
}
v8 = (unsigned int)v4;
if ( !(_DWORD)v4 )
{
if ( SHIBYTE(__s->__r_.__value_.__r.__words[2]) < 0 )
{
v29 = (std::string *)__s->__r_.__value_.__r.__words[0];
if ( strlen(__s->__r_.__value_.__l.__data_) >= 0x13 )
goto LABEL_64;
}
else
{
v29 = __s;
if ( strlen((const char *)__s) > 0x12 )
{
LABEL_64:
result = *(__n128 *)&__s->__r_.__value_.__l.__data_;
*(_OWORD *)a2 = *(_OWORD *)&__s->__r_.__value_.__l.__data_;
*(_QWORD *)(a2 + 16) = *((_QWORD *)&__s->__r_.__value_.__l + 2);
__s->__r_.__value_.__l.__size_ = 0;
__s->__r_.__value_.__r.__words[2] = 0;
__s->__r_.__value_.__r.__words[0] = 0;
return result;
}
}
v30 = (cocos2d::CCString *)sub_100268F4C("%s 2", (const char *)v29);
CString = cocos2d::CCString::getCString(v30);
std::string::assign(__s, CString);
goto LABEL_64;
}
v9 = LocalLevelManager::sharedState();
AllLevelsInDict = LocalLevelManager::getAllLevelsInDict(v9);
v11 = SHIBYTE(__s->__r_.__value_.__r.__words[2]);
if ( (v11 & 0x8000000000000000LL) != 0 )
v11 = __s->__r_.__value_.__l.__size_;
std::string::basic_string(&v36, __s, v11 - v8, v11, (std::allocator *)&__a);
if ( (v36.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v12 = &v36;
else
v12 = (std::string *)v36.__r_.__value_.__r.__words[0];
v13 = atoi((const char *)v12);
v14 = 0;
do
{
while ( 1 )
{
v15 = (cocos2d::CCString *)sub_100268F4C("%i", ++v13);
v16 = (char *)cocos2d::CCString::getCString(v15);
sub_100009900(&__a, v16);
v17 = HIBYTE(__a.__r_.__value_.__r.__words[2]);
if ( (__a.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
v17 = __a.__r_.__value_.__l.__size_;
if ( v17 < v8 )
{
sub_100009900(&__str, "");
v18 = (__a.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL
? SHIBYTE(__a.__r_.__value_.__r.__words[2])
: __a.__r_.__value_.__l.__size_;
if ( v8 == v18 )
{
v19 = (unsigned __int64)SHIBYTE(__a.__r_.__value_.__r.__words[2]) >> 63;
}
else
{
v20 = 0;
do
{
std::string::append(&__str, "0");
++v20;
if ( (__a.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v18 = SHIBYTE(__a.__r_.__value_.__r.__words[2]);
else
v18 = __a.__r_.__value_.__l.__size_;
}
while ( v8 - v18 > v20 );
v19 = (unsigned __int64)SHIBYTE(__a.__r_.__value_.__r.__words[2]) >> 63;
}
v21 = (_DWORD)v19 ? (std::string *)__a.__r_.__value_.__r.__words[0] : &__a;
std::string::append(&__str, (const std::string::value_type *)v21, v18);
std::string::operator=(&__a, &__str);
if ( SHIBYTE(__str.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__str.__r_.__value_.__l.__data_);
}
v22 = SHIBYTE(__s->__r_.__value_.__r.__words[2]);
if ( (v22 & 0x8000000000000000LL) != 0 )
v22 = __s->__r_.__value_.__l.__size_;
std::string::basic_string(&__str, __s, 0, v22 - v8, v32);
v23 = (__a.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL
? &__a
: (std::string *)__a.__r_.__value_.__r.__words[0];
v24 = (__a.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL
? HIBYTE(__a.__r_.__value_.__r.__words[2])
: __a.__r_.__value_.__l.__size_;
std::string::append(&__str, (const std::string::value_type *)v23, v24);
v25 = (__str.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL
? &__str
: (std::string *)__str.__r_.__value_.__r.__words[0];
sub_100009900(v32, (char *)v25);
v26 = cocos2d::CCDictionary::objectForKey_1(AllLevelsInDict, v32);
v28 = v26;
if ( v33 < 0 )
{
operator delete(*(void **)&v32[0].std::__non_trivial_if);
if ( !v28 )
{
LABEL_51:
result = *(__n128 *)&__str.__r_.__value_.__l.__data_;
*(std::string *)a2 = __str;
memset(&__str, 0, sizeof(__str));
goto LABEL_53;
}
}
else if ( !v26 )
{
goto LABEL_51;
}
if ( v14 < 999 )
{
++v14;
LOBYTE(v28) = 1;
}
else
{
LOBYTE(v28) = 0;
result = *(__n128 *)&__s->__r_.__value_.__l.__data_;
*(_OWORD *)a2 = *(_OWORD *)&__s->__r_.__value_.__l.__data_;
*(_QWORD *)(a2 + 16) = *((_QWORD *)&__s->__r_.__value_.__l + 2);
__s->__r_.__value_.__l.__size_ = 0;
__s->__r_.__value_.__r.__words[2] = 0;
__s->__r_.__value_.__r.__words[0] = 0;
}
LABEL_53:
if ( SHIBYTE(__str.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__str.__r_.__value_.__l.__data_);
if ( SHIBYTE(__a.__r_.__value_.__r.__words[2]) < 0 )
break;
if ( (v28 & 1) == 0 )
goto LABEL_59;
}
operator delete(__a.__r_.__value_.__l.__data_);
}
while ( (v28 & 1) != 0 );
LABEL_59:
if ( SHIBYTE(v36.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v36.__r_.__value_.__l.__data_);
return result;
}