//
// LeaderboardsLayer::selectLeaderboard from 0x1403dc440 to 0x1403dc7a1 (865 bytes)
//
// 8 xrefs:
// > LeaderboardsLayer::init @ 0x1403db706
// > LeaderboardsLayer::onStat @ 0x1403dc3b3
// > LeaderboardsLayer::onTop @ 0x1403dc3d5
// > LeaderboardsLayer::onWeek @ 0x1403dc3f5
// > LeaderboardsLayer::onGlobal @ 0x1403dc415
// > LeaderboardsLayer::onCreators @ 0x1403dc435
// > LeaderboardsLayer::updateUserScoreFinished @ 0x1403dca7a
// > ??> @ 0x140924c98
//
// 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 11:31:39 +0000
//
// Hidden C++ exception states: #wind=10
void __fastcall LeaderboardsLayer::selectLeaderboard(__int64 a1, int a2, int a3)
{
__int64 v6; // rcx
__int64 v7; // rdx
int v8; // r14d
__int64 v9; // rax
cocos2d::CCString *v10; // rax
const char *CString; // rax
size_t v12; // r8
void **v13; // rdi
__int64 v14; // rcx
__int64 StoredOnlineLevels; // rax
void **v16; // r8
__int64 v17; // rbx
__int64 v18; // rcx
void *v19; // rcx
__int64 v20; // rbx
__int64 v21; // rcx
void *v22; // [rsp+30h] [rbp-58h]
void *v23; // [rsp+30h] [rbp-58h]
void *v24; // [rsp+30h] [rbp-58h]
void *v25; // [rsp+30h] [rbp-58h]
void *v26; // [rsp+30h] [rbp-58h]
void *v27; // [rsp+30h] [rbp-58h]
void *Block[2]; // [rsp+38h] [rbp-50h] BYREF
__int64 v29; // [rsp+48h] [rbp-40h]
unsigned __int64 v30; // [rsp+50h] [rbp-38h]
if ( *(_DWORD *)(a1 + 440) != a2 || *(_DWORD *)(a1 + 444) != a3 )
{
*(_DWORD *)(a1 + 440) = a2;
*(_DWORD *)(a1 + 444) = a3;
v6 = *(_QWORD *)&qword_14090BFB0;
if ( !*(_QWORD *)&qword_14090BFB0 )
{
v22 = operator new(0x690u);
*(_QWORD *)&qword_14090BFB0 = GameLevelManager::GameLevelManager((__int64)v22);
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)&qword_14090BFB0 + 72LL))(*(_QWORD *)&qword_14090BFB0);
v6 = *(_QWORD *)&qword_14090BFB0;
}
*(_DWORD *)(v6 + 1336) = *(_DWORD *)(a1 + 440);
*(_DWORD *)(v6 + 1340) = *(_DWORD *)(a1 + 444);
LeaderboardsLayer::toggleTabButtons(a1);
LOBYTE(v7) = 1;
(*(void (__fastcall **)(_QWORD, __int64))(**(_QWORD **)(a1 + 480) + 336LL))(*(_QWORD *)(a1 + 480), v7);
(*(void (__fastcall **)(_QWORD, _QWORD))(**(_QWORD **)(a1 + 488) + 336LL))(*(_QWORD *)(a1 + 488), 0);
v8 = 0;
if ( *(_DWORD *)(a1 + 440) != 3 )
v8 = a3;
v9 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v23 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v23);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v9 = qword_14090BFD0;
}
if ( *(_BYTE *)(v9 + 688) )
{
if ( !*(_QWORD *)&qword_14090BFB0 )
{
v24 = operator new(0x690u);
*(_QWORD *)&qword_14090BFB0 = GameLevelManager::GameLevelManager((__int64)v24);
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)&qword_14090BFB0 + 72LL))(*(_QWORD *)&qword_14090BFB0);
}
v10 = cocos2d::CCString::createWithFormat("lb_%i_%i", *(_DWORD *)(a1 + 440), v8);
CString = cocos2d::CCString::getCString(v10);
*(_OWORD *)Block = 0;
v29 = 0;
v30 = 0;
v12 = -1;
do
++v12;
while ( CString[v12] );
sub_14003D230(Block, CString, v12);
v13 = Block;
if ( v30 > 0xF )
v13 = (void **)Block[0];
v14 = *(_QWORD *)&qword_14090BFB0;
if ( !*(_QWORD *)&qword_14090BFB0 )
{
v25 = operator new(0x690u);
*(_QWORD *)&qword_14090BFB0 = GameLevelManager::GameLevelManager((__int64)v25);
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)&qword_14090BFB0 + 72LL))(*(_QWORD *)&qword_14090BFB0);
v14 = *(_QWORD *)&qword_14090BFB0;
}
StoredOnlineLevels = GameLevelManager::getStoredOnlineLevels(v14, v13);
if ( StoredOnlineLevels )
{
v16 = Block;
if ( v30 > 0xF )
v16 = (void **)Block[0];
(*(void (__fastcall **)(__int64, __int64, void **))(*(_QWORD *)(a1 + 408) + 16LL))(
a1 + 408,
StoredOnlineLevels,
v16);
}
else
{
LeaderboardsLayer::setupLevelBrowser((__int64 *)a1, nullptr);
v17 = a1 + 408;
v18 = *(_QWORD *)&qword_14090BFB0;
if ( !*(_QWORD *)&qword_14090BFB0 )
{
v26 = operator new(0x690u);
*(_QWORD *)&qword_14090BFB0 = GameLevelManager::GameLevelManager((__int64)v26);
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)&qword_14090BFB0 + 72LL))(*(_QWORD *)&qword_14090BFB0);
v18 = *(_QWORD *)&qword_14090BFB0;
}
*(_QWORD *)(v18 + 1424) = v17;
GameLevelManager::getLeaderboardScores(v18, a2, v8);
}
if ( v30 > 0xF )
{
v19 = Block[0];
if ( v30 + 1 >= 0x1000 )
{
v19 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v19 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v19);
}
}
else
{
LeaderboardsLayer::setupLevelBrowser((__int64 *)a1, nullptr);
v20 = a1 + 408;
v21 = *(_QWORD *)&qword_14090BFB0;
if ( !*(_QWORD *)&qword_14090BFB0 )
{
v27 = operator new(0x690u);
*(_QWORD *)&qword_14090BFB0 = GameLevelManager::GameLevelManager((__int64)v27);
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)&qword_14090BFB0 + 72LL))(*(_QWORD *)&qword_14090BFB0);
v21 = *(_QWORD *)&qword_14090BFB0;
}
*(_QWORD *)(v21 + 1424) = v20;
GameLevelManager::updateUserScore(v21);
}
}
}