// File: sisong[P]ApkDiffPatch/HDiffPatch/libHDiffPatch/HDiff/private_diff/limit_mem_diff/stream_serialize.cpp
// Function: hdiff_private::_TCheckOutNewDataStream::_write_check(hpatch_TStreamOutput const*, unsigned long long, unsigned char const*, unsigned char const*)
hpatch_BOOL _TCheckOutNewDataStream::_write_check(const hpatch_TStreamOutput* stream,hpatch_StreamPos_t writeToPos,
                                                  const unsigned char* data,const unsigned char* data_end){
    _TCheckOutNewDataStream* self=(_TCheckOutNewDataStream*)stream->streamImport;
    _test_rt(self->writedLen==writeToPos);
    self->writedLen+=(size_t)(data_end-data);
    _test_rt(self->writedLen<=self->streamSize);
    
    hpatch_StreamPos_t readPos=writeToPos;
    while (data<data_end) {
        size_t readLen=(size_t)(data_end-data);
        if (readLen>self->bufSize) readLen=self->bufSize;
        _test_rt(self->newData->read(self->newData,readPos,self->buf,self->buf+readLen));
        _test_rt(0==memcmp(data,self->buf,readLen));
        data+=readLen;
        readPos+=readLen;
    }
    return hpatch_TRUE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rax
cmpq -0x18(%rbp), %rax
je 0x504d5
movq 0x95b18(%rip), %rax     # 0xe5fd0
movq (%rax), %rdi
leaq 0x611f1(%rip), %rsi     # 0xb16b3
movb $0x0, %al
callq 0x4520
movl $0x0, -0x4(%rbp)
jmp 0x50617
movq -0x28(%rbp), %rcx
movq -0x20(%rbp), %rax
subq %rax, %rcx
movq -0x30(%rbp), %rax
addq 0x28(%rax), %rcx
movq %rcx, 0x28(%rax)
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x30(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jbe 0x50522
movq 0x95acb(%rip), %rax     # 0xe5fd0
movq (%rax), %rdi
leaq 0x611ce(%rip), %rsi     # 0xb16dd
movb $0x0, %al
callq 0x4520
movl $0x0, -0x4(%rbp)
jmp 0x50617
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x50610
movq -0x28(%rbp), %rax
movq -0x20(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq -0x30(%rbp), %rcx
cmpq 0x38(%rcx), %rax
jbe 0x50561
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x10(%rax), %rax
movq -0x30(%rbp), %rcx
movq 0x20(%rcx), %rdi
movq -0x38(%rbp), %rsi
movq -0x30(%rbp), %rcx
movq 0x30(%rcx), %rdx
movq -0x30(%rbp), %rcx
movq 0x30(%rcx), %rcx
addq -0x40(%rbp), %rcx
callq *%rax
cmpl $0x0, %eax
jne 0x505b5
movq 0x95a35(%rip), %rax     # 0xe5fd0
movq (%rax), %rdi
leaq 0x61168(%rip), %rsi     # 0xb170d
movb $0x0, %al
callq 0x4520
movl $0x0, -0x4(%rbp)
jmp 0x50617
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rsi
movq -0x40(%rbp), %rdx
callq 0x4190
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
je 0x505f3
movq 0x959f7(%rip), %rax     # 0xe5fd0
movq (%rax), %rdi
leaq 0x6117f(%rip), %rsi     # 0xb1762
movb $0x0, %al
callq 0x4520
movl $0x0, -0x4(%rbp)
jmp 0x50617
movq -0x40(%rbp), %rax
addq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x40(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0x5052a
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq