#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 pollfd {
  int fd;
  int events;
  int revents;
};
typedef int nfds_t;

/* Variables and functions */
scalar_t__ EINTR;
int /*<<< orphan*/ EXIT_FAILURE;
int IN_CLOSE;
int IN_CREATE;
int /*<<< orphan*/ IN_NONBLOCK;
int IN_OPEN;
int POLLIN;
int STDIN_FILENO;
int *calloc(int, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ err(int, char *, ...);
scalar_t__ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ handle_events(int, int *, int, char **);
int inotify_add_watch(int, char *, int);
int inotify_init1(int /*<<< orphan*/);
int poll(struct pollfd *, int, int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ read(int, char *, int);
int main(int argc, char *argv[]) {
  char buf;
  int fd, i, poll_num;
  int *wd;
  nfds_t nfds;
  struct pollfd fds[2];
  if (argc < 2) {
    printf("Usage: %s PATH [PATH ...]\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  printf("Press ENTER key to terminate.\n");
  fd = inotify_init1(IN_NONBLOCK);
  if (fd == -1)
    err(1, "inotify_init1");
  wd = calloc(argc, sizeof(int));
  if (wd == NULL)
    err(1, "calloc");
  for (i = 1; i < argc; i++) {
    wd[i] = inotify_add_watch(fd, argv[i], IN_OPEN | IN_CLOSE | IN_CREATE);
    if (wd[i] == -1)
      err(1, "Cannot watch '%s'", argv[i]);
  }
  nfds = 2;
  fds[0].fd = STDIN_FILENO;
  fds[0].events = POLLIN;
  fds[1].fd = fd;
  fds[1].events = POLLIN;
  printf("Listening for events.\n");
  while (1) {
    poll_num = poll(fds, nfds, -1);
    if (poll_num == -1) {
      if (errno == EINTR)
        continue;
      err(1, "poll");
    }
    if (poll_num > 0) {
      if (fds[0].revents & POLLIN) {
        while (read(STDIN_FILENO, &buf, 1) > 0 && buf != '\n')
          continue;
        break;
      }
      if (fds[1].revents & POLLIN)
        handle_events(fd, wd, argc, argv);
    }
  }
  printf("Listening for events stopped.\n");
  close(fd);
  free(wd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11f3 <main+0x43>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2dcc(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2dd0(%rip),%rax
mov    (%rax),%edi
call   10d0 <inotify_init1@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    122f <main+0x7f>
mov    $0x1,%edi
lea    0xe12(%rip),%rsi
mov    $0x0,%al
call   1090 <err@plt>
mov    -0x8(%rbp),%edi
mov    $0x4,%esi
call   1070 <calloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    125e <main+0xae>
mov    $0x1,%edi
lea    0xdf1(%rip),%rsi
mov    $0x0,%al
call   1090 <err@plt>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12f1 <main+0x141>
mov    -0x18(%rbp),%edi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    0x2d11(%rip),%rax
mov    (%rax),%edx
mov    0x2d30(%rip),%rax
or     (%rax),%edx
mov    0x2d2f(%rip),%rax
or     (%rax),%edx
call   10a0 <inotify_add_watch@plt>
mov    %eax,%edx
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpl   $0xffffffff,(%rax,%rcx,4)
jne    12de <main+0x12e>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    $0x1,%edi
lea    0xd78(%rip),%rsi
mov    $0x0,%al
call   1090 <err@plt>
jmp    12e3 <main+0x133>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1265 <main+0xb5>
movl   $0x2,-0x2c(%rbp)
mov    0x2ca9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
mov    0x2cdd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    0x2ccb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
lea    0xd38(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x50(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    $0xffffffff,%edx
call   10b0 <poll@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xffffffff,-0x20(%rbp)
jne    1380 <main+0x1d0>
mov    0x2c7b(%rip),%rax
mov    (%rax),%rax
mov    0x2c51(%rip),%rcx
cmp    (%rcx),%rax
jne    136d <main+0x1bd>
jmp    1330 <main+0x180>
mov    $0x1,%edi
lea    0xcff(%rip),%rsi
mov    $0x0,%al
call   1090 <err@plt>
cmpl   $0x0,-0x20(%rbp)
jle    1421 <main+0x271>
mov    -0x48(%rbp),%eax
mov    0x2c54(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     13f4 <main+0x244>
jmp    13a4 <main+0x1f4>
mov    0x2bfd(%rip),%rax
mov    (%rax),%edi
lea    -0x11(%rbp),%rsi
mov    $0x1,%edx
call   1060 <read@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x51(%rbp)
jle    13da <main+0x22a>
movsbl -0x11(%rbp),%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0x51(%rbp)
mov    -0x51(%rbp),%al
test   $0x1,%al
jne    13ea <main+0x23a>
jmp    13ef <main+0x23f>
jmp    13a4 <main+0x1f4>
jmp    1426 <main+0x276>
mov    -0x3c(%rbp),%eax
mov    0x2bea(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     141c <main+0x26c>
mov    -0x18(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%rcx
call   1080 <handle_events@plt>
jmp    1421 <main+0x271>
jmp    1330 <main+0x180>
lea    0xc50(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%edi
call   1050 <close@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r13
cmp    $0x1,%edi
jle    13a9 <main+0x1e9>
mov    %edi,%ebx
lea    0xe64(%rip),%rdi
call   1040 <puts@plt>
mov    0x2de9(%rip),%rax
mov    (%rax),%edi
call   10e0 <inotify_init1@plt>
mov    %eax,%r15d
cmp    $0xffffffff,%eax
jne    1211 <main+0x51>
lea    0xe16(%rip),%rsi
mov    $0x1,%edi
xor    %eax,%eax
call   10a0 <err@plt>
mov    %ebx,%edi
mov    $0x4,%esi
call   1080 <calloc@plt>
mov    %rax,%r12
test   %rax,%rax
jne    1238 <main+0x78>
lea    0xdfd(%rip),%rsi
mov    $0x1,%edi
xor    %eax,%eax
call   10a0 <err@plt>
mov    %ebx,0xc(%rsp)
mov    %ebx,%ebp
mov    $0x1,%ebx
mov    0x2d7e(%rip),%r14
jmp    1259 <main+0x99>
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    %rbx,%rbp
je     129e <main+0xde>
mov    0x0(%r13,%rbx,8),%rsi
mov    0x2d5b(%rip),%rax
mov    (%rax),%edx
mov    0x2d2a(%rip),%rax
or     (%rax),%edx
or     (%r14),%edx
mov    %r15d,%edi
call   10b0 <inotify_add_watch@plt>
mov    %eax,(%r12,%rbx,4)
cmp    $0xffffffff,%eax
jne    1250 <main+0x90>
mov    0x0(%r13,%rbx,8),%rdx
mov    $0x1,%edi
lea    0xd9b(%rip),%rsi
xor    %eax,%eax
call   10a0 <err@plt>
jmp    1250 <main+0x90>
mov    0x2d03(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
mov    0x2d36(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x14(%rsp)
mov    %r15d,0x1c(%rsp)
mov    %eax,0x20(%rsp)
lea    0xd9d(%rip),%rdi
call   1040 <puts@plt>
lea    0x10(%rsp),%rbp
mov    0x2cf7(%rip),%rbx
mov    0x2cd0(%rip),%r14
mov    %rbp,%rdi
mov    $0x2,%esi
mov    $0xffffffff,%edx
call   10c0 <poll@plt>
cmp    $0xffffffff,%eax
je     1330 <main+0x170>
test   %eax,%eax
jle    12e0 <main+0x120>
mov    0x2ce6(%rip),%rax
mov    (%rax),%eax
test   %eax,0x18(%rsp)
jne    134d <main+0x18d>
test   %eax,0x24(%rsp)
je     12e0 <main+0x120>
mov    %r15d,%edi
mov    %r12,%rsi
mov    0xc(%rsp),%edx
mov    %r13,%rcx
call   1090 <handle_events@plt>
jmp    12e0 <main+0x120>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%rbx),%rax
cmp    (%r14),%rax
je     12e0 <main+0x120>
mov    $0x1,%edi
lea    0xcfe(%rip),%rsi
xor    %eax,%eax
call   10a0 <err@plt>
jmp    12e0 <main+0x120>
lea    0xb(%rsp),%rbx
mov    0x2c4f(%rip),%rbp
nopl   0x0(%rax)
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1070 <read@plt>
test   %rax,%rax
jle    137c <main+0x1bc>
cmpb   $0xa,0xb(%rsp)
jne    1360 <main+0x1a0>
lea    0xcf8(%rip),%rdi
call   1040 <puts@plt>
mov    %r15d,%edi
call   1060 <close@plt>
mov    %r12,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x0(%r13),%rsi
lea    0xc4c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2bf6(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
%struct.pollfd = type { i32, i32, i32 }
@.str = [27 x i8] c"Usage: %s PATH [PATH ...]\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [31 x i8] c"Press ENTER key to terminate.\0A\00"
@IN_NONBLOCK = global i32 0
@.str.2 = [14 x i8] c"inotify_init1\00"
@.str.3 = [7 x i8] c"calloc\00"
@IN_OPEN = global i32 0
@IN_CLOSE = global i32 0
@IN_CREATE = global i32 0
@.str.4 = [18 x i8] c"Cannot watch '%s'\00"
@STDIN_FILENO = global i32 0
@POLLIN = global i32 0
@.str.5 = [23 x i8] c"Listening for events.\0A\00"
@errno = global i64 0
@EINTR = global i64 0
@.str.6 = [5 x i8] c"poll\00"
@.str.7 = [31 x i8] c"Listening for events stopped.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32
%12 = alloca [2 x %struct.pollfd]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 2
br i1 %14, label %15, label %22
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = load i32, i32* @EXIT_FAILURE
%21 = call i32 @exit(i32 %20)
unreachable
22: ; preds = %2
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%24 = load i32, i32* @IN_NONBLOCK
%25 = call i32 @inotify_init1(i32 %24)
store i32 %25, i32* %7
%26 = load i32, i32* %7
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %30
28: ; preds = %22
%29 = call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %30
30: ; preds = %28, %22
%31 = load i32, i32* %4
%32 = call i32* @calloc(i32 %31, i32 4)
store i32* %32, i32** %10
%33 = load i32*, i32** %10
%34 = icmp eq i32* %33, null
br i1 %34, label %35, label %37
35: ; preds = %30
%36 = call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %37
37: ; preds = %35, %30
store i32 1, i32* %8
br label %38
38: ; preds = %73, %37
%39 = load i32, i32* %8
%40 = load i32, i32* %4
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %76
42: ; preds = %38
%43 = load i32, i32* %7
%44 = load i8**, i8*** %5
%45 = load i32, i32* %8
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8*, i8** %44, i64 %46
%48 = load i8*, i8** %47
%49 = load i32, i32* @IN_OPEN
%50 = load i32, i32* @IN_CLOSE
%51 = or i32 %49, %50
%52 = load i32, i32* @IN_CREATE
%53 = or i32 %51, %52
%54 = call i32 @inotify_add_watch(i32 %43, i8* %48, i32 %53)
%55 = load i32*, i32** %10
%56 = load i32, i32* %8
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i32, i32* %55, i64 %57
store i32 %54, i32* %58
%59 = load i32*, i32** %10
%60 = load i32, i32* %8
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i32, i32* %59, i64 %61
%63 = load i32, i32* %62
%64 = icmp eq i32 %63, -1
br i1 %64, label %65, label %72
65: ; preds = %42
%66 = load i8**, i8*** %5
%67 = load i32, i32* %8
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8*, i8** %66, i64 %68
%70 = load i8*, i8** %69
%71 = call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8* %70)
br label %72
72: ; preds = %65, %42
br label %73
73: ; preds = %72
%74 = load i32, i32* %8
%75 = add nsw i32 %74, 1
store i32 %75, i32* %8
br label %38
76: ; preds = %38
store i32 2, i32* %11
%77 = load i32, i32* @STDIN_FILENO
%78 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %12, i64 0, i64 0
%79 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %78, i32 0, i32 0
store i32 %77, i32* %79
%80 = load i32, i32* @POLLIN
%81 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %12, i64 0, i64 0
%82 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %81, i32 0, i32 1
store i32 %80, i32* %82
%83 = load i32, i32* %7
%84 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %12, i64 0, i64 1
%85 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %84, i32 0, i32 0
store i32 %83, i32* %85
%86 = load i32, i32* @POLLIN
%87 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %12, i64 0, i64 1
%88 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %87, i32 0, i32 1
store i32 %86, i32* %88
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
br label %90
90: ; preds = %76, %100, %140
%91 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %12, i64 0, i64 0
%92 = load i32, i32* %11
%93 = call i32 @poll(%struct.pollfd* %91, i32 %92, i32 -1)
store i32 %93, i32* %9
%94 = load i32, i32* %9
%95 = icmp eq i32 %94, -1
br i1 %95, label %96, label %103
96: ; preds = %90
%97 = load i64, i64* @errno
%98 = load i64, i64* @EINTR
%99 = icmp eq i64 %97, %98
br i1 %99, label %100, label %101
100: ; preds = %96
br label %90
101: ; preds = %96
%102 = call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
br label %103
103: ; preds = %101, %90
%104 = load i32, i32* %9
%105 = icmp sgt i32 %104, 0
br i1 %105, label %106, label %140
106: ; preds = %103
%107 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %12, i64 0, i64 0
%108 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %107, i32 0, i32 2
%109 = load i32, i32* %108
%110 = load i32, i32* @POLLIN
%111 = and i32 %109, %110
%112 = icmp ne i32 %111, 0
br i1 %112, label %113, label %126
113: ; preds = %106
br label %114
114: ; preds = %124, %113
%115 = load i32, i32* @STDIN_FILENO
%116 = call i64 @read(i32 %115, i8* %6, i32 1)
%117 = icmp sgt i64 %116, 0
br i1 %117, label %118, label %122
118: ; preds = %114
%119 = load i8, i8* %6
%120 = sext i8 %119 to i32
%121 = icmp ne i32 %120, 10
br label %122
122: ; preds = %118, %114
%123 = phi i1 [ false, %114 ], [ %121, %118 ]
br i1 %123, label %124, label %125
124: ; preds = %122
br label %114
125: ; preds = %122
br label %141
126: ; preds = %106
%127 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %12, i64 0, i64 1
%128 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %127, i32 0, i32 2
%129 = load i32, i32* %128
%130 = load i32, i32* @POLLIN
%131 = and i32 %129, %130
%132 = icmp ne i32 %131, 0
br i1 %132, label %133, label %139
133: ; preds = %126
%134 = load i32, i32* %7
%135 = load i32*, i32** %10
%136 = load i32, i32* %4
%137 = load i8**, i8*** %5
%138 = call i32 @handle_events(i32 %134, i32* %135, i32 %136, i8** %137)
br label %139
139: ; preds = %133, %126
br label %140
140: ; preds = %139, %103
br label %90
141: ; preds = %125
%142 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0))
%143 = load i32, i32* %7
%144 = call i32 @close(i32 %143)
%145 = load i32*, i32** %10
%146 = call i32 @free(i32* %145)
ret i32 0
}

LLVM IR (-O2):
%struct.pollfd = type { i32, i32, i32 }
@.str = [27 x i8] c"Usage: %s PATH [PATH ...]\0A\00"
@EXIT_FAILURE = global i32 0
@IN_NONBLOCK = global i32 0
@.str.2 = [14 x i8] c"inotify_init1\00"
@.str.3 = [7 x i8] c"calloc\00"
@IN_OPEN = global i32 0
@IN_CLOSE = global i32 0
@IN_CREATE = global i32 0
@.str.4 = [18 x i8] c"Cannot watch '%s'\00"
@STDIN_FILENO = global i32 0
@POLLIN = global i32 0
@errno = global i64 0
@EINTR = global i64 0
@.str.6 = [5 x i8] c"poll\00"
@str = [30 x i8] c"Press ENTER key to terminate.\00"
@str.8 = [22 x i8] c"Listening for events.\00"
@str.9 = [30 x i8] c"Listening for events stopped.\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i8
%4 = alloca [2 x %struct.pollfd]
%5 = bitcast [2 x %struct.pollfd]* %4 to i8*
%6 = icmp slt i32 %0, 2
br i1 %6, label %7, label %12
7: ; preds = %2
%8 = load i8*, i8** %1
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %2
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%14 = load i32, i32* @IN_NONBLOCK
%15 = tail call i32 @inotify_init1(i32 %14)
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %19
17: ; preds = %12
%18 = tail call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %19
19: ; preds = %17, %12
%20 = tail call i32* @calloc(i32 %0, i32 4)
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = tail call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %24
24: ; preds = %19, %22
%25 = zext i32 %0 to i64
br label %26
26: ; preds = %24, %41
%27 = phi i64 [ 1, %24 ], [ %42, %41 ]
%28 = getelementptr inbounds i8*, i8** %1, i64 %27
%29 = load i8*, i8** %28
%30 = load i32, i32* @IN_OPEN
%31 = load i32, i32* @IN_CLOSE
%32 = or i32 %31, %30
%33 = load i32, i32* @IN_CREATE
%34 = or i32 %32, %33
%35 = tail call i32 @inotify_add_watch(i32 %15, i8* %29, i32 %34)
%36 = getelementptr inbounds i32, i32* %20, i64 %27
store i32 %35, i32* %36
%37 = icmp eq i32 %35, -1
br i1 %37, label %38, label %41
38: ; preds = %26
%39 = load i8*, i8** %28
%40 = tail call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8* %39)
br label %41
41: ; preds = %26, %38
%42 = add nuw nsw i64 %27, 1
%43 = icmp eq i64 %42, %25
br i1 %43, label %44, label %26
44: ; preds = %41
%45 = load i32, i32* @STDIN_FILENO
%46 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %4, i64 0, i64 0
%47 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %4, i64 0, i64 0, i32 0
store i32 %45, i32* %47
%48 = load i32, i32* @POLLIN
%49 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %4, i64 0, i64 0, i32 1
store i32 %48, i32* %49
%50 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %4, i64 0, i64 1, i32 0
store i32 %15, i32* %50
%51 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %4, i64 0, i64 1, i32 1
store i32 %48, i32* %51
%52 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.8, i64 0, i64 0))
%53 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %4, i64 0, i64 0, i32 2
%54 = getelementptr inbounds [2 x %struct.pollfd], [2 x %struct.pollfd]* %4, i64 0, i64 1, i32 2
br label %55
55: ; preds = %66, %44
%56 = call i32 @poll(%struct.pollfd* %46, i32 2, i32 -1)
%57 = icmp eq i32 %56, -1
br i1 %57, label %58, label %64
58: ; preds = %55
%59 = load i64, i64* @errno
%60 = load i64, i64* @EINTR
%61 = icmp eq i64 %59, %60
br i1 %61, label %66, label %62
62: ; preds = %58
%63 = call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
br label %66
64: ; preds = %55
%65 = icmp sgt i32 %56, 0
br i1 %65, label %67, label %66
66: ; preds = %64, %83, %79, %62, %58
br label %55
67: ; preds = %64
%68 = load i32, i32* %53
%69 = load i32, i32* @POLLIN
%70 = and i32 %69, %68
%71 = icmp eq i32 %70, 0
br i1 %71, label %79, label %72
72: ; preds = %67, %72
%73 = load i32, i32* @STDIN_FILENO
%74 = call i64 @read(i32 %73, i8* %3, i32 1)
%75 = icmp sgt i64 %74, 0
%76 = load i8, i8* %3
%77 = icmp ne i8 %76, 10
%78 = select i1 %75, i1 %77, i1 false
br i1 %78, label %72, label %85
79: ; preds = %67
%80 = load i32, i32* %54
%81 = and i32 %80, %69
%82 = icmp eq i32 %81, 0
br i1 %82, label %66, label %83
83: ; preds = %79
%84 = call i32 @handle_events(i32 %15, i32* %20, i32 %0, i8** %1)
br label %66
85: ; preds = %72
%86 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.9, i64 0, i64 0))
%87 = call i32 @close(i32 %15)
%88 = call i32 @free(i32* %20)
ret i32 0
}