#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__ errno;
int /*<<< orphan*/ os_GetErrorString(scalar_t__);
scalar_t__ unlink(char const *);
int /*<<< orphan*/ write_log(int, int, char *, char const *, ...);
void logged_unlink(char const *path) {
  errno = 0;
  if (unlink(path) < 0) {
    write_log(3, 5, "Failed to remove temp file '%s': %s", path,
              os_GetErrorString(errno));
  } else {
    write_log(3, 1, "Temp file '%s' removed", path);
  }
}


x86 assembly (clang, -O0):
<logged_unlink>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e9d(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
call   1030 <unlink@plt>
cmp    $0x0,%rax
jge    1198 <logged_unlink+0x68>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    0x2e74(%rip),%rax
mov    (%rax),%rdi
call   1050 <os_GetErrorString@plt>
mov    -0x10(%rbp),%rcx
mov    %eax,%r8d
mov    $0x3,%edi
mov    $0x5,%esi
lea    0xe74(%rip),%rdx
mov    $0x0,%al
call   1040 <write_log@plt>
jmp    11b4 <logged_unlink+0x84>
mov    -0x8(%rbp),%rcx
mov    $0x3,%edi
mov    $0x1,%esi
lea    0xe77(%rip),%rdx
mov    $0x0,%al
call   1040 <write_log@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<logged_unlink>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2ea2(%rip),%r14
movq   $0x0,(%r14)
call   1030 <unlink@plt>
test   %rax,%rax
js     1171 <logged_unlink+0x41>
lea    0xece(%rip),%rdx
mov    $0x3,%edi
mov    $0x1,%esi
mov    %rbx,%rcx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <write_log@plt>
mov    (%r14),%rdi
call   1050 <os_GetErrorString@plt>
lea    0xe80(%rip),%rdx
mov    $0x3,%edi
mov    $0x5,%esi
mov    %rbx,%rcx
mov    %eax,%r8d
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <write_log@plt>

LLVM IR (-O0):
@errno = global i64 0
@.str = [36 x i8] c"Failed to remove temp file '%s': %s\00"
@.str.1 = [23 x i8] c"Temp file '%s' removed\00"
define void @logged_unlink(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
store i64 0, i64* @errno
%3 = load i8*, i8** %2
%4 = call i64 @unlink(i8* %3)
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %11
6: ; preds = %1
%7 = load i8*, i8** %2
%8 = load i64, i64* @errno
%9 = call i32 @os_GetErrorString(i64 %8)
%10 = call i32 (i32, i32, i8*, i8*, ...) @write_log(i32 3, i32 5, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %7, i32 %9)
br label %14
11: ; preds = %1
%12 = load i8*, i8** %2
%13 = call i32 (i32, i32, i8*, i8*, ...) @write_log(i32 3, i32 1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %12)
br label %14
14: ; preds = %11, %6
ret void
}

LLVM IR (-O2):
@errno = global i64 0
@.str = [36 x i8] c"Failed to remove temp file '%s': %s\00"
@.str.1 = [23 x i8] c"Temp file '%s' removed\00"
define void @logged_unlink(i8* %0) {
store i64 0, i64* @errno
%2 = tail call i64 @unlink(i8* %0)
%3 = icmp slt i64 %2, 0
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = load i64, i64* @errno
%6 = tail call i32 @os_GetErrorString(i64 %5)
%7 = tail call i32 (i32, i32, i8*, i8*, ...) @write_log(i32 3, i32 5, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %6)
br label %10
8: ; preds = %1
%9 = tail call i32 (i32, i32, i8*, i8*, ...) @write_log(i32 3, i32 1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %10
10: ; preds = %8, %4
ret void
}