//
// tinyxml2::XMLDocument::NewDeclaration from 0xb26f40 to 0xb270f8 (440 bytes)
//
// 4 xrefs:
// > cocos2d::CCFileUtils::writeToFile @ 0xb0470c
// > tinyxml2::XMLDeclaration::ShallowClone @ 0xb27124
// > tinyxml2::XMLDeclaration::ShallowClone @ 0xb27144
// > ??> @ 0x651d8
//
// 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
//
tinyxml2::XMLDeclaration *__fastcall tinyxml2::XMLDocument::NewDeclaration(tinyxml2::XMLDocument *this, const char *a2)
{
char *v2; // x19
tinyxml2::XMLDeclaration *v3; // x20
tinyxml2::XMLNode *v6; // x22
int v7; // w1
int v8; // w0
int v9; // w2
const char *v10; // x1
_QWORD *v12; // x24
int v13; // w2
int v14; // w0
_QWORD *v15; // x3
int v16; // w22
unsigned __int64 v17; // x0
void *v18; // x25
char *v19; // x0
v2 = (char *)this + 512;
v3 = *((tinyxml2::XMLDeclaration **)this + 77);
if ( v3 )
{
v6 = *((tinyxml2::XMLNode **)this + 77);
}
else
{
v12 = (_QWORD *)operator new(0x3C8u);
memset(v12, 0, 0x3C8u);
v13 = *((_DWORD *)this + 153);
v14 = v13 + 1;
if ( v13 + 1 > *((_DWORD *)this + 152) )
{
v16 = 2 * v14;
v17 = 16LL * v14;
if ( (unsigned __int64)v16 > 0xFE0000000000000LL )
v17 = -1;
v18 = (void *)operator new[](v17);
memcpy(v18, *((const void **)this + 65), 8LL * *((int *)this + 153));
v19 = *((char **)this + 65);
if ( v19 != (char *)this + 528 && v19 )
operator delete[](v19);
v13 = *((_DWORD *)this + 153);
v15 = v18;
*((_QWORD *)this + 65) = v18;
*((_DWORD *)this + 152) = v16;
v14 = v13 + 1;
}
else
{
v15 = *((_QWORD **)this + 65);
}
*((_DWORD *)this + 153) = v14;
v15[v13] = v12;
*v12 = v12 + 11;
v12[22] = v12 + 33;
v12[11] = v12 + 22;
v12[33] = v12 + 44;
v12[55] = v12 + 66;
v12[44] = v12 + 55;
v12[66] = v12 + 77;
v3 = (tinyxml2::XMLDeclaration *)v12;
v12[77] = v12 + 88;
v6 = (tinyxml2::XMLNode *)v12;
v12[88] = v12 + 99;
v12[99] = v12 + 110;
v12[110] = 0;
*((_QWORD *)v2 + 13) = v12;
}
v7 = *((_DWORD *)v2 + 30);
v8 = *((_DWORD *)v2 + 28) + 1;
*((_QWORD *)v2 + 13) = *(_QWORD *)v3;
*((_DWORD *)v2 + 28) = v8;
if ( v8 > v7 )
*((_DWORD *)v2 + 30) = v8;
v9 = *((_DWORD *)v2 + 31);
++*((_DWORD *)v2 + 29);
*((_DWORD *)v2 + 31) = v9 + 1;
tinyxml2::XMLDeclaration::XMLDeclaration(v3, this);
*((_QWORD *)v3 + 10) = v2;
if ( a2 )
v10 = a2;
else
v10 = "xml version=\"1.0\" encoding=\"UTF-8\"";
tinyxml2::XMLNode::SetValue(v6, v10, 0);
return v3;
}