//
// pugi::xml_node::prepend_attribute from 0xb54434 to 0xb54568 (308 bytes)
//
// 2 xrefs:
// > pugi::xml_node::prepend_copy @ 0xb54958
// > ??> @ 0x53508
//
// 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
//
pugi::xml_attribute_struct *__fastcall pugi::xml_node::prepend_attribute(pugi::xml_node *this, char *a2)
{
pugi::xml_attribute_struct *result; // x0
pugi::xml_attribute_struct **v5; // x0
pugi::xml_attribute_struct *v6; // x2
pugi::xml_attribute_struct *v7; // x1
pugi::xml_attribute *v8; // x1
pugi::xml_node_struct *root; // x2
__int64 v10; // x1
pugi::xml_attribute v11; // [xsp+38h] [xbp+38h] BYREF
pugi::xml_attribute v12; // [xsp+40h] [xbp+40h] BYREF
if ( (unsigned int)pugi::xml_node::type(this) != 2 && (unsigned int)pugi::xml_node::type(this) != 7 )
goto LABEL_3;
v5 = *(pugi::xml_attribute_struct ***)(*(_QWORD *)this->_root & 0xFFFFFFFFFFFFFFE0LL);
v6 = v5[1];
if ( (unsigned __int64)v6 + 40 > 0x8000 )
{
v8 = (pugi::xml_attribute *)sub_B4AD30((__int64)v5, 0x28u, &v12);
}
else
{
v7 = *v5;
v5[1] = (pugi::xml_attribute_struct *)((char *)v6 + 40);
v12._attr = v7;
v8 = (pugi::xml_attribute *)((char *)v6 + (_QWORD)v7 + 48);
}
if ( v8 )
{
v8->_attr = v12._attr;
v8[1]._attr = nullptr;
v8[2]._attr = nullptr;
v8[3]._attr = nullptr;
v8[4]._attr = nullptr;
}
pugi::xml_attribute::xml_attribute(&v11, (__int64)v8);
if ( !pugi::xml_attribute::operator!(&v11) )
{
pugi::xml_attribute::set_name(&v11, a2);
root = this->_root;
result = v11._attr;
v10 = *((_QWORD *)this->_root + 7);
if ( v10 )
{
*((_QWORD *)v11._attr + 3) = *(_QWORD *)(v10 + 24);
*(_QWORD *)(v10 + 24) = result;
}
else
{
*((pugi::xml_attribute *)v11._attr + 3) = v11;
}
*((_QWORD *)result + 4) = v10;
*((_QWORD *)root + 7) = result;
}
else
{
LABEL_3:
pugi::xml_attribute::xml_attribute(&v12);
return v12._attr;
}
return result;
}