// File: /workspace/github_cpp_makefile_star2_O2/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 0x48(%rdi), %rax
testq %rax, %rax
je 0x3795f
movq %rdi, %rcx
andl $0x0, 0x10(%rax)
movl %esi, 0x2c(%rsp)
movb %sil, 0x8a(%rdi)
movq 0x50(%rdi), %rax
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x3797e
movq %rdx, %rbp
movq 0x48(%rcx), %rax
movq 0x68(%rcx), %rdi
movzwl 0x8(%rax), %edx
movslq 0xc(%rax), %rax
movq %rax, 0x38(%rsp)
xorl %r13d, %r13d
xorl %esi, %esi
movq %rdx, 0x40(%rsp)
movq %rcx, 0x20(%rsp)
callq 0x41f0
movq 0x20(%rsp), %r8
andl $0x0, 0x70(%r8)
andl $0x0, (%rbp)
movb $0x1, 0x7(%rsp)
xorl %r15d, %r15d
movq 0x8(%rsp), %rsi
movq %rbp, 0x30(%rsp)
cmpq %r13, 0x40(%rsp)
je 0x378e6
movl %r15d, %ebx
cmpl $0x2014b50, (%rsi,%rbx) # imm = 0x2014B50
jne 0x37902
movq 0x58(%r8), %rax
movl %r15d, (%rax,%r13,4)
movl 0x14(%rsi,%rbx), %eax
movq 0x60(%r8), %rcx
movl %eax, (%rcx,%r13,4)
andl $0x0, 0x14(%rsi,%rbx)
movl 0x2a(%rsi,%rbx), %r12d
movq 0x80(%r8), %rax
testq %rax, %rax
je 0x37751
movl %r12d, (%rax,%r13,4)
andl $0x0, 0x2a(%rsi,%rbx)
movzwl 0x1c(%rsi,%rbx), %eax
addl %r12d, %eax
addl $0x1e, %eax
movzwl 0x1e(%rsi,%rbx), %r14d
addl %eax, %r14d
cmpb $0x0, 0x2c(%rsp)
je 0x3777b
movq 0x78(%r8), %rax
movl %r14d, (%rax,%r13,4)
jmp 0x377d0
leal 0x1a(%r12), %esi
movq (%r8), %rdi
leaq 0x10(%rsp), %rdx
leaq 0x14(%rsp), %rcx
movq %r8, %rbp
callq *0x10(%rdi)
testl %eax, %eax
je 0x37940
addl $0x1e, %r12d
movzwl 0x10(%rsp), %eax
movzwl 0x12(%rsp), %ecx
addl %eax, %ecx
addl %r12d, %ecx
movq 0x78(%rbp), %rax
movl %ecx, (%rax,%r13,4)
cmpl %r14d, %ecx
sete %al
andb %al, 0x7(%rsp)
movl %ecx, %r14d
movq %rbp, %r8
movq 0x30(%rsp), %rbp
movq 0x8(%rsp), %rsi
movq 0x60(%r8), %rax
addl (%rax,%r13,4), %r14d
cmpl (%rbp), %r14d
jbe 0x377e2
movl %r14d, (%rbp)
movzwl 0x8(%rsi,%rbx), %eax
testb $0x8, %al
je 0x37891
andb $-0x9, %al
movb %al, 0x8(%rsi,%rbx)
movb %ah, 0x9(%rsi,%rbx)
movq 0x50(%r8), %rax
movq 0x58(%r8), %rcx
movl (%rcx,%r13,4), %ecx
movl 0x10(%rax,%rcx), %r12d
movl 0x18(%rax,%rcx), %r14d
movq 0x78(%r8), %rax
movq (%r8), %rdi
movq 0x60(%r8), %rcx
movl (%rcx,%r13,4), %esi
addl (%rax,%r13,4), %esi
leaq 0x10(%rsp), %rdx
leaq 0x20(%rsp), %rcx
callq *0x10(%rdi)
testl %eax, %eax
je 0x37921
movb $0x1, %al
cmpl %r12d, 0x10(%rsp)
jne 0x37853
cmpl %r14d, 0x18(%rsp)
jne 0x37853
movq 0x20(%rsp), %r8
movq 0x8(%rsp), %rsi
jmp 0x37885
cmpl %r12d, 0x14(%rsp)
movq 0x20(%rsp), %r8
movq 0x8(%rsp), %rsi
jne 0x3786d
movb $0x2, %al
cmpl %r14d, 0x1c(%rsp)
je 0x37885
leaq 0x1eb28(%rip), %rdi     # 0x5639c
callq 0x4510
movq 0x8(%rsp), %rsi
movq 0x20(%rsp), %r8
movb $0x1, %al
movq 0x68(%r8), %rcx
movb %al, (%rcx,%r13)
incl 0x70(%r8)
movq 0x50(%r8), %rax
movq 0x58(%r8), %rcx
movl (%rcx,%r13,4), %ecx
movzwl 0x1c(%rax,%rcx), %eax
movzwl 0x1e(%rsi,%rbx), %ecx
movzwl 0x20(%rsi,%rbx), %edx
addl %ecx, %r15d
addl %eax, %r15d
addl %edx, %r15d
addl $0x2e, %r15d
incq %r13
cmpq 0x38(%rsp), %r15
jbe 0x37708
leaq 0x17782(%rip), %rdi     # 0x4f050
leaq 0x1daac(%rip), %rsi     # 0x55381
leaq 0x1e65f(%rip), %rcx     # 0x55f3b
movl $0x1ac, %edx            # imm = 0x1AC
callq 0x4230
movb 0x7(%rsp), %al
andb $0x1, %al
movb %al, 0x8a(%r8)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x17747(%rip), %rdi     # 0x4f050
leaq 0x1da71(%rip), %rsi     # 0x55381
leaq 0x1e624(%rip), %rcx     # 0x55f3b
movl $0x17f, %edx            # imm = 0x17F
callq 0x4230
leaq 0x17728(%rip), %rdi     # 0x4f050
leaq 0x1da52(%rip), %rsi     # 0x55381
leaq 0x1e605(%rip), %rcx     # 0x55f3b
movl $0x19b, %edx            # imm = 0x19B
callq 0x4230
leaq 0x17709(%rip), %rdi     # 0x4f050
leaq 0x1da33(%rip), %rsi     # 0x55381
leaq 0x1e641(%rip), %rcx     # 0x55f96
movl $0xcf, %edx
callq 0x4230
leaq 0x1e5b7(%rip), %rdi     # 0x55f1d
leaq 0x1da14(%rip), %rsi     # 0x55381
leaq 0x1e5c7(%rip), %rcx     # 0x55f3b
movl $0x170, %edx            # imm = 0x170
callq 0x4230
leaq 0x1e5f6(%rip), %rdi     # 0x55f7b
leaq 0x1d9f5(%rip), %rsi     # 0x55381
leaq 0x1e5a8(%rip), %rcx     # 0x55f3b
movl $0x175, %edx            # imm = 0x175
callq 0x4230