void Sys_UnloadDll(void *dllHandle) {
  const char *err;
  if (!dllHandle) {
    Com_Printf("Sys_UnloadDll(NULL)\n");
    return;
  }
  dlclose(dllHandle);
  err = dlerror();
  if (err != ((void *)0))
    Com_Printf("Sys_UnloadGame failed on dlclose: \"%s\"!\n", err);
}


x86 assembly (clang, -O0):
<Sys_UnloadDll>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    115a <Sys_UnloadDll+0x2a>
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1040 <Com_Printf@plt>
jmp    118f <Sys_UnloadDll+0x5f>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1050 <dlclose@plt>
mov    $0x0,%al
call   1030 <dlerror@plt>
cltq
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     118f <Sys_UnloadDll+0x5f>
mov    -0x10(%rbp),%rsi
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1040 <Com_Printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Sys_UnloadDll>:
test   %rdi,%rdi
je     115e <Sys_UnloadDll+0x2e>
push   %rax
xor    %eax,%eax
call   1050 <dlclose@plt>
xor    %eax,%eax
call   1030 <dlerror@plt>
test   %eax,%eax
lea    0x8(%rsp),%rsp
je     116c <Sys_UnloadDll+0x3c>
movslq %eax,%rsi
lea    0xebe(%rip),%rdi
xor    %eax,%eax
jmp    1040 <Com_Printf@plt>
lea    0xe9b(%rip),%rdi
xor    %eax,%eax
jmp    1040 <Com_Printf@plt>
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Sys_UnloadDll(NULL)\0A\00"
@.str.1 = [41 x i8] c"Sys_UnloadGame failed on dlclose: \22%s\22!\0A\00"
define void @Sys_UnloadDll(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = icmp ne i8* %4, null
br i1 %5, label %8, label %6
6: ; preds = %1
%7 = call i32 (i8*, ...) bitcast (i32 (...)* @Com_Printf to i32 (i8*, ...)*)(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %19
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = call i32 (i8*, ...) bitcast (i32 (...)* @dlclose to i32 (i8*, ...)*)(i8* %9)
%11 = call i32 (...) @dlerror()
%12 = sext i32 %11 to i64
%13 = inttoptr i64 %12 to i8*
store i8* %13, i8** %3
%14 = load i8*, i8** %3
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %19
16: ; preds = %8
%17 = load i8*, i8** %3
%18 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @Com_Printf to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8* %17)
br label %19
19: ; preds = %6, %16, %8
ret void
}

LLVM IR (-O2):
@.str = [21 x i8] c"Sys_UnloadDll(NULL)\0A\00"
@.str.1 = [41 x i8] c"Sys_UnloadGame failed on dlclose: \22%s\22!\0A\00"
define void @Sys_UnloadDll(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 (i8*, ...) bitcast (i32 (...)* @Com_Printf to i32 (i8*, ...)*)(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %13
5: ; preds = %1
%6 = tail call i32 (i8*, ...) bitcast (i32 (...)* @dlclose to i32 (i8*, ...)*)(i8* %0)
%7 = tail call i32 (...) @dlerror()
%8 = icmp eq i32 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %5
%10 = sext i32 %7 to i64
%11 = inttoptr i64 %10 to i8*
%12 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @Com_Printf to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8* %11)
br label %13
13: ; preds = %5, %9, %3
ret void
}