// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %rax
cmpq %rcx, %rdx
ja 0x49080
movq (%rdi), %r13
cmpq $0x0, 0x30(%r13)
jne 0x4909f
movq %rcx, %r14
movq %rdx, %r12
movl $0x1, %ebx
subq %rdx, %r14
je 0x49066
movq %rsi, %r15
movq 0x8(%r13), %rax
subq %r14, %rax
setb %cl
notb %cl
cmpq %rsi, %rax
setae %al
testb %al, %cl
jne 0x48f4a
callq 0x4050
movl $0x1b, (%rax)
movl 0x38(%r13), %eax
xorl %ebx, %ebx
cmpl $0x1b, %eax
je 0x49066
testl %eax, %eax
jne 0x48f40
movl $0x1b, 0x38(%r13)
callq 0x4ae5
jmp 0x49066
cmpl $0x0, 0x40(%r13)
je 0x48f61
movl $0x0, 0x40(%r13)
movq $-0x1, 0x28(%r13)
cmpq %r15, 0x28(%r13)
jne 0x48f9b
movq 0x20(%r13), %rdi
leaq (%r12,%r14), %rdx
movq %r12, %rsi
callq 0x489ab
testl %eax, %eax
je 0x48faf
addq %r15, %r14
movq %r14, 0x28(%r13)
movq 0x48(%r13), %rax
cmpq %r14, %rax
cmovaq %rax, %r14
movq %r14, 0x48(%r13)
movl $0x1, %ebx
jmp 0x49066
cmpl $0x0, 0x3c(%r13)
je 0x48fd7
movq 0x20(%r13), %rdi
callq 0x43a0
testl %eax, %eax
je 0x49000
movq $-0x1, 0x28(%r13)
callq 0x4050
movl (%rax), %ebp
movl 0x38(%r13), %eax
cmpl %ebp, %eax
sete %cl
testl %ebp, %ebp
sete %dl
orb %cl, %dl
je 0x49035
xorl %ebx, %ebx
jmp 0x49066
callq 0x4050
movl $0x22, (%rax)
movl 0x38(%r13), %eax
xorl %ebx, %ebx
cmpl $0x22, %eax
je 0x49066
testl %eax, %eax
jne 0x48ff9
movl $0x22, 0x38(%r13)
callq 0x4ab2
jmp 0x49066
movq 0x20(%r13), %rdi
xorl %ebx, %ebx
movq %r15, %rsi
xorl %edx, %edx
callq 0x4540
testl %eax, %eax
je 0x49077
movq $-0x1, 0x28(%r13)
callq 0x4050
movl (%rax), %ebp
movl 0x38(%r13), %eax
cmpl %ebp, %eax
sete %cl
testl %ebp, %ebp
sete %dl
orb %cl, %dl
jne 0x49066
testl %eax, %eax
jne 0x4903d
movl %ebp, 0x38(%r13)
movq 0x32f84(%rip), %rax     # 0x7bfc8
movq (%rax), %r14
movl %ebp, %edi
callq 0x40d0
leaq 0x102a1(%rip), %rsi     # 0x592f6
xorl %ebx, %ebx
movq %r14, %rdi
movl %ebp, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0x4450
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, 0x28(%r13)
jmp 0x48f67
leaq 0x193f0(%rip), %rdi     # 0x62477
leaq 0x1910e(%rip), %rsi     # 0x6219c
leaq 0x193f1(%rip), %rcx     # 0x62486
movl $0x26a, %edx            # imm = 0x26A
callq 0x4200
leaq 0x1945a(%rip), %rdi     # 0x62500
leaq 0x190ef(%rip), %rsi     # 0x6219c
leaq 0x193d2(%rip), %rcx     # 0x62486
movl $0x26b, %edx            # imm = 0x26B
callq 0x4200