//
// sub_632F78 from 0x632f78 to 0x63309c (292 bytes)
//
// 4 xrefs:
// > sub_627910 @ 0x627a3e
// > sub_627C48 @ 0x627d44
// > sub_627C48 @ 0x6282e2
// > sub_62F1BC @ 0x62f4e2
//
// 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_632F78(struct pollfd *fds, nfds_t nfds, int a3)
{
int v3; // r3
int v7; // r2
int v8; // r3
bool v9; // zf
struct pollfd *v10; // r1
struct pollfd *v11; // r3
__int16 revents; // r2
char v13; // r4
__int16 v14; // r2
int v15; // r3
bool v16; // zf
int result; // r0
int v18; // r3
bool v19; // zf
__time_t v20[2]; // [sp+0h] [bp-30h] BYREF
__time_t v21[10]; // [sp+8h] [bp-28h] BYREF
if ( !fds || !nfds )
return sub_632D00(a3);
if ( fds->fd == -1 )
{
v3 = 0;
while ( ++v3 != nfds )
{
if ( fds[v3].fd != -1 )
goto LABEL_8;
}
return sub_632D00(a3);
}
LABEL_8:
if ( a3 <= 0 )
{
if ( a3 )
{
while ( 1 )
{
result = poll(fds, nfds, -1);
if ( result != -1 )
break;
v18 = *(_DWORD *)_errno();
if ( v18 )
{
v19 = dword_ACAEC0 == 0;
if ( !dword_ACAEC0 )
v19 = v18 == 4;
if ( !v19 )
return -1;
}
}
}
else
{
while ( 1 )
{
result = poll(fds, nfds, 0);
if ( result != -1 )
break;
v15 = *(_DWORD *)_errno();
if ( v15 )
{
v16 = dword_ACAEC0 == 0;
if ( !dword_ACAEC0 )
v16 = v15 == 4;
if ( !v16 )
return -1;
}
}
}
}
else
{
sub_60F990(v20);
v7 = a3;
while ( 1 )
{
result = poll(fds, nfds, v7);
if ( result != -1 )
break;
v8 = *(_DWORD *)_errno();
if ( v8 )
{
v9 = dword_ACAEC0 == 0;
if ( !dword_ACAEC0 )
v9 = v8 == 4;
if ( !v9 )
return -1;
}
sub_60F990(v21);
v7 = a3 - sub_60F9D8(v21[0], v21[1], v20[0], v20[1]);
if ( v7 <= 0 )
return 0;
}
}
if ( result < 0 )
return -1;
if ( !result )
return 0;
v10 = &fds[nfds];
v11 = fds;
do
{
if ( v11->fd != -1 )
{
revents = v11->revents;
v13 = revents;
if ( (revents & 0x10) != 0 )
{
revents |= 1u;
v11->revents = revents;
v13 = revents;
}
v14 = revents | 5;
if ( (v13 & 8) != 0 )
v11->revents = v14;
}
++v11;
}
while ( v11 != v10 );
return result;
}