#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 RTLD_GLOBAL;
int RTLD_LAZY;
int RTLD_LOCAL;
int /*<<< orphan*/ dlclose(void *);
char *dlerror();
void *dlopen(char *, int);
void *dlsym(void *, char *);
int /*<<< orphan*/ printf(char *, ...);
int do_test(void) {
  unsigned int (*initial_getfoo)(void);
  void (*initial_setfoo)(unsigned int);
  unsigned int (*global_getfoo)(void);
  void (*global_setfoo)(unsigned int);
  unsigned int (*local_getfoo)(void);
  void (*local_setfoo)(unsigned int);
  unsigned int *initial_foop;
  unsigned int *global_foop;
  unsigned int *local_foop;
  void *initial_handle;
  void *global_handle;
  void *local_handle;
  unsigned int foo;
  initial_handle = dlopen(NULL, RTLD_LAZY | RTLD_GLOBAL);
  if (initial_handle == NULL) {
    printf("dlopen [initial] (NULL): %s\n", dlerror());
    return 1;
  }
  initial_foop = dlsym(initial_handle, "foo");
  if (initial_foop != NULL) {
    printf("dlsym [initial] (foo): got %p, expected NULL\n", initial_foop);
    return 1;
  }
  initial_getfoo = dlsym(initial_handle, "getfoo");
  if (initial_getfoo != NULL) {
    printf("dlsym [initial] (getfoo): got %p, expected NULL\n", initial_getfoo);
    return 1;
  }
  initial_setfoo = dlsym(initial_handle, "setfoo");
  if (initial_setfoo != NULL) {
    printf("dlsym [initial] (setfoo): got %p, expected NULL\n", initial_setfoo);
    return 1;
  }
  global_handle = dlopen("modstatic3.so", RTLD_LAZY | RTLD_GLOBAL);
  if (global_handle == NULL) {
    printf("dlopen [global] (modstatic3.so): %s\n", dlerror());
    return 1;
  }
  global_foop = dlsym(global_handle, "foo");
  if (global_foop == NULL) {
    printf("dlsym [global] (foo): %s\n", dlerror());
    return 1;
  }
  global_getfoo = dlsym(global_handle, "getfoo");
  if (global_getfoo == NULL) {
    printf("dlsym [global] (getfoo): %s\n", dlerror());
    return 1;
  }
  global_setfoo = dlsym(global_handle, "setfoo");
  if (global_setfoo == NULL) {
    printf("dlsym [global] (setfoo): %s\n", dlerror());
    return 1;
  }
  local_handle = dlopen(NULL, RTLD_LAZY | RTLD_LOCAL);
  if (local_handle == NULL) {
    printf("dlopen [local] (NULL): %s\n", dlerror());
    return 1;
  }
  local_foop = dlsym(local_handle, "foo");
  if (local_foop == NULL) {
    printf("dlsym [local] (foo): %s\n", dlerror());
    return 1;
  }
  local_getfoo = dlsym(local_handle, "getfoo");
  if (local_getfoo == NULL) {
    printf("dlsym [local] (getfoo): %s\n", dlerror());
    return 1;
  }
  local_setfoo = dlsym(local_handle, "setfoo");
  if (local_setfoo == NULL) {
    printf("dlsym [local] (setfoo): %s\n", dlerror());
    return 1;
  }
  initial_foop = dlsym(initial_handle, "foo");
  if (initial_foop == NULL) {
    printf("dlsym [initial] (foo): %s\n", dlerror());
    return 1;
  }
  initial_getfoo = dlsym(initial_handle, "getfoo");
  if (initial_getfoo == NULL) {
    printf("dlsym [initial] (getfoo): %s\n", dlerror());
    return 1;
  }
  initial_setfoo = dlsym(initial_handle, "setfoo");
  if (initial_setfoo == NULL) {
    printf("dlsym [initial] (setfoo): %s\n", dlerror());
    return 1;
  }
  foo = *initial_foop;
  if (foo != 0) {
    printf("*foop [initial]: got %#x, expected %#x\n", foo, 0);
    return 1;
  }
  foo = *global_foop;
  if (foo != 0) {
    printf("*foop [global]: got %#x, expected %#x\n", foo, 0);
    return 1;
  }
  foo = *local_foop;
  if (foo != 0) {
    printf("*foop [local]: got %#x, expected %#x\n", foo, 0);
    return 1;
  }
  foo = initial_getfoo();
  if (foo != 0) {
    printf("getfoo [initial]: got %#x, expected %#x\n", foo, 0);
    return 1;
  }
  foo = global_getfoo();
  if (foo != 0) {
    printf("getfoo [global]: got %#x, expected %#x\n", foo, 0);
    return 1;
  }
  foo = local_getfoo();
  if (foo != 0) {
    printf("getfoo [local]: got %#x, expected %#x\n", foo, 0);
    return 1;
  }
  initial_setfoo(0x5500ffaa);
  foo = *initial_foop;
  if (foo != 0x5500ffaa) {
    printf("*foop [initial]: got %#x, expected %#x\n", foo, 0x5500ffaa);
    return 1;
  }
  foo = *global_foop;
  if (foo != 0x5500ffaa) {
    printf("*foop [global]: got %#x, expected %#x\n", foo, 0x5500ffaa);
    return 1;
  }
  foo = *local_foop;
  if (foo != 0x5500ffaa) {
    printf("*foop [local]: got %#x, expected %#x\n", foo, 0x5500ffaa);
    return 1;
  }
  foo = initial_getfoo();
  if (foo != 0x5500ffaa) {
    printf("getfoo [initial]: got %#x, expected %#x\n", foo, 0x5500ffaa);
    return 1;
  }
  foo = global_getfoo();
  if (foo != 0x5500ffaa) {
    printf("getfoo [global]: got %#x, expected %#x\n", foo, 0x5500ffaa);
    return 1;
  }
  foo = local_getfoo();
  if (foo != 0x5500ffaa) {
    printf("getfoo [local]: got %#x, expected %#x\n", foo, 0x5500ffaa);
    return 1;
  }
  global_setfoo(0xaaff0055);
  foo = *initial_foop;
  if (foo != 0xaaff0055) {
    printf("*foop [initial]: got %#x, expected %#x\n", foo, 0xaaff0055);
    return 1;
  }
  foo = *global_foop;
  if (foo != 0xaaff0055) {
    printf("*foop [global]: got %#x, expected %#x\n", foo, 0xaaff0055);
    return 1;
  }
  foo = *local_foop;
  if (foo != 0xaaff0055) {
    printf("*foop [local]: got %#x, expected %#x\n", foo, 0xaaff0055);
    return 1;
  }
  foo = initial_getfoo();
  if (foo != 0xaaff0055) {
    printf("getfoo [initial]: got %#x, expected %#x\n", foo, 0xaaff0055);
    return 1;
  }
  foo = global_getfoo();
  if (foo != 0xaaff0055) {
    printf("getfoo [global]: got %#x, expected %#x\n", foo, 0xaaff0055);
    return 1;
  }
  foo = local_getfoo();
  if (foo != 0xaaff0055) {
    printf("getfoo [local]: got %#x, expected %#x\n", foo, 0xaaff0055);
    return 1;
  }
  local_setfoo(0xff55aa00);
  foo = *initial_foop;
  if (foo != 0xff55aa00) {
    printf("*foop [initial]: got %#x, expected %#x\n", foo, 0xff55aa00);
    return 1;
  }
  foo = *global_foop;
  if (foo != 0xff55aa00) {
    printf("*foop [global]: got %#x, expected %#x\n", foo, 0xff55aa00);
    return 1;
  }
  foo = *local_foop;
  if (foo != 0xff55aa00) {
    printf("*foop [local]: got %#x, expected %#x\n", foo, 0xff55aa00);
    return 1;
  }
  foo = initial_getfoo();
  if (foo != 0xff55aa00) {
    printf("getfoo [initial]: got %#x, expected %#x\n", foo, 0xff55aa00);
    return 1;
  }
  foo = global_getfoo();
  if (foo != 0xff55aa00) {
    printf("getfoo [global]: got %#x, expected %#x\n", foo, 0xff55aa00);
    return 1;
  }
  foo = local_getfoo();
  if (foo != 0xff55aa00) {
    printf("getfoo [local]: got %#x, expected %#x\n", foo, 0xff55aa00);
    return 1;
  }
  initial_getfoo = NULL;
  initial_setfoo = NULL;
  initial_foop = NULL;
  local_getfoo = NULL;
  local_setfoo = NULL;
  local_foop = NULL;
  dlclose(local_handle);
  global_getfoo = NULL;
  global_setfoo = NULL;
  global_foop = NULL;
  dlclose(global_handle);
  dlclose(initial_handle);
  return 0;
}


