//
// MusicDownloadManager::noteSFXUsed from 0x96f04c to 0x96f21c (464 bytes)
//
// 2 xrefs:
// > SFXBrowser::cellPerformedAction @ 0xb981fc
// > ??> @ 0x102190
//
// 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:40 +0000
//
__int64 __fastcall MusicDownloadManager::noteSFXUsed(MusicDownloadManager *this, int a2, int a3)
{
unsigned __int64 v5; // x1
_DWORD *v6; // x3
_DWORD *v7; // x0
_DWORD *v8; // x2
__int64 v9; // x2
__int64 v10; // x0
unsigned __int64 v11; // x1
__int64 v12; // x0
unsigned __int64 *v14; // x21
int v15; // [xsp+3Ch] [xbp+3Ch] BYREF
int v16; // [xsp+48h] [xbp+48h] BYREF
int v17; // [xsp+4Ch] [xbp+4Ch]
int *v18; // [xsp+50h] [xbp+50h] BYREF
v15 = a2;
if ( a2 <= 0 )
return _stack_chk_guard;
v5 = *((_QWORD *)this + 91);
v6 = *((_DWORD **)this + 92);
if ( a3 < 0 )
a3 = 0;
v16 = a2;
v7 = (_DWORD *)v5;
v17 = a3;
if ( (_DWORD *)v5 == v6 )
goto LABEL_17;
while ( a2 != *v7 || a3 != v7[1] )
{
v7 += 2;
if ( v6 == v7 )
goto LABEL_17;
}
v8 = v7;
if ( v6 != v7 )
{
while ( 1 )
{
v8 += 2;
if ( v6 == v8 )
break;
while ( *v8 == v16 && v8[1] == v17 )
{
v8 += 2;
if ( v6 == v8 )
goto LABEL_16;
}
*v7 = *v8;
v7 += 2;
*(v7 - 1) = v8[1];
}
LABEL_16:
v6 = *((_DWORD **)this + 92);
v5 = *((_QWORD *)this + 91);
LABEL_17:
v14 = (unsigned __int64 *)((char *)this + 728);
if ( v6 != v7 )
*((_QWORD *)this + 92) = &v6[2 * ~((unsigned __int64)((char *)(v6 - 2) - (char *)v7) >> 3)];
goto LABEL_19;
}
v14 = (unsigned __int64 *)((char *)this + 728);
LABEL_19:
std::vector>::insert(v14, v5, (unsigned __int64)&v16);
v9 = *((_QWORD *)this + 91);
v10 = *((_QWORD *)this + 92);
v11 = (v10 - v9) >> 3;
if ( (int)v11 > 30 )
{
if ( v11 <= 0x1D )
{
std::vector>::__append((__int64 *)v14, 30 - v11);
}
else if ( v11 != 30 && v10 != v9 + 240 )
{
*((_QWORD *)this + 92) = v10 + 8 * ~((unsigned __int64)(v10 - 248 - v9) >> 3);
}
}
v18 = &v15;
v12 = std::__tree,std::__map_value_compare,std::less,true>,std::allocator>>::__emplace_unique_key_args,std::tuple<>>(
(__int64 **)this + 97,
&v15,
(__int64)&unk_1168A28,
&v18);
++*(_DWORD *)(v12 + 32);
return _stack_chk_guard;
}