//
// DS_Dictionary::split from 0x100179ca0 to 0x100179fe3 (835 bytes)
//
// 1 xrefs:
// > DS_Dictionary::splitWithForm @ 0x10017a2f2
//
// 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::split(
DS_Dictionary *a1,
std::string *const a2,
const char *a3,
std::vector *a4)
{
double v4; // xmm0_8
std::uint8_t sizex2; // al
std::size_t v6; // r12
std::array *longStorage; // r14
std::size_t size; // r13
std::size_t v9; // r15
std::array *p_shortStorage; // rsi
signed __int64 v11; // rbx
std::size_t v12; // rax
std::size_t v13; // rcx
int v14; // r13d
bool v15; // zf
char *v16; // rdx
signed __int64 v17; // r15
int v18; // ecx
char *v19; // r13
std::size_t v20; // r15
size_t v21; // r12
int v22; // r13d
char *v23; // rbx
size_t v24; // r14
char *v25; // r13
size_t v26; // r15
char *v27; // r14
char *v28; // rax
std::size_t v29; // r15
size_t v30; // rbx
char *v31; // r15
size_t v32; // r14
char *v33; // rax
std::size_t v34; // [rsp+8h] [rbp-98h]
int v35; // [rsp+10h] [rbp-90h]
int v36; // [rsp+18h] [rbp-88h]
std::array *v38; // [rsp+28h] [rbp-78h]
int __c; // [rsp+3Ch] [rbp-64h]
std::size_t v42; // [rsp+48h] [rbp-58h]
std::array *v43; // [rsp+50h] [rbp-50h]
size_t __dst; // [rsp+58h] [rbp-48h] BYREF
size_t v45; // [rsp+60h] [rbp-40h]
void *__p; // [rsp+68h] [rbp-38h]
bool v47; // [rsp+77h] [rbp-29h]
sizex2 = a2->m_data.m_short.sizex2;
v6 = a2->m_data.m_short.sizex2 >> 1;
v47 = (a2->m_data.m_short.sizex2 & 1) == 0;
longStorage = (std::array *)a2->m_data.m_long.longStorage;
v43 = longStorage;
if ( (sizex2 & 1) == 0 )
longStorage = &a2->m_data.m_short.shortStorage;
size = a2->m_data.m_long.size;
v9 = size;
if ( (sizex2 & 1) == 0 )
v9 = v6;
p_shortStorage = &a2->m_data.m_short.shortStorage;
v11 = strlen(a3);
v12 = size;
v13 = 0;
v14 = 0;
v38 = p_shortStorage;
while ( 1 )
{
v42 = v13;
if ( v11 )
{
v35 = v14;
v34 = v12;
v16 = &longStorage->__elems_[v9];
v17 = v9 - v13;
v36 = (int)longStorage;
if ( v17 >= v11 )
{
v25 = &longStorage->__elems_[v13];
__c = *a3;
do
{
v26 = v17 - v11 + 1;
if ( !v26 )
break;
v27 = v16;
v28 = (char *)memchr(v25, __c, v26);
if ( !v28 )
{
v16 = v27;
v18 = (int)v27;
v19 = v27;
goto LABEL_14;
}
v19 = v28;
if ( !memcmp(v28, a3, v11) )
{
v18 = (int)v19;
v16 = v27;
goto LABEL_14;
}
v25 = v19 + 1;
v16 = v27;
v17 = v27 - v25;
}
while ( v27 - v25 >= v11 );
}
v18 = (int)v16;
v19 = v16;
LABEL_14:
LODWORD(v13) = v18 - v36;
if ( v19 == v16 )
LODWORD(v13) = -1;
p_shortStorage = v38;
v12 = v34;
v14 = v35;
}
if ( (_DWORD)v13 == -1 )
break;
if ( v47 )
{
v43 = p_shortStorage;
v20 = v42;
if ( v6 < v42 )
goto LABEL_50;
}
else
{
v6 = v12;
v20 = v42;
if ( v12 < v42 )
goto LABEL_50;
}
v21 = v6 - v20;
if ( v21 >= (int)v13 - v14 )
v21 = (int)v13 - v14;
if ( v21 >= 0xFFFFFFFFFFFFFFF8LL )
goto LABEL_58;
v22 = v13;
if ( v21 >= 0x17 )
{
v24 = (v21 | 7) + 1;
if ( (v21 | 7) == 0x17 )
v24 = 26;
v23 = (char *)operator new(v24);
__p = v23;
__dst = v24 + 1;
v45 = v21;
}
else
{
LOBYTE(__dst) = 2 * v21;
v23 = (char *)&__dst + 1;
if ( !v21 )
goto LABEL_32;
}
memmove(v23, &v43->__elems_[v20], v21);
LABEL_32:
v23[v21] = 0;
sub_10017A000(a4, &__dst);
if ( (__dst & 1) != 0 )
operator delete(__p);
v11 = strlen(a3);
v14 = v11 + v22;
v13 = v14;
v6 = a2->m_data.m_short.sizex2 >> 1;
v15 = (a2->m_data.m_short.sizex2 & 1) == 0;
v47 = v15;
v12 = a2->m_data.m_long.size;
longStorage = (std::array *)a2->m_data.m_long.longStorage;
v43 = longStorage;
p_shortStorage = v38;
if ( v15 )
longStorage = v38;
v9 = a2->m_data.m_long.size;
if ( v15 )
v9 = v6;
if ( v9 < v14 )
goto LABEL_43;
}
v13 = v42;
LABEL_43:
v29 = v13;
if ( v47 )
{
if ( v6 >= v13 )
goto LABEL_45;
LABEL_50:
sub_1000547C0();
}
v6 = v12;
p_shortStorage = v43;
if ( v12 < v13 )
goto LABEL_50;
LABEL_45:
v30 = v6 - v13;
if ( v6 - v13 >= 0xFFFFFFFFFFFFFFF8LL )
LABEL_58:
sub_100006BF0(v4);
if ( v30 >= 0x17 )
{
v32 = 26;
if ( (v30 | 7) != 0x17 )
v32 = (v30 | 7) + 1;
v33 = (char *)operator new(v32);
v13 = v29;
v31 = v33;
__p = v33;
__dst = v32 + 1;
v45 = v30;
goto LABEL_54;
}
LOBYTE(__dst) = 2 * v30;
v31 = (char *)&__dst + 1;
if ( v6 != v13 )
LABEL_54:
memmove(v31, &p_shortStorage->__elems_[v13], v30);
v31[v30] = 0;
sub_10017A000(a4, &__dst);
if ( (__dst & 1) != 0 )
operator delete(__p);
}