#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 inotify_event {
  int wd;
  char *name;
  scalar_t__ len;
};
typedef int /*<<< orphan*/ fd_set;

/* Variables and functions */
int EXIT_SUCCESS;
scalar_t__ FD_ISSET(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int IN_CREATE;
int IN_MODIFY;
int NAME_MAX;
int /*<<< orphan*/ close(int);
int inotify_add_watch(int, char *, int);
int inotify_init();
int /*<<< orphan*/ inotify_rm_watch(int, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *, ...);
int read(int, char *, int);
int select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  if (argc < 2) {
    printf("Usage: %s root/path/to/watch /anotherpath/to/watch  .. \r\n",
           argv[0]);
    return EXIT_SUCCESS;
  }
  int length, i = 0;
  int notifyfd;
  int wd;
  char buffer[(128 * ((sizeof(struct inotify_event)) + 16 + NAME_MAX))];
  int watches[argc - 1];
  fd_set selectset;
  FD_ZERO(&selectset);
  FD_SET(0, &selectset);
  notifyfd = inotify_init();
  FD_SET(notifyfd, &selectset);
  if (notifyfd < 0) {
    perror("inotify_init failed");
  }
  for (i = 1; i < argc; i++) {
    watches[i - 1] =
        inotify_add_watch(notifyfd, argv[i], IN_CREATE | IN_MODIFY);
  }
  for (;;) {
    fd_set readset = selectset;
    if (select(notifyfd + 1, &readset, NULL, NULL, NULL) == -1) {
      perror("Unable to select");
      return 0;
    }
    if (FD_ISSET(0, &readset))
      break;
    else {
      length = read(notifyfd, buffer,
                    (128 * ((sizeof(struct inotify_event)) + 16 + NAME_MAX)));
      if (length < 0) {
        perror("unable to read from inotify");
        return 0;
      }
      i = 0;
      while (i < length) {
        struct inotify_event *event = (struct inotify_event *)&buffer[i];
        if (event->len) {
          int j;
          for (j = 1; j < argc; j++) {
            if (watches[j - 1] == event->wd) {
              printf("%s/%s\r\n", argv[j], event->name);
              break;
            }
          }
        }
        i += (sizeof(struct inotify_event)) + event->len;
      }
    }
  }
  for (i = 1; i < argc; i++)
    inotify_rm_watch(notifyfd, watches[i - 1]);
  close(notifyfd);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11f6 <main+0x46>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2de4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14ab <main+0x2fb>
movl   $0x0,-0x18(%rbp)
mov    0x2dbc(%rip),%rax
movslq (%rax),%rax
shl    $0x7,%rax
add    $0x1400,%rax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rsp,%rcx
sub    %rax,%rcx
mov    %rcx,-0x68(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x60(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
lea    -0x3c(%rbp),%rdi
call   1080 <FD_ZERO@plt>
xor    %edi,%edi
lea    -0x3c(%rbp),%rsi
call   10d0 <FD_SET@plt>
mov    $0x0,%al
call   1070 <inotify_init@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x3c(%rbp),%rsi
call   10d0 <FD_SET@plt>
cmpl   $0x0,-0x1c(%rbp)
jge    128c <main+0xdc>
lea    0xdb3(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12e5 <main+0x135>
mov    -0x1c(%rbp),%edi
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    0x2d23(%rip),%rax
mov    (%rax),%edx
mov    0x2d32(%rip),%rax
or     (%rax),%edx
call   10a0 <inotify_add_watch@plt>
mov    %eax,%edx
mov    -0x60(%rbp),%rax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1293 <main+0xe3>
jmp    12ea <main+0x13a>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x1c(%rbp),%edi
add    $0x1,%edi
lea    -0x40(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rdx
mov    %r8,%rcx
call   1090 <select@plt>
cmp    $0xffffffff,%eax
jne    1332 <main+0x182>
lea    0xd34(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x44(%rbp)
jmp    14a4 <main+0x2f4>
xor    %edi,%edi
lea    -0x40(%rbp),%rsi
call   1030 <FD_ISSET@plt>
cmp    $0x0,%rax
je     134c <main+0x19c>
jmp    145c <main+0x2ac>
mov    -0x68(%rbp),%rsi
mov    -0x1c(%rbp),%edi
mov    0x2c66(%rip),%rax
movslq (%rax),%rax
add    $0x28,%rax
shl    $0x7,%rax
mov    %eax,%edx
call   1060 <read@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1398 <main+0x1e8>
lea    0xcdf(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x44(%rbp)
jmp    14a4 <main+0x2f4>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1452 <main+0x2a2>
mov    -0x68(%rbp),%rax
movslq -0x18(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
cmpq   $0x0,0x10(%rax)
je     1437 <main+0x287>
movl   $0x1,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1432 <main+0x282>
mov    -0x60(%rbp),%rax
mov    -0x54(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x50(%rbp),%rcx
cmp    (%rcx),%eax
jne    141f <main+0x26f>
mov    -0x10(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x50(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xc68(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1432 <main+0x282>
jmp    1424 <main+0x274>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    13d0 <main+0x220>
jmp    1437 <main+0x287>
mov    -0x50(%rbp),%rax
mov    0x10(%rax),%rcx
add    $0x18,%rcx
movslq -0x18(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x18(%rbp)
jmp    139f <main+0x1ef>
jmp    1457 <main+0x2a7>
jmp    12ea <main+0x13a>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1495 <main+0x2e5>
mov    -0x60(%rbp),%rax
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
call   10c0 <inotify_rm_watch@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1463 <main+0x2b3>
mov    -0x1c(%rbp),%edi
call   1050 <close@plt>
movl   $0x0,-0x44(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
cmp    $0x1,%edi
jg     11e5 <main+0x35>
mov    (%rsi),%rsi
lea    0xe30(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2df2(%rip),%rax
mov    (%rax),%eax
jmp    13f3 <main+0x243>
mov    %edi,%r12d
mov    %rsi,-0x50(%rbp)
mov    %rsp,-0x58(%rbp)
mov    0x2dc9(%rip),%rax
movslq (%rax),%rax
shl    $0x7,%rax
neg    %rax
add    %rsp,%rax
add    $0xffffffffffffec00,%rax
mov    %rax,-0x48(%rbp)
mov    %rax,%rsp
lea    -0x1(%r12),%eax
mov    %rsp,%r15
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
lea    -0x34(%rbp),%r13
mov    %r13,%rdi
call   1080 <FD_ZERO@plt>
xor    %edi,%edi
mov    %r13,%rsi
call   10d0 <FD_SET@plt>
xor    %eax,%eax
call   1070 <inotify_init@plt>
mov    %eax,%ebx
mov    %eax,%edi
mov    %r13,%rsi
call   10d0 <FD_SET@plt>
mov    %ebx,-0x30(%rbp)
test   %ebx,%ebx
js     1402 <main+0x252>
mov    %r12d,%r12d
lea    -0x1(%r12),%rax
mov    %rax,-0x40(%rbp)
xor    %ebx,%ebx
mov    -0x50(%rbp),%r13
mov    -0x30(%rbp),%r14d
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x8(%r13,%rbx,8),%rsi
mov    0x2d64(%rip),%rax
mov    (%rax),%edx
mov    0x2d43(%rip),%rax
or     (%rax),%edx
mov    %r14d,%edi
call   10a0 <inotify_add_watch@plt>
mov    %eax,(%r15,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,-0x40(%rbp)
jne    1280 <main+0xd0>
mov    %r14d,%edi
add    $0x1,%edi
mov    -0x34(%rbp),%eax
mov    %eax,-0x2c(%rbp)
lea    -0x2c(%rbp),%rsi
mov    %edi,-0x40(%rbp)
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1090 <select@plt>
lea    0xd7b(%rip),%rdi
cmp    $0xffffffff,%eax
je     1428 <main+0x278>
lea    -0x2c(%rbp),%rbx
jmp    1319 <main+0x169>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    -0x34(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x40(%rbp),%edi
lea    -0x2c(%rbp),%rbx
mov    %rbx,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1090 <select@plt>
cmp    $0xffffffff,%eax
mov    -0x30(%rbp),%r14d
je     1413 <main+0x263>
xor    %edi,%edi
mov    %rbx,%rsi
call   1030 <FD_ISSET@plt>
test   %rax,%rax
jne    13c2 <main+0x212>
mov    0x2c8d(%rip),%rax
mov    (%rax),%edx
shl    $0x7,%edx
add    $0x1400,%edx
mov    %r14d,%edi
mov    -0x48(%rbp),%rsi
call   1060 <read@plt>
test   %eax,%eax
js     1421 <main+0x271>
mov    -0x48(%rbp),%rdi
je     12f0 <main+0x140>
mov    %eax,%r13d
xor    %r14d,%r14d
jmp    1391 <main+0x1e1>
mov    %ecx,%ecx
mov    -0x50(%rbp),%rdx
mov    (%rdx,%rcx,8),%rsi
mov    0x8(%rdi,%rax,1),%rdx
lea    0xd05(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    -0x48(%rbp),%rdi
add    %ebx,%r14d
add    $0x18,%r14d
cmp    %r13d,%r14d
jge    12f0 <main+0x140>
movslq %r14d,%rax
mov    0x10(%rdi,%rax,1),%rbx
test   %rbx,%rbx
je     1381 <main+0x1d1>
mov    (%rdi,%rax,1),%edx
mov    $0x1,%ecx
cs nopw 0x0(%rax,%rax,1)
cmp    %edx,-0x4(%r15,%rcx,4)
je     1360 <main+0x1b0>
add    $0x1,%rcx
cmp    %rcx,%r12
jne    13b0 <main+0x200>
jmp    1381 <main+0x1d1>
add    $0xffffffffffffffff,%r12
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%r15,%rbx,4),%esi
mov    %r14d,%edi
call   10c0 <inotify_rm_watch@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    13d0 <main+0x220>
mov    %r14d,%edi
call   1050 <close@plt>
mov    -0x58(%rbp),%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc31(%rip),%rdi
call   10b0 <perror@plt>
jmp    125f <main+0xaf>
lea    0xc34(%rip),%rdi
call   10b0 <perror@plt>
jmp    13ed <main+0x23d>
lea    0xc37(%rip),%rdi
call   10b0 <perror@plt>
jmp    13ed <main+0x23d>

LLVM IR (-O0):
%struct.inotify_event = type { i32, i8*, i64 }
@.str = [58 x i8] c"Usage: %s root/path/to/watch /anotherpath/to/watch .. \0D\0A\00"
@EXIT_SUCCESS = global i32 0
@NAME_MAX = global i32 0
@.str.1 = [20 x i8] c"inotify_init failed\00"
@IN_CREATE = global i32 0
@IN_MODIFY = global i32 0
@.str.2 = [17 x i8] c"Unable to select\00"
@.str.3 = [28 x i8] c"unable to read from inotify\00"
@.str.4 = [8 x i8] c"%s/%s\0D\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i64
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca %struct.inotify_event*
%17 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%18 = load i32, i32* %4
%19 = icmp slt i32 %18, 2
br i1 %19, label %20, label %26
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 0
%23 = load i8*, i8** %22
%24 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i8* %23)
%25 = load i32, i32* @EXIT_SUCCESS
store i32 %25, i32* %3
br label %171
26: ; preds = %2
store i32 0, i32* %7
%27 = load i32, i32* @NAME_MAX
%28 = sext i32 %27 to i64
%29 = add i64 40, %28
%30 = mul i64 128, %29
%31 = call i8* @llvm.stacksave()
store i8* %31, i8** %10
%32 = alloca i8, i64 %30
store i64 %30, i64* %11
%33 = load i32, i32* %4
%34 = sub nsw i32 %33, 1
%35 = zext i32 %34 to i64
%36 = alloca i32, i64 %35
store i64 %35, i64* %12
%37 = call i32 @FD_ZERO(i32* %13)
%38 = call i32 @FD_SET(i32 0, i32* %13)
%39 = call i32 (...) @inotify_init()
store i32 %39, i32* %8
%40 = load i32, i32* %8
%41 = call i32 @FD_SET(i32 %40, i32* %13)
%42 = load i32, i32* %8
%43 = icmp slt i32 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %26
%45 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %46
46: ; preds = %44, %26
store i32 1, i32* %7
br label %47
47: ; preds = %66, %46
%48 = load i32, i32* %7
%49 = load i32, i32* %4
%50 = icmp slt i32 %48, %49
br i1 %50, label %51, label %69
51: ; preds = %47
%52 = load i32, i32* %8
%53 = load i8**, i8*** %5
%54 = load i32, i32* %7
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8*, i8** %53, i64 %55
%57 = load i8*, i8** %56
%58 = load i32, i32* @IN_CREATE
%59 = load i32, i32* @IN_MODIFY
%60 = or i32 %58, %59
%61 = call i32 @inotify_add_watch(i32 %52, i8* %57, i32 %60)
%62 = load i32, i32* %7
%63 = sub nsw i32 %62, 1
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i32, i32* %36, i64 %64
store i32 %61, i32* %65
br label %66
66: ; preds = %51
%67 = load i32, i32* %7
%68 = add nsw i32 %67, 1
store i32 %68, i32* %7
br label %47
69: ; preds = %47
br label %70
70: ; preds = %148, %69
%71 = load i32, i32* %13
store i32 %71, i32* %14
%72 = load i32, i32* %8
%73 = add nsw i32 %72, 1
%74 = call i32 @select(i32 %73, i32* %14, i32* null, i32* null, i32* null)
%75 = icmp eq i32 %74, -1
br i1 %75, label %76, label %78
76: ; preds = %70
%77 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
store i32 1, i32* %15
br label %168
78: ; preds = %70
%79 = call i64 @FD_ISSET(i32 0, i32* %14)
%80 = icmp ne i64 %79, 0
br i1 %80, label %81, label %82
81: ; preds = %78
br label %149
82: ; preds = %78
%83 = load i32, i32* %8
%84 = load i32, i32* @NAME_MAX
%85 = sext i32 %84 to i64
%86 = add i64 40, %85
%87 = mul i64 128, %86
%88 = trunc i64 %87 to i32
%89 = call i32 @read(i32 %83, i8* %32, i32 %88)
store i32 %89, i32* %6
%90 = load i32, i32* %6
%91 = icmp slt i32 %90, 0
br i1 %91, label %92, label %94
92: ; preds = %82
%93 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
store i32 1, i32* %15
br label %168
94: ; preds = %82
store i32 0, i32* %7
br label %95
95: ; preds = %138, %94
%96 = load i32, i32* %7
%97 = load i32, i32* %6
%98 = icmp slt i32 %96, %97
br i1 %98, label %99, label %147
99: ; preds = %95
%100 = load i32, i32* %7
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds i8, i8* %32, i64 %101
%103 = bitcast i8* %102 to %struct.inotify_event*
store %struct.inotify_event* %103, %struct.inotify_event** %16
%104 = load %struct.inotify_event*, %struct.inotify_event** %16
%105 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %104, i32 0, i32 2
%106 = load i64, i64* %105
%107 = icmp ne i64 %106, 0
br i1 %107, label %108, label %138
108: ; preds = %99
store i32 1, i32* %17
br label %109
109: ; preds = %134, %108
%110 = load i32, i32* %17
%111 = load i32, i32* %4
%112 = icmp slt i32 %110, %111
br i1 %112, label %113, label %137
113: ; preds = %109
%114 = load i32, i32* %17
%115 = sub nsw i32 %114, 1
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds i32, i32* %36, i64 %116
%118 = load i32, i32* %117
%119 = load %struct.inotify_event*, %struct.inotify_event** %16
%120 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %119, i32 0, i32 0
%121 = load i32, i32* %120
%122 = icmp eq i32 %118, %121
br i1 %122, label %123, label %133
123: ; preds = %113
%124 = load i8**, i8*** %5
%125 = load i32, i32* %17
%126 = sext i32 %125 to i64
%127 = getelementptr inbounds i8*, i8** %124, i64 %126
%128 = load i8*, i8** %127
%129 = load %struct.inotify_event*, %struct.inotify_event** %16
%130 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %129, i32 0, i32 1
%131 = load i8*, i8** %130
%132 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %128, i8* %131)
br label %137
133: ; preds = %113
br label %134
134: ; preds = %133
%135 = load i32, i32* %17
%136 = add nsw i32 %135, 1
store i32 %136, i32* %17
br label %109
137: ; preds = %123, %109
br label %138
138: ; preds = %137, %99
%139 = load %struct.inotify_event*, %struct.inotify_event** %16
%140 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %139, i32 0, i32 2
%141 = load i64, i64* %140
%142 = add i64 24, %141
%143 = load i32, i32* %7
%144 = sext i32 %143 to i64
%145 = add i64 %144, %142
%146 = trunc i64 %145 to i32
store i32 %146, i32* %7
br label %95
147: ; preds = %95
br label %148
148: ; preds = %147
br label %70
149: ; preds = %81
store i32 1, i32* %7
br label %150
150: ; preds = %162, %149
%151 = load i32, i32* %7
%152 = load i32, i32* %4
%153 = icmp slt i32 %151, %152
br i1 %153, label %154, label %165
154: ; preds = %150
%155 = load i32, i32* %8
%156 = load i32, i32* %7
%157 = sub nsw i32 %156, 1
%158 = sext i32 %157 to i64
%159 = getelementptr inbounds i32, i32* %36, i64 %158
%160 = load i32, i32* %159
%161 = call i32 @inotify_rm_watch(i32 %155, i32 %160)
br label %162
162: ; preds = %154
%163 = load i32, i32* %7
%164 = add nsw i32 %163, 1
store i32 %164, i32* %7
br label %150
165: ; preds = %150
%166 = load i32, i32* %8
%167 = call i32 @close(i32 %166)
store i32 0, i32* %15
br label %168
168: ; preds = %165, %92, %76
%169 = load i8*, i8** %10
%170 = load i32, i32* %15
switch i32 %170, label %173 [
i32 0, label %171
i32 1, label %171
]
171: ; preds = %20, %168, %168
%172 = load i32, i32* %3
ret i32 %172
173: ; preds = %168
unreachable
}

LLVM IR (-O2):
@.str = [58 x i8] c"Usage: %s root/path/to/watch /anotherpath/to/watch .. \0D\0A\00"
@EXIT_SUCCESS = global i32 0
@NAME_MAX = global i32 0
@.str.1 = [20 x i8] c"inotify_init failed\00"
@IN_CREATE = global i32 0
@IN_MODIFY = global i32 0
@.str.2 = [17 x i8] c"Unable to select\00"
@.str.3 = [28 x i8] c"unable to read from inotify\00"
@.str.4 = [8 x i8] c"%s/%s\0D\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = load i32, i32* @EXIT_SUCCESS
br label %113
10: ; preds = %2
%11 = load i32, i32* @NAME_MAX
%12 = sext i32 %11 to i64
%13 = shl nsw i64 %12, 7
%14 = add nsw i64 %13, 5120
%15 = tail call i8* @llvm.stacksave()
%16 = alloca i8, i64 %14
%17 = add nsw i32 %0, -1
%18 = zext i32 %17 to i64
%19 = alloca i32, i64 %18
%20 = bitcast i32* %3 to i8*
%21 = call i32 @FD_ZERO(i32* %3)
%22 = call i32 @FD_SET(i32 0, i32* %3)
%23 = call i32 (...) @inotify_init()
%24 = call i32 @FD_SET(i32 %23, i32* %3)
%25 = icmp slt i32 %23, 0
br i1 %25, label %26, label %28
26: ; preds = %10
%27 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %28
28: ; preds = %10, %26
%29 = zext i32 %0 to i64
br label %37
30: ; preds = %37
%31 = bitcast i32* %4 to i8*
%32 = add nsw i32 %23, 1
%33 = zext i32 %0 to i64
%34 = load i32, i32* %3
store i32 %34, i32* %4
%35 = call i32 @select(i32 %32, i32* %4, i32* null, i32* null, i32* null)
%36 = icmp eq i32 %35, -1
br i1 %36, label %93, label %49
37: ; preds = %28, %37
%38 = phi i64 [ 1, %28 ], [ %47, %37 ]
%39 = getelementptr inbounds i8*, i8** %1, i64 %38
%40 = load i8*, i8** %39
%41 = load i32, i32* @IN_CREATE
%42 = load i32, i32* @IN_MODIFY
%43 = or i32 %42, %41
%44 = call i32 @inotify_add_watch(i32 %23, i8* %40, i32 %43)
%45 = add nsw i64 %38, -1
%46 = getelementptr inbounds i32, i32* %19, i64 %45
store i32 %44, i32* %46
%47 = add nuw nsw i64 %38, 1
%48 = icmp eq i64 %47, %29
br i1 %48, label %30, label %37
49: ; preds = %30, %96
%50 = call i64 @FD_ISSET(i32 0, i32* %4)
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %100
52: ; preds = %49
%53 = load i32, i32* @NAME_MAX
%54 = shl i32 %53, 7
%55 = add i32 %54, 5120
%56 = call i32 @read(i32 %23, i8* %16, i32 %55)
%57 = icmp slt i32 %56, 0
br i1 %57, label %93, label %58
58: ; preds = %52
%59 = icmp eq i32 %56, 0
br i1 %59, label %96, label %60
60: ; preds = %58, %88
%61 = phi i32 [ %91, %88 ], [ 0, %58 ]
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8, i8* %16, i64 %62
%64 = getelementptr inbounds i8, i8* %63, i64 16
%65 = bitcast i8* %64 to i64*
%66 = load i64, i64* %65
%67 = icmp eq i64 %66, 0
br i1 %67, label %88, label %68
68: ; preds = %60
%69 = bitcast i8* %63 to i32*
%70 = load i32, i32* %69
br label %71
71: ; preds = %68, %85
%72 = phi i64 [ 1, %68 ], [ %86, %85 ]
%73 = add nsw i64 %72, -1
%74 = getelementptr inbounds i32, i32* %19, i64 %73
%75 = load i32, i32* %74
%76 = icmp eq i32 %75, %70
br i1 %76, label %77, label %85
77: ; preds = %71
%78 = and i64 %72, 4294967295
%79 = getelementptr inbounds i8*, i8** %1, i64 %78
%80 = load i8*, i8** %79
%81 = getelementptr inbounds i8, i8* %63, i64 8
%82 = bitcast i8* %81 to i8**
%83 = load i8*, i8** %82
%84 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %80, i8* %83)
br label %88
85: ; preds = %71
%86 = add nuw nsw i64 %72, 1
%87 = icmp eq i64 %86, %33
br i1 %87, label %88, label %71
88: ; preds = %85, %60, %77
%89 = trunc i64 %66 to i32
%90 = add i32 %61, 24
%91 = add i32 %90, %89
%92 = icmp slt i32 %91, %56
br i1 %92, label %60, label %96
93: ; preds = %96, %52, %30
%94 = phi i8* [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), %30 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), %96 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), %52 ]
%95 = call i32 @perror(i8* %94)
br label %112
96: ; preds = %88, %58
%97 = load i32, i32* %3
store i32 %97, i32* %4
%98 = call i32 @select(i32 %32, i32* %4, i32* null, i32* null, i32* null)
%99 = icmp eq i32 %98, -1
br i1 %99, label %93, label %49
100: ; preds = %49
%101 = zext i32 %0 to i64
br label %102
102: ; preds = %100, %102
%103 = phi i64 [ 1, %100 ], [ %108, %102 ]
%104 = add nsw i64 %103, -1
%105 = getelementptr inbounds i32, i32* %19, i64 %104
%106 = load i32, i32* %105
%107 = call i32 @inotify_rm_watch(i32 %23, i32 %106)
%108 = add nuw nsw i64 %103, 1
%109 = icmp eq i64 %108, %101
br i1 %109, label %110, label %102
110: ; preds = %102
%111 = call i32 @close(i32 %23)
br label %112
112: ; preds = %93, %110
br label %113
113: ; preds = %112, %6
%114 = phi i32 [ %9, %6 ], [ 0, %112 ]
ret i32 %114
}