//
// tinyxml2::XMLElement::FindOrCreateAttribute from 0xb263ac to 0xb26694 (744 bytes)
//
// 3 xrefs:
// > cocos2d::CCFileUtils::writeToFile @ 0xb04758
// > tinyxml2::XMLElement::ShallowClone @ 0xb26b1c
// > ??> @ 0xc65e8
//
// 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
//
_QWORD *__fastcall tinyxml2::XMLElement::FindOrCreateAttribute(
tinyxml2::XMLElement *this,
const char *a2,
__int64 a3,
int *a4)
{
__int64 v4; // 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; // x24
__int64 v19; // x25
_QWORD *v20; // x21
int v21; // w1
int v22; // w0
int v23; // w1
_QWORD *v24; // x20
int v25; // w1
int v26; // w0
_QWORD *v27; // x3
int v28; // w21
unsigned __int64 v29; // x0
void *v30; // x27
void *v31; // x0
v4 = *((_QWORD *)this + 12);
if ( v4 )
{
Str = (const char *)tinyxml2::StrPair::GetStr((tinyxml2::StrPair *)(v4 + 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 *)v4;
v15 = *(unsigned __int8 *)(v10 + 1);
goto LABEL_13;
}
v12 = *(unsigned __int8 *)++v10;
if ( !v12 || (_DWORD)v8 != v12 )
break;
if ( Str == v11 )
return (_QWORD *)v4;
}
if ( v14 == 0x7FFFFFFF )
return (_QWORD *)v4;
v16 = *(_QWORD *)(v4 + 56);
if ( !v16 )
goto LABEL_19;
LABEL_15:
v4 = v16;
Str = (const char *)tinyxml2::StrPair::GetStr((tinyxml2::StrPair *)(v16 + 8), v10, v8, v9);
if ( a2 == Str )
return (_QWORD *)v4;
}
v15 = *(unsigned __int8 *)a2;
LABEL_13:
if ( !v15 )
return (_QWORD *)v4;
LABEL_14:
v16 = *(_QWORD *)(v4 + 56);
if ( !v16 )
goto LABEL_19;
goto LABEL_15;
}
return (_QWORD *)v4;
}
else
{
LABEL_19:
v18 = *((_QWORD *)this + 1);
v19 = v18 + 256;
v20 = *(_QWORD **)(v18 + 360);
if ( !v20 )
{
v24 = (_QWORD *)operator new(0x3F0u);
memset(v24, 0, 0x3F0u);
v25 = *(_DWORD *)(v18 + 356);
v26 = v25 + 1;
if ( v25 + 1 > *(_DWORD *)(v18 + 352) )
{
v28 = 2 * v26;
v29 = 16LL * v26;
if ( (unsigned __int64)v28 > 0xFE0000000000000LL )
v29 = -1;
v30 = (void *)operator new[](v29);
memcpy(v30, *(const void **)(v18 + 264), 8LL * *(int *)(v18 + 356));
v31 = *(void **)(v18 + 264);
if ( v31 != (void *)(v18 + 272) && v31 )
operator delete[](v31);
v25 = *(_DWORD *)(v18 + 356);
v27 = v30;
*(_QWORD *)(v18 + 264) = v30;
*(_DWORD *)(v18 + 352) = v28;
v26 = v25 + 1;
}
else
{
v27 = *(_QWORD **)(v18 + 264);
}
*(_DWORD *)(v18 + 356) = v26;
v27[v25] = v24;
*v24 = v24 + 9;
v24[18] = v24 + 27;
v24[9] = v24 + 18;
v24[27] = v24 + 36;
v24[36] = v24 + 45;
v24[45] = v24 + 54;
v24[54] = v24 + 63;
v24[63] = v24 + 72;
v24[72] = v24 + 81;
v24[81] = v24 + 90;
v20 = v24;
v24[90] = v24 + 99;
v24[99] = v24 + 108;
v24[108] = v24 + 117;
v24[117] = 0;
*(_QWORD *)(v18 + 360) = v24;
v18 = *((_QWORD *)this + 1);
}
v21 = *(_DWORD *)(v19 + 120);
v22 = *(_DWORD *)(v19 + 112) + 1;
*(_QWORD *)(v19 + 104) = *v20;
*(_DWORD *)(v19 + 112) = v22;
if ( v22 > v21 )
*(_DWORD *)(v19 + 120) = v22;
v23 = *(_DWORD *)(v19 + 116);
++*(_DWORD *)(v19 + 124);
*(_DWORD *)(v19 + 116) = v23 + 1;
*v20 = off_1219350;
*((_DWORD *)v20 + 2) = 0;
v20[2] = 0;
v20[3] = 0;
*((_DWORD *)v20 + 8) = 0;
v20[5] = 0;
v20[6] = 0;
v20[7] = 0;
v20[8] = v18 + 256;
if ( v4 )
*(_QWORD *)(v4 + 56) = v20;
else
*((_QWORD *)this + 12) = v20;
tinyxml2::XMLAttribute::SetName((tinyxml2::XMLAttribute *)v20, a2);
(*(void (__fastcall **)(_QWORD))(*(_QWORD *)v20[8] + 40LL))(v20[8]);
return v20;
}
}