// File: chhylp123[P]hifiasm/Correct.cpp
// Function: rphase_lidel(overlap_region_alloc*, All_reads*, haplotype_evdience_alloc*, UC_Read*, UC_Read*, kv_ul_ov_t*, asg64_v*, asg64_v*, long, long, long, unsigned char, unsigned long, unsigned long, unsigned long)
uint64_t rphase_lidel(overlap_region_alloc* ol, All_reads *rref, haplotype_evdience_alloc* hp, UC_Read *qu, UC_Read *tu, kv_ul_ov_t *c_idx, asg64_v* idx, asg64_v* buf, int64_t bd, int64_t wl, int64_t ql, uint8_t occ_thres, uint64_t rid, uint64_t hpc_len, uint64_t std_bs)
{
    hp->length = hp->snp_stat.n = 0; 
    int64_t on = ol->length, k, i, zwn, q[2], t[2]; 
    overlap_region *z; //ul_ov_t *cp;
    for (k = idx->n = c_idx->n = 0; k < on; k++) {
        z = &(ol->list[k]); zwn = z->w_list.n; 
        if((!zwn) || (z->is_match != 1)) continue;
        for (i = 0; i < zwn; i++) {
            if(is_ualn_win(z->w_list.a[i])) continue;
            q[0] = z->w_list.a[i].x_start; q[1] = z->w_list.a[i].x_end + 1;
            t[0] = z->w_list.a[i].y_start; t[1] = z->w_list.a[i].y_end + 1;
            if(q[1] > q[0] && t[1] > t[0]) {
                extract_sub_cigar_sv(z, k, i, rref, qu->seq, qu->length, tu, c_idx, 16, hpc_len, 2);
            }
        }
    }
    if(c_idx->n <= 0) return 0;

    idx->n = (c_idx->n<<1);
    kv_resize(uint64_t, *idx, idx->n); on = c_idx->n; idx->n = 0;
    radix_sort_ul_ov_srt_qs1(c_idx->a, c_idx->a + on);
    for (k = 1, i = 0; k <= on; k++) {
        if (k == on || (c_idx->a[k].qs) != (c_idx->a[i].qs)) {
            if(k > i + k) radix_sort_ul_ov_srt_qe1(c_idx->a + i, c_idx->a + k);
            i = k;
        }
    }
    // fprintf(stderr, "-0-[M::%s]\n", __func__); 
    on = rphase_lidel_cc(ol, c_idx->a, on, 0.500001, 3, 0.25, 3, rid, buf, idx);
    c_idx->n = on; 
    // fprintf(stderr, "-1-[M::%s]\n", __func__); 
    return rcall_lidel_variant(c_idx, ol, hp, idx, buf, rid);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq 0x50(%rbp), %rax
movq 0x48(%rbp), %rax
movq 0x40(%rbp), %rax
movb 0x38(%rbp), %al
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq -0x20(%rbp), %rax
movq $0x0, 0x220(%rax)
movq -0x20(%rbp), %rax
movl $0x0, 0x10(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
movq $0x0, 0x8(%rax)
movq 0x10(%rbp), %rax
movq $0x0, (%rax)
movq $0x0, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x40(%rbp), %rax
jge 0x794e0
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0xa8, -0x48(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0x79358
movq -0x88(%rbp), %rax
movzbl 0x2c(%rax), %eax
cmpl $0x1, %eax
je 0x7935d
jmp 0x794cf
movq $0x0, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x58(%rbp), %rax
jge 0x794cd
movq -0x88(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x50(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movswl 0x14(%rax), %eax
cmpl $0x7fff, %eax           # imm = 0x7FFF
jne 0x793d4
movq -0x88(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x50(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpl $0x0, 0x1c(%rax)
jne 0x793d4
movq -0x88(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x50(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movswl 0x12(%rax), %eax
cmpl $0x0, %eax
jge 0x793d4
jmp 0x794bc
movq -0x88(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x50(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq (%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x88(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x50(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
addl $0x1, %eax
cltq
movq %rax, -0x68(%rbp)
movq -0x88(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x50(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movslq 0x8(%rax), %rax
movq %rax, -0x80(%rbp)
movq -0x88(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x50(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
addl $0x1, %eax
cltq
movq %rax, -0x78(%rbp)
movq -0x68(%rbp), %rax
cmpq -0x70(%rbp), %rax
jle 0x794ba
movq -0x78(%rbp), %rax
cmpq -0x80(%rbp), %rax
jle 0x794ba
movq -0x88(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq -0x18(%rbp), %rcx
movq -0x28(%rbp), %rax
movq (%rax), %r8
movq -0x28(%rbp), %rax
movq 0x8(%rax), %r9
movq -0x30(%rbp), %r11
movq -0x38(%rbp), %r10
movq 0x48(%rbp), %rax
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq $0x10, 0x10(%rsp)
movq %rax, 0x18(%rsp)
movq $0x2, 0x20(%rsp)
callq 0x6fb20
jmp 0x794bc
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x79365
jmp 0x794cf
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x7930b
movq -0x38(%rbp), %rax
cmpq $0x0, 0x8(%rax)
ja 0x794f8
movq $0x0, -0x8(%rbp)
jmp 0x79729
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rcx
shlq %rcx
movq 0x10(%rbp), %rax
movq %rcx, (%rax)
movq 0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x795e9
movq 0x10(%rbp), %rax
movq (%rax), %rcx
movq 0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq 0x10(%rbp), %rax
movq 0x8(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x8(%rax)
movq 0x10(%rbp), %rax
movq 0x8(%rax), %rcx
shrq %rcx
movq 0x10(%rbp), %rax
orq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq 0x10(%rbp), %rax
movq 0x8(%rax), %rcx
shrq $0x2, %rcx
movq 0x10(%rbp), %rax
orq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq 0x10(%rbp), %rax
movq 0x8(%rax), %rcx
shrq $0x4, %rcx
movq 0x10(%rbp), %rax
orq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq 0x10(%rbp), %rax
movq 0x8(%rax), %rcx
shrq $0x8, %rcx
movq 0x10(%rbp), %rax
orq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq 0x10(%rbp), %rax
movq 0x8(%rax), %rcx
shrq $0x10, %rcx
movq 0x10(%rbp), %rax
orq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq 0x10(%rbp), %rax
movq 0x8(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x8(%rax)
movq 0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movq 0x10(%rbp), %rax
movq 0x8(%rax), %rsi
shlq $0x3, %rsi
callq 0x2360
movq %rax, %rcx
movq 0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x795eb
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x40(%rbp)
movq 0x10(%rbp), %rax
movq $0x0, (%rax)
movq -0x38(%rbp), %rax
movq (%rax), %rdi
movq -0x38(%rbp), %rax
movq (%rax), %rsi
imulq $0x1c, -0x40(%rbp), %rax
addq %rax, %rsi
callq 0x30750
movq $0x1, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x40(%rbp), %rax
jg 0x796b6
movq -0x48(%rbp), %rax
cmpq -0x40(%rbp), %rax
je 0x79667
movq -0x38(%rbp), %rax
movq (%rax), %rax
imulq $0x1c, -0x48(%rbp), %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movq -0x38(%rbp), %rcx
movq (%rcx), %rcx
imulq $0x1c, -0x50(%rbp), %rdx
addq %rdx, %rcx
cmpl 0x4(%rcx), %eax
je 0x796a3
movq -0x48(%rbp), %rax
movq -0x50(%rbp), %rcx
addq -0x48(%rbp), %rcx
cmpq %rcx, %rax
jle 0x7969b
movq -0x38(%rbp), %rax
movq (%rax), %rdi
imulq $0x1c, -0x50(%rbp), %rax
addq %rax, %rdi
movq -0x38(%rbp), %rax
movq (%rax), %rsi
imulq $0x1c, -0x48(%rbp), %rax
addq %rax, %rsi
callq 0x31710
movq -0x48(%rbp), %rax
movq %rax, -0x50(%rbp)
jmp 0x796a5
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x7962d
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rax
movq (%rax), %rsi
movq -0x40(%rbp), %rdx
movq 0x40(%rbp), %r9
movq 0x18(%rbp), %r10
movq 0x10(%rbp), %rax
movsd 0x308bf7(%rip), %xmm0   # 0x3822d0
movl $0x3, %r8d
movsd 0x308b69(%rip), %xmm1   # 0x382250
movq %r8, %rcx
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x769b0
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x38(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq 0x10(%rbp), %rcx
movq 0x18(%rbp), %r8
movq 0x40(%rbp), %r9
callq 0x782d0
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)