//
// MusicDownloadManager::getAllMusicObjectsSorted from 0x971c44 to 0x971dc4 (384 bytes)
//
// 2 xrefs:
// > MusicSearchResult::updateObjects @ 0x971e00
// > ??> @ 0xb16b8
//
// This function is hookable on this platform (idp: arm, 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:57:41 +0000
//
cocos2d::CCArray *__fastcall MusicDownloadManager::getAllMusicObjectsSorted(__int64 a1, int a2, int a3)
{
__int64 **v4; // x22
__int64 **v5; // x0
int v6; // w19
__int64 **v7; // x4
cocos2d::CCArray *AllMusicObjects; // x23
__int64 v10; // x24
int v11; // w1
bool v12; // cc
__int64 v13; // x1
int v14; // w1
__int64 *v15; // x1
__int64 v16; // x0
__int64 **v18; // [xsp+50h] [xbp+50h]
v4 = (__int64 **)(a1 + 496);
v5 = *(__int64 ***)(a1 + 496);
v6 = a3 + 100 * a2;
if ( v5 )
{
v7 = v4;
do
{
while ( v6 <= *((_DWORD *)v5 + 8) )
{
v7 = v5;
v5 = (__int64 **)*v5;
if ( !v5 )
goto LABEL_5;
}
v5 = (__int64 **)v5[1];
}
while ( v5 );
LABEL_5:
if ( v4 != v7 && v6 >= *((_DWORD *)v7 + 8) )
return (cocos2d::CCArray *)v7[5];
}
AllMusicObjects = (cocos2d::CCArray *)MusicDownloadManager::getAllMusicObjects(a1, a2);
sub_959FEC(AllMusicObjects, a3);
cocos2d::CCObject::retain(AllMusicObjects);
v10 = *(_QWORD *)(a1 + 496);
if ( v10 )
{
v11 = *(_DWORD *)(v10 + 32);
v12 = v6 <= v11;
if ( v6 >= v11 )
goto LABEL_14;
while ( 1 )
{
v13 = *(_QWORD *)v10;
if ( !*(_QWORD *)v10 )
break;
while ( 1 )
{
v10 = v13;
v14 = *(_DWORD *)(v13 + 32);
v12 = v6 <= v14;
if ( v6 < v14 )
break;
LABEL_14:
if ( v12 )
goto LABEL_21;
v13 = *(_QWORD *)(v10 + 8);
if ( !v13 )
{
v18 = (__int64 **)v10;
v4 = (__int64 **)(v10 + 8);
goto LABEL_18;
}
}
}
v18 = (__int64 **)v10;
v4 = (__int64 **)v10;
}
else
{
v18 = v4;
}
LABEL_18:
v10 = operator new(0x30u);
*(_QWORD *)v10 = 0;
v15 = (__int64 *)v10;
*(_DWORD *)(v10 + 32) = v6;
*(_QWORD *)(v10 + 40) = 0;
*(_QWORD *)(v10 + 8) = 0;
*(_QWORD *)(v10 + 16) = v18;
*v4 = (__int64 *)v10;
v16 = **(_QWORD **)(a1 + 488);
if ( v16 )
{
*(_QWORD *)(a1 + 488) = v16;
v15 = *v4;
}
std::__tree_balance_after_insert *>(*(__int64 **)(a1 + 496), v15);
++*(_QWORD *)(a1 + 504);
LABEL_21:
*(_QWORD *)(v10 + 40) = AllMusicObjects;
return AllMusicObjects;
}