#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 /*<<< orphan*/ response;
};
struct fanotify_event_metadata {
  scalar_t__ vers;
  scalar_t__ fd;
  int mask;
  int /*<<< orphan*/ pid;
};
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 /*<<< orphan*/ FAN_ALLOW;
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 *);
char *get_comm_pid(int /*<<< orphan*/);
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;
          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.\t\t Comm %s", path, get_comm_pid(metadata->pid));
        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    0x2e1b(%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    1290 <handle_events+0xd0>
mov    0x2d55(%rip),%rax
mov    (%rax),%rax
mov    0x2d2b(%rip),%rcx
cmp    (%rcx),%rax
je     1290 <handle_events+0xd0>
lea    0xd83(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2d27(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
cmpl   $0x0,-0x12d4(%rbp)
jg     12a2 <handle_events+0xe2>
jmp    1462 <handle_events+0x2a2>
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     145d <handle_events+0x29d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    0x2d0c(%rip),%rcx
cmp    (%rcx),%rax
je     1300 <handle_events+0x140>
mov    0x2cdc(%rip),%rax
mov    (%rax),%edi
lea    0xd18(%rip),%rsi
call   10b0 <fprintf@plt>
mov    0x2cb7(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
jl     1445 <handle_events+0x285>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%eax
mov    0x2cab(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1368 <handle_events+0x1a8>
lea    0xcfe(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x1308(%rbp)
mov    0x2c5c(%rip),%rax
mov    (%rax),%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    0x2c62(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     138f <handle_events+0x1cf>
lea    0xcb5(%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    0xca1(%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    1400 <handle_events+0x240>
lea    0xc73(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2bb7(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    -0x1320(%rbp),%rax
movslq -0x12ec(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    0x14(%rax),%edi
call   10d0 <get_comm_pid@plt>
mov    -0x1320(%rbp),%rsi
mov    %rax,%rdx
lea    0xc3a(%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    12ad <handle_events+0xed>
jmp    1235 <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    0x2e11(%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     1382 <handle_events+0x1c2>
mov    %eax,%r14d
mov    -0x38(%rbp),%rax
add    $0xffffffff,%eax
mov    %rax,-0x38(%rbp)
jmp    1260 <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     1382 <handle_events+0x1c2>
test   %r14d,%r14d
jle    1398 <handle_events+0x1d8>
lea    -0x1310(%rbp),%rdi
mov    %r14d,%esi
call   10a0 <FAN_EVENT_OK@plt>
test   %rax,%rax
je     1240 <handle_events+0x80>
lea    -0x1310(%rbp),%r15
jmp    12ae <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     1240 <handle_events+0x80>
mov    (%r15),%rax
mov    0x2d28(%rip),%rcx
cmp    (%rcx),%rax
jne    13ab <handle_events+0x1eb>
cmpq   $0x0,0x8(%r15)
js     1290 <handle_events+0xd0>
mov    0x10(%r15),%eax
mov    0x2cf5(%rip),%rcx
test   %eax,(%rcx)
je     130e <handle_events+0x14e>
lea    0xd4f(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x8(%r15),%rax
mov    %rax,-0x50(%rbp)
mov    0x2cb4(%rip),%rax
mov    (%rax),%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    0x2cc3(%rip),%rcx
test   %eax,(%rcx)
je     1327 <handle_events+0x167>
lea    0xd1d(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x8(%r15),%rcx
mov    %r13,%rdi
mov    %r12d,%esi
lea    0xd17(%rip),%rdx
call   1070 <snprintf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
mov    -0x38(%rbp),%rdx
call   1040 <readlink@plt>
cmp    $0xffffffff,%eax
je     13c2 <handle_events+0x202>
cltq
movb   $0x0,(%rbx,%rax,1)
mov    0x14(%r15),%edi
call   10d0 <get_comm_pid@plt>
lea    0xd02(%rip),%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x8(%r15),%edi
call   1080 <close@plt>
jmp    1290 <handle_events+0xd0>
mov    0x2c2f(%rip),%rax
mov    (%rax),%rax
mov    0x2c05(%rip),%rcx
cmp    (%rcx),%rax
jne    13dc <handle_events+0x21c>
mov    -0x40(%rbp),%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c0e(%rip),%rax
mov    (%rax),%edi
lea    0xc4a(%rip),%rsi
call   10b0 <fprintf@plt>
jmp    13ce <handle_events+0x20e>
lea    0xc97(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2bdb(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
lea    0xc1d(%rip),%rdi
jmp    13c9 <handle_events+0x209>

LLVM IR (-O0):
%struct.fanotify_event_metadata = type { i64, i64, i32, 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_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 = [19 x i8] c"File %s.\09\09 Comm %s\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 = %118, %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 %119
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 = %114, %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 %118
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 %114
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 %76
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 = getelementptr inbounds %struct.fanotify_response, %struct.fanotify_response* %10, i32 0, i32 1
store i32 %72, i32* %73
%74 = load i32, i32* %2
%75 = call i32 @write(i32 %74, %struct.fanotify_response* %10, i32 16)
br label %76
76: ; preds = %66, %59
%77 = load %struct.fanotify_event_metadata*, %struct.fanotify_event_metadata** %3
%78 = getelementptr inbounds %struct.fanotify_event_metadata, %struct.fanotify_event_metadata* %77, i32 0, i32 2
%79 = load i32, i32* %78
%80 = load i32, i32* @FAN_CLOSE_WRITE
%81 = and i32 %79, %80
%82 = icmp ne i32 %81, 0
br i1 %82, label %83, label %85
83: ; preds = %76
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %85
85: ; preds = %83, %76
%86 = trunc i64 %16 to i32
%87 = load %struct.fanotify_event_metadata*, %struct.fanotify_event_metadata** %3
%88 = getelementptr inbounds %struct.fanotify_event_metadata, %struct.fanotify_event_metadata* %87, i32 0, i32 1
%89 = load i64, i64* %88
%90 = call i32 @snprintf(i8* %17, i32 %86, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i64 %89)
%91 = sub i64 %12, 1
%92 = trunc i64 %91 to i32
%93 = call i32 @readlink(i8* %17, i8* %14, i32 %92)
store i32 %93, i32* %8
%94 = load i32, i32* %8
%95 = icmp eq i32 %94, -1
br i1 %95, label %96, label %100
96: ; preds = %85
%97 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%98 = load i32, i32* @EXIT_FAILURE
%99 = call i32 @exit(i32 %98)
unreachable
100: ; preds = %85
%101 = load i32, i32* %8
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds i8, i8* %14, i64 %102
store i8 0, i8* %103
%104 = load %struct.fanotify_event_metadata*, %struct.fanotify_event_metadata** %3
%105 = getelementptr inbounds %struct.fanotify_event_metadata, %struct.fanotify_event_metadata* %104, i32 0, i32 3
%106 = load i32, i32* %105
%107 = call i8* @get_comm_pid(i32 %106)
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8* %14, i8* %107)
%109 = load %struct.fanotify_event_metadata*, %struct.fanotify_event_metadata** %3
%110 = getelementptr inbounds %struct.fanotify_event_metadata, %struct.fanotify_event_metadata* %109, i32 0, i32 1
%111 = load i64, i64* %110
%112 = trunc i64 %111 to i32
%113 = call i32 @close(i32 %112)
br label %114
114: ; preds = %100, %54
%115 = load %struct.fanotify_event_metadata*, %struct.fanotify_event_metadata** %3
%116 = load i32, i32* %5
%117 = call %struct.fanotify_event_metadata* @FAN_EVENT_NEXT(%struct.fanotify_event_metadata* %115, i32 %116)
store %struct.fanotify_event_metadata* %117, %struct.fanotify_event_metadata** %3
br label %38
118: ; preds = %38
br label %18
119: ; preds = %35
%120 = load i8*, i8** %6
ret void
}

LLVM IR (-O2):
%struct.fanotify_event_metadata = type { i64, i64, i32, 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_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 = [19 x i8] c"File %s.\09\09 Comm %s\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 = %90, %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 %94, 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 %94, 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, %90
%38 = phi %struct.fanotify_event_metadata* [ %91, %90 ], [ %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 %90
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 %64, 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
store i32 %61, i32* %18
%62 = call i32 @write(i32 %0, %struct.fanotify_response* %3, i32 16)
%63 = load i32, i32* %53
br label %64
64: ; preds = %58, %52
%65 = phi i32 [ %63, %58 ], [ %54, %52 ]
%66 = load i32, i32* @FAN_CLOSE_WRITE
%67 = and i32 %66, %65
%68 = icmp eq i32 %67, 0
br i1 %68, label %71, label %69
69: ; preds = %64
%70 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %71
71: ; preds = %69, %64
%72 = load i64, i64* %49
%73 = call i32 @snprintf(i8* %11, i32 %9, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i64 %72)
%74 = call i32 @readlink(i8* %11, i8* %8, i32 %19)
%75 = icmp eq i32 %74, -1
br i1 %75, label %76, label %80
76: ; preds = %71
%77 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%78 = load i32, i32* @EXIT_FAILURE
%79 = call i32 @exit(i32 %78)
unreachable
80: ; preds = %71
%81 = sext i32 %74 to i64
%82 = getelementptr inbounds i8, i8* %8, i64 %81
store i8 0, i8* %82
%83 = getelementptr inbounds %struct.fanotify_event_metadata, %struct.fanotify_event_metadata* %38, i64 0, i32 3
%84 = load i32, i32* %83
%85 = call i8* @get_comm_pid(i32 %84)
%86 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8* %8, i8* %85)
%87 = load i64, i64* %49
%88 = trunc i64 %87 to i32
%89 = call i32 @close(i32 %88)
br label %90
90: ; preds = %80, %48
%91 = call %struct.fanotify_event_metadata* @FAN_EVENT_NEXT(%struct.fanotify_event_metadata* %38, i32 %32)
%92 = call i64 @FAN_EVENT_OK(%struct.fanotify_event_metadata* %91, i32 %32)
%93 = icmp eq i64 %92, 0
br i1 %93, label %20, label %37
94: ; preds = %31, %23
ret void
}