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

    struct {
        uint16_t code;
        const char* name;
    } errors[] = {
        {SIR_E_NOERROR,   "SIR_E_NOERROR"},   /**< The operation completed successfully (1) */
        {SIR_E_NOTREADY,  "SIR_E_NOTREADY"},  /**< libsir has not been initialized (2) */
        {SIR_E_ALREADY,   "SIR_E_ALREADY"},   /**< libsir is already initialized (3) */
        {SIR_E_DUPITEM,   "SIR_E_DUPITEM"},   /**< Item already managed by libsir (4) */
        {SIR_E_NOITEM,    "SIR_E_NOITEM"},    /**< Item not managed by libsir (5) */
        {SIR_E_NOROOM,    "SIR_E_NOROOM"},    /**< Maximum number of items already stored (6) */
        {SIR_E_OPTIONS,   "SIR_E_OPTIONS"},   /**< Option flags are invalid (7) */
        {SIR_E_LEVELS,    "SIR_E_LEVELS"},    /**< Level flags are invalid (8) */
        {SIR_E_TEXTSTYLE, "SIR_E_TEXTSTYLE"}, /**< Text style is invalid (9) */
        {SIR_E_STRING,    "SIR_E_STRING"},    /**< Invalid string argument (10) */
        {SIR_E_NULLPTR,   "SIR_E_NULLPTR"},   /**< NULL pointer argument (11) */
        {SIR_E_INVALID,   "SIR_E_INVALID"},   /**< Invalid argument (12) */
        {SIR_E_NODEST,    "SIR_E_NODEST"},    /**< No destinations registered for level (13) */
        {SIR_E_UNAVAIL,   "SIR_E_UNAVAIL"},   /**< Feature is disabled or unavailable (14) */
        {SIR_E_INTERNAL,  "SIR_E_INTERNAL"},  /**< An internal error has occurred (15) */
        {SIR_E_COLORMODE, "SIR_E_COLORMODE"}, /**< Invalid color mode (16) */
        {SIR_E_TEXTATTR,  "SIR_E_TEXTATTR"},  /**< Invalid text attributes (17) */
        {SIR_E_TEXTCOLOR, "SIR_E_TEXTCOLOR"}, /**< Invalid text color (18) */
        {SIR_E_PLUGINBAD, "SIR_E_PLUGINBAD"}, /**< Plugin module is malformed (19) */
        {SIR_E_PLUGINDAT, "SIR_E_PLUGINDAT"}, /**< Data produced by plugin is invalid (20) */
        {SIR_E_PLUGINVER, "SIR_E_PLUGINVER"}, /**< Plugin interface version unsupported (21) */
        {SIR_E_PLUGINERR, "SIR_E_PLUGINERR"}, /**< Plugin reported failure (22) */
        {SIR_E_PLATFORM,  "SIR_E_PLATFORM"},  /**< Platform error code %d: %s (23) */
        {SIR_E_UNKNOWN,   "SIR_E_UNKNOWN"},   /**< Unknown error (4095) */
    };

    char message[SIR_MAXERROR] = {0};
    for (size_t n = 0; n < _sir_countof(errors); n++) {
        if (SIR_E_PLATFORM == errors[n].code) {
            /* cause an actual platform error. */
            (void)sir_addfile("invalid/file!name", SIRL_ALL, SIRO_DEFAULT);
        } else {
            (void)_sir_seterror(_sir_mkerror(errors[n].code));
        }

        (void)memset(message, 0, SIR_MAXERROR);
        uint16_t err = sir_geterror(message);
        _sir_eqland(pass, errors[n].code == err && *message != '\0');
        TEST_MSG("%s = %s", errors[n].name, message);

        /* ensure that sir_geterrorinfo agrees with sir_geterror, and
         * that it returns sane data. */
        sir_errorinfo errinfo = {0};
        sir_geterrorinfo(&errinfo);

        TEST_MSG("errinfo = {'%s', '%s', %"PRIu32", %"PRIu16", '%s', %d, '%s'}",
            errinfo.func, errinfo.file, errinfo.line, errinfo.code, errinfo.msg,
            errinfo.os_code, errinfo.os_msg);

        _sir_eqland(pass, errinfo.code == err);
        _sir_eqland(pass, errinfo.line != 0U);
        _sir_eqland(pass, _sir_validstrnofail(errinfo.msg));

        if (errinfo.code == SIR_E_PLATFORM) {
            _sir_eqland(pass, errinfo.os_code != 0);
            _sir_eqland(pass, _sir_validstrnofail(errinfo.os_msg));
            _sir_eqland(pass, _sir_validstrnofail(errinfo.func));
            _sir_eqland(pass, _sir_validstrnofail(errinfo.file));
        } else {
            _sir_eqland(pass, _sir_strsame(__func__, errinfo.func, strlen(__func__)));
            _sir_eqland(pass, _sir_strsame(__file__, errinfo.file, SIR_MAXPATH));
        }
    }

    _sir_eqland(pass, sir_cleanup());
    return PRINT_RESULT_RETURN(pass);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x428, %rsp            # imm = 0x428
