#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 */
typedef int /*<<< orphan*/ pid_t;
typedef int /*<<< orphan*/ LogStr;

/* Variables and functions */
scalar_t__ HDBLockFile(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ LOG_NOTICE;
int /*<<< orphan*/ LogMsg(int /*<<< orphan*/, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char const *);
int /*<<< orphan*/ unlink(char const *);
void HDBUnlockFile(const char *LockFile, pid_t LockPid) {
  char LogStr[255];
  if (HDBLockFile(LockFile, LockPid) == 0) {
    unlink(LockFile);
    snprintf(LogStr, sizeof(LogStr), "Unlocked lock file %s.", LockFile);
    LogStr[sizeof(LogStr) - 1] = '\0';
    LogMsg(LOG_NOTICE, LogStr);
  }
}


x86 assembly (clang, -O0):
<HDBUnlockFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1060 <HDBLockFile@plt>
cmp    $0x0,%rax
jne    11a6 <HDBUnlockFile+0x66>
mov    -0x8(%rbp),%rdi
call   1030 <unlink@plt>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0xff,%esi
lea    0xe78(%rip),%rdx
call   1040 <snprintf@plt>
movb   $0x0,-0x12(%rbp)
mov    0x2e48(%rip),%rax
mov    (%rax),%edi
lea    -0x110(%rbp),%rsi
call   1050 <LogMsg@plt>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HDBUnlockFile>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rdi,%rbx
call   1060 <HDBLockFile@plt>
test   %rax,%rax
jne    1192 <HDBUnlockFile+0x52>
mov    %rbx,%rdi
call   1030 <unlink@plt>
lea    0xe9a(%rip),%rdx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0xff,%esi
mov    %rbx,%rcx
call   1040 <snprintf@plt>
movb   $0x0,0xfe(%rsp)
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
mov    %r14,%rsi
call   1050 <LogMsg@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Unlocked lock file %s.\00"
@LOG_NOTICE = global i32 0
define void @HDBUnlockFile(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [255 x i8]
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i8*, i8** %3
%7 = load i32, i32* %4
%8 = call i64 @HDBLockFile(i8* %6, i32 %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %20
10: ; preds = %2
%11 = load i8*, i8** %3
%12 = call i32 @unlink(i8* %11)
%13 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%14 = load i8*, i8** %3
%15 = call i32 @snprintf(i8* %13, i32 255, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 254
store i8 0, i8* %16
%17 = load i32, i32* @LOG_NOTICE
%18 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%19 = call i32 @LogMsg(i32 %17, i8* %18)
br label %20
20: ; preds = %10, %2
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"Unlocked lock file %s.\00"
@LOG_NOTICE = global i32 0
define void @HDBUnlockFile(i8* %0, i32 %1) {
%3 = alloca [255 x i8]
%4 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%5 = tail call i64 @HDBLockFile(i8* %0, i32 %1)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %13
7: ; preds = %2
%8 = tail call i32 @unlink(i8* %0)
%9 = call i32 @snprintf(i8* %4, i32 255, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %0)
%10 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 254
store i8 0, i8* %10
%11 = load i32, i32* @LOG_NOTICE
%12 = call i32 @LogMsg(i32 %11, i8* %4)
br label %13
13: ; preds = %7, %2
ret void
}