//
// MusicDownloadManager::toggleMusicFavorite from 0x57702c to 0x5771c4 (408 bytes)
//
// 1 xrefs:
// > CustomSongWidget::onToggleFavorite @ 0x4e4f06
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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:52:43 +0000
//
void __fastcall MusicDownloadManager::toggleMusicFavorite(MusicDownloadManager *this, int a2)
{
int v2; // r6
char *v4; // r9
unsigned int v5; // r4
unsigned int v6; // r8
unsigned int v7; // r11
_DWORD *v8; // r3
unsigned int v9; // r0
int v10; // r1
float v11; // s13
float v12; // s15
bool v13; // r6
unsigned int v14; // r4
unsigned int v15; // r1
void **v16; // r3
unsigned int v17; // r0
int v18; // r1
unsigned int v19; // [sp+Ch] [bp-18h] BYREF
void *v20; // [sp+10h] [bp-14h] BYREF
v19 = a2;
if ( a2 <= 0 )
return;
v4 = (char *)this + 464;
if ( std::__hash_table,std::equal_to,std::allocator>::__erase_unique(
(int *)this + 116,
&v19) )
{
return;
}
v5 = *((_DWORD *)this + 117);
v6 = v19;
if ( v5 )
{
v7 = v5 - 1;
v2 = ((v5 - 1) & v5) != 0 ? v19 % v5 : v7 & v19;
v8 = *(_DWORD **)(*((_DWORD *)this + 116) + 4 * v2);
if ( v8 )
{
while ( 1 )
{
v8 = (_DWORD *)*v8;
if ( !v8 )
break;
v9 = v8[1];
v10 = ((v5 - 1) & v5) != 0 ? v9 % v5 : v7 & v9;
if ( v10 != v2 )
break;
if ( v8[2] == v19 )
return;
}
}
}
std::__hash_table,std::equal_to,std::allocator>::__construct_node_hash(
(int)&v20,
(int)v4,
v19,
&v19);
v11 = *((float *)this + 120);
v12 = (float)(unsigned int)(*((_DWORD *)this + 119) + 1);
if ( v12 > (float)((float)v5 * v11) )
{
v13 = v5 > 2 && ((v5 - 1) & v5) == 0;
goto LABEL_16;
}
if ( !v5 )
{
v13 = 0;
LABEL_16:
v14 = 2 * v5 + !v13;
v15 = (unsigned int)ceilf(v12 / v11);
if ( v15 < v14 )
v15 = v14;
std::__hash_table,std::equal_to,std::allocator>::rehash((int)v4, v15);
v5 = *((_DWORD *)this + 117);
if ( ((v5 - 1) & v5) != 0 )
v2 = v6 % v5;
else
v2 = (v5 - 1) & v6;
}
v16 = *(void ***)(*((_DWORD *)this + 116) + 4 * v2);
if ( v16 )
{
*(_DWORD *)v20 = *v16;
*v16 = v20;
}
else
{
*(_DWORD *)v20 = *((_DWORD *)this + 118);
*((_DWORD *)this + 118) = v20;
*(_DWORD *)(*((_DWORD *)this + 116) + 4 * v2) = (char *)this + 472;
if ( *(_DWORD *)v20 )
{
v17 = *(_DWORD *)(*(_DWORD *)v20 + 4);
if ( ((v5 - 1) & v5) != 0 )
v18 = v17 % v5;
else
v18 = (v5 - 1) & v17;
*(_DWORD *)(*((_DWORD *)this + 116) + 4 * v18) = v20;
}
}
++*((_DWORD *)this + 119);
}