#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 */
typedef int pid_t;

/* Variables and functions */
scalar_t__ EINTR;
int /*<<< orphan*/ EXIT_FAILURE;
int O_CREAT;
int O_TRUNC;
int O_WRONLY;
int /*<<< orphan*/ SIGTERM;
int /*<<< orphan*/ STDERR_FILENO;
int /*<<< orphan*/ STDOUT_FILENO;
int S_IRUSR;
int S_IWUSR;
int /*<<< orphan*/ assert(int /*<<< orphan*/);
double atof(char *);
scalar_t__ close(int);
int dup2(int, int /*<<< orphan*/);
scalar_t__ errno;
int execvp(char *, char **);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int input_timeout(int, double);
int kill(int, int /*<<< orphan*/);
scalar_t__ open(char *, int, int);
int /*<<< orphan*/ perror(char *);
int pipe(int *);
int /*<<< orphan*/ process_term_status(int);
int read(int, char *, int);
int /*<<< orphan*/ stderr;
char *strerror(scalar_t__);
int wait(int *);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char *argv[]) {
  if (argc < 5) {
    fprintf(stderr,
            "Usage: watchdogrun outfile errfile timeout cmd arg1 ...  argn\n");
    exit(EXIT_FAILURE);
  }
  char *outfilename = argv[1];
  char *errfilename = argv[2];
  double timeout = atof(argv[3]);
  char *cmd = argv[4];
  char **cmdargv = &(argv[4]);
  int pipefd[2];
  pid_t cpid;
  char buf;
  if (pipe(pipefd) == -1) {
    perror("pipe creation failed");
    exit(EXIT_FAILURE);
  }
  int pipe_input_fdnum = pipefd[1];
  int pipe_output_fdnum = pipefd[0];
  cpid = fork();
  if (cpid == -1) {
    perror("fork failed");
    exit(EXIT_FAILURE);
  }
  if (cpid == 0) {
    ({
      long int _result;
      do
        _result = (long int)(close(pipe_output_fdnum));
      while (_result == -1L && errno == EINTR);
      _result;
    });
    int errfile_fdnum = ({
      long int _result;
      do
        _result = (long int)(open(errfilename, O_CREAT | O_WRONLY | O_TRUNC,
                                  S_IRUSR | S_IWUSR));
      while (_result == -1L && errno == EINTR);
      _result;
    });
    if (errfile_fdnum < 0) {
      fprintf(stderr, "Error on open of errfile %s: %s\n", errfilename,
              strerror(errno));
      exit(EXIT_FAILURE);
    }
    {
      int dup2_status = dup2(errfile_fdnum, STDERR_FILENO);
      if (dup2_status < 0) {
        perror("Error on use of errfile fd for child stderr");
        exit(EXIT_FAILURE);
      }
    }
    ({
      long int _result;
      do
        _result = (long int)(close(errfile_fdnum));
      while (_result == -1L && errno == EINTR);
      _result;
    });
    {
      int dup2_status = dup2(pipe_input_fdnum, STDOUT_FILENO);
      if (dup2_status < 0) {
        perror("Error on use of pip input fd for child stdout");
        exit(EXIT_FAILURE);
      }
    }
    ({
      long int _result;
      do
        _result = (long int)(close(pipe_input_fdnum));
      while (_result == -1L && errno == EINTR);
      _result;
    });
    int status = execvp(cmd, cmdargv);
    if (status == -1) {
      perror("execv of cmd failed");
    }
    exit(EXIT_FAILURE);
  } else {
    ({
      long int _result;
      do
        _result = (long int)(close(pipe_input_fdnum));
      while (_result == -1L && errno == EINTR);
      _result;
    });
    int outfile_fdnum = ({
      long int _result;
      do
        _result = (long int)(open(outfilename, O_CREAT | O_WRONLY | O_TRUNC,
                                  S_IRUSR | S_IWUSR));
      while (_result == -1L && errno == EINTR);
      _result;
    });
    if (outfile_fdnum < 0) {
      fprintf(stderr, "Error on open of outfile %s: %s\n", outfilename,
              strerror(errno));
      exit(EXIT_FAILURE);
    }
    while (1) {
      int input_status = input_timeout(pipe_output_fdnum, timeout);
      if (input_status == -1) {
        fprintf(stderr, "Error on select input check: %s\n", strerror(errno));
        exit(EXIT_FAILURE);
      } else if (input_status == 0) {
        int kill_status = kill(cpid, SIGTERM);
        if (kill_status < 0) {
          perror("Error on kill of child");
          exit(EXIT_FAILURE);
        }
        int term_status;
        int wait_status = wait(&term_status);
        if (wait_status < 0) {
          perror("Error on wait after kill of child: ");
          exit(EXIT_FAILURE);
        }
        process_term_status(term_status);
        assert(0);
      }
      int read_status = read(pipe_output_fdnum, &buf, 1);
      if (read_status == 0) {
        int term_status;
        int wait_status = wait(&term_status);
        if (wait_status < 0) {
          perror("Error on wait after child exit: ");
          exit(EXIT_FAILURE);
        }
        process_term_status(term_status);
        assert(0);
      } else if (read_status == -1) {
        perror("Error on read of pipe from child");
        exit(EXIT_FAILURE);
      }
      write(outfile_fdnum, &buf, 1);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    1268 <main+0x48>
mov    0x2d6e(%rip),%rax
mov    (%rax),%edi
lea    0xdad(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    0x2d3f(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1040 <atof@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
add    $0x20,%rax
mov    %rax,-0x38(%rbp)
lea    -0x40(%rbp),%rdi
call   1080 <pipe@plt>
cmp    $0xffffffff,%eax
jne    12d6 <main+0xb6>
lea    0xd7c(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2cd1(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x40(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    $0x0,%al
call   1140 <fork@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0xffffffff,-0x44(%rbp)
jne    1310 <main+0xf0>
lea    0xd57(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2c97(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
cmpl   $0x0,-0x44(%rbp)
jne    15cd <main+0x3ad>
jmp    131f <main+0xff>
mov    -0x50(%rbp),%edi
call   1070 <close@plt>
mov    %rax,-0x58(%rbp)
xor    %eax,%eax
cmpq   $0xffffffffffffffff,-0x58(%rbp)
mov    %al,-0xf5(%rbp)
jne    135b <main+0x13b>
mov    0x2c6b(%rip),%rax
mov    (%rax),%rax
mov    0x2c49(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
mov    %al,-0xf5(%rbp)
mov    -0xf5(%rbp),%al
test   $0x1,%al
jne    131f <main+0xff>
mov    -0x58(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2c7c(%rip),%rax
mov    (%rax),%esi
mov    0x2bfb(%rip),%rax
or     (%rax),%esi
mov    0x2c62(%rip),%rax
or     (%rax),%esi
mov    0x2bf9(%rip),%rax
mov    (%rax),%edx
mov    0x2c28(%rip),%rax
or     (%rax),%edx
call   10d0 <open@plt>
mov    %rax,-0x70(%rbp)
xor    %eax,%eax
cmpq   $0xffffffffffffffff,-0x70(%rbp)
mov    %al,-0xf6(%rbp)
jne    13db <main+0x1bb>
mov    0x2beb(%rip),%rax
mov    (%rax),%rax
mov    0x2bc9(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
mov    %al,-0xf6(%rbp)
mov    -0xf6(%rbp),%al
test   $0x1,%al
jne    1371 <main+0x151>
mov    -0x70(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x78(%rbp),%rax
mov    %eax,-0x64(%rbp)
cmpl   $0x0,-0x64(%rbp)
jge    1457 <main+0x237>
mov    0x2baf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x104(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x100(%rbp)
mov    0x2b8d(%rip),%rax
mov    (%rax),%rdi
call   1110 <strerror@plt>
mov    -0x104(%rbp),%edi
mov    -0x100(%rbp),%rdx
mov    %rax,%rcx
lea    0xc1e(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    0x2b50(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
mov    -0x64(%rbp),%edi
mov    0x2b47(%rip),%rax
mov    (%rax),%esi
call   1060 <dup2@plt>
mov    %eax,-0x7c(%rbp)
cmpl   $0x0,-0x7c(%rbp)
jge    148f <main+0x26f>
lea    0xc05(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2b18(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
jmp    1494 <main+0x274>
mov    -0x64(%rbp),%edi
call   1070 <close@plt>
mov    %rax,-0x88(%rbp)
xor    %eax,%eax
cmpq   $0xffffffffffffffff,-0x88(%rbp)
ff
mov    %al,-0x105(%rbp)
jne    14d6 <main+0x2b6>
mov    0x2af0(%rip),%rax
mov    (%rax),%rax
mov    0x2ace(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
mov    %al,-0x105(%rbp)
mov    -0x105(%rbp),%al
test   $0x1,%al
jne    1494 <main+0x274>
mov    -0x88(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x4c(%rbp),%edi
mov    0x2ae4(%rip),%rax
mov    (%rax),%esi
call   1060 <dup2@plt>
mov    %eax,-0x94(%rbp)
cmpl   $0x0,-0x94(%rbp)
jge    1530 <main+0x310>
lea    0xb90(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2a77(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
jmp    1535 <main+0x315>
mov    -0x4c(%rbp),%edi
call   1070 <close@plt>
mov    %rax,-0xa0(%rbp)
xor    %eax,%eax
cmpq   $0xffffffffffffffff,-0xa0(%rbp)
ff
mov    %al,-0x106(%rbp)
jne    1577 <main+0x357>
mov    0x2a4f(%rip),%rax
mov    (%rax),%rax
mov    0x2a2d(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
mov    %al,-0x106(%rbp)
mov    -0x106(%rbp),%al
test   $0x1,%al
jne    1535 <main+0x315>
mov    -0xa0(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   10f0 <execvp@plt>
mov    %eax,-0xac(%rbp)
cmpl   $0xffffffff,-0xac(%rbp)
jne    15bf <main+0x39f>
lea    0xb21(%rip),%rdi
call   10e0 <perror@plt>
mov    0x29da(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
jmp    15d2 <main+0x3b2>
mov    -0x4c(%rbp),%edi
call   1070 <close@plt>
mov    %rax,-0xb8(%rbp)
xor    %eax,%eax
cmpq   $0xffffffffffffffff,-0xb8(%rbp)
ff
mov    %al,-0x107(%rbp)
jne    1614 <main+0x3f4>
mov    0x29b2(%rip),%rax
mov    (%rax),%rax
mov    0x2990(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
mov    %al,-0x107(%rbp)
mov    -0x107(%rbp),%al
test   $0x1,%al
jne    15d2 <main+0x3b2>
mov    -0xb8(%rbp),%rax
mov    %rax,-0xc0(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x29bd(%rip),%rax
mov    (%rax),%esi
mov    0x293c(%rip),%rax
or     (%rax),%esi
mov    0x29a3(%rip),%rax
or     (%rax),%esi
mov    0x293a(%rip),%rax
mov    (%rax),%edx
mov    0x2969(%rip),%rax
or     (%rax),%edx
call   10d0 <open@plt>
mov    %rax,-0xd0(%rbp)
xor    %eax,%eax
cmpq   $0xffffffffffffffff,-0xd0(%rbp)
ff
mov    %al,-0x108(%rbp)
jne    16a0 <main+0x480>
mov    0x2926(%rip),%rax
mov    (%rax),%rax
mov    0x2904(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
mov    %al,-0x108(%rbp)
mov    -0x108(%rbp),%al
test   $0x1,%al
jne    1630 <main+0x410>
mov    -0xd0(%rbp),%rax
mov    %rax,-0xd8(%rbp)
mov    -0xd8(%rbp),%rax
mov    %eax,-0xc4(%rbp)
cmpl   $0x0,-0xc4(%rbp)
jge    172b <main+0x50b>
mov    0x28db(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x114(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x110(%rbp)
mov    0x28b9(%rip),%rax
mov    (%rax),%rdi
call   1110 <strerror@plt>
mov    -0x114(%rbp),%edi
mov    -0x110(%rbp),%rdx
mov    %rax,%rcx
lea    0x9d9(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    0x287c(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
jmp    1730 <main+0x510>
mov    -0x50(%rbp),%edi
movsd  -0x28(%rbp),%xmm0
call   1130 <input_timeout@plt>
mov    %eax,-0xdc(%rbp)
cmpl   $0xffffffff,-0xdc(%rbp)
jne    1793 <main+0x573>
mov    0x2861(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x118(%rbp)
mov    0x284a(%rip),%rax
mov    (%rax),%rdi
call   1110 <strerror@plt>
mov    -0x118(%rbp),%edi
mov    %rax,%rdx
lea    0x992(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    0x2814(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
cmpl   $0x0,-0xdc(%rbp)
jne    1829 <main+0x609>
mov    -0x44(%rbp),%edi
mov    0x2826(%rip),%rax
mov    (%rax),%esi
call   10c0 <kill@plt>
mov    %eax,-0xe0(%rbp)
cmpl   $0x0,-0xe0(%rbp)
jge    17de <main+0x5be>
lea    0x966(%rip),%rdi
call   10e0 <perror@plt>
mov    0x27c9(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
lea    -0xe4(%rbp),%rdi
call   1120 <wait@plt>
mov    %eax,-0xe8(%rbp)
cmpl   $0x0,-0xe8(%rbp)
jge    1817 <main+0x5f7>
lea    0x944(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2790(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
mov    -0xe4(%rbp),%edi
call   1030 <process_term_status@plt>
xor    %edi,%edi
call   10a0 <assert@plt>
jmp    182e <main+0x60e>
mov    -0x50(%rbp),%edi
lea    -0x45(%rbp),%rsi
mov    $0x1,%edx
call   1090 <read@plt>
mov    %eax,-0xec(%rbp)
cmpl   $0x0,-0xec(%rbp)
jne    18a2 <main+0x682>
lea    -0xf0(%rbp),%rdi
call   1120 <wait@plt>
mov    %eax,-0xf4(%rbp)
cmpl   $0x0,-0xf4(%rbp)
jge    188b <main+0x66b>
lea    0x8f4(%rip),%rdi
call   10e0 <perror@plt>
mov    0x271c(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
mov    -0xf0(%rbp),%edi
call   1030 <process_term_status@plt>
xor    %edi,%edi
call   10a0 <assert@plt>
jmp    18ce <main+0x6ae>
cmpl   $0xffffffff,-0xec(%rbp)
jne    18c9 <main+0x6a9>
lea    0x8d7(%rip),%rdi
call   10e0 <perror@plt>
mov    0x26de(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
jmp    18ce <main+0x6ae>
mov    -0xc4(%rbp),%edi
lea    -0x45(%rbp),%rsi
mov    $0x1,%edx
call   1050 <write@plt>
jmp    1730 <main+0x510>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
cmp    $0x4,%edi
jg     124f <main+0x2f>
mov    0x2d7e(%rip),%rax
mov    (%rax),%edi
lea    0xdbd(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
jmp    1394 <main+0x174>
mov    %rsi,%r14
mov    0x8(%rsi),%rax
mov    %rax,0x10(%rsp)
mov    0x10(%rsi),%rax
mov    %rax,0x18(%rsp)
mov    0x18(%rsi),%rdi
call   1040 <atof@plt>
movsd  %xmm0,0x28(%rsp)
mov    0x20(%r14),%r15
lea    0x30(%rsp),%rdi
call   1080 <pipe@plt>
cmp    $0xffffffff,%eax
jne    1292 <main+0x72>
lea    0xdb2(%rip),%rdi
jmp    138f <main+0x16f>
mov    0x30(%rsp),%ebx
mov    0x34(%rsp),%ebp
xor    %eax,%eax
call   1140 <fork@plt>
cmp    $0xffffffff,%eax
je     1388 <main+0x168>
test   %eax,%eax
jne    13a2 <main+0x182>
mov    %r15,0x20(%rsp)
mov    %ebp,0x10(%rsp)
add    $0x20,%r14
mov    %r14,0x28(%rsp)
mov    0x2ce5(%rip),%r14
mov    0x2cc6(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebx,%edi
call   1070 <close@plt>
cmp    $0xffffffffffffffff,%rax
jne    12f6 <main+0xd6>
mov    0x0(%rbp),%rax
cmp    %rax,(%r14)
je     12e0 <main+0xc0>
mov    0x2cfb(%rip),%r13
mov    0x2c7c(%rip),%rbp
mov    0x2ce5(%rip),%r12
mov    0x2c7e(%rip),%r15
mov    0x2caf(%rip),%r14
nopl   0x0(%rax)
mov    0x0(%rbp),%esi
or     0x0(%r13),%esi
or     (%r12),%esi
mov    (%r14),%edx
or     (%r15),%edx
mov    0x18(%rsp),%rdi
call   10d0 <open@plt>
mov    %rax,%rbx
mov    0x2c6b(%rip),%rax
mov    (%rax),%rdi
cmp    $0xffffffffffffffff,%rbx
jne    135a <main+0x13a>
mov    0x2c43(%rip),%rax
cmp    (%rax),%rdi
je     1320 <main+0x100>
test   %ebx,%ebx
mov    0x10(%rsp),%r15d
jns    1467 <main+0x247>
mov    0x2c4a(%rip),%rax
mov    (%rax),%ebx
call   1110 <strerror@plt>
lea    0xce4(%rip),%rsi
mov    %ebx,%edi
mov    0x18(%rsp),%rdx
jmp    1458 <main+0x238>
lea    0xcc5(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2c05(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
mov    %eax,0x20(%rsp)
mov    %ebx,0x18(%rsp)
mov    0x2be7(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
call   1070 <close@plt>
cmp    $0xffffffffffffffff,%rax
jne    13dc <main+0x1bc>
mov    (%r15),%rax
mov    0x2bd9(%rip),%rcx
cmp    %rax,(%rcx)
je     13c0 <main+0x1a0>
mov    0x2b9d(%rip),%r12
mov    0x2c06(%rip),%r13
mov    0x2b9f(%rip),%r14
mov    0x2bd0(%rip),%rbx
nopl   0x0(%rax,%rax,1)
mov    (%r12),%esi
mov    0x2bed(%rip),%rax
or     (%rax),%esi
or     0x0(%r13),%esi
mov    (%rbx),%edx
or     (%r14),%edx
mov    0x10(%rsp),%rdi
call   10d0 <open@plt>
mov    %rax,%rbp
mov    0x2b86(%rip),%rax
mov    (%rax),%rdi
cmp    $0xffffffffffffffff,%rbp
jne    1438 <main+0x218>
cmp    (%r15),%rdi
je     1400 <main+0x1e0>
test   %ebp,%ebp
jns    148b <main+0x26b>
mov    0x2b75(%rip),%rax
mov    (%rax),%ebp
call   1110 <strerror@plt>
lea    0xc9e(%rip),%rsi
mov    %ebp,%edi
mov    0x10(%rsp),%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   10b0 <fprintf@plt>
jmp    1394 <main+0x174>
mov    0x2b3a(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
call   1060 <dup2@plt>
test   %eax,%eax
jns    1560 <main+0x340>
lea    0xbfb(%rip),%rdi
jmp    138f <main+0x16f>
mov    0x2b3e(%rip),%r13
lea    0xc(%rsp),%r14
lea    0xb(%rsp),%r15
mov    0x18(%rsp),%ebx
mov    0x20(%rsp),%r12d
jmp    14c8 <main+0x2a8>
nopw   0x0(%rax,%rax,1)
cmp    $0xffffffff,%eax
je     15f8 <main+0x3d8>
mov    %ebp,%edi
mov    %r15,%rsi
mov    $0x1,%edx
call   1050 <write@plt>
mov    %ebx,%edi
movsd  0x28(%rsp),%xmm0
call   1130 <input_timeout@plt>
test   %eax,%eax
je     14f0 <main+0x2d0>
cmp    $0xffffffff,%eax
jne    1524 <main+0x304>
jmp    1604 <main+0x3e4>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x0(%r13),%esi
mov    %r12d,%edi
call   10c0 <kill@plt>
test   %eax,%eax
js     1634 <main+0x414>
mov    %r14,%rdi
call   1120 <wait@plt>
test   %eax,%eax
js     1640 <main+0x420>
mov    0xc(%rsp),%edi
call   1030 <process_term_status@plt>
xor    %edi,%edi
call   10a0 <assert@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0x1,%edx
call   1090 <read@plt>
test   %eax,%eax
jne    14b0 <main+0x290>
mov    %r14,%rdi
call   1120 <wait@plt>
test   %eax,%eax
js     164c <main+0x42c>
mov    0xc(%rsp),%edi
call   1030 <process_term_status@plt>
xor    %edi,%edi
call   10a0 <assert@plt>
jmp    14b9 <main+0x299>
mov    0x2a49(%rip),%r12
mov    0x2a2a(%rip),%rbp
xchg   %ax,%ax
mov    %ebx,%edi
call   1070 <close@plt>
cmp    $0xffffffffffffffff,%rax
jne    1587 <main+0x367>
mov    0x0(%rbp),%rax
cmp    %rax,(%r12)
je     1570 <main+0x350>
mov    0x2a52(%rip),%rax
mov    (%rax),%esi
mov    %r15d,%edi
call   1060 <dup2@plt>
test   %eax,%eax
mov    0x28(%rsp),%r14
mov    0x20(%rsp),%rbx
jns    15c0 <main+0x3a0>
lea    0xb00(%rip),%rdi
jmp    138f <main+0x16f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15d,%edi
call   1070 <close@plt>
cmp    $0xffffffffffffffff,%rax
jne    15d8 <main+0x3b8>
mov    0x0(%rbp),%rax
cmp    %rax,(%r12)
je     15c0 <main+0x3a0>
mov    %rbx,%rdi
mov    %r14,%rsi
call   10f0 <execvp@plt>
cmp    $0xffffffff,%eax
jne    1394 <main+0x174>
lea    0xae8(%rip),%rdi
jmp    138f <main+0x16f>
lea    0xb8e(%rip),%rdi
jmp    138f <main+0x16f>
mov    0x29ad(%rip),%rax
mov    (%rax),%ebx
mov    0x299c(%rip),%rax
mov    (%rax),%rdi
call   1110 <strerror@plt>
lea    0xaed(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10b0 <fprintf@plt>
jmp    1394 <main+0x174>
lea    0xaf6(%rip),%rdi
jmp    138f <main+0x16f>
lea    0xb01(%rip),%rdi
jmp    138f <main+0x16f>
lea    0xb19(%rip),%rdi
jmp    138f <main+0x16f>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [63 x i8] c"Usage: watchdogrun outfile errfile timeout cmd arg1 ... argn\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [21 x i8] c"pipe creation failed\00"
@.str.2 = [12 x i8] c"fork failed\00"
@errno = global i64 0
@EINTR = global i64 0
@O_CREAT = global i32 0
@O_WRONLY = global i32 0
@O_TRUNC = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@.str.3 = [33 x i8] c"Error on open of errfile %s: %s\0A\00"
@STDERR_FILENO = global i32 0
@.str.4 = [44 x i8] c"Error on use of errfile fd for child stderr\00"
@STDOUT_FILENO = global i32 0
@.str.5 = [46 x i8] c"Error on use of pip input fd for child stdout\00"
@.str.6 = [20 x i8] c"execv of cmd failed\00"
@.str.7 = [33 x i8] c"Error on open of outfile %s: %s\0A\00"
@.str.8 = [33 x i8] c"Error on select input check: %s\0A\00"
@SIGTERM = global i32 0
@.str.9 = [23 x i8] c"Error on kill of child\00"
@.str.10 = [36 x i8] c"Error on wait after kill of child: \00"
@.str.11 = [33 x i8] c"Error on wait after child exit: \00"
@.str.12 = [33 x i8] c"Error on read of pipe from child\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca double
%9 = alloca i8*
%10 = alloca i8**
%11 = alloca [2 x i32]
%12 = alloca i32
%13 = alloca i8
%14 = alloca i32
%15 = alloca i32
%16 = alloca i64
%17 = alloca i64
%18 = alloca i32
%19 = alloca i64
%20 = alloca i64
%21 = alloca i32
%22 = alloca i64
%23 = alloca i64
%24 = alloca i32
%25 = alloca i64
%26 = alloca i64
%27 = alloca i32
%28 = alloca i64
%29 = alloca i64
%30 = alloca i32
%31 = alloca i64
%32 = alloca i64
%33 = alloca i32
%34 = alloca i32
%35 = alloca i32
%36 = alloca i32
%37 = alloca i32
%38 = alloca i32
%39 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%40 = load i32, i32* %4
%41 = icmp slt i32 %40, 5
br i1 %41, label %42, label %47
42: ; preds = %2
%43 = load i32, i32* @stderr
%44 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str, i64 0, i64 0))
%45 = load i32, i32* @EXIT_FAILURE
%46 = call i32 @exit(i32 %45)
unreachable
47: ; preds = %2
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 1
%50 = load i8*, i8** %49
store i8* %50, i8** %6
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 2
%53 = load i8*, i8** %52
store i8* %53, i8** %7
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 3
%56 = load i8*, i8** %55
%57 = call double @atof(i8* %56)
store double %57, double* %8
%58 = load i8**, i8*** %5
%59 = getelementptr inbounds i8*, i8** %58, i64 4
%60 = load i8*, i8** %59
store i8* %60, i8** %9
%61 = load i8**, i8*** %5
%62 = getelementptr inbounds i8*, i8** %61, i64 4
store i8** %62, i8*** %10
%63 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%64 = call i32 @pipe(i32* %63)
%65 = icmp eq i32 %64, -1
br i1 %65, label %66, label %70
66: ; preds = %47
%67 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%68 = load i32, i32* @EXIT_FAILURE
%69 = call i32 @exit(i32 %68)
unreachable
70: ; preds = %47
%71 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 1
%72 = load i32, i32* %71
store i32 %72, i32* %14
%73 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%74 = load i32, i32* %73
store i32 %74, i32* %15
%75 = call i32 (...) @fork()
store i32 %75, i32* %12
%76 = load i32, i32* %12
%77 = icmp eq i32 %76, -1
br i1 %77, label %78, label %82
78: ; preds = %70
%79 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%80 = load i32, i32* @EXIT_FAILURE
%81 = call i32 @exit(i32 %80)
unreachable
82: ; preds = %70
%83 = load i32, i32* %12
%84 = icmp eq i32 %83, 0
br i1 %84, label %85, label %196
85: ; preds = %82
br label %86
86: ; preds = %96, %85
%87 = load i32, i32* %15
%88 = call i64 @close(i32 %87)
store i64 %88, i64* %16
br label %89
89: ; preds = %86
%90 = load i64, i64* %16
%91 = icmp eq i64 %90, -1
br i1 %91, label %92, label %96
92: ; preds = %89
%93 = load i64, i64* @errno
%94 = load i64, i64* @EINTR
%95 = icmp eq i64 %93, %94
br label %96
96: ; preds = %92, %89
%97 = phi i1 [ false, %89 ], [ %95, %92 ]
br i1 %97, label %86, label %98
98: ; preds = %96
%99 = load i64, i64* %16
store i64 %99, i64* %17
%100 = load i64, i64* %17
br label %101
101: ; preds = %119, %98
%102 = load i8*, i8** %7
%103 = load i32, i32* @O_CREAT
%104 = load i32, i32* @O_WRONLY
%105 = or i32 %103, %104
%106 = load i32, i32* @O_TRUNC
%107 = or i32 %105, %106
%108 = load i32, i32* @S_IRUSR
%109 = load i32, i32* @S_IWUSR
%110 = or i32 %108, %109
%111 = call i64 @open(i8* %102, i32 %107, i32 %110)
store i64 %111, i64* %19
br label %112
112: ; preds = %101
%113 = load i64, i64* %19
%114 = icmp eq i64 %113, -1
br i1 %114, label %115, label %119
115: ; preds = %112
%116 = load i64, i64* @errno
%117 = load i64, i64* @EINTR
%118 = icmp eq i64 %116, %117
br label %119
119: ; preds = %115, %112
%120 = phi i1 [ false, %112 ], [ %118, %115 ]
br i1 %120, label %101, label %121
121: ; preds = %119
%122 = load i64, i64* %19
store i64 %122, i64* %20
%123 = load i64, i64* %20
%124 = trunc i64 %123 to i32
store i32 %124, i32* %18
%125 = load i32, i32* %18
%126 = icmp slt i32 %125, 0
br i1 %126, label %127, label %135
127: ; preds = %121
%128 = load i32, i32* @stderr
%129 = load i8*, i8** %7
%130 = load i64, i64* @errno
%131 = call i8* @strerror(i64 %130)
%132 = call i32 (i32, i8*, ...) @fprintf(i32 %128, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i8* %129, i8* %131)
%133 = load i32, i32* @EXIT_FAILURE
%134 = call i32 @exit(i32 %133)
unreachable
135: ; preds = %121
%136 = load i32, i32* %18
%137 = load i32, i32* @STDERR_FILENO
%138 = call i32 @dup2(i32 %136, i32 %137)
store i32 %138, i32* %21
%139 = load i32, i32* %21
%140 = icmp slt i32 %139, 0
br i1 %140, label %141, label %145
141: ; preds = %135
%142 = call i32 @perror(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0))
%143 = load i32, i32* @EXIT_FAILURE
%144 = call i32 @exit(i32 %143)
unreachable
145: ; preds = %135
br label %146
146: ; preds = %156, %145
%147 = load i32, i32* %18
%148 = call i64 @close(i32 %147)
store i64 %148, i64* %22
br label %149
149: ; preds = %146
%150 = load i64, i64* %22
%151 = icmp eq i64 %150, -1
br i1 %151, label %152, label %156
152: ; preds = %149
%153 = load i64, i64* @errno
%154 = load i64, i64* @EINTR
%155 = icmp eq i64 %153, %154
br label %156
156: ; preds = %152, %149
%157 = phi i1 [ false, %149 ], [ %155, %152 ]
br i1 %157, label %146, label %158
158: ; preds = %156
%159 = load i64, i64* %22
store i64 %159, i64* %23
%160 = load i64, i64* %23
%161 = load i32, i32* %14
%162 = load i32, i32* @STDOUT_FILENO
%163 = call i32 @dup2(i32 %161, i32 %162)
store i32 %163, i32* %24
%164 = load i32, i32* %24
%165 = icmp slt i32 %164, 0
br i1 %165, label %166, label %170
166: ; preds = %158
%167 = call i32 @perror(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.5, i64 0, i64 0))
%168 = load i32, i32* @EXIT_FAILURE
%169 = call i32 @exit(i32 %168)
unreachable
170: ; preds = %158
br label %171
171: ; preds = %181, %170
%172 = load i32, i32* %14
%173 = call i64 @close(i32 %172)
store i64 %173, i64* %25
br label %174
174: ; preds = %171
%175 = load i64, i64* %25
%176 = icmp eq i64 %175, -1
br i1 %176, label %177, label %181
177: ; preds = %174
%178 = load i64, i64* @errno
%179 = load i64, i64* @EINTR
%180 = icmp eq i64 %178, %179
br label %181
181: ; preds = %177, %174
%182 = phi i1 [ false, %174 ], [ %180, %177 ]
br i1 %182, label %171, label %183
183: ; preds = %181
%184 = load i64, i64* %25
store i64 %184, i64* %26
%185 = load i64, i64* %26
%186 = load i8*, i8** %9
%187 = load i8**, i8*** %10
%188 = call i32 @execvp(i8* %186, i8** %187)
store i32 %188, i32* %27
%189 = load i32, i32* %27
%190 = icmp eq i32 %189, -1
br i1 %190, label %191, label %193
191: ; preds = %183
%192 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
br label %193
193: ; preds = %191, %183
%194 = load i32, i32* @EXIT_FAILURE
%195 = call i32 @exit(i32 %194)
unreachable
196: ; preds = %82
br label %197
197: ; preds = %207, %196
%198 = load i32, i32* %14
%199 = call i64 @close(i32 %198)
store i64 %199, i64* %28
br label %200
200: ; preds = %197
%201 = load i64, i64* %28
%202 = icmp eq i64 %201, -1
br i1 %202, label %203, label %207
203: ; preds = %200
%204 = load i64, i64* @errno
%205 = load i64, i64* @EINTR
%206 = icmp eq i64 %204, %205
br label %207
207: ; preds = %203, %200
%208 = phi i1 [ false, %200 ], [ %206, %203 ]
br i1 %208, label %197, label %209
209: ; preds = %207
%210 = load i64, i64* %28
store i64 %210, i64* %29
%211 = load i64, i64* %29
br label %212
212: ; preds = %230, %209
%213 = load i8*, i8** %6
%214 = load i32, i32* @O_CREAT
%215 = load i32, i32* @O_WRONLY
%216 = or i32 %214, %215
%217 = load i32, i32* @O_TRUNC
%218 = or i32 %216, %217
%219 = load i32, i32* @S_IRUSR
%220 = load i32, i32* @S_IWUSR
%221 = or i32 %219, %220
%222 = call i64 @open(i8* %213, i32 %218, i32 %221)
store i64 %222, i64* %31
br label %223
223: ; preds = %212
%224 = load i64, i64* %31
%225 = icmp eq i64 %224, -1
br i1 %225, label %226, label %230
226: ; preds = %223
%227 = load i64, i64* @errno
%228 = load i64, i64* @EINTR
%229 = icmp eq i64 %227, %228
br label %230
230: ; preds = %226, %223
%231 = phi i1 [ false, %223 ], [ %229, %226 ]
br i1 %231, label %212, label %232
232: ; preds = %230
%233 = load i64, i64* %31
store i64 %233, i64* %32
%234 = load i64, i64* %32
%235 = trunc i64 %234 to i32
store i32 %235, i32* %30
%236 = load i32, i32* %30
%237 = icmp slt i32 %236, 0
br i1 %237, label %238, label %246
238: ; preds = %232
%239 = load i32, i32* @stderr
%240 = load i8*, i8** %6
%241 = load i64, i64* @errno
%242 = call i8* @strerror(i64 %241)
%243 = call i32 (i32, i8*, ...) @fprintf(i32 %239, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i8* %240, i8* %242)
%244 = load i32, i32* @EXIT_FAILURE
%245 = call i32 @exit(i32 %244)
unreachable
246: ; preds = %232
br label %247
247: ; preds = %246, %311
%248 = load i32, i32* %15
%249 = load double, double* %8
%250 = call i32 @input_timeout(i32 %248, double %249)
store i32 %250, i32* %33
%251 = load i32, i32* %33
%252 = icmp eq i32 %251, -1
br i1 %252, label %253, label %260
253: ; preds = %247
%254 = load i32, i32* @stderr
%255 = load i64, i64* @errno
%256 = call i8* @strerror(i64 %255)
%257 = call i32 (i32, i8*, ...) @fprintf(i32 %254, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i8* %256)
%258 = load i32, i32* @EXIT_FAILURE
%259 = call i32 @exit(i32 %258)
unreachable
260: ; preds = %247
%261 = load i32, i32* %33
%262 = icmp eq i32 %261, 0
br i1 %262, label %263, label %285
263: ; preds = %260
%264 = load i32, i32* %12
%265 = load i32, i32* @SIGTERM
%266 = call i32 @kill(i32 %264, i32 %265)
store i32 %266, i32* %34
%267 = load i32, i32* %34
%268 = icmp slt i32 %267, 0
br i1 %268, label %269, label %273
269: ; preds = %263
%270 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0))
%271 = load i32, i32* @EXIT_FAILURE
%272 = call i32 @exit(i32 %271)
unreachable
273: ; preds = %263
%274 = call i32 @wait(i32* %35)
store i32 %274, i32* %36
%275 = load i32, i32* %36
%276 = icmp slt i32 %275, 0
br i1 %276, label %277, label %281
277: ; preds = %273
%278 = call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.10, i64 0, i64 0))
%279 = load i32, i32* @EXIT_FAILURE
%280 = call i32 @exit(i32 %279)
unreachable
281: ; preds = %273
%282 = load i32, i32* %35
%283 = call i32 @process_term_status(i32 %282)
%284 = call i32 @assert(i32 0)
br label %285
285: ; preds = %281, %260
br label %286
286: ; preds = %285
%287 = load i32, i32* %15
%288 = call i32 @read(i32 %287, i8* %13, i32 1)
store i32 %288, i32* %37
%289 = load i32, i32* %37
%290 = icmp eq i32 %289, 0
br i1 %290, label %291, label %303
291: ; preds = %286
%292 = call i32 @wait(i32* %38)
store i32 %292, i32* %39
%293 = load i32, i32* %39
%294 = icmp slt i32 %293, 0
br i1 %294, label %295, label %299
295: ; preds = %291
%296 = call i32 @perror(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.11, i64 0, i64 0))
%297 = load i32, i32* @EXIT_FAILURE
%298 = call i32 @exit(i32 %297)
unreachable
299: ; preds = %291
%300 = load i32, i32* %38
%301 = call i32 @process_term_status(i32 %300)
%302 = call i32 @assert(i32 0)
br label %311
303: ; preds = %286
%304 = load i32, i32* %37
%305 = icmp eq i32 %304, -1
br i1 %305, label %306, label %310
306: ; preds = %303
%307 = call i32 @perror(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.12, i64 0, i64 0))
%308 = load i32, i32* @EXIT_FAILURE
%309 = call i32 @exit(i32 %308)
unreachable
310: ; preds = %303
br label %311
311: ; preds = %310, %299
%312 = load i32, i32* %30
%313 = call i32 @write(i32 %312, i8* %13, i32 1)
br label %247
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [63 x i8] c"Usage: watchdogrun outfile errfile timeout cmd arg1 ... argn\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [21 x i8] c"pipe creation failed\00"
@.str.2 = [12 x i8] c"fork failed\00"
@errno = global i64 0
@EINTR = global i64 0
@O_CREAT = global i32 0
@O_WRONLY = global i32 0
@O_TRUNC = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@.str.3 = [33 x i8] c"Error on open of errfile %s: %s\0A\00"
@STDERR_FILENO = global i32 0
@.str.4 = [44 x i8] c"Error on use of errfile fd for child stderr\00"
@STDOUT_FILENO = global i32 0
@.str.5 = [46 x i8] c"Error on use of pip input fd for child stdout\00"
@.str.6 = [20 x i8] c"execv of cmd failed\00"
@.str.7 = [33 x i8] c"Error on open of outfile %s: %s\0A\00"
@.str.8 = [33 x i8] c"Error on select input check: %s\0A\00"
@SIGTERM = global i32 0
@.str.9 = [23 x i8] c"Error on kill of child\00"
@.str.10 = [36 x i8] c"Error on wait after kill of child: \00"
@.str.11 = [33 x i8] c"Error on wait after child exit: \00"
@.str.12 = [33 x i8] c"Error on read of pipe from child\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [2 x i32]
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
%7 = icmp slt i32 %0, 5
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @EXIT_FAILURE
%12 = tail call i32 @exit(i32 %11)
unreachable
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = getelementptr inbounds i8*, i8** %1, i64 3
%19 = load i8*, i8** %18
%20 = tail call double @atof(i8* %19)
%21 = getelementptr inbounds i8*, i8** %1, i64 4
%22 = load i8*, i8** %21
%23 = bitcast [2 x i32]* %3 to i8*
%24 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%25 = call i32 @pipe(i32* %24)
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %31
27: ; preds = %13
%28 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%29 = load i32, i32* @EXIT_FAILURE
%30 = call i32 @exit(i32 %29)
unreachable
31: ; preds = %13
%32 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%33 = load i32, i32* %32
%34 = load i32, i32* %24
%35 = call i32 (...) @fork()
switch i32 %35, label %109 [
i32 -1, label %36
i32 0, label %40
]
36: ; preds = %31
%37 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%38 = load i32, i32* @EXIT_FAILURE
%39 = call i32 @exit(i32 %38)
unreachable
40: ; preds = %31, %40
%41 = call i64 @close(i32 %34)
%42 = icmp eq i64 %41, -1
%43 = load i64, i64* @errno
%44 = load i64, i64* @EINTR
%45 = icmp eq i64 %43, %44
%46 = select i1 %42, i1 %45, i1 false
br i1 %46, label %40, label %47
47: ; preds = %40, %47
%48 = load i32, i32* @O_CREAT
%49 = load i32, i32* @O_WRONLY
%50 = or i32 %49, %48
%51 = load i32, i32* @O_TRUNC
%52 = or i32 %50, %51
%53 = load i32, i32* @S_IRUSR
%54 = load i32, i32* @S_IWUSR
%55 = or i32 %54, %53
%56 = call i64 @open(i8* %17, i32 %52, i32 %55)
%57 = icmp eq i64 %56, -1
%58 = load i64, i64* @errno
%59 = load i64, i64* @EINTR
%60 = icmp eq i64 %58, %59
%61 = select i1 %57, i1 %60, i1 false
br i1 %61, label %47, label %62
62: ; preds = %47
%63 = trunc i64 %56 to i32
%64 = icmp slt i32 %63, 0
br i1 %64, label %65, label %71
65: ; preds = %62
%66 = load i32, i32* @stderr
%67 = call i8* @strerror(i64 %58)
%68 = call i32 (i32, i8*, ...) @fprintf(i32 %66, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i8* %17, i8* %67)
%69 = load i32, i32* @EXIT_FAILURE
%70 = call i32 @exit(i32 %69)
unreachable
71: ; preds = %62
%72 = load i32, i32* @STDERR_FILENO
%73 = call i32 @dup2(i32 %63, i32 %72)
%74 = icmp slt i32 %73, 0
br i1 %74, label %75, label %79
75: ; preds = %71
%76 = call i32 @perror(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0))
%77 = load i32, i32* @EXIT_FAILURE
%78 = call i32 @exit(i32 %77)
unreachable
79: ; preds = %71, %79
%80 = call i64 @close(i32 %63)
%81 = icmp eq i64 %80, -1
%82 = load i64, i64* @errno
%83 = load i64, i64* @EINTR
%84 = icmp eq i64 %82, %83
%85 = select i1 %81, i1 %84, i1 false
br i1 %85, label %79, label %86
86: ; preds = %79
%87 = load i32, i32* @STDOUT_FILENO
%88 = call i32 @dup2(i32 %33, i32 %87)
%89 = icmp slt i32 %88, 0
br i1 %89, label %90, label %94
90: ; preds = %86
%91 = call i32 @perror(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.5, i64 0, i64 0))
%92 = load i32, i32* @EXIT_FAILURE
%93 = call i32 @exit(i32 %92)
unreachable
94: ; preds = %86, %94
%95 = call i64 @close(i32 %33)
%96 = icmp eq i64 %95, -1
%97 = load i64, i64* @errno
%98 = load i64, i64* @EINTR
%99 = icmp eq i64 %97, %98
%100 = select i1 %96, i1 %99, i1 false
br i1 %100, label %94, label %101
101: ; preds = %94
%102 = call i32 @execvp(i8* %22, i8** %21)
%103 = icmp eq i32 %102, -1
br i1 %103, label %104, label %106
104: ; preds = %101
%105 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
br label %106
106: ; preds = %104, %101
%107 = load i32, i32* @EXIT_FAILURE
%108 = call i32 @exit(i32 %107)
unreachable
109: ; preds = %31, %109
%110 = call i64 @close(i32 %33)
%111 = icmp eq i64 %110, -1
%112 = load i64, i64* @errno
%113 = load i64, i64* @EINTR
%114 = icmp eq i64 %112, %113
%115 = select i1 %111, i1 %114, i1 false
br i1 %115, label %109, label %116
116: ; preds = %109, %116
%117 = load i32, i32* @O_CREAT
%118 = load i32, i32* @O_WRONLY
%119 = or i32 %118, %117
%120 = load i32, i32* @O_TRUNC
%121 = or i32 %119, %120
%122 = load i32, i32* @S_IRUSR
%123 = load i32, i32* @S_IWUSR
%124 = or i32 %123, %122
%125 = call i64 @open(i8* %15, i32 %121, i32 %124)
%126 = icmp eq i64 %125, -1
%127 = load i64, i64* @errno
%128 = load i64, i64* @EINTR
%129 = icmp eq i64 %127, %128
%130 = select i1 %126, i1 %129, i1 false
br i1 %130, label %116, label %131
131: ; preds = %116
%132 = trunc i64 %125 to i32
%133 = icmp slt i32 %132, 0
br i1 %133, label %137, label %134
134: ; preds = %131
%135 = bitcast i32* %5 to i8*
%136 = bitcast i32* %6 to i8*
br label %143
137: ; preds = %131
%138 = load i32, i32* @stderr
%139 = call i8* @strerror(i64 %127)
%140 = call i32 (i32, i8*, ...) @fprintf(i32 %138, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i8* %15, i8* %139)
%141 = load i32, i32* @EXIT_FAILURE
%142 = call i32 @exit(i32 %141)
unreachable
143: ; preds = %134, %188
%144 = call i32 @input_timeout(i32 %34, double %20)
switch i32 %144, label %171 [
i32 -1, label %145
i32 0, label %152
]
145: ; preds = %143
%146 = load i32, i32* @stderr
%147 = load i64, i64* @errno
%148 = call i8* @strerror(i64 %147)
%149 = call i32 (i32, i8*, ...) @fprintf(i32 %146, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i8* %148)
%150 = load i32, i32* @EXIT_FAILURE
%151 = call i32 @exit(i32 %150)
unreachable
152: ; preds = %143
%153 = load i32, i32* @SIGTERM
%154 = call i32 @kill(i32 %35, i32 %153)
%155 = icmp slt i32 %154, 0
br i1 %155, label %156, label %160
156: ; preds = %152
%157 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0))
%158 = load i32, i32* @EXIT_FAILURE
%159 = call i32 @exit(i32 %158)
unreachable
160: ; preds = %152
%161 = call i32 @wait(i32* %5)
%162 = icmp slt i32 %161, 0
br i1 %162, label %163, label %167
163: ; preds = %160
%164 = call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.10, i64 0, i64 0))
%165 = load i32, i32* @EXIT_FAILURE
%166 = call i32 @exit(i32 %165)
unreachable
167: ; preds = %160
%168 = load i32, i32* %5
%169 = call i32 @process_term_status(i32 %168)
%170 = call i32 @assert(i32 0)
br label %171
171: ; preds = %143, %167
%172 = call i32 @read(i32 %34, i8* %4, i32 1)
switch i32 %172, label %188 [
i32 0, label %173
i32 -1, label %184
]
173: ; preds = %171
%174 = call i32 @wait(i32* %6)
%175 = icmp slt i32 %174, 0
br i1 %175, label %176, label %180
176: ; preds = %173
%177 = call i32 @perror(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.11, i64 0, i64 0))
%178 = load i32, i32* @EXIT_FAILURE
%179 = call i32 @exit(i32 %178)
unreachable
180: ; preds = %173
%181 = load i32, i32* %6
%182 = call i32 @process_term_status(i32 %181)
%183 = call i32 @assert(i32 0)
br label %188
184: ; preds = %171
%185 = call i32 @perror(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.12, i64 0, i64 0))
%186 = load i32, i32* @EXIT_FAILURE
%187 = call i32 @exit(i32 %186)
unreachable
188: ; preds = %171, %180
%189 = call i32 @write(i32 %132, i8* %4, i32 1)
br label %143
}