#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 */
typedef int /*<<< orphan*/ uint32_t;

/* Variables and functions */
int ENOSPC;
int errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int inotify_add_watch(int, char const *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
int inotify_glue_watch(int fd, const char *filename, uint32_t mask) {
  int wd;
  wd = inotify_add_watch(fd, filename, mask);
  if (wd < 0) {
    int err = errno;
    perror("inotify_add_watch");
    if (err == ENOSPC)
      fprintf(stderr, "Maximum watch limit hit. "
                      "Try adjusting "
                      "/proc/sys/fs/inotify"
                      "/max_user_watches"
                      ".\n");
  }
  return wd;
}


x86 assembly (clang, -O0):
<inotify_glue_watch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1040 <inotify_add_watch@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    11a2 <inotify_glue_watch+0x72>
mov    0x2e73(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
lea    0xe8f(%rip),%rdi
call   1050 <perror@plt>
mov    -0x1c(%rbp),%eax
mov    0x2e50(%rip),%rcx
cmp    (%rcx),%eax
jne    119d <inotify_glue_watch+0x6d>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
lea    0xe7a(%rip),%rsi
call   1030 <fprintf@plt>
jmp    11a2 <inotify_glue_watch+0x72>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inotify_glue_watch>:
push   %rbp
push   %rbx
push   %rax
call   1040 <inotify_add_watch@plt>
mov    %eax,%ebx
test   %eax,%eax
js     1147 <inotify_glue_watch+0x17>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2e8a(%rip),%rax
mov    (%rax),%ebp
lea    0xea9(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e6d(%rip),%rax
cmp    (%rax),%ebp
jne    113e <inotify_glue_watch+0xe>
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
lea    0xe9b(%rip),%rsi
call   1030 <fprintf@plt>
jmp    113e <inotify_glue_watch+0xe>

LLVM IR (-O0):
@errno = global i32 0
@.str = [18 x i8] c"inotify_add_watch\00"
@ENOSPC = global i32 0
@stderr = global i32 0
@.str.1 = [79 x i8] c"Maximum watch limit hit. Try adjusting /proc/sys/fs/inotify/max_user_watches.\0A\00"
define i32 @inotify_glue_watch(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%9 = load i32, i32* %4
%10 = load i8*, i8** %5
%11 = load i32, i32* %6
%12 = call i32 @inotify_add_watch(i32 %9, i8* %10, i32 %11)
store i32 %12, i32* %7
%13 = load i32, i32* %7
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %25
15: ; preds = %3
%16 = load i32, i32* @errno
store i32 %16, i32* %8
%17 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%18 = load i32, i32* %8
%19 = load i32, i32* @ENOSPC
%20 = icmp eq i32 %18, %19
br i1 %20, label %21, label %24
21: ; preds = %15
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %21, %15
br label %25
25: ; preds = %24, %3
%26 = load i32, i32* %7
ret i32 %26
}

LLVM IR (-O2):
@errno = global i32 0
@.str = [18 x i8] c"inotify_add_watch\00"
@ENOSPC = global i32 0
@stderr = global i32 0
@.str.1 = [79 x i8] c"Maximum watch limit hit. Try adjusting /proc/sys/fs/inotify/max_user_watches.\0A\00"
define i32 @inotify_glue_watch(i32 %0, i8* %1, i32 %2) {
%4 = tail call i32 @inotify_add_watch(i32 %0, i8* %1, i32 %2)
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %14
6: ; preds = %3
%7 = load i32, i32* @errno
%8 = tail call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* @ENOSPC
%10 = icmp eq i32 %7, %9
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %6, %11, %3
ret i32 %4
}