// File: /workspace/github_cpp_makefile_star2_O1/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, 0x70(%rsp)
movq %r8, (%rsp)
movq %rcx, 0x58(%rsp)
movq %rdx, %r8
movq %rsi, 0x38(%rsp)
movq $0x0, 0x48(%rdi)
movb $0x0, 0x2c(%rdi)
movl 0x8(%rdi), %r15d
movl 0x4(%rdi), %r10d
leal 0x1(%r15), %esi
movq %r10, %rax
xorl %edx, %edx
idivq %r9
movq %rdx, %rcx
movq %rdx, %rax
subq %r10, %rax
addq %rsi, %rax
cqto
idivq %r9
xorl %esi, %esi
testq %rdx, %rdx
setg %sil
movq %r10, %rdx
subq %rcx, %rdx
movq %r9, 0x48(%rsp)
leaq (%r9,%rdx), %rcx
decq %rcx
cmpq %r15, %rcx
cmovlq %rcx, %r15
addq %rax, %rsi
jle 0x5f17f
movq %r8, 0x50(%rsp)
cmpq %r10, %rdx
cmovgq %rdx, %r10
leaq 0x38(%rdi), %rax
movq %rax, 0x68(%rsp)
movq %rdi, 0x28(%rsp)
movq %rsi, 0x78(%rsp)
leaq 0x1(%r15), %r12
movq %r12, 0x80(%rsp)
subq %r10, %r12
xorps %xmm0, %xmm0
cvtsi2sd %r12, %xmm0
mulsd 0x70(%rsp), %xmm0
cvttsd2si %xmm0, %rax
movq %rax, %rcx
cmpq $0x1f, %rax
jl 0x5ee7b
movl $0x1f, %ecx
cmpq $0x4, %r12
movq %rcx, %r13
movl $0x1, %edx
cmovgeq %rdx, %r13
testq %rax, %rax
cmovneq %rcx, %r13
movl 0x4(%rdi), %r14d
movl 0x14(%rdi), %ebx
movq %rdi, %rbp
movq %r10, 0x18(%rsp)
movq %r10, %rdi
movq 0x68(%rsp), %rsi
callq 0x48df6
movq 0x50(%rsp), %rcx
testq %rcx, %rcx
je 0x5eed3
movq (%rcx), %rcx
movq 0x10(%rcx), %rcx
movl 0x10(%rbp), %edx
leaq (%rdx,%rdx,4), %rdx
movl (%rcx,%rdx,8), %ecx
shrl %ecx
andl $0x3fffffff, %ecx       # imm = 0x3FFFFFFF
jmp 0x5eef0
movq 0x38(%rsp), %rcx
movq (%rcx), %rcx
movq 0x10(%rcx), %rcx
movl 0x10(%rbp), %edx
leaq (%rdx,%rdx,4), %rdx
movl (%rcx,%rdx,8), %ecx
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andl %edx, %ecx
movq %rbp, %rdi
movq 0x18(%rsp), %rsi
movq %rsi, %rdx
subq %r14, %rdx
addq %rax, %rbx
addq %rdx, %rbx
leaq (%r12,%r13,2), %r10
movl %ecx, %ecx
movb $0x1, %al
movq $-0x1, %rdx
cmpq %rcx, %rbx
jae 0x5ef66
leaq (,%r13,2), %r8
subq %rbx, %r8
addq %rcx, %r8
addq $0x1f, %r8
movq $-0x1, %r9
movq $-0x1, %r11
movq $-0x1, %r14
cmpq %r10, %r8
jl 0x5ef8b
subq %r13, %rbx
subq %rbx, %rcx
cmpq %r10, %rcx
movq %rcx, %r14
cmovgeq %r10, %r14
movq %r10, %r9
subq %r14, %r9
testq %rbx, %rbx
js 0x5ef7d
xorl %edx, %edx
movq %rbx, %r11
jmp 0x5ef89
movq $-0x1, %r9
movq $-0x1, %r11
movq $-0x1, %r14
jmp 0x5ef8b
addq %rbx, %r14
negq %rbx
xorl %r11d, %r11d
movq %rbx, %rdx
xorl %eax, %eax
testb %al, %al
jne 0x5f15a
movq %r14, 0x40(%rsp)
movq %r11, 0x8(%rsp)
movq %r9, 0x10(%rsp)
movb 0x1c(%rdi), %r14b
movl 0x10(%rdi), %ebp
movq 0x50(%rsp), %rax
testq %rax, %rax
movq %rdx, 0x60(%rsp)
je 0x5efe6
movq (%rax), %rax
movq 0x10(%rax), %rax
leaq (,%rbp,4), %rcx
addq %rbp, %rcx
testb %r14b, %r14b
je 0x5f06e
leaq (%rax,%rcx,8), %rdi
movl (%rdi), %ebx
shrl %ebx
andl $0x3fffffff, %ebx       # imm = 0x3FFFFFFF
jmp 0x5f070
movq (%rsp), %rdi
movl $0x4e, %esi
movq %rdx, %rbx
movq %r10, 0x20(%rsp)
callq 0x20e0
movq (%rsp), %rax
addq %rax, %rbx
movq 0x38(%rsp), %rax
movq (%rax), %rax
leaq (,%rbp,4), %rdx
addq %rbp, %rdx
shlq $0x3, %rdx
addq 0x10(%rax), %rdx
subq $0x8, %rsp
movzbl %r14b, %ecx
xorl %edi, %edi
movq %rbx, %rsi
movq 0x10(%rsp), %rbp
movq %rbp, %r8
movq 0x48(%rsp), %r14
movq %r14, %r9
pushq $0x0
callq 0x36b0d
addq $0x10, %rsp
addq %r14, %rbx
movq %rbx, %rdi
movl $0x4e, %esi
movq 0x10(%rsp), %r14
movq %r14, %rdx
callq 0x20e0
movq 0x20(%rsp), %r10
movq 0x18(%rsp), %rsi
movq (%rsp), %rbx
jmp 0x5f0ea
xorl %ebx, %ebx
movq 0x10(%rsp), %r14
movq %r14, %rdi
addq 0x20(%rax,%rcx,8), %rbx
orq %rdx, %rdi
je 0x5f0e2
movq (%rsp), %rbp
movq %rbp, %rdi
movl $0x4e, %esi
movq %rdx, %r14
movq %r10, 0x20(%rsp)
callq 0x20e0
addq %rbp, %r14
addq 0x8(%rsp), %rbx
movq %r14, %rdi
movq %rbx, %rsi
movq 0x40(%rsp), %rbx
movq %rbx, %rdx
callq 0x2160
addq %rbx, %r14
movq %r14, %rdi
movq 0x10(%rsp), %r14
movl $0x4e, %esi
movq %r14, %rdx
callq 0x20e0
movq 0x20(%rsp), %r10
movq 0x18(%rsp), %rsi
movq %rbp, %rbx
movq 0x8(%rsp), %rbp
jmp 0x5f0ea
movq 0x8(%rsp), %rbp
addq %rbp, %rbx
movq 0x58(%rsp), %rax
leaq (%rax,%rsi), %rdx
movzwl %r13w, %r8d
movq %rbx, %rdi
movl %r10d, %esi
movl %r12d, %ecx
leaq 0x34(%rsp), %r9
callq 0x8578f
movq 0x18(%rsp), %rsi
movl 0x34(%rsp), %r9d
cmpl $-0x1, %r9d
movq 0x28(%rsp), %rdi
movq 0x60(%rsp), %r10
je 0x5f15a
addl %r12d, 0x28(%rdi)
addl %ebp, %eax
subq $0x8, %rsp
movq 0x30(%rsp), %rdi
movq %r15, %rdx
movl %ebp, %ecx
movl %eax, %r8d
pushq 0xc8(%rsp)
pushq 0x58(%rsp)
pushq %r13
pushq %r14
pushq %r10
callq 0x3fb41
movq 0x58(%rsp), %rdi
addq $0x30, %rsp
addq 0x48(%rsp), %r15
movl 0x8(%rdi), %eax
cmpq %rax, %r15
cmovgeq %rax, %r15
movq 0x78(%rsp), %rsi
decq %rsi
movq 0x80(%rsp), %r10
jne 0x5ee46
movl 0x8(%rdi), %eax
cmpq %rax, %r15
jne 0x5f199
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1c6488(%rip), %rdi    # 0x225628
leaq 0x1c649c(%rip), %rsi    # 0x225643
leaq 0x1c7322(%rip), %rcx    # 0x2264d0
movl $0x362f, %edx           # imm = 0x362F
callq 0x2110