#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*/ logmsg;
typedef int /*<<< orphan*/ hostfile;

/* Variables and functions */
int /*<<< orphan*/ logging(char *, char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ unlink(char *);
int unlinkPortFile(char *file) {
  char hostfile[17];
  memset(hostfile, 0, sizeof(hostfile));
  strcpy(hostfile, ".");
  strcat(hostfile, file);
  if (unlink(hostfile) < 0) {
    char logmsg[128];
    snprintf(logmsg, sizeof(logmsg), "Failed to unlink file: %s \n", file);
    logging("lsrp-router.log", logmsg);
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<unlinkPortFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x11,%edx
call   1060 <memset@plt>
lea    -0x30(%rbp),%rdi
lea    0xe76(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1080 <strcat@plt>
lea    -0x30(%rbp),%rdi
call   1030 <unlink@plt>
cmp    $0x0,%rax
jge    11ea <unlinkPortFile+0x8a>
lea    -0xb0(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x80,%esi
lea    0xe3c(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0xb0(%rbp),%rsi
lea    0xe45(%rip),%rdi
call   1070 <logging@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f1 <unlinkPortFile+0x91>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unlinkPortFile>:
push   %rbp
push   %r14
push   %rbx
sub    $0xa0,%rsp
mov    %rdi,%r14
mov    %rsp,%rbx
xor    %ebp,%ebp
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x11,%edx
call   1060 <memset@plt>
lea    0xe77(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <strcat@plt>
mov    %rbx,%rdi
call   1030 <unlink@plt>
test   %rax,%rax
jns    11d9 <unlinkPortFile+0x79>
lea    0xe52(%rip),%rdx
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x80,%esi
mov    %r14,%rcx
call   1050 <snprintf@plt>
lea    0xe52(%rip),%rdi
mov    %rbx,%rsi
call   1070 <logging@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0xa0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c".\00"
@.str.1 = [28 x i8] c"Failed to unlink file: %s \0A\00"
@.str.2 = [16 x i8] c"lsrp-router.log\00"
define i32 @unlinkPortFile(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [17 x i8]
%5 = alloca [128 x i8]
store i8* %0, i8** %3
%6 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 0
%7 = call i32 @memset(i8* %6, i32 0, i32 17)
%8 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 0
%9 = call i32 @strcpy(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 0
%11 = load i8*, i8** %3
%12 = call i32 @strcat(i8* %10, i8* %11)
%13 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 0
%14 = call i64 @unlink(i8* %13)
%15 = icmp slt i64 %14, 0
br i1 %15, label %16, label %22
16: ; preds = %1
%17 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%18 = load i8*, i8** %3
%19 = call i32 @snprintf(i8* %17, i32 128, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%21 = call i32 @logging(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %20)
store i32 -1, i32* %2
br label %23
22: ; preds = %1
store i32 0, i32* %2
br label %23
23: ; preds = %22, %16
%24 = load i32, i32* %2
ret i32 %24
}

LLVM IR (-O2):
@.str = [2 x i8] c".\00"
@.str.1 = [28 x i8] c"Failed to unlink file: %s \0A\00"
@.str.2 = [16 x i8] c"lsrp-router.log\00"
define i32 @unlinkPortFile(i8* %0) {
%2 = alloca [17 x i8]
%3 = alloca [128 x i8]
%4 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 0
%5 = call i32 @memset(i8* %4, i32 0, i32 17)
%6 = call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @strcat(i8* %4, i8* %0)
%8 = call i64 @unlink(i8* %4)
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %1
%11 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%12 = call i32 @snprintf(i8* %11, i32 128, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%13 = call i32 @logging(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %11)
br label %14
14: ; preds = %1, %10
%15 = phi i32 [ -1, %10 ], [ 0, %1 ]
ret i32 %15
}