//
// LocalLevelManager::tryLoadMainLevelString from 0x1006c98e0 to 0x1006c9c7d (925 bytes)
//
// 1 xrefs:
// > LocalLevelManager::getMainLevelString @ 0x1006c9d0e
//
// This function is hookable on this platform (idp: pc, 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:35:35 +0000
//
void __fastcall LocalLevelManager::tryLoadMainLevelString(__int64 a1, unsigned __int64 a2)
{
int v2; // r14d
unsigned __int64 v4; // rdi
float *v5; // rbx
unsigned __int64 v6; // r9
__int64 **v7; // rax
__int64 *v8; // r8
__int64 v9; // rax
unsigned __int64 v10; // rax
__int64 v11; // r15
__int64 v12; // rax
const char *CString; // r12
size_t v14; // rax
size_t v15; // r14
char *v16; // r13
char *v17; // rdx
float *v18; // r15
size_t v19; // rbx
char *v20; // rdi
__int64 v21; // rax
const char *v22; // r14
size_t v23; // rax
std::string::size_type v24; // r15
char *data; // r12
size_t v26; // r13
char v27; // al
char *v28; // rax
int *v29; // [rsp+0h] [rbp-90h] BYREF
__int64 v30; // [rsp+8h] [rbp-88h]
char v31; // [rsp+10h] [rbp-80h] BYREF
char v32; // [rsp+11h] [rbp-7Fh] BYREF
void *__p; // [rsp+20h] [rbp-70h]
int v34; // [rsp+2Ch] [rbp-64h] BYREF
_QWORD __dst[2]; // [rsp+30h] [rbp-60h] BYREF
void *v36; // [rsp+40h] [rbp-50h]
std::string __str; // [rsp+48h] [rbp-48h] BYREF
v2 = a2;
v34 = a2;
v4 = *(_QWORD *)(a1 + 384);
v5 = (float *)(a1 + 376);
if ( v4 )
{
v6 = (0x101010101010101LL
* ((((v4 - ((v4 >> 1) & 0x5555555555555555LL)) & 0x3333333333333333LL)
+ (((v4 - ((v4 >> 1) & 0x5555555555555555LL)) >> 2) & 0x3333333333333333LL)
+ ((((v4 - ((v4 >> 1) & 0x5555555555555555LL)) & 0x3333333333333333LL)
+ (((v4 - ((v4 >> 1) & 0x5555555555555555LL)) >> 2) & 0x3333333333333333LL)) >> 4))
& 0xF0F0F0F0F0F0F0FLL)) >> 56;
if ( v6 <= 1 )
{
a2 = (int)a2 & (v4 - 1);
v7 = *(__int64 ***)(*(_QWORD *)v5 + 8 * a2);
if ( !v7 )
goto LABEL_28;
goto LABEL_9;
}
a2 = (int)a2;
if ( v4 <= (int)a2 )
{
if ( !((v4 | (int)a2) >> 32) )
{
a2 = (unsigned int)a2 % (unsigned int)v4;
v7 = *(__int64 ***)(*(_QWORD *)v5 + 8 * a2);
if ( !v7 )
goto LABEL_28;
goto LABEL_9;
}
a2 = (int)a2 % v4;
}
v7 = *(__int64 ***)(*(_QWORD *)v5 + 8 * a2);
if ( !v7 )
goto LABEL_28;
LABEL_9:
v8 = *v7;
if ( !*v7 )
goto LABEL_28;
if ( (unsigned int)v6 < 2 )
{
--v4;
while ( 1 )
{
v9 = v8[1];
if ( v9 == v2 )
{
if ( *((_DWORD *)v8 + 4) == v2 )
return;
}
else if ( (v4 & v9) != a2 )
{
goto LABEL_28;
}
v8 = (__int64 *)*v8;
if ( !v8 )
goto LABEL_28;
}
}
while ( 1 )
{
v10 = v8[1];
if ( v10 == v2 )
{
if ( *((_DWORD *)v8 + 4) == v2 )
return;
goto LABEL_18;
}
if ( v10 < v4 )
goto LABEL_23;
if ( (v4 | v10) >> 32 )
break;
if ( (unsigned int)v10 % (unsigned int)v4 != a2 )
goto LABEL_28;
LABEL_18:
v8 = (__int64 *)*v8;
if ( !v8 )
goto LABEL_28;
}
v10 %= v4;
LABEL_23:
if ( v10 != a2 )
goto LABEL_28;
goto LABEL_18;
}
LABEL_28:
v11 = cocos2d::CCFileUtils::sharedFileUtils(v4, a2);
v12 = sub_10088E820("levels/%i.txt", (char)v29);
CString = (const char *)cocos2d::CCString::getCString(v12);
v14 = strlen(CString);
if ( v14 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
v15 = v14;
if ( v14 >= 0x17 )
{
v30 = v11;
v18 = v5;
v19 = 26;
if ( (v14 | 7) != 0x17 )
v19 = (v14 | 7) + 1;
v16 = (char *)operator new(v19);
v36 = v16;
__dst[0] = v19 + 1;
v5 = v18;
v11 = v30;
__dst[1] = v15;
LABEL_36:
memmove(v16, CString, v15);
v16[v15] = 0;
if ( (__dst[0] & 1) != 0 )
goto LABEL_32;
goto LABEL_37;
}
LOBYTE(__dst[0]) = 2 * v14;
v16 = (char *)__dst + 1;
if ( v14 )
goto LABEL_36;
BYTE1(__dst[0]) = 0;
if ( (__dst[0] & 1) != 0 )
{
LABEL_32:
v17 = (char *)v36;
goto LABEL_38;
}
LABEL_37:
v17 = (char *)__dst + 1;
LABEL_38:
(*(void (__fastcall **)(char *, __int64, char *, _QWORD))(*(_QWORD *)v11 + 48LL))(&v31, v11, v17, 0);
if ( (v31 & 1) != 0 )
v20 = (char *)__p;
else
v20 = &v32;
v21 = cocos2d::CCString::createWithContentsOfFile(v20);
if ( v21 )
{
v22 = (const char *)cocos2d::CCString::getCString(v21);
v23 = strlen(v22);
if ( v23 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
v24 = v23;
if ( v23 >= 0x17 )
{
v26 = 26;
if ( (v23 | 7) != 0x17 )
v26 = (v23 | 7) + 1;
data = (char *)operator new(v26);
__str.__r_.__value_.__r.__words[2] = (std::string::size_type)data;
__str.__r_.__value_.__r.__words[0] = v26 | 1;
__str.__r_.__value_.__l.__size_ = v24;
}
else
{
__str.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v23);
data = __str.__r_.__value_.__s.__data_;
if ( !v23 )
{
LABEL_50:
data[v24] = 0;
v27 = *(_BYTE *)&__str.__r_.__value_.__s.0 & 1;
if ( (*(_BYTE *)&__str.__r_.__value_.__s.0 & 1) != 0 )
{
if ( !__str.__r_.__value_.__l.__size_ )
{
LABEL_55:
if ( v27 )
operator delete(__str.__r_.__value_.__l.__data_);
goto LABEL_57;
}
}
else if ( !(*(_BYTE *)&__str.__r_.__value_.__l.0 >> 1) )
{
goto LABEL_55;
}
v29 = &v34;
v28 = sub_1000E8600(v5, &v34, (__int64)&unk_100A10B71, &v29);
std::string::operator=((std::string *)v28 + 1, &__str);
v27 = *(_BYTE *)&__str.__r_.__value_.__s.0 & 1;
goto LABEL_55;
}
}
memmove(data, v22, v24);
goto LABEL_50;
}
LABEL_57:
if ( (v31 & 1) != 0 )
operator delete(__p);
if ( (__dst[0] & 1) != 0 )
operator delete(v36);
}