// File: /workspace/github_cpp_makefile_star2_O1/Nallantli[P]Rossa/main/rossa/global/global.cpp
// Function: global::loadLibrary(std::filesystem::__cxx11::path const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, token_t const*)
void global::loadLibrary(const std::filesystem::path &currentDir, const std::string &rawlibname, const token_t *token)
{
	if (loaded.find(rawlibname) == loaded.end())
	{
#ifndef _WIN32
		std::string libname = rawlibname + ".so";
		auto library = dlopen(dir::findFile(currentDir, libname, token).string().c_str(), RTLD_LAZY);
		if (library == NULL)
		{
			trace_t stack_trace;
			throw rossa_error_t(util::format(_EXTERNAL_LIBRARY_NOT_EXIST_, {libname}), *token, stack_trace);
		}
		auto f = dlsym(library, (rawlibname + "_rossaExportFunctions").c_str());
#else
		std::string libname = rawlibname + ".dll";
		auto path = dir::findFile(currentDir, libname, token);
		auto library = LoadLibraryA(path.string().c_str());
		if (library == NULL)
		{
			trace_t stack_trace;
			throw rossa_error_t(util::format(_EXTERNAL_LIBRARY_NOT_EXIST_, {libname}), *token, stack_trace);
		}
		auto f = GetProcAddress(library, (rawlibname + "_rossaExportFunctions").c_str());
#endif
		if (f == NULL)
		{
			trace_t stack_trace;
			throw rossa_error_t(util::format(_EXPORT_FUNCTION_NOT_FOUND_, {libname}), *token, stack_trace);
		}
		std::map<std::string, extf_t> fns;
		auto ef = (export_fns_t)f;
		ef(fns);
		loaded[rawlibname] = fns;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq 0x613fd(%rip), %r12     # 0xb7f58
movq %r12, %rdi
callq 0x587e4
addq $0x8, %r12
cmpq %r12, %rax
jne 0x56cd1
leaq 0x70(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x60(%rsp), %r12
movq %r12, %rdi
callq 0x1e014
leaq 0x2fcc4(%rip), %rsi     # 0x8685b
movq %r12, %rdi
callq 0x10770
leaq 0x10(%rsp), %rdi
leaq 0x60(%rsp), %rdx
movq %r15, %rsi
movq %rbx, %rcx
callq 0x567f8
movq 0x10(%rsp), %rsi
leaq 0x50(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x18(%rsp), %rdx
addq %rsi, %rdx
leaq 0x40(%rsp), %rdi
callq 0x1e7ca
movq 0x40(%rsp), %rdi
movl $0x1, %esi
callq 0x10550
movq %rax, %r15
movq 0x40(%rsp), %rdi
cmpq %r12, %rdi
je 0x56bfe
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x103d0
leaq 0x10(%rsp), %rdi
callq 0x1d736
testq %r15, %r15
je 0x56ce3
leaq 0x20(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x10(%rsp), %rdi
callq 0x1e014
leaq 0x2fc51(%rip), %rsi     # 0x86886
leaq 0x10(%rsp), %rdi
callq 0x10770
movq 0x10(%rsp), %rsi
movq %r15, %rdi
callq 0x10390
movq %rax, %r15
movq 0x10(%rsp), %rdi
cmpq %rbp, %rdi
je 0x56c66
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x103d0
testq %r15, %r15
je 0x56db6
leaq 0x18(%rsp), %rax
movl $0x0, (%rax)
xorl %ecx, %ecx
movq %rcx, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
movq %rcx, 0x20(%rax)
leaq 0x10(%rsp), %rdi
callq *%r15
leaq 0x612bd(%rip), %rdi     # 0xb7f58
movq %r14, %rsi
callq 0x580a4
leaq 0x10(%rsp), %rsi
movq %rax, %rdi
callq 0x583b2
leaq 0x10(%rsp), %rdi
callq 0x58748
movq 0x60(%rsp), %rdi
cmpq %r13, %rdi
je 0x56cd1
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x103d0
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorps %xmm0, %xmm0
movaps %xmm0, 0xa0(%rsp)
movq $0x0, 0xb0(%rsp)
movl $0xa8, %edi
callq 0x101e0
movq %rax, %r14
leaq 0x40(%rsp), %rdi
movq %r12, (%rdi)
leaq 0x2fb49(%rip), %rsi     # 0x8685f
leaq 0x2fb68(%rip), %rdx     # 0x86885
callq 0x1e7ca
leaq 0x90(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rdx
addq %rsi, %rdx
leaq 0x80(%rsp), %rdi
callq 0x1e014
leaq 0xc0(%rsp), %rdi
leaq 0x80(%rsp), %rsi
leaq 0xf(%rsp), %rcx
movl $0x1, %edx
callq 0x20c5e
leaq 0x10(%rsp), %rdi
leaq 0x40(%rsp), %rsi
leaq 0xc0(%rsp), %rdx
callq 0x48694
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
leaq 0xa0(%rsp), %rcx
movq %r14, %rdi
movq %rbx, %rdx
callq 0x476dc
xorl %ebp, %ebp
leaq 0x5bf3e(%rip), %rsi     # 0xb2ce0
leaq -0x1f5f5(%rip), %rdx    # 0x377b4
movq %r14, %rdi
callq 0x106d0
jmp 0x56e85
xorps %xmm0, %xmm0
movaps %xmm0, 0xa0(%rsp)
movq $0x0, 0xb0(%rsp)
movl $0xa8, %edi
callq 0x101e0
movq %rax, %r14
leaq 0x40(%rsp), %rdi
movq %r12, (%rdi)
leaq 0x2fab3(%rip), %rsi     # 0x8689c
leaq 0x2fad6(%rip), %rdx     # 0x868c6
callq 0x1e7ca
leaq 0x90(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rdx
addq %rsi, %rdx
leaq 0x80(%rsp), %rdi
callq 0x1e014
leaq 0xc0(%rsp), %rdi
leaq 0x80(%rsp), %rsi
leaq 0xf(%rsp), %rcx
movl $0x1, %edx
callq 0x20c5e
leaq 0x10(%rsp), %rdi
leaq 0x40(%rsp), %rsi
leaq 0xc0(%rsp), %rdx
callq 0x48694
movb $0x1, %r15b
leaq 0x10(%rsp), %rsi
leaq 0xa0(%rsp), %rcx
movq %r14, %rdi
movq %rbx, %rdx
callq 0x476dc
xorl %r15d, %r15d
leaq 0x5be6a(%rip), %rsi     # 0xb2ce0
leaq -0x1f6c9(%rip), %rdx    # 0x377b4
movq %r14, %rdi
callq 0x106d0
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %rbp, %rdi
je 0x56ea7
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x103d0
jmp 0x56ea7
movq %rax, %rbx
movb $0x1, %r15b
leaq 0xc0(%rsp), %rdi
callq 0x1dca2
jmp 0x56ef1
movq %rax, %rbx
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x56edc
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x103d0
jmp 0x56edc
movq %rax, %rbx
movb $0x1, %bpl
leaq 0xc0(%rsp), %rdi
callq 0x1dca2
jmp 0x56f1e
movq %rax, %rbx
movb $0x1, %r15b
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x56f43
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x103d0
jmp 0x56f43
movq %rax, %rbx
movb $0x1, %bpl
movq 0x80(%rsp), %rdi
cmpq %r15, %rdi
je 0x56f62
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x103d0
jmp 0x56f62
movq %rax, %rbx
movb $0x1, %r15b
movq 0x40(%rsp), %rdi
cmpq %r12, %rdi
je 0x56f81
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x103d0
jmp 0x56f81
movq %rax, %rbx
movb $0x1, %bpl
movq 0x40(%rsp), %rdi
cmpq %r12, %rdi
je 0x56f8e
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x103d0
jmp 0x56f8e
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
jne 0x56f93
jmp 0x56f9b
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0x56f9b
movq %r14, %rdi
callq 0x102d0
leaq 0xa0(%rsp), %rdi
callq 0x1d77a
jmp 0x56feb
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %rbp, %rdi
je 0x56feb
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x103d0
jmp 0x56feb
jmp 0x56fd9
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x1d736
jmp 0x56feb
jmp 0x56fd9
movq %rax, %rbx
jmp 0x56feb
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x58748
movq 0x60(%rsp), %rdi
cmpq %r13, %rdi
je 0x57002
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x103d0
movq %rbx, %rdi
callq 0x106f0