// File: /workspace/github_cpp_makefile_star2_O1/sisong[P]ApkDiffPatch/src/patch/Zipper.cpp
// Function: Zipper_file_append_beginWith
bool Zipper_file_append_beginWith(Zipper* self,UnZipper* srcZip,int srcFileIndex,
                                  bool appendDataIsCompressed,size_t dataUncompressedSize,size_t dataCompressedSize,
                                  int curFileCompressLevel,int curFileCompressMemLevel){
    const bool dstFileIsCompressed=_zipper_curFile_isCompressed(self,srcZip,srcFileIndex);
    if (dstFileIsCompressed&&(!appendDataIsCompressed))
        checkCompressSet(curFileCompressLevel,curFileCompressMemLevel);
    if ((!dstFileIsCompressed)&&(appendDataIsCompressed)){
        assert(false);//now need input decompressed data;
        return false; // for example: UnZipper_fileData_decompressTo(Zipper_file_append_part_as_stream());
    }
    if (0==dataCompressedSize){
        check((!appendDataIsCompressed)||(dataUncompressedSize==0));
        if (dataUncompressedSize!=0)
            dataCompressedSize=UnZipper_file_compressedSize(srcZip,srcFileIndex);//temp value
    }
    Zipper_file_append_stream* append_state=&self->_append_stream;
    if (append_state->self!=0){
        assert(false);  //need call Zipper_file_append_end()
        return false;
    }
    
    int curFileIndex=self->_fileEntryCount;
    check(curFileIndex < self->_fileEntryMaxCount);
    self->_fileEntryCount=curFileIndex+1;
    self->_fileCompressedSizes[curFileIndex]=dstFileIsCompressed?(ZipFilePos_t)dataCompressedSize: //maybe temp value
                                            (ZipFilePos_t)dataUncompressedSize; //finally value
    check(_write_fileHeaderInfo(self,curFileIndex,srcZip,srcFileIndex,false));//out file info
    
    append_state->self=self;
    append_state->compressor=&TZipCompressor_zlib;
    append_state->inputPos=0;
    append_state->outputPos=0;
    append_state->curFileIndex=curFileIndex;
    append_state->streamImport=append_state;
    append_state->streamSize=appendDataIsCompressed?dataCompressedSize:dataUncompressedSize; //finally value
    append_state->write=Zipper_file_append_stream::_append_part_input;
    assert(append_state->compressHandle==0);
    assert(append_state->threadWork==0);
    if (dstFileIsCompressed&&(!appendDataIsCompressed)){//compress data
#if (_IS_USED_MULTITHREAD)
        if (isUsedMT(self)&&(dataCompressedSize>0)){
            self->_threadWorks->waitCanFastDispatchWork();
            append_state->threadWork=newThreadWork(dataUncompressedSize,dataCompressedSize,self->_curFilePos,
                                                   curFileCompressLevel,curFileCompressMemLevel);
            if ((append_state->threadWork)&&(!_writeSkip(self,dataCompressedSize)))
                return false;
            //else continue : this thread do compress
        }
#endif
        if (!append_state->threadWork){
            append_state->compressOutStream.streamImport=append_state;
            append_state->compressOutStream.streamSize=self->_fileCompressedSizes[curFileIndex];//not used
            append_state->compressOutStream.write=Zipper_file_append_stream::_append_part_output;
            append_state->compressHandle=append_state->compressor->openCompressHandle(append_state->compressor,dataUncompressedSize,
                                                                curFileCompressLevel,curFileCompressMemLevel,
                                                                &append_state->compressOutStream,self->_codeBuf,kBufSize);
            if (!append_state->compressHandle)
                return false;
        }
    }//else //copy data
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, %r12
movq %r8, %r14
movl %ecx, %r13d
movl %edx, %ecx
movq %rsi, %rdx
movq %rdi, %rbx
cmpb $0x1, 0x150(%rdi)
jne 0x41c5a
movb 0x151(%rbx), %al
jmp 0x41c75
movq 0x50(%rdx), %rax
movq 0x58(%rdx), %rsi
movslq %ecx, %rdi
movl (%rsi,%rdi,4), %esi
movb 0xa(%rax,%rsi), %dil
orb 0xb(%rax,%rsi), %dil
setne %al
movl 0x58(%rsp), %esi
movl %eax, %ebp
xorb $0x1, %bpl
orb %r13b, %bpl
jne 0x41c9a
cmpl $0xa, 0x50(%rsp)
jae 0x41eaa
decl %esi
cmpl $0x9, %esi
jae 0x41eaa
movl %r13d, %esi
xorb $0x1, %sil
movl %eax, %edi
orb %sil, %dil
je 0x41ec9
testq %r12, %r12
jne 0x41cd6
testq %r14, %r14
sete %dil
orb %sil, %dil
je 0x41f83
testq %r14, %r14
je 0x41cd3
movq 0x60(%rdx), %rsi
movslq %ecx, %rdi
movl (%rsi,%rdi,4), %r12d
jmp 0x41cd6
xorl %r12d, %r12d
cmpq $0x0, 0xf0(%rbx)
jne 0x41ee8
movl 0x60(%rbx), %r15d
cmpl 0x5c(%rbx), %r15d
jge 0x41f07
movslq %r15d, %rdi
leal 0x1(%r15), %esi
movl %esi, 0x60(%rbx)
testb %al, %al
movl %r14d, %eax
cmovnel %r12d, %eax
movq 0xb0(%rbx), %rsi
movq %rdi, 0x10(%rsp)
movl %eax, (%rsi,%rdi,4)
movq %rbx, %rdi
movl %r15d, %esi
xorl %r8d, %r8d
callq 0x41fa2
testb %al, %al
je 0x41f26
leaq 0xc0(%rbx), %rdx
movq %rbx, 0xf0(%rbx)
leaq 0x3a7b9(%rip), %rax     # 0x7c4f8
movq %rax, 0x100(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0xe0(%rbx)
movl %r15d, 0x130(%rbx)
movq %rdx, 0xc0(%rbx)
testb %r13b, %r13b
movq %r14, %rax
cmovneq %r12, %rax
movq %rax, 0xc8(%rbx)
leaq -0x346(%rip), %rax      # 0x41a30
movq %rax, 0xd8(%rbx)
cmpq $0x0, 0x108(%rbx)
jne 0x41f45
cmpq $0x0, 0xf8(%rbx)
jne 0x41f64
testb %bpl, %bpl
jne 0x41e95
cmpl $0x2, 0x154(%rbx)
jl 0x41e29
testq %r12, %r12
je 0x41e29
movq %rdx, %rbp
movq 0x158(%rbx), %rdi
movl $0x1, %esi
callq 0x4966e
movl 0x58(%rbx), %r15d
leaq (%r14,%r12), %rdi
addq $0x30, %rdi
callq 0x4400
testq %rax, %rax
je 0x41e09
leaq 0x30(%rax), %rcx
movq %rcx, (%rax)
movq %r14, 0x10(%rax)
leaq (%rax,%r14), %rcx
addq $0x30, %rcx
movq %rcx, 0x8(%rax)
movq %r12, 0x18(%rax)
movq %r15, 0x20(%rax)
movl 0x50(%rsp), %ecx
movl %ecx, 0x28(%rax)
movl 0x58(%rsp), %ecx
movl %ecx, 0x2c(%rax)
jmp 0x41e0b
xorl %eax, %eax
movq %rax, 0xf8(%rbx)
testq %rax, %rax
movq %rbp, %rdx
je 0x41e29
movq %rbx, %rdi
callq 0x42e0c
movq %rbp, %rdx
addl %r12d, 0x58(%rbx)
cmpq $0x0, 0xf8(%rbx)
jne 0x41e95
leaq 0x110(%rbx), %r8
movq %rdx, 0x110(%rbx)
movq 0xb0(%rbx), %rax
movq 0xb8(%rbx), %r9
movq 0x10(%rsp), %rdx
movl (%rax,%rdx,4), %eax
movq %rax, 0x118(%rbx)
leaq -0x353(%rip), %rax      # 0x41b12
movq %rax, 0x128(%rbx)
movq 0x100(%rbx), %rdi
movq $0x4000, (%rsp)         # imm = 0x4000
movq %r14, %rsi
movl 0x50(%rsp), %edx
movl 0x58(%rsp), %ecx
callq *0x8(%rdi)
movq %rax, 0x108(%rbx)
testq %rax, %rax
je 0x41ea6
movb $0x1, %al
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
jmp 0x41e97
leaq 0x1819f(%rip), %rdi     # 0x5a050
leaq 0x1e3a9(%rip), %rsi     # 0x60261
leaq 0x1eaa2(%rip), %rcx     # 0x60961
movl $0x532, %edx            # imm = 0x532
callq 0x4200
leaq 0x18180(%rip), %rdi     # 0x5a050
leaq 0x1e38a(%rip), %rsi     # 0x60261
leaq 0x1ea83(%rip), %rcx     # 0x60961
movl $0x534, %edx            # imm = 0x534
callq 0x4200
leaq 0x18161(%rip), %rdi     # 0x5a050
leaq 0x1e36b(%rip), %rsi     # 0x60261
leaq 0x1ea64(%rip), %rcx     # 0x60961
movl $0x53e, %edx            # imm = 0x53E
callq 0x4200
leaq 0x18142(%rip), %rdi     # 0x5a050
leaq 0x1e34c(%rip), %rsi     # 0x60261
leaq 0x1ea45(%rip), %rcx     # 0x60961
movl $0x543, %edx            # imm = 0x543
callq 0x4200
leaq 0x18123(%rip), %rdi     # 0x5a050
leaq 0x1e32d(%rip), %rsi     # 0x60261
leaq 0x1ea26(%rip), %rcx     # 0x60961
movl $0x547, %edx            # imm = 0x547
callq 0x4200
leaq 0x1ea72(%rip), %rdi     # 0x609be
leaq 0x1e30e(%rip), %rsi     # 0x60261
leaq 0x1ea07(%rip), %rcx     # 0x60961
movl $0x551, %edx            # imm = 0x551
callq 0x4200
leaq 0x1ea73(%rip), %rdi     # 0x609de
leaq 0x1e2ef(%rip), %rsi     # 0x60261
leaq 0x1e9e8(%rip), %rcx     # 0x60961
movl $0x552, %edx            # imm = 0x552
callq 0x4200
leaq 0x180c6(%rip), %rdi     # 0x5a050
leaq 0x1e2d0(%rip), %rsi     # 0x60261
leaq 0x1e9c9(%rip), %rcx     # 0x60961
movl $0x538, %edx            # imm = 0x538
callq 0x4200