// File: /workspace/github_cpp_makefile_star2_O3/sisong[P]ApkDiffPatch/HDiffPatch/file_for_patch.c
// Function: TFileStreamOutput_write_file
static hpatch_BOOL _TFileStreamOutput_write_file(const hpatch_TStreamOutput* stream,hpatch_StreamPos_t writeToPos,
                                                     const TByte* data,const TByte* data_end){
        size_t writeLen;
        hpatch_TFileStreamOutput* self=(hpatch_TFileStreamOutput*)stream->streamImport;
        assert(data<=data_end);
        assert(self->m_offset==0);
        writeLen=(size_t)(data_end-data);
        if (writeLen==0) return hpatch_TRUE;
        if ((writeLen>self->base.streamSize)
            ||(writeToPos>self->base.streamSize-writeLen)) _ferr_returnv(EFBIG);
        if (self->is_in_readModel){
            self->is_in_readModel=hpatch_FALSE;
            self->m_fpos=hpatch_kNullStreamPos;
        }
        if (writeToPos!=self->m_fpos){
            if (self->is_random_out){
                if (!_import_fileFlush(self->m_file)) _rw_ferr_return(); //for lseek64 safe
                if (!_import_fileSeek64To(self->m_file,writeToPos)) _rw_ferr_return();
                self->m_fpos=writeToPos;
            }else{
                _ferr_returnv(ERANGE); //must continue write at self->m_fpos
            }
        }
        if (!_import_fileWrite(self->m_file,data,data+writeLen)) _rw_ferr_return();
        self->m_fpos=writeToPos+writeLen;
        self->out_length=(self->out_length>=self->m_fpos)?self->out_length:self->m_fpos;
        return hpatch_TRUE;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
cmpq %rcx, %rdx
ja 0x48410
movq %rsi, 0x10(%rsp)
movq (%rdi), %rbx
cmpq $0x0, 0x30(%rbx)
jne 0x4842f
movq %rcx, %r14
movq %rdx, %r15
movq %rcx, %rbp
movl $0x1, %r12d
subq %rdx, %rbp
je 0x483fe
movq 0x8(%rbx), %rax
subq %rbp, %rax
setb %cl
notb %cl
movq 0x10(%rsp), %r13
cmpq %r13, %rax
setae %al
testb %al, %cl
jne 0x4827e
callq 0x4050
movl $0x1b, (%rax)
movl 0x38(%rbx), %eax
xorl %r12d, %r12d
cmpl $0x1b, %eax
je 0x483fe
testl %eax, %eax
jne 0x48274
movl $0x1b, 0x38(%rbx)
callq 0x4ae5
jmp 0x483fe
cmpl $0x0, 0x40(%rbx)
je 0x4829c
movl $0x0, 0x40(%rbx)
movq $-0x1, 0x28(%rbx)
movq $-0x1, %rax
jmp 0x482a0
movq 0x28(%rbx), %rax
cmpq %r13, %rax
jne 0x482e6
movq %rbx, 0x8(%rsp)
movq 0x20(%rbx), %r12
movl $0x100000, %ebx         # imm = 0x100000
cmpq %r14, %r15
jae 0x48342
movq %r14, %r13
subq %r15, %r13
cmpq %rbx, %r13
cmovaeq %rbx, %r13
movl $0x1, %esi
movq %r15, %rdi
movq %r13, %rdx
movq %r12, %rcx
callq 0x4660
addq %r13, %r15
cmpq %rax, %r13
je 0x482b3
jmp 0x48344
cmpl $0x0, 0x3c(%rbx)
je 0x48374
movq 0x20(%rbx), %rdi
callq 0x43a0
testl %eax, %eax
jne 0x48349
movq 0x20(%rbx), %rdi
xorl %r12d, %r12d
movq %r13, %rsi
xorl %edx, %edx
callq 0x4540
testl %eax, %eax
je 0x483c1
movq $-0x1, 0x28(%rbx)
callq 0x4050
movl (%rax), %r15d
movl 0x38(%rbx), %eax
cmpl %r15d, %eax
sete %cl
testl %r15d, %r15d
sete %dl
orb %cl, %dl
jne 0x483fe
jmp 0x483ca
je 0x4839c
movq 0x8(%rsp), %rbx
movq $-0x1, 0x28(%rbx)
callq 0x4050
movl (%rax), %r15d
movl 0x38(%rbx), %eax
cmpl %r15d, %eax
sete %cl
testl %r15d, %r15d
sete %dl
orb %cl, %dl
je 0x483ca
xorl %r12d, %r12d
jmp 0x483fe
callq 0x4050
movl $0x22, (%rax)
movl 0x38(%rbx), %eax
xorl %r12d, %r12d
cmpl $0x22, %eax
je 0x483fe
testl %eax, %eax
jne 0x48395
movl $0x22, 0x38(%rbx)
callq 0x4ab2
jmp 0x483fe
addq 0x10(%rsp), %rbp
movq 0x8(%rsp), %rcx
movq %rbp, 0x28(%rcx)
movq 0x48(%rcx), %rax
cmpq %rbp, %rax
cmovaq %rax, %rbp
movq %rbp, 0x48(%rcx)
movl $0x1, %r12d
jmp 0x483fe
movq %r13, 0x28(%rbx)
jmp 0x482a5
testl %eax, %eax
jne 0x483d2
movl %r15d, 0x38(%rbx)
movq 0x33bef(%rip), %rax     # 0x7bfc8
movq (%rax), %r14
movl %r15d, %edi
callq 0x40d0
leaq 0x10f0b(%rip), %rsi     # 0x592f6
xorl %r12d, %r12d
movq %r14, %rdi
movl %r15d, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0x4450
movl %r12d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1a0ce(%rip), %rdi     # 0x624e5
leaq 0x19dec(%rip), %rsi     # 0x6220a
leaq 0x1a0cf(%rip), %rcx     # 0x624f4
movl $0x26a, %edx            # imm = 0x26A
callq 0x4200
leaq 0x1a138(%rip), %rdi     # 0x6256e
leaq 0x19dcd(%rip), %rsi     # 0x6220a
leaq 0x1a0b0(%rip), %rcx     # 0x624f4
movl $0x26b, %edx            # imm = 0x26B
callq 0x4200