//
// FMODAudioEngine::channelUnlinkSound from 0x6d43d4 to 0x6d46cc (760 bytes)
//
// 2 xrefs:
// > FMODAudioEngine::unregisterChannel @ 0x6d4830
// > ??> @ 0xa63a8
//
// This function is hookable on this platform (idp: arm, 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:51:29 +0000
//
__int64 __fastcall FMODAudioEngine::channelUnlinkSound(FMODAudioEngine *this, int a2)
{
unsigned __int64 v3; // x3
unsigned __int64 v4; // x6
unsigned __int64 v5; // x4
__int64 *v6; // x0
unsigned __int64 v7; // x19
unsigned __int64 v8; // x19
__int64 v10; // x0
__int64 v11; // x1
__int64 v12; // x0
int v13; // w4
unsigned __int64 v14; // x1
unsigned __int64 v15; // x6
__int64 v16; // x3
unsigned __int64 v17; // x5
__int64 v18; // x8
void **v19; // x0
__int64 *v20; // x19
unsigned __int64 v21; // x2
unsigned __int64 v22; // x0
__int64 v23; // x5
unsigned __int64 v24; // x4
__int64 v25; // x7
__int64 *i; // x2
unsigned __int64 v27; // x0
unsigned __int64 v28; // x0
unsigned __int64 v29; // x0
__int64 v30; // x0
unsigned __int64 v31; // x7
int v32; // [xsp+3Ch] [xbp+3Ch] BYREF
__int64 v33; // [xsp+40h] [xbp+40h] BYREF
__int64 v34; // [xsp+48h] [xbp+48h]
void *v35; // [xsp+50h] [xbp+50h]
v32 = a2;
v3 = *((_QWORD *)this + 179);
if ( v3 )
{
v4 = v3 - 1;
v5 = ((v3 - 1) & v3) != 0 ? a2 % v3 : v4 & a2;
v6 = *(__int64 **)(*((_QWORD *)this + 178) + 8 * v5);
if ( v6 )
{
do
{
v6 = (__int64 *)*v6;
if ( v6 )
{
v7 = v6[1];
v8 = ((v3 - 1) & v3) != 0 ? v7 % v3 : v4 & v7;
if ( v5 == v8 )
continue;
}
return _stack_chk_guard;
}
while ( a2 != *((_DWORD *)v6 + 4) );
v10 = std::unordered_map::operator[]((__int64)this + 1424, &v32);
v33 = 0;
v34 = 0;
v35 = nullptr;
if ( (*(_BYTE *)v10 & 1) != 0 )
{
std::string::__init(&v33, *(void **)(v10 + 16), *(_QWORD *)(v10 + 8));
}
else
{
v11 = *(_QWORD *)(v10 + 8);
v33 = *(_QWORD *)v10;
v34 = v11;
v35 = *(void **)(v10 + 16);
}
if ( !std::__hash_table,std::__unordered_map_hasher,std::hash,true>,std::__unordered_map_equal,std::equal_to,true>,std::allocator>>::find(
(_QWORD *)this + 45,
(__int64)&v33) )
{
if ( (v33 & 1) == 0 )
return _stack_chk_guard;
goto LABEL_31;
}
v12 = std::unordered_map::operator[]((unsigned __int64)this + 360, &v33);
v13 = v32;
--*(_DWORD *)(v12 + 36);
v14 = *((_QWORD *)this + 179);
if ( !v14
|| ((v15 = v14 - 1, (v16 = (v14 - 1) & v14) == 0) ? (v17 = v15 & v13) : (v17 = v13 % v14),
(v18 = *((_QWORD *)this + 178), (v19 = *(void ***)(v18 + 8 * v17)) == nullptr)
|| (v20 = (__int64 *)*v19) == nullptr) )
{
LABEL_28:
if ( (v33 & 1) == 0 )
return _stack_chk_guard;
LABEL_31:
operator delete(v35);
return _stack_chk_guard;
}
while ( 1 )
{
v21 = v20[1];
v22 = v15 & v21;
if ( v16 )
v22 = v21 % v14;
if ( v17 != v22 )
goto LABEL_28;
if ( v13 == *((_DWORD *)v20 + 4) )
break;
v20 = (__int64 *)*v20;
if ( !v20 )
goto LABEL_28;
}
v23 = *v20;
v24 = v21 & v15;
v25 = *v20;
if ( v16 )
v24 = v21 % v14;
for ( i = *(__int64 **)(v18 + 8 * v24); (__int64 *)*i != v20; i = (__int64 *)*i )
;
if ( i == (__int64 *)((char *)this + 1440)
|| ((v27 = i[1], v16) ? (v28 = v27 % v14) : (v28 = v15 & v27), v24 != v28) )
{
if ( v23 )
{
v29 = *(_QWORD *)(v23 + 8);
if ( v16 )
{
v31 = v29 / v14;
if ( v24 == v29 % v14 )
goto LABEL_50;
}
else
{
v30 = v15 & v29;
if ( v24 == v30 )
goto LABEL_51;
}
}
*(_QWORD *)(v18 + 8 * v24) = 0;
v23 = *v20;
v25 = *v20;
}
if ( !v23 )
goto LABEL_53;
v29 = *(_QWORD *)(v23 + 8);
if ( !v16 )
{
v30 = v15 & v29;
LABEL_51:
v25 = v23;
if ( v24 != v30 )
{
*(_QWORD *)(*((_QWORD *)this + 178) + 8 * v30) = i;
v25 = *v20;
}
LABEL_53:
*i = v25;
*v20 = 0;
--*((_QWORD *)this + 181);
if ( (v20[3] & 1) != 0 )
operator delete((void *)v20[5]);
operator delete(v20);
if ( (v33 & 1) == 0 )
return _stack_chk_guard;
goto LABEL_31;
}
v31 = v29 / v14;
LABEL_50:
v30 = v29 - v31 * v14;
goto LABEL_51;
}
}
return _stack_chk_guard;
}