//
// DS_Dictionary::setSubDictForKey from 0x10017e7a0 to 0x10017ea0b (619 bytes)
//
// 2 xrefs:
// > DS_Dictionary::setArrayForKey @ 0x100180757
// > DS_Dictionary::setObjectForKey @ 0x100180a2f
//
// 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 DS_Dictionary::setSubDictForKey(DS_Dictionary *a1, const char *a2, bool a3, bool a4)
{
_BOOL4 v4; // r13d
const char *v7; // r12
std::__vector_base
::pointer v8; // rdi
const char *v9; // rsi
char *v10; // rax
const char *v11; // rsi
__int64 v12; // rax
const char *v13; // rsi
__int64 v14; // rax
std::__vector_base::pointer end; // r14
pugi::xml_node *value; // rcx
pugi::xml_node *v17; // r15
std::__vector_base::pointer begin; // rdi
signed __int64 v19; // r14
__int64 v20; // r13
__int64 v21; // rcx
unsigned __int64 v22; // r15
pugi::xml_node *v23; // r12
const char *v24; // rsi
void *v25; // r13
__int64 v26; // [rsp+8h] [rbp-48h] BYREF
void *__src; // [rsp+10h] [rbp-40h]
pugi::xml_node *v28; // [rsp+18h] [rbp-38h]
_QWORD v29[6]; // [rsp+20h] [rbp-30h] BYREF
LODWORD(__src) = a4;
v4 = a3;
pugi::xml_node::xml_node(&v26);
v7 = "k";
if ( !v4 )
goto LABEL_10;
v8 = a1->dictTree.__end_ - 1;
v9 = "k";
if ( a1->compatible )
v9 = "key";
v29[0] = sub_10063B550(v8, v9);
if ( sub_10063B3F0(v29) )
{
while ( 1 )
{
v10 = (char *)sub_10063B880(v29);
if ( !sub_1001796D0(v10, (char *)a2) )
break;
v11 = "key";
if ( !a1->compatible )
v11 = "k";
v29[0] = sub_10063B730(v29, v11);
if ( !sub_10063B3F0(v29) )
goto LABEL_10;
}
v24 = "k";
if ( a1->compatible )
v24 = "key";
v12 = sub_10063C8D0(&a1->dictTree.__end_[-1], v24, v29);
}
else
{
LABEL_10:
if ( a1->compatible )
v7 = "key";
v12 = sub_10063C660(&a1->dictTree.__end_[-1], v7);
}
v26 = v12;
v29[0] = sub_10063C150(&v26, 3);
sub_10063BA40(v29, a2);
v13 = "d";
if ( a1->compatible )
v13 = "dict";
v14 = sub_10063C7D0(&a1->dictTree.__end_[-1], v13, &v26);
if ( (_BYTE)__src )
{
end = a1->dictTree.__end_;
value = a1->dictTree.__end_cap_.__value_;
if ( end >= value )
{
begin = a1->dictTree.__begin_;
v19 = (char *)end - (char *)begin;
v20 = v19 >> 3;
if ( (unsigned __int64)((v19 >> 3) + 1) >> 61 )
sub_100183910();
v21 = (char *)value - (char *)begin;
v22 = v21 >> 2;
if ( v21 >> 2 <= (unsigned __int64)((v19 >> 3) + 1) )
v22 = (v19 >> 3) + 1;
if ( (unsigned __int64)v21 >= 0x7FFFFFFFFFFFFFF8LL )
v22 = 0x1FFFFFFFFFFFFFFFLL;
__src = a1->dictTree.__begin_;
if ( v22 )
{
v28 = (pugi::xml_node *)v14;
if ( v22 > 0x1FFFFFFFFFFFFFFFLL )
sub_100054850();
v23 = (pugi::xml_node *)operator new(8 * v22);
v14 = (__int64)v28;
}
else
{
v23 = nullptr;
}
v28 = &v23[v22];
v23[v20]._root = (pugi::xml_node_struct *)v14;
v17 = &v23[v20 + 1];
v25 = __src;
memcpy(v23, __src, v19);
a1->dictTree.__begin_ = v23;
a1->dictTree.__end_ = v17;
a1->dictTree.__end_cap_.__value_ = v28;
if ( v25 )
operator delete(v25);
}
else
{
end->_root = (pugi::xml_node_struct *)v14;
v17 = end + 1;
}
a1->dictTree.__end_ = v17;
}
}