#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 uint64_t;
struct sysinfo {
  int dummy;
};
typedef int int64_t;
typedef int /*<<< orphan*/ fd_set;
typedef int /*<<< orphan*/ eventfd_val;
typedef int /*<<< orphan*/ event_str;
typedef int /*<<< orphan*/ event_control_file;

/* Variables and functions */
scalar_t__ FD_ISSET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ O_WRONLY;
int errno;
int eventfd(int /*<<< orphan*/, int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ read(int, int *, int);
int select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ snprintf(char *, int, char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, char *);
scalar_t__ strlen(char *);
int write(int, char *, scalar_t__);
int mem_alerts_init(char *memcg_dir, uint64_t total_mem) {
  struct sysinfo si;
  int fd_event_control;
  char event_str[255];
  char event_control_file[255];
  char memusage_file[255];
  char *cg_dirname;
  uint64_t threshold_mem;
  int fd_mem_alert_minor;
  int fd_mem_alert_severe;
  int fd_mem_alert_critical;
  int fd_cgroup_all_mem_usage;
  int ret;
  fd_mem_alert_minor = eventfd(0, 0);
  fd_mem_alert_severe = eventfd(0, 0);
  fd_mem_alert_critical = eventfd(0, 0);
  sprintf(memusage_file, "%s/memory.usage_in_bytes", memcg_dir);
  fd_cgroup_all_mem_usage = open(memusage_file, O_RDONLY);
  if (fd_cgroup_all_mem_usage < 0) {
    printf("Error opening cgroup file %s err %d\n", memusage_file, errno);
    return fd_cgroup_all_mem_usage;
  }
  snprintf(event_control_file, sizeof(event_control_file),
           "%s/cgroup.event_control", memcg_dir);
  fd_event_control = open(event_control_file, O_WRONLY);
  if (fd_event_control < 0) {
    printf("Error opening the control file %s err %d\n", event_control_file,
           errno);
    return fd_event_control;
  }
  threshold_mem = total_mem * (50) / 100;
  printf("minor threshold = %llu\n", threshold_mem);
  snprintf(event_str, sizeof(event_str), "%d %d %llu", fd_mem_alert_minor,
           fd_cgroup_all_mem_usage, threshold_mem);
  ret = write(fd_event_control, event_str, strlen(event_str) + 1);
  if (ret < 0) {
    printf("Error writing %s err %d\n", event_str, errno);
    return ret;
  }
  threshold_mem = total_mem * (70) / 100;
  printf("severe threshold = %llu\n", threshold_mem);
  snprintf(event_str, sizeof(event_str), "%d %d %llu", fd_mem_alert_severe,
           fd_cgroup_all_mem_usage, threshold_mem);
  ret = write(fd_event_control, event_str, strlen(event_str) + 1);
  if (ret < 0) {
    printf("Error writing %s err %d\n", event_str, errno);
    return ret;
  }
  threshold_mem = total_mem * (90) / 100;
  printf("critical threshold = %llu\n", threshold_mem);
  snprintf(event_str, sizeof(event_str), "%d %d %llu", fd_mem_alert_critical,
           fd_cgroup_all_mem_usage, threshold_mem);
  ret = write(fd_event_control, event_str, strlen(event_str) + 1);
  if (ret < 0) {
    printf("Error writing %s err %d\n", event_str, errno);
    return ret;
  }
  int max_fd = 0;
  fd_set readfds;
  FD_ZERO(&readfds);
  FD_SET(fd_mem_alert_minor, &readfds);
  max_fd = fd_mem_alert_minor > max_fd ? fd_mem_alert_minor : max_fd;
  FD_SET(fd_mem_alert_severe, &readfds);
  max_fd = fd_mem_alert_severe > max_fd ? fd_mem_alert_severe : max_fd;
  FD_SET(fd_mem_alert_critical, &readfds);
  max_fd = fd_mem_alert_critical > max_fd ? fd_mem_alert_critical : max_fd;
  int64_t eventfd_val;
  while ((ret = select(max_fd + 1, &readfds, NULL, NULL, NULL)) >= 0) {
    if (FD_ISSET(fd_mem_alert_minor, &readfds)) {
      printf(">> MINOR ALERT OCCURRED <<\n");
      if ((ret = read(fd_mem_alert_minor, &eventfd_val, sizeof(eventfd_val)) <
                 0)) {
        printf("reading minor alert eventfd failed with %d\n", errno);
        return ret;
      }
      printf("minor event count = %lld\n", eventfd_val);
    }
    if (FD_ISSET(fd_mem_alert_severe, &readfds)) {
      printf(">> SEVERE ALERT OCCURRED <<\n");
      if ((ret = read(fd_mem_alert_severe, &eventfd_val, sizeof(eventfd_val)) <
                 0)) {
        printf("reading severe alert eventfd failed with %d\n", errno);
        return ret;
      }
      printf("alert event count = %lld\n", eventfd_val);
    }
    if (FD_ISSET(fd_mem_alert_critical, &readfds)) {
      printf(">> CRITICAL ALERT OCCURRED <<\n");
      if ((ret = read(fd_mem_alert_critical, &eventfd_val,
                      sizeof(eventfd_val)) < 0)) {
        printf("reading critical alert eventfd failed with %d\n", errno);
        return ret;
      }
      printf("critical event count = %lld\n", eventfd_val);
    }
    FD_SET(fd_mem_alert_minor, &readfds);
    FD_SET(fd_mem_alert_severe, &readfds);
    FD_SET(fd_mem_alert_critical, &readfds);
  }
  return ret;
}


x86 assembly (clang, -O0):
<mem_alerts_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x390,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
xor    %esi,%esi
mov    %esi,%edi
call   10d0 <eventfd@plt>
mov    %eax,-0x330(%rbp)
xor    %esi,%esi
mov    %esi,%edi
call   10d0 <eventfd@plt>
mov    %eax,-0x334(%rbp)
xor    %esi,%esi
mov    %esi,%edi
call   10d0 <eventfd@plt>
mov    %eax,-0x338(%rbp)
lea    -0x320(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xdef(%rip),%rsi
call   10c0 <sprintf@plt>
lea    -0x320(%rbp),%rdi
mov    0x2dc4(%rip),%rax
mov    (%rax),%esi
call   10b0 <open@plt>
mov    %eax,-0x33c(%rbp)
cmpl   $0x0,-0x33c(%rbp)
jge    126a <mem_alerts_init+0xaa>
lea    -0x320(%rbp),%rsi
mov    0x2d8c(%rip),%rax
mov    (%rax),%edx
lea    0xdc4(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x33c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1884 <mem_alerts_init+0x6c4>
lea    -0x220(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0xff,%esi
lea    0xdbd(%rip),%rdx
mov    $0x0,%al
call   1070 <snprintf@plt>
lea    -0x220(%rbp),%rdi
mov    0x2d32(%rip),%rax
mov    (%rax),%esi
call   10b0 <open@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    12d3 <mem_alerts_init+0x113>
lea    -0x220(%rbp),%rsi
mov    0x2d20(%rip),%rax
mov    (%rax),%edx
lea    0xd95(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1884 <mem_alerts_init+0x6c4>
imul   $0x32,-0x14(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,-0x32c(%rbp)
mov    -0x32c(%rbp),%esi
lea    0xd8e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x120(%rbp),%rdi
mov    -0x330(%rbp),%ecx
mov    -0x33c(%rbp),%r8d
mov    -0x32c(%rbp),%r9d
mov    $0xff,%esi
lea    0xd78(%rip),%rdx
mov    $0x0,%al
call   1070 <snprintf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x35c(%rbp)
lea    -0x120(%rbp),%rax
mov    %rax,-0x358(%rbp)
lea    -0x120(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x35c(%rbp),%edi
mov    -0x358(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1030 <write@plt>
mov    %eax,-0x340(%rbp)
cmpl   $0x0,-0x340(%rbp)
jge    13a2 <mem_alerts_init+0x1e2>
lea    -0x120(%rbp),%rsi
mov    0x2c54(%rip),%rax
mov    (%rax),%edx
lea    0xd16(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x340(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1884 <mem_alerts_init+0x6c4>
imul   $0x46,-0x14(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,-0x32c(%rbp)
mov    -0x32c(%rbp),%esi
lea    0xcfb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x120(%rbp),%rdi
mov    -0x334(%rbp),%ecx
mov    -0x33c(%rbp),%r8d
mov    -0x32c(%rbp),%r9d
mov    $0xff,%esi
lea    0xca9(%rip),%rdx
mov    $0x0,%al
call   1070 <snprintf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x36c(%rbp)
lea    -0x120(%rbp),%rax
mov    %rax,-0x368(%rbp)
lea    -0x120(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x36c(%rbp),%edi
mov    -0x368(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1030 <write@plt>
mov    %eax,-0x340(%rbp)
cmpl   $0x0,-0x340(%rbp)
jge    1471 <mem_alerts_init+0x2b1>
lea    -0x120(%rbp),%rsi
mov    0x2b85(%rip),%rax
mov    (%rax),%edx
lea    0xc47(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x340(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1884 <mem_alerts_init+0x6c4>
imul   $0x5a,-0x14(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,-0x32c(%rbp)
mov    -0x32c(%rbp),%esi
lea    0xc45(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x120(%rbp),%rdi
mov    -0x338(%rbp),%ecx
mov    -0x33c(%rbp),%r8d
mov    -0x32c(%rbp),%r9d
mov    $0xff,%esi
lea    0xbda(%rip),%rdx
mov    $0x0,%al
call   1070 <snprintf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x37c(%rbp)
lea    -0x120(%rbp),%rax
mov    %rax,-0x378(%rbp)
lea    -0x120(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x37c(%rbp),%edi
mov    -0x378(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1030 <write@plt>
mov    %eax,-0x340(%rbp)
cmpl   $0x0,-0x340(%rbp)
jge    1540 <mem_alerts_init+0x380>
lea    -0x120(%rbp),%rsi
mov    0x2ab6(%rip),%rax
mov    (%rax),%edx
lea    0xb78(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x340(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1884 <mem_alerts_init+0x6c4>
movl   $0x0,-0x344(%rbp)
lea    -0x348(%rbp),%rdi
call   1090 <FD_ZERO@plt>
mov    -0x330(%rbp),%edi
lea    -0x348(%rbp),%rsi
call   10e0 <FD_SET@plt>
mov    -0x330(%rbp),%eax
cmp    -0x344(%rbp),%eax
jle    158b <mem_alerts_init+0x3cb>
mov    -0x330(%rbp),%eax
mov    %eax,-0x380(%rbp)
jmp    1597 <mem_alerts_init+0x3d7>
mov    -0x344(%rbp),%eax
mov    %eax,-0x380(%rbp)
mov    -0x380(%rbp),%eax
mov    %eax,-0x344(%rbp)
mov    -0x334(%rbp),%edi
lea    -0x348(%rbp),%rsi
call   10e0 <FD_SET@plt>
mov    -0x334(%rbp),%eax
cmp    -0x344(%rbp),%eax
jle    15d8 <mem_alerts_init+0x418>
mov    -0x334(%rbp),%eax
mov    %eax,-0x384(%rbp)
jmp    15e4 <mem_alerts_init+0x424>
mov    -0x344(%rbp),%eax
mov    %eax,-0x384(%rbp)
mov    -0x384(%rbp),%eax
mov    %eax,-0x344(%rbp)
mov    -0x338(%rbp),%edi
lea    -0x348(%rbp),%rsi
call   10e0 <FD_SET@plt>
mov    -0x338(%rbp),%eax
cmp    -0x344(%rbp),%eax
jle    1625 <mem_alerts_init+0x465>
mov    -0x338(%rbp),%eax
mov    %eax,-0x388(%rbp)
jmp    1631 <mem_alerts_init+0x471>
mov    -0x344(%rbp),%eax
mov    %eax,-0x388(%rbp)
mov    -0x388(%rbp),%eax
mov    %eax,-0x344(%rbp)
mov    -0x344(%rbp),%edi
add    $0x1,%edi
lea    -0x348(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rdx
mov    %r8,%rcx
call   10a0 <select@plt>
mov    %eax,-0x340(%rbp)
cmp    $0x0,%eax
jl     187b <mem_alerts_init+0x6bb>
mov    -0x330(%rbp),%edi
lea    -0x348(%rbp),%rsi
call   1040 <FD_ISSET@plt>
cmp    $0x0,%rax
je     1708 <mem_alerts_init+0x548>
lea    0xa61(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x330(%rbp),%edi
lea    -0x34c(%rbp),%rsi
mov    $0x4,%edx
call   1080 <read@plt>
cmp    $0x0,%rax
setl   %al
mov    %al,%cl
and    $0x1,%cl
movzbl %cl,%ecx
mov    %ecx,-0x340(%rbp)
test   $0x1,%al
jne    16cf <mem_alerts_init+0x50f>
jmp    16f4 <mem_alerts_init+0x534>
mov    0x2902(%rip),%rax
mov    (%rax),%esi
lea    0xa2d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x340(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1884 <mem_alerts_init+0x6c4>
mov    -0x34c(%rbp),%esi
lea    0xa37(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x334(%rbp),%edi
lea    -0x348(%rbp),%rsi
call   1040 <FD_ISSET@plt>
cmp    $0x0,%rax
je     17a4 <mem_alerts_init+0x5e4>
lea    0xa27(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x334(%rbp),%edi
lea    -0x34c(%rbp),%rsi
mov    $0x4,%edx
call   1080 <read@plt>
cmp    $0x0,%rax
setl   %al
mov    %al,%cl
and    $0x1,%cl
movzbl %cl,%ecx
mov    %ecx,-0x340(%rbp)
test   $0x1,%al
jne    176b <mem_alerts_init+0x5ab>
jmp    1790 <mem_alerts_init+0x5d0>
mov    0x2866(%rip),%rax
mov    (%rax),%esi
lea    0x9f4(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x340(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1884 <mem_alerts_init+0x6c4>
mov    -0x34c(%rbp),%esi
lea    0x9ff(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x338(%rbp),%edi
lea    -0x348(%rbp),%rsi
call   1040 <FD_ISSET@plt>
cmp    $0x0,%rax
je     1840 <mem_alerts_init+0x680>
lea    0x9ef(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x338(%rbp),%edi
lea    -0x34c(%rbp),%rsi
mov    $0x4,%edx
call   1080 <read@plt>
cmp    $0x0,%rax
setl   %al
mov    %al,%cl
and    $0x1,%cl
movzbl %cl,%ecx
mov    %ecx,-0x340(%rbp)
test   $0x1,%al
jne    1807 <mem_alerts_init+0x647>
jmp    182c <mem_alerts_init+0x66c>
mov    0x27ca(%rip),%rax
mov    (%rax),%esi
lea    0x9be(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x340(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1884 <mem_alerts_init+0x6c4>
mov    -0x34c(%rbp),%esi
lea    0x9cb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x330(%rbp),%edi
lea    -0x348(%rbp),%rsi
call   10e0 <FD_SET@plt>
mov    -0x334(%rbp),%edi
lea    -0x348(%rbp),%rsi
call   10e0 <FD_SET@plt>
mov    -0x338(%rbp),%edi
lea    -0x348(%rbp),%rsi
call   10e0 <FD_SET@plt>
jmp    163d <mem_alerts_init+0x47d>
mov    -0x340(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x390,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mem_alerts_init>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x318,%rsp
mov    %esi,%r13d
mov    %rdi,%rbx
xor    %edi,%edi
xor    %esi,%esi
call   10e0 <eventfd@plt>
mov    %eax,%r12d
xor    %edi,%edi
xor    %esi,%esi
call   10e0 <eventfd@plt>
mov    %eax,0x8(%rsp)
xor    %edi,%edi
xor    %esi,%esi
call   10e0 <eventfd@plt>
mov    %eax,%r14d
lea    0xded(%rip),%rsi
lea    0x110(%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rdx
call   10d0 <sprintf@plt>
mov    0x2dbb(%rip),%rax
mov    (%rax),%esi
mov    %rbp,%rdi
call   10c0 <open@plt>
mov    %eax,%ebp
test   %eax,%eax
js     1560 <mem_alerts_init+0x390>
mov    %r14d,0x4(%rsp)
lea    0xdf1(%rip),%rdx
lea    0x210(%rsp),%r14
mov    %r14,%rdi
mov    $0xff,%esi
mov    %rbx,%rcx
xor    %eax,%eax
call   1080 <snprintf@plt>
mov    0x2d5a(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   10c0 <open@plt>
mov    %eax,%r15d
test   %eax,%eax
js     1584 <mem_alerts_init+0x3b4>
mov    %r13d,%ebx
shr    $0x1f,%ebx
add    %r13d,%ebx
sar    %ebx
lea    0xdeb(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xdf3(%rip),%rdx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0xff,%esi
mov    %r12d,%ecx
mov    %ebp,%r8d
mov    %ebx,%r9d
xor    %eax,%eax
call   1080 <snprintf@plt>
mov    %r14,%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %r15d,%edi
mov    %r14,%rsi
call   1040 <write@plt>
test   %eax,%eax
js     15ab <mem_alerts_init+0x3db>
imul   $0x46,%r13d,%eax
cltq
imul   $0x51eb851f,%rax,%rbx
mov    %rbx,%rax
shr    $0x3f,%rax
sar    $0x25,%rbx
add    %eax,%ebx
lea    0xdba(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xd86(%rip),%rdx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0xff,%esi
mov    0x8(%rsp),%ecx
mov    %ebp,%r8d
mov    %ebx,%r9d
xor    %eax,%eax
call   1080 <snprintf@plt>
mov    %r14,%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %r15d,%edi
mov    %r14,%rsi
call   1040 <write@plt>
test   %eax,%eax
js     15cf <mem_alerts_init+0x3ff>
imul   $0x5a,%r13d,%eax
cltq
imul   $0x51eb851f,%rax,%rbx
mov    %rbx,%rax
shr    $0x3f,%rax
sar    $0x25,%rbx
add    %eax,%ebx
lea    0xd65(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xd18(%rip),%rdx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0xff,%esi
mov    0x4(%rsp),%r13d
mov    %r13d,%ecx
mov    %ebp,%r8d
mov    %ebx,%r9d
xor    %eax,%eax
call   1080 <snprintf@plt>
mov    %r14,%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %r15d,%edi
mov    %r14,%rsi
call   1040 <write@plt>
test   %eax,%eax
js     15f1 <mem_alerts_init+0x421>
lea    0xc(%rsp),%r14
mov    %r14,%rdi
call   10a0 <FD_ZERO@plt>
mov    %r12d,%edi
mov    %r14,%rsi
call   10f0 <FD_SET@plt>
test   %r12d,%r12d
mov    %r12d,%ebx
mov    $0x0,%eax
cmovs  %eax,%ebx
mov    0x8(%rsp),%ebp
mov    %ebp,%edi
mov    %r14,%rsi
call   10f0 <FD_SET@plt>
cmp    %ebx,%ebp
cmovg  %ebp,%ebx
mov    %r13d,%edi
mov    %r14,%rsi
call   10f0 <FD_SET@plt>
cmp    %ebx,%r13d
cmovg  %r13d,%ebx
add    $0x1,%ebx
mov    %ebx,%edi
mov    %r14,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10b0 <select@plt>
test   %eax,%eax
js     160d <mem_alerts_init+0x43d>
lea    0xc(%rsp),%r13
lea    0xcbc(%rip),%r15
jmp    1479 <mem_alerts_init+0x2a9>
cs nopw 0x0(%rax,%rax,1)
mov    %r12d,%edi
mov    %r13,%rsi
call   10f0 <FD_SET@plt>
mov    %ebp,%edi
mov    %r13,%rsi
call   10f0 <FD_SET@plt>
mov    %r14d,%edi
mov    %r13,%rsi
call   10f0 <FD_SET@plt>
mov    %ebx,%edi
mov    %r13,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10b0 <select@plt>
test   %eax,%eax
js     160d <mem_alerts_init+0x43d>
mov    %r12d,%edi
mov    %r13,%rsi
call   1050 <FD_ISSET@plt>
test   %rax,%rax
mov    0x8(%rsp),%ebp
je     14c3 <mem_alerts_init+0x2f3>
lea    0xd6f(%rip),%rdi
call   1030 <puts@plt>
mov    %r12d,%edi
mov    %rsp,%rsi
mov    $0x4,%edx
call   1090 <read@plt>
test   %rax,%rax
js     1611 <mem_alerts_init+0x441>
mov    (%rsp),%esi
lea    0xc60(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %ebp,%edi
mov    %r13,%rsi
call   1050 <FD_ISSET@plt>
test   %rax,%rax
je     1507 <mem_alerts_init+0x337>
lea    0xd0e(%rip),%rdi
call   1030 <puts@plt>
mov    %ebp,%edi
mov    %rsp,%rsi
mov    $0x4,%edx
call   1090 <read@plt>
test   %rax,%rax
js     1616 <mem_alerts_init+0x446>
mov    (%rsp),%esi
lea    0xc63(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x4(%rsp),%r14d
mov    %r14d,%edi
mov    %r13,%rsi
call   1050 <FD_ISSET@plt>
test   %rax,%rax
je     1440 <mem_alerts_init+0x270>
lea    0xca2(%rip),%rdi
call   1030 <puts@plt>
mov    %r14d,%edi
mov    %rsp,%rsi
mov    $0x4,%edx
call   1090 <read@plt>
test   %rax,%rax
js     161f <mem_alerts_init+0x44f>
mov    (%rsp),%esi
lea    0xc5d(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x4(%rsp),%r14d
jmp    1440 <mem_alerts_init+0x270>
mov    0x2a71(%rip),%rax
mov    (%rax),%edx
lea    0xaa9(%rip),%rdi
lea    0x110(%rsp),%rsi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    163b <mem_alerts_init+0x46b>
mov    0x2a4d(%rip),%rax
mov    (%rax),%edx
lea    0xac2(%rip),%rdi
lea    0x210(%rsp),%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r15d,%ebp
jmp    163b <mem_alerts_init+0x46b>
mov    %eax,%r14d
mov    0x2a23(%rip),%rax
mov    (%rax),%edx
lea    0xae5(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r14d,%ebp
jmp    163b <mem_alerts_init+0x46b>
mov    %eax,%ebx
mov    0x2a00(%rip),%rax
mov    (%rax),%edx
lea    0xac2(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %ebx,%ebp
jmp    163b <mem_alerts_init+0x46b>
mov    %eax,%ebp
mov    0x29de(%rip),%rax
mov    (%rax),%edx
lea    0xaa0(%rip),%rdi
lea    0x10(%rsp),%rsi
jmp    1578 <mem_alerts_init+0x3a8>
mov    %eax,%ebp
jmp    163b <mem_alerts_init+0x46b>
mov    %r15,%rdi
jmp    1626 <mem_alerts_init+0x456>
lea    0xb19(%rip),%rdi
jmp    1626 <mem_alerts_init+0x456>
lea    0xb57(%rip),%rdi
mov    0x29ab(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x318,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sysinfo = type { i32 }
@.str = [25 x i8] c"%s/memory.usage_in_bytes\00"
@O_RDONLY = global i32 0
@.str.1 = [37 x i8] c"Error opening cgroup file %s err %d\0A\00"
@errno = global i32 0
@.str.2 = [24 x i8] c"%s/cgroup.event_control\00"
@O_WRONLY = global i32 0
@.str.3 = [42 x i8] c"Error opening the control file %s err %d\0A\00"
@.str.4 = [24 x i8] c"minor threshold = %llu\0A\00"
@.str.5 = [11 x i8] c"%d %d %llu\00"
@.str.6 = [25 x i8] c"Error writing %s err %d\0A\00"
@.str.7 = [25 x i8] c"severe threshold = %llu\0A\00"
@.str.8 = [27 x i8] c"critical threshold = %llu\0A\00"
@.str.9 = [28 x i8] c">> MINOR ALERT OCCURRED <<\0A\00"
@.str.10 = [44 x i8] c"reading minor alert eventfd failed with %d\0A\00"
@.str.11 = [26 x i8] c"minor event count = %lld\0A\00"
@.str.12 = [29 x i8] c">> SEVERE ALERT OCCURRED <<\0A\00"
@.str.13 = [45 x i8] c"reading severe alert eventfd failed with %d\0A\00"
@.str.14 = [26 x i8] c"alert event count = %lld\0A\00"
@.str.15 = [31 x i8] c">> CRITICAL ALERT OCCURRED <<\0A\00"
@.str.16 = [47 x i8] c"reading critical alert eventfd failed with %d\0A\00"
@.str.17 = [29 x i8] c"critical event count = %lld\0A\00"
define i32 @mem_alerts_init(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca %struct.sysinfo
%7 = alloca i32
%8 = alloca [255 x i8]
%9 = alloca [255 x i8]
%10 = alloca [255 x i8]
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%21 = call i32 @eventfd(i32 0, i32 0)
store i32 %21, i32* %13
%22 = call i32 @eventfd(i32 0, i32 0)
store i32 %22, i32* %14
%23 = call i32 @eventfd(i32 0, i32 0)
store i32 %23, i32* %15
%24 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i64 0, i64 0
%25 = load i8*, i8** %4
%26 = call i32 @sprintf(i8* %24, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %25)
%27 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i64 0, i64 0
%28 = load i32, i32* @O_RDONLY
%29 = call i32 @open(i8* %27, i32 %28)
store i32 %29, i32* %16
%30 = load i32, i32* %16
%31 = icmp slt i32 %30, 0
br i1 %31, label %32, label %37
32: ; preds = %2
%33 = getelementptr inbounds [255 x i8], [255 x i8]* %10, i64 0, i64 0
%34 = load i32, i32* @errno
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %33, i32 %34)
%36 = load i32, i32* %16
store i32 %36, i32* %3
br label %223
37: ; preds = %2
%38 = getelementptr inbounds [255 x i8], [255 x i8]* %9, i64 0, i64 0
%39 = load i8*, i8** %4
%40 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %38, i32 255, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %39)
%41 = getelementptr inbounds [255 x i8], [255 x i8]* %9, i64 0, i64 0
%42 = load i32, i32* @O_WRONLY
%43 = call i32 @open(i8* %41, i32 %42)
store i32 %43, i32* %7
%44 = load i32, i32* %7
%45 = icmp slt i32 %44, 0
br i1 %45, label %46, label %51
46: ; preds = %37
%47 = getelementptr inbounds [255 x i8], [255 x i8]* %9, i64 0, i64 0
%48 = load i32, i32* @errno
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i8* %47, i32 %48)
%50 = load i32, i32* %7
store i32 %50, i32* %3
br label %223
51: ; preds = %37
%52 = load i32, i32* %5
%53 = mul nsw i32 %52, 50
%54 = sdiv i32 %53, 100
store i32 %54, i32* %12
%55 = load i32, i32* %12
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 %55)
%57 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%58 = load i32, i32* %13
%59 = load i32, i32* %16
%60 = load i32, i32* %12
%61 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %57, i32 255, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i32 %58, i32 %59, i32 %60)
%62 = load i32, i32* %7
%63 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%64 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%65 = call i64 @strlen(i8* %64)
%66 = add nsw i64 %65, 1
%67 = call i32 @write(i32 %62, i8* %63, i64 %66)
store i32 %67, i32* %17
%68 = load i32, i32* %17
%69 = icmp slt i32 %68, 0
br i1 %69, label %70, label %75
70: ; preds = %51
%71 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%72 = load i32, i32* @errno
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i8* %71, i32 %72)
%74 = load i32, i32* %17
store i32 %74, i32* %3
br label %223
75: ; preds = %51
%76 = load i32, i32* %5
%77 = mul nsw i32 %76, 70
%78 = sdiv i32 %77, 100
store i32 %78, i32* %12
%79 = load i32, i32* %12
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i32 %79)
%81 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%82 = load i32, i32* %14
%83 = load i32, i32* %16
%84 = load i32, i32* %12
%85 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %81, i32 255, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i32 %82, i32 %83, i32 %84)
%86 = load i32, i32* %7
%87 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%88 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%89 = call i64 @strlen(i8* %88)
%90 = add nsw i64 %89, 1
%91 = call i32 @write(i32 %86, i8* %87, i64 %90)
store i32 %91, i32* %17
%92 = load i32, i32* %17
%93 = icmp slt i32 %92, 0
br i1 %93, label %94, label %99
94: ; preds = %75
%95 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%96 = load i32, i32* @errno
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i8* %95, i32 %96)
%98 = load i32, i32* %17
store i32 %98, i32* %3
br label %223
99: ; preds = %75
%100 = load i32, i32* %5
%101 = mul nsw i32 %100, 90
%102 = sdiv i32 %101, 100
store i32 %102, i32* %12
%103 = load i32, i32* %12
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0), i32 %103)
%105 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%106 = load i32, i32* %15
%107 = load i32, i32* %16
%108 = load i32, i32* %12
%109 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %105, i32 255, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i32 %106, i32 %107, i32 %108)
%110 = load i32, i32* %7
%111 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%112 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%113 = call i64 @strlen(i8* %112)
%114 = add nsw i64 %113, 1
%115 = call i32 @write(i32 %110, i8* %111, i64 %114)
store i32 %115, i32* %17
%116 = load i32, i32* %17
%117 = icmp slt i32 %116, 0
br i1 %117, label %118, label %123
118: ; preds = %99
%119 = getelementptr inbounds [255 x i8], [255 x i8]* %8, i64 0, i64 0
%120 = load i32, i32* @errno
%121 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i8* %119, i32 %120)
%122 = load i32, i32* %17
store i32 %122, i32* %3
br label %223
123: ; preds = %99
store i32 0, i32* %18
%124 = call i32 @FD_ZERO(i32* %19)
%125 = load i32, i32* %13
%126 = call i32 @FD_SET(i32 %125, i32* %19)
%127 = load i32, i32* %13
%128 = load i32, i32* %18
%129 = icmp sgt i32 %127, %128
br i1 %129, label %130, label %132
130: ; preds = %123
%131 = load i32, i32* %13
br label %134
132: ; preds = %123
%133 = load i32, i32* %18
br label %134
134: ; preds = %132, %130
%135 = phi i32 [ %131, %130 ], [ %133, %132 ]
store i32 %135, i32* %18
%136 = load i32, i32* %14
%137 = call i32 @FD_SET(i32 %136, i32* %19)
%138 = load i32, i32* %14
%139 = load i32, i32* %18
%140 = icmp sgt i32 %138, %139
br i1 %140, label %141, label %143
141: ; preds = %134
%142 = load i32, i32* %14
br label %145
143: ; preds = %134
%144 = load i32, i32* %18
br label %145
145: ; preds = %143, %141
%146 = phi i32 [ %142, %141 ], [ %144, %143 ]
store i32 %146, i32* %18
%147 = load i32, i32* %15
%148 = call i32 @FD_SET(i32 %147, i32* %19)
%149 = load i32, i32* %15
%150 = load i32, i32* %18
%151 = icmp sgt i32 %149, %150
br i1 %151, label %152, label %154
152: ; preds = %145
%153 = load i32, i32* %15
br label %156
154: ; preds = %145
%155 = load i32, i32* %18
br label %156
156: ; preds = %154, %152
%157 = phi i32 [ %153, %152 ], [ %155, %154 ]
store i32 %157, i32* %18
br label %158
158: ; preds = %214, %156
%159 = load i32, i32* %18
%160 = add nsw i32 %159, 1
%161 = call i32 @select(i32 %160, i32* %19, i32* null, i32* null, i32* null)
store i32 %161, i32* %17
%162 = icmp sge i32 %161, 0
br i1 %162, label %163, label %221
163: ; preds = %158
%164 = load i32, i32* %13
%165 = call i64 @FD_ISSET(i32 %164, i32* %19)
%166 = icmp ne i64 %165, 0
br i1 %166, label %167, label %180
167: ; preds = %163
%168 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0))
%169 = load i32, i32* %13
%170 = call i64 @read(i32 %169, i32* %20, i32 4)
%171 = icmp slt i64 %170, 0
%172 = zext i1 %171 to i32
store i32 %172, i32* %17
br i1 %171, label %173, label %177
173: ; preds = %167
%174 = load i32, i32* @errno
%175 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.10, i64 0, i64 0), i32 %174)
%176 = load i32, i32* %17
store i32 %176, i32* %3
br label %223
177: ; preds = %167
%178 = load i32, i32* %20
%179 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0), i32 %178)
br label %180
180: ; preds = %177, %163
%181 = load i32, i32* %14
%182 = call i64 @FD_ISSET(i32 %181, i32* %19)
%183 = icmp ne i64 %182, 0
br i1 %183, label %184, label %197
184: ; preds = %180
%185 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.12, i64 0, i64 0))
%186 = load i32, i32* %14
%187 = call i64 @read(i32 %186, i32* %20, i32 4)
%188 = icmp slt i64 %187, 0
%189 = zext i1 %188 to i32
store i32 %189, i32* %17
br i1 %188, label %190, label %194
190: ; preds = %184
%191 = load i32, i32* @errno
%192 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.13, i64 0, i64 0), i32 %191)
%193 = load i32, i32* %17
store i32 %193, i32* %3
br label %223
194: ; preds = %184
%195 = load i32, i32* %20
%196 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.14, i64 0, i64 0), i32 %195)
br label %197
197: ; preds = %194, %180
%198 = load i32, i32* %15
%199 = call i64 @FD_ISSET(i32 %198, i32* %19)
%200 = icmp ne i64 %199, 0
br i1 %200, label %201, label %214
201: ; preds = %197
%202 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.15, i64 0, i64 0))
%203 = load i32, i32* %15
%204 = call i64 @read(i32 %203, i32* %20, i32 4)
%205 = icmp slt i64 %204, 0
%206 = zext i1 %205 to i32
store i32 %206, i32* %17
br i1 %205, label %207, label %211
207: ; preds = %201
%208 = load i32, i32* @errno
%209 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.16, i64 0, i64 0), i32 %208)
%210 = load i32, i32* %17
store i32 %210, i32* %3
br label %223
211: ; preds = %201
%212 = load i32, i32* %20
%213 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.17, i64 0, i64 0), i32 %212)
br label %214
214: ; preds = %211, %197
%215 = load i32, i32* %13
%216 = call i32 @FD_SET(i32 %215, i32* %19)
%217 = load i32, i32* %14
%218 = call i32 @FD_SET(i32 %217, i32* %19)
%219 = load i32, i32* %15
%220 = call i32 @FD_SET(i32 %219, i32* %19)
br label %158
221: ; preds = %158
%222 = load i32, i32* %17
store i32 %222, i32* %3
br label %223
223: ; preds = %221, %207, %190, %173, %118, %94, %70, %46, %32
%224 = load i32, i32* %3
ret i32 %224
}

LLVM IR (-O2):
@.str = [25 x i8] c"%s/memory.usage_in_bytes\00"
@O_RDONLY = global i32 0
@.str.1 = [37 x i8] c"Error opening cgroup file %s err %d\0A\00"
@errno = global i32 0
@.str.2 = [24 x i8] c"%s/cgroup.event_control\00"
@O_WRONLY = global i32 0
@.str.3 = [42 x i8] c"Error opening the control file %s err %d\0A\00"
@.str.4 = [24 x i8] c"minor threshold = %llu\0A\00"
@.str.5 = [11 x i8] c"%d %d %llu\00"
@.str.6 = [25 x i8] c"Error writing %s err %d\0A\00"
@.str.7 = [25 x i8] c"severe threshold = %llu\0A\00"
@.str.8 = [27 x i8] c"critical threshold = %llu\0A\00"
@.str.10 = [44 x i8] c"reading minor alert eventfd failed with %d\0A\00"
@.str.11 = [26 x i8] c"minor event count = %lld\0A\00"
@.str.13 = [45 x i8] c"reading severe alert eventfd failed with %d\0A\00"
@.str.14 = [26 x i8] c"alert event count = %lld\0A\00"
@.str.16 = [47 x i8] c"reading critical alert eventfd failed with %d\0A\00"
@.str.17 = [29 x i8] c"critical event count = %lld\0A\00"
@str = [30 x i8] c">> CRITICAL ALERT OCCURRED <<\00"
@str.18 = [28 x i8] c">> SEVERE ALERT OCCURRED <<\00"
@str.19 = [27 x i8] c">> MINOR ALERT OCCURRED <<\00"
define i32 @mem_alerts_init(i8* %0, i32 %1) {
%3 = alloca [255 x i8]
%4 = alloca [255 x i8]
%5 = alloca [255 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%10 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%11 = tail call i32 @eventfd(i32 0, i32 0)
%12 = tail call i32 @eventfd(i32 0, i32 0)
%13 = tail call i32 @eventfd(i32 0, i32 0)
%14 = call i32 @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %0)
%15 = load i32, i32* @O_RDONLY
%16 = call i32 @open(i8* %10, i32 %15)
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %2
%19 = load i32, i32* @errno
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %10, i32 %19)
br label %122
21: ; preds = %2
%22 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %9, i32 255, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%23 = load i32, i32* @O_WRONLY
%24 = call i32 @open(i8* %9, i32 %23)
%25 = icmp slt i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %21
%27 = load i32, i32* @errno
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i8* %9, i32 %27)
br label %122
29: ; preds = %21
%30 = sdiv i32 %1, 2
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 %30)
%32 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %8, i32 255, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i32 %11, i32 %16, i32 %30)
%33 = call i64 @strlen(i8* %8)
%34 = add nsw i64 %33, 1
%35 = call i32 @write(i32 %24, i8* %8, i64 %34)
%36 = icmp slt i32 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %29
%38 = load i32, i32* @errno
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i8* %8, i32 %38)
br label %122
40: ; preds = %29
%41 = mul nsw i32 %1, 70
%42 = sdiv i32 %41, 100
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i32 %42)
%44 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %8, i32 255, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i32 %12, i32 %16, i32 %42)
%45 = call i64 @strlen(i8* %8)
%46 = add nsw i64 %45, 1
%47 = call i32 @write(i32 %24, i8* %8, i64 %46)
%48 = icmp slt i32 %47, 0
br i1 %48, label %49, label %52
49: ; preds = %40
%50 = load i32, i32* @errno
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i8* %8, i32 %50)
br label %122
52: ; preds = %40
%53 = mul nsw i32 %1, 90
%54 = sdiv i32 %53, 100
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0), i32 %54)
%56 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %8, i32 255, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i32 %13, i32 %16, i32 %54)
%57 = call i64 @strlen(i8* %8)
%58 = add nsw i64 %57, 1
%59 = call i32 @write(i32 %24, i8* %8, i64 %58)
%60 = icmp slt i32 %59, 0
br i1 %60, label %61, label %64
61: ; preds = %52
%62 = load i32, i32* @errno
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i8* %8, i32 %62)
br label %122
64: ; preds = %52
%65 = bitcast i32* %6 to i8*
%66 = call i32 @FD_ZERO(i32* %6)
%67 = call i32 @FD_SET(i32 %11, i32* %6)
%68 = icmp sgt i32 %11, 0
%69 = select i1 %68, i32 %11, i32 0
%70 = call i32 @FD_SET(i32 %12, i32* %6)
%71 = icmp sgt i32 %12, %69
%72 = select i1 %71, i32 %12, i32 %69
%73 = call i32 @FD_SET(i32 %13, i32* %6)
%74 = icmp sgt i32 %13, %72
%75 = select i1 %74, i32 %13, i32 %72
%76 = bitcast i32* %7 to i8*
%77 = add nuw nsw i32 %75, 1
%78 = call i32 @select(i32 %77, i32* %6, i32* null, i32* null, i32* null)
%79 = icmp sgt i32 %78, -1
br i1 %79, label %80, label %120
80: ; preds = %64, %110
%81 = call i64 @FD_ISSET(i32 %11, i32* %6)
%82 = icmp eq i64 %81, 0
br i1 %82, label %90, label %83
83: ; preds = %80
%84 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.19, i64 0, i64 0))
%85 = call i64 @read(i32 %11, i32* %7, i32 4)
%86 = icmp slt i64 %85, 0
br i1 %86, label %116, label %87
87: ; preds = %83
%88 = load i32, i32* %7
%89 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0), i32 %88)
br label %90
90: ; preds = %87, %80
%91 = call i64 @FD_ISSET(i32 %12, i32* %6)
%92 = icmp eq i64 %91, 0
br i1 %92, label %100, label %93
93: ; preds = %90
%94 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.18, i64 0, i64 0))
%95 = call i64 @read(i32 %12, i32* %7, i32 4)
%96 = icmp slt i64 %95, 0
br i1 %96, label %116, label %97
97: ; preds = %93
%98 = load i32, i32* %7
%99 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.14, i64 0, i64 0), i32 %98)
br label %100
100: ; preds = %97, %90
%101 = call i64 @FD_ISSET(i32 %13, i32* %6)
%102 = icmp eq i64 %101, 0
br i1 %102, label %110, label %103
103: ; preds = %100
%104 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%105 = call i64 @read(i32 %13, i32* %7, i32 4)
%106 = icmp slt i64 %105, 0
br i1 %106, label %116, label %107
107: ; preds = %103
%108 = load i32, i32* %7
%109 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.17, i64 0, i64 0), i32 %108)
br label %110
110: ; preds = %107, %100
%111 = call i32 @FD_SET(i32 %11, i32* %6)
%112 = call i32 @FD_SET(i32 %12, i32* %6)
%113 = call i32 @FD_SET(i32 %13, i32* %6)
%114 = call i32 @select(i32 %77, i32* %6, i32* null, i32* null, i32* null)
%115 = icmp sgt i32 %114, -1
br i1 %115, label %80, label %120
116: ; preds = %103, %93, %83
%117 = phi i8* [ getelementptr inbounds ([44 x i8], [44 x i8]* @.str.10, i64 0, i64 0), %83 ], [ getelementptr inbounds ([45 x i8], [45 x i8]* @.str.13, i64 0, i64 0), %93 ], [ getelementptr inbounds ([47 x i8], [47 x i8]* @.str.16, i64 0, i64 0), %103 ]
%118 = load i32, i32* @errno
%119 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %117, i32 %118)
br label %120
120: ; preds = %110, %116, %64
%121 = phi i32 [ %78, %64 ], [ 1, %116 ], [ %114, %110 ]
br label %122
122: ; preds = %120, %61, %49, %37, %26, %18
%123 = phi i32 [ %16, %18 ], [ %24, %26 ], [ %35, %37 ], [ %47, %49 ], [ %59, %61 ], [ %121, %120 ]
ret i32 %123
}