//
// sub_509D8 from 0x509d8 to 0x50a68 (144 bytes)
//
// 2 xrefs:
// > ??> @ 0x509d6
// > sub_50AA4 @ 0x50b36
//
// 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_509D8(int fd)
{
int v2; // r0
bool v3; // zf
int result; // r0
int v5; // [sp+8h] [bp-18h] BYREF
int v6; // [sp+Ch] [bp-14h] BYREF
int v7; // [sp+10h] [bp-10h] BYREF
int optval; // [sp+14h] [bp-Ch] BYREF
optval = 1;
if ( setsockopt(fd, 1, 9, &optval, 4) == -1 )
return 43;
v7 = 10;
if ( setsockopt(fd, 6, 6, &v7, 4) == -1 )
return 43;
v2 = dword_ED604 / v7 / 1000;
if ( dword_ED604 / v7 < 2000 )
v2 = 1;
v6 = v2;
if ( setsockopt(fd, 6, 4, &v6, 4) == -1 )
return 43;
v5 = v6;
v3 = setsockopt(fd, 6, 5, &v5, 4) == -1;
result = 0;
if ( v3 )
return 43;
return result;
}