// File: /workspace/github_cpp_makefile_star2_O2/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 %r12
pushq %rbx
subq $0xd0, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq 0x6b1d4(%rip), %r12     # 0xb6f68
movq %r12, %rdi
callq 0x4d4dc
addq $0x8, %r12
cmpq %r12, %rax
jne 0x4bea2
leaq 0x2caeb(%rip), %rdx     # 0x7889b
leaq 0xb0(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x1cb3b
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x4baa4
leaq 0x70(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x1f1e6
leaq 0x70(%rsp), %r12
movq (%r12), %rdi
pushq $0x1
popq %rsi
callq 0x10560
movq %rax, %r15
movq %r12, %rdi
callq 0x101d0
leaq 0x10(%rsp), %rdi
callq 0x1ca5c
testq %r15, %r15
je 0x4beb2
leaq 0x2caab(%rip), %rdx     # 0x788c6
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x1cb3b
leaq 0x10(%rsp), %r12
movq (%r12), %rsi
movq %r15, %rdi
callq 0x103a0
movq %rax, %r15
movq %r12, %rdi
callq 0x101d0
testq %r15, %r15
je 0x4bf5b
leaq 0x18(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq 0x10(%rsp), %rdi
callq *%r15
leaq 0x6b0f2(%rip), %rdi     # 0xb6f68
movq %r14, %rsi
callq 0x4cdba
leaq 0x10(%rsp), %rsi
movq %rax, %rdi
callq 0x4d072
leaq 0x10(%rsp), %rdi
callq 0x4d41e
leaq 0xb0(%rsp), %rdi
callq 0x101d0
addq $0xd0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
andq $0x0, 0x50(%rsp)
movl $0xa8, %edi
callq 0x101f0
movq %rax, %r14
leaq 0x2c9cb(%rip), %rsi     # 0x7889f
leaq 0x70(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x1c814
leaq 0x90(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x10550
leaq 0x58(%rsp), %rdi
leaq 0x90(%rsp), %rsi
pushq $0x1
popq %rdx
leaq 0xe(%rsp), %rcx
callq 0x1f298
leaq 0x10(%rsp), %rdi
leaq 0x70(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x3f724
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
leaq 0x40(%rsp), %rcx
movq %r14, %rdi
movq %rbx, %rdx
callq 0x3ebb8
xorl %ebp, %ebp
leaq 0x65d59(%rip), %rsi     # 0xb1ca0
leaq -0x1cadc(%rip), %rdx    # 0x2f472
movq %r14, %rdi
callq 0x106c0
jmp 0x4bfff
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
andq $0x0, 0x50(%rsp)
movl $0xa8, %edi
callq 0x101f0
movq %rax, %r14
leaq 0x2c95f(%rip), %rsi     # 0x788dc
leaq 0x70(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x1c814
leaq 0x90(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x10550
leaq 0x58(%rsp), %rdi
leaq 0x90(%rsp), %rsi
pushq $0x1
popq %rdx
leaq 0xe(%rsp), %rcx
callq 0x1f298
leaq 0x10(%rsp), %rdi
leaq 0x70(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x3f724
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
leaq 0x40(%rsp), %rcx
movq %r14, %rdi
movq %rbx, %rdx
callq 0x3ebb8
xorl %ebp, %ebp
leaq 0x65cb0(%rip), %rsi     # 0xb1ca0
leaq -0x1cb85(%rip), %rdx    # 0x2f472
movq %r14, %rdi
callq 0x106c0
jmp 0x4c003
jmp 0x4c012
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x101d0
jmp 0x4c018
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x58(%rsp), %rdi
callq 0x1cea0
jmp 0x4c02c
jmp 0x4c026
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x90(%rsp), %rdi
callq 0x101d0
jmp 0x4c043
jmp 0x4c03d
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x70(%rsp), %rdi
callq 0x101d0
testb %bpl, %bpl
jne 0x4c059
jmp 0x4c061
jmp 0x4c056
movq %rax, %rbx
movq %r14, %rdi
callq 0x102e0
leaq 0x40(%rsp), %rdi
callq 0x1cb1a
jmp 0x4c090
jmp 0x4c07e
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x1ca5c
jmp 0x4c090
movq %rax, %rbx
jmp 0x4c090
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x4d41e
leaq 0xb0(%rsp), %rdi
callq 0x101d0
movq %rbx, %rdi
callq 0x106f0