#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 S_IREAD;
int S_IWRITE;
int W_OK;
int X_OK;
int /*<<< orphan*/ access(char *, int);
int creat(char *, int);
int main() {
  int fd1;
  fd1 = creat("foobar1", S_IREAD | S_IWRITE);
  access("foobar1", F_OK);
  access("foobar1", R_OK);
  access("foobar1", W_OK);
  access("foobar1", X_OK);
  access("foobar1", R_OK | W_OK);
  access("foobar1", R_OK | W_OK | X_OK);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e8a(%rip),%rax
mov    (%rax),%esi
mov    0x2ea9(%rip),%rax
or     (%rax),%esi
lea    0xeb8(%rip),%rdi
call   1040 <creat@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e59(%rip),%rax
mov    (%rax),%esi
lea    0xea0(%rip),%rdi
call   1030 <access@plt>
mov    0x2e5c(%rip),%rax
mov    (%rax),%esi
lea    0xe8b(%rip),%rdi
call   1030 <access@plt>
mov    0x2e5f(%rip),%rax
mov    (%rax),%esi
lea    0xe76(%rip),%rdi
call   1030 <access@plt>
mov    0x2e42(%rip),%rax
mov    (%rax),%esi
lea    0xe61(%rip),%rdi
call   1030 <access@plt>
mov    0x2e1d(%rip),%rax
mov    (%rax),%esi
mov    0x2e2c(%rip),%rax
or     (%rax),%esi
lea    0xe43(%rip),%rdi
call   1030 <access@plt>
mov    0x2dff(%rip),%rax
mov    (%rax),%esi
mov    0x2e0e(%rip),%rax
or     (%rax),%esi
mov    0x2dfd(%rip),%rax
or     (%rax),%esi
lea    0xe1c(%rip),%rdi
call   1030 <access@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    0x2e91(%rip),%rax
mov    0x2eb2(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xebf(%rip),%rbx
mov    %rbx,%rdi
call   1040 <creat@plt>
mov    0x2e60(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1030 <access@plt>
mov    0x2e67(%rip),%r14
mov    (%r14),%esi
mov    %rbx,%rdi
call   1030 <access@plt>
mov    0x2e6d(%rip),%r15
mov    (%r15),%esi
mov    %rbx,%rdi
call   1030 <access@plt>
mov    0x2e53(%rip),%r12
mov    (%r12),%esi
mov    %rbx,%rdi
call   1030 <access@plt>
mov    (%r15),%esi
or     (%r14),%esi
mov    %rbx,%rdi
call   1030 <access@plt>
mov    (%r15),%esi
or     (%r14),%esi
or     (%r12),%esi
mov    %rbx,%rdi
call   1030 <access@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [8 x i8] c"foobar1\00"
@S_IREAD = global i32 0
@S_IWRITE = global i32 0
@F_OK = global i32 0
@R_OK = global i32 0
@W_OK = global i32 0
@X_OK = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = load i32, i32* @S_IREAD
%4 = load i32, i32* @S_IWRITE
%5 = or i32 %3, %4
%6 = call i32 @creat(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %5)
store i32 %6, i32* %2
%7 = load i32, i32* @F_OK
%8 = call i32 @access(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = load i32, i32* @R_OK
%10 = call i32 @access(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = load i32, i32* @W_OK
%12 = call i32 @access(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = load i32, i32* @X_OK
%14 = call i32 @access(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = load i32, i32* @R_OK
%16 = load i32, i32* @W_OK
%17 = or i32 %15, %16
%18 = call i32 @access(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = load i32, i32* @R_OK
%20 = load i32, i32* @W_OK
%21 = or i32 %19, %20
%22 = load i32, i32* @X_OK
%23 = or i32 %21, %22
%24 = call i32 @access(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %23)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"foobar1\00"
@S_IREAD = global i32 0
@S_IWRITE = global i32 0
@F_OK = global i32 0
@R_OK = global i32 0
@W_OK = global i32 0
@X_OK = global i32 0
define i32 @main() {
%1 = load i32, i32* @S_IREAD
%2 = load i32, i32* @S_IWRITE
%3 = or i32 %2, %1
%4 = tail call i32 @creat(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = load i32, i32* @F_OK
%6 = tail call i32 @access(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = load i32, i32* @R_OK
%8 = tail call i32 @access(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = load i32, i32* @W_OK
%10 = tail call i32 @access(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = load i32, i32* @X_OK
%12 = tail call i32 @access(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = load i32, i32* @R_OK
%14 = load i32, i32* @W_OK
%15 = or i32 %14, %13
%16 = tail call i32 @access(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = load i32, i32* @R_OK
%18 = load i32, i32* @W_OK
%19 = or i32 %18, %17
%20 = load i32, i32* @X_OK
%21 = or i32 %19, %20
%22 = tail call i32 @access(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %21)
ret i32 0
}