//
// GameManager::getMenuMusicFile from 0x5e89cc to 0x5e8b10 (324 bytes)
//
// 3 xrefs:
// > GameManager::playMenuMusic @ 0x5efdd4
// > GameManager::fadeInMenuMusic @ 0x5f0094
// > ??> @ 0x7fe00
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
__int64 __usercall GameManager::getMenuMusicFile@(GameManager *this@, __int64 a2@)
{
MusicDownloadManager *v4; // x0
MusicDownloadManager *v6; // x0
char *v7; // x0
unsigned int *v8; // x2
int v9; // w1
char *v10; // [xsp+40h] [xbp+40h] BYREF
if ( this->m_customMenuSongID <= 0 )
goto LABEL_4;
v4 = MusicDownloadManager::sharedState();
if ( !MusicDownloadManager::isSongDownloaded(v4, this->m_customMenuSongID) )
{
this->m_customMenuSongID = 0;
LABEL_4:
sub_D153B8(a2, "menuLoop.mp3");
return a2;
}
if ( this->m_customMenuSongID <= 0 )
goto LABEL_4;
v6 = MusicDownloadManager::sharedState();
MusicDownloadManager::pathForSong((__int64 *)&v10, v6, this->m_customMenuSongID);
sub_D153B8(a2, v10);
v7 = v10 - 24;
if ( v10 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v8 = (unsigned int *)(v10 - 8);
do
v9 = __ldaxr(v8);
while ( __stlxr(v9 - 1, v8) );
}
else
{
v9 = *((_DWORD *)v10 - 2);
*((_DWORD *)v10 - 2) = v9 - 1;
}
if ( v9 <= 0 )
operator delete(v7);
}
return a2;
}