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

    static const size_t iterations = 10;

    /*
     * TODO(aremmell): Update printf -> TEST_MSG,
     * rename INDENT_ITEM to BULLETED_ITEM.
     */

    /* these should all be valid. */
    TEST_MSG_0(SIR_WHITEB("--- individual valid options ---"));
    _sir_eqland(pass, _sir_validopts(SIRO_ALL));
    (void)printf(INDENT_ITEM SIR_WHITE("valid option: %08"PRIx32) SIR_EOL, SIRO_ALL);
    _sir_eqland(pass, _sir_validopts(SIRO_NOTIME));
    (void)printf(INDENT_ITEM SIR_WHITE("valid option: %08"PRIx32) SIR_EOL, SIRO_NOTIME);
    _sir_eqland(pass, _sir_validopts(SIRO_NOHOST));
    (void)printf(INDENT_ITEM SIR_WHITE("valid option: %08"PRIx32) SIR_EOL, SIRO_NOHOST);
    _sir_eqland(pass, _sir_validopts(SIRO_NOLEVEL));
    (void)printf(INDENT_ITEM SIR_WHITE("valid option: %08"PRIx32) SIR_EOL, SIRO_NOLEVEL);
    _sir_eqland(pass, _sir_validopts(SIRO_NONAME));
    (void)printf(INDENT_ITEM SIR_WHITE("valid option: %08"PRIx32) SIR_EOL, SIRO_NONAME);
    _sir_eqland(pass, _sir_validopts(SIRO_NOPID));
    (void)printf(INDENT_ITEM SIR_WHITE("valid option: %08"PRIx32) SIR_EOL, SIRO_NOPID);
    _sir_eqland(pass, _sir_validopts(SIRO_NOTID));
    (void)printf(INDENT_ITEM SIR_WHITE("valid option: %08"PRIx32) SIR_EOL, SIRO_NOTID);
    _sir_eqland(pass, _sir_validopts(SIRO_NOHDR));
    (void)printf(INDENT_ITEM SIR_WHITE("valid option: %08"PRIx32) SIR_EOL, SIRO_NOHDR);
    _sir_eqland(pass, _sir_validopts(SIRO_MSGONLY));
    (void)printf(INDENT_ITEM SIR_WHITE("valid option: %08"PRIx32) SIR_EOL, SIRO_MSGONLY);
    PASSFAIL_MSG(pass, "\t--- individual valid options: %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_option option_arr[SIR_NUMOPTIONS] = {
        SIRO_NOTIME,
        SIRO_NOHOST,
        SIRO_NOLEVEL,
        SIRO_NONAME,
        SIRO_NOMSEC,
        SIRO_NOPID,
        SIRO_NOTID,
        SIRO_NOHDR
    };

    TEST_MSG_0(SIR_WHITEB("--- random bitmask of valid options ---"));
    uint32_t last_count = SIR_NUMOPTIONS;
    for (size_t n = 0; n < iterations; n++) {
        sir_options opts    = 0;
        uint32_t rand_count = 0;
        size_t last_idx     = 0;

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

        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_NUMOPTIONS - 2)
                    break;
                rand_idx = (size_t)getrand(SIR_NUMOPTIONS);
            } while (rand_idx == last_idx || _sir_bittest(opts, option_arr[rand_idx]));

            last_idx = rand_idx;
            opts |= option_arr[rand_idx];
        }

        _sir_eqland(pass, _sir_validopts(opts));
        (void)printf(INDENT_ITEM SIR_WHITE("(%zu/%zu): random valid (count: %"PRIu32
            ", options: %08"PRIx32")") SIR_EOL, n + 1, iterations, rand_count, opts);
    }
    PASSFAIL_MSG(pass, "\t--- random bitmask of valid options: %s ---" SIR_EOL SIR_EOL, PRN_PASS(pass));

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

    /* the lowest byte is not valid. */
    sir_options invalid = 0x000000ff;
    _sir_eqland(pass, !_sir_validopts(invalid));
    (void)printf(INDENT_ITEM SIR_WHITE("lowest byte: %08"PRIx32) SIR_EOL, invalid);

    /* gaps in between valid options. */
    invalid = 0x0001ff00U & ~(SIRO_NOTIME | SIRO_NOHOST | SIRO_NOLEVEL | SIRO_NONAME |
                             SIRO_NOMSEC | SIRO_NOPID | SIRO_NOTID  | SIRO_NOHDR);
    _sir_eqland(pass, !_sir_validopts(invalid));
    (void)printf(INDENT_ITEM SIR_WHITE("gaps in 0x001ff00U: %08"PRIx32) SIR_EOL, invalid);

    /* greater than SIRO_MSGONLY and less than SIRO_NOHDR. */
    for (sir_option o = 0x00008f00U; o < SIRO_NOHDR; o += 0x1000U) {
        _sir_eqland(pass, !_sir_validopts(o));
        (void)printf(INDENT_ITEM SIR_WHITE("SIRO_MSGONLY >< SIRO_NOHDR: %08"PRIx32) SIR_EOL, o);
    }

    /* greater than SIRO_NOHDR. */
    invalid = (0xFFFF0000 & ~SIRO_NOHDR);
    _sir_eqland(pass, !_sir_validopts(invalid));
    (void)printf(INDENT_ITEM SIR_WHITE("greater than SIRO_NOHDR: %08"PRIx32) SIR_EOL, invalid);

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

    _sir_eqland(pass, sir_cleanup());
    return PRINT_RESULT_RETURN(pass);
}

