//
// sub_CA9C0 from 0xca9c0 to 0xcaabc (252 bytes)
//
// 6 xrefs:
// > sub_52958 @ 0x52974
// > sub_A7328 @ 0xa738c
// > ??> @ 0x10d670
// > ??> @ 0x10eeb0
// > ??> @ 0x10ef18
// > ??> @ 0x10ef70
//
// 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_CA9C0(__int64 a1)
{
unsigned int *v1; // x20
char v2; // w8
char v4; // w8
__int64 v5; // x0
__int64 result; // x0
__int16 v7; // w8
unsigned int v8; // w8
__int64 v9; // x0
__int64 v10; // x1
__int64 v11; // [xsp+8h] [xbp-18h] BYREF
if ( !*(_QWORD *)(a1 + 168) )
return 0;
v1 = (unsigned int *)(a1 + 100);
v2 = atomic_load((unsigned int *)(a1 + 100));
if ( (v2 & 0x20) != 0 )
return 10;
v4 = atomic_load(v1);
if ( (v4 & 0x40) != 0 )
return 8;
v5 = *(_QWORD *)(a1 + 168);
if ( !v5 || (result = sub_77098(v5, a1), !(_DWORD)result) )
{
v7 = atomic_load(v1);
if ( (v7 & 0x300) != 0 )
{
sub_CD3EC(*(_QWORD *)(a1 + 168));
result = sub_CD594(a1, 0);
if ( !(_DWORD)result )
return sub_CA7BC(a1, 0);
}
else
{
result = sub_CD294(*(_QWORD *)(a1 + 168), &v11, 24);
if ( !(_DWORD)result )
{
do
v8 = __ldaxr(v1);
while ( __stlxr(v8 | 0x400, v1) );
v9 = sub_CD4B0();
*(_QWORD *)(v10 + 8) = a1;
*(_WORD *)(v10 + 16) = 257;
*(_BYTE *)(v10 + 18) = 1;
return sub_CD2F0(v9);
}
}
}
return result;
}