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

    static const size_t iterations = 10;

    /* these should all be valid. */
    TEST_MSG_0(SIR_WHITEB("--- individual valid levels ---"));
    _sir_eqland(pass, _sir_validlevel(SIRL_INFO) && _sir_validlevels(SIRL_INFO));
    (void)printf(INDENT_ITEM SIR_WHITE("valid level: %04x") SIR_EOL, SIRL_INFO);
    _sir_eqland(pass, _sir_validlevel(SIRL_DEBUG) && _sir_validlevels(SIRL_DEBUG));
    (void)printf(INDENT_ITEM SIR_WHITE("valid level: %04x") SIR_EOL, SIRL_DEBUG);
    _sir_eqland(pass, _sir_validlevel(SIRL_NOTICE) && _sir_validlevels(SIRL_NOTICE));
    (void)printf(INDENT_ITEM SIR_WHITE("valid level: %04x") SIR_EOL, SIRL_NOTICE);
    _sir_eqland(pass, _sir_validlevel(SIRL_WARN) && _sir_validlevels(SIRL_WARN));
    (void)printf(INDENT_ITEM SIR_WHITE("valid level: %04x") SIR_EOL, SIRL_WARN);
    _sir_eqland(pass, _sir_validlevel(SIRL_ERROR) && _sir_validlevels(SIRL_ERROR));
    (void)printf(INDENT_ITEM SIR_WHITE("valid level: %04x") SIR_EOL, SIRL_ERROR);
    _sir_eqland(pass, _sir_validlevel(SIRL_CRIT) && _sir_validlevels(SIRL_CRIT));
    (void)printf(INDENT_ITEM SIR_WHITE("valid level: %04x") SIR_EOL, SIRL_CRIT);
    _sir_eqland(pass, _sir_validlevel(SIRL_ALERT) && _sir_validlevels(SIRL_ALERT));
    (void)printf(INDENT_ITEM SIR_WHITE("valid level: %04x") SIR_EOL, SIRL_ALERT);
    _sir_eqland(pass, _sir_validlevel(SIRL_EMERG) && _sir_validlevels(SIRL_EMERG));
    (void)printf(INDENT_ITEM SIR_WHITE("valid level: %04x") SIR_EOL, SIRL_EMERG);
    _sir_eqland(pass, _sir_validlevels(SIRL_ALL));
    (void)printf(INDENT_ITEM SIR_WHITE("valid levels: %04x") SIR_EOL, SIRL_ALL);
    _sir_eqland(pass, _sir_validlevels(SIRL_NONE));
    (void)printf(INDENT_ITEM SIR_WHITE("valid levels: %04x") SIR_EOL, SIRL_NONE);
    PASSFAIL_MSG(pass, "\t--- individual valid levels: %s ---" SIR_EOL SIR_EOL, PRN_PASS(pass));

    /* any combination these bitwise OR'd together
     * to form a bitmask should also be valid. */
    static const sir_levels levels_arr[SIR_NUMLEVELS] = {
        SIRL_EMERG,
        SIRL_ALERT,
        SIRL_CRIT,
        SIRL_ERROR,
        SIRL_WARN,
        SIRL_NOTICE,
        SIRL_INFO,
        SIRL_DEBUG
    };

    TEST_MSG_0(SIR_WHITEB("--- random bitmask of valid levels ---"));
    uint32_t last_count = SIR_NUMLEVELS;
    for (size_t n = 0; n < iterations; n++) {
        sir_levels levels   = 0U;
        uint32_t rand_count = 0U;
        size_t last_idx     = 0UL;

        do {
            rand_count = getrand(SIR_NUMLEVELS);
        } while (rand_count == last_count || rand_count <= 1U);

        last_count = rand_count;

        for (size_t i = 0; i < rand_count; i++) {
            size_t rand_idx = 0;
            size_t tries    = 0;

            do {
                if (++tries > SIR_NUMLEVELS - 2)
                    break;
                rand_idx = (size_t)getrand(SIR_NUMLEVELS);
            } while (rand_idx == last_idx || _sir_bittest(levels, levels_arr[rand_idx]));

            last_idx = rand_idx;
            levels |= levels_arr[rand_idx];
        }

        _sir_eqland(pass, _sir_validlevels(levels));
        (void)printf(INDENT_ITEM SIR_WHITE("(%zu/%zu): random valid (count: %"PRIu32", levels:"
                                 " %04"PRIx16) ")" SIR_EOL, n + 1, iterations, rand_count, levels);
    }
    PASSFAIL_MSG(pass, "\t--- random bitmask of valid levels: %s ---" SIR_EOL SIR_EOL, PRN_PASS(pass));

    TEST_MSG_0(SIR_WHITEB("--- invalid values ---"));

    /* greater than SIRL_ALL. */
    sir_levels invalid = (0xffffU & ~SIRL_ALL);
    _sir_eqland(pass, !_sir_validlevels(invalid));
    (void)printf(INDENT_ITEM SIR_WHITE("greater than SIRL_ALL: %04"PRIx16) SIR_EOL, invalid);

    /* individual invalid level. */
    sir_level invalid2 = 0x1337U;
    _sir_eqland(pass, !_sir_validlevel(invalid2));
    (void)printf(INDENT_ITEM SIR_WHITE("individual invalid level: %04"PRIx16) SIR_EOL, invalid2);

    PASSFAIL_MSG(pass, "\t--- invalid values: %s ---" SIR_EOL, PRN_PASS(pass));

    _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), %r14
xorl %ebx, %ebx
movl $0x108, %edx            # imm = 0x108
movq %r14, %rdi
xorl %esi, %esi
callq 0x31f0
movl $0x100000, %eax         # imm = 0x100000
movl %eax, 0x4(%r14)
movw $0xff, (%r14)
movl %eax, 0xc(%r14)
movq %r14, %rdi
callq 0x9a21
movl %eax, %ebp
leaq 0xbf20(%rip), %rsi      # 0x12918
movl $0x1, %edi
xorl %eax, %eax
callq 0x3400
leaq 0xbef8(%rip), %rsi      # 0x12903
leaq 0xab3c(%rip), %rdx      # 0x1154e
movl $0x40, %edi
movl $0x3f3, %ecx            # imm = 0x3F3
callq 0xc7a8
testb %al, %al
je 0x6a47
leaq 0xbed7(%rip), %rsi      # 0x12903
leaq 0xab1b(%rip), %rdx      # 0x1154e
movl $0x40, %edi
movl $0x3f3, %ecx            # imm = 0x3F3
callq 0xc73c
movl %eax, %ebx
andb %bpl, %bl
leaq 0xbf00(%rip), %rsi      # 0x1294e
xorl %ebp, %ebp
movl $0x1, %edi
movl $0x40, %edx
xorl %eax, %eax
callq 0x3400
leaq 0xbe9b(%rip), %rsi      # 0x12903
leaq 0xaadf(%rip), %rdx      # 0x1154e
movl $0x80, %edi
movl $0x3f5, %ecx            # imm = 0x3F5
callq 0xc7a8
testb %al, %al
je 0x6aa4
leaq 0xbe7a(%rip), %rsi      # 0x12903
leaq 0xaabe(%rip), %rdx      # 0x1154e
movl $0x80, %edi
movl $0x3f5, %ecx            # imm = 0x3F5
callq 0xc73c
movl %eax, %ebp
andb %bl, %bpl
leaq 0xbea3(%rip), %rsi      # 0x1294e
xorl %ebx, %ebx
movl $0x1, %edi
movl $0x80, %edx
xorl %eax, %eax
callq 0x3400
leaq 0xbe3e(%rip), %rsi      # 0x12903
leaq 0xaa82(%rip), %rdx      # 0x1154e
movl $0x20, %edi
movl $0x3f7, %ecx            # imm = 0x3F7
callq 0xc7a8
testb %al, %al
je 0x6b01
leaq 0xbe1d(%rip), %rsi      # 0x12903
leaq 0xaa61(%rip), %rdx      # 0x1154e
movl $0x20, %edi
movl $0x3f7, %ecx            # imm = 0x3F7
callq 0xc73c
movl %eax, %ebx
andb %bpl, %bl
leaq 0xbe46(%rip), %rsi      # 0x1294e
xorl %ebp, %ebp
movl $0x1, %edi
movl $0x20, %edx
xorl %eax, %eax
callq 0x3400
leaq 0xbde1(%rip), %rsi      # 0x12903
leaq 0xaa25(%rip), %rdx      # 0x1154e
movl $0x10, %edi
movl $0x3f9, %ecx            # imm = 0x3F9
callq 0xc7a8
testb %al, %al
je 0x6b5e
leaq 0xbdc0(%rip), %rsi      # 0x12903
leaq 0xaa04(%rip), %rdx      # 0x1154e
movl $0x10, %edi
movl $0x3f9, %ecx            # imm = 0x3F9
callq 0xc73c
movl %eax, %ebp
andb %bl, %bpl
leaq 0xbde9(%rip), %rsi      # 0x1294e
xorl %ebx, %ebx
movl $0x1, %edi
movl $0x10, %edx
xorl %eax, %eax
callq 0x3400
leaq 0xbd84(%rip), %rsi      # 0x12903
leaq 0xa9c8(%rip), %rdx      # 0x1154e
movl $0x8, %edi
movl $0x3fb, %ecx            # imm = 0x3FB
callq 0xc7a8
testb %al, %al
je 0x6bbb
leaq 0xbd63(%rip), %rsi      # 0x12903
leaq 0xa9a7(%rip), %rdx      # 0x1154e
movl $0x8, %edi
movl $0x3fb, %ecx            # imm = 0x3FB
callq 0xc73c
movl %eax, %ebx
andb %bpl, %bl
leaq 0xbd8c(%rip), %rsi      # 0x1294e
xorl %r14d, %r14d
movl $0x1, %edi
movl $0x8, %edx
xorl %eax, %eax
callq 0x3400
leaq 0xbd26(%rip), %rsi      # 0x12903
leaq 0xa96a(%rip), %rdx      # 0x1154e
movl $0x4, %edi
movl $0x3fd, %ecx            # imm = 0x3FD
callq 0xc7a8
testb %al, %al
je 0x6c1a
leaq 0xbd05(%rip), %rsi      # 0x12903
leaq 0xa949(%rip), %rdx      # 0x1154e
movl $0x4, %edi
movl $0x3fd, %ecx            # imm = 0x3FD
callq 0xc73c
movl %eax, %r14d
andb %bl, %r14b
leaq 0xbd2d(%rip), %rsi      # 0x1294e
xorl %ebp, %ebp
movl $0x1, %edi
movl $0x4, %edx
xorl %eax, %eax
callq 0x3400
leaq 0xbcc8(%rip), %rsi      # 0x12903
leaq 0xa90c(%rip), %rdx      # 0x1154e
movl $0x2, %edi
movl $0x3ff, %ecx            # imm = 0x3FF
callq 0xc7a8
testb %al, %al
je 0x6c77
leaq 0xbca7(%rip), %rsi      # 0x12903
leaq 0xa8eb(%rip), %rdx      # 0x1154e
movl $0x2, %edi
movl $0x3ff, %ecx            # imm = 0x3FF
callq 0xc73c
movl %eax, %ebp
andb %r14b, %bpl
leaq 0xbcd0(%rip), %rsi      # 0x1294e
xorl %ebx, %ebx
movl $0x1, %edi
movl $0x2, %edx
xorl %eax, %eax
callq 0x3400
leaq 0xbc6b(%rip), %rsi      # 0x12903
leaq 0xa8af(%rip), %rdx      # 0x1154e
movl $0x1, %edi
movl $0x401, %ecx            # imm = 0x401
callq 0xc7a8
testb %al, %al
je 0x6cd4
leaq 0xbc4a(%rip), %rsi      # 0x12903
leaq 0xa88e(%rip), %rdx      # 0x1154e
movl $0x1, %edi
movl $0x401, %ecx            # imm = 0x401
callq 0xc73c
movl %eax, %ebx
andb %bpl, %bl
leaq 0xbc73(%rip), %rsi      # 0x1294e
movl $0x1, %edi
movl $0x1, %edx
xorl %eax, %eax
callq 0x3400
leaq 0xbc10(%rip), %r14      # 0x12903
leaq 0xa854(%rip), %r15      # 0x1154e
movl $0xff, %edi
movq %r14, %rsi
movq %r15, %rdx
movl $0x403, %ecx            # imm = 0x403
callq 0xc73c
movl %eax, %r12d
leaq 0xbc63(%rip), %r13      # 0x1297c
movl $0x1, %edi
movq %r13, %rsi
movl $0xff, %edx
xorl %eax, %eax
callq 0x3400
xorl %edi, %edi
movq %r14, %rsi
movq %r15, %rdx
movl $0x405, %ecx            # imm = 0x405
callq 0xc73c
movl %eax, %ebp
andb %r12b, %bpl
andb %bl, %bpl
movl $0x1, %edi
movq %r13, %rsi
xorl %edx, %edx
xorl %eax, %eax
callq 0x3400
leaq 0xbc4c(%rip), %rax      # 0x129ab
leaq 0xbc80(%rip), %rsi      # 0x129e6
testb %bpl, %bpl
cmovneq %rax, %rsi
leaq 0xa342(%rip), %rax      # 0x110b6
leaq 0xa354(%rip), %rdx      # 0x110cf
cmovneq %rax, %rdx
movl $0x1, %edi
xorl %eax, %eax
callq 0x3400
leaq 0xbc8f(%rip), %rsi      # 0x12a21
movl $0x1, %edi
xorl %eax, %eax
callq 0x3400
movl $0x8, %ebx
leaq 0xa746(%rip), %r15      # 0x114f0
xorl %r12d, %r12d
movq %r12, 0x10(%rsp)
movb %bpl, 0xb(%rsp)
movl $0x8, %edi
callq 0x408e
cmpl %ebx, %eax
sete %cl
cmpl $0x2, %eax
setb %dl
orb %cl, %dl
jne 0x6db7
movl %eax, 0xc(%rsp)
movl %eax, %eax
movq %rax, 0x18(%rsp)
xorl %r13d, %r13d
xorl %ebx, %ebx
xorl %r14d, %r14d
movl $0x1, %r12d
movl %r14d, %ebp
notl %ebp
movl $0x8, %edi
callq 0x408e
movl %eax, %eax
cmpq %rax, %rbx
jne 0x6e0a
incq %r12
cmpq $0x7, %r12
jb 0x6dee
jmp 0x6e1f
movzwl (%r15,%rax,2), %ecx
testw %bp, %cx
jne 0x6e27
incq %r12
cmpq $0x6, %r12
jbe 0x6dee
jmp 0x6e27
movzwl (%r15,%rbx,2), %ecx
movq %rbx, %rax
orl %r14d, %ecx
movl %ecx, %r14d
incq %r13
movq %rax, %rbx
cmpq 0x18(%rsp), %r13
jne 0x6de3
movzwl %r14w, %r14d
movl %r14d, %edi
leaq 0xbabb(%rip), %rsi      # 0x12903
leaq 0xa6ff(%rip), %rdx      # 0x1154e
movl $0x431, %ecx            # imm = 0x431
callq 0xc73c
movb 0xb(%rsp), %bpl
andb %al, %bpl
movq 0x10(%rsp), %r12
incq %r12
movl $0xa, %ecx
movl $0x1, %edi
leaq 0xbbe4(%rip), %rsi      # 0x12a5e
movq %r12, %rdx
movl 0xc(%rsp), %ebx
movl %ebx, %r8d
movl %r14d, %r9d
xorl %eax, %eax
callq 0x3400
cmpq $0xa, %r12
jne 0x6dad
leaq 0xbc0d(%rip), %rax      # 0x12aac
leaq 0xbc48(%rip), %rsi      # 0x12aee
testb %bpl, %bpl
cmovneq %rax, %rsi
leaq 0xa21b(%rip), %r12      # 0x110cf
movq %r12, %rdx
leaq 0xa1f8(%rip), %r13      # 0x110b6
cmovneq %r13, %rdx
movl $0x1, %edi
xorl %eax, %eax
callq 0x3400
leaq 0xb8c3(%rip), %rsi      # 0x12798
movl $0x1, %edi
xorl %eax, %eax
callq 0x3400
leaq 0xba1b(%rip), %rbx      # 0x12903
leaq 0xa65f(%rip), %r14      # 0x1154e
movl $0xff00, %edi           # imm = 0xFF00
movq %rbx, %rsi
movq %r14, %rdx
movl $0x43b, %ecx            # imm = 0x43B
callq 0xc73c
movl %eax, %r15d
leaq 0xbc22(%rip), %rsi      # 0x12b30
movl $0x1, %edi
movl $0xff00, %edx           # imm = 0xFF00
xorl %eax, %eax
callq 0x3400
movl $0x1337, %edi           # imm = 0x1337
movq %rbx, %rsi
movq %r14, %rdx
movl $0x440, %ecx            # imm = 0x440
callq 0xc7a8
movl %eax, %ebx
orb %r15b, %bl
xorb $0x1, %bl
andb %bpl, %bl
leaq 0xbc22(%rip), %rsi      # 0x12b68
movl $0x1, %edi
movl $0x1337, %edx           # imm = 0x1337
xorl %eax, %eax
callq 0x3400
leaq 0xbc45(%rip), %rax      # 0x12ba3
leaq 0xbc6f(%rip), %rsi      # 0x12bd4
testb $0x1, %bl
cmovneq %rax, %rsi
cmovneq %r13, %r12
movl $0x1, %edi
movq %r12, %rdx
xorl %eax, %eax
callq 0x3400
callq 0x9a26
andb %bl, %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