//
// RAND_poll from 0x8bd7d4 to 0x8bda04 (560 bytes)
//
// 4 xrefs:
// > sub_8BC4F8 @ 0x8bc60c
// > sub_8BC4F8 @ 0x8bc634
// > sub_8BCB18 @ 0x8bd56c
// > ??> @ 0x6b4cc
//
// 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 RAND_poll()
{
unsigned int v0; // r11
signed int v1; // r8
int v2; // r0
int v3; // r5
_BOOL4 v4; // r3
ssize_t v6; // r0
struct stat *buf; // [sp+0h] [bp-17Ch]
__pid_t v8; // [sp+14h] [bp-168h]
struct pollfd v9; // [sp+18h] [bp-164h] BYREF
_BYTE v10[32]; // [sp+20h] [bp-15Ch] BYREF
_QWORD v11[39]; // [sp+40h] [bp-13Ch] BYREF
v0 = 0;
v1 = 0;
v8 = getpid();
memset(v11, 0, sizeof(v11));
buf = (struct stat *)v11;
do
{
v2 = open(off_A3A510[v0], 2304);
v3 = v2;
if ( v2 >= 0 )
{
if ( !fstat(v2, buf)
&& (!v0
|| (v11[12] != *((_QWORD *)buf + 12) || v11[0] != *(_QWORD *)buf)
&& (v0 != 2 || *((_QWORD *)buf + 12) != v11[25] || v11[13] != v11[26])) )
{
v9.fd = v3;
v9.events = 1;
v9.revents = 0;
if ( poll(&v9, 1u, 10) >= 0 && (v9.revents & 1) != 0 && (v6 = read(v3, &v10[v1], 32 - v1), v6 > 0) )
{
v1 += v6;
}
else if ( *(_DWORD *)_errno() != 4 )
{
_errno();
}
}
close(v3);
}
++v0;
v4 = v1 <= 31;
if ( v0 > 2 )
v4 = 0;
buf = (struct stat *)((char *)buf + 104);
}
while ( v4 );
if ( v1 )
{
RAND_add((int)v10, 32, COERCE_UNSIGNED_INT64((double)v1), HIDWORD(COERCE_UNSIGNED_INT64((double)v1)));
OPENSSL_cleanse(v10, v1);
}
v9.fd = v8;
RAND_add((int)&v9, 4, 0, 0);
v9.fd = getuid();
RAND_add((int)&v9, 4, 0, 0);
v9.fd = time(nullptr);
RAND_add((int)&v9, 4, 0, 0);
return 1;
}