#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 {
  char *name;
  int mask;
  scalar_t__ len;
};

/* Variables and functions */
int IN_CREATE;
int IN_DELETE;
int IN_MODIFY;
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);
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  int length, i = 0;
  int fd;
  int wd;
  char buffer[(1024 * ((sizeof(struct inotify_event)) + 16))];
  fd = inotify_init();
  if (fd < 0) {
    perror("inotify_init");
  }
  wd = inotify_add_watch(fd, ".", IN_MODIFY | IN_CREATE | IN_DELETE);
  if (length < 0) {
    perror("read");
  }
  for (;;) {
    i = 0;
    length = read(fd, buffer, (1024 * ((sizeof(struct inotify_event)) + 16)));
    while (i < length) {
      struct inotify_event *event = (struct inotify_event *)&buffer[i];
      if (strcmp(event->name, "a.txt") != 0)
        break;
      if (event->len) {
        if (event->mask & IN_CREATE) {
          printf("The file %s was created.\n", event->name);
        } else if (event->mask & IN_DELETE) {
          printf("The file %s was deleted.\n", event->name);
        } else if (event->mask & IN_MODIFY) {
          printf("The file %s was modified.\n", event->name);
        }
      }
      i += (sizeof(struct inotify_event)) + event->len;
    }
  }
  (void)inotify_rm_watch(fd, wd);
  (void)close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa030,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    $0x0,%al
