//
// sub_1004D9A00 from 0x1004d9a00 to 0x1004d9ad0 (208 bytes)
//
// 2 xrefs:
// > sub_1004EBF30 @ 0x1004ebfd0
// > sub_1004ECD60 @ 0x1004ecdfc
//
// 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
//
double __fastcall sub_1004D9A00(__int64 a1, __int64 a2, int a3)
{
int v3; // w8
__int64 v7; // x9
size_t v8; // x2
double result; // d0
int v10; // w9
int v11; // w8
int v12; // w21
__int64 v13; // x0
v3 = *(_DWORD *)(a2 + 8);
if ( (v3 & 0x80000000) == 0 )
{
v7 = *(int *)(a2 + 16);
if ( (_DWORD)v7 )
{
v8 = (unsigned int)(*(_DWORD *)(a2 + 12) - v7);
*(_DWORD *)(a2 + 12) = v8;
if ( (int)v8 >= 1 )
{
memmove(*(void **)a2, (const void *)(*(_QWORD *)a2 + v7), v8);
v3 = *(_DWORD *)(a2 + 8);
}
*(_DWORD *)(a2 + 16) = 0;
}
v10 = *(_DWORD *)(a2 + 12);
if ( v3 - v10 < a3 )
{
v11 = a3 + v10;
v12 = a3 + v10 + 4096;
if ( *(_QWORD *)a2 )
{
v13 = sub_100478D28(a1, *(_QWORD *)a2, (unsigned int)(v11 + 4096));
if ( v13 )
{
LABEL_9:
*(_QWORD *)a2 = v13;
*(_DWORD *)(a2 + 8) = v12;
return result;
}
}
else
{
v13 = sub_100478C6C(a1, (unsigned int)(v11 + 4096));
if ( v13 )
goto LABEL_9;
}
*(_OWORD *)a2 = 0u;
*(_OWORD *)(a2 + 16) = 0u;
return 0.0;
}
}
return result;
}