// File: /workspace/github_c_makefile_star2_O0/aremmell[P]libsir/src/sirplugins.c
// Function: sir_plugin_probe
sirpluginid _sir_plugin_probe(sir_plugin* plugin) {
#if !defined(SIR_NO_PLUGINS)
    sirpluginid retval = 0U;
    if (plugin) {
# if SIR_PLUGIN_VCURRENT == SIR_PLUGIN_V1
       /* if/when new versions of plugin interfaces are introduced, we will need to
        * modify/extend the following code:
        *
        * - remove the enclosing #if
        * - get the v1 exports (all versions will have v1 exports), resolve them,
        * and call sir_plugin_query.
        * - switch on version returned to resolve additional exports. this will
        * necessitate additional versioned interface structures as members of the
        * sir_plugin struct, e.g. ifacev1, ifacev2). */
        plugin->iface.query   = (sir_plugin_queryfn)
            _sir_plugin_getexport(plugin->handle, SIR_PLUGIN_EXPORT_QUERY);
        plugin->iface.init    = (sir_plugin_initfn)
            _sir_plugin_getexport(plugin->handle, SIR_PLUGIN_EXPORT_INIT);
        plugin->iface.write   = (sir_plugin_writefn)
            _sir_plugin_getexport(plugin->handle, SIR_PLUGIN_EXPORT_WRITE);
        plugin->iface.cleanup = (sir_plugin_cleanupfn)
            _sir_plugin_getexport(plugin->handle, SIR_PLUGIN_EXPORT_CLEANUP);

        if (!plugin->iface.query || !plugin->iface.init ||
            !plugin->iface.write || !plugin->iface.cleanup) {
            _sir_selflog("error: export(s) not resolved for plugin (path:"
                         " '%s', addr: %p)!", plugin->path, plugin->handle);
            _sir_selflog("exports (query: %"PRIxPTR", init: %"PRIxPTR", write:"
                         " %"PRIxPTR", cleanup; %"PRIxPTR")",
                         (uintptr_t)plugin->iface.query, (uintptr_t)plugin->iface.init,
                         (uintptr_t)plugin->iface.write, (uintptr_t)plugin->iface.cleanup);
            _sir_plugin_destroy(&plugin);
            return _sir_seterror(_SIR_E_PLUGINBAD);
        }
# else
#  error "plugin version not implemented"
# endif
        /* query the plugin for information. */
        if (!plugin->iface.query(&plugin->info)) {
            _sir_selflog("error: plugin (path: '%s', addr: %p) returned false from"
                         " query fn!", plugin->path, plugin->handle);
            _sir_plugin_destroy(&plugin);
            (void)_sir_seterror(_SIR_E_PLUGINERR);
            return 0U;
        }

        /* verify version. */
        if (!plugin->info.iface_ver || plugin->info.iface_ver > SIR_PLUGIN_VCURRENT) {
            _sir_selflog("error: plugin (path: '%s', addr: %p) has version"
                         " %"PRIu8"; libsir has %d", plugin->path, plugin->handle,
                        plugin->info.iface_ver, SIR_PLUGIN_VCURRENT);
            _sir_plugin_destroy(&plugin);
            (void)_sir_seterror(_SIR_E_PLUGINVER);
            return 0U;
        }

        bool data_valid = true;

        /* verify level registration bitmask. */
        if (!_sir_validlevels(plugin->info.levels)) {
            _sir_selflog("error: plugin (path: '%s', addr: %p) has invalid levels"
                         " %04"PRIx16, plugin->path, plugin->handle, plugin->info.levels);
            data_valid = false;
        }

        /* verify formatting options bitmask. */
        if (!_sir_validopts(plugin->info.opts)) {
            _sir_selflog("error: plugin (path: '%s', addr: %p) has invalid opts"
                         " %08"PRIx32, plugin->path, plugin->handle, plugin->info.opts);
            data_valid = false;
        }

        /* verify strings */
        if (!_sir_validstrnofail(plugin->info.author) ||
            !_sir_validstrnofail(plugin->info.desc)) {
            _sir_selflog("error: plugin (path: '%s', addr: %p) has invalid author"
                         " or description", plugin->path, plugin->handle);
            data_valid = false;
        }

        /* if any category of data is invalid, fail and unload. */
        if (!data_valid) {
            _sir_plugin_destroy(&plugin);
            (void)_sir_seterror(_SIR_E_PLUGINDAT);
            return 0U;
        }

        /* plugin is valid; tell it to initialize, assign it an id,
         * print its information, and add to cache. */
        if (!plugin->iface.init()) {
            _sir_selflog("error: plugin (path: '%s', addr: %p) failed to initialize!",
                plugin->path, plugin->handle);
            _sir_plugin_destroy(&plugin);
            (void)_sir_seterror(_SIR_E_PLUGINERR);
            return 0U;
        }

        plugin->id    = FNV32_1a((const uint8_t*)&plugin->iface, sizeof(sir_pluginiface));
        plugin->valid = true;

        _sir_selflog("successfully validated plugin (path: '%s', id: %08"PRIx32"); properties:"
                     SIR_EOL "{"
                     SIR_EOL "\tversion = %"PRIu8".%"PRIu8".%"PRIu8
                     SIR_EOL "\tlevels = %04"PRIx16
                     SIR_EOL "\topts = %08"PRIx32
                     SIR_EOL "\tauthor = '%s'"
                     SIR_EOL "\tdesc = '%s'"
                     SIR_EOL "\tcaps = %016"PRIx64
                     SIR_EOL "}",
                     plugin->path, plugin->id, plugin->info.maj_ver, plugin->info.min_ver,
                     plugin->info.bld_ver, plugin->info.levels, plugin->info.opts,
                     _SIR_PRNSTR(plugin->info.author), _SIR_PRNSTR(plugin->info.desc),
                     plugin->info.caps);

        retval = _sir_plugin_add(plugin);
        if (0U == retval) {
            _sir_selflog("error: failed to add plugin (path: '%s', addr: %p) to"
                         " cache; unloading", plugin->path, plugin->handle);
            _sir_plugin_destroy(&plugin);
        }
    }

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

// Assembly:
pushq %rbp
pushq %rbx
subq $0x78, %rsp
movq %rdi, 0x68(%rsp)
movl $0x0, 0x64(%rsp)
cmpq $0x0, 0x68(%rsp)
je 0xd66e
movq 0x68(%rsp), %rax
movq 0x8(%rax), %rdi
leaq 0x4856(%rip), %rsi      # 0x11985
callq 0xd690
movq %rax, %rcx
movq 0x68(%rsp), %rax
movq %rcx, 0x40(%rax)
movq 0x68(%rsp), %rax
movq 0x8(%rax), %rdi
leaq 0x4846(%rip), %rsi      # 0x11996
callq 0xd690
movq %rax, %rcx
movq 0x68(%rsp), %rax
movq %rcx, 0x48(%rax)
movq 0x68(%rsp), %rax
movq 0x8(%rax), %rdi
leaq 0x4835(%rip), %rsi      # 0x119a6
callq 0xd690
movq %rax, %rcx
movq 0x68(%rsp), %rax
movq %rcx, 0x50(%rax)
movq 0x68(%rsp), %rax
movq 0x8(%rax), %rdi
leaq 0x4825(%rip), %rsi      # 0x119b7
callq 0xd690
movq %rax, %rcx
movq 0x68(%rsp), %rax
movq %rcx, 0x58(%rax)
movq 0x68(%rsp), %rax
cmpq $0x0, 0x40(%rax)
je 0xd1d7
movq 0x68(%rsp), %rax
cmpq $0x0, 0x48(%rax)
je 0xd1d7
movq 0x68(%rsp), %rax
cmpq $0x0, 0x50(%rax)
je 0xd1d7
movq 0x68(%rsp), %rax
cmpq $0x0, 0x58(%rax)
jne 0xd25d
movq 0x68(%rsp), %rax
movq (%rax), %rsi
movq 0x68(%rsp), %rax
movq 0x8(%rax), %rdx
leaq 0x47db(%rip), %rdi      # 0x119ca
movb $0x0, %al
callq 0xd060
movq 0x68(%rsp), %rax
movq 0x40(%rax), %rsi
movq 0x68(%rsp), %rax
movq 0x48(%rax), %rdx
movq 0x68(%rsp), %rax
movq 0x50(%rax), %rcx
movq 0x68(%rsp), %rax
movq 0x58(%rax), %r8
leaq 0x47ea(%rip), %rdi      # 0x11a0b
movb $0x0, %al
callq 0xd060
leaq 0x68(%rsp), %rdi
callq 0xd070
movl $0x80130000, %edi       # imm = 0x80130000
leaq 0x4807(%rip), %rsi      # 0x11a45
leaq 0x46db(%rip), %rdx      # 0x11920
movl $0x74, %ecx
callq 0x3940
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x74(%rsp)
jmp 0xd676
movq 0x68(%rsp), %rax
movq 0x40(%rax), %rax
movq 0x68(%rsp), %rdi
addq $0x10, %rdi
callq *%rax
testb $0x1, %al
jne 0xd2c8
movq 0x68(%rsp), %rax
movq (%rax), %rsi
movq 0x68(%rsp), %rax
movq 0x8(%rax), %rdx
leaq 0x47ca(%rip), %rdi      # 0x11a57
movb $0x0, %al
callq 0xd060
leaq 0x68(%rsp), %rdi
callq 0xd070
movl $0x80160000, %edi       # imm = 0x80160000
leaq 0x479b(%rip), %rsi      # 0x11a45
leaq 0x466f(%rip), %rdx      # 0x11920
movl $0x7e, %ecx
callq 0x3940
movl $0x0, 0x74(%rsp)
jmp 0xd676
movq 0x68(%rsp), %rax
cmpb $0x0, 0x10(%rax)
je 0xd2e1
movq 0x68(%rsp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x1, %eax
jle 0xd343
movq 0x68(%rsp), %rax
movq (%rax), %rsi
movq 0x68(%rsp), %rax
movq 0x8(%rax), %rdx
movq 0x68(%rsp), %rax
movzbl 0x10(%rax), %ecx
leaq 0x4798(%rip), %rdi      # 0x11a9a
movl $0x1, %r8d
movb $0x0, %al
callq 0xd060
leaq 0x68(%rsp), %rdi
callq 0xd070
movl $0x80150000, %edi       # imm = 0x80150000
leaq 0x4720(%rip), %rsi      # 0x11a45
leaq 0x45f4(%rip), %rdx      # 0x11920
movl $0x88, %ecx
callq 0x3940
movl $0x0, 0x74(%rsp)
jmp 0xd676
movb $0x1, 0x63(%rsp)
movq 0x68(%rsp), %rax
leaq 0x46f1(%rip), %rsi      # 0x11a45
leaq 0x45c5(%rip), %rdx      # 0x11920
movl $0x8f, %ecx
movzwl 0x14(%rax), %edi
callq 0x7da0
testb $0x1, %al
jne 0xd39a
movq 0x68(%rsp), %rax
movq (%rax), %rsi
movq 0x68(%rsp), %rax
movq 0x8(%rax), %rdx
movq 0x68(%rsp), %rax
movzwl 0x14(%rax), %ecx
leaq 0x474f(%rip), %rdi      # 0x11add
movb $0x0, %al
callq 0xd060
movb $0x0, 0x63(%rsp)
movq 0x68(%rsp), %rax
movl 0x18(%rax), %edi
leaq 0x469c(%rip), %rsi      # 0x11a45
leaq 0x4570(%rip), %rdx      # 0x11920
movl $0x96, %ecx
callq 0x7ed0
testb $0x1, %al
jne 0xd3ea
movq 0x68(%rsp), %rax
movq (%rax), %rsi
movq 0x68(%rsp), %rax
movq 0x8(%rax), %rdx
movq 0x68(%rsp), %rax
movl 0x18(%rax), %ecx
leaq 0x473c(%rip), %rdi      # 0x11b1a
movb $0x0, %al
callq 0xd060
movb $0x0, 0x63(%rsp)
movq 0x68(%rsp), %rax
movq 0x20(%rax), %rdi
xorl %esi, %esi
leaq 0x4649(%rip), %rdx      # 0x11a45
leaq 0x451d(%rip), %rcx      # 0x11920
movl $0x9d, %r8d
callq 0xcfe0
testb $0x1, %al
jne 0xd414
jmp 0xd43c
movq 0x68(%rsp), %rax
movq 0x28(%rax), %rdi
xorl %esi, %esi
leaq 0x461f(%rip), %rdx      # 0x11a45
leaq 0x44f3(%rip), %rcx      # 0x11920
movl $0x9e, %r8d
callq 0xcfe0
testb $0x1, %al
jne 0xd460
movq 0x68(%rsp), %rax
movq (%rax), %rsi
movq 0x68(%rsp), %rax
movq 0x8(%rax), %rdx
leaq 0x4701(%rip), %rdi      # 0x11b55
movb $0x0, %al
callq 0xd060
movb $0x0, 0x63(%rsp)
testb $0x1, 0x63(%rsp)
jne 0xd49b
leaq 0x68(%rsp), %rdi
callq 0xd070
movl $0x80140000, %edi       # imm = 0x80140000
leaq 0x45c8(%rip), %rsi      # 0x11a45
leaq 0x449c(%rip), %rdx      # 0x11920
movl $0xa7, %ecx
callq 0x3940
movl $0x0, 0x74(%rsp)
jmp 0xd676
movq 0x68(%rsp), %rax
callq *0x48(%rax)
testb $0x1, %al
jne 0xd4fa
movq 0x68(%rsp), %rax
movq (%rax), %rsi
movq 0x68(%rsp), %rax
movq 0x8(%rax), %rdx
leaq 0x46dd(%rip), %rdi      # 0x11b9c
movb $0x0, %al
callq 0xd060
leaq 0x68(%rsp), %rdi
callq 0xd070
movl $0x80160000, %edi       # imm = 0x80160000
leaq 0x4569(%rip), %rsi      # 0x11a45
leaq 0x443d(%rip), %rdx      # 0x11920
movl $0xb1, %ecx
callq 0x3940
movl $0x0, 0x74(%rsp)
jmp 0xd676
movq 0x68(%rsp), %rdi
addq $0x40, %rdi
movl $0x20, %esi
callq 0xd7e0
movl %eax, %ecx
movq 0x68(%rsp), %rax
movl %ecx, 0x60(%rax)
movq 0x68(%rsp), %rax
movb $0x1, 0x39(%rax)
movq 0x68(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x40(%rsp)
movq 0x68(%rsp), %rax
movl 0x60(%rax), %eax
movl %eax, 0x48(%rsp)
movq 0x68(%rsp), %rax
movzbl 0x11(%rax), %eax
movl %eax, 0x4c(%rsp)
movq 0x68(%rsp), %rax
movzbl 0x12(%rax), %eax
movl %eax, 0x50(%rsp)
movq 0x68(%rsp), %rax
movzbl 0x13(%rax), %eax
movl %eax, 0x54(%rsp)
movq 0x68(%rsp), %rax
movzwl 0x14(%rax), %eax
movl %eax, 0x58(%rsp)
movq 0x68(%rsp), %rax
movl 0x18(%rax), %eax
movl %eax, 0x5c(%rsp)
movq 0x68(%rsp), %rax
cmpq $0x0, 0x20(%rax)
je 0xd595
movq 0x68(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0x38(%rsp)
jmp 0xd5a3
leaq 0x43b1(%rip), %rax      # 0x1194d
movq %rax, 0x38(%rsp)
jmp 0xd5a3
movq 0x38(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x68(%rsp), %rax
cmpq $0x0, 0x28(%rax)
je 0xd5c9
movq 0x68(%rsp), %rax
movq 0x28(%rax), %rax
movq %rax, 0x28(%rsp)
jmp 0xd5d7
leaq 0x437d(%rip), %rax      # 0x1194d
movq %rax, 0x28(%rsp)
jmp 0xd5d7
movq 0x30(%rsp), %r11
movl 0x5c(%rsp), %ebx
movl 0x58(%rsp), %ebp
movl 0x54(%rsp), %r9d
movl 0x50(%rsp), %r8d
movl 0x4c(%rsp), %ecx
movl 0x48(%rsp), %edx
movq 0x40(%rsp), %rsi
movq 0x28(%rsp), %r10
movq 0x68(%rsp), %rax
movq 0x30(%rax), %rax
leaq 0x45c7(%rip), %rdi      # 0x11bd7
movl %ebp, (%rsp)
movl %ebx, 0x8(%rsp)
movq %r11, 0x10(%rsp)
movq %r10, 0x18(%rsp)
movq %rax, 0x20(%rsp)
movb $0x0, %al
callq 0xd060
movq 0x68(%rsp), %rdi
callq 0xd850
movl %eax, 0x64(%rsp)
xorl %eax, %eax
cmpl 0x64(%rsp), %eax
jne 0xd66c
movq 0x68(%rsp), %rax
movq (%rax), %rsi
movq 0x68(%rsp), %rax
movq 0x8(%rax), %rdx
leaq 0x461d(%rip), %rdi      # 0x11c78
movb $0x0, %al
callq 0xd060
leaq 0x68(%rsp), %rdi
callq 0xd070
jmp 0xd66e
movl 0x64(%rsp), %eax
movl %eax, 0x74(%rsp)
movl 0x74(%rsp), %eax
addq $0x78, %rsp
popq %rbx
popq %rbp
retq
nopw %cs:(%rax,%rax)