// File: /workspace/github_c_makefile_star2_O0/aremmell[P]libsir/src/sirplugins.c
// Function: sir_plugin_unload
bool _sir_plugin_unload(sir_plugin* plugin) {
#if !defined(SIR_NO_PLUGINS)
    if (!_sir_validptrnofail(plugin) || !_sir_validptrnofail(plugin->handle)) {
        _sir_selflog("error: plugin object (%p) or handle (%p) are null;"
                     " cannot unload!", (void*)plugin, (plugin ? plugin->handle : NULL));
        return false;
    }

    /* if the plugin cleanup export was resolved, call it. */
    if (plugin->iface.cleanup && !plugin->iface.cleanup())
        _sir_selflog("warning: plugin (path: '%s', addr: %p) reports unsuccessful"
                     " cleanup!", plugin->path, plugin->handle);

# if !defined(__WIN__)
    if (0 != dlclose(plugin->handle)) {
        const char* err = dlerror();
        _sir_selflog("error: dlclose(%p) failed (%s)", plugin->handle, _SIR_PRNSTR(err));
        return _sir_handleerr(errno);
    }
# else /* __WIN__ */
    if (!FreeLibrary(plugin->handle)) {
        DWORD err = GetLastError();
        _sir_selflog("error: FreeLibrary(%p) failed (%lu)", plugin->handle, err);
        return _sir_handlewin32err(err);
    }
# endif

    plugin->handle = NULL;
    plugin->loaded = false;
    _sir_selflog("unloaded plugin (path: '%s', id: %08"PRIx32")", plugin->path,
        plugin->id);
    return true;
#else
    SIR_UNUSED(plugin);
    return false;
#endif
}

// Assembly:
subq $0x38, %rsp
movq %rdi, 0x28(%rsp)
movq 0x28(%rsp), %rdi
xorl %esi, %esi
leaq 0x43ad(%rip), %rdx      # 0x11d34
leaq 0x3f92(%rip), %rcx      # 0x11920
movl $0xfb, %r8d
callq 0xd900
testb $0x1, %al
jne 0xd99f
jmp 0xd9c7
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rdi
xorl %esi, %esi
leaq 0x4383(%rip), %rdx      # 0x11d34
leaq 0x3f68(%rip), %rcx      # 0x11920
movl $0xfb, %r8d
callq 0xd900
testb $0x1, %al
jne 0xda14
movq 0x28(%rsp), %rax
movq %rax, 0x18(%rsp)
cmpq $0x0, 0x28(%rsp)
je 0xd9e9
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x10(%rsp)
jmp 0xd9f2
xorl %eax, %eax
movq %rax, 0x10(%rsp)
jmp 0xd9f2
movq 0x18(%rsp), %rsi
movq 0x10(%rsp), %rdx
leaq 0x4344(%rip), %rdi      # 0x11d47
movb $0x0, %al
callq 0xd060
movb $0x0, 0x37(%rsp)
jmp 0xdb10
movq 0x28(%rsp), %rax
cmpq $0x0, 0x58(%rax)
je 0xda4b
movq 0x28(%rsp), %rax
callq *0x58(%rax)
testb $0x1, %al
jne 0xda4b
movq 0x28(%rsp), %rax
movq (%rax), %rsi
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rdx
leaq 0x4345(%rip), %rdi      # 0x11d89
movb $0x0, %al
callq 0xd060
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x2410
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
je 0xdad7
callq 0x2040
movq %rax, 0x20(%rsp)
movq 0x28(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x8(%rsp)
cmpq $0x0, 0x20(%rsp)
je 0xda8c
movq 0x20(%rsp), %rax
movq %rax, (%rsp)
jmp 0xda99
leaq 0x3eba(%rip), %rax      # 0x1194d
movq %rax, (%rsp)
jmp 0xda99
movq 0x8(%rsp), %rsi
movq (%rsp), %rdx
leaq 0x4325(%rip), %rdi      # 0x11dce
movb $0x0, %al
callq 0xd060
callq 0x2070
movl (%rax), %edi
leaq 0x4276(%rip), %rsi      # 0x11d34
leaq 0x3e5b(%rip), %rdx      # 0x11920
movl $0x10a, %ecx            # imm = 0x10A
callq 0x3c00
andb $0x1, %al
movb %al, 0x37(%rsp)
jmp 0xdb10
movq 0x28(%rsp), %rax
movq $0x0, 0x8(%rax)
movq 0x28(%rsp), %rax
movb $0x0, 0x38(%rax)
movq 0x28(%rsp), %rax
movq (%rax), %rsi
movq 0x28(%rsp), %rax
movl 0x60(%rax), %edx
leaq 0x42e9(%rip), %rdi      # 0x11ded
movb $0x0, %al
callq 0xd060
movb $0x1, 0x37(%rsp)
movb 0x37(%rsp), %al
andb $0x1, %al
addq $0x38, %rsp
retq
nopl (%rax,%rax)