// File: /workspace/github_c_makefile_star2_O0/aremmell[P]libsir/tests/tests.c
// Function: sirtest_pluginloader
bool sirtest_pluginloader(void) {
    INIT(si, SIRL_ALL, 0, 0, 0);
    bool pass = si_init;

#if !defined(__WIN__)
# define PLUGIN_EXT "so"
#else
# define PLUGIN_EXT "dll"
#endif

    static const char* plugin1 = "build/lib/plugin_dummy."PLUGIN_EXT;
    static const char* plugin2 = "build/lib/plugin_dummy_bad1."PLUGIN_EXT;
    static const char* plugin3 = "build/lib/plugin_dummy_bad2."PLUGIN_EXT;
    static const char* plugin4 = "build/lib/plugin_dummy_bad3."PLUGIN_EXT;
    static const char* plugin5 = "build/lib/plugin_dummy_bad4."PLUGIN_EXT;
    static const char* plugin6 = "build/lib/plugin_dummy_bad5."PLUGIN_EXT;
    static const char* plugin7 = "build/lib/plugin_dummy_bad6."PLUGIN_EXT;
    static const char* plugin8 = "build/lib/i_dont_exist."PLUGIN_EXT;

#if defined(SIR_NO_PLUGINS)
    SIR_UNUSED(plugin2);
    SIR_UNUSED(plugin3);
    SIR_UNUSED(plugin4);
    SIR_UNUSED(plugin5);
    SIR_UNUSED(plugin6);
    SIR_UNUSED(plugin7);
    SIR_UNUSED(plugin8);

    TEST_MSG_0("SIR_NO_PLUGINS is defined; expecting calls to fail");

    TEST_MSG("loading good plugin: '%s'...", plugin1);
    /* load a valid, well-behaved plugin. */
    sirpluginid id = sir_loadplugin(plugin1);
    _sir_eqland(pass, 0 == id);

    if (pass)
        PRINT_EXPECTED_ERROR();

    TEST_MSG("unloading good plugin: '%s'...", plugin1);
    /* also try the unload function. */
    _sir_eqland(pass, !sir_unloadplugin(id));

    if (pass)
        PRINT_EXPECTED_ERROR();
#else
    /* load a valid, well-behaved plugin. */
    TEST_MSG("loading good plugin: '%s'...", plugin1);
    sirpluginid id = sir_loadplugin(plugin1);
    _sir_eqland(pass, 0 != id);

    (void)print_test_error(pass, pass);

    _sir_eqland(pass, sir_info("this message will be dispatched to the plugin."));
    _sir_eqland(pass, sir_warn("this message will *not* be dispatched to the plugin."));

    /* re-loading the same plugin should fail. */
    TEST_MSG("loading duplicate plugin: '%s'...", plugin1);
    sirpluginid badid = sir_loadplugin(plugin1);
    _sir_eqland(pass, 0 == badid);

    (void)print_test_error(pass, pass);

    /* the following are all invalid or misbehaved, and should all fail. */
    TEST_MSG("loading bad plugin: '%s'...", plugin2);
    badid = sir_loadplugin(plugin2);
    _sir_eqland(pass, 0 == badid);

    (void)print_test_error(pass, pass);

    TEST_MSG("loading bad plugin: '%s'...", plugin3);
    badid = sir_loadplugin(plugin3);
    _sir_eqland(pass, 0 == badid);

    (void)print_test_error(pass, pass);

    TEST_MSG("loading bad plugin: '%s'...", plugin4);
    badid = sir_loadplugin(plugin4);
    _sir_eqland(pass, 0 == badid);

    (void)print_test_error(pass, pass);

    TEST_MSG("loading bad plugin: '%s'...", plugin5);
    badid = sir_loadplugin(plugin5);
    _sir_eqland(pass, 0 == badid);

    (void)print_test_error(pass, pass);

    TEST_MSG("loading bad plugin: '%s'...", plugin6);
    badid = sir_loadplugin(plugin6);
    _sir_eqland(pass, 0 == badid);

    (void)print_test_error(pass, pass);

    TEST_MSG("loading bad plugin: '%s'...", plugin7);
    badid = sir_loadplugin(plugin7);
    _sir_eqland(pass, 0 != badid); /* this one should load, just return false from write */

    _sir_eqland(pass, !sir_info("should fail; a plugin failed to process the message."));

    (void)print_test_error(pass, pass);

    TEST_MSG("loading nonexistent plugin: '%s'...", plugin8);
    badid = sir_loadplugin(plugin8);
    _sir_eqland(pass, 0 == badid);

    (void)print_test_error(pass, pass);

    /* unload the good plugin manually. */
    TEST_MSG("unloading good plugin: '%s'...", plugin1);
    _sir_eqland(pass, sir_unloadplugin(id));

    (void)print_test_error(pass, pass);

    /* try to unload the plugin again. */
    TEST_MSG("unloading already unloaded plugin '%s'...", plugin1);
    _sir_eqland(pass, !sir_unloadplugin(id));

    (void)print_test_error(pass, pass);

    /* test bad paths. */
    TEST_MSG_0("trying to load plugin with NULL path...");
    badid = sir_loadplugin(NULL);
    _sir_eqland(pass, 0 == badid);

    (void)print_test_error(pass, pass);
#endif
    _sir_eqland(pass, sir_cleanup());
    return PRINT_RESULT_RETURN(pass);
}

