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

/* Variables and functions */
int FAN_ACCESS;
int FAN_CLOSE_NOWRITE;
int FAN_CLOSE_WRITE;
int FAN_MODIFY;
int FAN_OPEN;
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
const char *mask2str(uint64_t mask) {
  static char buffer[10];
  int offset = 0;
  memset(buffer, 0, sizeof(buffer));
  if (mask & FAN_ACCESS)
    buffer[offset++] = 'R';
  if (mask & FAN_CLOSE_WRITE || mask & FAN_CLOSE_NOWRITE)
    buffer[offset++] = 'C';
  if (mask & FAN_MODIFY || mask & FAN_CLOSE_WRITE)
    buffer[offset++] = 'W';
  if (mask & FAN_OPEN)
    buffer[offset++] = 'O';
  return buffer;
}


x86 assembly (clang, -O0):
<mask2str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0x2f03(%rip),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1030 <memset@plt>
mov    -0x4(%rbp),%eax
mov    0x2e99(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1163 <mask2str+0x53>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x8(%rbp)
movslq %eax,%rcx
lea    0x2ecd(%rip),%rax
movb   $0x52,(%rax,%rcx,1)
mov    -0x4(%rbp),%eax
mov    0x2e73(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    118d <mask2str+0x7d>
mov    -0x4(%rbp),%eax
mov    0x2e4e(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11a6 <mask2str+0x96>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x8(%rbp)
movslq %eax,%rcx
lea    0x2e8a(%rip),%rax
movb   $0x43,(%rax,%rcx,1)
mov    -0x4(%rbp),%eax
mov    0x2e38(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    11d0 <mask2str+0xc0>
mov    -0x4(%rbp),%eax
mov    0x2e1b(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11e9 <mask2str+0xd9>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x8(%rbp)
movslq %eax,%rcx
lea    0x2e47(%rip),%rax
movb   $0x57,(%rax,%rcx,1)
mov    -0x4(%rbp),%eax
mov    0x2dcd(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1217 <mask2str+0x107>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x8(%rbp)
movslq %eax,%rcx
lea    0x2e19(%rip),%rax
movb   $0x4f,(%rax,%rcx,1)
lea    0x2e0e(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mask2str>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebp
lea    0x2f0f(%rip),%r14
xor    %ebx,%ebx
mov    %r14,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1030 <memset@plt>
mov    0x2ea3(%rip),%rax
test   %ebp,(%rax)
je     1145 <mask2str+0x35>
movb   $0x52,0x2eec(%rip)
mov    $0x1,%ebx
mov    0x2e94(%rip),%rax
test   %ebp,(%rax)
je     115c <mask2str+0x4c>
mov    %ebx,%eax
add    $0x1,%ebx
movb   $0x43,(%rax,%r14,1)
jmp    117c <mask2str+0x6c>
mov    0x2e6d(%rip),%rax
test   %ebp,(%rax)
je     1171 <mask2str+0x61>
mov    %ebx,%eax
add    $0x1,%ebx
movb   $0x43,(%rax,%r14,1)
mov    0x2e70(%rip),%rax
test   %ebp,(%rax)
je     1186 <mask2str+0x76>
mov    %ebx,%eax
add    $0x1,%ebx
movb   $0x57,(%rax,%r14,1)
mov    0x2e33(%rip),%rax
test   %ebp,(%rax)
je     1198 <mask2str+0x88>
mov    %ebx,%eax
movb   $0x4f,(%rax,%r14,1)
lea    0x2e8d(%rip),%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@mask2str.buffer = internal global [10 x i8] zeroinitializer
@FAN_ACCESS = global i32 0
@FAN_CLOSE_WRITE = global i32 0
@FAN_CLOSE_NOWRITE = global i32 0
@FAN_MODIFY = global i32 0
@FAN_OPEN = global i32 0
define i8* @mask2str(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
%4 = call i32 @memset(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @mask2str.buffer, i64 0, i64 0), i32 0, i32 10)
%5 = load i32, i32* %2
%6 = load i32, i32* @FAN_ACCESS
%7 = and i32 %5, %6
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %1
%10 = load i32, i32* %3
%11 = add nsw i32 %10, 1
store i32 %11, i32* %3
%12 = sext i32 %10 to i64
%13 = getelementptr inbounds [10 x i8], [10 x i8]* @mask2str.buffer, i64 0, i64 %12
store i8 82, i8* %13
br label %14
14: ; preds = %9, %1
%15 = load i32, i32* %2
%16 = load i32, i32* @FAN_CLOSE_WRITE
%17 = and i32 %15, %16
%18 = icmp ne i32 %17, 0
br i1 %18, label %24, label %19
19: ; preds = %14
%20 = load i32, i32* %2
%21 = load i32, i32* @FAN_CLOSE_NOWRITE
%22 = and i32 %20, %21
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %29
24: ; preds = %19, %14
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
%27 = sext i32 %25 to i64
%28 = getelementptr inbounds [10 x i8], [10 x i8]* @mask2str.buffer, i64 0, i64 %27
store i8 67, i8* %28
br label %29
29: ; preds = %24, %19
%30 = load i32, i32* %2
%31 = load i32, i32* @FAN_MODIFY
%32 = and i32 %30, %31
%33 = icmp ne i32 %32, 0
br i1 %33, label %39, label %34
34: ; preds = %29
%35 = load i32, i32* %2
%36 = load i32, i32* @FAN_CLOSE_WRITE
%37 = and i32 %35, %36
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %44
39: ; preds = %34, %29
%40 = load i32, i32* %3
%41 = add nsw i32 %40, 1
store i32 %41, i32* %3
%42 = sext i32 %40 to i64
%43 = getelementptr inbounds [10 x i8], [10 x i8]* @mask2str.buffer, i64 0, i64 %42
store i8 87, i8* %43
br label %44
44: ; preds = %39, %34
%45 = load i32, i32* %2
%46 = load i32, i32* @FAN_OPEN
%47 = and i32 %45, %46
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %54
49: ; preds = %44
%50 = load i32, i32* %3
%51 = add nsw i32 %50, 1
store i32 %51, i32* %3
%52 = sext i32 %50 to i64
%53 = getelementptr inbounds [10 x i8], [10 x i8]* @mask2str.buffer, i64 0, i64 %52
store i8 79, i8* %53
br label %54
54: ; preds = %49, %44
ret i8* getelementptr inbounds ([10 x i8], [10 x i8]* @mask2str.buffer, i64 0, i64 0)
}

LLVM IR (-O2):
@mask2str.buffer = internal global [10 x i8] zeroinitializer
@FAN_ACCESS = global i32 0
@FAN_CLOSE_WRITE = global i32 0
@FAN_CLOSE_NOWRITE = global i32 0
@FAN_MODIFY = global i32 0
@FAN_OPEN = global i32 0
define i8* @mask2str(i32 %0) {
%2 = tail call i32 @memset(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @mask2str.buffer, i64 0, i64 0), i32 0, i32 10)
%3 = load i32, i32* @FAN_ACCESS
%4 = and i32 %3, %0
%5 = icmp eq i32 %4, 0
br i1 %5, label %7, label %6
6: ; preds = %1
store i8 82, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @mask2str.buffer, i64 0, i64 0)
br label %7
7: ; preds = %6, %1
%8 = phi i32 [ 1, %6 ], [ 0, %1 ]
%9 = load i32, i32* @FAN_CLOSE_WRITE
%10 = and i32 %9, %0
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %23
12: ; preds = %7
%13 = load i32, i32* @FAN_CLOSE_NOWRITE
%14 = and i32 %13, %0
%15 = icmp eq i32 %14, 0
br i1 %15, label %27, label %16
16: ; preds = %12
%17 = add nuw nsw i32 %8, 1
%18 = zext i32 %8 to i64
%19 = getelementptr inbounds [10 x i8], [10 x i8]* @mask2str.buffer, i64 0, i64 %18
store i8 67, i8* %19
%20 = load i32, i32* @FAN_MODIFY
%21 = and i32 %20, %0
%22 = icmp eq i32 %21, 0
br i1 %22, label %36, label %31
23: ; preds = %7
%24 = add nuw nsw i32 %8, 1
%25 = zext i32 %8 to i64
%26 = getelementptr inbounds [10 x i8], [10 x i8]* @mask2str.buffer, i64 0, i64 %25
store i8 67, i8* %26
br label %31
27: ; preds = %12
%28 = load i32, i32* @FAN_MODIFY
%29 = and i32 %28, %0
%30 = icmp eq i32 %29, 0
br i1 %30, label %36, label %31
31: ; preds = %23, %27, %16
%32 = phi i32 [ %8, %27 ], [ %17, %16 ], [ %24, %23 ]
%33 = add nuw nsw i32 %32, 1
%34 = zext i32 %32 to i64
%35 = getelementptr inbounds [10 x i8], [10 x i8]* @mask2str.buffer, i64 0, i64 %34
store i8 87, i8* %35
br label %36
36: ; preds = %16, %27, %31
%37 = phi i32 [ %33, %31 ], [ %8, %27 ], [ %17, %16 ]
%38 = load i32, i32* @FAN_OPEN
%39 = and i32 %38, %0
%40 = icmp eq i32 %39, 0
br i1 %40, label %44, label %41
41: ; preds = %36
%42 = zext i32 %37 to i64
%43 = getelementptr inbounds [10 x i8], [10 x i8]* @mask2str.buffer, i64 0, i64 %42
store i8 79, i8* %43
br label %44
44: ; preds = %41, %36
ret i8* getelementptr inbounds ([10 x i8], [10 x i8]* @mask2str.buffer, i64 0, i64 0)
}