// File: sisong[P]ApkDiffPatch/src/patch/NewStream.cpp
// Function: NewStream_open(NewStream*, Zipper*, UnZipper*, unsigned long, bool, unsigned long, hpatch_TStreamInput const*, unsigned int const*, unsigned long, unsigned int*, unsigned long, int, int, unsigned int const*, unsigned long, int)
bool NewStream_open(NewStream* self,Zipper* out_newZip,UnZipper* oldZip,
                    size_t newDataSize,bool newZipIsDataNormalized,
                    size_t newZipCESize,const hpatch_TStreamInput* extraEdit,
                    const uint32_t* samePairList,size_t samePairCount,
                    uint32_t* newRefOtherCompressedList,size_t newRefOtherCompressedCount,
                    int newOtherCompressLevel,int newOtherCompressMemLevel,
                    const uint32_t* reCompressList,size_t reCompressCount,
                    int threadNum _VIRTUAL_IN_D(virtual_in) _VIRTUAL_OUT_D(virtual_out)){
    assert(self->_out_newZip==0);
    self->isFinish=false;
    self->_out_newZip=out_newZip;
    self->_oldZip=oldZip;
    self->_newZipIsDataNormalized=newZipIsDataNormalized;
    self->_newZipCESize=newZipCESize;
    self->_samePairList=samePairList;
    self->_samePairCount=samePairCount;
    self->_newRefOtherCompressedList=newRefOtherCompressedList;
    self->_newRefOtherCompressedCount=newRefOtherCompressedCount;
    self->_newOtherCompressIsValid=(newOtherCompressLevel|newOtherCompressMemLevel)!=0;
    self->_newOtherCompressLevel=newOtherCompressLevel;
    self->_newOtherCompressMemLevel=newOtherCompressMemLevel;
    self->_newReCompressSizeList=reCompressList;
    self->_newReCompressSizeCount=reCompressCount;
    self->_fileCount=out_newZip->_fileEntryMaxCount;
    self->_threadNum=threadNum;
    
    self->_stream.streamImport=self;
    self->_stream.streamSize=newDataSize;
    self->_stream.write=_NewStream_write;
    self->stream=&self->_stream;
    
    self->_extraEditSize=(size_t)extraEdit->streamSize;
    check(UnZipper_openVirtualVCE(&self->_newZipVCE,(ZipFilePos_t)(newZipCESize+self->_extraEditSize),self->_fileCount));
    if (self->_extraEditSize>0){
        check(extraEdit->read(extraEdit,0,self->_newZipVCE._cache_fvce,
                              self->_newZipVCE._cache_fvce+self->_extraEditSize));
    }
    
    self->_curFileIndex=-1;
    self->_curWriteToPosEnd=newZipCESize;
    self->_curSamePairIndex=0;
    self->_curNewOtherCompressIndex=0;
    self->_curNewReCompressSizeIndex=0;
    self->_isAlwaysReCompress=false;
#if (_IS_NEED_VIRTUAL_ZIP)
    self->_vin=virtual_in;
    self->_vout=virtual_out;
#endif
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movb %r8b, %al
movl 0x58(%rbp), %r8d
movq 0x50(%rbp), %r8
movq 0x48(%rbp), %r8
movl 0x40(%rbp), %r8d
movl 0x38(%rbp), %r8d
movq 0x30(%rbp), %r8
movq 0x28(%rbp), %r8
movq 0x20(%rbp), %r8
movq 0x18(%rbp), %r8
movq 0x10(%rbp), %r8
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
andb $0x1, %al
movb %al, -0x21(%rbp)
movq %r9, -0x30(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0xa24d9
jmp 0xa24f8
leaq 0x1c71a(%rip), %rdi     # 0xbebfa
leaq 0x1c6d9(%rip), %rsi     # 0xbebc0
movl $0xda, %edx
leaq 0x1c71c(%rip), %rcx     # 0xbec0f
callq 0x4270
movq -0x8(%rbp), %rax
movb $0x0, 0x8(%rax)
movq -0x10(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x18(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x18(%rax)
movb -0x21(%rbp), %cl
movq -0x8(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x20(%rax)
movq -0x30(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x28(%rax)
movq 0x18(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x30(%rax)
movq 0x20(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x38(%rax)
movq 0x28(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x40(%rax)
movq 0x30(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x48(%rax)
movl 0x38(%rbp), %eax
orl 0x40(%rbp), %eax
cmpl $0x0, %eax
setne %cl
movq -0x8(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x50(%rax)
movl 0x38(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x54(%rax)
movl 0x40(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x58(%rax)
movq 0x48(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x60(%rax)
movq 0x50(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x68(%rax)
movq -0x10(%rbp), %rax
movl 0x5c(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x90(%rax)
movl 0x58(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0xa0(%rax)
movq -0x8(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x70(%rax)
movq -0x20(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x78(%rax)
movq -0x8(%rbp), %rax
leaq 0x15c(%rip), %rcx       # 0xa2740
movq %rcx, 0x88(%rax)
movq -0x8(%rbp), %rcx
addq $0x70, %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
movq 0x10(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x98(%rax)
movq -0x8(%rbp), %rdi
addq $0xd0, %rdi
movq -0x30(%rbp), %rax
movq -0x8(%rbp), %rcx
addq 0x98(%rcx), %rax
movl %eax, %esi
movq -0x8(%rbp), %rax
movl 0x90(%rax), %edx
callq 0x80220
testb $0x1, %al
jne 0xa2669
leaq 0x1c68d(%rip), %rdi     # 0xbecd0
movb $0x0, %al
callq 0x4060
leaq 0xac1f(%rip), %rdi      # 0xad270
leaq 0x1c568(%rip), %rsi     # 0xbebc0
movl $0xf2, %edx
leaq 0x1c5ab(%rip), %rcx     # 0xbec0f
callq 0x4270
movq -0x8(%rbp), %rax
cmpq $0x0, 0x98(%rax)
jbe 0xa26dc
movq 0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x10(%rbp), %rdi
movq -0x8(%rbp), %rcx
movq 0x170(%rcx), %rdx
movq -0x8(%rbp), %rcx
movq 0x170(%rcx), %rcx
movq -0x8(%rbp), %rsi
addq 0x98(%rsi), %rcx
xorl %esi, %esi
callq *%rax
cmpl $0x0, %eax
jne 0xa26da
leaq 0x1c692(%rip), %rdi     # 0xbed46
movb $0x0, %al
callq 0x4060
leaq 0xabae(%rip), %rdi      # 0xad270
leaq 0x1c4f7(%rip), %rsi     # 0xbebc0
movl $0xf5, %edx
leaq 0x1c53a(%rip), %rcx     # 0xbec0f
callq 0x4270
jmp 0xa26dc
movq -0x8(%rbp), %rax
movl $0xffffffff, 0xa4(%rax) # imm = 0xFFFFFFFF
movq -0x30(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0xa8(%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0xb0(%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0xb8(%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0xc0(%rax)
movq -0x8(%rbp), %rax
movb $0x0, 0xc8(%rax)
movb $0x1, %al
andb $0x1, %al
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)