//
// sub_1005DC200 from 0x1005dc200 to 0x1005dc358 (344 bytes)
//
// 1 xrefs:
// > ??> @ 0x100861128
//
// 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_1005DC200(__int64 a1, char *a2, __int64 a3)
{
char *v4; // x22
unsigned int *v6; // x24
__int64 v7; // x19
int i; // w23
int v9; // w25
unsigned int v10; // w9
__int64 v11; // x2
__int64 v12; // x0
unsigned int v13; // w8
v4 = a2;
if ( !a2 )
return 0;
v6 = *(unsigned int **)(a1 + 48);
if ( !v6 )
return 0;
if ( !*(_QWORD *)(a1 + 56) )
return 0;
sub_1005DA600(a1, 15);
LODWORD(v7) = 0;
for ( i = v6[4]; ; *((_QWORD *)v6 + 2) = (unsigned int)i )
{
if ( i )
{
if ( i <= (int)a3 )
v9 = i;
else
v9 = a3;
memcpy(v4, (const void *)(*((_QWORD *)v6 + 1) + (int)v6[5]), v9);
v10 = v6[5] + v9;
v6[4] -= v9;
v6[5] = v10;
v7 = (unsigned int)(v9 + v7);
if ( (_DWORD)a3 == v9 )
return v7;
a3 = (unsigned int)(a3 - v9);
v4 += v9;
}
v11 = *v6;
v12 = *(_QWORD *)(a1 + 56);
if ( (int)a3 > (int)v11 )
break;
i = sub_1005DA62C(v12, *((_QWORD *)v6 + 1), v11);
if ( i <= 0 )
goto LABEL_21;
}
i = sub_1005DA62C(v12, (__int64)v4, a3);
if ( i <= 0 )
{
LABEL_21:
sub_1005DB0A8(a1);
if ( (int)v7 <= 0 )
v13 = i;
else
v13 = v7;
if ( i < 0 )
return v13;
else
return (unsigned int)v7;
}
while ( 1 )
{
v7 = (unsigned int)(i + v7);
a3 = (unsigned int)(a3 - i);
if ( !(_DWORD)a3 )
return v7;
v4 += i;
i = sub_1005DA62C(*(_QWORD *)(a1 + 56), (__int64)v4, a3);
if ( i < 1 )
goto LABEL_21;
}
}