//
// sub_1400660E0 from 0x1400660e0 to 0x14006630e (558 bytes)
//
// 4 xrefs:
// > FMODAudioEngine::updateChannel @ 0x14006183a
// > FMODAudioEngine::setChannelVolume @ 0x140061a3c
// > FMODAudioEngine::setChannelVolumeMod @ 0x140061c0c
// > ??> @ 0x140910e2c
//
// 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:45 +0000
//
// Hidden C++ exception states: #wind=2
__int64 __fastcall sub_1400660E0(_QWORD *a1, __int64 a2, unsigned __int8 *a3, double *a4)
{
unsigned __int64 v8; // rbp
__int64 v9; // rdx
__int64 v10; // rcx
__int64 *v11; // rax
__int64 **v12; // r12
__int64 *v13; // rsi
__int64 *v14; // rdx
float *v16; // rbx
float v17; // xmm0_4
__int64 v18; // rdx
float v19; // xmm0_4
__int64 v20; // rcx
float v21; // xmm1_4
__int64 v22; // rax
unsigned __int64 v23; // rax
__int64 v24; // rdx
__int64 *v25; // rax
__int64 *v26; // rdx
int v27; // ecx
float **v28; // rdx
__int64 v29; // rax
__int64 v30; // rcx
__int64 *v31; // r8
v8 = 0x100000001B3LL
* (a3[3]
^ (0x100000001B3LL * (a3[2] ^ (0x100000001B3LL * (a3[1] ^ (0x100000001B3LL * (*a3 ^ 0xCBF29CE484222325uLL)))))));
v9 = 2 * (a1[6] & v8);
v10 = a1[3];
v11 = *(__int64 **)(v10 + 8 * v9 + 8);
v12 = (__int64 **)(a1 + 1);
v13 = (__int64 *)a1[1];
if ( v11 == v13 )
goto LABEL_8;
v14 = *(__int64 **)(v10 + 8 * v9);
if ( *(_DWORD *)a3 != *((_DWORD *)v11 + 4) )
{
while ( v11 != v14 )
{
v11 = (__int64 *)v11[1];
if ( *(_DWORD *)a3 == *((_DWORD *)v11 + 4) )
goto LABEL_5;
}
v13 = v11;
LABEL_8:
if ( a1[2] == 0xAAAAAAAAAAAAAAALL )
std::_Xlength_error("unordered_map/set too long");
v16 = (float *)operator new(0x18u);
v16[4] = *(float *)a3;
v17 = *a4;
v16[5] = v17;
v18 = a1[2] + 1LL;
if ( v18 < 0 )
v19 = (float)(v18 & 1 | (unsigned int)((unsigned __int64)v18 >> 1))
+ (float)(v18 & 1 | (unsigned int)((unsigned __int64)v18 >> 1));
else
v19 = (float)(int)v18;
v20 = a1[7];
if ( v20 < 0 )
{
v22 = a1[7] & 1LL | ((unsigned __int64)v20 >> 1);
v21 = (float)(int)v22 + (float)(int)v22;
}
else
{
v21 = (float)(int)v20;
}
if ( (float)(v19 / v21) > *(float *)a1 )
{
v23 = sub_14006A6B0(a1, v18);
sub_14003F310(a1, v23);
v24 = a1[3];
v25 = *(__int64 **)(v24 + 16 * (v8 & a1[6]) + 8);
v13 = *v12;
if ( v25 != *v12 )
{
v26 = *(__int64 **)(v24 + 16 * (v8 & a1[6]));
v27 = *((_DWORD *)v16 + 4);
if ( v27 == *((_DWORD *)v25 + 4) )
{
LABEL_21:
v13 = (__int64 *)*v25;
}
else
{
while ( v25 != v26 )
{
v25 = (__int64 *)v25[1];
if ( v27 == *((_DWORD *)v25 + 4) )
goto LABEL_21;
}
v13 = v25;
}
}
}
v28 = (float **)v13[1];
++a1[2];
*(_QWORD *)v16 = v13;
*((_QWORD *)v16 + 1) = v28;
*v28 = v16;
v13[1] = (__int64)v16;
v29 = 2 * (v8 & a1[6]);
v30 = a1[3];
v31 = *(__int64 **)(v30 + 16 * (v8 & a1[6]));
if ( v31 == *v12 )
{
*(_QWORD *)(v30 + 16 * (v8 & a1[6])) = v16;
LABEL_28:
*(_QWORD *)(v30 + 8 * v29 + 8) = v16;
goto LABEL_29;
}
if ( v31 == v13 )
{
*(_QWORD *)(v30 + 16 * (v8 & a1[6])) = v16;
}
else if ( *(float ***)(v30 + 16 * (v8 & a1[6]) + 8) == v28 )
{
goto LABEL_28;
}
LABEL_29:
*(_QWORD *)a2 = v16;
*(_BYTE *)(a2 + 8) = 1;
return a2;
}
LABEL_5:
*(_QWORD *)a2 = v11;
*(_BYTE *)(a2 + 8) = 0;
return a2;
}