// File: jimmiebergmann[P]fbx-file/miniz.c
// Function: mz_zip_validate_archive
mz_bool mz_zip_validate_archive(mz_zip_archive *pZip, mz_uint flags)
{
    mz_zip_internal_state *pState;
    uint32_t i;

    if ((!pZip) || (!pZip->m_pState) || (!pZip->m_pAlloc) || (!pZip->m_pFree) || (!pZip->m_pRead))
        return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);

    pState = pZip->m_pState;

    /* Basic sanity checks */
    if (!pState->m_zip64)
    {
        if (pZip->m_total_files > MZ_UINT16_MAX)
            return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE);

        if (pZip->m_archive_size > MZ_UINT32_MAX)
            return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE);
    }
    else
    {
        if (pZip->m_total_files >= MZ_UINT32_MAX)
            return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE);

        if (pState->m_central_dir.m_size >= MZ_UINT32_MAX)
            return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE);
    }

    for (i = 0; i < pZip->m_total_files; i++)
    {
        if (MZ_ZIP_FLAG_VALIDATE_LOCATE_FILE_FLAG & flags)
        {
            mz_uint32 found_index;
            mz_zip_archive_file_stat stat;

            if (!mz_zip_reader_file_stat(pZip, i, &stat))
                return MZ_FALSE;

            if (!mz_zip_reader_locate_file_v2(pZip, stat.m_filename, NULL, 0, &found_index))
                return MZ_FALSE;

            /* This check can fail if there are duplicate filenames in the archive (which we don't check for when writing - that's up to the user) */
            if (found_index != i)
                return mz_zip_set_error(pZip, MZ_ZIP_VALIDATION_FAILED);
        }

        if (!mz_zip_validate_file(pZip, i, flags))
            return MZ_FALSE;
    }

    return MZ_TRUE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4e0, %rsp            # imm = 0x4E0
movq %rdi, -0x68(%rbp)
movl %esi, -0x6c(%rbp)
cmpq $0x0, -0x68(%rbp)
je 0x123c5
movq -0x68(%rbp), %rax
cmpq $0x0, 0x68(%rax)
je 0x123c5
movq -0x68(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x123c5
movq -0x68(%rbp), %rax
cmpq $0x0, 0x30(%rax)
je 0x123c5
movq -0x68(%rbp), %rax
cmpq $0x0, 0x48(%rax)
jne 0x123f1
movq -0x68(%rbp), %rax
movq %rax, -0x8(%rbp)
movl $0x18, -0xc(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x123e5
movl -0xc(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x1c(%rax)
movl $0x0, -0x60(%rbp)
jmp 0x125ce
movq -0x68(%rbp), %rax
movq 0x68(%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
cmpl $0x0, 0x64(%rax)
jne 0x1247c
movq -0x68(%rbp), %rax
cmpl $0xffff, 0x10(%rax)     # imm = 0xFFFF
jbe 0x12440
movq -0x68(%rbp), %rax
movq %rax, -0x18(%rbp)
movl $0x1d, -0x1c(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x12434
movl -0x1c(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x1c(%rax)
movl $0x0, -0x60(%rbp)
jmp 0x125ce
movq -0x68(%rbp), %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, (%rax)
jbe 0x1247a
movq -0x68(%rbp), %rax
movq %rax, -0x28(%rbp)
movl $0x1d, -0x2c(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x1246e
movl -0x2c(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x1c(%rax)
movl $0x0, -0x60(%rbp)
jmp 0x125ce
jmp 0x124ef
movq -0x68(%rbp), %rax
cmpl $-0x1, 0x10(%rax)
jb 0x124b2
movq -0x68(%rbp), %rax
movq %rax, -0x38(%rbp)
movl $0x1d, -0x3c(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x124a6
movl -0x3c(%rbp), %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0x1c(%rax)
movl $0x0, -0x60(%rbp)
jmp 0x125ce
movq -0x78(%rbp), %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, 0x8(%rax)
jb 0x124ed
movq -0x68(%rbp), %rax
movq %rax, -0x48(%rbp)
movl $0x1d, -0x4c(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x124e1
movl -0x4c(%rbp), %ecx
movq -0x48(%rbp), %rax
movl %ecx, 0x1c(%rax)
movl $0x0, -0x60(%rbp)
jmp 0x125ce
jmp 0x124ef
movl $0x0, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
movq -0x68(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jae 0x125c7
movl -0x6c(%rbp), %eax
andl $0x1000, %eax           # imm = 0x1000
cmpl $0x0, %eax
je 0x1259a
movq -0x68(%rbp), %rdi
movl -0x7c(%rbp), %esi
leaq -0x4d8(%rbp), %rdx
callq 0xeda0
cmpl $0x0, %eax
jne 0x1253b
movl $0x0, -0x60(%rbp)
jmp 0x125ce
movq -0x68(%rbp), %rdi
leaq -0x4d8(%rbp), %rsi
addq $0x58, %rsi
xorl %eax, %eax
movl %eax, %edx
xorl %ecx, %ecx
leaq -0x80(%rbp), %r8
callq 0xdac0
cmpl $0x0, %eax
jne 0x12567
movl $0x0, -0x60(%rbp)
jmp 0x125ce
movl -0x80(%rbp), %eax
cmpl -0x7c(%rbp), %eax
je 0x12598
movq -0x68(%rbp), %rax
movq %rax, -0x58(%rbp)
movl $0x1e, -0x5c(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0x1258f
movl -0x5c(%rbp), %ecx
movq -0x58(%rbp), %rax
movl %ecx, 0x1c(%rax)
movl $0x0, -0x60(%rbp)
jmp 0x125ce
jmp 0x1259a
movq -0x68(%rbp), %rdi
movl -0x7c(%rbp), %esi
movl -0x6c(%rbp), %edx
callq 0x10f00
cmpl $0x0, %eax
jne 0x125b7
movl $0x0, -0x60(%rbp)
jmp 0x125ce
jmp 0x125b9
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x124f6
movl $0x1, -0x60(%rbp)
movl -0x60(%rbp), %eax
addq $0x4e0, %rsp            # imm = 0x4E0
popq %rbp
retq
nopw (%rax,%rax)