//
// sub_50D52 from 0x50d52 to 0x50da8 (86 bytes)
//
// 3 xrefs:
// > sub_6B444 @ 0x6b474
// > sub_6B444 @ 0x6b52e
// > sub_BE070 @ 0xbe09e
//
// 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
//
int __fastcall sub_50D52(int fd, char *buf, size_t n, _DWORD *a4)
{
ssize_t v8; // r0
int result; // r0
int v10; // r1
for ( *a4 = 0; ; *a4 += v8 )
{
if ( !n )
return 0;
v8 = recv(fd, buf, n, 0);
if ( !v8 )
return 16;
if ( v8 == -1 )
break;
buf += v8;
n -= v8;
}
v10 = *(_DWORD *)_errno(-1, 0);
result = 43;
if ( v10 == 104 )
result = 16;
if ( v10 == 11 )
return 45;
return result;
}