#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct timeval {
  int tv_sec;
  int tv_usec;
};
struct pollfd {
  int fd;
  int events;
  int revents;
};
typedef int pid_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int BUFSIZ;
scalar_t__ EAGAIN;
scalar_t__ EINTR;
int /*<<< orphan*/ F_GETFL;
int /*<<< orphan*/ F_SETFL;
int O_NONBLOCK;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ O_WRONLY;
int POLLIN;
int /*<<< orphan*/ WNOHANG;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ dup2(int, int);
scalar_t__ errno;
int /*<<< orphan*/ execl(char *, char *, char *, char *, char *, char *,
                         int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int fcntl(int, int /*<<< orphan*/, int);
int /*<<< orphan*/ *fdopen(int, char *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int fork();
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
scalar_t__ pipe(int *);
int poll(struct pollfd *, int, int);
int /*<<< orphan*/ strncmp(char *, char *, int);
int /*<<< orphan*/ waitpid(int, int /*<<< orphan*/ *, int /*<<< orphan*/);
long int _time_login(char *user_name) {
  FILE *su;
  char line[BUFSIZ];
  char name[BUFSIZ];
  char value[BUFSIZ];
  int fildes[2], found, fval, rc, timeleft;
  pid_t child;
  struct timeval begin, now;
  struct pollfd ufds;
  long int delta_t;
  if (pipe(fildes) < 0) {
    perror("pipe");
    return -1;
  }
  child = fork();
  if (child == -1) {
    perror("fork");
    return -1;
  }
  if (child == 0) {
    close(0);
    open("/dev/null", O_RDONLY);
    dup2(fildes[1], 1);
    close(2);
    open("/dev/null", O_WRONLY);
    execl("/bin/su", "su", "-", user_name, "-c", "echo; echo; echo HELLO",
          NULL);
    exit(1);
  }
  close(fildes[1]);
  if ((fval = fcntl(fildes[0], F_GETFL, 0)) >= 0)
    fcntl(fildes[0], F_SETFL, fval | O_NONBLOCK);
  su = fdopen(fildes[0], "r");
  gettimeofday(&begin, NULL);
  ufds.fd = fildes[0];
  ufds.events = POLLIN;
  found = 0;
  while (!found) {
    gettimeofday(&now, NULL);
    timeleft = 8000;
    timeleft -= (now.tv_sec - begin.tv_sec) * 1000;
    timeleft -= (now.tv_usec - begin.tv_usec) / 1000;
    if (timeleft <= 0)
      break;
    if ((rc = poll(&ufds, 1, timeleft)) <= 0) {
      if (rc == 0)
        break;
      if ((errno == EINTR) || (errno == EAGAIN))
        continue;
      perror("poll");
      break;
    }
    if (!(ufds.revents & POLLIN)) {
      perror("POLLERR|POLLHUP");
      break;
    }
    while (fgets(line, BUFSIZ, su)) {
      if (!strncmp(line, "HELLO", 5)) {
        found = 1;
        break;
      }
    }
  }
  close(fildes[0]);
  waitpid(-1, NULL, WNOHANG);
  delta_t = (now.tv_sec - begin.tv_sec) * 1000000;
  delta_t += now.tv_usec - begin.tv_usec;
  if (!found && (delta_t < (8000 * 1000)))
    return (8000 * 1000);
  return delta_t;
}


x86 assembly (clang, -O0):
<_time_login>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2db2(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x90(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
mov    0x2d83(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x30(%rbp)
mov    0x2d76(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x38(%rbp)
lea    -0x40(%rbp),%rdi
call   1080 <pipe@plt>
cmp    $0x0,%rax
jge    127e <_time_login+0x8e>
lea    0xd9e(%rip),%rdi
call   10e0 <perror@plt>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
movl   $0x1,-0x84(%rbp)
jmp    15ae <_time_login+0x3be>
mov    $0x0,%al
call   1110 <fork@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0xffffffff,-0x54(%rbp)
jne    12b5 <_time_login+0xc5>
lea    0xd6c(%rip),%rdi
call   10e0 <perror@plt>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
movl   $0x1,-0x84(%rbp)
jmp    15ae <_time_login+0x3be>
cmpl   $0x0,-0x54(%rbp)
jne    134f <_time_login+0x15f>
xor    %edi,%edi
call   1070 <close@plt>
mov    0x2d13(%rip),%rax
mov    (%rax),%esi
lea    0xd34(%rip),%rdi
call   10d0 <open@plt>
mov    -0x3c(%rbp),%edi
mov    $0x1,%esi
call   1050 <dup2@plt>
mov    $0x2,%edi
call   1070 <close@plt>
mov    0x2c97(%rip),%rax
mov    (%rax),%esi
lea    0xd08(%rip),%rdi
call   10d0 <open@plt>
mov    -0x10(%rbp),%rcx
lea    0xd02(%rip),%rdi
lea    0xd00(%rip),%rsi
lea    0xcfc(%rip),%rdx
lea    0xcf7(%rip),%r8
lea    0xcf3(%rip),%r9
xor    %eax,%eax
sub    $0x10,%rsp
movq   $0x0,(%rsp)
call   1100 <execl@plt>
add    $0x10,%rsp
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x3c(%rbp),%edi
call   1070 <close@plt>
mov    -0x40(%rbp),%edi
mov    0x2c47(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1040 <fcntl@plt>
mov    %eax,-0x48(%rbp)
cmp    $0x0,%eax
jl     1393 <_time_login+0x1a3>
mov    -0x40(%rbp),%edi
mov    0x2c40(%rip),%rax
mov    (%rax),%esi
mov    -0x48(%rbp),%edx
mov    0x2c5c(%rip),%rax
or     (%rax),%edx
call   1040 <fcntl@plt>
mov    -0x40(%rbp),%edi
lea    0xc9b(%rip),%rsi
call   10a0 <fdopen@plt>
mov    %rax,-0x18(%rbp)
lea    -0x60(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <gettimeofday@plt>
mov    -0x40(%rbp),%eax
mov    %eax,-0x78(%rbp)
mov    0x2c10(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x74(%rbp)
movl   $0x0,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    13e2 <_time_login+0x1f2>
jmp    152c <_time_login+0x33c>
lea    -0x68(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <gettimeofday@plt>
movl   $0x1f40,-0x50(%rbp)
mov    -0x68(%rbp),%eax
sub    -0x60(%rbp),%eax
imul   $0x3e8,%eax,%ecx
mov    -0x50(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x50(%rbp)
mov    -0x64(%rbp),%eax
sub    -0x5c(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x50(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x50(%rbp)
cmpl   $0x0,-0x50(%rbp)
jg     1431 <_time_login+0x241>
jmp    152c <_time_login+0x33c>
mov    -0x50(%rbp),%edx
lea    -0x78(%rbp),%rdi
mov    $0x1,%esi
call   10b0 <poll@plt>
mov    %eax,-0x4c(%rbp)
cmp    $0x0,%eax
jg     14a7 <_time_login+0x2b7>
cmpl   $0x0,-0x4c(%rbp)
jne    145d <_time_login+0x26d>
jmp    152c <_time_login+0x33c>
mov    0x2b4c(%rip),%rax
mov    (%rax),%rax
mov    0x2b32(%rip),%rcx
cmp    (%rcx),%rax
je     1491 <_time_login+0x2a1>
mov    0x2b32(%rip),%rax
mov    (%rax),%rax
mov    0x2b00(%rip),%rcx
cmp    (%rcx),%rax
jne    1496 <_time_login+0x2a6>
jmp    13cc <_time_login+0x1dc>
lea    0xb9d(%rip),%rdi
call   10e0 <perror@plt>
jmp    152c <_time_login+0x33c>
mov    -0x70(%rbp),%eax
mov    0x2b1f(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    14cd <_time_login+0x2dd>
lea    0xb7c(%rip),%rdi
call   10e0 <perror@plt>
jmp    152c <_time_login+0x33c>
jmp    14d2 <_time_login+0x2e2>
mov    -0x90(%rbp),%rdi
mov    0x2ad8(%rip),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rdx
call   1090 <fgets@plt>
cmp    $0x0,%rax
je     1527 <_time_login+0x337>
mov    -0x90(%rbp),%rdi
lea    0xb2f(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1522 <_time_login+0x332>
movl   $0x1,-0x44(%rbp)
jmp    1527 <_time_login+0x337>
jmp    14d2 <_time_login+0x2e2>
jmp    13cc <_time_login+0x1dc>
mov    -0x40(%rbp),%edi
call   1070 <close@plt>
mov    0x2a9d(%rip),%rax
mov    (%rax),%edx
mov    $0xffffffff,%edi
xor    %eax,%eax
mov    %eax,%esi
call   10c0 <waitpid@plt>
mov    -0x68(%rbp),%eax
sub    -0x60(%rbp),%eax
imul   $0xf4240,%eax,%eax
cltq
mov    %rax,-0x80(%rbp)
mov    -0x64(%rbp),%eax
sub    -0x5c(%rbp),%eax
cltq
add    -0x80(%rbp),%rax
mov    %rax,-0x80(%rbp)
cmpl   $0x0,-0x44(%rbp)
jne    159c <_time_login+0x3ac>
cmpq   $0x7a1200,-0x80(%rbp)
jge    159c <_time_login+0x3ac>
movq   $0x7a1200,-0x8(%rbp)
movl   $0x1,-0x84(%rbp)
jmp    15ae <_time_login+0x3be>
mov    -0x80(%rbp),%rax
mov    %rax,-0x8(%rbp)
movl   $0x1,-0x84(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x8(%rbp),%rax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_time_login>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdi,%r14
mov    0x2dad(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    -0x30(%rbp),%rdi
call   1080 <pipe@plt>
test   %rax,%rax
js     145e <_time_login+0x26e>
xor    %eax,%eax
call   1110 <fork@plt>
cmp    $0xffffffff,%eax
je     1467 <_time_login+0x277>
test   %eax,%eax
je     1490 <_time_login+0x2a0>
mov    -0x2c(%rbp),%edi
call   1070 <close@plt>
mov    -0x30(%rbp),%edi
mov    0x2d4e(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1040 <fcntl@plt>
test   %eax,%eax
js     1283 <_time_login+0x93>
mov    -0x30(%rbp),%edi
mov    0x2d4f(%rip),%rcx
mov    (%rcx),%esi
mov    0x2d6e(%rip),%rcx
or     (%rcx),%eax
mov    %eax,%edx
call   1040 <fcntl@plt>
mov    -0x30(%rbp),%edi
lea    0xdab(%rip),%rsi
call   10a0 <fdopen@plt>
mov    %rax,%r14
lea    -0x48(%rbp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    -0x30(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    0x2d23(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
mov    -0x48(%rbp),%r12d
mov    -0x44(%rbp),%eax
mov    %eax,-0x3c(%rbp)
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    -0x38(%rbp),%r15d
mov    -0x34(%rbp),%r13d
mov    %r12d,-0x40(%rbp)
sub    %r12d,%r15d
imul   $0xfffffc18,%r15d,%eax
sub    -0x3c(%rbp),%r13d
movslq %r13d,%rcx
imul   $0xffffffffef9db22d,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
lea    (%rax,%rcx,1),%edx
add    $0x1f40,%edx
mov    $0x1,%r12b
test   %edx,%edx
jle    140c <_time_login+0x21c>
lea    0xd1f(%rip),%r12
jmp    136a <_time_login+0x17a>
cs nopw 0x0(%rax,%rax,1)
nop
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    -0x38(%rbp),%r15d
mov    -0x34(%rbp),%r13d
sub    -0x40(%rbp),%r15d
imul   $0xfffffc18,%r15d,%eax
sub    -0x3c(%rbp),%r13d
movslq %r13d,%rcx
imul   $0xffffffffef9db22d,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
lea    (%rax,%rcx,1),%edx
add    $0x1f40,%edx
test   %edx,%edx
jle    1488 <_time_login+0x298>
lea    -0x58(%rbp),%rdi
mov    $0x1,%esi
call   10b0 <poll@plt>
test   %eax,%eax
jle    13d0 <_time_login+0x1e0>
mov    0x2c4d(%rip),%rax
mov    (%rax),%eax
test   %eax,-0x50(%rbp)
je     147c <_time_login+0x28c>
xchg   %ax,%ax
mov    0x2c21(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
mov    %r14,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     1320 <_time_login+0x130>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    1390 <_time_login+0x1a0>
jmp    1409 <_time_login+0x219>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
je     1488 <_time_login+0x298>
mov    0x2bd3(%rip),%rax
mov    (%rax),%rax
mov    0x2bb9(%rip),%rcx
cmp    (%rcx),%rax
je     1320 <_time_login+0x130>
mov    0x2b91(%rip),%rcx
cmp    (%rcx),%rax
je     1320 <_time_login+0x130>
lea    0xc33(%rip),%rdi
jmp    1483 <_time_login+0x293>
xor    %r12d,%r12d
mov    -0x30(%rbp),%edi
call   1070 <close@plt>
mov    0x2bbd(%rip),%rax
mov    (%rax),%edx
mov    $0xffffffff,%edi
xor    %esi,%esi
call   10c0 <waitpid@plt>
imul   $0xf4240,%r15d,%eax
cltq
movslq %r13d,%rcx
add    %rax,%rcx
cmp    $0x7a1200,%rcx
mov    $0x7a1200,%eax
cmovge %rcx,%rax
test   %r12b,%r12b
cmove  %rcx,%rax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xb9b(%rip),%rdi
jmp    146e <_time_login+0x27e>
lea    0xb97(%rip),%rdi
call   10e0 <perror@plt>
mov    $0xffffffffffffffff,%rax
jmp    144f <_time_login+0x25f>
lea    0xbbc(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%r12b
jmp    140c <_time_login+0x21c>
xor    %edi,%edi
call   1070 <close@plt>
mov    0x2b42(%rip),%rax
mov    (%rax),%esi
lea    0xb63(%rip),%rbx
mov    %rbx,%rdi
call   10d0 <open@plt>
mov    -0x2c(%rbp),%edi
mov    $0x1,%esi
call   1050 <dup2@plt>
mov    $0x2,%edi
call   1070 <close@plt>
mov    0x2ac3(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   10d0 <open@plt>
sub    $0x8,%rsp
lea    0xb32(%rip),%rdi
lea    0xb30(%rip),%rsi
lea    0xb2c(%rip),%rdx
lea    0xb27(%rip),%r8
lea    0xb23(%rip),%r9
mov    %r14,%rcx
push   $0x0
call   1100 <execl@plt>
add    $0x10,%rsp
mov    $0x1,%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
%struct.pollfd = type { i32, i32, i32 }
@BUFSIZ = global i32 0
@.str = [5 x i8] c"pipe\00"
@.str.1 = [5 x i8] c"fork\00"
@.str.2 = [10 x i8] c"/dev/null\00"
@O_RDONLY = global i32 0
@O_WRONLY = global i32 0
@.str.3 = [8 x i8] c"/bin/su\00"
@.str.4 = [3 x i8] c"su\00"
@.str.5 = [2 x i8] c"-\00"
@.str.6 = [3 x i8] c"-c\00"
@.str.7 = [23 x i8] c"echo; echo; echo HELLO\00"
@F_GETFL = global i32 0
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
@.str.8 = [2 x i8] c"r\00"
@POLLIN = global i32 0
@errno = global i64 0
@EINTR = global i64 0
@EAGAIN = global i64 0
@.str.9 = [5 x i8] c"poll\00"
@.str.10 = [16 x i8] c"POLLERR|POLLHUP\00"
@.str.11 = [6 x i8] c"HELLO\00"
@WNOHANG = global i32 0
define i64 @_time_login(i8* %0) {
%2 = alloca i64
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca [2 x i32]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca %struct.timeval
%16 = alloca %struct.timeval
%17 = alloca %struct.pollfd
%18 = alloca i64
%19 = alloca i32
store i8* %0, i8** %3
%20 = load i32, i32* @BUFSIZ
%21 = zext i32 %20 to i64
%22 = call i8* @llvm.stacksave()
store i8* %22, i8** %5
%23 = alloca i8, i64 %21
store i64 %21, i64* %6
%24 = load i32, i32* @BUFSIZ
%25 = zext i32 %24 to i64
%26 = alloca i8, i64 %25
store i64 %25, i64* %7
%27 = load i32, i32* @BUFSIZ
%28 = zext i32 %27 to i64
%29 = alloca i8, i64 %28
store i64 %28, i64* %8
%30 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%31 = call i64 @pipe(i32* %30)
%32 = icmp slt i64 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %1
%34 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i64 -1, i64* %2
store i32 1, i32* %19
br label %177
35: ; preds = %1
%36 = call i32 (...) @fork()
store i32 %36, i32* %14
%37 = load i32, i32* %14
%38 = icmp eq i32 %37, -1
br i1 %38, label %39, label %41
39: ; preds = %35
%40 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i64 -1, i64* %2
store i32 1, i32* %19
br label %177
41: ; preds = %35
%42 = load i32, i32* %14
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %57
44: ; preds = %41
%45 = call i32 @close(i32 0)
%46 = load i32, i32* @O_RDONLY
%47 = call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %46)
%48 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 1
%49 = load i32, i32* %48
%50 = call i32 @dup2(i32 %49, i32 1)
%51 = call i32 @close(i32 2)
%52 = load i32, i32* @O_WRONLY
%53 = call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %52)
%54 = load i8*, i8** %3
%55 = call i32 @execl(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* %54, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i32* null)
%56 = call i32 @exit(i32 1)
unreachable
57: ; preds = %41
%58 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 1
%59 = load i32, i32* %58
%60 = call i32 @close(i32 %59)
%61 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%62 = load i32, i32* %61
%63 = load i32, i32* @F_GETFL
%64 = call i32 @fcntl(i32 %62, i32 %63, i32 0)
store i32 %64, i32* %11
%65 = icmp sge i32 %64, 0
br i1 %65, label %66, label %74
66: ; preds = %57
%67 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%68 = load i32, i32* %67
%69 = load i32, i32* @F_SETFL
%70 = load i32, i32* %11
%71 = load i32, i32* @O_NONBLOCK
%72 = or i32 %70, %71
%73 = call i32 @fcntl(i32 %68, i32 %69, i32 %72)
br label %74
74: ; preds = %66, %57
%75 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%76 = load i32, i32* %75
%77 = call i32* @fdopen(i32 %76, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
store i32* %77, i32** %4
%78 = call i32 @gettimeofday(%struct.timeval* %15, i32* null)
%79 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%80 = load i32, i32* %79
%81 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %17, i32 0, i32 0
store i32 %80, i32* %81
%82 = load i32, i32* @POLLIN
%83 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %17, i32 0, i32 1
store i32 %82, i32* %83
store i32 0, i32* %10
br label %84
84: ; preds = %147, %125, %74
%85 = load i32, i32* %10
%86 = icmp ne i32 %85, 0
%87 = xor i1 %86, true
br i1 %87, label %88, label %148
88: ; preds = %84
%89 = call i32 @gettimeofday(%struct.timeval* %16, i32* null)
store i32 8000, i32* %13
%90 = getelementptr inbounds %struct.timeval, %struct.timeval* %16, i32 0, i32 0
%91 = load i32, i32* %90
%92 = getelementptr inbounds %struct.timeval, %struct.timeval* %15, i32 0, i32 0
%93 = load i32, i32* %92
%94 = sub nsw i32 %91, %93
%95 = mul nsw i32 %94, 1000
%96 = load i32, i32* %13
%97 = sub nsw i32 %96, %95
store i32 %97, i32* %13
%98 = getelementptr inbounds %struct.timeval, %struct.timeval* %16, i32 0, i32 1
%99 = load i32, i32* %98
%100 = getelementptr inbounds %struct.timeval, %struct.timeval* %15, i32 0, i32 1
%101 = load i32, i32* %100
%102 = sub nsw i32 %99, %101
%103 = sdiv i32 %102, 1000
%104 = load i32, i32* %13
%105 = sub nsw i32 %104, %103
store i32 %105, i32* %13
%106 = load i32, i32* %13
%107 = icmp sle i32 %106, 0
br i1 %107, label %108, label %109
108: ; preds = %88
br label %148
109: ; preds = %88
%110 = load i32, i32* %13
%111 = call i32 @poll(%struct.pollfd* %17, i32 1, i32 %110)
store i32 %111, i32* %12
%112 = icmp sle i32 %111, 0
br i1 %112, label %113, label %128
113: ; preds = %109
%114 = load i32, i32* %12
%115 = icmp eq i32 %114, 0
br i1 %115, label %116, label %117
116: ; preds = %113
br label %148
117: ; preds = %113
%118 = load i64, i64* @errno
%119 = load i64, i64* @EINTR
%120 = icmp eq i64 %118, %119
br i1 %120, label %125, label %121
121: ; preds = %117
%122 = load i64, i64* @errno
%123 = load i64, i64* @EAGAIN
%124 = icmp eq i64 %122, %123
br i1 %124, label %125, label %126
125: ; preds = %121, %117
br label %84
126: ; preds = %121
%127 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
br label %148
128: ; preds = %109
%129 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %17, i32 0, i32 2
%130 = load i32, i32* %129
%131 = load i32, i32* @POLLIN
%132 = and i32 %130, %131
%133 = icmp ne i32 %132, 0
br i1 %133, label %136, label %134
134: ; preds = %128
%135 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0))
br label %148
136: ; preds = %128
br label %137
137: ; preds = %146, %136
%138 = load i32, i32* @BUFSIZ
%139 = load i32*, i32** %4
%140 = call i64 @fgets(i8* %23, i32 %138, i32* %139)
%141 = icmp ne i64 %140, 0
br i1 %141, label %142, label %147
142: ; preds = %137
%143 = call i32 @strncmp(i8* %23, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i32 5)
%144 = icmp ne i32 %143, 0
br i1 %144, label %146, label %145
145: ; preds = %142
store i32 1, i32* %10
br label %147
146: ; preds = %142
br label %137
147: ; preds = %145, %137
br label %84
148: ; preds = %134, %126, %116, %108, %84
%149 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%150 = load i32, i32* %149
%151 = call i32 @close(i32 %150)
%152 = load i32, i32* @WNOHANG
%153 = call i32 @waitpid(i32 -1, i32* null, i32 %152)
%154 = getelementptr inbounds %struct.timeval, %struct.timeval* %16, i32 0, i32 0
%155 = load i32, i32* %154
%156 = getelementptr inbounds %struct.timeval, %struct.timeval* %15, i32 0, i32 0
%157 = load i32, i32* %156
%158 = sub nsw i32 %155, %157
%159 = mul nsw i32 %158, 1000000
%160 = sext i32 %159 to i64
store i64 %160, i64* %18
%161 = getelementptr inbounds %struct.timeval, %struct.timeval* %16, i32 0, i32 1
%162 = load i32, i32* %161
%163 = getelementptr inbounds %struct.timeval, %struct.timeval* %15, i32 0, i32 1
%164 = load i32, i32* %163
%165 = sub nsw i32 %162, %164
%166 = sext i32 %165 to i64
%167 = load i64, i64* %18
%168 = add nsw i64 %167, %166
store i64 %168, i64* %18
%169 = load i32, i32* %10
%170 = icmp ne i32 %169, 0
br i1 %170, label %175, label %171
171: ; preds = %148
%172 = load i64, i64* %18
%173 = icmp slt i64 %172, 8000000
br i1 %173, label %174, label %175
174: ; preds = %171
store i64 8000000, i64* %2
store i32 1, i32* %19
br label %177
175: ; preds = %171, %148
%176 = load i64, i64* %18
store i64 %176, i64* %2
store i32 1, i32* %19
br label %177
177: ; preds = %175, %174, %39, %33
%178 = load i8*, i8** %5
%179 = load i64, i64* %2
ret i64 %179
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
%struct.pollfd = type { i32, i32, i32 }
@BUFSIZ = global i32 0
@.str = [5 x i8] c"pipe\00"
@.str.1 = [5 x i8] c"fork\00"
@.str.2 = [10 x i8] c"/dev/null\00"
@O_RDONLY = global i32 0
@O_WRONLY = global i32 0
@.str.3 = [8 x i8] c"/bin/su\00"
@.str.4 = [3 x i8] c"su\00"
@.str.5 = [2 x i8] c"-\00"
@.str.6 = [3 x i8] c"-c\00"
@.str.7 = [23 x i8] c"echo; echo; echo HELLO\00"
@F_GETFL = global i32 0
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
@.str.8 = [2 x i8] c"r\00"
@POLLIN = global i32 0
@errno = global i64 0
@EINTR = global i64 0
@EAGAIN = global i64 0
@.str.9 = [5 x i8] c"poll\00"
@.str.10 = [16 x i8] c"POLLERR|POLLHUP\00"
@.str.11 = [6 x i8] c"HELLO\00"
@WNOHANG = global i32 0
define i64 @_time_login(i8* %0) {
%2 = alloca [2 x i32]
%3 = alloca %struct.timeval
%4 = alloca %struct.timeval
%5 = alloca %struct.pollfd
%6 = load i32, i32* @BUFSIZ
%7 = zext i32 %6 to i64
%8 = alloca i8, i64 %7
%9 = bitcast [2 x i32]* %2 to i8*
%10 = bitcast %struct.timeval* %3 to i8*
%11 = bitcast %struct.timeval* %4 to i8*
%12 = bitcast %struct.pollfd* %5 to i8*
%13 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%14 = call i64 @pipe(i32* %13)
%15 = icmp slt i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %1
%17 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %129
18: ; preds = %1
%19 = call i32 (...) @fork()
switch i32 %19, label %34 [
i32 -1, label %20
i32 0, label %22
]
20: ; preds = %18
%21 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %129
22: ; preds = %18
%23 = call i32 @close(i32 0)
%24 = load i32, i32* @O_RDONLY
%25 = call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%26 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%27 = load i32, i32* %26
%28 = call i32 @dup2(i32 %27, i32 1)
%29 = call i32 @close(i32 2)
%30 = load i32, i32* @O_WRONLY
%31 = call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %30)
%32 = call i32 @execl(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i32* null)
%33 = call i32 @exit(i32 1)
unreachable
34: ; preds = %18
%35 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%36 = load i32, i32* %35
%37 = call i32 @close(i32 %36)
%38 = load i32, i32* %13
%39 = load i32, i32* @F_GETFL
%40 = call i32 @fcntl(i32 %38, i32 %39, i32 0)
%41 = icmp sgt i32 %40, -1
br i1 %41, label %42, label %48
42: ; preds = %34
%43 = load i32, i32* %13
%44 = load i32, i32* @F_SETFL
%45 = load i32, i32* @O_NONBLOCK
%46 = or i32 %45, %40
%47 = call i32 @fcntl(i32 %43, i32 %44, i32 %46)
br label %48
48: ; preds = %42, %34
%49 = load i32, i32* %13
%50 = call i32* @fdopen(i32 %49, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%51 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%52 = load i32, i32* %13
%53 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %5, i64 0, i32 0
store i32 %52, i32* %53
%54 = load i32, i32* @POLLIN
%55 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %5, i64 0, i32 1
store i32 %54, i32* %55
%56 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
%57 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%58 = load i32, i32* %57
%59 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
%60 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%61 = load i32, i32* %60
%62 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %5, i64 0, i32 2
%63 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%64 = load i32, i32* %56
%65 = sub nsw i32 %64, %58
%66 = mul i32 %65, -1000
%67 = add i32 %66, 8000
%68 = load i32, i32* %59
%69 = sub nsw i32 %68, %61
%70 = sdiv i32 %69, -1000
%71 = add i32 %67, %70
%72 = icmp slt i32 %71, 1
br i1 %72, label %114, label %73
73: ; preds = %48, %100
%74 = phi i32 [ %109, %100 ], [ %71, %48 ]
%75 = phi i32 [ %107, %100 ], [ %69, %48 ]
%76 = phi i32 [ %103, %100 ], [ %65, %48 ]
%77 = call i32 @poll(%struct.pollfd* %5, i32 1, i32 %74)
%78 = icmp slt i32 %77, 1
br i1 %78, label %79, label %88
79: ; preds = %73
%80 = icmp eq i32 %77, 0
br i1 %80, label %114, label %81
81: ; preds = %79
%82 = load i64, i64* @errno
%83 = load i64, i64* @EINTR
%84 = icmp eq i64 %82, %83
%85 = load i64, i64* @EAGAIN
%86 = icmp eq i64 %82, %85
%87 = select i1 %84, i1 true, i1 %86
br i1 %87, label %100, label %111
88: ; preds = %73
%89 = load i32, i32* %62
%90 = load i32, i32* @POLLIN
%91 = and i32 %90, %89
%92 = icmp eq i32 %91, 0
br i1 %92, label %111, label %93
93: ; preds = %88, %97
%94 = load i32, i32* @BUFSIZ
%95 = call i64 @fgets(i8* %8, i32 %94, i32* %50)
%96 = icmp eq i64 %95, 0
br i1 %96, label %100, label %97
97: ; preds = %93
%98 = call i32 @strncmp(i8* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i32 5)
%99 = icmp eq i32 %98, 0
br i1 %99, label %114, label %93
100: ; preds = %93, %81
%101 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%102 = load i32, i32* %56
%103 = sub nsw i32 %102, %58
%104 = mul i32 %103, -1000
%105 = add i32 %104, 8000
%106 = load i32, i32* %59
%107 = sub nsw i32 %106, %61
%108 = sdiv i32 %107, -1000
%109 = add i32 %105, %108
%110 = icmp slt i32 %109, 1
br i1 %110, label %114, label %73
111: ; preds = %88, %81
%112 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), %81 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), %88 ]
%113 = call i32 @perror(i8* %112)
br label %114
114: ; preds = %100, %79, %97, %48, %111
%115 = phi i32 [ %76, %111 ], [ %65, %48 ], [ %76, %97 ], [ %76, %79 ], [ %103, %100 ]
%116 = phi i32 [ %75, %111 ], [ %69, %48 ], [ %75, %97 ], [ %75, %79 ], [ %107, %100 ]
%117 = phi i1 [ true, %111 ], [ true, %48 ], [ false, %97 ], [ true, %79 ], [ true, %100 ]
%118 = load i32, i32* %13
%119 = call i32 @close(i32 %118)
%120 = load i32, i32* @WNOHANG
%121 = call i32 @waitpid(i32 -1, i32* null, i32 %120)
%122 = mul nsw i32 %115, 1000000
%123 = sext i32 %122 to i64
%124 = sext i32 %116 to i64
%125 = add nsw i64 %124, %123
%126 = icmp slt i64 %125, 8000000
%127 = select i1 %117, i1 %126, i1 false
%128 = select i1 %127, i64 8000000, i64 %125
br label %129
129: ; preds = %114, %20, %16
%130 = phi i64 [ -1, %16 ], [ -1, %20 ], [ %128, %114 ]
ret i64 %130
}