#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 */
int /*<<< orphan*/ EXIT_FAILURE;
int dlclose(void *);
char *dlerror();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int vdlclose(void *handle) {
  int i;
  i = dlclose(handle);
  if (i) {
    printf("Unload error %i: %s\n", i, dlerror());
    exit(EXIT_FAILURE);
  } else {
    printf("Unload, success!\n");
  }
  return i;
}


x86 assembly (clang, -O0):
<vdlclose>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <dlclose@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1191 <vdlclose+0x51>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1030 <dlerror@plt>
mov    -0x10(%rbp),%esi
mov    %rax,%rdx
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e56(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vdlclose>:
push   %rbx
call   1070 <dlclose@plt>
test   %eax,%eax
jne    116a <vdlclose+0x1a>
lea    0xeb4(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    %eax,%ebx
xor    %eax,%eax
call   1030 <dlerror@plt>
lea    0xe86(%rip),%rdi
mov    %ebx,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"Unload error %i: %s\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [18 x i8] c"Unload, success!\0A\00"
define i32 @vdlclose(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @dlclose(i8* %4)
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %14
8: ; preds = %1
%9 = load i32, i32* %3
%10 = call i8* (...) @dlerror()
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %9, i8* %10)
%12 = load i32, i32* @EXIT_FAILURE
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %1
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %16
16: ; preds = %14
%17 = load i32, i32* %3
ret i32 %17
}

LLVM IR (-O2):
@.str = [21 x i8] c"Unload error %i: %s\0A\00"
@EXIT_FAILURE = global i32 0
@str = [17 x i8] c"Unload, success!\00"
define i32 @vdlclose(i8* %0) {
%2 = tail call i32 @dlclose(i8* %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %9, label %4
4: ; preds = %1
%5 = tail call i8* (...) @dlerror()
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %2, i8* %5)
%7 = load i32, i32* @EXIT_FAILURE
%8 = tail call i32 @exit(i32 %7)
unreachable
9: ; preds = %1
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
ret i32 0
}