#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_ALL_EVENTS;
int IN_MODIFY;
int inotify_add_watch(int, char *, int);
int inotify_init();
int /*<<< orphan*/ inotify_rm_watch(int, int);
int main() {
  int fd = inotify_init();
  int wd = inotify_add_watch(fd, "/tmp", IN_ALL_EVENTS);
  inotify_rm_watch(fd, wd);
  inotify_add_watch(-1, "/tmp", IN_MODIFY);
  inotify_add_watch(fd, (char *)-1, IN_MODIFY);
  wd = inotify_add_watch(fd, "/tmp", -1);
  inotify_rm_watch(fd, wd);
  inotify_rm_watch(-1, wd);
  inotify_rm_watch(fd, -1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <inotify_init@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2e85(%rip),%rax
mov    (%rax),%edx
lea    0xea4(%rip),%rsi
call   1040 <inotify_add_watch@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <inotify_rm_watch@plt>
mov    0x2e7a(%rip),%rax
mov    (%rax),%edx
mov    $0xffffffff,%edi
lea    0xe7c(%rip),%rsi
call   1040 <inotify_add_watch@plt>
mov    -0x8(%rbp),%edi
mov    0x2e5d(%rip),%rax
mov    (%rax),%edx
mov    $0xffffffffffffffff,%rsi
call   1040 <inotify_add_watch@plt>
mov    -0x8(%rbp),%edi
lea    0xe55(%rip),%rsi
mov    $0xffffffff,%edx
call   1040 <inotify_add_watch@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <inotify_rm_watch@plt>
mov    -0xc(%rbp),%esi
mov    $0xffffffff,%edi
call   1050 <inotify_rm_watch@plt>
mov    -0x8(%rbp),%edi
mov    $0xffffffff,%esi
call   1050 <inotify_rm_watch@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   1030 <inotify_init@plt>
mov    %eax,%ebx
mov    0x2e94(%rip),%rax
mov    (%rax),%edx
lea    0xeb3(%rip),%r14
mov    %ebx,%edi
mov    %r14,%rsi
call   1040 <inotify_add_watch@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1050 <inotify_rm_watch@plt>
mov    0x2e89(%rip),%rbp
mov    0x0(%rbp),%edx
mov    $0xffffffff,%edi
mov    %r14,%rsi
call   1040 <inotify_add_watch@plt>
mov    0x0(%rbp),%edx
mov    %ebx,%edi
mov    $0xffffffffffffffff,%rsi
call   1040 <inotify_add_watch@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0xffffffff,%edx
call   1040 <inotify_add_watch@plt>
mov    %eax,%ebp
mov    %ebx,%edi
mov    %eax,%esi
call   1050 <inotify_rm_watch@plt>
mov    $0xffffffff,%edi
mov    %ebp,%esi
call   1050 <inotify_rm_watch@plt>
mov    %ebx,%edi
mov    $0xffffffff,%esi
call   1050 <inotify_rm_watch@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"/tmp\00"
@IN_ALL_EVENTS = global i32 0
@IN_MODIFY = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (...) @inotify_init()
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = load i32, i32* @IN_ALL_EVENTS
%7 = call i32 @inotify_add_watch(i32 %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %6)
store i32 %7, i32* %3
%8 = load i32, i32* %2
%9 = load i32, i32* %3
%10 = call i32 @inotify_rm_watch(i32 %8, i32 %9)
%11 = load i32, i32* @IN_MODIFY
%12 = call i32 @inotify_add_watch(i32 -1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = load i32, i32* %2
%14 = load i32, i32* @IN_MODIFY
%15 = call i32 @inotify_add_watch(i32 %13, i8* inttoptr (i64 -1 to i8*), i32 %14)
%16 = load i32, i32* %2
%17 = call i32 @inotify_add_watch(i32 %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 -1)
store i32 %17, i32* %3
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = call i32 @inotify_rm_watch(i32 %18, i32 %19)
%21 = load i32, i32* %3
%22 = call i32 @inotify_rm_watch(i32 -1, i32 %21)
%23 = load i32, i32* %2
%24 = call i32 @inotify_rm_watch(i32 %23, i32 -1)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"/tmp\00"
@IN_ALL_EVENTS = global i32 0
@IN_MODIFY = global i32 0
define i32 @main() {
%1 = tail call i32 (...) @inotify_init()
%2 = load i32, i32* @IN_ALL_EVENTS
%3 = tail call i32 @inotify_add_watch(i32 %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = tail call i32 @inotify_rm_watch(i32 %1, i32 %3)
%5 = load i32, i32* @IN_MODIFY
%6 = tail call i32 @inotify_add_watch(i32 -1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = load i32, i32* @IN_MODIFY
%8 = tail call i32 @inotify_add_watch(i32 %1, i8* inttoptr (i64 -1 to i8*), i32 %7)
%9 = tail call i32 @inotify_add_watch(i32 %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 -1)
%10 = tail call i32 @inotify_rm_watch(i32 %1, i32 %9)
%11 = tail call i32 @inotify_rm_watch(i32 -1, i32 %9)
%12 = tail call i32 @inotify_rm_watch(i32 %1, i32 -1)
ret i32 0
}