#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 access(char *, int /*<<< orphan*/);
int errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int);
int /*<<< orphan*/ stderr;
int unlink(char *);
int remove_file(char *fname) {
  int status = 0;
  if ((*fname != '\0') && (access(fname, F_OK) != -1)) {
    status = unlink(fname);
    if (status != 0) {
      fprintf(stderr, "Can't remove %s (err %d)\n", fname, errno);
    } else {
      *fname = '\0';
    }
  }
  return status;
}


x86 assembly (clang, -O0):
<remove_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11b7 <remove_file+0x87>
mov    -0x8(%rbp),%rdi
mov    0x2e6a(%rip),%rax
mov    (%rax),%esi
call   1050 <access@plt>
cmp    $0xffffffff,%eax
je     11b7 <remove_file+0x87>
mov    -0x8(%rbp),%rdi
call   1030 <unlink@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11ab <remove_file+0x7b>
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    0x2e40(%rip),%rax
mov    (%rax),%ecx
lea    0xe5f(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11b2 <remove_file+0x82>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
jmp    11b7 <remove_file+0x87>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_file>:
push   %rbp
push   %r14
push   %rbx
xor    %ebp,%ebp
cmpb   $0x0,(%rdi)
je     1189 <remove_file+0x59>
mov    %rdi,%rbx
mov    0x2e83(%rip),%rax
mov    (%rax),%esi
call   1050 <access@plt>
cmp    $0xffffffff,%eax
je     1189 <remove_file+0x59>
mov    %rbx,%rdi
call   1030 <unlink@plt>
test   %eax,%eax
je     1186 <remove_file+0x56>
mov    %eax,%r14d
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
mov    0x2e68(%rip),%rax
mov    (%rax),%ecx
lea    0xe87(%rip),%rsi
mov    %rbx,%rdx
call   1040 <fprintf@plt>
mov    %r14d,%ebp
jmp    1189 <remove_file+0x59>
movb   $0x0,(%rbx)
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@F_OK = global i32 0
@stderr = global i32 0
@.str = [26 x i8] c"Can't remove %s (err %d)\0A\00"
@errno = global i32 0
define i32 @remove_file(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
%4 = load i8*, i8** %2
%5 = load i8, i8* %4
%6 = sext i8 %5 to i32
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %26
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = load i32, i32* @F_OK
%11 = call i32 @access(i8* %9, i32 %10)
%12 = icmp ne i32 %11, -1
br i1 %12, label %13, label %26
13: ; preds = %8
%14 = load i8*, i8** %2
%15 = call i32 @unlink(i8* %14)
store i32 %15, i32* %3
%16 = load i32, i32* %3
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %13
%19 = load i32, i32* @stderr
%20 = load i8*, i8** %2
%21 = load i32, i32* @errno
%22 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %20, i32 %21)
br label %25
23: ; preds = %13
%24 = load i8*, i8** %2
store i8 0, i8* %24
br label %25
25: ; preds = %23, %18
br label %26
26: ; preds = %25, %8, %1
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
@F_OK = global i32 0
@stderr = global i32 0
@.str = [26 x i8] c"Can't remove %s (err %d)\0A\00"
@errno = global i32 0
define i32 @remove_file(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %16, label %4
4: ; preds = %1
%5 = load i32, i32* @F_OK
%6 = tail call i32 @access(i8* %0, i32 %5)
%7 = icmp eq i32 %6, -1
br i1 %7, label %16, label %8
8: ; preds = %4
%9 = tail call i32 @unlink(i8* %0)
%10 = icmp eq i32 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %8
%12 = load i32, i32* @stderr
%13 = load i32, i32* @errno
%14 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %13)
br label %16
15: ; preds = %8
store i8 0, i8* %0
br label %16
16: ; preds = %11, %15, %4, %1
%17 = phi i32 [ %9, %11 ], [ 0, %15 ], [ 0, %4 ], [ 0, %1 ]
ret i32 %17
}