//
// cocos2d::CCDictionary::setObjectUnSafe from 0xad053c to 0xad08e8 (940 bytes)
//
// 2 xrefs:
// > cocos2d::CCDictionary::setObject @ 0xad0a4c
// > ??> @ 0x34d58
//
// 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::CCDictionary::setObjectUnSafe(cocos2d::CCDictionary *a1, cocos2d::CCObject *a2, intptr_t a3)
{
__int64 v5; // x20
cocos2d::CCDictElement *m_pElements; // x4
__int64 v7; // x19
UT_hash_table *tbl; // x3
UT_hash_handle *tail; // x0
std::ptrdiff_t hho; // x2
int v11; // w6
int v12; // w5
int v13; // w0
int v14; // w1
unsigned int v15; // w2
UT_hash_table *v16; // x5
unsigned int v17; // w1
int v18; // w0
unsigned int v19; // w2
int v20; // w4
unsigned int v21; // w1
UT_hash_bucket *buckets; // x5
unsigned int v23; // w0
unsigned int v24; // w0
__int64 v25; // x0
UT_hash_handle *hh_head; // x4
unsigned int v27; // w2
unsigned int expand_mult; // w1
char *v29; // x0
char *v30; // x19
char **v31; // x8
int v32; // w2
unsigned int v33; // w3
int v34; // w6
int v35; // w9
unsigned int v36; // w7
char *v37; // x0
__int64 v38; // x10
__int64 v39; // x11
__int64 v40; // x1
__int64 v41; // x5
__int64 v42; // x2
unsigned int v43; // w3
__int64 v44; // x3
__int64 v45; // x0
unsigned int v46; // w4
unsigned int v47; // w3
int v48; // w1
unsigned int v49; // w1
_QWORD *v50; // x0
__int64 v51; // x22
void *v52; // x0
__int64 v54; // [xsp+38h] [xbp+38h]
cocos2d::CCObject::retain(a2);
v5 = operator new(0x148u);
cocos2d::CCDictElement::CCDictElement((cocos2d::CCDictElement *)v5, a3, a2);
m_pElements = a1->m_pElements;
*(_QWORD *)(v5 + 288) = 0;
*(_QWORD *)(v5 + 312) = v5 + 256;
*(_DWORD *)(v5 + 320) = 8;
if ( m_pElements )
{
v7 = v5 + 272;
tbl = m_pElements->hh.tbl;
tail = tbl->tail;
hho = tbl->hho;
tail->next = (void *)v5;
*(_QWORD *)(v5 + 280) = (char *)tail - hho;
tbl->tail = (UT_hash_handle *)(v5 + 272);
}
else
{
a1->m_pElements = (cocos2d::CCDictElement *)v5;
*(_QWORD *)(v5 + 280) = 0;
v50 = malloc(0x40u);
*(_QWORD *)(v5 + 272) = v50;
if ( !v50 )
goto LABEL_26;
*v50 = 0;
v50[1] = 0;
v50[2] = 0;
v50[3] = 0;
v50[4] = 0;
v50[5] = 0;
v50[6] = 0;
v50[7] = 0;
v7 = v5 + 272;
v51 = *(_QWORD *)(v5 + 272);
*(_DWORD *)(v51 + 8) = 32;
*(_QWORD *)(v51 + 24) = v5 + 272;
*(_DWORD *)(v51 + 12) = 5;
*(_QWORD *)(v51 + 32) = 272;
v52 = malloc(0x200u);
*(_QWORD *)v51 = v52;
if ( !v52 )
goto LABEL_26;
memset(v52, 0, 0x200u);
m_pElements = a1->m_pElements;
tbl = m_pElements->hh.tbl;
tbl->signature = -1609490463;
}
++tbl->num_items;
v11 = *(unsigned __int8 *)(v5 + 260)
- 1640531527
+ (*(unsigned __int8 *)(v5 + 263) << 24)
+ (*(unsigned __int8 *)(v5 + 262) << 16)
+ (*(unsigned __int8 *)(v5 + 261) << 8);
v12 = *(unsigned __int8 *)(v5 + 256)
- 1622558014
+ (*(unsigned __int8 *)(v5 + 259) << 24)
+ (*(unsigned __int8 *)(v5 + 258) << 16)
+ (*(unsigned __int8 *)(v5 + 257) << 8)
- v11;
*(_QWORD *)(v5 + 272) = tbl;
v13 = v12 ^ 0x7F76D;
v14 = -17973513 - (v12 ^ 0x7F76D);
v15 = (v11 + 17973513 - (v12 ^ 0x7F76D)) ^ ((v12 ^ 0x7F76D) << 8);
v16 = m_pElements->hh.tbl;
v17 = (v14 - v15) ^ (v15 >> 13);
v18 = (v13 - v15 - v17) ^ (v17 >> 12);
v19 = (v15 - v17 - v18) ^ (v18 << 16);
v20 = v16->num_buckets - 1;
v21 = (v17 - v18 - v19) ^ (v19 >> 5);
buckets = v16->buckets;
v23 = v18 - v19 - v21;
v24 = (v21 - (v23 ^ (v21 >> 3)) - ((v19 - v21 - (v23 ^ (v21 >> 3))) ^ ((v23 ^ (v21 >> 3)) << 10)))
^ (((v19 - v21 - (v23 ^ (v21 >> 3))) ^ ((v23 ^ (v21 >> 3)) << 10)) >> 15);
*(_DWORD *)(v5 + 324) = v24;
v25 = v24 & v20;
hh_head = buckets[v25].hh_head;
v27 = buckets[v25].count + 1;
buckets[v25].count = v27;
*(_QWORD *)(v5 + 304) = hh_head;
*(_QWORD *)(v5 + 296) = 0;
if ( hh_head )
hh_head->hh_prev = (UT_hash_handle *)v7;
expand_mult = buckets[v25].expand_mult;
buckets[v25].hh_head = (UT_hash_handle *)v7;
if ( v27 >= 10 * (expand_mult + 1) && tbl->noexpand != 1 )
{
v54 = 32LL * (tbl->num_buckets & 0x7FFFFFFF);
v29 = (char *)malloc(v54);
v30 = v29;
if ( v29 )
{
memset(v29, 0, v54);
v31 = *(char ***)(v5 + 272);
v32 = *((_DWORD *)v31 + 2);
v33 = *((_DWORD *)v31 + 4);
v34 = *((_DWORD *)v31 + 3);
v35 = 2 * v32 - 1;
*((_DWORD *)v31 + 11) = 0;
v36 = ((v35 & v33) != 0) + (v33 >> (v34 + 1));
*((_DWORD *)v31 + 10) = v36;
if ( v32 )
{
v37 = *v31;
v38 = 0;
v39 = 16 * ((unsigned int)(v32 - 1) + 1LL);
do
{
v40 = *(_QWORD *)&v37[v38];
if ( v40 )
{
do
{
v41 = *(_QWORD *)(v40 + 32);
v42 = 16LL * ((unsigned int)v35 & *(_DWORD *)(v40 + 52));
v43 = *(_DWORD *)&v30[v42 + 8] + 1;
*(_DWORD *)&v30[v42 + 8] = v43;
if ( v36 < v43 )
{
++*((_DWORD *)v31 + 11);
*(_DWORD *)&v30[v42 + 12] = v43 / v36;
}
v44 = *(_QWORD *)&v30[v42];
*(_QWORD *)(v40 + 32) = v44;
*(_QWORD *)(v40 + 24) = 0;
if ( v44 )
*(_QWORD *)(v44 + 24) = v40;
*(_QWORD *)&v30[v42] = v40;
v40 = v41;
}
while ( v41 );
}
v38 += 16;
}
while ( v38 != v39 );
}
else
{
v37 = *v31;
}
free(v37);
v45 = *(_QWORD *)(v5 + 272);
v46 = *(_DWORD *)(v45 + 16);
v47 = *(_DWORD *)(v45 + 44);
v48 = *(_DWORD *)(v45 + 12) + 1;
*(_DWORD *)(v45 + 8) *= 2;
*(_DWORD *)(v45 + 12) = v48;
*(_QWORD *)v45 = v30;
if ( v47 <= v46 >> 1 )
{
*(_DWORD *)(v45 + 48) = 0;
}
else
{
v49 = *(_DWORD *)(v45 + 48) + 1;
*(_DWORD *)(v45 + 48) = v49;
if ( v49 > 1 )
*(_DWORD *)(v45 + 52) = 1;
}
return;
}
LABEL_26:
exit(-1);
}
}