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

#if !defined(__WIN__)
    static const char* filename1 = "./logs/faildupefile.log";
    static const char* filename2 = "logs/faildupefile.log";
#else
    static const char* filename1 = "logs\\faildupefile.log";
    static const char* filename2 = "logs/faildupefile.log";
#endif

    static const char* filename3 = "logs/not-a-dupe.log";
    static const char* filename4 = "logs/also-not-a-dupe.log";

    TEST_MSG("adding log file '%s'...", filename1);

    /* should be fine; no other files added yet. */
    sirfileid fid = sir_addfile(filename1, SIRL_ALL, SIRO_DEFAULT);
    _sir_eqland(pass, 0U != fid);

    TEST_MSG("trying again to add log file '%s'...", filename1);

    /* should fail. this is the same file we already added. */
    _sir_eqland(pass, 0U == sir_addfile(filename1, SIRL_ALL, SIRO_DEFAULT));

    if (pass)
        PRINT_EXPECTED_ERROR();

    TEST_MSG("adding log file '%s'...", filename2);

    /* should also fail. this is the same file we already added, even
     * if the path strings don't match. */
    _sir_eqland(pass, 0U == sir_addfile(filename2, SIRL_ALL, SIRO_DEFAULT));

    if (pass)
        PRINT_EXPECTED_ERROR();

    TEST_MSG("adding log file '%s'...", filename3);

    /* should pass. this is a different file. */
    sirfileid fid2 = sir_addfile(filename3, SIRL_ALL, SIRO_DEFAULT);
    _sir_eqland(pass, 0U != fid2);

    /* should also pass. */
    sirfileid fid3 = sir_addfile(filename4, SIRL_ALL, SIRO_DEFAULT);
    _sir_eqland(pass, 0U != fid3);

    _sir_eqland(pass, sir_info("hello three valid files"));

    /* should now fail since we added it earlier. */
    _sir_eqland(pass, 0U == sir_addfile(filename3, SIRL_ALL, SIRO_DEFAULT));

    if (pass)
        PRINT_EXPECTED_ERROR();

    /* don't remove all of the log files in order to also test
     * cache tear-down. */
    _sir_eqland(pass, sir_remfile(fid));
    _sir_eqland(pass, sir_cleanup());

    rmfile(filename1, cl_cfg.leave_logs);
    rmfile(filename2, cl_cfg.leave_logs);
    rmfile(filename3, cl_cfg.leave_logs);
    rmfile(filename4, cl_cfg.leave_logs);

    return PRINT_RESULT_RETURN(pass);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x110, %rsp            # imm = 0x110
leaq 0x8(%rsp), %rbx
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, %ebp
leaq 0xcabc(%rip), %rsi      # 0x11ae9
leaq 0xca70(%rip), %r14      # 0x11aa4
movl $0x1, %edi
movq %r14, %rdx
xorl %eax, %eax
callq 0x3400
movq %r14, %rdi
movl $0xff, %esi
movl $0x100000, %edx         # imm = 0x100000
callq 0xa045
movl %eax, %ebx
testl %eax, %eax
setne %r12b
leaq 0xca9f(%rip), %rsi      # 0x11b03
movl $0x1, %edi
movq %r14, %rdx
xorl %eax, %eax
callq 0x3400
movq %r14, %rdi
movl $0xff, %esi
movl $0x100000, %edx         # imm = 0x100000
callq 0xa045
testl %eax, %eax
sete %r15b
andb %r12b, %r15b
andb %bpl, %r15b
cmpb $0x1, %r15b
jne 0x50a6
movl $0x1, %edi
movl $0x1, %esi
callq 0x3b04
leaq 0xca3c(%rip), %rsi      # 0x11ae9
leaq 0xc9f2(%rip), %r14      # 0x11aa6
movl $0x1, %edi
movq %r14, %rdx
xorl %eax, %eax
callq 0x3400
movq %r14, %rdi
movl $0xff, %esi
movl $0x100000, %edx         # imm = 0x100000
callq 0xa045
testl %eax, %eax
sete %al
andb %al, %r15b
cmpb $0x1, %r15b
jne 0x50f2
movl $0x1, %edi
movl $0x1, %esi
callq 0x3b04
leaq 0xc9f0(%rip), %rsi      # 0x11ae9
leaq 0xc9bc(%rip), %r14      # 0x11abc
movl $0x1, %edi
movq %r14, %rdx
xorl %eax, %eax
callq 0x3400
movq %r14, %rdi
movl $0xff, %esi
movl $0x100000, %edx         # imm = 0x100000
callq 0xa045
testl %eax, %eax
setne %al
andb %al, %r15b
leaq 0xc9a0(%rip), %rdi      # 0x11ad0
movl $0xff, %esi
movl $0x100000, %edx         # imm = 0x100000
callq 0xa045
testl %eax, %eax
setne %r12b
leaq 0xc9de(%rip), %rdi      # 0x11b2a
xorl %eax, %eax
callq 0x9b13
movl %eax, %ebp
movq %r14, %rdi
movl $0xff, %esi
movl $0x100000, %edx         # imm = 0x100000
callq 0xa045
testl %eax, %eax
sete %r14b
andb %bpl, %r14b
andb %r12b, %r14b
andb %r15b, %r14b
cmpb $0x1, %r14b
jne 0x518b
movl $0x1, %edi
movl $0x1, %esi
callq 0x3b04
movl %ebx, %edi
callq 0xa04a
andb %al, %r14b
callq 0x9a36
movl %eax, %ebx
andb %r14b, %bl
movzbl 0x16752(%rip), %esi     # 0x1b8f8
leaq 0xc8f7(%rip), %rdi      # 0x11aa4
callq 0x4053
movzbl 0x1673f(%rip), %esi     # 0x1b8f8
leaq 0xc8e6(%rip), %rdi      # 0x11aa6
callq 0x4053
movzbl 0x1672c(%rip), %esi     # 0x1b8f8
leaq 0xc8e9(%rip), %rdi      # 0x11abc
callq 0x4053
movzbl 0x16719(%rip), %esi     # 0x1b8f8
leaq 0xc8ea(%rip), %rdi      # 0x11ad0
callq 0x4053
movzbl %bl, %edi
xorl %esi, %esi
callq 0x3b04
addq $0x110, %rsp            # imm = 0x110
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq