//
// sub_5E18A4 from 0x5e18a4 to 0x5e18fa (86 bytes)
//
// 0 xrefs:
//
// 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_5E18A4(int a1, unsigned __int64 a2, int a3)
{
int v4; // r4
int v5; // r1
__int64 result; // r0
int v7; // r4
v4 = *(_DWORD *)(a1 + 4);
if ( !a3 )
{
LABEL_2:
if ( a2 < v4 )
goto LABEL_7;
return -1;
}
if ( a3 != 1 )
{
if ( a3 == 2 )
{
if ( a2 < v4 )
{
v7 = v4 - 1 - a2;
*(_DWORD *)(a1 + 8) = v7;
LODWORD(result) = v7;
return (int)result;
}
return -1;
}
goto LABEL_2;
}
v5 = *(_DWORD *)(a1 + 8);
if ( a2 + v5 < v4 )
{
LODWORD(a2) = a2 + v5;
LABEL_7:
*(_DWORD *)(a1 + 8) = a2;
LODWORD(result) = a2;
return (int)result;
}
return -1;
}