// File: /workspace/github_c_makefile_star2_O0/aremmell[P]libsir/src/sirplugins.c
// Function: sir_plugin_load
sirpluginid _sir_plugin_load(const char* path) {
#if !defined(SIR_NO_PLUGINS)
    (void)_sir_seterror(_SIR_E_NOERROR);

    if (!_sir_sanity() || !_sir_validstr(path))
        return 0U;

    sir_plugin* plugin = (sir_plugin*)calloc(1, sizeof(sir_plugin));
    if (!plugin)
        return _sir_handleerr(errno);

# if !defined (__WIN__)
    plugin->handle = dlopen(path, RTLD_NOW | RTLD_LOCAL);
    if (!plugin->handle) {
        const char* err = dlerror();
        _sir_selflog("error: dlopen('%s') failed (%s)", path, _SIR_PRNSTR(err));
        _sir_plugin_destroy(&plugin);
        return _sir_handleerr(errno);
    }
# else /* __WIN__ */
    UINT old_error_mode = SetErrorMode(SEM_FAILCRITICALERRORS);
    plugin->handle      = LoadLibraryA(path);
    SetErrorMode(old_error_mode);
    if (!plugin->handle) {
        DWORD err = GetLastError();
        _sir_selflog("error: LoadLibraryA(%s) failed (%lu)", path, err);
        _sir_plugin_destroy(&plugin);
        return _sir_handlewin32err(err);
    }
# endif

    plugin->loaded = true;
    plugin->path   = strndup(path, strnlen(path, SIR_MAXPATH));

    if (!_sir_validstrnofail(plugin->path)) {
        _sir_plugin_destroy(&plugin);
        return _sir_handleerr(errno);
    }

    _sir_selflog("loaded plugin (path: '%s', addr: %p); probing...", //-V576
        plugin->path, plugin->handle);

    return _sir_plugin_probe(plugin);
#else
    SIR_UNUSED(path);
    return 0U;
#endif
}

// Assembly:
subq $0x38, %rsp
movq %rdi, 0x28(%rsp)
movl $0x80010000, %edi       # imm = 0x80010000
leaq 0x4b4a(%rip), %rsi      # 0x1190f
leaq 0x4b54(%rip), %rdx      # 0x11920
movl $0x25, %ecx
callq 0x3940
callq 0x9d10
testb $0x1, %al
jne 0xcde1
jmp 0xce08
movq 0x28(%rsp), %rdi
movl $0x1, %esi
leaq 0x4b1d(%rip), %rdx      # 0x1190f
leaq 0x4b27(%rip), %rcx      # 0x11920
movl $0x27, %r8d
callq 0xcfe0
testb $0x1, %al
jne 0xce15
movl $0x0, 0x34(%rsp)
jmp 0xcfce
movl $0x1, %edi
movl $0x68, %esi
callq 0x2230
movq %rax, 0x20(%rsp)
cmpq $0x0, 0x20(%rsp)
jne 0xce5e
callq 0x2070
movl (%rax), %edi
leaq 0x4ad0(%rip), %rsi      # 0x1190f
leaq 0x4ada(%rip), %rdx      # 0x11920
movl $0x2c, %ecx
callq 0x3c00
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x34(%rsp)
jmp 0xcfce
movq 0x28(%rsp), %rdi
movl $0x2, %esi
callq 0x2250
movq %rax, %rcx
movq 0x20(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x20(%rsp), %rax
cmpq $0x0, 0x8(%rax)
jne 0xcf0e
callq 0x2040
movq %rax, 0x18(%rsp)
movq 0x28(%rsp), %rax
movq %rax, 0x10(%rsp)
cmpq $0x0, 0x18(%rsp)
je 0xceb1
movq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
jmp 0xcebf
leaq 0x4a95(%rip), %rax      # 0x1194d
movq %rax, 0x8(%rsp)
jmp 0xcebf
movq 0x10(%rsp), %rsi
movq 0x8(%rsp), %rdx
leaq 0x4a5d(%rip), %rdi      # 0x1192d
movb $0x0, %al
callq 0xd060
leaq 0x20(%rsp), %rdi
callq 0xd070
callq 0x2070
movl (%rax), %edi
leaq 0x4a20(%rip), %rsi      # 0x1190f
leaq 0x4a2a(%rip), %rdx      # 0x11920
movl $0x34, %ecx
callq 0x3c00
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x34(%rsp)
jmp 0xcfce
movq 0x20(%rsp), %rax
movb $0x1, 0x38(%rax)
movq 0x28(%rsp), %rax
movq %rax, (%rsp)
movq 0x28(%rsp), %rdi
movl $0x1000, %esi           # imm = 0x1000
callq 0x21d0
movq (%rsp), %rdi
movq %rax, %rsi
callq 0x2210
movq %rax, %rcx
movq 0x20(%rsp), %rax
movq %rcx, (%rax)
movq 0x20(%rsp), %rax
movq (%rax), %rdi
xorl %esi, %esi
leaq 0x49b8(%rip), %rdx      # 0x1190f
leaq 0x49c2(%rip), %rcx      # 0x11920
movl $0x45, %r8d
callq 0xcfe0
testb $0x1, %al
jne 0xcfa1
leaq 0x20(%rsp), %rdi
callq 0xd070
callq 0x2070
movl (%rax), %edi
leaq 0x498a(%rip), %rsi      # 0x1190f
leaq 0x4994(%rip), %rdx      # 0x11920
movl $0x47, %ecx
callq 0x3c00
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x34(%rsp)
jmp 0xcfce
movq 0x20(%rsp), %rax
movq (%rax), %rsi
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rdx
leaq 0x499b(%rip), %rdi      # 0x11954
movb $0x0, %al
callq 0xd060
movq 0x20(%rsp), %rdi
callq 0xd100
movl %eax, 0x34(%rsp)
movl 0x34(%rsp), %eax
addq $0x38, %rsp
retq
nopw (%rax,%rax)