#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 uint32_t;

/* Variables and functions */
int /*<<< orphan*/ strcmp(char *, char *);
uint32_t ace_mask_value(char *mask) {
  uint32_t maskval = 0;
  char cur;
  if (!strcmp(mask, "FULL"))
    return 0x001f01ff;
  if (!strcmp(mask, "CHANGE"))
    return 0x001301bf;
  if (!strcmp(mask, "READ"))
    return 0x001200a9;
  while ((cur = *mask++)) {
    switch (cur) {
    case 'R':
      maskval |= 0x001200a9;
      break;
    case 'W':
      maskval |= 0x00000116;
      break;
    case 'X':
      maskval |= 0x00000020;
      break;
    case 'D':
      maskval |= 0x00010000;
      break;
    case 'P':
      maskval |= 0x00040000;
      break;
    case 'O':
      maskval |= 0x00080000;
      break;
    default:
      return 0;
    }
  }
  return maskval;
}


x86 assembly (clang, -O0):
<ace_mask_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xf26(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1148 <ace_mask_value+0x38>
movl   $0x1f01ff,-0x4(%rbp)
jmp    1252 <ace_mask_value+0x142>
mov    -0x10(%rbp),%rdi
lea    0xf06(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    116d <ace_mask_value+0x5d>
movl   $0x1301bf,-0x4(%rbp)
jmp    1252 <ace_mask_value+0x142>
mov    -0x10(%rbp),%rdi
lea    0xee8(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1192 <ace_mask_value+0x82>
movl   $0x1200a9,-0x4(%rbp)
jmp    1252 <ace_mask_value+0x142>
jmp    1197 <ace_mask_value+0x87>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%al
mov    %al,-0x15(%rbp)
cmp    $0x0,%al
je     124c <ace_mask_value+0x13c>
movsbl -0x15(%rbp),%eax
add    $0xffffffbc,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x14,%eax
ja     123b <ace_mask_value+0x12b>
mov    -0x20(%rbp),%rax
lea    0xe2c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x14(%rbp),%eax
or     $0x1200a9,%eax
mov    %eax,-0x14(%rbp)
jmp    1247 <ace_mask_value+0x137>
mov    -0x14(%rbp),%eax
or     $0x116,%eax
mov    %eax,-0x14(%rbp)
jmp    1247 <ace_mask_value+0x137>
mov    -0x14(%rbp),%eax
or     $0x20,%eax
mov    %eax,-0x14(%rbp)
jmp    1247 <ace_mask_value+0x137>
mov    -0x14(%rbp),%eax
or     $0x10000,%eax
mov    %eax,-0x14(%rbp)
jmp    1247 <ace_mask_value+0x137>
mov    -0x14(%rbp),%eax
or     $0x40000,%eax
mov    %eax,-0x14(%rbp)
jmp    1247 <ace_mask_value+0x137>
mov    -0x14(%rbp),%eax
or     $0x80000,%eax
mov    %eax,-0x14(%rbp)
jmp    1247 <ace_mask_value+0x137>
movl   $0x0,-0x4(%rbp)
jmp    1252 <ace_mask_value+0x142>
jmp    1197 <ace_mask_value+0x87>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ace_mask_value>:
push   %rbx
mov    %rdi,%rbx
lea    0xf39(%rip),%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11b6 <ace_mask_value+0xa6>
lea    0xf2a(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11bd <ace_mask_value+0xad>
lea    0xf1a(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11c4 <ace_mask_value+0xb4>
mov    (%rbx),%cl
test   %cl,%cl
je     11cb <ace_mask_value+0xbb>
add    $0x1,%rbx
lea    0xe9d(%rip),%rsi
xor    %edx,%edx
jmp    117f <ace_mask_value+0x6f>
mov    $0x80000,%ecx
nopl   0x0(%rax)
or     %ecx,%edx
movzbl (%rbx),%ecx
add    $0x1,%rbx
mov    %edx,%eax
test   %cl,%cl
je     11c9 <ace_mask_value+0xb9>
movsbl %cl,%eax
add    $0xffffffbc,%eax
cmp    $0x14,%eax
ja     11cb <ace_mask_value+0xbb>
mov    $0x1200a9,%ecx
movslq (%rsi,%rax,4),%rdi
add    %rsi,%rdi
xor    %eax,%eax
jmp    *%rdi
mov    $0x10000,%ecx
jmp    1170 <ace_mask_value+0x60>
mov    $0x40000,%ecx
jmp    1170 <ace_mask_value+0x60>
mov    $0x116,%ecx
jmp    1170 <ace_mask_value+0x60>
mov    $0x20,%ecx
jmp    1170 <ace_mask_value+0x60>
mov    $0x1f01ff,%eax
pop    %rbx
ret
mov    $0x1301bf,%eax
pop    %rbx
ret
mov    $0x1200a9,%eax
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"FULL\00"
@.str.1 = [7 x i8] c"CHANGE\00"
@.str.2 = [5 x i8] c"READ\00"
define i32 @ace_mask_value(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8
store i8* %0, i8** %3
store i32 0, i32* %4
%6 = load i8*, i8** %3
%7 = call i32 @strcmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%8 = icmp ne i32 %7, 0
br i1 %8, label %10, label %9
9: ; preds = %1
store i32 2032127, i32* %2
br label %51
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = call i32 @strcmp(i8* %11, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp ne i32 %12, 0
br i1 %13, label %15, label %14
14: ; preds = %10
store i32 1245631, i32* %2
br label %51
15: ; preds = %10
%16 = load i8*, i8** %3
%17 = call i32 @strcmp(i8* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp ne i32 %17, 0
br i1 %18, label %20, label %19
19: ; preds = %15
store i32 1179817, i32* %2
br label %51
20: ; preds = %15
br label %21
21: ; preds = %48, %20
%22 = load i8*, i8** %3
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %3
%24 = load i8, i8* %22
store i8 %24, i8* %5
%25 = icmp ne i8 %24, 0
br i1 %25, label %26, label %49
26: ; preds = %21
%27 = load i8, i8* %5
%28 = sext i8 %27 to i32
switch i32 %28, label %47 [
i32 82, label %29
i32 87, label %32
i32 88, label %35
i32 68, label %38
i32 80, label %41
i32 79, label %44
]
29: ; preds = %26
%30 = load i32, i32* %4
%31 = or i32 %30, 1179817
store i32 %31, i32* %4
br label %48
32: ; preds = %26
%33 = load i32, i32* %4
%34 = or i32 %33, 278
store i32 %34, i32* %4
br label %48
35: ; preds = %26
%36 = load i32, i32* %4
%37 = or i32 %36, 32
store i32 %37, i32* %4
br label %48
38: ; preds = %26
%39 = load i32, i32* %4
%40 = or i32 %39, 65536
store i32 %40, i32* %4
br label %48
41: ; preds = %26
%42 = load i32, i32* %4
%43 = or i32 %42, 262144
store i32 %43, i32* %4
br label %48
44: ; preds = %26
%45 = load i32, i32* %4
%46 = or i32 %45, 524288
store i32 %46, i32* %4
br label %48
47: ; preds = %26
store i32 0, i32* %2
br label %51
48: ; preds = %44, %41, %38, %35, %32, %29
br label %21
49: ; preds = %21
%50 = load i32, i32* %4
store i32 %50, i32* %2
br label %51
51: ; preds = %49, %47, %19, %14, %9
%52 = load i32, i32* %2
ret i32 %52
}

LLVM IR (-O2):
@.str = [5 x i8] c"FULL\00"
@.str.1 = [7 x i8] c"CHANGE\00"
@.str.2 = [5 x i8] c"READ\00"
define i32 @ace_mask_value(i8* nocapture %0) {
%2 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32 %2, 0
br i1 %3, label %29, label %4
4: ; preds = %1
%5 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32 %5, 0
br i1 %6, label %29, label %7
7: ; preds = %4
%8 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
br i1 %9, label %29, label %10
10: ; preds = %7
%11 = load i8, i8* %0
%12 = icmp eq i8 %11, 0
br i1 %12, label %29, label %13
13: ; preds = %10, %24
%14 = phi i8 [ %27, %24 ], [ %11, %10 ]
%15 = phi i8* [ %17, %24 ], [ %0, %10 ]
%16 = phi i32 [ %26, %24 ], [ 0, %10 ]
%17 = getelementptr inbounds i8, i8* %15, i64 1
%18 = sext i8 %14 to i32
switch i32 %18, label %29 [
i32 82, label %24
i32 87, label %19
i32 88, label %20
i32 68, label %21
i32 80, label %22
i32 79, label %23
]
19: ; preds = %13
br label %24
20: ; preds = %13
br label %24
21: ; preds = %13
br label %24
22: ; preds = %13
br label %24
23: ; preds = %13
br label %24
24: ; preds = %13, %23, %22, %21, %20, %19
%25 = phi i32 [ 524288, %23 ], [ 262144, %22 ], [ 65536, %21 ], [ 32, %20 ], [ 278, %19 ], [ 1179817, %13 ]
%26 = or i32 %16, %25
%27 = load i8, i8* %17
%28 = icmp eq i8 %27, 0
br i1 %28, label %29, label %13
29: ; preds = %13, %24, %10, %7, %4, %1
%30 = phi i32 [ 2032127, %1 ], [ 1245631, %4 ], [ 1179817, %7 ], [ 0, %10 ], [ 0, %13 ], [ %26, %24 ]
ret i32 %30
}