//
// sub_816170 from 0x816170 to 0x8163b0 (576 bytes)
//
// 8 xrefs:
// > sub_8163B4 @ 0x8163c0
// > sub_8163B4 @ 0x8163d2
// > sub_8163B4 @ 0x8163e4
// > sub_8163F8 @ 0x816420
// > sub_8165B4 @ 0x81668c
// > sub_8165B4 @ 0x8166be
// > sub_8165B4 @ 0x8166e8
// > sub_8165B4 @ 0x816716
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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 12:01:42 +0000
//
void (*__fastcall sub_816170(void (**a1)(), void (**a2)(), int a3))()
{
unsigned int v5; // r4
int v6; // r1
int v7; // r2
unsigned int v8; // r0
int v9; // r1
int v10; // r2
bool v11; // cf
int v12; // r1
int v13; // r2
void (*k)(); // r0
void (*result)(); // r0
int v16; // r1
int v17; // r1
int v18; // r2
int v19; // r1
int v20; // r2
unsigned int v21; // r4
int v22; // r1
unsigned int v23; // r10
unsigned int v24; // r7
int v25; // r1
unsigned int v26; // r6
int v27; // r1
int v28; // r1
int v29; // r1
int v30; // r1
int v31; // r1
void (*v32)(); // [sp+4h] [bp-24h] BYREF
void (*v33)(); // [sp+8h] [bp-20h] BYREF
void (*i)(); // [sp+Ch] [bp-1Ch] BYREF
void (*j)(); // [sp+10h] [bp-18h] BYREF
void (*sibling)(); // [sp+14h] [bp-14h] BYREF
int v37; // [sp+18h] [bp-10h] BYREF
void (*v38)(); // [sp+1Ch] [bp-Ch] BYREF
void (*v39)(); // [sp+20h] [bp-8h] BYREF
v5 = sub_815DF8(a1, (int)a2, a3);
v8 = sub_815DF8(a2, v6, v7);
if ( v5 && v8 )
{
v11 = v5 >= v8;
return (void (*)())!v11;
}
v32 = pugi::xpath_node::node(a1, v9, v10);
v33 = pugi::xpath_node::node(a2, v12, v13);
v39 = (void (*)())pugi::xpath_node::attribute((pugi::xpath_node *)a1);
if ( !pugi::xml_attribute::operator void (*)(pugi::xml_attribute***)(&v39)
|| (v38 = (void (*)())pugi::xpath_node::attribute((pugi::xpath_node *)a2),
!pugi::xml_attribute::operator void (*)(pugi::xml_attribute***)(&v38)) )
{
v39 = (void (*)())pugi::xpath_node::attribute((pugi::xpath_node *)a1);
if ( pugi::xml_attribute::operator void (*)(pugi::xml_attribute***)(&v39) )
{
v39 = (void (*)())pugi::xpath_node::parent(a1);
v38 = pugi::xpath_node::node(a2, v17, v18);
if ( pugi::xml_node::operator==(&v39, &v38) )
return nullptr;
v32 = (void (*)())pugi::xpath_node::parent(a1);
LABEL_20:
if ( !pugi::xml_node::operator==(&v32, &v33) )
{
v21 = 0;
for ( i = v32;
pugi::xml_node::operator void (*)(pugi::xml_node***)(&i);
i = (void (*)())pugi::xml_node::parent((pugi::xml_node *)&i, v22) )
{
++v21;
}
v23 = v21;
v24 = 0;
for ( j = v33;
pugi::xml_node::operator void (*)(pugi::xml_node***)(&j);
j = (void (*)())pugi::xml_node::parent((pugi::xml_node *)&j, v25) )
{
++v24;
}
v26 = v24;
sibling = v32;
v37 = (int)v33;
while ( v26 < v21 )
{
++v26;
sibling = (void (*)())pugi::xml_node::parent((pugi::xml_node *)&sibling, v25);
}
while ( v23 < v24 )
{
++v23;
v37 = pugi::xml_node::parent((pugi::xml_node *)&v37, v25);
}
if ( pugi::xml_node::operator==(&sibling, &v37) )
{
v11 = v21 >= v24;
return (void (*)())!v11;
}
while ( 1 )
{
v39 = (void (*)())pugi::xml_node::parent((pugi::xml_node *)&sibling, v27);
v38 = (void (*)())pugi::xml_node::parent((pugi::xml_node *)&v37, v28);
if ( !pugi::xml_node::operator!=(&v39, &v38) )
break;
sibling = (void (*)())pugi::xml_node::parent((pugi::xml_node *)&sibling, v29);
v37 = pugi::xml_node::parent((pugi::xml_node *)&v37, v30);
}
v39 = (void (*)())pugi::xml_node::parent((pugi::xml_node *)&sibling, v29);
if ( pugi::xml_node::operator!(&v39) )
return (void (*)())pugi::xml_node::operator<(&sibling, &v37);
while ( pugi::xml_node::operator void (*)(pugi::xml_node***)(&sibling) )
{
if ( pugi::xml_node::operator==(&sibling, &v37) )
return (void (*)())(&dword_0 + 1);
sibling = (void (*)())pugi::xml_node::next_sibling((pugi::xml_node *)&sibling, v31);
}
}
return nullptr;
}
v39 = (void (*)())pugi::xpath_node::attribute((pugi::xpath_node *)a2);
if ( !pugi::xml_attribute::operator void (*)(pugi::xml_attribute***)(&v39) )
goto LABEL_20;
v39 = (void (*)())pugi::xpath_node::parent(a2);
v38 = pugi::xpath_node::node(a1, v19, v20);
if ( pugi::xml_node::operator==(&v39, &v38) )
return (void (*)())(&dword_0 + 1);
LABEL_19:
v33 = (void (*)())pugi::xpath_node::parent(a2);
goto LABEL_20;
}
v39 = (void (*)())pugi::xpath_node::parent(a1);
v38 = (void (*)())pugi::xpath_node::parent(a2);
if ( !pugi::xml_node::operator==(&v39, &v38) )
{
v32 = (void (*)())pugi::xpath_node::parent(a1);
goto LABEL_19;
}
for ( k = (void (*)())pugi::xpath_node::attribute((pugi::xpath_node *)a1);
;
k = (void (*)())pugi::xml_attribute::next_attribute((pugi::xml_attribute *)&v38, v16) )
{
v38 = k;
result = pugi::xml_attribute::operator void (*)(pugi::xml_attribute***)(&v38);
if ( !result )
break;
v39 = (void (*)())pugi::xpath_node::attribute((pugi::xpath_node *)a2);
result = (void (*)())pugi::xml_attribute::operator==(&v38, &v39);
if ( result )
break;
}
return result;
}