// File: /workspace/github_c_makefile_star2_O2/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 $0x438, %rsp            # imm = 0x438
leaq 0x330(%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 0x94a9
movl %eax, %r13d
leaq 0x230(%rsp), %rdi
movl $0x100, %edx            # imm = 0x100
xorl %esi, %esi
callq 0x31f0
pushq $0x8
popq %r15
cmpq $0x188, %r15            # imm = 0x188
je 0x5b2b
leaq 0x14ff4(%rip), %rax     # 0x1a950
movzwl -0x8(%r15,%rax), %ebp
cmpl $0x17, %ebp
jne 0x597f
leaq 0xb4ac(%rip), %rdi      # 0x10e1a
movl $0xff, %esi
movl $0x100000, %edx         # imm = 0x100000
callq 0x9a6b
jmp 0x59a2
movl %ebp, %edi
shll $0x10, %edi
orl $0x80000000, %edi       # imm = 0x80000000
leaq 0xb318(%rip), %rsi      # 0x10ca9
leaq 0xab76(%rip), %rdx      # 0x1050e
movl $0x2e2, %ecx            # imm = 0x2E2
callq 0x9d4c
movl $0x100, %edx            # imm = 0x100
leaq 0x230(%rsp), %r12
movq %r12, %rdi
xorl %esi, %esi
callq 0x31f0
movq %r12, %rdi
callq 0x94b8
movl %eax, %r14d
xorl %r14d, %ebp
cmpb $0x0, 0x230(%rsp)
setne %bl
leaq 0x14f77(%rip), %rax     # 0x1a950
movq %r15, 0x8(%rsp)
movq (%r15,%rax), %rdx
pushq $0x1
popq %r15
movl %r15d, %edi
leaq 0xb43c(%rip), %rsi      # 0x10e2c
movq %r12, %rcx
xorl %eax, %eax
callq 0x3410
movl $0x220, %edx            # imm = 0x220
leaq 0x10(%rsp), %r12
movq %r12, %rdi
xorl %esi, %esi
callq 0x31f0
movq %r12, %rdi
callq 0x94c8
movq 0x10(%rsp), %rdx
movq 0x18(%rsp), %rcx
movl 0x20(%rsp), %r8d
movzwl 0x128(%rsp), %r9d
movl 0x24(%rsp), %r10d
subq $0x8, %rsp
movl %r15d, %edi
leaq 0xb3f5(%rip), %rsi      # 0x10e36
xorl %eax, %eax
leaq 0x30(%rsp), %r11
pushq %r11
pushq %r10
leaq 0x142(%rsp), %r10
pushq %r10
callq 0x3410
addq $0x20, %rsp
movl 0x128(%rsp), %eax
movl %eax, %ecx
xorl %r14d, %ecx
cmpl $0x0, 0x20(%rsp)
setne %dl
cmpb $0x0, 0x12a(%rsp)
setne %r12b
andb %dl, %r12b
orl %ebp, %ecx
testw %cx, %cx
sete %cl
andb %bl, %r12b
andb %r13b, %r12b
andb %cl, %r12b
cmpw $0x17, %ax
jne 0x5aac
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x5ae9
cmpb $0x0, (%rax)
setne %r13b
jmp 0x5aec
movq 0x10(%rsp), %rsi
leaq 0xb1f1(%rip), %rdi      # 0x10ca9
pushq $0x13
popq %rdx
callq 0x5b4f
movl %eax, %r14d
movq 0x18(%rsp), %rsi
movl $0x1000, %edx           # imm = 0x1000
leaq 0xaa3a(%rip), %rdi      # 0x1050e
callq 0x5b4f
movl %eax, %r13d
andb %r14b, %r13b
andb %r12b, %r13b
movq 0x8(%rsp), %r15
jmp 0x5b22
xorl %r13d, %r13d
movq 0x8(%rsp), %r15
movq 0x18(%rsp), %rax
testq %rax, %rax
je 0x5b1f
cmpb $0x0, 0x28(%rsp)
setne %cl
cmpl $0x0, 0x24(%rsp)
setne %dl
cmpb $0x0, (%rax)
setne %al
andb %cl, %r13b
andb %dl, %r13b
andb %r12b, %r13b
andb %al, %r13b
jmp 0x5b22
xorl %r13d, %r13d
addq $0x10, %r15
jmp 0x5948
callq 0x94ae
andb %r13b, %al
movzbl %al, %edi
xorl %esi, %esi
callq 0x3ac9
addq $0x438, %rsp            # imm = 0x438
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq