// File: chhylp123[P]hifiasm/Correct.cpp
// Function: push_wlst_exz(ul_idx_t const*, hpc_t*, All_reads*, overlap_region*, char*, char*, bit_extz_t*, unsigned int, long, long, long, long, long, long, long, double, long, unsigned int, double, long, void*)
uint32_t push_wlst_exz(const ul_idx_t *uref, hpc_t *hpc_g, All_reads *rref, overlap_region* ol, 
                        char* qstr, char *tstr, bit_extz_t *exz, uint32_t max_err,
                        int64_t qs, int64_t qe, int64_t ts, int64_t te, int64_t tl, 
                        int64_t aux_beg, int64_t aux_end, double e_rate, int64_t block_s, uint32_t sec_check, 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_exz(ol, rref, hpc_g, uref, qstr, tstr, 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_adv_exz(&p, ol, rref, hpc_g, uref, qstr, tstr, 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_exz(ol, rref, hpc_g, uref, qstr, tstr, 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))) {
        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 %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movq 0x70(%rbp), %rax
movq 0x68(%rbp), %rax
movl 0x60(%rbp), %eax
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
movl 0x18(%rbp), %eax
movq 0x10(%rbp), %rax
movq %rdi, -0x38(%rbp)
movq %rsi, -0x40(%rbp)
movq %rdx, -0x48(%rbp)
movq %rcx, -0x50(%rbp)
movq %r8, -0x58(%rbp)
movq %r9, -0x60(%rbp)
movsd %xmm0, -0x68(%rbp)
movsd %xmm1, -0x70(%rbp)
movq 0x20(%rbp), %rax
subq $0x1, %rax
movq %rax, -0xd0(%rbp)
movq -0x50(%rbp), %rax
movl 0x4(%rax), %eax
movq %rax, -0xd8(%rbp)
movq 0x20(%rbp), %rax
movl %eax, -0x90(%rbp)
movq 0x28(%rbp), %rax
movl %eax, -0x8c(%rbp)
movq 0x30(%rbp), %rax
movl %eax, -0x88(%rbp)
movq 0x38(%rbp), %rax
movl %eax, -0x84(%rbp)
movq 0x10(%rbp), %rax
movl 0x2c(%rax), %eax
movw %ax, -0x7c(%rbp)
movq 0x48(%rbp), %rax
movw %ax, -0x80(%rbp)
movq 0x50(%rbp), %rax
movw %ax, -0x7e(%rbp)
movq 0x10(%rbp), %rax
movl 0x28(%rax), %eax
movw %ax, -0x7a(%rbp)
movl $0x0, -0x74(%rbp)
movl $0x0, -0x78(%rbp)
movq -0x50(%rbp), %rax
cmpq $0x0, 0x48(%rax)
jbe 0x4f2dc
movq -0x50(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x50(%rbp), %rcx
movq 0x48(%rcx), %rcx
subq $0x1, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0x4(%rax), %rax
movq %rax, -0xc0(%rbp)
movq -0x50(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x50(%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, -0xe0(%rbp)
movq -0xc0(%rbp), %rcx
xorl %eax, %eax
cmpq -0xd0(%rbp), %rcx
movb %al, -0x111(%rbp)
jge 0x4f1ac
movq -0xe0(%rbp), %rax
cmpq 0x40(%rbp), %rax
setl %al
movb %al, -0x111(%rbp)
movb -0x111(%rbp), %al
testb $0x1, %al
jne 0x4f1bb
jmp 0x4f2b2
movq -0xc0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xc8(%rbp)
movq -0x50(%rbp), %rdi
movq -0xc8(%rbp), %rsi
movq 0x58(%rbp), %rdx
leaq -0xc0(%rbp), %rcx
callq 0x9e2e0
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq -0x58(%rbp), %r8
movq -0x60(%rbp), %r9
movq 0x10(%rbp), %r13
movl 0x18(%rbp), %r12d
movq -0x50(%rbp), %rax
movl 0x1c(%rax), %r15d
movq -0x50(%rbp), %rax
movl 0x10(%rax), %r14d
movq -0xc8(%rbp), %rbx
movq -0xc0(%rbp), %r11
movq -0xe0(%rbp), %r10
movq 0x58(%rbp), %rax
movq %rax, -0x120(%rbp)
movsd -0x68(%rbp), %xmm0
xorl %eax, %eax
movq -0x120(%rbp), %rax
movq %r13, (%rsp)
movl %r12d, 0x8(%rsp)
movl %r15d, 0x10(%rsp)
movl %r14d, 0x18(%rsp)
movq %rbx, 0x20(%rsp)
movq %r11, 0x28(%rsp)
movq %r10, 0x30(%rsp)
movq %rax, 0x38(%rsp)
movl $0x0, 0x40(%rsp)
callq 0xa7370
cmpl $0x0, %eax
je 0x4f2ab
movq -0x50(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x50(%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, -0xe0(%rbp)
jmp 0x4f2ad
jmp 0x4f2b2
jmp 0x4f180
movq -0x50(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x50(%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, -0xd8(%rbp)
movq -0x50(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x108(%rbp)
movq 0x20(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rax
cmpq -0xd8(%rbp), %rax
jle 0x4f497
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %r8
movq -0x58(%rbp), %r9
movq -0x60(%rbp), %rbx
movq 0x10(%rbp), %r11
movq -0x50(%rbp), %rax
movl 0x1c(%rax), %r10d
movq -0x50(%rbp), %rax
movl 0x10(%rax), %eax
leaq -0x90(%rbp), %rdi
movq %rbx, (%rsp)
movq %r11, 0x8(%rsp)
movl %r10d, 0x10(%rsp)
movl %eax, 0x18(%rsp)
callq 0xa79c0
movl -0x88(%rbp), %eax
subl $0x1, %eax
cltq
movq %rax, -0xe0(%rbp)
movq -0xc8(%rbp), %rax
cmpq -0xd8(%rbp), %rax
jle 0x4f495
movq -0xc8(%rbp), %rax
subq $0x1, %rax
movq %rax, -0xc0(%rbp)
movq -0x50(%rbp), %rdi
movq -0xc0(%rbp), %rsi
movq 0x58(%rbp), %rdx
leaq -0xc8(%rbp), %rcx
callq 0x9e250
movq -0xe0(%rbp), %rax
addq $0x1, %rax
movq -0xc0(%rbp), %rcx
addq $0x1, %rcx
subq -0xc8(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x100(%rbp)
cmpq $0x0, -0x100(%rbp)
jl 0x4f48e
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq -0x58(%rbp), %r8
movq -0x60(%rbp), %r9
movq 0x10(%rbp), %r13
movl 0x18(%rbp), %r12d
movq -0x50(%rbp), %rax
movl 0x1c(%rax), %r15d
movq -0x50(%rbp), %rax
movl 0x10(%rax), %r14d
movq -0xc8(%rbp), %rbx
movq -0xc0(%rbp), %r11
movq -0x100(%rbp), %r10
movq 0x58(%rbp), %rax
movsd -0x68(%rbp), %xmm0
movq %r13, (%rsp)
movl %r12d, 0x8(%rsp)
movl %r15d, 0x10(%rsp)
movl %r14d, 0x18(%rsp)
movq %rbx, 0x20(%rsp)
movq %r11, 0x28(%rsp)
movq %r10, 0x30(%rsp)
movq %rax, 0x38(%rsp)
movl $0x1, 0x40(%rsp)
callq 0xa7370
cmpl $0x0, %eax
je 0x4f48e
movq -0x50(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x50(%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, -0xe0(%rbp)
jmp 0x4f490
jmp 0x4f495
jmp 0x4f365
jmp 0x4f497
movq 0x28(%rbp), %rdx
addq $0x1, %rdx
subq 0x20(%rbp), %rdx
movq -0x50(%rbp), %rax
movl 0x28(%rax), %ecx
addq %rdx, %rcx
movl %ecx, 0x28(%rax)
movq -0x50(%rbp), %rax
movl 0x8(%rax), %eax
addl $0x1, %eax
movq -0x50(%rbp), %rcx
subl 0x4(%rcx), %eax
movl %eax, %eax
movq %rax, -0xe8(%rbp)
movq 0x28(%rbp), %rax
addq $0x1, %rax
movq -0x50(%rbp), %rcx
movl 0x4(%rcx), %ecx
subq %rcx, %rax
movq -0x50(%rbp), %rcx
movl 0x28(%rcx), %ecx
subq %rcx, %rax
movq %rax, -0xf0(%rbp)
movq -0xe8(%rbp), %rax
subq -0xf0(%rbp), %rax
movq %rax, -0xf8(%rbp)
cmpq $0x0, 0x68(%rbp)
jne 0x4f623
movq -0xe8(%rbp), %rdi
movq -0xf8(%rbp), %rsi
movsd -0x70(%rbp), %xmm0
xorl %edx, %edx
leaq -0x68(%rbp), %rcx
callq 0xa7100
cmpl $0x0, %eax
jne 0x4f623
movq -0xe8(%rbp), %rdi
movq -0xf8(%rbp), %rsi
movl 0x60(%rbp), %edx
movsd -0x70(%rbp), %xmm0
xorl %eax, %eax
movl %eax, %ecx
callq 0xa7100
cmpl $0x0, %eax
jne 0x4f623
jmp 0x4f55e
movq -0x50(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x50(%rbp), %rcx
cmpq 0x50(%rcx), %rax
jne 0x4f5d0
movq -0x50(%rbp), %rax
cmpq $0x0, 0x50(%rax)
je 0x4f58f
movq -0x50(%rbp), %rax
movq 0x50(%rax), %rax
shlq %rax
movq %rax, -0x128(%rbp)
jmp 0x4f59d
movl $0x2, %eax
movq %rax, -0x128(%rbp)
jmp 0x4f59d
movq -0x128(%rbp), %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x50(%rbp), %rax
movq 0x58(%rax), %rdi
movq -0x50(%rbp), %rax
movq 0x50(%rax), %rsi
shlq $0x5, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x58(%rax)
movq -0x50(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x50(%rbp), %rdx
movq 0x48(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x48(%rdx)
shlq $0x5, %rcx
addq %rcx, %rax
movq -0x90(%rbp), %rcx
movq %rcx, (%rax)
movq -0x88(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x80(%rbp), %rcx
movq %rcx, 0x10(%rax)
movq -0x78(%rbp), %rcx
movq %rcx, 0x18(%rax)
movl $0x0, -0x2c(%rbp)
jmp 0x4f862
movq -0x50(%rbp), %rax
movq 0x48(%rax), %rax
cmpq -0x108(%rbp), %rax
jbe 0x4f7a0
movq -0x50(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x108(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0xb8(%rbp)
movq -0x50(%rbp), %rax
movq 0x48(%rax), %rax
subq -0x108(%rbp), %rax
movq %rax, -0x108(%rbp)
movq -0x108(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0x108(%rbp), %rax
shrq %rax
movq %rax, -0x108(%rbp)
movq $0x0, -0x110(%rbp)
movq -0x110(%rbp), %rax
cmpq -0x108(%rbp), %rax
jae 0x4f79e
movq -0xb8(%rbp), %rax
movq -0x110(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movq %rcx, -0xb0(%rbp)
movq 0x8(%rax), %rcx
movq %rcx, -0xa8(%rbp)
movq 0x10(%rax), %rcx
movq %rcx, -0xa0(%rbp)
movq 0x18(%rax), %rax
movq %rax, -0x98(%rbp)
movq -0xb8(%rbp), %rcx
movq -0xe0(%rbp), %rax
subq $0x1, %rax
subq -0x110(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rcx
movq -0xb8(%rbp), %rax
movq -0x110(%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 -0xb8(%rbp), %rax
movq -0xe0(%rbp), %rcx
subq $0x1, %rcx
subq -0x110(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq -0xb0(%rbp), %rcx
movq %rcx, (%rax)
movq -0xa8(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0xa0(%rbp), %rcx
movq %rcx, 0x10(%rax)
movq -0x98(%rbp), %rcx
movq %rcx, 0x18(%rax)
movq -0x110(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x110(%rbp)
jmp 0x4f695
jmp 0x4f7a0
jmp 0x4f7a2
movq -0x50(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x50(%rbp), %rcx
cmpq 0x50(%rcx), %rax
jne 0x4f814
movq -0x50(%rbp), %rax
cmpq $0x0, 0x50(%rax)
je 0x4f7d3
movq -0x50(%rbp), %rax
movq 0x50(%rax), %rax
shlq %rax
movq %rax, -0x130(%rbp)
jmp 0x4f7e1
movl $0x2, %eax
movq %rax, -0x130(%rbp)
jmp 0x4f7e1
movq -0x130(%rbp), %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x50(%rbp), %rax
movq 0x58(%rax), %rdi
movq -0x50(%rbp), %rax
movq 0x50(%rax), %rsi
shlq $0x5, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x58(%rax)
movq -0x50(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x50(%rbp), %rdx
movq 0x48(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x48(%rdx)
shlq $0x5, %rcx
addq %rcx, %rax
movq -0x90(%rbp), %rcx
movq %rcx, (%rax)
movq -0x88(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x80(%rbp), %rcx
movq %rcx, 0x10(%rax)
movq -0x78(%rbp), %rcx
movq %rcx, 0x18(%rax)
movl $0x1, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopw (%rax,%rax)