//
// tinyxml2::XMLElement::FindOrCreateAttribute from 0xd96f54 to 0xd97238 (740 bytes)
//
// 3 xrefs:
// > cocos2d::CCFileUtils::writeToFile @ 0xd74b5c
// > tinyxml2::XMLElement::ShallowClone @ 0xd976c0
// > ??> @ 0x102298
//
// 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
//
_QWORD *__fastcall tinyxml2::XMLElement::FindOrCreateAttribute(
tinyxml2::XMLElement *this,
const char *a2,
__int64 a3,
int *a4)
{
__int64 v6; // x23
const char *Str; // x0
__int64 v8; // x2
int *v9; // x3
__int64 v10; // x1
const char *v11; // x6
int v12; // w4
unsigned int v13; // t1
int v14; // w5
int v15; // w0
__int64 v16; // x0
__int64 v18; // x25
_QWORD *v19; // x21
int v20; // w1
int v21; // w0
int v22; // w1
_QWORD *v23; // x20
int v24; // w1
int v25; // w0
void *v26; // x27
int v27; // w21
unsigned __int64 v28; // x0
void *v29; // x0
v6 = *((_QWORD *)this + 12);
if ( v6 )
{
Str = (const char *)tinyxml2::StrPair::GetStr((tinyxml2::StrPair *)(v6 + 8), (__int64)a2, a3, a4);
if ( a2 != Str )
{
while ( 1 )
{
v10 = *(unsigned __int8 *)Str;
if ( !*Str )
break;
v8 = *(unsigned __int8 *)a2;
if ( (_DWORD)v10 != (_DWORD)v8 || !*a2 )
goto LABEL_14;
v11 = Str + 0x7FFFFFFF;
v10 = (__int64)a2;
while ( 1 )
{
v13 = *(unsigned __int8 *)++Str;
v8 = v13;
v9 = (int *)(v10 + 1);
v14 = v10 + 1 - (_DWORD)a2;
if ( !v13 )
{
if ( v14 == 0x7FFFFFFF )
return (_QWORD *)v6;
v15 = *(unsigned __int8 *)(v10 + 1);
goto LABEL_13;
}
v12 = *(unsigned __int8 *)++v10;
if ( !v12 || (_DWORD)v8 != v12 )
break;
if ( Str == v11 )
return (_QWORD *)v6;
}
if ( v14 == 0x7FFFFFFF )
return (_QWORD *)v6;
v16 = *(_QWORD *)(v6 + 56);
if ( !v16 )
goto LABEL_19;
LABEL_15:
v6 = v16;
Str = (const char *)tinyxml2::StrPair::GetStr((tinyxml2::StrPair *)(v16 + 8), v10, v8, v9);
if ( a2 == Str )
return (_QWORD *)v6;
}
v15 = *(unsigned __int8 *)a2;
LABEL_13:
if ( !v15 )
return (_QWORD *)v6;
LABEL_14:
v16 = *(_QWORD *)(v6 + 56);
if ( !v16 )
goto LABEL_19;
goto LABEL_15;
}
return (_QWORD *)v6;
}
else
{
LABEL_19:
v18 = *((_QWORD *)this + 1);
v19 = *(_QWORD **)(v18 + 360);
if ( !v19 )
{
v23 = (_QWORD *)operator new(0x3F0u);
memset(v23, 0, 0x3F0u);
v24 = *(_DWORD *)(v18 + 356);
v25 = v24 + 1;
if ( v24 + 1 > *(_DWORD *)(v18 + 352) )
{
v27 = 2 * v25;
v28 = 16LL * v25;
if ( (unsigned __int64)v27 > 0xFE0000000000000LL )
v28 = -1;
v26 = (void *)operator new[](v28);
memcpy(v26, *(const void **)(v18 + 264), 8LL * *(int *)(v18 + 356));
v29 = *(void **)(v18 + 264);
if ( v29 != (void *)(v18 + 272) && v29 )
operator delete[](v29);
*(_QWORD *)(v18 + 264) = v26;
*(_DWORD *)(v18 + 352) = v27;
v24 = *(_DWORD *)(v18 + 356);
v25 = v24 + 1;
}
else
{
v26 = *(void **)(v18 + 264);
}
*(_DWORD *)(v18 + 356) = v25;
*((_QWORD *)v26 + v24) = v23;
*v23 = v23 + 9;
v23[18] = v23 + 27;
v23[9] = v23 + 18;
v23[27] = v23 + 36;
v23[36] = v23 + 45;
v23[45] = v23 + 54;
v23[54] = v23 + 63;
v23[63] = v23 + 72;
v23[72] = v23 + 81;
v23[81] = v23 + 90;
v19 = v23;
v23[90] = v23 + 99;
v23[99] = v23 + 108;
v23[108] = v23 + 117;
v23[117] = 0;
*(_QWORD *)(v18 + 360) = v23;
}
v20 = *(_DWORD *)(v18 + 376);
v21 = *(_DWORD *)(v18 + 368) + 1;
*(_QWORD *)(v18 + 360) = *v19;
*(_DWORD *)(v18 + 368) = v21;
if ( v21 > v20 )
*(_DWORD *)(v18 + 376) = v21;
v22 = *(_DWORD *)(v18 + 372);
++*(_DWORD *)(v18 + 380);
*(_DWORD *)(v18 + 372) = v22 + 1;
*v19 = off_152F1B0;
*((_DWORD *)v19 + 2) = 0;
v19[2] = 0;
v19[3] = 0;
*((_DWORD *)v19 + 8) = 0;
v19[5] = 0;
v19[6] = 0;
v19[7] = 0;
v19[8] = *((_QWORD *)this + 1) + 256LL;
if ( v6 )
*(_QWORD *)(v6 + 56) = v19;
else
*((_QWORD *)this + 12) = v19;
tinyxml2::XMLAttribute::SetName((tinyxml2::XMLAttribute *)v19, a2);
(*(void (__fastcall **)(_QWORD))(*(_QWORD *)v19[8] + 40LL))(v19[8]);
return v19;
}
}