// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movsd %xmm1, 0x48(%rsp)
movsd %xmm0, 0x20(%rsp)
movq %r8, %r15
movq %rcx, 0x8(%rsp)
movq %rsi, (%rsp)
movq %rdi, %rbx
movq 0xe8(%rsp), %rbp
movq 0xc0(%rsp), %rdi
movq 0xb8(%rsp), %r8
movzwl 0xe0(%rsp), %eax
movzwl 0xd8(%rsp), %ecx
movl 0xd0(%rsp), %edx
movl 0xc8(%rsp), %esi
movl 0x4(%rbx), %r13d
movl %r8d, 0x28(%rsp)
movl %edi, 0x2c(%rsp)
movl %esi, 0x30(%rsp)
movl %edx, 0x34(%rsp)
movzwl 0x2c(%r9), %edx
movw %dx, 0x3c(%rsp)
movw %cx, 0x38(%rsp)
movw %ax, 0x3a(%rsp)
movq %r9, 0x10(%rsp)
movzwl 0x28(%r9), %eax
movw %ax, 0x3e(%rsp)
movq $0x0, 0x40(%rsp)
movq 0x48(%rbx), %rax
testq %rax, %rax
movq %r15, 0x18(%rsp)
je 0x5b5db
leaq -0x1(%r8), %r12
movq 0x58(%rbx), %rcx
shlq $0x5, %rax
movslq -0x1c(%rcx,%rax), %r13
movslq -0x14(%rcx,%rax), %r10
incq %r10
cmpq %r13, %r12
setg %al
cmpq %r15, %r10
setl %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x5b5bf
movq %r13, %r11
incq %r11
movl 0x8(%rbx), %r13d
movl 0x4(%rbx), %ecx
movq %rcx, %rax
xorl %edx, %edx
idivq %rbp
subq %rdx, %rcx
movq %r11, %rax
subq %rcx, %rax
cqto
idivq %rbp
incq %rax
imulq %rbp, %rax
addq %rcx, %rax
decq %rax
cmpq %r13, %rax
cmovlq %rax, %r13
movl 0x1c(%rbx), %eax
movl 0x10(%rbx), %r14d
subq $0x8, %rsp
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %r15, %rcx
movq 0x18(%rsp), %r8
movl 0xb8(%rsp), %r9d
movsd 0x28(%rsp), %xmm0
pushq $0x0
pushq %rbp
pushq %r10
pushq %r13
pushq %r11
pushq %r14
pushq %rax
callq 0x8b8e2
addq $0x40, %rsp
testl %eax, %eax
je 0x5b5bf
cmpq %r12, %r13
jge 0x5b5bf
movq 0x48(%rbx), %rax
movq 0x58(%rbx), %rcx
shlq $0x5, %rax
movslq -0x14(%rcx,%rax), %r10
incq %r10
cmpq %r15, %r10
jl 0x5b51f
movq 0x48(%rbx), %rax
movq 0x58(%rbx), %rcx
shlq $0x5, %rax
movslq -0x1c(%rcx,%rax), %r13
incq %r13
movq 0xb8(%rsp), %r8
movq 0x48(%rbx), %r12
cmpq %r8, %r13
jge 0x5b6cf
movl 0x10(%rbx), %eax
movl 0x1c(%rbx), %r10d
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movq (%rsp), %rdx
movq 0x8(%rsp), %rcx
movq 0x18(%rsp), %r8
movq 0x10(%rsp), %r9
pushq %rax
pushq %r10
callq 0x8be12
addq $0x10, %rsp
movl 0x8(%r14), %edi
movq 0xb8(%rsp), %r14
movq %r14, %r8
leaq -0x1(%r14), %r10
movl 0x4(%rbx), %ecx
movq %rcx, %rax
xorl %edx, %edx
idivq %rbp
movq %rcx, %r14
subq %rdx, %r14
movq %r10, %rsi
subq %r14, %rsi
movq %rsi, %rax
cqto
idivq %rbp
subq %rdx, %r14
addq %rsi, %r14
cmpq %rcx, %r14
cmovleq %rcx, %r14
movslq %edi, %rcx
movq %r14, %rax
subq %r8, %rax
addq %rcx, %rax
js 0x5b6cf
movl 0x10(%rbx), %r11d
movq %r13, %r15
movl 0x1c(%rbx), %r13d
subq $0x8, %rsp
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x20(%rsp), %rcx
movq 0x18(%rsp), %r8
movl 0xb8(%rsp), %r9d
movsd 0x28(%rsp), %xmm0
pushq $0x1
pushq %rbp
pushq %rax
pushq %r10
pushq %r14
pushq %r11
pushq %r13
movq %r15, %r13
callq 0x8b8e2
addq $0x40, %rsp
testl %eax, %eax
je 0x5b6cf
movq 0x48(%rbx), %rax
movq 0x58(%rbx), %rcx
shlq $0x5, %rax
movl -0x18(%rcx,%rax), %edi
cmpq %r13, %r14
jg 0x5b625
movq 0xc0(%rsp), %rsi
movl %esi, %eax
movq 0xb8(%rsp), %rcx
subl %ecx, %eax
movl 0x28(%rbx), %ecx
addl %eax, %ecx
incl %ecx
movl %ecx, 0x28(%rbx)
cmpq $0x0, 0xf0(%rsp)
je 0x5b783
movq 0x48(%rbx), %rcx
movq %rcx, %rax
subq %r12, %rax
jbe 0x5b778
cmpq $0x2, %rax
jb 0x5b778
movq 0x58(%rbx), %rdx
shlq $0x5, %r12
addq %rdx, %r12
shrq %rax
cmpq $0x1, %rax
adcq $0x0, %rax
shlq $0x5, %rcx
addq %rdx, %rcx
addq $-0x20, %rcx
movups (%r12), %xmm0
movups 0x10(%r12), %xmm1
movaps %xmm1, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movups (%rcx), %xmm0
movups 0x10(%rcx), %xmm1
movups %xmm1, 0x10(%r12)
movups %xmm0, (%r12)
movapd 0x50(%rsp), %xmm0
movapd 0x60(%rsp), %xmm1
movupd %xmm1, 0x10(%rcx)
movupd %xmm0, (%rcx)
addq $0x20, %r12
addq $-0x20, %rcx
decq %rax
jne 0x5b72f
movq 0x50(%rbx), %rax
movl $0x1, %ebp
jmp 0x5b7c3
movl 0x4(%rbx), %edx
movl 0x8(%rbx), %eax
subl %edx, %eax
incl %eax
notq %rsi
addq %rdx, %rsi
addq %rcx, %rsi
addq %rax, %rsi
testq %rsi, %rsi
jle 0x5b7bd
movl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
mulsd 0x48(%rsp), %xmm0
cvtsi2sd %rsi, %xmm1
ucomisd %xmm0, %xmm1
jae 0x5b6fc
movq 0x50(%rbx), %rax
xorl %ebp, %ebp
cmpq %rax, 0x48(%rbx)
jne 0x5b7ee
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %esi
cmovneq %rcx, %rsi
movq %rsi, 0x50(%rbx)
movq 0x58(%rbx), %rdi
shlq $0x5, %rsi
callq 0x2370
movq %rax, 0x58(%rbx)
movq 0x48(%rbx), %rax
movq 0x58(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x48(%rbx)
shlq $0x5, %rax
movups 0x28(%rsp), %xmm0
movups 0x38(%rsp), %xmm1
movups %xmm1, 0x10(%rcx,%rax)
movups %xmm0, (%rcx,%rax)
movl %ebp, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq