// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x5e8, %rsp            # imm = 0x5E8
leaq 0x4e0(%rsp), %rdi
xorl %esi, %esi
movl $0x108, %edx            # imm = 0x108
callq 0x4210
movl $0x100000, 0x4e4(%rsp) # imm = 0x100000
movw $0xff, 0x4e0(%rsp)
movl $0x100000, 0x4ec(%rsp) # imm = 0x100000
movw $0x0, 0x4e8(%rsp)
leaq 0x14a9b(%rip), %rdi     # 0x1d2c7
xorl %esi, %esi
leaq 0x155e0(%rip), %rdx     # 0x1de15
leaq 0x14cf1(%rip), %rcx     # 0x1d52d
movl $0x2bb, %r8d            # imm = 0x2BB
callq 0x5ce0
testb $0x1, %al
jne 0x884d
jmp 0x8870
leaq 0x4e0(%rsp), %rdi
addq $0xe8, %rdi
movl $0x20, %ecx
leaq 0x14a5f(%rip), %rdx     # 0x1d2c7
movq %rcx, %rsi
callq 0x14f50
movb $0x0, 0x4df(%rsp)
leaq 0x4e0(%rsp), %rdi
callq 0xf560
andb $0x1, %al
movb %al, 0x4df(%rsp)
movb 0x4df(%rsp), %al
andb $0x1, %al
movb %al, 0x4de(%rsp)
leaq 0x350(%rsp), %rdi
leaq 0x1f0a3(%rip), %rsi     # 0x27950
movl $0x180, %edx            # imm = 0x180
callq 0x4340
leaq 0x250(%rsp), %rdi
xorl %esi, %esi
movl $0x100, %edx            # imm = 0x100
callq 0x4210
movq $0x0, 0x248(%rsp)
cmpq $0x18, 0x248(%rsp)
jae 0x8cc1
movq 0x248(%rsp), %rcx
leaq 0x350(%rsp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movzwl (%rax), %ecx
movl $0x17, %eax
cmpl %ecx, %eax
jne 0x8921
leaq 0x15676(%rip), %rdi     # 0x1df86
movl $0xff, %esi
movl $0x100000, %edx         # imm = 0x100000
callq 0xfee0
jmp 0x8962
movq 0x248(%rsp), %rcx
leaq 0x350(%rsp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movzwl (%rax), %edi
andl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
shll $0x10, %edi
orl $0x80000000, %edi       # imm = 0x80000000
leaq 0x154c4(%rip), %rsi     # 0x1de15
leaq 0x14bd5(%rip), %rdx     # 0x1d52d
movl $0x2e2, %ecx            # imm = 0x2E2
callq 0x104c0
leaq 0x250(%rsp), %rdi
xorl %esi, %esi
movl $0x100, %edx            # imm = 0x100
callq 0x4210
leaq 0x250(%rsp), %rdi
callq 0xf5a0
movw %ax, 0x246(%rsp)
movq 0x248(%rsp), %rcx
leaq 0x350(%rsp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movzwl (%rax), %ecx
movzwl 0x246(%rsp), %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, 0x1f(%rsp)
jne 0x89d5
movsbl 0x250(%rsp), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, 0x1f(%rsp)
je 0x89d5
movb 0x4de(%rsp), %al
movb %al, 0x1f(%rsp)
movb 0x1f(%rsp), %al
andb $0x1, %al
movb %al, 0x4de(%rsp)
movq 0x248(%rsp), %rcx
leaq 0x350(%rsp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rsi
leaq 0x250(%rsp), %rdx
leaq 0x1558c(%rip), %rdi     # 0x1df98
movb $0x0, %al
callq 0x4180
leaq 0x20(%rsp), %rdi
xorl %esi, %esi
movl $0x220, %edx            # imm = 0x220
callq 0x4210
leaq 0x20(%rsp), %rdi
callq 0xf5e0
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
movl 0x30(%rsp), %ecx
movzwl 0x138(%rsp), %r8d
leaq 0x20(%rsp), %r9
addq $0x11a, %r9             # imm = 0x11A
movl 0x34(%rsp), %r10d
leaq 0x20(%rsp), %rax
addq $0x18, %rax
leaq 0x1553c(%rip), %rdi     # 0x1dfa2
movl %r10d, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x4180
movzwl 0x138(%rsp), %ecx
movzwl 0x246(%rsp), %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, 0x1e(%rsp)
jne 0x8a9b
movb 0x4de(%rsp), %al
movb %al, 0x1e(%rsp)
movb 0x1e(%rsp), %al
andb $0x1, %al
movb %al, 0x4de(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x30(%rsp)
movb %al, 0x1d(%rsp)
je 0x8ac0
movb 0x4de(%rsp), %al
movb %al, 0x1d(%rsp)
movb 0x1d(%rsp), %al
andb $0x1, %al
movb %al, 0x4de(%rsp)
leaq 0x20(%rsp), %rdi
addq $0x11a, %rdi            # imm = 0x11A
xorl %esi, %esi
leaq 0x15333(%rip), %rdx     # 0x1de15
leaq 0x14a44(%rip), %rcx     # 0x1d52d
movl $0x2f5, %r8d            # imm = 0x2F5
callq 0x5ce0
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x1c(%rsp)
jne 0x8b03
jmp 0x8b0e
movb 0x4de(%rsp), %al
movb %al, 0x1c(%rsp)
movb 0x1c(%rsp), %al
andb $0x1, %al
movb %al, 0x4de(%rsp)
movzwl 0x138(%rsp), %eax
cmpl $0x17, %eax
jne 0x8c2c
xorl %eax, %eax
cmpl $0x0, 0x34(%rsp)
movb %al, 0x1b(%rsp)
je 0x8b44
movb 0x4de(%rsp), %al
movb %al, 0x1b(%rsp)
movb 0x1b(%rsp), %al
andb $0x1, %al
movb %al, 0x4de(%rsp)
leaq 0x20(%rsp), %rdi
addq $0x18, %rdi
xorl %esi, %esi
leaq 0x152b2(%rip), %rdx     # 0x1de15
leaq 0x149c3(%rip), %rcx     # 0x1d52d
movl $0x2f9, %r8d            # imm = 0x2F9
callq 0x5ce0
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x1a(%rsp)
jne 0x8b84
jmp 0x8b8f
movb 0x4de(%rsp), %al
movb %al, 0x1a(%rsp)
movb 0x1a(%rsp), %al
andb $0x1, %al
movb %al, 0x4de(%rsp)
movq 0x20(%rsp), %rdi
xorl %esi, %esi
leaq 0x1526b(%rip), %rdx     # 0x1de15
leaq 0x1497c(%rip), %rcx     # 0x1d52d
movl $0x2fa, %r8d            # imm = 0x2FA
callq 0x5ce0
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x19(%rsp)
jne 0x8bcb
jmp 0x8bd6
movb 0x4de(%rsp), %al
movb %al, 0x19(%rsp)
movb 0x19(%rsp), %al
andb $0x1, %al
movb %al, 0x4de(%rsp)
movq 0x28(%rsp), %rdi
xorl %esi, %esi
leaq 0x15224(%rip), %rdx     # 0x1de15
leaq 0x14935(%rip), %rcx     # 0x1d52d
movl $0x2fb, %r8d            # imm = 0x2FB
callq 0x5ce0
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x18(%rsp)
jne 0x8c12
jmp 0x8c1d
movb 0x4de(%rsp), %al
movb %al, 0x18(%rsp)
movb 0x18(%rsp), %al
andb $0x1, %al
movb %al, 0x4de(%rsp)
jmp 0x8ca6
movq 0x20(%rsp), %rsi
leaq 0x151dd(%rip), %rdi     # 0x1de15
movl $0x13, %edx
callq 0x8d10
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x17(%rsp)
jne 0x8c51
jmp 0x8c5c
movb 0x4de(%rsp), %al
movb %al, 0x17(%rsp)
movb 0x17(%rsp), %al
andb $0x1, %al
movb %al, 0x4de(%rsp)
movq 0x28(%rsp), %rsi
leaq 0x148b8(%rip), %rdi     # 0x1d52d
movl $0x1000, %edx           # imm = 0x1000
callq 0x8d10
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x16(%rsp)
jne 0x8c8e
jmp 0x8c99
movb 0x4de(%rsp), %al
movb %al, 0x16(%rsp)
movb 0x16(%rsp), %al
andb $0x1, %al
movb %al, 0x4de(%rsp)
jmp 0x8ca8
movq 0x248(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x248(%rsp)
jmp 0x88d7
callq 0xf580
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x15(%rsp)
jne 0x8cd5
jmp 0x8ce0
movb 0x4de(%rsp), %al
movb %al, 0x15(%rsp)
movb 0x15(%rsp), %al
andb $0x1, %al
movb %al, 0x4de(%rsp)
movb 0x4de(%rsp), %al
xorl %esi, %esi
andb $0x1, %al
movzbl %al, %edi
callq 0x4da0
andb $0x1, %al
addq $0x5e8, %rsp            # imm = 0x5E8
retq
nopw (%rax,%rax)