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

    size_t numfiles             = SIR_MAXFILES + 1;
    sirfileid ids[SIR_MAXFILES] = {0};

    sir_options even = SIRO_MSGONLY;
    sir_options odd  = SIRO_ALL;

    for (size_t n = 0; n < numfiles - 1; n++) {
        char path[SIR_MAXPATH] = {0};
        (void)snprintf(path, SIR_MAXPATH, MAKE_LOG_NAME("test-%zu.log"), n);
        rmfile(path, cl_cfg.leave_logs);
        ids[n] = sir_addfile(path, SIRL_ALL, (n % 2) ? odd : even);
        _sir_eqland(pass, 0U != ids[n] && sir_info("test %zu", n));
    }

    _sir_eqland(pass, sir_info("test test test"));

    /* this one should fail; max files already added. */
    _sir_eqland(pass, 0U == sir_addfile(MAKE_LOG_NAME("should-fail.log"),
        SIRL_ALL, SIRO_MSGONLY));

    if (pass)
        PRINT_EXPECTED_ERROR();

    _sir_eqland(pass, sir_info("test test test"));

    /* now remove previously added files in a different order. */
    size_t removeorder[SIR_MAXFILES];
    (void)memset(removeorder, -1, sizeof(removeorder));

    long processed = 0L;
    TEST_MSG_0("creating random file ID order...");

    do {
        size_t rnd = (size_t)getrand(SIR_MAXFILES);
        bool skip  = false;

        for (size_t n = 0; n < SIR_MAXFILES; n++)
            if (removeorder[n] == rnd) {
                skip = true;
                break;
            }

        if (skip)
            continue;

        removeorder[processed++] = rnd;

        if (processed == SIR_MAXFILES)
            break;
    } while (true);

    (void)printf("\tremove order: {");
    for (size_t n = 0; n < SIR_MAXFILES; n++)
        (void)printf(" %zu%s", removeorder[n], (n < SIR_MAXFILES - 1) ? "," : "");
    (void)printf(" }..." SIR_EOL);

    for (size_t n = 0; n < SIR_MAXFILES; n++) {
        _sir_eqland(pass, sir_remfile(ids[removeorder[n]]));

        char path[SIR_MAXPATH] = {0};
        (void)snprintf(path, SIR_MAXPATH, MAKE_LOG_NAME("test-%zu.log"), removeorder[n]);
        rmfile(path, cl_cfg.leave_logs);
    }

    _sir_eqland(pass, sir_info("test test test"));

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

