// File: jimmiebergmann[P]fbx-file/miniz.c
// Function: mz_zip_writer_init_v2
mz_bool mz_zip_writer_init_v2(mz_zip_archive *pZip, mz_uint64 existing_size, mz_uint flags)
{
    mz_bool zip64 = (flags & MZ_ZIP_FLAG_WRITE_ZIP64) != 0;

    if ((!pZip) || (pZip->m_pState) || (!pZip->m_pWrite) || (pZip->m_zip_mode != MZ_ZIP_MODE_INVALID))
        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);

    if (flags & MZ_ZIP_FLAG_WRITE_ALLOW_READING)
    {
        if (!pZip->m_pRead)
            return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
    }

    if (pZip->m_file_offset_alignment)
    {
        /* Ensure user specified file offset alignment is a power of 2. */
        if (pZip->m_file_offset_alignment & (pZip->m_file_offset_alignment - 1))
            return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
    }

    if (!pZip->m_pAlloc)
        pZip->m_pAlloc = miniz_def_alloc_func;
    if (!pZip->m_pFree)
        pZip->m_pFree = miniz_def_free_func;
    if (!pZip->m_pRealloc)
        pZip->m_pRealloc = miniz_def_realloc_func;

    pZip->m_archive_size = existing_size;
    pZip->m_central_directory_file_ofs = 0;
    pZip->m_total_files = 0;

    if (NULL == (pZip->m_pState = (mz_zip_internal_state *)pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, sizeof(mz_zip_internal_state))))
        return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);

    memset(pZip->m_pState, 0, sizeof(mz_zip_internal_state));

    MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir, sizeof(mz_uint8));
    MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir_offsets, sizeof(mz_uint32));
    MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_sorted_central_dir_offsets, sizeof(mz_uint32));

    pZip->m_pState->m_zip64 = zip64;
    pZip->m_pState->m_zip64_has_extended_info_fields = zip64;

    pZip->m_zip_type = MZ_ZIP_TYPE_USER;
    pZip->m_zip_mode = MZ_ZIP_MODE_WRITING;

    return MZ_TRUE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x48(%rbp)
movq %rsi, -0x50(%rbp)
movl %edx, -0x54(%rbp)
movl -0x54(%rbp), %eax
andl $0x4000, %eax           # imm = 0x4000
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x58(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x12860
movq -0x48(%rbp), %rax
cmpq $0x0, 0x68(%rax)
jne 0x12860
movq -0x48(%rbp), %rax
cmpq $0x0, 0x50(%rax)
je 0x12860
movq -0x48(%rbp), %rax
cmpl $0x0, 0x14(%rax)
je 0x1288c
movq -0x48(%rbp), %rax
movq %rax, -0x8(%rbp)
movl $0x18, -0xc(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x12880
movl -0xc(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x1c(%rax)
movl $0x0, -0x40(%rbp)
jmp 0x12a69
movl -0x54(%rbp), %eax
andl $0x8000, %eax           # imm = 0x8000
cmpl $0x0, %eax
je 0x128d2
movq -0x48(%rbp), %rax
cmpq $0x0, 0x48(%rax)
jne 0x128d0
movq -0x48(%rbp), %rax
movq %rax, -0x18(%rbp)
movl $0x18, -0x1c(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x128c4
movl -0x1c(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x1c(%rax)
movl $0x0, -0x40(%rbp)
jmp 0x12a69
jmp 0x128d2
movq -0x48(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x12928
movq -0x48(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x48(%rbp), %rcx
movq 0x20(%rcx), %rcx
subq $0x1, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
je 0x12926
movq -0x48(%rbp), %rax
movq %rax, -0x28(%rbp)
movl $0x18, -0x2c(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x1291a
movl -0x2c(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x1c(%rax)
movl $0x0, -0x40(%rbp)
jmp 0x12a69
jmp 0x12928
movq -0x48(%rbp), %rax
cmpq $0x0, 0x28(%rax)
jne 0x12942
movq -0x48(%rbp), %rax
leaq -0xeebe(%rip), %rcx     # 0x3a80
movq %rcx, 0x28(%rax)
movq -0x48(%rbp), %rax
cmpq $0x0, 0x30(%rax)
jne 0x1295c
movq -0x48(%rbp), %rax
leaq -0xeea8(%rip), %rcx     # 0x3ab0
movq %rcx, 0x30(%rax)
movq -0x48(%rbp), %rax
cmpq $0x0, 0x38(%rax)
jne 0x12976
movq -0x48(%rbp), %rax
leaq -0xeea2(%rip), %rcx     # 0x3ad0
movq %rcx, 0x38(%rax)
movq -0x50(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, (%rax)
movq -0x48(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x48(%rbp), %rax
movl $0x0, 0x10(%rax)
movq -0x48(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x48(%rbp), %rcx
movq 0x40(%rcx), %rdi
movl $0x1, %esi
movl $0x98, %edx
callq *%rax
movq %rax, %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x68(%rax)
xorl %eax, %eax
cmpq %rcx, %rax
jne 0x129ef
movq -0x48(%rbp), %rax
movq %rax, -0x38(%rbp)
movl $0x10, -0x3c(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x129e6
movl -0x3c(%rbp), %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0x1c(%rax)
movl $0x0, -0x40(%rbp)
jmp 0x12a69
movq -0x48(%rbp), %rax
movq 0x68(%rax), %rdi
xorl %esi, %esi
movl $0x98, %edx
callq 0x3190
movq -0x48(%rbp), %rax
movq 0x68(%rax), %rax
movl $0x1, 0x18(%rax)
movq -0x48(%rbp), %rax
movq 0x68(%rax), %rax
movl $0x4, 0x38(%rax)
movq -0x48(%rbp), %rax
movq 0x68(%rax), %rax
movl $0x4, 0x58(%rax)
movl -0x58(%rbp), %ecx
movq -0x48(%rbp), %rax
movq 0x68(%rax), %rax
movl %ecx, 0x64(%rax)
movl -0x58(%rbp), %ecx
movq -0x48(%rbp), %rax
movq 0x68(%rax), %rax
movl %ecx, 0x68(%rax)
movq -0x48(%rbp), %rax
movl $0x1, 0x18(%rax)
movq -0x48(%rbp), %rax
movl $0x2, 0x14(%rax)
movl $0x1, -0x40(%rbp)
movl -0x40(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)