#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;
};

/* Variables and functions */
int IN_DELETE;
int IN_DELETE_SELF;
int IN_MODIFY;
int IN_MOVE_SELF;
int /*<<< orphan*/ close(int const);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(struct inotify_event *);
int inotify_add_watch(int const, char *, int);
int inotify_init();
struct inotify_event *malloc(size_t const);
int /*<<< orphan*/ memset(struct inotify_event *, int /*<<< orphan*/,
                          size_t const);
int read(int const, struct inotify_event *, size_t const);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[argc]) {
  if (argc < 2) {
    char *s = argv[0];
    fprintf(stderr, "%s - waits until file(s) change.\n", s);
    fprintf(stderr, "Usage: %s FILE [FILES...]\n", s);
    fprintf(stderr, "  Waits until the inotify kernel facility indicates one "
                    "of FILE changed.\n");
    fprintf(stderr, "  Exit Status: index of changed file in argument list "
                    "(starts with 1).\n");
    return 0;
  }
  argv++;
  argc--;
  const int fd = inotify_init();
  int wd[argc];
  int n = 0;
  for (int i = 0; i < argc; i++) {
    wd[i] = 0;
    wd[i] = inotify_add_watch(
        fd, argv[i], IN_DELETE | IN_DELETE_SELF | IN_MODIFY | IN_MOVE_SELF);
    if (wd[i] > 0) {
      n++;
    }
  }
  if (!n) {
    fprintf(stderr,
            "No watchable files listed. Invoke without arguments for usage.\n");
    return 0;
  }
  const size_t len = sizeof(struct inotify_event);
  struct inotify_event *e = malloc(len);
  if (!e) {
    fprintf(stderr, "No memory left.\n");
    return 0;
  }
  memset(e, 0, len);
  if (-1 == read(fd, e, len)) {
    fprintf(stderr, "Interrupted.\n");
    free(e);
    return 0;
  }
  close(fd);
  int idx = 0;
  for (; (idx < argc) && (wd[idx] != e->wd); idx++)
    ;
  free(e);
  return idx + 1;
}


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    121b <main+0x9b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe41(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2e03(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe48(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2de8(%rip),%rax
mov    (%rax),%edi
lea    0xe4c(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2dd1(%rip),%rax
mov    (%rax),%edi
lea    0xe7f(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1455 <main+0x2d5>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
xor    %eax,%eax
call   1080 <inotify_init@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x60(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12f9 <main+0x179>
mov    -0x60(%rbp),%rax
movslq -0x38(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x1c(%rbp),%edi
mov    -0x10(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    0x2d40(%rip),%rax
mov    (%rax),%edx
mov    0x2d0f(%rip),%rax
or     (%rax),%edx
mov    0x2d3e(%rip),%rax
or     (%rax),%edx
mov    0x2d0d(%rip),%rax
or     (%rax),%edx
call   10a0 <inotify_add_watch@plt>
mov    %eax,%edx
mov    -0x60(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
movslq -0x38(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jle    12e6 <main+0x166>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    12eb <main+0x16b>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    126f <main+0xef>
cmpl   $0x0,-0x34(%rbp)
jne    132d <main+0x1ad>
mov    0x2cc6(%rip),%rax
mov    (%rax),%edi
lea    0xdbc(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    144e <main+0x2ce>
movq   $0x4,-0x48(%rbp)
mov    $0x4,%edi
call   1090 <malloc@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    1378 <main+0x1f8>
mov    0x2c7b(%rip),%rax
mov    (%rax),%edi
lea    0xdb1(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    144e <main+0x2ce>
mov    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1040 <memset@plt>
mov    -0x1c(%rbp),%edi
mov    -0x50(%rbp),%rsi
mov    $0x4,%edx
call   1060 <read@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    13db <main+0x25b>
mov    0x2c21(%rip),%rax
mov    (%rax),%edi
lea    0xd68(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    144e <main+0x2ce>
mov    -0x1c(%rbp),%edi
call   1050 <close@plt>
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%ecx
xor    %eax,%eax
cmp    -0x8(%rbp),%ecx
mov    %al,-0x61(%rbp)
jge    1412 <main+0x292>
mov    -0x60(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x50(%rbp),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,-0x61(%rbp)
mov    -0x61(%rbp),%al
test   $0x1,%al
jne    1422 <main+0x2a2>
jmp    1435 <main+0x2b5>
jmp    1427 <main+0x2a7>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    13ea <main+0x26a>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x3c(%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    $0x18,%rsp
cmp    $0x1,%edi
jg     11f1 <main+0x71>
mov    (%rsi),%r15
mov    0x2e30(%rip),%r14
mov    (%r14),%edi
lea    0xe56(%rip),%rsi
xor    %ebx,%ebx
mov    %r15,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%r14),%edi
lea    0xe62(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%r14),%edi
lea    0xe69(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%r14),%edi
lea    0xea2(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    1331 <main+0x1b1>
mov    %rdi,-0x38(%rbp)
lea    -0x1(%rdi),%r15d
xor    %ebx,%ebx
xor    %eax,%eax
mov    %rsi,-0x40(%rbp)
call   1080 <inotify_init@plt>
mov    %eax,%r14d
mov    %rsp,-0x30(%rbp)
mov    %rsp,%rdx
mov    %r15,%r13
lea    0xf(,%r15,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rdx
mov    %rdx,%rsp
xor    %r15d,%r15d
nopl   0x0(%rax,%rax,1)
mov    -0x40(%rbp),%rax
mov    0x8(%rax,%rbx,8),%rsi
mov    %rdx,%r12
mov    0x2d75(%rip),%rax
mov    (%rax),%edx
mov    0x2d94(%rip),%rax
or     (%rax),%edx
mov    0x2d9b(%rip),%rax
or     (%rax),%edx
mov    0x2d6a(%rip),%rax
or     (%rax),%edx
mov    %r14d,%edi
call   10a0 <inotify_add_watch@plt>
mov    %r12,%rdx
mov    %eax,(%r12,%rbx,4)
xor    %ecx,%ecx
test   %eax,%eax
setg   %cl
add    %ecx,%r15d
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1230 <main+0xb0>
test   %r15d,%r15d
je     12ff <main+0x17f>
mov    $0x4,%edi
call   1090 <malloc@plt>
test   %rax,%rax
je     1311 <main+0x191>
mov    %rax,%r15
xor    %ebx,%ebx
mov    $0x4,%edx
mov    %rax,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
mov    $0x4,%edx
mov    %r14d,%edi
mov    %r15,%rsi
call   1060 <read@plt>
cmp    $0xffffffff,%eax
je     1342 <main+0x1c2>
mov    %r14d,%edi
call   1050 <close@plt>
cmpl   $0x2,-0x38(%rbp)
jl     12f2 <main+0x172>
mov    (%r15),%eax
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
cmp    %eax,(%r12,%rbx,4)
je     12f2 <main+0x172>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    12e0 <main+0x160>
mov    %r13d,%ebx
mov    %r15,%rdi
call   1030 <free@plt>
add    $0x1,%ebx
jmp    132a <main+0x1aa>
mov    0x2cca(%rip),%rax
mov    (%rax),%edi
lea    0xdc0(%rip),%rsi
jmp    1321 <main+0x1a1>
mov    0x2cb8(%rip),%rax
mov    (%rax),%edi
lea    0xdee(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    %ebx,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c87(%rip),%rax
mov    (%rax),%edi
lea    0xdce(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %r15,%rdi
call   1030 <free@plt>
jmp    132a <main+0x1aa>

LLVM IR (-O0):
%struct.inotify_event = type { i32 }
@stderr = global i32 0
@.str = [34 x i8] c"%s - waits until file(s) change.\0A\00"
@.str.1 = [27 x i8] c"Usage: %s FILE [FILES...]\0A\00"
@.str.2 = [74 x i8] c" Waits until the inotify kernel facility indicates one of FILE changed.\0A\00"
@.str.3 = [72 x i8] c" Exit Status: index of changed file in argument list (starts with 1).\0A\00"
@IN_DELETE = global i32 0
@IN_DELETE_SELF = global i32 0
@IN_MODIFY = global i32 0
@IN_MOVE_SELF = global i32 0
@.str.4 = [64 x i8] c"No watchable files listed. Invoke without arguments for usage.\0A\00"
@.str.5 = [17 x i8] c"No memory left.\0A\00"
@.str.6 = [14 x i8] c"Interrupted.\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 i8*
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i64
%14 = alloca %struct.inotify_event*
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = load i32, i32* %4
%17 = zext i32 %16 to i64
%18 = load i32, i32* %4
%19 = icmp slt i32 %18, 2
br i1 %19, label %20, label %34
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 0
%23 = load i8*, i8** %22
store i8* %23, i8** %6
%24 = load i32, i32* @stderr
%25 = load i8*, i8** %6
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %25)
%27 = load i32, i32* @stderr
%28 = load i8*, i8** %6
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %28)
%30 = load i32, i32* @stderr
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.2, i64 0, i64 0))
%32 = load i32, i32* @stderr
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %135
34: ; preds = %2
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i32 1
store i8** %36, i8*** %5
%37 = load i32, i32* %4
%38 = add nsw i32 %37, -1
store i32 %38, i32* %4
%39 = call i32 (...) @inotify_init()
store i32 %39, i32* %7
%40 = load i32, i32* %4
%41 = zext i32 %40 to i64
%42 = call i8* @llvm.stacksave()
store i8* %42, i8** %8
%43 = alloca i32, i64 %41
store i64 %41, i64* %9
store i32 0, i32* %10
store i32 0, i32* %11
br label %44
44: ; preds = %78, %34
%45 = load i32, i32* %11
%46 = load i32, i32* %4
%47 = icmp slt i32 %45, %46
br i1 %47, label %48, label %81
48: ; preds = %44
%49 = load i32, i32* %11
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i32, i32* %43, i64 %50
store i32 0, i32* %51
%52 = load i32, i32* %7
%53 = load i8**, i8*** %5
%54 = load i32, i32* %11
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8*, i8** %53, i64 %55
%57 = load i8*, i8** %56
%58 = load i32, i32* @IN_DELETE
%59 = load i32, i32* @IN_DELETE_SELF
%60 = or i32 %58, %59
%61 = load i32, i32* @IN_MODIFY
%62 = or i32 %60, %61
%63 = load i32, i32* @IN_MOVE_SELF
%64 = or i32 %62, %63
%65 = call i32 @inotify_add_watch(i32 %52, i8* %57, i32 %64)
%66 = load i32, i32* %11
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i32, i32* %43, i64 %67
store i32 %65, i32* %68
%69 = load i32, i32* %11
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i32, i32* %43, i64 %70
%72 = load i32, i32* %71
%73 = icmp sgt i32 %72, 0
br i1 %73, label %74, label %77
74: ; preds = %48
%75 = load i32, i32* %10
%76 = add nsw i32 %75, 1
store i32 %76, i32* %10
br label %77
77: ; preds = %74, %48
br label %78
78: ; preds = %77
%79 = load i32, i32* %11
%80 = add nsw i32 %79, 1
store i32 %80, i32* %11
br label %44
81: ; preds = %44
%82 = load i32, i32* %10
%83 = icmp ne i32 %82, 0
br i1 %83, label %87, label %84
84: ; preds = %81
%85 = load i32, i32* @stderr
%86 = call i32 (i32, i8*, ...) @fprintf(i32 %85, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
store i32 1, i32* %12
br label %133
87: ; preds = %81
store i64 4, i64* %13
%88 = call %struct.inotify_event* @malloc(i64 4)
store %struct.inotify_event* %88, %struct.inotify_event** %14
%89 = load %struct.inotify_event*, %struct.inotify_event** %14
%90 = icmp ne %struct.inotify_event* %89, null
br i1 %90, label %94, label %91
91: ; preds = %87
%92 = load i32, i32* @stderr
%93 = call i32 (i32, i8*, ...) @fprintf(i32 %92, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %3
store i32 1, i32* %12
br label %133
94: ; preds = %87
%95 = load %struct.inotify_event*, %struct.inotify_event** %14
%96 = call i32 @memset(%struct.inotify_event* %95, i32 0, i64 4)
%97 = load i32, i32* %7
%98 = load %struct.inotify_event*, %struct.inotify_event** %14
%99 = call i32 @read(i32 %97, %struct.inotify_event* %98, i64 4)
%100 = icmp eq i32 -1, %99
br i1 %100, label %101, label %106
101: ; preds = %94
%102 = load i32, i32* @stderr
%103 = call i32 (i32, i8*, ...) @fprintf(i32 %102, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%104 = load %struct.inotify_event*, %struct.inotify_event** %14
%105 = call i32 @free(%struct.inotify_event* %104)
store i32 0, i32* %3
store i32 1, i32* %12
br label %133
106: ; preds = %94
%107 = load i32, i32* %7
%108 = call i32 @close(i32 %107)
store i32 0, i32* %15
br label %109
109: ; preds = %125, %106
%110 = load i32, i32* %15
%111 = load i32, i32* %4
%112 = icmp slt i32 %110, %111
br i1 %112, label %113, label %122
113: ; preds = %109
%114 = load i32, i32* %15
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds i32, i32* %43, i64 %115
%117 = load i32, i32* %116
%118 = load %struct.inotify_event*, %struct.inotify_event** %14
%119 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %118, i32 0, i32 0
%120 = load i32, i32* %119
%121 = icmp ne i32 %117, %120
br label %122
122: ; preds = %113, %109
%123 = phi i1 [ false, %109 ], [ %121, %113 ]
br i1 %123, label %124, label %128
124: ; preds = %122
br label %125
125: ; preds = %124
%126 = load i32, i32* %15
%127 = add nsw i32 %126, 1
store i32 %127, i32* %15
br label %109
128: ; preds = %122
%129 = load %struct.inotify_event*, %struct.inotify_event** %14
%130 = call i32 @free(%struct.inotify_event* %129)
%131 = load i32, i32* %15
%132 = add nsw i32 %131, 1
store i32 %132, i32* %3
store i32 1, i32* %12
br label %133
133: ; preds = %128, %101, %91, %84
%134 = load i8*, i8** %8
br label %135
135: ; preds = %133, %20
%136 = load i32, i32* %3
ret i32 %136
}

LLVM IR (-O2):
%struct.inotify_event = type { i32 }
@stderr = global i32 0
@.str = [34 x i8] c"%s - waits until file(s) change.\0A\00"
@.str.1 = [27 x i8] c"Usage: %s FILE [FILES...]\0A\00"
@.str.2 = [74 x i8] c" Waits until the inotify kernel facility indicates one of FILE changed.\0A\00"
@.str.3 = [72 x i8] c" Exit Status: index of changed file in argument list (starts with 1).\0A\00"
@IN_DELETE = global i32 0
@IN_DELETE_SELF = global i32 0
@IN_MODIFY = global i32 0
@IN_MOVE_SELF = global i32 0
@.str.4 = [64 x i8] c"No watchable files listed. Invoke without arguments for usage.\0A\00"
@.str.5 = [17 x i8] c"No memory left.\0A\00"
@.str.6 = [14 x i8] c"Interrupted.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %14
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = load i32, i32* @stderr
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %5)
%8 = load i32, i32* @stderr
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%10 = load i32, i32* @stderr
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.2, i64 0, i64 0))
%12 = load i32, i32* @stderr
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.3, i64 0, i64 0))
br label %81
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = add nsw i32 %0, -1
%17 = tail call i32 (...) @inotify_init()
%18 = zext i32 %16 to i64
%19 = tail call i8* @llvm.stacksave()
%20 = alloca i32, i64 %18
br label %23
21: ; preds = %23
%22 = icmp eq i32 %39, 0
br i1 %22, label %42, label %45
23: ; preds = %14, %23
%24 = phi i64 [ 0, %14 ], [ %40, %23 ]
%25 = phi i32 [ 0, %14 ], [ %39, %23 ]
%26 = getelementptr inbounds i32, i32* %20, i64 %24
%27 = getelementptr inbounds i8*, i8** %15, i64 %24
%28 = load i8*, i8** %27
%29 = load i32, i32* @IN_DELETE
%30 = load i32, i32* @IN_DELETE_SELF
%31 = or i32 %30, %29
%32 = load i32, i32* @IN_MODIFY
%33 = or i32 %31, %32
%34 = load i32, i32* @IN_MOVE_SELF
%35 = or i32 %33, %34
%36 = tail call i32 @inotify_add_watch(i32 %17, i8* %28, i32 %35)
store i32 %36, i32* %26
%37 = icmp sgt i32 %36, 0
%38 = zext i1 %37 to i32
%39 = add nuw nsw i32 %25, %38
%40 = add nuw nsw i64 %24, 1
%41 = icmp eq i64 %40, %18
br i1 %41, label %21, label %23
42: ; preds = %21
%43 = load i32, i32* @stderr
%44 = tail call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.4, i64 0, i64 0))
br label %79
45: ; preds = %21
%46 = tail call %struct.inotify_event* @malloc(i64 4)
%47 = icmp eq %struct.inotify_event* %46, null
br i1 %47, label %48, label %51
48: ; preds = %45
%49 = load i32, i32* @stderr
%50 = tail call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
br label %79
51: ; preds = %45
%52 = tail call i32 @memset(%struct.inotify_event* %46, i32 0, i64 4)
%53 = tail call i32 @read(i32 %17, %struct.inotify_event* %46, i64 4)
%54 = icmp eq i32 %53, -1
br i1 %54, label %55, label %59
55: ; preds = %51
%56 = load i32, i32* @stderr
%57 = tail call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%58 = tail call i32 @free(%struct.inotify_event* %46)
br label %79
59: ; preds = %51
%60 = tail call i32 @close(i32 %17)
%61 = icmp sgt i32 %0, 1
br i1 %61, label %62, label %75
62: ; preds = %59
%63 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %46, i64 0, i32 0
%64 = load i32, i32* %63
br label %65
65: ; preds = %62, %70
%66 = phi i64 [ 0, %62 ], [ %71, %70 ]
%67 = getelementptr inbounds i32, i32* %20, i64 %66
%68 = load i32, i32* %67
%69 = icmp eq i32 %68, %64
br i1 %69, label %73, label %70
70: ; preds = %65
%71 = add nuw nsw i64 %66, 1
%72 = icmp eq i64 %71, %18
br i1 %72, label %75, label %65
73: ; preds = %65
%74 = trunc i64 %66 to i32
br label %75
75: ; preds = %70, %73, %59
%76 = phi i32 [ 0, %59 ], [ %74, %73 ], [ %16, %70 ]
%77 = tail call i32 @free(%struct.inotify_event* %46)
%78 = add nuw nsw i32 %76, 1
br label %79
79: ; preds = %48, %55, %75, %42
%80 = phi i32 [ 0, %42 ], [ 0, %55 ], [ %78, %75 ], [ 0, %48 ]
tail call void @llvm.stackrestore(i8* %19)
br label %81
81: ; preds = %79, %4
%82 = phi i32 [ 0, %4 ], [ %80, %79 ]
ret i32 %82
}