// File: /workspace/github_c_makefile_star2_O3/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 %rbx
subq $0x318, %rsp            # imm = 0x318
leaq 0x8(%rsp), %rbx
xorl %r15d, %r15d
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 0x9a21
movl %eax, %ebx
leaq 0xd223(%rip), %rsi      # 0x11712
leaq 0xd060(%rip), %r14      # 0x11556
movl $0x1, %edi
movq %r14, %rdx
xorl %eax, %eax
callq 0x3400
movq %r14, %rdi
movl $0x80, %esi
movl $0x10400, %edx          # imm = 0x10400
callq 0xa035
movl %eax, %ebp
testl %eax, %eax
setne %al
andb %bl, %al
movzbl %al, %ebx
movl %ebx, %edi
xorl %esi, %esi
callq 0x3b6d
leaq 0xd203(%rip), %rsi      # 0x11736
movl $0x1, %edi
movq %r14, %rdx
xorl %eax, %eax
callq 0x3400
leaq 0xccdf(%rip), %rdi      # 0x11228
leaq 0xd020(%rip), %rsi      # 0x11570
xorl %eax, %eax
callq 0x9a45
andb %al, %bl
movzbl %bl, %ebx
movl %ebx, %edi
xorl %esi, %esi
callq 0x3b6d
leaq 0xd1f0(%rip), %rsi      # 0x1175c
movl $0x1, %edi
movq %r14, %rdx
xorl %eax, %eax
callq 0x3400
movl %ebp, %edi
callq 0xa03a
andb %al, %bl
movzbl %bl, %edi
xorl %esi, %esi
callq 0x3b6d
leaq 0xd1e4(%rip), %rsi      # 0x11779
movl $0x1, %edi
movq %r14, %rdx
xorl %eax, %eax
callq 0x3400
leaq 0xf046(%rip), %rsi      # 0x135f1
movq %r14, %rdi
callq 0x3490
movq %rax, (%rsp)
testq %rax, %rax
je 0x4665
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 0x401b
testq %rax, %rax
setne %bpl
leaq 0xcf78(%rip), %r14      # 0x11570
movq %r15, %rdi
movq %r14, %rsi
callq 0x35a0
testq %rax, %rax
setne %r15b
leaq 0xd184(%rip), %rax      # 0x11795
leaq 0xd19e(%rip), %rsi      # 0x117b6
cmovneq %rax, %rsi
andb %bpl, %r15b
andb %bl, %r15b
movl $0x1, %edi
movq %r14, %rdx
xorl %eax, %eax
callq 0x3400
movq %rsp, %rdi
callq 0xc5b7
leaq 0xd19e(%rip), %rsi      # 0x117de
leaq 0xcf0f(%rip), %rbx      # 0x11556
movl $0x1, %edi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x3400
movzbl 0x1729b(%rip), %esi     # 0x1b8f8
movq %rbx, %rdi
callq 0x40a2
callq 0x9a26
andb %r15b, %al
movzbl %al, %edi
xorl %esi, %esi
callq 0x3b6d
addq $0x318, %rsp            # imm = 0x318
popq %rbx
popq %r14
popq %r15
popq %rbp
retq