//
// sub_180099B90 from 0x180099b90 to 0x180099c4d (189 bytes)
//
// 7 xrefs:
// > sub_18001C780 @ 0x18001c8db
// > sub_180022480 @ 0x180022614
// > sub_1800273E0 @ 0x18002753c
// > sub_180037A60 @ 0x180037bbb
// > sub_18003F610 @ 0x18003f76b
// > sub_1800BCAD0 @ 0x1800bcc08
// > ??> @ 0x1801fab78
//
// 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_180099B90(__int64 a1, __int64 a2, unsigned int a3, int a4)
{
int v5; // ebx
__int64 result; // rax
int v7; // eax
int v8; // r9d
__int64 v9; // r8
__int64 v10; // rax
__int64 v11; // rdx
__int64 v12; // rcx
bool v13; // [rsp+60h] [rbp+18h] BYREF
*(_WORD *)(a2 + 90) = a3;
v5 = 0;
*(_DWORD *)(a2 + 44) = 0x100000;
*(_WORD *)(a2 + 88) = 0;
v13 = 0;
*(_DWORD *)(a1 + 60) = 0;
result = sub_180099840(a2 + 8, a1, a2 + 8, a3, 0, a3, a4, &v13);
if ( !(_DWORD)result )
{
v7 = *(_DWORD *)(a1 + 12);
if ( *(_DWORD *)(a1 + 60) < v7 )
{
v8 = 0;
if ( v7 > 0 )
{
v9 = 0;
v10 = 0;
do
{
v11 = *(_QWORD *)(a1 + 32);
v12 = *(_QWORD *)(v10 + v11);
if ( (*(_DWORD *)(v12 + 92) & 0x40000) != 0 )
{
++v8;
*(_QWORD *)(v9 + v11) = v12;
v9 += 8;
}
else
{
_InterlockedAnd((volatile signed __int32 *)(v12 + 92), 0xFFE7FFFF);
}
++v5;
v10 += 8;
}
while ( v5 < *(_DWORD *)(a1 + 12) );
}
*(_DWORD *)(a1 + 12) = v8;
}
return 0;
}
return result;
}