// File: /workspace/github_cpp_makefile_star2_O3/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 0x417ae
movb 0x151(%rbx), %al
jmp 0x417c5
movq 0x50(%rdx), %rax
movq 0x58(%rdx), %rsi
movslq %ecx, %rdi
movl (%rsi,%rdi,4), %esi
cmpw $0x0, 0xa(%rax,%rsi)
setne %al
movl 0x58(%rsp), %esi
movl %eax, %ebp
xorb $0x1, %bpl
orb %r13b, %bpl
jne 0x417ea
cmpl $0xa, 0x50(%rsp)
jae 0x41a12
decl %esi
cmpl $0x9, %esi
jae 0x41a12
movl %r13d, %esi
xorb $0x1, %sil
movl %eax, %edi
orb %sil, %dil
je 0x41a31
testq %r12, %r12
jne 0x41826
testq %r14, %r14
sete %dil
orb %sil, %dil
je 0x41aeb
testq %r14, %r14
je 0x41823
movq 0x60(%rdx), %rsi
movslq %ecx, %rdi
movl (%rsi,%rdi,4), %r12d
jmp 0x41826
xorl %r12d, %r12d
cmpq $0x0, 0xf0(%rbx)
jne 0x41a50
movl 0x60(%rbx), %r15d
cmpl 0x5c(%rbx), %r15d
jge 0x41a6f
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 0x41b0a
testb %al, %al
je 0x41a8e
leaq 0xc0(%rbx), %rdx
movq %rbx, 0xf0(%rbx)
leaq 0x3ac69(%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 -0x344(%rip), %rax      # 0x41582
movq %rax, 0xd8(%rbx)
cmpq $0x0, 0x108(%rbx)
jne 0x41aad
cmpq $0x0, 0xf8(%rbx)
jne 0x41acc
testb %bpl, %bpl
jne 0x419fd
movq %r14, %rcx
cmpl $0x2, 0x154(%rbx)
jl 0x4199b
testq %r12, %r12
je 0x4199b
movq %rdx, %r14
movq 0x158(%rbx), %rdi
movl $0x1, %esi
movq %rcx, %r13
callq 0x489dc
movl 0x58(%rbx), %r15d
leaq (%r12,%r13), %rdi
addq $0x30, %rdi
callq 0x4400
testq %rax, %rax
je 0x4198a
leaq 0x30(%rax), %rcx
movq %rcx, (%rax)
movq %r13, 0x10(%rax)
leaq (%rax,%r13), %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)
movq %rax, 0xf8(%rbx)
movq %rbx, %rdi
callq 0x42910
addl %r12d, 0x58(%rbx)
cmpq $0x0, 0xf8(%rbx)
movq %r13, %rcx
movq %r14, %rdx
jne 0x419fd
jmp 0x4199b
movq $0x0, 0xf8(%rbx)
movq %r13, %rcx
movq %r14, %rdx
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 -0x36b(%rip), %rax      # 0x41662
movq %rax, 0x128(%rbx)
movq 0x100(%rbx), %rdi
movq $0x4000, (%rsp)         # imm = 0x4000
movq %rcx, %rsi
movl 0x50(%rsp), %edx
movl 0x58(%rsp), %ecx
callq *0x8(%rdi)
movq %rax, 0x108(%rbx)
testq %rax, %rax
je 0x41a0e
movb $0x1, %al
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
jmp 0x419ff
leaq 0x18637(%rip), %rdi     # 0x5a050
leaq 0x1e8c1(%rip), %rsi     # 0x602e1
leaq 0x1efba(%rip), %rcx     # 0x609e1
movl $0x532, %edx            # imm = 0x532
callq 0x4200
leaq 0x18618(%rip), %rdi     # 0x5a050
leaq 0x1e8a2(%rip), %rsi     # 0x602e1
leaq 0x1ef9b(%rip), %rcx     # 0x609e1
movl $0x534, %edx            # imm = 0x534
callq 0x4200
leaq 0x185f9(%rip), %rdi     # 0x5a050
leaq 0x1e883(%rip), %rsi     # 0x602e1
leaq 0x1ef7c(%rip), %rcx     # 0x609e1
movl $0x53e, %edx            # imm = 0x53E
callq 0x4200
leaq 0x185da(%rip), %rdi     # 0x5a050
leaq 0x1e864(%rip), %rsi     # 0x602e1
leaq 0x1ef5d(%rip), %rcx     # 0x609e1
movl $0x543, %edx            # imm = 0x543
callq 0x4200
leaq 0x185bb(%rip), %rdi     # 0x5a050
leaq 0x1e845(%rip), %rsi     # 0x602e1
leaq 0x1ef3e(%rip), %rcx     # 0x609e1
movl $0x547, %edx            # imm = 0x547
callq 0x4200
leaq 0x1ef8a(%rip), %rdi     # 0x60a3e
leaq 0x1e826(%rip), %rsi     # 0x602e1
leaq 0x1ef1f(%rip), %rcx     # 0x609e1
movl $0x551, %edx            # imm = 0x551
callq 0x4200
leaq 0x1ef8b(%rip), %rdi     # 0x60a5e
leaq 0x1e807(%rip), %rsi     # 0x602e1
leaq 0x1ef00(%rip), %rcx     # 0x609e1
movl $0x552, %edx            # imm = 0x552
callq 0x4200
leaq 0x1855e(%rip), %rdi     # 0x5a050
leaq 0x1e7e8(%rip), %rsi     # 0x602e1
leaq 0x1eee1(%rip), %rcx     # 0x609e1
movl $0x538, %edx            # imm = 0x538
callq 0x4200