//
// pugi::xml_node::insert_attribute_after from 0xb546e8 to 0xb54868 (384 bytes)
//
// 2 xrefs:
// > pugi::xml_node::insert_copy_after @ 0xb54a0c
// > ??> @ 0x46320
//
// 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::insert_attribute_after(
pugi::xml_node *this,
char *a2,
pugi::xml_attribute *a3)
{
pugi::xml_attribute_struct *result; // x0
pugi::xml_attribute_struct *i; // x1
pugi::xml_attribute_struct **v8; // x0
pugi::xml_attribute_struct *v9; // x2
pugi::xml_attribute_struct *v10; // x1
pugi::xml_attribute *v11; // x1
pugi::xml_attribute_struct *attr; // x2
pugi::xml_attribute *v13; // x0
pugi::xml_attribute_struct *v14; // x1
pugi::xml_attribute v15; // [xsp+48h] [xbp+48h] BYREF
pugi::xml_attribute v16; // [xsp+50h] [xbp+50h] BYREF
if ( (unsigned int)pugi::xml_node::type(this) != 2 && (unsigned int)pugi::xml_node::type(this) != 7 )
goto LABEL_3;
if ( pugi::xml_attribute::empty(a3) )
goto LABEL_3;
for ( i = a3->_attr; *(_QWORD *)(*((_QWORD *)i + 3) + 32LL); i = *((pugi::xml_attribute_struct **)i + 3) )
;
if ( i != *((pugi::xml_attribute_struct **)this->_root + 7) )
goto LABEL_3;
v8 = *(pugi::xml_attribute_struct ***)(*(_QWORD *)this->_root & 0xFFFFFFFFFFFFFFE0LL);
v9 = v8[1];
if ( (unsigned __int64)v9 + 40 > 0x8000 )
{
v11 = (pugi::xml_attribute *)sub_B4AD30((__int64)v8, 0x28u, &v16);
}
else
{
v10 = *v8;
v8[1] = (pugi::xml_attribute_struct *)((char *)v9 + 40);
v16._attr = v10;
v11 = (pugi::xml_attribute *)((char *)v9 + (_QWORD)v10 + 48);
}
if ( v11 )
{
v11->_attr = v16._attr;
v11[1]._attr = nullptr;
v11[2]._attr = nullptr;
v11[3]._attr = nullptr;
v11[4]._attr = nullptr;
}
pugi::xml_attribute::xml_attribute(&v15, (__int64)v11);
if ( !pugi::xml_attribute::operator!(&v15) )
{
pugi::xml_attribute::set_name(&v15, a2);
attr = a3->_attr;
v13 = *((pugi::xml_attribute **)a3->_attr + 4);
v14 = v15._attr;
if ( v13 )
v13[3]._attr = v15._attr;
else
*(pugi::xml_attribute *)(*((_QWORD *)this->_root + 7) + 24LL) = v15;
*((_QWORD *)v14 + 4) = v13;
*((_QWORD *)v14 + 3) = attr;
result = v15._attr;
*((_QWORD *)attr + 4) = v14;
}
else
{
LABEL_3:
pugi::xml_attribute::xml_attribute(&v16);
return v16._attr;
}
return result;
}