#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 /*<<< orphan*/ EINVAL;
int /*<<< orphan*/ ENOSYS;
int F_OK;
int R_OK;
int W_OK;
int X_OK;
int /*<<< orphan*/ __set_errno(int /*<<< orphan*/);
int __access(const char *file, int type) {
  if (file == NULL || (type & ~(R_OK | W_OK | X_OK | F_OK)) != 0) {
    __set_errno(EINVAL);
    return -1;
  }
  __set_errno(ENOSYS);
  return -1;
}


x86 assembly (clang, -O0):
<__access>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     115f <__access+0x4f>
mov    -0x14(%rbp),%eax
mov    0x2e8c(%rip),%rcx
mov    (%rcx),%ecx
mov    0x2ea3(%rip),%rdx
or     (%rdx),%ecx
mov    0x2e92(%rip),%rdx
or     (%rdx),%ecx
mov    0x2e61(%rip),%rdx
or     (%rdx),%ecx
xor    $0xffffffff,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1179 <__access+0x69>
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    118e <__access+0x7e>
mov    0x2e68(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__access>:
push   %rax
test   %rdi,%rdi
je     1149 <__access+0x39>
mov    0x2ea3(%rip),%rax
mov    0x2ebc(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2ea9(%rip),%rax
or     (%rax),%ecx
mov    0x2e78(%rip),%rax
or     (%rax),%ecx
not    %ecx
test   %esi,%ecx
jne    1149 <__access+0x39>
mov    0x2ea1(%rip),%rax
jmp    1150 <__access+0x40>
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
@R_OK = global i32 0
@W_OK = global i32 0
@X_OK = global i32 0
@F_OK = global i32 0
@EINVAL = global i32 0
@ENOSYS = global i32 0
define i32 @__access(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%6 = load i8*, i8** %4
%7 = icmp eq i8* %6, null
br i1 %7, label %20, label %8
8: ; preds = %2
%9 = load i32, i32* %5
%10 = load i32, i32* @R_OK
%11 = load i32, i32* @W_OK
%12 = or i32 %10, %11
%13 = load i32, i32* @X_OK
%14 = or i32 %12, %13
%15 = load i32, i32* @F_OK
%16 = or i32 %14, %15
%17 = xor i32 %16, -1
%18 = and i32 %9, %17
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %8, %2
%21 = load i32, i32* @EINVAL
%22 = call i32 @__set_errno(i32 %21)
store i32 -1, i32* %3
br label %26
23: ; preds = %8
%24 = load i32, i32* @ENOSYS
%25 = call i32 @__set_errno(i32 %24)
store i32 -1, i32* %3
br label %26
26: ; preds = %23, %20
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
@R_OK = global i32 0
@W_OK = global i32 0
@X_OK = global i32 0
@F_OK = global i32 0
@EINVAL = global i32 0
@ENOSYS = global i32 0
define i32 @__access(i8* readnone %0, i32 %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %16, label %4
4: ; preds = %2
%5 = load i32, i32* @R_OK
%6 = load i32, i32* @W_OK
%7 = or i32 %6, %5
%8 = load i32, i32* @X_OK
%9 = or i32 %7, %8
%10 = load i32, i32* @F_OK
%11 = or i32 %9, %10
%12 = xor i32 %11, -1
%13 = and i32 %12, %1
%14 = icmp eq i32 %13, 0
%15 = select i1 %14, i32* @ENOSYS, i32* @EINVAL
br label %16
16: ; preds = %4, %2
%17 = phi i32* [ @EINVAL, %2 ], [ %15, %4 ]
%18 = load i32, i32* %17
%19 = tail call i32 @__set_errno(i32 %18)
ret i32 -1
}