//
// cocos2d::CCDictMaker::endElement from 0xb0489c to 0xb04d38 (1180 bytes)
//
// 2 xrefs:
// > ??> @ 0x6a8a8
// > ??> @ 0x1217a68
//
// 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
//
__int64 __fastcall cocos2d::CCDictMaker::endElement(cocos2d::CCDictMaker *this, void *a2, char *a3)
{
__int64 v4; // x0
int v5; // w23
char *v6; // x0
void *v7; // x0
__int64 v8; // x0
__int64 v9; // x2
void *v10; // x0
char *v12; // x0
void *v13; // x0
__int64 v14; // x0
unsigned int *v15; // x2
int v16; // w1
cocos2d::CCString *v17; // x24
cocos2d::CCObject *v18; // x2
__int64 *v19; // x2
__int64 v20; // x0
__int64 *v21; // x2
__int64 v22; // x0
__int64 *v23; // x2
__int64 v24; // x0
cocos2d::CCObject *v25; // x25
cocos2d::CCObject *v26; // x2
__int64 *v27; // x2
__int64 v28; // x0
__int64 v29; // x23
__int64 v30; // x23
_QWORD v31[2]; // [xsp+0h] [xbp+0h] BYREF
__int64 v32; // [xsp+68h] [xbp+68h] BYREF
const char *v33; // [xsp+70h] [xbp+70h] BYREF
v4 = *((_QWORD *)this + 35);
if ( v4 == *((_QWORD *)this + 31) )
{
v5 = 2;
}
else
{
if ( v4 == *((_QWORD *)this + 36) )
v4 = *(_QWORD *)(*((_QWORD *)this + 38) - 8LL) + 512LL;
v5 = *(_DWORD *)(v4 - 4);
}
sub_D153B8((int)&v32, a3);
if ( !(unsigned int)sub_D171E0((unsigned int)v31 + 104, "dict") )
{
v6 = *((char **)this + 35);
if ( v6 == *((char **)this + 36) )
{
operator delete(v6);
v21 = (__int64 *)(*((_QWORD *)this + 38) - 8LL);
*((_QWORD *)this + 38) = v21;
v22 = *v21;
*((_QWORD *)this + 36) = *v21;
*((_QWORD *)this + 37) = v22 + 512;
*((_QWORD *)this + 35) = v22 + 508;
}
else
{
*((_QWORD *)this + 35) = v6 - 4;
}
v7 = *((void **)this + 11);
if ( v7 == *((void **)this + 12) )
{
operator delete(v7);
v23 = (__int64 *)(*((_QWORD *)this + 14) - 8LL);
*((_QWORD *)this + 14) = v23;
v24 = *v23;
*((_QWORD *)this + 12) = *v23;
*((_QWORD *)this + 13) = v24 + 512;
v8 = v24 + 504;
}
else
{
v8 = (__int64)v7 - 8;
}
*((_QWORD *)this + 11) = v8;
if ( *((_QWORD *)this + 7) != v8 )
{
if ( *((_QWORD *)this + 12) == v8 )
v8 = *(_QWORD *)(*((_QWORD *)this + 14) - 8LL) + 512LL;
*((_QWORD *)this + 4) = *(_QWORD *)(v8 - 8);
}
goto LABEL_14;
}
if ( (unsigned int)sub_D171E0((unsigned int)v31 + 104, "array") )
{
if ( (unsigned int)sub_D171E0((unsigned int)v31 + 104, "true") )
{
if ( (unsigned int)sub_D171E0((unsigned int)v31 + 104, "false") )
{
if ( !(unsigned int)sub_D171E0((unsigned int)v31 + 104, "string")
|| !(unsigned int)sub_D171E0((unsigned int)v31 + 104, "integer")
|| !(unsigned int)sub_D171E0((unsigned int)v31 + 104, "real") )
{
v25 = (cocos2d::CCObject *)operator new(0x40u);
cocos2d::CCString::CCString(v25);
if ( v5 == 6 )
{
cocos2d::CCArray::addObject(*((cocos2d::CCArray **)this + 18), (cocos2d::_ccArray *)v25, v26);
}
else if ( v5 == 2 )
{
v30 = *((_QWORD *)this + 4);
sub_D153B8((int)&v33, *((char **)this + 15));
cocos2d::CCDictionary::setObject(v30, v25, &v33);
if ( v33 - 24 != (const char *)&qword_124B6B0 )
sub_4DDDE8((void *)(v33 - 24));
}
cocos2d::CCObject::release(v25);
sub_D174B8((char *)this + 128, 0, *(_QWORD *)(*((_QWORD *)this + 16) - 24LL), 0);
}
LABEL_14:
*((_DWORD *)this + 34) = 0;
v9 = v32;
v10 = (void *)(v32 - 24);
if ( (__int64 *)(v32 - 24) == &qword_124B6B0 )
return _stack_chk_guard;
goto LABEL_25;
}
v17 = (cocos2d::CCString *)operator new(0x40u);
cocos2d::CCString::CCString(v17, "0");
if ( v5 != 6 )
goto LABEL_37;
}
else
{
v17 = (cocos2d::CCString *)operator new(0x40u);
cocos2d::CCString::CCString(v17, "1");
if ( v5 != 6 )
{
LABEL_37:
if ( v5 == 2 )
{
v29 = *((_QWORD *)this + 4);
sub_D153B8((int)&v33, *((char **)this + 15));
cocos2d::CCDictionary::setObject(v29, v17, &v33);
if ( v33 - 24 != (const char *)&qword_124B6B0 )
sub_4DDDE8((void *)(v33 - 24));
}
goto LABEL_38;
}
}
cocos2d::CCArray::addObject(*((cocos2d::CCArray **)this + 18), (cocos2d::_ccArray *)v17, v18);
LABEL_38:
cocos2d::CCObject::release(v17);
goto LABEL_14;
}
v12 = *((char **)this + 35);
if ( v12 == *((char **)this + 36) )
{
operator delete(v12);
v19 = (__int64 *)(*((_QWORD *)this + 38) - 8LL);
*((_QWORD *)this + 38) = v19;
v20 = *v19;
*((_QWORD *)this + 36) = *v19;
*((_QWORD *)this + 37) = v20 + 512;
*((_QWORD *)this + 35) = v20 + 508;
}
else
{
*((_QWORD *)this + 35) = v12 - 4;
}
v13 = *((void **)this + 25);
if ( v13 == *((void **)this + 26) )
{
operator delete(v13);
v27 = (__int64 *)(*((_QWORD *)this + 28) - 8LL);
*((_QWORD *)this + 28) = v27;
v28 = *v27;
*((_QWORD *)this + 26) = *v27;
*((_QWORD *)this + 27) = v28 + 512;
v14 = v28 + 504;
}
else
{
v14 = (__int64)v13 - 8;
}
*((_QWORD *)this + 25) = v14;
if ( *((_QWORD *)this + 21) == v14 )
goto LABEL_14;
if ( *((_QWORD *)this + 26) == v14 )
v14 = *(_QWORD *)(*((_QWORD *)this + 28) - 8LL) + 512LL;
*((_QWORD *)this + 18) = *(_QWORD *)(v14 - 8);
*((_DWORD *)this + 34) = 0;
v9 = v32;
v10 = (void *)(v32 - 24);
if ( (__int64 *)(v32 - 24) != &qword_124B6B0 )
{
LABEL_25:
if ( &pthread_create )
{
v15 = (unsigned int *)(v9 - 8);
do
v16 = __ldaxr(v15);
while ( __stlxr(v16 - 1, v15) );
}
else
{
v16 = *(_DWORD *)(v9 - 8);
*(_DWORD *)(v9 - 8) = v16 - 1;
}
if ( v16 <= 0 )
operator delete(v10);
}
return _stack_chk_guard;
}