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

#if !defined(SIR_NO_TEXT_STYLING)
    TEST_MSG_0(SIR_WHITEB("--- explicitly invalid ---"));
    _sir_eqland(pass, !sir_settextstyle(SIRL_INFO, (sir_textattr)0xbbb, 800, 920));
    _sir_eqland(pass, sir_info("I have set an invalid text style."));

    _sir_eqland(pass, !sir_settextstyle(SIRL_DEBUG, SIRTA_NORMAL, SIRTC_BLACK, SIRTC_BLACK));
    _sir_eqland(pass, sir_info("oops, did it again..."));

    _sir_eqland(pass, !sir_settextstyle(SIRL_ALERT, SIRTA_NORMAL, 0xff, 0xff));
    _sir_eqland(pass, sir_info("and again."));
    PASSFAIL_MSG(pass, "\t--- explicitly invalid: %s ---" SIR_EOL SIR_EOL, PRN_PASS(pass));

    TEST_MSG_0(SIR_WHITEB("--- unusual but valid ---"));
    _sir_eqland(pass, sir_settextstyle(SIRL_INFO, SIRTA_NORMAL, SIRTC_DEFAULT, SIRTC_DEFAULT));
    _sir_eqland(pass, sir_info("system default fg and bg"));
    PASSFAIL_MSG(pass, "\t--- unusual but valid: %s ---" SIR_EOL SIR_EOL, PRN_PASS(pass));

    TEST_MSG_0(SIR_WHITEB("--- override defaults ---"));
    _sir_eqland(pass, sir_resettextstyles());

    _sir_eqland(pass, sir_debug("default style"));
    _sir_eqland(pass, sir_settextstyle(SIRL_DEBUG, SIRTA_NORMAL, SIRTC_BYELLOW, SIRTC_DGRAY));
    _sir_eqland(pass, sir_debug("override style"));

    _sir_eqland(pass, sir_info("default style"));
    _sir_eqland(pass, sir_settextstyle(SIRL_INFO, SIRTA_NORMAL, SIRTC_GREEN, SIRTC_MAGENTA));
    _sir_eqland(pass, sir_info("override style"));

    _sir_eqland(pass, sir_notice("default style"));
    _sir_eqland(pass, sir_settextstyle(SIRL_NOTICE, SIRTA_NORMAL, SIRTC_BLACK, SIRTC_BYELLOW));
    _sir_eqland(pass, sir_notice("override style"));

    _sir_eqland(pass, sir_warn("default style"));
    _sir_eqland(pass, sir_settextstyle(SIRL_WARN, SIRTA_NORMAL, SIRTC_BLACK, SIRTC_WHITE));
    _sir_eqland(pass, sir_warn("override style"));

    _sir_eqland(pass, sir_error("default style"));
    _sir_eqland(pass, sir_settextstyle(SIRL_ERROR, SIRTA_NORMAL, SIRTC_WHITE, SIRTC_BLUE));
    _sir_eqland(pass, sir_error("override style"));

    _sir_eqland(pass, sir_crit("default style"));
    _sir_eqland(pass, sir_settextstyle(SIRL_CRIT, SIRTA_EMPH, SIRTC_DGRAY, SIRTC_BGREEN));
    _sir_eqland(pass, sir_crit("override style"));

    _sir_eqland(pass, sir_alert("default style"));
    _sir_eqland(pass, sir_settextstyle(SIRL_ALERT, SIRTA_ULINE, SIRTC_BBLUE, SIRTC_DEFAULT));
    _sir_eqland(pass, sir_alert("override style"));

    _sir_eqland(pass, sir_emerg("default style"));
    _sir_eqland(pass, sir_settextstyle(SIRL_EMERG, SIRTA_BOLD, SIRTC_DGRAY, SIRTC_DEFAULT));
    _sir_eqland(pass, sir_emerg("override style"));
    PASSFAIL_MSG(pass, "\t--- override defaults: %s ---" SIR_EOL SIR_EOL, PRN_PASS(pass));

    TEST_MSG_0(SIR_WHITEB("--- reset to defaults ---"));
    _sir_eqland(pass, sir_resettextstyles());

    _sir_eqland(pass, sir_debug("default style (debug)"));
    _sir_eqland(pass, sir_info("default style (info)"));
    _sir_eqland(pass, sir_notice("default style (notice)"));
    _sir_eqland(pass, sir_warn("default style (warning)"));
    _sir_eqland(pass, sir_error("default style (error)"));
    _sir_eqland(pass, sir_crit("default style (crit)"));
    _sir_eqland(pass, sir_alert("default style (alert)"));
    _sir_eqland(pass, sir_emerg("default style (emergency)"));
    PASSFAIL_MSG(pass, "\t--- reset to defaults: %s ---" SIR_EOL SIR_EOL, PRN_PASS(pass));

    TEST_MSG_0(SIR_WHITEB("--- change mode: 256-color ---"));
    _sir_eqland(pass, sir_setcolormode(SIRCM_256));

    for (sir_textcolor fg = 0, bg = 255; (fg < 256 && bg > 0); fg++, bg--) {
        if (fg != bg) {
            _sir_eqland(pass, sir_settextstyle(SIRL_DEBUG, SIRTA_NORMAL, fg, bg));
            _sir_eqland(pass, sir_debug("this is 256-color mode (fg: %"PRIu32", bg: %"PRIu32")",
                fg, bg));
        }
    }

    PASSFAIL_MSG(pass, "\t--- change mode: 256-color: %s ---" SIR_EOL SIR_EOL, PRN_PASS(pass));

    TEST_MSG_0(SIR_WHITEB("--- change mode: RGB-color ---"));
    _sir_eqland(pass, sir_setcolormode(SIRCM_RGB));

    for (size_t n = 0; n < 256; n++) {
        sir_textcolor fg = sir_makergb(getrand(255U), getrand(255U), getrand(255U));
        sir_textcolor bg = sir_makergb(getrand(255U), getrand(255U), getrand(255U));
        _sir_eqland(pass, sir_settextstyle(SIRL_DEBUG, SIRTA_NORMAL, fg, bg));
        _sir_eqland(pass, sir_debug("this is RGB-color mode (fg: %"PRIu32", %"PRIu32", %"PRIu32
            ", bg: %"PRIu32", %"PRIu32", %"PRIu32")", _sir_getredfromcolor(fg),
            _sir_getgreenfromcolor(fg), _sir_getbluefromcolor(fg), _sir_getredfromcolor(bg),
            _sir_getgreenfromcolor(bg), _sir_getbluefromcolor(bg)));
    }
    PASSFAIL_MSG(pass, "\t--- change mode: RGB-color: %s ---" SIR_EOL SIR_EOL, PRN_PASS(pass));

    TEST_MSG_0(SIR_WHITEB("--- change mode: invalid mode ---"));
    _sir_eqland(pass, !sir_setcolormode(SIRCM_INVALID));
    sir_textcolor fg = sir_makergb(255, 0, 0);
    sir_textcolor bg = sir_makergb(0, 0, 0);
    _sir_eqland(pass, sir_settextstyle(SIRL_DEBUG, SIRTA_NORMAL, fg, bg));
    _sir_eqland(pass, sir_debug("this is still RGB color mode"));
    PASSFAIL_MSG(pass, "\t--- change mode: invalid mode %s ---" SIR_EOL SIR_EOL, PRN_PASS(pass));

    TEST_MSG_0(SIR_WHITEB("--- change mode: 16-color ---"));
    _sir_eqland(pass, sir_setcolormode(SIRCM_16));
    _sir_eqland(pass, sir_settextstyle(SIRL_DEBUG, SIRTA_EMPH, SIRTC_BMAGENTA, SIRTC_DEFAULT));
    _sir_eqland(pass, sir_debug("this is 16-color mode (fg: %"PRId32", bg: default)",
        SIRTC_BMAGENTA));
    PASSFAIL_MSG(pass, "\t--- change mode: 16-color: %s ---" SIR_EOL SIR_EOL, PRN_PASS(pass));
