//
// cocos2d::CCDictionary::copyWithZone from 0x180009b20 to 0x18000a1f0 (1744 bytes)
//
// 3 xrefs:
// > ??> @ 0x1800e64b8
// > ??> @ 0x1801438a8
// > ??> @ 0x1801adcc0
//
// 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
//
// Hidden C++ exception states: #wind=2
struct cocos2d::CCObject *__fastcall cocos2d::CCDictionary::copyWithZone(
cocos2d::CCDictionary *this,
struct cocos2d::CCZone *a2)
{
cocos2d::CCObject *v3; // rax
cocos2d::CCObject *v4; // r14
cocos2d::CCDictionary::CCDictType m_eDictType; // eax
cocos2d::CCDictElement *m_pElements; // rbx
cocos2d::CCDictElement *i; // rsi
cocos2d::CCObject *v8; // rdi
unsigned __int64 m_iKey; // r9
cocos2d::CCObject_vtbl *v10; // rbp
int v11; // edx
unsigned int v12; // r8d
unsigned int v13; // ecx
int v14; // edx
unsigned int v15; // r8d
unsigned int v16; // ecx
int v17; // edx
int (__stdcall *getTag)(const cocos2d::CCObject *__hidden); // r10
__int64 v19; // rbx
__int64 v20; // rcx
__int64 v21; // rbx
__int64 v22; // rbx
cocos2d::CCObject *v23; // rcx
cocos2d::CCDictElement *v24; // rbx
cocos2d::CCDictElement *j; // r12
cocos2d::CCObject *v26; // r15
cocos2d::CCObject_vtbl *v27; // rbp
unsigned __int8 *v28; // rbx
unsigned __int64 v29; // r13
bool v30; // si
_QWORD *v31; // rdi
int v32; // r8d
unsigned int v33; // r9d
int v34; // r10d
_QWORD *v35; // rax
__int64 v36; // r11
__int64 v37; // rdx
int v38; // r9d
unsigned int v39; // r8d
int v40; // r10d
unsigned int v41; // r9d
unsigned int v42; // r8d
int v43; // r10d
unsigned int v44; // r9d
unsigned int v45; // r8d
_QWORD *v46; // rcx
__int64 v47; // rax
unsigned int v48; // r8d
int v49; // r10d
unsigned int v50; // r9d
unsigned int v51; // r8d
int v52; // r10d
unsigned int v53; // r9d
unsigned int v54; // r8d
int v55; // r10d
int (__stdcall *v56)(const cocos2d::CCObject *__hidden); // rbp
__int64 v57; // rbx
__int64 v58; // rbp
__int64 v59; // rbx
_QWORD *v60; // rcx
__int64 v61; // rax
_QWORD *v62; // rax
_QWORD *v63; // rdx
size_t v64; // r8
__int64 v65; // rbx
char *v66; // rax
cocos2d::CCObject *v67; // rcx
_QWORD Buf2[3]; // [rsp+28h] [rbp-50h] BYREF
unsigned __int64 v70; // [rsp+40h] [rbp-38h]
v3 = (cocos2d::CCObject *)operator new(0x48u);
v4 = v3;
if ( v3 )
{
cocos2d::CCObject::CCObject(v3);
v4->__vftable = (cocos2d::CCObject_vtbl *)&cocos2d::CCDictionary::`vftable';
v4[1].__vftable = nullptr;
v4[1].m_uID = 0;
}
else
{
v4 = nullptr;
}
m_eDictType = this->m_eDictType;
if ( m_eDictType == kCCDictInt )
{
m_pElements = this->m_pElements;
if ( m_pElements )
{
for ( i = (cocos2d::CCDictElement *)m_pElements->hh.next; ; i = (cocos2d::CCDictElement *)i->hh.next )
{
v8 = cocos2d::CCObject::copy(m_pElements->m_pObject);
m_iKey = m_pElements->m_iKey;
if ( !v4[1].m_uID )
v4[1].m_uID = 2;
v10 = v4[1].__vftable;
if ( !v10 )
goto LABEL_16;
v11 = (((BYTE1(m_iKey) + ((BYTE2(m_iKey) + (BYTE3(m_iKey) << 8)) << 8)) << 8)
+ (unsigned __int8)m_iKey
- (((BYTE5(m_iKey) + ((BYTE6(m_iKey) + (HIBYTE(m_iKey) << 8)) << 8)) << 8)
+ BYTE4(m_iKey))
+ 17973513)
^ 0x7F76D;
v12 = (v11 << 8)
^ (((BYTE5(m_iKey) + ((BYTE6(m_iKey) + (HIBYTE(m_iKey) << 8)) << 8)) << 8)
- 1640531527
+ BYTE4(m_iKey)
- v11
+ 17973513);
v13 = (v12 >> 13) ^ (-17973513 - v12 - v11);
v14 = (v13 >> 12) ^ (v11 - v12 - v13);
v15 = (v14 << 16) ^ (v12 - v14 - v13);
v16 = (v15 >> 5) ^ (v13 - v15 - v14);
v17 = (v16 >> 3) ^ (v14 - v15 - v16);
getTag = v10[3].getTag;
v19 = *(_QWORD *)(*(_QWORD *)getTag
+ 16
* ((unsigned int)(*((_DWORD *)getTag + 2) - 1)
& (((unsigned __int64)((v17 << 10) ^ (v15 - v17 - v16)) >> 15)
^ (v16 - ((v17 << 10) ^ (v15 - v17 - v16)) - v17))));
if ( !v19 )
goto LABEL_16;
v20 = *((_QWORD *)getTag + 4);
v21 = v19 - v20;
if ( v21 )
{
while ( *(_DWORD *)(v21 + 320) != 8 || **(_QWORD **)(v21 + 312) != m_iKey )
{
v22 = *(_QWORD *)(v21 + 304);
if ( v22 )
{
v21 = v22 - v20;
if ( v21 )
continue;
}
goto LABEL_16;
}
v23 = *(cocos2d::CCObject **)(v21 + 264);
if ( v23 != v8 )
{
cocos2d::CCObject::release(v23);
*(_QWORD *)(v21 + 264) = v8;
cocos2d::CCObject::retain(v8);
}
}
else
{
LABEL_16:
cocos2d::CCDictionary::setObjectUnSafe((cocos2d::CCDictionary *)v4, v8, m_iKey);
}
cocos2d::CCObject::release(v8);
m_pElements = i;
if ( !i )
break;
}
}
}
else if ( m_eDictType == kCCDictStr )
{
v24 = this->m_pElements;
if ( v24 )
{
for ( j = (cocos2d::CCDictElement *)v24->hh.next; ; j = (cocos2d::CCDictElement *)j->hh.next )
{
v26 = cocos2d::CCObject::copy(v24->m_pObject);
sub_180005910(Buf2, v24);
if ( !v4[1].m_uID )
v4[1].m_uID = 1;
v27 = v4[1].__vftable;
if ( !v27 )
goto LABEL_67;
v28 = (unsigned __int8 *)Buf2;
v29 = v70;
v30 = v70 > 0xF;
v31 = (_QWORD *)Buf2[0];
if ( v70 > 0xF )
v28 = (unsigned __int8 *)Buf2[0];
v32 = -17973521;
v33 = -1640531527;
v34 = -1640531527;
v35 = Buf2;
if ( v70 > 0xF )
v35 = (_QWORD *)Buf2[0];
v36 = -1;
do
++v36;
while ( *((_BYTE *)v35 + v36) );
if ( (unsigned int)v36 >= 0xC )
{
v37 = (unsigned int)v36 / 0xC;
do
{
v38 = ((v28[5] + ((v28[6] + (v28[7] << 8)) << 8)) << 8) + v28[4] + v33;
v39 = ((v28[9] + ((v28[10] + (v28[11] << 8)) << 8)) << 8) + v28[8] + v32;
v40 = (v39 >> 13) ^ (*v28 + ((v28[1] + ((v28[2] + (v28[3] << 8)) << 8)) << 8) - v38 - v39 + v34);
v41 = (v40 << 8) ^ (v38 - v40 - v39);
v42 = (v41 >> 13) ^ (v39 - v41 - v40);
v43 = (v42 >> 12) ^ (v40 - v41 - v42);
v44 = (v43 << 16) ^ (v41 - v43 - v42);
v45 = (v44 >> 5) ^ (v42 - v44 - v43);
v34 = (v45 >> 3) ^ (v43 - v44 - v45);
v33 = (v34 << 10) ^ (v44 - v34 - v45);
v32 = (v33 >> 15) ^ (v45 - v33 - v34);
v28 += 12;
LODWORD(v36) = v36 - 12;
--v37;
}
while ( v37 );
}
v46 = Buf2;
if ( v70 > 0xF )
v46 = (_QWORD *)Buf2[0];
v47 = -1;
do
++v47;
while ( *((_BYTE *)v46 + v47) );
v48 = v47 + v32;
switch ( (int)v36 )
{
case 1:
goto LABEL_51;
case 2:
goto LABEL_50;
case 3:
goto LABEL_49;
case 4:
goto LABEL_48;
case 5:
goto LABEL_47;
case 6:
goto LABEL_46;
case 7:
goto LABEL_45;
case 8:
goto LABEL_44;
case 9:
goto LABEL_43;
case 10:
goto LABEL_42;
case 11:
v48 += v28[10] << 24;
LABEL_42:
v48 += v28[9] << 16;
LABEL_43:
v48 += v28[8] << 8;
LABEL_44:
v33 += v28[7] << 24;
LABEL_45:
v33 += v28[6] << 16;
LABEL_46:
v33 += v28[5] << 8;
LABEL_47:
v33 += v28[4];
LABEL_48:
v34 += v28[3] << 24;
LABEL_49:
v34 += v28[2] << 16;
LABEL_50:
v34 += v28[1] << 8;
LABEL_51:
v34 += *v28;
break;
default:
break;
}
v49 = (v48 >> 13) ^ (v34 - v33 - v48);
v50 = (v49 << 8) ^ (v33 - v49 - v48);
v51 = (v50 >> 13) ^ (v48 - v50 - v49);
v52 = (v51 >> 12) ^ (v49 - v50 - v51);
v53 = (v52 << 16) ^ (v50 - v52 - v51);
v54 = (v53 >> 5) ^ (v51 - v53 - v52);
v55 = (v54 >> 3) ^ (v52 - v53 - v54);
v56 = v27[3].getTag;
v57 = *(_QWORD *)(*(_QWORD *)v56
+ 16LL
* (((((v55 << 10) ^ (v53 - v55 - v54)) >> 15)
^ (v54 - ((v55 << 10) ^ (v53 - v55 - v54)) - v55))
& (*((_DWORD *)v56 + 2) - 1)));
if ( !v57 )
goto LABEL_67;
v58 = *((_QWORD *)v56 + 4);
v59 = v57 - v58;
if ( v59 )
{
while ( 1 )
{
v60 = Buf2;
if ( v30 )
v60 = v31;
v61 = -1;
do
++v61;
while ( *((_BYTE *)v60 + v61) );
if ( *(_DWORD *)(v59 + 320) == v61 )
{
v62 = Buf2;
if ( v30 )
{
v62 = v31;
v63 = v31;
}
else
{
v63 = Buf2;
}
v64 = -1;
do
++v64;
while ( *((_BYTE *)v62 + v64) );
if ( !memcmp(*(const void **)(v59 + 312), v63, v64) )
break;
}
v65 = *(_QWORD *)(v59 + 304);
if ( v65 )
{
v59 = v65 - v58;
if ( v59 )
continue;
}
goto LABEL_67;
}
v67 = *(cocos2d::CCObject **)(v59 + 264);
if ( v67 != v26 )
{
cocos2d::CCObject::release(v67);
*(_QWORD *)(v59 + 264) = v26;
cocos2d::CCObject::retain(v26);
}
}
else
{
LABEL_67:
cocos2d::CCDictionary::setObjectUnSafe(v4, v26, Buf2);
v29 = v70;
v31 = (_QWORD *)Buf2[0];
}
if ( v29 > 0xF )
{
v66 = (char *)v31;
if ( v29 + 1 >= 0x1000 )
{
v31 = (_QWORD *)*(v31 - 1);
if ( (unsigned __int64)(v66 - (char *)v31 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free_0(v31);
}
cocos2d::CCObject::release(v26);
v24 = j;
if ( !j )
break;
}
}
}
return v4;
}