#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 stat {
  int /*<<< orphan*/ st_mode;
};
struct inotify_event {
  int mask;
  char *name;
  scalar_t__ len;
};
typedef scalar_t__ ssize_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int IN_ACCESS;
int IN_CREATE;
int IN_DELETE;
int IN_ISDIR;
int IN_MODIFY;
int /*<<< orphan*/ S_ISDIR(int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int inotify_add_watch(int, char *, int);
int inotify_init();
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ read(int, char *, int);
int stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
char *strerror(int);
int main(int argc, char *argv[]) {
  int fd, wd;
  ssize_t nread;
  char buf[(1024 * ((sizeof(struct inotify_event)) + 16))], *p;
  struct inotify_event *event;
  struct stat sb;
  if (argc != 2) {
    fprintf(stderr, "Usage: %s <dirname>\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  if (stat(argv[1], &sb) == -1) {
    fprintf(stderr, "Err.: %d stat() %s\n", errno, strerror(errno));
    exit(EXIT_FAILURE);
  }
  if (!S_ISDIR(sb.st_mode)) {
    fprintf(stderr, "'%s' is not a directory, plese fix.\n", argv[1]);
    exit(EXIT_FAILURE);
  }
  fd = inotify_init();
  if (fd < 0) {
    fprintf(stderr, "Err.: %d inotify_init; %s\n", errno, strerror(errno));
    exit(EXIT_FAILURE);
  }
  wd = inotify_add_watch(fd, argv[1],
                         (IN_MODIFY | IN_ACCESS | IN_CREATE | IN_DELETE));
  if (wd <= 0) {
    fprintf(stderr, "Err.: %d watch list %s\n", errno, strerror(errno));
    exit(EXIT_FAILURE);
  }
  while (1) {
    nread = read(fd, buf, (1024 * ((sizeof(struct inotify_event)) + 16)));
    if (nread < 0) {
      fprintf(stderr, "Err.: %d read(); %s\n", errno, strerror(errno));
      exit(EXIT_FAILURE);
    }
    for (p = buf; p < buf + nread;) {
      event = (struct inotify_event *)p;
      if (event->len) {
        if (event->mask & IN_CREATE) {
          if (event->mask & IN_ISDIR) {
            printf("The dir \'%s\' was created.\n", event->name);
          } else
            printf("The file \'%s\' was created.\n", event->name);
        } else if (event->mask & IN_DELETE) {
          if (event->mask & IN_ISDIR) {
            printf("The dir \'%s\' was deleted.\n", event->name);
          } else
            printf("The file \'%s\' was deleted.\n", event->name);
        } else if (event->mask & IN_MODIFY) {
          if (event->mask & IN_ISDIR) {
            printf("The dir \'%s\' was modified.\n", event->name);
          } else
            printf("The file \'%s\' was modified.\n", event->name);
        }
      }
      p += (sizeof(struct inotify_event)) + event->len;
    }
  }
  close(fd);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa060,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11df <main+0x4f>
mov    0x2e06(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe36(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2dd0(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0xa038(%rbp),%rsi
call   1070 <stat@plt>
cmp    $0xffffffff,%eax
jne    1253 <main+0xc3>
mov    0x2dbd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xa040(%rbp)
mov    0x2da6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xa03c(%rbp)
mov    0x2d97(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0xa040(%rbp),%edi
mov    -0xa03c(%rbp),%edx
mov    %rax,%rcx
lea    0xdd7(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2d5c(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0xa038(%rbp),%edi
call   1040 <S_ISDIR@plt>
cmp    $0x0,%eax
jne    1294 <main+0x104>
mov    0x2d52(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xdaa(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2d1b(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    $0x0,%al
call   1080 <inotify_init@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    12ff <main+0x16f>
mov    0x2d11(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xa048(%rbp)
mov    0x2cfa(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xa044(%rbp)
mov    0x2ceb(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0xa048(%rbp),%edi
mov    -0xa044(%rbp),%edx
mov    %rax,%rcx
lea    0xd64(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2cb0(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    0x2cdf(%rip),%rax
mov    (%rax),%edx
mov    0x2cae(%rip),%rax
or     (%rax),%edx
mov    0x2c8d(%rip),%rax
or     (%rax),%edx
mov    0x2cb4(%rip),%rax
or     (%rax),%edx
call   1090 <inotify_add_watch@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jg     1397 <main+0x207>
mov    0x2c79(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xa050(%rbp)
mov    0x2c62(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xa04c(%rbp)
mov    0x2c53(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0xa050(%rbp),%edi
mov    -0xa04c(%rbp),%edx
mov    %rax,%rcx
lea    0xce7(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2c18(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
jmp    139c <main+0x20c>
mov    -0x14(%rbp),%edi
lea    -0xa020(%rbp),%rsi
mov    $0xa000,%edx
call   1050 <read@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jge    1416 <main+0x286>
mov    0x2bfa(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xa058(%rbp)
mov    0x2be3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xa054(%rbp)
mov    0x2bd4(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
mov    -0xa058(%rbp),%edi
mov    -0xa054(%rbp),%edx
mov    %rax,%rcx
lea    0xc80(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2b99(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
lea    -0xa020(%rbp),%rax
mov    %rax,-0xa028(%rbp)
mov    -0xa028(%rbp),%rax
lea    -0xa020(%rbp),%rcx
add    -0x20(%rbp),%rcx
cmp    %rcx,%rax
jae    15da <main+0x44a>
mov    -0xa028(%rbp),%rax
mov    %rax,-0xa030(%rbp)
mov    -0xa030(%rbp),%rax
cmpq   $0x0,0x10(%rax)
je     15b8 <main+0x428>
mov    -0xa030(%rbp),%rax
mov    (%rax),%eax
mov    0x2b41(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     14cd <main+0x33d>
mov    -0xa030(%rbp),%rax
mov    (%rax),%eax
mov    0x2b4e(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     14b1 <main+0x321>
mov    -0xa030(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xbef(%rip),%rdi
call   1030 <printf@plt>
jmp    14c8 <main+0x338>
mov    -0xa030(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xbee(%rip),%rdi
call   1030 <printf@plt>
jmp    15b3 <main+0x423>
mov    -0xa030(%rbp),%rax
mov    (%rax),%eax
mov    0x2b03(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     153b <main+0x3ab>
mov    -0xa030(%rbp),%rax
mov    (%rax),%eax
mov    0x2ae0(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     151f <main+0x38f>
mov    -0xa030(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xbb8(%rip),%rdi
call   1030 <printf@plt>
jmp    1536 <main+0x3a6>
mov    -0xa030(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xbb7(%rip),%rdi
call   1030 <printf@plt>
jmp    15ae <main+0x41e>
mov    -0xa030(%rbp),%rax
mov    (%rax),%eax
mov    0x2aa5(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     15a9 <main+0x419>
mov    -0xa030(%rbp),%rax
mov    (%rax),%eax
mov    0x2a72(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     158d <main+0x3fd>
mov    -0xa030(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xb81(%rip),%rdi
call   1030 <printf@plt>
jmp    15a4 <main+0x414>
mov    -0xa030(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xb81(%rip),%rdi
call   1030 <printf@plt>
jmp    15a9 <main+0x419>
jmp    15ae <main+0x41e>
jmp    15b3 <main+0x423>
jmp    15b8 <main+0x428>
mov    -0xa030(%rbp),%rax
mov    0x10(%rax),%rax
add    $0x18,%rax
add    -0xa028(%rbp),%rax
mov    %rax,-0xa028(%rbp)
jmp    1424 <main+0x294>
jmp    139c <main+0x20c>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa018,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    11ec <main+0x5c>
mov    0x8(%rbx),%rdi
lea    0x8(%rsp),%rsi
call   1070 <stat@plt>
cmp    $0xffffffff,%eax
jne    1214 <main+0x84>
mov    0x2dfd(%rip),%rax
mov    (%rax),%ebx
mov    0x2dec(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   10b0 <strerror@plt>
lea    0xe39(%rip),%rsi
mov    %ebx,%edi
mov    %ebp,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    1206 <main+0x76>
mov    0x2dcd(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe01(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x2d9b(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    0x8(%rsp),%edi
call   1040 <S_ISDIR@plt>
test   %eax,%eax
jne    1237 <main+0xa7>
mov    0x2d98(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xdf4(%rip),%rsi
jmp    11ff <main+0x6f>
xor    %eax,%eax
call   1080 <inotify_init@plt>
test   %eax,%eax
jns    1267 <main+0xd7>
mov    0x2d77(%rip),%rax
mov    (%rax),%ebx
mov    0x2d66(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   10b0 <strerror@plt>
lea    0xdec(%rip),%rsi
jmp    11dc <main+0x4c>
mov    %eax,%r14d
mov    0x2d7f(%rip),%rcx
mov    0x2d50(%rip),%rax
mov    (%rax),%edx
or     (%rcx),%edx
mov    0x2d2d(%rip),%r13
or     0x0(%r13),%edx
mov    0x8(%rbx),%rsi
mov    0x2d4e(%rip),%rax
or     (%rax),%edx
mov    %r14d,%edi
call   1090 <inotify_add_watch@plt>
test   %eax,%eax
jg     12c5 <main+0x135>
mov    0x2d19(%rip),%rax
mov    (%rax),%ebx
mov    0x2d08(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   10b0 <strerror@plt>
lea    0xda9(%rip),%rsi
jmp    11dc <main+0x4c>
lea    0x10(%rsp),%rsi
mov    %r14d,%edi
mov    $0xa000,%edx
call   1050 <read@plt>
test   %rax,%rax
jns    1301 <main+0x171>
mov    0x2cdd(%rip),%rax
mov    (%rax),%ebx
mov    0x2ccc(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%edi
call   10b0 <strerror@plt>
lea    0xd85(%rip),%rsi
jmp    11dc <main+0x4c>
mov    0x2cd0(%rip),%rbx
lea    0xd87(%rip),%r12
jmp    1337 <main+0x1a7>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14d,%edi
lea    0x10(%rsp),%rsi
mov    $0xa000,%edx
call   1050 <read@plt>
test   %rax,%rax
js     12dc <main+0x14c>
test   %rax,%rax
je     1320 <main+0x190>
lea    (%rsp,%rax,1),%rbp
add    $0x10,%rbp
lea    0x10(%rsp),%r15
jmp    1367 <main+0x1d7>
lea    0xd5f(%rip),%rdi
call   1030 <printf@plt>
mov    0x10(%r15),%rax
add    %rax,%r15
add    $0x18,%r15
cmp    %rbp,%r15
jae    1320 <main+0x190>
cmpq   $0x0,0x10(%r15)
je     1357 <main+0x1c7>
mov    (%r15),%eax
test   %eax,0x0(%r13)
je     1390 <main+0x200>
mov    0x8(%r15),%rsi
test   %eax,(%rbx)
je     134b <main+0x1bb>
mov    %r12,%rdi
jmp    1352 <main+0x1c2>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x2c49(%rip),%rcx
test   %eax,(%rcx)
je     13ac <main+0x21c>
mov    0x8(%r15),%rsi
test   %eax,(%rbx)
je     13c8 <main+0x238>
lea    0xd23(%rip),%rdi
jmp    1352 <main+0x1c2>
mov    0x2c3d(%rip),%rcx
test   %eax,(%rcx)
je     1357 <main+0x1c7>
mov    0x8(%r15),%rsi
test   %eax,(%rbx)
je     13d1 <main+0x241>
lea    0xd3e(%rip),%rdi
jmp    1352 <main+0x1c2>
lea    0xd19(%rip),%rdi
jmp    1352 <main+0x1c2>
lea    0xd48(%rip),%rdi
jmp    1352 <main+0x1c2>

LLVM IR (-O0):
%struct.inotify_event = type { i32, i8*, i64 }
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [21 x i8] c"Usage: %s <dirname>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [20 x i8] c"Err.: %d stat() %s\0A\00"
@errno = global i32 0
@.str.2 = [37 x i8] c"'%s' is not a directory, plese fix.\0A\00"
@.str.3 = [27 x i8] c"Err.: %d inotify_init; %s\0A\00"
@IN_MODIFY = global i32 0
@IN_ACCESS = global i32 0
@IN_CREATE = global i32 0
@IN_DELETE = global i32 0
@.str.4 = [24 x i8] c"Err.: %d watch list %s\0A\00"
@.str.5 = [21 x i8] c"Err.: %d read(); %s\0A\00"
@IN_ISDIR = global i32 0
@.str.6 = [27 x i8] c"The dir '%s' was created.\0A\00"
@.str.7 = [28 x i8] c"The file '%s' was created.\0A\00"
@.str.8 = [27 x i8] c"The dir '%s' was deleted.\0A\00"
@.str.9 = [28 x i8] c"The file '%s' was deleted.\0A\00"
@.str.10 = [28 x i8] c"The dir '%s' was modified.\0A\00"
@.str.11 = [29 x i8] c"The file '%s' was modified.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i64
%9 = alloca [40960 x i8]
%10 = alloca i8*
%11 = alloca %struct.inotify_event*
%12 = alloca %struct.stat
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 2
br i1 %14, label %15, label %23
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = load i32, i32* @EXIT_FAILURE
%22 = call i32 @exit(i32 %21)
unreachable
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32 @stat(i8* %26, %struct.stat* %12)
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %37
29: ; preds = %23
%30 = load i32, i32* @stderr
%31 = load i32, i32* @errno
%32 = load i32, i32* @errno
%33 = call i8* @strerror(i32 %32)
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %31, i8* %33)
%35 = load i32, i32* @EXIT_FAILURE
%36 = call i32 @exit(i32 %35)
unreachable
37: ; preds = %23
%38 = getelementptr inbounds %struct.stat, %struct.stat* %12, i32 0, i32 0
%39 = load i32, i32* %38
%40 = call i32 @S_ISDIR(i32 %39)
%41 = icmp ne i32 %40, 0
br i1 %41, label %50, label %42
42: ; preds = %37
%43 = load i32, i32* @stderr
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 1
%46 = load i8*, i8** %45
%47 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %46)
%48 = load i32, i32* @EXIT_FAILURE
%49 = call i32 @exit(i32 %48)
unreachable
50: ; preds = %37
%51 = call i32 (...) @inotify_init()
store i32 %51, i32* %6
%52 = load i32, i32* %6
%53 = icmp slt i32 %52, 0
br i1 %53, label %54, label %62
54: ; preds = %50
%55 = load i32, i32* @stderr
%56 = load i32, i32* @errno
%57 = load i32, i32* @errno
%58 = call i8* @strerror(i32 %57)
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %56, i8* %58)
%60 = load i32, i32* @EXIT_FAILURE
%61 = call i32 @exit(i32 %60)
unreachable
62: ; preds = %50
%63 = load i32, i32* %6
%64 = load i8**, i8*** %5
%65 = getelementptr inbounds i8*, i8** %64, i64 1
%66 = load i8*, i8** %65
%67 = load i32, i32* @IN_MODIFY
%68 = load i32, i32* @IN_ACCESS
%69 = or i32 %67, %68
%70 = load i32, i32* @IN_CREATE
%71 = or i32 %69, %70
%72 = load i32, i32* @IN_DELETE
%73 = or i32 %71, %72
%74 = call i32 @inotify_add_watch(i32 %63, i8* %66, i32 %73)
store i32 %74, i32* %7
%75 = load i32, i32* %7
%76 = icmp sle i32 %75, 0
br i1 %76, label %77, label %85
77: ; preds = %62
%78 = load i32, i32* @stderr
%79 = load i32, i32* @errno
%80 = load i32, i32* @errno
%81 = call i8* @strerror(i32 %80)
%82 = call i32 (i32, i8*, ...) @fprintf(i32 %78, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 %79, i8* %81)
%83 = load i32, i32* @EXIT_FAILURE
%84 = call i32 @exit(i32 %83)
unreachable
85: ; preds = %62
br label %86
86: ; preds = %85, %200
%87 = load i32, i32* %6
%88 = getelementptr inbounds [40960 x i8], [40960 x i8]* %9, i64 0, i64 0
%89 = call i64 @read(i32 %87, i8* %88, i32 40960)
store i64 %89, i64* %8
%90 = load i64, i64* %8
%91 = icmp slt i64 %90, 0
br i1 %91, label %92, label %100
92: ; preds = %86
%93 = load i32, i32* @stderr
%94 = load i32, i32* @errno
%95 = load i32, i32* @errno
%96 = call i8* @strerror(i32 %95)
%97 = call i32 (i32, i8*, ...) @fprintf(i32 %93, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i32 %94, i8* %96)
%98 = load i32, i32* @EXIT_FAILURE
%99 = call i32 @exit(i32 %98)
unreachable
100: ; preds = %86
%101 = getelementptr inbounds [40960 x i8], [40960 x i8]* %9, i64 0, i64 0
store i8* %101, i8** %10
br label %102
102: ; preds = %193, %100
%103 = load i8*, i8** %10
%104 = getelementptr inbounds [40960 x i8], [40960 x i8]* %9, i64 0, i64 0
%105 = load i64, i64* %8
%106 = getelementptr inbounds i8, i8* %104, i64 %105
%107 = icmp ult i8* %103, %106
br i1 %107, label %108, label %200
108: ; preds = %102
%109 = load i8*, i8** %10
%110 = bitcast i8* %109 to %struct.inotify_event*
store %struct.inotify_event* %110, %struct.inotify_event** %11
%111 = load %struct.inotify_event*, %struct.inotify_event** %11
%112 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %111, i32 0, i32 2
%113 = load i64, i64* %112
%114 = icmp ne i64 %113, 0
br i1 %114, label %115, label %193
115: ; preds = %108
%116 = load %struct.inotify_event*, %struct.inotify_event** %11
%117 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %116, i32 0, i32 0
%118 = load i32, i32* %117
%119 = load i32, i32* @IN_CREATE
%120 = and i32 %118, %119
%121 = icmp ne i32 %120, 0
br i1 %121, label %122, label %140
122: ; preds = %115
%123 = load %struct.inotify_event*, %struct.inotify_event** %11
%124 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %123, i32 0, i32 0
%125 = load i32, i32* %124
%126 = load i32, i32* @IN_ISDIR
%127 = and i32 %125, %126
%128 = icmp ne i32 %127, 0
br i1 %128, label %129, label %134
129: ; preds = %122
%130 = load %struct.inotify_event*, %struct.inotify_event** %11
%131 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %130, i32 0, i32 1
%132 = load i8*, i8** %131
%133 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i8* %132)
br label %139
134: ; preds = %122
%135 = load %struct.inotify_event*, %struct.inotify_event** %11
%136 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %135, i32 0, i32 1
%137 = load i8*, i8** %136
%138 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), i8* %137)
br label %139
139: ; preds = %134, %129
br label %192
140: ; preds = %115
%141 = load %struct.inotify_event*, %struct.inotify_event** %11
%142 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %141, i32 0, i32 0
%143 = load i32, i32* %142
%144 = load i32, i32* @IN_DELETE
%145 = and i32 %143, %144
%146 = icmp ne i32 %145, 0
br i1 %146, label %147, label %165
147: ; preds = %140
%148 = load %struct.inotify_event*, %struct.inotify_event** %11
%149 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %148, i32 0, i32 0
%150 = load i32, i32* %149
%151 = load i32, i32* @IN_ISDIR
%152 = and i32 %150, %151
%153 = icmp ne i32 %152, 0
br i1 %153, label %154, label %159
154: ; preds = %147
%155 = load %struct.inotify_event*, %struct.inotify_event** %11
%156 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %155, i32 0, i32 1
%157 = load i8*, i8** %156
%158 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0), i8* %157)
br label %164
159: ; preds = %147
%160 = load %struct.inotify_event*, %struct.inotify_event** %11
%161 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %160, i32 0, i32 1
%162 = load i8*, i8** %161
%163 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0), i8* %162)
br label %164
164: ; preds = %159, %154
br label %191
165: ; preds = %140
%166 = load %struct.inotify_event*, %struct.inotify_event** %11
%167 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %166, i32 0, i32 0
%168 = load i32, i32* %167
%169 = load i32, i32* @IN_MODIFY
%170 = and i32 %168, %169
%171 = icmp ne i32 %170, 0
br i1 %171, label %172, label %190
172: ; preds = %165
%173 = load %struct.inotify_event*, %struct.inotify_event** %11
%174 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %173, i32 0, i32 0
%175 = load i32, i32* %174
%176 = load i32, i32* @IN_ISDIR
%177 = and i32 %175, %176
%178 = icmp ne i32 %177, 0
br i1 %178, label %179, label %184
179: ; preds = %172
%180 = load %struct.inotify_event*, %struct.inotify_event** %11
%181 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %180, i32 0, i32 1
%182 = load i8*, i8** %181
%183 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.10, i64 0, i64 0), i8* %182)
br label %189
184: ; preds = %172
%185 = load %struct.inotify_event*, %struct.inotify_event** %11
%186 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %185, i32 0, i32 1
%187 = load i8*, i8** %186
%188 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.11, i64 0, i64 0), i8* %187)
br label %189
189: ; preds = %184, %179
br label %190
190: ; preds = %189, %165
br label %191
191: ; preds = %190, %164
br label %192
192: ; preds = %191, %139
br label %193
193: ; preds = %192, %108
%194 = load %struct.inotify_event*, %struct.inotify_event** %11
%195 = getelementptr inbounds %struct.inotify_event, %struct.inotify_event* %194, i32 0, i32 2
%196 = load i64, i64* %195
%197 = add i64 24, %196
%198 = load i8*, i8** %10
%199 = getelementptr inbounds i8, i8* %198, i64 %197
store i8* %199, i8** %10
br label %102
200: ; preds = %102
br label %86
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [21 x i8] c"Usage: %s <dirname>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [20 x i8] c"Err.: %d stat() %s\0A\00"
@errno = global i32 0
@.str.2 = [37 x i8] c"'%s' is not a directory, plese fix.\0A\00"
@.str.3 = [27 x i8] c"Err.: %d inotify_init; %s\0A\00"
@IN_MODIFY = global i32 0
@IN_ACCESS = global i32 0
@IN_CREATE = global i32 0
@IN_DELETE = global i32 0
@.str.4 = [24 x i8] c"Err.: %d watch list %s\0A\00"
@.str.5 = [21 x i8] c"Err.: %d read(); %s\0A\00"
@IN_ISDIR = global i32 0
@.str.6 = [27 x i8] c"The dir '%s' was created.\0A\00"
@.str.7 = [28 x i8] c"The file '%s' was created.\0A\00"
@.str.8 = [27 x i8] c"The dir '%s' was deleted.\0A\00"
@.str.9 = [28 x i8] c"The file '%s' was deleted.\0A\00"
@.str.10 = [28 x i8] c"The dir '%s' was modified.\0A\00"
@.str.11 = [29 x i8] c"The file '%s' was modified.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [40960 x i8]
%4 = alloca %struct.stat
%5 = getelementptr inbounds [40960 x i8], [40960 x i8]* %3, i64 0, i64 0
%6 = bitcast %struct.stat* %4 to i8*
%7 = icmp eq i32 %0, 2
br i1 %7, label %14, label %8
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %1
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = load i32, i32* @EXIT_FAILURE
%13 = tail call i32 @exit(i32 %12)
unreachable
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @stat(i8* %16, %struct.stat* %4)
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %26
19: ; preds = %14
%20 = load i32, i32* @stderr
%21 = load i32, i32* @errno
%22 = tail call i8* @strerror(i32 %21)
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %21, i8* %22)
%24 = load i32, i32* @EXIT_FAILURE
%25 = tail call i32 @exit(i32 %24)
unreachable
26: ; preds = %14
%27 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
%28 = load i32, i32* %27
%29 = tail call i32 @S_ISDIR(i32 %28)
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %37
31: ; preds = %26
%32 = load i32, i32* @stderr
%33 = load i8*, i8** %15
%34 = tail call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %33)
%35 = load i32, i32* @EXIT_FAILURE
%36 = tail call i32 @exit(i32 %35)
unreachable
37: ; preds = %26
%38 = tail call i32 (...) @inotify_init()
%39 = icmp slt i32 %38, 0
br i1 %39, label %40, label %47
40: ; preds = %37
%41 = load i32, i32* @stderr
%42 = load i32, i32* @errno
%43 = tail call i8* @strerror(i32 %42)
%44 = tail call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %42, i8* %43)
%45 = load i32, i32* @EXIT_FAILURE
%46 = tail call i32 @exit(i32 %45)
unreachable
47: ; preds = %37
%48 = load i8*, i8** %15
%49 = load i32, i32* @IN_MODIFY
%50 = load i32, i32* @IN_ACCESS
%51 = or i32 %50, %49
%52 = load i32, i32* @IN_CREATE
%53 = or i32 %51, %52
%54 = load i32, i32* @IN_DELETE
%55 = or i32 %53, %54
%56 = tail call i32 @inotify_add_watch(i32 %38, i8* %48, i32 %55)
%57 = icmp slt i32 %56, 1
br i1 %57, label %61, label %58
58: ; preds = %47
%59 = call i64 @read(i32 %38, i8* %5, i32 40960)
%60 = icmp slt i64 %59, 0
br i1 %60, label %75, label %71
61: ; preds = %47
%62 = load i32, i32* @stderr
%63 = load i32, i32* @errno
%64 = tail call i8* @strerror(i32 %63)
%65 = tail call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 %63, i8* %64)
%66 = load i32, i32* @EXIT_FAILURE
%67 = tail call i32 @exit(i32 %66)
unreachable
68: ; preds = %135, %71
%69 = call i64 @read(i32 %38, i8* %5, i32 40960)
%70 = icmp slt i64 %69, 0
br i1 %70, label %75, label %71
71: ; preds = %58, %68
%72 = phi i64 [ %69, %68 ], [ %59, %58 ]
%73 = getelementptr inbounds [40960 x i8], [40960 x i8]* %3, i64 0, i64 %72
%74 = icmp eq i64 %72, 0
br i1 %74, label %68, label %82
75: ; preds = %68, %58
%76 = load i32, i32* @stderr
%77 = load i32, i32* @errno
%78 = call i8* @strerror(i32 %77)
%79 = call i32 (i32, i8*, ...) @fprintf(i32 %76, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i32 %77, i8* %78)
%80 = load i32, i32* @EXIT_FAILURE
%81 = call i32 @exit(i32 %80)
unreachable
82: ; preds = %71, %135
%83 = phi i8* [ %138, %135 ], [ %5, %71 ]
%84 = getelementptr inbounds i8, i8* %83, i64 16
%85 = bitcast i8* %84 to i64*
%86 = load i64, i64* %85
%87 = icmp eq i64 %86, 0
br i1 %87, label %135, label %88
88: ; preds = %82
%89 = bitcast i8* %83 to i32*
%90 = load i32, i32* %89
%91 = load i32, i32* @IN_CREATE
%92 = and i32 %91, %90
%93 = icmp eq i32 %92, 0
br i1 %93, label %105, label %94
94: ; preds = %88
%95 = load i32, i32* @IN_ISDIR
%96 = and i32 %95, %90
%97 = icmp eq i32 %96, 0
%98 = getelementptr inbounds i8, i8* %83, i64 8
%99 = bitcast i8* %98 to i8**
%100 = load i8*, i8** %99
br i1 %97, label %103, label %101
101: ; preds = %94
%102 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i8* %100)
br label %135
103: ; preds = %94
%104 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), i8* %100)
br label %135
105: ; preds = %88
%106 = load i32, i32* @IN_DELETE
%107 = and i32 %106, %90
%108 = icmp eq i32 %107, 0
br i1 %108, label %120, label %109
109: ; preds = %105
%110 = load i32, i32* @IN_ISDIR
%111 = and i32 %110, %90
%112 = icmp eq i32 %111, 0
%113 = getelementptr inbounds i8, i8* %83, i64 8
%114 = bitcast i8* %113 to i8**
%115 = load i8*, i8** %114
br i1 %112, label %118, label %116
116: ; preds = %109
%117 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0), i8* %115)
br label %135
118: ; preds = %109
%119 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0), i8* %115)
br label %135
120: ; preds = %105
%121 = load i32, i32* @IN_MODIFY
%122 = and i32 %121, %90
%123 = icmp eq i32 %122, 0
br i1 %123, label %135, label %124
124: ; preds = %120
%125 = load i32, i32* @IN_ISDIR
%126 = and i32 %125, %90
%127 = icmp eq i32 %126, 0
%128 = getelementptr inbounds i8, i8* %83, i64 8
%129 = bitcast i8* %128 to i8**
%130 = load i8*, i8** %129
br i1 %127, label %133, label %131
131: ; preds = %124
%132 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.10, i64 0, i64 0), i8* %130)
br label %135
133: ; preds = %124
%134 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.11, i64 0, i64 0), i8* %130)
br label %135
135: ; preds = %103, %101, %120, %133, %131, %116, %118, %82
%136 = load i64, i64* %85
%137 = add i64 %136, 24
%138 = getelementptr inbounds i8, i8* %83, i64 %137
%139 = icmp ult i8* %138, %73
br i1 %139, label %82, label %68
}