// File: chhylp123[P]hifiasm/Correct.cpp
// Function: recal_boundary_exz(char*, char*, long, long, long, long, long, long, long, long, unsigned int, bit_extz_t*, All_reads*, hpc_t*, ul_idx_t const*, long*, long*, long*)
inline int recal_boundary_exz(char* qstr, char* tstr, int64_t ql0, int64_t tl0, int64_t thres,
int64_t toff, int64_t ts0, int64_t te0, int64_t err0, 
int64_t tid, uint32_t rev, bit_extz_t *exz,
All_reads* rref, hpc_t *hpc_g, const ul_idx_t *uref, 
int64_t *ts_r, int64_t *aux_beg_r, int64_t *aux_end_r)
{
    int64_t ts, tl, t_tot_l, aux_beg, aux_end, t_pri_l, aln_l = ql0 + (thres << 1);
    char *q_string = qstr, *t_string; 
    if(hpc_g) t_tot_l = hpc_len(*hpc_g, tid);
    else if(uref) t_tot_l = uref->ug->u.a[tid].len;
    else t_tot_l = Get_READ_LENGTH((*rref), tid);

    if(ts0 == 0) {//left boundary
        ts = toff;
    } else if((te0 + 1) == tl0) {//right boundary
        ts = toff + te0 - ql0 + 1;
    } else {
        return 0;
    }
    if(!init_waln(thres, ts, t_tot_l, aln_l, &aux_beg, &aux_end, &ts, &t_pri_l)) return 0;
    if(ts == toff && tl0 == t_pri_l) return 0;//unchanged, make no sense

    tl = t_pri_l;
    if(rref) {
        recover_UC_Read_sub_region(tstr, ts, tl, rev, rref, tid); t_string = tstr;
    } else {
        t_string = return_str_seq_exz(tstr, ts, tl, rev, hpc_g, uref, tid);
    }

    clear_align(*exz); 
    ed_band_cal_semi_64_w_absent_diag_trace(t_string, tl, q_string, ql0, thres, aux_beg, exz);

    if(is_align(*exz) && exz->err < err0) {
        (*aux_beg_r) = aux_beg;
        (*aux_end_r) = aux_end;
        (*ts_r) = ts;
        return 1;
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq 0x68(%rbp), %rax
movq 0x60(%rbp), %rax
movq 0x58(%rbp), %rax
movq 0x50(%rbp), %rax
movq 0x48(%rbp), %rax
movq 0x40(%rbp), %rax
movq 0x38(%rbp), %rax
movl 0x30(%rbp), %eax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq -0x20(%rbp), %rax
movq -0x30(%rbp), %rcx
shlq %rcx
addq %rcx, %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x78(%rbp)
cmpq $0x0, 0x48(%rbp)
je 0xc6f17
movq 0x48(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
imulq $0x28, 0x28(%rbp), %rcx
addq %rcx, %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
sarl %eax
cltq
movq %rax, -0x50(%rbp)
jmp 0xc6f56
cmpq $0x0, 0x50(%rbp)
je 0xc6f40
movq 0x50(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
imulq $0x28, 0x28(%rbp), %rcx
addq %rcx, %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movq %rax, -0x50(%rbp)
jmp 0xc6f54
movq 0x40(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x50(%rbp)
jmp 0xc6f56
cmpq $0x0, 0x10(%rbp)
jne 0xc6f67
movq -0x38(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0xc6f99
movq 0x18(%rbp), %rax
addq $0x1, %rax
cmpq -0x28(%rbp), %rax
jne 0xc6f8b
movq -0x38(%rbp), %rax
addq 0x18(%rbp), %rax
subq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0xc6f97
movl $0x0, -0x4(%rbp)
jmp 0xc70e6
jmp 0xc6f99
movq -0x30(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq -0x70(%rbp), %rcx
leaq -0x58(%rbp), %r8
leaq -0x60(%rbp), %r9
leaq -0x40(%rbp), %r10
leaq -0x68(%rbp), %rax
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x33f90
cmpl $0x0, %eax
jne 0xc6fd8
movl $0x0, -0x4(%rbp)
jmp 0xc70e6
movq -0x40(%rbp), %rax
cmpq -0x38(%rbp), %rax
jne 0xc6ff8
movq -0x28(%rbp), %rax
cmpq -0x68(%rbp), %rax
jne 0xc6ff8
movl $0x0, -0x4(%rbp)
jmp 0xc70e6
movq -0x68(%rbp), %rax
movq %rax, -0x48(%rbp)
cmpq $0x0, 0x40(%rbp)
je 0xc7030
movq -0x18(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x48(%rbp), %rdx
movl 0x30(%rbp), %eax
movq 0x40(%rbp), %r8
movq 0x28(%rbp), %r9
movzbl %al, %ecx
callq 0x9a30
movq -0x18(%rbp), %rax
movq %rax, -0x80(%rbp)
jmp 0xc705d
movq -0x18(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x48(%rbp), %rdx
movl 0x30(%rbp), %eax
movb %al, %cl
movq 0x48(%rbp), %r8
movq 0x50(%rbp), %r9
movq 0x28(%rbp), %rax
movzbl %cl, %ecx
movq %rax, (%rsp)
callq 0xa8880
movq %rax, -0x80(%rbp)
movq 0x38(%rbp), %rax
movl $0x7fffffff, 0x2c(%rax) # imm = 0x7FFFFFFF
movq -0x80(%rbp), %rdi
movq -0x48(%rbp), %rax
movl %eax, %esi
movq -0x78(%rbp), %rdx
movq -0x20(%rbp), %rax
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %eax, %r8d
movq -0x58(%rbp), %rax
movl %eax, %r9d
movq 0x38(%rbp), %rax
movq %rax, (%rsp)
callq 0xab870
movq 0x38(%rbp), %rax
movl 0x2c(%rax), %eax
movq 0x38(%rbp), %rcx
cmpl 0x28(%rcx), %eax
jg 0xc70df
movq 0x38(%rbp), %rax
movslq 0x2c(%rax), %rax
cmpq 0x20(%rbp), %rax
jge 0xc70df
movq -0x58(%rbp), %rcx
movq 0x60(%rbp), %rax
movq %rcx, (%rax)
movq -0x60(%rbp), %rcx
movq 0x68(%rbp), %rax
movq %rcx, (%rax)
movq -0x40(%rbp), %rcx
movq 0x58(%rbp), %rax
movq %rcx, (%rax)
movl $0x1, -0x4(%rbp)
jmp 0xc70e6
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)