//
// sub_1800D6EF0 from 0x1800d6ef0 to 0x1800d70d3 (483 bytes)
//
// 5 xrefs:
// > sub_1800DF7C0 @ 0x1800dffc6
// > sub_1800E0D20 @ 0x1800e0ee3
// > ??> @ 0x18014bf9c
// > ??> @ 0x18014bfac
// > ??> @ 0x1801c48d8
//
// 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 11:22:33 +0000
//
int *__fastcall sub_1800D6EF0(int *a1, __int64 a2, unsigned int a3)
{
unsigned int v3; // r14d
int *v4; // rbp
unsigned int v6; // r15d
unsigned int v7; // r12d
int *v8; // rdx
__int64 v9; // r13
int v10; // edi
unsigned int v11; // ecx
int v12; // r11d
int v13; // r10d
int v14; // eax
int v15; // ebx
unsigned int v16; // esi
int v17; // eax
unsigned int v18; // r8d
int v19; // eax
int v20; // eax
unsigned int v21; // eax
int v22; // ecx
int v23; // ecx
int v24; // ecx
int v25; // ecx
v3 = -1;
v4 = nullptr;
v6 = -1;
v7 = -1;
if ( a3 )
{
v8 = (int *)(a2 + 40);
v9 = a3;
while ( 1 )
{
if ( a1[11] > 0 && !v8[1] )
goto LABEL_55;
v10 = a1[3];
v11 = 0;
if ( v10 > 0 )
v11 = *(v8 - 7) == 0;
v12 = a1[4];
if ( v12 > 0 && !*(v8 - 6) )
++v11;
v13 = a1[5];
if ( v13 > 0 && !*(v8 - 5) )
++v11;
v14 = a1[10];
if ( v14 > 0 && *v8 < v14 )
v11 += v14 - *v8;
v15 = a1[12];
if ( v15 > 0 && !v8[2] )
++v11;
v16 = v11 + 1;
v17 = *a1;
if ( a1[15] == v8[5] )
v16 = v11;
v18 = 0;
if ( v17 != -1 )
v18 = (v17 - *(v8 - 10)) * (v17 - *(v8 - 10));
v19 = a1[1];
if ( v19 != -1 )
v18 += (v19 - *(v8 - 9)) * (v19 - *(v8 - 9));
v20 = a1[2];
if ( v20 != -1 )
v18 += (v20 - *(v8 - 8)) * (v20 - *(v8 - 8));
v21 = 0;
if ( v10 != -1 )
v21 = (v10 - *(v8 - 7)) * (v10 - *(v8 - 7));
if ( v12 != -1 )
v21 += (v12 - *(v8 - 6)) * (v12 - *(v8 - 6));
if ( v13 != -1 )
v21 += (v13 - *(v8 - 5)) * (v13 - *(v8 - 5));
v22 = a1[6];
if ( v22 != -1 )
v21 += (v22 - *(v8 - 4)) * (v22 - *(v8 - 4));
v23 = a1[7];
if ( v23 != -1 )
v21 += (v23 - *(v8 - 3)) * (v23 - *(v8 - 3));
v24 = a1[8];
if ( v24 != -1 )
v21 += (v24 - *(v8 - 2)) * (v24 - *(v8 - 2));
v25 = a1[9];
if ( v25 != -1 )
v21 += (v25 - *(v8 - 1)) * (v25 - *(v8 - 1));
if ( v15 != -1 )
v21 += (v15 - v8[2]) * (v15 - v8[2]);
if ( a1[13] && !v8[3] )
++v21;
if ( v16 < v3 )
break;
if ( v16 == v3 && (v18 < v6 || v18 == v6 && v21 < v7) )
{
v4 = v8 - 10;
goto LABEL_54;
}
if ( v8 - 10 == v4 )
goto LABEL_54;
LABEL_55:
v8 += 18;
if ( !--v9 )
return v4;
}
v4 = v8 - 10;
LABEL_54:
v3 = v16;
v6 = v18;
v7 = v21;
goto LABEL_55;
}
return v4;
}