//
// DS_Dictionary::getDictForKey from 0x180019f90 to 0x18001a3be (1070 bytes)
//
// 5 xrefs:
// > CCContentManager::addDictDS @ 0x180005ea0
// > DS_Dictionary::getDictForKey @ 0x18001a14b
// > DS_Dictionary::getObjectForKey @ 0x18001ac22
// > ??> @ 0x1801438a8
// > ??> @ 0x1801ae9c8
//
// 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
//
// Hidden C++ exception states: #wind=3
struct cocos2d::CCDictionary *__fastcall DS_Dictionary::getDictForKey(DS_Dictionary *this, const char *a2, char a3)
{
struct cocos2d::CCDictionary *v6; // r13
const char *v7; // r15
__int64 v8; // rax
const char *v9; // rcx
__int64 v10; // rax
int v11; // edx
int v12; // r8d
std::_Vector_val>::pointer Mylast; // rdx
bool BoolForKey; // si
int IntegerForKey; // eax
int v16; // edi
ObjectDecoder *v17; // rax
struct cocos2d::CCArray *DecodedObject; // rdi
__int64 v19; // rax
const char *v20; // rcx
__int64 v21; // rax
int v22; // edx
int v23; // r8d
void *v24; // rcx
_BYTE *v25; // rax
size_t v26; // r8
void *v27; // rcx
size_t v28; // r8
void *v29; // rcx
__int64 v30; // rax
__int64 v31; // [rsp+20h] [rbp-59h] BYREF
pugi::xml_node_struct *v32; // [rsp+28h] [rbp-51h] BYREF
_BYTE v33[8]; // [rsp+30h] [rbp-49h] BYREF
_BYTE v34[8]; // [rsp+38h] [rbp-41h] BYREF
__int128 v35; // [rsp+40h] [rbp-39h] BYREF
__int64 v36; // [rsp+50h] [rbp-29h]
unsigned __int64 v37; // [rsp+58h] [rbp-21h]
__int128 v38; // [rsp+60h] [rbp-19h] BYREF
__int64 v39; // [rsp+70h] [rbp-9h]
unsigned __int64 v40; // [rsp+78h] [rbp-1h]
__int128 v41; // [rsp+80h] [rbp+7h] BYREF
__int64 v42; // [rsp+90h] [rbp+17h]
unsigned __int64 v43; // [rsp+98h] [rbp+1Fh]
if ( a2 && !a3 && !DS_Dictionary::stepIntoSubDictWithKey(this, a2) )
return cocos2d::CCDictionary::create();
v6 = cocos2d::CCDictionary::create();
sub_180080CF0(&this->dictTree._Mypair._Myval2._Mylast[-1], &v31);
for ( ; sub_18007F4E0(&v31); v31 = *(_QWORD *)sub_180081AB0(v30, v34) )
{
sub_180081AB0(&v31, &v32);
v7 = (const char *)sub_18007FB70(&v31);
v8 = sub_180081A30(&v32);
v9 = "d";
if ( this->compatible )
v9 = "dict";
v10 = v8 - (_QWORD)v9;
do
{
v11 = (unsigned __int8)v9[v10];
v12 = *(unsigned __int8 *)v9 - v11;
if ( v12 )
break;
++v9;
}
while ( v11 );
if ( v12 )
{
v19 = sub_180081A30(&v32);
v20 = "t";
if ( this->compatible )
v20 = "true";
v21 = v19 - (_QWORD)v20;
do
{
v22 = (unsigned __int8)v20[v21];
v23 = *(unsigned __int8 *)v20 - v22;
if ( v23 )
break;
++v20;
}
while ( v22 );
if ( v23 )
{
v25 = (_BYTE *)sub_18007FB70(&v32);
v38 = 0;
v39 = 0;
v40 = 0;
v26 = -1;
do
++v26;
while ( v25[v26] );
sub_18000CE60(&v38, v25, v26);
DecodedObject = (struct cocos2d::CCArray *)cocos2d::CCString::create((__int64)&v38);
if ( v40 > 0xF )
{
v27 = (void *)v38;
if ( v40 + 1 >= 0x1000 )
{
v27 = *(void **)(v38 - 8);
if ( (unsigned __int64)(v38 - (_QWORD)v27 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free_0(v27);
}
v39 = 0;
v40 = 15;
LOBYTE(v38) = 0;
}
else
{
v35 = 0;
v36 = 1;
v37 = 15;
LOWORD(v35) = 49;
DecodedObject = (struct cocos2d::CCArray *)cocos2d::CCString::create((__int64)&v35);
if ( v37 > 0xF )
{
v24 = (void *)v35;
if ( v37 + 1 >= 0x1000 )
{
v24 = *(void **)(v35 - 8);
if ( (unsigned __int64)(v35 - (_QWORD)v24 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free_0(v24);
}
v36 = 0;
v37 = 15;
LOBYTE(v35) = 0;
}
}
else
{
Mylast = this->dictTree._Mypair._Myval2._Mylast;
if ( Mylast == this->dictTree._Mypair._Myval2._Myend )
{
sub_180015D80((const void **)&this->dictTree._Mypair._Myval2._Myfirst, Mylast, &v32);
}
else
{
Mylast->_root = v32;
++this->dictTree._Mypair._Myval2._Mylast;
}
BoolForKey = DS_Dictionary::getBoolForKey(this, "_isArr");
IntegerForKey = DS_Dictionary::getIntegerForKey(this, "kCEK");
v16 = IntegerForKey;
if ( IntegerForKey )
{
if ( IntegerForKey == -1 )
v16 = DS_Dictionary::getIntegerForKey(this, "kCEK");
v17 = ObjectDecoder::sharedDecoder();
DecodedObject = (struct cocos2d::CCArray *)ObjectDecoder::getDecodedObject(v17, v16, this);
if ( (unsigned __int64)(this->dictTree._Mypair._Myval2._Mylast - this->dictTree._Mypair._Myval2._Myfirst) > 1 )
--this->dictTree._Mypair._Myval2._Mylast;
}
else if ( BoolForKey )
{
DecodedObject = DS_Dictionary::getArrayForKey(this, v7, 1);
}
else
{
DecodedObject = (struct cocos2d::CCArray *)DS_Dictionary::getDictForKey(this, v7, 1);
}
}
if ( DecodedObject )
{
v41 = 0;
v42 = 0;
v43 = 0;
v28 = -1;
do
++v28;
while ( v7[v28] );
sub_18000CE60(&v41, v7, v28);
cocos2d::CCDictionary::setObject((__int64)v6, DecodedObject, (unsigned __int8 *)&v41);
if ( v43 > 0xF )
{
v29 = (void *)v41;
if ( v43 + 1 >= 0x1000 )
{
v29 = *(void **)(v41 - 8);
if ( (unsigned __int64)(v41 - (_QWORD)v29 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free_0(v29);
}
}
v30 = sub_180081AB0(&v31, v33);
}
if ( a2 )
{
if ( (unsigned __int64)(this->dictTree._Mypair._Myval2._Mylast - this->dictTree._Mypair._Myval2._Myfirst) > 1 )
--this->dictTree._Mypair._Myval2._Mylast;
}
return v6;
}