//
// sub_1006E4EB0 from 0x1006e4eb0 to 0x1006e5005 (341 bytes)
//
// 3 xrefs:
// > KeybindingsLayer::settingsEntries @ 0x1006e47a7
// > sub_10091DEE0 @ 0x10091df41
// > LevelBindingsLayer::settingsEntries @ 0x10091efba
//
// 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:35:46 +0000
//
unsigned __int64 __fastcall sub_1006E4EB0(unsigned __int64 *a1, char *a2, __int64 a3, unsigned __int64 a4)
{
char *v6; // rdi
__int64 v7; // rax
unsigned __int64 v8; // r12
unsigned __int64 v9; // rax
__int64 v10; // r13
unsigned __int64 result; // rax
char *v12; // r12
size_t v13; // r14
size_t v14; // rdx
char *v15; // r13
size_t v16; // r14
v6 = (char *)*a1;
v7 = a1[2];
if ( 0xAAAAAAAAAAAAAAABLL * ((v7 - (__int64)v6) >> 4) < a4 )
{
if ( v6 )
{
a1[1] = (unsigned __int64)v6;
v8 = a4;
operator delete(v6);
a4 = v8;
*(_OWORD *)a1 = 0;
a1[2] = 0;
v7 = 0;
}
if ( a4 > 0x555555555555555LL )
goto LABEL_22;
v9 = 0xAAAAAAAAAAAAAAABLL * (v7 >> 4);
if ( 2 * v9 > a4 )
a4 = 2 * v9;
if ( v9 >= 0x2AAAAAAAAAAAAAALL )
a4 = 0x555555555555555LL;
if ( a4 > 0x555555555555555LL )
LABEL_22:
sub_1006E5010(v6);
v10 = 48 * a4;
result = (unsigned __int64)operator new(48 * a4);
v12 = (char *)result;
*a1 = result;
a1[1] = result;
a1[2] = result + v10;
v13 = a3 - (_QWORD)a2;
if ( v13 )
result = (unsigned __int64)memcpy((void *)result, a2, v13);
LABEL_17:
a1[1] = (unsigned __int64)&v12[v13];
return result;
}
v12 = (char *)a1[1];
v14 = v12 - v6;
result = 0xAAAAAAAAAAAAAAABLL * ((v12 - v6) >> 4);
if ( result < a4 )
{
v15 = &a2[v14];
if ( v12 != v6 )
{
result = (unsigned __int64)memmove(v6, a2, v14);
v12 = (char *)a1[1];
}
v13 = a3 - (_QWORD)v15;
if ( v13 )
result = (unsigned __int64)memmove(v12, v15, v13);
goto LABEL_17;
}
v16 = a3 - (_QWORD)a2;
if ( v16 )
result = (unsigned __int64)memmove(v6, a2, v16);
a1[1] = (unsigned __int64)&v6[v16];
return result;
}