//
// sub_1801124D0 from 0x1801124d0 to 0x1801125a2 (210 bytes)
//
// 2 xrefs:
// > sub_1800DA550 @ 0x1800da924
// > ??> @ 0x180201c28
//
// 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_1801124D0(__int64 a1, _QWORD *a2, __int64 a3)
{
__int64 v3; // rbp
__int64 result; // rax
__int64 v8; // rcx
int v9; // ebx
int v10; // r8d
int v11; // edx
_DWORD *i; // rax
int v13; // eax
__int64 v14; // rcx
int v15; // eax
v3 = a1 + 1312;
result = sub_180112D30(a1 + 1312, 0);
if ( (_DWORD)result == 45 )
goto LABEL_15;
if ( (_DWORD)result )
return result;
if ( *(_BYTE *)(a1 + 720) )
goto LABEL_15;
v8 = *(_QWORD *)(a3 + 8);
v9 = 0;
if ( (v8 & 3) != 0 )
{
do
++v9;
while ( (((_BYTE)v8 + (_BYTE)v9) & 3) != 0 );
}
v10 = *(_DWORD *)(a3 + 24);
v11 = v9 + 4;
for ( i = (_DWORD *)(v8 + v9); v11 <= v10; v11 += 4 )
{
if ( *i != -1 )
break;
++i;
v9 += 4;
}
result = sub_180111EE0(v3, v9);
if ( !(_DWORD)result )
{
v13 = *(_DWORD *)(a3 + 24);
if ( v9 >= v13 )
{
v14 = *(_QWORD *)(a3 + 16);
v15 = *(_DWORD *)(a3 + 28);
}
else
{
v14 = *(_QWORD *)(a3 + 8) + v9;
v15 = v13 - v9;
}
if ( v15 > 0 )
{
*a2 = v14;
return 0;
}
LABEL_15:
*a2 = 0;
return 0;
}
return result;
}