//
// sub_180042EC0 from 0x180042ec0 to 0x18004305d (413 bytes)
//
// 2 xrefs:
// > sub_180047E40 @ 0x180048086
// > ??> @ 0x1801f80d0
//
// 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
//
__int64 __fastcall sub_180042EC0(void **a1, int a2, unsigned int a3, unsigned int a4, unsigned int a5)
{
unsigned __int64 v9; // rsi
void *v10; // rdi
size_t v11; // rcx
void *v12; // rax
unsigned int v13; // ecx
char *v14; // rdi
unsigned int v15; // ebp
char *v16; // rdx
void **v17; // rcx
char *v18; // rdi
unsigned __int64 v19; // rbp
v9 = a3 * a4 * (unsigned __int64)a5;
if ( a3 > 0xFFFFFFFFFFFFFFFFuLL / a5 || a3 * (unsigned __int64)a5 > 0xFFFFFFFFFFFFFFFFuLL / a4 )
return 0;
if ( (unsigned __int64)a1[12] < v9 )
{
v10 = j__realloc_base(a1[11], a3 * a4 * (unsigned __int64)a5);
if ( v10 )
goto LABEL_8;
free(a1[11]);
v11 = 1;
if ( v9 )
v11 = v9;
v12 = j__malloc_base(v11);
a1[11] = v12;
if ( v12 )
{
LABEL_8:
a1[11] = v10;
a1[12] = (void *)v9;
goto LABEL_9;
}
return 0;
}
LABEL_9:
sub_180043940((unsigned int)a1[11], a2, a3, a4, a5);
v13 = *((_DWORD *)a1 + 20);
v14 = (char *)a1[11];
*((_DWORD *)a1 + 20) = v13 + v9;
if ( v13 + (unsigned int)v9 < v13 )
++*((_DWORD *)a1 + 21);
v15 = 64 - (v13 & 0x3F);
v16 = v14;
v17 = (void **)((char *)a1 - v15 + 64);
if ( v15 <= (unsigned int)v9 )
{
memmove(v17, v14, v15);
sub_180043150(a1 + 8, a1);
v18 = &v14[v15];
LODWORD(v9) = v9 - v15;
if ( (unsigned int)v9 >= 0x40 )
{
v19 = (unsigned __int64)(unsigned int)v9 >> 6;
do
{
*(_OWORD *)a1 = *(_OWORD *)v18;
*((_OWORD *)a1 + 1) = *((_OWORD *)v18 + 1);
*((_OWORD *)a1 + 2) = *((_OWORD *)v18 + 2);
*((_OWORD *)a1 + 3) = *((_OWORD *)v18 + 3);
sub_180043150(a1 + 8, a1);
v18 += 64;
LODWORD(v9) = v9 - 64;
--v19;
}
while ( v19 );
}
v16 = v18;
v17 = a1;
}
memmove(v17, v16, (unsigned int)v9);
return 1;
}