// File: /workspace/github_c_makefile_star2_O1/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)
movw $0x0, 0x8(%rbx)
movq %rbx, %rdi
callq 0x9a31
movb %al, 0xd(%rsp)
leaq 0xc14f(%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 0xa0dc
movl %eax, %ebx
xorb $0x1, %bl
leaq 0xc14f(%rip), %rdi      # 0x11ed8
xorl %eax, %eax
callq 0x9b13
movl %eax, %r15d
movl $0x80, %edi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0xa0dc
movl %eax, %r12d
xorb $0x1, %r12b
leaq 0xc149(%rip), %rdi      # 0x11efa
xorl %eax, %eax
callq 0x9b13
movl %eax, %r13d
movl $0xff, %ebp
movl $0x2, %edi
xorl %esi, %esi
movl $0xff, %edx
movl $0xff, %ecx
callq 0xa0dc
movl %eax, %r14d
xorb $0x1, %r14b
leaq 0xc12c(%rip), %rdi      # 0x11f10
xorl %eax, %eax
callq 0x9b13
andb %r13b, %al
andb %r14b, %al
andb %r15b, %r12b
andb %al, %r12b
andb 0xd(%rsp), %bl
andb %r12b, %bl
leaq 0xc116(%rip), %rax      # 0x11f1b
leaq 0xc145(%rip), %rsi      # 0x11f51
testb $0x1, %bl
cmovneq %rax, %rsi
leaq 0xb29c(%rip), %rax      # 0x110b6
leaq 0xb2ae(%rip), %rcx      # 0x110cf
movq %rcx, %rdx
movq %rcx, %r12
cmovneq %rax, %rdx
movq %rax, %r15
movl $0x1, %edi
xorl %eax, %eax
callq 0x3400
leaq 0xc146(%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 0xa0dc
movl %eax, %r14d
andb %bl, %r14b
leaq 0xc147(%rip), %rdi      # 0x11fb7
xorl %eax, %eax
callq 0x9b13
movl %eax, %ebx
andb %r14b, %bl
leaq 0xc14d(%rip), %rax      # 0x11fd0
leaq 0xc17b(%rip), %rsi      # 0x12005
cmovneq %rax, %rsi
movq %r12, %rdx
cmovneq %r15, %rdx
movl $0x1, %edi
xorl %eax, %eax
callq 0x3400
leaq 0xc192(%rip), %rsi      # 0x1203a
movl $0x1, %edi
xorl %eax, %eax
callq 0x3400
callq 0xa0fa
andb %bl, %al
movb %al, 0xd(%rsp)
leaq 0xc1a4(%rip), %r14      # 0x1206a
movq %r14, %rdi
xorl %eax, %eax
callq 0x9a55
movb %al, 0xf(%rsp)
movl $0x80, %edi
xorl %esi, %esi
movl $0xb, %edx
movl $0x8, %ecx
callq 0xa0dc
movb %al, 0xe(%rsp)
leaq 0xc183(%rip), %rbx      # 0x12078
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9a55
movb %al, 0x1f(%rsp)
movq %r14, %rdi
xorl %eax, %eax
callq 0x9b13
movb %al, 0x1e(%rsp)
movl $0x40, %edi
xorl %esi, %esi
movl $0x2, %edx
movl $0x5, %ecx
callq 0xa0dc
movb %al, 0x1d(%rsp)
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9b13
movb %al, 0x1c(%rsp)
movq %r14, %rdi
xorl %eax, %eax
callq 0x9bd1
movb %al, 0x1b(%rsp)
movl $0x20, %edi
xorl %esi, %esi
xorl %edx, %edx
movl $0xb, %ecx
callq 0xa0dc
movl %eax, %r13d
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9bd1
movb %al, 0x1a(%rsp)
movq %r14, %rdi
xorl %eax, %eax
callq 0x9c8f
movb %al, 0x19(%rsp)
movl $0x10, %edi
xorl %esi, %esi
xorl %edx, %edx
movl $0xf, %ecx
callq 0xa0dc
movb %al, 0x18(%rsp)
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9c8f
movb %al, 0x17(%rsp)
movq %r14, %rdi
xorl %eax, %eax
callq 0x9d4d
movl %eax, %r15d
movl $0x8, %edi
xorl %esi, %esi
movl $0xf, %edx
movl $0x4, %ecx
callq 0xa0dc
movb %al, 0x16(%rsp)
movq %rbx, %rdi
xorl %eax, %eax
callq 0x9d4d
movb %al, 0x15(%rsp)
movq %r14, %rdi
xorl %eax, %eax
callq 0x9e0b
movb %al, 0x14(%rsp)
movl $0x4, %edi
movl $0x3, %esi
movl $0x8, %edx
movl $0xa, %ecx
callq 0xa0dc
movl %eax, %r12d
movq %rbx, %rdi
movq %rbx, %r14
xorl %eax, %eax
callq 0x9e0b
movb %al, 0x13(%rsp)
leaq 0xc055(%rip), %rdi      # 0x1206a
xorl %eax, %eax
callq 0x9ec9
movb %al, 0x12(%rsp)
movl $0x2, %edi
movl $0x4, %esi
movl $0xc, %edx
movl $0x100, %ecx            # imm = 0x100
callq 0xa0dc
movl %eax, %ebx
movq %r14, %rdi
xorl %eax, %eax
callq 0x9ec9
movb %al, 0x11(%rsp)
leaq 0xc01a(%rip), %rdi      # 0x1206a
xorl %eax, %eax
callq 0x9f87
movl %eax, %r14d
movl $0x1, %edi
movl $0x1, %esi
movl $0x8, %edx
movl $0x100, %ecx            # imm = 0x100
callq 0xa0dc
movb %al, 0x10(%rsp)
leaq 0xbffa(%rip), %rdi      # 0x12078
xorl %eax, %eax
callq 0x9f87
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 0xbf90(%rip), %rax      # 0x12087
leaq 0xbfbe(%rip), %rsi      # 0x120bc
testb $0x1, %cl
movl %ecx, %r14d
cmovneq %rax, %rsi
leaq 0xafc0(%rip), %rdx      # 0x110cf
leaq 0xafa0(%rip), %rax      # 0x110b6
cmovneq %rax, %rdx
movl $0x1, %edi
xorl %eax, %eax
callq 0x3400
leaq 0xbfc4(%rip), %rsi      # 0x120f1
movl $0x1, %edi
xorl %eax, %eax
callq 0x3400
callq 0xa0fa
movl %eax, %ebx
andb %r14b, %bl
leaq 0xbfd7(%rip), %rdi      # 0x12121
xorl %eax, %eax
callq 0x9a55
movb %al, 0xd(%rsp)
leaq 0xbfdb(%rip), %rdi      # 0x12137
xorl %eax, %eax
callq 0x9b13
movb %al, 0xf(%rsp)
leaq 0xbfde(%rip), %rdi      # 0x1214c
xorl %eax, %eax
callq 0x9bd1
movb %al, 0xe(%rsp)
leaq 0xbfe3(%rip), %rdi      # 0x12163
xorl %eax, %eax
callq 0x9c8f
movl %eax, %r14d
leaq 0xbfea(%rip), %rdi      # 0x1217b
xorl %eax, %eax
callq 0x9d4d
movl %eax, %r15d
leaq 0xbfef(%rip), %rdi      # 0x12191
xorl %eax, %eax
callq 0x9e0b
movl %eax, %r12d
leaq 0xbff3(%rip), %rdi      # 0x121a6
xorl %eax, %eax
callq 0x9ec9
movl %eax, %r13d
leaq 0xbff8(%rip), %rdi      # 0x121bc
xorl %eax, %eax
callq 0x9f87
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
andb $0x1, %r14b
leaq 0xbfe2(%rip), %rax      # 0x121d6
leaq 0xc010(%rip), %rsi      # 0x1220b
cmovneq %rax, %rsi
leaq 0xaec9(%rip), %rdx      # 0x110cf
leaq 0xaea9(%rip), %rax      # 0x110b6
cmovneq %rax, %rdx
movl $0x1, %edi
xorl %eax, %eax
callq 0x3400
leaq 0xc01c(%rip), %rsi      # 0x12240
movl $0x1, %edi
xorl %eax, %eax
callq 0x3400
movl $0x1, %edi
callq 0xa116
movl %eax, %ebx
andb %r14b, %bl
leaq 0xc02f(%rip), %r14      # 0x12275
xorl %r15d, %r15d
cmpl %r15d, %ebp
je 0x627f
movl $0x80, %edi
xorl %esi, %esi
movl %r15d, %edx
movl %ebp, %ecx
callq 0xa0dc
movl %eax, %r12d
movq %r14, %rdi
movl %r15d, %esi
movl %ebp, %edx
xorl %eax, %eax
callq 0x9a55
movzbl %bl, %ebx
testb %r12b, %al
movl $0x0, %eax
cmovel %eax, %ebx
incl %r15d
decl %ebp
jne 0x6249
leaq 0xc010(%rip), %rax      # 0x1229d
leaq 0xc043(%rip), %rsi      # 0x122d7
testb $0x1, %bl
cmovneq %rax, %rsi
leaq 0xae2d(%rip), %rdx      # 0x110cf
leaq 0xae0d(%rip), %rax      # 0x110b6
cmovneq %rax, %rdx
movl $0x1, %edi
xorl %eax, %eax
callq 0x3400
leaq 0xc051(%rip), %rsi      # 0x12311
movl $0x1, %edi
xorl %eax, %eax
callq 0x3400
movl $0x2, %edi
callq 0xa116
movl %eax, %ebp
andb %bl, %bpl
movl $0x100, %r13d           # imm = 0x100
movl $0xff, %ebx
movl $0xff, %edi
callq 0x403f
movl %eax, %r14d
movl $0xff, %edi
callq 0x403f
movl %eax, %r15d
movl $0xff, %edi
callq 0x403f
movl %r14d, %edi
movl %r15d, %esi
movl %eax, %edx
callq 0xa0ff
movl %eax, %r14d
movl $0xff, %edi
callq 0x403f
movl %eax, %r15d
movl $0xff, %edi
callq 0x403f
movl %eax, %r12d
movl $0xff, %edi
callq 0x403f
movl %r15d, %edi
movl %r12d, %esi
movl %eax, %edx
callq 0xa0ff
movl %eax, %r12d
movl $0x80, %edi
xorl %esi, %esi
movl %r14d, %edx
movl %eax, %ecx
callq 0xa0dc
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 0xbfaf(%rip), %rdi      # 0x12346
movl %r14d, %ecx
xorl %eax, %eax
callq 0x9a55
andb %r15b, %bpl
andb %al, %bpl
decq %r13
jne 0x62e6
leaq 0xbfc7(%rip), %rax      # 0x1237e
leaq 0xbffa(%rip), %rsi      # 0x123b8
testb %bpl, %bpl
cmovneq %rax, %rsi
leaq 0xad03(%rip), %r12      # 0x110cf
movq %r12, %rdx
leaq 0xace0(%rip), %r13      # 0x110b6
cmovneq %r13, %rdx
movl $0x1, %edi
xorl %eax, %eax
callq 0x3400
leaq 0xc005(%rip), %rsi      # 0x123f2
movl $0x1, %edi
xorl %eax, %eax
callq 0x3400
movl $0x3, %edi
callq 0xa116
movl %eax, %ebx
xorb $0x1, %bl
movl $0xff, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0xa0ff
movl %eax, %r14d
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0xa0ff
movl $0x80, %edi
xorl %esi, %esi
movl %r14d, %edx
movl %eax, %ecx
callq 0xa0dc
movl %eax, %r15d
leaq 0xbfeb(%rip), %rdi      # 0x1242a
xorl %eax, %eax
callq 0x9a55
movl %eax, %r14d
andb %r15b, %r14b
andb %bl, %r14b
andb %bpl, %r14b
leaq 0xbfee(%rip), %rax      # 0x12447
leaq 0xc023(%rip), %rsi      # 0x12483
cmovneq %rax, %rsi
movq %r12, %rdx
cmovneq %r13, %rdx
movl $0x1, %edi
xorl %eax, %eax
callq 0x3400
leaq 0xc041(%rip), %rsi      # 0x124bf
movl $0x1, %edi
xorl %eax, %eax
callq 0x3400
xorl %edi, %edi
callq 0xa116
movl %eax, %ebx
andb %r14b, %bl
movl $0x80, %edi
movl $0x3, %esi
movl $0xd, %edx
movl $0x100, %ecx            # imm = 0x100
callq 0xa0dc
movl %eax, %ebp
leaq 0xc03b(%rip), %rdi      # 0x124f3
movl $0xd, %esi
xorl %eax, %eax
callq 0x9a55
movl %eax, %r14d
andb %bpl, %r14b
andb %bl, %r14b
leaq 0xc04b(%rip), %rax      # 0x1251f
leaq 0xc07d(%rip), %rsi      # 0x12558
cmovneq %rax, %rsi
cmovneq %r13, %r12
movl $0x1, %edi
movq %r12, %rdx
xorl %eax, %eax
callq 0x3400
callq 0x9a36
andb %r14b, %al
movzbl %al, %edi
xorl %esi, %esi
callq 0x3b04
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq