#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ RTLD_LAZY;
int /*<<< orphan*/ _DEBUG(int, int, char *, char *, char const *);
char *dlerror();
void *dlopen(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ stderr;
void *loadModule(const char *modPath) {
  void *md;
  md = dlopen(modPath, RTLD_LAZY);
  if (md == NULL) {
    fprintf(stderr, "Error loading module %s\n", modPath);
    fprintf(stderr, "%s\n", dlerror());
  } else {
    _DEBUG(3, 124,
           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/zehome/old-MyBot/refs/heads/master/src/"
           "modules.c",
           "Module %s successfully loaded.", modPath);
  }
  return md;
}


x86 assembly (clang, -O0):
<loadModule>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e81(%rip),%rax
mov    (%rax),%esi
call   1040 <dlopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11b0 <loadModule+0x70>
mov    0x2e6c(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe7f(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e53(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1030 <dlerror@plt>
mov    -0x14(%rbp),%edi
mov    %rax,%rdx
lea    0xe6f(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11d1 <loadModule+0x91>
mov    -0x8(%rbp),%r8
mov    $0x3,%edi
mov    $0x7c,%esi
lea    0xe54(%rip),%rdx
lea    0xed8(%rip),%rcx
call   1060 <_DEBUG@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<loadModule>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    0x2e89(%rip),%rax
mov    (%rax),%esi
call   1040 <dlopen@plt>
mov    %rax,%r14
test   %rax,%rax
je     1180 <loadModule+0x40>
lea    0xeb4(%rip),%rdx
lea    0xf38(%rip),%rcx
mov    $0x3,%edi
mov    $0x7c,%esi
mov    %rbx,%r8
call   1060 <_DEBUG@plt>
jmp    11b4 <loadModule+0x74>
mov    0x2e59(%rip),%r15
mov    (%r15),%edi
lea    0xe6f(%rip),%rsi
mov    %rbx,%rdx
call   1050 <fprintf@plt>
mov    (%r15),%ebx
xor    %eax,%eax
call   1030 <dlerror@plt>
lea    0xe6b(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1050 <fprintf@plt>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@RTLD_LAZY = global i32 0
@stderr = global i32 0
@.str = [25 x i8] c"Error loading module %s\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [139 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/zehome/old-MyBot/refs/heads/master/src/modules.c\00"
@.str.3 = [31 x i8] c"Module %s successfully loaded.\00"
define i8* @loadModule(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = load i32, i32* @RTLD_LAZY
%6 = call i8* @dlopen(i8* %4, i32 %5)
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %16
9: ; preds = %1
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %2
%12 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = load i32, i32* @stderr
%14 = call i8* (...) @dlerror()
%15 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %14)
br label %19
16: ; preds = %1
%17 = load i8*, i8** %2
%18 = call i32 @_DEBUG(i32 3, i32 124, i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %17)
br label %19
19: ; preds = %16, %9
%20 = load i8*, i8** %3
ret i8* %20
}

LLVM IR (-O2):
@RTLD_LAZY = global i32 0
@stderr = global i32 0
@.str = [25 x i8] c"Error loading module %s\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [139 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/zehome/old-MyBot/refs/heads/master/src/modules.c\00"
@.str.3 = [31 x i8] c"Module %s successfully loaded.\00"
define i8* @loadModule(i8* %0) {
%2 = load i32, i32* @RTLD_LAZY
%3 = tail call i8* @dlopen(i8* %0, i32 %2)
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %11
5: ; preds = %1
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %0)
%8 = load i32, i32* @stderr
%9 = tail call i8* (...) @dlerror()
%10 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %9)
br label %13
11: ; preds = %1
%12 = tail call i32 @_DEBUG(i32 3, i32 124, i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %0)
br label %13
13: ; preds = %11, %5
ret i8* %3
}