// File: sisong[P]ApkDiffPatch/HDiffPatch/file_for_patch.c
// Function: hpatch_TFileStreamOutput_reopen
hpatch_BOOL hpatch_TFileStreamOutput_reopen(hpatch_TFileStreamOutput* self,const char* fileName_utf8,
                                            hpatch_StreamPos_t max_file_length){
    hpatch_StreamPos_t curFileWritePos=0;
    assert(self->m_file==0);
    self->fileError=hpatch_FALSE;
    if (self->m_file) _ferr_returnv(EINVAL);
    if (!_import_fileReopenWrite(fileName_utf8,&self->m_file,&curFileWritePos))
       _ferr_return();
    if (curFileWritePos>max_file_length){
        //note: now not support reset file length to max_file_length
        _import_fileClose(&self->m_file);
        _ferr_returnv(EFBIG);
    }
    self->base.streamImport=self;
    self->base.streamSize=max_file_length;
    self->base.read_writed=_hpatch_TFileStreamOutput_read_file;
    self->base.write=_TFileStreamOutput_write_file;
    self->m_fpos=curFileWritePos;
    self->m_offset=0;
    self->is_in_readModel=hpatch_FALSE;
    self->is_random_out=hpatch_FALSE;
    self->out_length=curFileWritePos;
    return hpatch_TRUE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x20(%rax)
jne 0x8e909
jmp 0x8e928
leaq 0x270a4(%rip), %rdi     # 0xb59b4
leaq 0x27005(%rip), %rsi     # 0xb591c
movl $0x2a5, %edx            # imm = 0x2A5
leaq 0x2715b(%rip), %rcx     # 0xb5a7e
callq 0x4270
movq -0x10(%rbp), %rax
movl $0x0, 0x38(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x8e9b0
jmp 0x8e940
jmp 0x8e942
callq 0x4050
movl $0x16, (%rax)
jmp 0x8e94f
movq -0x10(%rbp), %rax
cmpl $0x16, 0x38(%rax)
je 0x8e9a0
movq -0x10(%rbp), %rax
cmpl $0x0, 0x38(%rax)
jne 0x8e96e
movq -0x10(%rbp), %rax
movl $0x16, 0x38(%rax)
movq 0x5765b(%rip), %rax     # 0xe5fd0
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movl $0x16, %edi
callq 0x4100
movq -0x38(%rbp), %rdi
movq %rax, %rcx
leaq 0x1e38b(%rip), %rsi     # 0xacd1f
movl $0x16, %edx
movb $0x0, %al
callq 0x4520
jmp 0x8e9a2
jmp 0x8e9a4
movl $0x0, -0x4(%rbp)
jmp 0x8eb3a
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x20, %rsi
leaq -0x28(%rbp), %rdx
callq 0x8eb50
cmpl $0x0, %eax
jne 0x8ea40
jmp 0x8e9cc
callq 0x4050
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movl 0x38(%rax), %eax
cmpl -0x2c(%rbp), %eax
je 0x8ea30
cmpl $0x0, -0x2c(%rbp)
je 0x8ea30
movq -0x10(%rbp), %rax
cmpl $0x0, 0x38(%rax)
jne 0x8e9fc
movl -0x2c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x38(%rax)
movq 0x575cd(%rip), %rax     # 0xe5fd0
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x2c(%rbp), %edi
callq 0x4100
movq -0x48(%rbp), %rdi
movl -0x3c(%rbp), %edx
movq %rax, %rcx
leaq 0x1e2f6(%rip), %rsi     # 0xacd1f
movb $0x0, %al
callq 0x4520
jmp 0x8ea32
jmp 0x8ea34
movl $0x0, -0x4(%rbp)
jmp 0x8eb3a
movq -0x28(%rbp), %rax
cmpq -0x20(%rbp), %rax
jbe 0x8eac4
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
callq 0x8e0e0
jmp 0x8ea59
callq 0x4050
movl $0x1b, (%rax)
jmp 0x8ea66
movq -0x10(%rbp), %rax
cmpl $0x1b, 0x38(%rax)
je 0x8eab7
movq -0x10(%rbp), %rax
cmpl $0x0, 0x38(%rax)
jne 0x8ea85
movq -0x10(%rbp), %rax
movl $0x1b, 0x38(%rax)
movq 0x57544(%rip), %rax     # 0xe5fd0
movq (%rax), %rax
movq %rax, -0x50(%rbp)
movl $0x1b, %edi
callq 0x4100
movq -0x50(%rbp), %rdi
movq %rax, %rcx
leaq 0x1e274(%rip), %rsi     # 0xacd1f
movl $0x1b, %edx
movb $0x0, %al
callq 0x4520
jmp 0x8eab9
jmp 0x8eabb
movl $0x0, -0x4(%rbp)
jmp 0x8eb3a
movq -0x10(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
leaq -0x736(%rip), %rcx      # 0x8e3b0
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
leaq -0x645(%rip), %rcx      # 0x8e4b0
movq %rcx, 0x18(%rax)
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x30(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x40(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x3c(%rax)
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x48(%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)