// File: /workspace/github_cpp_makefile_star2_O1/jimmiebergmann[P]fbx-file/miniz.c
// Function: mz_zip_reader_locate_file_v2
mz_bool mz_zip_reader_locate_file_v2(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags, mz_uint32 *pIndex)
{
    mz_uint file_index;
    size_t name_len, comment_len;

    if (pIndex)
        *pIndex = 0;

    if ((!pZip) || (!pZip->m_pState) || (!pName))
        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);

    /* See if we can use a binary search */
    if (((pZip->m_pState->m_init_flags & MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY) == 0) &&
        (pZip->m_zip_mode == MZ_ZIP_MODE_READING) &&
        ((flags & (MZ_ZIP_FLAG_IGNORE_PATH | MZ_ZIP_FLAG_CASE_SENSITIVE)) == 0) && (!pComment) && (pZip->m_pState->m_sorted_central_dir_offsets.m_size))
    {
        return mz_zip_locate_file_binary_search(pZip, pName, pIndex);
    }

    /* Locate the entry by scanning the entire central directory */
    name_len = strlen(pName);
    if (name_len > MZ_UINT16_MAX)
        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);

    comment_len = pComment ? strlen(pComment) : 0;
    if (comment_len > MZ_UINT16_MAX)
        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);

    for (file_index = 0; file_index < pZip->m_total_files; file_index++)
    {
        const mz_uint8 *pHeader = &MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32, file_index));
        mz_uint filename_len = MZ_READ_LE16(pHeader + MZ_ZIP_CDH_FILENAME_LEN_OFS);
        const char *pFilename = (const char *)pHeader + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE;
        if (filename_len < name_len)
            continue;
        if (comment_len)
        {
            mz_uint file_extra_len = MZ_READ_LE16(pHeader + MZ_ZIP_CDH_EXTRA_LEN_OFS), file_comment_len = MZ_READ_LE16(pHeader + MZ_ZIP_CDH_COMMENT_LEN_OFS);
            const char *pFile_comment = pFilename + filename_len + file_extra_len;
            if ((file_comment_len != comment_len) || (!mz_zip_string_equal(pComment, pFile_comment, file_comment_len, flags)))
                continue;
        }
        if ((flags & MZ_ZIP_FLAG_IGNORE_PATH) && (filename_len))
        {
            int ofs = filename_len - 1;
            do
            {
                if ((pFilename[ofs] == '/') || (pFilename[ofs] == '\\') || (pFilename[ofs] == ':'))
                    break;
            } while (--ofs >= 0);
            ofs++;
            pFilename += ofs;
            filename_len -= ofs;
        }
        if ((filename_len == name_len) && (mz_zip_string_equal(pName, pFilename, filename_len, flags)))
        {
            if (pIndex)
                *pIndex = file_index;
            return MZ_TRUE;
        }
    }

    return mz_zip_set_error(pZip, MZ_ZIP_FILE_NOT_FOUND);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r8, %rbx
