//
// sub_1004F6BB0 from 0x1004f6bb0 to 0x1004f6d4e (414 bytes)
//
// 2 xrefs:
// > GameToolbox::stringSetupToMap @ 0x1004ed666
// > sub_100980010 @ 0x100980161
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:31:27 +0000
//
char *__fastcall sub_1004F6BB0(__int64 **a1, unsigned __int8 *a2, __int64 a3, _BYTE **a4)
{
__int64 *v4; // rax
unsigned int v5; // r15d
size_t v6; // r15
const void *v7; // rbx
__int64 *v8; // r12
__int64 *v9; // r13
unsigned int v10; // r14d
size_t v11; // r14
const void *v12; // r12
size_t v13; // r13
int v14; // eax
bool v15; // cl
int v16; // eax
bool v17; // cl
char *v18; // r14
_QWORD *v19; // rdi
_BYTE *v20; // rax
__int64 *v21; // rax
__int64 *v25; // [rsp+30h] [rbp-30h]
v4 = a1[1];
if ( v4 )
{
v5 = *a2;
if ( (v5 & 1) != 0 )
{
v6 = *((_QWORD *)a2 + 1);
v7 = *((const void **)a2 + 2);
}
else
{
v6 = v5 >> 1;
v7 = a2 + 1;
}
while ( 1 )
{
while ( 1 )
{
v10 = *((unsigned __int8 *)v4 + 32);
v25 = v4;
if ( (v10 & 1) != 0 )
{
v11 = v4[5];
v12 = (const void *)v4[6];
}
else
{
v11 = v10 >> 1;
v12 = (char *)v4 + 33;
}
v13 = v6;
if ( v11 < v6 )
v13 = v11;
v14 = memcmp(v7, v12, v13);
v15 = v6 < v11;
if ( v14 )
v15 = v14 < 0;
if ( !v15 )
break;
v9 = v25;
v4 = (__int64 *)*v25;
v8 = v25;
if ( !*v25 )
goto LABEL_20;
}
v16 = memcmp(v12, v7, v13);
v17 = v11 < v6;
if ( v16 )
v17 = v16 < 0;
if ( !v17 )
return (char *)v25;
v9 = v25;
v4 = (__int64 *)v25[1];
if ( !v4 )
{
v8 = v25 + 1;
goto LABEL_20;
}
}
}
else
{
v8 = (__int64 *)(a1 + 1);
v9 = (__int64 *)(a1 + 1);
LABEL_20:
v18 = (char *)operator new(0x50u);
v19 = v18 + 32;
v20 = *a4;
if ( (**a4 & 1) != 0 )
{
sub_10001AD30(v19, *((const void **)v20 + 2), *((_QWORD *)v20 + 1));
}
else
{
*((_QWORD *)v18 + 6) = *((_QWORD *)v20 + 2);
*(_OWORD *)v19 = *(_OWORD *)v20;
}
*(_OWORD *)(v18 + 56) = 0;
*((_QWORD *)v18 + 9) = 0;
*(_OWORD *)v18 = 0;
*((_QWORD *)v18 + 2) = v9;
*v8 = (__int64)v18;
v21 = (__int64 *)**a1;
if ( v21 )
*a1 = v21;
sub_10001B680(a1[1], (__int64 *)v18);
a1[2] = (__int64 *)((char *)a1[2] + 1);
}
return v18;
}