// File: chhylp123[P]hifiasm/Correct.cpp
// Function: push_hc_wlst_non_retrieve_exz(overlap_region*, char*, long, char*, long, bit_extz_t*, unsigned int, long, long, long, long, long, long, double, long, double, long, void*)
uint32_t push_hc_wlst_non_retrieve_exz(overlap_region* ol, char* qa, int64_t ql, char *ta, int64_t tl, bit_extz_t *exz, uint32_t max_err,
                        int64_t qs, int64_t qe, int64_t ts, int64_t te, int64_t aux_beg, int64_t aux_end, double e_rate, int64_t block_s, double ovlp_cut, int64_t force_aln, void *km)
{

    window_list p, t, *a; int64_t w_e, w_s, ce = qs - 1, cs = ol->x_pos_s, toff, ovl, ualn, aln, ys; 
    uint64_t a_n, k;
    p.x_start = qs; p.x_end = qe; p.y_start = ts; p.y_end = te; p.error = exz->err;
    p.extra_begin = aux_beg; p.extra_end = aux_end; p.error_threshold = exz->thre; p.cidx = p.clen = 0;
    if(ol->w_list.n > 0) { //utilize the the end pos of pre-window in forward
        w_e = ol->w_list.a[ol->w_list.n-1].x_end; 
        toff = ol->w_list.a[ol->w_list.n-1].y_end + 1;
        while ((w_e < ce) && (toff < tl)) {
            w_s = w_e + 1;
            get_win_id_by_s(ol, w_s, block_s, &w_e);
            // x_start = w_s; x_end = w_e;
            if(aln_wlst_adv_non_retrieve_exz(ol, qa, ta, tl, exz, max_err,
            ol->y_pos_strand, ol->y_id, w_s, w_e, toff, block_s, e_rate, 0)) {
                toff = ol->w_list.a[ol->w_list.n-1].y_end + 1;
            } else {
                break;
            }
        }
        cs = ol->w_list.a[ol->w_list.n-1].x_end + 1;
    }
    ///utilize the the start pos of next window in backward
    a_n = ol->w_list.n; w_s = qs;
    if(w_s > cs) {
        gen_backtrace_non_retrieve_adv_exz(&p, ol, qa, ta, tl, exz, ol->y_pos_strand, ol->y_id);
        toff = p.y_start - 1;
        while (w_s > cs) {
            w_e = w_s - 1;
            get_win_id_by_e(ol, w_e, block_s, &w_s); ys = toff+1-(w_e+1-w_s);
            // x_start = w_s; x_end = w_e; x_len = x_end + 1 - x_start;
            if((ys >= 0) && aln_wlst_adv_non_retrieve_exz(ol, qa, ta, tl, exz, max_err,
                ol->y_pos_strand, ol->y_id, w_s, w_e, ys, block_s, e_rate, 1)) {
                toff = ol->w_list.a[ol->w_list.n-1].y_start - 1;
            } else {
                break;
            }
        }
    }

    ol->align_length += qe + 1 - qs;
    ovl = ol->x_pos_e+1-ol->x_pos_s; ualn = (qe + 1 - ol->x_pos_s) - ol->align_length; aln = ovl-ualn;
    // if((!force_aln) && (!simi_pass(ovl, aln, 0, ovlp_cut, &e_rate)) && (!simi_pass(ovl, aln, sec_check, ovlp_cut, NULL))) {
    if((!force_aln) && (!pass_qovlp(ovl, aln, ovlp_cut))) {
        kv_push(window_list, ol->w_list, p); 
        return 0;
    }

    if(ol->w_list.n > a_n) {
        a = ol->w_list.a + a_n; a_n = ol->w_list.n - a_n; toff = a_n; a_n >>=1;
        for (k = 0; k < a_n; k++) {
            t = a[k]; a[k] = a[toff-1-k]; a[toff-1-k] = t;
        }
    }
    kv_push(window_list, ol->w_list, p); 
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x140, %rsp            # imm = 0x140
movq 0x58(%rbp), %rax
movq 0x50(%rbp), %rax
movq 0x48(%rbp), %rax
movq 0x40(%rbp), %rax
movq 0x38(%rbp), %rax
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movl 0x10(%rbp), %eax
movq %rdi, -0x30(%rbp)
movq %rsi, -0x38(%rbp)
movq %rdx, -0x40(%rbp)
movq %rcx, -0x48(%rbp)
movq %r8, -0x50(%rbp)
movq %r9, -0x58(%rbp)
movsd %xmm0, -0x60(%rbp)
movsd %xmm1, -0x68(%rbp)
movq 0x18(%rbp), %rax
subq $0x1, %rax
movq %rax, -0xc8(%rbp)
movq -0x30(%rbp), %rax
movl 0x4(%rax), %eax
movq %rax, -0xd0(%rbp)
movq 0x18(%rbp), %rax
movl %eax, -0x88(%rbp)
movq 0x20(%rbp), %rax
movl %eax, -0x84(%rbp)
movq 0x28(%rbp), %rax
movl %eax, -0x80(%rbp)
movq 0x30(%rbp), %rax
movl %eax, -0x7c(%rbp)
movq -0x58(%rbp), %rax
movl 0x2c(%rax), %eax
movw %ax, -0x74(%rbp)
movq 0x38(%rbp), %rax
movw %ax, -0x78(%rbp)
movq 0x40(%rbp), %rax
movw %ax, -0x76(%rbp)
movq -0x58(%rbp), %rax
movl 0x28(%rax), %eax
movw %ax, -0x72(%rbp)
movl $0x0, -0x6c(%rbp)
movl $0x0, -0x70(%rbp)
movq -0x30(%rbp), %rax
cmpq $0x0, 0x48(%rax)
jbe 0x502fa
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x30(%rbp), %rcx
movq 0x48(%rcx), %rcx
subq $0x1, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0x4(%rax), %rax
movq %rax, -0xb8(%rbp)
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x30(%rbp), %rcx
movq 0x48(%rcx), %rcx
subq $0x1, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
addl $0x1, %eax
cltq
movq %rax, -0xd8(%rbp)
movq -0xb8(%rbp), %rcx
xorl %eax, %eax
cmpq -0xc8(%rbp), %rcx
movb %al, -0x109(%rbp)
jge 0x501e9
movq -0xd8(%rbp), %rax
cmpq -0x50(%rbp), %rax
setl %al
movb %al, -0x109(%rbp)
movb -0x109(%rbp), %al
testb $0x1, %al
jne 0x501f8
jmp 0x502d0
movq -0xb8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xc0(%rbp)
movq -0x30(%rbp), %rdi
movq -0xc0(%rbp), %rsi
movq 0x48(%rbp), %rdx
leaq -0xb8(%rbp), %rcx
callq 0x9e2e0
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq -0x50(%rbp), %rcx
movq -0x58(%rbp), %r8
movl 0x10(%rbp), %r9d
movq -0x30(%rbp), %rax
movl 0x1c(%rax), %r15d
movq -0x30(%rbp), %rax
movl 0x10(%rax), %r14d
movq -0xc0(%rbp), %rbx
movq -0xb8(%rbp), %r11
movq -0xd8(%rbp), %r10
movq 0x48(%rbp), %rax
movsd -0x60(%rbp), %xmm0
xorl %r12d, %r12d
movl %r15d, (%rsp)
movl %r14d, 0x8(%rsp)
movq %rbx, 0x10(%rsp)
movq %r11, 0x18(%rsp)
movq %r10, 0x20(%rsp)
movq %rax, 0x28(%rsp)
movl $0x0, 0x30(%rsp)
callq 0xa7f20
cmpl $0x0, %eax
je 0x502c9
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x30(%rbp), %rcx
movq 0x48(%rcx), %rcx
subq $0x1, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
addl $0x1, %eax
cltq
movq %rax, -0xd8(%rbp)
jmp 0x502cb
jmp 0x502d0
jmp 0x501bd
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x30(%rbp), %rcx
movq 0x48(%rcx), %rcx
subq $0x1, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
addl $0x1, %eax
cltq
movq %rax, -0xd0(%rbp)
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x100(%rbp)
movq 0x18(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
cmpq -0xd0(%rbp), %rax
jle 0x5048e
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x48(%rbp), %rcx
movq -0x50(%rbp), %r8
movq -0x58(%rbp), %r9
movq -0x30(%rbp), %rax
movl 0x1c(%rax), %r10d
movq -0x30(%rbp), %rax
movl 0x10(%rax), %eax
leaq -0x88(%rbp), %rdi
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
callq 0xa8430
movl -0x80(%rbp), %eax
subl $0x1, %eax
cltq
movq %rax, -0xd8(%rbp)
movq -0xc0(%rbp), %rax
cmpq -0xd0(%rbp), %rax
jle 0x5048c
movq -0xc0(%rbp), %rax
subq $0x1, %rax
movq %rax, -0xb8(%rbp)
movq -0x30(%rbp), %rdi
movq -0xb8(%rbp), %rsi
movq 0x48(%rbp), %rdx
leaq -0xc0(%rbp), %rcx
callq 0x9e250
movq -0xd8(%rbp), %rax
addq $0x1, %rax
movq -0xb8(%rbp), %rcx
addq $0x1, %rcx
subq -0xc0(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0xf8(%rbp)
cmpq $0x0, -0xf8(%rbp)
jl 0x50485
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq -0x50(%rbp), %rcx
movq -0x58(%rbp), %r8
movl 0x10(%rbp), %r9d
movq -0x30(%rbp), %rax
movl 0x1c(%rax), %r15d
movq -0x30(%rbp), %rax
movl 0x10(%rax), %r14d
movq -0xc0(%rbp), %rbx
movq -0xb8(%rbp), %r11
movq -0xf8(%rbp), %r10
movq 0x48(%rbp), %rax
movsd -0x60(%rbp), %xmm0
movl %r15d, (%rsp)
movl %r14d, 0x8(%rsp)
movq %rbx, 0x10(%rsp)
movq %r11, 0x18(%rsp)
movq %r10, 0x20(%rsp)
movq %rax, 0x28(%rsp)
movl $0x1, 0x30(%rsp)
callq 0xa7f20
cmpl $0x0, %eax
je 0x50485
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x30(%rbp), %rcx
movq 0x48(%rcx), %rcx
subq $0x1, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
subl $0x1, %eax
cltq
movq %rax, -0xd8(%rbp)
jmp 0x50487
jmp 0x5048c
jmp 0x5036e
jmp 0x5048e
movq 0x20(%rbp), %rdx
addq $0x1, %rdx
subq 0x18(%rbp), %rdx
movq -0x30(%rbp), %rax
movl 0x28(%rax), %ecx
addq %rdx, %rcx
movl %ecx, 0x28(%rax)
movq -0x30(%rbp), %rax
movl 0x8(%rax), %eax
addl $0x1, %eax
movq -0x30(%rbp), %rcx
subl 0x4(%rcx), %eax
movl %eax, %eax
movq %rax, -0xe0(%rbp)
movq 0x20(%rbp), %rax
addq $0x1, %rax
movq -0x30(%rbp), %rcx
movl 0x4(%rcx), %ecx
subq %rcx, %rax
movq -0x30(%rbp), %rcx
movl 0x28(%rcx), %ecx
subq %rcx, %rax
movq %rax, -0xe8(%rbp)
movq -0xe0(%rbp), %rax
subq -0xe8(%rbp), %rax
movq %rax, -0xf0(%rbp)
cmpq $0x0, 0x50(%rbp)
jne 0x505f3
cmpq $0x0, -0xf0(%rbp)
jle 0x5052f
cvtsi2sdq -0xe0(%rbp), %xmm1
mulsd -0x68(%rbp), %xmm1
cvtsi2sdq -0xf0(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jae 0x505f3
jmp 0x50531
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x30(%rbp), %rcx
cmpq 0x50(%rcx), %rax
jne 0x505a3
movq -0x30(%rbp), %rax
cmpq $0x0, 0x50(%rax)
je 0x50562
movq -0x30(%rbp), %rax
movq 0x50(%rax), %rax
shlq %rax
movq %rax, -0x118(%rbp)
jmp 0x50570
movl $0x2, %eax
movq %rax, -0x118(%rbp)
jmp 0x50570
movq -0x118(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x50(%rax), %rsi
shlq $0x5, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x58(%rax)
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x30(%rbp), %rdx
movq 0x48(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x48(%rdx)
shlq $0x5, %rcx
addq %rcx, %rax
movq -0x88(%rbp), %rcx
movq %rcx, (%rax)
movq -0x80(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x78(%rbp), %rcx
movq %rcx, 0x10(%rax)
movq -0x70(%rbp), %rcx
movq %rcx, 0x18(%rax)
movl $0x0, -0x24(%rbp)
jmp 0x5082f
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rax
cmpq -0x100(%rbp), %rax
jbe 0x50770
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x100(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0xb0(%rbp)
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rax
subq -0x100(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0x100(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0x100(%rbp), %rax
shrq %rax
movq %rax, -0x100(%rbp)
movq $0x0, -0x108(%rbp)
movq -0x108(%rbp), %rax
cmpq -0x100(%rbp), %rax
jae 0x5076e
movq -0xb0(%rbp), %rax
movq -0x108(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movq %rcx, -0xa8(%rbp)
movq 0x8(%rax), %rcx
movq %rcx, -0xa0(%rbp)
movq 0x10(%rax), %rcx
movq %rcx, -0x98(%rbp)
movq 0x18(%rax), %rax
movq %rax, -0x90(%rbp)
movq -0xb0(%rbp), %rcx
movq -0xd8(%rbp), %rax
subq $0x1, %rax
subq -0x108(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rcx
movq -0xb0(%rbp), %rax
movq -0x108(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq 0x10(%rcx), %rdx
movq %rdx, 0x10(%rax)
movq 0x18(%rcx), %rcx
movq %rcx, 0x18(%rax)
movq -0xb0(%rbp), %rax
movq -0xd8(%rbp), %rcx
subq $0x1, %rcx
subq -0x108(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq -0xa8(%rbp), %rcx
movq %rcx, (%rax)
movq -0xa0(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x98(%rbp), %rcx
movq %rcx, 0x10(%rax)
movq -0x90(%rbp), %rcx
movq %rcx, 0x18(%rax)
movq -0x108(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x108(%rbp)
jmp 0x50665
jmp 0x50770
jmp 0x50772
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x30(%rbp), %rcx
cmpq 0x50(%rcx), %rax
jne 0x507e4
movq -0x30(%rbp), %rax
cmpq $0x0, 0x50(%rax)
je 0x507a3
movq -0x30(%rbp), %rax
movq 0x50(%rax), %rax
shlq %rax
movq %rax, -0x120(%rbp)
jmp 0x507b1
movl $0x2, %eax
movq %rax, -0x120(%rbp)
jmp 0x507b1
movq -0x120(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rdi
movq -0x30(%rbp), %rax
movq 0x50(%rax), %rsi
shlq $0x5, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x58(%rax)
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x30(%rbp), %rdx
movq 0x48(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x48(%rdx)
shlq $0x5, %rcx
addq %rcx, %rax
movq -0x88(%rbp), %rcx
movq %rcx, (%rax)
movq -0x80(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x78(%rbp), %rcx
movq %rcx, 0x10(%rax)
movq -0x70(%rbp), %rcx
movq %rcx, 0x18(%rax)
movl $0x1, -0x24(%rbp)
movl -0x24(%rbp), %eax
addq $0x140, %rsp            # imm = 0x140
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nopw %cs:(%rax,%rax)