//
// sub_1800FB2A0 from 0x1800fb2a0 to 0x1800fb6fe (1118 bytes)
//
// 7 xrefs:
// > sub_1800E4120 @ 0x1800e416a
// > sub_1800E4500 @ 0x1800e4553
// > sub_180102CA0 @ 0x180103191
// > ??> @ 0x18018f398
// > ??> @ 0x18018f3a8
// > ??> @ 0x18018f3bc
// > ??> @ 0x180200d58
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 10:54:25 +0000
//
__int64 __fastcall sub_1800FB2A0(__int64 a1, __int64 a2)
{
__int64 v2; // rax
char v3; // di
__int64 v4; // rbx
__int64 result; // rax
unsigned __int64 v6; // rax
__int64 v7; // rax
void (__fastcall *v8)(__int64); // rdx
__int64 v9; // rcx
void (__fastcall *v10)(__int64, __int64, _QWORD); // r10
int v11; // eax
int v12; // edi
unsigned int v13; // esi
__int64 v14; // rax
__int128 v15; // xmm0
unsigned __int64 v16; // rax
__int64 v17; // rdx
int v18; // eax
__int64 (__fastcall *v19)(__int64, int *); // r8
__int64 v20; // rcx
__int64 v21; // rdx
unsigned int v22; // edi
_BYTE v23[4]; // [rsp+40h] [rbp-30h] BYREF
int v24; // [rsp+44h] [rbp-2Ch] BYREF
DWORD v25; // [rsp+48h] [rbp-28h] BYREF
int v26; // [rsp+4Ch] [rbp-24h] BYREF
__int128 v27; // [rsp+50h] [rbp-20h] BYREF
v2 = *(unsigned int *)(a1 + 69808);
v23[0] = 0;
v3 = a2;
v25 = 0;
v4 = a1;
if ( !*((_BYTE *)&dword_1801F09C0 + v2) )
{
sub_1800C1770(&v25);
a1 = v25;
if ( !v3 || v25 - *(_DWORD *)(v4 + 69816) >= 0x3E8 || *(_BYTE *)(*(_QWORD *)(v4 + 1648) + 785LL) )
{
*(_DWORD *)(v4 + 69816) = v25;
result = sub_1800C0AF0(v23);
if ( (_DWORD)result )
return result;
if ( v23[0] )
{
dword_1801F09C0 = 16843009;
dword_1801F09C8 = 16843009;
dword_1801F09C4 = 16843009;
dword_1801F09CC = 16843009;
}
}
}
v6 = *(unsigned int *)(v4 + 69808);
if ( *((_BYTE *)&dword_1801F09C8 + v6) )
{
if ( v6 >= 8 )
goto LABEL_68;
*((_BYTE *)&dword_1801F09C8 + v6) = 0;
*(_BYTE *)(*(_QWORD *)(v4 + 1648) + 784LL) = 0;
v7 = *(_QWORD *)(v4 + 1648);
v8 = *(void (__fastcall **)(__int64))(v7 + 944);
if ( v8 )
{
v9 = v7 + 8;
if ( !v7 )
v9 = 0;
v8(v9);
}
}
if ( !v3 )
return 0;
if ( !*((_BYTE *)&dword_1801F09C0 + *(unsigned int *)(v4 + 69808)) )
goto LABEL_50;
v10 = *(void (__fastcall **)(__int64, __int64, _QWORD))(v4 + 70192);
if ( v10 && (*(_BYTE *)(v4 + 70200) & 1) != 0 )
{
v10(v4, 1, 0);
goto LABEL_48;
}
if ( *(_DWORD *)(v4 + 1656) == 2 )
{
if ( !(unsigned int)sub_1800FBAE0(v4, *(unsigned int *)(v4 + 69820), *(unsigned int *)(v4 + 69824)) )
goto LABEL_48;
goto LABEL_21;
}
result = sub_1800E4500(v4, &v24);
if ( (_DWORD)result )
return result;
v11 = v24;
if ( !v24 )
{
LABEL_21:
result = sub_1800FBAE0(v4, 2, 0);
if ( (_DWORD)result )
return result;
goto LABEL_48;
}
v12 = 0;
if ( v24 > 0 )
{
while ( 1 )
{
result = sub_1800E4120(v4, v12, nullptr, 0, &v27, nullptr, nullptr, nullptr);
if ( (_DWORD)result )
return result;
if ( v27 == *(_OWORD *)(v4 + 69828) )
break;
v11 = v24;
if ( ++v12 >= v24 )
goto LABEL_30;
}
v11 = v24;
}
LABEL_30:
v26 = 0;
if ( v12 == v11 )
v12 = 0;
if ( (unsigned int)sub_1800E4500(v4, &v26) || v12 < -1 || v12 >= v26 )
goto LABEL_47;
v13 = 0;
if ( v12 != -1 )
v13 = v12;
if ( (unsigned int)sub_1800E4120(v4, v13, nullptr, 0, &v27, nullptr, nullptr, nullptr) )
goto LABEL_47;
if ( v27 == *(_OWORD *)(v4 + 1668) )
{
*(_DWORD *)(v4 + 1664) = v13;
goto LABEL_48;
}
if ( !*(_BYTE *)(v4 + 8) )
goto LABEL_46;
if ( (unsigned int)sub_1800FC360(v4) )
goto LABEL_47;
v14 = *(_QWORD *)(v4 + 67512);
if ( v14 )
*(_DWORD *)(v14 + 48) = 1;
if ( (unsigned int)sub_1800FBCA0(v4, v13) && (unsigned int)sub_1800FBAE0(v4, 2, 0) )
{
LABEL_47:
result = sub_1800FBAE0(v4, 2, 0);
if ( (_DWORD)result )
return result;
}
else
{
LABEL_46:
v15 = v27;
*(_DWORD *)(v4 + 1664) = v13;
*(_OWORD *)(v4 + 1668) = v15;
}
LABEL_48:
v16 = *(unsigned int *)(v4 + 69808);
if ( v16 >= 8 )
LABEL_68:
_report_rangecheckfailure(a1, a2);
*((_BYTE *)&dword_1801F09C0 + v16) = 0;
LABEL_50:
if ( !*(_BYTE *)(*(_QWORD *)(v4 + 1648) + 785LL) )
return 0;
result = sub_1800FC360(v4);
if ( (_DWORD)result )
return result;
v17 = *(_QWORD *)(v4 + 1648);
v18 = 0;
v24 = 0;
v19 = *(__int64 (__fastcall **)(__int64, int *))(v17 + 824);
if ( v19 )
{
v20 = v17 + 8;
if ( !v17 )
v20 = 0;
result = v19(v20, &v24);
if ( (_DWORD)result )
return result;
v18 = v24;
}
v21 = *(unsigned int *)(v4 + 1664);
if ( !(_DWORD)v21 || (*(_DWORD *)(v4 + 1664) = 0, v22 = 0, v21 = 0, v18 <= 0) )
{
LABEL_64:
if ( (unsigned int)sub_1800FBCA0(v4, v21) )
{
result = sub_1800FBAE0(v4, 2, 0);
if ( (_DWORD)result )
return result;
}
return 0;
}
while ( 1 )
{
result = sub_1800E4120(v4, v22, nullptr, 0, &v27, nullptr, nullptr, nullptr);
if ( (_DWORD)result )
return result;
if ( v27 == *(_OWORD *)(v4 + 1668) )
{
*(_DWORD *)(v4 + 1664) = v22;
v21 = v22;
goto LABEL_64;
}
if ( (int)++v22 >= v24 )
{
v21 = *(unsigned int *)(v4 + 1664);
goto LABEL_64;
}
}
}