#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*/ F_OK;
int /*<<< orphan*/ R_OK;
int /*<<< orphan*/ W_OK;
int /*<<< orphan*/ X_OK;
int access(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char const *, int);
int main(int argc, char *argv[]) {
  const char *p = "access.c";
  int x = access(p, R_OK);
  printf("[%s] on R_OK : [%d]\n", p, x);
  x = access(p, W_OK);
  printf("[%s] on W_OK : [%d]\n", p, x);
  x = access(p, X_OK);
  printf("[%s] on X_OK : [%d]\n", p, x);
  x = access(p, F_OK);
  printf("[%s] on F_OK : [%d]\n", p, x);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xec3(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2e84(%rip),%rax
mov    (%rax),%esi
call   1040 <access@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    0x2e74(%rip),%rax
mov    (%rax),%esi
call   1040 <access@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    0x2e44(%rip),%rax
mov    (%rax),%esi
call   1040 <access@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
lea    0xe7f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    0x2dfc(%rip),%rax
mov    (%rax),%esi
call   1040 <access@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
lea    0xe6c(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x2ea8(%rip),%rax
mov    (%rax),%esi
lea    0xecf(%rip),%rbx
mov    %rbx,%rdi
call   1040 <access@plt>
lea    0xec9(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <printf@plt>
mov    0x2e97(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1040 <access@plt>
lea    0xebc(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <printf@plt>
mov    0x2e6d(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1040 <access@plt>
lea    0xeaf(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <printf@plt>
mov    0x2e2b(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1040 <access@plt>
lea    0xea2(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"access.c\00"
@R_OK = global i32 0
@.str.1 = [21 x i8] c"[%s] on R_OK : [%d]\0A\00"
@W_OK = global i32 0
@.str.2 = [21 x i8] c"[%s] on W_OK : [%d]\0A\00"
@X_OK = global i32 0
@.str.3 = [21 x i8] c"[%s] on X_OK : [%d]\0A\00"
@F_OK = global i32 0
@.str.4 = [21 x i8] c"[%s] on F_OK : [%d]\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8** %6
%8 = load i8*, i8** %6
%9 = load i32, i32* @R_OK
%10 = call i32 @access(i8* %8, i32 %9)
store i32 %10, i32* %7
%11 = load i8*, i8** %6
%12 = load i32, i32* %7
%13 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %11, i32 %12)
%14 = load i8*, i8** %6
%15 = load i32, i32* @W_OK
%16 = call i32 @access(i8* %14, i32 %15)
store i32 %16, i32* %7
%17 = load i8*, i8** %6
%18 = load i32, i32* %7
%19 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %17, i32 %18)
%20 = load i8*, i8** %6
%21 = load i32, i32* @X_OK
%22 = call i32 @access(i8* %20, i32 %21)
store i32 %22, i32* %7
%23 = load i8*, i8** %6
%24 = load i32, i32* %7
%25 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %23, i32 %24)
%26 = load i8*, i8** %6
%27 = load i32, i32* @F_OK
%28 = call i32 @access(i8* %26, i32 %27)
store i32 %28, i32* %7
%29 = load i8*, i8** %6
%30 = load i32, i32* %7
%31 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* %29, i32 %30)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"access.c\00"
@R_OK = global i32 0
@.str.1 = [21 x i8] c"[%s] on R_OK : [%d]\0A\00"
@W_OK = global i32 0
@.str.2 = [21 x i8] c"[%s] on W_OK : [%d]\0A\00"
@X_OK = global i32 0
@.str.3 = [21 x i8] c"[%s] on X_OK : [%d]\0A\00"
@F_OK = global i32 0
@.str.4 = [21 x i8] c"[%s] on F_OK : [%d]\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @R_OK
%4 = tail call i32 @access(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = load i32, i32* @W_OK
%7 = tail call i32 @access(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = load i32, i32* @X_OK
%10 = tail call i32 @access(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = load i32, i32* @F_OK
%13 = tail call i32 @access(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %13)
ret i32 0
}