//
// sub_7D31B8 from 0x7d31b8 to 0x7d3250 (152 bytes)
//
// 2 xrefs:
// > ??> @ 0xa3080c
// > ??> @ 0xa30834
//
// 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
//
signed int __fastcall sub_7D31B8(int a1, void *a2, signed int a3)
{
int v4; // r5
unsigned int v7; // r3
bool v8; // cc
int v10; // r3
v4 = *(_DWORD *)(*(_DWORD *)(a1 + 32) + 4);
BIO_clear_flags(a1, 15);
v7 = *(_DWORD *)v4;
if ( a3 < 0 )
goto LABEL_14;
if ( a3 >= v7 )
a3 = *(_DWORD *)v4;
v8 = (int)a2 <= 0;
if ( a2 )
v8 = a3 <= 0;
if ( v8 )
{
LABEL_14:
if ( !v7 && (a3 = *(_DWORD *)(a1 + 28)) != 0 )
{
BIO_set_flags(a1, 9);
return a3;
}
else
{
return a3;
}
}
else
{
memcpy(a2, *(const void **)(v4 + 4), a3);
v10 = *(_DWORD *)(v4 + 4) + a3;
*(_DWORD *)v4 -= a3;
*(_DWORD *)(v4 + 4) = v10;
return a3;
}
}