//
// GameLevelManager::getLengthStr from 0x6f4cfc to 0x6f5058 (860 bytes)
//
// 2 xrefs:
// > LevelSearchLayer::getLevelLenKey @ 0x6cf584
// > ??> @ 0xc2f10
//
// 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
//
void **__usercall GameLevelManager::getLengthStr@(
GameLevelManager *this@,
unsigned __int8 a2@,
unsigned __int8 a3@,
unsigned __int8 a4@,
unsigned __int8 a5@,
unsigned __int8 a6@,
unsigned __int8 a7@,
void **a8@)
{
int v8; // w24
int v9; // w19
unsigned int v10; // w20
int v11; // w0
const char *v12; // x1
int v13; // w22
cocos2d::CCString *v14; // x0
size_t v15; // x0
_DWORD *v16; // x22
unsigned __int64 v17; // x20
unsigned __int64 v18; // x21
size_t v19; // x2
int v20; // w19
__int64 v21; // x20
char *v22; // x0
cocos2d::CCString *v24; // x0
char *v25; // x0
_DWORD *v26; // x19
char *v27; // x20
unsigned int *v28; // x19
int v29; // w0
unsigned int *v30; // x22
int v31; // w1
int v32; // [xsp+6Ch] [xbp+6Ch]
int v33; // [xsp+70h] [xbp+70h]
int v34; // [xsp+74h] [xbp+74h]
int v35; // [xsp+78h] [xbp+78h]
int v36; // [xsp+7Ch] [xbp+7Ch]
const char *CString; // [xsp+88h] [xbp+88h]
void *v39; // [xsp+A8h] [xbp+A8h] BYREF
void *v40; // [xsp+B0h] [xbp+B0h] BYREF
v35 = a3;
v36 = a4;
v34 = a5;
v8 = a2;
v33 = a6;
v9 = 1;
v32 = a7;
v10 = 0;
sub_D153B8((int)&v39, &byte_F288A0);
v11 = -1;
v12 = nullptr;
v13 = 0;
LABEL_2:
switch ( v11 )
{
case 0:
if ( v35 )
goto LABEL_4;
goto LABEL_7;
case 1:
if ( v36 )
goto LABEL_4;
goto LABEL_7;
case 2:
if ( !v34 )
goto LABEL_7;
goto LABEL_4;
case 3:
if ( !v33 )
goto LABEL_7;
goto LABEL_4;
case 4:
if ( v32 )
goto LABEL_4;
if ( v13 == 1 )
goto LABEL_31;
goto LABEL_11;
default:
break;
}
while ( !v8 )
{
if ( v9 == 6 )
goto LABEL_10;
LABEL_7:
v10 = v9++;
v11 = v9 - 2;
if ( (unsigned int)(v9 - 2) <= 4 )
goto LABEL_2;
}
LABEL_4:
if ( v13 )
sub_D15FD4(&v39, &byte_F804F8, 1);
v14 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", (const char *)v10);
CString = cocos2d::CCString::getCString(v14);
v15 = strlen(CString);
sub_D15FD4(&v39, CString, v15);
++v13;
v12 = (const char *)v10;
if ( v9 != 6 )
goto LABEL_7;
LABEL_10:
if ( v13 == 1 )
{
LABEL_31:
v24 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", v12);
v25 = (char *)cocos2d::CCString::getCString(v24);
sub_D153B8((int)a8, v25);
v26 = v39;
}
else
{
LABEL_11:
sub_D153B8((int)&v40, &byte_F288A0);
v16 = v40;
v17 = *((_QWORD *)v39 - 3);
v18 = *((_QWORD *)v40 - 3);
if ( v18 > v17 )
v19 = *((_QWORD *)v39 - 3);
else
v19 = *((_QWORD *)v40 - 3);
v20 = memcmp(v39, v40, v19);
if ( !v20 )
{
v20 = 0x7FFFFFFF;
v21 = v17 - v18;
if ( v21 <= 0x7FFFFFFF )
{
if ( v21 >= (__int64)0xFFFFFFFF80000000LL )
v20 = v21;
else
v20 = 0x80000000;
}
}
v22 = (char *)(v16 - 6);
if ( v16 - 6 != (_DWORD *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v30 = v16 - 2;
do
v31 = __ldaxr(v30);
while ( __stlxr(v31 - 1, v30) );
}
else
{
v31 = *(v16 - 2);
*(v16 - 2) = v31 - 1;
}
if ( v31 <= 0 )
operator delete(v22);
}
if ( v20 )
{
*a8 = v39;
v39 = &byte_124B6C8;
return a8;
}
sub_D153B8((int)a8, &byte_F10E40);
v26 = v39;
}
v27 = (char *)(v26 - 6);
if ( v26 - 6 != (_DWORD *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v28 = v26 - 2;
do
v29 = __ldaxr(v28);
while ( __stlxr(v29 - 1, v28) );
}
else
{
v29 = *(v26 - 2);
*(v26 - 2) = v29 - 1;
}
if ( v29 <= 0 )
operator delete(v27);
}
return a8;
}