//
// sub_609EA8 from 0x609ea8 to 0x609f4a (162 bytes)
//
// 2 xrefs:
// > sub_607BBC @ 0x607cb0
// > sub_609F50 @ 0x609f70
//
// 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
//
int __fastcall sub_609EA8(int result, int a2, unsigned __int8 *a3, int **a4)
{
double v4; // d0
int v6; // r8
unsigned int v7; // r9
int v8; // r3
int *v9; // r4
_DWORD *v10; // r7
int *v11; // r5
int v12; // r0
int v13; // r1
bool v14; // zf
int v15; // r1
int v17; // [sp+4h] [bp-20h]
_DWORD v18[4]; // [sp+Ch] [bp-18h] BYREF
v6 = result;
v7 = 1;
v8 = *(_DWORD *)(result + 4);
v9 = (int *)(v8 + 8 * a2);
v10 = v9 + 2;
v17 = ((*(_DWORD *)(result + 8) - v8) >> 3) - a2;
while ( 1 )
{
v11 = v10 - 2;
if ( *(_DWORD **)(v6 + 8) == v10 - 2 )
break;
v12 = *v11;
v13 = *(v10 - 1);
v14 = a3[1] == 2;
v18[2] = v7;
v18[0] = v12;
v18[1] = v13;
v18[3] = v17;
if ( v14 )
{
result = sub_608F28(COERCE_DOUBLE(__PAIR64__(v18, (unsigned int)a3)), a4);
if ( v4 != (double)v7 )
goto LABEL_9;
LABEL_8:
result = *v11;
v15 = *(v10 - 1);
*v9 = *v11;
v9[1] = v15;
v9 += 2;
goto LABEL_9;
}
result = sub_608878(a3, (pugi::xpath_node *)v18, a4);
if ( result )
goto LABEL_8;
LABEL_9:
++v7;
v10 += 2;
}
*(_DWORD *)(v6 + 8) = v9;
return result;
}