//
// MusicDownloadManager::toggleSFXFavorite from 0x972bf0 to 0x972e44 (596 bytes)
//
// 2 xrefs:
// > CustomSFXWidget::onToggleFavorite @ 0xb5f0ac
// > ??> @ 0xd4c98
//
// 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:42 +0000
//
__int64 __fastcall MusicDownloadManager::toggleSFXFavorite(MusicDownloadManager *this, int a2)
{
__int64 v3; // x24
unsigned __int64 v4; // x26
unsigned __int64 v5; // x21
unsigned __int64 v6; // x24
__int64 v7; // x23
unsigned __int64 v8; // x4
__int64 v9; // x25
__int64 *v10; // x0
unsigned __int64 v11; // x1
unsigned __int64 v12; // x1
float v13; // s2
float v14; // s0
_BOOL8 v15; // x0
unsigned __int64 v16; // x24
unsigned __int64 v17; // x1
_QWORD *v18; // x0
__int64 v20; // x1
unsigned __int64 v21; // x1
unsigned __int64 v22; // x24
int v23; // [xsp+5Ch] [xbp+5Ch] BYREF
void *v24[3]; // [xsp+60h] [xbp+60h] BYREF
v23 = a2;
if ( a2 <= 0 )
return _stack_chk_guard;
v3 = std::__hash_table,std::equal_to,std::allocator>::__erase_unique(
(__int64 *)this + 76,
&v23);
if ( v3 )
return _stack_chk_guard;
v4 = *((_QWORD *)this + 77);
v5 = v23;
if ( v4 )
{
v6 = v4 - 1;
v7 = (v4 - 1) & v4;
v8 = (v4 - 1) & v23;
if ( v7 )
v8 = v23 % v4;
v9 = 8 * v8;
v10 = *(__int64 **)(*((_QWORD *)this + 76) + 8 * v8);
if ( v10 )
{
while ( 1 )
{
v10 = (__int64 *)*v10;
if ( !v10 )
break;
v11 = v10[1];
v12 = v7 ? v11 % v4 : v6 & v11;
if ( v8 != v12 )
break;
if ( v23 == *((_DWORD *)v10 + 4) )
return _stack_chk_guard;
}
}
std::__hash_table,std::equal_to,std::allocator>::__construct_node_hash(
(__int64)this + 608,
v23,
&v23,
(__int64)v24);
v13 = *((float *)this + 160);
v14 = (float)(unsigned __int64)(*((_QWORD *)this + 79) + 1LL);
if ( v14 <= (float)((float)v4 * v13) )
goto LABEL_18;
v15 = 1;
v3 = 2 * v4;
if ( v4 > 2 )
v15 = v7 != 0;
}
else
{
std::__hash_table,std::equal_to,std::allocator>::__construct_node_hash(
(__int64)this + 608,
v23,
&v23,
(__int64)v24);
v15 = 1;
v13 = *((float *)this + 160);
v14 = (float)(unsigned __int64)(*((_QWORD *)this + 79) + 1LL);
}
v16 = v15 + v3;
v17 = vcvtps_u32_f32(v14 / v13);
if ( v17 < v16 )
v17 = v16;
std::__hash_table,std::equal_to,std::allocator>::rehash(
(unsigned __int64)this + 608,
v17);
v4 = *((_QWORD *)this + 77);
v6 = v4 - 1;
if ( ((v4 - 1) & v4) != 0 )
v9 = 8 * (v5 % v4);
else
v9 = 8 * (v6 & v5);
LABEL_18:
v18 = *(_QWORD **)(*((_QWORD *)this + 76) + v9);
if ( v18 )
{
*(_QWORD *)v24[0] = *v18;
*v18 = v24[0];
}
else
{
*(_QWORD *)v24[0] = *((_QWORD *)this + 78);
v20 = *((_QWORD *)this + 76);
*((void **)this + 78) = v24[0];
*(_QWORD *)(v20 + v9) = (char *)this + 624;
if ( *(_QWORD *)v24[0] )
{
v21 = *(_QWORD *)(*(_QWORD *)v24[0] + 8LL);
if ( (v6 & v4) != 0 )
v22 = v21 % v4;
else
v22 = v6 & v21;
*(void **)(*((_QWORD *)this + 76) + 8 * v22) = v24[0];
}
}
++*((_QWORD *)this + 79);
return _stack_chk_guard;
}