//
// cocos2d::CCDictionary::setObjectUnSafe from 0x1004239a4 to 0x100423cc8 (804 bytes)
//
// 1 xrefs:
// > cocos2d::CCDictionary::setObject @ 0x100423968
//
// 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 __fastcall cocos2d::CCDictionary::setObjectUnSafe(cocos2d::CCDictionary *a1, cocos2d::CCObject *a2, intptr_t a3)
{
_QWORD *v6; // x0
cocos2d::CCDictElement *v7; // x20
int32x2_t **v8; // x21
cocos2d::CCDictElement *m_pElements; // x8
UT_hash_table *tbl; // x19
UT_hash_handle *tail; // x9
std::ptrdiff_t hho; // x10
UT_hash_table *v13; // x0
UT_hash_bucket *v14; // x0
unsigned int v15; // w22
int v16; // w9
int v17; // w10
unsigned int v18; // w9
unsigned int v19; // w11
int v20; // w10
unsigned int v21; // w9
unsigned int v22; // w11
int v23; // w10
unsigned int v24; // w9
__int64 v25; // x9
unsigned int v26; // w8
UT_hash_handle *v27; // x10
__int64 num_buckets; // x23
int v29; // w24
char *v30; // x0
char *v31; // x20
unsigned int v32; // w9
UT_hash_bucket *buckets; // x0
int v34; // w10
__int64 i; // x11
UT_hash_handle *hh_head; // x12
UT_hash_handle *hh_next; // x13
char *v38; // x14
unsigned int v39; // w15
UT_hash_handle *v40; // x15
int32x2_t *v41; // x8
int32x2_t v42; // d0
int32x2_t v43; // d1
unsigned int v44; // w9
cocos2d::CCObject::retain(a2);
v6 = operator new(0x148u);
v7 = (cocos2d::CCDictElement *)v6;
*(_BYTE *)v6 = 0;
v6[32] = a3;
v6[33] = a2;
v8 = (int32x2_t **)(v6 + 34);
*((_OWORD *)v6 + 18) = 0u;
*((_OWORD *)v6 + 19) = 0u;
*((_OWORD *)v6 + 17) = 0u;
v6[39] = v6 + 32;
v6[40] = 0;
*((_DWORD *)v6 + 80) = 8;
m_pElements = a1->m_pElements;
if ( m_pElements )
{
tbl = m_pElements->hh.tbl;
tail = tbl->tail;
hho = tbl->hho;
tail->next = v6;
v6[35] = (char *)tail - hho;
tbl->tail = (UT_hash_handle *)v8;
}
else
{
a1->m_pElements = (cocos2d::CCDictElement *)v6;
v13 = (UT_hash_table *)calloc(1u, 0x40u);
v7->hh.tbl = v13;
if ( !v13 )
goto LABEL_27;
tbl = v13;
*(_QWORD *)&v13->num_buckets = 0x500000020LL;
v13->tail = (UT_hash_handle *)v8;
v13->hho = 272;
v14 = (UT_hash_bucket *)calloc(1u, 0x200u);
tbl->buckets = v14;
if ( !v14 )
goto LABEL_27;
tbl->signature = -1609490463;
m_pElements = v7;
}
v15 = tbl->num_items + 1;
tbl->num_items = v15;
v7->hh.tbl = tbl;
v16 = HIDWORD(v7->m_iKey) - 1640531527;
v17 = ((BYTE3(v7->m_iKey) << 24)
- v16
+ (BYTE2(v7->m_iKey) << 16)
+ (BYTE1(v7->m_iKey) << 8)
+ LOBYTE(v7->m_iKey)
- 1622558014)
^ 0x7F76D;
v18 = (v16 - v17 + 17973513) ^ (v17 << 8);
v19 = (-17973513 - v17 - v18) ^ (v18 >> 13);
v20 = (v17 - v18 - v19) ^ (v19 >> 12);
v21 = (v18 - v19 - v20) ^ (v20 << 16);
v22 = (v19 - v20 - v21) ^ (v21 >> 5);
v23 = (v20 - v21 - v22) ^ (v22 >> 3);
v24 = (v22 - v23 - ((v21 - v22 - v23) ^ (v23 << 10))) ^ (((v21 - v22 - v23) ^ (v23 << 10)) >> 15);
v7->hh.hashv = v24;
v25 = (__int64)&m_pElements->hh.tbl->buckets[v24 & (m_pElements->hh.tbl->num_buckets - 1)];
v26 = *(_DWORD *)(v25 + 8) + 1;
*(_DWORD *)(v25 + 8) = v26;
v27 = *(UT_hash_handle **)v25;
v7->hh.hh_prev = nullptr;
v7->hh.hh_next = v27;
if ( v27 )
v27->hh_prev = (UT_hash_handle *)v8;
*(_QWORD *)v25 = v8;
if ( v26 >= 10 * *(_DWORD *)(v25 + 12) + 10 && tbl->noexpand != 1 )
{
num_buckets = tbl->num_buckets;
v29 = 2 * num_buckets;
v30 = (char *)calloc(1u, 16LL * (unsigned int)(2 * num_buckets));
if ( v30 )
{
v31 = v30;
v32 = v15 >> (tbl->log2_num_buckets + 1);
if ( ((v29 - 1) & v15) != 0 )
++v32;
tbl->ideal_chain_maxlen = v32;
tbl->nonideal_items = 0;
buckets = tbl->buckets;
if ( (_DWORD)num_buckets )
{
v34 = 0;
for ( i = 0; i != num_buckets; ++i )
{
hh_head = buckets[i].hh_head;
if ( hh_head )
{
do
{
hh_next = hh_head->hh_next;
v38 = &v31[16 * (hh_head->hashv & (v29 - 1))];
v39 = *((_DWORD *)v38 + 2) + 1;
*((_DWORD *)v38 + 2) = v39;
if ( v39 > v32 )
{
tbl->nonideal_items = ++v34;
*((_DWORD *)v38 + 3) = v39 / v32;
}
v40 = *(UT_hash_handle **)v38;
hh_head->hh_prev = nullptr;
hh_head->hh_next = v40;
if ( v40 )
v40->hh_prev = hh_head;
*(_QWORD *)v38 = hh_head;
hh_head = hh_next;
}
while ( hh_next );
}
}
}
free(buckets);
v41 = *v8;
v42 = (*v8)[1];
v43.i32[0] = vadd_s32(v42, v42).u32[0];
v43.i32[1] = vadd_s32(v42, (int32x2_t)0x100000001LL).i32[1];
v41[1] = v43;
*v41 = (int32x2_t)v31;
if ( v41[5].i32[1] <= (unsigned __int32)v41[2].i32[0] >> 1 )
{
v41[6].i32[0] = 0;
}
else
{
v44 = v41[6].i32[0] + 1;
v41[6].i32[0] = v44;
if ( v44 >= 2 )
v41[6].i32[1] = 1;
}
return;
}
LABEL_27:
exit(-1);
}
}