#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 chirp_acl_from_access_flags(int flags) {
  int acl = 0;
  if (flags & R_OK)
    acl |= (1 << 0);
  if (flags & W_OK)
    acl |= (1 << 1);
  if (flags & X_OK)
    acl |= (1 << 5);
  if (flags & F_OK)
    acl |= (1 << 0);
  if (acl == 0)
    acl |= (1 << 0);
  return acl;
}


x86 assembly (clang, -O0):
<chirp_acl_from_access_flags>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2eb8(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     112c <chirp_acl_from_access_flags+0x2c>
mov    -0x8(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2eb2(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     114a <chirp_acl_from_access_flags+0x4a>
mov    -0x8(%rbp),%eax
or     $0x2,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2e8c(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1168 <chirp_acl_from_access_flags+0x68>
mov    -0x8(%rbp),%eax
or     $0x20,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2e4e(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1186 <chirp_acl_from_access_flags+0x86>
mov    -0x8(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1199 <chirp_acl_from_access_flags+0x99>
mov    -0x8(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<chirp_acl_from_access_flags>:
mov    0x2ec9(%rip),%rax
xor    %ecx,%ecx
test   %edi,(%rax)
setne  %cl
mov    0x2ed3(%rip),%rax
lea    0x2(%rcx),%edx
test   %edi,(%rax)
cmove  %ecx,%edx
mov    0x2ebc(%rip),%rax
test   %edi,(%rax)
lea    0x20(%rdx),%eax
cmove  %edx,%eax
mov    0x2e8d(%rip),%rcx
xor    %edx,%edx
test   %edi,(%rcx)
setne  %dl
or     %eax,%edx
mov    $0x1,%eax
cmovne %edx,%eax
ret

LLVM IR (-O0):
@R_OK = global i32 0
@W_OK = global i32 0
@X_OK = global i32 0
@F_OK = global i32 0
define i32 @chirp_acl_from_access_flags(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
%4 = load i32, i32* %2
%5 = load i32, i32* @R_OK
%6 = and i32 %4, %5
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load i32, i32* %3
%10 = or i32 %9, 1
store i32 %10, i32* %3
br label %11
11: ; preds = %8, %1
%12 = load i32, i32* %2
%13 = load i32, i32* @W_OK
%14 = and i32 %12, %13
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = load i32, i32* %3
%18 = or i32 %17, 2
store i32 %18, i32* %3
br label %19
19: ; preds = %16, %11
%20 = load i32, i32* %2
%21 = load i32, i32* @X_OK
%22 = and i32 %20, %21
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %19
%25 = load i32, i32* %3
%26 = or i32 %25, 32
store i32 %26, i32* %3
br label %27
27: ; preds = %24, %19
%28 = load i32, i32* %2
%29 = load i32, i32* @F_OK
%30 = and i32 %28, %29
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %27
%33 = load i32, i32* %3
%34 = or i32 %33, 1
store i32 %34, i32* %3
br label %35
35: ; preds = %32, %27
%36 = load i32, i32* %3
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %35
%39 = load i32, i32* %3
%40 = or i32 %39, 1
store i32 %40, i32* %3
br label %41
41: ; preds = %38, %35
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
@R_OK = global i32 0
@W_OK = global i32 0
@X_OK = global i32 0
@F_OK = global i32 0
define i32 @chirp_acl_from_access_flags(i32 %0) {
%2 = load i32, i32* @R_OK
%3 = and i32 %2, %0
%4 = icmp ne i32 %3, 0
%5 = zext i1 %4 to i32
%6 = load i32, i32* @W_OK
%7 = and i32 %6, %0
%8 = icmp eq i32 %7, 0
%9 = or i32 %5, 2
%10 = select i1 %8, i32 %5, i32 %9
%11 = load i32, i32* @X_OK
%12 = and i32 %11, %0
%13 = icmp eq i32 %12, 0
%14 = or i32 %10, 32
%15 = select i1 %13, i32 %10, i32 %14
%16 = load i32, i32* @F_OK
%17 = and i32 %16, %0
%18 = icmp ne i32 %17, 0
%19 = zext i1 %18 to i32
%20 = or i32 %15, %19
%21 = icmp eq i32 %20, 0
%22 = select i1 %21, i32 1, i32 %20
ret i32 %22
}