//
// tinyxml2::XMLDocument::NewDeclaration from 0xd97ae4 to 0xd97c9c (440 bytes)
//
// 4 xrefs:
// > cocos2d::CCFileUtils::writeToFile @ 0xd74b10
// > tinyxml2::XMLDeclaration::ShallowClone @ 0xd97cc8
// > tinyxml2::XMLDeclaration::ShallowClone @ 0xd97ce8
// > ??> @ 0x89680
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// 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 13:08:22 +0000
//
tinyxml2::XMLDeclaration *__fastcall tinyxml2::XMLDocument::NewDeclaration(tinyxml2::XMLDocument *this, const char *a2)
{
char *v2; // x19
tinyxml2::XMLDeclaration *v5; // 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;
v5 = *((tinyxml2::XMLDeclaration **)this + 77);
if ( v5 )
{
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);
*((_QWORD *)this + 65) = v18;
v15 = v18;
*((_DWORD *)this + 152) = v16;
v13 = *((_DWORD *)this + 153);
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;
v5 = (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 *)v5;
*((_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(v5, this);
*((_QWORD *)v5 + 10) = v2;
if ( a2 )
v10 = a2;
else
v10 = "xml version=\"1.0\" encoding=\"UTF-8\"";
tinyxml2::XMLNode::SetValue(v6, v10, 0);
return v5;
}