// File: /workspace/github_cpp_makefile_star2_O1/jimmiebergmann[P]fbx-file/miniz.c
// Function: mz_zip_file_stat_internal(mz_zip_archive*, unsigned int, unsigned char const*, mz_zip_archive_file_stat*, int*)
static mz_bool mz_zip_file_stat_internal(mz_zip_archive *pZip, mz_uint file_index, const mz_uint8 *pCentral_dir_header, mz_zip_archive_file_stat *pStat, mz_bool *pFound_zip64_extra_data)
{
    mz_uint n;
    const mz_uint8 *p = pCentral_dir_header;

    if (pFound_zip64_extra_data)
        *pFound_zip64_extra_data = MZ_FALSE;

    if ((!p) || (!pStat))
        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);

    /* Extract fields from the central directory record. */
    pStat->m_file_index = file_index;
    pStat->m_central_dir_ofs = MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32, file_index);
    pStat->m_version_made_by = MZ_READ_LE16(p + MZ_ZIP_CDH_VERSION_MADE_BY_OFS);
    pStat->m_version_needed = MZ_READ_LE16(p + MZ_ZIP_CDH_VERSION_NEEDED_OFS);
    pStat->m_bit_flag = MZ_READ_LE16(p + MZ_ZIP_CDH_BIT_FLAG_OFS);
    pStat->m_method = MZ_READ_LE16(p + MZ_ZIP_CDH_METHOD_OFS);
#ifndef MINIZ_NO_TIME
    pStat->m_time = mz_zip_dos_to_time_t(MZ_READ_LE16(p + MZ_ZIP_CDH_FILE_TIME_OFS), MZ_READ_LE16(p + MZ_ZIP_CDH_FILE_DATE_OFS));
#endif
    pStat->m_crc32 = MZ_READ_LE32(p + MZ_ZIP_CDH_CRC32_OFS);
    pStat->m_comp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS);
    pStat->m_uncomp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS);
    pStat->m_internal_attr = MZ_READ_LE16(p + MZ_ZIP_CDH_INTERNAL_ATTR_OFS);
    pStat->m_external_attr = MZ_READ_LE32(p + MZ_ZIP_CDH_EXTERNAL_ATTR_OFS);
    pStat->m_local_header_ofs = MZ_READ_LE32(p + MZ_ZIP_CDH_LOCAL_HEADER_OFS);

    /* Copy as much of the filename and comment as possible. */
    n = MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS);
    n = MZ_MIN(n, MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE - 1);
    memcpy(pStat->m_filename, p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE, n);
    pStat->m_filename[n] = '\0';

    n = MZ_READ_LE16(p + MZ_ZIP_CDH_COMMENT_LEN_OFS);
    n = MZ_MIN(n, MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE - 1);
    pStat->m_comment_size = n;
    memcpy(pStat->m_comment, p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS) + MZ_READ_LE16(p + MZ_ZIP_CDH_EXTRA_LEN_OFS), n);
    pStat->m_comment[n] = '\0';

    /* Set some flags for convienance */
    pStat->m_is_directory = mz_zip_reader_is_file_a_directory(pZip, file_index);
    pStat->m_is_encrypted = mz_zip_reader_is_file_encrypted(pZip, file_index);
    pStat->m_is_supported = mz_zip_reader_is_file_supported(pZip, file_index);

    /* See if we need to read any zip64 extended information fields. */
    /* Confusingly, these zip64 fields can be present even on non-zip64 archives (Debian zip on a huge files from stdin piped to stdout creates them). */
    if (MZ_MAX(MZ_MAX(pStat->m_comp_size, pStat->m_uncomp_size), pStat->m_local_header_ofs) == MZ_UINT32_MAX)
    {
        /* Attempt to find zip64 extended information field in the entry's extra data */
        mz_uint32 extra_size_remaining = MZ_READ_LE16(p + MZ_ZIP_CDH_EXTRA_LEN_OFS);

        if (extra_size_remaining)
        {
            const mz_uint8 *pExtra_data = p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS);

            do
            {
                mz_uint32 field_id;
                mz_uint32 field_data_size;

                if (extra_size_remaining < (sizeof(mz_uint16) * 2))
                    return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);

                field_id = MZ_READ_LE16(pExtra_data);
                field_data_size = MZ_READ_LE16(pExtra_data + sizeof(mz_uint16));

                if ((field_data_size + sizeof(mz_uint16) * 2) > extra_size_remaining)
                    return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);

                if (field_id == MZ_ZIP64_EXTENDED_INFORMATION_FIELD_HEADER_ID)
                {
                    const mz_uint8 *pField_data = pExtra_data + sizeof(mz_uint16) * 2;
                    mz_uint32 field_data_remaining = field_data_size;

                    if (pFound_zip64_extra_data)
                        *pFound_zip64_extra_data = MZ_TRUE;

                    if (pStat->m_uncomp_size == MZ_UINT32_MAX)
                    {
                        if (field_data_remaining < sizeof(mz_uint64))
                            return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);

                        pStat->m_uncomp_size = MZ_READ_LE64(pField_data);
                        pField_data += sizeof(mz_uint64);
                        field_data_remaining -= sizeof(mz_uint64);
                    }

                    if (pStat->m_comp_size == MZ_UINT32_MAX)
                    {
                        if (field_data_remaining < sizeof(mz_uint64))
                            return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);

                        pStat->m_comp_size = MZ_READ_LE64(pField_data);
                        pField_data += sizeof(mz_uint64);
                        field_data_remaining -= sizeof(mz_uint64);
                    }

                    if (pStat->m_local_header_ofs == MZ_UINT32_MAX)
                    {
                        if (field_data_remaining < sizeof(mz_uint64))
                            return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);

                        pStat->m_local_header_ofs = MZ_READ_LE64(pField_data);
                        pField_data += sizeof(mz_uint64);
                        field_data_remaining -= sizeof(mz_uint64);
                    }

                    break;
                }

                pExtra_data += sizeof(mz_uint16) * 2 + field_data_size;
                extra_size_remaining = extra_size_remaining - sizeof(mz_uint16) * 2 - field_data_size;
            } while (extra_size_remaining);
        }
    }

    return MZ_TRUE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rcx, %r15
movq %rdx, %r13
movq %rdi, %r14
testq %r8, %r8
je 0xa8a1
movl $0x0, (%r8)
testq %r13, %r13
setne %al
testq %r15, %r15
setne %cl
testb %cl, %al
je 0xab3a
movq %r8, -0x40(%rbp)
movl %esi, (%r15)
movq 0x68(%r14), %rax
movq 0x20(%rax), %rax
movl %esi, %ecx
movl (%rax,%rcx,4), %eax
movq %rax, 0x8(%r15)
movzwl 0x4(%r13), %eax
movw %ax, 0x10(%r15)
movzwl 0x6(%r13), %eax
movw %ax, 0x12(%r15)
movzwl 0x8(%r13), %eax
movw %ax, 0x14(%r15)
movzwl 0xa(%r13), %eax
movw %ax, 0x16(%r15)
movzwl 0xc(%r13), %eax
movzwl 0xe(%r13), %ecx
xorps %xmm0, %xmm0
leaq -0x80(%rbp), %rdi
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
movq $0x0, 0x30(%rdi)
movl $0xffffffff, 0x20(%rdi) # imm = 0xFFFFFFFF
movl %ecx, %edx
shrl $0x9, %edx
addl $0x50, %edx
movl %edx, 0x14(%rdi)
movl %ecx, %edx
shrl $0x5, %edx
andl $0xf, %edx
decl %edx
movl %edx, 0x10(%rdi)
andl $0x1f, %ecx
movl %ecx, 0xc(%rdi)
movl %eax, %ecx
shrl $0xb, %ecx
movl %ecx, 0x8(%rdi)
movl %eax, %ecx
shrl $0x5, %ecx
andl $0x3f, %ecx
movl %ecx, 0x4(%rdi)
addl %eax, %eax
andl $0x3e, %eax
movl %eax, (%rdi)
movl %esi, -0x2c(%rbp)
callq 0x3180
movq %rax, 0x18(%r15)
movl 0x10(%r13), %eax
movl %eax, 0x20(%r15)
movl 0x14(%r13), %eax
movq %rax, 0x28(%r15)
movl 0x18(%r13), %eax
movq %rax, 0x30(%r15)
movzwl 0x24(%r13), %eax
movw %ax, 0x38(%r15)
movl 0x26(%r13), %eax
movl %eax, 0x3c(%r15)
movl 0x2a(%r13), %eax
movq %rax, 0x40(%r15)
movzwl 0x1c(%r13), %ebx
movl $0x1ff, %r12d           # imm = 0x1FF
cmpl %r12d, %ebx
cmovael %r12d, %ebx
leaq 0x58(%r15), %rdi
leaq 0x2e(%r13), %rsi
movq %rsi, -0x38(%rbp)
movq %rbx, %rdx
callq 0x31e0
xorl %eax, %eax
movb %al, 0x58(%r15,%rbx)
movq %r14, %rbx
movzwl 0x20(%r13), %eax
cmpl %r12d, %eax
cmovbl %eax, %r12d
movl %r12d, 0x48(%r15)
leaq 0x258(%r15), %rdi
movzwl 0x1c(%r13), %eax
addq %r13, %rax
addq $0x2e, %rax
movzwl 0x1e(%r13), %esi
addq %rax, %rsi
movq %r12, %rdx
callq 0x31e0
xorl %eax, %eax
movb %al, 0x258(%r15,%r12)
movq %r14, %rdi
movl -0x2c(%rbp), %r14d
movl %r14d, %esi
callq 0x8a53
movl %eax, 0x4c(%r15)
movq %rbx, %rdi
movl %r14d, %esi
callq 0x8993
movl %eax, 0x50(%r15)
movq %rbx, %rdi
movl %r14d, %esi
callq 0x89d8
movl %eax, 0x54(%r15)
movq 0x28(%r15), %rax
movq 0x30(%r15), %rcx
cmpq %rcx, %rax
cmovaq %rax, %rcx
movq 0x40(%r15), %rax
cmpq %rax, %rcx
cmovbeq %rax, %rcx
movl $0x1, %eax
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
cmpq %rdx, %rcx
jne 0xab5c
movzwl 0x1e(%r13), %ecx
testl %ecx, %ecx
movq -0x40(%rbp), %r8
movq -0x38(%rbp), %r9
je 0xab57
movzwl 0x1c(%r13), %eax
addq %rax, %r9
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl $0x3, %ecx
jbe 0xaa98
movl %ecx, %edi
movzwl 0x2(%r9), %esi
leaq 0x4(%rsi), %rdx
cmpq %rdi, %rdx
jbe 0xaabc
movl $0x1, %edx
testq %rbx, %rbx
je 0xaaa9
movl $0x9, 0x1c(%rbx)
xorl %esi, %esi
testl %edx, %edx
jne 0xab4b
testl %ecx, %ecx
jne 0xaa83
jmp 0xab57
cmpw $0x1, (%r9)
jne 0xaaec
testq %r8, %r8
je 0xaacf
movl $0x1, (%r8)
cmpq %rax, 0x30(%r15)
jne 0xaafd
cmpw $0x7, %si
jbe 0xaa98
movq 0x4(%r9), %rdx
movq %rdx, 0x30(%r15)
leaq 0xc(%r9), %rdi
addl $-0x8, %esi
jmp 0xab01
addq %rdx, %r9
subl %esi, %edi
addl $-0x4, %edi
xorl %edx, %edx
movb $0x1, %sil
movl %edi, %ecx
jmp 0xaaab
leaq 0x4(%r9), %rdi
cmpq %rax, 0x28(%r15)
jne 0xab1a
cmpl $0x7, %esi
jbe 0xaa98
movq (%rdi), %rdx
movq %rdx, 0x28(%r15)
addq $0x8, %rdi
addl $-0x8, %esi
movl $0x2, %edx
cmpq %rax, 0x40(%r15)
jne 0xaaa9
cmpl $0x7, %esi
jbe 0xaa98
movq (%rdi), %rsi
movq %rsi, 0x40(%r15)
jmp 0xaaa9
xorl %eax, %eax
testq %r14, %r14
je 0xab5c
movl $0x18, 0x1c(%r14)
jmp 0xab5c
cmpl $0x2, %edx
je 0xab57
xorl %eax, %eax
testb %sil, %sil
je 0xab5c
movl $0x1, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq