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

    static const char* logfilename = MAKE_LOG_NAME("write-validate.log");
    static const char* message     = "Lorem ipsum dolor sit amet, sea ei dicit"
                                     " regione laboramus, eos cu minim putent."
                                     " Sale omnium conceptam est in, cu nam possim"
                                     " prompta eleifend. Duo purto nostrud eu."
                                     " Alia accumsan has cu, mentitum invenire"
                                     " mel an, dicta noster legendos et pro."
                                     " Solum nobis laboramus et quo, nam putant"
                                     " dolores consequuntur ex. Sit veniam eruditi"
                                     " contentiones at. Cu ponderum oporteat"
                                     " oportere mel, has et saperet accusata"
                                     " complectitur.";

    TEST_MSG("adding log file '%s' to libsir...", logfilename);
    sirfileid id = sir_addfile(logfilename, SIRL_DEBUG, SIRO_NOHDR | SIRO_NOHOST);
    _sir_eqland(pass, 0U != id);

    (void)print_test_error(pass, false);

    TEST_MSG("writing message to stdout and %s...", logfilename);

    _sir_eqland(pass, sir_debug("%s", message));

    (void)print_test_error(pass, false);

    TEST_MSG("removing %s from libsir...", logfilename);
    _sir_eqland(pass, sir_remfile(id));

    (void)print_test_error(pass, false);

    TEST_MSG("opening %s for reading...", logfilename);

    FILE* f = fopen(logfilename, "r");
    if (!f) {
        pass = false;
    } else {
        char buf[512] = {0};
        _sir_eqland(pass, 0 != sir_readline(f, buf, 512));

        bool found = NULL != strstr(buf, message);
        _sir_eqland(pass, found);

        if (found)
            TEST_MSG(SIR_GREEN("found '%s'"), message);
        else
            TEST_MSG(SIR_RED("did not find '%s'"), message);

        _sir_safefclose(&f);
        TEST_MSG("deleting %s...", logfilename);
        rmfile(logfilename, cl_cfg.leave_logs);
    }

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x310, %rsp            # imm = 0x310
leaq 0x8(%rsp), %rbx
xorl %r12d, %r12d
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 0x94a9
movl %eax, %ebx
leaq 0xc2d9(%rip), %rsi      # 0x106d2
leaq 0xc116(%rip), %r14      # 0x10516
pushq $0x1
popq %rbp
movl %ebp, %edi
movq %r14, %rdx
xorl %eax, %eax
callq 0x3410
movq %r14, %rdi
movl $0x80, %esi
movl $0x10400, %edx          # imm = 0x10400
callq 0x9a6b
movl %eax, %r15d
testl %eax, %eax
setne %al
andb %bl, %al
movzbl %al, %ebx
movl %ebx, %edi
xorl %esi, %esi
callq 0x3ac9
leaq 0xc2b8(%rip), %rsi      # 0x106f6
movl %ebp, %edi
movq %r14, %rdx
xorl %eax, %eax
callq 0x3410
leaq 0xbdd7(%rip), %rdi      # 0x10228
leaq 0xc0d8(%rip), %rsi      # 0x10530
xorl %eax, %eax
callq 0x94cd
andb %al, %bl
movzbl %bl, %ebx
movl %ebx, %edi
xorl %esi, %esi
callq 0x3ac9
leaq 0xc2a8(%rip), %rsi      # 0x1071c
movl %ebp, %edi
movq %r14, %rdx
xorl %eax, %eax
callq 0x3410
movl %r15d, %edi
callq 0x9a70
andb %al, %bl
movzbl %bl, %edi
xorl %esi, %esi
callq 0x3ac9
leaq 0xc29e(%rip), %rsi      # 0x10739
movl %ebp, %edi
movq %r14, %rdx
xorl %eax, %eax
callq 0x3410
leaq 0xe103(%rip), %rsi      # 0x125b1
movq %r14, %rdi
callq 0x34a0
movq %rax, (%rsp)
testq %rax, %rax
je 0x4565
movq %rax, %r14
leaq 0x110(%rsp), %r15
movl $0x200, %edx            # imm = 0x200
movq %r15, %rdi
xorl %esi, %esi
callq 0x31f0
movl $0x200, %edx            # imm = 0x200
movq %r14, %rdi
movq %r15, %rsi
callq 0x3f36
testq %rax, %rax
setne %bpl
leaq 0xc035(%rip), %r14      # 0x10530
movq %r15, %rdi
movq %r14, %rsi
callq 0x35b0
testq %rax, %rax
setne %r12b
leaq 0xc241(%rip), %rax      # 0x10755
leaq 0xc25b(%rip), %rsi      # 0x10776
cmovneq %rax, %rsi
andb %bpl, %r12b
andb %bl, %r12b
pushq $0x1
popq %rbx
movl %ebx, %edi
movq %r14, %rdx
xorl %eax, %eax
callq 0x3410
movq %rsp, %rdi
callq 0xbd03
leaq 0xc25b(%rip), %rsi      # 0x1079e
leaq 0xbfcc(%rip), %r14      # 0x10516
movl %ebx, %edi
movq %r14, %rdx
xorl %eax, %eax
callq 0x3410
movzbl 0x173ab(%rip), %esi     # 0x1b908
movq %r14, %rdi
callq 0x3fbf
callq 0x94ae
andb %r12b, %al
movzbl %al, %edi
xorl %esi, %esi
callq 0x3ac9
addq $0x310, %rsp            # imm = 0x310
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq