//
// GameLevelManager::onGetLeaderboardScoresCompleted from 0x100525200 to 0x1005254c9 (713 bytes)
//
// 1 xrefs:
// > GameLevelManager::handleIt @ 0x10051e786
//
// 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:45 +0000
//
__int64 __fastcall GameLevelManager::onGetLeaderboardScoresCompleted(__int64 a1, unsigned __int8 *a2, __int64 a3)
{
__int64 v4; // r14
__int64 v5; // rbx
int v6; // eax
int v7; // ecx
__int64 v8; // rax
bool v9; // zf
int v10; // eax
__int64 v11; // rax
int v12; // r12d
int v13; // r13d
char v14; // bl
const void *v15; // rdi
unsigned __int64 v16; // rax
unsigned __int64 v17; // rcx
const void *v18; // r14
size_t v19; // rdx
__int64 result; // rax
__int64 v21; // rdi
__int64 Scores; // r13
unsigned int *v23; // rax
__int64 v24; // rcx
unsigned __int64 v25; // rax
unsigned __int64 v26; // rcx
int v27; // eax
__int64 v28; // rbx
int (__cdecl *v29)(const void *, const void *); // rcx
unsigned int *v30; // rax
__int64 v31; // rcx
unsigned __int64 v32; // rax
unsigned __int64 v33; // rcx
int v34; // edx
__int64 v35; // r14
__int64 v36; // rdi
_WORD __s2[11]; // [rsp+1h] [rbp-9Fh] BYREF
__int16 v38; // [rsp+18h] [rbp-88h] BYREF
char v39; // [rsp+1Ah] [rbp-86h]
unsigned __int8 *v40; // [rsp+30h] [rbp-70h]
unsigned __int64 v41; // [rsp+38h] [rbp-68h]
__int128 v42; // [rsp+40h] [rbp-60h] BYREF
void *__p; // [rsp+50h] [rbp-50h]
__int64 v44; // [rsp+58h] [rbp-48h]
int v45; // [rsp+64h] [rbp-3Ch]
__int64 v46; // [rsp+68h] [rbp-38h]
int v47; // [rsp+74h] [rbp-2Ch]
if ( (*(_BYTE *)a3 & 1) != 0 )
v4 = *(_QWORD *)(a3 + 16);
else
v4 = a3 + 1;
v46 = a1;
GameLevelManager::removeDLFromActive(a1, v4);
v5 = sub_10053FBE0(a3, "_");
v6 = sub_1007FEF90(v5);
v7 = 0;
if ( v6 == 3 )
{
v8 = cocos2d::CCArray::stringAtIndex(v5, 1);
v7 = cocos2d::CCString::intValue(v8);
}
v47 = v7;
v44 = v4;
v9 = (unsigned int)sub_1007FEF90(v5) == 3;
v10 = 0;
if ( v9 )
{
v11 = cocos2d::CCArray::stringAtIndex(v5, 2);
v10 = cocos2d::CCString::intValue(v11);
}
v12 = 0;
v13 = v47;
v45 = v10;
if ( v47 != 3 )
v12 = v10;
strcpy((char *)__s2, "-1");
v14 = *a2;
v15 = a2 + 1;
v16 = *a2 >> 1;
v17 = *((_QWORD *)a2 + 1);
v40 = a2;
v18 = *((const void **)a2 + 2);
if ( (v14 & 1) != 0 )
v15 = *((const void **)a2 + 2);
v41 = v17;
if ( (v14 & 1) != 0 )
v16 = v17;
v19 = 2;
if ( v16 < 2 )
v19 = v16;
if ( (v16 != 2) | (memcmp(v15, __s2, v19) != 0) )
{
if ( (v14 & 1) != 0 )
{
sub_10001AD30(&v42, v18, v41);
}
else
{
__p = *((void **)v40 + 2);
v42 = *(_OWORD *)v40;
}
Scores = GameLevelManager::createAndGetScores(v46, &v42, v13 == 3);
if ( (v42 & 1) != 0 )
operator delete(__p);
if ( (unsigned int)sub_1007FEF90(Scores) != 0 && v12 != 0 && Scores != 0 )
{
v23 = *(unsigned int **)(Scores + 56);
v24 = *v23;
if ( *v23 )
{
v25 = *((_QWORD *)v23 + 2);
v26 = v25 + 8 * v24 - 8;
do
{
if ( !*(_QWORD *)v25 )
break;
*(_DWORD *)(*(_QWORD *)v25 + 840LL) = v12;
v25 += 8LL;
}
while ( v25 <= v26 );
}
}
v27 = sub_1007FEF90(Scores);
v28 = v44;
if ( v27 != 0 && v47 == 4 )
{
v29 = (unsigned int)(v45 - 1) > 2
? (int (__cdecl *)(const void *, const void *))scoreCompare
: (int (__cdecl *)(const void *, const void *))off_100B700D8[v45 - 1];
qsort(*(void **)(*(_QWORD *)(Scores + 56) + 16LL), **(unsigned int **)(Scores + 56), 8u, v29);
v30 = *(unsigned int **)(Scores + 56);
v31 = *v30;
if ( *v30 )
{
v32 = *((_QWORD *)v30 + 2);
v33 = v32 + 8 * v31 - 8;
v34 = 1;
do
{
if ( !*(_QWORD *)v32 )
break;
*(_DWORD *)(*(_QWORD *)v32 + 396LL) = v34++;
v32 += 8LL;
}
while ( v32 <= v33 );
}
}
v38 = 8194;
v39 = 0;
v35 = v46;
result = GameLevelManager::storeSearchResult(v46, Scores, &v38, v28);
v36 = *(_QWORD *)(v35 + 1296);
if ( v36 )
return (*(__int64 (__fastcall **)(__int64, __int64, __int64))(*(_QWORD *)v36 + 16LL))(v36, Scores, v28);
}
else
{
result = v46;
v21 = *(_QWORD *)(v46 + 1296);
if ( v21 )
return (*(__int64 (__fastcall **)(__int64, __int64))(*(_QWORD *)v21 + 24LL))(v21, v44);
}
return result;
}