#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;
scalar_t__ access(char *, int);
int /*<<< orphan*/ open_rdwr(char *);
int execute_access() {
  if (access("syscalls.txt", F_OK) != 0)
    open_rdwr("syscalls.txt");
  access("syscalls.txt", R_OK | W_OK);
  access("syscalls.txt", X_OK);
  return 0;
}


x86 assembly (clang, -O0):
<execute_access>:
push   %rbp
mov    %rsp,%rbp
mov    0x2e95(%rip),%rax
mov    (%rax),%esi
lea    0xecc(%rip),%rdi
call   1040 <access@plt>
cmp    $0x0,%rax
je     114f <execute_access+0x2f>
lea    0xeb6(%rip),%rdi
call   1030 <open_rdwr@plt>
mov    0x2e7a(%rip),%rax
mov    (%rax),%esi
mov    0x2e89(%rip),%rax
or     (%rax),%esi
lea    0xe98(%rip),%rdi
call   1040 <access@plt>
mov    0x2e6c(%rip),%rax
mov    (%rax),%esi
lea    0xe83(%rip),%rdi
call   1040 <access@plt>
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<execute_access>:
push   %rbx
mov    0x2e98(%rip),%rax
mov    (%rax),%esi
lea    0xecf(%rip),%rdi
call   1040 <access@plt>
test   %rax,%rax
je     1147 <execute_access+0x27>
lea    0xebe(%rip),%rdi
call   1030 <open_rdwr@plt>
mov    0x2e82(%rip),%rax
mov    0x2e93(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xea0(%rip),%rbx
mov    %rbx,%rdi
call   1040 <access@plt>
mov    0x2e71(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1040 <access@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"syscalls.txt\00"
@F_OK = global i32 0
@R_OK = global i32 0
@W_OK = global i32 0
@X_OK = global i32 0
define i32 @execute_access() {
%1 = load i32, i32* @F_OK
%2 = call i64 @access(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = icmp ne i64 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = call i32 @open_rdwr(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %0
%7 = load i32, i32* @R_OK
%8 = load i32, i32* @W_OK
%9 = or i32 %7, %8
%10 = call i64 @access(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = load i32, i32* @X_OK
%12 = call i64 @access(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %11)
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"syscalls.txt\00"
@F_OK = global i32 0
@R_OK = global i32 0
@W_OK = global i32 0
@X_OK = global i32 0
define i32 @execute_access() {
%1 = load i32, i32* @F_OK
%2 = tail call i64 @access(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = icmp eq i64 %2, 0
br i1 %3, label %6, label %4
4: ; preds = %0
%5 = tail call i32 @open_rdwr(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %0
%7 = load i32, i32* @R_OK
%8 = load i32, i32* @W_OK
%9 = or i32 %8, %7
%10 = tail call i64 @access(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = load i32, i32* @X_OK
%12 = tail call i64 @access(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %11)
ret i32 0
}