//
// sub_18009C2B0 from 0x18009c2b0 to 0x18009c3db (299 bytes)
//
// 5 xrefs:
// > sub_1800C8FD0 @ 0x1800c90a1
// > sub_1800FC980 @ 0x1800fcd20
// > ??> @ 0x180185360
// > ??> @ 0x180185370
// > ??> @ 0x1801fac2c
//
// 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_18009C2B0(__int64 a1, __int64 a2, char a3, __int64 a4)
{
char v5; // dl
__int64 result; // rax
__int64 v9; // r8
int v10; // edi
int v11; // ebp
_QWORD *v12; // rax
int i; // ecx
__int64 v14; // rdx
void (__fastcall ***v15)(_QWORD, __int64); // rcx
__int64 v16; // [rsp+30h] [rbp+8h] BYREF
v5 = 0;
if ( (*(_DWORD *)(a1 + 100) & 0x100) == 0 )
v5 = a4;
if ( !v5 )
{
if ( a3 )
{
v10 = 0;
v11 = *(__int16 *)(a1 + 424);
if ( v11 > 0 )
{
do
{
if ( v10 >= *(__int16 *)(a1 + 424) )
goto LABEL_16;
v12 = *(_QWORD **)(a1 + 120);
if ( v12 == (_QWORD *)(a1 + 120) )
goto LABEL_16;
for ( i = 0; ; ++i )
{
v14 = v12[2];
if ( i >= v10 )
break;
v12 = (_QWORD *)*v12;
}
if ( !v14 )
LABEL_16:
v15 = nullptr;
else
v15 = *(void (__fastcall ****)(_QWORD, __int64))(v14 + 88);
(**v15)(v15, a2);
++v10;
}
while ( v10 < v11 );
}
}
(**(void (__fastcall ***)(__int64, __int64))a1)(a1, a2);
return 0;
}
LOBYTE(a4) = 1;
result = sub_1800FCF40(*(_QWORD *)(a1 + 168), &v16, 32, a4);
if ( !(_DWORD)result )
{
*(_BYTE *)v16 = 12;
*(_QWORD *)(v16 + 8) = a1;
*(_QWORD *)(v16 + 16) = a2;
*(_BYTE *)(v16 + 24) = a3;
*(_QWORD *)(a1 + 440) = a2;
_InterlockedOr((volatile signed __int32 *)(a1 + 100), 0x800u);
LOBYTE(v9) = 1;
result = sub_1800FD370(*(_QWORD *)(a1 + 168), v16, v9);
if ( !(_DWORD)result )
return 0;
}
return result;
}