// File: /workspace/github_cpp_makefile_star2_O2/sisong[P]ApkDiffPatch/src/patch/Zipper.cpp
// Function: Zipper_openStream
bool Zipper_openStream(Zipper* self,const hpatch_TStreamOutput* zipStream,int fileEntryMaxCount,
                       int ZipAlignSize,int compressLevel,int compressMemLevel,
                       size_t normalizeSoPageAlign,bool pageAlignCompatible,TPageAlignState pageAlignState){
#if (_IS_NEED_FIXED_ZLIB_VERSION)
    check(0==strcmp(kNormalizedZlibVersion,zlibVersion()));//fixed zlib version
#endif
    if (ZipAlignSize<=0) ZipAlignSize=1;
    checkCompressSet(compressLevel,compressMemLevel);
    self->_ZipAlignSize=ZipAlignSize;
    self->_normalizeSoPageAlign=normalizeSoPageAlign;
    self->_pageAlignCompatible=pageAlignCompatible;
    self->_compressLevel=compressLevel;
    self->_compressMemLevel=compressMemLevel;
    self->_pageAlignState=pageAlignState;
    
    assert(self->_stream==0);
    self->_stream=zipStream;
    
    size_t memSize=kBufSize*2+sizeof(ZipFilePos_t)*(fileEntryMaxCount*2+1);
    if (self->_pageAlignState==kPageAlign_inNormalize)
        memSize+=sizeof(uint16_t)*fileEntryMaxCount + (kMaxExtraFieldLen+1);
    TByte* buf=(TByte*)malloc(memSize);
    self->_buf=buf;
    self->_codeBuf=buf+kBufSize;
    size_t alignBuf=_hpatch_align_upper((buf+kBufSize*2),sizeof(ZipFilePos_t));
    self->_fileEntryOffsets=(ZipFilePos_t*)alignBuf; alignBuf+=sizeof(ZipFilePos_t)*fileEntryMaxCount;
    self->_fileCompressedSizes=(ZipFilePos_t*)alignBuf; alignBuf+=sizeof(ZipFilePos_t)*fileEntryMaxCount;
    memset(self->_fileCompressedSizes,0,fileEntryMaxCount*sizeof(ZipFilePos_t));//set error len
    self->_normalizeExtraFieldLens=0;
    if (self->_pageAlignState==kPageAlign_inNormalize){
        self->_normalizeExtraFieldLens=(uint16_t*)alignBuf; alignBuf+=sizeof(uint16_t)*fileEntryMaxCount;
        self->_normalizeExtraFieldBuf=(TByte*)alignBuf;
    }
    self->_fileEntryCount=0;
    self->_fileEntryMaxCount=fileEntryMaxCount;
    self->_fileHeaderCount=0;
    self->_curFilePos=0;
    self->_centralDirectory_pos=0;
    
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %r9d, %r12d
movl %r8d, %ebp
movl %ecx, %r13d
movl %edx, %r14d
movq %rsi, %r15
movq %rdi, %rbx
callq 0x48cac
leaq 0x160e9(%rip), %rdi     # 0x4e293
movq %rax, %rsi
callq 0x4450
testl %eax, %eax
jne 0x382f6
cmpl $0x2, %r13d
pushq $0x1
popq %rcx
cmovgel %r13d, %ecx
cmpl $0xa, %ebp
jae 0x382d7
leal -0x1(%r12), %eax
cmpl $0x9, %eax
jae 0x382d7
movl 0x50(%rsp), %eax
movq 0x40(%rsp), %rdx
movb 0x48(%rsp), %sil
movl %ecx, %ecx
movq %rcx, 0x68(%rbx)
movq %rdx, 0x70(%rbx)
movb %sil, 0x88(%rbx)
movl %ebp, 0x94(%rbx)
movl %r12d, 0x98(%rbx)
movl %eax, 0x90(%rbx)
cmpq $0x0, (%rbx)
jne 0x38315
movq %r15, (%rbx)
leal 0x1(,%r14,2), %ecx
movslq %ecx, %rcx
movslq %r14d, %r13
xorl %edx, %edx
cmpl $0x1, %eax
leaq 0x10000(%r13,%r13), %rax
cmovneq %rdx, %rax
leaq (%rax,%rcx,4), %rdi
addq $0x8000, %rdi           # imm = 0x8000
callq 0x4430
movq %rax, 0x138(%rbx)
leaq 0x4000(%rax), %rcx
movq %rcx, 0xb8(%rbx)
addq $0x8003, %rax           # imm = 0x8003
andq $-0x4, %rax
movq %rax, 0xa8(%rbx)
leaq (,%r13,4), %r12
leaq (%rax,%r13,4), %r15
movq %r15, 0xb0(%rbx)
movq %r15, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x41f0
andq $0x0, 0x78(%rbx)
cmpl $0x1, 0x90(%rbx)
jne 0x382b2
addq %r13, %r13
addq %r12, %r15
movq %r15, 0x78(%rbx)
addq %r13, %r15
movq %r15, 0x80(%rbx)
andl $0x0, 0x60(%rbx)
movl %r14d, 0x5c(%rbx)
andq $0x0, 0x9c(%rbx)
andl $0x0, 0x58(%rbx)
movb $0x1, %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x16d72(%rip), %rdi     # 0x4f050
leaq 0x1d09c(%rip), %rsi     # 0x55381
leaq 0x1d486(%rip), %rcx     # 0x55772
movl $0x38d, %edx            # imm = 0x38D
callq 0x4230
leaq 0x16d53(%rip), %rdi     # 0x4f050
leaq 0x1d07d(%rip), %rsi     # 0x55381
leaq 0x1d467(%rip), %rcx     # 0x55772
movl $0x38a, %edx            # imm = 0x38A
callq 0x4230
leaq 0x1d4c8(%rip), %rdi     # 0x557e4
leaq 0x1d05e(%rip), %rsi     # 0x55381
leaq 0x1d448(%rip), %rcx     # 0x55772
movl $0x395, %edx            # imm = 0x395
callq 0x4230