//
// sub_82B20 from 0x82b20 to 0x82cb0 (400 bytes)
//
// 2 xrefs:
// > sub_83280 @ 0x832ac
// > sub_836EC @ 0x8372c
//
// 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_82B20(__int64 *a1, char a2, __int64 a3)
{
unsigned int v3; // w23
unsigned int v7; // w0
unsigned int v8; // w25
int v9; // w8
int v10; // w9
unsigned int v11; // w0
__int64 v12; // x0
unsigned int v13; // w0
unsigned int v14; // w0
int v15; // w10
__int64 v16; // x11
int v17; // w8
int v18; // w10
__int64 v19; // x12
int v20; // w8
while ( 1 )
{
if ( *((_BYTE *)a1 + 24) )
return 0;
v7 = FMOD_OS_CriticalSection_Enter(a1[4]);
if ( v7 )
v8 = v7;
else
v8 = v3;
if ( v7 )
return v7;
v9 = *((_DWORD *)a1 + 4);
v10 = *((_DWORD *)a1 + 3) - v9;
if ( v10 )
break;
if ( *((_DWORD *)a1 + 5) )
{
sub_E2D74(*(__int64 *)((char *)&qword_1B0 + (_QWORD)off_114000), *a1, "../../src/fmod_profile_client.cpp", 243, 1);
v11 = sub_82CB0(*((unsigned int *)a1 + 5));
*((_DWORD *)a1 + 2) = v11;
v12 = sub_E2908(
*(__int64 *)((char *)&qword_1B0 + (_QWORD)off_114000),
v11,
"../../src/fmod_profile_client.cpp",
247,
0,
0,
1);
*a1 = v12;
if ( !v12 )
return 38;
*((_DWORD *)a1 + 3) = 0;
a1[2] = 0;
v7 = sub_82CD0(a1);
if ( v7 )
return v7;
}
if ( (a2 & 1) != 0 )
++*((_DWORD *)a1 + 14);
v13 = FMOD_OS_CriticalSection_Leave(a1[4]);
if ( v13 || (a2 & 1) == 0 )
{
if ( v13 )
return v13;
else
return 45;
}
v14 = sub_E71A8(a1[5]);
if ( v14 )
v3 = v14;
else
v3 = v8;
if ( v14 )
return v3;
}
v15 = *((_DWORD *)a1 + 2);
v16 = *a1;
v17 = (v15 - 1) & v9;
v18 = v15 - v17;
v19 = *a1 + v17;
v20 = v10 - v18;
*(_QWORD *)(a3 + 8) = v19;
if ( v10 <= v18 )
{
v20 = 0;
v18 = v10;
*(_QWORD *)(a3 + 16) = 0;
}
else
{
*(_QWORD *)(a3 + 16) = v16;
}
*(_DWORD *)(a3 + 24) = v18;
*(_DWORD *)(a3 + 28) = v20;
v3 = 0;
*(_QWORD *)a3 = a1[4];
return v3;
}