//
// DS_Dictionary::split from 0x180020d30 to 0x180020f7b (587 bytes)
//
// 3 xrefs:
// > DS_Dictionary::splitWithForm @ 0x180021130
// > ??> @ 0x1801438a8
// > ??> @ 0x1801aeda0
//
// 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=1
void __fastcall DS_Dictionary::split(__int64 a1, __int64 *a2, char *a3, __int64 *a4)
{
int v7; // ebx
size_t v8; // rax
__int64 v9; // rcx
unsigned __int64 v10; // r14
size_t v11; // rsi
int v12; // r12d
size_t v13; // r8
size_t v14; // rsi
__int64 v15; // rax
_OWORD *v16; // rdx
unsigned __int64 v17; // rdx
void *v18; // rcx
__int64 v19; // rbx
__int64 v20; // rax
_OWORD *v21; // rdx
unsigned __int64 v22; // rax
void *v23; // rcx
void *Block[2]; // [rsp+38h] [rbp-60h] BYREF
__int128 v25; // [rsp+48h] [rbp-50h]
v7 = 0;
while ( 1 )
{
v8 = -1;
do
++v8;
while ( a3[v8] );
v9 = (__int64)a2;
v10 = a2[3];
if ( v10 > 0xF )
v9 = *a2;
v11 = a2[2];
v12 = sub_180016610(v9, v11, v7, a3, v8);
*(_OWORD *)Block = 0;
if ( v12 == -1 )
break;
v25 = 0u;
if ( v11 < v7 )
goto LABEL_36;
v13 = v12 - v7;
v14 = v11 - v7;
if ( v14 < v13 )
v13 = v14;
v15 = (__int64)a2;
if ( v10 > 0xF )
v15 = *a2;
sub_18000CE60(Block, (const void *)(v15 + v7), v13);
v16 = (_OWORD *)a4[1];
if ( v16 == (_OWORD *)a4[2] )
{
sub_18000D000(a4, (__int64)v16, (__int64)Block);
v17 = *((_QWORD *)&v25 + 1);
}
else
{
*v16 = *(_OWORD *)Block;
v16[1] = v25;
v17 = 15;
LOBYTE(Block[0]) = 0;
a4[1] += 32;
}
if ( v17 <= 0xF )
{
v20 = -1;
do
++v20;
while ( a3[v20] );
v7 = v12 + v20;
}
else
{
v18 = Block[0];
if ( v17 + 1 >= 0x1000 )
{
v18 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v18 - 8) > 0x1F )
goto LABEL_33;
}
j_j_free_0(v18);
v19 = -1;
do
++v19;
while ( a3[v19] );
v7 = v12 + v19;
}
}
v25 = 0u;
if ( v11 < v7 )
LABEL_36:
std::vector::_Xlen();
if ( v10 > 0xF )
a2 = (__int64 *)*a2;
sub_18000CE60(Block, (char *)a2 + v7, v11 - v7);
v21 = (_OWORD *)a4[1];
if ( v21 == (_OWORD *)a4[2] )
{
sub_18000D000(a4, (__int64)v21, (__int64)Block);
v22 = *((_QWORD *)&v25 + 1);
}
else
{
*v21 = *(_OWORD *)Block;
v21[1] = v25;
LOBYTE(Block[0]) = 0;
a4[1] += 32;
v22 = 15;
}
if ( v22 > 0xF )
{
v23 = Block[0];
if ( v22 + 1 >= 0x1000 )
{
v23 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v23 - 8) > 0x1F )
LABEL_33:
invalid_parameter_noinfo_noreturn();
}
j_j_free_0(v23);
}
}