// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/Correct.cpp
// Function: verify_ul_window_s(overlap_region*, ul_idx_t const*, char*, char*, double, long, long, void*)
void verify_ul_window_s(overlap_region *z, const ul_idx_t *uref, char* qstr, char *tstr,
double e_rate, int64_t w_l, int64_t e_max, void *km)
{
    int64_t q_s, q_e, nw, k, q_l;
    int64_t aux_beg, aux_end, t_s, thre, aln_l, t_pri_l, t_end;
    char *q_string, *t_string; unsigned int error;
    z->w_list.n = 0; nw = get_num_wins(z->x_pos_s, z->x_pos_e+1, w_l);
    get_win_se_by_normalize_xs(z, (z->x_pos_s/w_l)*w_l, w_l, &q_s, &q_e);
    // q_s = z->x_pos_s; get_win_id_by_s(z, q_s, w_l, &q_e); 
    for (k = 0; k < nw; k++) {
        aux_beg = aux_end = 0; q_l = 1 + q_e - q_s;
        thre = q_l*e_rate; thre = Adjust_Threshold(thre, q_l);
        if(thre > THRESHOLD_MAX_SIZE) thre = THRESHOLD_MAX_SIZE;
        ///offset of y
        t_s = (q_s - z->x_pos_s) + z->y_pos_s;
        t_s += y_start_offset(q_s, &(z->f_cigar));

        aln_l = q_l + (thre<<1);
        // if(z->y_id == 115) {
        //     fprintf(stderr, "+[M::] q_s::%ld, t_s::%ld, t_pri_l::%ld, aux_beg::%ld, aux_end::%ld, aln_l::%ld, t_end::%ld, error::%u\n", 
        //     q_s, t_s, t_pri_l, aux_beg, aux_end, aln_l, t_end, error);
        // }
        if(init_waln(thre, t_s, uref->ug->u.a[z->y_id].len, aln_l, &aux_beg, &aux_end, &t_s, &t_pri_l)) {
            gen_str_seq(tstr, t_s, t_pri_l, z->y_pos_strand, uref, z->y_id, aux_beg, aux_end);
            q_string = qstr+q_s; t_string = tstr;
            t_end = Reserve_Banded_BPM(t_string, aln_l, q_string, q_l, thre, &error);
            // if(z->y_id == 115) {
            //     fprintf(stderr, "-[M::] q_s::%ld, t_s::%ld, t_pri_l::%ld, aux_beg::%ld, aux_end::%ld, aln_l::%ld, t_end::%ld, error::%u, thre::%ld\n", 
            //     q_s, t_s, t_pri_l, aux_beg, aux_end, aln_l, t_end, error, thre);
            // }
            if (error!=((unsigned int)-1)) {
                z->align_length += q_l;
                ///t_s do not have aux_beg, while t_s + t_end (aka, te) has 
                append_window_list(z, q_s, q_e, t_s, t_s + t_end, error, aux_beg, aux_end, thre, w_l, km);
            }
        }
        q_s = q_e + 1; q_e = q_s + w_l - 1; 
        if(q_e >= (int64_t)z->x_pos_e) q_e = z->x_pos_e;
    }

    // if(q_e != (int64_t)z->x_pos_e) {
    //     fprintf(stderr, "[M::%s] q_e::%ld, z->x_pos_s::%u, z->x_pos_e::%u, w_l::%ld, nw::%ld\n", __func__, 
    //     q_e, z->x_pos_s, z->x_pos_e, w_l, nw);
    // }
    assert(q_e == (int64_t)z->x_pos_e);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %r8, %r9
movsd %xmm0, 0x70(%rsp)
movq %rcx, 0x50(%rsp)
movq %rdx, 0x48(%rsp)
movq %rsi, 0x28(%rsp)
movq %rdi, %r14
andq $0x0, 0x48(%rdi)
movl 0x8(%rdi), %edi
movl 0x4(%r14), %esi
incl %edi
xorl %ebx, %ebx
movq %rsi, %rax
xorl %edx, %edx
idivq %r8
movq %rdx, %rcx
movq %rdx, %rax
subq %rsi, %rax
addq %rdi, %rax
cqto
idivq %r8
xorl %r15d, %r15d
testq %rdx, %rdx
setg %r15b
addq %rax, %r15
subq %rcx, %rsi
leaq 0x10(%rsp), %rcx
leaq 0x8(%rsp), %r8
movq %r14, %rdi
movq %r9, 0x20(%rsp)
movq %r9, %rdx
callq 0x51f30
testq %r15, %r15
cmovleq %rbx, %r15
movq %r14, %rbx
leaq 0x38(%r14), %rax
movq %rax, 0x68(%rsp)
subq $0x1, %r15
jb 0x1cb58
movq %r15, 0x78(%rsp)
andq $0x0, 0x38(%rsp)
andq $0x0, 0x40(%rsp)
movq 0x8(%rsp), %r13
movq 0x10(%rsp), %rdi
subq %rdi, %r13
leaq 0x1(%r13), %r14
cvtsi2sd %r14, %xmm0
mulsd 0x70(%rsp), %xmm0
cvttsd2si %xmm0, %rax
movq %rax, %rcx
cmpq $0x1f, %rax
jl 0x1c9e8
pushq $0x1f
popq %rcx
cmpq $0x4, %r14
movq %rcx, %r15
pushq $0x1
popq %rdx
cmovgeq %rdx, %r15
testq %rax, %rax
cmovneq %rcx, %r15
movl 0x4(%rbx), %eax
movq %rbx, %r12
movl 0x14(%rbx), %ebx
movq %rdi, %rcx
subq %rax, %rcx
addq %rcx, %rbx
movq 0x68(%rsp), %rsi
callq 0x1bebf
addq %rax, %rbx
movq %rbx, 0x30(%rsp)
leaq 0x1(,%r15,2), %rbp
addq %r13, %rbp
movq 0x28(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movl 0x10(%r12), %r13d
imulq $0x28, %r13, %rcx
movl (%rax,%rcx), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movq %r15, %rdi
movq %rbx, %rsi
movq %r12, %rbx
movq %rbp, %rcx
leaq 0x40(%rsp), %r8
leaq 0x38(%rsp), %r9
leaq 0x80(%rsp), %rax
pushq %rax
leaq 0x38(%rsp), %rax
pushq %rax
callq 0x1c7e7
popq %rcx
popq %rdx
testl %eax, %eax
je 0x1cb2c
movq 0x30(%rsp), %rsi
movq 0x80(%rsp), %rdx
movzbl 0x1c(%rbx), %ecx
movq 0x40(%rsp), %rax
movq 0x38(%rsp), %r10
movq 0x50(%rsp), %rbx
movq %rbx, %rdi
movq %rsi, 0x58(%rsp)
movq 0x28(%rsp), %r8
movq %r13, %r9
movq %rax, %r13
movq %r10, 0x60(%rsp)
pushq %r10
pushq %rax
callq 0x1c88a
popq %rax
popq %rcx
movq 0x10(%rsp), %rdx
addq 0x48(%rsp), %rdx
movzwl %r15w, %r8d
movq %rbx, %rdi
movq %r12, %rbx
movl %ebp, %esi
movl %r14d, %ecx
leaq 0x1c(%rsp), %r9
callq 0x516e4
movl 0x1c(%rsp), %r9d
cmpl $-0x1, %r9d
je 0x1cb2c
addl %r14d, 0x28(%rbx)
movq 0x10(%rsp), %rsi
movq 0x8(%rsp), %rdx
movq 0x58(%rsp), %rcx
addl %ecx, %eax
subq $0x8, %rsp
movq %rbx, %rdi
movl %eax, %r8d
pushq 0xc8(%rsp)
pushq 0x30(%rsp)
pushq %r15
pushq 0x80(%rsp)
pushq %r13
callq 0x13b3b
addq $0x30, %rsp
movq 0x8(%rsp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x10(%rsp)
addq 0x20(%rsp), %rax
movl 0x8(%rbx), %ecx
cmpq %rcx, %rax
cmovgeq %rcx, %rax
movq %rax, 0x8(%rsp)
movq 0x78(%rsp), %r15
jmp 0x1c9a0
movl 0x8(%rbx), %eax
cmpq %rax, 0x8(%rsp)
jne 0x1cb74
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1c6b0d(%rip), %rdi    # 0x1e3688
leaq 0x1c6b21(%rip), %rsi    # 0x1e36a3
leaq 0x1c6b26(%rip), %rcx    # 0x1e36af
movl $0x349, %edx            # imm = 0x349
callq 0x2110