//
// sub_100530800 from 0x100530800 to 0x100530a74 (628 bytes)
//
// 1 xrefs:
// > GameLevelManager::handleIt @ 0x100520148
//
// 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:31:50 +0000
//
__int64 __fastcall sub_100530800(__int64 a1, unsigned __int8 *a2, unsigned __int8 *a3)
{
_QWORD *v4; // r13
__int64 v5; // r12
_QWORD *v6; // rcx
_QWORD *v7; // rax
_QWORD *v8; // rcx
bool v9; // zf
unsigned int v10; // r12d
unsigned __int64 v11; // r12
unsigned __int8 *v12; // r15
size_t v13; // r12
char *v14; // r13
unsigned int v15; // r15d
unsigned int v16; // ebx
const char *v17; // r13
const char *v18; // rdi
int v19; // r12d
const char *v20; // rdi
unsigned __int64 v21; // rax
size_t v22; // rdx
char v23; // cl
__int64 result; // rax
__int64 v25; // rdi
__int64 v26; // rdx
size_t v27; // rbx
char *v28; // rbx
__int64 v29; // [rsp+8h] [rbp-48h]
char __s2[8]; // [rsp+10h] [rbp-40h] BYREF
size_t v31; // [rsp+18h] [rbp-38h]
char *v32; // [rsp+20h] [rbp-30h]
v4 = (_QWORD *)(a1 + 720);
v5 = sub_100309350(a1 + 720, a3);
if ( v5 != a1 + 728 )
{
v6 = *(_QWORD **)(v5 + 8);
if ( v6 )
{
do
{
v7 = v6;
v6 = (_QWORD *)*v6;
}
while ( v6 );
}
else
{
v8 = (_QWORD *)v5;
do
{
v7 = (_QWORD *)v8[2];
v9 = *v7 == (_QWORD)v8;
v8 = v7;
}
while ( !v9 );
}
if ( *v4 == v5 )
*v4 = v7;
--*(_QWORD *)(a1 + 736);
sub_1001454C0(*(__int64 **)(a1 + 728), (__int64 *)v5);
if ( (*(_BYTE *)(v5 + 32) & 1) != 0 )
operator delete(*(void **)(v5 + 48));
operator delete((void *)v5);
}
v10 = *a3;
v29 = a1;
if ( (v10 & 1) == 0 )
{
if ( (unsigned __int8)v10 > 0xEu )
{
v11 = v10 >> 1;
v12 = a3 + 1;
goto LABEL_17;
}
LABEL_23:
v15 = 0;
v16 = *a2;
if ( (v16 & 1) != 0 )
goto LABEL_22;
goto LABEL_24;
}
v11 = *((_QWORD *)a3 + 1);
if ( v11 <= 7 )
goto LABEL_23;
v12 = *((unsigned __int8 **)a3 + 2);
LABEL_17:
v13 = v11 - 7;
if ( v13 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
if ( v13 >= 0x17 )
{
v27 = 26;
if ( (v13 | 7) != 0x17 )
v27 = (v13 | 7) + 1;
v14 = (char *)operator new(v27);
v32 = v14;
*(_QWORD *)__s2 = v27 + 1;
v31 = v13;
}
else
{
__s2[0] = 2 * v13;
v14 = &__s2[1];
if ( !v13 )
{
__s2[1] = 0;
if ( (__s2[0] & 1) == 0 )
goto LABEL_21;
LABEL_43:
v28 = v32;
v15 = atoi(v32);
operator delete(v28);
v16 = *a2;
if ( (v16 & 1) != 0 )
goto LABEL_22;
goto LABEL_24;
}
}
memmove(v14, v12 + 7, v13);
v14[v13] = 0;
if ( (__s2[0] & 1) != 0 )
goto LABEL_43;
LABEL_21:
v15 = atoi(&__s2[1]);
v16 = *a2;
if ( (v16 & 1) != 0 )
{
LABEL_22:
v17 = *((const char **)a2 + 2);
v18 = v17;
goto LABEL_25;
}
LABEL_24:
v18 = (const char *)(a2 + 1);
v17 = *((const char **)a2 + 2);
LABEL_25:
v19 = atoi(v18);
v20 = (const char *)(a2 + 1);
v21 = v16 >> 1;
*(_WORD *)&__s2[1] = 12589;
if ( (v16 & 1) != 0 )
v20 = v17;
__s2[3] = 0;
if ( (v16 & 1) != 0 )
v21 = *((_QWORD *)a2 + 1);
v22 = 2;
if ( v21 < 2 )
v22 = v21;
v23 = (v21 == 2) & (memcmp(v20, &__s2[1], v22) == 0) | (v19 < 0);
result = v29;
v25 = *(_QWORD *)(v29 + 1344);
if ( v23 == 1 )
{
if ( v25 )
{
v26 = 0;
if ( v19 == -21 )
v26 = 4294967275LL;
return (*(__int64 (__fastcall **)(__int64, _QWORD, __int64))(*(_QWORD *)v25 + 8LL))(v25, v15, v26);
}
}
else if ( v25 )
{
return (**(__int64 (__fastcall ***)(__int64, _QWORD))v25)(v25, v15);
}
return result;
}