int main() {
  void *global;
  void *library;
  char *error;
  int (*function)(void);
  int ret;
  library = dlopen("testdll.dll", (1 << 1));
  if (!library) {
    error = dlerror();
    printf("Could not open library globally: %s\n", error ? error : "");
  } else
    printf("Opened library globally: %p\n", library);
  global = dlopen(0, (1 << 1));
  if (!global) {
    error = dlerror();
    printf("Could not open global handle: %s\n", error ? error : "");
  } else
    printf("Got global handle: %p\n", global);
  function = dlsym(library, "function");
  if (!function) {
    error = dlerror();
    printf("Could not get symbol from library handle: %s\n",
           error ? error : "");
  } else
    printf("Got symbol from library handle: %p\n", function);
  if (function)
    function();
  function = dlsym(global, "function");
  if (!function) {
    error = dlerror();
    printf("Could not get symbol from global handle: %s\n", error ? error : "");
  } else
    printf("Got symbol from global handle: %p\n", function);
  if (function)
    function();
  ret = dlclose(library);
  if (ret) {
    error = dlerror();
    printf("Could not close library: %s\n", error ? error : "");
  } else
    printf("Closed library.\n");
  library = dlopen("testdll.dll", (1 << 2));
  if (!library) {
    error = dlerror();
    printf("Could not open library locally: %s\n", error ? error : "");
  } else
    printf("Opened library locally: %p\n", library);
  function = dlsym(library, "function");
  if (!function) {
    error = dlerror();
    printf("Could not get symbol from library handle: %s\n",
           error ? error : "");
  } else
    printf("Got symbol from library handle: %p\n", function);
  if (function)
    function();
  function = dlsym(global, "function");
  if (!function) {
    error = dlerror();
    printf("Could not get symbol from global handle: %s\n", error ? error : "");
  } else
    printf("Got symbol from global handle: %p\n", function);
  if (function)
    function();
  ret = dlclose(library);
  if (ret) {
    error = dlerror();
    printf("Could not close library: %s\n", error ? error : "");
  } else
    printf("Closed library.\n");
  ret = dlclose(global);
  if (ret) {
    error = dlerror();
    printf("Could not close global handle: %s\n", error ? error : "");
  } else
    printf("Closed global handle.\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe97(%rip),%rdi
mov    $0x2,%esi
mov    $0x0,%al
call   1050 <dlopen@plt>
cltq
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11d2 <main+0x82>
mov    $0x0,%al
call   1030 <dlerror@plt>
cltq
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11ab <main+0x5b>
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    11bb <main+0x6b>
lea    0x1027(%rip),%rax
mov    %rax,-0x38(%rbp)
jmp    11bb <main+0x6b>
mov    -0x38(%rbp),%rsi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11e4 <main+0x94>
mov    -0x18(%rbp),%rsi
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
mov    $0x2,%esi
mov    $0x0,%al
call   1050 <dlopen@plt>
cltq
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    124f <main+0xff>
mov    $0x0,%al
call   1030 <dlerror@plt>
cltq
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1228 <main+0xd8>
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
jmp    1238 <main+0xe8>
lea    0xfaa(%rip),%rax
mov    %rax,-0x40(%rbp)
jmp    1238 <main+0xe8>
mov    -0x40(%rbp),%rsi
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1261 <main+0x111>
mov    -0x10(%rbp),%rsi
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe1b(%rip),%rsi
mov    $0x0,%al
call   1060 <dlsym@plt>
cltq
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    12d0 <main+0x180>
mov    $0x0,%al
call   1030 <dlerror@plt>
cltq
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     12a9 <main+0x159>
mov    -0x20(%rbp),%rax
mov    %rax,-0x48(%rbp)
jmp    12b9 <main+0x169>
lea    0xf29(%rip),%rax
mov    %rax,-0x48(%rbp)
jmp    12b9 <main+0x169>
mov    -0x48(%rbp),%rsi
lea    0xdcc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12e2 <main+0x192>
mov    -0x28(%rbp),%rsi
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x0,-0x28(%rbp)
je     12f0 <main+0x1a0>
call   *-0x28(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xd8c(%rip),%rsi
mov    $0x0,%al
call   1060 <dlsym@plt>
cltq
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    135f <main+0x20f>
mov    $0x0,%al
call   1030 <dlerror@plt>
cltq
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1338 <main+0x1e8>
mov    -0x20(%rbp),%rax
mov    %rax,-0x50(%rbp)
jmp    1348 <main+0x1f8>
lea    0xe9a(%rip),%rax
mov    %rax,-0x50(%rbp)
jmp    1348 <main+0x1f8>
mov    -0x50(%rbp),%rsi
lea    0xd8f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1371 <main+0x221>
mov    -0x28(%rbp),%rsi
lea    0xda5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x0,-0x28(%rbp)
je     137f <main+0x22f>
call   *-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x0,%al
call   1070 <dlclose@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     13e3 <main+0x293>
mov    $0x0,%al
call   1030 <dlerror@plt>
cltq
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     13bc <main+0x26c>
mov    -0x20(%rbp),%rax
mov    %rax,-0x58(%rbp)
jmp    13cc <main+0x27c>
lea    0xe16(%rip),%rax
mov    %rax,-0x58(%rbp)
jmp    13cc <main+0x27c>
mov    -0x58(%rbp),%rsi
lea    0xd5b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13f1 <main+0x2a1>
lea    0xd65(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xc08(%rip),%rdi
mov    $0x4,%esi
mov    $0x0,%al
call   1050 <dlopen@plt>
cltq
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1461 <main+0x311>
mov    $0x0,%al
call   1030 <dlerror@plt>
cltq
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     143a <main+0x2ea>
mov    -0x20(%rbp),%rax
mov    %rax,-0x60(%rbp)
jmp    144a <main+0x2fa>
lea    0xd98(%rip),%rax
mov    %rax,-0x60(%rbp)
jmp    144a <main+0x2fa>
mov    -0x60(%rbp),%rsi
lea    0xd0b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1473 <main+0x323>
mov    -0x18(%rbp),%rsi
lea    0xd18(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    0xc09(%rip),%rsi
mov    $0x0,%al
call   1060 <dlsym@plt>
cltq
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    14e2 <main+0x392>
mov    $0x0,%al
call   1030 <dlerror@plt>
cltq
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     14bb <main+0x36b>
mov    -0x20(%rbp),%rax
mov    %rax,-0x68(%rbp)
jmp    14cb <main+0x37b>
lea    0xd17(%rip),%rax
mov    %rax,-0x68(%rbp)
jmp    14cb <main+0x37b>
mov    -0x68(%rbp),%rsi
lea    0xbba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    14f4 <main+0x3a4>
mov    -0x28(%rbp),%rsi
lea    0xbd1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x0,-0x28(%rbp)
je     1502 <main+0x3b2>
call   *-0x28(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xb7a(%rip),%rsi
mov    $0x0,%al
call   1060 <dlsym@plt>
cltq
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1571 <main+0x421>
mov    $0x0,%al
call   1030 <dlerror@plt>
cltq
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     154a <main+0x3fa>
mov    -0x20(%rbp),%rax
mov    %rax,-0x70(%rbp)
jmp    155a <main+0x40a>
lea    0xc88(%rip),%rax
mov    %rax,-0x70(%rbp)
jmp    155a <main+0x40a>
mov    -0x70(%rbp),%rsi
lea    0xb7d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1583 <main+0x433>
mov    -0x28(%rbp),%rsi
lea    0xb93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x0,-0x28(%rbp)
je     1591 <main+0x441>
call   *-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x0,%al
call   1070 <dlclose@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     15f5 <main+0x4a5>
mov    $0x0,%al
call   1030 <dlerror@plt>
cltq
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     15ce <main+0x47e>
mov    -0x20(%rbp),%rax
mov    %rax,-0x78(%rbp)
jmp    15de <main+0x48e>
lea    0xc04(%rip),%rax
mov    %rax,-0x78(%rbp)
jmp    15de <main+0x48e>
mov    -0x78(%rbp),%rsi
lea    0xb49(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1603 <main+0x4b3>
lea    0xb53(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1070 <dlclose@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     1667 <main+0x517>
mov    $0x0,%al
call   1030 <dlerror@plt>
cltq
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1640 <main+0x4f0>
mov    -0x20(%rbp),%rax
mov    %rax,-0x80(%rbp)
jmp    1650 <main+0x500>
lea    0xb92(%rip),%rax
mov    %rax,-0x80(%rbp)
jmp    1650 <main+0x500>
mov    -0x80(%rbp),%rsi
lea    0xb45(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1675 <main+0x525>
lea    0xb55(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
lea    0xe94(%rip),%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1060 <dlopen@plt>
movslq %eax,%r15
test   %r15d,%r15d
je     118c <main+0x2c>
lea    0xeaa(%rip),%rdi
mov    %r15,%rsi
jmp    11a9 <main+0x49>
xor    %eax,%eax
call   1030 <dlerror@plt>
cltq
test   %eax,%eax
lea    0xf93(%rip),%rsi
cmovne %rax,%rsi
lea    0xe63(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
mov    $0x2,%esi
xor    %eax,%eax
call   1060 <dlopen@plt>
movslq %eax,%r14
test   %r14d,%r14d
je     11d2 <main+0x72>
lea    0xea3(%rip),%rdi
mov    %r14,%rsi
jmp    11ef <main+0x8f>
xor    %eax,%eax
call   1030 <dlerror@plt>
cltq
test   %eax,%eax
lea    0xf4d(%rip),%rsi
cmovne %rax,%rsi
lea    0xe5f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe8a(%rip),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1070 <dlsym@plt>
test   %eax,%eax
je     1223 <main+0xc3>
movslq %eax,%rbx
lea    0xea9(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
call   *%rbx
jmp    1247 <main+0xe7>
xor    %eax,%eax
call   1030 <dlerror@plt>
cltq
test   %eax,%eax
lea    0xefc(%rip),%rsi
cmovne %rax,%rsi
lea    0xe50(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe39(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <dlsym@plt>
test   %eax,%eax
je     1274 <main+0x114>
movslq %eax,%rbx
lea    0xea9(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
call   *%rbx
jmp    1298 <main+0x138>
xor    %eax,%eax
call   1030 <dlerror@plt>
cltq
test   %eax,%eax
lea    0xeab(%rip),%rsi
cmovne %rax,%rsi
lea    0xe51(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1080 <dlclose@plt>
test   %eax,%eax
je     12cc <main+0x16c>
xor    %eax,%eax
call   1030 <dlerror@plt>
cltq
test   %eax,%eax
lea    0xe79(%rip),%rsi
cmovne %rax,%rsi
lea    0xe6f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    12d8 <main+0x178>
lea    0xedf(%rip),%rdi
call   1040 <puts@plt>
lea    0xd21(%rip),%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1060 <dlopen@plt>
movslq %eax,%r15
test   %r15d,%r15d
je     12ff <main+0x19f>
lea    0xe79(%rip),%rdi
mov    %r15,%rsi
jmp    131c <main+0x1bc>
xor    %eax,%eax
call   1030 <dlerror@plt>
cltq
test   %eax,%eax
lea    0xe20(%rip),%rsi
cmovne %rax,%rsi
lea    0xe33(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd5d(%rip),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1070 <dlsym@plt>
test   %eax,%eax
je     1350 <main+0x1f0>
movslq %eax,%rbx
lea    0xd7c(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
call   *%rbx
jmp    1374 <main+0x214>
xor    %eax,%eax
call   1030 <dlerror@plt>
cltq
test   %eax,%eax
lea    0xdcf(%rip),%rsi
cmovne %rax,%rsi
lea    0xd23(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd0c(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <dlsym@plt>
test   %eax,%eax
je     13a1 <main+0x241>
movslq %eax,%rbx
lea    0xd7c(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
call   *%rbx
jmp    13c5 <main+0x265>
xor    %eax,%eax
call   1030 <dlerror@plt>
cltq
test   %eax,%eax
lea    0xd7e(%rip),%rsi
cmovne %rax,%rsi
lea    0xd24(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1080 <dlclose@plt>
test   %eax,%eax
je     13f9 <main+0x299>
xor    %eax,%eax
call   1030 <dlerror@plt>
cltq
test   %eax,%eax
lea    0xd4c(%rip),%rsi
cmovne %rax,%rsi
lea    0xd42(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1405 <main+0x2a5>
lea    0xdb2(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1080 <dlclose@plt>
test   %eax,%eax
je     1439 <main+0x2d9>
xor    %eax,%eax
call   1030 <dlerror@plt>
cltq
test   %eax,%eax
lea    0xd0c(%rip),%rsi
cmovne %rax,%rsi
lea    0xd5f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1445 <main+0x2e5>
lea    0xd82(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [12 x i8] c"testdll.dll\00"
@.str.1 = [37 x i8] c"Could not open library globally: %s\0A\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [29 x i8] c"Opened library globally: %p\0A\00"
@.str.4 = [34 x i8] c"Could not open global handle: %s\0A\00"
@.str.5 = [23 x i8] c"Got global handle: %p\0A\00"
@.str.6 = [9 x i8] c"function\00"
@.str.7 = [46 x i8] c"Could not get symbol from library handle: %s\0A\00"
@.str.8 = [36 x i8] c"Got symbol from library handle: %p\0A\00"
@.str.9 = [45 x i8] c"Could not get symbol from global handle: %s\0A\00"
@.str.10 = [35 x i8] c"Got symbol from global handle: %p\0A\00"
@.str.11 = [29 x i8] c"Could not close library: %s\0A\00"
@.str.12 = [17 x i8] c"Closed library.\0A\00"
@.str.13 = [36 x i8] c"Could not open library locally: %s\0A\00"
@.str.14 = [28 x i8] c"Opened library locally: %p\0A\00"
@.str.15 = [35 x i8] c"Could not close global handle: %s\0A\00"
@.str.16 = [23 x i8] c"Closed global handle.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32 ()*
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @dlopen to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 2)
%8 = sext i32 %7 to i64
%9 = inttoptr i64 %8 to i8*
store i8* %9, i8** %3
%10 = load i8*, i8** %3
%11 = icmp ne i8* %10, null
br i1 %11, label %24, label %12
12: ; preds = %0
%13 = call i32 (...) @dlerror()
%14 = sext i32 %13 to i64
%15 = inttoptr i64 %14 to i8*
store i8* %15, i8** %4
%16 = load i8*, i8** %4
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %20
18: ; preds = %12
%19 = load i8*, i8** %4
br label %21
20: ; preds = %12
br label %21
21: ; preds = %20, %18
%22 = phi i8* [ %19, %18 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), %20 ]
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %22)
br label %27
24: ; preds = %0
%25 = load i8*, i8** %3
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i8* %25)
br label %27
27: ; preds = %24, %21
%28 = call i32 (i32, i32, ...) bitcast (i32 (...)* @dlopen to i32 (i32, i32, ...)*)(i32 0, i32 2)
%29 = sext i32 %28 to i64
%30 = inttoptr i64 %29 to i8*
store i8* %30, i8** %2
%31 = load i8*, i8** %2
%32 = icmp ne i8* %31, null
br i1 %32, label %45, label %33
33: ; preds = %27
%34 = call i32 (...) @dlerror()
%35 = sext i32 %34 to i64
%36 = inttoptr i64 %35 to i8*
store i8* %36, i8** %4
%37 = load i8*, i8** %4
%38 = icmp ne i8* %37, null
br i1 %38, label %39, label %41
39: ; preds = %33
%40 = load i8*, i8** %4
br label %42
41: ; preds = %33
br label %42
42: ; preds = %41, %39
%43 = phi i8* [ %40, %39 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), %41 ]
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i8* %43)
br label %48
45: ; preds = %27
%46 = load i8*, i8** %2
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %46)
br label %48
48: ; preds = %45, %42
%49 = load i8*, i8** %3
%50 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @dlsym to i32 (i8*, i8*, ...)*)(i8* %49, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%51 = sext i32 %50 to i64
%52 = inttoptr i64 %51 to i32 ()*
store i32 ()* %52, i32 ()** %5
%53 = load i32 ()*, i32 ()** %5
%54 = icmp ne i32 ()* %53, null
br i1 %54, label %67, label %55
55: ; preds = %48
%56 = call i32 (...) @dlerror()
%57 = sext i32 %56 to i64
%58 = inttoptr i64 %57 to i8*
store i8* %58, i8** %4
%59 = load i8*, i8** %4
%60 = icmp ne i8* %59, null
br i1 %60, label %61, label %63
61: ; preds = %55
%62 = load i8*, i8** %4
br label %64
63: ; preds = %55
br label %64
64: ; preds = %63, %61
%65 = phi i8* [ %62, %61 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), %63 ]
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.7, i64 0, i64 0), i8* %65)
br label %70
67: ; preds = %48
%68 = load i32 ()*, i32 ()** %5
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0), i32 ()* %68)
br label %70
70: ; preds = %67, %64
%71 = load i32 ()*, i32 ()** %5
%72 = icmp ne i32 ()* %71, null
br i1 %72, label %73, label %76
73: ; preds = %70
%74 = load i32 ()*, i32 ()** %5
%75 = call i32 %74()
br label %76
76: ; preds = %73, %70
%77 = load i8*, i8** %2
%78 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @dlsym to i32 (i8*, i8*, ...)*)(i8* %77, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%79 = sext i32 %78 to i64
%80 = inttoptr i64 %79 to i32 ()*
store i32 ()* %80, i32 ()** %5
%81 = load i32 ()*, i32 ()** %5
%82 = icmp ne i32 ()* %81, null
br i1 %82, label %95, label %83
83: ; preds = %76
%84 = call i32 (...) @dlerror()
%85 = sext i32 %84 to i64
%86 = inttoptr i64 %85 to i8*
store i8* %86, i8** %4
%87 = load i8*, i8** %4
%88 = icmp ne i8* %87, null
br i1 %88, label %89, label %91
89: ; preds = %83
%90 = load i8*, i8** %4
br label %92
91: ; preds = %83
br label %92
92: ; preds = %91, %89
%93 = phi i8* [ %90, %89 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), %91 ]
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.9, i64 0, i64 0), i8* %93)
br label %98
95: ; preds = %76
%96 = load i32 ()*, i32 ()** %5
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.10, i64 0, i64 0), i32 ()* %96)
br label %98
98: ; preds = %95, %92
%99 = load i32 ()*, i32 ()** %5
%100 = icmp ne i32 ()* %99, null
br i1 %100, label %101, label %104
101: ; preds = %98
%102 = load i32 ()*, i32 ()** %5
%103 = call i32 %102()
br label %104
104: ; preds = %101, %98
%105 = load i8*, i8** %3
%106 = call i32 (i8*, ...) bitcast (i32 (...)* @dlclose to i32 (i8*, ...)*)(i8* %105)
store i32 %106, i32* %6
%107 = load i32, i32* %6
%108 = icmp ne i32 %107, 0
br i1 %108, label %109, label %121
109: ; preds = %104
%110 = call i32 (...) @dlerror()
%111 = sext i32 %110 to i64
%112 = inttoptr i64 %111 to i8*
store i8* %112, i8** %4
%113 = load i8*, i8** %4
%114 = icmp ne i8* %113, null
br i1 %114, label %115, label %117
115: ; preds = %109
%116 = load i8*, i8** %4
br label %118
117: ; preds = %109
br label %118
118: ; preds = %117, %115
%119 = phi i8* [ %116, %115 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), %117 ]
%120 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.11, i64 0, i64 0), i8* %119)
br label %123
121: ; preds = %104
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.12, i64 0, i64 0))
br label %123
123: ; preds = %121, %118
%124 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @dlopen to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 4)
%125 = sext i32 %124 to i64
%126 = inttoptr i64 %125 to i8*
store i8* %126, i8** %3
%127 = load i8*, i8** %3
%128 = icmp ne i8* %127, null
br i1 %128, label %141, label %129
129: ; preds = %123
%130 = call i32 (...) @dlerror()
%131 = sext i32 %130 to i64
%132 = inttoptr i64 %131 to i8*
store i8* %132, i8** %4
%133 = load i8*, i8** %4
%134 = icmp ne i8* %133, null
br i1 %134, label %135, label %137
135: ; preds = %129
%136 = load i8*, i8** %4
br label %138
137: ; preds = %129
br label %138
138: ; preds = %137, %135
%139 = phi i8* [ %136, %135 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), %137 ]
%140 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.13, i64 0, i64 0), i8* %139)
br label %144
141: ; preds = %123
%142 = load i8*, i8** %3
%143 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.14, i64 0, i64 0), i8* %142)
br label %144
144: ; preds = %141, %138
%145 = load i8*, i8** %3
%146 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @dlsym to i32 (i8*, i8*, ...)*)(i8* %145, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%147 = sext i32 %146 to i64
%148 = inttoptr i64 %147 to i32 ()*
store i32 ()* %148, i32 ()** %5
%149 = load i32 ()*, i32 ()** %5
%150 = icmp ne i32 ()* %149, null
br i1 %150, label %163, label %151
151: ; preds = %144
%152 = call i32 (...) @dlerror()
%153 = sext i32 %152 to i64
%154 = inttoptr i64 %153 to i8*
store i8* %154, i8** %4
%155 = load i8*, i8** %4
%156 = icmp ne i8* %155, null
br i1 %156, label %157, label %159
157: ; preds = %151
%158 = load i8*, i8** %4
br label %160
159: ; preds = %151
br label %160
160: ; preds = %159, %157
%161 = phi i8* [ %158, %157 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), %159 ]
%162 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.7, i64 0, i64 0), i8* %161)
br label %166
163: ; preds = %144
%164 = load i32 ()*, i32 ()** %5
%165 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0), i32 ()* %164)
br label %166
166: ; preds = %163, %160
%167 = load i32 ()*, i32 ()** %5
%168 = icmp ne i32 ()* %167, null
br i1 %168, label %169, label %172
169: ; preds = %166
%170 = load i32 ()*, i32 ()** %5
%171 = call i32 %170()
br label %172
172: ; preds = %169, %166
%173 = load i8*, i8** %2
%174 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @dlsym to i32 (i8*, i8*, ...)*)(i8* %173, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%175 = sext i32 %174 to i64
%176 = inttoptr i64 %175 to i32 ()*
store i32 ()* %176, i32 ()** %5
%177 = load i32 ()*, i32 ()** %5
%178 = icmp ne i32 ()* %177, null
br i1 %178, label %191, label %179
179: ; preds = %172
%180 = call i32 (...) @dlerror()
%181 = sext i32 %180 to i64
%182 = inttoptr i64 %181 to i8*
store i8* %182, i8** %4
%183 = load i8*, i8** %4
%184 = icmp ne i8* %183, null
br i1 %184, label %185, label %187
185: ; preds = %179
%186 = load i8*, i8** %4
br label %188
187: ; preds = %179
br label %188
188: ; preds = %187, %185
%189 = phi i8* [ %186, %185 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), %187 ]
%190 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.9, i64 0, i64 0), i8* %189)
br label %194
191: ; preds = %172
%192 = load i32 ()*, i32 ()** %5
%193 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.10, i64 0, i64 0), i32 ()* %192)
br label %194
194: ; preds = %191, %188
%195 = load i32 ()*, i32 ()** %5
%196 = icmp ne i32 ()* %195, null
br i1 %196, label %197, label %200
197: ; preds = %194
%198 = load i32 ()*, i32 ()** %5
%199 = call i32 %198()
br label %200
200: ; preds = %197, %194
%201 = load i8*, i8** %3
%202 = call i32 (i8*, ...) bitcast (i32 (...)* @dlclose to i32 (i8*, ...)*)(i8* %201)
store i32 %202, i32* %6
%203 = load i32, i32* %6
%204 = icmp ne i32 %203, 0
br i1 %204, label %205, label %217
205: ; preds = %200
%206 = call i32 (...) @dlerror()
%207 = sext i32 %206 to i64
%208 = inttoptr i64 %207 to i8*
store i8* %208, i8** %4
%209 = load i8*, i8** %4
%210 = icmp ne i8* %209, null
br i1 %210, label %211, label %213
211: ; preds = %205
%212 = load i8*, i8** %4
br label %214
213: ; preds = %205
br label %214
214: ; preds = %213, %211
%215 = phi i8* [ %212, %211 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), %213 ]
%216 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.11, i64 0, i64 0), i8* %215)
br label %219
217: ; preds = %200
%218 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.12, i64 0, i64 0))
br label %219
219: ; preds = %217, %214
%220 = load i8*, i8** %2
%221 = call i32 (i8*, ...) bitcast (i32 (...)* @dlclose to i32 (i8*, ...)*)(i8* %220)
store i32 %221, i32* %6
%222 = load i32, i32* %6
%223 = icmp ne i32 %222, 0
br i1 %223, label %224, label %236
224: ; preds = %219
%225 = call i32 (...) @dlerror()
%226 = sext i32 %225 to i64
%227 = inttoptr i64 %226 to i8*
store i8* %227, i8** %4
%228 = load i8*, i8** %4
%229 = icmp ne i8* %228, null
br i1 %229, label %230, label %232
230: ; preds = %224
%231 = load i8*, i8** %4
br label %233
232: ; preds = %224
br label %233
233: ; preds = %232, %230
%234 = phi i8* [ %231, %230 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), %232 ]
%235 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.15, i64 0, i64 0), i8* %234)
br label %238
236: ; preds = %219
%237 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.16, i64 0, i64 0))
br label %238
238: ; preds = %236, %233
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"testdll.dll\00"
@.str.1 = [37 x i8] c"Could not open library globally: %s\0A\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [29 x i8] c"Opened library globally: %p\0A\00"
@.str.4 = [34 x i8] c"Could not open global handle: %s\0A\00"
@.str.5 = [23 x i8] c"Got global handle: %p\0A\00"
@.str.6 = [9 x i8] c"function\00"
@.str.7 = [46 x i8] c"Could not get symbol from library handle: %s\0A\00"
@.str.8 = [36 x i8] c"Got symbol from library handle: %p\0A\00"
@.str.9 = [45 x i8] c"Could not get symbol from global handle: %s\0A\00"
@.str.10 = [35 x i8] c"Got symbol from global handle: %p\0A\00"
@.str.11 = [29 x i8] c"Could not close library: %s\0A\00"
@.str.13 = [36 x i8] c"Could not open library locally: %s\0A\00"
@.str.14 = [28 x i8] c"Opened library locally: %p\0A\00"
@.str.15 = [35 x i8] c"Could not close global handle: %s\0A\00"
@str.17 = [16 x i8] c"Closed library.\00"
@str.18 = [22 x i8] c"Closed global handle.\00"
define i32 @main() {
%1 = tail call i32 (i8*, i32, ...) bitcast (i32 (...)* @dlopen to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 2)
%2 = sext i32 %1 to i64
%3 = inttoptr i64 %2 to i8*
%4 = icmp eq i32 %1, 0
br i1 %4, label %5, label %12
5: ; preds = %0
%6 = tail call i32 (...) @dlerror()
%7 = sext i32 %6 to i64
%8 = inttoptr i64 %7 to i8*
%9 = icmp eq i32 %6, 0
%10 = select i1 %9, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* %8
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %10)
br label %14
12: ; preds = %0
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i8* %3)
br label %14
14: ; preds = %12, %5
%15 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @dlopen to i32 (i32, i32, ...)*)(i32 0, i32 2)
%16 = sext i32 %15 to i64
%17 = inttoptr i64 %16 to i8*
%18 = icmp eq i32 %15, 0
br i1 %18, label %19, label %26
19: ; preds = %14
%20 = tail call i32 (...) @dlerror()
%21 = sext i32 %20 to i64
%22 = inttoptr i64 %21 to i8*
%23 = icmp eq i32 %20, 0
%24 = select i1 %23, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* %22
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i8* %24)
br label %28
26: ; preds = %14
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %17)
br label %28
28: ; preds = %26, %19
%29 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @dlsym to i32 (i8*, i8*, ...)*)(i8* %3, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%30 = sext i32 %29 to i64
%31 = inttoptr i64 %30 to i32 ()*
%32 = icmp eq i32 %29, 0
br i1 %32, label %33, label %40
33: ; preds = %28
%34 = tail call i32 (...) @dlerror()
%35 = sext i32 %34 to i64
%36 = inttoptr i64 %35 to i8*
%37 = icmp eq i32 %34, 0
%38 = select i1 %37, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* %36
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.7, i64 0, i64 0), i8* %38)
br label %43
40: ; preds = %28
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0), i32 ()* %31)
%42 = tail call i32 %31()
br label %43
43: ; preds = %33, %40
%44 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @dlsym to i32 (i8*, i8*, ...)*)(i8* %17, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%45 = sext i32 %44 to i64
%46 = inttoptr i64 %45 to i32 ()*
%47 = icmp eq i32 %44, 0
br i1 %47, label %48, label %55
48: ; preds = %43
%49 = tail call i32 (...) @dlerror()
%50 = sext i32 %49 to i64
%51 = inttoptr i64 %50 to i8*
%52 = icmp eq i32 %49, 0
%53 = select i1 %52, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* %51
%54 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.9, i64 0, i64 0), i8* %53)
br label %58
55: ; preds = %43
%56 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.10, i64 0, i64 0), i32 ()* %46)
%57 = tail call i32 %46()
br label %58
58: ; preds = %48, %55
%59 = tail call i32 (i8*, ...) bitcast (i32 (...)* @dlclose to i32 (i8*, ...)*)(i8* %3)
%60 = icmp eq i32 %59, 0
br i1 %60, label %68, label %61
61: ; preds = %58
%62 = tail call i32 (...) @dlerror()
%63 = sext i32 %62 to i64
%64 = inttoptr i64 %63 to i8*
%65 = icmp eq i32 %62, 0
%66 = select i1 %65, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* %64
%67 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.11, i64 0, i64 0), i8* %66)
br label %70
68: ; preds = %58
%69 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.17, i64 0, i64 0))
br label %70
70: ; preds = %68, %61
%71 = tail call i32 (i8*, i32, ...) bitcast (i32 (...)* @dlopen to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 4)
%72 = sext i32 %71 to i64
%73 = inttoptr i64 %72 to i8*
%74 = icmp eq i32 %71, 0
br i1 %74, label %75, label %82
75: ; preds = %70
%76 = tail call i32 (...) @dlerror()
%77 = sext i32 %76 to i64
%78 = inttoptr i64 %77 to i8*
%79 = icmp eq i32 %76, 0
%80 = select i1 %79, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* %78
%81 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.13, i64 0, i64 0), i8* %80)
br label %84
82: ; preds = %70
%83 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.14, i64 0, i64 0), i8* %73)
br label %84
84: ; preds = %82, %75
%85 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @dlsym to i32 (i8*, i8*, ...)*)(i8* %73, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%86 = sext i32 %85 to i64
%87 = inttoptr i64 %86 to i32 ()*
%88 = icmp eq i32 %85, 0
br i1 %88, label %89, label %96
89: ; preds = %84
%90 = tail call i32 (...) @dlerror()
%91 = sext i32 %90 to i64
%92 = inttoptr i64 %91 to i8*
%93 = icmp eq i32 %90, 0
%94 = select i1 %93, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* %92
%95 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.7, i64 0, i64 0), i8* %94)
br label %99
96: ; preds = %84
%97 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0), i32 ()* %87)
%98 = tail call i32 %87()
br label %99
99: ; preds = %89, %96
%100 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @dlsym to i32 (i8*, i8*, ...)*)(i8* %17, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%101 = sext i32 %100 to i64
%102 = inttoptr i64 %101 to i32 ()*
%103 = icmp eq i32 %100, 0
br i1 %103, label %104, label %111
104: ; preds = %99
%105 = tail call i32 (...) @dlerror()
%106 = sext i32 %105 to i64
%107 = inttoptr i64 %106 to i8*
%108 = icmp eq i32 %105, 0
%109 = select i1 %108, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* %107
%110 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.9, i64 0, i64 0), i8* %109)
br label %114
111: ; preds = %99
%112 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.10, i64 0, i64 0), i32 ()* %102)
%113 = tail call i32 %102()
br label %114
114: ; preds = %104, %111
%115 = tail call i32 (i8*, ...) bitcast (i32 (...)* @dlclose to i32 (i8*, ...)*)(i8* %73)
%116 = icmp eq i32 %115, 0
br i1 %116, label %124, label %117
117: ; preds = %114
%118 = tail call i32 (...) @dlerror()
%119 = sext i32 %118 to i64
%120 = inttoptr i64 %119 to i8*
%121 = icmp eq i32 %118, 0
%122 = select i1 %121, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* %120
%123 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.11, i64 0, i64 0), i8* %122)
br label %126
124: ; preds = %114
%125 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.17, i64 0, i64 0))
br label %126
126: ; preds = %124, %117
%127 = tail call i32 (i8*, ...) bitcast (i32 (...)* @dlclose to i32 (i8*, ...)*)(i8* %17)
%128 = icmp eq i32 %127, 0
br i1 %128, label %136, label %129
129: ; preds = %126
%130 = tail call i32 (...) @dlerror()
%131 = sext i32 %130 to i64
%132 = inttoptr i64 %131 to i8*
%133 = icmp eq i32 %130, 0
%134 = select i1 %133, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* %132
%135 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.15, i64 0, i64 0), i8* %134)
br label %138
136: ; preds = %126
%137 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.18, i64 0, i64 0))
br label %138
138: ; preds = %136, %129
ret i32 0
}