//
// sub_18001B0B0 from 0x18001b0b0 to 0x18001b303 (595 bytes)
//
// 5 xrefs:
// > DS_Dictionary::saveRootSubDictToCompressedFile @ 0x18001d524
// > DS_Dictionary::saveRootSubDictToCompressedFile @ 0x18001d556
// > DS_Dictionary::saveRootSubDictToFile @ 0x18001dd14
// > DS_Dictionary::saveRootSubDictToFile @ 0x18001dd46
// > ??> @ 0x1801aea40
//
// 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
char *__fastcall sub_18001B0B0(char *a1, _BYTE *a2, _BYTE *a3, _BYTE *a4)
{
char *v7; // rbx
size_t v8; // rdi
size_t v9; // r8
size_t v10; // r8
size_t v11; // rdi
void **v12; // r13
void **v13; // rsi
char *v14; // r12
size_t v15; // rax
size_t v16; // rax
char *v17; // rbp
int v18; // r15d
char *v19; // rbx
void *v20; // rcx
void **v21; // r9
void **v22; // rax
void *Block[2]; // [rsp+40h] [rbp-98h] BYREF
__int64 v25; // [rsp+50h] [rbp-88h]
unsigned __int64 v26; // [rsp+58h] [rbp-80h]
void *Buf2[2]; // [rsp+60h] [rbp-78h] BYREF
size_t Size; // [rsp+70h] [rbp-68h]
unsigned __int64 v29; // [rsp+78h] [rbp-60h]
v7 = nullptr;
*(_OWORD *)a1 = 0;
*((_QWORD *)a1 + 2) = 0;
*((_QWORD *)a1 + 3) = 0;
v8 = -1;
v9 = -1;
do
++v9;
while ( a2[v9] );
sub_18000CE60(a1, a2, v9);
*(_OWORD *)Buf2 = 0;
Size = 0;
v29 = 0;
v10 = -1;
do
++v10;
while ( a3[v10] );
sub_18000CE60(Buf2, a3, v10);
*(_OWORD *)Block = 0;
v25 = 0;
v26 = 0;
do
++v8;
while ( a4[v8] );
sub_18000CE60(Block, a4, v8);
v11 = Size;
v12 = (void **)Buf2[0];
while ( 1 )
{
v13 = Buf2;
if ( v29 > 0xF )
v13 = v12;
v14 = a1;
if ( *((_QWORD *)a1 + 3) > 0xFu )
v14 = *(char **)a1;
v15 = *((_QWORD *)a1 + 2);
if ( v11 > v15 )
break;
v16 = v15 - v11;
if ( (unsigned __int64)v7 > v16 )
break;
if ( v11 )
{
v17 = &v14[v16];
v18 = *(char *)v13;
v19 = (char *)memchr(&v7[(_QWORD)v14], v18, v16 + 1 - (_QWORD)v7);
if ( !v19 )
break;
while ( memcmp(v19, v13, v11) )
{
v19 = (char *)memchr(v19 + 1, v18, v17 - v19);
if ( !v19 )
goto LABEL_18;
}
v7 = (char *)(v19 - v14);
}
if ( v7 == (char *)-1LL )
break;
v21 = Block;
if ( v26 > 0xF )
v21 = (void **)Block[0];
sub_18001D1C0(a1, v7, v11, v21, v25);
v7 += v25;
}
LABEL_18:
if ( v26 > 0xF )
{
v20 = Block[0];
if ( v26 + 1 >= 0x1000 )
{
v20 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v20 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free_0(v20);
}
if ( v29 > 0xF )
{
v22 = v12;
if ( v29 + 1 >= 0x1000 )
{
v12 = (void **)*(v12 - 1);
if ( (unsigned __int64)((char *)v22 - (char *)v12 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free_0(v12);
}
return a1;
}