// File: sisong[P]ApkDiffPatch/HDiffPatch/libHDiffPatch/HPatchLite/hpatch_lite.c
// Function: hpatchi_listener_extra_write_new
static hpi_BOOL _hpatchi_listener_extra_write_new(hpatchi_listener_t* listener,const hpi_byte* data,hpi_size_t data_size){
    hpatchi_listener_extra_t* self=(hpatchi_listener_extra_t*)listener;
    while (data_size){
        hpi_size_t posi;
        hpi_size_t cur_len=data_size+self->cached_data_len;
        if (cur_len>self->write_extra_size){//need out cached data by _wrap_listener->write_new()
            cur_len-=self->write_extra_size;
            cur_len=(cur_len<=self->cached_data_len)?cur_len:self->cached_data_len;
            if (!_hpatchi_listener_extra_out(self,cur_len)) return _hpi_FALSE;
        }
        assert(self->cached_data_len<self->write_extra_size);

        cur_len=self->write_extra_size-self->cached_data_len;
        cur_len=(cur_len<=data_size)?cur_len:data_size;
        data_size-=cur_len;
        posi=self->cached_data_pos+self->cached_data_len;
        self->cached_data_len+=cur_len;
        while (cur_len--){//save data to cache
            posi-=(posi<self->write_extra_size)?0:self->write_extra_size;
            self->write_extra[posi++]=*data++;
        }
    }
    return hpi_TRUE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x18b6f
movl -0x1c(%rbp), %eax
movq -0x28(%rbp), %rcx
addl 0x38(%rcx), %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl 0x30(%rcx), %eax
jbe 0x18a80
movq -0x28(%rbp), %rax
movl 0x30(%rax), %ecx
movl -0x30(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl 0x38(%rcx), %eax
ja 0x18a51
movl -0x30(%rbp), %eax
movl %eax, -0x34(%rbp)
jmp 0x18a5b
movq -0x28(%rbp), %rax
movl 0x38(%rax), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x30(%rbp)
movq -0x28(%rbp), %rdi
movl -0x30(%rbp), %esi
callq 0x18880
cmpl $0x0, %eax
jne 0x18a7e
movl $0x0, -0x4(%rbp)
jmp 0x18b76
jmp 0x18a80
movq -0x28(%rbp), %rax
movl 0x38(%rax), %eax
movq -0x28(%rbp), %rcx
cmpl 0x30(%rcx), %eax
jae 0x18a92
jmp 0x18ab1
leaq 0x96021(%rip), %rdi     # 0xaeaba
leaq 0x95ec0(%rip), %rsi     # 0xae960
movl $0x105, %edx            # imm = 0x105
leaq 0x9603b(%rip), %rcx     # 0xaeae7
callq 0x4270
movq -0x28(%rbp), %rax
movl 0x30(%rax), %eax
movq -0x28(%rbp), %rcx
subl 0x38(%rcx), %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x1c(%rbp), %eax
ja 0x18ad2
movl -0x30(%rbp), %eax
movl %eax, -0x38(%rbp)
jmp 0x18ad8
movl -0x1c(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %ecx
movl -0x1c(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x1c(%rbp)
movq -0x28(%rbp), %rax
movl 0x34(%rax), %eax
movq -0x28(%rbp), %rcx
addl 0x38(%rcx), %eax
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %ecx
movq -0x28(%rbp), %rax
addl 0x38(%rax), %ecx
movl %ecx, 0x38(%rax)
movl -0x30(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x30(%rbp)
cmpl $0x0, %eax
je 0x18b6a
movl -0x2c(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl 0x30(%rcx), %eax
jae 0x18b2a
xorl %eax, %eax
movl %eax, -0x3c(%rbp)
jmp 0x18b34
movq -0x28(%rbp), %rax
movl 0x30(%rax), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %ecx
movl -0x2c(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x2c(%rbp)
movq -0x18(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x18(%rbp)
movb (%rax), %dl
movq -0x28(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x2c(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x2c(%rbp)
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
jmp 0x18b07
jmp 0x18a0b
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nop