// File: /workspace/github_cpp_makefile_star2_O2/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 0x3efe7
movq (%rdi), %r13
cmpq $0x0, 0x30(%r13)
jne 0x3f006
movq %rcx, %r14
movq %rdx, %r12
pushq $0x1
popq %rbx
subq %rdx, %r14
je 0x3efb9
movq %rsi, %r15
movq 0x8(%r13), %rax
subq %r14, %rax
setb %cl
notb %cl
cmpq %rsi, %rax
setae %al
testb %al, %cl
jne 0x3eef9
callq 0x4050
movl $0x1b, (%rax)
movl 0x38(%r13), %eax
cmpl $0x1b, %eax
je 0x3efb7
testl %eax, %eax
jne 0x3eec8
movl $0x1b, 0x38(%r13)
movq 0x360f9(%rip), %rax     # 0x74fc8
movq (%rax), %r14
pushq $0x1b
popq %rbp
movl %ebp, %edi
callq 0x40e0
leaq 0xf413(%rip), %rsi      # 0x4e2f6
xorl %ebx, %ebx
movq %r14, %rdi
movl %ebp, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0x4480
jmp 0x3efb9
cmpl $0x0, 0x40(%r13)
je 0x3ef0f
andl $0x0, 0x40(%r13)
orq $-0x1, 0x28(%r13)
pushq $-0x1
popq %rax
jmp 0x3ef13
movq 0x28(%r13), %rax
cmpq %r15, %rax
jne 0x3ef44
movq 0x20(%r13), %rdi
leaq (%r12,%r14), %rdx
movq %r12, %rsi
callq 0x3e941
testl %eax, %eax
je 0x3ef6e
addq %r15, %r14
movq %r14, 0x28(%r13)
movq 0x48(%r13), %rax
cmpq %r14, %rax
cmovaq %rax, %r14
movq %r14, 0x48(%r13)
jmp 0x3efb9
cmpl $0x0, 0x3c(%r13)
je 0x3efa3
movq 0x20(%r13), %rdi
callq 0x3f26b
testl %eax, %eax
je 0x3ef6e
movq 0x20(%r13), %rdi
movq %r15, %rsi
callq 0x3f364
testl %eax, %eax
je 0x3ef6e
movq %r15, 0x28(%r13)
jmp 0x3ef18
orq $-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 0x3efb7
testl %eax, %eax
jne 0x3ef94
movl %ebp, 0x38(%r13)
movq 0x3602d(%rip), %rax     # 0x74fc8
movq (%rax), %r14
jmp 0x3eed5
callq 0x4050
movl $0x22, (%rax)
movl 0x38(%r13), %eax
cmpl $0x22, %eax
jne 0x3efca
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testl %eax, %eax
jne 0x3efd6
movl $0x22, 0x38(%r13)
movq 0x35feb(%rip), %rax     # 0x74fc8
movq (%rax), %r14
pushq $0x22
jmp 0x3eed4
leaq 0x18597(%rip), %rdi     # 0x57585
leaq 0x182b5(%rip), %rsi     # 0x572aa
leaq 0x18598(%rip), %rcx     # 0x57594
movl $0x26a, %edx            # imm = 0x26A
callq 0x4230
leaq 0x18601(%rip), %rdi     # 0x5760e
leaq 0x18296(%rip), %rsi     # 0x572aa
leaq 0x18579(%rip), %rcx     # 0x57594
movl $0x26b, %edx            # imm = 0x26B
callq 0x4230