// File: /workspace/github_cpp_makefile_star2_O1/sisong[P]ApkDiffPatch/src/patch/Zipper.cpp
// Function: UnZipper_vce_normalized(UnZipper*, bool, unsigned int*)
static bool _UnZipper_vce_normalized(UnZipper* self,bool isFileDataOffsetMatch,ZipFilePos_t* out_fileDataEndPos){
    assert(self->_endCentralDirectory!=0);
    writeUInt32_to(self->_endCentralDirectory+16,0);//normalized CentralDirectory的开始位置偏移;
    self->_isFileDataOffsetMatch=isFileDataOffsetMatch;
    bool test_isFileDataOffsetMatch=true;
    
    assert(self->_centralDirectory!=0);
    TByte* buf=self->_centralDirectory;
    const int fileCount=UnZipper_fileCount(self);
    size_t centralDirectory_size=_centralDirectory_size(self);
    ZipFilePos_t curOffset=0;
    memset(self->_dataDescriptors,kDataDescriptor_NO,fileCount);
    self->_dataDescriptorCount=0;
    *out_fileDataEndPos=0;
    for (int i=0; i<fileCount; ++i) {
        TByte* headBuf=buf+curOffset;
        check(kCENTRALHEADERMAGIC==readUInt32(headBuf));
        self->_fileHeaderOffsets[i]=curOffset;
        
        self->_fileCompressedSizes[i]=readUInt32(headBuf+20);
        writeUInt32_to(headBuf+20,0);//normalized 压缩大小占位;
        
        ZipFilePos_t fileEntryOffset=readUInt32(headBuf+42);
        if (self->_fileEntryOffsets)
            self->_fileEntryOffsets[i]=fileEntryOffset;
        writeUInt32_to(headBuf+42,0);//normalized 文件Entry开始位置偏移;
        ZipFilePos_t fastFileDataOffset=(fileEntryOffset+30+readUInt16(headBuf+28)+readUInt16(headBuf+30)); //fast
        if (isFileDataOffsetMatch){
            self->_fileDataOffsets[i]=fastFileDataOffset;
        }else{
            ZipFilePos_t fileDataOffset=_fileData_offset_read(self,fileEntryOffset);//seek&read;
            self->_fileDataOffsets[i]=fileDataOffset;
            test_isFileDataOffsetMatch&=(fileDataOffset==fastFileDataOffset);
        }
        ZipFilePos_t curFileDataEndPos=self->_fileDataOffsets[i]+self->_fileCompressedSizes[i];
        if (curFileDataEndPos>*out_fileDataEndPos)
            *out_fileDataEndPos=curFileDataEndPos;
        
        uint16_t fileTag=readUInt16(headBuf+8);//标志;
        if ((fileTag&(1<<3))!=0){//have descriptor?
            writeUInt16_to(headBuf+8,fileTag&(~(1<<3)));//normalized 标志中去掉data descriptor标识;
            const uint32_t crc=UnZipper_file_crc32(self,i);
            const ZipFilePos_t uncompressedSize=UnZipper_file_uncompressedSize(self,i);
            TByte buf[16];
            check(UnZipper_fileData_read(self,self->_fileDataOffsets[i]+self->_fileCompressedSizes[i],buf,buf+16));
            if ((readUInt32(buf)==crc)&&(readUInt32(buf+8)==uncompressedSize))
                self->_dataDescriptors[i]=kDataDescriptor_12;
            else if ((readUInt32(buf+4)==crc)&&(readUInt32(buf+12)==uncompressedSize))
                self->_dataDescriptors[i]=kDataDescriptor_16;
            else {
                //check(false);
                printf("WARNING: zip format error, unknow data descriptor!\n");
                self->_dataDescriptors[i]=kDataDescriptor_12;
            }
            ++self->_dataDescriptorCount;
        }
        
        int fileNameLen=UnZipper_file_nameLen(self,i);
        int extraFieldLen=readUInt16(headBuf+30);
        int fileCommentLen=readUInt16(headBuf+32);
        curOffset+= kMinFileHeaderSize + fileNameLen+extraFieldLen+fileCommentLen;
        check((size_t)curOffset <= centralDirectory_size);
    }
    
    //update
    self->_isFileDataOffsetMatch=test_isFileDataOffsetMatch;
    
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdx, 0x28(%rsp)
movq 0x48(%rdi), %rax
testq %rax, %rax
je 0x40785
movl %esi, %ebp
movq %rdi, %rbx
movl $0x0, 0x10(%rax)
movb %bpl, 0x8a(%rdi)
movq 0x50(%rdi), %rax
movq %rax, 0x20(%rsp)
testq %rax, %rax
je 0x407a4
movq 0x48(%rbx), %rax
movq 0x68(%rbx), %rdi
movzwl 0x8(%rax), %r14d
movslq 0xc(%rax), %rax
movq %rax, 0x40(%rsp)
xorl %r13d, %r13d
xorl %esi, %esi
movq %r14, %rdx
callq 0x41c0
movl %r13d, 0x70(%rbx)
movq 0x28(%rsp), %rax
movl %r13d, (%rax)
testl %r14d, %r14d
je 0x406f2
movl %ebp, 0x34(%rsp)
movl %r14d, %eax
movq %rax, 0x38(%rsp)
movb $0x1, 0xf(%rsp)
xorl %r12d, %r12d
movq 0x20(%rsp), %rsi
movl %r13d, %ebp
cmpl $0x2014b50, (%rsi,%rbp) # imm = 0x2014B50
jne 0x40728
movq 0x58(%rbx), %rax
movl %r13d, (%rax,%r12,4)
movl 0x14(%rsi,%rbp), %eax
movq 0x60(%rbx), %rcx
movl %eax, (%rcx,%r12,4)
movl $0x0, 0x14(%rsi,%rbp)
movl 0x2a(%rsi,%rbp), %r14d
movq 0x80(%rbx), %rax
testq %rax, %rax
je 0x4058c
movl %r14d, (%rax,%r12,4)
movl $0x0, 0x2a(%rsi,%rbp)
movzwl 0x1c(%rsi,%rbp), %eax
addl %r14d, %eax
addl $0x1e, %eax
movzwl 0x1e(%rsi,%rbp), %r15d
addl %eax, %r15d
cmpb $0x0, 0x34(%rsp)
je 0x405b9
movq 0x78(%rbx), %rax
movl %r15d, (%rax,%r12,4)
jmp 0x405ff
leal 0x1a(%r14), %esi
movq (%rbx), %rdi
leaq 0x10(%rsp), %rdx
leaq 0x14(%rsp), %rcx
callq *0x10(%rdi)
testl %eax, %eax
je 0x40766
addl $0x1e, %r14d
movzwl 0x10(%rsp), %eax
movzwl 0x12(%rsp), %ecx
addl %eax, %ecx
addl %r14d, %ecx
movq 0x78(%rbx), %rax
movl %ecx, (%rax,%r12,4)
cmpl %r15d, %ecx
sete %al
andb %al, 0xf(%rsp)
movq 0x20(%rsp), %rsi
movq 0x60(%rbx), %rax
movq 0x78(%rbx), %rcx
movl (%rax,%r12,4), %eax
addl (%rcx,%r12,4), %eax
movq 0x28(%rsp), %rcx
cmpl (%rcx), %eax
jbe 0x4061f
movq 0x28(%rsp), %rcx
movl %eax, (%rcx)
movb 0x8(%rsi,%rbp), %al
testb $0x8, %al
je 0x406ad
andb $-0x9, %al
movb %al, 0x8(%rsi,%rbp)
movq 0x50(%rbx), %rax
movq 0x58(%rbx), %rcx
movl (%rcx,%r12,4), %ecx
movl 0x10(%rax,%rcx), %r15d
movl 0x18(%rax,%rcx), %r14d
movq 0x78(%rbx), %rax
movq (%rbx), %rdi
movq 0x60(%rbx), %rcx
movl (%rcx,%r12,4), %esi
addl (%rax,%r12,4), %esi
leaq 0x10(%rsp), %rdx
leaq 0x20(%rsp), %rcx
callq *0x10(%rdi)
testl %eax, %eax
je 0x40747
cmpl %r15d, 0x10(%rsp)
jne 0x4067f
movb $0x1, %al
cmpl %r14d, 0x18(%rsp)
je 0x4069d
cmpl %r15d, 0x14(%rsp)
jne 0x4068f
movb $0x2, %al
cmpl %r14d, 0x1c(%rsp)
je 0x4069d
leaq 0x20be6(%rip), %rdi     # 0x6127c
callq 0x44e0
movb $0x1, %al
movq 0x68(%rbx), %rcx
movb %al, (%rcx,%r12)
incl 0x70(%rbx)
movq 0x20(%rsp), %rsi
movq 0x50(%rbx), %rax
movq 0x58(%rbx), %rcx
movl (%rcx,%r12,4), %ecx
movzwl 0x1c(%rax,%rcx), %eax
movzwl 0x1e(%rsi,%rbp), %ecx
movzwl 0x20(%rsi,%rbp), %edx
addl %ecx, %r13d
addl %eax, %r13d
addl %edx, %r13d
addl $0x2e, %r13d
cmpq 0x40(%rsp), %r13
ja 0x40709
incq %r12
cmpq %r12, 0x38(%rsp)
jne 0x4054b
movb 0xf(%rsp), %al
andb $0x1, %al
jmp 0x406f4
movb $0x1, %al
movb %al, 0x8a(%rbx)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x19940(%rip), %rdi     # 0x5a050
leaq 0x1fb4a(%rip), %rsi     # 0x60261
leaq 0x206fd(%rip), %rcx     # 0x60e1b
movl $0x1ac, %edx            # imm = 0x1AC
callq 0x4200
leaq 0x19921(%rip), %rdi     # 0x5a050
leaq 0x1fb2b(%rip), %rsi     # 0x60261
leaq 0x206de(%rip), %rcx     # 0x60e1b
movl $0x17f, %edx            # imm = 0x17F
callq 0x4200
leaq 0x19902(%rip), %rdi     # 0x5a050
leaq 0x1fb0c(%rip), %rsi     # 0x60261
leaq 0x206bf(%rip), %rcx     # 0x60e1b
movl $0x19b, %edx            # imm = 0x19B
callq 0x4200
leaq 0x198e3(%rip), %rdi     # 0x5a050
leaq 0x1faed(%rip), %rsi     # 0x60261
leaq 0x206fb(%rip), %rcx     # 0x60e76
movl $0xcf, %edx
callq 0x4200
leaq 0x20671(%rip), %rdi     # 0x60dfd
leaq 0x1face(%rip), %rsi     # 0x60261
leaq 0x20681(%rip), %rcx     # 0x60e1b
movl $0x170, %edx            # imm = 0x170
callq 0x4200
leaq 0x206b0(%rip), %rdi     # 0x60e5b
leaq 0x1faaf(%rip), %rsi     # 0x60261
leaq 0x20662(%rip), %rcx     # 0x60e1b
movl $0x175, %edx            # imm = 0x175
callq 0x4200