//
// GameManager::playMenuMusic from 0x14017b830 to 0x14017baa7 (631 bytes)
//
// 2 xrefs:
// > OptionsLayer::musicSliderChanged @ 0x140372a73
// > ??> @ 0x1406cb358
//
// 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
//
// Hidden C++ exception states: #wind=8
void GameManager::playMenuMusic(GameManager *a1)
{
GameManager *v2; // rcx
__int64 v3; // rbx
_QWORD *v4; // rbx
FMODAudioEngine *v5; // rcx
__int64 v6; // rdx
__int64 v7; // rcx
__int64 v8; // r8
__int64 v9; // r9
void **v10; // rsi
__int64 v11; // rbx
unsigned __int64 v12; // rdi
FMODAudioEngine *v13; // rcx
void *v14; // [rsp+30h] [rbp-29h]
FMODAudioEngine *v15; // [rsp+30h] [rbp-29h]
FMODAudioEngine *v16; // [rsp+30h] [rbp-29h]
__int128 v17; // [rsp+38h] [rbp-21h] BYREF
unsigned __int64 v18; // [rsp+48h] [rbp-11h]
__int64 v19; // [rsp+50h] [rbp-9h]
FMODAudioEngine *v20; // [rsp+58h] [rbp-1h]
_BYTE v21[32]; // [rsp+60h] [rbp+7h] BYREF
void *Src[2]; // [rsp+80h] [rbp+27h] BYREF
unsigned __int64 v23; // [rsp+90h] [rbp+37h]
unsigned __int64 v24; // [rsp+98h] [rbp+3Fh]
v2 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v14 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v14);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v2 = (GameManager *)qword_1406C2ED8;
}
if ( GameManager::getGameVariable(v2, "0122") )
{
v3 = qword_1406C2E88;
if ( !qword_1406C2E88 )
{
v15 = (FMODAudioEngine *)operator new(0x888u);
qword_1406C2E88 = (__int64)FMODAudioEngine::FMODAudioEngine(v15);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2E88 + 72LL))(qword_1406C2E88);
v3 = qword_1406C2E88;
}
if ( *(_QWORD *)(v3 + 552) )
FMOD::ChannelControl::stop(*(FMOD::ChannelControl **)(v3 + 552));
sub_14005E0D0((_QWORD *)(v3 + 1064));
sub_14005E0D0((_QWORD *)(v3 + 1128));
sub_14005E0D0((_QWORD *)(v3 + 1192));
}
else
{
GameManager::getMenuMusicFile((__int64)a1, (__int64)Src);
v4 = (_QWORD *)sub_14003BDB0((__int64)v21, (__int64)Src);
v5 = (FMODAudioEngine *)qword_1406C2E88;
if ( !qword_1406C2E88 )
{
v20 = (FMODAudioEngine *)operator new(0x888u);
qword_1406C2E88 = (__int64)FMODAudioEngine::FMODAudioEngine(v20);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2E88 + 72LL))(qword_1406C2E88);
v5 = (FMODAudioEngine *)qword_1406C2E88;
}
if ( !FMODAudioEngine::isMusicPlaying(v5, v4) )
{
v20 = (FMODAudioEngine *)&v17;
v17 = 0;
v18 = 0;
v19 = 0;
v10 = Src;
if ( v24 > 0xF )
v10 = (void **)Src[0];
v11 = 0x7FFFFFFFFFFFFFFFLL;
v12 = v23;
if ( v23 > 0x7FFFFFFFFFFFFFFFLL )
sub_140007B50(v7, v6, v8, v9);
v19 = 15;
if ( v23 > 0xF )
{
if ( (v23 | 0xF) <= 0x7FFFFFFFFFFFFFFFLL )
{
v11 = v23 | 0xF;
if ( (v23 | 0xF) < 0x16 )
v11 = 22;
}
*(_QWORD *)&v17 = sub_14003AA10(v11 + 1);
v18 = v12;
v19 = v11;
memcpy((void *)v17, v10, v12 + 1);
}
else
{
v18 = v23;
v17 = *(_OWORD *)v10;
}
v13 = (FMODAudioEngine *)qword_1406C2E88;
if ( !qword_1406C2E88 )
{
v16 = (FMODAudioEngine *)operator new(0x888u);
qword_1406C2E88 = (__int64)FMODAudioEngine::FMODAudioEngine(v16);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2E88 + 72LL))(qword_1406C2E88);
v13 = (FMODAudioEngine *)qword_1406C2E88;
}
FMODAudioEngine::playMusic(v13, (__int64)&v17, 1, 0.0);
}
sub_14003A830((__int64)Src);
}
}