x86 assembly (clang, -O0):
<do_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0x2e79(%rip),%rax
mov    (%rax),%esi
mov    0x2e80(%rip),%rax
or     (%rax),%esi
xor    %eax,%eax
mov    %eax,%edi
call   1050 <dlopen@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    11a6 <do_test+0x56>
mov    $0x0,%al
call   1030 <dlerror@plt>
mov    %rax,%rsi
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1ad1 <do_test+0x981>
mov    -0x58(%rbp),%rdi
lea    0xe9d(%rip),%rsi
call   1060 <dlsym@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     11e3 <do_test+0x93>
mov    -0x40(%rbp),%rsi
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1ad1 <do_test+0x981>
mov    -0x58(%rbp),%rdi
lea    0xe5d(%rip),%rsi
call   1060 <dlsym@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1220 <do_test+0xd0>
mov    -0x10(%rbp),%rsi
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1ad1 <do_test+0x981>
mov    -0x58(%rbp),%rdi
lea    0xe58(%rip),%rsi
call   1060 <dlsym@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     125d <do_test+0x10d>
mov    -0x18(%rbp),%rsi
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1ad1 <do_test+0x981>
mov    0x2d74(%rip),%rax
mov    (%rax),%esi
mov    0x2d7b(%rip),%rax
or     (%rax),%esi
lea    0xe45(%rip),%rdi
call   1050 <dlopen@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
jne    12ae <do_test+0x15e>
mov    $0x0,%al
call   1030 <dlerror@plt>
mov    %rax,%rsi
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1ad1 <do_test+0x981>
mov    -0x60(%rbp),%rdi
lea    0xd95(%rip),%rsi
call   1060 <dlsym@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    12f1 <do_test+0x1a1>
mov    $0x0,%al
call   1030 <dlerror@plt>
mov    %rax,%rsi
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1ad1 <do_test+0x981>
mov    -0x60(%rbp),%rdi
lea    0xd4f(%rip),%rsi
call   1060 <dlsym@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1334 <do_test+0x1e4>
mov    $0x0,%al
call   1030 <dlerror@plt>
mov    %rax,%rsi
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1ad1 <do_test+0x981>
mov    -0x60(%rbp),%rdi
lea    0xd44(%rip),%rsi
call   1060 <dlsym@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1377 <do_test+0x227>
mov    $0x0,%al
call   1030 <dlerror@plt>
mov    %rax,%rsi
lea    0xdc1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1ad1 <do_test+0x981>
mov    0x2c5a(%rip),%rax
mov    (%rax),%esi
mov    0x2c41(%rip),%rax
or     (%rax),%esi
xor    %eax,%eax
mov    %eax,%edi
call   1050 <dlopen@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x68(%rbp)
jne    13c5 <do_test+0x275>
mov    $0x0,%al
call   1030 <dlerror@plt>
mov    %rax,%rsi
lea    0xd90(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1ad1 <do_test+0x981>
mov    -0x68(%rbp),%rdi
lea    0xc7e(%rip),%rsi
call   1060 <dlsym@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    1408 <do_test+0x2b8>
mov    $0x0,%al
call   1030 <dlerror@plt>
mov    %rax,%rsi
lea    0xd68(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1ad1 <do_test+0x981>
mov    -0x68(%rbp),%rdi
lea    0xc38(%rip),%rsi
call   1060 <dlsym@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    144b <do_test+0x2fb>
mov    $0x0,%al
call   1030 <dlerror@plt>
mov    %rax,%rsi
lea    0xd3e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1ad1 <do_test+0x981>
mov    -0x68(%rbp),%rdi
lea    0xc2d(%rip),%rsi
call   1060 <dlsym@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    148e <do_test+0x33e>
mov    $0x0,%al
call   1030 <dlerror@plt>
mov    %rax,%rsi
lea    0xd17(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1ad1 <do_test+0x981>
mov    -0x58(%rbp),%rdi
lea    0xbb5(%rip),%rsi
call   1060 <dlsym@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    14d1 <do_test+0x381>
mov    $0x0,%al
call   1030 <dlerror@plt>
mov    %rax,%rsi
lea    0xcf0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1ad1 <do_test+0x981>
mov    -0x58(%rbp),%rdi
lea    0xb6f(%rip),%rsi
call   1060 <dlsym@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1514 <do_test+0x3c4>
mov    $0x0,%al
call   1030 <dlerror@plt>
mov    %rax,%rsi
lea    0xcc8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1ad1 <do_test+0x981>
mov    -0x58(%rbp),%rdi
lea    0xb64(%rip),%rsi
call   1060 <dlsym@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1557 <do_test+0x407>
mov    $0x0,%al
call   1030 <dlerror@plt>
mov    %rax,%rsi
lea    0xca3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1ad1 <do_test+0x981>
mov    -0x40(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
cmpl   $0x0,-0x6c(%rbp)
je     1589 <do_test+0x439>
mov    -0x6c(%rbp),%esi
lea    0xc91(%rip),%rdi
xor    %edx,%edx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1ad1 <do_test+0x981>
mov    -0x48(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
cmpl   $0x0,-0x6c(%rbp)
je     15bb <do_test+0x46b>
mov    -0x6c(%rbp),%esi
lea    0xc87(%rip),%rdi
xor    %edx,%edx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1ad1 <do_test+0x981>
mov    -0x50(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
cmpl   $0x0,-0x6c(%rbp)
je     15ed <do_test+0x49d>
mov    -0x6c(%rbp),%esi
lea    0xc7c(%rip),%rdi
xor    %edx,%edx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1ad1 <do_test+0x981>
call   *-0x10(%rbp)
mov    %eax,-0x6c(%rbp)
cmpl   $0x0,-0x6c(%rbp)
je     161c <do_test+0x4cc>
mov    -0x6c(%rbp),%esi
lea    0xc73(%rip),%rdi
xor    %edx,%edx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1ad1 <do_test+0x981>
call   *-0x20(%rbp)
mov    %eax,-0x6c(%rbp)
cmpl   $0x0,-0x6c(%rbp)
je     164b <do_test+0x4fb>
mov    -0x6c(%rbp),%esi
lea    0xc6d(%rip),%rdi
xor    %edx,%edx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1ad1 <do_test+0x981>
call   *-0x30(%rbp)
mov    %eax,-0x6c(%rbp)
cmpl   $0x0,-0x6c(%rbp)
je     167a <do_test+0x52a>
mov    -0x6c(%rbp),%esi
lea    0xc66(%rip),%rdi
xor    %edx,%edx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1ad1 <do_test+0x981>
mov    $0x5500ffaa,%edi
call   *-0x18(%rbp)
mov    -0x40(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
cmpl   $0x5500ffaa,-0x6c(%rbp)
je     16ba <do_test+0x56a>
mov    -0x6c(%rbp),%esi
lea    0xb63(%rip),%rdi
mov    $0x5500ffaa,%edx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1ad1 <do_test+0x981>
mov    -0x48(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
cmpl   $0x5500ffaa,-0x6c(%rbp)
je     16f2 <do_test+0x5a2>
mov    -0x6c(%rbp),%esi
lea    0xb53(%rip),%rdi
mov    $0x5500ffaa,%edx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1ad1 <do_test+0x981>
mov    -0x50(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
cmpl   $0x5500ffaa,-0x6c(%rbp)
je     172a <do_test+0x5da>
mov    -0x6c(%rbp),%esi
lea    0xb42(%rip),%rdi
mov    $0x5500ffaa,%edx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1ad1 <do_test+0x981>
call   *-0x10(%rbp)
mov    %eax,-0x6c(%rbp)
cmpl   $0x5500ffaa,-0x6c(%rbp)
je     175f <do_test+0x60f>
mov    -0x6c(%rbp),%esi
lea    0xb33(%rip),%rdi
mov    $0x5500ffaa,%edx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1ad1 <do_test+0x981>
call   *-0x20(%rbp)
mov    %eax,-0x6c(%rbp)
cmpl   $0x5500ffaa,-0x6c(%rbp)
je     1794 <do_test+0x644>
mov    -0x6c(%rbp),%esi
lea    0xb27(%rip),%rdi
mov    $0x5500ffaa,%edx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1ad1 <do_test+0x981>
call   *-0x30(%rbp)
mov    %eax,-0x6c(%rbp)
cmpl   $0x5500ffaa,-0x6c(%rbp)
je     17c9 <do_test+0x679>
mov    -0x6c(%rbp),%esi
lea    0xb1a(%rip),%rdi
mov    $0x5500ffaa,%edx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1ad1 <do_test+0x981>
mov    $0xaaff0055,%edi
call   *-0x28(%rbp)
mov    -0x40(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
cmpl   $0xaaff0055,-0x6c(%rbp)
je     1809 <do_test+0x6b9>
mov    -0x6c(%rbp),%esi
lea    0xa14(%rip),%rdi
mov    $0xaaff0055,%edx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1ad1 <do_test+0x981>
mov    -0x48(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
cmpl   $0xaaff0055,-0x6c(%rbp)
je     1841 <do_test+0x6f1>
mov    -0x6c(%rbp),%esi
lea    0xa04(%rip),%rdi
mov    $0xaaff0055,%edx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1ad1 <do_test+0x981>
mov    -0x50(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
cmpl   $0xaaff0055,-0x6c(%rbp)
je     1879 <do_test+0x729>
mov    -0x6c(%rbp),%esi
lea    0x9f3(%rip),%rdi
mov    $0xaaff0055,%edx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1ad1 <do_test+0x981>
call   *-0x10(%rbp)
mov    %eax,-0x6c(%rbp)
cmpl   $0xaaff0055,-0x6c(%rbp)
je     18ae <do_test+0x75e>
mov    -0x6c(%rbp),%esi
lea    0x9e4(%rip),%rdi
mov    $0xaaff0055,%edx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1ad1 <do_test+0x981>
call   *-0x20(%rbp)
mov    %eax,-0x6c(%rbp)
cmpl   $0xaaff0055,-0x6c(%rbp)
je     18e3 <do_test+0x793>
mov    -0x6c(%rbp),%esi
lea    0x9d8(%rip),%rdi
mov    $0xaaff0055,%edx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1ad1 <do_test+0x981>
call   *-0x30(%rbp)
mov    %eax,-0x6c(%rbp)
cmpl   $0xaaff0055,-0x6c(%rbp)
je     1918 <do_test+0x7c8>
mov    -0x6c(%rbp),%esi
lea    0x9cb(%rip),%rdi
mov    $0xaaff0055,%edx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1ad1 <do_test+0x981>
mov    $0xff55aa00,%edi
call   *-0x38(%rbp)
mov    -0x40(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
cmpl   $0xff55aa00,-0x6c(%rbp)
je     1958 <do_test+0x808>
mov    -0x6c(%rbp),%esi
lea    0x8c5(%rip),%rdi
mov    $0xff55aa00,%edx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1ad1 <do_test+0x981>
mov    -0x48(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
cmpl   $0xff55aa00,-0x6c(%rbp)
je     1990 <do_test+0x840>
mov    -0x6c(%rbp),%esi
lea    0x8b5(%rip),%rdi
mov    $0xff55aa00,%edx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1ad1 <do_test+0x981>
mov    -0x50(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
cmpl   $0xff55aa00,-0x6c(%rbp)
je     19c8 <do_test+0x878>
mov    -0x6c(%rbp),%esi
lea    0x8a4(%rip),%rdi
mov    $0xff55aa00,%edx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1ad1 <do_test+0x981>
call   *-0x10(%rbp)
mov    %eax,-0x6c(%rbp)
cmpl   $0xff55aa00,-0x6c(%rbp)
je     19fd <do_test+0x8ad>
mov    -0x6c(%rbp),%esi
lea    0x895(%rip),%rdi
mov    $0xff55aa00,%edx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1ad1 <do_test+0x981>
call   *-0x20(%rbp)
mov    %eax,-0x6c(%rbp)
cmpl   $0xff55aa00,-0x6c(%rbp)
je     1a32 <do_test+0x8e2>
mov    -0x6c(%rbp),%esi
lea    0x889(%rip),%rdi
mov    $0xff55aa00,%edx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1ad1 <do_test+0x981>
call   *-0x30(%rbp)
mov    %eax,-0x6c(%rbp)
cmpl   $0xff55aa00,-0x6c(%rbp)
je     1a67 <do_test+0x917>
mov    -0x6c(%rbp),%esi
lea    0x87c(%rip),%rdi
mov    $0xff55aa00,%edx
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1ad1 <do_test+0x981>
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x50(%rbp)
mov    -0x68(%rbp),%rdi
call   1070 <dlclose@plt>
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x48(%rbp)
mov    -0x60(%rbp),%rdi
call   1070 <dlclose@plt>
mov    -0x58(%rbp),%rdi
call   1070 <dlclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_test>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    0x2e73(%rip),%rbp
mov    0x2e7c(%rip),%rbx
mov    (%rbx),%esi
or     0x0(%rbp),%esi
xor    %edi,%edi
call   1050 <dlopen@plt>
test   %rax,%rax
je     119d <do_test+0x4d>
mov    %rax,%r13
lea    0xec7(%rip),%rsi
mov    %rax,%rdi
call   1060 <dlsym@plt>
test   %rax,%rax
je     11ad <do_test+0x5d>
lea    0xe82(%rip),%rdi
jmp    11e5 <do_test+0x95>
xor    %eax,%eax
call   1030 <dlerror@plt>
lea    0xe55(%rip),%rdi
jmp    11e5 <do_test+0x95>
lea    0xe97(%rip),%rsi
mov    %r13,%rdi
call   1060 <dlsym@plt>
test   %rax,%rax
je     11ca <do_test+0x7a>
lea    0xe8a(%rip),%rdi
jmp    11e5 <do_test+0x95>
lea    0xeb2(%rip),%rsi
mov    %r13,%rdi
call   1060 <dlsym@plt>
test   %rax,%rax
je     1203 <do_test+0xb3>
lea    0xea5(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%rbx),%esi
or     0x0(%rbp),%esi
lea    0xeac(%rip),%rdi
call   1050 <dlopen@plt>
test   %rax,%rax
je     1357 <do_test+0x207>
mov    %rax,%r14
lea    0xe27(%rip),%rsi
mov    %rax,%rdi
call   1060 <dlsym@plt>
test   %rax,%rax
je     136a <do_test+0x21a>
mov    %rax,%r12
lea    0xe09(%rip),%rsi
mov    %r14,%rdi
call   1060 <dlsym@plt>
test   %rax,%rax
je     137d <do_test+0x22d>
mov    %rax,%r15
lea    0xe26(%rip),%rsi
mov    %r14,%rdi
call   1060 <dlsym@plt>
test   %rax,%rax
je     1390 <do_test+0x240>
mov    %rax,%rbx
mov    0x2d50(%rip),%rax
mov    (%rax),%esi
or     0x0(%rbp),%esi
xor    %edi,%edi
call   1050 <dlopen@plt>
test   %rax,%rax
je     13a3 <do_test+0x253>
mov    %rax,%rbp
lea    0xdb7(%rip),%rsi
mov    %rax,%rdi
call   1060 <dlsym@plt>
test   %rax,%rax
je     13b6 <do_test+0x266>
mov    %rax,0x20(%rsp)
lea    0xd97(%rip),%rsi
mov    %rbp,%rdi
call   1060 <dlsym@plt>
test   %rax,%rax
je     13c9 <do_test+0x279>
mov    %rax,0x18(%rsp)
lea    0xdb2(%rip),%rsi
mov    %rbp,%rdi
call   1060 <dlsym@plt>
test   %rax,%rax
je     13dc <do_test+0x28c>
mov    %rax,0x30(%rsp)
lea    0xd60(%rip),%rsi
mov    %r13,%rdi
call   1060 <dlsym@plt>
test   %rax,%rax
je     13ef <do_test+0x29f>
mov    %rax,0x10(%rsp)
lea    0xd40(%rip),%rsi
mov    %r13,%rdi
call   1060 <dlsym@plt>
test   %rax,%rax
je     1402 <do_test+0x2b2>
mov    %rax,0x8(%rsp)
lea    0xd5b(%rip),%rsi
mov    %r13,%rdi
call   1060 <dlsym@plt>
test   %rax,%rax
je     1415 <do_test+0x2c5>
mov    %rax,%rcx
mov    0x10(%rsp),%rax
mov    (%rax),%esi
test   %esi,%esi
je     1428 <do_test+0x2d8>
lea    0xeb3(%rip),%rdi
jmp    1484 <do_test+0x334>
xor    %eax,%eax
call   1030 <dlerror@plt>
lea    0xd64(%rip),%rdi
jmp    11e5 <do_test+0x95>
xor    %eax,%eax
call   1030 <dlerror@plt>
lea    0xd76(%rip),%rdi
jmp    11e5 <do_test+0x95>
xor    %eax,%eax
call   1030 <dlerror@plt>
lea    0xd7d(%rip),%rdi
jmp    11e5 <do_test+0x95>
xor    %eax,%eax
call   1030 <dlerror@plt>
lea    0xd87(%rip),%rdi
jmp    11e5 <do_test+0x95>
xor    %eax,%eax
call   1030 <dlerror@plt>
lea    0xd91(%rip),%rdi
jmp    11e5 <do_test+0x95>
xor    %eax,%eax
call   1030 <dlerror@plt>
lea    0xd99(%rip),%rdi
jmp    11e5 <do_test+0x95>
xor    %eax,%eax
call   1030 <dlerror@plt>
lea    0xd9f(%rip),%rdi
jmp    11e5 <do_test+0x95>
xor    %eax,%eax
call   1030 <dlerror@plt>
lea    0xda8(%rip),%rdi
jmp    11e5 <do_test+0x95>
xor    %eax,%eax
call   1030 <dlerror@plt>
lea    0xdb1(%rip),%rdi
jmp    11e5 <do_test+0x95>
xor    %eax,%eax
call   1030 <dlerror@plt>
lea    0xdb9(%rip),%rdi
jmp    11e5 <do_test+0x95>
xor    %eax,%eax
call   1030 <dlerror@plt>
lea    0xdc4(%rip),%rdi
jmp    11e5 <do_test+0x95>
mov    %rcx,0x28(%rsp)
mov    (%r12),%esi
test   %esi,%esi
je     143e <do_test+0x2ee>
lea    0xdf1(%rip),%rdi
jmp    1484 <do_test+0x334>
mov    0x20(%rsp),%rax
mov    (%rax),%esi
test   %esi,%esi
je     1452 <do_test+0x302>
lea    0xe04(%rip),%rdi
jmp    1484 <do_test+0x334>
call   *0x8(%rsp)
test   %eax,%eax
je     1463 <do_test+0x313>
lea    0xe19(%rip),%rdi
jmp    1482 <do_test+0x332>
call   *%r15
test   %eax,%eax
je     1473 <do_test+0x323>
lea    0xe32(%rip),%rdi
jmp    1482 <do_test+0x332>
call   *0x18(%rsp)
test   %eax,%eax
je     1492 <do_test+0x342>
lea    0xe49(%rip),%rdi
mov    %eax,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11ef <do_test+0x9f>
mov    $0x5500ffaa,%edi
call   *0x28(%rsp)
mov    0x10(%rsp),%rax
mov    (%rax),%esi
cmp    $0x5500ffaa,%esi
jne    15f0 <do_test+0x4a0>
mov    (%r12),%esi
cmp    $0x5500ffaa,%esi
jne    1601 <do_test+0x4b1>
mov    0x20(%rsp),%rax
mov    (%rax),%esi
cmp    $0x5500ffaa,%esi
jne    1612 <do_test+0x4c2>
call   *0x8(%rsp)
cmp    $0x5500ffaa,%eax
jne    1623 <do_test+0x4d3>
call   *%r15
cmp    $0x5500ffaa,%eax
jne    162c <do_test+0x4dc>
call   *0x18(%rsp)
cmp    $0x5500ffaa,%eax
jne    1635 <do_test+0x4e5>
mov    $0xaaff0055,%edi
call   *%rbx
mov    0x10(%rsp),%rax
mov    (%rax),%esi
cmp    $0xaaff0055,%esi
jne    1648 <do_test+0x4f8>
mov    (%r12),%esi
cmp    $0xaaff0055,%esi
jne    1659 <do_test+0x509>
mov    0x20(%rsp),%rax
mov    (%rax),%esi
cmp    $0xaaff0055,%esi
jne    166a <do_test+0x51a>
call   *0x8(%rsp)
cmp    $0xaaff0055,%eax
jne    167b <do_test+0x52b>
call   *%r15
cmp    $0xaaff0055,%eax
jne    1684 <do_test+0x534>
call   *0x18(%rsp)
cmp    $0xaaff0055,%eax
jne    168d <do_test+0x53d>
mov    $0xff55aa00,%edi
call   *0x30(%rsp)
mov    0x10(%rsp),%rax
mov    (%rax),%esi
cmp    $0xff55aa00,%esi
jne    16a0 <do_test+0x550>
mov    (%r12),%esi
cmp    $0xff55aa00,%esi
jne    16b1 <do_test+0x561>
mov    0x20(%rsp),%rax
mov    (%rax),%esi
cmp    $0xff55aa00,%esi
jne    16c2 <do_test+0x572>
call   *0x8(%rsp)
cmp    $0xff55aa00,%eax
jne    16d3 <do_test+0x583>
call   *%r15
cmp    $0xff55aa00,%eax
jne    16dc <do_test+0x58c>
call   *0x18(%rsp)
cmp    $0xff55aa00,%eax
jne    16e5 <do_test+0x595>
mov    %rbp,%rdi
call   1070 <dlclose@plt>
mov    %r14,%rdi
call   1070 <dlclose@plt>
mov    %r13,%rdi
call   1070 <dlclose@plt>
xor    %eax,%eax
jmp    11f4 <do_test+0xa4>
lea    0xc0e(%rip),%rdi
mov    $0x5500ffaa,%edx
jmp    1486 <do_test+0x336>
lea    0xc25(%rip),%rdi
mov    $0x5500ffaa,%edx
jmp    1486 <do_test+0x336>
lea    0xc3b(%rip),%rdi
mov    $0x5500ffaa,%edx
jmp    1486 <do_test+0x336>
lea    0xc50(%rip),%rdi
jmp    163c <do_test+0x4ec>
lea    0xc70(%rip),%rdi
jmp    163c <do_test+0x4ec>
lea    0xc8f(%rip),%rdi
mov    %eax,%esi
mov    $0x5500ffaa,%edx
jmp    1486 <do_test+0x336>
lea    0xbb6(%rip),%rdi
mov    $0xaaff0055,%edx
jmp    1486 <do_test+0x336>
lea    0xbcd(%rip),%rdi
mov    $0xaaff0055,%edx
jmp    1486 <do_test+0x336>
lea    0xbe3(%rip),%rdi
mov    $0xaaff0055,%edx
jmp    1486 <do_test+0x336>
lea    0xbf8(%rip),%rdi
jmp    1694 <do_test+0x544>
lea    0xc18(%rip),%rdi
jmp    1694 <do_test+0x544>
lea    0xc37(%rip),%rdi
mov    %eax,%esi
mov    $0xaaff0055,%edx
jmp    1486 <do_test+0x336>
lea    0xb5e(%rip),%rdi
mov    $0xff55aa00,%edx
jmp    1486 <do_test+0x336>
lea    0xb75(%rip),%rdi
mov    $0xff55aa00,%edx
jmp    1486 <do_test+0x336>
lea    0xb8b(%rip),%rdi
mov    $0xff55aa00,%edx
jmp    1486 <do_test+0x336>
lea    0xba0(%rip),%rdi
jmp    16ec <do_test+0x59c>
lea    0xbc0(%rip),%rdi
jmp    16ec <do_test+0x59c>
lea    0xbdf(%rip),%rdi
mov    %eax,%esi
mov    $0xff55aa00,%edx
jmp    1486 <do_test+0x336>

LLVM IR (-O0):
@RTLD_LAZY = global i32 0
@RTLD_GLOBAL = global i32 0
@.str = [29 x i8] c"dlopen [initial] (NULL): %s\0A\00"
@.str.1 = [4 x i8] c"foo\00"
@.str.2 = [46 x i8] c"dlsym [initial] (foo): got %p, expected NULL\0A\00"
@.str.3 = [7 x i8] c"getfoo\00"
@.str.4 = [49 x i8] c"dlsym [initial] (getfoo): got %p, expected NULL\0A\00"
@.str.5 = [7 x i8] c"setfoo\00"
@.str.6 = [49 x i8] c"dlsym [initial] (setfoo): got %p, expected NULL\0A\00"
@.str.7 = [14 x i8] c"modstatic3.so\00"
@.str.8 = [37 x i8] c"dlopen [global] (modstatic3.so): %s\0A\00"
@.str.9 = [26 x i8] c"dlsym [global] (foo): %s\0A\00"
@.str.10 = [29 x i8] c"dlsym [global] (getfoo): %s\0A\00"
@.str.11 = [29 x i8] c"dlsym [global] (setfoo): %s\0A\00"
@RTLD_LOCAL = global i32 0
@.str.12 = [27 x i8] c"dlopen [local] (NULL): %s\0A\00"
@.str.13 = [25 x i8] c"dlsym [local] (foo): %s\0A\00"
@.str.14 = [28 x i8] c"dlsym [local] (getfoo): %s\0A\00"
@.str.15 = [28 x i8] c"dlsym [local] (setfoo): %s\0A\00"
@.str.16 = [27 x i8] c"dlsym [initial] (foo): %s\0A\00"
@.str.17 = [30 x i8] c"dlsym [initial] (getfoo): %s\0A\00"
@.str.18 = [30 x i8] c"dlsym [initial] (setfoo): %s\0A\00"
@.str.19 = [40 x i8] c"*foop [initial]: got %#x, expected %#x\0A\00"
@.str.20 = [39 x i8] c"*foop [global]: got %#x, expected %#x\0A\00"
@.str.21 = [38 x i8] c"*foop [local]: got %#x, expected %#x\0A\00"
@.str.22 = [41 x i8] c"getfoo [initial]: got %#x, expected %#x\0A\00"
@.str.23 = [40 x i8] c"getfoo [global]: got %#x, expected %#x\0A\00"
@.str.24 = [39 x i8] c"getfoo [local]: got %#x, expected %#x\0A\00"
define i32 @do_test() {
%1 = alloca i32
%2 = alloca i32 ()*
%3 = alloca void (i32)*
%4 = alloca i32 ()*
%5 = alloca void (i32)*
%6 = alloca i32 ()*
%7 = alloca void (i32)*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i32
%15 = load i32, i32* @RTLD_LAZY
%16 = load i32, i32* @RTLD_GLOBAL
%17 = or i32 %15, %16
%18 = call i8* @dlopen(i8* null, i32 %17)
store i8* %18, i8** %11
%19 = load i8*, i8** %11
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %24
21: ; preds = %0
%22 = call i8* (...) @dlerror()
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %22)
store i32 1, i32* %1
br label %354
24: ; preds = %0
%25 = load i8*, i8** %11
%26 = call i8* @dlsym(i8* %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%27 = bitcast i8* %26 to i32*
store i32* %27, i32** %8
%28 = load i32*, i32** %8
%29 = icmp ne i32* %28, null
br i1 %29, label %30, label %33
30: ; preds = %24
%31 = load i32*, i32** %8
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), i32* %31)
store i32 1, i32* %1
br label %354
33: ; preds = %24
%34 = load i8*, i8** %11
%35 = call i8* @dlsym(i8* %34, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%36 = bitcast i8* %35 to i32 ()*
store i32 ()* %36, i32 ()** %2
%37 = load i32 ()*, i32 ()** %2
%38 = icmp ne i32 ()* %37, null
br i1 %38, label %39, label %42
39: ; preds = %33
%40 = load i32 ()*, i32 ()** %2
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0), i32 ()* %40)
store i32 1, i32* %1
br label %354
42: ; preds = %33
%43 = load i8*, i8** %11
%44 = call i8* @dlsym(i8* %43, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%45 = bitcast i8* %44 to void (i32)*
store void (i32)* %45, void (i32)** %3
%46 = load void (i32)*, void (i32)** %3
%47 = icmp ne void (i32)* %46, null
br i1 %47, label %48, label %51
48: ; preds = %42
%49 = load void (i32)*, void (i32)** %3
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.6, i64 0, i64 0), void (i32)* %49)
store i32 1, i32* %1
br label %354
51: ; preds = %42
%52 = load i32, i32* @RTLD_LAZY
%53 = load i32, i32* @RTLD_GLOBAL
%54 = or i32 %52, %53
%55 = call i8* @dlopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i32 %54)
store i8* %55, i8** %12
%56 = load i8*, i8** %12
%57 = icmp eq i8* %56, null
br i1 %57, label %58, label %61
58: ; preds = %51
%59 = call i8* (...) @dlerror()
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0), i8* %59)
store i32 1, i32* %1
br label %354
61: ; preds = %51
%62 = load i8*, i8** %12
%63 = call i8* @dlsym(i8* %62, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%64 = bitcast i8* %63 to i32*
store i32* %64, i32** %9
%65 = load i32*, i32** %9
%66 = icmp eq i32* %65, null
br i1 %66, label %67, label %70
67: ; preds = %61
%68 = call i8* (...) @dlerror()
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0), i8* %68)
store i32 1, i32* %1
br label %354
70: ; preds = %61
%71 = load i8*, i8** %12
%72 = call i8* @dlsym(i8* %71, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%73 = bitcast i8* %72 to i32 ()*
store i32 ()* %73, i32 ()** %4
%74 = load i32 ()*, i32 ()** %4
%75 = icmp eq i32 ()* %74, null
br i1 %75, label %76, label %79
76: ; preds = %70
%77 = call i8* (...) @dlerror()
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0), i8* %77)
store i32 1, i32* %1
br label %354
79: ; preds = %70
%80 = load i8*, i8** %12
%81 = call i8* @dlsym(i8* %80, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%82 = bitcast i8* %81 to void (i32)*
store void (i32)* %82, void (i32)** %5
%83 = load void (i32)*, void (i32)** %5
%84 = icmp eq void (i32)* %83, null
br i1 %84, label %85, label %88
85: ; preds = %79
%86 = call i8* (...) @dlerror()
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.11, i64 0, i64 0), i8* %86)
store i32 1, i32* %1
br label %354
88: ; preds = %79
%89 = load i32, i32* @RTLD_LAZY
%90 = load i32, i32* @RTLD_LOCAL
%91 = or i32 %89, %90
%92 = call i8* @dlopen(i8* null, i32 %91)
store i8* %92, i8** %13
%93 = load i8*, i8** %13
%94 = icmp eq i8* %93, null
br i1 %94, label %95, label %98
95: ; preds = %88
%96 = call i8* (...) @dlerror()
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.12, i64 0, i64 0), i8* %96)
store i32 1, i32* %1
br label %354
98: ; preds = %88
%99 = load i8*, i8** %13
%100 = call i8* @dlsym(i8* %99, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%101 = bitcast i8* %100 to i32*
store i32* %101, i32** %10
%102 = load i32*, i32** %10
%103 = icmp eq i32* %102, null
br i1 %103, label %104, label %107
104: ; preds = %98
%105 = call i8* (...) @dlerror()
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.13, i64 0, i64 0), i8* %105)
store i32 1, i32* %1
br label %354
107: ; preds = %98
%108 = load i8*, i8** %13
%109 = call i8* @dlsym(i8* %108, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%110 = bitcast i8* %109 to i32 ()*
store i32 ()* %110, i32 ()** %6
%111 = load i32 ()*, i32 ()** %6
%112 = icmp eq i32 ()* %111, null
br i1 %112, label %113, label %116
113: ; preds = %107
%114 = call i8* (...) @dlerror()
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.14, i64 0, i64 0), i8* %114)
store i32 1, i32* %1
br label %354
116: ; preds = %107
%117 = load i8*, i8** %13
%118 = call i8* @dlsym(i8* %117, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%119 = bitcast i8* %118 to void (i32)*
store void (i32)* %119, void (i32)** %7
%120 = load void (i32)*, void (i32)** %7
%121 = icmp eq void (i32)* %120, null
br i1 %121, label %122, label %125
122: ; preds = %116
%123 = call i8* (...) @dlerror()
%124 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.15, i64 0, i64 0), i8* %123)
store i32 1, i32* %1
br label %354
125: ; preds = %116
%126 = load i8*, i8** %11
%127 = call i8* @dlsym(i8* %126, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%128 = bitcast i8* %127 to i32*
store i32* %128, i32** %8
%129 = load i32*, i32** %8
%130 = icmp eq i32* %129, null
br i1 %130, label %131, label %134
131: ; preds = %125
%132 = call i8* (...) @dlerror()
%133 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.16, i64 0, i64 0), i8* %132)
store i32 1, i32* %1
br label %354
134: ; preds = %125
%135 = load i8*, i8** %11
%136 = call i8* @dlsym(i8* %135, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%137 = bitcast i8* %136 to i32 ()*
store i32 ()* %137, i32 ()** %2
%138 = load i32 ()*, i32 ()** %2
%139 = icmp eq i32 ()* %138, null
br i1 %139, label %140, label %143
140: ; preds = %134
%141 = call i8* (...) @dlerror()
%142 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.17, i64 0, i64 0), i8* %141)
store i32 1, i32* %1
br label %354
143: ; preds = %134
%144 = load i8*, i8** %11
%145 = call i8* @dlsym(i8* %144, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%146 = bitcast i8* %145 to void (i32)*
store void (i32)* %146, void (i32)** %3
%147 = load void (i32)*, void (i32)** %3
%148 = icmp eq void (i32)* %147, null
br i1 %148, label %149, label %152
149: ; preds = %143
%150 = call i8* (...) @dlerror()
%151 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.18, i64 0, i64 0), i8* %150)
store i32 1, i32* %1
br label %354
152: ; preds = %143
%153 = load i32*, i32** %8
%154 = load i32, i32* %153
store i32 %154, i32* %14
%155 = load i32, i32* %14
%156 = icmp ne i32 %155, 0
br i1 %156, label %157, label %160
157: ; preds = %152
%158 = load i32, i32* %14
%159 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.19, i64 0, i64 0), i32 %158, i32 0)
store i32 1, i32* %1
br label %354
160: ; preds = %152
%161 = load i32*, i32** %9
%162 = load i32, i32* %161
store i32 %162, i32* %14
%163 = load i32, i32* %14
%164 = icmp ne i32 %163, 0
br i1 %164, label %165, label %168
165: ; preds = %160
%166 = load i32, i32* %14
%167 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.20, i64 0, i64 0), i32 %166, i32 0)
store i32 1, i32* %1
br label %354
168: ; preds = %160
%169 = load i32*, i32** %10
%170 = load i32, i32* %169
store i32 %170, i32* %14
%171 = load i32, i32* %14
%172 = icmp ne i32 %171, 0
br i1 %172, label %173, label %176
173: ; preds = %168
%174 = load i32, i32* %14
%175 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.21, i64 0, i64 0), i32 %174, i32 0)
store i32 1, i32* %1
br label %354
176: ; preds = %168
%177 = load i32 ()*, i32 ()** %2
%178 = call i32 %177()
store i32 %178, i32* %14
%179 = load i32, i32* %14
%180 = icmp ne i32 %179, 0
br i1 %180, label %181, label %184
181: ; preds = %176
%182 = load i32, i32* %14
%183 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.22, i64 0, i64 0), i32 %182, i32 0)
store i32 1, i32* %1
br label %354
184: ; preds = %176
%185 = load i32 ()*, i32 ()** %4
%186 = call i32 %185()
store i32 %186, i32* %14
%187 = load i32, i32* %14
%188 = icmp ne i32 %187, 0
br i1 %188, label %189, label %192
189: ; preds = %184
%190 = load i32, i32* %14
%191 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.23, i64 0, i64 0), i32 %190, i32 0)
store i32 1, i32* %1
br label %354
192: ; preds = %184
%193 = load i32 ()*, i32 ()** %6
%194 = call i32 %193()
store i32 %194, i32* %14
%195 = load i32, i32* %14
%196 = icmp ne i32 %195, 0
br i1 %196, label %197, label %200
197: ; preds = %192
%198 = load i32, i32* %14
%199 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.24, i64 0, i64 0), i32 %198, i32 0)
store i32 1, i32* %1
br label %354
200: ; preds = %192
%201 = load void (i32)*, void (i32)** %3
%202 = load i32*, i32** %8
%203 = load i32, i32* %202
store i32 %203, i32* %14
%204 = load i32, i32* %14
%205 = icmp ne i32 %204, 1426128810
br i1 %205, label %206, label %209
206: ; preds = %200
%207 = load i32, i32* %14
%208 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.19, i64 0, i64 0), i32 %207, i32 1426128810)
store i32 1, i32* %1
br label %354
209: ; preds = %200
%210 = load i32*, i32** %9
%211 = load i32, i32* %210
store i32 %211, i32* %14
%212 = load i32, i32* %14
%213 = icmp ne i32 %212, 1426128810
br i1 %213, label %214, label %217
214: ; preds = %209
%215 = load i32, i32* %14
%216 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.20, i64 0, i64 0), i32 %215, i32 1426128810)
store i32 1, i32* %1
br label %354
217: ; preds = %209
%218 = load i32*, i32** %10
%219 = load i32, i32* %218
store i32 %219, i32* %14
%220 = load i32, i32* %14
%221 = icmp ne i32 %220, 1426128810
br i1 %221, label %222, label %225
222: ; preds = %217
%223 = load i32, i32* %14
%224 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.21, i64 0, i64 0), i32 %223, i32 1426128810)
store i32 1, i32* %1
br label %354
225: ; preds = %217
%226 = load i32 ()*, i32 ()** %2
%227 = call i32 %226()
store i32 %227, i32* %14
%228 = load i32, i32* %14
%229 = icmp ne i32 %228, 1426128810
br i1 %229, label %230, label %233
230: ; preds = %225
%231 = load i32, i32* %14
%232 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.22, i64 0, i64 0), i32 %231, i32 1426128810)
store i32 1, i32* %1
br label %354
233: ; preds = %225
%234 = load i32 ()*, i32 ()** %4
%235 = call i32 %234()
store i32 %235, i32* %14
%236 = load i32, i32* %14
%237 = icmp ne i32 %236, 1426128810
br i1 %237, label %238, label %241
238: ; preds = %233
%239 = load i32, i32* %14
%240 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.23, i64 0, i64 0), i32 %239, i32 1426128810)
store i32 1, i32* %1
br label %354
241: ; preds = %233
%242 = load i32 ()*, i32 ()** %6
%243 = call i32 %242()
store i32 %243, i32* %14
%244 = load i32, i32* %14
%245 = icmp ne i32 %244, 1426128810
br i1 %245, label %246, label %249
246: ; preds = %241
%247 = load i32, i32* %14
%248 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.24, i64 0, i64 0), i32 %247, i32 1426128810)
store i32 1, i32* %1
br label %354
249: ; preds = %241
%250 = load void (i32)*, void (i32)** %5
%251 = load i32*, i32** %8
%252 = load i32, i32* %251
store i32 %252, i32* %14
%253 = load i32, i32* %14
%254 = icmp ne i32 %253, -1426128811
br i1 %254, label %255, label %258
255: ; preds = %249
%256 = load i32, i32* %14
%257 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.19, i64 0, i64 0), i32 %256, i32 -1426128811)
store i32 1, i32* %1
br label %354
258: ; preds = %249
%259 = load i32*, i32** %9
%260 = load i32, i32* %259
store i32 %260, i32* %14
%261 = load i32, i32* %14
%262 = icmp ne i32 %261, -1426128811
br i1 %262, label %263, label %266
263: ; preds = %258
%264 = load i32, i32* %14
%265 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.20, i64 0, i64 0), i32 %264, i32 -1426128811)
store i32 1, i32* %1
br label %354
266: ; preds = %258
%267 = load i32*, i32** %10
%268 = load i32, i32* %267
store i32 %268, i32* %14
%269 = load i32, i32* %14
%270 = icmp ne i32 %269, -1426128811
br i1 %270, label %271, label %274
271: ; preds = %266
%272 = load i32, i32* %14
%273 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.21, i64 0, i64 0), i32 %272, i32 -1426128811)
store i32 1, i32* %1
br label %354
274: ; preds = %266
%275 = load i32 ()*, i32 ()** %2
%276 = call i32 %275()
store i32 %276, i32* %14
%277 = load i32, i32* %14
%278 = icmp ne i32 %277, -1426128811
br i1 %278, label %279, label %282
279: ; preds = %274
%280 = load i32, i32* %14
%281 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.22, i64 0, i64 0), i32 %280, i32 -1426128811)
store i32 1, i32* %1
br label %354
282: ; preds = %274
%283 = load i32 ()*, i32 ()** %4
%284 = call i32 %283()
store i32 %284, i32* %14
%285 = load i32, i32* %14
%286 = icmp ne i32 %285, -1426128811
br i1 %286, label %287, label %290
287: ; preds = %282
%288 = load i32, i32* %14
%289 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.23, i64 0, i64 0), i32 %288, i32 -1426128811)
store i32 1, i32* %1
br label %354
290: ; preds = %282
%291 = load i32 ()*, i32 ()** %6
%292 = call i32 %291()
store i32 %292, i32* %14
%293 = load i32, i32* %14
%294 = icmp ne i32 %293, -1426128811
br i1 %294, label %295, label %298
295: ; preds = %290
%296 = load i32, i32* %14
%297 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.24, i64 0, i64 0), i32 %296, i32 -1426128811)
store i32 1, i32* %1
br label %354
298: ; preds = %290
%299 = load void (i32)*, void (i32)** %7
%300 = load i32*, i32** %8
%301 = load i32, i32* %300
store i32 %301, i32* %14
%302 = load i32, i32* %14
%303 = icmp ne i32 %302, -11163136
br i1 %303, label %304, label %307
304: ; preds = %298
%305 = load i32, i32* %14
%306 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.19, i64 0, i64 0), i32 %305, i32 -11163136)
store i32 1, i32* %1
br label %354
307: ; preds = %298
%308 = load i32*, i32** %9
%309 = load i32, i32* %308
store i32 %309, i32* %14
%310 = load i32, i32* %14
%311 = icmp ne i32 %310, -11163136
br i1 %311, label %312, label %315
312: ; preds = %307
%313 = load i32, i32* %14
%314 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.20, i64 0, i64 0), i32 %313, i32 -11163136)
store i32 1, i32* %1
br label %354
315: ; preds = %307
%316 = load i32*, i32** %10
%317 = load i32, i32* %316
store i32 %317, i32* %14
%318 = load i32, i32* %14
%319 = icmp ne i32 %318, -11163136
br i1 %319, label %320, label %323
320: ; preds = %315
%321 = load i32, i32* %14
%322 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.21, i64 0, i64 0), i32 %321, i32 -11163136)
store i32 1, i32* %1
br label %354
323: ; preds = %315
%324 = load i32 ()*, i32 ()** %2
%325 = call i32 %324()
store i32 %325, i32* %14
%326 = load i32, i32* %14
%327 = icmp ne i32 %326, -11163136
br i1 %327, label %328, label %331
328: ; preds = %323
%329 = load i32, i32* %14
%330 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.22, i64 0, i64 0), i32 %329, i32 -11163136)
store i32 1, i32* %1
br label %354
331: ; preds = %323
%332 = load i32 ()*, i32 ()** %4
%333 = call i32 %332()
store i32 %333, i32* %14
%334 = load i32, i32* %14
%335 = icmp ne i32 %334, -11163136
br i1 %335, label %336, label %339
336: ; preds = %331
%337 = load i32, i32* %14
%338 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.23, i64 0, i64 0), i32 %337, i32 -11163136)
store i32 1, i32* %1
br label %354
339: ; preds = %331
%340 = load i32 ()*, i32 ()** %6
%341 = call i32 %340()
store i32 %341, i32* %14
%342 = load i32, i32* %14
%343 = icmp ne i32 %342, -11163136
br i1 %343, label %344, label %347
344: ; preds = %339
%345 = load i32, i32* %14
%346 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.24, i64 0, i64 0), i32 %345, i32 -11163136)
store i32 1, i32* %1
br label %354
347: ; preds = %339
store i32 ()* null, i32 ()** %2
store void (i32)* null, void (i32)** %3
store i32* null, i32** %8
store i32 ()* null, i32 ()** %6
store void (i32)* null, void (i32)** %7
store i32* null, i32** %10
%348 = load i8*, i8** %13
%349 = call i32 @dlclose(i8* %348)
store i32 ()* null, i32 ()** %4
store void (i32)* null, void (i32)** %5
store i32* null, i32** %9
%350 = load i8*, i8** %12
%351 = call i32 @dlclose(i8* %350)
%352 = load i8*, i8** %11
%353 = call i32 @dlclose(i8* %352)
store i32 0, i32* %1
br label %354
354: ; preds = %347, %344, %336, %328, %320, %312, %304, %295, %287, %279, %271, %263, %255, %246, %238, %230, %222, %214, %206, %197, %189, %181, %173, %165, %157, %149, %140, %131, %122, %113, %104, %95, %85, %76, %67, %58, %48, %39, %30, %21
%355 = load i32, i32* %1
ret i32 %355
}

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