//
// GameManager::fadeInMusic from 0x5e8c54 to 0x5e8e0c (440 bytes)
//
// 12 xrefs:
// > GameManager::fadeInMenuMusic @ 0x5f00a0
// > SecretLayer::init @ 0x905cd0
// > GJShopLayer::onBack @ 0x92b550
// > SecretLayer2::init @ 0x9422dc
// > SecretLayer3::init @ 0x944d3c
// > SecretLayer4::init @ 0x94a84c
// > LevelAreaInnerLayer::tryResumeTowerMusic @ 0xa2d568
// > LevelAreaLayer::init @ 0xa2f6e4
// > SecretRewardsLayer::init @ 0xa62494
// > SecretLayer5::init @ 0xa95b7c
// > SecretLayer6::init @ 0xa96ee8
// > ??> @ 0x9b9a0
//
// 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 __fastcall GameManager::fadeInMusic(__int64 a1, _QWORD *a2)
{
FMODAudioEngine *v4; // x21
_BOOL4 isMusicPlaying; // w23
void *v6; // x0
FMODAudioEngine *v7; // x23
void *v8; // x0
unsigned int *v9; // x20
int v10; // w1
unsigned int *v11; // x1
int v12; // w2
__int64 v13; // [xsp+0h] [xbp+0h] BYREF
__int64 v14; // [xsp+50h] [xbp+50h] BYREF
if ( *(_QWORD *)(*a2 - 24LL) )
{
v4 = FMODAudioEngine::sharedEngine();
sub_D18D28(&v14, a2);
isMusicPlaying = FMODAudioEngine::isMusicPlaying(v4, (unsigned int)&v13 + 80);
v6 = (void *)(v14 - 24);
if ( (__int64 *)(v14 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v11 = (unsigned int *)(v14 - 8);
do
v12 = __ldaxr(v11);
while ( __stlxr(v12 - 1, v11) );
}
else
{
v12 = *(_DWORD *)(v14 - 8);
*(_DWORD *)(v14 - 8) = v12 - 1;
}
if ( v12 <= 0 )
operator delete(v6);
}
if ( !isMusicPlaying )
{
v7 = FMODAudioEngine::sharedEngine();
sub_D18D28(&v14, a2);
FMODAudioEngine::playMusic(v7, (__int64)&v14, 1u, 0, 1.0);
v8 = (void *)(v14 - 24);
if ( (__int64 *)(v14 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v9 = (unsigned int *)(v14 - 8);
do
v10 = __ldaxr(v9);
while ( __stlxr(v10 - 1, v9) );
}
else
{
v10 = *(_DWORD *)(v14 - 8);
*(_DWORD *)(v14 - 8) = v10 - 1;
}
if ( v10 <= 0 )
operator delete(v8);
}
}
}
return _stack_chk_guard;
}