#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*/ errno;
int /*<<< orphan*/ getpid();
int /*<<< orphan*/ logging(char *, char const *const, ...);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int unlink(char const *const);
void remove_pid_file(char const *const pid_file) {
  logging("Removing pid file [%s]: [%d]", pid_file, getpid());
  int const rval = unlink(pid_file);
  if (rval == -1) {
    logging("Cannot remove pid file, reason [%s]", strerror(errno));
  }
}


x86 assembly (clang, -O0):
<remove_pid_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0x18(%rbp),%rsi
mov    %eax,%edx
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1050 <logging@plt>
mov    -0x8(%rbp),%rdi
call   1030 <unlink@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    11a4 <remove_pid_file+0x64>
mov    0x2e54(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
movslq %eax,%rsi
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1050 <logging@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_pid_file>:
push   %rbx
mov    %rdi,%rbx
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xeae(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <logging@plt>
mov    %rbx,%rdi
call   1030 <unlink@plt>
cmp    $0xffffffff,%eax
je     116d <remove_pid_file+0x2d>
pop    %rbx
ret
mov    0x2e6c(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
movslq %eax,%rsi
lea    0xe98(%rip),%rdi
xor    %eax,%eax
pop    %rbx
jmp    1050 <logging@plt>

LLVM IR (-O0):
@.str = [29 x i8] c"Removing pid file [%s]: [%d]\00"
@.str.1 = [36 x i8] c"Cannot remove pid file, reason [%s]\00"
@errno = global i32 0
define void @remove_pid_file(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 (...) @getpid()
%6 = call i32 (i8*, i8*, ...) @logging(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %4, i32 %5)
%7 = load i8*, i8** %2
%8 = call i32 @unlink(i8* %7)
store i32 %8, i32* %3
%9 = load i32, i32* %3
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %17
11: ; preds = %1
%12 = load i32, i32* @errno
%13 = call i32 @strerror(i32 %12)
%14 = sext i32 %13 to i64
%15 = inttoptr i64 %14 to i8*
%16 = call i32 (i8*, i8*, ...) @logging(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* %15)
br label %17
17: ; preds = %11, %1
ret void
}

LLVM IR (-O2):
@.str = [29 x i8] c"Removing pid file [%s]: [%d]\00"
@.str.1 = [36 x i8] c"Cannot remove pid file, reason [%s]\00"
@errno = global i32 0
define void @remove_pid_file(i8* %0) {
%2 = tail call i32 (...) @getpid()
%3 = tail call i32 (i8*, i8*, ...) @logging(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %2)
%4 = tail call i32 @unlink(i8* %0)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %12
6: ; preds = %1
%7 = load i32, i32* @errno
%8 = tail call i32 @strerror(i32 %7)
%9 = sext i32 %8 to i64
%10 = inttoptr i64 %9 to i8*
%11 = tail call i32 (i8*, i8*, ...) @logging(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* %10)
br label %12
12: ; preds = %6, %1
ret void
}