// File: /workspace/github_cpp_makefile_star2_O2/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)
movslq %ecx, %rsi
jne 0x38ccb
movb 0x151(%rbx), %al
jmp 0x38cdf
movq 0x50(%rdx), %rax
movq 0x58(%rdx), %rdi
movl (%rdi,%rsi,4), %edi
cmpw $0x0, 0xa(%rax,%rdi)
setne %al
movl 0x58(%rsp), %edi
movl %eax, %ebp
xorb $0x1, %bpl
orb %r13b, %bpl
jne 0x38d04
cmpl $0xa, 0x50(%rsp)
jae 0x38ee6
decl %edi
cmpl $0x9, %edi
jae 0x38ee6
movl %r13d, %edi
xorb $0x1, %dil
movl %eax, %r8d
orb %dil, %r8b
je 0x38f05
testq %r12, %r12
jne 0x38d3e
testq %r14, %r14
sete %r8b
orb %dil, %r8b
je 0x38fbf
testq %r14, %r14
je 0x38d3b
movq 0x60(%rdx), %rdi
movl (%rdi,%rsi,4), %r12d
jmp 0x38d3e
xorl %r12d, %r12d
cmpq $0x0, 0xf0(%rbx)
jne 0x38f24
movl 0x60(%rbx), %r15d
cmpl 0x5c(%rbx), %r15d
jge 0x38f43
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 0x38fde
testb %al, %al
je 0x38f62
leaq 0xc0(%rbx), %rcx
movq %rbx, 0xf0(%rbx)
leaq 0x3c761(%rip), %rax     # 0x75508
movq %rax, 0x100(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0xe0(%rbx)
movl %r15d, 0x130(%rbx)
movq %rcx, 0xc0(%rbx)
testb %r13b, %r13b
movq %r14, %rax
cmovneq %r12, %rax
movq %rax, 0xc8(%rbx)
leaq -0x336(%rip), %rax      # 0x38aa8
movq %rax, 0xd8(%rbx)
cmpq $0x0, 0x108(%rbx)
jne 0x38f81
cmpq $0x0, 0xf8(%rbx)
jne 0x38fa0
testb %bpl, %bpl
jne 0x38ed1
movq %r14, %rsi
cmpl $0x2, 0x154(%rbx)
jl 0x38e72
testq %r12, %r12
je 0x38e72
movq 0x158(%rbx), %rdi
movq %rsi, %r15
movq %rcx, %r14
callq 0x3a484
movl 0x58(%rbx), %edx
movq %r15, %rdi
movq %r12, %rsi
movl 0x50(%rsp), %ecx
movl 0x58(%rsp), %r8d
callq 0x37fbd
movq %r14, %rcx
movq %r15, %rsi
movq %rax, 0xf8(%rbx)
testq %rax, %rax
je 0x38e72
movq %rbx, %rdi
callq 0x39c30
movq %r14, %rcx
movq %r15, %rsi
addl %r12d, 0x58(%rbx)
cmpq $0x0, 0xf8(%rbx)
jne 0x38ed1
leaq 0x110(%rbx), %r8
movq %rcx, 0x110(%rbx)
movq 0xb0(%rbx), %rax
movq 0xb8(%rbx), %r9
movq 0x10(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movq %rax, 0x118(%rbx)
leaq -0x324(%rip), %rax      # 0x38b80
movq %rax, 0x128(%rbx)
movq 0x100(%rbx), %rdi
movq $0x4000, (%rsp)         # imm = 0x4000
movl 0x50(%rsp), %edx
movl 0x58(%rsp), %ecx
callq *0x8(%rdi)
movq %rax, 0x108(%rbx)
testq %rax, %rax
je 0x38ee2
movb $0x1, %al
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
jmp 0x38ed3
leaq 0x16163(%rip), %rdi     # 0x4f050
leaq 0x1c48d(%rip), %rsi     # 0x55381
leaq 0x1cb86(%rip), %rcx     # 0x55a81
movl $0x532, %edx            # imm = 0x532
callq 0x4230
leaq 0x16144(%rip), %rdi     # 0x4f050
leaq 0x1c46e(%rip), %rsi     # 0x55381
leaq 0x1cb67(%rip), %rcx     # 0x55a81
movl $0x534, %edx            # imm = 0x534
callq 0x4230
leaq 0x16125(%rip), %rdi     # 0x4f050
leaq 0x1c44f(%rip), %rsi     # 0x55381
leaq 0x1cb48(%rip), %rcx     # 0x55a81
movl $0x53e, %edx            # imm = 0x53E
callq 0x4230
leaq 0x16106(%rip), %rdi     # 0x4f050
leaq 0x1c430(%rip), %rsi     # 0x55381
leaq 0x1cb29(%rip), %rcx     # 0x55a81
movl $0x543, %edx            # imm = 0x543
callq 0x4230
leaq 0x160e7(%rip), %rdi     # 0x4f050
leaq 0x1c411(%rip), %rsi     # 0x55381
leaq 0x1cb0a(%rip), %rcx     # 0x55a81
movl $0x547, %edx            # imm = 0x547
callq 0x4230
leaq 0x1cb56(%rip), %rdi     # 0x55ade
leaq 0x1c3f2(%rip), %rsi     # 0x55381
leaq 0x1caeb(%rip), %rcx     # 0x55a81
movl $0x551, %edx            # imm = 0x551
callq 0x4230
leaq 0x1cb57(%rip), %rdi     # 0x55afe
leaq 0x1c3d3(%rip), %rsi     # 0x55381
leaq 0x1cacc(%rip), %rcx     # 0x55a81
movl $0x552, %edx            # imm = 0x552
callq 0x4230
leaq 0x1608a(%rip), %rdi     # 0x4f050
leaq 0x1c3b4(%rip), %rsi     # 0x55381
leaq 0x1caad(%rip), %rcx     # 0x55a81
movl $0x538, %edx            # imm = 0x538
callq 0x4230