#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_resource_name(char *, char const *);
int /*<<< orphan*/ perror(char *);
scalar_t__ unlink(char *);
int unregister_resource(const char *name) {
  char linkname[PATH_MAX];
  linkname_from_resource_name(linkname, name);
  if (unlink(linkname) != 0) {
    if (errno != ENOENT) {
      perror(linkname);
      return -1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<unregister_resource>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2ead(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x30(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rsi
call   1050 <linkname_from_resource_name@plt>
mov    -0x30(%rbp),%rdi
call   1030 <unlink@plt>
cmp    $0x0,%rax
je     11bf <unregister_resource+0x8f>
mov    0x2e4d(%rip),%rax
mov    (%rax),%rax
mov    0x2e33(%rip),%rcx
cmp    (%rcx),%rax
je     11ba <unregister_resource+0x8a>
mov    -0x30(%rbp),%rdi
call   1040 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x24(%rbp)
jmp    11cd <unregister_resource+0x9d>
jmp    11bf <unregister_resource+0x8f>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unregister_resource>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
push   %rax
mov    %rdi,%rsi
mov    0x2eb0(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
call   1050 <linkname_from_resource_name@plt>
mov    %rbx,%rdi
call   1030 <unlink@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
je     1183 <unregister_resource+0x53>
mov    0x2e64(%rip),%rcx
mov    (%rcx),%rcx
mov    0x2e4a(%rip),%rdx
cmp    (%rdx),%rcx
jne    118a <unregister_resource+0x5a>
lea    -0x8(%rbp),%rsp
pop    %rbx
pop    %rbp
ret
mov    %rbx,%rdi
call   1040 <perror@plt>
mov    $0xffffffff,%eax
jmp    1183 <unregister_resource+0x53>

LLVM IR (-O0):
@PATH_MAX = global i32 0
@errno = global i64 0
@ENOENT = global i64 0
define i32 @unregister_resource(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
store i8* %0, i8** %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 i8*, i8** %3
%12 = call i32 @linkname_from_resource_name(i8* %10, i8* %11)
%13 = call i64 @unlink(i8* %10)
%14 = icmp ne 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* %10)
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
define i32 @unregister_resource(i8* %0) {
%2 = load i32, i32* @PATH_MAX
%3 = zext i32 %2 to i64
%4 = alloca i8, i64 %3
%5 = call i32 @linkname_from_resource_name(i8* %4, i8* %0)
%6 = call i64 @unlink(i8* %4)
%7 = icmp eq i64 %6, 0
br i1 %7, label %14, label %8
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* %4)
br label %14
14: ; preds = %1, %8, %12
%15 = phi i32 [ -1, %12 ], [ 0, %8 ], [ 0, %1 ]
ret i32 %15
}