// File: /workspace/github_cpp_makefile_star2_O1/jimmiebergmann[P]fbx-file/miniz.c
// Function: mz_zip_writer_add_from_zip_reader
mz_bool mz_zip_writer_add_from_zip_reader(mz_zip_archive *pZip, mz_zip_archive *pSource_zip, mz_uint src_file_index)
{
    mz_uint n, bit_flags, num_alignment_padding_bytes, src_central_dir_following_data_size;
    mz_uint64 src_archive_bytes_remaining, local_dir_header_ofs;
    mz_uint64 cur_src_file_ofs, cur_dst_file_ofs;
    mz_uint32 local_header_u32[(MZ_ZIP_LOCAL_DIR_HEADER_SIZE + sizeof(mz_uint32) - 1) / sizeof(mz_uint32)];
    mz_uint8 *pLocal_header = (mz_uint8 *)local_header_u32;
    mz_uint8 new_central_header[MZ_ZIP_CENTRAL_DIR_HEADER_SIZE];
    size_t orig_central_dir_size;
    mz_zip_internal_state *pState;
    void *pBuf;
    const mz_uint8 *pSrc_central_header;
    mz_zip_archive_file_stat src_file_stat;
    mz_uint32 src_filename_len, src_comment_len, src_ext_len;
    mz_uint32 local_header_filename_size, local_header_extra_len;
    mz_uint64 local_header_comp_size, local_header_uncomp_size;
    mz_bool found_zip64_ext_data_in_ldir = MZ_FALSE;

    /* Sanity checks */
    if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING) || (!pSource_zip->m_pRead))
        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);

    pState = pZip->m_pState;

    /* Don't support copying files from zip64 archives to non-zip64, even though in some cases this is possible */
    if ((pSource_zip->m_pState->m_zip64) && (!pZip->m_pState->m_zip64))
        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);

    /* Get pointer to the source central dir header and crack it */
    if (NULL == (pSrc_central_header = mz_zip_get_cdh(pSource_zip, src_file_index)))
        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);

    if (MZ_READ_LE32(pSrc_central_header + MZ_ZIP_CDH_SIG_OFS) != MZ_ZIP_CENTRAL_DIR_HEADER_SIG)
        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);

    src_filename_len = MZ_READ_LE16(pSrc_central_header + MZ_ZIP_CDH_FILENAME_LEN_OFS);
    src_comment_len = MZ_READ_LE16(pSrc_central_header + MZ_ZIP_CDH_COMMENT_LEN_OFS);
    src_ext_len = MZ_READ_LE16(pSrc_central_header + MZ_ZIP_CDH_EXTRA_LEN_OFS);
    src_central_dir_following_data_size = src_filename_len + src_ext_len + src_comment_len;

    /* TODO: We don't support central dir's >= MZ_UINT32_MAX bytes right now (+32 fudge factor in case we need to add more extra data) */
    if ((pState->m_central_dir.m_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + src_central_dir_following_data_size + 32) >= MZ_UINT32_MAX)
        return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_CDIR_SIZE);

    num_alignment_padding_bytes = mz_zip_writer_compute_padding_needed_for_file_alignment(pZip);

    if (!pState->m_zip64)
    {
        if (pZip->m_total_files == MZ_UINT16_MAX)
            return mz_zip_set_error(pZip, MZ_ZIP_TOO_MANY_FILES);
    }
    else
    {
        /* TODO: Our zip64 support still has some 32-bit limits that may not be worth fixing. */
        if (pZip->m_total_files == MZ_UINT32_MAX)
            return mz_zip_set_error(pZip, MZ_ZIP_TOO_MANY_FILES);
    }

    if (!mz_zip_file_stat_internal(pSource_zip, src_file_index, pSrc_central_header, &src_file_stat, NULL))
        return MZ_FALSE;

    cur_src_file_ofs = src_file_stat.m_local_header_ofs;
    cur_dst_file_ofs = pZip->m_archive_size;

    /* Read the source archive's local dir header */
    if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs, pLocal_header, MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != MZ_ZIP_LOCAL_DIR_HEADER_SIZE)
        return mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED);

    if (MZ_READ_LE32(pLocal_header) != MZ_ZIP_LOCAL_DIR_HEADER_SIG)
        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);

    cur_src_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE;

    /* Compute the total size we need to copy (filename+extra data+compressed data) */
    local_header_filename_size = MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_FILENAME_LEN_OFS);
    local_header_extra_len = MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_EXTRA_LEN_OFS);
    local_header_comp_size = MZ_READ_LE32(pLocal_header + MZ_ZIP_LDH_COMPRESSED_SIZE_OFS);
    local_header_uncomp_size = MZ_READ_LE32(pLocal_header + MZ_ZIP_LDH_DECOMPRESSED_SIZE_OFS);
    src_archive_bytes_remaining = local_header_filename_size + local_header_extra_len + src_file_stat.m_comp_size;

    /* Try to find a zip64 extended information field */
    if ((local_header_extra_len) && ((local_header_comp_size == MZ_UINT32_MAX) || (local_header_uncomp_size == MZ_UINT32_MAX)))
    {
        mz_zip_array file_data_array;
        const mz_uint8 *pExtra_data;
        mz_uint32 extra_size_remaining = local_header_extra_len;

        mz_zip_array_init(&file_data_array, 1);
        if (!mz_zip_array_resize(pZip, &file_data_array, local_header_extra_len, MZ_FALSE))
        {
            return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
        }

        if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, src_file_stat.m_local_header_ofs + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + local_header_filename_size, file_data_array.m_p, local_header_extra_len) != local_header_extra_len)
        {
            mz_zip_array_clear(pZip, &file_data_array);
            return mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED);
        }

        pExtra_data = (const mz_uint8 *)file_data_array.m_p;

        do
        {
            mz_uint32 field_id, field_data_size, field_total_size;

            if (extra_size_remaining < (sizeof(mz_uint16) * 2))
            {
                mz_zip_array_clear(pZip, &file_data_array);
                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)
            {
                mz_zip_array_clear(pZip, &file_data_array);
                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 *pSrc_field_data = pExtra_data + sizeof(mz_uint32);

                if (field_data_size < sizeof(mz_uint64) * 2)
                {
                    mz_zip_array_clear(pZip, &file_data_array);
                    return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
                }

                local_header_uncomp_size = MZ_READ_LE64(pSrc_field_data);
                local_header_comp_size = MZ_READ_LE64(pSrc_field_data + sizeof(mz_uint64)); /* may be 0 if there's a descriptor */

                found_zip64_ext_data_in_ldir = MZ_TRUE;
                break;
            }

            pExtra_data += field_total_size;
            extra_size_remaining -= field_total_size;
        } while (extra_size_remaining);

        mz_zip_array_clear(pZip, &file_data_array);
    }

    if (!pState->m_zip64)
    {
        /* Try to detect if the new archive will most likely wind up too big and bail early (+(sizeof(mz_uint32) * 4) is for the optional descriptor which could be present, +64 is a fudge factor). */
        /* We also check when the archive is finalized so this doesn't need to be perfect. */
        mz_uint64 approx_new_archive_size = cur_dst_file_ofs + num_alignment_padding_bytes + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + src_archive_bytes_remaining + (sizeof(mz_uint32) * 4) +
                                            pState->m_central_dir.m_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + src_central_dir_following_data_size + MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE + 64;

        if (approx_new_archive_size >= MZ_UINT32_MAX)
            return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE);
    }

    /* Write dest archive padding */
    if (!mz_zip_writer_write_zeros(pZip, cur_dst_file_ofs, num_alignment_padding_bytes))
        return MZ_FALSE;

    cur_dst_file_ofs += num_alignment_padding_bytes;

    local_dir_header_ofs = cur_dst_file_ofs;
    if (pZip->m_file_offset_alignment)
    {
        MZ_ASSERT((local_dir_header_ofs & (pZip->m_file_offset_alignment - 1)) == 0);
    }

    /* The original zip's local header+ext block doesn't change, even with zip64, so we can just copy it over to the dest zip */
    if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_dst_file_ofs, pLocal_header, MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != MZ_ZIP_LOCAL_DIR_HEADER_SIZE)
        return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);

    cur_dst_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE;

    /* Copy over the source archive bytes to the dest archive, also ensure we have enough buf space to handle optional data descriptor */
    if (NULL == (pBuf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)MZ_MAX(32U, MZ_MIN((mz_uint64)MZ_ZIP_MAX_IO_BUF_SIZE, src_archive_bytes_remaining)))))
        return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);

    while (src_archive_bytes_remaining)
    {
        n = (mz_uint)MZ_MIN((mz_uint64)MZ_ZIP_MAX_IO_BUF_SIZE, src_archive_bytes_remaining);
        if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs, pBuf, n) != n)
        {
            pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf);
            return mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED);
        }
        cur_src_file_ofs += n;

        if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_dst_file_ofs, pBuf, n) != n)
        {
            pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf);
            return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
        }
        cur_dst_file_ofs += n;

        src_archive_bytes_remaining -= n;
    }

    /* Now deal with the optional data descriptor */
    bit_flags = MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_BIT_FLAG_OFS);
    if (bit_flags & 8)
    {
        /* Copy data descriptor */
        if ((pSource_zip->m_pState->m_zip64) || (found_zip64_ext_data_in_ldir))
        {
            /* src is zip64, dest must be zip64 */

            /* name			uint32_t's */
            /* id				1 (optional in zip64?) */
            /* crc			1 */
            /* comp_size	2 */
            /* uncomp_size 2 */
            if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs, pBuf, (sizeof(mz_uint32) * 6)) != (sizeof(mz_uint32) * 6))
            {
                pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf);
                return mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED);
            }

            n = sizeof(mz_uint32) * ((MZ_READ_LE32(pBuf) == MZ_ZIP_DATA_DESCRIPTOR_ID) ? 6 : 5);
        }
        else
        {
            /* src is NOT zip64 */
            mz_bool has_id;

            if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs, pBuf, sizeof(mz_uint32) * 4) != sizeof(mz_uint32) * 4)
            {
                pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf);
                return mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED);
            }

            has_id = (MZ_READ_LE32(pBuf) == MZ_ZIP_DATA_DESCRIPTOR_ID);

            if (pZip->m_pState->m_zip64)
            {
                /* dest is zip64, so upgrade the data descriptor */
                const mz_uint32 *pSrc_descriptor = (const mz_uint32 *)((const mz_uint8 *)pBuf + (has_id ? sizeof(mz_uint32) : 0));
                const mz_uint32 src_crc32 = pSrc_descriptor[0];
                const mz_uint64 src_comp_size = pSrc_descriptor[1];
                const mz_uint64 src_uncomp_size = pSrc_descriptor[2];

                mz_write_le32((mz_uint8 *)pBuf, MZ_ZIP_DATA_DESCRIPTOR_ID);
                mz_write_le32((mz_uint8 *)pBuf + sizeof(mz_uint32) * 1, src_crc32);
                mz_write_le64((mz_uint8 *)pBuf + sizeof(mz_uint32) * 2, src_comp_size);
                mz_write_le64((mz_uint8 *)pBuf + sizeof(mz_uint32) * 4, src_uncomp_size);

                n = sizeof(mz_uint32) * 6;
            }
            else
            {
                /* dest is NOT zip64, just copy it as-is */
                n = sizeof(mz_uint32) * (has_id ? 4 : 3);
            }
        }

        if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_dst_file_ofs, pBuf, n) != n)
        {
            pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf);
            return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
        }

        cur_src_file_ofs += n;
        cur_dst_file_ofs += n;
    }
    pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf);

    /* Finally, add the new central dir header */
    orig_central_dir_size = pState->m_central_dir.m_size;

    memcpy(new_central_header, pSrc_central_header, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE);

    if (pState->m_zip64)
    {
        /* This is the painful part: We need to write a new central dir header + ext block with updated zip64 fields, and ensure the old fields (if any) are not included. */
        const mz_uint8 *pSrc_ext = pSrc_central_header + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + src_filename_len;
        mz_zip_array new_ext_block;

        mz_zip_array_init(&new_ext_block, sizeof(mz_uint8));

        MZ_WRITE_LE32(new_central_header + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS, MZ_UINT32_MAX);
        MZ_WRITE_LE32(new_central_header + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS, MZ_UINT32_MAX);
        MZ_WRITE_LE32(new_central_header + MZ_ZIP_CDH_LOCAL_HEADER_OFS, MZ_UINT32_MAX);

        if (!mz_zip_writer_update_zip64_extension_block(&new_ext_block, pZip, pSrc_ext, src_ext_len, &src_file_stat.m_comp_size, &src_file_stat.m_uncomp_size, &local_dir_header_ofs, NULL))
        {
            mz_zip_array_clear(pZip, &new_ext_block);
            return MZ_FALSE;
        }

        MZ_WRITE_LE16(new_central_header + MZ_ZIP_CDH_EXTRA_LEN_OFS, new_ext_block.m_size);

        if (!mz_zip_array_push_back(pZip, &pState->m_central_dir, new_central_header, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE))
        {
            mz_zip_array_clear(pZip, &new_ext_block);
            return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
        }

        if (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pSrc_central_header + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE, src_filename_len))
        {
            mz_zip_array_clear(pZip, &new_ext_block);
            mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, MZ_FALSE);
            return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
        }

        if (!mz_zip_array_push_back(pZip, &pState->m_central_dir, new_ext_block.m_p, new_ext_block.m_size))
        {
            mz_zip_array_clear(pZip, &new_ext_block);
            mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, MZ_FALSE);
            return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
        }

        if (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pSrc_central_header + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + src_filename_len + src_ext_len, src_comment_len))
        {
            mz_zip_array_clear(pZip, &new_ext_block);
            mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, MZ_FALSE);
            return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
        }

        mz_zip_array_clear(pZip, &new_ext_block);
    }
    else
    {
        /* sanity checks */
        if (cur_dst_file_ofs > MZ_UINT32_MAX)
            return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE);

        if (local_dir_header_ofs >= MZ_UINT32_MAX)
            return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE);

        MZ_WRITE_LE32(new_central_header + MZ_ZIP_CDH_LOCAL_HEADER_OFS, local_dir_header_ofs);

        if (!mz_zip_array_push_back(pZip, &pState->m_central_dir, new_central_header, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE))
            return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);

        if (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pSrc_central_header + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE, src_central_dir_following_data_size))
        {
            mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, MZ_FALSE);
            return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
        }
    }

    /* This shouldn't trigger unless we screwed up during the initial sanity checks */
    if (pState->m_central_dir.m_size >= MZ_UINT32_MAX)
    {
        /* TODO: Support central dirs >= 32-bits in size */
        mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, MZ_FALSE);
        return mz_zip_set_error(pZip, MZ_ZIP_UNSUPPORTED_CDIR_SIZE);
    }

    n = (mz_uint32)orig_central_dir_size;
    if (!mz_zip_array_push_back(pZip, &pState->m_central_dir_offsets, &n, 1))
    {
        mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, MZ_FALSE);
        return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
    }

    pZip->m_total_files++;
    pZip->m_archive_size = cur_dst_file_ofs;

    return MZ_TRUE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x548, %rsp            # imm = 0x548
