#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*/ name;

/* Variables and functions */
int errno;
int /*<<< orphan*/ shm_unlink(char *);
int shmlog_get_name(char *, long long, char *, int);
int shmlog_unlink(char *prefix, long long seq) {
  char name[256];
  int ret;
  ret = shmlog_get_name(prefix, seq, name, sizeof(name));
  if (ret < 0) {
    do {
      errno =
          errno < 0 ? errno : (-1 * ((((4) * 10000 + (381))) * 1000 + (errno)));
    } while (0);
    return -1;
  }
  (void)shm_unlink(name);
  return 0;
}


x86 assembly (clang, -O0):
<shmlog_unlink>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x120(%rbp),%rdx
mov    $0x100,%ecx
call   1030 <shmlog_get_name@plt>
mov    %eax,-0x124(%rbp)
cmpl   $0x0,-0x124(%rbp)
jge    11bd <shmlog_unlink+0x9d>
jmp    1164 <shmlog_unlink+0x44>
mov    0x2e75(%rip),%rax
cmpl   $0x0,(%rax)
jge    1188 <shmlog_unlink+0x68>
mov    0x2e65(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x128(%rbp)
jmp    11a2 <shmlog_unlink+0x82>
mov    0x2e51(%rip),%rax
mov    (%rax),%eax
add    $0x2682a48,%eax
imul   $0xffffffff,%eax,%eax
mov    %eax,-0x128(%rbp)
mov    -0x128(%rbp),%ecx
mov    0x2e31(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    11d0 <shmlog_unlink+0xb0>
lea    -0x120(%rbp),%rdi
call   1040 <shm_unlink@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shmlog_unlink>:
sub    $0x108,%rsp
mov    %rsp,%rdx
mov    $0x100,%ecx
call   1030 <shmlog_get_name@plt>
test   %eax,%eax
js     114a <shmlog_unlink+0x2a>
mov    %rsp,%rdi
call   1040 <shm_unlink@plt>
xor    %eax,%eax
add    $0x108,%rsp
ret
mov    0x2e8f(%rip),%rax
mov    (%rax),%ecx
mov    $0xfd97d5b8,%edx
sub    %ecx,%edx
test   %ecx,%ecx
cmovs  %ecx,%edx
mov    %edx,(%rax)
mov    $0xffffffff,%eax
add    $0x108,%rsp
ret

LLVM IR (-O0):
@errno = global i32 0
define i32 @shmlog_unlink(i8* %0, i64 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca [256 x i8]
%7 = alloca i32
store i8* %0, i8** %4
store i64 %1, i64* %5
%8 = load i8*, i8** %4
%9 = load i64, i64* %5
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%11 = call i32 @shmlog_get_name(i8* %8, i64 %9, i8* %10, i32 256)
store i32 %11, i32* %7
%12 = load i32, i32* %7
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %27
14: ; preds = %2
br label %15
15: ; preds = %14
%16 = load i32, i32* @errno
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = load i32, i32* @errno
br label %24
20: ; preds = %15
%21 = load i32, i32* @errno
%22 = add nsw i32 40381000, %21
%23 = mul nsw i32 -1, %22
br label %24
24: ; preds = %20, %18
%25 = phi i32 [ %19, %18 ], [ %23, %20 ]
store i32 %25, i32* @errno
br label %26
26: ; preds = %24
store i32 -1, i32* %3
br label %30
27: ; preds = %2
%28 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%29 = call i32 @shm_unlink(i8* %28)
store i32 0, i32* %3
br label %30
30: ; preds = %27, %26
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@errno = global i32 0
define i32 @shmlog_unlink(i8* %0, i64 %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = call i32 @shmlog_get_name(i8* %0, i64 %1, i8* %4, i32 256)
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %2
%8 = load i32, i32* @errno
%9 = icmp slt i32 %8, 0
%10 = sub i32 -40381000, %8
%11 = select i1 %9, i32 %8, i32 %10
store i32 %11, i32* @errno
br label %14
12: ; preds = %2
%13 = call i32 @shm_unlink(i8* %4)
br label %14
14: ; preds = %12, %7
%15 = phi i32 [ -1, %7 ], [ 0, %12 ]
ret i32 %15
}