// File: /workspace/github_cpp_makefile_star2_O1/jimmiebergmann[P]fbx-file/miniz.c
// Function: mz_zip_writer_update_zip64_extension_block(mz_zip_array*, mz_zip_archive*, unsigned char const*, unsigned int, unsigned long*, unsigned long*, unsigned long*, unsigned int*)
static mz_bool mz_zip_writer_update_zip64_extension_block(mz_zip_array *pNew_ext, mz_zip_archive *pZip, const mz_uint8 *pExt, uint32_t ext_len, mz_uint64 *pComp_size, mz_uint64 *pUncomp_size, mz_uint64 *pLocal_header_ofs, mz_uint32 *pDisk_start)
{
    /* + 64 should be enough for any new zip64 data */
    if (!mz_zip_array_reserve(pZip, pNew_ext, ext_len + 64, MZ_FALSE))
        return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);

    mz_zip_array_resize(pZip, pNew_ext, 0, MZ_FALSE);

    if ((pUncomp_size) || (pComp_size) || (pLocal_header_ofs) || (pDisk_start))
    {
        mz_uint8 new_ext_block[64];
        mz_uint8 *pDst = new_ext_block;
        mz_write_le16(pDst, MZ_ZIP64_EXTENDED_INFORMATION_FIELD_HEADER_ID);
        mz_write_le16(pDst + sizeof(mz_uint16), 0);
        pDst += sizeof(mz_uint16) * 2;

        if (pUncomp_size)
        {
            mz_write_le64(pDst, *pUncomp_size);
            pDst += sizeof(mz_uint64);
        }

        if (pComp_size)
        {
            mz_write_le64(pDst, *pComp_size);
            pDst += sizeof(mz_uint64);
        }

        if (pLocal_header_ofs)
        {
            mz_write_le64(pDst, *pLocal_header_ofs);
            pDst += sizeof(mz_uint64);
        }

        if (pDisk_start)
        {
            mz_write_le32(pDst, *pDisk_start);
            pDst += sizeof(mz_uint32);
        }

        mz_write_le16(new_ext_block + sizeof(mz_uint16), (mz_uint16)((pDst - new_ext_block) - sizeof(mz_uint16) * 2));

        if (!mz_zip_array_push_back(pZip, pNew_ext, new_ext_block, pDst - new_ext_block))
            return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
    }

    if ((pExt) && (ext_len))
    {
        mz_uint32 extra_size_remaining = ext_len;
        const mz_uint8 *pExtra_data = pExt;

        do
        {
            mz_uint32 field_id, field_data_size, field_total_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));
            field_total_size = field_data_size + sizeof(mz_uint16) * 2;

            if (field_total_size > 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)
            {
                if (!mz_zip_array_push_back(pZip, pNew_ext, pExtra_data, field_total_size))
                    return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
            }

            pExtra_data += field_total_size;
            extra_size_remaining -= field_total_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 %r9, %r13
movq %r8, %rbx
movl %ecx, %r12d
movq %rdx, %r14
movq %rsi, %r8
movq %rdi, %rsi
leal 0x40(%r12), %edx
cmpq %rdx, 0x10(%rdi)
movq %r8, -0x38(%rbp)
movq %rdi, -0x30(%rbp)
jae 0xddf0
xorl %r15d, %r15d
movq %r8, %rdi
xorl %ecx, %ecx
callq 0xffe4
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %r8
testl %eax, %eax
je 0xde25
movq 0x10(%rbp), %rax
movq $0x0, 0x8(%rsi)
movq %rbx, %rcx
orq %r13, %rcx
orq %rax, %rcx
je 0xdeed
movl $0x1, -0x80(%rbp)
testq %r13, %r13
je 0xde3b
movq (%r13), %rcx
leaq -0x74(%rbp), %r13
movq %rcx, -0x8(%r13)
jmp 0xde3f
testq %r8, %r8
je 0xdfd0
movl $0x10, 0x1c(%r8)
jmp 0xdfd0
leaq -0x7c(%rbp), %r13
testq %rbx, %rbx
je 0xde4f
movq (%rbx), %rcx
movq %rcx, (%r13)
addq $0x8, %r13
testq %rax, %rax
je 0xde5f
movq (%rax), %rax
movq %rax, (%r13)
addq $0x8, %r13
leaq -0x80(%rbp), %rax
subq %rax, %r13
leal -0x4(%r13), %ecx
movw %cx, 0x2(%rax)
movq 0x8(%rsi), %rdi
leaq (%rdi,%r13), %r15
cmpq %r15, 0x10(%rsi)
jae 0xdea2
movq %rdi, %rbx
movq %r8, %rdi
movq %r15, %rdx
movl $0x1, %ecx
callq 0xffe4
movq %rbx, %rdi
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %r8
testl %eax, %eax
je 0xdfe2
movq %r15, 0x8(%rsi)
xorl %ebx, %ebx
testb %bl, %bl
jne 0xdece
movl 0x18(%rsi), %eax
imulq %rax, %rdi
addq (%rsi), %rdi
imulq %rax, %r13
leaq -0x80(%rbp), %rsi
movq %r13, %rdx
callq 0x31e0
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %r8
testq %r8, %r8
sete %al
movl %ebx, %ecx
xorb $0x1, %cl
orb %al, %cl
jne 0xdee5
movl $0x10, 0x1c(%r8)
testb %bl, %bl
jne 0xdfcd
testq %r14, %r14
sete %al
testl %r12d, %r12d
sete %cl
orb %al, %cl
jne 0xdfc5
movq %r14, %r15
cmpl $0x3, %r12d
jbe 0xdf1b
movzwl 0x2(%r15), %ebx
addq $0x4, %rbx
movl %r12d, %r14d
subl %ebx, %r14d
jae 0xdf2f
testq %r8, %r8
je 0xdf28
movl $0x9, 0x1c(%r8)
xorl %eax, %eax
movl %r12d, %r14d
jmp 0xdf97
cmpw $0x1, (%r15)
je 0xdf90
movq %r15, -0x40(%rbp)
movq 0x8(%rsi), %r15
leaq (%r15,%rbx), %r13
cmpq %r13, 0x10(%rsi)
jae 0xdf64
movq %r8, %rdi
movq %r13, %rdx
movl $0x1, %ecx
callq 0xffe4
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %r8
testl %eax, %eax
je 0xdfa9
movq %r13, 0x8(%rsi)
movl 0x18(%rsi), %eax
imulq %rax, %r15
addq (%rsi), %r15
movq %rbx, %rdx
imulq %rax, %rdx
movq %r15, %rdi
movq -0x40(%rbp), %r15
movq %r15, %rsi
callq 0x31e0
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %r8
movl %ebx, %eax
addq %rax, %r15
movb $0x1, %al
testl %r14d, %r14d
je 0xdfc1
movl %r14d, %r12d
testb %al, %al
jne 0xdf04
jmp 0xdfc1
testq %r8, %r8
je 0xdfb6
movl $0x10, 0x1c(%r8)
xorl %eax, %eax
movl %r12d, %r14d
movq -0x40(%rbp), %r15
jmp 0xdf97
testb %al, %al
je 0xdfcd
movl $0x1, %r15d
jmp 0xdfd0
xorl %r15d, %r15d
movl %r15d, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x1, %bl
jmp 0xdea8