#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;
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ linkname_from_minor(char *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
scalar_t__ unlink(char *);
int unregister_minor(int minor) {
  char buf[255];
  if (minor >= 256 || minor < 0) {
    fprintf(stderr, "unregister_minor: minor too big (%d).\n", minor);
    return -1;
  }
  linkname_from_minor(buf, minor);
  if (unlink(buf) < 0) {
    if (errno != ENOENT) {
      perror("unlink");
      return -1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<unregister_minor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x100,-0x8(%rbp)
jge    1165 <unregister_minor+0x25>
cmpl   $0x0,-0x8(%rbp)
jge    1189 <unregister_minor+0x49>
mov    0x2e74(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
lea    0xe88(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ec <unregister_minor+0xac>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1040 <linkname_from_minor@plt>
lea    -0x110(%rbp),%rdi
call   1030 <unlink@plt>
cmp    $0x0,%rax
jge    11e5 <unregister_minor+0xa5>
mov    0x2e23(%rip),%rax
mov    (%rax),%rax
mov    0x2e09(%rip),%rcx
cmp    (%rcx),%rax
je     11e0 <unregister_minor+0xa0>
lea    0xe58(%rip),%rdi
call   1060 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ec <unregister_minor+0xac>
jmp    11e5 <unregister_minor+0xa5>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unregister_minor>:
push   %rbx
sub    $0x100,%rsp
mov    %edi,%edx
cmp    $0x100,%edi
jb     116e <unregister_minor+0x2e>
mov    0x2e87(%rip),%rax
mov    (%rax),%edi
lea    0xe9e(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xffffffff,%eax
jmp    11a3 <unregister_minor+0x63>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %edx,%esi
call   1040 <linkname_from_minor@plt>
mov    %rbx,%rdi
call   1030 <unlink@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jns    11a3 <unregister_minor+0x63>
mov    0x2e44(%rip),%rcx
mov    (%rcx),%rcx
mov    0x2e2a(%rip),%rdx
cmp    (%rdx),%rcx
jne    11ac <unregister_minor+0x6c>
add    $0x100,%rsp
pop    %rbx
ret
lea    0xe74(%rip),%rdi
call   1060 <perror@plt>
jmp    1167 <unregister_minor+0x27>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [39 x i8] c"unregister_minor: minor too big (%d).\0A\00"
@errno = global i64 0
@ENOENT = global i64 0
@.str.1 = [7 x i8] c"unlink\00"
define i32 @unregister_minor(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [255 x i8]
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = icmp sge i32 %5, 256
br i1 %6, label %10, label %7
7: ; preds = %1
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %7, %1
%11 = load i32, i32* @stderr
%12 = load i32, i32* %3
%13 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %12)
store i32 -1, i32* %2
br label %29
14: ; preds = %7
%15 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%16 = load i32, i32* %3
%17 = call i32 @linkname_from_minor(i8* %15, i32 %16)
%18 = getelementptr inbounds [255 x i8], [255 x i8]* %4, i64 0, i64 0
%19 = call i64 @unlink(i8* %18)
%20 = icmp slt i64 %19, 0
br i1 %20, label %21, label %28
21: ; preds = %14
%22 = load i64, i64* @errno
%23 = load i64, i64* @ENOENT
%24 = icmp ne i64 %22, %23
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %2
br label %29
27: ; preds = %21
br label %28
28: ; preds = %27, %14
store i32 0, i32* %2
br label %29
29: ; preds = %28, %25, %10
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [39 x i8] c"unregister_minor: minor too big (%d).\0A\00"
@errno = global i64 0
@ENOENT = global i64 0
@.str.1 = [7 x i8] c"unlink\00"
define i32 @unregister_minor(i32 %0) {
%2 = alloca [255 x i8]
%3 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%4 = icmp ugt i32 %0, 255
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %18
8: ; preds = %1
%9 = call i32 @linkname_from_minor(i8* %3, i32 %0)
%10 = call i64 @unlink(i8* %3)
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %18
12: ; preds = %8
%13 = load i64, i64* @errno
%14 = load i64, i64* @ENOENT
%15 = icmp eq i64 %13, %14
br i1 %15, label %18, label %16
16: ; preds = %12
%17 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %8, %12, %16, %5
%19 = phi i32 [ -1, %5 ], [ -1, %16 ], [ 0, %12 ], [ 0, %8 ]
ret i32 %19
}