//
// sub_BE986 from 0xbe986 to 0xbe9d0 (74 bytes)
//
// 2 xrefs:
// > sub_6505C @ 0x6510c
// > sub_6505C @ 0x65120
//
// 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_BE986(int a1, int a2)
{
int v3; // r0
char v4; // r4
int v5; // r0
__int64 v6; // r0
if ( *(_BYTE *)(a1 + 56) )
{
v3 = *(_DWORD *)(a1 + 52);
v4 = a2;
if ( a2 )
{
if ( !v3 )
{
j_FMOD_OS_Time_GetUs(a1 + 12);
v3 = *(_DWORD *)(a1 + 52);
}
*(_DWORD *)(a1 + 52) = v3 + 1;
}
else
{
v5 = v3 - 1;
*(_DWORD *)(a1 + 52) = v5;
if ( !v5 )
{
j_FMOD_OS_Time_GetUs(a1 + 16);
v6 = *(_QWORD *)(a1 + 12);
if ( HIDWORD(v6) > (unsigned int)v6 )
*(_DWORD *)(a1 + 48) += HIDWORD(v6) - v6;
}
}
*(_BYTE *)(a1 + 44) = v4;
}
return 0;
}