int FUN_004031d8(code *param_1,undefined4 param_2,uint param_3)
{
int *piVar1;
ssize_t sVar2;
char *pcVar3;
uint __nbytes;
__fd_mask *__buf;
int iVar4;
int iVar5;
timeval local_4c0;
undefined4 local_4b8;
int local_4b4;
uint local_4a8 [32];
char local_428 [1024];
local_4b8 = 2;
local_4b4 = sobj_new();
iVar5 = -1;
if (local_4b4 != 0) {
iVar5 = 0;
LAB_0040332c:
do {
__buf = (__fd_mask *)local_4a8;
if (param_3 == 0) {
LAB_00403334:
(*param_1)(param_2,&local_4b8);
goto LAB_0040334c;
}
do {
*__buf = 0;
__buf = __buf + 1;
} while (__buf != (__fd_mask *)local_428);
local_4a8[0] = local_4a8[0] | 1;
local_4c0.tv_usec = 0;
local_4c0.tv_sec = 5;
iVar5 = select(1,(fd_set *)local_4a8,(fd_set *)0x0,(fd_set *)0x0,&local_4c0);
if (-1 < iVar5) {
if (iVar5 != 0) {
__nbytes = param_3;
if (0x400 < param_3) {
__nbytes = 0x400;
}
sVar2 = read(0,__buf,__nbytes) //possible issue identified - semgrep
if (-1 < sVar2) {
iVar4 = 0;
pcVar3 = local_428;
if (sVar2 == 0) goto LAB_00403334;
do {
iVar4 = iVar4 + 1;
sobj_add_char(local_4b4,(int)*pcVar3);
pcVar3 = local_428 + iVar4;
} while (iVar4 < sVar2);
param_3 = param_3 - sVar2;
goto LAB_0040332c;
}
}
iVar5 = -1;
goto LAB_0040334c;
}
piVar1 = __errno_location();
} while (*piVar1 == 4);
iVar5 = -1;
LAB_0040334c:
if (local_4b4 != 0) {
sobj_del();
}
}
return iVar5;
}