#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 */
scalar_t__ ENOENT;
scalar_t__ errno;
int /*<<< orphan*/ exit_failure();
int /*<<< orphan*/ printf(char *, scalar_t__, char *);
char *strerror(scalar_t__);
scalar_t__ unlink(char *);
void delete_file(char *file) {
  if (unlink(file) < 0) {
    if (errno != ENOENT) {
      printf("ERROR: unlinked failed: %d(%s)\n", errno, strerror(errno));
      exit_failure();
    }
  }
}


x86 assembly (clang, -O0):
<delete_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <unlink@plt>
cmp    $0x0,%rax
jge    11b5 <delete_file+0x75>
mov    0x2e7a(%rip),%rax
mov    (%rax),%rax
mov    0x2e60(%rip),%rcx
cmp    (%rcx),%rax
je     11b0 <delete_file+0x70>
mov    0x2e60(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
mov    0x2e52(%rip),%rax
mov    (%rax),%rdi
call   1060 <strerror@plt>
mov    -0x10(%rbp),%rsi
mov    %rax,%rdx
lea    0xe5c(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <exit_failure@plt>
jmp    11b5 <delete_file+0x75>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<delete_file>:
push   %rbx
call   1030 <unlink@plt>
test   %rax,%rax
jns    1161 <delete_file+0x21>
mov    0x2e8e(%rip),%rax
mov    (%rax),%rbx
mov    0x2e74(%rip),%rax
cmp    (%rax),%rbx
jne    1163 <delete_file+0x23>
pop    %rbx
ret
mov    %rbx,%rdi
call   1060 <strerror@plt>
lea    0xe8e(%rip),%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
jmp    1050 <exit_failure@plt>

LLVM IR (-O0):
@errno = global i64 0
@ENOENT = global i64 0
@.str = [32 x i8] c"ERROR: unlinked failed: %d(%s)\0A\00"
define void @delete_file(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i64 @unlink(i8* %3)
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %17
6: ; preds = %1
%7 = load i64, i64* @errno
%8 = load i64, i64* @ENOENT
%9 = icmp ne i64 %7, %8
br i1 %9, label %10, label %16
10: ; preds = %6
%11 = load i64, i64* @errno
%12 = load i64, i64* @errno
%13 = call i8* @strerror(i64 %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i64 %11, i8* %13)
%15 = call i32 (...) @exit_failure()
br label %16
16: ; preds = %10, %6
br label %17
17: ; preds = %16, %1
ret void
}

LLVM IR (-O2):
@errno = global i64 0
@ENOENT = global i64 0
@.str = [32 x i8] c"ERROR: unlinked failed: %d(%s)\0A\00"
define void @delete_file(i8* nocapture %0) {
%2 = tail call i64 @unlink(i8* %0)
%3 = icmp slt i64 %2, 0
br i1 %3, label %4, label %12
4: ; preds = %1
%5 = load i64, i64* @errno
%6 = load i64, i64* @ENOENT
%7 = icmp eq i64 %5, %6
br i1 %7, label %12, label %8
8: ; preds = %4
%9 = tail call i8* @strerror(i64 %5)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i64 %5, i8* %9)
%11 = tail call i32 (...) @exit_failure()
br label %12
12: ; preds = %4, %8, %1
ret void
}