#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*/ MP_printLog(char *, int, char *, int, char *, ...);
int /*<<< orphan*/ dlerror();
void *dlsym(void *, char const *);
void *mepinta_solve_symbol_quiet(const void *handle, const char *symbol) {
  if (handle != NULL && symbol != NULL) {
    dlerror();
    void *sym_p = dlsym((void *)handle, symbol);
    return sym_p;
  } else {
    if (handle != NULL) {
      MP_printLog("LOG_MEPINTA_DEBUG", 50,
                  "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                  "outputs/2022-01-22/02-19-57/repos/joaduo/mepinta/refs/heads/"
                  "master/backend/c_and_cpp/backend_api_c/solve_symbol.c",
                  80,
                  "Failed to find the requested symbol for handle at %p. "
                  "Symbol is NULL.\n",
                  handle);
    } else if (symbol != NULL) {
      MP_printLog("LOG_MEPINTA_DEBUG", 50,
                  "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                  "outputs/2022-01-22/02-19-57/repos/joaduo/mepinta/refs/heads/"
                  "master/backend/c_and_cpp/backend_api_c/solve_symbol.c",
                  83,
                  "Failed to find the requested symbol '%s'. Handle is NULL.\n",
                  symbol);
    } else {
      MP_printLog(
          "LOG_MEPINTA_DEBUG", 50,
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/joaduo/mepinta/refs/heads/master/backend/"
          "c_and_cpp/backend_api_c/solve_symbol.c",
          86,
          "Failed to find the requested symbol. Handle and symbol are NULL.\n");
    }
    return NULL;
  }
}


x86 assembly (clang, -O0):
<mepinta_solve_symbol_quiet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     117b <mepinta_solve_symbol_quiet+0x4b>
cmpq   $0x0,-0x18(%rbp)
je     117b <mepinta_solve_symbol_quiet+0x4b>
mov    $0x0,%al
call   1030 <dlerror@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <dlsym@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1222 <mepinta_solve_symbol_quiet+0xf2>
cmpq   $0x0,-0x10(%rbp)
je     11b5 <mepinta_solve_symbol_quiet+0x85>
mov    -0x10(%rbp),%r9
lea    0xe6f(%rip),%rdi
mov    $0x32,%esi
lea    0xe75(%rip),%rdx
mov    $0x50,%ecx
lea    0xf13(%rip),%r8
mov    $0x0,%al
call   1040 <MP_printLog@plt>
jmp    121a <mepinta_solve_symbol_quiet+0xea>
cmpq   $0x0,-0x18(%rbp)
je     11ef <mepinta_solve_symbol_quiet+0xbf>
mov    -0x18(%rbp),%r9
lea    0xe35(%rip),%rdi
mov    $0x32,%esi
lea    0xe3b(%rip),%rdx
mov    $0x53,%ecx
lea    0xf20(%rip),%r8
mov    $0x0,%al
call   1040 <MP_printLog@plt>
jmp    1215 <mepinta_solve_symbol_quiet+0xe5>
lea    0xe0a(%rip),%rdi
mov    $0x32,%esi
lea    0xe10(%rip),%rdx
mov    $0x56,%ecx
lea    0xf30(%rip),%r8
mov    $0x0,%al
call   1040 <MP_printLog@plt>
jmp    121a <mepinta_solve_symbol_quiet+0xea>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mepinta_solve_symbol_quiet>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
test   %rdi,%rdi
je     115d <mepinta_solve_symbol_quiet+0x2d>
test   %r14,%r14
je     115d <mepinta_solve_symbol_quiet+0x2d>
xor    %eax,%eax
call   1030 <dlerror@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <dlsym@plt>
lea    0xe9c(%rip),%rdi
lea    0xea7(%rip),%rdx
test   %rbx,%rbx
je     1186 <mepinta_solve_symbol_quiet+0x56>
lea    0xf45(%rip),%r8
mov    $0x32,%esi
mov    $0x50,%ecx
mov    %rbx,%r9
jmp    119f <mepinta_solve_symbol_quiet+0x6f>
test   %r14,%r14
je     11b0 <mepinta_solve_symbol_quiet+0x80>
lea    0xf71(%rip),%r8
mov    $0x32,%esi
mov    $0x53,%ecx
mov    %r14,%r9
xor    %eax,%eax
call   1040 <MP_printLog@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xf87(%rip),%r8
mov    $0x32,%esi
mov    $0x56,%ecx
xor    %eax,%eax
call   1040 <MP_printLog@plt>
jmp    11a6 <mepinta_solve_symbol_quiet+0x76>

