// File: /workspace/github_cpp_makefile_star2_O2/sisong[P]ApkDiffPatch/src/patch/OldStream.cpp
// Function: createRange(OldStream*, unsigned int const*, unsigned long, unsigned int const*, unsigned long)
bool _createRange(OldStream* self,const uint32_t* refList,size_t refCount,
                  const uint32_t* refNotDecompressList,size_t refNotDecompressCount){
    bool result=true;
    assert(self->_buf==0);
    const int fileCount=UnZipper_fileCount(self->_oldZip);
    size_t   rangIndex;
    uint32_t curSumSize=0;
    uint32_t curDecompressPos=0;
    size_t refi=0;
    size_t noti=0;
    
    self->_rangeCount= 1 + refCount + refNotDecompressCount;
    size_t _memSize=sizeof(uint32_t)*(self->_rangeCount*2+1)+self->_rangeCount*sizeof(unsigned char);
#if (_IS_NEED_VIRTUAL_ZIP)
    if (self->_vin)
        _memSize+=self->_rangeCount*sizeof(unsigned char);
#endif
    self->_buf=(unsigned char*)malloc(_memSize);
    check(self->_buf!=0);
    self->_rangeEndList=((uint32_t*)self->_buf)+1; //+1 for _rangeEndList[-1] safe
    self->_rangeFileOffsets=self->_rangeEndList+self->_rangeCount;
    self->_rangIsInDecBuf=(unsigned char*)(self->_rangeFileOffsets+self->_rangeCount);
#if (_IS_NEED_VIRTUAL_ZIP)
    if (self->_vin){
        self->_rangIsInVirtualBuf=self->_rangIsInDecBuf+self->_rangeCount;
        memset(self->_rangIsInVirtualBuf,0,self->_rangeCount);
    }
#endif
    curSumSize=(uint32_t)UnZipper_CESize(self->_oldZip);
    self->_rangeEndList[-1]=0;
    self->_rangeEndList[0]=curSumSize;
    self->_rangeFileOffsets[0]=0;
    self->_rangIsInDecBuf[0]=0;
    rangIndex=1;
    for (int fileIndex=0; fileIndex<fileCount; ++fileIndex) {
        if ((refi<refCount)&&((int)refList[refi]==fileIndex)){
            ZipFilePos_t rangeSize;
            bool         isCompressed;
#if (_IS_NEED_VIRTUAL_ZIP)
            if ((self->_vin)&&(self->_vin->entryDatas[fileIndex])){
                TZipEntryData* entryData=self->_vin->entryDatas[fileIndex];
                rangeSize=entryData->uncompressedSize;
                isCompressed=entryData->isCompressed;
                if (!isCompressed) self->_rangIsInVirtualBuf[rangIndex]=1;
            } else
#endif
            {
                rangeSize=UnZipper_file_uncompressedSize(self->_oldZip,fileIndex);
                isCompressed=UnZipper_file_isCompressed(self->_oldZip,fileIndex);
            }
            if (isCompressed){
                self->_rangIsInDecBuf[rangIndex]=1;
                self->_rangeFileOffsets[rangIndex]=curDecompressPos;
                curDecompressPos+=rangeSize;
            }else{
                self->_rangIsInDecBuf[rangIndex]=0;
#if (_IS_NEED_VIRTUAL_ZIP)
                if ((self->_vin)&&(self->_rangIsInVirtualBuf[rangIndex]))
                    self->_rangeFileOffsets[rangIndex]=fileIndex;
                else
#endif
                    self->_rangeFileOffsets[rangIndex]=UnZipper_fileData_offset(self->_oldZip,fileIndex);
            }
            curSumSize+=rangeSize;
            self->_rangeEndList[rangIndex]=curSumSize;
            ++refi;
            ++rangIndex;
        }
        if ((noti<refNotDecompressCount)&&((int)refNotDecompressList[noti]==fileIndex)){
            ZipFilePos_t rangeSize=UnZipper_file_compressedSize(self->_oldZip,fileIndex);
            self->_rangIsInDecBuf[rangIndex]=0;
            self->_rangeFileOffsets[rangIndex]=UnZipper_fileData_offset(self->_oldZip,fileIndex);
            curSumSize+=rangeSize;
            self->_rangeEndList[rangIndex]=curSumSize;
            ++noti;
            ++rangIndex;
        }
    }
    assert(rangIndex==self->_rangeCount);
    assert(curDecompressPos==self->_input_decompressedStream->streamSize);
    self->_curRangeIndex=0;
clear:
    return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, 0x30(%rsp)
movq %rsi, 0x28(%rsp)
cmpq $0x0, 0x60(%rdi)
jne 0x355ee
movq %r8, %r13
movq %rdx, %r14
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
callq 0x36bfd
movl %eax, %ebp
leaq (%r14,%r13), %rax
movq %r14, 0x18(%rsp)
addq %r13, %r14
incq %r14
movq %r14, 0x50(%rbx)
leaq (%rax,%rax,8), %rdi
addq $0xd, %rdi
callq 0x4430
movq %rax, 0x60(%rbx)
testq %rax, %rax
je 0x3560d
leaq 0x4(%rax), %rcx
movq %rcx, 0x38(%rbx)
leaq (%rax,%r14,4), %rcx
addq $0x4, %rcx
movq %rcx, 0x40(%rbx)
leaq (%rcx,%r14,4), %rcx
movq %rcx, 0x48(%rbx)
movq 0x8(%rbx), %rdx
movl 0xa0(%rdx), %esi
addl 0xa8(%rdx), %esi
subl 0x50(%rdx), %esi
andl $0x0, (%rax)
movl %esi, 0x4(%rax)
andl $0x0, 0x4(%rax,%r14,4)
movb $0x0, (%rcx)
xorl %r12d, %r12d
testl %ebp, %ebp
cmovlel %r12d, %ebp
movl %ebp, %ecx
pushq $0x1
popq %rbp
xorl %r14d, %r14d
movl $0x0, 0x10(%rsp)
xorl %r15d, %r15d
movq %r13, 0x20(%rsp)
movq 0x18(%rsp), %rdx
movl %ecx, 0x14(%rsp)
cmpl %r15d, %ecx
je 0x355c5
cmpq %rdx, %r12
jae 0x35551
movq 0x28(%rsp), %rax
cmpl (%rax,%r12,4), %r15d
jne 0x35551
movl %esi, 0xc(%rsp)
movq 0x8(%rbx), %rdi
movl %r15d, %esi
callq 0x37b03
movl %eax, %r13d
movq 0x8(%rbx), %rdi
movl %r15d, %esi
callq 0x370d6
movq 0x48(%rbx), %rcx
testb %al, %al
je 0x35518
movb $0x1, (%rcx,%rbp)
movq 0x40(%rbx), %rax
movl 0x10(%rsp), %ecx
movl %ecx, (%rax,%rbp,4)
addl %r13d, %ecx
movl %ecx, 0x10(%rsp)
jmp 0x3552f
movb $0x0, (%rcx,%rbp)
movq 0x8(%rbx), %rdi
movl %r15d, %esi
callq 0x37b5f
movq 0x40(%rbx), %rcx
movl %eax, (%rcx,%rbp,4)
movl 0xc(%rsp), %esi
addl %r13d, %esi
movq 0x38(%rbx), %rax
movl %esi, (%rax,%rbp,4)
incq %r12
incq %rbp
movq 0x20(%rsp), %r13
movq 0x18(%rsp), %rdx
movl 0x14(%rsp), %ecx
cmpq %r13, %r14
jae 0x355bd
movq 0x30(%rsp), %rax
cmpl (%rax,%r14,4), %r15d
jne 0x355bd
movq 0x8(%rbx), %rdi
movq %r14, %r13
movq %r12, %r14
movl %esi, %r12d
movl %r15d, %esi
callq 0x37b16
movl %eax, 0xc(%rsp)
movq 0x48(%rbx), %rax
movb $0x0, (%rax,%rbp)
movq 0x8(%rbx), %rdi
movl %r15d, %esi
callq 0x37b5f
movl %r12d, %esi
movq %r14, %r12
movq %r13, %r14
movq 0x18(%rsp), %rdx
movq 0x40(%rbx), %rcx
movl %eax, (%rcx,%rbp,4)
movl 0x14(%rsp), %ecx
addl 0xc(%rsp), %esi
movq 0x20(%rsp), %r13
movq 0x38(%rbx), %rax
movl %esi, (%rax,%rbp,4)
incq %r14
incq %rbp
incl %r15d
jmp 0x354bc
cmpq 0x50(%rbx), %rbp
jne 0x35638
movl 0x10(%rsp), %eax
movq 0x10(%rbx), %rcx
cmpq %rax, 0x8(%rcx)
jne 0x35657
andl $0x0, 0x58(%rbx)
movb $0x1, %al
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1f4fb(%rip), %rdi     # 0x54af0
leaq 0x1f502(%rip), %rsi     # 0x54afe
leaq 0x1f513(%rip), %rcx     # 0x54b16
movl $0xd0, %edx
callq 0x4230
leaq 0x1f6b7(%rip), %rdi     # 0x54ccb
callq 0x4510
leaq 0x19a30(%rip), %rdi     # 0x4f050
leaq 0x1f4d7(%rip), %rsi     # 0x54afe
leaq 0x1f4e8(%rip), %rcx     # 0x54b16
movl $0xdf, %edx
callq 0x4230
leaq 0x1f52a(%rip), %rdi     # 0x54b69
leaq 0x1f4b8(%rip), %rsi     # 0x54afe
leaq 0x1f4c9(%rip), %rcx     # 0x54b16
movl $0x11b, %edx            # imm = 0x11B
callq 0x4230
leaq 0x1f528(%rip), %rdi     # 0x54b86
leaq 0x1f499(%rip), %rsi     # 0x54afe
leaq 0x1f4aa(%rip), %rcx     # 0x54b16
movl $0x11c, %edx            # imm = 0x11C
callq 0x4230