//
// sub_4CF44 from 0x4cf44 to 0x4d04c (264 bytes)
//
// 1 xrefs:
// > sub_46B58 @ 0x46c38
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
int __fastcall sub_4CF44(_DWORD *a1, int a2, _DWORD *a3)
{
int result; // r0
_DWORD *v7; // r0
_DWORD *v8; // r1
_DWORD *v9; // r2
bool v10; // zf
int v11; // r2
int v12; // r1
int v13; // r2
_DWORD *v14; // r3
int v15; // r1
_DWORD *v16; // r1
_DWORD *v17; // t1
_DWORD *v18; // [sp+0h] [bp-20h] BYREF
int v19; // [sp+4h] [bp-1Ch] BYREF
char v20; // [sp+8h] [bp-18h]
int v21; // [sp+Ch] [bp-14h] BYREF
v21 = 0;
if ( FMOD::ChannelI::validate(a2, &v21, 0) )
{
result = sub_48F28(a2, &v18, nullptr);
if ( result )
return result;
v19 = a1[79];
j_FMOD_OS_CriticalSection_Enter(v19);
v20 = 1;
v7 = v18;
if ( v18[95] != 1 )
{
v18[96] = a2;
v7[95] = 0;
v7[97] = *a3;
v7[98] = a3[1];
v7[99] = a3[2];
v8 = v7 + 92;
v9 = (_DWORD *)v7[92];
v10 = v9 == v7 + 92;
if ( v9 == v7 + 92 )
v10 = v7[93] == (_DWORD)v8;
if ( v10 )
{
v11 = a1[77];
v7[92] = a1 + 76;
v7[93] = v11;
a1[77] = v8;
*(_DWORD *)v7[93] = v8;
}
}
}
else
{
v19 = a1[79];
j_FMOD_OS_CriticalSection_Enter(v19);
v20 = 1;
v12 = a1[75];
v13 = *(int *)((char *)&dword_144 + v21);
v14 = (_DWORD *)(v12 + 44 * v13);
if ( v14[3] != 1 )
{
v14[3] = 0;
v14[4] = a2;
v14[5] = *a3;
v14[6] = a3[1];
v14[7] = a3[2];
if ( *(_DWORD **)(v12 + 44 * v13) == v14 )
{
v15 = v12 + 44 * v13;
v17 = *(_DWORD **)(v15 + 4);
v16 = (_DWORD *)(v15 + 4);
if ( v17 == v14 )
{
*v16 = a1[77];
*v14 = a1 + 76;
a1[77] = v14;
*(_DWORD *)*v16 = v14;
}
}
}
}
return sub_44984((int)&v19);
}