//
// sub_100564020 from 0x100564020 to 0x1005641ae (398 bytes)
//
// 3 xrefs:
// > GameLevelManager::createNewLevelList @ 0x10052d3b9
// > GameLevelManager::uploadLevelList @ 0x100541347
// > GameLevelManager::deleteServerLevelList @ 0x100542074
//
// 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
//
__int64 *__fastcall sub_100564020(__int64 **a1, unsigned __int8 *a2, __int64 a3, double a4)
{
__int64 *v4; // rax
unsigned int v5; // r15d
size_t v6; // r15
const void *v7; // rbx
__int64 **v8; // r12
__int64 *v9; // r13
unsigned int v10; // r14d
size_t v11; // r14
const void *v12; // r12
size_t v13; // r13
int v14; // eax
bool v15; // cl
int v16; // eax
bool v17; // cl
__int64 *v18; // r14
_QWORD *v19; // rdi
__int64 *v20; // rax
__int64 *v24; // [rsp+30h] [rbp-30h]
v4 = a1[1];
if ( v4 )
{
v5 = *a2;
if ( (v5 & 1) != 0 )
{
v6 = *((_QWORD *)a2 + 1);
v7 = *((const void **)a2 + 2);
}
else
{
v6 = v5 >> 1;
v7 = a2 + 1;
}
while ( 1 )
{
while ( 1 )
{
v10 = *((unsigned __int8 *)v4 + 32);
v24 = v4;
if ( (v10 & 1) != 0 )
{
v11 = v4[5];
v12 = (const void *)v4[6];
}
else
{
v11 = v10 >> 1;
v12 = (char *)v4 + 33;
}
v13 = v6;
if ( v11 < v6 )
v13 = v11;
v14 = memcmp(v7, v12, v13);
v15 = v6 < v11;
if ( v14 )
v15 = v14 < 0;
if ( !v15 )
break;
v9 = v24;
v4 = (__int64 *)*v24;
v8 = (__int64 **)v24;
if ( !*v24 )
goto LABEL_20;
}
v16 = memcmp(v12, v7, v13);
v17 = v11 < v6;
if ( v16 )
v17 = v16 < 0;
if ( !v17 )
return v24;
v9 = v24;
v4 = (__int64 *)v24[1];
if ( !v4 )
{
v8 = (__int64 **)(v24 + 1);
goto LABEL_20;
}
}
}
else
{
v8 = a1 + 1;
v9 = (__int64 *)(a1 + 1);
LABEL_20:
v18 = (__int64 *)operator new(0x38u);
v19 = v18 + 4;
if ( (*(_BYTE *)a3 & 1) != 0 )
{
sub_100006B70(v19, *(const void **)(a3 + 16), *(_QWORD *)(a3 + 8), a4);
}
else
{
v18[6] = *(_QWORD *)(a3 + 16);
*(_OWORD *)v19 = *(_OWORD *)a3;
}
*(_OWORD *)v18 = 0;
v18[2] = (__int64)v9;
*v8 = v18;
v20 = (__int64 *)**a1;
if ( v20 )
*a1 = v20;
sub_100054DD0(a1[1], v18);
a1[2] = (__int64 *)((char *)a1[2] + 1);
}
return v18;
}