#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 /*<<< orphan*/ systemid_path;
struct timeval {
  int tv_sec;
  scalar_t__ tv_usec;
};
typedef int /*<<< orphan*/ fd_set;
typedef int /*<<< orphan*/ buffer;

/* Variables and functions */
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int LOG_CONS;
int /*<<< orphan*/ LOG_DAEMON;
int /*<<< orphan*/ LOG_DEBUG;
int /*<<< orphan*/ LOG_ERR;
int /*<<< orphan*/ LOG_INFO;
int LOG_ODELAY;
int LOG_PID;
int /*<<< orphan*/ LOG_WARNING;
int /*<<< orphan*/ R_OK;
int STDERR_FILENO;
int STDOUT_FILENO;
int WEXITSTATUS(int);
scalar_t__ WIFEXITED(int);
int /*<<< orphan*/ WNOHANG;
scalar_t__ access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ closelog();
int /*<<< orphan*/ dup2(int, int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ execv(char *, char **);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fork();
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ openlog(char *, int, int /*<<< orphan*/);
scalar_t__ parse_systemid_path(char *, int);
scalar_t__ pipe(int *);
int /*<<< orphan*/ printf(char *);
int read(int, char *, int);
char *realloc(char *, int);
int select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, struct timeval *);
int /*<<< orphan*/ set_signal_handlers();
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
scalar_t__ strlen(char *);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ unset_signal_handlers();
int waitpid(int, int *, int /*<<< orphan*/);
int rhn_do_action(void) {
  int child;
  int retval;
  int fds[2];
  char systemid_path[512] = {0};
  if (access("/etc/sysconfig/rhn/up2date", R_OK)) {
    syslog(LOG_DEBUG, "%s does not exist or is unreadable",
           "/etc/sysconfig/rhn/up2date");
    return -1;
  }
  if (parse_systemid_path(systemid_path, sizeof(systemid_path))) {
    syslog(LOG_DEBUG, "%s does not contain valid systemIdPath entry",
           "/etc/sysconfig/rhn/up2date");
    return -1;
  }
  if (access(systemid_path, R_OK)) {
    syslog(LOG_DEBUG, "%s does not exist or is unreadable", systemid_path);
    return -1;
  }
  if (pipe(fds) != 0) {
    syslog(LOG_ERR, "Could not create pipe for forking process; %m");
    return -1;
  }
  if ((child = fork()) == 0) {
    char *args[] = {NULL, NULL};
    close(fds[0]);
    closelog();
    if (fds[1] != STDOUT_FILENO) {
      dup2(fds[1], STDOUT_FILENO);
      close(fds[1]);
    }
    dup2(STDOUT_FILENO, STDERR_FILENO);
    openlog("rhnsd", LOG_CONS | LOG_ODELAY | LOG_PID, LOG_DAEMON);
    syslog(LOG_DEBUG, "running program %s", "/usr/sbin/rhn_check");
    unset_signal_handlers();
    args[0] = "/usr/sbin/rhn_check";
    execv("/usr/sbin/rhn_check", args);
    set_signal_handlers();
    syslog(LOG_ERR, "could not execute %s : %s", "/usr/sbin/rhn_check",
           strerror(errno));
    exit(errno);
  } else if (child > 0) {
    int ret = 1;
    char *buf, buffer[10];
    int bufsize = 0;
    buf = malloc(sizeof(buffer));
    if (buf == NULL) {
      syslog(LOG_ERR, "out of memory");
      return -1;
    } else {
      bufsize = sizeof(buffer);
    }
    memset(buf, '\0', bufsize);
    close(fds[1]);
    while (ret > 0) {
      struct timeval tv;
      fd_set rset;
      memset(buffer, '\0', sizeof(buffer));
      tv.tv_sec = 2;
      tv.tv_usec = 0;
      FD_ZERO(&rset);
      FD_SET(fds[0], &rset);
      ret = select(fds[0] + 1, &rset, NULL, NULL, &tv);
      if (ret < 0) {
        syslog(LOG_ERR, "error in select(): %m");
        printf("returning -1\n");
        free(buf);
        close(fds[0]);
        return -1;
      } else if (ret > 0) {
        int chars;
        chars = read(fds[0], buffer, sizeof(buffer) - 1);
        if (chars > 0) {
          bufsize += chars;
          buf = realloc(buf, bufsize);
          strcat(buf, buffer);
        } else {
          ret = 0;
        }
      }
      if (ret == 0) {
        ret = waitpid(child, &retval, WNOHANG);
        if (ret == child) {
          if (strlen(buffer) > 0)
            syslog(LOG_INFO, "%s returned: %s", "/usr/sbin/rhn_check", buf);
          free(buf);
          close(fds[0]);
          if (WIFEXITED(retval))
            return WEXITSTATUS(retval);
          return -1;
        } else if (ret == 0) {
          ret = 1;
          continue;
        }
      }
    }
    syslog(LOG_WARNING, "caught exceptional exit status from child program");
    (void)waitpid(child, &retval, 0);
    free(buf);
    close(fds[0]);
    return -2;
  } else {
    syslog(LOG_ERR, "Could not fork process %s: %m", "/usr/sbin/rhn_check");
    close(fds[0]);
    close(fds[1]);
    return -1;
  }
  close(fds[0]);
  close(fds[1]);
  return 0;
}


x86 assembly (clang, -O0):
<rhn_do_action>:
push   %rbp
mov    %rsp,%rbp
sub    $0x270,%rsp
lea    -0x220(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1090 <memset@plt>
mov    0x2cb3(%rip),%rax
mov    (%rax),%esi
lea    0xd12(%rip),%rdi
call   1150 <access@plt>
cmp    $0x0,%rax
je     1327 <rhn_do_action+0x67>
mov    0x2c8c(%rip),%rax
mov    (%rax),%edi
lea    0xd0e(%rip),%rsi
lea    0xcec(%rip),%rdx
mov    $0x0,%al
call   1110 <syslog@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1857 <rhn_do_action+0x597>
lea    -0x220(%rbp),%rdi
mov    $0x200,%esi
call   1080 <parse_systemid_path@plt>
cmp    $0x0,%rax
je     136c <rhn_do_action+0xac>
mov    0x2c47(%rip),%rax
mov    (%rax),%edi
lea    0xcec(%rip),%rsi
lea    0xca7(%rip),%rdx
mov    $0x0,%al
call   1110 <syslog@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1857 <rhn_do_action+0x597>
lea    -0x220(%rbp),%rdi
mov    0x2c1e(%rip),%rax
mov    (%rax),%esi
call   1150 <access@plt>
cmp    $0x0,%rax
je     13b5 <rhn_do_action+0xf5>
mov    0x2bfe(%rip),%rax
mov    (%rax),%edi
lea    -0x220(%rbp),%rdx
lea    0xc79(%rip),%rsi
mov    $0x0,%al
call   1110 <syslog@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1857 <rhn_do_action+0x597>
lea    -0x14(%rbp),%rdi
call   10b0 <pipe@plt>
cmp    $0x0,%rax
je     13eb <rhn_do_action+0x12b>
mov    0x2ba9(%rip),%rax
mov    (%rax),%edi
lea    0xc93(%rip),%rsi
mov    $0x0,%al
call   1110 <syslog@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1857 <rhn_do_action+0x597>
mov    $0x0,%al
call   11e0 <fork@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jne    1527 <rhn_do_action+0x267>
lea    -0x230(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1090 <memset@plt>
mov    -0x14(%rbp),%edi
call   10a0 <close@plt>
mov    $0x0,%al
call   1040 <closelog@plt>
mov    -0x10(%rbp),%eax
mov    0x2bc6(%rip),%rcx
cmp    (%rcx),%eax
je     144b <rhn_do_action+0x18b>
mov    -0x10(%rbp),%edi
mov    0x2bb4(%rip),%rax
mov    (%rax),%esi
call   1060 <dup2@plt>
mov    -0x10(%rbp),%edi
call   10a0 <close@plt>
mov    0x2b9e(%rip),%rax
mov    (%rax),%edi
mov    0x2b45(%rip),%rax
mov    (%rax),%esi
call   1060 <dup2@plt>
mov    0x2b3f(%rip),%rax
mov    (%rax),%esi
mov    0x2b6e(%rip),%rax
or     (%rax),%esi
mov    0x2b3d(%rip),%rax
or     (%rax),%esi
mov    0x2b54(%rip),%rax
mov    (%rax),%edx
lea    0xc0c(%rip),%rdi
call   1170 <openlog@plt>
mov    0x2af7(%rip),%rax
mov    (%rax),%edi
lea    0xbfd(%rip),%rsi
lea    0xc09(%rip),%rdx
mov    $0x0,%al
call   1110 <syslog@plt>
mov    $0x0,%al
call   11c0 <unset_signal_handlers@plt>
lea    0xbf4(%rip),%rax
mov    %rax,-0x230(%rbp)
lea    -0x230(%rbp),%rsi
lea    0xbdf(%rip),%rdi
call   11d0 <execv@plt>
mov    $0x0,%al
call   10d0 <set_signal_handlers@plt>
mov    0x2a92(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x26c(%rbp)
mov    0x2abb(%rip),%rax
mov    (%rax),%edi
call   11a0 <strerror@plt>
mov    -0x26c(%rbp),%edi
mov    %eax,%ecx
lea    0xbbb(%rip),%rsi
lea    0xba0(%rip),%rdx
mov    $0x0,%al
call   1110 <syslog@plt>
mov    0x2a90(%rip),%rax
mov    (%rax),%edi
call   1190 <exit@plt>
cmpl   $0x0,-0x8(%rbp)
jle    1822 <rhn_do_action+0x562>
movl   $0x1,-0x234(%rbp)
movl   $0x0,-0x250(%rbp)
mov    $0xa,%edi
call   1100 <malloc@plt>
mov    %rax,-0x240(%rbp)
cmpq   $0x0,-0x240(%rbp)
jne    1587 <rhn_do_action+0x2c7>
mov    0x2a0d(%rip),%rax
mov    (%rax),%edi
lea    0xb6c(%rip),%rsi
mov    $0x0,%al
call   1110 <syslog@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1857 <rhn_do_action+0x597>
movl   $0xa,-0x250(%rbp)
mov    -0x240(%rbp),%rdi
mov    -0x250(%rbp),%edx
xor    %esi,%esi
call   1090 <memset@plt>
mov    -0x10(%rbp),%edi
call   10a0 <close@plt>
cmpl   $0x0,-0x234(%rbp)
jle    17dd <rhn_do_action+0x51d>
lea    -0x24a(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1090 <memset@plt>
movl   $0x2,-0x260(%rbp)
movq   $0x0,-0x258(%rbp)
lea    -0x264(%rbp),%rdi
call   10e0 <FD_ZERO@plt>
mov    -0x14(%rbp),%edi
lea    -0x264(%rbp),%rsi
call   11b0 <FD_SET@plt>
mov    -0x14(%rbp),%edi
add    $0x1,%edi
lea    -0x264(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x260(%rbp),%r8
mov    %rcx,%rdx
call   10f0 <select@plt>
mov    %eax,-0x234(%rbp)
cmpl   $0x0,-0x234(%rbp)
jge    1673 <rhn_do_action+0x3b3>
mov    0x2941(%rip),%rax
mov    (%rax),%edi
lea    0xaae(%rip),%rsi
mov    $0x0,%al
call   1110 <syslog@plt>
lea    0xab6(%rip),%rdi
call   1070 <printf@plt>
mov    -0x240(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%edi
call   10a0 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1857 <rhn_do_action+0x597>
cmpl   $0x0,-0x234(%rbp)
jle    16f9 <rhn_do_action+0x439>
mov    -0x14(%rbp),%edi
lea    -0x24a(%rbp),%rsi
mov    $0x9,%edx
call   10c0 <read@plt>
mov    %eax,-0x268(%rbp)
cmpl   $0x0,-0x268(%rbp)
jle    16ea <rhn_do_action+0x42a>
mov    -0x268(%rbp),%eax
add    -0x250(%rbp),%eax
mov    %eax,-0x250(%rbp)
mov    -0x240(%rbp),%rdi
mov    -0x250(%rbp),%esi
call   1120 <realloc@plt>
mov    %rax,-0x240(%rbp)
mov    -0x240(%rbp),%rdi
lea    -0x24a(%rbp),%rsi
call   1160 <strcat@plt>
jmp    16f4 <rhn_do_action+0x434>
movl   $0x0,-0x234(%rbp)
jmp    16f9 <rhn_do_action+0x439>
jmp    16fe <rhn_do_action+0x43e>
cmpl   $0x0,-0x234(%rbp)
jne    17d8 <rhn_do_action+0x518>
mov    -0x8(%rbp),%edi
mov    0x28bb(%rip),%rax
mov    (%rax),%edx
lea    -0xc(%rbp),%rsi
call   1140 <waitpid@plt>
mov    %eax,-0x234(%rbp)
mov    -0x234(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    17b2 <rhn_do_action+0x4f2>
lea    -0x24a(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x0,%rax
jle    1770 <rhn_do_action+0x4b0>
mov    0x2836(%rip),%rax
mov    (%rax),%edi
mov    -0x240(%rbp),%rcx
lea    0x9b0(%rip),%rsi
lea    0x949(%rip),%rdx
mov    $0x0,%al
call   1110 <syslog@plt>
mov    -0x240(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%edi
call   10a0 <close@plt>
mov    -0xc(%rbp),%edi
call   1180 <WIFEXITED@plt>
cmp    $0x0,%rax
je     17a6 <rhn_do_action+0x4e6>
mov    -0xc(%rbp),%edi
call   1130 <WEXITSTATUS@plt>
mov    %eax,-0x4(%rbp)
jmp    1857 <rhn_do_action+0x597>
movl   $0xffffffff,-0x4(%rbp)
jmp    1857 <rhn_do_action+0x597>
cmpl   $0x0,-0x234(%rbp)
jne    17ce <rhn_do_action+0x50e>
movl   $0x1,-0x234(%rbp)
jmp    15ad <rhn_do_action+0x2ed>
jmp    17d3 <rhn_do_action+0x513>
jmp    17d8 <rhn_do_action+0x518>
jmp    15ad <rhn_do_action+0x2ed>
mov    0x27e4(%rip),%rax
mov    (%rax),%edi
lea    0x935(%rip),%rsi
mov    $0x0,%al
call   1110 <syslog@plt>
mov    -0x8(%rbp),%edi
lea    -0xc(%rbp),%rsi
xor    %edx,%edx
call   1140 <waitpid@plt>
mov    -0x240(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%edi
call   10a0 <close@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    1857 <rhn_do_action+0x597>
mov    0x274f(%rip),%rax
mov    (%rax),%edi
lea    0x922(%rip),%rsi
lea    0x879(%rip),%rdx
mov    $0x0,%al
call   1110 <syslog@plt>
mov    -0x14(%rbp),%edi
call   10a0 <close@plt>
mov    -0x10(%rbp),%edi
call   10a0 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x270,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rhn_do_action>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x238,%rsp
lea    0x30(%rsp),%rdi
mov    $0x200,%edx
xor    %esi,%esi
call   1090 <memset@plt>
mov    0x2caf(%rip),%rbx
mov    (%rbx),%esi
lea    0xd0e(%rip),%rdi
call   1150 <access@plt>
test   %rax,%rax
je     130e <rhn_do_action+0x4e>
mov    0x2c8d(%rip),%rax
mov    (%rax),%edi
lea    0xd0f(%rip),%rsi
jmp    1332 <rhn_do_action+0x72>
lea    0x30(%rsp),%rdi
mov    $0x200,%esi
call   1080 <parse_systemid_path@plt>
test   %rax,%rax
je     1357 <rhn_do_action+0x97>
mov    0x2c67(%rip),%rax
mov    (%rax),%edi
lea    0xd0c(%rip),%rsi
lea    0xcc7(%rip),%rdx
xor    %eax,%eax
call   1110 <syslog@plt>
mov    $0xffffffff,%eax
add    $0x238,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%rbx),%esi
lea    0x30(%rsp),%rdi
call   1150 <access@plt>
test   %rax,%rax
je     137f <rhn_do_action+0xbf>
mov    0x2c21(%rip),%rax
mov    (%rax),%edi
lea    0xca3(%rip),%rsi
lea    0x30(%rsp),%rdx
jmp    1339 <rhn_do_action+0x79>
lea    0x4(%rsp),%rdi
call   10b0 <pipe@plt>
test   %rax,%rax
je     13a7 <rhn_do_action+0xe7>
mov    0x2be3(%rip),%rax
mov    (%rax),%edi
lea    0xccd(%rip),%rsi
xor    %eax,%eax
call   1110 <syslog@plt>
jmp    1340 <rhn_do_action+0x80>
xor    %eax,%eax
call   11e0 <fork@plt>
test   %eax,%eax
je     15e4 <rhn_do_action+0x324>
jle    14c8 <rhn_do_action+0x208>
mov    %eax,%ebp
mov    $0xa,%r12d
mov    $0xa,%edi
call   1100 <malloc@plt>
test   %rax,%rax
je     14f5 <rhn_do_action+0x235>
mov    %rax,%r14
mov    %rax,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1090 <memset@plt>
mov    0x8(%rsp),%edi
call   10a0 <close@plt>
lea    0x26(%rsp),%r15
lea    0x20(%rsp),%rbx
jmp    1423 <rhn_do_action+0x163>
add    %eax,%r12d
mov    %r14,%rdi
mov    %r12d,%esi
call   1120 <realloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %r15,%rsi
call   1160 <strcat@plt>
test   %r13d,%r13d
jle    1543 <rhn_do_action+0x283>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1090 <memset@plt>
movl   $0x2,0x10(%rsp)
movq   $0x0,0x18(%rsp)
mov    %rbx,%rdi
call   10e0 <FD_ZERO@plt>
mov    0x4(%rsp),%edi
mov    %rbx,%rsi
call   11b0 <FD_SET@plt>
mov    0x4(%rsp),%edi
add    $0x1,%edi
mov    %rbx,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
lea    0x10(%rsp),%r8
call   10f0 <select@plt>
test   %eax,%eax
js     150a <rhn_do_action+0x24a>
je     1495 <rhn_do_action+0x1d5>
mov    %eax,%r13d
mov    0x4(%rsp),%edi
mov    %r15,%rsi
mov    $0x9,%edx
call   10c0 <read@plt>
test   %eax,%eax
jg     13fe <rhn_do_action+0x13e>
mov    0x2b34(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%edi
lea    0xc(%rsp),%rsi
call   1140 <waitpid@plt>
cmp    %ebp,%eax
je     1583 <rhn_do_action+0x2c3>
mov    %eax,%r13d
test   %eax,%eax
jne    141a <rhn_do_action+0x15a>
mov    $0x1,%r13d
jmp    141a <rhn_do_action+0x15a>
mov    0x2aa9(%rip),%rax
mov    (%rax),%edi
lea    0xc6e(%rip),%rsi
lea    0xbd3(%rip),%rdx
xor    %eax,%eax
call   1110 <syslog@plt>
mov    0x4(%rsp),%edi
call   10a0 <close@plt>
mov    0x8(%rsp),%edi
jmp    1539 <rhn_do_action+0x279>
mov    0x2a7c(%rip),%rax
mov    (%rax),%edi
lea    0xbdb(%rip),%rsi
jmp    139e <rhn_do_action+0xde>
mov    0x2a67(%rip),%rax
mov    (%rax),%edi
lea    0xbd4(%rip),%rsi
xor    %eax,%eax
call   1110 <syslog@plt>
lea    0xc3c(%rip),%rdi
call   1050 <puts@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x4(%rsp),%edi
call   10a0 <close@plt>
jmp    1340 <rhn_do_action+0x80>
mov    0x2a7e(%rip),%rax
mov    (%rax),%edi
lea    0xbc1(%rip),%rsi
xor    %eax,%eax
call   1110 <syslog@plt>
lea    0xc(%rsp),%rsi
mov    %ebp,%edi
xor    %edx,%edx
call   1140 <waitpid@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x4(%rsp),%edi
call   10a0 <close@plt>
mov    $0xfffffffe,%eax
jmp    1345 <rhn_do_action+0x85>
lea    0x26(%rsp),%rdi
call   1060 <strlen@plt>
test   %rax,%rax
jle    15b3 <rhn_do_action+0x2f3>
mov    0x29ef(%rip),%rax
mov    (%rax),%edi
lea    0xb62(%rip),%rsi
lea    0xb09(%rip),%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1110 <syslog@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x4(%rsp),%edi
call   10a0 <close@plt>
mov    0xc(%rsp),%edi
call   1180 <WIFEXITED@plt>
test   %rax,%rax
je     1340 <rhn_do_action+0x80>
mov    0xc(%rsp),%edi
call   1130 <WEXITSTATUS@plt>
jmp    1345 <rhn_do_action+0x85>
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
mov    0x4(%rsp),%edi
call   10a0 <close@plt>
xor    %eax,%eax
call   1040 <closelog@plt>
mov    0x8(%rsp),%edi
mov    0x29e9(%rip),%rbx
mov    (%rbx),%esi
cmp    %esi,%edi
je     161d <rhn_do_action+0x35d>
call   1070 <dup2@plt>
mov    0x8(%rsp),%edi
call   10a0 <close@plt>
mov    (%rbx),%edi
mov    0x297c(%rip),%rax
mov    (%rax),%esi
call   1070 <dup2@plt>
mov    0x2976(%rip),%rax
mov    0x29a7(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2974(%rip),%rax
or     (%rax),%esi
mov    0x298b(%rip),%rax
mov    (%rax),%edx
lea    0xa43(%rip),%rdi
call   1170 <openlog@plt>
mov    0x292e(%rip),%rax
mov    (%rax),%edi
lea    0xa34(%rip),%rsi
lea    0xa40(%rip),%rbx
mov    %rbx,%rdx
xor    %eax,%eax
call   1110 <syslog@plt>
xor    %eax,%eax
call   11c0 <unset_signal_handlers@plt>
mov    %rbx,0x10(%rsp)
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   11d0 <execv@plt>
xor    %eax,%eax
call   10d0 <set_signal_handlers@plt>
mov    0x28d5(%rip),%rax
mov    (%rax),%ebp
mov    0x2904(%rip),%r14
mov    (%r14),%edi
call   11a0 <strerror@plt>
lea    0xa0b(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %eax,%ecx
xor    %eax,%eax
call   1110 <syslog@plt>
mov    (%r14),%edi
call   1190 <exit@plt>

LLVM IR (-O0):
%struct.timeval = type { i32, i64 }
@.str = [27 x i8] c"/etc/sysconfig/rhn/up2date\00"
@R_OK = global i32 0
@LOG_DEBUG = global i32 0
@.str.1 = [35 x i8] c"%s does not exist or is unreadable\00"
@.str.2 = [45 x i8] c"%s does not contain valid systemIdPath entry\00"
@LOG_ERR = global i32 0
@.str.3 = [46 x i8] c"Could not create pipe for forking process; %m\00"
@STDOUT_FILENO = global i32 0
@STDERR_FILENO = global i32 0
@.str.4 = [6 x i8] c"rhnsd\00"
@LOG_CONS = global i32 0
@LOG_ODELAY = global i32 0
@LOG_PID = global i32 0
@LOG_DAEMON = global i32 0
@.str.5 = [19 x i8] c"running program %s\00"
@.str.6 = [20 x i8] c"/usr/sbin/rhn_check\00"
@.str.7 = [26 x i8] c"could not execute %s : %s\00"
@errno = global i32 0
@.str.8 = [14 x i8] c"out of memory\00"
@.str.9 = [22 x i8] c"error in select(): %m\00"
@.str.10 = [14 x i8] c"returning -1\0A\00"
@WNOHANG = global i32 0
@LOG_INFO = global i32 0
@.str.11 = [16 x i8] c"%s returned: %s\00"
@LOG_WARNING = global i32 0
@.str.12 = [50 x i8] c"caught exceptional exit status from child program\00"
@.str.13 = [30 x i8] c"Could not fork process %s: %m\00"
define i32 @rhn_do_action() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [2 x i32]
%5 = alloca [512 x i8]
%6 = alloca [2 x i8*]
%7 = alloca i32
%8 = alloca i8*
%9 = alloca [10 x i8]
%10 = alloca i32
%11 = alloca %struct.timeval
%12 = alloca i32
%13 = alloca i32
%14 = bitcast [512 x i8]* %5 to i8*
%15 = load i32, i32* @R_OK
%16 = call i64 @access(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %0
%19 = load i32, i32* @LOG_DEBUG
%20 = call i32 (i32, i8*, ...) @syslog(i32 %19, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %1
br label %214
21: ; preds = %0
%22 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%23 = call i64 @parse_systemid_path(i8* %22, i32 512)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = load i32, i32* @LOG_DEBUG
%27 = call i32 (i32, i8*, ...) @syslog(i32 %26, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %1
br label %214
28: ; preds = %21
%29 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%30 = load i32, i32* @R_OK
%31 = call i64 @access(i8* %29, i32 %30)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %37
33: ; preds = %28
%34 = load i32, i32* @LOG_DEBUG
%35 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%36 = call i32 (i32, i8*, ...) @syslog(i32 %34, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %35)
store i32 -1, i32* %1
br label %214
37: ; preds = %28
%38 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%39 = call i64 @pipe(i32* %38)
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %37
%42 = load i32, i32* @LOG_ERR
%43 = call i32 (i32, i8*, ...) @syslog(i32 %42, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %1
br label %214
44: ; preds = %37
%45 = call i32 (...) @fork()
store i32 %45, i32* %2
%46 = icmp eq i32 %45, 0
br i1 %46, label %47, label %89
47: ; preds = %44
%48 = bitcast [2 x i8*]* %6 to i8*
%49 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%50 = load i32, i32* %49
%51 = call i32 @close(i32 %50)
%52 = call i32 (...) @closelog()
%53 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%54 = load i32, i32* %53
%55 = load i32, i32* @STDOUT_FILENO
%56 = icmp ne i32 %54, %55
br i1 %56, label %57, label %65
57: ; preds = %47
%58 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%59 = load i32, i32* %58
%60 = load i32, i32* @STDOUT_FILENO
%61 = call i32 @dup2(i32 %59, i32 %60)
%62 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%63 = load i32, i32* %62
%64 = call i32 @close(i32 %63)
br label %65
65: ; preds = %57, %47
%66 = load i32, i32* @STDOUT_FILENO
%67 = load i32, i32* @STDERR_FILENO
%68 = call i32 @dup2(i32 %66, i32 %67)
%69 = load i32, i32* @LOG_CONS
%70 = load i32, i32* @LOG_ODELAY
%71 = or i32 %69, %70
%72 = load i32, i32* @LOG_PID
%73 = or i32 %71, %72
%74 = load i32, i32* @LOG_DAEMON
%75 = call i32 @openlog(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %73, i32 %74)
%76 = load i32, i32* @LOG_DEBUG
%77 = call i32 (i32, i8*, ...) @syslog(i32 %76, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%78 = call i32 (...) @unset_signal_handlers()
%79 = getelementptr inbounds [2 x i8*], [2 x i8*]* %6, i64 0, i64 0
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8** %79
%80 = getelementptr inbounds [2 x i8*], [2 x i8*]* %6, i64 0, i64 0
%81 = call i32 @execv(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8** %80)
%82 = call i32 (...) @set_signal_handlers()
%83 = load i32, i32* @LOG_ERR
%84 = load i32, i32* @errno
%85 = call i32 @strerror(i32 %84)
%86 = call i32 (i32, i8*, ...) @syslog(i32 %83, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %85)
%87 = load i32, i32* @errno
%88 = call i32 @exit(i32 %87)
unreachable
89: ; preds = %44
%90 = load i32, i32* %2
%91 = icmp sgt i32 %90, 0
br i1 %91, label %92, label %205
92: ; preds = %89
store i32 1, i32* %7
store i32 0, i32* %10
%93 = call i8* @malloc(i32 10)
store i8* %93, i8** %8
%94 = load i8*, i8** %8
%95 = icmp eq i8* %94, null
br i1 %95, label %96, label %99
96: ; preds = %92
%97 = load i32, i32* @LOG_ERR
%98 = call i32 (i32, i8*, ...) @syslog(i32 %97, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0))
store i32 -1, i32* %1
br label %214
99: ; preds = %92
store i32 10, i32* %10
br label %100
100: ; preds = %99
%101 = load i8*, i8** %8
%102 = load i32, i32* %10
%103 = call i32 @memset(i8* %101, i8 signext 0, i32 %102)
%104 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%105 = load i32, i32* %104
%106 = call i32 @close(i32 %105)
br label %107
107: ; preds = %194, %191, %100
%108 = load i32, i32* %7
%109 = icmp sgt i32 %108, 0
br i1 %109, label %110, label %195
110: ; preds = %107
%111 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 0
%112 = call i32 @memset(i8* %111, i8 signext 0, i32 10)
%113 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i32 0, i32 0
store i32 2, i32* %113
%114 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i32 0, i32 1
store i64 0, i64* %114
%115 = call i32 @FD_ZERO(i32* %12)
%116 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%117 = load i32, i32* %116
%118 = call i32 @FD_SET(i32 %117, i32* %12)
%119 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%120 = load i32, i32* %119
%121 = add nsw i32 %120, 1
%122 = call i32 @select(i32 %121, i32* %12, i32* null, i32* null, %struct.timeval* %11)
store i32 %122, i32* %7
%123 = load i32, i32* %7
%124 = icmp slt i32 %123, 0
br i1 %124, label %125, label %134
125: ; preds = %110
%126 = load i32, i32* @LOG_ERR
%127 = call i32 (i32, i8*, ...) @syslog(i32 %126, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0))
%128 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0))
%129 = load i8*, i8** %8
%130 = call i32 @free(i8* %129)
%131 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%132 = load i32, i32* %131
%133 = call i32 @close(i32 %132)
store i32 -1, i32* %1
br label %214
134: ; preds = %110
%135 = load i32, i32* %7
%136 = icmp sgt i32 %135, 0
br i1 %136, label %137, label %156
137: ; preds = %134
%138 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%139 = load i32, i32* %138
%140 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 0
%141 = call i32 @read(i32 %139, i8* %140, i32 9)
store i32 %141, i32* %13
%142 = load i32, i32* %13
%143 = icmp sgt i32 %142, 0
br i1 %143, label %144, label %154
144: ; preds = %137
%145 = load i32, i32* %13
%146 = load i32, i32* %10
%147 = add nsw i32 %146, %145
store i32 %147, i32* %10
%148 = load i8*, i8** %8
%149 = load i32, i32* %10
%150 = call i8* @realloc(i8* %148, i32 %149)
store i8* %150, i8** %8
%151 = load i8*, i8** %8
%152 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 0
%153 = call i32 @strcat(i8* %151, i8* %152)
br label %155
154: ; preds = %137
store i32 0, i32* %7
br label %155
155: ; preds = %154, %144
br label %156
156: ; preds = %155, %134
br label %157
157: ; preds = %156
%158 = load i32, i32* %7
%159 = icmp eq i32 %158, 0
br i1 %159, label %160, label %194
160: ; preds = %157
%161 = load i32, i32* %2
%162 = load i32, i32* @WNOHANG
%163 = call i32 @waitpid(i32 %161, i32* %3, i32 %162)
store i32 %163, i32* %7
%164 = load i32, i32* %7
%165 = load i32, i32* %2
%166 = icmp eq i32 %164, %165
br i1 %166, label %167, label %188
167: ; preds = %160
%168 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 0
%169 = call i64 @strlen(i8* %168)
%170 = icmp sgt i64 %169, 0
br i1 %170, label %171, label %175
171: ; preds = %167
%172 = load i32, i32* @LOG_INFO
%173 = load i8*, i8** %8
%174 = call i32 (i32, i8*, ...) @syslog(i32 %172, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %173)
br label %175
175: ; preds = %171, %167
%176 = load i8*, i8** %8
%177 = call i32 @free(i8* %176)
%178 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%179 = load i32, i32* %178
%180 = call i32 @close(i32 %179)
%181 = load i32, i32* %3
%182 = call i64 @WIFEXITED(i32 %181)
%183 = icmp ne i64 %182, 0
br i1 %183, label %184, label %187
184: ; preds = %175
%185 = load i32, i32* %3
%186 = call i32 @WEXITSTATUS(i32 %185)
store i32 %186, i32* %1
br label %214
187: ; preds = %175
store i32 -1, i32* %1
br label %214
188: ; preds = %160
%189 = load i32, i32* %7
%190 = icmp eq i32 %189, 0
br i1 %190, label %191, label %192
191: ; preds = %188
store i32 1, i32* %7
br label %107
192: ; preds = %188
br label %193
193: ; preds = %192
br label %194
194: ; preds = %193, %157
br label %107
195: ; preds = %107
%196 = load i32, i32* @LOG_WARNING
%197 = call i32 (i32, i8*, ...) @syslog(i32 %196, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.12, i64 0, i64 0))
%198 = load i32, i32* %2
%199 = call i32 @waitpid(i32 %198, i32* %3, i32 0)
%200 = load i8*, i8** %8
%201 = call i32 @free(i8* %200)
%202 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%203 = load i32, i32* %202
%204 = call i32 @close(i32 %203)
store i32 -2, i32* %1
br label %214
205: ; preds = %89
%206 = load i32, i32* @LOG_ERR
%207 = call i32 (i32, i8*, ...) @syslog(i32 %206, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%208 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%209 = load i32, i32* %208
%210 = call i32 @close(i32 %209)
%211 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%212 = load i32, i32* %211
%213 = call i32 @close(i32 %212)
store i32 -1, i32* %1
br label %214
214: ; preds = %205, %195, %187, %184, %125, %96, %41, %33, %25, %18
%215 = load i32, i32* %1
ret i32 %215
}

LLVM IR (-O2):
%struct.timeval = type { i32, i64 }
@.str = [27 x i8] c"/etc/sysconfig/rhn/up2date\00"
@R_OK = global i32 0
@LOG_DEBUG = global i32 0
@.str.1 = [35 x i8] c"%s does not exist or is unreadable\00"
@.str.2 = [45 x i8] c"%s does not contain valid systemIdPath entry\00"
@LOG_ERR = global i32 0
@.str.3 = [46 x i8] c"Could not create pipe for forking process; %m\00"
@STDOUT_FILENO = global i32 0
@STDERR_FILENO = global i32 0
@.str.4 = [6 x i8] c"rhnsd\00"
@LOG_CONS = global i32 0
@LOG_ODELAY = global i32 0
@LOG_PID = global i32 0
@LOG_DAEMON = global i32 0
@.str.5 = [19 x i8] c"running program %s\00"
@.str.6 = [20 x i8] c"/usr/sbin/rhn_check\00"
@.str.7 = [26 x i8] c"could not execute %s : %s\00"
@errno = global i32 0
@.str.8 = [14 x i8] c"out of memory\00"
@.str.9 = [22 x i8] c"error in select(): %m\00"
@WNOHANG = global i32 0
@LOG_INFO = global i32 0
@.str.11 = [16 x i8] c"%s returned: %s\00"
@LOG_WARNING = global i32 0
@.str.12 = [50 x i8] c"caught exceptional exit status from child program\00"
@.str.13 = [30 x i8] c"Could not fork process %s: %m\00"
@str = [13 x i8] c"returning -1\00"
define i32 @rhn_do_action() {
%1 = alloca i32
%2 = alloca [2 x i32]
%3 = alloca [512 x i8]
%4 = alloca [2 x i8*]
%5 = alloca [10 x i8]
%6 = alloca %struct.timeval
%7 = alloca i32
%8 = bitcast i32* %1 to i8*
%9 = bitcast [2 x i32]* %2 to i8*
%10 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%11 = load i32, i32* @R_OK
%12 = tail call i64 @access(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %0
%15 = load i32, i32* @LOG_DEBUG
%16 = tail call i32 (i32, i8*, ...) @syslog(i32 %15, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %173
17: ; preds = %0
%18 = call i64 @parse_systemid_path(i8* %10, i32 512)
%19 = icmp eq i64 %18, 0
br i1 %19, label %23, label %20
20: ; preds = %17
%21 = load i32, i32* @LOG_DEBUG
%22 = call i32 (i32, i8*, ...) @syslog(i32 %21, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %173
23: ; preds = %17
%24 = load i32, i32* @R_OK
%25 = call i64 @access(i8* %10, i32 %24)
%26 = icmp eq i64 %25, 0
br i1 %26, label %30, label %27
27: ; preds = %23
%28 = load i32, i32* @LOG_DEBUG
%29 = call i32 (i32, i8*, ...) @syslog(i32 %28, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %10)
br label %173
30: ; preds = %23
%31 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%32 = call i64 @pipe(i32* %31)
%33 = icmp eq i64 %32, 0
br i1 %33, label %37, label %34
34: ; preds = %30
%35 = load i32, i32* @LOG_ERR
%36 = call i32 (i32, i8*, ...) @syslog(i32 %35, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0))
br label %173
37: ; preds = %30
%38 = call i32 (...) @fork()
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %77
40: ; preds = %37
%41 = bitcast [2 x i8*]* %4 to i8*
%42 = load i32, i32* %31
%43 = call i32 @close(i32 %42)
%44 = call i32 (...) @closelog()
%45 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%46 = load i32, i32* %45
%47 = load i32, i32* @STDOUT_FILENO
%48 = icmp eq i32 %46, %47
br i1 %48, label %54, label %49
49: ; preds = %40
%50 = call i32 @dup2(i32 %46, i32 %47)
%51 = load i32, i32* %45
%52 = call i32 @close(i32 %51)
%53 = load i32, i32* @STDOUT_FILENO
br label %54
54: ; preds = %49, %40
%55 = phi i32 [ %53, %49 ], [ %46, %40 ]
%56 = load i32, i32* @STDERR_FILENO
%57 = call i32 @dup2(i32 %55, i32 %56)
%58 = load i32, i32* @LOG_CONS
%59 = load i32, i32* @LOG_ODELAY
%60 = or i32 %59, %58
%61 = load i32, i32* @LOG_PID
%62 = or i32 %60, %61
%63 = load i32, i32* @LOG_DAEMON
%64 = call i32 @openlog(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %62, i32 %63)
%65 = load i32, i32* @LOG_DEBUG
%66 = call i32 (i32, i8*, ...) @syslog(i32 %65, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%67 = call i32 (...) @unset_signal_handlers()
%68 = getelementptr inbounds [2 x i8*], [2 x i8*]* %4, i64 0, i64 0
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8** %68
%69 = call i32 @execv(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8** %68)
%70 = call i32 (...) @set_signal_handlers()
%71 = load i32, i32* @LOG_ERR
%72 = load i32, i32* @errno
%73 = call i32 @strerror(i32 %72)
%74 = call i32 (i32, i8*, ...) @syslog(i32 %71, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %73)
%75 = load i32, i32* @errno
%76 = call i32 @exit(i32 %75)
unreachable
77: ; preds = %37
%78 = icmp sgt i32 %38, 0
br i1 %78, label %79, label %165
79: ; preds = %77
%80 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%81 = call dereferenceable_or_null(10) i8* @malloc(i32 10)
%82 = icmp eq i8* %81, null
br i1 %82, label %83, label %86
83: ; preds = %79
%84 = load i32, i32* @LOG_ERR
%85 = call i32 (i32, i8*, ...) @syslog(i32 %84, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0))
br label %163
86: ; preds = %79
%87 = call i32 @memset(i8* %81, i8 signext 0, i32 10)
%88 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%89 = load i32, i32* %88
%90 = call i32 @close(i32 %89)
%91 = bitcast %struct.timeval* %6 to i8*
%92 = bitcast i32* %7 to i8*
%93 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 0
%94 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 1
br label %95
95: ; preds = %86, %151
%96 = phi i32 [ 10, %86 ], [ %154, %151 ]
%97 = phi i8* [ %81, %86 ], [ %153, %151 ]
%98 = call i32 @memset(i8* %80, i8 signext 0, i32 10)
store i32 2, i32* %93
store i64 0, i64* %94
%99 = call i32 @FD_ZERO(i32* %7)
%100 = load i32, i32* %31
%101 = call i32 @FD_SET(i32 %100, i32* %7)
%102 = load i32, i32* %31
%103 = add nsw i32 %102, 1
%104 = call i32 @select(i32 %103, i32* %7, i32* null, i32* null, %struct.timeval* %6)
%105 = icmp slt i32 %104, 0
br i1 %105, label %106, label %113
106: ; preds = %95
%107 = load i32, i32* @LOG_ERR
%108 = call i32 (i32, i8*, ...) @syslog(i32 %107, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0))
%109 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%110 = call i32 @free(i8* %97)
%111 = load i32, i32* %31
%112 = call i32 @close(i32 %111)
br label %149
113: ; preds = %95
%114 = icmp eq i32 %104, 0
br i1 %114, label %123, label %115
115: ; preds = %113
%116 = load i32, i32* %31
%117 = call i32 @read(i32 %116, i8* %80, i32 9)
%118 = icmp sgt i32 %117, 0
br i1 %118, label %119, label %123
119: ; preds = %115
%120 = add nsw i32 %117, %96
%121 = call i8* @realloc(i8* %97, i32 %120)
%122 = call i32 @strcat(i8* %121, i8* %80)
br label %145
123: ; preds = %113, %115
%124 = load i32, i32* @WNOHANG
%125 = call i32 @waitpid(i32 %38, i32* %1, i32 %124)
%126 = icmp eq i32 %125, %38
br i1 %126, label %127, label %143
127: ; preds = %123
%128 = call i64 @strlen(i8* %80)
%129 = icmp sgt i64 %128, 0
br i1 %129, label %130, label %133
130: ; preds = %127
%131 = load i32, i32* @LOG_INFO
%132 = call i32 (i32, i8*, ...) @syslog(i32 %131, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %97)
br label %133
133: ; preds = %130, %127
%134 = call i32 @free(i8* %97)
%135 = load i32, i32* %31
%136 = call i32 @close(i32 %135)
%137 = load i32, i32* %1
%138 = call i64 @WIFEXITED(i32 %137)
%139 = icmp eq i64 %138, 0
br i1 %139, label %149, label %140
140: ; preds = %133
%141 = load i32, i32* %1
%142 = call i32 @WEXITSTATUS(i32 %141)
br label %149
143: ; preds = %123
%144 = icmp eq i32 %125, 0
br i1 %144, label %151, label %145
145: ; preds = %119, %143
%146 = phi i32 [ %96, %143 ], [ %120, %119 ]
%147 = phi i8* [ %97, %143 ], [ %121, %119 ]
%148 = phi i32 [ %125, %143 ], [ %104, %119 ]
br label %151
149: ; preds = %106, %140, %133
%150 = phi i32 [ -1, %133 ], [ %142, %140 ], [ -1, %106 ]
br label %163
151: ; preds = %143, %145
%152 = phi i32 [ %148, %145 ], [ 1, %143 ]
%153 = phi i8* [ %147, %145 ], [ %97, %143 ]
%154 = phi i32 [ %146, %145 ], [ %96, %143 ]
%155 = icmp sgt i32 %152, 0
br i1 %155, label %95, label %156
156: ; preds = %151
%157 = load i32, i32* @LOG_WARNING
%158 = call i32 (i32, i8*, ...) @syslog(i32 %157, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.12, i64 0, i64 0))
%159 = call i32 @waitpid(i32 %38, i32* %1, i32 0)
%160 = call i32 @free(i8* %153)
%161 = load i32, i32* %31
%162 = call i32 @close(i32 %161)
br label %163
163: ; preds = %149, %156, %83
%164 = phi i32 [ -1, %83 ], [ -2, %156 ], [ %150, %149 ]
br label %173
165: ; preds = %77
%166 = load i32, i32* @LOG_ERR
%167 = call i32 (i32, i8*, ...) @syslog(i32 %166, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%168 = load i32, i32* %31
%169 = call i32 @close(i32 %168)
%170 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%171 = load i32, i32* %170
%172 = call i32 @close(i32 %171)
br label %173
173: ; preds = %165, %163, %34, %27, %20, %14
%174 = phi i32 [ -1, %14 ], [ -1, %20 ], [ -1, %27 ], [ -1, %34 ], [ %164, %163 ], [ -1, %165 ]
ret i32 %174
}