// File: /workspace/github_cpp_makefile_star2_O3/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 0x53138
leaq 0x18675(%rip), %rdi     # 0x59293
movq %rax, %rsi
callq 0x4420
testl %eax, %eax
jne 0x40d73
cmpl $0x2, %r13d
movl $0x1, %ecx
cmovgel %r13d, %ecx
cmpl $0xa, %ebp
jae 0x40d54
leal -0x1(%r12), %eax
cmpl $0x9, %eax
jae 0x40d54
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 0x40d92
movq %r15, (%rbx)
leal 0x1(,%r14,2), %ecx
movslq %ecx, %rcx
movslq %r14d, %rbp
xorl %r13d, %r13d
cmpl $0x1, %eax
leaq 0x10000(%rbp,%rbp), %rax
cmovneq %r13, %rax
leaq (%rax,%rcx,4), %rdi
addq $0x8000, %rdi           # imm = 0x8000
callq 0x4400
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 (,%rbp,4), %r12
leaq (%rax,%rbp,4), %r15
movq %r15, 0xb0(%rbx)
movq %r15, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x41c0
movq $0x0, 0x78(%rbx)
cmpl $0x1, 0x90(%rbx)
jne 0x40d2c
addq %rbp, %rbp
addq %r12, %r15
movq %r15, 0x78(%rbx)
addq %rbp, %r15
movq %r15, 0x80(%rbx)
movl %r13d, 0x60(%rbx)
movl %r14d, 0x5c(%rbx)
movq $0x0, 0x9c(%rbx)
movl %r13d, 0x58(%rbx)
movb $0x1, %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x192f5(%rip), %rdi     # 0x5a050
leaq 0x1f57f(%rip), %rsi     # 0x602e1
leaq 0x1f969(%rip), %rcx     # 0x606d2
movl $0x38d, %edx            # imm = 0x38D
callq 0x4200
leaq 0x192d6(%rip), %rdi     # 0x5a050
leaq 0x1f560(%rip), %rsi     # 0x602e1
leaq 0x1f94a(%rip), %rcx     # 0x606d2
movl $0x38a, %edx            # imm = 0x38A
callq 0x4200
leaq 0x1f9ab(%rip), %rdi     # 0x60744
leaq 0x1f541(%rip), %rsi     # 0x602e1
leaq 0x1f92b(%rip), %rcx     # 0x606d2
movl $0x395, %edx            # imm = 0x395
callq 0x4200