//
// sub_1004D8680 from 0x1004d8680 to 0x1004d8700 (128 bytes)
//
// 2 xrefs:
// > sub_100442E2C @ 0x100442f68
// > sub_100442E2C @ 0x100442f80
//
// 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_1004D8680(__int64 a1, int a2)
{
char v2; // w19
int v4; // w8
int v5; // w8
unsigned int v6; // w8
unsigned int v7; // w9
bool v8; // cf
unsigned int v9; // w8
if ( *(_BYTE *)(a1 + 56) )
{
v2 = a2;
v4 = *(_DWORD *)(a1 + 52);
if ( a2 )
{
if ( !v4 )
{
sub_1004B57E0((_DWORD *)(a1 + 12));
v4 = *(_DWORD *)(a1 + 52);
}
*(_DWORD *)(a1 + 52) = v4 + 1;
}
else
{
v5 = v4 - 1;
*(_DWORD *)(a1 + 52) = v5;
if ( !v5 )
{
sub_1004B57E0((_DWORD *)(a1 + 16));
v7 = *(_DWORD *)(a1 + 12);
v6 = *(_DWORD *)(a1 + 16);
v8 = v6 >= v7;
v9 = v6 - v7;
if ( v9 != 0 && v8 )
*(_DWORD *)(a1 + 48) += v9;
}
}
*(_BYTE *)(a1 + 44) = v2;
}
return 0;
}