//
// sub_1000C6280 from 0x1000c6280 to 0x1000c63dc (348 bytes)
//
// 2 xrefs:
// > sub_1000BB8C0 @ 0x1000bbff4
// > sub_1000BB8C0 @ 0x1000bc01c
//
// 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
//
unsigned __int64 __fastcall sub_1000C6280(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
__int64 v13; // r14
signed __int64 v14; // rdx
char *v15; // r13
__int64 v16; // r14
v6 = (char *)*a1;
v7 = a1[2];
if ( 0xAAAAAAAAAAAAAAABLL * ((v7 - (__int64)v6) >> 5) < 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 > 0x2AAAAAAAAAAAAAALL )
goto LABEL_22;
v9 = 0xAAAAAAAAAAAAAAABLL * (v7 >> 5);
if ( 2 * v9 > a4 )
a4 = 2 * v9;
if ( v9 >= 0x155555555555555LL )
a4 = 0x2AAAAAAAAAAAAAALL;
if ( a4 > 0x2AAAAAAAAAAAAAALL )
LABEL_22:
sub_1000C63E0(v6);
v10 = 96 * a4;
result = (unsigned __int64)operator new(96 * 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 - 4);
LABEL_17:
a1[1] = (unsigned __int64)&v12[v13];
return result;
}
v12 = (char *)a1[1];
v14 = v12 - v6;
result = 0xAAAAAAAAAAAAAAABLL * ((v12 - v6) >> 5);
if ( result < a4 )
{
v15 = &a2[v14];
if ( v12 != v6 )
{
result = (unsigned __int64)memmove(v6, a2, v14 - 4);
v12 = (char *)a1[1];
}
v13 = a3 - (_QWORD)v15;
if ( v13 )
result = (unsigned __int64)memmove(v12, v15, v13 - 4);
goto LABEL_17;
}
v16 = a3 - (_QWORD)a2;
if ( v16 )
result = (unsigned __int64)memmove(v6, a2, v16 - 4);
a1[1] = (unsigned __int64)&v6[v16];
return result;
}