#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 */
scalar_t__ ENOENT;
int PATH_MAX;
scalar_t__ errno;
int /*<<< orphan*/ linkname_from_minor(char *, int);
int /*<<< orphan*/ perror(char *);
scalar_t__ unlink(char *);
int unregister_minor(int minor) {
  char linkname[PATH_MAX];
  linkname_from_minor(linkname, minor);
  if (unlink(linkname) < 0) {
    if (errno != ENOENT) {
      perror("unlink");
      return -1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<unregister_minor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    0x2eae(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x28(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%esi
call   1040 <linkname_from_minor@plt>
mov    -0x28(%rbp),%rdi
call   1030 <unlink@plt>
cmp    $0x0,%rax
jge    11c0 <unregister_minor+0x90>
mov    0x2e4f(%rip),%rax
mov    (%rax),%rax
mov    0x2e35(%rip),%rcx
cmp    (%rcx),%rax
je     11bb <unregister_minor+0x8b>
lea    0xe5d(%rip),%rdi
call   1050 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x1c(%rbp)
jmp    11ce <unregister_minor+0x9e>
jmp    11c0 <unregister_minor+0x90>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unregister_minor>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
push   %rax
mov    %edi,%esi
mov    0x2eb1(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
call   1040 <linkname_from_minor@plt>
mov    %rbx,%rdi
call   1030 <unlink@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jns    1182 <unregister_minor+0x52>
mov    0x2e65(%rip),%rcx
mov    (%rcx),%rcx
mov    0x2e4b(%rip),%rdx
cmp    (%rdx),%rcx
jne    1189 <unregister_minor+0x59>
lea    -0x8(%rbp),%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe70(%rip),%rdi
call   1050 <perror@plt>
mov    $0xffffffff,%eax
jmp    1182 <unregister_minor+0x52>

LLVM IR (-O0):
@PATH_MAX = global i32 0
@errno = global i64 0
@ENOENT = global i64 0
@.str = [7 x i8] c"unlink\00"
define i32 @unregister_minor(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
store i32 %0, i32* %3
%7 = load i32, i32* @PATH_MAX
%8 = zext i32 %7 to i64
%9 = call i8* @llvm.stacksave()
store i8* %9, i8** %4
%10 = alloca i8, i64 %8
store i64 %8, i64* %5
%11 = load i32, i32* %3
%12 = call i32 @linkname_from_minor(i8* %10, i32 %11)
%13 = call i64 @unlink(i8* %10)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %22
15: ; preds = %1
%16 = load i64, i64* @errno
%17 = load i64, i64* @ENOENT
%18 = icmp ne i64 %16, %17
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %2
store i32 1, i32* %6
br label %23
21: ; preds = %15
br label %22
22: ; preds = %21, %1
store i32 0, i32* %2
store i32 1, i32* %6
br label %23
23: ; preds = %22, %19
%24 = load i8*, i8** %4
%25 = load i32, i32* %2
ret i32 %25
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
@errno = global i64 0
@ENOENT = global i64 0
@.str = [7 x i8] c"unlink\00"
define i32 @unregister_minor(i32 %0) {
%2 = load i32, i32* @PATH_MAX
%3 = zext i32 %2 to i64
%4 = alloca i8, i64 %3
%5 = call i32 @linkname_from_minor(i8* %4, i32 %0)
%6 = call i64 @unlink(i8* %4)
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %14
8: ; preds = %1
%9 = load i64, i64* @errno
%10 = load i64, i64* @ENOENT
%11 = icmp eq i64 %9, %10
br i1 %11, label %14, label %12
12: ; preds = %8
%13 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %1, %8, %12
%15 = phi i32 [ -1, %12 ], [ 0, %8 ], [ 0, %1 ]
ret i32 %15
}