LLVM IR (-O0):
@.str = [18 x i8] c"LOG_MEPINTA_DEBUG\00"
@.str.1 = [170 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/joaduo/mepinta/refs/heads/master/backend/c_and_cpp/backend_api_c/solve_symbol.c\00"
@.str.2 = [71 x i8] c"Failed to find the requested symbol for handle at %p. Symbol is NULL.\0A\00"
@.str.3 = [59 x i8] c"Failed to find the requested symbol '%s'. Handle is NULL.\0A\00"
@.str.4 = [66 x i8] c"Failed to find the requested symbol. Handle and symbol are NULL.\0A\00"
define i8* @mepinta_solve_symbol_quiet(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %18
9: ; preds = %2
%10 = load i8*, i8** %5
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %18
12: ; preds = %9
%13 = call i32 (...) @dlerror()
%14 = load i8*, i8** %4
%15 = load i8*, i8** %5
%16 = call i8* @dlsym(i8* %14, i8* %15)
store i8* %16, i8** %6
%17 = load i8*, i8** %6
store i8* %17, i8** %3
br label %34
18: ; preds = %9, %2
%19 = load i8*, i8** %4
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load i8*, i8** %4
%23 = call i32 (i8*, i32, i8*, i32, i8*, ...) @MP_printLog(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 50, i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str.1, i64 0, i64 0), i32 80, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.2, i64 0, i64 0), i8* %22)
br label %33
24: ; preds = %18
%25 = load i8*, i8** %5
%26 = icmp ne i8* %25, null
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = load i8*, i8** %5
%29 = call i32 (i8*, i32, i8*, i32, i8*, ...) @MP_printLog(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 50, i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str.1, i64 0, i64 0), i32 83, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.3, i64 0, i64 0), i8* %28)
br label %32
30: ; preds = %24
%31 = call i32 (i8*, i32, i8*, i32, i8*, ...) @MP_printLog(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 50, i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str.1, i64 0, i64 0), i32 86, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.4, i64 0, i64 0))
br label %32
32: ; preds = %30, %27
br label %33
33: ; preds = %32, %21
store i8* null, i8** %3
br label %34
34: ; preds = %33, %12
%35 = load i8*, i8** %3
ret i8* %35
}

LLVM IR (-O2):
@.str = [18 x i8] c"LOG_MEPINTA_DEBUG\00"
@.str.1 = [170 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/joaduo/mepinta/refs/heads/master/backend/c_and_cpp/backend_api_c/solve_symbol.c\00"
@.str.2 = [71 x i8] c"Failed to find the requested symbol for handle at %p. Symbol is NULL.\0A\00"
@.str.3 = [59 x i8] c"Failed to find the requested symbol '%s'. Handle is NULL.\0A\00"
@.str.4 = [66 x i8] c"Failed to find the requested symbol. Handle and symbol are NULL.\0A\00"
define i8* @mepinta_solve_symbol_quiet(i8* %0, i8* %1) {
%3 = icmp ne i8* %0, null
%4 = icmp ne i8* %1, null
%5 = and i1 %3, %4
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = tail call i32 (...) @dlerror()
%8 = tail call i8* @dlsym(i8* %0, i8* %1)
br label %17
9: ; preds = %2
br i1 %3, label %10, label %12
10: ; preds = %9
%11 = tail call i32 (i8*, i32, i8*, i32, i8*, ...) @MP_printLog(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 50, i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str.1, i64 0, i64 0), i32 80, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %17
12: ; preds = %9
br i1 %4, label %13, label %15
13: ; preds = %12
%14 = tail call i32 (i8*, i32, i8*, i32, i8*, ...) @MP_printLog(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 50, i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str.1, i64 0, i64 0), i32 83, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.3, i64 0, i64 0), i8* %1)
br label %17
15: ; preds = %12
%16 = tail call i32 (i8*, i32, i8*, i32, i8*, ...) @MP_printLog(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 50, i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str.1, i64 0, i64 0), i32 86, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.4, i64 0, i64 0))
br label %17
17: ; preds = %10, %15, %13, %6
%18 = phi i8* [ %8, %6 ], [ null, %13 ], [ null, %15 ], [ null, %10 ]
ret i8* %18
}