//
// sub_1005DB278 from 0x1005db278 to 0x1005db33c (196 bytes)
//
// 2 xrefs:
// > sub_1005DB370 @ 0x1005db3dc
// > ??> @ 0x100860fe8
//
// 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_1005DB278(__int64 a1, void *a2, __int64 a3)
{
size_t *v6; // x23
unsigned __int64 v7; // x8
char *v8; // x0
size_t v9; // x2
char *v10; // x1
v6 = *(size_t **)(a1 + 48);
sub_1005DA600(a1, 15);
if ( (a3 & 0x80000000) != 0 )
{
v7 = *v6;
}
else
{
v7 = *v6;
if ( (int)a3 <= *v6 )
a3 = (unsigned int)a3;
else
a3 = (unsigned int)v7;
if ( a2 && (int)a3 >= 1 )
{
memcpy(a2, (const void *)v6[1], (int)a3);
v8 = (char *)v6[1];
v9 = *v6 - (int)a3;
*v6 = v9;
v10 = &v8[(int)a3];
if ( (*(_BYTE *)(a1 + 33) & 2) != 0 )
v6[1] = (size_t)v10;
else
memmove(v8, v10, v9);
return a3;
}
}
if ( !v7 )
{
a3 = *(unsigned int *)(a1 + 40);
if ( (_DWORD)a3 )
sub_1005DA61C(a1, 9);
else
return 0;
}
return a3;
}