// File: chhylp123[P]hifiasm/Correct.cpp
// Function: ul_gap_filling_local(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_local(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, a_n = aln->n; uint64_t pqn, pk; overlap_region *z; //k_mer_hit *ch_a;
    count_k_hits_filter(ol, cl, buf, &(cl->chainDP));
    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);  
            for (pk = pqn; pk < aln->a[l].qn; pk++) ol->list[pk].w_list.n = 0;
            pqn = aln->a[l].qn+1;  
            cigar_gen_by_chain_adv_local(z, cl, aln->a+l, k-l, wl, uref, hpc_g, rref, qstr, tu, exz, aux_o, e_rate, ql, rid, khit);
            // ch_n = gen_cns_chain(z, cl, iidx, max_lgap, e_rate, 0);
            // 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 $0xc8, %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, -0x78(%rbp)
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq 0x38(%rbp), %rdx
movq -0x38(%rbp), %rcx
addq $0x18, %rcx
callq 0x5bb10
movq $0x1, -0x68(%rbp)
movq $0x0, -0x70(%rbp)
movq $0x0, -0x80(%rbp)
movq -0x68(%rbp), %rax
cmpq -0x78(%rbp), %rax
jg 0x88406
movq -0x68(%rbp), %rax
cmpq -0x78(%rbp), %rax
je 0x8827e
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 0x883f3
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, -0x90(%rbp)
movq -0x90(%rbp), %rax
movl 0x28(%rax), %eax
cmpq -0x70(%rbp), %rax
jne 0x882b9
jmp 0x882d8
leaq 0x2fd390(%rip), %rdi    # 0x385650
leaq 0x2fa054(%rip), %rsi    # 0x38231b
movl $0x56a0, %edx           # imm = 0x56A0
leaq 0x2fd494(%rip), %rcx    # 0x385767
callq 0x2130
movq -0x80(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq -0x40(%rbp), %rcx
movq (%rcx), %rcx
imulq $0x1c, -0x70(%rbp), %rdx
addq %rdx, %rcx
movl (%rcx), %ecx
cmpq %rcx, %rax
jae 0x88331
movq -0x30(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x88(%rbp), %rcx
addq %rcx, %rax
movq $0x0, 0x48(%rax)
movq -0x88(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x88(%rbp)
jmp 0x882e3
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, -0x80(%rbp)
movq -0x90(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rax
movq (%rax), %rdx
imulq $0x1c, -0x70(%rbp), %rax
addq %rax, %rdx
movq -0x68(%rbp), %rcx
subq -0x70(%rbp), %rcx
movq -0x48(%rbp), %r8
movq -0x50(%rbp), %r9
movq -0x58(%rbp), %rax
movq %rax, -0xa0(%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, -0x98(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, (%rsp)
movq -0x98(%rbp), %rax
movq %r13, 0x8(%rsp)
movq %r12, 0x10(%rsp)
movq %r15, 0x18(%rsp)
movq %r14, 0x20(%rsp)
movq %rbx, 0x28(%rsp)
movq %r11, 0x30(%rsp)
movq %r10, 0x38(%rsp)
movq %rax, 0x40(%rsp)
callq 0x68d10
movq -0x68(%rbp), %rax
movq %rax, -0x70(%rbp)
jmp 0x883f5
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
jmp 0x8823e
movq -0x80(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq -0x30(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jae 0x88453
movq -0x30(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x88(%rbp), %rcx
addq %rcx, %rax
movq $0x0, 0x48(%rax)
movq -0x88(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x88(%rbp)
jmp 0x88411
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopw %cs:(%rax,%rax)