//
// engine_unlocked_init from 0xd9d0a0 to 0xd9d0f4 (84 bytes)
//
// 6 xrefs:
// > ENGINE_init @ 0xd9d24c
// > engine_table_register @ 0xe5e2e0
// > engine_table_select @ 0xe5e514
// > engine_table_select @ 0xe5e558
// > engine_table_select @ 0xe5e5b4
// > ??> @ 0x8d870
//
// 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 engine_unlocked_init(__int64 a1)
{
int v1; // w1
__int64 (*v3)(void); // x2
__int64 result; // x0
int v5; // w2
v1 = *(_DWORD *)(a1 + 160);
if ( v1 || (v3 = *(__int64 (**)(void))(a1 + 96)) == nullptr )
{
result = 1;
}
else
{
result = v3();
if ( !(_DWORD)result )
return result;
v1 = *(_DWORD *)(a1 + 160);
}
v5 = *(_DWORD *)(a1 + 156);
*(_DWORD *)(a1 + 160) = v1 + 1;
*(_DWORD *)(a1 + 156) = v5 + 1;
return result;
}