//
// sub_5A67C from 0x5a67c to 0x5a8f4 (632 bytes)
//
// 1 xrefs:
// > FMOD::System::attachChannelGroupToPort @ 0xb9cfe
//
// 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_5A67C(int a1, int a2, unsigned int a3, unsigned int a4, int a5, int a6)
{
int v8; // r4
int v12; // r11
int v13; // r5
int v14; // r0
bool v15; // zf
char v16; // r1
int v17; // r0
int v18; // r10
int v19; // r0
int v20; // r0
int v21; // r0
int v22; // r0
int i; // r6
int v24; // r0
int v25; // [sp+Ch] [bp-5Ch] BYREF
int v26; // [sp+10h] [bp-58h] BYREF
int v27; // [sp+14h] [bp-54h] BYREF
_DWORD v28[10]; // [sp+18h] [bp-50h] BYREF
_DWORD v29[2]; // [sp+40h] [bp-28h] BYREF
char v30; // [sp+48h] [bp-20h]
if ( !a5 || *(unsigned __int16 *)(a5 + 360) != 0xFFFF || !*(_DWORD *)(a5 + 16) )
return 31;
if ( !*(_DWORD *)(*(_DWORD *)(a1 + 1112) + 748) )
return 68;
v28[1] = 23;
LOBYTE(v28[2]) = 0;
v28[0] = a1;
sub_44998((int)v28);
v12 = a1 + 1176;
v13 = a1 + 1176;
while ( 1 )
{
v13 = *(_DWORD *)v13;
if ( v13 == v12 )
break;
v14 = *(_DWORD *)(v13 + 32);
v15 = v14 == a2;
if ( v14 == a2 )
v15 = *(_QWORD *)(v13 + 24) == __PAIR64__(a4, a3);
if ( v15 )
{
++*(_DWORD *)(v13 + 40);
goto LABEL_15;
}
}
v13 = 0;
LABEL_15:
sub_448CC((int)v28);
if ( !v13 )
{
v29[0] = a1;
v29[1] = 23;
v30 = 0;
v13 = sub_BD580(*(int *)((char *)&dword_14C + (_DWORD)off_E8000), 72, "../../src/fmod_systemi.cpp", 4853, 0);
if ( !v13 )
{
v18 = 1;
v8 = 38;
v13 = 0;
goto LABEL_28;
}
*(_DWORD *)(v13 + 40) = 1;
*(_DWORD *)(v13 + 24) = a3;
*(_DWORD *)(v13 + 28) = a4;
*(_DWORD *)(v13 + 32) = a2;
*(_DWORD *)v13 = v13;
*(_DWORD *)(v13 + 4) = v13;
qmemcpy(v28, (const void *)sub_67110(), 0x24u);
v28[1] = "Output Port Head";
v18 = 1;
v19 = sub_617B8(a1, v28, 0, v13 + 8, 1);
if ( v19 )
{
LABEL_23:
v8 = v19;
goto LABEL_28;
}
v27 = 0;
v20 = (*(int (__fastcall **)(_DWORD, int, int *))(**(_DWORD **)(a1 + 68868) + 144))(
*(_DWORD *)(a1 + 68868),
-1,
&v27);
if ( v20 )
{
v8 = v20;
}
else
{
v26 = 0;
v18 = 1;
v19 = sub_AA8A8(v27, *(_DWORD *)(v13 + 8), &v26, 0, 1, 0);
if ( v19 )
goto LABEL_23;
v18 = 1;
v19 = sub_8E614(v26, 0, 0, 1, 0);
if ( v19 )
goto LABEL_23;
v22 = sub_B3BF8(*(_DWORD *)(a1 + 1112), v13);
if ( !v22 )
{
sub_44998((int)v29);
v24 = *(_DWORD *)(a1 + 1180);
v18 = 0;
v8 = 0;
*(_DWORD *)v13 = v12;
*(_DWORD *)(v13 + 4) = v24;
*(_DWORD *)(a1 + 1180) = v13;
**(_DWORD **)(v13 + 4) = v13;
LABEL_28:
sub_448CC((int)v29);
if ( v18 )
return v8;
goto LABEL_16;
}
v8 = v22;
(*(void (__fastcall **)(_DWORD))(**(_DWORD **)(v13 + 8) + 8))(*(_DWORD *)(v13 + 8));
sub_5A908(v13, "../../src/fmod_systemi.cpp", 4888);
}
v18 = 1;
goto LABEL_28;
}
LABEL_16:
v28[0] = 0;
v8 = (*(int (__fastcall **)(int, int, _DWORD *))(*(_DWORD *)a5 + 144))(a5, -1, v28);
if ( !v8 )
{
v8 = sub_AA8A8(*(_DWORD *)(v13 + 8), v28[0], 0, 0, 1, 0);
if ( !v8 )
{
v16 = a6;
if ( !a6 )
{
v29[0] = 0;
v21 = (*(int (__fastcall **)(_DWORD, int, _DWORD *))(**(_DWORD **)(a5 + 16) + 144))(
*(_DWORD *)(a5 + 16),
-3,
v29);
if ( v21 )
return v21;
v27 = 0;
v8 = sub_5A93C(v28[0], &v27);
if ( v8 )
return v8;
for ( i = 0; i < v27; ++i )
{
v25 = 0;
v26 = 0;
v21 = sub_5A944(v28[0], i, &v26, &v25);
if ( v21 )
return v21;
if ( v26 == v29[0] )
{
v21 = sub_8E614(v25, 0, 0, 1, 0);
if ( v21 )
return v21;
}
}
v16 = 0;
}
v17 = *(_DWORD *)(v13 + 36);
v8 = 0;
*(_BYTE *)(a5 + 362) = v16;
*(_WORD *)(a5 + 360) = v17;
}
}
return v8;
}