//
// cocos2d::CCDictionary::setObjectUnSafe from 0x5c04a4 to 0x5c0704 (608 bytes)
//
// 1 xrefs:
// > cocos2d::CCDictionary::setObject @ 0x5c07da
//
// 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)
{
int v6; // r4
cocos2d::CCDictElement *m_pElements; // r6
UT_hash_handle *v8; // r5
void *v9; // r0
_DWORD *v10; // r7
void *v11; // r0
UT_hash_table *tbl; // r2
UT_hash_handle *tail; // r3
std::ptrdiff_t hho; // r1
cocos2d::CCDictElement *v15; // r0
UT_hash_table *v16; // r1
int v17; // r2
int v18; // r6
unsigned int v19; // r2
unsigned int v20; // r3
int v21; // r6
unsigned int v22; // r2
unsigned int v23; // r3
int v24; // r6
unsigned int v25; // r2
unsigned int v26; // r3
unsigned int v27; // r2
UT_hash_table *v28; // r6
int v29; // r2
unsigned int num_buckets; // r0
UT_hash_bucket *buckets; // r6
int v32; // r2
UT_hash_handle *hh_head; // r7
unsigned int v34; // r0
size_t v35; // r5
char *v36; // r0
char *v37; // r10
int v38; // r5
int v39; // r2
unsigned int v40; // r7
int v41; // r11
int v42; // r3
unsigned int v43; // r7
int v44; // r6
_DWORD *i; // r8
int v46; // r9
unsigned int v47; // r0
int v48; // r3
_DWORD *v49; // r3
int v50; // r2
unsigned int v51; // r1
unsigned int v52; // r2
bool v53; // cc
unsigned int v54; // r2
_DWORD *v55; // [sp+0h] [bp-14h]
cocos2d::CCObject::retain(a2);
v6 = operator new(0x128u);
cocos2d::CCDictElement::CCDictElement((cocos2d::CCDictElement *)v6, a3, a2);
m_pElements = a1->m_pElements;
v8 = (UT_hash_handle *)(v6 + 264);
*(_DWORD *)(v6 + 272) = 0;
*(_DWORD *)(v6 + 284) = v6 + 256;
*(_DWORD *)(v6 + 288) = 4;
if ( m_pElements )
{
tbl = m_pElements->hh.tbl;
tail = tbl->tail;
hho = tbl->hho;
tail->next = (void *)v6;
*(_DWORD *)(v6 + 268) = (char *)tail - hho;
tbl->tail = v8;
}
else
{
a1->m_pElements = (cocos2d::CCDictElement *)v6;
*(_DWORD *)(v6 + 268) = 0;
v9 = malloc(0x2Cu);
*(_DWORD *)(v6 + 264) = v9;
if ( !v9 )
goto LABEL_3;
memset(v9, 0, 0x2Cu);
v10 = *(_DWORD **)(v6 + 264);
v10[1] = 32;
v10[4] = v8;
v10[2] = 5;
v10[5] = 264;
v11 = malloc(0x180u);
*v10 = v11;
if ( !v11 )
goto LABEL_3;
memset(v11, 0, 0x180u);
a1->m_pElements->hh.tbl->signature = -1609490463;
}
v15 = a1->m_pElements;
v16 = v15->hh.tbl;
++v16->num_items;
v17 = *(unsigned __int8 *)(v6 + 256);
*(_DWORD *)(v6 + 264) = v16;
v18 = (v17
+ 17973517
+ (*(unsigned __int8 *)(v6 + 259) << 24)
+ (*(unsigned __int8 *)(v6 + 258) << 16)
+ (*(unsigned __int8 *)(v6 + 257) << 8))
^ 0x7F76D;
v19 = (-1622558010 - v18) ^ (v18 << 8);
v20 = (-17973517 - v18 - v19) ^ (v19 >> 13);
v21 = (v18 - v19 - v20) ^ (v20 >> 12);
v22 = (v19 - v20 - v21) ^ (v21 << 16);
v23 = (v20 - v21 - v22) ^ (v22 >> 5);
v24 = (v21 - v22 - v23) ^ (v23 >> 3);
v25 = v22 - v23 - v24;
v26 = v23 - v24;
v27 = v25 ^ (v24 << 10);
v28 = v15->hh.tbl;
v29 = (v26 - v27) ^ (v27 >> 15);
*(_DWORD *)(v6 + 292) = v29;
num_buckets = v28->num_buckets;
buckets = v28->buckets;
v32 = v29 & (num_buckets - 1);
hh_head = buckets[v32].hh_head;
v34 = buckets[v32].count + 1;
buckets[v32].count = v34;
*(_DWORD *)(v6 + 280) = hh_head;
*(_DWORD *)(v6 + 276) = 0;
if ( hh_head )
hh_head->hh_prev = v8;
buckets[v32].hh_head = v8;
if ( v34 >= 10 * buckets[v32].expand_mult + 10 && v16->noexpand != 1 )
{
v35 = 24 * v16->num_buckets;
v36 = (char *)malloc(v35);
v37 = v36;
if ( v36 )
{
memset(v36, 0, v35);
v38 = *(_DWORD *)(v6 + 264);
v39 = *(_DWORD *)(v38 + 4);
v40 = *(_DWORD *)(v38 + 12);
v41 = 2 * v39 - 1;
v42 = v41 & v40;
v43 = v40 >> (*(_BYTE *)(v38 + 8) + 1);
if ( v42 )
++v43;
v44 = 0;
*(_DWORD *)(v38 + 24) = v43;
*(_DWORD *)(v38 + 28) = 0;
while ( v44 != v39 )
{
for ( i = *(_DWORD **)(*(_DWORD *)v38 + 12 * v44); i; i = v55 )
{
v55 = (_DWORD *)i[4];
v46 = 12 * (v41 & i[7]);
v47 = *(_DWORD *)&v37[v46 + 4] + 1;
*(_DWORD *)&v37[v46 + 4] = v47;
if ( v47 > v43 )
{
++*(_DWORD *)(v38 + 28);
*(_DWORD *)&v37[v46 + 8] = v47 / v43;
}
i[3] = 0;
v48 = *(_DWORD *)&v37[v46];
i[4] = v48;
if ( v48 )
*(_DWORD *)(v48 + 12) = i;
*(_DWORD *)&v37[v46] = i;
}
++v44;
}
free(*(void **)v38);
v49 = *(_DWORD **)(v6 + 264);
v50 = v49[1];
v51 = v49[3];
*v49 = v37;
v49[1] = 2 * v50;
++v49[2];
v52 = v49[7];
v53 = v52 > v51 >> 1;
if ( v52 <= v51 >> 1 )
v54 = 0;
else
v54 = v49[8];
if ( v53 )
++v54;
v49[8] = v54;
if ( v54 > 1 )
v49[9] = 1;
return;
}
LABEL_3:
exit(-1);
}
}