call   1060 <inotify_init@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    11a0 <main+0x40>
lea    0xe65(%rip),%rdi
call   1080 <perror@plt>
mov    -0x1c(%rbp),%edi
mov    0x2e46(%rip),%rax
mov    (%rax),%edx
mov    0x2e1d(%rip),%rax
or     (%rax),%edx
mov    0x2e24(%rip),%rax
or     (%rax),%edx
lea    0xe48(%rip),%rsi
call   1070 <inotify_add_watch@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11e3 <main+0x83>
lea    0xe31(%rip),%rdi
call   1080 <perror@plt>
jmp    11e8 <main+0x88>
movl   $0x0,-0x18(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0xa020(%rbp),%rsi
mov    $0xa000,%edx
call   1040 <read@plt>
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    132b <main+0x1cb>
movslq -0x18(%rbp),%rcx
lea    -0xa020(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0xa028(%rbp)
mov    -0xa028(%rbp),%rax
mov    (%rax),%rdi
lea    0xddc(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     124c <main+0xec>
jmp    132b <main+0x1cb>
mov    -0xa028(%rbp),%rax
cmpq   $0x0,0x10(%rax)
je     130d <main+0x1ad>
mov    -0xa028(%rbp),%rax
mov    0x8(%rax),%eax
mov    0x2d61(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1295 <main+0x135>
mov    -0xa028(%rbp),%rax
mov    (%rax),%rsi
lea    0xd8f(%rip),%rdi
call   1030 <printf@plt>
jmp    1308 <main+0x1a8>
mov    -0xa028(%rbp),%rax
mov    0x8(%rax),%eax
mov    0x2d3a(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     12cc <main+0x16c>
mov    -0xa028(%rbp),%rax
mov    (%rax),%rsi
lea    0xd72(%rip),%rdi
call   1030 <printf@plt>
jmp    1303 <main+0x1a3>
mov    -0xa028(%rbp),%rax
mov    0x8(%rax),%eax
mov    0x2d13(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     12fe <main+0x19e>
mov    -0xa028(%rbp),%rax
mov    (%rax),%rsi
lea    0xd55(%rip),%rdi
call   1030 <printf@plt>
jmp    1303 <main+0x1a3>
jmp    1308 <main+0x1a8>
jmp    130d <main+0x1ad>
mov    -0xa028(%rbp),%rax
mov    0x10(%rax),%rcx
add    $0x18,%rcx
movslq -0x18(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x18(%rbp)
jmp    1206 <main+0xa6>
jmp    11e8 <main+0x88>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa018,%rsp
xor    %eax,%eax
call   1060 <inotify_init@plt>
mov    %eax,%ebx
test   %eax,%eax
js     1253 <main+0xf3>
mov    0x2e67(%rip),%rax
mov    0x2e40(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2e45(%rip),%rax
or     (%rax),%edx
lea    0xe69(%rip),%rsi
mov    %ebx,0xc(%rsp)
mov    %ebx,%edi
call   1070 <inotify_add_watch@plt>
lea    0xe59(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
mov    0xc(%rsp),%edi
lea    0x10(%rsp),%rsi
mov    $0xa000,%edx
call   1040 <read@plt>
test   %eax,%eax
jle    11c0 <main+0x60>
mov    %eax,%ebp
xor    %r14d,%r14d
jmp    11f4 <main+0x94>
xchg   %ax,%ax
mov    %rbx,%rsi
call   1030 <printf@plt>
add    %r13d,%r14d
add    $0x18,%r14d
cmp    %ebp,%r14d
jge    11c0 <main+0x60>
movslq %r14d,%r15
mov    0x10(%rsp,%r15,1),%rbx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    11c0 <main+0x60>
mov    0x20(%rsp,%r15,1),%r13
test   %r13,%r13
je     11e8 <main+0x88>
mov    0x18(%rsp,%r15,1),%eax
lea    0xdf3(%rip),%rdi
mov    0x2da7(%rip),%rcx
test   %eax,(%rcx)
jne    11e0 <main+0x80>
lea    0xdfb(%rip),%rdi
mov    0x2da5(%rip),%rcx
test   %eax,(%rcx)
jne    11e0 <main+0x80>
lea    0xe03(%rip),%rdi
mov    0x2da3(%rip),%rcx
test   %eax,(%rcx)
jne    11e0 <main+0x80>
jmp    11e8 <main+0x88>
lea    0xda6(%rip),%rdi
call   1080 <perror@plt>
jmp    1182 <main+0x22>

LLVM IR (-O0):
%struct.inotify_event = type { i8*, i32, i64 }
@.str = [13 x i8] c"inotify_init\00"
@.str.1 = [2 x i8] c".\00"
@IN_MODIFY = global i32 0
@IN_CREATE = global i32 0
@IN_DELETE = global i32 0
@.str.2 = [5 x i8] c"read\00"
@.str.3 = [6 x i8] c"a.txt\00"
@.str.4 = [26 x i8] c"The file %s was created.\0A\00"
@.str.5 = [26 x i8] c"The file %s was deleted.\0A\00"
@.str.6 = [27 x i8] c"The file %s was modified.\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 [40960 x i8]
%11 = alloca %struct.inotify_event*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
%12 = call i32 (...) @inotify_init()
store i32 %12, i32* %8
%13 = load i32, i32* %8
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %15, %2
%18 = load i32, i32* %8
%19 = load i32, i32* @IN_MODIFY
%20 = load i32, i32* @IN_CREATE
%21 = or i32 %19, %20
%22 = load i32, i32* @IN_DELETE
%23 = or i32 %21, %22
%24 = call i32 @inotify_add_watch(i32 %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %23)
store i32 %24, i32* %9
%25 = load i32, i32* %6
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %17
%28 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %29
29: ; preds = %27, %17
br label %30
30: ; preds = %102, %29
store i32 0, i32* %7
%31 = load i32, i32* %8
%32 = getelementptr inbounds [40960 x i8], [40960 x i8]* %10, i64 0, i64 0
%33 = call i32 @read(i32 %31, i8* %32, i32 40960)
store i32 %33, i32* %6
br label %34
34: ; preds = %93, %30
%35 = load i32, i32* %7
%36 = load i32, i32* %6
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %102
38: ; preds = %34
%39 = load i32, i32* %7
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [40960 x i8], [40960 x i8]* %10, i64 0, i64 %40
%42 = bitcast i8* %41 to %struct.inotify_event*
store %struct.inotify_event* %42, %struct.inotify_event** %11
%43 = load %struct.inotify_event*, %struct.inotify_event** %11
%44 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %43, i32 0, i32 0
%45 = load i8*, i8** %44
%46 = call i64 @strcmp(i8* %45, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %49
48: ; preds = %38
br label %102
49: ; preds = %38
%50 = load %struct.inotify_event*, %struct.inotify_event** %11
%51 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %50, i32 0, i32 2
%52 = load i64, i64* %51
%53 = icmp ne i64 %52, 0
br i1 %53, label %54, label %93
54: ; preds = %49
%55 = load %struct.inotify_event*, %struct.inotify_event** %11
%56 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %55, i32 0, i32 1
%57 = load i32, i32* %56
%58 = load i32, i32* @IN_CREATE
%59 = and i32 %57, %58
%60 = icmp ne i32 %59, 0
br i1 %60, label %61, label %66
61: ; preds = %54
%62 = load %struct.inotify_event*, %struct.inotify_event** %11
%63 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %62, i32 0, i32 0
%64 = load i8*, i8** %63
%65 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %64)
br label %92
66: ; preds = %54
%67 = load %struct.inotify_event*, %struct.inotify_event** %11
%68 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %67, i32 0, i32 1
%69 = load i32, i32* %68
%70 = load i32, i32* @IN_DELETE
%71 = and i32 %69, %70
%72 = icmp ne i32 %71, 0
br i1 %72, label %73, label %78
73: ; preds = %66
%74 = load %struct.inotify_event*, %struct.inotify_event** %11
%75 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %74, i32 0, i32 0
%76 = load i8*, i8** %75
%77 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i8* %76)
br label %91
78: ; preds = %66
%79 = load %struct.inotify_event*, %struct.inotify_event** %11
%80 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %79, i32 0, i32 1
%81 = load i32, i32* %80
%82 = load i32, i32* @IN_MODIFY
%83 = and i32 %81, %82
%84 = icmp ne i32 %83, 0
br i1 %84, label %85, label %90
85: ; preds = %78
%86 = load %struct.inotify_event*, %struct.inotify_event** %11
%87 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %86, i32 0, i32 0
%88 = load i8*, i8** %87
%89 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i8* %88)
br label %90
90: ; preds = %85, %78
br label %91
91: ; preds = %90, %73
br label %92
92: ; preds = %91, %61
br label %93
93: ; preds = %92, %49
%94 = load %struct.inotify_event*, %struct.inotify_event** %11
%95 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %94, i32 0, i32 2
%96 = load i64, i64* %95
%97 = add i64 24, %96
%98 = load i32, i32* %7
%99 = sext i32 %98 to i64
%100 = add i64 %99, %97
%101 = trunc i64 %100 to i32
store i32 %101, i32* %7
br label %34
102: ; preds = %48, %34
br label %30
}

LLVM IR (-O2):
@.str = [13 x i8] c"inotify_init\00"
@.str.1 = [2 x i8] c".\00"
@IN_MODIFY = global i32 0
@IN_CREATE = global i32 0
@IN_DELETE = global i32 0
@.str.3 = [6 x i8] c"a.txt\00"
@.str.4 = [26 x i8] c"The file %s was created.\0A\00"
@.str.5 = [26 x i8] c"The file %s was deleted.\0A\00"
@.str.6 = [27 x i8] c"The file %s was modified.\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [40960 x i8]
%4 = getelementptr inbounds [40960 x i8], [40960 x i8]* %3, i64 0, i64 0
%5 = tail call i32 (...) @inotify_init()
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %7, %2
%10 = load i32, i32* @IN_MODIFY
%11 = load i32, i32* @IN_CREATE
%12 = or i32 %11, %10
%13 = load i32, i32* @IN_DELETE
%14 = or i32 %12, %13
%15 = tail call i32 @inotify_add_watch(i32 %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %19, %9
%17 = call i32 @read(i32 %5, i8* %4, i32 40960)
%18 = icmp sgt i32 %17, 0
br i1 %18, label %20, label %19
19: ; preds = %20, %51, %16
br label %16
20: ; preds = %16, %51
%21 = phi i32 [ %54, %51 ], [ 0, %16 ]
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [40960 x i8], [40960 x i8]* %3, i64 0, i64 %22
%24 = bitcast i8* %23 to i8**
%25 = load i8*, i8** %24
%26 = tail call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %19
28: ; preds = %20
%29 = getelementptr inbounds i8, i8* %23, i64 16
%30 = bitcast i8* %29 to i64*
%31 = load i64, i64* %30
%32 = icmp eq i64 %31, 0
br i1 %32, label %51, label %33
33: ; preds = %28
%34 = getelementptr inbounds i8, i8* %23, i64 8
%35 = bitcast i8* %34 to i32*
%36 = load i32, i32* %35
%37 = load i32, i32* @IN_CREATE
%38 = and i32 %37, %36
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %48
40: ; preds = %33
%41 = load i32, i32* @IN_DELETE
%42 = and i32 %41, %36
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %48
44: ; preds = %40
%45 = load i32, i32* @IN_MODIFY
%46 = and i32 %45, %36
%47 = icmp eq i32 %46, 0
br i1 %47, label %51, label %48
48: ; preds = %44, %40, %33
%49 = phi i8* [ getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), %33 ], [ getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), %40 ], [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), %44 ]
%50 = tail call i32 @printf(i8* %49, i8* %25)
br label %51
51: ; preds = %48, %28, %44
%52 = trunc i64 %31 to i32
%53 = add i32 %21, 24
%54 = add i32 %53, %52
%55 = icmp slt i32 %54, %17
br i1 %55, label %20, label %19
}