// File: /workspace/github_cpp_makefile_star2_O3/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 $0x158, %rsp            # imm = 0x158
movq %rdx, %r12
movq %rsi, %r14
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
movl $0x6, %r15d
cmovnsl %eax, %r15d
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %sil
orb %al, %sil
jne 0xe1be
testq %rcx, %rcx
setne %al
testq %r12, %r12
sete %sil
testb %al, %sil
jne 0xe1be
testw %r9w, %r9w
sete %al
testq %r8, %r8
setne %sil
orb %al, %sil
movl %r15d, %eax
andl $0xf, %eax
cmpl $0xb, %eax
setb %al
testb %al, %sil
jne 0xe1e1
xorl %r13d, %r13d
testq %rdx, %rdx
je 0xe1cc
movl $0x18, (%rdx)
movl %r13d, %eax
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb (%r14), %sil
cmpb $0x2f, %sil
jne 0xe1fa
xorl %r13d, %r13d
testq %rdx, %rdx
je 0xe1cc
movl $0x19, (%rdx)
jmp 0xe1cc
movq %rdi, %rbx
leaq 0x1(%r14), %rax
testb %sil, %sil
je 0xe21c
movzbl %sil, %esi
cmpl $0x3a, %esi
je 0xe1ea
cmpl $0x5c, %esi
je 0xe1ea
movb (%rax), %sil
incq %rax
jmp 0xe201
movl %r9d, -0x30(%rbp)
movq %rcx, -0x38(%rbp)
movq %r8, -0x40(%rbp)
leaq -0x140(%rbp), %rsi
movq %rbx, %rdi
callq 0x3410
movl %eax, -0x2c(%rbp)
testl %eax, %eax
je 0xe25e
xorl %r13d, %r13d
leaq -0xb0(%rbp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
movl %r15d, %ecx
callq 0xb169
testl %eax, %eax
jne 0xe2a0
jmp 0xe34c
movl %r15d, %edx
orl $0x800, %edx            # imm = 0x800
xorl %r13d, %r13d
leaq -0xb0(%rbp), %rdi
movq %rbx, %rsi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x8744
testl %eax, %eax
je 0xe34c
leaq -0xb0(%rbp), %rdi
movq %rbx, %rsi
movl %r15d, %edx
callq 0xb39b
testl %eax, %eax
je 0xe366
xorl %eax, %eax
movl %eax, 0x38(%rsp)
movq %rax, 0x30(%rsp)
movl %eax, 0x28(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rsp)
movl %eax, 0x10(%rsp)
movq %rax, 0x8(%rsp)
movl %r15d, (%rsp)
movzwl -0x30(%rbp), %r9d
leaq -0xb0(%rbp), %r15
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq -0x38(%rbp), %rcx
movq -0x40(%rbp), %r8
callq 0xb59b
movl %eax, %r13d
movl 0x1c(%r15), %r14d
movq %r15, %rdi
callq 0xdc90
testl %eax, %eax
cmovel %eax, %r13d
orl %r14d, %eax
jne 0xe307
movl -0x94(%rbp), %r14d
movq %r15, %rdi
movl %r13d, %esi
callq 0xb027
testl %eax, %eax
cmovel %eax, %r13d
orl %r14d, %eax
jne 0xe324
movl -0x94(%rbp), %r14d
cmpl $0x0, -0x2c(%rbp)
je 0xe337
testl %r13d, %r13d
jne 0xe337
movq %rbx, %rdi
callq 0x3450
movq 0x18(%rbp), %rax
testq %rax, %rax
je 0xe1cc
movl %r14d, (%rax)
jmp 0xe1cc
movq 0x18(%rbp), %rcx
testq %rcx, %rcx
je 0xe1cc
movl -0x94(%rbp), %eax
movl %eax, (%rcx)
jmp 0xe1cc
movq 0x18(%rbp), %rcx
testq %rcx, %rcx
je 0xe377
movl -0x94(%rbp), %eax
movl %eax, (%rcx)
leaq -0xb0(%rbp), %rdi
xorl %r13d, %r13d
xorl %esi, %esi
callq 0x7dd1
jmp 0xe1cc