//
// LocalLevelManager::getMainLevelString from 0x1006c9cf0 to 0x1006c9eef (511 bytes)
//
// 4 xrefs:
// > LevelAreaInnerLayer::playStep1 @ 0x1002680b7
// > sub_1003AE2B0 @ 0x1003ae2fe
// > LevelPage::playStep3 @ 0x10042505e
// > LevelTools::getLevel @ 0x1004fc6ea
//
// 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
//
_QWORD *__fastcall LocalLevelManager::getMainLevelString(_QWORD *a1, __int64 a2, int a3)
{
unsigned __int64 v5; // rdi
float *v6; // r14
unsigned __int64 v7; // r9
unsigned __int64 v8; // rsi
__int64 **v9; // rax
__int64 *v10; // r8
unsigned __int64 v11; // rdi
__int64 v12; // rax
unsigned __int64 v13; // rax
char *v14; // rax
char *v15; // rax
int *v17; // [rsp+8h] [rbp-28h] BYREF
int v18; // [rsp+10h] [rbp-20h] BYREF
v18 = a3;
LocalLevelManager::tryLoadMainLevelString(a2, (unsigned int)a3);
v5 = *(_QWORD *)(a2 + 384);
if ( !v5 )
goto LABEL_30;
v6 = (float *)(a2 + 376);
v7 = (0x101010101010101LL
* ((((v5 - ((v5 >> 1) & 0x5555555555555555LL)) & 0x3333333333333333LL)
+ (((v5 - ((v5 >> 1) & 0x5555555555555555LL)) >> 2) & 0x3333333333333333LL)
+ ((((v5 - ((v5 >> 1) & 0x5555555555555555LL)) & 0x3333333333333333LL)
+ (((v5 - ((v5 >> 1) & 0x5555555555555555LL)) >> 2) & 0x3333333333333333LL)) >> 4))
& 0xF0F0F0F0F0F0F0FLL)) >> 56;
if ( v7 <= 1 )
{
v8 = a3 & (v5 - 1);
v9 = *(__int64 ***)(*(_QWORD *)v6 + 8 * v8);
if ( !v9 )
goto LABEL_30;
goto LABEL_9;
}
v8 = a3;
if ( v5 <= a3 )
{
if ( !((v5 | a3) >> 32) )
{
v8 = a3 % (unsigned int)v5;
v9 = *(__int64 ***)(*(_QWORD *)v6 + 8 * v8);
if ( !v9 )
goto LABEL_30;
goto LABEL_9;
}
v8 = a3 % v5;
}
v9 = *(__int64 ***)(*(_QWORD *)v6 + 8 * v8);
if ( !v9 )
{
LABEL_30:
*(_WORD *)a1 = 0;
return a1;
}
LABEL_9:
v10 = *v9;
if ( !*v9 )
goto LABEL_30;
if ( (unsigned int)v7 < 2 )
{
v11 = v5 - 1;
while ( 1 )
{
v12 = v10[1];
if ( v12 == a3 )
{
if ( *((_DWORD *)v10 + 4) == a3 )
goto LABEL_27;
}
else if ( (v11 & v12) != v8 )
{
goto LABEL_30;
}
v10 = (__int64 *)*v10;
if ( !v10 )
goto LABEL_30;
}
}
while ( 1 )
{
v13 = v10[1];
if ( v13 == a3 )
break;
if ( v13 < v5 )
goto LABEL_23;
if ( (v5 | v13) >> 32 )
{
v13 %= v5;
LABEL_23:
if ( v13 != v8 )
goto LABEL_30;
goto LABEL_18;
}
if ( (unsigned int)v13 % (unsigned int)v5 != v8 )
goto LABEL_30;
LABEL_18:
v10 = (__int64 *)*v10;
if ( !v10 )
goto LABEL_30;
}
if ( *((_DWORD *)v10 + 4) != a3 )
goto LABEL_18;
LABEL_27:
v17 = &v18;
v14 = sub_1000E8600(v6, &v18, (__int64)&unk_100A10B71, &v17);
if ( (v14[24] & 1) != 0 )
{
sub_10001AD30(a1, *((const void **)v14 + 5), *((_QWORD *)v14 + 4));
}
else
{
v15 = v14 + 24;
a1[2] = *((_QWORD *)v15 + 2);
*(_OWORD *)a1 = *(_OWORD *)v15;
}
return a1;
}