// Assembly:
subq $0x128, %rsp            # imm = 0x128
leaq 0x20(%rsp), %rdi
xorl %esi, %esi
movl $0x108, %edx            # imm = 0x108
callq 0x4210
movl $0x100000, 0x24(%rsp)   # imm = 0x100000
movw $0xff, 0x20(%rsp)
movl $0x100000, 0x2c(%rsp)   # imm = 0x100000
movw $0x0, 0x28(%rsp)
leaq 0xf8fa(%rip), %rdi      # 0x1d2c7
xorl %esi, %esi
leaq 0x12212(%rip), %rdx     # 0x1fbe8
leaq 0xfb50(%rip), %rcx      # 0x1d52d
movl $0x767, %r8d            # imm = 0x767
callq 0x5ce0
testb $0x1, %al
jne 0xd9ee
jmp 0xda0e
leaq 0x20(%rsp), %rdi
addq $0xe8, %rdi
movl $0x20, %ecx
leaq 0xf8c1(%rip), %rdx      # 0x1d2c7
movq %rcx, %rsi
callq 0x14f50
movb $0x0, 0x1f(%rsp)
leaq 0x20(%rsp), %rdi
callq 0xf560
andb $0x1, %al
movb %al, 0x1f(%rsp)
movb 0x1f(%rsp), %al
andb $0x1, %al
movb %al, 0x1e(%rsp)
movq 0x1acbc(%rip), %rsi     # 0x286f0
leaq 0x122b0(%rip), %rdi     # 0x1fceb
movb $0x0, %al
callq 0x4180
movq 0x1aca7(%rip), %rdi     # 0x286f0
callq 0xff30
movl %eax, 0x18(%rsp)
xorl %eax, %eax
xorl %ecx, %ecx
cmpl 0x18(%rsp), %ecx
movb %al, 0x13(%rsp)
je 0xda68
movb 0x1e(%rsp), %al
movb %al, 0x13(%rsp)
movb 0x13(%rsp), %al
andb $0x1, %al
movb %al, 0x1e(%rsp)
movb 0x1e(%rsp), %cl
movb 0x1e(%rsp), %al
andb $0x1, %cl
andb $0x1, %al
movzbl %cl, %edi
movzbl %al, %esi
callq 0x4da0
leaq 0x12279(%rip), %rdi     # 0x1fd0a
movb $0x0, %al
callq 0xf770
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x12(%rsp)
jne 0xdaa7
jmp 0xdaaf
movb 0x1e(%rsp), %al
movb %al, 0x12(%rsp)
movb 0x12(%rsp), %al
andb $0x1, %al
movb %al, 0x1e(%rsp)
leaq 0x12279(%rip), %rdi     # 0x1fd39
movb $0x0, %al
callq 0xf990
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x11(%rsp)
jne 0xdad6
jmp 0xdade
movb 0x1e(%rsp), %al
movb %al, 0x11(%rsp)
movb 0x11(%rsp), %al
andb $0x1, %al
movb %al, 0x1e(%rsp)
movq 0x1ac01(%rip), %rsi     # 0x286f0
leaq 0x12278(%rip), %rdi     # 0x1fd6e
movb $0x0, %al
callq 0x4180
movq 0x1abec(%rip), %rdi     # 0x286f0
callq 0xff30
movl %eax, 0x14(%rsp)
xorl %eax, %eax
xorl %ecx, %ecx
cmpl 0x14(%rsp), %ecx
movb %al, 0x10(%rsp)
jne 0xdb23
movb 0x1e(%rsp), %al
movb %al, 0x10(%rsp)
movb 0x10(%rsp), %al
andb $0x1, %al
movb %al, 0x1e(%rsp)
movb 0x1e(%rsp), %cl
movb 0x1e(%rsp), %al
andb $0x1, %cl
andb $0x1, %al
movzbl %cl, %edi
movzbl %al, %esi
callq 0x4da0
movq 0x1abac(%rip), %rsi     # 0x286f8
leaq 0x1223f(%rip), %rdi     # 0x1fd92
movb $0x0, %al
callq 0x4180
movq 0x1ab97(%rip), %rdi     # 0x286f8
callq 0xff30
movl %eax, 0x14(%rsp)
xorl %eax, %eax
xorl %ecx, %ecx
cmpl 0x14(%rsp), %ecx
movb %al, 0xf(%rsp)
jne 0xdb80
movb 0x1e(%rsp), %al
movb %al, 0xf(%rsp)
movb 0xf(%rsp), %al
andb $0x1, %al
movb %al, 0x1e(%rsp)
movb 0x1e(%rsp), %cl
movb 0x1e(%rsp), %al
andb $0x1, %cl
andb $0x1, %al
movzbl %cl, %edi
movzbl %al, %esi
callq 0x4da0
movq 0x1ab57(%rip), %rsi     # 0x28700
leaq 0x121e2(%rip), %rdi     # 0x1fd92
movb $0x0, %al
callq 0x4180
movq 0x1ab42(%rip), %rdi     # 0x28700
callq 0xff30
movl %eax, 0x14(%rsp)
xorl %eax, %eax
xorl %ecx, %ecx
cmpl 0x14(%rsp), %ecx
movb %al, 0xe(%rsp)
jne 0xdbdd
movb 0x1e(%rsp), %al
movb %al, 0xe(%rsp)
movb 0xe(%rsp), %al
andb $0x1, %al
movb %al, 0x1e(%rsp)
movb 0x1e(%rsp), %cl
movb 0x1e(%rsp), %al
andb $0x1, %cl
andb $0x1, %al
movzbl %cl, %edi
movzbl %al, %esi
callq 0x4da0
movq 0x1ab02(%rip), %rsi     # 0x28708
leaq 0x12185(%rip), %rdi     # 0x1fd92
movb $0x0, %al
callq 0x4180
movq 0x1aaed(%rip), %rdi     # 0x28708
callq 0xff30
movl %eax, 0x14(%rsp)
xorl %eax, %eax
xorl %ecx, %ecx
cmpl 0x14(%rsp), %ecx
movb %al, 0xd(%rsp)
jne 0xdc3a
movb 0x1e(%rsp), %al
movb %al, 0xd(%rsp)
movb 0xd(%rsp), %al
andb $0x1, %al
movb %al, 0x1e(%rsp)
movb 0x1e(%rsp), %cl
movb 0x1e(%rsp), %al
andb $0x1, %cl
andb $0x1, %al
movzbl %cl, %edi
movzbl %al, %esi
callq 0x4da0
movq 0x1aaad(%rip), %rsi     # 0x28710
leaq 0x12128(%rip), %rdi     # 0x1fd92
movb $0x0, %al
callq 0x4180
movq 0x1aa98(%rip), %rdi     # 0x28710
callq 0xff30
movl %eax, 0x14(%rsp)
xorl %eax, %eax
xorl %ecx, %ecx
cmpl 0x14(%rsp), %ecx
movb %al, 0xc(%rsp)
jne 0xdc97
movb 0x1e(%rsp), %al
movb %al, 0xc(%rsp)
movb 0xc(%rsp), %al
andb $0x1, %al
movb %al, 0x1e(%rsp)
movb 0x1e(%rsp), %cl
movb 0x1e(%rsp), %al
andb $0x1, %cl
andb $0x1, %al
movzbl %cl, %edi
movzbl %al, %esi
callq 0x4da0
movq 0x1aa58(%rip), %rsi     # 0x28718
leaq 0x120cb(%rip), %rdi     # 0x1fd92
movb $0x0, %al
callq 0x4180
movq 0x1aa43(%rip), %rdi     # 0x28718
callq 0xff30
movl %eax, 0x14(%rsp)
xorl %eax, %eax
xorl %ecx, %ecx
cmpl 0x14(%rsp), %ecx
movb %al, 0xb(%rsp)
jne 0xdcf4
movb 0x1e(%rsp), %al
movb %al, 0xb(%rsp)
movb 0xb(%rsp), %al
andb $0x1, %al
movb %al, 0x1e(%rsp)
movb 0x1e(%rsp), %cl
movb 0x1e(%rsp), %al
andb $0x1, %cl
andb $0x1, %al
movzbl %cl, %edi
movzbl %al, %esi
callq 0x4da0
movq 0x1aa03(%rip), %rsi     # 0x28720
leaq 0x1206e(%rip), %rdi     # 0x1fd92
movb $0x0, %al
callq 0x4180
movq 0x1a9ee(%rip), %rdi     # 0x28720
callq 0xff30
movl %eax, 0x14(%rsp)
xorl %eax, %eax
xorl %ecx, %ecx
cmpl 0x14(%rsp), %ecx
movb %al, 0xa(%rsp)
je 0xdd51
movb 0x1e(%rsp), %al
movb %al, 0xa(%rsp)
movb 0xa(%rsp), %al
andb $0x1, %al
movb %al, 0x1e(%rsp)
leaq 0x1204e(%rip), %rdi     # 0x1fdb0
movb $0x0, %al
callq 0xf770
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x9(%rsp)
jne 0xdd7e
movb 0x1e(%rsp), %al
movb %al, 0x9(%rsp)
movb 0x9(%rsp), %al
andb $0x1, %al
movb %al, 0x1e(%rsp)
movb 0x1e(%rsp), %cl
movb 0x1e(%rsp), %al
andb $0x1, %cl
andb $0x1, %al
movzbl %cl, %edi
movzbl %al, %esi
callq 0x4da0
movq 0x1a981(%rip), %rsi     # 0x28728
leaq 0x12037(%rip), %rdi     # 0x1fde5
movb $0x0, %al
callq 0x4180
movq 0x1a96c(%rip), %rdi     # 0x28728
callq 0xff30
movl %eax, 0x14(%rsp)
xorl %eax, %eax
xorl %ecx, %ecx
cmpl 0x14(%rsp), %ecx
movb %al, 0x8(%rsp)
jne 0xdddb
movb 0x1e(%rsp), %al
movb %al, 0x8(%rsp)
movb 0x8(%rsp), %al
andb $0x1, %al
movb %al, 0x1e(%rsp)
movb 0x1e(%rsp), %cl
movb 0x1e(%rsp), %al
andb $0x1, %cl
andb $0x1, %al
movzbl %cl, %edi
movzbl %al, %esi
callq 0x4da0
movq 0x1a8ec(%rip), %rsi     # 0x286f0
leaq 0x12000(%rip), %rdi     # 0x1fe0b
movb $0x0, %al
callq 0x4180
movl 0x18(%rsp), %edi
callq 0xff40
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x7(%rsp)
jne 0xde2a
jmp 0xde32
movb 0x1e(%rsp), %al
movb %al, 0x7(%rsp)
movb 0x7(%rsp), %al
andb $0x1, %al
movb %al, 0x1e(%rsp)
movb 0x1e(%rsp), %cl
movb 0x1e(%rsp), %al
andb $0x1, %cl
andb $0x1, %al
movzbl %cl, %edi
movzbl %al, %esi
callq 0x4da0
movq 0x1a895(%rip), %rsi     # 0x286f0
leaq 0x11fca(%rip), %rdi     # 0x1fe2c
movb $0x0, %al
callq 0x4180
movl 0x18(%rsp), %edi
callq 0xff40
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x6(%rsp)
jne 0xde87
movb 0x1e(%rsp), %al
movb %al, 0x6(%rsp)
movb 0x6(%rsp), %al
andb $0x1, %al
movb %al, 0x1e(%rsp)
movb 0x1e(%rsp), %cl
movb 0x1e(%rsp), %al
andb $0x1, %cl
andb $0x1, %al
movzbl %cl, %edi
movzbl %al, %esi
callq 0x4da0
leaq 0x11fa8(%rip), %rdi     # 0x1fe58
movb $0x0, %al
callq 0x4180
xorl %eax, %eax
movl %eax, %edi
callq 0xff30
movl %eax, 0x14(%rsp)
xorl %eax, %eax
xorl %ecx, %ecx
cmpl 0x14(%rsp), %ecx
movb %al, 0x5(%rsp)
jne 0xdeda
movb 0x1e(%rsp), %al
movb %al, 0x5(%rsp)
movb 0x5(%rsp), %al
andb $0x1, %al
movb %al, 0x1e(%rsp)
movb 0x1e(%rsp), %cl
movb 0x1e(%rsp), %al
andb $0x1, %cl
andb $0x1, %al
movzbl %cl, %edi
movzbl %al, %esi
callq 0x4da0
callq 0xf580
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x4(%rsp)
jne 0xdf10
jmp 0xdf18
movb 0x1e(%rsp), %al
movb %al, 0x4(%rsp)
movb 0x4(%rsp), %al
andb $0x1, %al
movb %al, 0x1e(%rsp)
movb 0x1e(%rsp), %al
xorl %esi, %esi
andb $0x1, %al
movzbl %al, %edi
callq 0x4da0
andb $0x1, %al
addq $0x128, %rsp            # imm = 0x128
retq
nopl (%rax)