// File: /workspace/github_cpp_makefile_star2_O3/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 0x40377
movl %esi, %r14d
movq %rdi, %rbx
movl $0x0, 0x10(%rax)
movb %r14b, 0x8a(%rdi)
movq 0x50(%rdi), %rax
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x40396
movq 0x48(%rbx), %rax
movq 0x68(%rbx), %rdi
movzwl 0x8(%rax), %r15d
movslq 0xc(%rax), %rax
movq %rax, 0x40(%rsp)
xorl %ebp, %ebp
xorl %esi, %esi
movq %r15, %rdx
callq 0x41c0
movl %ebp, 0x70(%rbx)
movq 0x28(%rsp), %rax
movl %ebp, (%rax)
movq %r15, 0x38(%rsp)
testq %r15, %r15
je 0x402e4
movl %r14d, 0x34(%rsp)
movb $0x1, 0x7(%rsp)
xorl %r15d, %r15d
movq 0x8(%rsp), %rsi
movl %ebp, %r12d
cmpl $0x2014b50, (%rsi,%r12) # imm = 0x2014B50
jne 0x4031a
movq 0x58(%rbx), %rax
movl %ebp, (%rax,%r15,4)
movl 0x14(%rsi,%r12), %eax
movq 0x60(%rbx), %rcx
movl %eax, (%rcx,%r15,4)
movl $0x0, 0x14(%rsi,%r12)
movl 0x2a(%rsi,%r12), %r13d
movq 0x80(%rbx), %rax
testq %rax, %rax
je 0x40173
movl %r13d, (%rax,%r15,4)
movl $0x0, 0x2a(%rsi,%r12)
movzwl 0x1c(%rsi,%r12), %eax
addl %r13d, %eax
addl $0x1e, %eax
movzwl 0x1e(%rsi,%r12), %r14d
addl %eax, %r14d
cmpb $0x0, 0x34(%rsp)
je 0x401a2
movq 0x78(%rbx), %rax
movl %r14d, (%rax,%r15,4)
jmp 0x401eb
movq (%rbx), %rdi
leal 0x1a(%r13), %esi
leaq 0x10(%rsp), %rdx
leaq 0x14(%rsp), %rcx
callq *0x10(%rdi)
testl %eax, %eax
je 0x40358
addl $0x1e, %r13d
movzwl 0x10(%rsp), %eax
movzwl 0x12(%rsp), %ecx
addl %eax, %ecx
addl %r13d, %ecx
movq 0x78(%rbx), %rax
movl %ecx, (%rax,%r15,4)
cmpl %r14d, %ecx
sete %al
andb %al, 0x7(%rsp)
movl %ecx, %r14d
movq 0x8(%rsp), %rsi
movq 0x60(%rbx), %rax
addl (%rax,%r15,4), %r14d
movq 0x28(%rsp), %rax
cmpl (%rax), %r14d
jbe 0x40205
movq 0x28(%rsp), %rax
movl %r14d, (%rax)
movb 0x8(%rsi,%r12), %al
testb $0x8, %al
je 0x402a1
andb $-0x9, %al
movb %al, 0x8(%rsi,%r12)
movq 0x50(%rbx), %rax
movq 0x58(%rbx), %rcx
movl (%rcx,%r15,4), %ecx
movl 0x10(%rax,%rcx), %r13d
movl 0x18(%rax,%rcx), %r14d
movq 0x78(%rbx), %rax
movq (%rbx), %rdi
movq 0x60(%rbx), %rcx
movl (%rcx,%r15,4), %esi
addl (%rax,%r15,4), %esi
leaq 0x10(%rsp), %rdx
leaq 0x20(%rsp), %rcx
callq *0x10(%rdi)
testl %eax, %eax
je 0x40339
movb $0x1, %al
cmpl %r13d, 0x10(%rsp)
jne 0x4026e
cmpl %r14d, 0x18(%rsp)
jne 0x4026e
movq 0x8(%rsp), %rsi
jmp 0x40296
cmpl %r13d, 0x14(%rsp)
movq 0x8(%rsp), %rsi
jne 0x40283
movb $0x2, %al
cmpl %r14d, 0x1c(%rsp)
je 0x40296
leaq 0x21072(%rip), %rdi     # 0x612fc
callq 0x44e0
movq 0x8(%rsp), %rsi
movb $0x1, %al
movq 0x68(%rbx), %rcx
movb %al, (%rcx,%r15)
incl 0x70(%rbx)
movq 0x50(%rbx), %rax
movq 0x58(%rbx), %rcx
movl (%rcx,%r15,4), %ecx
movzwl 0x1c(%rax,%rcx), %eax
movzwl 0x1e(%rsi,%r12), %ecx
movzwl 0x20(%rsi,%r12), %edx
addl %ecx, %ebp
addl %eax, %ebp
addl %edx, %ebp
addl $0x2e, %ebp
cmpq 0x40(%rsp), %rbp
ja 0x402fb
incq %r15
cmpq %r15, 0x38(%rsp)
jne 0x4012f
movb 0x7(%rsp), %al
andb $0x1, %al
jmp 0x402e6
movb $0x1, %al
movb %al, 0x8a(%rbx)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x19d4e(%rip), %rdi     # 0x5a050
leaq 0x1ffd8(%rip), %rsi     # 0x602e1
leaq 0x20b8b(%rip), %rcx     # 0x60e9b
movl $0x1ac, %edx            # imm = 0x1AC
callq 0x4200
leaq 0x19d2f(%rip), %rdi     # 0x5a050
leaq 0x1ffb9(%rip), %rsi     # 0x602e1
leaq 0x20b6c(%rip), %rcx     # 0x60e9b
movl $0x17f, %edx            # imm = 0x17F
callq 0x4200
leaq 0x19d10(%rip), %rdi     # 0x5a050
leaq 0x1ff9a(%rip), %rsi     # 0x602e1
leaq 0x20b4d(%rip), %rcx     # 0x60e9b
movl $0x19b, %edx            # imm = 0x19B
callq 0x4200
leaq 0x19cf1(%rip), %rdi     # 0x5a050
leaq 0x1ff7b(%rip), %rsi     # 0x602e1
leaq 0x20b89(%rip), %rcx     # 0x60ef6
movl $0xcf, %edx
callq 0x4200
leaq 0x20aff(%rip), %rdi     # 0x60e7d
leaq 0x1ff5c(%rip), %rsi     # 0x602e1
leaq 0x20b0f(%rip), %rcx     # 0x60e9b
movl $0x170, %edx            # imm = 0x170
callq 0x4200
leaq 0x20b3e(%rip), %rdi     # 0x60edb
leaq 0x1ff3d(%rip), %rsi     # 0x602e1
leaq 0x20af0(%rip), %rcx     # 0x60e9b
movl $0x175, %edx            # imm = 0x175
callq 0x4200