//
// sub_9A3A8 from 0x9a3a8 to 0x9a4e0 (312 bytes)
//
// 2 xrefs:
// > sub_9C81C @ 0x9c9c4
// > sub_9C81C @ 0x9ca34
//
// 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
//
__int64 __fastcall sub_9A3A8(__int64 a1, _DWORD *a2, unsigned int *a3, int a4, _DWORD *a5)
{
__int64 v5; // x10
unsigned int v6; // w12
char *v7; // x9
unsigned __int64 v8; // x23
unsigned int v12; // w8
unsigned int v13; // w24
__int64 v14; // x25
char *v15; // x26
int v16; // w27
int v17; // w22
int v18; // w28
int v19; // w8
*a5 = 0;
v5 = a3[3];
v6 = a3[4];
v7 = (char *)&FMOD::CodecMPEG::gI_SLen2 + ((2 * v5) & 0x1FFFFFFFCLL);
if ( !a4 )
v7 = (char *)&FMOD::CodecMPEG::gMapBuf2 + 4 * v5 + 1584;
v8 = *(unsigned int *)v7;
v12 = 0;
a3[19] = ((unsigned int)v8 >> 15) & 1;
if ( v6 == 2 )
{
if ( a3[5] )
v12 = 2;
else
v12 = 1;
}
v13 = v12;
v14 = 0;
v15 = (char *)&unk_4D74C + 24 * v12 + 4 * ((v8 >> 12) & 7);
while ( v14 != 4 )
{
v16 = (unsigned __int8)v15[v14];
v17 = v8 & 7;
LODWORD(v8) = (unsigned int)v8 >> 3;
v18 = v16;
if ( v17 )
{
if ( v15[v14] )
{
do
{
*a2++ = sub_9783C(a1, v17);
--v18;
}
while ( v18 );
}
*a5 += v17 * v16;
}
else
{
while ( v16 )
{
*a2++ = 0;
--v16;
}
}
++v14;
}
v19 = (2 * v13) | 1;
do
{
*a2++ = 0;
--v19;
}
while ( v19 );
return 0;
}