xorl %r15d, %r15d
testq %rdi, %rdi
je 0xd32a
movq %rdi, %rbx
movq 0x68(%rdi), %r14
testq %r14, %r14
je 0xd31e
cmpl $0x2, 0x14(%rbx)
jne 0xd31e
movq %rsi, %r12
cmpq $0x0, 0x48(%rsi)
je 0xd31e
movq 0x68(%r12), %rax
cmpl $0x0, 0x64(%rax)
je 0xd2f6
cmpl $0x0, 0x64(%r14)
je 0xd323
testq %r12, %r12
sete %cl
testq %rax, %rax
sete %sil
orb %cl, %sil
jne 0xd33f
cmpl %edx, 0x10(%r12)
jbe 0xd33f
movq 0x20(%rax), %rcx
movl %edx, %esi
movl (%rcx,%rsi,4), %r13d
addq (%rax), %r13
jmp 0xd342
testq %rbx, %rbx
je 0xd32a
movl $0x18, 0x1c(%rbx)
movl %r15d, %eax
addq $0x548, %rsp            # imm = 0x548
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r13d, %r13d
testq %r13, %r13
je 0xd38d
cmpl $0x2014b50, (%r13)      # imm = 0x2014B50
jne 0xd396
movzwl 0x1c(%r13), %r8d
movzwl 0x20(%r13), %esi
movzwl 0x1e(%r13), %edi
leal (%rsi,%r8), %r9d
addl %edi, %r9d
movq 0x8(%r14), %rax
addq %r9, %rax
movabsq $-0xffffffff, %rcx      # imm = 0xFFFFFFFF00000001
addq %rcx, %rax
addq $0x4e, %rax
cmpq %rcx, %rax
jae 0xd3a2
movl $0xf, 0x1c(%rbx)
jmp 0xd39d
movl $0x18, 0x1c(%rbx)
jmp 0xd39d
movl $0x9, 0x1c(%rbx)
xorl %r15d, %r15d
jmp 0xd32a
movq 0x20(%rbx), %r10
testq %r10, %r10
je 0xd3bb
leal -0x1(%r10), %eax
movl (%rbx), %ecx
andl %eax, %ecx
subl %ecx, %r10d
andl %eax, %r10d
jmp 0xd3be
xorl %r10d, %r10d
cmpl $0x0, 0x64(%r14)
movl 0x10(%rbx), %eax
je 0xd5ad
cmpl $-0x1, %eax
je 0xd5b8
movq %r10, -0x30(%rbp)
movq %r9, -0x48(%rbp)
movq %r8, -0x70(%rbp)
movl %edi, -0x74(%rbp)
movq %rsi, -0xe0(%rbp)
xorl %r15d, %r15d
leaq -0x568(%rbp), %rcx
movq %r12, %rdi
movl %edx, %esi
movq %r13, %rdx
xorl %r8d, %r8d
callq 0xa87b
testl %eax, %eax
je 0xd32a
movq -0x528(%rbp), %rsi
movq (%rbx), %rax
movq %rax, -0x50(%rbp)
movq 0x60(%r12), %rdi
leaq -0x110(%rbp), %rdx
movl $0x1e, %ecx
movq %rsi, -0x68(%rbp)
callq *0x48(%r12)
cmpq $0x1e, %rax
jne 0xda49
cmpl $0x4034b50, -0x110(%rbp) # imm = 0x4034B50
jne 0xd5c4
movzwl -0xf6(%rbp), %r8d
movzwl -0xf4(%rbp), %r15d
leal (%r15,%r8), %esi
addq -0x540(%rbp), %rsi
xorl %ecx, %ecx
testl %r15d, %r15d
movq %rsi, -0x60(%rbp)
je 0xd5d0
cmpl $-0x1, -0xfe(%rbp)
movq -0x50(%rbp), %rdx
je 0xd493
cmpl $-0x1, -0xfa(%rbp)
jne 0xd647
xorps %xmm0, %xmm0
movaps %xmm0, -0xa0(%rbp)
movaps %xmm0, -0xb0(%rbp)
movl $0x1, -0x98(%rbp)
movl %r15d, %ecx
cmpq %rcx, -0xa0(%rbp)
movq %rcx, -0x38(%rbp)
jae 0xd4e6
leaq -0xb0(%rbp), %rsi
movq %rbx, %rdi
movq %rcx, %rdx
xorl %ecx, %ecx
movq %r8, -0x58(%rbp)
callq 0xffe4
movq -0x38(%rbp), %rcx
movq -0x58(%rbp), %r8
testl %eax, %eax
je 0xd629
movq %rcx, -0xa8(%rbp)
movq 0x60(%r12), %rdi
movq -0x528(%rbp), %rax
leaq (%r8,%rax), %rsi
addq $0x1e, %rsi
movq -0xb0(%rbp), %rdx
movq %rdx, -0xd8(%rbp)
callq *0x48(%r12)
cmpq -0x38(%rbp), %rax
jne 0xd5d6
movl $0x0, -0x58(%rbp)
movq -0xd8(%rbp), %rsi
cmpl $0x3, %r15d
jbe 0xd541
movzwl 0x2(%rsi), %eax
leaq 0x4(%rax), %rcx
movl %r15d, %edx
subl %ecx, %edx
jae 0xd587
movq 0x40(%rbx), %rdi
movq %r15, -0x38(%rbp)
movq %rsi, %r15
movq -0xb0(%rbp), %rsi
callq *0x30(%rbx)
movq %r15, %rsi
movq -0x38(%rbp), %r15
xorps %xmm0, %xmm0
movaps %xmm0, -0xa0(%rbp)
movaps %xmm0, -0xb0(%rbp)
movl $0x9, 0x1c(%rbx)
movl $0x1, %ecx
xorl %eax, %eax
testl %ecx, %ecx
jne 0xd5fe
testl %r15d, %r15d
jne 0xd52c
jmp 0xd603
cmpw $0x1, (%rsi)
jne 0xd5a1
cmpw $0xf, %ax
jbe 0xd541
movl $0x1, -0x58(%rbp)
movl $0x2, %ecx
jmp 0xd57a
addq %rcx, %rsi
xorl %ecx, %ecx
movb $0x1, %al
movl %edx, %r15d
jmp 0xd57c
cmpl $0xffff, %eax           # imm = 0xFFFF
jne 0xd3d5
movl $0x2, 0x1c(%rbx)
jmp 0xd39d
movl $0x9, 0x1c(%rbx)
jmp 0xd32a
movq -0x50(%rbp), %rdx
jmp 0xd647
movq 0x40(%rbx), %rdi
movq -0xd8(%rbp), %rsi
callq *0x30(%rbx)
xorps %xmm0, %xmm0
movaps %xmm0, -0xa0(%rbp)
movaps %xmm0, -0xb0(%rbp)
movl $0x14, 0x1c(%rbx)
jmp 0xd630
cmpl $0x2, %ecx
jne 0xd624
movq 0x40(%rbx), %rdi
movq -0xb0(%rbp), %rsi
callq *0x30(%rbx)
xorps %xmm0, %xmm0
movaps %xmm0, -0xa0(%rbp)
movaps %xmm0, -0xb0(%rbp)
movb $0x1, %al
movl -0x58(%rbp), %ecx
jmp 0xd634
movl $0x10, 0x1c(%rbx)
xorl %eax, %eax
xorl %ecx, %ecx
xorl %r15d, %r15d
testb %al, %al
movq -0x50(%rbp), %rdx
movq -0x60(%rbp), %rsi
je 0xd32a
movl %ecx, -0x58(%rbp)
cmpl $0x0, 0x64(%r14)
movq -0x30(%rbp), %r15
jne 0xd67d
movl %r15d, %eax
movq 0x8(%r14), %rcx
addq -0x48(%rbp), %rax
addq %rdx, %rax
addq %rsi, %rax
addq %rcx, %rax
addq $0xb2, %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, %rax
jae 0xd7a2
movq %rbx, %rdi
movq %rdx, %rsi
movl %r15d, %edx
callq 0xc227
movq %r15, %rcx
xorl %r15d, %r15d
testl %eax, %eax
je 0xd32a
movl %ecx, %eax
movq -0x50(%rbp), %rsi
addq %rax, %rsi
movq %rsi, -0xe8(%rbp)
movq 0x20(%rbx), %rax
testq %rax, %rax
je 0xd6be
decq %rax
testq %rsi, %rax
jne 0xdd82
movq 0x60(%rbx), %rdi
leaq -0x110(%rbp), %rdx
movl $0x1e, %ecx
movq %rsi, -0x50(%rbp)
callq *0x50(%rbx)
cmpq $0x1e, %rax
jne 0xdd03
movq 0x40(%rbx), %rdi
movl $0x10000, %eax          # imm = 0x10000
movq -0x60(%rbp), %rcx
cmpq %rax, %rcx
cmovbq %rcx, %rax
cmpq $0x21, %rax
movl $0x20, %edx
cmovaeq %rax, %rdx
movl $0x1, %esi
callq *0x28(%rbx)
testq %rax, %rax
je 0xdd76
movq -0x68(%rbp), %rsi
addq $0x1e, %rsi
movq -0x50(%rbp), %rdx
addq $0x1e, %rdx
movq -0x60(%rbp), %rcx
testq %rcx, %rcx
movq %rax, -0x38(%rbp)
movq %rdx, -0x50(%rbp)
je 0xd7ae
movq %rcx, %rdi
movl $0x10000, %edx          # imm = 0x10000
cmpq %rdx, %rdi
movl $0x10000, %ecx          # imm = 0x10000
movq %rdi, -0x60(%rbp)
cmovbq %rdi, %rcx
movq %rcx, -0x30(%rbp)
movq 0x60(%r12), %rdi
movq %rsi, -0x68(%rbp)
movq %rax, %rdx
callq *0x48(%r12)
movq -0x30(%rbp), %rcx
cmpq %rcx, %rax
jne 0xda3b
movq 0x60(%rbx), %rdi
movq -0x50(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq *0x50(%rbx)
movq -0x30(%rbp), %rdx
cmpq %rdx, %rax
jne 0xda55
movq -0x68(%rbp), %rsi
addq %rdx, %rsi
addq %rdx, -0x50(%rbp)
movq -0x60(%rbp), %rdi
subq %rdx, %rdi
movq -0x38(%rbp), %rax
jne 0xd735
jmp 0xd7b1
movl $0x1d, 0x1c(%rbx)
jmp 0xd39d
movl -0x3c(%rbp), %edx
movl %edx, -0x3c(%rbp)
testb $0x8, -0x10a(%rbp)
jne 0xd9f5
movq 0x40(%rbx), %rdi
movq -0x38(%rbp), %rsi
callq *0x30(%rbx)
movq 0x8(%r14), %rax
movq %rax, -0x30(%rbp)
movups (%r13), %xmm0
movups 0x10(%r13), %xmm1
movups 0x1e(%r13), %xmm2
movups %xmm2, -0x92(%rbp)
movaps %xmm1, -0xa0(%rbp)
movaps %xmm0, -0xb0(%rbp)
cmpl $0x0, 0x64(%r14)
je 0xdaf9
leaq -0x540(%rbp), %r8
movq -0x70(%rbp), %rax
leaq (%rax,%r13), %rdx
addq $0x2e, %rdx
xorps %xmm0, %xmm0
leaq -0xd0(%rbp), %rdi
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
movl $0x1, 0x18(%rdi)
leaq -0x538(%rbp), %r9
movq $-0x1, -0x9c(%rbp)
movl $0xffffffff, -0x86(%rbp) # imm = 0xFFFFFFFF
leaq -0xe8(%rbp), %rax
movq %rax, (%rsp)
movq %rbx, %rsi
movq %rdx, -0x60(%rbp)
movl -0x74(%rbp), %ecx
callq 0xdda1
testl %eax, %eax
je 0xdb20
movq -0xc8(%rbp), %rcx
movq %rcx, -0x68(%rbp)
movw %cx, -0x92(%rbp)
movq 0x8(%r14), %r12
leaq 0x2e(%r12), %rax
movq %rax, -0x48(%rbp)
cmpq %rax, 0x10(%r14)
jae 0xd8ad
movq %rbx, %rdi
movq %r14, %rsi
movq -0x48(%rbp), %rdx
movl $0x1, %ecx
callq 0xffe4
testl %eax, %eax
je 0xdd0f
movq -0x48(%rbp), %rax
movq %rax, 0x8(%r14)
movl 0x18(%r14), %eax
imulq %rax, %r12
addq (%r14), %r12
imulq $0x2e, %rax, %rdx
leaq -0xb0(%rbp), %rsi
movq %r12, %rdi
callq 0x31e0
movq 0x8(%r14), %r12
movq -0x70(%rbp), %rax
addq %r12, %rax
movq %rax, -0x48(%rbp)
cmpq %rax, 0x10(%r14)
jae 0xd904
movq %rbx, %rdi
movq %r14, %rsi
movq -0x48(%rbp), %rdx
movl $0x1, %ecx
callq 0xffe4
testl %eax, %eax
je 0xdd30
addq $0x2e, %r13
movq -0x48(%rbp), %rax
movq %rax, 0x8(%r14)
movl 0x18(%r14), %eax
imulq %rax, %r12
addq (%r14), %r12
movq -0x70(%rbp), %rdx
imulq %rax, %rdx
movq %r12, %rdi
movq %r13, %rsi
callq 0x31e0
movq -0xd0(%rbp), %rax
movq %rax, -0x48(%rbp)
movq 0x8(%r14), %r12
movq -0x68(%rbp), %rax
leaq (%r12,%rax), %r13
cmpq %r13, 0x10(%r14)
jae 0xd966
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
movl $0x1, %ecx
callq 0xffe4
testl %eax, %eax
je 0xdca9
movq %r13, 0x8(%r14)
movl 0x18(%r14), %eax
imulq %rax, %r12
addq (%r14), %r12
movq -0x68(%rbp), %rdx
imulq %rax, %rdx
movq %r12, %rdi
movq -0x48(%rbp), %rsi
callq 0x31e0
movq 0x8(%r14), %r12
movq -0xe0(%rbp), %rax
leaq (%r12,%rax), %r13
cmpq %r13, 0x10(%r14)
jae 0xd9b9
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
movl $0x1, %ecx
callq 0xffe4
testl %eax, %eax
je 0xdca9
movl -0x74(%rbp), %eax
movq -0x60(%rbp), %rsi
addq %rax, %rsi
movq %r13, 0x8(%r14)
movl 0x18(%r14), %eax
imulq %rax, %r12
addq (%r14), %r12
movq -0xe0(%rbp), %rdx
imulq %rax, %rdx
movq %r12, %rdi
callq 0x31e0
movq 0x40(%rbx), %rdi
movq -0x48(%rbp), %rsi
callq *0x30(%rbx)
jmp 0xdc08
movq 0x68(%r12), %rcx
movq 0x48(%r12), %rax
movq 0x60(%r12), %rdi
movl -0x58(%rbp), %edx
orl 0x64(%rcx), %edx
je 0xda5d
movl $0x18, %ecx
movq -0x38(%rbp), %rdx
callq *%rax
cmpq $0x18, %rax
jne 0xda3e
xorl %eax, %eax
movq -0x38(%rbp), %rcx
cmpl $0x8074b50, (%rcx)      # imm = 0x8074B50
sete %al
leal 0x14(,%rax,4), %eax
movl %eax, -0x3c(%rbp)
jmp 0xdcd4
movl %ecx, -0x3c(%rbp)
movq 0x40(%rbx), %rdi
movq -0x38(%rbp), %rsi
callq *0x30(%rbx)
movl $0x14, 0x1c(%rbx)
jmp 0xd32a
movl %edx, -0x3c(%rbp)
jmp 0xdcf8
movl $0x10, %ecx
movq -0x38(%rbp), %rdx
callq *%rax
movq %rax, %r12
cmpq $0x10, %rax
jne 0xdb44
movq -0x38(%rbp), %rax
movl (%rax), %eax
movq 0x68(%rbx), %rcx
cmpl $0x0, 0x64(%rcx)
je 0xdcb6
movl $0x8074b50, %esi        # imm = 0x8074B50
xorl %edi, %edi
cmpl %esi, %eax
sete %dil
movq -0x38(%rbp), %rax
movl (%rax,%rdi,4), %edx
movl 0x4(%rax,%rdi,4), %ecx
movl 0x8(%rax,%rdi,4), %edi
movl %esi, (%rax)
movb %dl, 0x4(%rax)
movb %dh, 0x5(%rax)
movl %edx, %esi
shrl $0x10, %esi
movb %sil, 0x6(%rax)
shrl $0x18, %edx
movb %dl, 0x7(%rax)
movb %cl, 0x8(%rax)
movb %ch, 0x9(%rax)
movl %ecx, %edx
shrl $0x10, %edx
movb %dl, 0xa(%rax)
shrl $0x18, %ecx
movb %cl, 0xb(%rax)
xorl %ecx, %ecx
movl %ecx, 0xc(%rax)
movl %edi, %edx
movb %dl, 0x10(%rax)
movb %dh, 0x11(%rax)
movl %edi, %esi
shrl $0x10, %edx
movb %dl, 0x12(%rax)
shrl $0x18, %esi
movb %sil, 0x13(%rax)
movl %ecx, 0x14(%rax)
movl $0x18, %eax
jmp 0xdcc7
movq -0x50(%rbp), %rax
shrq $0x20, %rax
jne 0xdb14
movq -0xe8(%rbp), %rax
movl $0xfffffffe, %ecx       # imm = 0xFFFFFFFE
cmpq %rcx, %rax
jbe 0xdb5b
movl $0x1d, 0x1c(%rbx)
jmp 0xd32a
movq 0x40(%rbx), %rdi
movq -0xd0(%rbp), %rsi
callq *0x30(%rbx)
xorps %xmm0, %xmm0
movaps %xmm0, -0xc0(%rbp)
movaps %xmm0, -0xd0(%rbp)
jmp 0xd32a
movq 0x40(%rbx), %rdi
movq -0x38(%rbp), %rsi
callq *0x30(%rbx)
movl $0x14, 0x1c(%rbx)
jmp 0xdcca
movl %eax, -0x86(%rbp)
movq -0x30(%rbp), %rax
leaq 0x2e(%rax), %r12
cmpq %r12, 0x10(%r14)
jae 0xdb8a
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
movl $0x1, %ecx
callq 0xffe4
testl %eax, %eax
je 0xdd76
movq %r12, 0x8(%r14)
movl 0x18(%r14), %eax
movq -0x30(%rbp), %rdi
imulq %rax, %rdi
addq (%r14), %rdi
imulq $0x2e, %rax, %rdx
leaq -0xb0(%rbp), %rsi
callq 0x31e0
movq 0x8(%r14), %r12
movq -0x48(%rbp), %rax
addq %r12, %rax
movq %rax, -0x70(%rbp)
cmpq %rax, 0x10(%r14)
jae 0xdbde
movq %rbx, %rdi
movq %r14, %rsi
movq -0x70(%rbp), %rdx
movl $0x1, %ecx
callq 0xffe4
testl %eax, %eax
je 0xdd4f
addq $0x2e, %r13
movq -0x70(%rbp), %rax
movq %rax, 0x8(%r14)
movl 0x18(%r14), %eax
imulq %rax, %r12
addq (%r14), %r12
movq -0x48(%rbp), %rdx
imulq %rax, %rdx
movq %r12, %rdi
movq %r13, %rsi
callq 0x31e0
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
cmpq %rax, 0x8(%r14)
jbe 0xdc46
movq -0x30(%rbp), %rax
cmpq %rax, 0x10(%r14)
jae 0xdc32
movq %rbx, %rdi
movq %r14, %rsi
movq -0x30(%rbp), %rdx
xorl %ecx, %ecx
callq 0xffe4
testl %eax, %eax
je 0xdc3a
movq -0x30(%rbp), %rax
movq %rax, 0x8(%r14)
movl $0xf, 0x1c(%rbx)
jmp 0xd32a
movq -0x30(%rbp), %rax
movl %eax, -0x3c(%rbp)
movq 0x28(%r14), %r12
leaq 0x1(%r12), %r13
cmpq %r13, 0x30(%r14)
jae 0xdc78
leaq 0x20(%r14), %rsi
movq %rbx, %rdi
movq %r13, %rdx
movl $0x1, %ecx
callq 0xffe4
testl %eax, %eax
je 0xdd4f
movq %r13, 0x28(%r14)
movl 0x38(%r14), %edx
imulq %rdx, %r12
addq 0x20(%r14), %r12
leaq -0x3c(%rbp), %rsi
movq %r12, %rdi
callq 0x31e0
incl 0x10(%rbx)
movq -0x50(%rbp), %rax
movq %rax, (%rbx)
movl $0x1, %r15d
jmp 0xd32a
movq 0x40(%rbx), %rdi
movq -0x48(%rbp), %rsi
jmp 0xdd3b
xorl %ecx, %ecx
cmpl $0x8074b50, %eax        # imm = 0x8074B50
sete %cl
leal 0xc(,%rcx,4), %eax
movl %eax, -0x3c(%rbp)
cmpq $0x10, %r12
jne 0xd32a
movq 0x60(%rbx), %rdi
movl -0x3c(%rbp), %r12d
movq -0x50(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq %r12, %rcx
callq *0x50(%rbx)
cmpq %r12, %rax
jne 0xdcf8
addq %r12, -0x50(%rbp)
jmp 0xd7c1
movq 0x40(%rbx), %rdi
movq -0x38(%rbp), %rsi
callq *0x30(%rbx)
movl $0x13, 0x1c(%rbx)
jmp 0xd32a
movq 0x40(%rbx), %rdi
movq -0xd0(%rbp), %rsi
callq *0x30(%rbx)
xorps %xmm0, %xmm0
movaps %xmm0, -0xc0(%rbp)
movaps %xmm0, -0xd0(%rbp)
jmp 0xdd76
movq 0x40(%rbx), %rdi
movq -0xd0(%rbp), %rsi
callq *0x30(%rbx)
xorps %xmm0, %xmm0
movaps %xmm0, -0xc0(%rbp)
movaps %xmm0, -0xd0(%rbp)
movq -0x30(%rbp), %rax
cmpq %rax, 0x10(%r14)
jae 0xdd6e
movq %rbx, %rdi
movq %r14, %rsi
movq -0x30(%rbp), %rdx
xorl %ecx, %ecx
callq 0xffe4
testl %eax, %eax
je 0xdd76
movq -0x30(%rbp), %rax
movq %rax, 0x8(%r14)
movl $0x10, 0x1c(%rbx)
jmp 0xd32a
leaq 0x94be(%rip), %rdi      # 0x17247
leaq 0x93ae(%rip), %rsi      # 0x1713e
leaq 0x96dd(%rip), %rcx      # 0x17474
movl $0x1adf, %edx           # imm = 0x1ADF
callq 0x3170