//
// sub_18004C090 from 0x18004c090 to 0x18004c145 (181 bytes)
//
// 4 xrefs:
// > sub_180050C10 @ 0x180050cb8
// > sub_180053230 @ 0x1800532ba
// > sub_180053530 @ 0x1800535b7
// > ??> @ 0x1801f85bc
//
// 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_18004C090(__int64 a1, __int64 a2, int a3)
{
int v3; // eax
__int64 v7; // rdx
size_t v8; // r8
int v9; // ecx
unsigned int v10; // edi
__int64 v11; // rax
v3 = *(_DWORD *)(a2 + 8);
if ( v3 < 0 )
return 0;
v7 = *(int *)(a2 + 16);
if ( (_DWORD)v7 )
{
*(_DWORD *)(a2 + 12) -= v7;
v8 = *(int *)(a2 + 12);
if ( (int)v8 > 0 )
{
memmove(*(void **)a2, (const void *)(*(_QWORD *)a2 + v7), v8);
v3 = *(_DWORD *)(a2 + 8);
}
*(_DWORD *)(a2 + 16) = 0;
}
v9 = *(_DWORD *)(a2 + 12);
if ( a3 > v3 - v9 )
{
v10 = v9 + a3 + 4096;
if ( *(_QWORD *)a2 )
v11 = sub_180033D20(a1, *(_QWORD *)a2, v10);
else
v11 = sub_180033CC0(a1, v10);
if ( !v11 )
{
*(_OWORD *)a2 = 0;
*(_OWORD *)(a2 + 16) = 0;
return 0;
}
v9 = *(_DWORD *)(a2 + 12);
*(_QWORD *)a2 = v11;
*(_DWORD *)(a2 + 8) = v10;
}
return *(_QWORD *)a2 + v9;
}