#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 */
typedef void (*ssuproxyinit_t)();

/* Variables and functions */
int /*<<< orphan*/ RTLD_LAZY;
int /*<<< orphan*/ dlclose(void *);
char *dlerror();
void *dlopen(char *, int /*<<< orphan*/);
scalar_t__ dlsym(void *, char *);
void set_application_proxy_factory() {
  void *proxylib = dlopen("libssunetworkproxy.so", RTLD_LAZY);
  if (proxylib) {
    typedef void (*ssuproxyinit_t)();
    dlerror();
    ssuproxyinit_t proxy_init = (ssuproxyinit_t)dlsym(proxylib, "initialize");
    const char *dlsym_err = dlerror();
    if (!dlsym_err) {
      proxy_init();
    }
    dlclose(proxylib);
  }
}


x86 assembly (clang, -O0):
<set_application_proxy_factory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0x2e91(%rip),%rax
mov    (%rax),%esi
lea    0xea8(%rip),%rdi
call   1040 <dlopen@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11ab <set_application_proxy_factory+0x6b>
mov    $0x0,%al
call   1030 <dlerror@plt>
mov    -0x8(%rbp),%rdi
lea    0xe98(%rip),%rsi
call   1050 <dlsym@plt>
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1030 <dlerror@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11a2 <set_application_proxy_factory+0x62>
mov    $0x0,%al
call   *-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <dlclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_application_proxy_factory>:
push   %r14
push   %rbx
push   %rax
mov    0x2e95(%rip),%rax
mov    (%rax),%esi
lea    0xeac(%rip),%rdi
call   1040 <dlopen@plt>
test   %rax,%rax
je     119a <set_application_proxy_factory+0x5a>
mov    %rax,%rbx
xor    %eax,%eax
call   1030 <dlerror@plt>
lea    0xea7(%rip),%rsi
mov    %rbx,%rdi
call   1050 <dlsym@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1030 <dlerror@plt>
test   %rax,%rax
jne    118b <set_application_proxy_factory+0x4b>
xor    %eax,%eax
call   *%r14
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <dlclose@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [22 x i8] c"libssunetworkproxy.so\00"
@RTLD_LAZY = global i32 0
@.str.1 = [11 x i8] c"initialize\00"
define void @set_application_proxy_factory() {
%1 = alloca i8*
%2 = alloca void (...)*
%3 = alloca i8*
%4 = load i32, i32* @RTLD_LAZY
%5 = call i8* @dlopen(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %4)
store i8* %5, i8** %1
%6 = load i8*, i8** %1
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %21
8: ; preds = %0
%9 = call i8* (...) @dlerror()
%10 = load i8*, i8** %1
%11 = call i64 @dlsym(i8* %10, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%12 = inttoptr i64 %11 to void (...)*
store void (...)* %12, void (...)** %2
%13 = call i8* (...) @dlerror()
store i8* %13, i8** %3
%14 = load i8*, i8** %3
%15 = icmp ne i8* %14, null
br i1 %15, label %18, label %16
16: ; preds = %8
%17 = load void (...)*, void (...)** %2
br label %18
18: ; preds = %16, %8
%19 = load i8*, i8** %1
%20 = call i32 @dlclose(i8* %19)
br label %21
21: ; preds = %18, %0
ret void
}

LLVM IR (-O2):
@.str = [22 x i8] c"libssunetworkproxy.so\00"
@RTLD_LAZY = global i32 0
@.str.1 = [11 x i8] c"initialize\00"
define void @set_application_proxy_factory() {
%1 = load i32, i32* @RTLD_LAZY
%2 = tail call i8* @dlopen(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = icmp eq i8* %2, null
br i1 %3, label %13, label %4
4: ; preds = %0
%5 = tail call i8* (...) @dlerror()
%6 = tail call i64 @dlsym(i8* %2, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i8* (...) @dlerror()
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %11
9: ; preds = %4
%10 = inttoptr i64 %6 to void (...)*
tail call void (...) %10()
br label %11
11: ; preds = %9, %4
%12 = tail call i32 @dlclose(i8* %2)
br label %13
13: ; preds = %11, %0
ret void
}