//
// sub_1800491D0 from 0x1800491d0 to 0x180049242 (114 bytes)
//
// 6 xrefs:
// > sub_1800510D0 @ 0x18005137f
// > sub_180052020 @ 0x18005207d
// > sub_180052A90 @ 0x180052d22
// > sub_180052A90 @ 0x180052d51
// > sub_180052A90 @ 0x180052dcd
// > ??> @ 0x1801f83e8
//
// 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_1800491D0(__int64 *a1, _QWORD *a2)
{
int v2; // eax
__int64 v3; // r11
int v4; // r10d
__int64 v5; // r9
v2 = *((_DWORD *)a1 + 8);
if ( v2 <= -1 || v2 >= *((_DWORD *)a1 + 7) )
return 0;
if ( a2 )
{
v3 = *a1;
v4 = 0;
if ( *(int *)(*a1 + 4) > 0 )
{
v5 = 0;
do
{
v5 += 8;
++v4;
*(_QWORD *)(v5 + a1[2] - 8) = *(_QWORD *)(a1[1] + v5 - 8) + 4LL * *((int *)a1 + 8);
}
while ( v4 < *(_DWORD *)(v3 + 4) );
}
*a2 = a1[2];
}
return (unsigned int)(*((_DWORD *)a1 + 7) - *((_DWORD *)a1 + 8));
}