//
// cocos2d::CCTMXMapInfo::endElement from 0xb3b508 to 0xb3b7fc (756 bytes)
//
// 3 xrefs:
// > `non-virtual thunk to'cocos2d::CCTMXMapInfo::endElement @ 0xb3b800
// > ??> @ 0x42930
// > ??> @ 0x121b398
//
// 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
//
void cocos2d::CCTMXMapInfo::endElement(cocos2d::CCTMXMapInfo *a1, void *a2, const char *a3)
{
__int64 v4; // x1
void *v5; // x0
cocos2d::CCTMXMapInfo_vtbl *v6; // x1
cocos2d::CCArray *v7; // x0
cocos2d::CCObject *Object; // x21
unsigned int v9; // w23
void *v10; // x0
char *v11; // x0
unsigned int *v12; // x1
int v13; // w2
char *v14; // x0
unsigned int *v15; // x1
int v16; // w2
unsigned int *v17; // x1
unsigned int *v18; // x1
int v19; // w2
__int64 v20; // [xsp+0h] [xbp+0h] BYREF
unsigned int v21; // [xsp+4Ch] [xbp+4Ch]
__int64 v22; // [xsp+50h] [xbp+50h] BYREF
cocos2d *v23; // [xsp+58h] [xbp+58h] BYREF
void *p; // [xsp+60h] [xbp+60h] BYREF
void *v25; // [xsp+68h] [xbp+68h] BYREF
cocos2d::CCSize v26; // [xsp+70h] [xbp+70h] BYREF
sub_D153B8((int)&v22, (char *)a3);
if ( (unsigned int)sub_D171E0((int)&v22, "data") || ((__int64)a1[1].cocos2d::CCSAXDelegator::__vftable & 2) == 0 )
{
if ( !(unsigned int)sub_D171E0((int)&v22, "map")
|| !(unsigned int)sub_D171E0((int)&v22, "layer")
|| !(unsigned int)sub_D171E0((int)&v22, "objectgroup")
|| !(unsigned int)sub_D171E0((int)&v22, "object") )
{
a1[1].m_uOrderOfArrival = 0;
}
goto LABEL_5;
}
v6 = a1->cocos2d::CCObject::cocos2d::CCCopying::__vftable;
BYTE4(a1[1].cocos2d::CCSAXDelegator::__vftable) = 0;
v7 = v6->getLayers(a1);
Object = cocos2d::CCArray::lastObject(v7);
sub_D153B8((int)&v23, *(char **)&a1[2].m_uAutoReleaseCount);
v9 = base64Decode(v23, (const unsigned __int8 *)*((unsigned int *)v23 - 6), &p, 0);
v10 = p;
if ( p )
{
if ( ((__int64)a1[1].cocos2d::CCSAXDelegator::__vftable & 0xC) == 0 )
goto LABEL_9;
cocos2d::CCSize::CCSize(&v26, (const cocos2d::CCSize *)&Object[1].m_nTag);
cocos2d::ZipUtils::ccInflateMemoryWithHint(
(cocos2d::ZipUtils *)p,
(unsigned __int8 *)v9,
&v25,
(unsigned __int8 **)(unsigned int)(int)(float)((float)(v26.width * v26.height) * 4.0));
v21 = (unsigned int)&v20 + 76;
if ( p )
operator delete[](p);
v10 = v25;
p = nullptr;
if ( v25 )
{
LABEL_9:
*(_QWORD *)&Object[1].m_uAutoReleaseCount = v10;
sub_D1798C(&a1[2].m_uAutoReleaseCount, &byte_F288A0, 0);
v11 = (char *)v23 - 24;
if ( (__int64 *)((char *)v23 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v12 = (unsigned int *)((char *)v23 - 8);
do
v13 = __ldaxr(v12);
while ( __stlxr(v13 - 1, v12) );
}
else
{
v13 = *((_DWORD *)v23 - 2);
*((_DWORD *)v23 - 2) = v13 - 1;
}
if ( v13 <= 0 )
operator delete(v11);
}
LABEL_5:
v4 = v22;
v5 = (void *)(v22 - 24);
if ( (__int64 *)(v22 - 24) == &qword_124B6B0 )
return;
if ( &pthread_create )
{
v17 = (unsigned int *)(v22 - 8);
do
v16 = __ldaxr(v17);
while ( __stlxr(v16 - 1, v17) );
goto LABEL_31;
}
LABEL_33:
v16 = *(_DWORD *)(v4 - 8);
*(_DWORD *)(v4 - 8) = v16 - 1;
LABEL_31:
if ( v16 <= 0 )
operator delete(v5);
return;
}
}
v14 = (char *)v23 - 24;
if ( (__int64 *)((char *)v23 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v18 = (unsigned int *)((char *)v23 - 8);
do
v19 = __ldaxr(v18);
while ( __stlxr(v19 - 1, v18) );
}
else
{
v19 = *((_DWORD *)v23 - 2);
*((_DWORD *)v23 - 2) = v19 - 1;
}
if ( v19 <= 0 )
operator delete(v14);
}
v4 = v22;
v5 = (void *)(v22 - 24);
if ( (__int64 *)(v22 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v15 = (unsigned int *)(v22 - 8);
do
v16 = __ldaxr(v15);
while ( __stlxr(v16 - 1, v15) );
goto LABEL_31;
}
goto LABEL_33;
}
}