#else /* SIR_NO_TEXT_STYLING */
    TEST_MSG_0("SIR_NO_TEXT_STYLING is defined; skipping");
#endif

    _sir_eqland(pass, sir_cleanup());

    return PRINT_RESULT_RETURN(pass);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
leaq 0x20(%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
movb %al, 0xd(%rsp)
leaq 0xc19a(%rip), %rsi      # 0x11ea7
movl $0x1, %edi
xorl %eax, %eax
callq 0x3400
movl $0x40, %edi
movl $0xbbb, %esi            # imm = 0xBBB
movl $0x320, %edx            # imm = 0x320
movl $0x398, %ecx            # imm = 0x398
callq 0xa0cc
movl %eax, %ebx
xorb $0x1, %bl
leaq 0xc19a(%rip), %rdi      # 0x11ed8
xorl %eax, %eax
callq 0x9b03
movl %eax, %r15d
movl $0x80, %edi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xa0cc
movl %eax, %r12d
xorb $0x1, %r12b
leaq 0xc194(%rip), %rdi      # 0x11efa
xorl %eax, %eax
callq 0x9b03
movl %eax, %r13d
movl $0xff, %ebp
movl $0x2, %edi
xorl %esi, %esi
movl $0xff, %edx
movl $0xff, %ecx
callq 0xa0cc
movl %eax, %r14d
xorb $0x1, %r14b
leaq 0xc177(%rip), %rdi      # 0x11f10
xorl %eax, %eax
callq 0x9b03
andb %r13b, %al
andb %r14b, %al
andb %r15b, %r12b
andb %al, %r12b
andb 0xd(%rsp), %bl
andb %r12b, %bl
leaq 0xc161(%rip), %rax      # 0x11f1b
leaq 0xc190(%rip), %rsi      # 0x11f51
testb $0x1, %bl
cmovneq %rax, %rsi
leaq 0xb2e7(%rip), %rax      # 0x110b6
leaq 0xb2f9(%rip), %rcx      # 0x110cf
movq %rcx, %rdx
movq %rcx, %r12
cmovneq %rax, %rdx
movq %rax, %r15
movl $0x1, %edi
xorl %eax, %eax
callq 0x3400
leaq 0xc191(%rip), %rsi      # 0x11f87
movl $0x1, %edi
xorl %eax, %eax
callq 0x3400
movl $0x40, %edi
xorl %esi, %esi
movl $0x100, %edx            # imm = 0x100
movl $0x100, %ecx            # imm = 0x100
callq 0xa0cc
movl %eax, %r14d
andb %bl, %r14b
leaq 0xc192(%rip), %rdi      # 0x11fb7
xorl %eax, %eax
callq 0x9b03
movl %eax, %ebx
andb %r14b, %bl
leaq 0xc198(%rip), %rax      # 0x11fd0
leaq 0xc1c6(%rip), %rsi      # 0x12005
cmovneq %rax, %rsi
movq %r12, %rdx
cmovneq %r15, %rdx
movl $0x1, %edi
xorl %eax, %eax
callq 0x3400
leaq 0xc1dd(%rip), %rsi      # 0x1203a
movl $0x1, %edi
xorl %eax, %eax
callq 0x3400
callq 0xa0ea
andb %bl, %al
movb %al, 0xd(%rsp)
leaq 0xc1ef(%rip), %r14      # 0x1206a
movq %r14, %rdi
xorl %eax, %eax
callq 0x9a45
movb %al, 0xf(%rsp)
movl $0x80, %edi
xorl %esi, %esi
movl $0xb, %edx
movl $0x8, %ecx
callq 0xa0cc
movb %al, 0xe(%rsp)
leaq 0xc1ce(%rip), %rbx      # 0x12078
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9a45
movb %al, 0x1f(%rsp)
movq %r14, %rdi
xorl %eax, %eax
callq 0x9b03
movb %al, 0x1e(%rsp)
movl $0x40, %edi
xorl %esi, %esi
movl $0x2, %edx
movl $0x5, %ecx
callq 0xa0cc
movb %al, 0x1d(%rsp)
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9b03
movb %al, 0x1c(%rsp)
movq %r14, %rdi
xorl %eax, %eax
callq 0x9bc1
movb %al, 0x1b(%rsp)
movl $0x20, %edi
xorl %esi, %esi
xorl %edx, %edx
movl $0xb, %ecx
callq 0xa0cc
movl %eax, %r13d
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9bc1
movb %al, 0x1a(%rsp)
movq %r14, %rdi
xorl %eax, %eax
callq 0x9c7f
movb %al, 0x19(%rsp)
movl $0x10, %edi
xorl %esi, %esi
xorl %edx, %edx
movl $0xf, %ecx
callq 0xa0cc
movb %al, 0x18(%rsp)
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9c7f
movb %al, 0x17(%rsp)
movq %r14, %rdi
xorl %eax, %eax
callq 0x9d3d
movl %eax, %r15d
movl $0x8, %edi
xorl %esi, %esi
movl $0xf, %edx
movl $0x4, %ecx
callq 0xa0cc
movb %al, 0x16(%rsp)
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9d3d
movb %al, 0x15(%rsp)
movq %r14, %rdi
xorl %eax, %eax
callq 0x9dfb
movb %al, 0x14(%rsp)
movl $0x4, %edi
movl $0x3, %esi
movl $0x8, %edx
movl $0xa, %ecx
callq 0xa0cc
movl %eax, %r12d
movq %rbx, %rdi
movq %rbx, %r14
xorl %eax, %eax
callq 0x9dfb
movb %al, 0x13(%rsp)
leaq 0xc0a0(%rip), %rdi      # 0x1206a
xorl %eax, %eax
callq 0x9eb9
movb %al, 0x12(%rsp)
movl $0x2, %edi
movl $0x4, %esi
movl $0xc, %edx
movl $0x100, %ecx            # imm = 0x100
callq 0xa0cc
movl %eax, %ebx
movq %r14, %rdi
xorl %eax, %eax
callq 0x9eb9
movb %al, 0x11(%rsp)
leaq 0xc065(%rip), %rdi      # 0x1206a
xorl %eax, %eax
callq 0x9f77
movl %eax, %r14d
movl $0x1, %edi
movl $0x1, %esi
movl $0x8, %edx
movl $0x100, %ecx            # imm = 0x100
callq 0xa0cc
movb %al, 0x10(%rsp)
leaq 0xc045(%rip), %rdi      # 0x12078
xorl %eax, %eax
callq 0x9f77
andb 0x10(%rsp), %al
andb 0x11(%rsp), %r14b
andb %al, %r14b
andb 0x12(%rsp), %bl
andb 0x13(%rsp), %bl
andb %r14b, %bl
andb 0x14(%rsp), %r12b
andb 0x15(%rsp), %r12b
andb 0x16(%rsp), %r12b
andb %bl, %r12b
andb 0x17(%rsp), %r15b
andb 0x18(%rsp), %r15b
andb 0x19(%rsp), %r15b
andb 0x1a(%rsp), %r15b
andb %r12b, %r15b
andb 0x1b(%rsp), %r13b
andb 0x1c(%rsp), %r13b
andb 0x1d(%rsp), %r13b
andb 0x1e(%rsp), %r13b
andb 0x1f(%rsp), %r13b
andb %r15b, %r13b
movb 0xe(%rsp), %cl
andb 0xf(%rsp), %cl
andb %r13b, %cl
andb 0xd(%rsp), %cl
leaq 0xbfdb(%rip), %rax      # 0x12087
leaq 0xc009(%rip), %rsi      # 0x120bc
testb $0x1, %cl
movl %ecx, %r14d
cmovneq %rax, %rsi
leaq 0xb00b(%rip), %rdx      # 0x110cf
leaq 0xafeb(%rip), %rax      # 0x110b6
cmovneq %rax, %rdx
movl $0x1, %edi
xorl %eax, %eax
callq 0x3400
leaq 0xc00f(%rip), %rsi      # 0x120f1
movl $0x1, %edi
xorl %eax, %eax
callq 0x3400
callq 0xa0ea
movl %eax, %ebx
andb %r14b, %bl
leaq 0xc022(%rip), %rdi      # 0x12121
xorl %eax, %eax
callq 0x9a45
movb %al, 0xd(%rsp)
leaq 0xc026(%rip), %rdi      # 0x12137
xorl %eax, %eax
callq 0x9b03
movb %al, 0xf(%rsp)
leaq 0xc029(%rip), %rdi      # 0x1214c
xorl %eax, %eax
callq 0x9bc1
movb %al, 0xe(%rsp)
leaq 0xc02e(%rip), %rdi      # 0x12163
xorl %eax, %eax
callq 0x9c7f
movl %eax, %r14d
leaq 0xc035(%rip), %rdi      # 0x1217b
xorl %eax, %eax
callq 0x9d3d
movl %eax, %r15d
leaq 0xc03a(%rip), %rdi      # 0x12191
xorl %eax, %eax
callq 0x9dfb
movl %eax, %r12d
leaq 0xc03e(%rip), %rdi      # 0x121a6
xorl %eax, %eax
callq 0x9eb9
movl %eax, %r13d
leaq 0xc043(%rip), %rdi      # 0x121bc
xorl %eax, %eax
callq 0x9f77
andb %r13b, %al
andb %r15b, %r12b
andb %al, %r12b
andb 0xe(%rsp), %r14b
andb 0xf(%rsp), %r14b
andb %r12b, %r14b
andb 0xd(%rsp), %r14b
andb %bl, %r14b
leaq 0xc031(%rip), %rax      # 0x121d6
leaq 0xc05f(%rip), %rsi      # 0x1220b
testb $0x1, %r14b
cmovneq %rax, %rsi
leaq 0xaf14(%rip), %rdx      # 0x110cf
leaq 0xaef4(%rip), %rax      # 0x110b6
cmovneq %rax, %rdx
movl $0x1, %edi
xorl %eax, %eax
callq 0x3400
leaq 0xc067(%rip), %rsi      # 0x12240
movl $0x1, %edi
xorl %eax, %eax
callq 0x3400
movl $0x1, %edi
callq 0xa106
movl %eax, %ebx
andb %r14b, %bl
leaq 0xc07a(%rip), %r14      # 0x12275
xorl %r15d, %r15d
cmpl %r15d, %ebp
je 0x622b
movl $0x80, %edi
xorl %esi, %esi
movl %r15d, %edx
movl %ebp, %ecx
callq 0xa0cc
movl %eax, %r12d
movq %r14, %rdi
movl %r15d, %esi
movl %ebp, %edx
xorl %eax, %eax
callq 0x9a45
andb %r12b, %al
andb %al, %bl
incl %r15d
decl %ebp
cmpl $0xff, %r15d
jne 0x61fe
leaq 0xc05d(%rip), %rax      # 0x1229d
leaq 0xc090(%rip), %rsi      # 0x122d7
testb $0x1, %bl
cmovneq %rax, %rsi
leaq 0xae7a(%rip), %rdx      # 0x110cf
leaq 0xae5a(%rip), %rax      # 0x110b6
cmovneq %rax, %rdx
movl $0x1, %edi
xorl %eax, %eax
callq 0x3400
leaq 0xc09e(%rip), %rsi      # 0x12311
movl $0x1, %edi
xorl %eax, %eax
callq 0x3400
movl $0x2, %edi
callq 0xa106
movl %eax, %ebp
andb %bl, %bpl
movl $0x100, %r13d           # imm = 0x100
movl $0xff, %ebx
movl $0xff, %edi
callq 0x408e
movl %eax, %r14d
movl $0xff, %edi
callq 0x408e
movl %eax, %r15d
movl $0xff, %edi
callq 0x408e
movl %r14d, %edi
movl %r15d, %esi
movl %eax, %edx
callq 0xa0ef
movl %eax, %r14d
movl $0xff, %edi
callq 0x408e
movl %eax, %r15d
movl $0xff, %edi
callq 0x408e
movl %eax, %r12d
movl $0xff, %edi
callq 0x408e
movl %r15d, %edi
movl %r12d, %esi
movl %eax, %edx
callq 0xa0ef
movl %eax, %r12d
movl $0x80, %edi
xorl %esi, %esi
movl %r14d, %edx
movl %eax, %ecx
callq 0xa0cc
movl %eax, %r15d
movl %r14d, %esi
shrl $0x10, %esi
andl %ebx, %esi
movl %r14d, %edx
shrl $0x8, %edx
andl %ebx, %edx
andl %ebx, %r14d
movl %r12d, %r8d
shrl $0x10, %r8d
andl %ebx, %r8d
movl %r12d, %r9d
shrl $0x8, %r9d
andl %ebx, %r9d
andl %ebx, %r12d
movl %r12d, (%rsp)
leaq 0xbffc(%rip), %rdi      # 0x12346
movl %r14d, %ecx
xorl %eax, %eax
callq 0x9a45
andb %r15b, %bpl
andb %al, %bpl
decq %r13
jne 0x6299
leaq 0xc014(%rip), %rax      # 0x1237e
leaq 0xc047(%rip), %rsi      # 0x123b8
testb %bpl, %bpl
cmovneq %rax, %rsi
leaq 0xad50(%rip), %r12      # 0x110cf
movq %r12, %rdx
leaq 0xad2d(%rip), %r13      # 0x110b6
cmovneq %r13, %rdx
movl $0x1, %edi
xorl %eax, %eax
callq 0x3400
leaq 0xc052(%rip), %rsi      # 0x123f2
movl $0x1, %edi
xorl %eax, %eax
callq 0x3400
movl $0x3, %edi
callq 0xa106
movl %eax, %ebx
xorb $0x1, %bl
movl $0xff, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0xa0ef
movl %eax, %r14d
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0xa0ef
movl $0x80, %edi
xorl %esi, %esi
movl %r14d, %edx
movl %eax, %ecx
callq 0xa0cc
movl %eax, %r15d
leaq 0xc038(%rip), %rdi      # 0x1242a
xorl %eax, %eax
callq 0x9a45
movl %eax, %r14d
andb %r15b, %r14b
andb %bl, %r14b
andb %bpl, %r14b
leaq 0xc03b(%rip), %rax      # 0x12447
leaq 0xc070(%rip), %rsi      # 0x12483
cmovneq %rax, %rsi
movq %r12, %rdx
cmovneq %r13, %rdx
movl $0x1, %edi
xorl %eax, %eax
callq 0x3400
leaq 0xc08e(%rip), %rsi      # 0x124bf
movl $0x1, %edi
xorl %eax, %eax
callq 0x3400
xorl %edi, %edi
callq 0xa106
movl %eax, %ebx
andb %r14b, %bl
movl $0x80, %edi
movl $0x3, %esi
movl $0xd, %edx
movl $0x100, %ecx            # imm = 0x100
callq 0xa0cc
movl %eax, %ebp
leaq 0xc088(%rip), %rdi      # 0x124f3
movl $0xd, %esi
xorl %eax, %eax
callq 0x9a45
movl %eax, %r14d
andb %bpl, %r14b
andb %bl, %r14b
leaq 0xc098(%rip), %rax      # 0x1251f
leaq 0xc0ca(%rip), %rsi      # 0x12558
cmovneq %rax, %rsi
cmovneq %r13, %r12
movl $0x1, %edi
movq %r12, %rdx
xorl %eax, %eax
callq 0x3400
callq 0x9a26
andb %r14b, %al
movzbl %al, %edi
xorl %esi, %esi
callq 0x3b6d
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq