#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 stat {
  scalar_t__ st_ino;
};

/* Variables and functions */
int LOG_CONS;
int /*<<< orphan*/ LOG_ERR;
int /*<<< orphan*/ LOG_INFO;
int /*<<< orphan*/ LOG_LOCAL1;
int LOG_NDELAY;
int LOG_PID;
int /*<<< orphan*/ LOG_WARNING;
int /*<<< orphan*/ O_NONBLOCK;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ RNDGETENTCNT;
int /*<<< orphan*/ abort();
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ closelog();
int /*<<< orphan*/ fflush_unlocked(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getopt(int, char **, char *);
int ioctl(int, int /*<<< orphan*/, int *);
int open(char const *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ openlog(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ show_help();
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stat(char const *, struct stat *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, ...);
int main(int argc, char **argv) {
  const char dev_random_file[] = "/dev/random";
  int debug_flag = 0;
  int zabbix_flag = 0;
  int syslog_flag = 0;
  int verbose_flag = 0;
  int test_flag = 0;
  int samples_of_avail_ent = 60;
  int error_found = 0;
  int read_wakeup_threshold = 0;
  int write_wakeup_threshold = 0;
  int avail_ent;
  int result;
  int dev_random_filehandle;
  struct stat dev_random_stat;
  while ((result = getopt(argc, argv, "dhltvz")) != -1) {
    switch (result) {
    case 'd':
      debug_flag = 1;
      break;
    case 'h':
      show_help();
      return 0;
      break;
    case 'l':
      syslog_flag = 1;
      break;
    case 't':
      test_flag = 1;
      read_wakeup_threshold = 3400;
      write_wakeup_threshold = 4000;
      samples_of_avail_ent = 10;
      break;
    case 'v':
      verbose_flag = 1;
      break;
    case 'z':
      zabbix_flag = 1;
      break;
    default:
      show_help();
      abort();
    }
  }
  if (debug_flag) {
    fprintf(stderr,
            "DEBUG: "
            "debug_flag: %d syslog_flag: %d test_flag: %d verbose_flag: %d "
            "zabbix_flag: %d\n",
            debug_flag, syslog_flag, test_flag, verbose_flag, zabbix_flag);
  }
  dev_random_filehandle = open(dev_random_file, O_RDONLY, O_NONBLOCK);
  stat(dev_random_file, &dev_random_stat);
  if (debug_flag)
    fprintf(stderr, "DEBUG: %s I-node number: %ld\n", dev_random_file,
            (long)dev_random_stat.st_ino);
  if (syslog_flag) {
    openlog("entropy_monitor", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
  }
  if (verbose_flag)
    fprintf(stderr,
            "Collecting available entropy from %s for %d iterations every %d "
            "seconds\n",
            dev_random_file, samples_of_avail_ent, 1);
  if (!test_flag) {
    read_wakeup_threshold = 64;
    write_wakeup_threshold = 128;
  }
  while (!error_found) {
    long avail_entropy_sum = 0;
    int avail_entropy_avg = 0;
    int avail_entropy_high = 0;
    int avail_entropy_low = 0;
    int i;
    int below_read_wakeup_threshold_count = 0;
    int below_write_wakeup_threshold_count = 0;
    int consecutive_below_read_wakeup_threshold_count = 0;
    int consecutive_below_write_wakeup_threshold_count = 0;
    int max_consecutive_below_read_wakeup_threshold_count = 0;
    int max_consecutive_below_write_wakeup_threshold_count = 0;
    int avail_ent_previous = -1;
    for (i = 1; i <= samples_of_avail_ent; i++) {
      result = ioctl(dev_random_filehandle, RNDGETENTCNT, &avail_ent);
      if (result) {
        fprintf(stderr, "/dev/random result = %d\n", result);
        fprintf(stderr, "/dev/random is not a random device\n");
        avail_ent = -1;
        error_found = 1;
        break;
      }
      if (i == 1) {
        avail_entropy_high = avail_ent;
        avail_entropy_low = avail_ent;
      }
      if (avail_ent > avail_entropy_high)
        avail_entropy_high = avail_ent;
      if (avail_ent < avail_entropy_low)
        avail_entropy_low = avail_ent;
      avail_entropy_sum = avail_entropy_sum + avail_ent;
      if (debug_flag || verbose_flag)
        fprintf(stderr, "/dev/random avail_ent = %d  iters %d  sum %ld\n",
                avail_ent, i, avail_entropy_sum);
      if (avail_ent < below_write_wakeup_threshold_count) {
        below_write_wakeup_threshold_count++;
        if (avail_ent < below_read_wakeup_threshold_count) {
          below_read_wakeup_threshold_count++;
        }
        fprintf(stdout, "- kernel.random.entropy_avail.log \"%s\"\n",
                "low avalable entropy log text here");
      }
      if (avail_ent_previous != -1) {
        if ((avail_ent_previous < read_wakeup_threshold) &&
            (avail_ent < read_wakeup_threshold)) {
          consecutive_below_read_wakeup_threshold_count++;
          if (consecutive_below_read_wakeup_threshold_count >
              max_consecutive_below_read_wakeup_threshold_count) {
            max_consecutive_below_read_wakeup_threshold_count =
                consecutive_below_read_wakeup_threshold_count;
          }
        } else {
          consecutive_below_read_wakeup_threshold_count = 0;
        }
        if ((avail_ent_previous < write_wakeup_threshold) &&
            (avail_ent < write_wakeup_threshold)) {
          consecutive_below_write_wakeup_threshold_count++;
          if (consecutive_below_write_wakeup_threshold_count >
              max_consecutive_below_write_wakeup_threshold_count) {
            max_consecutive_below_write_wakeup_threshold_count =
                consecutive_below_write_wakeup_threshold_count;
          }
        } else {
          consecutive_below_write_wakeup_threshold_count = 0;
        }
      }
      avail_ent_previous = avail_ent;
      sleep(1);
    }
    if (max_consecutive_below_read_wakeup_threshold_count > 0)
      max_consecutive_below_read_wakeup_threshold_count++;
    if (max_consecutive_below_write_wakeup_threshold_count > 0)
      max_consecutive_below_write_wakeup_threshold_count++;
    avail_entropy_avg = (long)avail_entropy_sum / (long)samples_of_avail_ent;
    if (zabbix_flag) {
      fprintf(
          stdout,
          "- kernel.random.entropy_avail.maxsamplesbelow_read_wu_threshhold "
          "%d\n",
          max_consecutive_below_read_wakeup_threshold_count);
      fprintf(
          stdout,
          "- kernel.random.entropy_avail.maxsamplesbelow_write_wu_threshhold "
          "%d\n",
          max_consecutive_below_write_wakeup_threshold_count);
    }
    if (max_consecutive_below_read_wakeup_threshold_count > 0) {
      if (syslog_flag) {
        syslog(LOG_WARNING,
               "entropy below read wakeup value %d for a maximum of %d "
               "consecutive measurements",
               read_wakeup_threshold,
               max_consecutive_below_read_wakeup_threshold_count);
      }
      if (debug_flag || verbose_flag) {
        fprintf(stderr,
                "entropy below read wakeup value %d for a maximum of %d "
                "consecutive measurements\n",
                write_wakeup_threshold,
                max_consecutive_below_read_wakeup_threshold_count);
      }
    }
    if (max_consecutive_below_write_wakeup_threshold_count > 0) {
      if (syslog_flag) {
        syslog(LOG_WARNING,
               "entropy below write wakeup value %d for a maximum of %d "
               "consecutive measurements",
               write_wakeup_threshold,
               max_consecutive_below_write_wakeup_threshold_count);
      }
      if (debug_flag || verbose_flag) {
        fprintf(stderr,
                "entropy below write wakeup value %d for a maximum of %d "
                "consecutive measurements\n",
                write_wakeup_threshold,
                max_consecutive_below_write_wakeup_threshold_count);
      }
    }
    if (syslog_flag) {
      syslog(LOG_INFO,
             "avail.low %d high %d mean %d for last period of (%d) iterations",
             avail_entropy_low, avail_entropy_high, avail_entropy_avg,
             samples_of_avail_ent);
    }
    if (debug_flag || verbose_flag) {
      fprintf(
          stderr,
          "avail.low %d high %d mean %d for last period of (%d) iterations\n",
          avail_entropy_low, avail_entropy_high, avail_entropy_avg,
          samples_of_avail_ent);
    }
    if (zabbix_flag) {
      fprintf(stdout, "- kernel.random.entropy_avail.mean %d\n",
              avail_entropy_avg);
      fprintf(stdout, "- kernel.random.entropy_avail.high %d\n",
              avail_entropy_high);
      fprintf(stdout, "- kernel.random.entropy_avail.low %d\n",
              avail_entropy_low);
    }
    fflush_unlocked(stdout);
  }
  fprintf(stderr, "exiting due to error\n");
  if (syslog_flag) {
    syslog(LOG_ERR, "exiting due to error");
    closelog();
  }
  close(dev_random_filehandle);
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xe6c(%rip),%rax
mov    %rax,-0x1c(%rbp)
mov    0xe6a(%rip),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x3c,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe1e(%rip),%rdx
call   10c0 <getopt@plt>
mov    %eax,-0x48(%rbp)
cmp    $0xffffffff,%eax
je     1301 <main+0x131>
mov    -0x48(%rbp),%eax
add    $0xffffff9c,%eax
mov    %eax,%ecx
mov    %rcx,-0x98(%rbp)
sub    $0x16,%eax
ja     12ee <main+0x11e>
mov    -0x98(%rbp),%rax
lea    0xd7f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x20(%rbp)
jmp    12fc <main+0x12c>
mov    $0x0,%al
call   1090 <show_help@plt>
movl   $0x0,-0x4(%rbp)
jmp    190b <main+0x73b>
movl   $0x1,-0x28(%rbp)
jmp    12fc <main+0x12c>
movl   $0x1,-0x30(%rbp)
movl   $0xd48,-0x3c(%rbp)
movl   $0xfa0,-0x40(%rbp)
movl   $0xa,-0x34(%rbp)
jmp    12fc <main+0x12c>
movl   $0x1,-0x2c(%rbp)
jmp    12fc <main+0x12c>
movl   $0x1,-0x24(%rbp)
jmp    12fc <main+0x12c>
mov    $0x0,%al
call   1090 <show_help@plt>
mov    $0x0,%al
call   1040 <abort@plt>
jmp    123c <main+0x6c>
cmpl   $0x0,-0x20(%rbp)
je     1336 <main+0x166>
mov    0x2ca6(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%edx
mov    -0x28(%rbp),%ecx
mov    -0x30(%rbp),%r8d
mov    -0x2c(%rbp),%r9d
mov    -0x24(%rbp),%eax
lea    0xd43(%rip),%rsi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1070 <fprintf@plt>
lea    -0x1c(%rbp),%rdi
mov    0x2c9f(%rip),%rax
mov    (%rax),%esi
mov    0x2c9e(%rip),%rax
mov    (%rax),%edx
call   10b0 <open@plt>
mov    %eax,-0x4c(%rbp)
lea    -0x1c(%rbp),%rdi
lea    -0x58(%rbp),%rsi
call   1080 <stat@plt>
cmpl   $0x0,-0x20(%rbp)
je     138a <main+0x1ba>
mov    0x2c46(%rip),%rax
mov    (%rax),%edi
lea    -0x1c(%rbp),%rdx
mov    -0x58(%rbp),%rcx
lea    0xd42(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
cmpl   $0x0,-0x28(%rbp)
je     13c4 <main+0x1f4>
mov    0x2c15(%rip),%rax
mov    (%rax),%esi
mov    0x2c1c(%rip),%rax
or     (%rax),%esi
mov    0x2bdb(%rip),%rax
or     (%rax),%esi
mov    0x2bf2(%rip),%rax
mov    (%rax),%edx
lea    0xd24(%rip),%rdi
call   10d0 <openlog@plt>
cmpl   $0x0,-0x2c(%rbp)
je     13f2 <main+0x222>
mov    0x2be3(%rip),%rax
mov    (%rax),%edi
lea    -0x1c(%rbp),%rdx
mov    -0x34(%rbp),%ecx
lea    0xd0e(%rip),%rsi
mov    $0x1,%r8d
mov    $0x0,%al
call   1070 <fprintf@plt>
cmpl   $0x0,-0x30(%rbp)
jne    140a <main+0x23a>
movl   $0x40,-0x3c(%rbp)
movl   $0x80,-0x40(%rbp)
jmp    140f <main+0x23f>
cmpl   $0x0,-0x38(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1425 <main+0x255>
jmp    18bd <main+0x6ed>
movq   $0x0,-0x60(%rbp)
movl   $0x0,-0x64(%rbp)
movl   $0x0,-0x68(%rbp)
movl   $0x0,-0x6c(%rbp)
movl   $0x0,-0x74(%rbp)
movl   $0x0,-0x78(%rbp)
movl   $0x0,-0x7c(%rbp)
movl   $0x0,-0x80(%rbp)
movl   $0x0,-0x84(%rbp)
movl   $0x0,-0x88(%rbp)
movl   $0xffffffff,-0x8c(%rbp)
ff ff ff
movl   $0x1,-0x70(%rbp)
mov    -0x70(%rbp),%eax
cmp    -0x34(%rbp),%eax
jg     167e <main+0x4ae>
mov    -0x4c(%rbp),%edi
mov    0x2b3f(%rip),%rax
mov    (%rax),%esi
lea    -0x44(%rbp),%rdx
call   1050 <ioctl@plt>
mov    %eax,-0x48(%rbp)
cmpl   $0x0,-0x48(%rbp)
je     14f5 <main+0x325>
mov    0x2b00(%rip),%rax
mov    (%rax),%edi
mov    -0x48(%rbp),%edx
lea    0xc78(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2ae6(%rip),%rax
mov    (%rax),%edi
lea    0xc7a(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x44(%rbp)
movl   $0x1,-0x38(%rbp)
jmp    167e <main+0x4ae>
cmpl   $0x1,-0x70(%rbp)
jne    150b <main+0x33b>
mov    -0x44(%rbp),%eax
mov    %eax,-0x68(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x68(%rbp),%eax
jle    151d <main+0x34d>
mov    -0x44(%rbp),%eax
mov    %eax,-0x68(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x6c(%rbp),%eax
jge    152f <main+0x35f>
mov    -0x44(%rbp),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x60(%rbp),%rax
movslq -0x44(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x60(%rbp)
cmpl   $0x0,-0x20(%rbp)
jne    1552 <main+0x382>
cmpl   $0x0,-0x2c(%rbp)
je     1573 <main+0x3a3>
mov    0x2a5f(%rip),%rax
mov    (%rax),%edi
mov    -0x44(%rbp),%edx
mov    -0x70(%rbp),%ecx
mov    -0x60(%rbp),%r8
lea    0xc0d(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x44(%rbp),%eax
cmp    -0x78(%rbp),%eax
jge    15bb <main+0x3eb>
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x74(%rbp),%eax
jge    159d <main+0x3cd>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
mov    0x29fc(%rip),%rax
mov    (%rax),%edi
lea    0xbfb(%rip),%rsi
lea    0xc1c(%rip),%rdx
mov    $0x0,%al
call   1070 <fprintf@plt>
cmpl   $0xffffffff,-0x8c(%rbp)
je     165d <main+0x48d>
mov    -0x8c(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    1609 <main+0x439>
mov    -0x44(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    1609 <main+0x439>
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
cmp    -0x84(%rbp),%eax
jle    1604 <main+0x434>
mov    -0x7c(%rbp),%eax
mov    %eax,-0x84(%rbp)
jmp    1610 <main+0x440>
movl   $0x0,-0x7c(%rbp)
mov    -0x8c(%rbp),%eax
cmp    -0x40(%rbp),%eax
jge    1651 <main+0x481>
mov    -0x44(%rbp),%eax
cmp    -0x40(%rbp),%eax
jge    1651 <main+0x481>
mov    -0x80(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x80(%rbp)
mov    -0x80(%rbp),%eax
cmp    -0x88(%rbp),%eax
jle    164c <main+0x47c>
mov    -0x80(%rbp),%eax
mov    %eax,-0x88(%rbp)
jmp    1658 <main+0x488>
movl   $0x0,-0x80(%rbp)
jmp    165d <main+0x48d>
mov    -0x44(%rbp),%eax
mov    %eax,-0x8c(%rbp)
mov    $0x1,%edi
call   10f0 <sleep@plt>
mov    -0x70(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x70(%rbp)
jmp    1483 <main+0x2b3>
cmpl   $0x0,-0x84(%rbp)
jle    169a <main+0x4ca>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
cmpl   $0x0,-0x88(%rbp)
jle    16b6 <main+0x4e6>
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
mov    -0x60(%rbp),%rax
movslq -0x34(%rbp),%rcx
cqto
idiv   %rcx
mov    %eax,-0x64(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     170a <main+0x53a>
mov    0x28c9(%rip),%rax
mov    (%rax),%edi
mov    -0x84(%rbp),%edx
lea    0xb0d(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x28ac(%rip),%rax
mov    (%rax),%edi
mov    -0x88(%rbp),%edx
lea    0xb35(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
cmpl   $0x0,-0x84(%rbp)
jle    177a <main+0x5aa>
cmpl   $0x0,-0x28(%rbp)
je     1741 <main+0x571>
mov    0x28a8(%rip),%rax
mov    (%rax),%edi
mov    -0x3c(%rbp),%edx
mov    -0x84(%rbp),%ecx
lea    0xb44(%rip),%rsi
mov    $0x0,%al
call   10a0 <syslog@plt>
cmpl   $0x0,-0x20(%rbp)
jne    1755 <main+0x585>
cmpl   $0x0,-0x2c(%rbp)
je     1775 <main+0x5a5>
mov    0x285c(%rip),%rax
mov    (%rax),%edi
mov    -0x40(%rbp),%edx
mov    -0x84(%rbp),%ecx
lea    0xb60(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    177a <main+0x5aa>
cmpl   $0x0,-0x88(%rbp)
jle    17ea <main+0x61a>
cmpl   $0x0,-0x28(%rbp)
je     17b1 <main+0x5e1>
mov    0x2838(%rip),%rax
mov    (%rax),%edi
mov    -0x40(%rbp),%edx
mov    -0x88(%rbp),%ecx
lea    0xb75(%rip),%rsi
mov    $0x0,%al
call   10a0 <syslog@plt>
cmpl   $0x0,-0x20(%rbp)
jne    17c5 <main+0x5f5>
cmpl   $0x0,-0x2c(%rbp)
je     17e5 <main+0x615>
mov    0x27ec(%rip),%rax
mov    (%rax),%edi
mov    -0x40(%rbp),%edx
mov    -0x88(%rbp),%ecx
lea    0xb92(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    17ea <main+0x61a>
cmpl   $0x0,-0x28(%rbp)
je     1819 <main+0x649>
mov    0x279d(%rip),%rax
mov    (%rax),%edi
mov    -0x6c(%rbp),%edx
mov    -0x68(%rbp),%ecx
mov    -0x64(%rbp),%r8d
mov    -0x34(%rbp),%r9d
lea    0xbb0(%rip),%rsi
mov    $0x0,%al
call   10a0 <syslog@plt>
cmpl   $0x0,-0x20(%rbp)
jne    182d <main+0x65d>
cmpl   $0x0,-0x2c(%rbp)
je     1852 <main+0x682>
mov    0x2784(%rip),%rax
mov    (%rax),%edi
mov    -0x6c(%rbp),%edx
mov    -0x68(%rbp),%ecx
mov    -0x64(%rbp),%r8d
mov    -0x34(%rbp),%r9d
lea    0xbb7(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
cmpl   $0x0,-0x24(%rbp)
je     18aa <main+0x6da>
mov    0x273d(%rip),%rax
mov    (%rax),%edi
mov    -0x64(%rbp),%edx
lea    0xbd4(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2723(%rip),%rax
mov    (%rax),%edi
mov    -0x68(%rbp),%edx
lea    0xbe1(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2709(%rip),%rax
mov    (%rax),%edi
mov    -0x6c(%rbp),%edx
lea    0xbee(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x26ef(%rip),%rax
mov    (%rax),%edi
call   10e0 <fflush_unlocked@plt>
jmp    140f <main+0x23f>
mov    0x26f4(%rip),%rax
mov    (%rax),%edi
lea    0xbea(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
cmpl   $0x0,-0x28(%rbp)
je     18fc <main+0x72c>
mov    0x269b(%rip),%rax
mov    (%rax),%edi
lea    0xbdf(%rip),%rsi
mov    $0x0,%al
call   10a0 <syslog@plt>
mov    $0x0,%al
call   1030 <closelog@plt>
mov    -0x4c(%rbp),%edi
call   1060 <close@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rsi,%r13
mov    %edi,%ebx
movabs $0x6e61722f7665642f,%rax
72 61 6e
mov    %rax,0x48(%rsp)
movl   $0x6d6f64,0x50(%rsp)
lea    0xe3b(%rip),%rdx
call   10c0 <getopt@plt>
cmp    $0xffffffff,%eax
je     1310 <main+0x140>
movl   $0x3c,0x18(%rsp)
movl   $0x0,0x14(%rsp)
lea    0xdda(%rip),%rbp
lea    0xe0f(%rip),%r12
movl   $0x0,0x1c(%rsp)
xor    %r15d,%r15d
movl   $0x0,0x10(%rsp)
movl   $0x0,0x20(%rsp)
movl   $0x0,0x24(%rsp)
xor    %r14d,%r14d
jmp    1272 <main+0xa2>
movl   $0x1,0x20(%rsp)
mov    %ecx,%r14d
mov    %ebx,%edi
mov    %r13,%rsi
mov    %r12,%rdx
call   10c0 <getopt@plt>
cmp    $0xffffffff,%eax
je     12c7 <main+0xf7>
add    $0xffffff9c,%eax
ror    %eax
cmp    $0xb,%eax
ja     186f <main+0x69f>
mov    %r14d,%ecx
mov    $0x1,%r14d
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
movl   $0xfa0,0x14(%rsp)
movl   $0xd48,0x1c(%rsp)
movl   $0xa,0x18(%rsp)
mov    $0x1,%r15d
jmp    125d <main+0x8d>
movl   $0x1,0x10(%rsp)
jmp    125d <main+0x8d>
movl   $0x1,0x24(%rsp)
jmp    125d <main+0x8d>
test   %r14d,%r14d
je     133b <main+0x16b>
mov    0x2ce5(%rip),%rax
mov    (%rax),%edi
mov    0x24(%rsp),%eax
mov    %eax,(%rsp)
lea    0xd60(%rip),%rsi
mov    $0x1,%edx
mov    0x20(%rsp),%ecx
mov    %r15d,%r12d
mov    %r15d,%r8d
mov    0x10(%rsp),%r15d
mov    %r15d,%r9d
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%bpl
mov    0x18(%rsp),%r13d
mov    0x14(%rsp),%r14d
jmp    134f <main+0x17f>
mov    $0x3c,%r13d
xor    %ebp,%ebp
xor    %r14d,%r14d
movl   $0x0,0x1c(%rsp)
xor    %r12d,%r12d
xor    %r15d,%r15d
movl   $0x0,0x20(%rsp)
movl   $0x0,0x24(%rsp)
jmp    134f <main+0x17f>
xor    %ebp,%ebp
mov    0x18(%rsp),%r13d
mov    0x14(%rsp),%r14d
mov    %r15d,%r12d
mov    0x10(%rsp),%r15d
mov    0x2c8a(%rip),%rax
mov    (%rax),%esi
mov    0x2c89(%rip),%rax
mov    (%rax),%edx
lea    0x48(%rsp),%rbx
mov    %rbx,%rdi
call   10b0 <open@plt>
mov    %eax,0x40(%rsp)
lea    0x60(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <stat@plt>
test   %bpl,%bpl
je     13a5 <main+0x1d5>
mov    0x2c2d(%rip),%rax
mov    (%rax),%edi
mov    0x60(%rsp),%rcx
lea    0xd00(%rip),%rsi
lea    0x48(%rsp),%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
cmpl   $0x0,0x20(%rsp)
je     13dc <main+0x20c>
mov    0x2bfd(%rip),%rax
mov    0x2c06(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2bc3(%rip),%rax
or     (%rax),%esi
mov    0x2bda(%rip),%rax
mov    (%rax),%edx
lea    0xce0(%rip),%rdi
call   10d0 <openlog@plt>
test   %r15d,%r15d
je     1406 <main+0x236>
mov    0x2bd0(%rip),%rax
mov    (%rax),%edi
lea    0xcd6(%rip),%rsi
lea    0x48(%rsp),%rdx
mov    %r13d,%ecx
mov    $0x1,%r8d
xor    %eax,%eax
call   1070 <fprintf@plt>
test   %r15d,%r15d
setne  %al
test   %r12d,%r12d
mov    $0x40,%ecx
mov    0x1c(%rsp),%edx
cmove  %ecx,%edx
mov    %edx,0x1c(%rsp)
mov    $0x80,%ecx
cmove  %ecx,%r14d
mov    %r14d,0x14(%rsp)
or     %al,%bpl
mov    %ebp,0x34(%rsp)
mov    %r13d,0x18(%rsp)
mov    %r13d,%eax
mov    %rax,0x58(%rsp)
mov    $0x1,%r15d
mov    $0xffffffff,%r13d
xor    %r14d,%r14d
xor    %r12d,%r12d
xor    %eax,%eax
mov    %rax,0x38(%rsp)
xor    %ebx,%ebx
movl   $0x0,0x2c(%rsp)
movl   $0x0,0x10(%rsp)
movl   $0x0,0x30(%rsp)
xor    %ebp,%ebp
jmp    14d3 <main+0x303>
nopl   0x0(%rax,%rax,1)
mov    (%rbx),%edi
call   10e0 <fflush_unlocked@plt>
xor    %r14d,%r14d
mov    $0xffffffff,%r13d
mov    $0x0,%r12d
mov    $0x0,%eax
mov    %rax,0x38(%rsp)
mov    $0x0,%ebx
movl   $0x0,0x2c(%rsp)
mov    $0x1,%r15d
movl   $0x0,0x10(%rsp)
movl   $0x0,0x30(%rsp)
mov    $0x0,%ebp
cmpl   $0x0,0x44(%rsp)
jne    1809 <main+0x639>
mov    0x2afe(%rip),%rax
mov    (%rax),%esi
mov    0x40(%rsp),%edi
lea    0x28(%rsp),%rdx
call   1050 <ioctl@plt>
test   %eax,%eax
mov    %eax,0x44(%rsp)
je     1530 <main+0x360>
mov    0x2abf(%rip),%rbx
mov    (%rbx),%edi
lea    0xc0e(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%rbx),%edi
lea    0xc15(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
movl   $0xffffffff,0x28(%rsp)
ff
jmp    1638 <main+0x468>
nopl   0x0(%rax,%rax,1)
cmp    $0x1,%r15d
movslq 0x28(%rsp),%rdx
mov    0x30(%rsp),%esi
cmove  %edx,%esi
mov    0x10(%rsp),%eax
cmove  %edx,%eax
cmp    %esi,%edx
cmovg  %edx,%esi
mov    %esi,0x30(%rsp)
cmp    %eax,%edx
cmovl  %edx,%eax
mov    %eax,0x10(%rsp)
add    %rdx,%rbp
cmpb   $0x0,0x34(%rsp)
je     1584 <main+0x3b4>
mov    0x2a4e(%rip),%rax
mov    (%rax),%edi
lea    0xbda(%rip),%rsi
mov    %r15d,%ecx
mov    %rbp,%r8
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x28(%rsp),%edx
mov    0x2c(%rsp),%eax
cmp    %eax,%edx
jge    15b1 <main+0x3e1>
add    $0x1,%eax
mov    %eax,0x2c(%rsp)
mov    0x2a06(%rip),%rax
mov    (%rax),%edi
lea    0xbd9(%rip),%rsi
lea    0xbfa(%rip),%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
cmp    $0xffffffff,%r13d
je     1602 <main+0x432>
mov    0x1c(%rsp),%ecx
cmp    %ecx,%r13d
setl   %al
mov    0x28(%rsp),%edi
cmp    %ecx,%edi
setl   %cl
lea    0x1(%rbx),%edx
cmp    %r12d,%ebx
mov    %edx,%ebx
cmovl  %r12d,%edx
xor    %esi,%esi
test   %cl,%al
cmove  %esi,%ebx
cmovne %edx,%r12d
mov    0x14(%rsp),%eax
cmp    %eax,%r13d
jge    1609 <main+0x439>
cmp    %eax,%edi
mov    %edi,%r13d
jge    1615 <main+0x445>
mov    0x38(%rsp),%rax
cmp    %r14d,%eax
lea    0x1(%rax),%eax
cmovge %eax,%r14d
jmp    1617 <main+0x447>
mov    0x28(%rsp),%r13d
jmp    161c <main+0x44c>
xor    %eax,%eax
mov    %rax,0x38(%rsp)
mov    %edi,%r13d
jmp    161c <main+0x44c>
xor    %eax,%eax
mov    %rax,0x38(%rsp)
mov    $0x1,%edi
call   10f0 <sleep@plt>
lea    0x1(%r15),%eax
cmp    0x18(%rsp),%r15d
mov    %eax,%r15d
jne    14d3 <main+0x303>
xor    %esi,%esi
test   %r12d,%r12d
setg   %bl
xor    %ecx,%ecx
test   %r14d,%r14d
setg   %dil
mov    %rbp,%rax
shr    $0x20,%rax
je     1670 <main+0x4a0>
mov    %rbp,%rax
cqto
idivq  0x58(%rsp)
mov    %rax,%r13
jmp    167b <main+0x4ab>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebp,%eax
xor    %edx,%edx
divl   0x58(%rsp)
mov    %eax,%r13d
mov    0x18(%rsp),%ebp
mov    0x14(%rsp),%r15d
mov    %bl,%sil
add    %esi,%r12d
mov    %dil,%cl
add    %ecx,%r14d
cmpl   $0x0,0x24(%rsp)
je     16c4 <main+0x4f4>
mov    0x2902(%rip),%rbx
mov    (%rbx),%edi
lea    0xb20(%rip),%rsi
mov    %r12d,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%rbx),%edi
lea    0xb52(%rip),%rsi
mov    %r14d,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
test   %r12d,%r12d
mov    0x20(%rsp),%ebx
jle    1713 <main+0x543>
test   %ebx,%ebx
je     16ef <main+0x51f>
mov    0x28f8(%rip),%rax
mov    (%rax),%edi
lea    0xb71(%rip),%rsi
mov    0x1c(%rsp),%edx
mov    %r12d,%ecx
xor    %eax,%eax
call   10a0 <syslog@plt>
cmpb   $0x0,0x34(%rsp)
je     1713 <main+0x543>
mov    0x28bb(%rip),%rax
mov    (%rax),%edi
lea    0xb9c(%rip),%rsi
mov    %r15d,%edx
mov    %r12d,%ecx
xor    %eax,%eax
call   1070 <fprintf@plt>
test   %r14d,%r14d
mov    0x34(%rsp),%r12d
jle    1760 <main+0x590>
test   %ebx,%ebx
je     173e <main+0x56e>
mov    0x28a8(%rip),%rax
mov    (%rax),%edi
lea    0xbc2(%rip),%rsi
mov    %r15d,%edx
mov    %r14d,%ecx
xor    %eax,%eax
call   10a0 <syslog@plt>
test   %r12b,%r12b
je     1760 <main+0x590>
mov    0x286e(%rip),%rax
mov    (%rax),%edi
lea    0xbf1(%rip),%rsi
mov    %r15d,%edx
mov    %r14d,%ecx
xor    %eax,%eax
call   1070 <fprintf@plt>
test   %ebx,%ebx
mov    0x10(%rsp),%r14d
mov    0x30(%rsp),%r15d
je     1791 <main+0x5c1>
mov    0x2823(%rip),%rax
mov    (%rax),%edi
lea    0xc18(%rip),%rsi
mov    %r14d,%edx
mov    %r15d,%ecx
mov    %r13d,%r8d
mov    %ebp,%r9d
xor    %eax,%eax
call   10a0 <syslog@plt>
test   %r12b,%r12b
mov    0x2805(%rip),%rbx
je     17c0 <main+0x5f0>
mov    0x2814(%rip),%rax
mov    (%rax),%edi
lea    0xc29(%rip),%rsi
mov    %r14d,%edx
mov    %r15d,%ecx
mov    %r13d,%r8d
mov    %ebp,%r9d
xor    %eax,%eax
call   1070 <fprintf@plt>
cmpl   $0x0,0x24(%rsp)
je     1480 <main+0x2b0>
mov    (%rbx),%edi
lea    0xc43(%rip),%rsi
mov    %r13d,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%rbx),%edi
lea    0xc57(%rip),%rsi
mov    %r15d,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%rbx),%edi
lea    0xc6b(%rip),%rsi
mov    %r14d,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    1480 <main+0x2b0>
mov    0x27a8(%rip),%rax
mov    (%rax),%edi
lea    0xc72(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
cmpl   $0x0,0x20(%rsp)
je     1845 <main+0x675>
mov    0x2752(%rip),%rax
mov    (%rax),%edi
lea    0xc6a(%rip),%rsi
xor    %eax,%eax
call   10a0 <syslog@plt>
xor    %eax,%eax
call   1030 <closelog@plt>
mov    0x40(%rsp),%edi
call   1060 <close@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebx,%ebx
xor    %eax,%eax
call   1090 <show_help@plt>
jmp    1853 <main+0x683>
xor    %eax,%eax
call   1090 <show_help@plt>
xor    %eax,%eax
call   1040 <abort@plt>

LLVM IR (-O0):
%struct.stat = type { i64 }
@__const.main.dev_random_file = [12 x i8] c"/dev/random\00"
@.str = [7 x i8] c"dhltvz\00"
@stderr = global i32 0
@.str.1 = [86 x i8] c"DEBUG: debug_flag: %d syslog_flag: %d test_flag: %d verbose_flag: %d zabbix_flag: %d\0A\00"
@O_RDONLY = global i32 0
@O_NONBLOCK = global i32 0
@.str.2 = [30 x i8] c"DEBUG: %s I-node number: %ld\0A\00"
@.str.3 = [16 x i8] c"entropy_monitor\00"
@LOG_CONS = global i32 0
@LOG_PID = global i32 0
@LOG_NDELAY = global i32 0
@LOG_LOCAL1 = global i32 0
@.str.4 = [73 x i8] c"Collecting available entropy from %s for %d iterations every %d seconds\0A\00"
@RNDGETENTCNT = global i32 0
@.str.5 = [25 x i8] c"/dev/random result = %d\0A\00"
@.str.6 = [36 x i8] c"/dev/random is not a random device\0A\00"
@.str.7 = [47 x i8] c"/dev/random avail_ent = %d iters %d sum %ld\0A\00"
@stdout = global i32 0
@.str.8 = [40 x i8] c"- kernel.random.entropy_avail.log \22%s\22\0A\00"
@.str.9 = [35 x i8] c"low avalable entropy log text here\00"
@.str.10 = [69 x i8] c"- kernel.random.entropy_avail.maxsamplesbelow_read_wu_threshhold %d\0A\00"
@.str.11 = [70 x i8] c"- kernel.random.entropy_avail.maxsamplesbelow_write_wu_threshhold %d\0A\00"
@LOG_WARNING = global i32 0
@.str.12 = [80 x i8] c"entropy below read wakeup value %d for a maximum of %d consecutive measurements\00"
@.str.13 = [81 x i8] c"entropy below read wakeup value %d for a maximum of %d consecutive measurements\0A\00"
@.str.14 = [81 x i8] c"entropy below write wakeup value %d for a maximum of %d consecutive measurements\00"
@.str.15 = [82 x i8] c"entropy below write wakeup value %d for a maximum of %d consecutive measurements\0A\00"
@LOG_INFO = global i32 0
@.str.16 = [64 x i8] c"avail.low %d high %d mean %d for last period of (%d) iterations\00"
@.str.17 = [65 x i8] c"avail.low %d high %d mean %d for last period of (%d) iterations\0A\00"
@.str.18 = [39 x i8] c"- kernel.random.entropy_avail.mean %d\0A\00"
@.str.19 = [39 x i8] c"- kernel.random.entropy_avail.high %d\0A\00"
@.str.20 = [38 x i8] c"- kernel.random.entropy_avail.low %d\0A\00"
@.str.21 = [22 x i8] c"exiting due to error\0A\00"
@LOG_ERR = global i32 0
@.str.22 = [21 x i8] c"exiting due to error\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [12 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca %struct.stat
%20 = alloca i64
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca i32
%28 = alloca i32
%29 = alloca i32
%30 = alloca i32
%31 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%32 = bitcast [12 x i8]* %6 to i8*
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
store i32 60, i32* %12
store i32 0, i32* %13
store i32 0, i32* %14
store i32 0, i32* %15
br label %33
33: ; preds = %50, %2
%34 = load i32, i32* %4
%35 = load i8**, i8*** %5
%36 = call i32 @getopt(i32 %34, i8** %35, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 %36, i32* %17
%37 = icmp ne i32 %36, -1
br i1 %37, label %38, label %51
38: ; preds = %33
%39 = load i32, i32* %17
switch i32 %39, label %47 [
i32 100, label %40
i32 104, label %41
i32 108, label %43
i32 116, label %44
i32 118, label %45
i32 122, label %46
]
40: ; preds = %38
store i32 1, i32* %7
br label %50
41: ; preds = %38
%42 = call i32 (...) @show_help()
store i32 0, i32* %3
br label %342
43: ; preds = %38
store i32 1, i32* %9
br label %50
44: ; preds = %38
store i32 1, i32* %11
store i32 3400, i32* %14
store i32 4000, i32* %15
store i32 10, i32* %12
br label %50
45: ; preds = %38
store i32 1, i32* %10
br label %50
46: ; preds = %38
store i32 1, i32* %8
br label %50
47: ; preds = %38
%48 = call i32 (...) @show_help()
%49 = call i32 (...) @abort()
unreachable
50: ; preds = %46, %45, %44, %43, %40
br label %33
51: ; preds = %33
%52 = load i32, i32* %7
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %62
54: ; preds = %51
%55 = load i32, i32* @stderr
%56 = load i32, i32* %7
%57 = load i32, i32* %9
%58 = load i32, i32* %11
%59 = load i32, i32* %10
%60 = load i32, i32* %8
%61 = call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([86 x i8], [86 x i8]* @.str.1, i64 0, i64 0), i32 %56, i32 %57, i32 %58, i32 %59, i32 %60)
br label %62
62: ; preds = %54, %51
%63 = getelementptr inbounds [12 x i8], [12 x i8]* %6, i64 0, i64 0
%64 = load i32, i32* @O_RDONLY
%65 = load i32, i32* @O_NONBLOCK
%66 = call i32 @open(i8* %63, i32 %64, i32 %65)
store i32 %66, i32* %18
%67 = getelementptr inbounds [12 x i8], [12 x i8]* %6, i64 0, i64 0
%68 = call i32 @stat(i8* %67, %struct.stat* %19)
%69 = load i32, i32* %7
%70 = icmp ne i32 %69, 0
br i1 %70, label %71, label %77
71: ; preds = %62
%72 = load i32, i32* @stderr
%73 = getelementptr inbounds [12 x i8], [12 x i8]* %6, i64 0, i64 0
%74 = getelementptr inbounds %struct.stat, %struct.stat* %19, i32 0, i32 0
%75 = load i64, i64* %74
%76 = call i32 (i32, i8*, ...) @fprintf(i32 %72, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %73, i64 %75)
br label %77
77: ; preds = %71, %62
%78 = load i32, i32* %9
%79 = icmp ne i32 %78, 0
br i1 %79, label %80, label %88
80: ; preds = %77
%81 = load i32, i32* @LOG_CONS
%82 = load i32, i32* @LOG_PID
%83 = or i32 %81, %82
%84 = load i32, i32* @LOG_NDELAY
%85 = or i32 %83, %84
%86 = load i32, i32* @LOG_LOCAL1
%87 = call i32 @openlog(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %85, i32 %86)
br label %88
88: ; preds = %80, %77
%89 = load i32, i32* %10
%90 = icmp ne i32 %89, 0
br i1 %90, label %91, label %96
91: ; preds = %88
%92 = load i32, i32* @stderr
%93 = getelementptr inbounds [12 x i8], [12 x i8]* %6, i64 0, i64 0
%94 = load i32, i32* %12
%95 = call i32 (i32, i8*, ...) @fprintf(i32 %92, i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.4, i64 0, i64 0), i8* %93, i32 %94, i32 1)
br label %96
96: ; preds = %91, %88
%97 = load i32, i32* %11
%98 = icmp ne i32 %97, 0
br i1 %98, label %100, label %99
99: ; preds = %96
store i32 64, i32* %14
store i32 128, i32* %15
br label %100
100: ; preds = %99, %96
br label %101
101: ; preds = %327, %100
%102 = load i32, i32* %13
%103 = icmp ne i32 %102, 0
%104 = xor i1 %103, true
br i1 %104, label %105, label %330
105: ; preds = %101
store i64 0, i64* %20
store i32 0, i32* %21
store i32 0, i32* %22
store i32 0, i32* %23
store i32 0, i32* %25
store i32 0, i32* %26
store i32 0, i32* %27
store i32 0, i32* %28
store i32 0, i32* %29
store i32 0, i32* %30
store i32 -1, i32* %31
store i32 1, i32* %24
br label %106
106: ; preds = %215, %105
%107 = load i32, i32* %24
%108 = load i32, i32* %12
%109 = icmp sle i32 %107, %108
br i1 %109, label %110, label %218
110: ; preds = %106
%111 = load i32, i32* %18
%112 = load i32, i32* @RNDGETENTCNT
%113 = call i32 @ioctl(i32 %111, i32 %112, i32* %16)
store i32 %113, i32* %17
%114 = load i32, i32* %17
%115 = icmp ne i32 %114, 0
br i1 %115, label %116, label %122
116: ; preds = %110
%117 = load i32, i32* @stderr
%118 = load i32, i32* %17
%119 = call i32 (i32, i8*, ...) @fprintf(i32 %117, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %118)
%120 = load i32, i32* @stderr
%121 = call i32 (i32, i8*, ...) @fprintf(i32 %120, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0))
store i32 -1, i32* %16
store i32 1, i32* %13
br label %218
122: ; preds = %110
%123 = load i32, i32* %24
%124 = icmp eq i32 %123, 1
br i1 %124, label %125, label %128
125: ; preds = %122
%126 = load i32, i32* %16
store i32 %126, i32* %22
%127 = load i32, i32* %16
store i32 %127, i32* %23
br label %128
128: ; preds = %125, %122
%129 = load i32, i32* %16
%130 = load i32, i32* %22
%131 = icmp sgt i32 %129, %130
br i1 %131, label %132, label %134
132: ; preds = %128
%133 = load i32, i32* %16
store i32 %133, i32* %22
br label %134
134: ; preds = %132, %128
%135 = load i32, i32* %16
%136 = load i32, i32* %23
%137 = icmp slt i32 %135, %136
br i1 %137, label %138, label %140
138: ; preds = %134
%139 = load i32, i32* %16
store i32 %139, i32* %23
br label %140
140: ; preds = %138, %134
%141 = load i64, i64* %20
%142 = load i32, i32* %16
%143 = sext i32 %142 to i64
%144 = add nsw i64 %141, %143
store i64 %144, i64* %20
%145 = load i32, i32* %7
%146 = icmp ne i32 %145, 0
br i1 %146, label %150, label %147
147: ; preds = %140
%148 = load i32, i32* %10
%149 = icmp ne i32 %148, 0
br i1 %149, label %150, label %156
150: ; preds = %147, %140
%151 = load i32, i32* @stderr
%152 = load i32, i32* %16
%153 = load i32, i32* %24
%154 = load i64, i64* %20
%155 = call i32 (i32, i8*, ...) @fprintf(i32 %151, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.7, i64 0, i64 0), i32 %152, i32 %153, i64 %154)
br label %156
156: ; preds = %150, %147
%157 = load i32, i32* %16
%158 = load i32, i32* %26
%159 = icmp slt i32 %157, %158
br i1 %159, label %160, label %172
160: ; preds = %156
%161 = load i32, i32* %26
%162 = add nsw i32 %161, 1
store i32 %162, i32* %26
%163 = load i32, i32* %16
%164 = load i32, i32* %25
%165 = icmp slt i32 %163, %164
br i1 %165, label %166, label %169
166: ; preds = %160
%167 = load i32, i32* %25
%168 = add nsw i32 %167, 1
store i32 %168, i32* %25
br label %169
169: ; preds = %166, %160
%170 = load i32, i32* @stdout
%171 = call i32 (i32, i8*, ...) @fprintf(i32 %170, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0))
br label %172
172: ; preds = %169, %156
%173 = load i32, i32* %31
%174 = icmp ne i32 %173, -1
br i1 %174, label %175, label %212
175: ; preds = %172
%176 = load i32, i32* %31
%177 = load i32, i32* %14
%178 = icmp slt i32 %176, %177
br i1 %178, label %179, label %192
179: ; preds = %175
%180 = load i32, i32* %16
%181 = load i32, i32* %14
%182 = icmp slt i32 %180, %181
br i1 %182, label %183, label %192
183: ; preds = %179
%184 = load i32, i32* %27
%185 = add nsw i32 %184, 1
store i32 %185, i32* %27
%186 = load i32, i32* %27
%187 = load i32, i32* %29
%188 = icmp sgt i32 %186, %187
br i1 %188, label %189, label %191
189: ; preds = %183
%190 = load i32, i32* %27
store i32 %190, i32* %29
br label %191
191: ; preds = %189, %183
br label %193
192: ; preds = %179, %175
store i32 0, i32* %27
br label %193
193: ; preds = %192, %191
%194 = load i32, i32* %31
%195 = load i32, i32* %15
%196 = icmp slt i32 %194, %195
br i1 %196, label %197, label %210
197: ; preds = %193
%198 = load i32, i32* %16
%199 = load i32, i32* %15
%200 = icmp slt i32 %198, %199
br i1 %200, label %201, label %210
201: ; preds = %197
%202 = load i32, i32* %28
%203 = add nsw i32 %202, 1
store i32 %203, i32* %28
%204 = load i32, i32* %28
%205 = load i32, i32* %30
%206 = icmp sgt i32 %204, %205
br i1 %206, label %207, label %209
207: ; preds = %201
%208 = load i32, i32* %28
store i32 %208, i32* %30
br label %209
209: ; preds = %207, %201
br label %211
210: ; preds = %197, %193
store i32 0, i32* %28
br label %211
211: ; preds = %210, %209
br label %212
212: ; preds = %211, %172
%213 = load i32, i32* %16
store i32 %213, i32* %31
%214 = call i32 @sleep(i32 1)
br label %215
215: ; preds = %212
%216 = load i32, i32* %24
%217 = add nsw i32 %216, 1
store i32 %217, i32* %24
br label %106
218: ; preds = %116, %106
%219 = load i32, i32* %29
%220 = icmp sgt i32 %219, 0
br i1 %220, label %221, label %224
221: ; preds = %218
%222 = load i32, i32* %29
%223 = add nsw i32 %222, 1
store i32 %223, i32* %29
br label %224
224: ; preds = %221, %218
%225 = load i32, i32* %30
%226 = icmp sgt i32 %225, 0
br i1 %226, label %227, label %230
227: ; preds = %224
%228 = load i32, i32* %30
%229 = add nsw i32 %228, 1
store i32 %229, i32* %30
br label %230
230: ; preds = %227, %224
%231 = load i64, i64* %20
%232 = load i32, i32* %12
%233 = sext i32 %232 to i64
%234 = sdiv i64 %231, %233
%235 = trunc i64 %234 to i32
store i32 %235, i32* %21
%236 = load i32, i32* %8
%237 = icmp ne i32 %236, 0
br i1 %237, label %238, label %245
238: ; preds = %230
%239 = load i32, i32* @stdout
%240 = load i32, i32* %29
%241 = call i32 (i32, i8*, ...) @fprintf(i32 %239, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.10, i64 0, i64 0), i32 %240)
%242 = load i32, i32* @stdout
%243 = load i32, i32* %30
%244 = call i32 (i32, i8*, ...) @fprintf(i32 %242, i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.11, i64 0, i64 0), i32 %243)
br label %245
245: ; preds = %238, %230
%246 = load i32, i32* %29
%247 = icmp sgt i32 %246, 0
br i1 %247, label %248, label %268
248: ; preds = %245
%249 = load i32, i32* %9
%250 = icmp ne i32 %249, 0
br i1 %250, label %251, label %256
251: ; preds = %248
%252 = load i32, i32* @LOG_WARNING
%253 = load i32, i32* %14
%254 = load i32, i32* %29
%255 = call i32 (i32, i8*, ...) @syslog(i32 %252, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @.str.12, i64 0, i64 0), i32 %253, i32 %254)
br label %256
256: ; preds = %251, %248
%257 = load i32, i32* %7
%258 = icmp ne i32 %257, 0
br i1 %258, label %262, label %259
259: ; preds = %256
%260 = load i32, i32* %10
%261 = icmp ne i32 %260, 0
br i1 %261, label %262, label %267
262: ; preds = %259, %256
%263 = load i32, i32* @stderr
%264 = load i32, i32* %15
%265 = load i32, i32* %29
%266 = call i32 (i32, i8*, ...) @fprintf(i32 %263, i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.13, i64 0, i64 0), i32 %264, i32 %265)
br label %267
267: ; preds = %262, %259
br label %268
268: ; preds = %267, %245
%269 = load i32, i32* %30
%270 = icmp sgt i32 %269, 0
br i1 %270, label %271, label %291
271: ; preds = %268
%272 = load i32, i32* %9
%273 = icmp ne i32 %272, 0
br i1 %273, label %274, label %279
274: ; preds = %271
%275 = load i32, i32* @LOG_WARNING
%276 = load i32, i32* %15
%277 = load i32, i32* %30
%278 = call i32 (i32, i8*, ...) @syslog(i32 %275, i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.14, i64 0, i64 0), i32 %276, i32 %277)
br label %279
279: ; preds = %274, %271
%280 = load i32, i32* %7
%281 = icmp ne i32 %280, 0
br i1 %281, label %285, label %282
282: ; preds = %279
%283 = load i32, i32* %10
%284 = icmp ne i32 %283, 0
br i1 %284, label %285, label %290
285: ; preds = %282, %279
%286 = load i32, i32* @stderr
%287 = load i32, i32* %15
%288 = load i32, i32* %30
%289 = call i32 (i32, i8*, ...) @fprintf(i32 %286, i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.15, i64 0, i64 0), i32 %287, i32 %288)
br label %290
290: ; preds = %285, %282
br label %291
291: ; preds = %290, %268
%292 = load i32, i32* %9
%293 = icmp ne i32 %292, 0
br i1 %293, label %294, label %301
294: ; preds = %291
%295 = load i32, i32* @LOG_INFO
%296 = load i32, i32* %23
%297 = load i32, i32* %22
%298 = load i32, i32* %21
%299 = load i32, i32* %12
%300 = call i32 (i32, i8*, ...) @syslog(i32 %295, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.16, i64 0, i64 0), i32 %296, i32 %297, i32 %298, i32 %299)
br label %301
301: ; preds = %294, %291
%302 = load i32, i32* %7
%303 = icmp ne i32 %302, 0
br i1 %303, label %307, label %304
304: ; preds = %301
%305 = load i32, i32* %10
%306 = icmp ne i32 %305, 0
br i1 %306, label %307, label %314
307: ; preds = %304, %301
%308 = load i32, i32* @stderr
%309 = load i32, i32* %23
%310 = load i32, i32* %22
%311 = load i32, i32* %21
%312 = load i32, i32* %12
%313 = call i32 (i32, i8*, ...) @fprintf(i32 %308, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.17, i64 0, i64 0), i32 %309, i32 %310, i32 %311, i32 %312)
br label %314
314: ; preds = %307, %304
%315 = load i32, i32* %8
%316 = icmp ne i32 %315, 0
br i1 %316, label %317, label %327
317: ; preds = %314
%318 = load i32, i32* @stdout
%319 = load i32, i32* %21
%320 = call i32 (i32, i8*, ...) @fprintf(i32 %318, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.18, i64 0, i64 0), i32 %319)
%321 = load i32, i32* @stdout
%322 = load i32, i32* %22
%323 = call i32 (i32, i8*, ...) @fprintf(i32 %321, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.19, i64 0, i64 0), i32 %322)
%324 = load i32, i32* @stdout
%325 = load i32, i32* %23
%326 = call i32 (i32, i8*, ...) @fprintf(i32 %324, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.20, i64 0, i64 0), i32 %325)
br label %327
327: ; preds = %317, %314
%328 = load i32, i32* @stdout
%329 = call i32 @fflush_unlocked(i32 %328)
br label %101
330: ; preds = %101
%331 = load i32, i32* @stderr
%332 = call i32 (i32, i8*, ...) @fprintf(i32 %331, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.21, i64 0, i64 0))
%333 = load i32, i32* %9
%334 = icmp ne i32 %333, 0
br i1 %334, label %335, label %339
335: ; preds = %330
%336 = load i32, i32* @LOG_ERR
%337 = call i32 (i32, i8*, ...) @syslog(i32 %336, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.22, i64 0, i64 0))
%338 = call i32 (...) @closelog()
br label %339
339: ; preds = %335, %330
%340 = load i32, i32* %18
%341 = call i32 @close(i32 %340)
store i32 1, i32* %3
br label %342
342: ; preds = %339, %41
%343 = load i32, i32* %3
ret i32 %343
}

LLVM IR (-O2):
%struct.stat = type { i64 }
@__const.main.dev_random_file = [12 x i8] c"/dev/random\00"
@.str = [7 x i8] c"dhltvz\00"
@stderr = global i32 0
@.str.1 = [86 x i8] c"DEBUG: debug_flag: %d syslog_flag: %d test_flag: %d verbose_flag: %d zabbix_flag: %d\0A\00"
@O_RDONLY = global i32 0
@O_NONBLOCK = global i32 0
@.str.2 = [30 x i8] c"DEBUG: %s I-node number: %ld\0A\00"
@.str.3 = [16 x i8] c"entropy_monitor\00"
@LOG_CONS = global i32 0
@LOG_PID = global i32 0
@LOG_NDELAY = global i32 0
@LOG_LOCAL1 = global i32 0
@.str.4 = [73 x i8] c"Collecting available entropy from %s for %d iterations every %d seconds\0A\00"
@RNDGETENTCNT = global i32 0
@.str.5 = [25 x i8] c"/dev/random result = %d\0A\00"
@.str.6 = [36 x i8] c"/dev/random is not a random device\0A\00"
@.str.7 = [47 x i8] c"/dev/random avail_ent = %d iters %d sum %ld\0A\00"
@stdout = global i32 0
@.str.8 = [40 x i8] c"- kernel.random.entropy_avail.log \22%s\22\0A\00"
@.str.9 = [35 x i8] c"low avalable entropy log text here\00"
@.str.10 = [69 x i8] c"- kernel.random.entropy_avail.maxsamplesbelow_read_wu_threshhold %d\0A\00"
@.str.11 = [70 x i8] c"- kernel.random.entropy_avail.maxsamplesbelow_write_wu_threshhold %d\0A\00"
@LOG_WARNING = global i32 0
@.str.12 = [80 x i8] c"entropy below read wakeup value %d for a maximum of %d consecutive measurements\00"
@.str.13 = [81 x i8] c"entropy below read wakeup value %d for a maximum of %d consecutive measurements\0A\00"
@.str.14 = [81 x i8] c"entropy below write wakeup value %d for a maximum of %d consecutive measurements\00"
@.str.15 = [82 x i8] c"entropy below write wakeup value %d for a maximum of %d consecutive measurements\0A\00"
@LOG_INFO = global i32 0
@.str.16 = [64 x i8] c"avail.low %d high %d mean %d for last period of (%d) iterations\00"
@.str.17 = [65 x i8] c"avail.low %d high %d mean %d for last period of (%d) iterations\0A\00"
@.str.18 = [39 x i8] c"- kernel.random.entropy_avail.mean %d\0A\00"
@.str.19 = [39 x i8] c"- kernel.random.entropy_avail.high %d\0A\00"
@.str.20 = [38 x i8] c"- kernel.random.entropy_avail.low %d\0A\00"
@.str.21 = [22 x i8] c"exiting due to error\0A\00"
@LOG_ERR = global i32 0
@.str.22 = [21 x i8] c"exiting due to error\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [12 x i8]
%4 = alloca i32
%5 = alloca %struct.stat
%6 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
%7 = bitcast i32* %4 to i8*
%8 = bitcast %struct.stat* %5 to i8*
%9 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32 %9, -1
br i1 %10, label %48, label %11
11: ; preds = %2, %32
%12 = phi i32 [ %41, %32 ], [ %9, %2 ]
%13 = phi i32 [ %40, %32 ], [ 0, %2 ]
%14 = phi i32 [ %39, %32 ], [ 0, %2 ]
%15 = phi i32 [ %38, %32 ], [ 60, %2 ]
%16 = phi i32 [ %37, %32 ], [ 0, %2 ]
%17 = phi i32 [ %36, %32 ], [ 0, %2 ]
%18 = phi i32 [ %35, %32 ], [ 0, %2 ]
%19 = phi i32 [ %34, %32 ], [ 0, %2 ]
%20 = phi i32 [ %33, %32 ], [ 0, %2 ]
%21 = add i32 %12, -100
%22 = tail call i32 @llvm.fshl.i32(i32 %21, i32 %21, i32 31)
switch i32 %22, label %29 [
i32 0, label %32
i32 2, label %23
i32 4, label %25
i32 8, label %26
i32 9, label %27
i32 11, label %28
]
23: ; preds = %11
%24 = tail call i32 (...) @show_help()
br label %238
25: ; preds = %11
br label %32
26: ; preds = %11
br label %32
27: ; preds = %11
br label %32
28: ; preds = %11
br label %32
29: ; preds = %11
%30 = tail call i32 (...) @show_help()
%31 = tail call i32 (...) @abort()
unreachable
32: ; preds = %11, %28, %27, %26, %25
%33 = phi i32 [ %20, %28 ], [ %20, %27 ], [ %20, %26 ], [ %20, %25 ], [ 1, %11 ]
%34 = phi i32 [ 1, %28 ], [ %19, %27 ], [ %19, %26 ], [ %19, %25 ], [ %19, %11 ]
%35 = phi i32 [ %18, %28 ], [ %18, %27 ], [ %18, %26 ], [ 1, %25 ], [ %18, %11 ]
%36 = phi i32 [ %17, %28 ], [ 1, %27 ], [ %17, %26 ], [ %17, %25 ], [ %17, %11 ]
%37 = phi i32 [ %16, %28 ], [ %16, %27 ], [ 1, %26 ], [ %16, %25 ], [ %16, %11 ]
%38 = phi i32 [ %15, %28 ], [ %15, %27 ], [ 10, %26 ], [ %15, %25 ], [ %15, %11 ]
%39 = phi i32 [ %14, %28 ], [ %14, %27 ], [ 3400, %26 ], [ %14, %25 ], [ %14, %11 ]
%40 = phi i32 [ %13, %28 ], [ %13, %27 ], [ 4000, %26 ], [ %13, %25 ], [ %13, %11 ]
%41 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%42 = icmp eq i32 %41, -1
br i1 %42, label %43, label %11
43: ; preds = %32
%44 = icmp eq i32 %33, 0
br i1 %44, label %48, label %45
45: ; preds = %43
%46 = load i32, i32* @stderr
%47 = tail call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([86 x i8], [86 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 %35, i32 %37, i32 %36, i32 %34)
br label %48
48: ; preds = %2, %45, %43
%49 = phi i1 [ true, %45 ], [ false, %43 ], [ false, %2 ]
%50 = phi i32 [ %40, %45 ], [ %40, %43 ], [ 0, %2 ]
%51 = phi i32 [ %39, %45 ], [ %39, %43 ], [ 0, %2 ]
%52 = phi i32 [ %38, %45 ], [ %38, %43 ], [ 60, %2 ]
%53 = phi i32 [ %37, %45 ], [ %37, %43 ], [ 0, %2 ]
%54 = phi i32 [ %36, %45 ], [ %36, %43 ], [ 0, %2 ]
%55 = phi i32 [ %35, %45 ], [ %35, %43 ], [ 0, %2 ]
%56 = phi i32 [ %34, %45 ], [ %34, %43 ], [ 0, %2 ]
%57 = load i32, i32* @O_RDONLY
%58 = load i32, i32* @O_NONBLOCK
%59 = call i32 @open(i8* %6, i32 %57, i32 %58)
%60 = call i32 @stat(i8* %6, %struct.stat* %5)
br i1 %49, label %61, label %66
61: ; preds = %48
%62 = load i32, i32* @stderr
%63 = getelementptr inbounds %struct.stat, %struct.stat* %5, i64 0, i32 0
%64 = load i64, i64* %63
%65 = call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %6, i64 %64)
br label %66
66: ; preds = %61, %48
%67 = icmp eq i32 %55, 0
br i1 %67, label %76, label %68
68: ; preds = %66
%69 = load i32, i32* @LOG_CONS
%70 = load i32, i32* @LOG_PID
%71 = or i32 %70, %69
%72 = load i32, i32* @LOG_NDELAY
%73 = or i32 %71, %72
%74 = load i32, i32* @LOG_LOCAL1
%75 = call i32 @openlog(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %73, i32 %74)
br label %76
76: ; preds = %68, %66
%77 = icmp ne i32 %54, 0
br i1 %77, label %78, label %81
78: ; preds = %76
%79 = load i32, i32* @stderr
%80 = call i32 (i32, i8*, ...) @fprintf(i32 %79, i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.4, i64 0, i64 0), i8* %6, i32 %52, i32 1)
br label %81
81: ; preds = %78, %76
%82 = icmp eq i32 %53, 0
%83 = select i1 %82, i32 64, i32 %51
%84 = select i1 %82, i32 128, i32 %50
%85 = select i1 %49, i1 true, i1 %77
%86 = zext i32 %52 to i64
%87 = icmp eq i32 %56, 0
br label %88
88: ; preds = %160, %81
%89 = phi i32 [ -1, %81 ], [ %161, %160 ]
%90 = phi i32 [ 0, %81 ], [ %162, %160 ]
%91 = phi i32 [ 0, %81 ], [ %163, %160 ]
%92 = phi i32 [ 0, %81 ], [ %164, %160 ]
%93 = phi i32 [ 0, %81 ], [ %165, %160 ]
%94 = phi i32 [ 0, %81 ], [ %166, %160 ]
%95 = phi i32 [ 1, %81 ], [ %167, %160 ]
%96 = phi i32 [ 0, %81 ], [ %168, %160 ]
%97 = phi i32 [ 0, %81 ], [ %169, %160 ]
%98 = phi i64 [ 0, %81 ], [ %170, %160 ]
%99 = load i32, i32* @RNDGETENTCNT
%100 = call i32 @ioctl(i32 %59, i32 %99, i32* %4)
%101 = icmp eq i32 %100, 0
br i1 %101, label %107, label %102
102: ; preds = %88
%103 = load i32, i32* @stderr
%104 = call i32 (i32, i8*, ...) @fprintf(i32 %103, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %100)
%105 = load i32, i32* @stderr
%106 = call i32 (i32, i8*, ...) @fprintf(i32 %105, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0))
store i32 -1, i32* %4
br label %171
107: ; preds = %88
%108 = icmp eq i32 %95, 1
%109 = load i32, i32* %4
%110 = select i1 %108, i32 %109, i32 %97
%111 = select i1 %108, i32 %109, i32 %96
%112 = icmp sgt i32 %109, %110
%113 = select i1 %112, i32 %109, i32 %110
%114 = icmp slt i32 %109, %111
%115 = select i1 %114, i32 %109, i32 %111
%116 = sext i32 %109 to i64
%117 = add nsw i64 %98, %116
br i1 %85, label %118, label %122
118: ; preds = %107
%119 = load i32, i32* @stderr
%120 = call i32 (i32, i8*, ...) @fprintf(i32 %119, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.7, i64 0, i64 0), i32 %109, i32 %95, i64 %117)
%121 = load i32, i32* %4
br label %122
122: ; preds = %107, %118
%123 = phi i32 [ %109, %107 ], [ %121, %118 ]
%124 = icmp slt i32 %123, %94
br i1 %124, label %125, label %129
125: ; preds = %122
%126 = add nsw i32 %94, 1
%127 = load i32, i32* @stdout
%128 = call i32 (i32, i8*, ...) @fprintf(i32 %127, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0))
br label %129
129: ; preds = %125, %122
%130 = phi i32 [ %126, %125 ], [ %94, %122 ]
%131 = icmp eq i32 %89, -1
br i1 %131, label %132, label %134
132: ; preds = %129
%133 = load i32, i32* %4
br label %151
134: ; preds = %129
%135 = icmp slt i32 %89, %83
%136 = load i32, i32* %4
%137 = icmp slt i32 %136, %83
%138 = select i1 %135, i1 %137, i1 false
%139 = add nsw i32 %93, 1
%140 = icmp slt i32 %93, %91
%141 = select i1 %140, i32 %91, i32 %139
%142 = select i1 %138, i32 %139, i32 0
%143 = select i1 %138, i32 %141, i32 %91
%144 = icmp slt i32 %89, %84
%145 = icmp slt i32 %136, %84
%146 = select i1 %144, i1 %145, i1 false
br i1 %146, label %147, label %151
147: ; preds = %134
%148 = add nsw i32 %92, 1
%149 = icmp slt i32 %92, %90
%150 = select i1 %149, i32 %90, i32 %148
br label %151
151: ; preds = %132, %147, %134
%152 = phi i32 [ %133, %132 ], [ %136, %147 ], [ %136, %134 ]
%153 = phi i32 [ %93, %132 ], [ %142, %147 ], [ %142, %134 ]
%154 = phi i32 [ %92, %132 ], [ %148, %147 ], [ 0, %134 ]
%155 = phi i32 [ %91, %132 ], [ %143, %147 ], [ %143, %134 ]
%156 = phi i32 [ %90, %132 ], [ %150, %147 ], [ %90, %134 ]
%157 = call i32 @sleep(i32 1)
%158 = add nuw i32 %95, 1
%159 = icmp eq i32 %95, %52
br i1 %159, label %171, label %160
160: ; preds = %151, %226
%161 = phi i32 [ %152, %151 ], [ -1, %226 ]
%162 = phi i32 [ %156, %151 ], [ 0, %226 ]
%163 = phi i32 [ %155, %151 ], [ 0, %226 ]
%164 = phi i32 [ %154, %151 ], [ 0, %226 ]
%165 = phi i32 [ %153, %151 ], [ 0, %226 ]
%166 = phi i32 [ %130, %151 ], [ 0, %226 ]
%167 = phi i32 [ %158, %151 ], [ 1, %226 ]
%168 = phi i32 [ %115, %151 ], [ 0, %226 ]
%169 = phi i32 [ %113, %151 ], [ 0, %226 ]
%170 = phi i64 [ %117, %151 ], [ 0, %226 ]
br label %88
171: ; preds = %151, %102
%172 = phi i64 [ %98, %102 ], [ %117, %151 ]
%173 = phi i32 [ %97, %102 ], [ %113, %151 ]
%174 = phi i32 [ %96, %102 ], [ %115, %151 ]
%175 = phi i32 [ %91, %102 ], [ %155, %151 ]
%176 = phi i32 [ %90, %102 ], [ %156, %151 ]
%177 = icmp sgt i32 %175, 0
%178 = zext i1 %177 to i32
%179 = add nsw i32 %175, %178
%180 = icmp sgt i32 %176, 0
%181 = zext i1 %180 to i32
%182 = add nsw i32 %176, %181
%183 = sdiv i64 %172, %86
%184 = trunc i64 %183 to i32
br i1 %87, label %190, label %185
185: ; preds = %171
%186 = load i32, i32* @stdout
%187 = call i32 (i32, i8*, ...) @fprintf(i32 %186, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.10, i64 0, i64 0), i32 %179)
%188 = load i32, i32* @stdout
%189 = call i32 (i32, i8*, ...) @fprintf(i32 %188, i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.11, i64 0, i64 0), i32 %182)
br label %190
190: ; preds = %185, %171
%191 = icmp sgt i32 %179, 0
br i1 %191, label %192, label %200
192: ; preds = %190
br i1 %67, label %196, label %193
193: ; preds = %192
%194 = load i32, i32* @LOG_WARNING
%195 = call i32 (i32, i8*, ...) @syslog(i32 %194, i8* getelementptr inbounds ([80 x i8], [80 x i8]* @.str.12, i64 0, i64 0), i32 %83, i32 %179)
br label %196
196: ; preds = %193, %192
br i1 %85, label %197, label %200
197: ; preds = %196
%198 = load i32, i32* @stderr
%199 = call i32 (i32, i8*, ...) @fprintf(i32 %198, i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.13, i64 0, i64 0), i32 %84, i32 %179)
br label %200
200: ; preds = %197, %196, %190
%201 = icmp sgt i32 %182, 0
br i1 %201, label %202, label %210
202: ; preds = %200
br i1 %67, label %206, label %203
203: ; preds = %202
%204 = load i32, i32* @LOG_WARNING
%205 = call i32 (i32, i8*, ...) @syslog(i32 %204, i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.14, i64 0, i64 0), i32 %84, i32 %182)
br label %206
206: ; preds = %203, %202
br i1 %85, label %207, label %210
207: ; preds = %206
%208 = load i32, i32* @stderr
%209 = call i32 (i32, i8*, ...) @fprintf(i32 %208, i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.15, i64 0, i64 0), i32 %84, i32 %182)
br label %210
210: ; preds = %207, %206, %200
br i1 %67, label %214, label %211
211: ; preds = %210
%212 = load i32, i32* @LOG_INFO
%213 = call i32 (i32, i8*, ...) @syslog(i32 %212, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.16, i64 0, i64 0), i32 %174, i32 %173, i32 %184, i32 %52)
br label %214
214: ; preds = %211, %210
br i1 %85, label %215, label %218
215: ; preds = %214
%216 = load i32, i32* @stderr
%217 = call i32 (i32, i8*, ...) @fprintf(i32 %216, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.17, i64 0, i64 0), i32 %174, i32 %173, i32 %184, i32 %52)
br label %218
218: ; preds = %214, %215
br i1 %87, label %226, label %219
219: ; preds = %218
%220 = load i32, i32* @stdout
%221 = call i32 (i32, i8*, ...) @fprintf(i32 %220, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.18, i64 0, i64 0), i32 %184)
%222 = load i32, i32* @stdout
%223 = call i32 (i32, i8*, ...) @fprintf(i32 %222, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.19, i64 0, i64 0), i32 %173)
%224 = load i32, i32* @stdout
%225 = call i32 (i32, i8*, ...) @fprintf(i32 %224, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.20, i64 0, i64 0), i32 %174)
br label %226
226: ; preds = %219, %218
%227 = load i32, i32* @stdout
%228 = call i32 @fflush_unlocked(i32 %227)
br i1 %101, label %160, label %229
229: ; preds = %226
%230 = load i32, i32* @stderr
%231 = call i32 (i32, i8*, ...) @fprintf(i32 %230, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.21, i64 0, i64 0))
br i1 %67, label %236, label %232
232: ; preds = %229
%233 = load i32, i32* @LOG_ERR
%234 = call i32 (i32, i8*, ...) @syslog(i32 %233, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.22, i64 0, i64 0))
%235 = call i32 (...) @closelog()
br label %236
236: ; preds = %232, %229
%237 = call i32 @close(i32 %59)
br label %238
238: ; preds = %236, %23
%239 = phi i32 [ 0, %23 ], [ 1, %236 ]
ret i32 %239
}