//
// sub_5B474 from 0x5b474 to 0x5b586 (274 bytes)
//
// 1 xrefs:
// > FMOD::System::recordStart @ 0xba310
//
// 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_5B474(_DWORD *a1, int a2, int a3, char a4)
{
int v8; // r5
int v10; // r0
int v11; // r10
_DWORD *v12; // r0
int v13; // r1
int v14; // r3
int v15; // r5
int v16; // r6
int v17; // r0
v8 = sub_5B0B8((int)a1);
if ( !v8 )
{
if ( a2 < 0 )
return 31;
v8 = 31;
if ( !a3 || a1[286] <= a2 )
return v8;
if ( (*(_BYTE *)(a3 + 28) & 0x80) != 0 || !*(_DWORD *)(a3 + 44) )
return 31;
if ( *(unsigned __int8 *)(a1[289] + 44 * a2 + 20) << 31 )
{
v8 = sub_577FC(a1, a2);
if ( !v8 )
{
v10 = sub_BD580(*(int *)((char *)&dword_14C + (_DWORD)off_E8000), 72, "../../src/fmod_systemi.cpp", 5493, 0);
if ( v10 )
{
v11 = v10;
v12 = (_DWORD *)(a1[289] + 44 * a2);
v13 = v12[1];
v12 += 6;
*(_DWORD *)(v11 + 56) = a3;
*(_BYTE *)(v11 + 44) = a4;
*(_DWORD *)v11 = v13;
*(_DWORD *)(v11 + 28) = (int)*(float *)(a3 + 80);
*(_DWORD *)(v11 + 32) = *(_DWORD *)(a3 + 76);
*(_DWORD *)(v11 + 24) = *(_DWORD *)(a3 + 24);
*(_DWORD *)(v11 + 36) = *(_DWORD *)(a3 + 44);
v14 = v12[1];
v15 = v12[2];
v16 = v12[3];
*(_DWORD *)(v11 + 4) = *v12;
*(_DWORD *)(v11 + 8) = v14;
*(_DWORD *)(v11 + 12) = v15;
*(_DWORD *)(v11 + 16) = v16;
v17 = sub_B2E14(a1[278], v11);
if ( v17 )
{
v8 = v17;
sub_B3038(a1[278], v11);
sub_BD7AC(*(int *)((char *)&dword_14C + (_DWORD)off_E8000), v11, "../../src/fmod_systemi.cpp", 5513, 1);
}
else
{
v8 = 0;
*(_DWORD *)(a1[289] + 44 * a2 + 40) = v11;
}
}
else
{
return 38;
}
}
}
else
{
return 80;
}
}
return v8;
}