#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_ATTRIB;
int IN_CREATE;
int IN_DELETE;
int IN_DELETE_SELF;
int IN_MODIFY;
int IN_MOVED_FROM;
int IN_MOVED_TO;
int IN_MOVE_SELF;
int IN_UNMOUNT;
int /*<<< orphan*/ LOG_DEBUG;
int /*<<< orphan*/ check_root_removal(char const *);
int /*<<< orphan*/ output(char *);
int /*<<< orphan*/ report_event(char *, char const *);
int /*<<< orphan*/ userlog(int /*<<< orphan*/, char *);
void inotify_callback(const char *path, int event) {
  if (event & (IN_CREATE | IN_MOVED_TO)) {
    report_event("CREATE", path);
    report_event("CHANGE", path);
  } else if (event & IN_MODIFY) {
    report_event("CHANGE", path);
  } else if (event & IN_ATTRIB) {
    report_event("STATS", path);
  } else if (event & (IN_DELETE | IN_MOVED_FROM)) {
    report_event("DELETE", path);
  }
  if (event & (IN_DELETE_SELF | IN_MOVE_SELF)) {
    check_root_removal(path);
  } else if (event & IN_UNMOUNT) {
    output("RESET\n");
    userlog(LOG_DEBUG, "RESET");
  }
}


x86 assembly (clang, -O0):
<inotify_callback>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    0x2e4f(%rip),%rcx
mov    (%rcx),%ecx
mov    0x2e5e(%rip),%rdx
or     (%rdx),%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1194 <inotify_callback+0x54>
mov    -0x8(%rbp),%rsi
lea    0xe86(%rip),%rdi
call   1040 <report_event@plt>
mov    -0x8(%rbp),%rsi
lea    0xe7d(%rip),%rdi
call   1040 <report_event@plt>
jmp    1227 <inotify_callback+0xe7>
mov    -0xc(%rbp),%eax
mov    0x2e52(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11be <inotify_callback+0x7e>
mov    -0x8(%rbp),%rsi
lea    0xe53(%rip),%rdi
call   1040 <report_event@plt>
jmp    1222 <inotify_callback+0xe2>
mov    -0xc(%rbp),%eax
mov    0x2e18(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11e8 <inotify_callback+0xa8>
mov    -0x8(%rbp),%rsi
lea    0xe30(%rip),%rdi
call   1040 <report_event@plt>
jmp    121d <inotify_callback+0xdd>
mov    -0xc(%rbp),%eax
mov    0x2de6(%rip),%rcx
mov    (%rcx),%ecx
mov    0x2dbd(%rip),%rdx
or     (%rdx),%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1218 <inotify_callback+0xd8>
mov    -0x8(%rbp),%rsi
lea    0xe01(%rip),%rdi
call   1040 <report_event@plt>
jmp    121d <inotify_callback+0xdd>
jmp    1222 <inotify_callback+0xe2>
jmp    1227 <inotify_callback+0xe7>
mov    -0xc(%rbp),%eax
mov    0x2d5f(%rip),%rcx
mov    (%rcx),%ecx
mov    0x2d76(%rip),%rdx
or     (%rdx),%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1255 <inotify_callback+0x115>
mov    -0x8(%rbp),%rdi
call   1060 <check_root_removal@plt>
jmp    1290 <inotify_callback+0x150>
mov    -0xc(%rbp),%eax
mov    0x2d71(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     128b <inotify_callback+0x14b>
lea    0xdaa(%rip),%rdi
call   1030 <output@plt>
mov    0x2d23(%rip),%rax
mov    (%rax),%edi
lea    0xd9c(%rip),%rsi
call   1050 <userlog@plt>
jmp    1290 <inotify_callback+0x150>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inotify_callback>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r14
mov    0x2e58(%rip),%rax
mov    0x2e69(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
test   %esi,%ecx
je     1177 <inotify_callback+0x37>
lea    0xe9a(%rip),%rdi
mov    %r14,%rsi
call   1040 <report_event@plt>
lea    0xe92(%rip),%rdi
jmp    11bc <inotify_callback+0x7c>
mov    0x2e72(%rip),%rax
test   %ebx,(%rax)
je     118b <inotify_callback+0x4b>
lea    0xe7e(%rip),%rdi
jmp    11bc <inotify_callback+0x7c>
mov    0x2e4e(%rip),%rax
test   %ebx,(%rax)
je     119f <inotify_callback+0x5f>
lea    0xe71(%rip),%rdi
jmp    11bc <inotify_callback+0x7c>
mov    0x2e32(%rip),%rax
mov    0x2e0b(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
test   %ebx,%ecx
je     11c4 <inotify_callback+0x84>
lea    0xe58(%rip),%rdi
mov    %r14,%rsi
call   1040 <report_event@plt>
mov    0x2dc5(%rip),%rax
mov    0x2dde(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
test   %ebx,%ecx
je     11e9 <inotify_callback+0xa9>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <check_root_removal@plt>
mov    0x2de0(%rip),%rax
test   %ebx,(%rax)
je     121c <inotify_callback+0xdc>
lea    0xe20(%rip),%rdi
call   1030 <output@plt>
mov    0x2d99(%rip),%rax
mov    (%rax),%edi
lea    0xe12(%rip),%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <userlog@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@IN_CREATE = global i32 0
@IN_MOVED_TO = global i32 0
@.str = [7 x i8] c"CREATE\00"
@.str.1 = [7 x i8] c"CHANGE\00"
@IN_MODIFY = global i32 0
@IN_ATTRIB = global i32 0
@.str.2 = [6 x i8] c"STATS\00"
@IN_DELETE = global i32 0
@IN_MOVED_FROM = global i32 0
@.str.3 = [7 x i8] c"DELETE\00"
@IN_DELETE_SELF = global i32 0
@IN_MOVE_SELF = global i32 0
@IN_UNMOUNT = global i32 0
@.str.4 = [7 x i8] c"RESET\0A\00"
@LOG_DEBUG = global i32 0
@.str.5 = [6 x i8] c"RESET\00"
define void @inotify_callback(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = load i32, i32* @IN_CREATE
%7 = load i32, i32* @IN_MOVED_TO
%8 = or i32 %6, %7
%9 = and i32 %5, %8
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8*, i8** %3
%13 = call i32 @report_event(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = load i8*, i8** %3
%15 = call i32 @report_event(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %14)
br label %45
16: ; preds = %2
%17 = load i32, i32* %4
%18 = load i32, i32* @IN_MODIFY
%19 = and i32 %17, %18
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %16
%22 = load i8*, i8** %3
%23 = call i32 @report_event(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %22)
br label %44
24: ; preds = %16
%25 = load i32, i32* %4
%26 = load i32, i32* @IN_ATTRIB
%27 = and i32 %25, %26
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %24
%30 = load i8*, i8** %3
%31 = call i32 @report_event(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %30)
br label %43
32: ; preds = %24
%33 = load i32, i32* %4
%34 = load i32, i32* @IN_DELETE
%35 = load i32, i32* @IN_MOVED_FROM
%36 = or i32 %34, %35
%37 = and i32 %33, %36
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %32
%40 = load i8*, i8** %3
%41 = call i32 @report_event(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %40)
br label %42
42: ; preds = %39, %32
br label %43
43: ; preds = %42, %29
br label %44
44: ; preds = %43, %21
br label %45
45: ; preds = %44, %11
%46 = load i32, i32* %4
%47 = load i32, i32* @IN_DELETE_SELF
%48 = load i32, i32* @IN_MOVE_SELF
%49 = or i32 %47, %48
%50 = and i32 %46, %49
%51 = icmp ne i32 %50, 0
br i1 %51, label %52, label %55
52: ; preds = %45
%53 = load i8*, i8** %3
%54 = call i32 @check_root_removal(i8* %53)
br label %65
55: ; preds = %45
%56 = load i32, i32* %4
%57 = load i32, i32* @IN_UNMOUNT
%58 = and i32 %56, %57
%59 = icmp ne i32 %58, 0
br i1 %59, label %60, label %64
60: ; preds = %55
%61 = call i32 @output(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%62 = load i32, i32* @LOG_DEBUG
%63 = call i32 @userlog(i32 %62, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
br label %64
64: ; preds = %60, %55
br label %65
65: ; preds = %64, %52
ret void
}

LLVM IR (-O2):
@IN_CREATE = global i32 0
@IN_MOVED_TO = global i32 0
@.str = [7 x i8] c"CREATE\00"
@.str.1 = [7 x i8] c"CHANGE\00"
@IN_MODIFY = global i32 0
@IN_ATTRIB = global i32 0
@.str.2 = [6 x i8] c"STATS\00"
@IN_DELETE = global i32 0
@IN_MOVED_FROM = global i32 0
@.str.3 = [7 x i8] c"DELETE\00"
@IN_DELETE_SELF = global i32 0
@IN_MOVE_SELF = global i32 0
@IN_UNMOUNT = global i32 0
@.str.4 = [7 x i8] c"RESET\0A\00"
@LOG_DEBUG = global i32 0
@.str.5 = [6 x i8] c"RESET\00"
define void @inotify_callback(i8* %0, i32 %1) {
%3 = load i32, i32* @IN_CREATE
%4 = load i32, i32* @IN_MOVED_TO
%5 = or i32 %4, %3
%6 = and i32 %5, %1
%7 = icmp eq i32 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = tail call i32 @report_event(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %24
10: ; preds = %2
%11 = load i32, i32* @IN_MODIFY
%12 = and i32 %11, %1
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %24
14: ; preds = %10
%15 = load i32, i32* @IN_ATTRIB
%16 = and i32 %15, %1
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %14
%19 = load i32, i32* @IN_DELETE
%20 = load i32, i32* @IN_MOVED_FROM
%21 = or i32 %20, %19
%22 = and i32 %21, %1
%23 = icmp eq i32 %22, 0
br i1 %23, label %27, label %24
24: ; preds = %18, %14, %10, %8
%25 = phi i8* [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), %8 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), %10 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), %14 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), %18 ]
%26 = tail call i32 @report_event(i8* %25, i8* %0)
br label %27
27: ; preds = %24, %18
%28 = load i32, i32* @IN_DELETE_SELF
%29 = load i32, i32* @IN_MOVE_SELF
%30 = or i32 %29, %28
%31 = and i32 %30, %1
%32 = icmp eq i32 %31, 0
br i1 %32, label %35, label %33
33: ; preds = %27
%34 = tail call i32 @check_root_removal(i8* %0)
br label %43
35: ; preds = %27
%36 = load i32, i32* @IN_UNMOUNT
%37 = and i32 %36, %1
%38 = icmp eq i32 %37, 0
br i1 %38, label %43, label %39
39: ; preds = %35
%40 = tail call i32 @output(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%41 = load i32, i32* @LOG_DEBUG
%42 = tail call i32 @userlog(i32 %41, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
br label %43
43: ; preds = %35, %39, %33
ret void
}