//
// sub_1004A07E0 from 0x1004a07e0 to 0x1004a0884 (164 bytes)
//
// 2 xrefs:
// > sub_1004571E0 @ 0x1004573a8
// > ??> @ 0x100828178
//
// 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_1004A07E0(__int64 a1, char a2, int a3, int a4)
{
__int64 v5; // x20
bool v6; // zf
int v7; // w8
__int16 v9; // w8
if ( (a2 & 1) == 0 )
{
v7 = -1;
LABEL_9:
*(_DWORD *)(a1 + 556) = v7;
return 0;
}
if ( !a3 )
{
if ( (unsigned int)(*(_DWORD *)(a1 + 556) + 1) > 1 )
return 0;
v9 = atomic_load((unsigned int *)(a1 + 100));
if ( (v9 & 0x100) != 0 )
v7 = 0;
else
v7 = *(_DWORD *)(*(_QWORD *)(a1 + 168) + 69864LL) + 1;
goto LABEL_9;
}
v5 = *(_QWORD *)(a1 + 168);
if ( v5 )
v6 = a4 == 0;
else
v6 = 0;
if ( v6 )
{
sub_100442B5C(*(_QWORD *)(a1 + 168), 3u);
*(_DWORD *)(a1 + 556) = 0;
sub_100442B7C(v5, 3u);
}
else
{
*(_DWORD *)(a1 + 556) = 0;
}
return 0;
}