// File: /workspace/github_c_makefile_star2_O3/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)
movq %rbx, %rdi
callq 0x9a21
movl %eax, %ebp
leaq 0xcaae(%rip), %rsi      # 0x11ae9
leaq 0xca62(%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 0xa035
movl %eax, %ebx
testl %eax, %eax
setne %r12b
leaq 0xca91(%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 0xa035
testl %eax, %eax
sete %r15b
andb %r12b, %r15b
andb %bpl, %r15b
cmpb $0x1, %r15b
jne 0x50b4
movl $0x1, %edi
movl $0x1, %esi
callq 0x3b6d
leaq 0xca2e(%rip), %rsi      # 0x11ae9
leaq 0xc9e4(%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 0xa035
testl %eax, %eax
sete %al
andb %al, %r15b
cmpb $0x1, %r15b
jne 0x5100
movl $0x1, %edi
movl $0x1, %esi
callq 0x3b6d
leaq 0xc9e2(%rip), %rsi      # 0x11ae9
leaq 0xc9ae(%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 0xa035
testl %eax, %eax
setne %al
andb %al, %r15b
leaq 0xc992(%rip), %rdi      # 0x11ad0
movl $0xff, %esi
movl $0x100000, %edx         # imm = 0x100000
callq 0xa035
testl %eax, %eax
setne %r12b
leaq 0xc9d0(%rip), %rdi      # 0x11b2a
xorl %eax, %eax
callq 0x9b03
movl %eax, %ebp
movq %r14, %rdi
movl $0xff, %esi
movl $0x100000, %edx         # imm = 0x100000
callq 0xa035
testl %eax, %eax
sete %r14b
andb %bpl, %r14b
andb %r12b, %r14b
andb %r15b, %r14b
cmpb $0x1, %r14b
jne 0x5199
movl $0x1, %edi
movl $0x1, %esi
callq 0x3b6d
movl %ebx, %edi
callq 0xa03a
andb %al, %r14b
callq 0x9a26
movl %eax, %ebx
andb %r14b, %bl
movzbl 0x16744(%rip), %esi     # 0x1b8f8
leaq 0xc8e9(%rip), %rdi      # 0x11aa4
callq 0x40a2
movzbl 0x16731(%rip), %esi     # 0x1b8f8
leaq 0xc8d8(%rip), %rdi      # 0x11aa6
callq 0x40a2
movzbl 0x1671e(%rip), %esi     # 0x1b8f8
leaq 0xc8db(%rip), %rdi      # 0x11abc
callq 0x40a2
movzbl 0x1670b(%rip), %esi     # 0x1b8f8
leaq 0xc8dc(%rip), %rdi      # 0x11ad0
callq 0x40a2
movzbl %bl, %edi
xorl %esi, %esi
callq 0x3b6d
addq $0x110, %rsp            # imm = 0x110
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq