// File: /workspace/github_c_makefile_star2_O1/aremmell[P]libsir/src/sirfilecache.c
// Function: sir_fcache_pred_path
bool _sir_fcache_pred_path(const void* match, const sirfile* iter) {
    const char* path = (const char*)match;
    bool equal       = false;

    _sir_selflog("comparing '%s' == '%s'", path, iter->path);

#if !defined(__WIN__)
    /* if we're able to stat both files then we can use that information for the
     * comparison. otherwise, fall back on comparing the canonical path strings
     * returned by realpath. */
    char resolved1[SIR_MAXPATH] = {0};
    char resolved2[SIR_MAXPATH] = {0};
    struct stat st1             = {0};
    struct stat st2             = {0};

    const char* real1 = realpath(path, resolved1);
    const char* real2 = realpath(iter->path, resolved2);

    SIR_UNUSED(real1);
    SIR_UNUSED(real2);

    if ((!stat(resolved1, &st1) && !stat(resolved2, &st2)) ||
        (!stat(path, &st1) && !stat(iter->path, &st2))) {
        equal = st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino;
        _sir_selflog("returning %d for '%s' == '%s'", equal, path, iter->path);
    } else {
        _sir_selflog("falling back to canonical path string compare");
        equal = 0 == strncmp(resolved1, resolved2, SIR_MAXPATH);
        _sir_selflog("returning %d for '%s' == '%s'", equal, resolved1, resolved2);
    }

    return equal;
#else /* __WIN__ */
    /* open both files (only if they already exist) and compare their
     * filesystem info. failing that, fall back on conversion to canonical path
     * and string comparison. */
    DWORD sh_flags   = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
    DWORD open_type  = OPEN_EXISTING;
    DWORD attr_flags = FILE_ATTRIBUTE_NORMAL;
    BY_HANDLE_FILE_INFORMATION fi1 = {0};
    BY_HANDLE_FILE_INFORMATION fi2 = {0};

    HANDLE h1 = CreateFileA(path, 0, sh_flags, NULL, open_type, attr_flags, NULL);
    HANDLE h2 = CreateFileA(iter->path,0, sh_flags, NULL, open_type, attr_flags, NULL);

    if (INVALID_HANDLE_VALUE != h1 && INVALID_HANDLE_VALUE != h2 &&
        GetFileInformationByHandle(h1, &fi1) && GetFileInformationByHandle(h2, &fi2)) {
        equal = fi1.dwVolumeSerialNumber == fi2.dwVolumeSerialNumber &&
                fi1.nFileIndexLow        == fi2.nFileIndexLow        &&
                fi1.nFileIndexHigh       == fi2.nFileIndexHigh;
        _sir_selflog("returning %d for '%s' == '%s'", equal, path, iter->path);
    } else {
        _sir_selflog("falling back to canonical path string compare");
        char resolved1[SIR_MAXPATH] = {0}, resolved2[SIR_MAXPATH] = {0};
        if (GetFullPathNameA(path, SIR_MAXPATH, resolved1, NULL) &&
            GetFullPathNameA(iter->path, SIR_MAXPATH, resolved2, NULL))
            equal = 0 == StrCmpIA(resolved1, resolved2);
        _sir_selflog("returning %d for '%s' == '%s'", equal, resolved1, resolved2);
    }

    if (INVALID_HANDLE_VALUE != h1)
        CloseHandle(h1);

    if (INVALID_HANDLE_VALUE != h2)
        CloseHandle(h2);

    return equal;
#endif
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2120, %rsp           # imm = 0x2120
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x1120(%rsp), %r15
movl $0x1000, %edx           # imm = 0x1000
movq %r15, %rdi
xorl %esi, %esi
callq 0x21b0
leaq 0x120(%rsp), %r12
movl $0x1000, %edx           # imm = 0x1000
movq %r12, %rdi
xorl %esi, %esi
callq 0x21b0
leaq 0x90(%rsp), %r13
movl $0x90, %edx
movq %r13, %rdi
xorl %esi, %esi
callq 0x21b0
movq %rsp, %rdi
movl $0x90, %edx
xorl %esi, %esi
callq 0x21b0
movq %r14, %rdi
movq %r15, %rsi
callq 0x2270
movq (%rbx), %rdi
movq %r12, %rsi
callq 0x2270
movq %r15, %rdi
movq %r13, %rsi
callq 0x2250
testl %eax, %eax
jne 0x4a14
leaq 0x120(%rsp), %rdi
movq %rsp, %rsi
callq 0x2250
testl %eax, %eax
je 0x4a55
leaq 0x90(%rsp), %rsi
movq %r14, %rdi
callq 0x2250
testl %eax, %eax
jne 0x4a37
movq (%rbx), %rdi
movq %rsp, %rsi
callq 0x2250
testl %eax, %eax
je 0x4a55
leaq 0x1120(%rsp), %rdi
leaq 0x120(%rsp), %rsi
movl $0x1000, %edx           # imm = 0x1000
callq 0x20a0
testl %eax, %eax
jmp 0x4a71
movq 0x90(%rsp), %rax
xorq (%rsp), %rax
movq 0x8(%rsp), %rcx
xorq 0x98(%rsp), %rcx
orq %rax, %rcx
sete %al
addq $0x2120, %rsp           # imm = 0x2120
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq