// File: /workspace/github_cpp_makefile_star2_O3/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 0x3de98
movq %r8, %r13
movq %rdx, %r14
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
callq 0x3f577
movl %eax, %ebp
leaq (%r14,%r13), %rax
movq %r14, 0x18(%rsp)
leaq (%r14,%r13), %r12
incq %r12
movq %r12, 0x50(%rbx)
leaq (%rax,%rax,8), %rdi
addq $0xd, %rdi
callq 0x4400
movq %rax, 0x60(%rbx)
testq %rax, %rax
je 0x3deb7
leaq 0x4(%rax), %rcx
movq %rcx, 0x38(%rbx)
leaq (%rax,%r12,4), %rcx
addq $0x4, %rcx
movq %rcx, 0x40(%rbx)
leaq (%rcx,%r12,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,%r12,4)
movb $0x0, (%rcx)
testl %ebp, %ebp
jle 0x3de67
movl %ebp, %ecx
movl $0x1, %r14d
movl $0x0, 0x10(%rsp)
xorl %ebp, %ebp
xorl %r12d, %r12d
movq %r13, 0x20(%rsp)
movq 0x18(%rsp), %rdx
movl %ecx, 0x14(%rsp)
cmpq %rdx, %r12
jae 0x3dde3
movq 0x28(%rsp), %rax
cmpl (%rax,%r12,4), %r15d
jne 0x3dde3
movl %esi, 0xc(%rsp)
movq 0x8(%rbx), %rdi
movl %r15d, %esi
callq 0x40520
movl %eax, %r13d
movq 0x8(%rbx), %rdi
movl %r15d, %esi
callq 0x3fadd
movq 0x48(%rbx), %rcx
testb %al, %al
je 0x3dda7
movb $0x1, (%rcx,%r14)
movq 0x40(%rbx), %rax
movl 0x10(%rsp), %ecx
movl %ecx, (%rax,%r14,4)
addl %r13d, %ecx
movl %ecx, 0x10(%rsp)
jmp 0x3ddc0
movb $0x0, (%rcx,%r14)
movq 0x8(%rbx), %rdi
movl %r15d, %esi
callq 0x4057c
movq 0x40(%rbx), %rcx
movl %eax, (%rcx,%r14,4)
movl 0xc(%rsp), %esi
addl %r13d, %esi
movq 0x38(%rbx), %rax
movl %esi, (%rax,%r14,4)
incq %r12
incq %r14
movq 0x20(%rsp), %r13
movq 0x18(%rsp), %rdx
movl 0x14(%rsp), %ecx
cmpq %r13, %rbp
jae 0x3de50
movq 0x30(%rsp), %rax
cmpl (%rax,%rbp,4), %r15d
jne 0x3de50
movq 0x8(%rbx), %rdi
movq %r12, %r13
movq %rbp, %r12
movl %esi, %ebp
movl %r15d, %esi
callq 0x40533
movl %eax, 0xc(%rsp)
movq 0x48(%rbx), %rax
movb $0x0, (%rax,%r14)
movq 0x8(%rbx), %rdi
movl %r15d, %esi
callq 0x4057c
movl %ebp, %esi
movq %r12, %rbp
movq %r13, %r12
movq 0x18(%rsp), %rdx
movq 0x40(%rbx), %rcx
movl %eax, (%rcx,%r14,4)
movl 0x14(%rsp), %ecx
addl 0xc(%rsp), %esi
movq 0x20(%rsp), %r13
movq 0x38(%rbx), %rax
movl %esi, (%rax,%r14,4)
incq %rbp
incq %r14
incl %r15d
cmpl %r15d, %ecx
jne 0x3dd52
movq 0x50(%rbx), %r12
movl 0x10(%rsp), %r15d
jmp 0x3de6d
movl $0x1, %r14d
cmpq %r12, %r14
jne 0x3dee2
movq 0x10(%rbx), %rax
cmpq %r15, 0x8(%rax)
jne 0x3df01
movl $0x0, 0x58(%rbx)
movb $0x1, %al
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x21bb1(%rip), %rdi     # 0x5fa50
leaq 0x21bb8(%rip), %rsi     # 0x5fa5e
leaq 0x21bc9(%rip), %rcx     # 0x5fa76
movl $0xd0, %edx
callq 0x4200
leaq 0x21d6d(%rip), %rdi     # 0x5fc2b
callq 0x44e0
leaq 0x1c186(%rip), %rdi     # 0x5a050
leaq 0x21b8d(%rip), %rsi     # 0x5fa5e
leaq 0x21b9e(%rip), %rcx     # 0x5fa76
movl $0xdf, %edx
callq 0x4200
leaq 0x21be0(%rip), %rdi     # 0x5fac9
leaq 0x21b6e(%rip), %rsi     # 0x5fa5e
leaq 0x21b7f(%rip), %rcx     # 0x5fa76
movl $0x11b, %edx            # imm = 0x11B
callq 0x4200
leaq 0x21bde(%rip), %rdi     # 0x5fae6
leaq 0x21b4f(%rip), %rsi     # 0x5fa5e
leaq 0x21b60(%rip), %rcx     # 0x5fa76
movl $0x11c, %edx            # imm = 0x11C
callq 0x4200