//
// sub_10064F220 from 0x10064f220 to 0x10064fafe (2270 bytes)
//
// 2 xrefs:
// > sub_10064EF90 @ 0x10064ef9e
// > sub_10064EF90 @ 0x10064efe2
//
// 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_10064F220(__int64 a1, __int64 a2)
{
__int64 v2; // r15
__int64 v3; // rbx
__int64 v4; // r13
int v5; // eax
char v6; // r14
_QWORD *v7; // r14
__int64 v8; // rax
__int64 v9; // rsi
char v10; // al
_QWORD *v11; // r14
__int64 v12; // rax
_BYTE *v13; // r12
__int64 v14; // r13
int v15; // eax
__int64 v16; // rax
__int64 v17; // rcx
__int64 v18; // rcx
__int64 v19; // rcx
const char *v20; // rcx
char v21; // r14
_QWORD *v22; // rax
_QWORD *v23; // rax
__int64 v24; // r13
__int64 j; // rax
const char *v26; // rax
__int64 i; // rax
__int64 v28; // rcx
__int64 v29; // rcx
__int64 v30; // rcx
__int64 v31; // rcx
__int64 v32; // rcx
__int64 v33; // rcx
__int64 v34; // rcx
__int64 k; // rax
int v36; // eax
int v37; // eax
int v38; // eax
const char **v39; // rax
const char *v40; // rcx
__int64 v41; // rdx
_QWORD *v42; // r14
__int64 v43; // rax
size_t v44; // rdx
_QWORD *v45; // r14
__int64 v46; // rax
unsigned __int64 v47; // rcx
void *v48; // r13
__int64 v49; // r13
_QWORD *v50; // rax
unsigned __int64 v51; // r15
_QWORD *v52; // rax
size_t v53; // r14
__int64 v54; // r14
__int64 v55; // r15
__int64 v56; // rdx
const char *v57; // rcx
__int64 v58; // r13
__int64 v59; // r15
_QWORD *v60; // rbx
__int64 v61; // rax
__int64 v62; // r12
_QWORD *v63; // rax
__int64 *v64; // rax
__int64 v66; // r13
__int64 v67; // rcx
__int64 v68; // r14
_QWORD *v69; // rax
__int64 v70; // [rsp+8h] [rbp-58h]
size_t __n; // [rsp+10h] [rbp-50h]
_QWORD *v72; // [rsp+18h] [rbp-48h]
char v73; // [rsp+24h] [rbp-3Ch]
char v74; // [rsp+28h] [rbp-38h]
__int64 *v75; // [rsp+28h] [rbp-38h]
__int64 v76; // [rsp+30h] [rbp-30h]
v2 = a2;
v3 = a1;
if ( a2 && *(_BYTE *)(a2 + 1) != 1 )
{
v39 = *(const char ***)(a1 + 64);
v40 = "Step has to be applied to node set";
goto LABEL_154;
}
v4 = a1 + 8;
v5 = *(_DWORD *)(a1 + 40);
switch ( v5 )
{
case 24:
sub_10064C690(a1 + 8);
v11 = *(_QWORD **)a1;
v12 = *(_QWORD *)(*(_QWORD *)a1 + 8LL);
if ( (unsigned __int64)(v12 + 40) > 0x1000 )
{
v23 = (_QWORD *)off_10099E670();
if ( !v23 )
goto LABEL_148;
*v23 = *v11;
*v11 = v23;
v11[1] = 40;
v9 = (__int64)(v23 + 1);
}
else
{
v9 = *v11 + v12 + 8;
v11[1] = v12 + 40;
}
v10 = 9;
goto LABEL_37;
case 23:
sub_10064C690(a1 + 8);
v7 = *(_QWORD **)a1;
v8 = *(_QWORD *)(*(_QWORD *)a1 + 8LL);
if ( (unsigned __int64)(v8 + 40) > 0x1000 )
{
v22 = (_QWORD *)off_10099E670();
if ( !v22 )
goto LABEL_148;
*v22 = *v7;
*v7 = v22;
v7[1] = 40;
v9 = (__int64)(v22 + 1);
v10 = 12;
}
else
{
v9 = *v7 + v8 + 8;
v7[1] = v8 + 40;
v10 = 12;
}
LABEL_37:
*(_WORD *)v9 = 313;
*(_BYTE *)(v9 + 2) = v10;
*(_BYTE *)(v9 + 3) = 2;
*(_QWORD *)(v9 + 8) = v2;
*(_OWORD *)(v9 + 16) = 0;
*(_QWORD *)(v9 + 32) = 0;
return v9;
case 22:
sub_10064C690(a1 + 8);
v5 = *(_DWORD *)(a1 + 40);
v6 = 1;
v76 = a1 + 8;
v74 = 2;
if ( v5 == 9 )
goto LABEL_98;
break;
default:
v6 = 0;
v76 = a1 + 8;
v74 = 3;
if ( v5 == 9 )
{
LABEL_98:
sub_10064C690(v4);
LOBYTE(v38) = 7;
LABEL_99:
v13 = nullptr;
v41 = 0;
goto LABEL_100;
}
break;
}
if ( v5 != 20 )
{
LABEL_149:
v39 = *(const char ***)(a1 + 64);
v40 = "Unrecognized node test";
goto LABEL_154;
}
v13 = *(_BYTE **)(a1 + 24);
v14 = *(_QWORD *)(a1 + 32);
sub_10064C690(v76);
v15 = *(_DWORD *)(a1 + 40);
if ( v15 == 25 )
{
if ( v6 )
{
v39 = *(const char ***)(a1 + 64);
v40 = "Two axis specifiers in one step";
goto LABEL_154;
}
switch ( *v13 )
{
case 'a':
v16 = v14 - (_QWORD)v13;
if ( (_BYTE *)v14 == v13 )
goto LABEL_21;
v17 = 0;
do
{
if ( aAncestor[v17] != v13[v17] )
goto LABEL_22;
++v17;
}
while ( v16 != v17 );
LABEL_21:
if ( !aAncestor[v16] )
{
v21 = 0;
goto LABEL_91;
}
LABEL_22:
if ( (_BYTE *)v14 == v13 )
{
LABEL_26:
if ( !aAncestorOrSelf[v16] )
{
v21 = 1;
goto LABEL_91;
}
}
else
{
v18 = 0;
while ( aAncestorOrSelf[v18] == v13[v18] )
{
if ( v16 == ++v18 )
goto LABEL_26;
}
}
if ( (_BYTE *)v14 != v13 )
{
v19 = 0;
while ( aAttribute[v19] == v13[v19] )
{
if ( v16 == ++v19 )
goto LABEL_31;
}
goto LABEL_145;
}
LABEL_31:
v20 = "attribute";
v21 = 2;
goto LABEL_83;
case 'c':
v24 = v14 - (_QWORD)v13;
if ( !v24 )
goto LABEL_47;
for ( i = 0; i != v24; ++i )
{
if ( aChild[i] != v13[i] )
goto LABEL_145;
}
LABEL_47:
v26 = "child";
v21 = 3;
goto LABEL_90;
case 'd':
v16 = v14 - (_QWORD)v13;
if ( (_BYTE *)v14 == v13 )
goto LABEL_67;
v31 = 0;
do
{
if ( aDescendant[v31] != v13[v31] )
goto LABEL_68;
++v31;
}
while ( v16 != v31 );
LABEL_67:
if ( !aDescendant[v16] )
{
v21 = 4;
goto LABEL_91;
}
LABEL_68:
if ( (_BYTE *)v14 != v13 )
{
v32 = 0;
while ( aDescendantOrSe[v32] == v13[v32] )
{
if ( v16 == ++v32 )
goto LABEL_72;
}
goto LABEL_145;
}
LABEL_72:
v20 = "descendant-or-self";
v21 = 5;
goto LABEL_83;
case 'f':
v16 = v14 - (_QWORD)v13;
if ( (_BYTE *)v14 == v13 )
goto LABEL_77;
v33 = 0;
do
{
if ( aFollowing[v33] != v13[v33] )
goto LABEL_78;
++v33;
}
while ( v16 != v33 );
LABEL_77:
if ( !aFollowing[v16] )
{
v21 = 6;
goto LABEL_91;
}
LABEL_78:
if ( (_BYTE *)v14 != v13 )
{
v34 = 0;
while ( aFollowingSibli[v34] == v13[v34] )
{
if ( v16 == ++v34 )
goto LABEL_82;
}
goto LABEL_145;
}
LABEL_82:
v20 = "following-sibling";
v21 = 7;
goto LABEL_83;
case 'n':
v24 = v14 - (_QWORD)v13;
if ( !v24 )
goto LABEL_42;
for ( j = 0; j != v24; ++j )
{
if ( aNamespace[j] != v13[j] )
goto LABEL_145;
}
LABEL_42:
v26 = "namespace";
v21 = 8;
goto LABEL_90;
case 'p':
v16 = v14 - (_QWORD)v13;
if ( (_BYTE *)v14 == v13 )
goto LABEL_52;
v28 = 0;
do
{
if ( aParent[v28] != v13[v28] )
goto LABEL_53;
++v28;
}
while ( v16 != v28 );
LABEL_52:
if ( !aParent[v16] )
{
v21 = 9;
goto LABEL_91;
}
LABEL_53:
if ( (_BYTE *)v14 == v13 )
{
LABEL_57:
if ( !aPreceding[v16] )
{
v21 = 10;
goto LABEL_91;
}
}
else
{
v29 = 0;
while ( aPreceding[v29] == v13[v29] )
{
if ( v16 == ++v29 )
goto LABEL_57;
}
}
if ( (_BYTE *)v14 != v13 )
{
v30 = 0;
while ( aPrecedingSibli[v30] == v13[v30] )
{
if ( v16 == ++v30 )
goto LABEL_62;
}
goto LABEL_145;
}
LABEL_62:
v20 = "preceding-sibling";
v21 = 11;
LABEL_83:
if ( v20[v16] )
{
LABEL_145:
v39 = *(const char ***)(a1 + 64);
v40 = "Unknown axis";
goto LABEL_154;
}
LABEL_91:
v4 = v76;
sub_10064C690(v76);
v36 = *(_DWORD *)(a1 + 40);
v74 = v21;
if ( v36 == 9 )
goto LABEL_98;
if ( v36 != 20 )
goto LABEL_149;
v13 = *(_BYTE **)(a1 + 24);
v14 = *(_QWORD *)(a1 + 32);
sub_10064C690(v76);
v15 = *(_DWORD *)(a1 + 40);
break;
case 's':
v24 = v14 - (_QWORD)v13;
if ( !v24 )
goto LABEL_89;
for ( k = 0; k != v24; ++k )
{
if ( aSelf[k] != v13[k] )
goto LABEL_145;
}
LABEL_89:
v26 = "self";
v21 = 12;
LABEL_90:
if ( !v26[v24] )
goto LABEL_91;
goto LABEL_145;
default:
goto LABEL_145;
}
}
if ( v15 == 12 )
{
sub_10064C690(v76);
v37 = *(_DWORD *)(a1 + 40);
if ( v37 == 13 )
{
sub_10064C690(v76);
v38 = sub_10064EE10(v13, v14);
if ( !v38 )
{
v39 = *(const char ***)(a1 + 64);
v40 = "Unrecognized node type";
goto LABEL_154;
}
goto LABEL_99;
}
v66 = v14 - (_QWORD)v13;
if ( v66 )
{
v67 = 0;
while ( aProcessingInst[v67] == v13[v67] )
{
if ( v66 == ++v67 )
goto LABEL_133;
}
goto LABEL_146;
}
LABEL_133:
if ( aProcessingInst[v66] )
{
LABEL_146:
v39 = *(const char ***)(a1 + 64);
v40 = "Unmatched brace near node type test";
goto LABEL_154;
}
if ( v37 != 14 )
{
v39 = *(const char ***)(a1 + 64);
v40 = "Only literals are allowed as arguments to processing-instruction()";
goto LABEL_154;
}
v13 = *(_BYTE **)(a1 + 24);
v68 = *(_QWORD *)(a1 + 32);
sub_10064C690(v76);
if ( *(_DWORD *)(a1 + 40) != 13 )
{
v39 = *(const char ***)(a1 + 64);
v40 = "Unmatched brace near processing-instruction()";
goto LABEL_154;
}
sub_10064C690(v76);
LOBYTE(v38) = 6;
v41 = v68;
}
else
{
v41 = v14;
LOBYTE(v38) = 1;
if ( v14 - (__int64)v13 >= 3 && *(_BYTE *)(v14 - 2) == 58 )
{
if ( *(_BYTE *)(v14 - 1) == 42 )
v41 = v14 - 1;
LOBYTE(v38) = 1;
if ( *(_BYTE *)(v14 - 1) == 42 )
LOBYTE(v38) = 8;
}
}
LABEL_100:
v73 = v38;
v42 = *(_QWORD **)a1;
v43 = *(_QWORD *)(*(_QWORD *)a1 + 8LL);
if ( (unsigned __int64)(v43 + 40) > 0x1000 )
{
v49 = v41;
v50 = (_QWORD *)off_10099E670();
if ( v50 )
{
*v50 = *v42;
*v42 = v50;
v42[1] = 40;
v9 = (__int64)(v50 + 1);
v41 = v49;
v72 = v50 + 1;
if ( v13 )
goto LABEL_102;
LABEL_106:
v48 = nullptr;
goto LABEL_110;
}
LABEL_148:
v39 = *(const char ***)(a1 + 64);
v40 = "Out of memory";
goto LABEL_154;
}
v9 = v43 + *v42 + 8;
v42[1] = v43 + 40;
v72 = (_QWORD *)v9;
if ( !v13 )
goto LABEL_106;
LABEL_102:
v70 = v2;
v44 = v41 - (_QWORD)v13;
v45 = *(_QWORD **)a1;
v46 = *(_QWORD *)(*(_QWORD *)a1 + 8LL);
v47 = v46 + (v44 & 0xFFFFFFFFFFFFFFF8LL) + 8;
if ( v47 > 0x1000 )
{
__n = v44;
v51 = (v44 & 0xFFFFFFFFFFFFFFF8LL) + 8;
v52 = (_QWORD *)off_10099E670();
if ( !v52 )
sub_10064EC10(a1);
*v52 = *v45;
*v45 = v52;
v45[1] = v51;
v48 = v52 + 1;
v44 = __n;
}
else
{
v48 = (void *)(*v45 + v46 + 8);
v45[1] = v47;
}
v53 = v44;
memcpy(v48, v13, v44);
*((_BYTE *)v48 + v53) = 0;
v2 = v70;
v9 = (__int64)v72;
LABEL_110:
*(_WORD *)v9 = 313;
*(_BYTE *)(v9 + 2) = v74;
*(_BYTE *)(v9 + 3) = v73;
*(_QWORD *)(v9 + 8) = v2;
*(_OWORD *)(v9 + 16) = 0;
*(_QWORD *)(v9 + 32) = v48;
if ( *(_DWORD *)(a1 + 40) == 18 )
{
v75 = (__int64 *)(v9 + 16);
v54 = 0;
v55 = v76;
while ( 1 )
{
sub_10064C690(v55);
v9 = sub_10064CF70(v3, v9, v56, v57);
v58 = sub_10064CC10(v3, v9, 0);
v59 = v3;
v60 = *(_QWORD **)v3;
v61 = v60[1];
if ( (unsigned __int64)(v61 + 40) > 0x1000 )
{
v63 = (_QWORD *)off_10099E670();
if ( !v63 )
{
v69 = *(_QWORD **)(v59 + 64);
*v69 = "Out of memory";
v69[1] = *(_QWORD *)(v59 + 16) - *(_QWORD *)(v59 + 48);
longjmp((int *)(v59 + 104), 1);
}
*v63 = *v60;
*v60 = v63;
v60[1] = 40;
v62 = (__int64)(v63 + 1);
}
else
{
v62 = *v60 + v61 + 8;
v60[1] = v61 + 40;
}
*(_DWORD *)v62 = 272;
*(_QWORD *)(v62 + 8) = v58;
*(_OWORD *)(v62 + 16) = 0;
v3 = v59;
if ( *(_DWORD *)(v59 + 40) != 19 )
break;
v55 = v76;
sub_10064C690(v76);
v64 = (__int64 *)(v54 + 24);
if ( !v54 )
v64 = v75;
*v64 = v62;
v54 = v62;
if ( *(_DWORD *)(v3 + 40) != 18 )
return (__int64)v72;
}
v39 = *(const char ***)(v59 + 64);
v40 = "Unmatched square brace";
LABEL_154:
*v39 = v40;
v39[1] = (const char *)(*(_QWORD *)(v3 + 16) - *(_QWORD *)(v3 + 48));
longjmp((int *)(v3 + 104), 1);
}
return v9;
}