//
// FMODAudioEngine::stopAndGetFade from 0x140061620 to 0x14006175f (319 bytes)
//
// 5 xrefs:
// > FMODAudioEngine::stopChannel_1 @ 0x1400614d9
// > FMODAudioEngine::fadeInMusic @ 0x1400653d2
// > FMODAudioEngine::fadeOutMusic @ 0x140065517
// > FMODAudioEngine::fadeMusic @ 0x14006565a
// > ??> @ 0x140910b14
//
// This function is hookable on this platform (idp: pc, 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 11:25:44 +0000
//
float __fastcall FMODAudioEngine::stopAndGetFade(__int64 a1, __int64 a2)
{
int FadePoints; // eax
bool v5; // zf
int v6; // eax
__int64 v7; // r8
__int64 v8; // rdx
int v9; // ecx
float v10; // xmm1_4
unsigned __int64 v11; // rax
int v12; // ecx
float v13; // xmm0_4
unsigned __int64 v15; // rax
__int64 v16; // [rsp+20h] [rbp-18h] BYREF
__int64 v17; // [rsp+28h] [rbp-10h]
int v18; // [rsp+48h] [rbp+10h] BYREF
float v19; // [rsp+50h] [rbp+18h] BYREF
float v20; // [rsp+54h] [rbp+1Ch]
__int64 v21; // [rsp+58h] [rbp+20h] BYREF
if ( !a2 )
return 1.0;
v18 = 0;
FadePoints = FMOD_Channel_GetFadePoints(a2, &v18, 0, 0);
v5 = v18 == 0;
*(_DWORD *)(a1 + 608) = FadePoints;
if ( v5 )
return 1.0;
FMOD_Channel_GetDSPClock(a2, 0, &v21);
*(_DWORD *)(a1 + 608) = FMOD::ChannelControl::getDSPClock(a2, 0, &v21);
v6 = FMOD_Channel_GetFadePoints(a2, &v18, &v16, &v19);
v7 = v17;
v8 = v16;
*(_DWORD *)(a1 + 608) = v6;
FMOD_Channel_RemoveFadePoints(a2, v8, v7);
v9 = v17 - v16;
if ( v17 - v16 < 0 )
{
v11 = v9 & 1 | ((unsigned __int64)(v17 - v16) >> 1);
v10 = (float)(int)v11 + (float)(int)v11;
}
else
{
v10 = (float)v9;
}
v12 = v21 - v16;
v13 = (float)(v20 - v19) / v10;
if ( v21 - v16 >= 0 )
return (float)(v13 * (float)v12) + v19;
v15 = v12 & 1 | ((unsigned __int64)(v21 - v16) >> 1);
return (float)(v13 * (float)((float)(int)v15 + (float)(int)v15)) + v19;
}