// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/Correct.cpp
// Function: align_ul_ed(overlap_region*, ul_idx_t const*, hpc_t*, char*, char*, double, long, void*)
void align_ul_ed(overlap_region *z, const ul_idx_t *uref, hpc_t *hpc_g, char* qstr, char *tstr, double e_rate, int64_t w_l, void *km)
{
    int64_t q_s, q_e, nw, k, q_l, t_tot_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; z->is_match = 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);
    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); t_tot_l = hpc_g?hpc_len(*hpc_g, z->y_id):uref->ug->u.a[z->y_id].len;
        if(init_waln(thre, t_s, t_tot_l, aln_l, &aux_beg, &aux_end, &t_s, &t_pri_l)) {
            q_string = qstr+q_s; 
            t_string = return_str_seq(tstr, t_s, t_pri_l, z->y_pos_strand, hpc_g, uref, z->y_id, aux_beg, aux_end);

            t_end = Reserve_Banded_BPM(t_string, aln_l, q_string, q_l, thre, &error);
            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;
    }

    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 %r8, (%rsp)
movq %rcx, 0x60(%rsp)
movq %rdx, %rbx
movq %rsi, 0x48(%rsp)
movq %rdi, %rbp
movq $0x0, 0x48(%rdi)
movb $0x0, 0x2c(%rdi)
movl 0x8(%rdi), %esi
movl 0x4(%rdi), %r15d
leal 0x1(%rsi), %edi
movq %r15, %rax
xorl %edx, %edx
idivq %r9
movq %rdx, %rcx
movq %rdx, %rax
subq %r15, %rax
addq %rdi, %rax
cqto
idivq %r9
xorl %edi, %edi
testq %rdx, %rdx
setg %dil
movq %r15, %rdx
subq %rcx, %rdx
movq %r9, 0x50(%rsp)
leaq (%r9,%rdx), %r13
decq %r13
cmpq %rsi, %r13
cmovgeq %rsi, %r13
addq %rax, %rdi
movq %rdi, 0x70(%rsp)
jle 0x5e9ae
cmpq %r15, %rdx
cmovgq %rdx, %r15
leaq 0x38(%rbp), %rax
movq %rax, 0x30(%rsp)
xorl %r14d, %r14d
movq %rbx, 0x68(%rsp)
movq %r14, 0x58(%rsp)
leaq 0x1(%r13), %rax
movq %rax, 0x80(%rsp)
movq %rax, %rdx
subq %r15, %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, 0x28(%rsp)
cmpq $0x4, %rdx
movq %rcx, %rsi
movl $0x1, %edx
cmovgeq %rdx, %rsi
testq %rax, %rax
cmovneq %rcx, %rsi
movq %rsi, 0x8(%rsp)
movl 0x4(%rbp), %r12d
movl 0x14(%rbp), %r14d
movl 0x40(%rbp), %esi
decl %esi
movq 0x30(%rsp), %rdi
callq 0x3d110
cltq
movl 0x40(%rbp), %ebx
cmpq %rax, %r15
je 0x5e752
testl %ebx, %ebx
je 0x5e9c5
xorl %ebx, %ebx
movq 0x30(%rsp), %rdi
movl %ebx, %esi
callq 0x3d110
cltq
cmpq %rax, %r15
jl 0x5e73d
incq %rbx
movl 0x40(%rbp), %eax
cmpq %rax, %rbx
jb 0x5e71d
jmp 0x5e749
testq %rbx, %rbx
je 0x5e9c5
movl 0x40(%rbp), %eax
cmpq %rax, %rbx
je 0x5e9c5
decl %ebx
movq 0x30(%rsp), %rdi
movl %ebx, %esi
callq 0x3d11b
movl 0x10(%rbp), %ecx
leaq (%rcx,%rcx,4), %r10
movq 0x68(%rsp), %rbx
testq %rbx, %rbx
je 0x5e786
movq (%rbx), %rcx
movq 0x10(%rcx), %rcx
movl (%rcx,%r10,8), %ecx
shrl %ecx
andl $0x3fffffff, %ecx       # imm = 0x3FFFFFFF
jmp 0x5e79d
movq 0x48(%rsp), %rcx
movq (%rcx), %rcx
movq 0x10(%rcx), %rcx
movl (%rcx,%r10,8), %ecx
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andl %edx, %ecx
movq %r15, %rdx
subq %r12, %rdx
addq %rdx, %r14
movslq %eax, %r12
addq %r14, %r12
movl %ecx, %eax
cmpq %rax, %r12
movq 0x58(%rsp), %r14
jae 0x5e989
movq 0x8(%rsp), %rdx
leaq (%rdx,%rdx), %rcx
movq 0x28(%rsp), %rsi
leaq (%rsi,%rdx,2), %rsi
subq %r12, %rcx
addq %rax, %rcx
addq $0x1f, %rcx
cmpq %rsi, %rcx
jl 0x5e989
subq 0x8(%rsp), %r12
subq %r12, %rax
cmpq %rsi, %rax
cmovgeq %rsi, %rax
movq %rsi, %r8
subq %rax, %r8
movq %r12, %rcx
negq %rcx
movq %r12, %rdx
sarq $0x3f, %rdx
andq %rcx, %rdx
testq %r12, %r12
movl $0x0, %r9d
cmovgq %r12, %r9
movl $0x0, %ecx
cmovnsq %rcx, %r12
addq %rax, %r12
movb 0x1c(%rbp), %r14b
testq %rbx, %rbx
movq %rdx, 0x40(%rsp)
movq %r9, 0x20(%rsp)
je 0x5e84e
movq (%rbx), %rax
movq 0x10(%rax), %rax
testb %r14b, %r14b
je 0x5e8ae
leaq (%rax,%r10,8), %rcx
movl (%rcx), %ebx
shrl %ebx
andl $0x3fffffff, %ebx       # imm = 0x3FFFFFFF
jmp 0x5e8b0
movq %r10, %rbx
movq (%rsp), %rdi
movq %rsi, 0x18(%rsp)
movl $0x4e, %esi
movq %r8, 0x10(%rsp)
callq 0x20e0
movq (%rsp), %rax
movq 0x40(%rsp), %rcx
leaq (%rax,%rcx), %rdx
movq 0x48(%rsp), %rax
movq (%rax), %rax
shlq $0x3, %rbx
addq 0x10(%rax), %rbx
subq $0x8, %rsp
movzbl %r14b, %ecx
xorl %edi, %edi
movq %rdx, %r14
movq %rdx, %rsi
movq %rbx, %rdx
movq 0x28(%rsp), %r8
movq %r12, %r9
pushq $0x0
callq 0x36049
addq $0x10, %rsp
jmp 0x5e8f2
xorl %ebx, %ebx
movq %r8, %rcx
addq 0x20(%rax,%r10,8), %rbx
orq %rdx, %rcx
je 0x5e915
movq (%rsp), %rdi
movq %rsi, 0x18(%rsp)
movl $0x4e, %esi
movq %rdx, %r14
movq %r8, 0x10(%rsp)
callq 0x20e0
movq (%rsp), %rax
addq %rax, %r14
addq 0x20(%rsp), %rbx
movq %r14, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x2160
addq %r12, %r14
movq %r14, %rdi
movl $0x4e, %esi
movq 0x10(%rsp), %rdx
movq %rdx, %r12
callq 0x20e0
movq 0x18(%rsp), %rsi
movq (%rsp), %rbx
jmp 0x5e91b
movq %r8, %r12
addq %r9, %rbx
movq 0x60(%rsp), %rax
leaq (%rax,%r15), %rdx
movzwl 0x8(%rsp), %r8d
movq %rbx, %rdi
movq 0x28(%rsp), %rcx
leaq 0x3c(%rsp), %r9
callq 0x84e99
movl 0x3c(%rsp), %r9d
cmpl $-0x1, %r9d
movq 0x58(%rsp), %r14
je 0x5e989
movq 0x28(%rsp), %rcx
addl %ecx, 0x28(%rbp)
movq 0x20(%rsp), %rcx
addl %ecx, %eax
subq $0x8, %rsp
movq %rbp, %rdi
movq %r15, %rsi
movq %r13, %rdx
movl %eax, %r8d
pushq 0xc8(%rsp)
pushq 0x60(%rsp)
pushq 0x20(%rsp)
pushq %r12
pushq 0x68(%rsp)
callq 0x3efc4
addq $0x30, %rsp
addq 0x50(%rsp), %r13
movl 0x8(%rbp), %esi
cmpq %rsi, %r13
cmovgeq %rsi, %r13
incq %r14
cmpq 0x70(%rsp), %r14
movq 0x80(%rsp), %r15
jne 0x5e69a
cmpq %rsi, %r13
jne 0x5e9ca
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x5ee3
leaq 0x1d2d67(%rip), %rdi    # 0x231738
leaq 0x1d2d7b(%rip), %rsi    # 0x231753
leaq 0x1d3c01(%rip), %rcx    # 0x2325e0
movl $0x362f, %edx           # imm = 0x362F
callq 0x2110