// File: jimmiebergmann[P]fbx-file/miniz.c
// Function: mz_zip_locate_file_binary_search(mz_zip_archive*, char const*, unsigned int*)
static mz_bool mz_zip_locate_file_binary_search(mz_zip_archive *pZip, const char *pFilename, mz_uint32 *pIndex)
{
    mz_zip_internal_state *pState = pZip->m_pState;
    const mz_zip_array *pCentral_dir_offsets = &pState->m_central_dir_offsets;
    const mz_zip_array *pCentral_dir = &pState->m_central_dir;
    mz_uint32 *pIndices = &MZ_ZIP_ARRAY_ELEMENT(&pState->m_sorted_central_dir_offsets, mz_uint32, 0);
    const uint32_t size = pZip->m_total_files;
    const mz_uint filename_len = (mz_uint)strlen(pFilename);

    if (pIndex)
        *pIndex = 0;

    if (size)
    {
        /* yes I could use uint32_t's, but then we would have to add some special case checks in the loop, argh, and */
        /* honestly the major expense here on 32-bit CPU's will still be the filename compare */
        mz_int64 l = 0, h = (mz_int64)size - 1;

        while (l <= h)
        {
            mz_int64 m = l + ((h - l) >> 1);
            uint32_t file_index = pIndices[(uint32_t)m];

            int comp = mz_zip_filename_compare(pCentral_dir, pCentral_dir_offsets, file_index, pFilename, filename_len);
            if (!comp)
            {
                if (pIndex)
                    *pIndex = file_index;
                return MZ_TRUE;
            }
            else if (comp < 0)
                l = m + 1;
            else
                h = m - 1;
        }
    }

    return mz_zip_set_error(pZip, MZ_ZIP_FILE_NOT_FOUND);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x58(%rbp)
movq %rsi, -0x60(%rbp)
movq %rdx, -0x68(%rbp)
movq -0x58(%rbp), %rax
movq 0x68(%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x78(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x70(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x88(%rbp)
movq -0x58(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x8c(%rbp)
movq -0x60(%rbp), %rdi
callq 0x3140
movl %eax, -0x90(%rbp)
cmpq $0x0, -0x68(%rbp)
je 0xe1e3
movq -0x68(%rbp), %rax
movl $0x0, (%rax)
cmpl $0x0, -0x8c(%rbp)
je 0xe456
movq $0x0, -0x98(%rbp)
movl -0x8c(%rbp), %eax
subq $0x1, %rax
movq %rax, -0xa0(%rbp)
movq -0x98(%rbp), %rax
cmpq -0xa0(%rbp), %rax
jg 0xe454
movq -0x98(%rbp), %rax
movq -0xa0(%rbp), %rcx
subq -0x98(%rbp), %rcx
sarq %rcx
addq %rcx, %rax
movq %rax, -0xa8(%rbp)
movq -0x88(%rbp), %rax
movq -0xa8(%rbp), %rcx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0xac(%rbp)
movq -0x80(%rbp), %rdi
movq -0x78(%rbp), %rsi
movl -0xac(%rbp), %edx
movq -0x60(%rbp), %rcx
movl -0x90(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
movl -0x14(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movzwl 0x1c(%rax), %eax
movl %eax, -0x3c(%rbp)
movb $0x0, -0x3d(%rbp)
movb $0x0, -0x3e(%rbp)
movq -0x30(%rbp), %rax
addq $0x2e, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0xb8(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jae 0xe2dd
movl -0x3c(%rbp), %eax
movl %eax, -0xbc(%rbp)
jmp 0xe2e6
movl -0x24(%rbp), %eax
movl %eax, -0xbc(%rbp)
movq -0xb8(%rbp), %rax
movl -0xbc(%rbp), %ecx
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x38(%rbp), %rax
jae 0xe3c5
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x41, %eax
jl 0xe337
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x5a, %eax
jg 0xe337
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
subl $0x41, %eax
addl $0x61, %eax
movl %eax, -0xc0(%rbp)
jmp 0xe344
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
movl %eax, -0xc0(%rbp)
movl -0xc0(%rbp), %eax
movb %al, -0x3d(%rbp)
movzbl %al, %eax
movl %eax, -0xc4(%rbp)
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x41, %eax
jl 0xe383
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5a, %eax
jg 0xe383
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
subl $0x41, %eax
addl $0x61, %eax
movl %eax, -0xc8(%rbp)
jmp 0xe390
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0xc8(%rbp)
movl -0xc4(%rbp), %eax
movl -0xc8(%rbp), %ecx
movb %cl, -0x3e(%rbp)
movzbl %cl, %ecx
cmpl %ecx, %eax
je 0xe3a8
jmp 0xe3c5
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0xe2fc
movq -0x30(%rbp), %rax
cmpq -0x38(%rbp), %rax
jne 0xe3dd
movl -0x3c(%rbp), %eax
subl -0x24(%rbp), %eax
movl %eax, -0xcc(%rbp)
jmp 0xe3ed
movzbl -0x3d(%rbp), %eax
movzbl -0x3e(%rbp), %ecx
subl %ecx, %eax
movl %eax, -0xcc(%rbp)
movl -0xcc(%rbp), %eax
movl %eax, -0xb0(%rbp)
cmpl $0x0, -0xb0(%rbp)
jne 0xe41e
cmpq $0x0, -0x68(%rbp)
je 0xe415
movl -0xac(%rbp), %ecx
movq -0x68(%rbp), %rax
movl %ecx, (%rax)
movl $0x1, -0x50(%rbp)
jmp 0xe47d
cmpl $0x0, -0xb0(%rbp)
jge 0xe43b
movq -0xa8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x98(%rbp)
jmp 0xe44d
movq -0xa8(%rbp), %rax
subq $0x1, %rax
movq %rax, -0xa0(%rbp)
jmp 0xe44f
jmp 0xe20c
jmp 0xe456
movq -0x58(%rbp), %rax
movq %rax, -0x48(%rbp)
movl $0x1c, -0x4c(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0xe476
movl -0x4c(%rbp), %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0x1c(%rax)
movl $0x0, -0x50(%rbp)
movl -0x50(%rbp), %eax
addq $0xd0, %rsp
popq %rbp
retq
nopl (%rax)