movq %rdx, %r12
movq %rsi, %r15
testq %r8, %r8
je 0x8af8
movl $0x0, (%rbx)
xorl %eax, %eax
testq %rdi, %rdi
je 0x8f63
movq 0x68(%rdi), %r14
testq %r14, %r14
setne %sil
testq %r15, %r15
setne %dl
testb %sil, %dl
je 0x8c86
testb $0x8, 0x61(%r14)
movq %rdi, -0x30(%rbp)
jne 0x8c99
cmpl $0x1, 0x14(%rdi)
jne 0x8c99
testl $0x300, %ecx            # imm = 0x300
setne %al
testq %r12, %r12
setne %dl
orb %al, %dl
jne 0x8c99
cmpq $0x0, 0x48(%r14)
je 0x8c99
movq 0x40(%r14), %rax
movq %rax, -0x38(%rbp)
movl 0x10(%rdi), %r13d
movq %r15, %rdi
callq 0x3110
movq %rax, -0x40(%rbp)
testq %rbx, %rbx
je 0x8b7b
movl $0x0, (%rbx)
movl $0x1c, %edx
testq %r13, %r13
je 0x8cb1
decq %r13
xorl %edx, %edx
movq -0x30(%rbp), %rdi
movq %r13, %rcx
subq %rdx, %rcx
jl 0x8f59
sarq %rcx
addq %rdx, %rcx
movl %ecx, %esi
movq -0x38(%rbp), %rax
movl (%rax,%rsi,4), %esi
movq (%r14), %rdi
movq 0x20(%r14), %r8
movl (%r8,%rsi,4), %r8d
leaq (%rdi,%r8), %r9
leaq 0x2e(%rdi,%r8), %r8
movzwl -0x12(%r8), %r10d
movl %r10d, %edi
movq -0x40(%rbp), %rax
subl %eax, %edi
cmovael %eax, %r10d
addq %r10, %r9
addq $0x2e, %r9
testl %r10d, %r10d
je 0x8c3f
movq %r13, -0x50(%rbp)
movq %rbx, %rax
movq %r15, %r12
movq %r15, %r10
movzbl (%r8), %ebx
leal -0x41(%rbx), %r11d
leal 0x20(%rbx), %r13d
cmpb $0x1a, %r11b
movzbl %r13b, %r11d
cmovael %ebx, %r11d
movzbl (%r10), %r13d
leal -0x41(%r13), %ebx
leal 0x20(%r13), %r15d
cmpb $0x1a, %bl
movzbl %r15b, %ebx
cmovael %r13d, %ebx
cmpb %bl, %r11b
jne 0x8c2b
incq %r8
incq %r10
cmpq %r9, %r8
jb 0x8bec
movzbl %r11b, %r10d
movzbl %bl, %r11d
subl %r11d, %r10d
movq %rax, %rbx
movq -0x50(%rbp), %r13
jmp 0x8c45
movq %r15, %r12
xorl %r10d, %r10d
cmpq %r9, %r8
cmovel %edi, %r10d
testl %r10d, %r10d
je 0x8c65
leaq 0x1(%rcx), %rsi
decq %rcx
testl %r10d, %r10d
cmovnsq %rcx, %r13
cmovsq %rsi, %rdx
jmp 0x8c6c
testq %rbx, %rbx
je 0x8c6c
movl %esi, (%rbx)
movq %r12, %r15
movl $0x1, %eax
testl %r10d, %r10d
movq -0x30(%rbp), %rdi
jne 0x8b92
jmp 0x8f63
movl $0x18, %edx
testq %rdi, %rdi
jne 0x8f5e
jmp 0x8f63
movl %ecx, -0x38(%rbp)
movq %r15, %rdi
callq 0x3110
movl $0x18, %edx
cmpq $0xffff, %rax           # imm = 0xFFFF
jbe 0x8cba
movq -0x30(%rbp), %rdi
jmp 0x8f5e
movq %rax, -0x40(%rbp)
testq %r12, %r12
je 0x8cd5
movq %r12, %rdi
callq 0x3110
movl $0x18, %edx
movq %rax, %r8
jmp 0x8cd8
xorl %r8d, %r8d
movq -0x30(%rbp), %rdi
movl -0x38(%rbp), %r11d
cmpq $0xffff, %r8            # imm = 0xFFFF
ja 0x8f5e
movl $0x1c, %edx
cmpl $0x0, 0x10(%rdi)
je 0x8f5e
movq %r12, -0x50(%rbp)
movq %r15, -0x70(%rbp)
movq %rbx, -0x48(%rbp)
movq (%r14), %r9
movq 0x20(%r14), %r10
leaq 0x2e(%r9), %rax
movq %rax, -0x78(%rbp)
leaq 0x2d(%r9), %rax
movq %rax, -0x80(%rbp)
xorl %r14d, %r14d
movl $0xff, %r15d
movq -0x40(%rbp), %rsi
movq %r8, -0x68(%rbp)
movq %r9, -0x60(%rbp)
movq %r10, -0x58(%rbp)
movl (%r10,%r14,4), %ebx
movzwl 0x1c(%r9,%rbx), %r13d
movl $0x4, %eax
cmpq %r13, %rsi
ja 0x8f46
leaq (%r9,%rbx), %r12
addq $0x2e, %r12
testq %r8, %r8
je 0x8e2c
leaq (%r9,%rbx), %rax
movzwl 0x20(%rax), %edx
cmpq %rdx, %r8
jne 0x8de2
movzwl 0x1e(%rax), %esi
btl $0x8, %r11d
jb 0x8deb
testq %rdx, %rdx
je 0x8e09
decq %rdx
addq %rbx, %rsi
movq -0x78(%rbp), %rax
addq %r13, %rax
addq %rax, %rsi
xorl %eax, %eax
movq -0x50(%rbp), %rcx
movsbl (%rcx,%rax), %ecx
movl %ecx, %r10d
andl %r15d, %r10d
leal -0x41(%rcx), %r8d
addl $0x20, %r10d
cmpb $0x1a, %r8b
cmovael %ecx, %r10d
movsbl (%rsi,%rax), %ecx
movl %ecx, %r8d
andl %r15d, %r8d
leal -0x41(%rcx), %r9d
addl $0x20, %r8d
cmpb $0x1a, %r9b
cmovael %ecx, %r8d
cmpl %r8d, %r10d
setne %cl
jne 0x8e0b
leaq 0x1(%rax), %r8
cmpq %rax, %rdx
movq %r8, %rax
jne 0x8d94
jmp 0x8e0b
movl $0x4, %eax
xorl %ecx, %ecx
jmp 0x8e24
addq %r12, %rsi
addq %r13, %rsi
movq -0x50(%rbp), %rdi
callq 0x3270
movl -0x38(%rbp), %r11d
movq -0x30(%rbp), %rdi
testl %eax, %eax
setne %cl
jmp 0x8e0b
xorl %ecx, %ecx
movzbl %cl, %eax
xorb $0x1, %cl
shll $0x2, %eax
movq -0x40(%rbp), %rsi
movq -0x68(%rbp), %r8
movq -0x60(%rbp), %r9
movq -0x58(%rbp), %r10
testb %cl, %cl
je 0x8f46
btl $0x9, %r11d
jae 0x8e73
testw %r13w, %r13w
je 0x8e73
addq -0x80(%rbp), %rbx
movq %r13, %rax
movabsq $0x200000000801, %rdx   # imm = 0x200000000801
movzbl (%rbx,%rax), %ecx
addl $-0x2f, %ecx
cmpl $0x2d, %ecx
ja 0x8e5c
btq %rcx, %rdx
jb 0x8e6b
decq %rax
leaq 0x1(%rax), %rcx
cmpq $0x1, %rcx
jg 0x8e4a
xorl %eax, %eax
movl %eax, %ecx
addq %rcx, %r12
subl %eax, %r13d
movl %r13d, %edx
xorl %eax, %eax
cmpq %rdx, %rsi
jne 0x8f46
btl $0x8, %r11d
jb 0x8ee3
testq %rdx, %rdx
movq -0x70(%rbp), %r11
je 0x8efa
decq %rdx
xorl %eax, %eax
movq -0x48(%rbp), %r10
movsbl (%r11,%rax), %ecx
movl %ecx, %esi
andl %r15d, %esi
leal -0x41(%rcx), %r8d
addl $0x20, %esi
cmpb $0x1a, %r8b
cmovael %ecx, %esi
movsbl (%r12,%rax), %ecx
movl %ecx, %r9d
andl %r15d, %r9d
leal -0x41(%rcx), %r8d
addl $0x20, %r9d
cmpb $0x1a, %r8b
cmovael %ecx, %r9d
cmpl %r9d, %esi
setne %cl
jne 0x8f00
leaq 0x1(%rax), %rsi
cmpq %rax, %rdx
movq %rsi, %rax
jne 0x8e9a
jmp 0x8f00
movq -0x70(%rbp), %rdi
movq %r12, %rsi
callq 0x3270
movq -0x30(%rbp), %rdi
testl %eax, %eax
setne %cl
jmp 0x8efc
xorl %ecx, %ecx
movq -0x48(%rbp), %r10
movl %ecx, %eax
xorb $0x1, %al
movzbl %al, %eax
testq %r10, %r10
je 0x8f32
testb %cl, %cl
movl -0x38(%rbp), %r11d
movq -0x40(%rbp), %rsi
movq -0x68(%rbp), %r8
movq -0x60(%rbp), %r9
movq -0x58(%rbp), %r10
jne 0x8f46
movq -0x48(%rbp), %rax
movl %r14d, (%rax)
movl $0x1, %eax
jmp 0x8f46
movl -0x38(%rbp), %r11d
movq -0x40(%rbp), %rsi
movq -0x68(%rbp), %r8
movq -0x60(%rbp), %r9
movq -0x58(%rbp), %r10
testb $0x3, %al
jne 0x8f72
incq %r14
movl 0x10(%rdi), %eax
cmpq %rax, %r14
jb 0x8d38
movl $0x1c, %edx
movl %edx, 0x1c(%rdi)
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %eax
jmp 0x8f63