// File: /workspace/github_cpp_makefile_star2_O3/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, %r14d
movq %rdx, %r15
movq %rsi, %r12
leal 0x40(%r14), %edx
cmpq %rdx, 0x10(%rdi)
movq %rdi, -0x30(%rbp)
jae 0xdadd
movq %r12, %rdi
movq -0x30(%rbp), %rsi
xorl %ecx, %ecx
callq 0xfd63
movq -0x30(%rbp), %rdi
testl %eax, %eax
je 0xdb16
movq %r12, -0x38(%rbp)
movq 0x10(%rbp), %rax
movq $0x0, 0x8(%rdi)
movq %rbx, %rcx
orq %r13, %rcx
orq %rax, %rcx
je 0xdbb8
movl $0x1, -0x80(%rbp)
testq %r13, %r13
je 0xdb2d
movq (%r13), %rcx
leaq -0x74(%rbp), %r13
movq %rcx, -0x8(%r13)
jmp 0xdb31
testq %r12, %r12
je 0xdc6b
movl $0x10, 0x1c(%r12)
jmp 0xdc6b
leaq -0x7c(%rbp), %r13
testq %rbx, %rbx
je 0xdb41
movq (%rbx), %rcx
movq %rcx, (%r13)
addq $0x8, %r13
testq %rax, %rax
je 0xdb57
movq (%rax), %rax
movq %rax, (%r13)
addq $0x8, %r13
movq 0x8(%rdi), %rbx
jmp 0xdb59
xorl %ebx, %ebx
leaq -0x80(%rbp), %rax
subq %rax, %r13
leal -0x4(%r13), %ecx
movw %cx, 0x2(%rax)
leaq (%rbx,%r13), %r12
cmpq %r12, 0x10(%rdi)
jae 0xdb93
movq -0x38(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq %r12, %rdx
movl $0x1, %ecx
callq 0xfd63
movq -0x30(%rbp), %rdi
testl %eax, %eax
je 0xdc5b
movq %r12, 0x8(%rdi)
movl 0x18(%rdi), %eax
imulq %rax, %rbx
addq (%rdi), %rbx
imulq %rax, %r13
leaq -0x80(%rbp), %rsi
movq %rbx, %rdi
movq %r13, %rdx
callq 0x31e0
movq -0x30(%rbp), %rdi
testq %r15, %r15
sete %dl
testl %r14d, %r14d
sete %cl
movl $0x1, %eax
orb %dl, %cl
jne 0xdc6d
cmpl $0x3, %r14d
jbe 0xdc47
movzwl 0x2(%r15), %r12d
addq $0x4, %r12
cmpl %r12d, %r14d
jb 0xdc47
cmpw $0x1, (%r15)
je 0xdc38
movq 0x8(%rdi), %rbx
leaq (%rbx,%r12), %r13
cmpq %r13, 0x10(%rdi)
jae 0xdc17
movq -0x38(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq %r13, %rdx
movl $0x1, %ecx
callq 0xfd63
movq -0x30(%rbp), %rdi
testl %eax, %eax
je 0xdc7c
movq %r13, 0x8(%rdi)
movl 0x18(%rdi), %edx
imulq %rdx, %rbx
addq (%rdi), %rbx
imulq %r12, %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x31e0
movq -0x30(%rbp), %rdi
addq %r12, %r15
subl %r12d, %r14d
jne 0xdbd1
movl $0x1, %eax
jmp 0xdc6d
xorl %eax, %eax
movq -0x38(%rbp), %rcx
testq %rcx, %rcx
je 0xdc6d
movl $0x9, 0x1c(%rcx)
jmp 0xdc6d
movq -0x38(%rbp), %rax
testq %rax, %rax
je 0xdc6b
movl $0x10, 0x1c(%rax)
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
movq -0x38(%rbp), %rcx
testq %rcx, %rcx
je 0xdc6d
movl $0x10, 0x1c(%rcx)
jmp 0xdc6d