#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*/ asfPrintWarning(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ errno;
scalar_t__ fileExists(char *);
int /*<<< orphan*/ free(char *);
char *full_tmp_name(char const *);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int unlink(char *);
int unlink_tmp_file(const char *filename) {
  char *full_name;
  int ret = 0;
  full_name = full_tmp_name(filename);
  if (fileExists(full_name)) {
    ret = unlink(full_name);
    if (ret < 0)
      asfPrintWarning("unlink_tmp_file '%s': %s\n", full_name, strerror(errno));
  }
  free(full_name);
  return ret;
}


x86 assembly (clang, -O0):
<unlink_tmp_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <full_tmp_name@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <fileExists@plt>
cmp    $0x0,%rax
je     11d6 <unlink_tmp_file+0x76>
mov    -0x10(%rbp),%rdi
call   1050 <unlink@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11d1 <unlink_tmp_file+0x71>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
lea    0xe34(%rip),%rdi
call   1040 <asfPrintWarning@plt>
jmp    11d6 <unlink_tmp_file+0x76>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unlink_tmp_file>:
push   %rbp
push   %rbx
push   %rax
call   1070 <full_tmp_name@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <fileExists@plt>
test   %rax,%rax
je     11a7 <unlink_tmp_file+0x47>
mov    %rbx,%rdi
call   1050 <unlink@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    11a9 <unlink_tmp_file+0x49>
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xe65(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <asfPrintWarning@plt>
jmp    11a9 <unlink_tmp_file+0x49>
xor    %ebp,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"unlink_tmp_file '%s': %s\0A\00"
@errno = global i32 0
define i32 @unlink_tmp_file(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %4
%5 = load i8*, i8** %2
%6 = call i8* @full_tmp_name(i8* %5)
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = call i64 @fileExists(i8* %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %21
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = call i32 @unlink(i8* %11)
store i32 %12, i32* %4
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %10
%16 = load i8*, i8** %3
%17 = load i32, i32* @errno
%18 = call i32 @strerror(i32 %17)
%19 = call i32 @asfPrintWarning(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %16, i32 %18)
br label %20
20: ; preds = %15, %10
br label %21
21: ; preds = %20, %1
%22 = load i8*, i8** %3
%23 = call i32 @free(i8* %22)
%24 = load i32, i32* %4
ret i32 %24
}

LLVM IR (-O2):
@.str = [26 x i8] c"unlink_tmp_file '%s': %s\0A\00"
@errno = global i32 0
define i32 @unlink_tmp_file(i8* %0) {
%2 = tail call i8* @full_tmp_name(i8* %0)
%3 = tail call i64 @fileExists(i8* %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %12, label %5
5: ; preds = %1
%6 = tail call i32 @unlink(i8* %2)
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %5
%9 = load i32, i32* @errno
%10 = tail call i32 @strerror(i32 %9)
%11 = tail call i32 @asfPrintWarning(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %2, i32 %10)
br label %12
12: ; preds = %5, %8, %1
%13 = phi i32 [ %6, %8 ], [ %6, %5 ], [ 0, %1 ]
%14 = tail call i32 @free(i8* %2)
ret i32 %13
}