//
// MusicDownloadManager::noteSongUsed from 0x96f21c to 0x96f3b0 (404 bytes)
//
// 2 xrefs:
// > MusicBrowser::cellPerformedAction @ 0xb83b2c
// > ??> @ 0x730d8
//
// 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::noteSongUsed(MusicDownloadManager *this, int a2)
{
char *v4; // x1
char *v5; // x3
char *v6; // x2
char *v7; // x0
int v8; // t1
__int64 v9; // x2
__int64 v10; // x0
unsigned __int64 v11; // x1
__int64 v12; // x0
char *i; // x0
int v15[3]; // [xsp+3Ch] [xbp+3Ch] BYREF
int *v16; // [xsp+50h] [xbp+50h] BYREF
v15[0] = a2;
if ( a2 > 0 )
{
v4 = *((char **)this + 94);
v5 = *((char **)this + 95);
v6 = v4;
if ( v4 != v5 )
{
if ( a2 == *(_DWORD *)v4 )
{
LABEL_12:
for ( i = v6 + 4; v5 != i; i += 4 )
{
if ( *(_DWORD *)i != v15[0] )
{
*(_DWORD *)v6 = *(_DWORD *)i;
v6 += 4;
}
}
v5 = *((char **)this + 95);
v4 = *((char **)this + 94);
}
else
{
v7 = v4 + 4;
while ( 1 )
{
v6 = v7;
if ( v5 == v7 )
break;
v8 = *(_DWORD *)v7;
v7 += 4;
if ( a2 == v8 )
goto LABEL_12;
}
}
}
if ( v6 != v5 )
*((_QWORD *)this + 95) = &v5[4 * ~((unsigned __int64)(v5 - 4 - v6) >> 2)];
std::vector::insert((_QWORD *)this + 94, v4, (char *)v15);
v9 = *((_QWORD *)this + 94);
v10 = *((_QWORD *)this + 95);
v11 = (v10 - v9) >> 2;
if ( (int)v11 > 20 )
{
if ( v11 <= 0x13 )
{
std::vector::__append((__int64)this + 752, 20 - v11);
}
else if ( v11 != 20 && v10 != v9 + 80 )
{
*((_QWORD *)this + 95) = v10 + 4 * ~((unsigned __int64)(v10 - 84 - v9) >> 2);
}
}
v16 = v15;
v12 = std::__tree,std::__map_value_compare,std::less,true>,std::allocator>>::__emplace_unique_key_args,std::tuple<>>(
(__int64 **)this + 100,
v15,
(__int64)&unk_1168A28,
&v16);
++*(_DWORD *)(v12 + 32);
}
return _stack_chk_guard;
}