//
// sub_1004A5E18 from 0x1004a5e18 to 0x1004a5f2c (276 bytes)
//
// 6 xrefs:
// > sub_1004567DC @ 0x1004567fc
// > sub_100488A3C @ 0x100488aa8
// > ??> @ 0x100827448
// > ??> @ 0x1008280f8
// > ??> @ 0x100828160
// > ??> @ 0x1008281b8
//
// 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_1004A5E18(__int64 a1)
{
unsigned int *v2; // x20
char v3; // w8
char v4; // w8
__int64 v5; // x0
__int64 result; // x0
__int16 v7; // w8
unsigned int v8; // w8
int *v9; // x1
int *v10; // [xsp+8h] [xbp-18h] BYREF
if ( !*(_QWORD *)(a1 + 168) )
return 0;
v2 = (unsigned int *)(a1 + 100);
v3 = atomic_load((unsigned int *)(a1 + 100));
if ( (v3 & 0x20) != 0 )
return 10;
v4 = atomic_load(v2);
if ( (v4 & 0x40) != 0 )
return 8;
v5 = *(_QWORD *)(a1 + 168);
if ( !v5 || (result = sub_10043DDA0(v5, a1), !(_DWORD)result) )
{
v7 = atomic_load(v2);
if ( (v7 & 0x300) != 0 )
{
sub_10043E2C8(*(_QWORD *)(a1 + 168), 1);
result = sub_1004A5F2C(a1, 0, 0, 1, 1, 4);
if ( !(_DWORD)result )
return sub_1004A5B34(a1);
}
else
{
result = sub_10043E710(*(_QWORD *)(a1 + 168), &v10, 24, 1);
if ( !(_DWORD)result )
{
do
v8 = __ldaxr(v2);
while ( __stlxr(v8 | 0x400, v2) );
*(_BYTE *)v10 = 5;
v9 = v10;
*((_QWORD *)v10 + 1) = a1;
*((_WORD *)v9 + 8) = 257;
*((_BYTE *)v9 + 18) = 1;
return sub_10043E7B4(*(_QWORD *)(a1 + 168), (__int64)v9, 1);
}
}
}
return result;
}