#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 /*<<< orphan*/ AT_FDCWD;
int FAN_ACCESS;
int FAN_CLOSE;
int FAN_EVENT_ON_CHILD;
int FAN_MARK_ADD;
int FAN_MARK_MOUNT;
int FAN_MODIFY;
int FAN_ONDIR;
int FAN_OPEN;
int fanotify_mark(int, int, int, int /*<<< orphan*/, char const *);
int mark(int fan_fd, const char *pathname, int *count) {
  int ret;
  ret = fanotify_mark(fan_fd, FAN_MARK_ADD | FAN_MARK_MOUNT,
                      FAN_ACCESS | FAN_MODIFY | FAN_OPEN | FAN_CLOSE |
                          FAN_ONDIR | FAN_EVENT_ON_CHILD,
                      AT_FDCWD, pathname);
  if (ret >= 0) {
    (*count)++;
    return 0;
  }
  return -1;
}


x86 assembly (clang, -O0):
<mark>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2e83(%rip),%rax
mov    (%rax),%esi
mov    0x2ea2(%rip),%rax
or     (%rax),%esi
mov    0x2e81(%rip),%rax
mov    (%rax),%edx
mov    0x2e98(%rip),%rax
or     (%rax),%edx
mov    0x2e57(%rip),%rax
or     (%rax),%edx
mov    0x2e96(%rip),%rax
or     (%rax),%edx
mov    0x2e6d(%rip),%rax
or     (%rax),%edx
mov    0x2e5c(%rip),%rax
or     (%rax),%edx
mov    0x2e23(%rip),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%r8
call   1030 <fanotify_mark@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jl     11a4 <mark+0x94>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    11ab <mark+0x9b>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mark>:
push   %r14
push   %rbx
push   %rax
mov    0x2e95(%rip),%rcx
mov    0x2eb6(%rip),%rax
mov    (%rax),%eax
or     (%rcx),%eax
mov    0x2e93(%rip),%rcx
mov    0x2eac(%rip),%rbx
mov    (%rbx),%ebx
or     (%rcx),%ebx
mov    0x2e69(%rip),%rcx
or     (%rcx),%ebx
mov    %rdx,%r14
mov    %rsi,%r8
mov    0x2ea2(%rip),%rcx
or     (%rcx),%ebx
mov    0x2e79(%rip),%rcx
or     (%rcx),%ebx
mov    0x2e68(%rip),%rcx
or     (%rcx),%ebx
mov    0x2e2f(%rip),%rcx
mov    (%rcx),%ecx
mov    %eax,%esi
mov    %ebx,%edx
call   1030 <fanotify_mark@plt>
test   %eax,%eax
js     1180 <mark+0x70>
addl   $0x1,(%r14)
xor    %eax,%eax
jmp    1185 <mark+0x75>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@FAN_MARK_ADD = global i32 0
@FAN_MARK_MOUNT = global i32 0
@FAN_ACCESS = global i32 0
@FAN_MODIFY = global i32 0
@FAN_OPEN = global i32 0
@FAN_CLOSE = global i32 0
@FAN_ONDIR = global i32 0
@FAN_EVENT_ON_CHILD = global i32 0
@AT_FDCWD = global i32 0
define i32 @mark(i32 %0, i8* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32
store i32 %0, i32* %5
store i8* %1, i8** %6
store i32* %2, i32** %7
%9 = load i32, i32* %5
%10 = load i32, i32* @FAN_MARK_ADD
%11 = load i32, i32* @FAN_MARK_MOUNT
%12 = or i32 %10, %11
%13 = load i32, i32* @FAN_ACCESS
%14 = load i32, i32* @FAN_MODIFY
%15 = or i32 %13, %14
%16 = load i32, i32* @FAN_OPEN
%17 = or i32 %15, %16
%18 = load i32, i32* @FAN_CLOSE
%19 = or i32 %17, %18
%20 = load i32, i32* @FAN_ONDIR
%21 = or i32 %19, %20
%22 = load i32, i32* @FAN_EVENT_ON_CHILD
%23 = or i32 %21, %22
%24 = load i32, i32* @AT_FDCWD
%25 = load i8*, i8** %6
%26 = call i32 @fanotify_mark(i32 %9, i32 %12, i32 %23, i32 %24, i8* %25)
store i32 %26, i32* %8
%27 = load i32, i32* %8
%28 = icmp sge i32 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %3
%30 = load i32*, i32** %7
%31 = load i32, i32* %30
%32 = add nsw i32 %31, 1
store i32 %32, i32* %30
store i32 0, i32* %4
br label %34
33: ; preds = %3
store i32 -1, i32* %4
br label %34
34: ; preds = %33, %29
%35 = load i32, i32* %4
ret i32 %35
}

LLVM IR (-O2):
@FAN_MARK_ADD = global i32 0
@FAN_MARK_MOUNT = global i32 0
@FAN_ACCESS = global i32 0
@FAN_MODIFY = global i32 0
@FAN_OPEN = global i32 0
@FAN_CLOSE = global i32 0
@FAN_ONDIR = global i32 0
@FAN_EVENT_ON_CHILD = global i32 0
@AT_FDCWD = global i32 0
define i32 @mark(i32 %0, i8* %1, i32* nocapture %2) {
%4 = load i32, i32* @FAN_MARK_ADD
%5 = load i32, i32* @FAN_MARK_MOUNT
%6 = or i32 %5, %4
%7 = load i32, i32* @FAN_ACCESS
%8 = load i32, i32* @FAN_MODIFY
%9 = or i32 %8, %7
%10 = load i32, i32* @FAN_OPEN
%11 = or i32 %9, %10
%12 = load i32, i32* @FAN_CLOSE
%13 = or i32 %11, %12
%14 = load i32, i32* @FAN_ONDIR
%15 = or i32 %13, %14
%16 = load i32, i32* @FAN_EVENT_ON_CHILD
%17 = or i32 %15, %16
%18 = load i32, i32* @AT_FDCWD
%19 = tail call i32 @fanotify_mark(i32 %0, i32 %6, i32 %17, i32 %18, i8* %1)
%20 = icmp sgt i32 %19, -1
br i1 %20, label %21, label %24
21: ; preds = %3
%22 = load i32, i32* %2
%23 = add nsw i32 %22, 1
store i32 %23, i32* %2
br label %24
24: ; preds = %3, %21
%25 = phi i32 [ 0, %21 ], [ -1, %3 ]
ret i32 %25
}