leaq 0x320(%rsp), %rbx
movl $0x108, %edx            # imm = 0x108
movq %rbx, %rdi
xorl %esi, %esi
callq 0x31f0
movl $0x100000, %eax         # imm = 0x100000
movl %eax, 0x4(%rbx)
movw $0xff, (%rbx)
movl %eax, 0xc(%rbx)
movq %rbx, %rdi
callq 0x9a21
movl %eax, %r15d
leaq 0x220(%rsp), %rdi
movl $0x100, %edx            # imm = 0x100
xorl %esi, %esi
callq 0x31f0
movl $0x8, %ebp
leaq 0x14e3a(%rip), %rax     # 0x1a910
movzwl -0x8(%rbp,%rax), %r14d
cmpl $0x17, %r14d
jne 0x5afa
leaq 0xc371(%rip), %rdi      # 0x11e5a
movl $0xff, %esi
movl $0x100000, %edx         # imm = 0x100000
callq 0xa035
jmp 0x5b1e
movl %r14d, %edi
shll $0x10, %edi
orl $0x80000000, %edi       # imm = 0x80000000
leaq 0xc1dc(%rip), %rsi      # 0x11ce9
leaq 0xba3a(%rip), %rdx      # 0x1154e
movl $0x2e2, %ecx            # imm = 0x2E2
callq 0xa338
movl $0x100, %edx            # imm = 0x100
leaq 0x220(%rsp), %rbx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x31f0
movq %rbx, %rdi
callq 0x9a30
movl %eax, %r13d
xorl %r13d, %r14d
cmpb $0x0, 0x220(%rsp)
setne %r12b
leaq 0x14dba(%rip), %rax     # 0x1a910
movq (%rbp,%rax), %rdx
movl $0x1, %edi
leaq 0xc305(%rip), %rsi      # 0x11e6c
movq %rbx, %rcx
xorl %eax, %eax
callq 0x3400
movl $0x220, %edx            # imm = 0x220
movq %rsp, %rbx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x31f0
movq %rbx, %rdi
callq 0x9a40
movq (%rsp), %rdx
movq 0x8(%rsp), %rcx
movl 0x10(%rsp), %r8d
movzwl 0x118(%rsp), %r9d
movl 0x14(%rsp), %r10d
subq $0x8, %rsp
movl $0x1, %edi
leaq 0xc2bf(%rip), %rsi      # 0x11e76
xorl %eax, %eax
leaq 0x20(%rsp), %r11
pushq %r11
pushq %r10
leaq 0x132(%rsp), %r10
pushq %r10
callq 0x3400
addq $0x20, %rsp
movl 0x118(%rsp), %eax
movl %eax, %ecx
xorl %r13d, %ecx
cmpl $0x0, 0x10(%rsp)
setne %dl
cmpb $0x0, 0x11a(%rsp)
setne %r13b
andb %dl, %r13b
orl %r14d, %ecx
testw %cx, %cx
sete %cl
andb %r12b, %r13b
andb %r15b, %r13b
andb %cl, %r13b
cmpw $0x17, %ax
jne 0x5c22
movq (%rsp), %rax
testq %rax, %rax
je 0x5c5c
cmpb $0x0, (%rax)
setne %r15b
jmp 0x5c5f
movq (%rsp), %rsi
movl $0x13, %edx
leaq 0xc0b7(%rip), %rdi      # 0x11ce9
callq 0x30a0
movl %eax, %r15d
movq 0x8(%rsp), %rsi
movl $0x1000, %edx           # imm = 0x1000
leaq 0xb903(%rip), %rdi      # 0x1154e
callq 0x30a0
orl %r15d, %eax
sete %r15b
andb %r13b, %r15b
jmp 0x5c90
xorl %r15d, %r15d
movq 0x8(%rsp), %rax
testq %rax, %rax
je 0x5c8d
cmpb $0x0, 0x18(%rsp)
setne %cl
cmpl $0x0, 0x14(%rsp)
setne %dl
cmpb $0x0, (%rax)
setne %al
andb %cl, %r15b
andb %dl, %r15b
andb %r13b, %r15b
andb %al, %r15b
jmp 0x5c90
xorl %r15d, %r15d
addq $0x10, %rbp
cmpq $0x188, %rbp            # imm = 0x188
jne 0x5acf
callq 0x9a26
andb %r15b, %al
movzbl %al, %edi
xorl %esi, %esi
callq 0x3b6d
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq