//
// sub_180040E10 from 0x180040e10 to 0x180040ee7 (215 bytes)
//
// 5 xrefs:
// > sub_18003DC70 @ 0x18003dd95
// > sub_18003DC70 @ 0x18003dda5
// > sub_18003E5C0 @ 0x18003e6e5
// > sub_18003E5C0 @ 0x18003e6f5
// > ??> @ 0x1801bb4a0
//
// 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 11:21:38 +0000
//
char *__fastcall sub_180040E10(__int64 *a1, const void *a2, size_t a3, unsigned int *a4)
{
size_t v4; // rax
__int64 v6; // r14
unsigned int v10; // edx
char *v11; // rbx
int v12; // ecx
__int64 v13; // rax
v4 = *a4;
v6 = *a1;
if ( v4 <= a3 )
{
sub_180044BB0(a1, v6 + a3);
v11 = (char *)(v6 + a1[2]);
}
else
{
sub_180044BB0(a1, v6 + v4);
v10 = a4[2];
v11 = (char *)(v6 + a1[2]);
v12 = *((unsigned __int8 *)a4 + 4);
v13 = *a4;
if ( v10 == 2 )
{
if ( (unsigned int)v13 != a3 )
memset(v11, v12, (unsigned int)v13 - a3);
v11 += *a4 - a3;
}
else if ( v10 == 3 )
{
v11 = (char *)fmt::BasicWriter::FillPadding(v11, (unsigned int)v13, a3, (unsigned int)(char)v12);
}
else if ( v13 != a3 )
{
memset(&v11[a3], v12, v13 - a3);
}
}
memmove(v11, a2, a3);
return v11;
}