//
// cocos2d::CCDictionary::setObjectUnSafe from 0x18000bfe0 to 0x18000c48d (1197 bytes)
//
// 4 xrefs:
// > cocos2d::CCDictionary::copyWithZone @ 0x180009d3f
// > cocos2d::CCDictionary::setObject @ 0x18000b8f2
// > ??> @ 0x1801438a8
// > ??> @ 0x1801ade1c
//
// 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 *this,
struct cocos2d::CCObject *a2,
std::intptr_t a3)
{
cocos2d::CCDictElement *v6; // rax
int v7; // ebp
cocos2d::CCDictElement *v8; // rbx
cocos2d::CCDictElement *m_pElements; // rax
UT_hash_table *tbl; // rcx
UT_hash_bucket *buckets; // rcx
UT_hash_handle *p_hh; // rsi
int v13; // edx
int v14; // ecx
unsigned int v15; // edx
unsigned int v16; // r8d
int v17; // ecx
unsigned int v18; // edx
unsigned int v19; // r8d
unsigned int v20; // ecx
unsigned int v21; // ecx
UT_hash_table *v22; // rdx
__int64 v23; // r8
UT_hash_handle *hh_head; // rcx
UT_hash_bucket *v25; // rcx
UT_hash_bucket *v26; // rax
UT_hash_bucket *v27; // r14
UT_hash_table *v28; // rdi
unsigned int v29; // ebx
unsigned int v30; // r11d
void **i; // rax
UT_hash_handle *v32; // r9
UT_hash_handle *hh_next; // r10
UT_hash_bucket *v34; // rcx
unsigned int v35; // eax
UT_hash_table *v36; // rcx
cocos2d::CCObject::retain(a2);
v6 = (cocos2d::CCDictElement *)operator new(0x148u);
v7 = 0;
v8 = v6;
if ( v6 )
{
v6->m_szKey[0] = 0;
v6->m_iKey = a3;
v6->m_pObject = a2;
*(_OWORD *)&v6->hh.tbl = 0;
*(_OWORD *)&v6->hh.next = 0;
*(_OWORD *)&v6->hh.hh_next = 0;
*(_QWORD *)&v6->hh.keylen = 0;
}
else
{
v8 = nullptr;
}
v8->hh.next = nullptr;
v8->hh.key = &v8->m_iKey;
v8->hh.keylen = 8;
m_pElements = this->m_pElements;
if ( m_pElements )
{
p_hh = &v8->hh;
m_pElements->hh.tbl->tail->next = v8;
v8->hh.prev = (char *)this->m_pElements->hh.tbl->tail - this->m_pElements->hh.tbl->hho;
this->m_pElements->hh.tbl->tail = &v8->hh;
}
else
{
this->m_pElements = v8;
v8->hh.prev = nullptr;
this->m_pElements->hh.tbl = (UT_hash_table *)malloc(0x40u);
tbl = this->m_pElements->hh.tbl;
if ( !tbl )
goto LABEL_14;
*(_OWORD *)&tbl->buckets = 0;
*(_OWORD *)&tbl->num_items = 0;
*(_OWORD *)&tbl->hho = 0;
*(_OWORD *)&tbl->ineff_expands = 0;
this->m_pElements->hh.tbl->tail = &this->m_pElements->hh;
this->m_pElements->hh.tbl->num_buckets = 32;
this->m_pElements->hh.tbl->log2_num_buckets = 5;
this->m_pElements->hh.tbl->hho = 272;
this->m_pElements->hh.tbl->buckets = (UT_hash_bucket *)malloc(0x200u);
buckets = this->m_pElements->hh.tbl->buckets;
if ( !buckets )
LABEL_14:
exit(-1);
memset(buckets, 0, 0x200u);
p_hh = &v8->hh;
this->m_pElements->hh.tbl->signature = -1609490463;
}
++this->m_pElements->hh.tbl->num_items;
p_hh->tbl = this->m_pElements->hh.tbl;
v8->hh.hashv = -17973513;
v13 = ((BYTE5(v8->m_iKey) + ((BYTE6(v8->m_iKey) + (HIBYTE(v8->m_iKey) << 8)) << 8)) << 8)
- 1640531527
+ BYTE4(v8->m_iKey);
v14 = (LOBYTE(v8->m_iKey)
+ ((BYTE1(v8->m_iKey) + ((BYTE2(v8->m_iKey) + (BYTE3(v8->m_iKey) << 8)) << 8)) << 8)
- v13
- 1622558014)
^ 0x7F76D;
v15 = (v14 << 8) ^ (v13 - v14 + 17973513);
v16 = (v15 >> 13) ^ (-17973513 - v15 - v14);
v17 = (v16 >> 12) ^ (v14 - v16 - v15);
v18 = (v17 << 16) ^ (v15 - v16 - v17);
v19 = (v18 >> 5) ^ (v16 - v18 - v17);
v20 = v17 - v19 - v18;
v21 = (((((v19 >> 3) ^ v20) << 10) ^ (v18 - v19 - ((v19 >> 3) ^ v20))) >> 15)
^ (v19 - ((((v19 >> 3) ^ v20) << 10) ^ (v18 - v19 - ((v19 >> 3) ^ v20))) - ((v19 >> 3) ^ v20));
v8->hh.hashv = v21;
v22 = this->m_pElements->hh.tbl;
v23 = v21 & (v22->num_buckets - 1);
++v22->buckets[v23].count;
v8->hh.hh_next = this->m_pElements->hh.tbl->buckets[v23].hh_head;
v8->hh.hh_prev = nullptr;
hh_head = this->m_pElements->hh.tbl->buckets[v23].hh_head;
if ( hh_head )
hh_head->hh_prev = p_hh;
this->m_pElements->hh.tbl->buckets[v23].hh_head = p_hh;
v25 = this->m_pElements->hh.tbl->buckets;
if ( v25[v23].count >= 10 * (v25[v23].expand_mult + 1) && p_hh->tbl->noexpand != 1 )
{
v26 = (UT_hash_bucket *)malloc(32LL * p_hh->tbl->num_buckets);
v27 = v26;
if ( !v26 )
goto LABEL_14;
v28 = p_hh->tbl;
v29 = 2 * p_hh->tbl->num_buckets;
memset(v26, 0, 16LL * v29);
v30 = 0;
v28->ideal_chain_maxlen = (((v29 - 1) & v28->num_items) != 0)
+ (v28->num_items >> (LOBYTE(v28->log2_num_buckets) + 1));
p_hh->tbl->nonideal_items = 0;
for ( i = (void **)&p_hh->tbl->buckets; v30 < p_hh->tbl->num_buckets; ++v30 )
{
v32 = *((UT_hash_handle **)*i + 2 * v30);
if ( v32 )
{
do
{
hh_next = v32->hh_next;
v34 = &v27[v32->hashv & (2 * p_hh->tbl->num_buckets - 1)];
v35 = v34->count + 1;
v34->count = v35;
if ( v35 > p_hh->tbl->ideal_chain_maxlen )
{
++p_hh->tbl->nonideal_items;
v34->expand_mult = v34->count / p_hh->tbl->ideal_chain_maxlen;
}
v32->hh_prev = nullptr;
v32->hh_next = v34->hh_head;
if ( v34->hh_head )
v34->hh_head->hh_prev = v32;
v34->hh_head = v32;
v32 = hh_next;
}
while ( hh_next );
}
i = (void **)&p_hh->tbl->buckets;
}
free(*i);
p_hh->tbl->num_buckets *= 2;
++p_hh->tbl->log2_num_buckets;
p_hh->tbl->buckets = v27;
v36 = p_hh->tbl;
if ( p_hh->tbl->nonideal_items > p_hh->tbl->num_items >> 1 )
v7 = v36->ineff_expands + 1;
v36->ineff_expands = v7;
if ( p_hh->tbl->ineff_expands > 1 )
p_hh->tbl->noexpand = 1;
}
}