//
// sub_5A958 from 0x5a958 to 0x5aaa8 (336 bytes)
//
// 2 xrefs:
// > sub_4933C @ 0x493e2
// > FMOD::System::detachChannelGroupFromPort @ 0xb9dcc
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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:40:48 +0000
//
int __fastcall sub_5A958(int a1, int a2)
{
int v4; // r0
_DWORD *v5; // r10
_DWORD *v6; // r5
int v7; // r6
int v8; // r0
int v10; // r0
__int64 v11; // r0
int i; // r11
int v13; // [sp+Ch] [bp-34h] BYREF
int v14; // [sp+10h] [bp-30h] BYREF
int v15; // [sp+14h] [bp-2Ch] BYREF
_DWORD v16[2]; // [sp+18h] [bp-28h] BYREF
char v17; // [sp+20h] [bp-20h]
v16[0] = a1;
v16[1] = 23;
v17 = 0;
sub_44998((int)v16);
if ( !a2 || (v4 = *(__int16 *)(a2 + 360), v4 == -1) )
{
v7 = 31;
goto LABEL_13;
}
v5 = (_DWORD *)(a1 + 1176);
v6 = (_DWORD *)(a1 + 1176);
while ( 1 )
{
v6 = (_DWORD *)*v6;
if ( v6 == v5 )
break;
if ( v6[9] == v4 )
{
v5 = v6;
break;
}
}
v15 = 0;
v7 = (*(int (__fastcall **)(int, int, int *))(*(_DWORD *)a2 + 144))(a2, -1, &v15);
if ( !v7 )
{
v7 = sub_AAEE0(v6[2], v15, 0, 4);
if ( !v7 )
{
if ( !*(_BYTE *)(a2 + 362) )
{
v14 = 0;
v10 = (*(int (__fastcall **)(_DWORD, int, int *))(**(_DWORD **)(a2 + 16) + 144))(*(_DWORD *)(a2 + 16), -3, &v14);
if ( v10 )
{
LABEL_15:
v7 = v10;
goto LABEL_13;
}
v13 = 0;
v7 = sub_5A93C(v15, (int)&v13);
if ( v7 )
goto LABEL_13;
for ( i = 0; i < v13; ++i )
{
v10 = sub_5A944(v15, i);
if ( v10 )
goto LABEL_15;
if ( !v14 )
{
v10 = sub_8E614(0, 1065353216, 0, 1, 0);
if ( v10 )
goto LABEL_15;
}
}
}
v8 = v6[10] - 1;
v6[10] = v8;
if ( v8 )
goto LABEL_11;
v11 = *(_QWORD *)v6;
*(_DWORD *)HIDWORD(v11) = v11;
*(_DWORD *)(*v6 + 4) = HIDWORD(v11);
*v6 = v5;
v6[1] = v5;
v7 = sub_B3E50(*(_DWORD *)(a1 + 1112), v6);
if ( !v7 )
{
v7 = (*(int (__fastcall **)(_DWORD))(*(_DWORD *)v6[2] + 8))(v6[2]);
if ( !v7 )
{
sub_5A908(v6, (int)"../../src/fmod_systemi.cpp", 5018);
LABEL_11:
v7 = 0;
*(_BYTE *)(a2 + 362) = 0;
*(_WORD *)(a2 + 360) = -1;
}
}
}
}
LABEL_13:
sub_448CC((int)v16);
return v7;
}