#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 */

/* Variables and functions */
int IN_CREATE;
int IN_DELETE;
int inotify_add_watch(int, char *, int);
int inotify_init();
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ read_process_inotify_fd(int);
int main(int argc, char **argv) {
  int mINotifyFd;
  int result;
  if (argc != 2) {
    printf("Usage: %s <dir>\n", argv[0]);
    return -1;
  }
  mINotifyFd = inotify_init();
  result = inotify_add_watch(mINotifyFd, argv[1], IN_DELETE | IN_CREATE);
  while (1) {
    read_process_inotify_fd(mINotifyFd);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     117e <main+0x3e>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
mov    $0xffffffff,%eax
add    $0x20,%rsp
pop    %rbp
ret
mov    $0x0,%al
call   1050 <inotify_init@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    0x2e4e(%rip),%rax
mov    (%rax),%edx
mov    0x2e35(%rip),%rax
or     (%rax),%edx
call   1060 <inotify_add_watch@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <read_process_inotify_fd@plt>
jmp    11ad <main+0x6d>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
cmp    $0x2,%edi
jne    1189 <main+0x49>
xor    %eax,%eax
call   1050 <inotify_init@plt>
mov    %eax,%ebx
mov    0x8(%r14),%rsi
mov    0x2e88(%rip),%rax
mov    0x2e71(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    %ebx,%edi
call   1060 <inotify_add_watch@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebx,%edi
call   1040 <read_process_inotify_fd@plt>
jmp    1180 <main+0x40>
mov    (%r14),%rsi
lea    0xe6d(%rip),%rdi
call   1030 <printf@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Usage: %s <dir>\0A\00"
@IN_DELETE = global i32 0
@IN_CREATE = 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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %13)
ret i32 -1
15: ; preds = %2
%16 = call i32 (...) @inotify_init()
store i32 %16, i32* %6
%17 = load i32, i32* %6
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = load i32, i32* @IN_DELETE
%22 = load i32, i32* @IN_CREATE
%23 = or i32 %21, %22
%24 = call i32 @inotify_add_watch(i32 %17, i8* %20, i32 %23)
store i32 %24, i32* %7
br label %25
25: ; preds = %15, %25
%26 = load i32, i32* %6
%27 = call i32 @read_process_inotify_fd(i32 %26)
br label %25
}

LLVM IR (-O2):
@.str = [17 x i8] c"Usage: %s <dir>\0A\00"
@IN_DELETE = global i32 0
@IN_CREATE = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %5)
ret i32 -1
7: ; preds = %2
%8 = tail call i32 (...) @inotify_init()
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = load i32, i32* @IN_DELETE
%12 = load i32, i32* @IN_CREATE
%13 = or i32 %12, %11
%14 = tail call i32 @inotify_add_watch(i32 %8, i8* %10, i32 %13)
br label %15
15: ; preds = %15, %7
%16 = tail call i32 @read_process_inotify_fd(i32 %8)
br label %15
}