#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*/ W_OK;
int access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int /*<<< orphan*/ stderr;
void FAccessWPerm(char *fn) {
  if (access(fn, F_OK) != -1) {
    fprintf(stderr, "Error: file %s already exists!\n", fn);
    if (access(fn, W_OK) != -1)
      fprintf(stderr,
              "Note: file %s has write permission.\nTip: to force "
              "writing rerun with \"-f\" option.\nWarning: on forcing, the old "
              "(%s) "
              "file will be deleted permanently.\n",
              fn, fn);
    exit(1);
  }
}


x86 assembly (clang, -O0):
<FAccessWPerm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e81(%rip),%rax
mov    (%rax),%esi
call   1040 <access@plt>
cmp    $0xffffffff,%eax
je     11b6 <FAccessWPerm+0x86>
mov    0x2e7a(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe95(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    0x2e6b(%rip),%rax
mov    (%rax),%esi
call   1040 <access@plt>
cmp    $0xffffffff,%eax
je     11ac <FAccessWPerm+0x7c>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x8(%rbp),%rcx
lea    0xe7b(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FAccessWPerm>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2e8a(%rip),%rax
mov    (%rax),%esi
call   1040 <access@plt>
cmp    $0xffffffff,%eax
jne    1152 <FAccessWPerm+0x22>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e7f(%rip),%r14
mov    (%r14),%edi
lea    0xe9d(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x2e74(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1040 <access@plt>
cmp    $0xffffffff,%eax
je     119a <FAccessWPerm+0x6a>
mov    (%r14),%edi
lea    0xe93(%rip),%rsi
mov    %rbx,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@F_OK = global i32 0
@stderr = global i32 0
@.str = [32 x i8] c"Error: file %s already exists!\0A\00"
@W_OK = global i32 0
@.str.1 = [151 x i8] c"Note: file %s has write permission.\0ATip: to force writing rerun with \22-f\22 option.\0AWarning: on forcing, the old (%s) file will be deleted permanently.\0A\00"
define void @FAccessWPerm(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = load i32, i32* @F_OK
%5 = call i32 @access(i8* %3, i32 %4)
%6 = icmp ne i32 %5, -1
br i1 %6, label %7, label %22
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = load i8*, i8** %2
%10 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = load i8*, i8** %2
%12 = load i32, i32* @W_OK
%13 = call i32 @access(i8* %11, i32 %12)
%14 = icmp ne i32 %13, -1
br i1 %14, label %15, label %20
15: ; preds = %7
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %2
%18 = load i8*, i8** %2
%19 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([151 x i8], [151 x i8]* @.str.1, i64 0, i64 0), i8* %17, i8* %18)
br label %20
20: ; preds = %15, %7
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %1
ret void
}

LLVM IR (-O2):
@F_OK = global i32 0
@stderr = global i32 0
@.str = [32 x i8] c"Error: file %s already exists!\0A\00"
@W_OK = global i32 0
@.str.1 = [151 x i8] c"Note: file %s has write permission.\0ATip: to force writing rerun with \22-f\22 option.\0AWarning: on forcing, the old (%s) file will be deleted permanently.\0A\00"
define void @FAccessWPerm(i8* %0) {
%2 = load i32, i32* @F_OK
%3 = tail call i32 @access(i8* %0, i32 %2)
%4 = icmp eq i32 %3, -1
br i1 %4, label %16, label %5
5: ; preds = %1
%6 = load i32, i32* @stderr
%7 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %0)
%8 = load i32, i32* @W_OK
%9 = tail call i32 @access(i8* %0, i32 %8)
%10 = icmp eq i32 %9, -1
br i1 %10, label %14, label %11
11: ; preds = %5
%12 = load i32, i32* @stderr
%13 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([151 x i8], [151 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %0)
br label %14
14: ; preds = %11, %5
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %1
ret void
}