// File: chhylp123[P]hifiasm/Correct.cpp
// Function: ul_gap_filling_adv(overlap_region_alloc*, Candidates_list*, kv_ul_ov_t*, unsigned long, ul_idx_t const*, hpc_t*, All_reads*, char*, UC_Read*, bit_extz_t*, overlap_region*, asg64_v*, asg64_v*, double, long, unsigned long, long, long, long)
void ul_gap_filling_adv(overlap_region_alloc* ol, Candidates_list *cl, kv_ul_ov_t *aln, uint64_t wl, 
const ul_idx_t *uref, hpc_t *hpc_g, All_reads *rref, char* qstr, UC_Read *tu, bit_extz_t *exz, overlap_region *aux_o,  
asg64_v* buf, asg64_v* iidx, double e_rate, int64_t ql, uint64_t rid, int64_t khit, int64_t base_chekc_k_hit,
int64_t max_lgap)
{
    int64_t k, l, ch_n, a_n = aln->n; uint64_t pqn, pk; overlap_region *z; //k_mer_hit *ch_a;
    // count_k_hits(rref, uref, qstr, tu, ol, cl, buf, khit, base_chekc_k_hit);
    count_k_hits_adv(rref, uref, qstr, tu, ol, cl, buf, &(cl->chainDP), e_rate, khit, base_chekc_k_hit);
    // prt_khit(cl, ol, NULL, 109111, "e");
    for (k = 1, l = 0, pqn = 0; k <= a_n; k++) {
        if(k == a_n || aln->a[l].qn != aln->a[k].qn) {
            z = &(ol->list[aln->a[l].qn]); assert(z->align_length == l);  
            // fprintf(stderr, "[M::%s::] oid::[%lu, %u)\n", __func__, pqn, aln->a[l].qn);
            for (pk = pqn; pk < aln->a[l].qn; pk++) ol->list[pk].w_list.n = 0;
            pqn = aln->a[l].qn+1;  
            // fprintf(stderr, "[M::%s::utg%.6dl::%c]\n", __func__, (int32_t)z->y_id+1, "+-"[z->y_pos_strand]);
            // prt_khit(cl, ol, NULL, 109111, "f");
            ch_n = gen_cns_chain(ol, z, cl, iidx, max_lgap, e_rate, 0);
            // prt_khit(cl, ol, NULL, 109111, "g");
            if(ch_n) {
                cigar_gen_by_chain_adv(z, cl, cl->length, ch_n, aln->a+l, k-l, wl, uref, hpc_g, rref, qstr, tu, exz, aux_o, e_rate, ql, rid, khit);
            }
            l = k;
        }
    }
    for (pk = pqn; pk < ol->length; pk++) ol->list[pk].w_list.n = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq 0x68(%rbp), %rax
movq 0x60(%rbp), %rax
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
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x30(%rbp)
movq %rsi, -0x38(%rbp)
movq %rdx, -0x40(%rbp)
movq %rcx, -0x48(%rbp)
movq %r8, -0x50(%rbp)
movq %r9, -0x58(%rbp)
movsd %xmm0, -0x60(%rbp)
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x80(%rbp)
movq 0x10(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq 0x18(%rbp), %rdx
movq 0x20(%rbp), %rcx
movq -0x30(%rbp), %r8
movq -0x38(%rbp), %r9
movq 0x38(%rbp), %rbx
movq -0x38(%rbp), %r11
addq $0x18, %r11
movsd -0x60(%rbp), %xmm0
movq 0x58(%rbp), %r10
movq 0x60(%rbp), %rax
movq %rbx, (%rsp)
movq %r11, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movq %rax, 0x18(%rsp)
callq 0x5bff0
movq $0x1, -0x68(%rbp)
movq $0x0, -0x70(%rbp)
movq $0x0, -0x88(%rbp)
movq -0x68(%rbp), %rax
cmpq -0x80(%rbp), %rax
jg 0x88136
movq -0x68(%rbp), %rax
cmpq -0x80(%rbp), %rax
je 0x87f41
movq -0x40(%rbp), %rax
movq (%rax), %rax
imulq $0x1c, -0x70(%rbp), %rcx
addq %rcx, %rax
movl (%rax), %eax
movq -0x40(%rbp), %rcx
movq (%rcx), %rcx
imulq $0x1c, -0x68(%rbp), %rdx
addq %rdx, %rcx
cmpl (%rcx), %eax
je 0x88123
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq -0x40(%rbp), %rcx
movq (%rcx), %rcx
imulq $0x1c, -0x70(%rbp), %rdx
addq %rdx, %rcx
movl (%rcx), %ecx
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
movl 0x28(%rax), %eax
cmpq -0x70(%rbp), %rax
jne 0x87f7c
jmp 0x87f9b
leaq 0x2fd6cd(%rip), %rdi    # 0x385650
leaq 0x2fa391(%rip), %rsi    # 0x38231b
movl $0x5686, %edx           # imm = 0x5686
leaq 0x2fd6cf(%rip), %rcx    # 0x385665
callq 0x2130
movq -0x88(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movq -0x40(%rbp), %rcx
movq (%rcx), %rcx
imulq $0x1c, -0x70(%rbp), %rdx
addq %rdx, %rcx
movl (%rcx), %ecx
cmpq %rcx, %rax
jae 0x87ff7
movq -0x30(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x90(%rbp), %rcx
addq %rcx, %rax
movq $0x0, 0x48(%rax)
movq -0x90(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x90(%rbp)
jmp 0x87fa9
movq -0x40(%rbp), %rax
movq (%rax), %rax
imulq $0x1c, -0x70(%rbp), %rcx
addq %rcx, %rax
movl (%rax), %eax
addl $0x1, %eax
movl %eax, %eax
movq %rax, -0x88(%rbp)
movq -0x30(%rbp), %rdi
movq -0x98(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq 0x40(%rbp), %rcx
movq 0x68(%rbp), %r8
movsd -0x60(%rbp), %xmm0
xorl %eax, %eax
movl %eax, %r9d
callq 0x5a8c0
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
je 0x8811b
movq -0x98(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdx
movq -0x78(%rbp), %rcx
movq -0x40(%rbp), %rax
movq (%rax), %r8
imulq $0x1c, -0x70(%rbp), %rax
addq %rax, %r8
movq -0x68(%rbp), %r9
subq -0x70(%rbp), %r9
movq -0x48(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq 0x10(%rbp), %r13
movq 0x18(%rbp), %r12
movq 0x20(%rbp), %r15
movq 0x28(%rbp), %r14
movq 0x30(%rbp), %rbx
movsd -0x60(%rbp), %xmm0
movq 0x48(%rbp), %r11
movq 0x50(%rbp), %r10
movq 0x58(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0xb8(%rbp), %rax
movq %rax, (%rsp)
movq -0xb0(%rbp), %rax
movq %rax, 0x8(%rsp)
movq -0xa8(%rbp), %rax
movq %rax, 0x10(%rsp)
movq -0xa0(%rbp), %rax
movq %r13, 0x18(%rsp)
movq %r12, 0x20(%rsp)
movq %r15, 0x28(%rsp)
movq %r14, 0x30(%rsp)
movq %rbx, 0x38(%rsp)
movq %r11, 0x40(%rsp)
movq %r10, 0x48(%rsp)
movq %rax, 0x50(%rsp)
callq 0x67780
movq -0x68(%rbp), %rax
movq %rax, -0x70(%rbp)
jmp 0x88125
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
jmp 0x87f01
movq -0x88(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movq -0x30(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jae 0x88186
movq -0x30(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x90(%rbp), %rcx
addq %rcx, %rax
movq $0x0, 0x48(%rax)
movq -0x90(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x90(%rbp)
jmp 0x88144
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax,%rax)