// File: jimmiebergmann[P]fbx-file/miniz.c
// Function: mz_zip_writer_end_internal(mz_zip_archive*, int)
static mz_bool mz_zip_writer_end_internal(mz_zip_archive *pZip, mz_bool set_last_error)
{
    mz_zip_internal_state *pState;
    mz_bool status = MZ_TRUE;

    if ((!pZip) || (!pZip->m_pState) || (!pZip->m_pAlloc) || (!pZip->m_pFree) || ((pZip->m_zip_mode != MZ_ZIP_MODE_WRITING) && (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED)))
    {
        if (set_last_error)
            mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
        return MZ_FALSE;
    }

    pState = pZip->m_pState;
    pZip->m_pState = NULL;
    mz_zip_array_clear(pZip, &pState->m_central_dir);
    mz_zip_array_clear(pZip, &pState->m_central_dir_offsets);
    mz_zip_array_clear(pZip, &pState->m_sorted_central_dir_offsets);

#ifndef MINIZ_NO_STDIO
    if (pState->m_pFile)
    {
        if (pZip->m_zip_type == MZ_ZIP_TYPE_FILE)
        {
            if (MZ_FCLOSE(pState->m_pFile) == EOF)
            {
                if (set_last_error)
                    mz_zip_set_error(pZip, MZ_ZIP_FILE_CLOSE_FAILED);
                status = MZ_FALSE;
            }
        }

        pState->m_pFile = NULL;
    }
#endif /* #ifndef MINIZ_NO_STDIO */

    if ((pZip->m_pWrite == mz_zip_heap_write_func) && (pState->m_pMem))
    {
        pZip->m_pFree(pZip->m_pAlloc_opaque, pState->m_pMem);
        pState->m_pMem = NULL;
    }

    pZip->m_pFree(pZip->m_pAlloc_opaque, pState);
    pZip->m_zip_mode = MZ_ZIP_MODE_INVALID;
    return status;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x58(%rbp)
movl %esi, -0x5c(%rbp)
movl $0x1, -0x6c(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0x12de2
movq -0x58(%rbp), %rax
cmpq $0x0, 0x68(%rax)
je 0x12de2
movq -0x58(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x12de2
movq -0x58(%rbp), %rax
cmpq $0x0, 0x30(%rax)
je 0x12de2
movq -0x58(%rbp), %rax
cmpl $0x2, 0x14(%rax)
je 0x12e16
movq -0x58(%rbp), %rax
cmpl $0x3, 0x14(%rax)
je 0x12e16
cmpl $0x0, -0x5c(%rbp)
je 0x12e0a
movq -0x58(%rbp), %rax
movq %rax, -0x38(%rbp)
movl $0x18, -0x3c(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x12e08
movl -0x3c(%rbp), %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0x1c(%rax)
jmp 0x12e0a
movl $0x0, -0x50(%rbp)
jmp 0x12fb7
movq -0x58(%rbp), %rax
movq 0x68(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x58(%rbp), %rax
movq $0x0, 0x68(%rax)
movq -0x58(%rbp), %rcx
movq -0x68(%rbp), %rax
movq %rcx, -0x8(%rbp)
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x40(%rcx), %rdi
movq -0x10(%rbp), %rcx
movq (%rcx), %rsi
callq *%rax
movq -0x10(%rbp), %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x3190
movq -0x58(%rbp), %rcx
movq -0x68(%rbp), %rax
addq $0x20, %rax
movq %rcx, -0x18(%rbp)
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x18(%rbp), %rcx
movq 0x40(%rcx), %rdi
movq -0x20(%rbp), %rcx
movq (%rcx), %rsi
callq *%rax
movq -0x20(%rbp), %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x3190
movq -0x58(%rbp), %rcx
movq -0x68(%rbp), %rax
addq $0x40, %rax
movq %rcx, -0x28(%rbp)
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x28(%rbp), %rcx
movq 0x40(%rcx), %rdi
movq -0x30(%rbp), %rcx
movq (%rcx), %rsi
callq *%rax
movq -0x30(%rbp), %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x3190
movq -0x68(%rbp), %rax
cmpq $0x0, 0x70(%rax)
je 0x12f45
movq -0x58(%rbp), %rax
cmpl $0x4, 0x18(%rax)
jne 0x12f39
movq -0x68(%rbp), %rax
movq 0x70(%rax), %rdi
callq 0x3300
cmpl $-0x1, %eax
jne 0x12f37
cmpl $0x0, -0x5c(%rbp)
je 0x12f30
movq -0x58(%rbp), %rax
movq %rax, -0x48(%rbp)
movl $0x15, -0x4c(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x12f2e
movl -0x4c(%rbp), %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0x1c(%rax)
jmp 0x12f30
movl $0x0, -0x6c(%rbp)
jmp 0x12f39
movq -0x68(%rbp), %rax
movq $0x0, 0x70(%rax)
movq -0x58(%rbp), %rax
leaq -0x360(%rip), %rcx      # 0x12bf0
cmpq %rcx, 0x50(%rax)
jne 0x12f90
movq -0x68(%rbp), %rax
cmpq $0x0, 0x80(%rax)
je 0x12f90
movq -0x58(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x58(%rbp), %rcx
movq 0x40(%rcx), %rdi
movq -0x68(%rbp), %rcx
movq 0x80(%rcx), %rsi
callq *%rax
movq -0x68(%rbp), %rax
movq $0x0, 0x80(%rax)
movq -0x58(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x58(%rbp), %rcx
movq 0x40(%rcx), %rdi
movq -0x68(%rbp), %rsi
callq *%rax
movq -0x58(%rbp), %rax
movl $0x0, 0x14(%rax)
movl -0x6c(%rbp), %eax
movl %eax, -0x50(%rbp)
movl -0x50(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq