#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 fanotify_response {
  scalar_t__ fd;
  int response;
};
struct fanotify_event_metadata {
  scalar_t__ vers;
  scalar_t__ fd;
  int mask;
};
typedef int ssize_t;
typedef int /*<<< orphan*/ procfd_path;
typedef int /*<<< orphan*/ path;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
scalar_t__ EAGAIN;
int /*<<< orphan*/ EXIT_FAILURE;
scalar_t__ FANOTIFY_METADATA_VERSION;
int FAN_ALLOW;
int FAN_AUDIT;
int FAN_CLOSE_WRITE;
struct fanotify_event_metadata *
FAN_EVENT_NEXT(struct fanotify_event_metadata const *, int);
scalar_t__ FAN_EVENT_OK(struct fanotify_event_metadata const *, int);
int FAN_OPEN_PERM;
int PATH_MAX;
int /*<<< orphan*/ close(int);
scalar_t__ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, void *, int);
int readlink(char *, char *, int);
int /*<<< orphan*/ snprintf(char *, int, char *, scalar_t__);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ write(int, struct fanotify_response *, int);
void handle_events(int fd) {
  const struct fanotify_event_metadata *metadata;
  struct fanotify_event_metadata buf[200];
  ssize_t len;
  char path[PATH_MAX];
  ssize_t path_len;
  char procfd_path[PATH_MAX];
  struct fanotify_response response;
  for (;;) {
    len = read(fd, (void *)&buf, sizeof(buf));
    if (len == -1 && errno != EAGAIN) {
      perror("read");
      exit(EXIT_FAILURE);
    }
    if (len <= 0)
      break;
    metadata = buf;
    while (FAN_EVENT_OK(metadata, len)) {
      if (metadata->vers != FANOTIFY_METADATA_VERSION) {
        fprintf(stderr, "Mismatch of fanotify metadata version.\n");
        exit(EXIT_FAILURE);
      }
      if (metadata->fd >= 0) {
        if (metadata->mask & FAN_OPEN_PERM) {
          printf("FAN_OPEN_PERM: ");
          response.fd = metadata->fd;
          response.response = FAN_ALLOW | FAN_AUDIT;
          write(fd, &response, sizeof(struct fanotify_response));
        }
        if (metadata->mask & FAN_CLOSE_WRITE)
          printf("FAN_CLOSE_WRITE: ");
        snprintf(procfd_path, sizeof(procfd_path), "/proc/self/fd/%d",
                 metadata->fd);
        path_len = readlink(procfd_path, path, sizeof(path) - 1);
        if (path_len == -1) {
          perror("readlink");
          exit(EXIT_FAILURE);
        }
        path[path_len] = '\0';
        printf("File %s\n", path);
        close(metadata->fd);
      }
      metadata = FAN_EVENT_NEXT(metadata, len);
    }
  }
}


