//
// sub_100428350 from 0x100428350 to 0x100428469 (281 bytes)
//
// 2 xrefs:
// > sub_1004273E0 @ 0x1004279d8
// > sub_1004273E0 @ 0x1004279f7
//
// 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:30:18 +0000
//
unsigned __int64 __fastcall sub_100428350(unsigned __int64 *a1, char *a2, __int64 a3, unsigned __int64 a4)
{
char *v6; // rdi
unsigned __int64 result; // rax
unsigned __int64 v8; // r15
size_t v9; // r12
char *v10; // r15
size_t v11; // r14
size_t v12; // rdx
char *v13; // r12
size_t v14; // r14
v6 = (char *)*a1;
result = a1[2];
if ( result - (unsigned __int64)v6 < a4 )
{
if ( v6 )
{
a1[1] = (unsigned __int64)v6;
v8 = a4;
operator delete(v6);
a4 = v8;
*(_OWORD *)a1 = 0;
a1[2] = 0;
result = 0;
}
if ( (a4 & 0x8000000000000000LL) != 0LL )
sub_1000A32E0();
if ( 2 * result > a4 )
a4 = 2 * result;
v9 = 0x7FFFFFFFFFFFFFFFLL;
if ( result < 0x3FFFFFFFFFFFFFFFLL )
v9 = a4;
result = (unsigned __int64)operator new(v9);
v10 = (char *)result;
*a1 = result;
a1[1] = result;
a1[2] = result + v9;
v11 = a3 - (_QWORD)a2;
if ( v11 )
result = (unsigned __int64)memcpy((void *)result, a2, v11);
LABEL_16:
a1[1] = (unsigned __int64)&v10[v11];
return result;
}
v10 = (char *)a1[1];
v12 = v10 - v6;
if ( v10 - v6 < a4 )
{
v13 = &a2[v12];
if ( v10 != v6 )
{
result = (unsigned __int64)memmove(v6, a2, v12);
v10 = (char *)a1[1];
}
v11 = a3 - (_QWORD)v13;
if ( v11 )
result = (unsigned __int64)memmove(v10, v13, v11);
goto LABEL_16;
}
v14 = a3 - (_QWORD)a2;
if ( v14 )
result = (unsigned __int64)memmove(v6, a2, v14);
a1[1] = (unsigned __int64)&v6[v14];
return result;
}