// File: /workspace/github_c_makefile_star2_O1/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)
movw $0x0, 0x8(%rbx)
movq %rbx, %rdi
callq 0x9a31
movl %eax, %ebx
leaq 0xd25f(%rip), %rsi      # 0x11712
leaq 0xd09c(%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 0xa045
movl %eax, %ebp
testl %eax, %eax
setne %al
andb %bl, %al
movzbl %al, %ebx
movl %ebx, %edi
xorl %esi, %esi
callq 0x3b04
leaq 0xd23f(%rip), %rsi      # 0x11736
movl $0x1, %edi
movq %r14, %rdx
xorl %eax, %eax
callq 0x3400
leaq 0xcd1b(%rip), %rdi      # 0x11228
leaq 0xd05c(%rip), %rsi      # 0x11570
xorl %eax, %eax
callq 0x9a55
andb %al, %bl
movzbl %bl, %ebx
movl %ebx, %edi
xorl %esi, %esi
callq 0x3b04
leaq 0xd22c(%rip), %rsi      # 0x1175c
movl $0x1, %edi
movq %r14, %rdx
xorl %eax, %eax
callq 0x3400
movl %ebp, %edi
callq 0xa04a
andb %al, %bl
movzbl %bl, %edi
xorl %esi, %esi
callq 0x3b04
leaq 0xd220(%rip), %rsi      # 0x11779
movl $0x1, %edi
movq %r14, %rdx
xorl %eax, %eax
callq 0x3400
leaq 0xf082(%rip), %rsi      # 0x135f1
movq %r14, %rdi
callq 0x3490
movq %rax, (%rsp)
testq %rax, %rax
je 0x4629
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 0x3fc5
testq %rax, %rax
setne %bpl
leaq 0xcfb4(%rip), %r14      # 0x11570
movq %r15, %rdi
movq %r14, %rsi
callq 0x35a0
testq %rax, %rax
setne %r15b
leaq 0xd1c0(%rip), %rax      # 0x11795
leaq 0xd1da(%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 0xc677
leaq 0xd1da(%rip), %rsi      # 0x117de
leaq 0xcf4b(%rip), %rbx      # 0x11556
movl $0x1, %edi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x3400
movzbl 0x172d7(%rip), %esi     # 0x1b8f8
movq %rbx, %rdi
callq 0x4053
callq 0x9a36
andb %r15b, %al
movzbl %al, %edi
xorl %esi, %esi
callq 0x3b04
addq $0x318, %rsp            # imm = 0x318
popq %rbx
popq %r14
popq %r15
popq %rbp
retq