// File: /workspace/github_cpp_makefile_star2_O1/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 0xe4ea
testq %rcx, %rcx
setne %al
testq %r12, %r12
sete %sil
testb %al, %sil
jne 0xe4ea
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 0xe50d
xorl %r13d, %r13d
testq %rdx, %rdx
je 0xe4f8
movl $0x18, (%rdx)
movl %r13d, %eax
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpb $0x2f, (%r14)
jne 0xe523
xorl %r13d, %r13d
testq %rdx, %rdx
je 0xe4f8
movl $0x19, (%rdx)
jmp 0xe4f8
movq %rdi, %rbx
movq %r14, %rax
movzbl (%rax), %esi
testl %esi, %esi
je 0xe53f
cmpl $0x3a, %esi
je 0xe513
cmpl $0x5c, %esi
je 0xe513
incq %rax
jmp 0xe529
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 0xe581
xorl %r13d, %r13d
leaq -0xb0(%rbp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
movl %r15d, %ecx
callq 0xb265
testl %eax, %eax
jne 0xe5c3
jmp 0xe66f
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 0x86eb
testl %eax, %eax
je 0xe66f
leaq -0xb0(%rbp), %rdi
movq %rbx, %rsi
movl %r15d, %edx
callq 0xb4b2
testl %eax, %eax
je 0xe689
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 0xb6b3
movl %eax, %r13d
movl 0x1c(%r15), %r14d
movq %r15, %rdi
callq 0xdfe9
testl %eax, %eax
cmovel %eax, %r13d
orl %r14d, %eax
jne 0xe62a
movl -0x94(%rbp), %r14d
movq %r15, %rdi
movl %r13d, %esi
callq 0xb118
testl %eax, %eax
cmovel %eax, %r13d
orl %r14d, %eax
jne 0xe647
movl -0x94(%rbp), %r14d
cmpl $0x0, -0x2c(%rbp)
je 0xe65a
testl %r13d, %r13d
jne 0xe65a
movq %rbx, %rdi
callq 0x3450
movq 0x18(%rbp), %rax
testq %rax, %rax
je 0xe4f8
movl %r14d, (%rax)
jmp 0xe4f8
movq 0x18(%rbp), %rcx
testq %rcx, %rcx
je 0xe4f8
movl -0x94(%rbp), %eax
movl %eax, (%rcx)
jmp 0xe4f8
movq 0x18(%rbp), %rcx
testq %rcx, %rcx
je 0xe69a
movl -0x94(%rbp), %eax
movl %eax, (%rcx)
leaq -0xb0(%rbp), %rdi
xorl %r13d, %r13d
xorl %esi, %esi
callq 0x7dc3
jmp 0xe4f8