// Assembly:
subq $0x168, %rsp            # imm = 0x168
leaq 0x60(%rsp), %rdi
xorl %esi, %esi
movl $0x108, %edx            # imm = 0x108
callq 0x4210
movl $0x100000, 0x64(%rsp)   # imm = 0x100000
movw $0xff, 0x60(%rsp)
movl $0x100000, 0x6c(%rsp)   # imm = 0x100000
movw $0x0, 0x68(%rsp)
leaq 0x1365a(%rip), %rdi     # 0x1d2c7
xorl %esi, %esi
leaq 0x14a5f(%rip), %rdx     # 0x1e6d5
leaq 0x138b0(%rip), %rcx     # 0x1d52d
movl $0x37f, %r8d            # imm = 0x37F
callq 0x5ce0
testb $0x1, %al
jne 0x9c8e
jmp 0x9cae
leaq 0x60(%rsp), %rdi
addq $0xe8, %rdi
movl $0x20, %ecx
leaq 0x13621(%rip), %rdx     # 0x1d2c7
movq %rcx, %rsi
callq 0x14f50
movb $0x0, 0x5f(%rsp)
leaq 0x60(%rsp), %rdi
callq 0xf560
andb $0x1, %al
movb %al, 0x5f(%rsp)
movb 0x5f(%rsp), %al
andb $0x1, %al
movb %al, 0x5e(%rsp)
leaq 0x14a17(%rip), %rdi     # 0x1e6eb
movb $0x0, %al
callq 0x4180
xorl %edi, %edi
leaq 0x149f1(%rip), %rsi     # 0x1e6d5
leaq 0x13842(%rip), %rdx     # 0x1d52d
movl $0x38b, %ecx            # imm = 0x38B
callq 0x14a50
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x1f(%rsp)
jne 0x9d04
jmp 0x9d0c
movb 0x5e(%rsp), %al
movb %al, 0x1f(%rsp)
movb 0x1f(%rsp), %al
andb $0x1, %al
movb %al, 0x5e(%rsp)
leaq 0x14a05(%rip), %rdi     # 0x1e722
xorl %esi, %esi
movb $0x0, %al
callq 0x4180
movl $0x100, %edi            # imm = 0x100
leaq 0x149a3(%rip), %rsi     # 0x1e6d5
leaq 0x137f4(%rip), %rdx     # 0x1d52d
movl $0x38d, %ecx            # imm = 0x38D
callq 0x14a50
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x1e(%rsp)
jne 0x9d52
jmp 0x9d5a
movb 0x5e(%rsp), %al
movb %al, 0x1e(%rsp)
movb 0x1e(%rsp), %al
andb $0x1, %al
movb %al, 0x5e(%rsp)
leaq 0x149b7(%rip), %rdi     # 0x1e722
movl $0x100, %esi            # imm = 0x100
movb $0x0, %al
callq 0x4180
movl $0x400, %edi            # imm = 0x400
leaq 0x14952(%rip), %rsi     # 0x1e6d5
leaq 0x137a3(%rip), %rdx     # 0x1d52d
movl $0x38f, %ecx            # imm = 0x38F
callq 0x14a50
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x1d(%rsp)
jne 0x9da3
jmp 0x9dab
movb 0x5e(%rsp), %al
movb %al, 0x1d(%rsp)
movb 0x1d(%rsp), %al
andb $0x1, %al
movb %al, 0x5e(%rsp)
leaq 0x14966(%rip), %rdi     # 0x1e722
movl $0x400, %esi            # imm = 0x400
movb $0x0, %al
callq 0x4180
movl $0x800, %edi            # imm = 0x800
leaq 0x14901(%rip), %rsi     # 0x1e6d5
leaq 0x13752(%rip), %rdx     # 0x1d52d
movl $0x391, %ecx            # imm = 0x391
callq 0x14a50
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x1c(%rsp)
jne 0x9df4
jmp 0x9dfc
movb 0x5e(%rsp), %al
movb %al, 0x1c(%rsp)
movb 0x1c(%rsp), %al
andb $0x1, %al
movb %al, 0x5e(%rsp)
leaq 0x14915(%rip), %rdi     # 0x1e722
movl $0x800, %esi            # imm = 0x800
movb $0x0, %al
callq 0x4180
movl $0x1000, %edi           # imm = 0x1000
leaq 0x148b0(%rip), %rsi     # 0x1e6d5
leaq 0x13701(%rip), %rdx     # 0x1d52d
movl $0x393, %ecx            # imm = 0x393
callq 0x14a50
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x1b(%rsp)
jne 0x9e45
jmp 0x9e4d
movb 0x5e(%rsp), %al
movb %al, 0x1b(%rsp)
movb 0x1b(%rsp), %al
andb $0x1, %al
movb %al, 0x5e(%rsp)
leaq 0x148c4(%rip), %rdi     # 0x1e722
movl $0x1000, %esi           # imm = 0x1000
movb $0x0, %al
callq 0x4180
movl $0x2000, %edi           # imm = 0x2000
leaq 0x1485f(%rip), %rsi     # 0x1e6d5
leaq 0x136b0(%rip), %rdx     # 0x1d52d
movl $0x395, %ecx            # imm = 0x395
callq 0x14a50
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x1a(%rsp)
jne 0x9e96
jmp 0x9e9e
movb 0x5e(%rsp), %al
movb %al, 0x1a(%rsp)
movb 0x1a(%rsp), %al
andb $0x1, %al
movb %al, 0x5e(%rsp)
leaq 0x14873(%rip), %rdi     # 0x1e722
movl $0x2000, %esi           # imm = 0x2000
movb $0x0, %al
callq 0x4180
movl $0x4000, %edi           # imm = 0x4000
leaq 0x1480e(%rip), %rsi     # 0x1e6d5
leaq 0x1365f(%rip), %rdx     # 0x1d52d
movl $0x397, %ecx            # imm = 0x397
callq 0x14a50
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x19(%rsp)
jne 0x9ee7
jmp 0x9eef
movb 0x5e(%rsp), %al
movb %al, 0x19(%rsp)
movb 0x19(%rsp), %al
andb $0x1, %al
movb %al, 0x5e(%rsp)
leaq 0x14822(%rip), %rdi     # 0x1e722
movl $0x4000, %esi           # imm = 0x4000
movb $0x0, %al
callq 0x4180
movl $0x10000, %edi          # imm = 0x10000
leaq 0x147bd(%rip), %rsi     # 0x1e6d5
leaq 0x1360e(%rip), %rdx     # 0x1d52d
movl $0x399, %ecx            # imm = 0x399
callq 0x14a50
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x18(%rsp)
jne 0x9f38
jmp 0x9f40
movb 0x5e(%rsp), %al
movb %al, 0x18(%rsp)
movb 0x18(%rsp), %al
andb $0x1, %al
movb %al, 0x5e(%rsp)
leaq 0x147d1(%rip), %rdi     # 0x1e722
movl $0x10000, %esi          # imm = 0x10000
movb $0x0, %al
callq 0x4180
movl $0x7f00, %edi           # imm = 0x7F00
leaq 0x1476c(%rip), %rsi     # 0x1e6d5
leaq 0x135bd(%rip), %rdx     # 0x1d52d
movl $0x39b, %ecx            # imm = 0x39B
callq 0x14a50
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x17(%rsp)
jne 0x9f89
jmp 0x9f91
movb 0x5e(%rsp), %al
movb %al, 0x17(%rsp)
movb 0x17(%rsp), %al
andb $0x1, %al
movb %al, 0x5e(%rsp)
leaq 0x14780(%rip), %rdi     # 0x1e722
movl $0x7f00, %esi           # imm = 0x7F00
movb $0x0, %al
callq 0x4180
movb 0x5e(%rsp), %cl
leaq 0x147d4(%rip), %rdi     # 0x1e78d
leaq 0x14791(%rip), %rax     # 0x1e751
testb $0x1, %cl
cmovneq %rax, %rdi
movb 0x5e(%rsp), %cl
leaq 0x130fd(%rip), %rsi     # 0x1d0cf
leaq 0x130dd(%rip), %rax     # 0x1d0b6
testb $0x1, %cl
cmovneq %rax, %rsi
movb $0x0, %al
callq 0x4180
leaq 0x147db(%rip), %rdi     # 0x1e7c9
movb $0x0, %al
callq 0x4180
movl $0x8, 0x58(%rsp)
movq $0x0, 0x50(%rsp)
cmpq $0xa, 0x50(%rsp)
jae 0xa198
movl $0x0, 0x4c(%rsp)
movl $0x0, 0x48(%rsp)
movq $0x0, 0x40(%rsp)
movl $0x8, %edi
callq 0x5510
movl %eax, 0x48(%rsp)
movl 0x48(%rsp), %ecx
movb $0x1, %al
cmpl 0x58(%rsp), %ecx
movb %al, 0x16(%rsp)
je 0xa055
cmpl $0x1, 0x48(%rsp)
setbe %al
movb %al, 0x16(%rsp)
movb 0x16(%rsp), %al
testb $0x1, %al
jne 0xa02b
movl 0x48(%rsp), %eax
movl %eax, 0x58(%rsp)
movq $0x0, 0x38(%rsp)
movq 0x38(%rsp), %rax
movl 0x48(%rsp), %ecx
cmpq %rcx, %rax
jae 0xa123
movq $0x0, 0x30(%rsp)
movq $0x0, 0x28(%rsp)
movq 0x28(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x28(%rsp)
cmpq $0x6, %rax
jbe 0xa0a8
jmp 0xa0ef
movl $0x8, %edi
callq 0x5510
movl %eax, %eax
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rcx
movb $0x1, %al
cmpq 0x40(%rsp), %rcx
movb %al, 0x15(%rsp)
je 0xa0e7
movl 0x4c(%rsp), %edi
movq 0x30(%rsp), %rcx
leaq 0x16f15(%rip), %rax     # 0x20ff0
movl (%rax,%rcx,4), %esi
callq 0xa3d0
movb %al, 0x15(%rsp)
movb 0x15(%rsp), %al
testb $0x1, %al
jne 0xa092
movq 0x30(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x30(%rsp), %rcx
leaq 0x16eeb(%rip), %rax     # 0x20ff0
movl (%rax,%rcx,4), %eax
orl 0x4c(%rsp), %eax
movl %eax, 0x4c(%rsp)
movq 0x38(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x38(%rsp)
jmp 0xa06e
movl 0x4c(%rsp), %edi
leaq 0x145a7(%rip), %rsi     # 0x1e6d5
leaq 0x133f8(%rip), %rdx     # 0x1d52d
movl $0x3c7, %ecx            # imm = 0x3C7
callq 0x14a50
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x14(%rsp)
jne 0xa14e
jmp 0xa156
movb 0x5e(%rsp), %al
movb %al, 0x14(%rsp)
movb 0x14(%rsp), %al
andb $0x1, %al
movb %al, 0x5e(%rsp)
movq 0x50(%rsp), %rsi
addq $0x1, %rsi
movl 0x48(%rsp), %ecx
movl 0x4c(%rsp), %r8d
leaq 0x1468e(%rip), %rdi     # 0x1e807
movl $0xa, %edx
movb $0x0, %al
callq 0x4180
movq 0x50(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x50(%rsp)
jmp 0xa006
movb 0x5e(%rsp), %cl
leaq 0x146f6(%rip), %rdi     # 0x1e899
leaq 0x146ac(%rip), %rax     # 0x1e856
testb $0x1, %cl
cmovneq %rax, %rdi
movb 0x5e(%rsp), %cl
leaq 0x12f13(%rip), %rsi     # 0x1d0cf
leaq 0x12ef3(%rip), %rax     # 0x1d0b6
testb $0x1, %cl
cmovneq %rax, %rsi
movb $0x0, %al
callq 0x4180
leaq 0x14704(%rip), %rdi     # 0x1e8dc
movb $0x0, %al
callq 0x4180
movl $0xff, 0x24(%rsp)
movl 0x24(%rsp), %edi
leaq 0x144e3(%rip), %rsi     # 0x1e6d5
leaq 0x13334(%rip), %rdx     # 0x1d52d
movl $0x3d1, %ecx            # imm = 0x3D1
callq 0x14a50
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x13(%rsp)
jne 0xa218
movb 0x5e(%rsp), %al
movb %al, 0x13(%rsp)
movb 0x13(%rsp), %al
andb $0x1, %al
movb %al, 0x5e(%rsp)
movl 0x24(%rsp), %esi
leaq 0x146dc(%rip), %rdi     # 0x1e909
movb $0x0, %al
callq 0x4180
movl $0x8000, 0x24(%rsp)     # imm = 0x8000
movl 0x24(%rsp), %edi
leaq 0x1448e(%rip), %rsi     # 0x1e6d5
leaq 0x132df(%rip), %rdx     # 0x1d52d
movl $0x3d7, %ecx            # imm = 0x3D7
callq 0x14a50
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x12(%rsp)
jne 0xa26d
movb 0x5e(%rsp), %al
movb %al, 0x12(%rsp)
movb 0x12(%rsp), %al
andb $0x1, %al
movb %al, 0x5e(%rsp)
movl 0x24(%rsp), %esi
leaq 0x146b5(%rip), %rdi     # 0x1e937
movb $0x0, %al
callq 0x4180
movl $0x8f00, 0x20(%rsp)     # imm = 0x8F00
cmpl $0x10000, 0x20(%rsp)    # imm = 0x10000
jae 0xa2f7
movl 0x20(%rsp), %edi
leaq 0x1442f(%rip), %rsi     # 0x1e6d5
leaq 0x13280(%rip), %rdx     # 0x1d52d
movl $0x3dc, %ecx            # imm = 0x3DC
callq 0x14a50
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x11(%rsp)
jne 0xa2cc
movb 0x5e(%rsp), %al
movb %al, 0x11(%rsp)
movb 0x11(%rsp), %al
andb $0x1, %al
movb %al, 0x5e(%rsp)
movl 0x20(%rsp), %esi
leaq 0x1468b(%rip), %rdi     # 0x1e96c
movb $0x0, %al
callq 0x4180
movl 0x20(%rsp), %eax
addl $0x1000, %eax           # imm = 0x1000
movl %eax, 0x20(%rsp)
jmp 0xa291
movl $0xfffe0000, 0x24(%rsp) # imm = 0xFFFE0000
movl 0x24(%rsp), %edi
leaq 0x143cb(%rip), %rsi     # 0x1e6d5
leaq 0x1321c(%rip), %rdx     # 0x1d52d
movl $0x3e2, %ecx            # imm = 0x3E2
callq 0x14a50
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x10(%rsp)
jne 0xa330
movb 0x5e(%rsp), %al
movb %al, 0x10(%rsp)
movb 0x10(%rsp), %al
andb $0x1, %al
movb %al, 0x5e(%rsp)
movl 0x24(%rsp), %esi
leaq 0x14664(%rip), %rdi     # 0x1e9a9
movb $0x0, %al
callq 0x4180
movb 0x5e(%rsp), %cl
leaq 0x146be(%rip), %rdi     # 0x1ea15
leaq 0x14685(%rip), %rax     # 0x1e9e3
testb $0x1, %cl
cmovneq %rax, %rdi
movb 0x5e(%rsp), %cl
leaq 0x12d5f(%rip), %rsi     # 0x1d0cf
leaq 0x12d3f(%rip), %rax     # 0x1d0b6
testb $0x1, %cl
cmovneq %rax, %rsi
movb $0x0, %al
callq 0x4180
callq 0xf580
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0xf(%rsp)
jne 0xa399
jmp 0xa3a1
movb 0x5e(%rsp), %al
movb %al, 0xf(%rsp)
movb 0xf(%rsp), %al
andb $0x1, %al
movb %al, 0x5e(%rsp)
movb 0x5e(%rsp), %al
xorl %esi, %esi
andb $0x1, %al
movzbl %al, %edi
callq 0x4da0
andb $0x1, %al
addq $0x168, %rsp            # imm = 0x168
retq
nopw %cs:(%rax,%rax)