// Assembly:
subq $0x2238, %rsp           # imm = 0x2238
leaq 0x2130(%rsp), %rdi
xorl %esi, %esi
movl $0x108, %edx            # imm = 0x108
callq 0x4210
movl $0x100000, 0x2134(%rsp) # imm = 0x100000
movw $0xff, 0x2130(%rsp)
movl $0x100000, 0x213c(%rsp) # imm = 0x100000
movw $0x0, 0x2138(%rsp)
leaq 0x1664b(%rip), %rdi     # 0x1d2c7
xorl %esi, %esi
leaq 0x16dce(%rip), %rdx     # 0x1da53
leaq 0x168a1(%rip), %rcx     # 0x1d52d
movl $0x187, %r8d            # imm = 0x187
callq 0x5ce0
testb $0x1, %al
jne 0x6c9d
jmp 0x6cc0
leaq 0x2130(%rsp), %rdi
addq $0xe8, %rdi
movl $0x20, %ecx
leaq 0x1660f(%rip), %rdx     # 0x1d2c7
movq %rcx, %rsi
callq 0x14f50
movb $0x0, 0x212f(%rsp)
leaq 0x2130(%rsp), %rdi
callq 0xf560
andb $0x1, %al
movb %al, 0x212f(%rsp)
movb 0x212f(%rsp), %al
andb $0x1, %al
movb %al, 0x212e(%rsp)
movq $0x11, 0x2120(%rsp)
leaq 0x20e0(%rsp), %rdi
xorl %esi, %esi
movl $0x40, %edx
callq 0x4210
movl $0x7f00, 0x20dc(%rsp) # imm = 0x7F00
movl $0x0, 0x20d8(%rsp)
movq $0x0, 0x20d0(%rsp)
movq 0x20d0(%rsp), %rax
movq 0x2120(%rsp), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
jae 0x6e66
leaq 0x10d0(%rsp), %rdi
xorl %esi, %esi
movl $0x1000, %edx           # imm = 0x1000
callq 0x4210
leaq 0x10d0(%rsp), %rdi
movq 0x20d0(%rsp), %rcx
movl $0x1000, %esi           # imm = 0x1000
leaq 0x16cee(%rip), %rdx     # 0x1da6b
movb $0x0, %al
callq 0x41b0
leaq 0x10d0(%rsp), %rdi
movb 0x21c26(%rip), %al      # 0x289b8
andb $0x1, %al
movzbl %al, %esi
callq 0x5530
leaq 0x10d0(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x20d0(%rsp), %rax
andq $0x1, %rax
cmpq $0x0, %rax
je 0x6dc8
movl 0x20d8(%rsp), %eax
movl %eax, 0x14(%rsp)
jmp 0x6dd3
movl 0x20dc(%rsp), %eax
movl %eax, 0x14(%rsp)
movq 0x18(%rsp), %rdi
movl 0x14(%rsp), %edx
movl $0xff, %esi
callq 0xfee0
movl %eax, %ecx
movq 0x20d0(%rsp), %rax
movl %ecx, 0x20e0(%rsp,%rax,4)
movq 0x20d0(%rsp), %rdx
xorl %eax, %eax
xorl %ecx, %ecx
cmpl 0x20e0(%rsp,%rdx,4), %ecx
movb %al, 0x13(%rsp)
je 0x6e40
movq 0x20d0(%rsp), %rsi
leaq 0x16c60(%rip), %rdi     # 0x1da7f
movb $0x0, %al
callq 0xf770
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x13(%rsp)
jne 0x6e35
jmp 0x6e40
movb 0x212e(%rsp), %al
movb %al, 0x13(%rsp)
movb 0x13(%rsp), %al
andb $0x1, %al
movb %al, 0x212e(%rsp)
movq 0x20d0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x20d0(%rsp)
jmp 0x6d30
leaq 0x16c1b(%rip), %rdi     # 0x1da88
movb $0x0, %al
callq 0xf770
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x12(%rsp)
jne 0x6e83
jmp 0x6e8e
movb 0x212e(%rsp), %al
movb %al, 0x12(%rsp)
movb 0x12(%rsp), %al
andb $0x1, %al
movb %al, 0x212e(%rsp)
leaq 0x16bf5(%rip), %rdi     # 0x1da97
movl $0xff, %esi
movl $0x7f00, %edx           # imm = 0x7F00
callq 0xfee0
movl %eax, %edx
xorl %eax, %eax
xorl %ecx, %ecx
cmpl %edx, %ecx
movb %al, 0x11(%rsp)
jne 0x6eca
movb 0x212e(%rsp), %al
movb %al, 0x11(%rsp)
movb 0x11(%rsp), %al
andb $0x1, %al
movb %al, 0x212e(%rsp)
testb $0x1, 0x212e(%rsp)
je 0x6eed
movl $0x1, %esi
movl %esi, %edi
callq 0x4da0
leaq 0x16b94(%rip), %rdi     # 0x1da88
movb $0x0, %al
callq 0xf770
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x10(%rsp)
jne 0x6f0a
jmp 0x6f15
movb 0x212e(%rsp), %al
movb %al, 0x10(%rsp)
movb 0x10(%rsp), %al
andb $0x1, %al
movb %al, 0x212e(%rsp)
leaq 0x1050(%rsp), %rdi
movl $0xff, %esi
movl $0x80, %edx
callq 0x4210
movq $0x0, 0x1048(%rsp)
leaq 0x16b62(%rip), %rdi     # 0x1daae
movb $0x0, %al
callq 0x4180
movl $0x10, %edi
callq 0x5510
movl %eax, %eax
movq %rax, 0x1040(%rsp)
movb $0x0, 0x103f(%rsp)
movq $0x0, 0x1030(%rsp)
cmpq $0x10, 0x1030(%rsp)
jae 0x6fc2
movq 0x1030(%rsp), %rax
movq 0x1050(%rsp,%rax,8), %rax
cmpq 0x1040(%rsp), %rax
jne 0x6faa
movb $0x1, 0x103f(%rsp)
jmp 0x6fc2
jmp 0x6fac
movq 0x1030(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x1030(%rsp)
jmp 0x6f7b
testb $0x1, 0x103f(%rsp)
je 0x6fce
jmp 0x7004
movq 0x1040(%rsp), %rcx
movq 0x1048(%rsp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, 0x1048(%rsp)
movq %rcx, 0x1050(%rsp,%rax,8)
cmpq $0x10, 0x1048(%rsp)
jne 0x7002
jmp 0x7010
jmp 0x7004
movb $0x1, %al
testb $0x1, %al
jne 0x6f53
jmp 0x7010
leaq 0x16aba(%rip), %rdi     # 0x1dad1
movb $0x0, %al
callq 0x4180
movq $0x0, 0x1028(%rsp)
cmpq $0x10, 0x1028(%rsp)
jae 0x7087
movq 0x1028(%rsp), %rax
movq 0x1050(%rsp,%rax,8), %rsi
movq 0x1028(%rsp), %rcx
leaq 0x16273(%rip), %rdx     # 0x1d2c7
leaq 0x16a8e(%rip), %rax     # 0x1dae9
cmpq $0xf, %rcx
cmovbq %rax, %rdx
leaq 0x16a78(%rip), %rdi     # 0x1dae2
movb $0x0, %al
callq 0x4180
movq 0x1028(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x1028(%rsp)
jmp 0x702a
leaq 0x16a5d(%rip), %rdi     # 0x1daeb
movb $0x0, %al
callq 0x4180
movq $0x0, 0x1020(%rsp)
cmpq $0x10, 0x1020(%rsp)
jae 0x715a
movq 0x1020(%rsp), %rax
movq 0x1050(%rsp,%rax,8), %rax
movl 0x20e0(%rsp,%rax,4), %edi
callq 0xff10
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0xf(%rsp)
jne 0x70db
jmp 0x70e6
movb 0x212e(%rsp), %al
movb %al, 0xf(%rsp)
movb 0xf(%rsp), %al
andb $0x1, %al
movb %al, 0x212e(%rsp)
leaq 0x20(%rsp), %rdi
xorl %esi, %esi
movl $0x1000, %edx           # imm = 0x1000
callq 0x4210
leaq 0x20(%rsp), %rdi
movq 0x1020(%rsp), %rax
movq 0x1050(%rsp,%rax,8), %rcx
movl $0x1000, %esi           # imm = 0x1000
leaq 0x16946(%rip), %rdx     # 0x1da6b
movb $0x0, %al
callq 0x41b0
leaq 0x20(%rsp), %rdi
movb 0x21881(%rip), %al      # 0x289b8
andb $0x1, %al
movzbl %al, %esi
callq 0x5530
movq 0x1020(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x1020(%rsp)
jmp 0x70a1
leaq 0x16927(%rip), %rdi     # 0x1da88
movb $0x0, %al
callq 0xf770
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0xe(%rsp)
jne 0x7177
jmp 0x7182
movb 0x212e(%rsp), %al
movb %al, 0xe(%rsp)
movb 0xe(%rsp), %al
andb $0x1, %al
movb %al, 0x212e(%rsp)
callq 0xf580
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0xd(%rsp)
jne 0x71a3
jmp 0x71ae
movb 0x212e(%rsp), %al
movb %al, 0xd(%rsp)
movb 0xd(%rsp), %al
andb $0x1, %al
movb %al, 0x212e(%rsp)
movb 0x212e(%rsp), %al
xorl %esi, %esi
andb $0x1, %al
movzbl %al, %edi
callq 0x4da0
andb $0x1, %al
addq $0x2238, %rsp           # imm = 0x2238
retq
nopl (%rax,%rax)