// File: williewillus[P]panda_scratchpad/src/utils/ClassLoader.h
// Function: int utils::ClassLoader<tests::BaseTestCase>::load_class<tests::BaseTestCase* (*)()>(char const*, char const*, char const*)
int load_class(const char *path, const char *factory_name,
      const char *defactory_name) {
    const char* dl_error = NULL;

    loader_handle = dlopen(path, RTLD_LAZY);
    if (loader_handle == NULL) {
      std::cerr << "Error loading class " << path << std::endl
        << dlerror() << std::endl;
      return CASE_HANDLE_ERR;
    }

    // Get needed methods from loaded class.
    factory = dlsym(loader_handle, factory_name);
    dl_error = dlerror();
    if (dl_error) {
      std::cerr << "Error gettig factory method " << dl_error << std::endl;
      dlclose(loader_handle);
      factory = NULL;
      defactory = NULL;
      loader_handle = NULL;
      return CASE_INIT_ERR;
    }
    defactory = dlsym(loader_handle, defactory_name);
    dl_error = dlerror();
    if (dl_error) {
      std::cerr << "Error gettig deleter method " << dl_error << std::endl;
      dlclose(loader_handle);
      factory = NULL;
      defactory = NULL;
      loader_handle = NULL;
      return CASE_DEST_ERR;
    }
    instance = ((F)(factory))();
    return SUCCESS;
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x18(%rbp), %rdi
movl $0x1, %esi
callq 0x6690
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
cmpq $0x0, (%rax)
jne 0x1c8e4
movq 0x18763(%rip), %rdi     # 0x34ff0
leaq 0x8d5f(%rip), %rsi      # 0x255f3
callq 0x6520
movq %rax, %rdi
movq -0x18(%rbp), %rsi
callq 0x6520
movq %rax, %rdi
movq 0x186e9(%rip), %rsi     # 0x34f98
callq 0x6580
movq %rax, -0x40(%rbp)
callq 0x64f0
movq -0x40(%rbp), %rdi
movq %rax, %rsi
callq 0x6520
movq %rax, %rdi
movq 0x186c5(%rip), %rsi     # 0x34f98
callq 0x6580
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1ca12
movq -0x38(%rbp), %rax
movq (%rax), %rdi
movq -0x20(%rbp), %rsi
callq 0x64e0
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x8(%rax)
callq 0x64f0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x1c970
movq 0x186da(%rip), %rdi     # 0x34ff0
leaq 0x8ceb(%rip), %rsi      # 0x25608
callq 0x6520
movq %rax, %rdi
movq -0x30(%rbp), %rsi
callq 0x6520
movq %rax, %rdi
movq 0x18660(%rip), %rsi     # 0x34f98
callq 0x6580
movq -0x38(%rbp), %rax
movq (%rax), %rdi
callq 0x6430
movq -0x38(%rbp), %rax
movq $0x0, 0x8(%rax)
movq $0x0, 0x10(%rax)
movq $0x0, (%rax)
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x1ca12
movq -0x38(%rbp), %rax
movq (%rax), %rdi
movq -0x28(%rbp), %rsi
callq 0x64e0
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x10(%rax)
callq 0x64f0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x1c9f9
movq 0x1864e(%rip), %rdi     # 0x34ff0
leaq 0x8c7c(%rip), %rsi      # 0x25625
callq 0x6520
movq %rax, %rdi
movq -0x30(%rbp), %rsi
callq 0x6520
movq %rax, %rdi
movq 0x185d4(%rip), %rsi     # 0x34f98
callq 0x6580
movq -0x38(%rbp), %rax
movq (%rax), %rdi
callq 0x6430
movq -0x38(%rbp), %rax
movq $0x0, 0x8(%rax)
movq $0x0, 0x10(%rax)
movq $0x0, (%rax)
movl $0xfffffffd, -0x4(%rbp) # imm = 0xFFFFFFFD
jmp 0x1ca12
movq -0x38(%rbp), %rax
callq *0x8(%rax)
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x18(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)