//
// cocos2d::CCDictionary::setObjectUnSafe from 0x10030f120 to 0x10030f48c (876 bytes)
//
// 1 xrefs:
// > cocos2d::CCDictionary::setObject @ 0x10030f102
//
// 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 *v4; // r14
UT_hash_handle *v5; // r15
cocos2d::CCDictElement *m_pElements; // rax
UT_hash_table *tbl; // rbx
UT_hash_handle *tail; // rcx
UT_hash_table *v9; // rax
UT_hash_bucket *v10; // rax
unsigned int v11; // r12d
int v12; // ecx
int v13; // edi
unsigned int v14; // edx
unsigned int v15; // ecx
int v16; // esi
unsigned int v17; // edi
unsigned int v18; // edx
int v19; // ecx
unsigned int v20; // esi
__int64 v21; // rcx
unsigned int v22; // eax
__int64 v23; // rdx
__int64 num_buckets; // r13
char *v25; // rax
char *v26; // r14
int v27; // r15d
unsigned int v28; // r12d
UT_hash_bucket *buckets; // rdi
int v30; // ecx
__int64 i; // rsi
UT_hash_handle *hh_head; // r8
UT_hash_handle *hh_next; // r9
char *v34; // r10
unsigned int v35; // eax
UT_hash_handle *v36; // rax
__int64 v37; // rax
unsigned int v38; // ecx
__int64 *v39; // [rsp+0h] [rbp-30h]
cocos2d::CCObject::retain(a2);
v4 = operator new(0x148u);
*(_BYTE *)v4 = 0;
v4[32] = a3;
v4[33] = a2;
v5 = (UT_hash_handle *)(v4 + 34);
*((_OWORD *)v4 + 19) = 0;
*((_OWORD *)v4 + 17) = 0;
*((_OWORD *)v4 + 18) = 0;
v4[40] = 0;
v4[39] = v4 + 32;
*((_DWORD *)v4 + 80) = 8;
m_pElements = a1->m_pElements;
if ( m_pElements )
{
tbl = m_pElements->hh.tbl;
tail = tbl->tail;
tail->next = v4;
v4[35] = (char *)tail - tbl->hho;
tbl->tail = v5;
}
else
{
a1->m_pElements = (cocos2d::CCDictElement *)v4;
v9 = (UT_hash_table *)calloc(1u, 0x40u);
v4[34] = v9;
if ( !v9 )
goto LABEL_26;
tbl = v9;
v9->tail = v5;
*(_QWORD *)&v9->num_buckets = 0x500000020LL;
v9->hho = 272;
v10 = (UT_hash_bucket *)calloc(1u, 0x200u);
tbl->buckets = v10;
if ( !v10 )
goto LABEL_26;
tbl->signature = -1609490463;
m_pElements = (cocos2d::CCDictElement *)v4;
}
v11 = tbl->num_items + 1;
tbl->num_items = v11;
v4[34] = tbl;
v12 = *((_DWORD *)v4 + 65) - 1640531527;
v13 = (*((unsigned __int8 *)v4 + 256)
+ (*((unsigned __int8 *)v4 + 258) << 16)
+ (*((unsigned __int8 *)v4 + 257) << 8)
+ (*((unsigned __int8 *)v4 + 259) << 24)
- v12
- 1622558014)
^ 0x7F76D;
v14 = (v12 - v13 + 17973513) ^ (v13 << 8);
v15 = (-17973513 - v13 - v14) ^ (v14 >> 13);
v16 = (v13 - v14 - v15) ^ (v15 >> 12);
v17 = (v14 - v15 - v16) ^ (v16 << 16);
v18 = (v15 - v16 - v17) ^ (v17 >> 5);
v19 = (v16 - v17 - v18) ^ (v18 >> 3);
v20 = (v18 - (((v17 - v18 - v19) ^ (v19 << 10)) + v19)) ^ (((v17 - v18 - v19) ^ (v19 << 10)) >> 15);
*((_DWORD *)v4 + 81) = v20;
v21 = (__int64)&m_pElements->hh.tbl->buckets[v20 & (m_pElements->hh.tbl->num_buckets - 1)];
v22 = *(_DWORD *)(v21 + 8) + 1;
*(_DWORD *)(v21 + 8) = v22;
v23 = *(_QWORD *)v21;
v4[38] = *(_QWORD *)v21;
v4[37] = 0;
if ( v23 )
*(_QWORD *)(v23 + 24) = v5;
*(_QWORD *)v21 = v5;
if ( v22 >= 10 * *(_DWORD *)(v21 + 12) + 10 && tbl->noexpand != 1 )
{
v39 = v4 + 34;
num_buckets = tbl->num_buckets;
v25 = (char *)calloc(1u, 16LL * (unsigned int)(2 * num_buckets));
if ( v25 )
{
v26 = v25;
v27 = 2 * num_buckets - 1;
v28 = (v11 >> (LOBYTE(tbl->log2_num_buckets) + 1)) - (((v11 & v27) == 0) - 1);
*(_QWORD *)&tbl->ideal_chain_maxlen = v28;
buckets = tbl->buckets;
if ( num_buckets )
{
v30 = 0;
for ( i = 0; i != num_buckets; ++i )
{
hh_head = buckets[i].hh_head;
if ( hh_head )
{
do
{
hh_next = hh_head->hh_next;
v34 = &v26[16 * (v27 & hh_head->hashv)];
v35 = *((_DWORD *)v34 + 2) + 1;
*((_DWORD *)v34 + 2) = v35;
if ( v35 > v28 )
{
tbl->nonideal_items = ++v30;
*((_DWORD *)v34 + 3) = v35 / v28;
}
hh_head->hh_prev = nullptr;
v36 = *(UT_hash_handle **)v34;
hh_head->hh_next = *(UT_hash_handle **)v34;
if ( v36 )
v36->hh_prev = hh_head;
*(_QWORD *)v34 = hh_head;
hh_head = hh_next;
}
while ( hh_next );
}
}
}
free(buckets);
v37 = *v39;
*(_DWORD *)(v37 + 8) *= 2;
++*(_DWORD *)(v37 + 12);
*(_QWORD *)v37 = v26;
if ( *(_DWORD *)(v37 + 44) <= *(_DWORD *)(v37 + 16) >> 1 )
{
*(_DWORD *)(v37 + 48) = 0;
}
else
{
v38 = *(_DWORD *)(v37 + 48) + 1;
*(_DWORD *)(v37 + 48) = v38;
if ( v38 >= 2 )
*(_DWORD *)(v37 + 52) = 1;
}
return;
}
LABEL_26:
exit(-1);
}
}