//
// sub_10054AEF0 from 0x10054aef0 to 0x10054b2a5 (949 bytes)
//
// 1 xrefs:
// > GameLevelManager::onGetLevelLeaderboardCompleted @ 0x10052955f
//
// 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 __fastcall sub_10054AEF0(unsigned __int8 *a1, int *a2, int *a3, int *a4)
{
unsigned __int8 *v4; // r13
unsigned int v5; // eax
double v6; // xmm0_8
unsigned __int8 *v7; // rax
__int64 v8; // r12
__int64 v9; // rcx
__int64 v10; // rsi
unsigned __int8 *v11; // rdx
unsigned __int64 v12; // rbx
bool v13; // zf
unsigned int v14; // r14d
unsigned __int64 v15; // r14
unsigned __int8 *v16; // r15
size_t v17; // r14
char *v18; // r13
unsigned __int64 v19; // r12
size_t v20; // rbx
__int64 v21; // rcx
__int64 v22; // r14
__int64 v23; // rbx
_OWORD *v24; // r14
char *v25; // r14
unsigned int v26; // esi
unsigned __int8 *v27; // rax
unsigned __int64 v28; // rsi
unsigned __int8 *v29; // rdx
unsigned __int64 v30; // rdi
void **v31; // rbx
void **v32; // r14
const char *v33; // rdi
void **v34; // rdi
const char *v35; // rdi
__int64 v37; // [rsp+10h] [rbp-90h]
__int64 v39; // [rsp+20h] [rbp-80h]
unsigned __int8 *v40; // [rsp+28h] [rbp-78h]
void *v43[2]; // [rsp+40h] [rbp-60h] BYREF
void *v44; // [rsp+50h] [rbp-50h]
__int128 __dst; // [rsp+60h] [rbp-40h] BYREF
void *__p; // [rsp+70h] [rbp-30h]
v4 = a1;
v5 = *a1;
if ( (v5 & 1) != 0 )
{
if ( !*((_QWORD *)a1 + 1) )
return;
}
else if ( !(v5 >> 1) )
{
return;
}
v6 = 0.0;
*(_OWORD *)v43 = 0;
v44 = nullptr;
v40 = a1 + 1;
if ( (v5 & 1) != 0 )
{
v7 = *((unsigned __int8 **)a1 + 2);
v8 = -1;
v39 = *((_QWORD *)a1 + 1);
if ( !v39 )
goto LABEL_15;
LABEL_9:
v10 = v39;
v11 = v7;
while ( *v11 != 95 )
{
++v11;
if ( !--v10 )
{
v11 = &v7[v39];
break;
}
}
v8 = -1;
if ( v11 != &v7[v39] )
v8 = v11 - v7;
goto LABEL_15;
}
v9 = (unsigned __int8)v5 >> 1;
v7 = a1 + 1;
v8 = -1;
v39 = v9;
if ( v9 )
goto LABEL_9;
LABEL_15:
v12 = 0;
do
{
v14 = *v4;
if ( (v14 & 1) != 0 )
{
v15 = *((_QWORD *)v4 + 1);
if ( v15 < v12 )
LABEL_77:
sub_1000547C0();
v16 = *((unsigned __int8 **)v4 + 2);
}
else
{
v15 = v14 >> 1;
v16 = v40;
if ( v12 > v15 )
goto LABEL_77;
}
v17 = v15 - v12;
if ( v17 >= v8 - v12 )
v17 = v8 - v12;
if ( v17 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(v6);
if ( v17 >= 0x17 )
{
v37 = v8;
v19 = v12;
v20 = (v17 | 7) + 1;
if ( (v17 | 7) == 0x17 )
v20 = 26;
v18 = (char *)operator new(v20);
__p = v18;
*(_QWORD *)&__dst = v20 | 1;
*((_QWORD *)&__dst + 1) = v17;
v12 = v19;
v8 = v37;
LABEL_31:
memmove(v18, &v16[v12], v17);
goto LABEL_32;
}
LOBYTE(__dst) = 2 * v17;
v18 = (char *)&__dst + 1;
if ( v17 )
goto LABEL_31;
LABEL_32:
v18[v17] = 0;
v21 = (unsigned __int8)__dst >> 1;
if ( (__dst & 1) != 0 )
v21 = *((_QWORD *)&__dst + 1);
v4 = a1;
if ( v21 || v12 != v39 )
{
v24 = v43[1];
if ( v43[1] >= v44 )
{
v25 = sub_100054890((__int64)v43, (__int64)&__dst, v6);
}
else
{
if ( (__dst & 1) != 0 )
{
sub_100006B70((_QWORD *)v43[1], __p, *((unsigned __int64 *)&__dst + 1), v6);
}
else
{
*((_QWORD *)v43[1] + 2) = __p;
v6 = *(double *)&__dst;
*v24 = __dst;
}
v25 = (char *)v24 + 24;
}
v43[1] = v25;
v22 = v12;
v23 = -1;
if ( v8 == -1 )
goto LABEL_55;
}
else
{
v22 = v12;
v23 = -1;
if ( v8 == -1 )
goto LABEL_55;
}
v26 = *a1;
if ( (v26 & 1) != 0 )
{
v27 = *((unsigned __int8 **)a1 + 2);
v28 = *((_QWORD *)a1 + 1);
v22 = v8 + 1;
if ( v28 <= v8 + 1 )
goto LABEL_55;
}
else
{
v28 = v26 >> 1;
v27 = v40;
v22 = v8 + 1;
if ( v28 <= v8 + 1 )
goto LABEL_55;
}
v29 = &v27[v22];
v30 = v28 + ~v8;
while ( *v29 != 95 )
{
++v29;
if ( !--v30 )
{
v29 = &v27[v28];
break;
}
}
v23 = v29 - v27;
if ( v29 == &v27[v28] )
v23 = -1;
LABEL_55:
if ( (__dst & 1) != 0 )
operator delete(__p);
v13 = v8 == -1;
v8 = v23;
v12 = v22;
}
while ( !v13 );
v31 = (void **)v43[0];
v32 = (void **)v43[1];
if ( (void *)((char *)v43[1] - (char *)v43[0]) != (void *)96 )
{
if ( !v43[0] )
return;
v34 = (void **)v43[0];
if ( v43[1] == v43[0] )
goto LABEL_75;
do
{
LABEL_72:
if ( (*(_BYTE *)(v32 - 3) & 1) != 0 )
operator delete(*(v32 - 1));
v32 -= 3;
}
while ( v32 != v31 );
v34 = (void **)v43[0];
goto LABEL_75;
}
if ( (*((_BYTE *)v43[0] + 24) & 1) != 0 )
v33 = *((const char **)v43[0] + 5);
else
v33 = (char *)v43[0] + 25;
*a2 = atoi(v33);
if ( ((_BYTE)v31[6] & 1) != 0 )
{
*a3 = atoi((const char *)v31[8]);
if ( ((_BYTE)v31[9] & 1) == 0 )
goto LABEL_68;
LABEL_66:
v35 = (const char *)v31[11];
}
else
{
*a3 = atoi((const char *)v31 + 49);
if ( ((_BYTE)v31[9] & 1) != 0 )
goto LABEL_66;
LABEL_68:
v35 = (char *)v31 + 73;
}
*a4 = atoi(v35);
v34 = v31;
if ( v32 != v31 )
goto LABEL_72;
LABEL_75:
v43[1] = v31;
operator delete(v34);
}