// File: 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
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x90(%rbp)
movq %rsi, -0x98(%rbp)
movq %rdx, -0xa0(%rbp)
movl %ecx, -0xa4(%rbp)
movq %r8, -0xb0(%rbp)
cmpq $0x0, -0xb0(%rbp)
je 0xdb04
movq -0xb0(%rbp), %rax
movl $0x0, (%rax)
cmpq $0x0, -0x90(%rbp)
je 0xdb26
movq -0x90(%rbp), %rax
cmpq $0x0, 0x68(%rax)
je 0xdb26
cmpq $0x0, -0x98(%rbp)
jne 0xdb58
movq -0x90(%rbp), %rax
movq %rax, -0x50(%rbp)
movl $0x18, -0x54(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0xdb49
movl -0x54(%rbp), %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x1c(%rax)
movl $0x0, -0x88(%rbp)
jmp 0xe15b
movq -0x90(%rbp), %rax
movq 0x68(%rax), %rax
movl 0x60(%rax), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
jne 0xdbce
movq -0x90(%rbp), %rax
cmpl $0x1, 0x14(%rax)
jne 0xdbce
movl -0xa4(%rbp), %eax
andl $0x300, %eax            # imm = 0x300
cmpl $0x0, %eax
jne 0xdbce
cmpq $0x0, -0xa0(%rbp)
jne 0xdbce
movq -0x90(%rbp), %rax
movq 0x68(%rax), %rax
cmpq $0x0, 0x48(%rax)
je 0xdbce
movq -0x90(%rbp), %rdi
movq -0x98(%rbp), %rsi
movq -0xb0(%rbp), %rdx
callq 0xe170
movl %eax, -0x88(%rbp)
jmp 0xe15b
movq -0x98(%rbp), %rdi
callq 0x3140
movq %rax, -0xc0(%rbp)
cmpq $0xffff, -0xc0(%rbp) # imm = 0xFFFF
jbe 0xdc20
movq -0x90(%rbp), %rax
movq %rax, -0x60(%rbp)
movl $0x18, -0x64(%rbp)
cmpq $0x0, -0x60(%rbp)
je 0xdc11
movl -0x64(%rbp), %ecx
movq -0x60(%rbp), %rax
movl %ecx, 0x1c(%rax)
movl $0x0, -0x88(%rbp)
jmp 0xe15b
cmpq $0x0, -0xa0(%rbp)
je 0xdc3f
movq -0xa0(%rbp), %rdi
callq 0x3140
movq %rax, -0x100(%rbp)
jmp 0xdc4a
xorl %eax, %eax
movq %rax, -0x100(%rbp)
jmp 0xdc4a
movq -0x100(%rbp), %rax
movq %rax, -0xc8(%rbp)
cmpq $0xffff, -0xc8(%rbp) # imm = 0xFFFF
jbe 0xdc97
movq -0x90(%rbp), %rax
movq %rax, -0x70(%rbp)
movl $0x18, -0x74(%rbp)
cmpq $0x0, -0x70(%rbp)
je 0xdc88
movl -0x74(%rbp), %ecx
movq -0x70(%rbp), %rax
movl %ecx, 0x1c(%rax)
movl $0x0, -0x88(%rbp)
jmp 0xe15b
movl $0x0, -0xb4(%rbp)
movl -0xb4(%rbp), %eax
movq -0x90(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jae 0xe128
movq -0x90(%rbp), %rax
movq 0x68(%rax), %rax
movq (%rax), %rax
movq -0x90(%rbp), %rcx
movq 0x68(%rcx), %rcx
movq 0x20(%rcx), %rcx
movl -0xb4(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
addq %rcx, %rax
movq %rax, -0xd0(%rbp)
movq -0xd0(%rbp), %rax
movzwl 0x1c(%rax), %eax
movl %eax, -0xd4(%rbp)
movq -0xd0(%rbp), %rax
addq $0x2e, %rax
movq %rax, -0xe0(%rbp)
movl -0xd4(%rbp), %eax
cmpq -0xc0(%rbp), %rax
jae 0xdd1e
jmp 0xe114
cmpq $0x0, -0xc8(%rbp)
je 0xdecc
movq -0xd0(%rbp), %rax
movzwl 0x1e(%rax), %eax
movl %eax, -0xe4(%rbp)
movq -0xd0(%rbp), %rax
movzwl 0x20(%rax), %eax
movl %eax, -0xe8(%rbp)
movq -0xe0(%rbp), %rax
movl -0xd4(%rbp), %ecx
addq %rcx, %rax
movl -0xe4(%rbp), %ecx
addq %rcx, %rax
movq %rax, -0xf0(%rbp)
movl -0xe8(%rbp), %eax
cmpq -0xc8(%rbp), %rax
jne 0xdec5
movq -0xa0(%rbp), %rsi
movq -0xf0(%rbp), %rdx
movl -0xe8(%rbp), %ecx
movl -0xa4(%rbp), %eax
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0xddde
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %eax
movl %eax, %edx
callq 0x3150
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4(%rbp)
jmp 0xdebf
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jae 0xdeb8
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x41, %eax
jl 0xde2a
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x5a, %eax
jg 0xde2a
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
movsbl (%rax,%rcx), %eax
subl $0x41, %eax
addl $0x61, %eax
movl %eax, -0x104(%rbp)
jmp 0xde3b
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
movsbl (%rax,%rcx), %eax
movl %eax, -0x104(%rbp)
movl -0x104(%rbp), %eax
movl %eax, -0x108(%rbp)
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x41, %eax
jl 0xde80
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x5a, %eax
jg 0xde80
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
movsbl (%rax,%rcx), %eax
subl $0x41, %eax
addl $0x61, %eax
movl %eax, -0x10c(%rbp)
jmp 0xde91
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
movsbl (%rax,%rcx), %eax
movl %eax, -0x10c(%rbp)
movl -0x108(%rbp), %eax
movl -0x10c(%rbp), %ecx
cmpl %ecx, %eax
je 0xdeaa
movl $0x0, -0x4(%rbp)
jmp 0xdebf
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xdde5
movl $0x1, -0x4(%rbp)
cmpl $0x0, -0x4(%rbp)
jne 0xdeca
jmp 0xe114
jmp 0xdecc
movl -0xa4(%rbp), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
je 0xdf96
cmpl $0x0, -0xd4(%rbp)
je 0xdf96
movl -0xd4(%rbp), %eax
subl $0x1, %eax
movl %eax, -0xf4(%rbp)
movq -0xe0(%rbp), %rax
movslq -0xf4(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2f, %eax
je 0xdf41
movq -0xe0(%rbp), %rax
movslq -0xf4(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x5c, %eax
je 0xdf41
movq -0xe0(%rbp), %rax
movslq -0xf4(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x3a, %eax
jne 0xdf43
jmp 0xdf59
jmp 0xdf45
movl -0xf4(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0xf4(%rbp)
cmpl $0x0, %eax
jge 0xdefc
movl -0xf4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf4(%rbp)
movl -0xf4(%rbp), %ecx
movq -0xe0(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0xe0(%rbp)
movl -0xf4(%rbp), %ecx
movl -0xd4(%rbp), %eax
subl %ecx, %eax
movl %eax, -0xd4(%rbp)
movl -0xd4(%rbp), %eax
cmpq -0xc0(%rbp), %rax
jne 0xe112
movq -0x98(%rbp), %rsi
movq -0xe0(%rbp), %rdx
movl -0xd4(%rbp), %ecx
movl -0xa4(%rbp), %eax
movq %rsi, -0x30(%rbp)
movq %rdx, -0x38(%rbp)
movl %ecx, -0x3c(%rbp)
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0xe006
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl -0x3c(%rbp), %eax
movl %eax, %edx
callq 0x3150
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x28(%rbp)
jmp 0xe0e7
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jae 0xe0e0
movq -0x30(%rbp), %rax
movl -0x44(%rbp), %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x41, %eax
jl 0xe052
movq -0x30(%rbp), %rax
movl -0x44(%rbp), %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x5a, %eax
jg 0xe052
movq -0x30(%rbp), %rax
movl -0x44(%rbp), %ecx
movsbl (%rax,%rcx), %eax
subl $0x41, %eax
addl $0x61, %eax
movl %eax, -0x110(%rbp)
jmp 0xe063
movq -0x30(%rbp), %rax
movl -0x44(%rbp), %ecx
movsbl (%rax,%rcx), %eax
movl %eax, -0x110(%rbp)
movl -0x110(%rbp), %eax
movl %eax, -0x114(%rbp)
movq -0x38(%rbp), %rax
movl -0x44(%rbp), %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x41, %eax
jl 0xe0a8
movq -0x38(%rbp), %rax
movl -0x44(%rbp), %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x5a, %eax
jg 0xe0a8
movq -0x38(%rbp), %rax
movl -0x44(%rbp), %ecx
movsbl (%rax,%rcx), %eax
subl $0x41, %eax
addl $0x61, %eax
movl %eax, -0x118(%rbp)
jmp 0xe0b9
movq -0x38(%rbp), %rax
movl -0x44(%rbp), %ecx
movsbl (%rax,%rcx), %eax
movl %eax, -0x118(%rbp)
movl -0x114(%rbp), %eax
movl -0x118(%rbp), %ecx
cmpl %ecx, %eax
je 0xe0d2
movl $0x0, -0x28(%rbp)
jmp 0xe0e7
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0xe00d
movl $0x1, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0xe112
cmpq $0x0, -0xb0(%rbp)
je 0xe106
movl -0xb4(%rbp), %ecx
movq -0xb0(%rbp), %rax
movl %ecx, (%rax)
movl $0x1, -0x88(%rbp)
jmp 0xe15b
jmp 0xe114
movl -0xb4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb4(%rbp)
jmp 0xdca1
movq -0x90(%rbp), %rax
movq %rax, -0x80(%rbp)
movl $0x1c, -0x84(%rbp)
cmpq $0x0, -0x80(%rbp)
je 0xe151
movl -0x84(%rbp), %ecx
movq -0x80(%rbp), %rax
movl %ecx, 0x1c(%rax)
movl $0x0, -0x88(%rbp)
movl -0x88(%rbp), %eax
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
nopw (%rax,%rax)