x86 assembly (clang, -O0):
<handle_events>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1330,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2e2b(%rip),%rax
mov    (%rax),%ecx
mov    %rcx,-0x1328(%rbp)
mov    %rsp,%rdx
mov    %rdx,-0x12e0(%rbp)
mov    %rcx,%rsi
add    $0xf,%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x1320(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x12e8(%rbp)
mov    (%rax),%eax
mov    %rax,-0x1318(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x1310(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x12f8(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x12d0(%rbp),%rsi
mov    $0x12c0,%edx
call   1090 <read@plt>
mov    %eax,-0x12d4(%rbp)
cmpl   $0xffffffff,-0x12d4(%rbp)
jne    1280 <handle_events+0xd0>
mov    0x2d5d(%rip),%rax
mov    (%rax),%rax
mov    0x2d33(%rip),%rcx
cmp    (%rcx),%rax
je     1280 <handle_events+0xd0>
lea    0xd93(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2d2f(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
cmpl   $0x0,-0x12d4(%rbp)
jg     1292 <handle_events+0xe2>
jmp    1445 <handle_events+0x295>
lea    -0x12d0(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x12d4(%rbp),%esi
call   10a0 <FAN_EVENT_OK@plt>
cmp    $0x0,%rax
je     1440 <handle_events+0x290>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    0x2d1c(%rip),%rcx
cmp    (%rcx),%rax
je     12f0 <handle_events+0x140>
mov    0x2ce4(%rip),%rax
mov    (%rax),%edi
lea    0xd28(%rip),%rsi
call   10b0 <fprintf@plt>
mov    0x2cbf(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
jl     1428 <handle_events+0x278>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%eax
mov    0x2cbb(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1361 <handle_events+0x1b1>
lea    0xd0e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x1308(%rbp)
mov    0x2c64(%rip),%rax
mov    (%rax),%eax
mov    0x2c7b(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x1300(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x1308(%rbp),%rsi
mov    $0x10,%edx
call   1050 <write@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%eax
mov    0x2c69(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1388 <handle_events+0x1d8>
lea    0xcbc(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1310(%rbp),%rdi
mov    -0x1318(%rbp),%rax
mov    %eax,%esi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xca8(%rip),%rdx
call   1070 <snprintf@plt>
mov    -0x1310(%rbp),%rdi
mov    -0x1320(%rbp),%rsi
mov    -0x1328(%rbp),%rax
sub    $0x1,%rax
mov    %eax,%edx
call   1040 <readlink@plt>
mov    %eax,-0x12ec(%rbp)
cmpl   $0xffffffff,-0x12ec(%rbp)
jne    13f9 <handle_events+0x249>
lea    0xc7a(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2bb6(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
mov    -0x1320(%rbp),%rsi
movslq -0x12ec(%rbp),%rax
movb   $0x0,(%rsi,%rax,1)
lea    0xc57(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %eax,%edi
call   1080 <close@plt>
mov    -0x10(%rbp),%rdi
mov    -0x12d4(%rbp),%esi
call   1030 <FAN_EVENT_NEXT@plt>
mov    %rax,-0x10(%rbp)
jmp    129d <handle_events+0xed>
jmp    1225 <handle_events+0x75>
mov    -0x12e0(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_events>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x12e8,%rsp
mov    %rsp,-0x40(%rbp)
mov    0x2e21(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%rbx
mov    %rcx,-0x38(%rbp)
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%rbx
mov    %rbx,%rsp
mov    (%rax),%r12d
mov    %rsp,%r13
lea    0xf(%r12),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
lea    -0x1310(%rbp),%rsi
mov    %edi,-0x2c(%rbp)
mov    $0x12c0,%edx
call   1090 <read@plt>
cmp    $0xffffffff,%eax
je     136f <handle_events+0x1bf>
mov    %eax,%r14d
mov    -0x38(%rbp),%rax
add    $0xffffffff,%eax
mov    %rax,-0x38(%rbp)
jmp    1250 <handle_events+0xa0>
nopl   0x0(%rax,%rax,1)
mov    -0x2c(%rbp),%edi
lea    -0x1310(%rbp),%rsi
mov    $0x12c0,%edx
call   1090 <read@plt>
mov    %eax,%r14d
cmp    $0xffffffff,%eax
je     136f <handle_events+0x1bf>
test   %r14d,%r14d
jle    1385 <handle_events+0x1d5>
lea    -0x1310(%rbp),%rdi
mov    %r14d,%esi
call   10a0 <FAN_EVENT_OK@plt>
test   %rax,%rax
je     1230 <handle_events+0x80>
lea    -0x1310(%rbp),%r15
jmp    129e <handle_events+0xee>
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r14d,%esi
call   1030 <FAN_EVENT_NEXT@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    %r14d,%esi
call   10a0 <FAN_EVENT_OK@plt>
test   %rax,%rax
je     1230 <handle_events+0x80>
mov    (%r15),%rax
mov    0x2d38(%rip),%rcx
cmp    (%rcx),%rax
jne    1398 <handle_events+0x1e8>
cmpq   $0x0,0x8(%r15)
js     1280 <handle_events+0xd0>
mov    0x10(%r15),%eax
mov    0x2d05(%rip),%rcx
test   %eax,(%rcx)
je     1307 <handle_events+0x157>
lea    0xd5f(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x8(%r15),%rax
mov    %rax,-0x50(%rbp)
mov    0x2cdc(%rip),%rax
mov    (%rax),%eax
mov    0x2cb3(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x48(%rbp)
mov    -0x2c(%rbp),%edi
lea    -0x50(%rbp),%rsi
mov    $0x10,%edx
call   1050 <write@plt>
mov    0x10(%r15),%eax
mov    0x2cca(%rip),%rcx
test   %eax,(%rcx)
je     1320 <handle_events+0x170>
lea    0xd24(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x8(%r15),%rcx
mov    %r13,%rdi
mov    %r12d,%esi
lea    0xd1e(%rip),%rdx
call   1070 <snprintf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
mov    -0x38(%rbp),%rdx
call   1040 <readlink@plt>
cmp    $0xffffffff,%eax
je     13af <handle_events+0x1ff>
cltq
movb   $0x0,(%rbx,%rax,1)
lea    0xd12(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x8(%r15),%edi
call   1080 <close@plt>
jmp    1280 <handle_events+0xd0>
mov    0x2c3a(%rip),%rax
mov    (%rax),%rax
mov    0x2c10(%rip),%rcx
cmp    (%rcx),%rax
jne    13c9 <handle_events+0x219>
mov    -0x40(%rbp),%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c19(%rip),%rax
mov    (%rax),%edi
lea    0xc5d(%rip),%rsi
call   10b0 <fprintf@plt>
jmp    13bb <handle_events+0x20b>
lea    0xcaa(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2be6(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
lea    0xc30(%rip),%rdi
jmp    13b6 <handle_events+0x206>

LLVM IR (-O0):
%struct.fanotify_event_metadata = type { i64, i64, i32 }
%struct.fanotify_response = type { i64, i32 }
@PATH_MAX = global i32 0
@errno = global i64 0
@EAGAIN = global i64 0
@.str = [5 x i8] c"read\00"
@EXIT_FAILURE = global i32 0
@FANOTIFY_METADATA_VERSION = global i64 0
@stderr = global i32 0
@.str.1 = [40 x i8] c"Mismatch of fanotify metadata version.\0A\00"
@FAN_OPEN_PERM = global i32 0
@.str.2 = [16 x i8] c"FAN_OPEN_PERM: \00"
@FAN_ALLOW = global i32 0
@FAN_AUDIT = global i32 0
@FAN_CLOSE_WRITE = global i32 0
@.str.3 = [18 x i8] c"FAN_CLOSE_WRITE: \00"
@.str.4 = [17 x i8] c"/proc/self/fd/%d\00"
@.str.5 = [9 x i8] c"readlink\00"
@.str.6 = [9 x i8] c"File %s\0A\00"
define void @handle_events(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.fanotify_event_metadata*
%4 = alloca [200 x %struct.fanotify_event_metadata]
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
%9 = alloca i64
%10 = alloca %struct.fanotify_response
store i32 %0, i32* %2
%11 = load i32, i32* @PATH_MAX
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %6
%14 = alloca i8, i64 %12
store i64 %12, i64* %7
%15 = load i32, i32* @PATH_MAX
%16 = zext i32 %15 to i64
%17 = alloca i8, i64 %16
store i64 %16, i64* %9
br label %18
18: ; preds = %116, %1
%19 = load i32, i32* %2
%20 = bitcast [200 x %struct.fanotify_event_metadata]* %4 to i8*
%21 = call i32 @read(i32 %19, i8* %20, i32 4800)
store i32 %21, i32* %5
%22 = load i32, i32* %5
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %32
24: ; preds = %18
%25 = load i64, i64* @errno
%26 = load i64, i64* @EAGAIN
%27 = icmp ne i64 %25, %26
br i1 %27, label %28, label %32
28: ; preds = %24
%29 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%30 = load i32, i32* @EXIT_FAILURE
%31 = call i32 @exit(i32 %30)
unreachable
32: ; preds = %24, %18
%33 = load i32, i32* %5
%34 = icmp sle i32 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %32
br label %117
36: ; preds = %32
%37 = getelementptr inbounds [200 x %struct.fanotify_event_metadata], [200 x %struct.fanotify_event_metadata]* %4, i64 0, i64 0
store %struct.fanotify_event_metadata* %37, %struct.fanotify_event_metadata** %3
br label %38
38: ; preds = %112, %36
%39 = load %struct.fanotify_event_metadata*, %struct.fanotify_event_metadata** %3
%40 = load i32, i32* %5
%41 = call i64 @FAN_EVENT_OK(%struct.fanotify_event_metadata* %39, i32 %40)
%42 = icmp ne i64 %41, 0
br i1 %42, label %43, label %116
43: ; preds = %38
%44 = load %struct.fanotify_event_metadata*, %struct.fanotify_event_metadata** %3
%45 = getelementptr inbounds %struct.fanotify_event_metadata, %struct.fanotify_event_metadata* %44, i32 0, i32 0
%46 = load i64, i64* %45
%47 = load i64, i64* @FANOTIFY_METADATA_VERSION
%48 = icmp ne i64 %46, %47
br i1 %48, label %49, label %54
49: ; preds = %43
%50 = load i32, i32* @stderr
%51 = call i32 @fprintf(i32 %50, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%52 = load i32, i32* @EXIT_FAILURE
%53 = call i32 @exit(i32 %52)
unreachable
54: ; preds = %43
%55 = load %struct.fanotify_event_metadata*, %struct.fanotify_event_metadata** %3
%56 = getelementptr inbounds %struct.fanotify_event_metadata, %struct.fanotify_event_metadata* %55, i32 0, i32 1
%57 = load i64, i64* %56
%58 = icmp sge i64 %57, 0
br i1 %58, label %59, label %112
59: ; preds = %54
%60 = load %struct.fanotify_event_metadata*, %struct.fanotify_event_metadata** %3
%61 = getelementptr inbounds %struct.fanotify_event_metadata, %struct.fanotify_event_metadata* %60, i32 0, i32 2
%62 = load i32, i32* %61
%63 = load i32, i32* @FAN_OPEN_PERM
%64 = and i32 %62, %63
%65 = icmp ne i32 %64, 0
br i1 %65, label %66, label %78
66: ; preds = %59
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%68 = load %struct.fanotify_event_metadata*, %struct.fanotify_event_metadata** %3
%69 = getelementptr inbounds %struct.fanotify_event_metadata, %struct.fanotify_event_metadata* %68, i32 0, i32 1
%70 = load i64, i64* %69
%71 = getelementptr inbounds %struct.fanotify_response, %struct.fanotify_response* %10, i32 0, i32 0
store i64 %70, i64* %71
%72 = load i32, i32* @FAN_ALLOW
%73 = load i32, i32* @FAN_AUDIT
%74 = or i32 %72, %73
%75 = getelementptr inbounds %struct.fanotify_response, %struct.fanotify_response* %10, i32 0, i32 1
store i32 %74, i32* %75
%76 = load i32, i32* %2
%77 = call i32 @write(i32 %76, %struct.fanotify_response* %10, i32 16)
br label %78
78: ; preds = %66, %59
%79 = load %struct.fanotify_event_metadata*, %struct.fanotify_event_metadata** %3
%80 = getelementptr inbounds %struct.fanotify_event_metadata, %struct.fanotify_event_metadata* %79, i32 0, i32 2
%81 = load i32, i32* %80
%82 = load i32, i32* @FAN_CLOSE_WRITE
%83 = and i32 %81, %82
%84 = icmp ne i32 %83, 0
br i1 %84, label %85, label %87
85: ; preds = %78
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %87
87: ; preds = %85, %78
%88 = trunc i64 %16 to i32
%89 = load %struct.fanotify_event_metadata*, %struct.fanotify_event_metadata** %3
%90 = getelementptr inbounds %struct.fanotify_event_metadata, %struct.fanotify_event_metadata* %89, i32 0, i32 1
%91 = load i64, i64* %90
%92 = call i32 @snprintf(i8* %17, i32 %88, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i64 %91)
%93 = sub i64 %12, 1
%94 = trunc i64 %93 to i32
%95 = call i32 @readlink(i8* %17, i8* %14, i32 %94)
store i32 %95, i32* %8
%96 = load i32, i32* %8
%97 = icmp eq i32 %96, -1
br i1 %97, label %98, label %102
98: ; preds = %87
%99 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%100 = load i32, i32* @EXIT_FAILURE
%101 = call i32 @exit(i32 %100)
unreachable
102: ; preds = %87
%103 = load i32, i32* %8
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds i8, i8* %14, i64 %104
store i8 0, i8* %105
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8* %14)
%107 = load %struct.fanotify_event_metadata*, %struct.fanotify_event_metadata** %3
%108 = getelementptr inbounds %struct.fanotify_event_metadata, %struct.fanotify_event_metadata* %107, i32 0, i32 1
%109 = load i64, i64* %108
%110 = trunc i64 %109 to i32
%111 = call i32 @close(i32 %110)
br label %112
112: ; preds = %102, %54
%113 = load %struct.fanotify_event_metadata*, %struct.fanotify_event_metadata** %3
%114 = load i32, i32* %5
%115 = call %struct.fanotify_event_metadata* @FAN_EVENT_NEXT(%struct.fanotify_event_metadata* %113, i32 %114)
store %struct.fanotify_event_metadata* %115, %struct.fanotify_event_metadata** %3
br label %38
116: ; preds = %38
br label %18
117: ; preds = %35
%118 = load i8*, i8** %6
ret void
}

LLVM IR (-O2):
%struct.fanotify_event_metadata = type { i64, i64, i32 }
%struct.fanotify_response = type { i64, i32 }
@PATH_MAX = global i32 0
@errno = global i64 0
@EAGAIN = global i64 0
@.str = [5 x i8] c"read\00"
@EXIT_FAILURE = global i32 0
@FANOTIFY_METADATA_VERSION = global i64 0
@stderr = global i32 0
@.str.1 = [40 x i8] c"Mismatch of fanotify metadata version.\0A\00"
@FAN_OPEN_PERM = global i32 0
@.str.2 = [16 x i8] c"FAN_OPEN_PERM: \00"
@FAN_ALLOW = global i32 0
@FAN_AUDIT = global i32 0
@FAN_CLOSE_WRITE = global i32 0
@.str.3 = [18 x i8] c"FAN_CLOSE_WRITE: \00"
@.str.4 = [17 x i8] c"/proc/self/fd/%d\00"
@.str.5 = [9 x i8] c"readlink\00"
@.str.6 = [9 x i8] c"File %s\0A\00"
define void @handle_events(i32 %0) {
%2 = alloca [200 x %struct.fanotify_event_metadata]
%3 = alloca %struct.fanotify_response
%4 = bitcast [200 x %struct.fanotify_event_metadata]* %2 to i8*
%5 = load i32, i32* @PATH_MAX
%6 = zext i32 %5 to i64
%7 = tail call i8* @llvm.stacksave()
%8 = alloca i8, i64 %6
%9 = load i32, i32* @PATH_MAX
%10 = zext i32 %9 to i64
%11 = alloca i8, i64 %10
%12 = bitcast %struct.fanotify_response* %3 to i8*
%13 = call i32 @read(i32 %0, i8* %4, i32 4800)
%14 = icmp eq i32 %13, -1
br i1 %14, label %23, label %15
15: ; preds = %1
%16 = getelementptr inbounds [200 x %struct.fanotify_event_metadata], [200 x %struct.fanotify_event_metadata]* %2, i64 0, i64 0
%17 = getelementptr inbounds %struct.fanotify_response, %struct.fanotify_response* %3, i64 0, i32 0
%18 = getelementptr inbounds %struct.fanotify_response, %struct.fanotify_response* %3, i64 0, i32 1
%19 = add i32 %5, -1
br label %31
20: ; preds = %89, %34
%21 = call i32 @read(i32 %0, i8* %4, i32 4800)
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %31
23: ; preds = %20, %1
%24 = load i64, i64* @errno
%25 = load i64, i64* @EAGAIN
%26 = icmp eq i64 %24, %25
br i1 %26, label %93, label %27
27: ; preds = %23
%28 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%29 = load i32, i32* @EXIT_FAILURE
%30 = call i32 @exit(i32 %29)
unreachable
31: ; preds = %15, %20
%32 = phi i32 [ %13, %15 ], [ %21, %20 ]
%33 = icmp slt i32 %32, 1
br i1 %33, label %93, label %34
34: ; preds = %31
%35 = call i64 @FAN_EVENT_OK(%struct.fanotify_event_metadata* %16, i32 %32)
%36 = icmp eq i64 %35, 0
br i1 %36, label %20, label %37
37: ; preds = %34, %89
%38 = phi %struct.fanotify_event_metadata* [ %90, %89 ], [ %16, %34 ]
%39 = getelementptr inbounds %struct.fanotify_event_metadata, %struct.fanotify_event_metadata* %38, i64 0, i32 0
%40 = load i64, i64* %39
%41 = load i64, i64* @FANOTIFY_METADATA_VERSION
%42 = icmp eq i64 %40, %41
br i1 %42, label %48, label %43
43: ; preds = %37
%44 = load i32, i32* @stderr
%45 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%46 = load i32, i32* @EXIT_FAILURE
%47 = call i32 @exit(i32 %46)
unreachable
48: ; preds = %37
%49 = getelementptr inbounds %struct.fanotify_event_metadata, %struct.fanotify_event_metadata* %38, i64 0, i32 1
%50 = load i64, i64* %49
%51 = icmp sgt i64 %50, -1
br i1 %51, label %52, label %89
52: ; preds = %48
%53 = getelementptr inbounds %struct.fanotify_event_metadata, %struct.fanotify_event_metadata* %38, i64 0, i32 2
%54 = load i32, i32* %53
%55 = load i32, i32* @FAN_OPEN_PERM
%56 = and i32 %55, %54
%57 = icmp eq i32 %56, 0
br i1 %57, label %66, label %58
58: ; preds = %52
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%60 = load i64, i64* %49
store i64 %60, i64* %17
%61 = load i32, i32* @FAN_ALLOW
%62 = load i32, i32* @FAN_AUDIT
%63 = or i32 %62, %61
store i32 %63, i32* %18
%64 = call i32 @write(i32 %0, %struct.fanotify_response* %3, i32 16)
%65 = load i32, i32* %53
br label %66
66: ; preds = %58, %52
%67 = phi i32 [ %65, %58 ], [ %54, %52 ]
%68 = load i32, i32* @FAN_CLOSE_WRITE
%69 = and i32 %68, %67
%70 = icmp eq i32 %69, 0
br i1 %70, label %73, label %71
71: ; preds = %66
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %73
73: ; preds = %71, %66
%74 = load i64, i64* %49
%75 = call i32 @snprintf(i8* %11, i32 %9, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i64 %74)
%76 = call i32 @readlink(i8* %11, i8* %8, i32 %19)
%77 = icmp eq i32 %76, -1
br i1 %77, label %78, label %82
78: ; preds = %73
%79 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%80 = load i32, i32* @EXIT_FAILURE
%81 = call i32 @exit(i32 %80)
unreachable
82: ; preds = %73
%83 = sext i32 %76 to i64
%84 = getelementptr inbounds i8, i8* %8, i64 %83
store i8 0, i8* %84
%85 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8* %8)
%86 = load i64, i64* %49
%87 = trunc i64 %86 to i32
%88 = call i32 @close(i32 %87)
br label %89
89: ; preds = %82, %48
%90 = call %struct.fanotify_event_metadata* @FAN_EVENT_NEXT(%struct.fanotify_event_metadata* %38, i32 %32)
%91 = call i64 @FAN_EVENT_OK(%struct.fanotify_event_metadata* %90, i32 %32)
%92 = icmp eq i64 %91, 0
br i1 %92, label %20, label %37
93: ; preds = %31, %23
ret void
}