// File: /workspace/github_cpp_makefile_star2_O3/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, %r14
movq %rdi, %r12
testq %r8, %r8
je 0x8b3d
movl $0x0, (%r14)
xorl %ebx, %ebx
testq %r12, %r12
je 0x8f47
movq 0x68(%r12), %r15
testq %r15, %r15
setne %al
testq %rsi, %rsi
setne %dil
testb %al, %dil
je 0x8b9c
testb $0x8, 0x61(%r15)
movq %rsi, -0x38(%rbp)
movl %ecx, -0x2c(%rbp)
movq %rdx, -0x48(%rbp)
jne 0x8b8c
cmpl $0x1, 0x14(%r12)
jne 0x8b8c
testl $0x300, %ecx            # imm = 0x300
setne %al
testq %rdx, %rdx
setne %cl
orb %al, %cl
je 0x8be5
movq %rsi, %rdi
callq 0x3110
cmpq $0xffff, %rax           # imm = 0xFFFF
jbe 0x8baa
movl $0x18, 0x1c(%r12)
jmp 0x8f47
movq %rax, %r13
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0x8d27
callq 0x3110
movq %rax, -0x40(%rbp)
cmpq $0xffff, %rax           # imm = 0xFFFF
movq -0x38(%rbp), %rdi
movl -0x2c(%rbp), %r11d
jbe 0x8d37
movl $0x18, 0x1c(%r12)
jmp 0x8f45
cmpq $0x0, 0x48(%r15)
je 0x8d10
movq 0x40(%r15), %rax
movq %rax, -0x50(%rbp)
movq %r14, %rbx
movl 0x10(%r12), %r14d
movq %rsi, %rdi
callq 0x3110
movq %rax, -0x48(%rbp)
testq %rbx, %rbx
je 0x8c17
movl $0x0, (%rbx)
movq %rbx, -0x58(%rbp)
testq %r14, %r14
je 0x8d02
decq %r14
movq (%r15), %rax
movq 0x20(%r15), %rcx
movq %rcx, -0x60(%rbp)
xorl %esi, %esi
movq %r14, %rdi
subq %rsi, %rdi
sarq %rdi
addq %rsi, %rdi
movl %edi, %r8d
movq -0x50(%rbp), %rcx
movl (%rcx,%r8,4), %r8d
movq -0x60(%rbp), %rcx
movl (%rcx,%r8,4), %r9d
leaq (%rax,%r9), %r11
leaq 0x2e(%rax,%r9), %r10
movzwl -0x12(%r10), %r15d
movl %r15d, %r9d
movq -0x48(%rbp), %rcx
subl %ecx, %r9d
cmovael %ecx, %r15d
addq %r15, %r11
addq $0x2e, %r11
testl %r15d, %r15d
je 0x8cd4
movq %r12, %rcx
movq -0x38(%rbp), %r15
movzbl (%r10), %r13d
leal -0x41(%r13), %r12d
leal 0x20(%r13), %ebx
cmpb $0x1a, %r12b
movzbl %bl, %r12d
cmovael %r13d, %r12d
movzbl (%r15), %ebx
leal -0x41(%rbx), %r13d
leal 0x20(%rbx), %edx
cmpb $0x1a, %r13b
movzbl %dl, %r13d
cmovael %ebx, %r13d
cmpb %r13b, %r12b
jne 0x8cc4
incq %r10
incq %r15
cmpq %r11, %r10
jb 0x8c82
movl %r12d, %r13d
movzbl %r12b, %r15d
movzbl %r13b, %edx
subl %edx, %r15d
movq %rcx, %r12
jmp 0x8cd7
xorl %r15d, %r15d
cmpq %r11, %r10
cmovel %r9d, %r15d
testl %r15d, %r15d
je 0x8f58
leaq 0x1(%rdi), %rdx
decq %rdi
testl %r15d, %r15d
cmovnsq %rdi, %r14
cmovsq %rdx, %rsi
cmpq %r14, %rsi
jle 0x8c34
movl $0x1c, 0x1c(%r12)
jmp 0x8f45
movq %rsi, %rdi
callq 0x3110
cmpq $0x10000, %rax          # imm = 0x10000
jae 0x8b9c
movq %rax, %r13
movq $0x0, -0x40(%rbp)
movq -0x38(%rbp), %rdi
movl -0x2c(%rbp), %r11d
movq %r14, -0x58(%rbp)
movq %r12, -0x68(%rbp)
movl 0x10(%r12), %eax
movq %rax, -0x60(%rbp)
testq %rax, %rax
je 0x8f3a
movq (%r15), %rax
movq 0x20(%r15), %rcx
movq %rcx, -0x80(%rbp)
leaq 0x2e(%rax), %rcx
movq %rcx, -0x70(%rbp)
movq %rax, -0x50(%rbp)
addq $0x2d, %rax
movq %rax, -0x78(%rbp)
xorl %r15d, %r15d
movq -0x80(%rbp), %rax
movl (%rax,%r15,4), %ebx
movq -0x50(%rbp), %rax
movzwl 0x1c(%rax,%rbx), %r12d
cmpq %r12, %r13
ja 0x8f2d
movq -0x50(%rbp), %rax
leaq (%rax,%rbx), %r14
addq $0x2e, %r14
cmpq $0x0, -0x40(%rbp)
je 0x8e4e
movq -0x50(%rbp), %rax
leaq (%rax,%rbx), %rcx
movzwl 0x20(%rcx), %eax
cmpq %rax, -0x40(%rbp)
jne 0x8f2d
movzwl 0x1e(%rcx), %esi
btl $0x8, %r11d
jb 0x8e26
addq %rbx, %rsi
movq -0x70(%rbp), %rcx
addq %r12, %rcx
addq %rcx, %rsi
xorl %ecx, %ecx
movq -0x48(%rbp), %rdx
movsbl (%rdx,%rcx), %edx
movl %edx, %r10d
movl $0xff, %r9d
andl %r9d, %r10d
leal -0x41(%rdx), %r8d
addl $0x20, %r10d
cmpb $0x1a, %r8b
cmovael %edx, %r10d
movsbl (%rsi,%rcx), %edx
movl %edx, %r8d
andl %r9d, %r8d
leal -0x41(%rdx), %r9d
addl $0x20, %r8d
cmpb $0x1a, %r9b
cmovael %edx, %r8d
cmpl %r8d, %r10d
jne 0x8f2d
incq %rcx
cmpq %rcx, %rax
jne 0x8dd5
jmp 0x8e4e
addq %r14, %rsi
addq %r12, %rsi
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rdx
callq 0x3270
movl -0x2c(%rbp), %r11d
movq -0x38(%rbp), %rdi
movl $0x4, %ecx
testl %eax, %eax
jne 0x8f28
btl $0x9, %r11d
jae 0x8e95
testw %r12w, %r12w
je 0x8e95
addq -0x78(%rbp), %rbx
movq %r12, %rax
movabsq $0x200000000801, %rdx   # imm = 0x200000000801
movzbl (%rbx,%rax), %ecx
addl $-0x2f, %ecx
cmpl $0x2d, %ecx
ja 0x8e7e
btq %rcx, %rdx
jb 0x8e8d
decq %rax
leaq 0x1(%rax), %rcx
cmpq $0x1, %rcx
jg 0x8e6c
xorl %eax, %eax
movl %eax, %ecx
addq %rcx, %r14
subl %eax, %r12d
movl %r12d, %eax
cmpq %rax, %r13
jne 0x8f2d
btl $0x8, %r11d
jb 0x8ef3
testl %r12d, %r12d
je 0x8eef
xorl %eax, %eax
movsbl (%rdi,%rax), %ecx
movl %ecx, %edx
movl $0xff, %r8d
andl %r8d, %edx
leal -0x41(%rcx), %esi
addl $0x20, %edx
cmpb $0x1a, %sil
cmovael %ecx, %edx
movsbl (%r14,%rax), %ecx
movl %ecx, %esi
andl %r8d, %esi
leal -0x41(%rcx), %r8d
addl $0x20, %esi
cmpb $0x1a, %r8b
cmovael %ecx, %esi
cmpl %esi, %edx
jne 0x8f2d
incq %rax
cmpq %rax, %r13
jne 0x8eaf
xorl %eax, %eax
jmp 0x8f03
movq %r14, %rsi
movq %r13, %rdx
callq 0x3270
testl %eax, %eax
setne %al
movl %eax, %ecx
xorb $0x1, %cl
movzbl %cl, %ecx
cmpq $0x0, -0x58(%rbp)
je 0x8f20
testb %al, %al
movq -0x38(%rbp), %rdi
movl -0x2c(%rbp), %r11d
jne 0x8f28
jmp 0x8f6b
movq -0x38(%rbp), %rdi
movl -0x2c(%rbp), %r11d
testb $0x3, %cl
jne 0x8f72
incq %r15
cmpq -0x60(%rbp), %r15
jne 0x8d73
movq -0x68(%rbp), %rax
movl $0x1c, 0x1c(%rax)
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %ebx
movq -0x58(%rbp), %rax
testq %rax, %rax
je 0x8f47
movl %r8d, (%rax)
jmp 0x8f47
movq -0x58(%rbp), %rax
movl %r15d, (%rax)
movl $0x1, %ebx
jmp 0x8f47