//
// sub_819400 from 0x819400 to 0x819c8c (2188 bytes)
//
// 3 xrefs:
// > sub_819400 @ 0x819870
// > sub_819D3C @ 0x819d7a
// > sub_819E00 @ 0x819e04
//
// 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:44 +0000
//
int *__fastcall sub_819400(int a1)
{
__int64 v1; // d0
int v2; // r6
int v3; // r5
int v4; // r3
int v5; // r2
int v6; // t1
int *result; // r0
unsigned int v8; // r5
pugi::xpath_variable_set *v9; // r9
const void *v10; // r10
const char *v11; // r1
size_t v12; // r5
void *v13; // r8
void *v14; // r4
pugi::xpath_variable *v15; // r5
char v16; // r8
int *v17; // r0
int *v18; // r4
unsigned __int8 **v19; // r5
unsigned __int8 **v20; // r0
int *v21; // r5
int *v22; // r0
const void *v23; // r9
void *v24; // r8
size_t v25; // r4
void *v26; // r5
int v27; // r1
int v28; // r9
int v29; // r3
int v30; // r0
int *v31; // r3
int *v32; // r0
int v33; // r5
unsigned __int8 *v34; // r0
unsigned __int8 *v35; // r11
int v36; // r3
int *v37; // r0
char v38; // r3
int *v39; // r8
int *v40; // r0
int v41; // r0
int v42; // r4
int *v43; // r0
int *v44; // r0
int v45; // r2
char v46; // r3
char v47; // r3
char v48; // r3
int v49; // r1
char v50; // r3
int v51; // r2
char v52; // r3
char v53; // r3
char v54; // r3
char v55; // r3
int *v56; // r0
char v57; // r3
int *v58; // r0
int *v59; // r0
int *v60; // r0
int *v61; // r0
int *v62; // r0
char v63; // r3
int *v64; // r0
int v65; // [sp+Ch] [bp-20h]
int v66; // [sp+14h] [bp-18h] BYREF
int v67; // [sp+18h] [bp-14h]
int v68[2]; // [sp+1Ch] [bp-10h] BYREF
v2 = a1;
v3 = *(_DWORD *)(a1 + 20);
switch ( v3 )
{
case 11:
v9 = *(pugi::xpath_variable_set **)(a1 + 28);
v10 = *(const void **)(a1 + 12);
if ( !v9 )
{
v11 = "Unknown variable: variable set is not provided";
goto LABEL_17;
}
v12 = *(_DWORD *)(a1 + 16) - (_DWORD)v10;
v13 = (void *)(a1 + 36);
if ( v12 <= 0x1F )
{
v14 = (void *)(a1 + 36);
}
else
{
v14 = (void *)off_D2006C(v12 + 1);
if ( !v14 )
goto LABEL_16;
}
memcpy(v14, v10, v12);
*((_BYTE *)v14 + v12) = 0;
v15 = pugi::xpath_variable_set::get(v9, (const char *)v14);
if ( v14 != v13 )
off_D20070(v14);
if ( v15 )
{
sub_80F84C((unsigned __int8 **)(v2 + 4));
v16 = pugi::xpath_variable::type(v15);
v17 = sub_8101B8((int **)v2);
v18 = v17;
if ( v17 )
{
*((_BYTE *)v17 + 1) = v16;
*(_BYTE *)v17 = 21;
v17[4] = (int)v15;
*((_BYTE *)v17 + 2) = 0;
*((_BYTE *)v17 + 3) = 0;
v17[1] = 0;
v17[2] = 0;
v17[3] = 0;
}
LABEL_91:
while ( 1 )
{
v33 = *(_DWORD *)(v2 + 20);
if ( v33 != 18 )
break;
sub_80F84C((unsigned __int8 **)(v2 + 4));
v34 = (unsigned __int8 *)sub_819E00(v2);
v35 = v34;
if ( *((_BYTE *)v18 + 1) != 1 )
{
a1 = v2;
v11 = "Predicate has to be applied to node set";
goto LABEL_17;
}
if ( v34[1] == 2 )
v36 = 0;
else
v36 = sub_80FAC0(v34);
v65 = v36;
v37 = sub_8101B8((int **)v2);
if ( v37 )
{
*((_BYTE *)v37 + 1) = 1;
*((_BYTE *)v37 + 2) = 0;
*((_BYTE *)v37 + 3) = 0;
if ( v65 )
v38 = 18;
else
v38 = 17;
v37[1] = (int)v18;
*(_BYTE *)v37 = v38;
v37[2] = (int)v35;
v37[3] = 0;
}
if ( *(_DWORD *)(v2 + 20) != 19 )
{
a1 = v2;
v11 = "Unmatched square brace";
goto LABEL_17;
}
v18 = v37;
sub_80F84C((unsigned __int8 **)(v2 + 4));
}
v39 = v18;
if ( (unsigned int)(v33 - 16) > 1 )
return v18;
sub_80F84C((unsigned __int8 **)(v2 + 4));
if ( v33 == 17 )
{
a1 = v2;
if ( *((_BYTE *)v18 + 1) != 1 )
{
v11 = "Step has to be applied to node set";
LABEL_17:
sub_810198(a1, (int)v11);
}
v40 = sub_8101B8((int **)v2);
v18 = v40;
if ( v40 )
{
*((_BYTE *)v40 + 1) = 1;
*(_BYTE *)v40 = 57;
v40[1] = (int)v39;
*((_BYTE *)v40 + 2) = 5;
*((_BYTE *)v40 + 3) = 2;
v40[2] = 0;
v40[3] = 0;
v40[4] = 0;
}
}
return (int *)sub_81A290(v2, v18);
}
LABEL_16:
a1 = v2;
v11 = "Unknown variable: variable set does not contain the given name";
goto LABEL_17;
case 12:
v19 = (unsigned __int8 **)(a1 + 4);
sub_80F84C((unsigned __int8 **)(a1 + 4));
v18 = (int *)sub_819E00(v2);
if ( *(_DWORD *)(v2 + 20) != 13 )
{
a1 = v2;
v11 = "Unmatched braces";
goto LABEL_17;
}
v20 = v19;
LABEL_30:
sub_80F84C(v20);
goto LABEL_91;
case 14:
v21 = sub_811A50((int **)a1, a1 + 12);
v22 = sub_8101B8((int **)v2);
v18 = v22;
if ( v22 )
{
v22[4] = (int)v21;
*(_BYTE *)v22 = 19;
*((_BYTE *)v22 + 1) = 3;
*((_BYTE *)v22 + 2) = 0;
*((_BYTE *)v22 + 3) = 0;
v22[1] = 0;
v22[2] = 0;
v22[3] = 0;
}
LABEL_29:
v20 = (unsigned __int8 **)(v2 + 4);
goto LABEL_30;
case 15:
v23 = *(const void **)(a1 + 12);
v24 = (void *)(a1 + 36);
v25 = *(_DWORD *)(a1 + 16) - (_DWORD)v23;
if ( v25 <= 0x1F )
{
v26 = (void *)(a1 + 36);
}
else
{
v26 = (void *)off_D2006C(v25 + 1);
if ( !v26 )
{
a1 = v2;
v11 = "Out of memory";
goto LABEL_17;
}
}
memcpy(v26, v23, v25);
*((_BYTE *)v26 + v25) = 0;
sub_811038((const char *)v26);
if ( v26 != v24 )
off_D20070(v26);
v43 = sub_8101B8((int **)v2);
v18 = v43;
if ( v43 )
{
*((_QWORD *)v43 + 2) = v1;
*(_BYTE *)v43 = 20;
*((_BYTE *)v43 + 1) = 2;
*((_BYTE *)v43 + 2) = 0;
*((_BYTE *)v43 + 3) = 0;
v43[1] = 0;
v43[2] = 0;
v43[3] = 0;
}
goto LABEL_29;
case 20:
v4 = *(_DWORD *)(a1 + 4) - 1;
do
{
v6 = *(unsigned __int8 *)++v4;
v5 = v6;
}
while ( (a7[v6] & 8) != 0 );
if ( v5 != 40 )
return (int *)sub_81A2F2(v2);
v8 = sub_810AF0((int *)(a1 + 12));
if ( v8 )
return (int *)sub_81A2F2(v2);
v66 = 0;
v67 = 0;
v27 = *(_DWORD *)(v2 + 16);
v68[0] = *(_DWORD *)(v2 + 12);
v68[1] = v27;
sub_80F84C((unsigned __int8 **)(v2 + 4));
if ( *(_DWORD *)(v2 + 20) != 12 )
{
a1 = v2;
v11 = "Unrecognized function call";
goto LABEL_17;
}
sub_80F84C((unsigned __int8 **)(v2 + 4));
if ( *(_DWORD *)(v2 + 20) != 13 )
{
v8 = 1;
v66 = sub_819E00(v2);
}
v28 = 0;
while ( 1 )
{
v29 = *(_DWORD *)(v2 + 20);
if ( v29 == 13 )
break;
if ( v29 != 21 )
{
a1 = v2;
v11 = "No comma between function arguments";
goto LABEL_17;
}
sub_80F84C((unsigned __int8 **)(v2 + 4));
v30 = sub_819E00(v2);
if ( v8 > 1 )
*(_DWORD *)(v28 + 12) = v30;
else
v31 = &v66;
v28 = v30;
if ( v8 <= 1 )
v31[v8] = v30;
++v8;
}
sub_80F84C((unsigned __int8 **)(v2 + 4));
switch ( *(_BYTE *)v68[0] )
{
case 'b':
if ( !sub_80F83C(v68, (int)"boolean") || v8 != 1 )
goto LABEL_89;
v44 = sub_8101B8((int **)v2);
v18 = v44;
if ( !v44 )
goto LABEL_91;
v45 = v66;
v46 = 46;
goto LABEL_121;
case 'c':
if ( sub_80F83C(v68, (int)"count") && v8 == 1 )
{
if ( *(_BYTE *)(v66 + 1) != 1 )
{
LABEL_126:
a1 = v2;
v11 = "Function has to be applied to node set";
goto LABEL_17;
}
v18 = sub_8101B8((int **)v2);
if ( !v18 )
goto LABEL_91;
v45 = v66;
v48 = 24;
goto LABEL_129;
}
if ( !sub_80F83C(v68, (int)"contains") || v8 != 2 )
{
if ( !sub_80F83C(v68, (int)"concat") || v8 <= 1 )
{
if ( !sub_80F83C(v68, (int)"ceiling") || v8 != 1 )
{
LABEL_89:
a1 = v2;
v11 = "Unrecognized function or wrong parameter count";
goto LABEL_17;
}
v18 = sub_8101B8((int **)v2);
if ( !v18 )
goto LABEL_91;
v45 = v66;
v48 = 55;
LABEL_129:
*(_BYTE *)v18 = v48;
v47 = 2;
goto LABEL_122;
}
v18 = sub_8101B8((int **)v2);
if ( !v18 )
goto LABEL_91;
v49 = v66;
v53 = 34;
v51 = v67;
goto LABEL_143;
}
v18 = sub_8101B8((int **)v2);
if ( !v18 )
goto LABEL_91;
v49 = v66;
v50 = 36;
v51 = v67;
goto LABEL_138;
case 'f':
if ( !sub_80F83C(v68, (int)"false") || v8 )
{
if ( !sub_80F83C(v68, (int)"floor") || v8 != 1 )
goto LABEL_89;
v18 = sub_8101B8((int **)v2);
if ( !v18 )
goto LABEL_91;
v45 = v66;
v48 = 54;
goto LABEL_129;
}
v18 = sub_8101B8((int **)v2);
if ( !v18 )
goto LABEL_91;
v54 = 49;
goto LABEL_152;
case 'i':
if ( !sub_80F83C(v68, (int)"id") || v8 != 1 )
goto LABEL_89;
v56 = sub_8101B8((int **)v2);
v18 = v56;
if ( !v56 )
goto LABEL_91;
v45 = v66;
*((_BYTE *)v56 + 1) = 1;
*(_BYTE *)v56 = 25;
goto LABEL_123;
case 'l':
if ( sub_80F83C(v68, (int)"last") && !v8 )
{
v18 = sub_8101B8((int **)v2);
if ( !v18 )
goto LABEL_91;
v57 = 22;
LABEL_162:
*(_BYTE *)v18 = v57;
v55 = 2;
LABEL_153:
*((_BYTE *)v18 + 1) = v55;
*((_BYTE *)v18 + 2) = 0;
*((_BYTE *)v18 + 3) = 0;
v18[1] = 0;
v18[2] = 0;
v18[3] = 0;
goto LABEL_91;
}
if ( sub_80F83C(v68, (int)"lang") && v8 == 1 )
{
v18 = sub_8101B8((int **)v2);
if ( !v18 )
goto LABEL_91;
v45 = v66;
v46 = 50;
LABEL_121:
*(_BYTE *)v18 = v46;
v47 = 4;
goto LABEL_122;
}
if ( !sub_80F83C(v68, (int)"local-name") || v8 > 1 )
goto LABEL_89;
v32 = sub_8101D8((int **)v2, 26, 27, v8, &v66);
goto LABEL_172;
case 'n':
if ( sub_80F83C(v68, (int)"name") && v8 <= 1 )
{
v32 = sub_8101D8((int **)v2, 30, 31, v8, &v66);
LABEL_172:
v18 = v32;
goto LABEL_91;
}
if ( sub_80F83C(v68, (int)"namespace-uri") && v8 <= 1 )
{
v32 = sub_8101D8((int **)v2, 28, 29, v8, &v66);
goto LABEL_172;
}
if ( sub_80F83C(v68, (int)"normalize-space") && v8 <= 1 )
{
v58 = sub_8101B8((int **)v2);
v18 = v58;
if ( v58 )
{
if ( v8 )
v53 = 44;
else
v53 = 43;
LABEL_190:
v49 = v66;
v51 = v67;
LABEL_143:
*(_BYTE *)v18 = v53;
v52 = 3;
goto LABEL_139;
}
goto LABEL_191;
}
if ( sub_80F83C(v68, (int)"not") && v8 == 1 )
{
v59 = sub_8101B8((int **)v2);
v18 = v59;
if ( !v59 )
goto LABEL_91;
v45 = v66;
v46 = 47;
goto LABEL_121;
}
if ( !sub_80F83C(v68, (int)"number") || v8 > 1 )
goto LABEL_89;
v60 = sub_8101B8((int **)v2);
v18 = v60;
if ( !v60 )
goto LABEL_191;
if ( v8 )
v48 = 52;
else
v48 = 51;
break;
case 'p':
if ( !sub_80F83C(v68, (int)"position") || v8 )
goto LABEL_89;
v18 = sub_8101B8((int **)v2);
if ( !v18 )
goto LABEL_91;
v57 = 23;
goto LABEL_162;
case 'r':
if ( !sub_80F83C(v68, (int)"round") || v8 != 1 )
goto LABEL_89;
v61 = sub_8101B8((int **)v2);
v18 = v61;
if ( !v61 )
goto LABEL_91;
v45 = v66;
v48 = 56;
goto LABEL_129;
case 's':
if ( sub_80F83C(v68, (int)"string") && v8 <= 1 )
{
v62 = sub_8101B8((int **)v2);
v18 = v62;
if ( v62 )
{
v45 = v66;
if ( v8 )
v63 = 33;
else
v63 = 32;
*(_BYTE *)v62 = v63;
v47 = 3;
LABEL_122:
*((_BYTE *)v18 + 1) = v47;
LABEL_123:
v18[1] = v45;
*((_BYTE *)v18 + 2) = 0;
*((_BYTE *)v18 + 3) = 0;
v18[2] = 0;
goto LABEL_124;
}
goto LABEL_191;
}
if ( !sub_80F83C(v68, (int)"string-length") || v8 > 1 )
{
if ( sub_80F83C(v68, (int)"starts-with") && v8 == 2 )
{
v18 = sub_8101B8((int **)v2);
if ( !v18 )
goto LABEL_91;
v49 = v66;
v50 = 35;
v51 = v67;
LABEL_138:
*(_BYTE *)v18 = v50;
v52 = 4;
LABEL_139:
*((_BYTE *)v18 + 1) = v52;
LABEL_140:
v18[1] = v49;
*((_BYTE *)v18 + 2) = 0;
*((_BYTE *)v18 + 3) = 0;
v18[2] = v51;
LABEL_124:
v18[3] = 0;
goto LABEL_91;
}
if ( sub_80F83C(v68, (int)"substring-before") && v8 == 2 )
{
v18 = sub_8101B8((int **)v2);
if ( !v18 )
goto LABEL_91;
v49 = v66;
v53 = 37;
v51 = v67;
goto LABEL_143;
}
if ( sub_80F83C(v68, (int)"substring-after") && v8 == 2 )
{
v18 = sub_8101B8((int **)v2);
if ( !v18 )
goto LABEL_91;
v49 = v66;
v53 = 38;
v51 = v67;
goto LABEL_143;
}
if ( !sub_80F83C(v68, (int)"substring") || v8 - 2 > 1 )
{
if ( !sub_80F83C(v68, (int)"sum") || v8 != 1 )
goto LABEL_89;
if ( *(_BYTE *)(v66 + 1) != 1 )
goto LABEL_126;
v18 = sub_8101B8((int **)v2);
if ( !v18 )
goto LABEL_91;
v45 = v66;
v48 = 53;
goto LABEL_129;
}
v18 = sub_8101B8((int **)v2);
if ( v18 )
{
if ( v8 == 2 )
v53 = 39;
else
v53 = 40;
goto LABEL_190;
}
LABEL_191:
v18 = nullptr;
goto LABEL_91;
}
v18 = sub_8101B8((int **)v2);
if ( !v18 )
goto LABEL_191;
if ( v8 )
v48 = 42;
else
v48 = 41;
break;
case 't':
if ( sub_80F83C(v68, (int)"translate") && v8 == 3 )
{
v64 = sub_8101B8((int **)v2);
v18 = v64;
if ( !v64 )
goto LABEL_91;
v49 = v66;
v51 = v67;
*(_BYTE *)v64 = 45;
*((_BYTE *)v64 + 1) = 3;
goto LABEL_140;
}
if ( !sub_80F83C(v68, (int)"true") || v8 )
goto LABEL_89;
v18 = sub_8101B8((int **)v2);
if ( !v18 )
goto LABEL_91;
v54 = 48;
LABEL_152:
*(_BYTE *)v18 = v54;
v55 = 4;
goto LABEL_153;
default:
goto LABEL_89;
}
v45 = v66;
goto LABEL_129;
}
if ( v3 != 8 )
return (int *)sub_81A2F2(v2);
sub_80F84C((unsigned __int8 **)(a1 + 4));
v41 = sub_819400(v2);
v42 = sub_819D3C(v2, v41, 7);
result = sub_8101B8((int **)v2);
if ( result )
{
result[1] = v42;
*(_BYTE *)result = 14;
*((_BYTE *)result + 1) = 2;
*((_BYTE *)result + 2) = 0;
*((_BYTE *)result + 3) = 0;
result[2] = 0;
result[3] = 0;
}
return result;
}