// File: sisong[P]ApkDiffPatch/src/patch/Zipper.cpp
// Function: Zipper_file_append_end
bool Zipper_file_append_end(Zipper* self){
    Zipper_file_append_stream* append_state=&self->_append_stream;
    if (append_state->self==0) { assert(false); return false; }
    
    bool result=true;
    const bool isCompressedFile=(append_state->compressHandle!=0);
    if (isCompressedFile){
        if ((append_state->inputPos==0)&&(append_state->outputPos==0)){
            Byte emptyBuf=0; //compress empty file
            check(append_state->write(append_state,0,&emptyBuf,&emptyBuf));
        }
        void* compressHandle=append_state->compressHandle;
        append_state->compressHandle=0;
        check_clear(append_state->compressor->closeCompressHandle(append_state->compressor,compressHandle));
    }
    
    check_clear(append_state->inputPos==append_state->streamSize);
#if (_IS_USED_MULTITHREAD)
    if (isUsedMT(self)) {
        if (append_state->threadWork){
            self->_threadWorks->dispatchWork(append_state->threadWork);
            append_state->threadWork=0;
        }
        check_clear(_dispose_filishedThreadWork(self,false));
    }
#endif
    if (isCompressedFile){
        assert(append_state->outputPos==(ZipFilePos_t)append_state->outputPos);
        ZipFilePos_t compressedSize=(ZipFilePos_t)append_state->outputPos;
        check_clear(_zipper_file_update_compressedSize(self,append_state->curFileIndex,compressedSize));
    }
clear:
    memset(append_state,0,sizeof(Zipper_file_append_stream));
    return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xc0, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x30(%rax)
jne 0x832c4
leaq 0x29fc4(%rip), %rdi     # 0xad270
leaq 0x306d7(%rip), %rsi     # 0xb398a
movl $0x596, %edx            # imm = 0x596
leaq 0x30ed3(%rip), %rcx     # 0xb4192
callq 0x4270
movb $0x1, -0x11(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x48(%rax)
setne %al
andb $0x1, %al
movb %al, -0x12(%rbp)
testb $0x1, -0x12(%rbp)
je 0x83397
movq -0x10(%rbp), %rax
cmpq $0x0, 0x20(%rax)
jne 0x8333c
movq -0x10(%rbp), %rax
cmpq $0x0, 0x28(%rax)
jne 0x8333c
movb $0x0, -0x13(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x10(%rbp), %rdi
xorl %ecx, %ecx
movl %ecx, %esi
leaq -0x13(%rbp), %rcx
movq %rcx, %rdx
callq *%rax
cmpl $0x0, %eax
jne 0x8333a
leaq 0x29f4e(%rip), %rdi     # 0xad270
leaq 0x30661(%rip), %rsi     # 0xb398a
movl $0x59d, %edx            # imm = 0x59D
leaq 0x30e5d(%rip), %rcx     # 0xb4192
callq 0x4270
jmp 0x8333c
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq $0x0, 0x48(%rax)
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x18(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x40(%rcx), %rdi
movq -0x20(%rbp), %rsi
callq *%rax
testb $0x1, %al
jne 0x83395
movb $0x0, -0x11(%rbp)
leaq 0x29ef3(%rip), %rdi     # 0xad270
leaq 0x30606(%rip), %rsi     # 0xb398a
movl $0x5a1, %edx            # imm = 0x5A1
leaq 0x30e02(%rip), %rcx     # 0xb4192
callq 0x4270
jmp 0x83397
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x8(%rcx), %rax
je 0x833cc
movb $0x0, -0x11(%rbp)
leaq 0x29ebc(%rip), %rdi     # 0xad270
leaq 0x305cf(%rip), %rsi     # 0xb398a
movl $0x5a4, %edx            # imm = 0x5A4
leaq 0x30dcb(%rip), %rcx     # 0xb4192
callq 0x4270
movq -0x8(%rbp), %rax
cmpl $0x1, 0x154(%rax)
jle 0x8343c
movq -0x10(%rbp), %rax
cmpq $0x0, 0x38(%rax)
je 0x83408
movq -0x8(%rbp), %rax
movq 0x158(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rsi
callq 0x856c0
movq -0x10(%rbp), %rax
movq $0x0, 0x38(%rax)
movq -0x8(%rbp), %rdi
xorl %esi, %esi
callq 0x834e0
testb $0x1, %al
jne 0x8343a
movb $0x0, -0x11(%rbp)
leaq 0x29e4e(%rip), %rdi     # 0xad270
leaq 0x30561(%rip), %rsi     # 0xb398a
movl $0x5ab, %edx            # imm = 0x5AB
leaq 0x30d5d(%rip), %rcx     # 0xb4192
callq 0x4270
jmp 0x8343c
testb $0x1, -0x12(%rbp)
je 0x834c1
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x28(%rcx), %rcx
movl %ecx, %ecx
cmpq %rcx, %rax
jne 0x8345b
jmp 0x8347a
leaq 0x30d56(%rip), %rdi     # 0xb41b8
leaq 0x30521(%rip), %rsi     # 0xb398a
movl $0x5af, %edx            # imm = 0x5AF
leaq 0x30d1d(%rip), %rcx     # 0xb4192
callq 0x4270
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x70(%rax), %esi
movl -0x24(%rbp), %edx
callq 0x835b0
testb $0x1, %al
jne 0x834bf
movb $0x0, -0x11(%rbp)
leaq 0x29dc9(%rip), %rdi     # 0xad270
leaq 0x304dc(%rip), %rsi     # 0xb398a
movl $0x5b1, %edx            # imm = 0x5B1
leaq 0x30cd8(%rip), %rcx     # 0xb4192
callq 0x4270
jmp 0x834c1
jmp 0x834c3
movq -0x10(%rbp), %rdi
xorl %esi, %esi
movl $0x78, %edx
callq 0x4210
movb -0x11(%rbp), %al
andb $0x1, %al
addq $0x30, %rsp
popq %rbp
retq
nop