#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 PATH_MAX;
int /*<<< orphan*/ elg_cntl_msg(char *, char *);
int /*<<< orphan*/ elg_warning(char *, char *, int /*<<< orphan*/);
char *epk_archive_get_name();
int /*<<< orphan*/ errno;
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
scalar_t__ unlink(char *);
void epk_archive_unlock(void) {
  char epik_lock[PATH_MAX];
  snprintf(epik_lock, PATH_MAX, "%s/%s", epk_archive_get_name(), "epik.lock");
  if (unlink(epik_lock) != 0)
    elg_warning("Failed to unlink %s: %s", epik_lock, strerror(errno));
  else
    elg_cntl_msg("Unlinked lock file %s", epik_lock);
}


x86 assembly (clang, -O0):
<epk_archive_unlock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0x2e81(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x8(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x10(%rbp)
mov    0x2e55(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1040 <epk_archive_get_name@plt>
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%rdi
mov    %rax,%rcx
lea    0xe48(%rip),%rdx
lea    0xe47(%rip),%r8
call   1060 <snprintf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <unlink@plt>
cmp    $0x0,%rax
je     11fc <epk_archive_unlock+0x9c>
mov    0x2dfa(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x18(%rbp),%rsi
mov    %eax,%edx
lea    0xe1e(%rip),%rdi
call   1070 <elg_warning@plt>
jmp    120c <epk_archive_unlock+0xac>
mov    -0x18(%rbp),%rsi
lea    0xe21(%rip),%rdi
call   1050 <elg_cntl_msg@plt>
mov    -0x8(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<epk_archive_unlock>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
mov    0x2e82(%rip),%rax
mov    (%rax),%r14d
mov    %rsp,%rbx
mov    %r14,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
xor    %eax,%eax
call   1040 <epk_archive_get_name@plt>
lea    0xe6d(%rip),%rdx
lea    0xe6c(%rip),%r8
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %rax,%rcx
call   1060 <snprintf@plt>
mov    %rbx,%rdi
call   1030 <unlink@plt>
test   %rax,%rax
je     11d6 <epk_archive_unlock+0x76>
mov    0x2e1c(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xe46(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1070 <elg_warning@plt>
jmp    11e5 <epk_archive_unlock+0x85>
lea    0xe4b(%rip),%rdi
mov    %rbx,%rsi
call   1050 <elg_cntl_msg@plt>
lea    -0x10(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@PATH_MAX = global i32 0
@.str = [6 x i8] c"%s/%s\00"
@.str.1 = [10 x i8] c"epik.lock\00"
@.str.2 = [24 x i8] c"Failed to unlink %s: %s\00"
@errno = global i32 0
@.str.3 = [22 x i8] c"Unlinked lock file %s\00"
define void @epk_archive_unlock() {
%1 = alloca i8*
%2 = alloca i64
%3 = load i32, i32* @PATH_MAX
%4 = zext i32 %3 to i64
%5 = call i8* @llvm.stacksave()
store i8* %5, i8** %1
%6 = alloca i8, i64 %4
store i64 %4, i64* %2
%7 = load i32, i32* @PATH_MAX
%8 = call i8* (...) @epk_archive_get_name()
%9 = call i32 @snprintf(i8* %6, i32 %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %8, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%10 = call i64 @unlink(i8* %6)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %0
%13 = load i32, i32* @errno
%14 = call i32 @strerror(i32 %13)
%15 = call i32 @elg_warning(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %6, i32 %14)
br label %18
16: ; preds = %0
%17 = call i32 @elg_cntl_msg(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %6)
br label %18
18: ; preds = %16, %12
%19 = load i8*, i8** %1
ret void
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
@.str = [6 x i8] c"%s/%s\00"
@.str.1 = [10 x i8] c"epik.lock\00"
@.str.2 = [24 x i8] c"Failed to unlink %s: %s\00"
@errno = global i32 0
@.str.3 = [22 x i8] c"Unlinked lock file %s\00"
define void @epk_archive_unlock() {
%1 = load i32, i32* @PATH_MAX
%2 = zext i32 %1 to i64
%3 = alloca i8, i64 %2
%4 = tail call i8* (...) @epk_archive_get_name()
%5 = call i32 @snprintf(i8* %3, i32 %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %4, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%6 = call i64 @unlink(i8* %3)
%7 = icmp eq i64 %6, 0
br i1 %7, label %12, label %8
8: ; preds = %0
%9 = load i32, i32* @errno
%10 = call i32 @strerror(i32 %9)
%11 = call i32 @elg_warning(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %3, i32 %10)
br label %14
12: ; preds = %0
%13 = call i32 @elg_cntl_msg(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %3)
br label %14
14: ; preds = %12, %8
ret void
}