#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 F_OK;
int R_OK;
int W_OK;
int X_OK;
int /*<<< orphan*/ strcmp(char *, char *);
int read_access_flag(char *s) {
  int flag = 0;
  if (!strcmp(s, "F_OK")) {
    flag |= F_OK;
  } else if (!strcmp(s, "R_OK")) {
    flag |= R_OK;
  } else if (!strcmp(s, "W_OK")) {
    flag |= W_OK;
  } else if (!strcmp(s, "X_OK")) {
    flag |= X_OK;
  }
  return flag;
}


x86 assembly (clang, -O0):
<read_access_flag>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xed2(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1150 <read_access_flag+0x40>
mov    0x2e7d(%rip),%rax
mov    (%rax),%eax
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11e1 <read_access_flag+0xd1>
mov    -0x8(%rbp),%rdi
lea    0xeaa(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    117d <read_access_flag+0x6d>
mov    0x2e60(%rip),%rax
mov    (%rax),%eax
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11dc <read_access_flag+0xcc>
mov    -0x8(%rbp),%rdi
lea    0xe82(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11aa <read_access_flag+0x9a>
mov    0x2e4b(%rip),%rax
mov    (%rax),%eax
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11d7 <read_access_flag+0xc7>
mov    -0x8(%rbp),%rdi
lea    0xe5a(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11d2 <read_access_flag+0xc2>
mov    0x2e16(%rip),%rax
mov    (%rax),%eax
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11d7 <read_access_flag+0xc7>
jmp    11dc <read_access_flag+0xcc>
jmp    11e1 <read_access_flag+0xd1>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_access_flag>:
push   %rbx
mov    %rdi,%rbx
lea    0xee5(%rip),%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     116a <read_access_flag+0x5a>
lea    0xeda(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1173 <read_access_flag+0x63>
lea    0xecc(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     117c <read_access_flag+0x6c>
lea    0xebe(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
jne    1185 <read_access_flag+0x75>
mov    0x2e78(%rip),%rax
jmp    1183 <read_access_flag+0x73>
mov    0x2e4f(%rip),%rax
jmp    1183 <read_access_flag+0x73>
mov    0x2e56(%rip),%rax
jmp    1183 <read_access_flag+0x73>
mov    0x2e65(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"F_OK\00"
@F_OK = global i32 0
@.str.1 = [5 x i8] c"R_OK\00"
@R_OK = global i32 0
@.str.2 = [5 x i8] c"W_OK\00"
@W_OK = global i32 0
@.str.3 = [5 x i8] c"X_OK\00"
@X_OK = global i32 0
define i32 @read_access_flag(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
%4 = load i8*, i8** %2
%5 = call i32 @strcmp(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%6 = icmp ne i32 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %1
%8 = load i32, i32* @F_OK
%9 = load i32, i32* %3
%10 = or i32 %9, %8
store i32 %10, i32* %3
br label %38
11: ; preds = %1
%12 = load i8*, i8** %2
%13 = call i32 @strcmp(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp ne i32 %13, 0
br i1 %14, label %19, label %15
15: ; preds = %11
%16 = load i32, i32* @R_OK
%17 = load i32, i32* %3
%18 = or i32 %17, %16
store i32 %18, i32* %3
br label %37
19: ; preds = %11
%20 = load i8*, i8** %2
%21 = call i32 @strcmp(i8* %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp ne i32 %21, 0
br i1 %22, label %27, label %23
23: ; preds = %19
%24 = load i32, i32* @W_OK
%25 = load i32, i32* %3
%26 = or i32 %25, %24
store i32 %26, i32* %3
br label %36
27: ; preds = %19
%28 = load i8*, i8** %2
%29 = call i32 @strcmp(i8* %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%30 = icmp ne i32 %29, 0
br i1 %30, label %35, label %31
31: ; preds = %27
%32 = load i32, i32* @X_OK
%33 = load i32, i32* %3
%34 = or i32 %33, %32
store i32 %34, i32* %3
br label %35
35: ; preds = %31, %27
br label %36
36: ; preds = %35, %23
br label %37
37: ; preds = %36, %15
br label %38
38: ; preds = %37, %7
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@.str = [5 x i8] c"F_OK\00"
@F_OK = global i32 0
@.str.1 = [5 x i8] c"R_OK\00"
@R_OK = global i32 0
@.str.2 = [5 x i8] c"W_OK\00"
@W_OK = global i32 0
@.str.3 = [5 x i8] c"X_OK\00"
@X_OK = global i32 0
define i32 @read_access_flag(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 %4, label %6
4: ; preds = %1
%5 = load i32, i32* @F_OK
br label %21
6: ; preds = %1
%7 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = load i32, i32* @R_OK
br label %21
11: ; preds = %6
%12 = 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))
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = load i32, i32* @W_OK
br label %21
16: ; preds = %11
%17 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%18 = icmp eq i32 %17, 0
%19 = load i32, i32* @X_OK
%20 = select i1 %18, i32 %19, i32 0
br label %21
21: ; preds = %16, %9, %14, %4
%22 = phi i32 [ %15, %14 ], [ %10, %9 ], [ %5, %4 ], [ %20, %16 ]
ret i32 %22
}