// File: /workspace/github_cpp_makefile_star2_O2/jimmiebergmann[P]fbx-file/miniz.c
// Function: mz_zip_add_mem_to_archive_file_in_place_v2
mz_bool mz_zip_add_mem_to_archive_file_in_place_v2(const char *pZip_filename, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, mz_zip_error *pErr)
{
    mz_bool status, created_new_archive = MZ_FALSE;
    mz_zip_archive zip_archive;
    struct MZ_FILE_STAT_STRUCT file_stat;
    mz_zip_error actual_err = MZ_ZIP_NO_ERROR;

    mz_zip_zero_struct(&zip_archive);
    if ((int)level_and_flags < 0)
        level_and_flags = MZ_DEFAULT_LEVEL;

    if ((!pZip_filename) || (!pArchive_name) || ((buf_size) && (!pBuf)) || ((comment_size) && (!pComment)) || ((level_and_flags & 0xF) > MZ_UBER_COMPRESSION))
    {
        if (pErr)
            *pErr = MZ_ZIP_INVALID_PARAMETER;
        return MZ_FALSE;
    }

    if (!mz_zip_writer_validate_archive_name(pArchive_name))
    {
        if (pErr)
            *pErr = MZ_ZIP_INVALID_FILENAME;
        return MZ_FALSE;
    }

    /* Important: The regular non-64 bit version of stat() can fail here if the file is very large, which could cause the archive to be overwritten. */
    /* So be sure to compile with _LARGEFILE64_SOURCE 1 */
    if (MZ_FILE_STAT(pZip_filename, &file_stat) != 0)
    {
        /* Create a new archive. */
        if (!mz_zip_writer_init_file_v2(&zip_archive, pZip_filename, 0, level_and_flags))
        {
            if (pErr)
                *pErr = zip_archive.m_last_error;
            return MZ_FALSE;
        }

        created_new_archive = MZ_TRUE;
    }
    else
    {
        /* Append to an existing archive. */
        if (!mz_zip_reader_init_file_v2(&zip_archive, pZip_filename, level_and_flags | MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY, 0, 0))
        {
            if (pErr)
                *pErr = zip_archive.m_last_error;
            return MZ_FALSE;
        }

        if (!mz_zip_writer_init_from_reader_v2(&zip_archive, pZip_filename, level_and_flags))
        {
            if (pErr)
                *pErr = zip_archive.m_last_error;

            mz_zip_reader_end_internal(&zip_archive, MZ_FALSE);

            return MZ_FALSE;
        }
    }

    status = mz_zip_writer_add_mem_ex(&zip_archive, pArchive_name, pBuf, buf_size, pComment, comment_size, level_and_flags, 0, 0);
    actual_err = zip_archive.m_last_error;

    /* Always finalize, even if adding failed for some reason, so we have a valid central directory. (This may not always succeed, but we can try.) */
    if (!mz_zip_writer_finalize_archive(&zip_archive))
    {
        if (!actual_err)
            actual_err = zip_archive.m_last_error;

        status = MZ_FALSE;
    }

    if (!mz_zip_writer_end_internal(&zip_archive, status))
    {
        if (!actual_err)
            actual_err = zip_archive.m_last_error;

        status = MZ_FALSE;
    }

    if ((!status) && (created_new_archive))
    {
        /* It's a new archive and something went wrong, so just delete it. */
        int ignoredStatus = MZ_DELETE_FILE(pZip_filename);
        (void)ignoredStatus;
    }

    if (pErr)
        *pErr = actual_err;

    return status;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdx, %r13
movq %rsi, %r15
movq 0x18(%rbp), %rdx
movl 0x10(%rbp), %eax
xorps %xmm0, %xmm0
movaps %xmm0, -0xb0(%rbp)
movaps %xmm0, -0xa0(%rbp)
movaps %xmm0, -0x90(%rbp)
movaps %xmm0, -0x80(%rbp)
movaps %xmm0, -0x70(%rbp)
movaps %xmm0, -0x60(%rbp)
movaps %xmm0, -0x50(%rbp)
testl %eax, %eax
pushq $0x6
popq %r12
cmovnsl %eax, %r12d
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %sil
orb %al, %sil
jne 0xdf54
testq %rcx, %rcx
setne %al
testq %r13, %r13
sete %sil
testb %al, %sil
jne 0xdf54
movq %r8, %r14
testw %r9w, %r9w
sete %al
testq %r8, %r8
setne %sil
orb %al, %sil
movl %r12d, %eax
andl $0xf, %eax
cmpl $0xb, %eax
setb %al
testb %al, %sil
jne 0xdf77
xorl %r14d, %r14d
testq %rdx, %rdx
je 0xdf62
movl $0x18, (%rdx)
movl %r14d, %eax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdi, %rbx
movl %r9d, -0x30(%rbp)
movq %rcx, -0x40(%rbp)
movq %r15, %rdi
callq 0xbec4
testl %eax, %eax
je 0xdfc8
movq %r14, -0x38(%rbp)
leaq -0x140(%rbp), %rsi
movq %rbx, %rdi
callq 0x3430
movl %eax, -0x2c(%rbp)
testl %eax, %eax
je 0xdfdc
xorl %r14d, %r14d
leaq -0xb0(%rbp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
movl %r12d, %ecx
callq 0xb00c
testl %eax, %eax
jne 0xe01e
jmp 0xe0b5
xorl %r14d, %r14d
movq 0x18(%rbp), %rax
testq %rax, %rax
je 0xdf62
movl $0x19, (%rax)
jmp 0xdf62
movl %r12d, %edx
orl $0x800, %edx            # imm = 0x800
xorl %r14d, %r14d
leaq -0xb0(%rbp), %rdi
movq %rbx, %rsi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x86e7
testl %eax, %eax
je 0xe0b5
leaq -0xb0(%rbp), %rdi
movq %rbx, %rsi
movl %r12d, %edx
callq 0xb226
testl %eax, %eax
je 0xe0cf
subq $0x8, %rsp
movzwl -0x30(%rbp), %r9d
leaq -0xb0(%rbp), %rdi
movq %r15, %rsi
movq %r13, %rdx
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %r8
pushq $0x0
pushq $0x0
pushq %r12
movq %rdi, %r12
callq 0xb3c1
addq $0x20, %rsp
movl %eax, %r14d
movl 0x1c(%r12), %r15d
movq %r12, %rdi
callq 0xda2f
testl %eax, %eax
cmovel %eax, %r14d
orl %r15d, %eax
jne 0xe070
movl -0x94(%rbp), %r15d
movq %r12, %rdi
movl %r14d, %esi
callq 0xaed8
testl %eax, %eax
cmovel %eax, %r14d
orl %r15d, %eax
jne 0xe08d
movl -0x94(%rbp), %r15d
cmpl $0x0, -0x2c(%rbp)
je 0xe0a0
testl %r14d, %r14d
jne 0xe0a0
movq %rbx, %rdi
callq 0x3470
movq 0x18(%rbp), %rax
testq %rax, %rax
je 0xdf62
movl %r15d, (%rax)
jmp 0xdf62
movq 0x18(%rbp), %rcx
testq %rcx, %rcx
je 0xdf62
movl -0x94(%rbp), %eax
movl %eax, (%rcx)
jmp 0xdf62
movq 0x18(%rbp), %rcx
testq %rcx, %rcx
je 0xe0e0
movl -0x94(%rbp), %eax
movl %eax, (%rcx)
leaq -0xb0(%rbp), %rdi
xorl %r14d, %r14d
xorl %esi, %esi
callq 0x7ac9
jmp 0xdf62