// File: /workspace/github_cpp_makefile_star2_O1/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 0x3e2f1
movq %r8, %r13
movq %rdx, %r14
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
callq 0x3f9dd
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 0x4400
movq %rax, 0x60(%rbx)
testq %rax, %rax
je 0x3e310
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
xorl %r15d, %r15d
movl %r15d, (%rax)
movl %esi, 0x4(%rax)
movl %r15d, 0x4(%rax,%r14,4)
movb $0x0, (%rcx)
testl %ebp, %ebp
jle 0x3e2bf
movl %ebp, %ecx
movl $0x1, %r12d
movl $0x0, 0x10(%rsp)
xorl %ebp, %ebp
xorl %r14d, %r14d
movq %r13, 0x20(%rsp)
movq 0x18(%rsp), %rdx
movl %ecx, 0x14(%rsp)
cmpq %rdx, %r14
jae 0x3e23f
movq 0x28(%rsp), %rax
cmpl (%rax,%r14,4), %r15d
jne 0x3e23f
movl %esi, 0xc(%rsp)
movq 0x8(%rbx), %rdi
movl %r15d, %esi
callq 0x4092e
movl %eax, %r13d
movq 0x8(%rbx), %rdi
movl %r15d, %esi
callq 0x3fee7
movq 0x48(%rbx), %rcx
testb %al, %al
je 0x3e203
movb $0x1, (%rcx,%r12)
movq 0x40(%rbx), %rax
movl 0x10(%rsp), %ecx
movl %ecx, (%rax,%r12,4)
addl %r13d, %ecx
movl %ecx, 0x10(%rsp)
jmp 0x3e21c
movb $0x0, (%rcx,%r12)
movq 0x8(%rbx), %rdi
movl %r15d, %esi
callq 0x4098a
movq 0x40(%rbx), %rcx
movl %eax, (%rcx,%r12,4)
movl 0xc(%rsp), %esi
addl %r13d, %esi
movq 0x38(%rbx), %rax
movl %esi, (%rax,%r12,4)
incq %r14
incq %r12
movq 0x20(%rsp), %r13
movq 0x18(%rsp), %rdx
movl 0x14(%rsp), %ecx
cmpq %r13, %rbp
jae 0x3e2ac
movq 0x30(%rsp), %rax
cmpl (%rax,%rbp,4), %r15d
jne 0x3e2ac
movq 0x8(%rbx), %rdi
movq %r14, %r13
movq %rbp, %r14
movl %esi, %ebp
movl %r15d, %esi
callq 0x40941
movl %eax, 0xc(%rsp)
movq 0x48(%rbx), %rax
movb $0x0, (%rax,%r12)
movq 0x8(%rbx), %rdi
movl %r15d, %esi
callq 0x4098a
movl %ebp, %esi
movq %r14, %rbp
movq %r13, %r14
movq 0x18(%rsp), %rdx
movq 0x40(%rbx), %rcx
movl %eax, (%rcx,%r12,4)
movl 0x14(%rsp), %ecx
addl 0xc(%rsp), %esi
movq 0x20(%rsp), %r13
movq 0x38(%rbx), %rax
movl %esi, (%rax,%r12,4)
incq %rbp
incq %r12
incl %r15d
cmpl %r15d, %ecx
jne 0x3e1ae
movl 0x10(%rsp), %r15d
jmp 0x3e2c5
movl $0x1, %r12d
cmpq 0x50(%rbx), %r12
jne 0x3e33b
movq 0x10(%rbx), %rax
cmpq %r15, 0x8(%rax)
jne 0x3e35a
movl $0x0, 0x58(%rbx)
movb $0x1, %al
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x216d8(%rip), %rdi     # 0x5f9d0
leaq 0x216df(%rip), %rsi     # 0x5f9de
leaq 0x216f0(%rip), %rcx     # 0x5f9f6
movl $0xd0, %edx
callq 0x4200
leaq 0x21894(%rip), %rdi     # 0x5fbab
callq 0x44e0
leaq 0x1bd2d(%rip), %rdi     # 0x5a050
leaq 0x216b4(%rip), %rsi     # 0x5f9de
leaq 0x216c5(%rip), %rcx     # 0x5f9f6
movl $0xdf, %edx
callq 0x4200
leaq 0x21707(%rip), %rdi     # 0x5fa49
leaq 0x21695(%rip), %rsi     # 0x5f9de
leaq 0x216a6(%rip), %rcx     # 0x5f9f6
movl $0x11b, %edx            # imm = 0x11B
callq 0x4200
leaq 0x21705(%rip), %rdi     # 0x5fa66
leaq 0x21676(%rip), %rsi     # 0x5f9de
leaq 0x21687(%rip), %rcx     # 0x5f9f6
movl $0x11c, %edx            # imm = 0x11C
callq 0x4200