//
// sub_8295C from 0x8295c to 0x82a7c (288 bytes)
//
// 2 xrefs:
// > sub_8337C @ 0x833c8
// > sub_834C0 @ 0x83610
//
// 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_8295C(__int64 *a1, int a2, char a3, __int64 a4)
{
unsigned int v8; // w0
int v9; // w10
int v10; // w8
int v11; // w11
__int64 v12; // x9
int v13; // w12
int v14; // w8
int v15; // w10
int v16; // w11
int v17; // w9
__int64 v18; // x0
unsigned int v19; // w0
unsigned int v20; // w19
while ( 1 )
{
if ( *((_BYTE *)a1 + 24) )
return 0;
v8 = FMOD_OS_CriticalSection_Enter(a1[4]);
if ( v8 )
return v8;
if ( !*((_DWORD *)a1 + 5) )
break;
LABEL_13:
v18 = a1[4];
++*((_DWORD *)a1 + 15);
v8 = FMOD_OS_CriticalSection_Leave(v18);
if ( v8 )
return v8;
v19 = sub_E71A8(a1[6]);
if ( v19 )
return v19;
}
v9 = *((_DWORD *)a1 + 2);
if ( v9 < a2 )
{
*((_DWORD *)a1 + 5) = a2;
v8 = sub_82A7C(a1);
if ( v8 )
return v8;
goto LABEL_13;
}
v10 = *((_DWORD *)a1 + 3);
v11 = *((_DWORD *)a1 + 4);
v12 = *a1;
*(_DWORD *)(a4 + 24) = a2;
*(_DWORD *)(a4 + 28) = 0;
v13 = v10 & (v9 - 1);
v14 = v9 - v10 + v11;
v15 = v9 - v13;
*(_QWORD *)(a4 + 8) = v12 + v13;
*(_QWORD *)(a4 + 16) = 0;
v16 = a2;
if ( v15 < a2 )
{
if ( (a3 & 1) != 0 )
{
v16 = v15 + a2;
*(_DWORD *)(a4 + 24) = v15;
*(_QWORD *)(a4 + 16) = v12;
v17 = a2;
}
else
{
*(_QWORD *)(a4 + 16) = v12;
v17 = a2 - v15;
v16 = a2;
*(_DWORD *)(a4 + 24) = v15;
}
*(_DWORD *)(a4 + 28) = v17;
}
if ( v14 < v16 )
goto LABEL_13;
v20 = 0;
*(_QWORD *)a4 = a1[4];
return v20;
}