// File: /workspace/github_cpp_makefile_star2_O2/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 $0x48, %rsp
movq %r8, %rbx
movq %rdx, %r14
movq %rsi, -0x48(%rbp)
movq %rdi, %r15
testq %r8, %r8
je 0x8ad5
andl $0x0, (%rbx)
xorl %r12d, %r12d
testq %r15, %r15
je 0x8e94
movq 0x68(%r15), %rdx
testq %rdx, %rdx
setne %al
cmpq $0x0, -0x48(%rbp)
setne %sil
testb %al, %sil
je 0x8c5d
testb $0x8, 0x61(%rdx)
movq %rdx, -0x38(%rbp)
jne 0x8c45
cmpl $0x1, 0x14(%r15)
jne 0x8c45
testw $0x300, %cx             # imm = 0x300
setne %al
testq %r14, %r14
setne %sil
orb %al, %sil
jne 0x8c45
cmpq $0x0, 0x48(%rdx)
je 0x8c45
movq 0x40(%rdx), %rax
movq %rax, -0x40(%rbp)
movl 0x10(%r15), %r14d
movq -0x48(%rbp), %rdi
callq 0x3100
movq %rax, -0x60(%rbp)
testq %rbx, %rbx
je 0x8b5a
andl $0x0, (%rbx)
testq %r14, %r14
movq -0x38(%rbp), %rdi
je 0x8ea6
decq %r14
xorl %ecx, %ecx
movq %rbx, -0x50(%rbp)
movq %r15, -0x68(%rbp)
movq %r14, %rdx
subq %rcx, %rdx
jl 0x8ea6
sarq %rdx
addq %rcx, %rdx
movl %edx, %esi
movq -0x40(%rbp), %rax
movl (%rax,%rsi,4), %eax
movq (%rdi), %r9
movq 0x20(%rdi), %rdi
movl (%rdi,%rax,4), %r11d
leaq 0x2e(%r9,%r11), %r10
movzwl -0x12(%r10), %r8d
movl %r8d, %edi
movq -0x60(%rbp), %rsi
subl %esi, %edi
cmovael %esi, %r8d
addq %r11, %r9
leaq (%r8,%r9), %r11
addq $0x2e, %r11
xorl %r9d, %r9d
xorl %r15d, %r15d
leaq (%r10,%r9), %rbx
movl %r15d, %r13d
cmpq %r11, %rbx
jae 0x8c0b
movzbl (%rbx), %ebx
leal -0x41(%rbx), %r15d
leal 0x20(%rbx), %r13d
cmpb $0x1a, %r15b
movzbl %r13b, %r15d
cmovael %ebx, %r15d
movq -0x48(%rbp), %rsi
movzbl (%rsi,%r9), %ebx
leal -0x41(%rbx), %r13d
leal 0x20(%rbx), %esi
cmpb $0x1a, %r13b
movzbl %sil, %r13d
cmovael %ebx, %r13d
cmpb %r13b, %r15b
jne 0x8c0b
incq %r9
jmp 0x8bc2
movzbl %r15b, %r10d
movzbl %r13b, %esi
subl %esi, %r10d
cmpq %r9, %r8
cmovel %edi, %r10d
testl %r10d, %r10d
je 0x8ebd
leaq 0x1(%rdx), %rax
decq %rdx
testl %r10d, %r10d
cmovnsq %rdx, %r14
cmovsq %rax, %rcx
movq -0x68(%rbp), %r15
movq -0x38(%rbp), %rdi
jmp 0x8b74
movl %ecx, -0x2c(%rbp)
movq -0x48(%rbp), %rdi
callq 0x3100
movq %rax, -0x40(%rbp)
cmpq $0x10000, %rax          # imm = 0x10000
jb 0x8c6a
movl $0x18, 0x1c(%r15)
jmp 0x8e94
testq %r14, %r14
je 0x8c98
movq %r14, %rdi
callq 0x3100
movq %rax, -0x58(%rbp)
cmpq $0xffff, %rax           # imm = 0xFFFF
movq -0x38(%rbp), %r10
movl -0x2c(%rbp), %r11d
jbe 0x8ca8
movl $0x18, 0x1c(%r15)
jmp 0x8e91
movq $0x0, -0x58(%rbp)
movq -0x38(%rbp), %r10
movl -0x2c(%rbp), %r11d
movq %r14, -0x60(%rbp)
movq %rbx, -0x50(%rbp)
movq %r15, -0x68(%rbp)
movl 0x10(%r15), %eax
movq %rax, -0x70(%rbp)
xorl %r13d, %r13d
cmpq -0x70(%rbp), %r13
je 0x8e86
movq (%r10), %r14
movq 0x20(%r10), %rax
movl (%rax,%r13,4), %ebx
movzwl 0x1c(%r14,%rbx), %r15d
cmpq %r15, -0x40(%rbp)
ja 0x8e7e
leaq (%r14,%rbx), %r12
addq $0x2e, %r12
cmpq $0x0, -0x58(%rbp)
je 0x8d97
leaq (%r14,%rbx), %rcx
movzwl 0x20(%rcx), %eax
cmpq %rax, -0x58(%rbp)
jne 0x8e7e
movzwl 0x1e(%rcx), %esi
btl $0x8, %r11d
jb 0x8d71
addq %rbx, %rsi
addq %r15, %rsi
leaq (%r14,%rsi), %rcx
addq $0x2e, %rcx
xorl %edx, %edx
cmpq %rdx, %rax
je 0x8d97
movq -0x60(%rbp), %rsi
movsbl (%rsi,%rdx), %esi
movl %esi, %edi
movl $0xff, %r9d
andl %r9d, %edi
leal -0x41(%rsi), %r8d
addl $0x20, %edi
cmpb $0x1a, %r8b
cmovael %esi, %edi
movsbl (%rcx,%rdx), %esi
movl %esi, %r8d
andl %r9d, %r8d
leal -0x41(%rsi), %r9d
addl $0x20, %r8d
cmpb $0x1a, %r9b
cmovael %esi, %r8d
incq %rdx
cmpl %r8d, %edi
je 0x8d24
jmp 0x8e7e
addq %r12, %rsi
addq %r15, %rsi
movq -0x60(%rbp), %rdi
movq -0x58(%rbp), %rdx
callq 0x3280
movl -0x2c(%rbp), %r11d
movq -0x38(%rbp), %r10
pushq $0x4
popq %rcx
testl %eax, %eax
jne 0x8e79
btl $0x9, %r11d
jae 0x8de2
testw %r15w, %r15w
je 0x8de2
leaq (%r14,%rbx), %rcx
addq $0x2d, %rcx
movq %r15, %rax
movzbl (%rcx,%rax), %edx
addl $-0x2f, %edx
cmpl $0x2d, %edx
ja 0x8dcb
movabsq $0x200000000801, %rsi   # imm = 0x200000000801
btq %rdx, %rsi
jb 0x8dda
decq %rax
leaq 0x1(%rax), %rdx
cmpq $0x1, %rdx
jg 0x8daf
xorl %eax, %eax
movl %eax, %ecx
addq %rcx, %r12
subl %eax, %r15d
movl %r15d, %eax
cmpq %rax, -0x40(%rbp)
jne 0x8e7e
btl $0x8, %r11d
jb 0x8e3b
xorl %eax, %eax
cmpq %rax, -0x40(%rbp)
je 0x8e52
movq -0x48(%rbp), %rcx
movsbl (%rcx,%rax), %ecx
movl %ecx, %edx
movl $0xff, %edi
andl %edi, %edx
leal -0x41(%rcx), %esi
addl $0x20, %edx
cmpb $0x1a, %sil
cmovael %ecx, %edx
movsbl (%r12,%rax), %ecx
movl %ecx, %esi
andl %edi, %esi
leal -0x41(%rcx), %edi
addl $0x20, %esi
cmpb $0x1a, %dil
cmovael %ecx, %esi
incq %rax
cmpl %esi, %edx
je 0x8df8
jmp 0x8e7e
movq -0x48(%rbp), %rdi
movq %r12, %rsi
movq -0x40(%rbp), %rdx
callq 0x3280
testl %eax, %eax
setne %al
jmp 0x8e54
xorl %eax, %eax
movl %eax, %ecx
xorb $0x1, %cl
movzbl %cl, %ecx
cmpq $0x0, -0x50(%rbp)
je 0x8e71
testb %al, %al
movq -0x38(%rbp), %r10
movl -0x2c(%rbp), %r11d
jne 0x8e79
jmp 0x8eb0
movq -0x38(%rbp), %r10
movl -0x2c(%rbp), %r11d
testb $0x3, %cl
jne 0x8eb7
incq %r13
jmp 0x8cbf
movq -0x68(%rbp), %rax
movl $0x1c, 0x1c(%rax)
xorl %r12d, %r12d
movl %r12d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1c, 0x1c(%r15)
jmp 0x8e94
movq -0x50(%rbp), %rax
movl %r13d, (%rax)
pushq $0x1
popq %r12
jmp 0x8e94
pushq $0x1
popq %r12
movq -0x50(%rbp), %rcx
testq %rcx, %rcx
je 0x8e94
movl %eax, (%rcx)
jmp 0x8e94