//
// FMODAudioEngine::unregisterChannel from 0x1003d2450 to 0x1003d266d (541 bytes)
//
// 1 xrefs:
// > FMODAudioEngine::channelStopped @ 0x1003d2b1a
//
// 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 12:29:39 +0000
//
__int64 __fastcall FMODAudioEngine::unregisterChannel(__int64 a1, int a2, __m128 a3)
{
__int64 v3; // rsi
unsigned __int64 v4; // r9
__int64 *v5; // r14
unsigned __int64 v6; // r11
unsigned __int64 v7; // r8
__int64 **v8; // rax
__int64 *v9; // r10
unsigned __int64 v10; // r9
__int64 v11; // rax
unsigned __int64 v12; // rax
int *v14; // [rsp+8h] [rbp-28h] BYREF
int v15[7]; // [rsp+14h] [rbp-1Ch] BYREF
v15[0] = a2;
sub_10001C120((__int64 *)(a1 + 1256), v15);
sub_10001C120((__int64 *)(a1 + 1296), v15);
sub_1000E9050((__int64 *)(a1 + 1144), v15);
v3 = (unsigned int)v15[0];
v4 = *(_QWORD *)(a1 + 1352);
if ( !v4 )
return FMODAudioEngine::channelUnlinkSound(a1, v3);
v5 = (__int64 *)(a1 + 1344);
v6 = (0x101010101010101LL
* ((((v4 - ((v4 >> 1) & 0x5555555555555555LL)) & 0x3333333333333333LL)
+ (((v4 - ((v4 >> 1) & 0x5555555555555555LL)) >> 2) & 0x3333333333333333LL)
+ ((((v4 - ((v4 >> 1) & 0x5555555555555555LL)) & 0x3333333333333333LL)
+ (((v4 - ((v4 >> 1) & 0x5555555555555555LL)) >> 2) & 0x3333333333333333LL)) >> 4))
& 0xF0F0F0F0F0F0F0FLL)) >> 56;
if ( v6 <= 1 )
{
v7 = v15[0] & (v4 - 1);
v8 = *(__int64 ***)(*v5 + 8 * v7);
if ( !v8 )
return FMODAudioEngine::channelUnlinkSound(a1, v3);
goto LABEL_9;
}
v7 = v15[0];
if ( v4 > v15[0] )
{
LABEL_8:
v8 = *(__int64 ***)(*v5 + 8 * v7);
if ( !v8 )
return FMODAudioEngine::channelUnlinkSound(a1, v3);
goto LABEL_9;
}
if ( (v4 | v15[0]) >> 32 )
{
v7 = v15[0] % v4;
goto LABEL_8;
}
v7 = v15[0] % (unsigned int)v4;
v8 = *(__int64 ***)(*v5 + 8 * v7);
if ( !v8 )
return FMODAudioEngine::channelUnlinkSound(a1, v3);
LABEL_9:
v9 = *v8;
if ( *v8 )
{
if ( (unsigned int)v6 < 2 )
{
v10 = v4 - 1;
while ( 1 )
{
v11 = v9[1];
if ( v11 == v15[0] )
{
if ( *((_DWORD *)v9 + 4) == v15[0] )
goto LABEL_27;
}
else if ( (v10 & v11) != v7 )
{
return FMODAudioEngine::channelUnlinkSound(a1, v3);
}
v9 = (__int64 *)*v9;
if ( !v9 )
return FMODAudioEngine::channelUnlinkSound(a1, v3);
}
}
do
{
v12 = v9[1];
if ( v12 == v15[0] )
{
if ( *((_DWORD *)v9 + 4) == v15[0] )
{
LABEL_27:
v14 = v15;
LODWORD(v14) = *((_DWORD *)sub_10001C2C0((float *)(a1 + 1344), v15, a3, (__int64)&unk_100A09642, &v14) + 5);
sub_10001C120(v5, v15);
sub_10001C120((__int64 *)(a1 + 1384), (int *)&v14);
v3 = (unsigned int)v15[0];
return FMODAudioEngine::channelUnlinkSound(a1, v3);
}
}
else
{
if ( v12 < v4 )
goto LABEL_23;
if ( (v4 | v12) >> 32 )
{
v12 %= v4;
LABEL_23:
if ( v12 != v7 )
return FMODAudioEngine::channelUnlinkSound(a1, v3);
goto LABEL_18;
}
if ( (unsigned int)v12 % (unsigned int)v4 != v7 )
return FMODAudioEngine::channelUnlinkSound(a1, v3);
}
LABEL_18:
v9 = (__int64 *)*v9;
}
while ( v9 );
}
return FMODAudioEngine::channelUnlinkSound(a1, v3);
}