// File: /workspace/github_cpp_makefile_star2_O3/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
movsd %xmm0, 0x78(%rsp)
movq %rcx, 0x8(%rsp)
movq %rdx, 0x48(%rsp)
movq %rsi, 0x38(%rsp)
movq %rdi, %r13
movq $0x0, 0x48(%rdi)
movl 0x8(%rdi), %esi
movl 0x4(%rdi), %ebp
leal 0x1(%rsi), %edi
movq %rbp, %rax
xorl %edx, %edx
idivq %r8
movq %rdx, %rcx
movq %rdx, %rax
subq %rbp, %rax
addq %rdi, %rax
cqto
idivq %r8
xorl %edi, %edi
testq %rdx, %rdx
setg %dil
movq %rbp, %rdx
subq %rcx, %rdx
movq %r8, 0x30(%rsp)
leaq (%r8,%rdx), %r15
decq %r15
cmpq %rsi, %r15
cmovgeq %rsi, %r15
addq %rax, %rdi
movq %rdi, 0x70(%rsp)
jle 0x49280
cmpq %rbp, %rdx
cmovgq %rdx, %rbp
leaq 0x38(%r13), %r14
xorl %eax, %eax
movq %r14, 0x40(%rsp)
movq %rax, 0x20(%rsp)
leaq 0x1(%r15), %rax
movq %rax, 0x80(%rsp)
movq %rax, %rdx
subq %rbp, %rdx
xorps %xmm0, %xmm0
cvtsi2sd %rdx, %xmm0
mulsd 0x78(%rsp), %xmm0
cvttsd2si %xmm0, %rax
cmpq $0x1f, %rax
movl $0x1f, %ecx
cmovlq %rax, %rcx
movq %rdx, 0x10(%rsp)
cmpq $0x4, %rdx
movq %rcx, %rsi
movl $0x1, %edx
cmovgeq %rdx, %rsi
testq %rax, %rax
cmovneq %rcx, %rsi
movq %rsi, (%rsp)
movl 0x4(%r13), %eax
movq %rax, 0x18(%rsp)
movl 0x14(%r13), %r12d
movl 0x40(%r13), %esi
decl %esi
movq %r14, %rdi
callq 0x3d110
cltq
movl 0x40(%r13), %ebx
cmpq %rax, %rbp
je 0x490a8
testl %ebx, %ebx
je 0x49297
xorl %ebx, %ebx
movq %r14, %rdi
movl %ebx, %esi
callq 0x3d110
cltq
cmpq %rax, %rbp
jl 0x49092
incq %rbx
movl 0x40(%r13), %eax
cmpq %rax, %rbx
jb 0x49073
jmp 0x4909f
testq %rbx, %rbx
je 0x49297
movl 0x40(%r13), %eax
cmpq %rax, %rbx
je 0x49297
movq %rbp, %rax
subq 0x18(%rsp), %rax
addq %rax, %r12
decl %ebx
movq %r14, %rdi
movl %ebx, %esi
callq 0x3d11b
movslq %eax, %rbx
addq %r12, %rbx
movq 0x38(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movl 0x10(%r13), %ecx
leaq (%rcx,%rcx,4), %r12
movl (%rax,%r12,8), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmpq %rax, %rbx
movq 0x20(%rsp), %r8
jae 0x49257
movq (%rsp), %rdx
leaq (%rdx,%rdx), %rcx
movq 0x10(%rsp), %rsi
leaq (%rsi,%rdx,2), %rdx
subq %rbx, %rcx
addq %rax, %rcx
addq $0x1f, %rcx
cmpq %rdx, %rcx
jl 0x49257
subq (%rsp), %rbx
subq %rbx, %rax
cmpq %rdx, %rax
cmovgeq %rdx, %rax
movq %rdx, %rcx
subq %rax, %rcx
movq %rcx, 0x18(%rsp)
movq %rbx, %rcx
negq %rcx
movq %rbx, %r14
sarq $0x3f, %r14
andq %rcx, %r14
testq %rbx, %rbx
movl $0x0, %ecx
cmovgq %rbx, %rcx
movq %rcx, 0x60(%rsp)
movl $0x0, %ecx
cmovnsq %rcx, %rbx
addq %rax, %rbx
movzbl 0x1c(%r13), %eax
movl %eax, 0x28(%rsp)
movq 0x8(%rsp), %rdi
movq %rdx, 0x68(%rsp)
movl $0x4e, %esi
movq %r14, %rdx
callq 0x20e0
movq %r14, 0x50(%rsp)
movq 0x8(%rsp), %rax
leaq (%rax,%r14), %rsi
movq %rsi, 0x58(%rsp)
movq 0x40(%rsp), %r14
movq 0x38(%rsp), %rax
movq (%rax), %rax
shlq $0x3, %r12
addq 0x10(%rax), %r12
subq $0x8, %rsp
xorl %edi, %edi
movq %r12, %rdx
movq 0x68(%rsp), %r12
movl 0x30(%rsp), %ecx
movq %r12, %r8
movq %rbx, %r9
pushq $0x0
callq 0x36049
addq $0x10, %rsp
addq 0x58(%rsp), %rbx
movq %rbx, %rdi
movq 0x18(%rsp), %rbx
movl $0x4e, %esi
movq %rbx, %rdx
callq 0x20e0
movq 0x48(%rsp), %rax
leaq (%rax,%rbp), %rdx
movzwl (%rsp), %r8d
movq 0x8(%rsp), %rdi
movq 0x68(%rsp), %rsi
movq 0x10(%rsp), %rcx
leaq 0x2c(%rsp), %r9
callq 0x84e99
movq 0x20(%rsp), %r8
movl 0x2c(%rsp), %r9d
cmpl $-0x1, %r9d
je 0x49257
movq 0x10(%rsp), %rcx
addl %ecx, 0x28(%r13)
addl %r12d, %eax
subq $0x8, %rsp
movq %r13, %rdi
movq %rbp, %rsi
movq %r15, %rdx
movl %r12d, %ecx
movl %eax, %r8d
pushq 0xc8(%rsp)
pushq 0x40(%rsp)
pushq 0x18(%rsp)
pushq %rbx
pushq 0x78(%rsp)
callq 0x3efc4
movq 0x50(%rsp), %r8
addq $0x30, %rsp
addq 0x30(%rsp), %r15
movl 0x8(%r13), %esi
cmpq %rsi, %r15
cmovgeq %rsi, %r15
incq %r8
cmpq 0x70(%rsp), %r8
movq 0x80(%rsp), %rbp
movq %r8, %rax
jne 0x48fec
cmpq %rsi, %r15
jne 0x4929c
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x5740
leaq 0x1e8495(%rip), %rdi    # 0x231738
leaq 0x1e84a9(%rip), %rsi    # 0x231753
leaq 0x1e84ae(%rip), %rcx    # 0x23175f
movl $0x349, %edx            # imm = 0x349
callq 0x2110