//
// sub_606D38 from 0x606d38 to 0x606eec (436 bytes)
//
// 22 xrefs:
// > sub_608878 @ 0x6089f8
// > sub_608878 @ 0x608a02
// > sub_608878 @ 0x608a96
// > sub_608878 @ 0x608b00
// > sub_608878 @ 0x608c04
// > sub_608878 @ 0x608c0e
// > sub_608878 @ 0x608c9a
// > sub_608878 @ 0x608d08
// > sub_608F28 @ 0x60909e
// > sub_608F28 @ 0x6090f0
// > sub_608F28 @ 0x609142
// > sub_609260 @ 0x6093b4
// > sub_609260 @ 0x6096be
// > sub_609260 @ 0x609846
// > sub_609AD8 @ 0x609b76
// > sub_609AD8 @ 0x609b9a
// > sub_609AD8 @ 0x609c18
// > sub_609AD8 @ 0x609c78
// > sub_609CC0 @ 0x609d5e
// > sub_609CC0 @ 0x609d82
// > sub_609CC0 @ 0x609e00
// > sub_609CC0 @ 0x609e60
//
// 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_606D38(int a1, pugi::xpath_node *this, int a3)
{
pugi::xml_node_struct *v5; // r1
pugi::xml_node_struct *v6; // r2
void *v7; // r0
pugi::xml_node_struct *v8; // r1
const char *v9; // r7
int v10; // r8
pugi::xml_node_struct *v11; // r1
const char *v12; // r10
pugi::xml_node_struct *v13; // r1
pugi::xml_node_struct *v14; // r0
pugi::xml_node_struct *v15; // r1
pugi::xml_node_struct *v16; // r1
size_t v17; // r9
size_t v18; // r0
int *v19; // r1
int *v20; // r0
int *v21; // r11
const char *v22; // r1
size_t v24; // [sp+0h] [bp-24h]
size_t v25; // [sp+4h] [bp-20h]
pugi::xml_node v27; // [sp+10h] [bp-14h] BYREF
pugi::xml_node v28; // [sp+14h] [bp-10h] BYREF
pugi::xml_attribute v29; // [sp+18h] [bp-Ch] BYREF
v29._attr = (pugi::xml_attribute_struct *)pugi::xpath_node::attribute(this);
if ( !pugi::xml_attribute::operator void (*)(pugi::xml_attribute***)((void (**)())&v29) )
{
v28._root = pugi::xpath_node::node((void (**)())this, v5, v6);
switch ( (unsigned int)pugi::xml_node::type(&v28) )
{
case 1u:
case 2u:
v9 = (const char *)&unk_939830;
v10 = 0;
v27._root = pugi::xml_node::first_child(&v28, v8);
break;
case 3u:
case 4u:
case 5u:
case 6u:
v7 = pugi::xml_node::value(&v28);
goto LABEL_5;
default:
*(_DWORD *)a1 = &unk_939830;
goto LABEL_11;
}
while ( 1 )
{
if ( !pugi::xml_node::operator void (*)(pugi::xml_node***)((void (**)())&v27)
|| !pugi::xml_node::operator!=(&v27, &v28) )
{
*(_DWORD *)a1 = v9;
*(_BYTE *)(a1 + 4) = v10;
return a1;
}
if ( pugi::xml_node::type(&v27) == (pugi::xml_node_struct *)((char *)&dword_0 + 3)
|| pugi::xml_node::type(&v27) == (pugi::xml_node_struct *)byte_4 )
{
v12 = (const char *)pugi::xml_node::value(&v27);
if ( *v12 )
{
if ( *v9 || v10 )
{
v17 = strlen(v9);
v18 = strlen(v12);
if ( v10 )
v19 = (int *)v9;
else
v19 = nullptr;
v24 = v18;
v25 = v18 + v17;
v20 = sub_601B48(a3, v19, v17 + 1, v18 + v17 + 1);
v21 = v20;
if ( !v10 )
memcpy(v20, v9, v17);
v22 = v12;
v12 = (const char *)v21;
memcpy((char *)v21 + v17, v22, v24);
v10 = 1;
*((_BYTE *)v21 + v25) = 0;
}
}
else
{
v12 = v9;
}
v9 = v12;
}
v29._attr = pugi::xml_node::first_child(&v27, v11);
if ( pugi::xml_node::operator void (*)(pugi::xml_node***)((void (**)())&v29) )
break;
v29._attr = pugi::xml_node::next_sibling(&v27, v13);
if ( !pugi::xml_node::operator void (*)(pugi::xml_node***)((void (**)())&v29) )
{
while ( 1 )
{
v29._attr = pugi::xml_node::next_sibling(&v27, v15);
if ( !pugi::xml_node::operator!(&v29) || !pugi::xml_node::operator!=(&v27, &v28) )
break;
v27._root = pugi::xml_node::parent(&v27, v16);
}
if ( !pugi::xml_node::operator!=(&v27, &v28) )
continue;
}
v14 = pugi::xml_node::next_sibling(&v27, v15);
LABEL_22:
v27._root = v14;
}
v14 = pugi::xml_node::first_child(&v27, v13);
goto LABEL_22;
}
v29._attr = (pugi::xml_attribute_struct *)pugi::xpath_node::attribute(this);
v7 = pugi::xml_attribute::value(&v29);
LABEL_5:
*(_DWORD *)a1 = v7;
LABEL_11:
*(_BYTE *)(a1 + 4) = 0;
return a1;
}