// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/ecovlp.cpp
// Function: worker_hap_ec_dbg_paf(void*, long, int)
static void worker_hap_ec_dbg_paf(void *data, long i, int tid)
{
	ec_ovec_buf_t0 *b = &(((cal_ec_r_dbg_step_t*)data)->buf->a[tid]);
    r_dbg_step_res_t *rr = &(((cal_ec_r_dbg_step_t*)data)->res[tid]);
    uint32_t high_occ = asm_opt.hom_cov * (2.0 - HA_KMER_GOOD_RATIO);
    uint32_t low_occ = asm_opt.hom_cov * HA_KMER_GOOD_RATIO;
    overlap_region *aux_o = NULL; i += ((cal_ec_r_dbg_step_t*)data)->si;

    // debug_retrive_bqual(D, &b->v8t, i, 256); return;

    recover_UC_Read(&b->self_read, &R_INF, i); 

    h_ec_lchain(b->ab, i, b->self_read.seq, b->self_read.length, asm_opt.mz_win, asm_opt.k_mer_length, &R_INF, &b->olist, &b->clist, ((asm_opt.is_ont)?(0.05):(0.02)), asm_opt.max_n_chain, 1, NULL, NULL, &(b->sp), &high_occ, &low_occ, 1, 1, 3, 0.7, 2, 32, COV_W);///ONT high error

    aux_o = fetch_aux_ovlp(&b->olist);///must be here

    // stderr_phase_ovlp(&b->olist);
    gen_hc_r_alin_ea(&b->olist, &b->clist, &R_INF, &b->self_read, &b->ovlp_read, &b->exz, aux_o, asm_opt.max_ov_diff_ec, (asm_opt.is_ont)?(WINDOW_OHC):(WINDOW_HC), i, E_KHIT, 1, &b->v16, &b->v64, &(R_INF.paf[i]), 0, -1, -1);

    uint32_t k, m, tl; overlap_region *z; bit_extz_t ez; ma_hit_t *t; 
    for (k = 0; k < b->olist.length; k++) {
        z = &(b->olist.list[k]);
        if(!(z->w_list.n)) continue;

        tl = Get_READ_LENGTH((R_INF), z->y_id);
        for (m = 0; m < z->w_list.n; m++) {
            if(is_ualn_win(z->w_list.a[m])) continue;
            set_bit_extz_t(ez, (*z), m);
            kv_pushp(ma_hit_t, *rr, &t);

            t->qns = z->x_id; t->qns = t->qns << 32;
            t->tn = z->y_id;

            t->qns = t->qns | (uint64_t)(z->w_list.a[m].x_start);
            t->qe = z->w_list.a[m].x_end + 1;

            t->ts = z->w_list.a[m].y_start;
            t->te = z->w_list.a[m].y_end + 1;

            t->rev = z->y_pos_strand;
            
            t->bl = rr->ec.n;
            kv_resize(uint16_t, rr->ec, rr->ec.n + ez.cigar.n);
            memcpy(rr->ec.a + rr->ec.n, ez.cigar.a, ez.cigar.n * sizeof((*(rr->ec.a))));
            rr->ec.n += ez.cigar.n;
            t->cc = rr->ec.n - t->bl;

            if(t->rev) {
                t->ts = tl - z->w_list.a[m].y_end - 1;
                t->te = tl - z->w_list.a[m].y_start;
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq (%rdi), %rax
movq (%rax), %rbx
movslq %edx, %rax
imulq $0x5c0, %rax, %r14      # imm = 0x5C0
leaq (%rbx,%r14), %rcx
movq %rcx, 0x18(%rsp)
imulq $0x30, %rax, %rax
addq 0x8(%rdi), %rax
movq %rax, 0x20(%rsp)
leaq 0x104c22(%rip), %r13    # 0x253758
cvtsi2sdl 0xd0(%r13), %xmm0
movsd 0x9df49(%rip), %xmm1    # 0x1eca90
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %rax
leaq 0x14(%rsp), %rdx
movl %eax, (%rdx)
mulsd 0x9ca61(%rip), %xmm0    # 0x1eb5c0
cvttsd2si %xmm0, %rax
leaq 0x10(%rsp), %rdx
movl %eax, (%rdx)
movl 0x10(%rdi), %r12d
addq %rsi, %r12
leaq 0x1056b7(%rip), %rsi    # 0x254230
movq %rcx, %rdi
movq %r12, %rdx
callq 0x715e
leaq (%rbx,%r14), %r15
addq $0x98, %r15
movq 0x20(%r15), %rdi
movq -0x98(%r15), %rdx
movq -0x90(%r15), %rcx
movslq 0x94(%r13), %r8
movslq 0x80(%r13), %r9
leaq (%rbx,%r14), %rbp
addq $0x40, %rbp
xorl %eax, %eax
cmpq $0x0, 0x2a8(%r13)
sete %al
leaq 0xa1255(%rip), %rsi     # 0x1efe20
movsd (%rsi,%rax,8), %xmm0
movl 0xe8(%r13), %eax
leaq (%rbx,%r14), %rsi
addq $0x568, %rsi            # imm = 0x568
subq $0x80, %rsp
pushq $0x1
popq %r10
movl %r10d, 0x58(%rsp)
movl %r10d, 0x50(%rsp)
leaq 0x90(%rsp), %r11
movq %r11, 0x48(%rsp)
leaq 0x94(%rsp), %r11
movq %r11, 0x40(%rsp)
movq %rsi, 0x38(%rsp)
xorpd %xmm1, %xmm1
movupd %xmm1, 0x28(%rsp)
movl %r10d, 0x20(%rsp)
movl %eax, 0x18(%rsp)
movq %rbp, 0x10(%rsp)
movq %r15, 0x8(%rsp)
leaq 0x1055f6(%rip), %rax    # 0x254230
movq %rax, (%rsp)
movq $0xc00, 0x78(%rsp)      # imm = 0xC00
movl $0x20, 0x70(%rsp)
movl $0x2, 0x68(%rsp)
movq $0x3, 0x60(%rsp)
movsd 0x94888(%rip), %xmm1    # 0x1e34f0
movl %r12d, %esi
callq 0xea30c
addq $0x80, %rsp
movq %r15, %rdi
callq 0x13d428
leaq (%rbx,%r14), %r8
addq $0x20, %r8
leaq (%rbx,%r14), %r9
addq $0x3e0, %r9             # imm = 0x3E0
movsd 0xc0(%r13), %xmm0
cmpq $0x0, 0x2a8(%r13)
movl $0x307, %ecx            # imm = 0x307
movl $0x177, %r10d           # imm = 0x177
cmoveq %rcx, %r10
leaq (%rbx,%r14), %r11
addq $0x500, %r11            # imm = 0x500
addq %r14, %rbx
addq $0x4d0, %rbx            # imm = 0x4D0
imulq $0x18, %r12, %r14
leaq 0x10555e(%rip), %rdx    # 0x254230
addq 0x78(%rdx), %r14
movsd 0x948a2(%rip), %xmm1    # 0x1e3580
movq %r15, 0x28(%rsp)
movq %r15, %rdi
movq %rbp, %rsi
movq 0x18(%rsp), %rcx
pushq $-0x1
pushq $0x0
pushq %r14
pushq %rbx
pushq %r11
pushq $0x1
pushq $0x1f
pushq %r12
pushq %r10
pushq %rax
callq 0x143a42
movq 0x70(%rsp), %rdi
addq $0x50, %rsp
xorl %ecx, %ecx
movl %ecx, %ecx
movq 0x18(%rsp), %rax
cmpq %rcx, 0xa8(%rax)
jbe 0x14ef82
movq 0x28(%rsp), %rax
movq (%rax), %r13
movq %rcx, 0x30(%rsp)
imulq $0xa8, %rcx, %rcx
movq 0x48(%r13,%rcx), %rax
testq %rax, %rax
je 0x14ef76
addq %rcx, %r13
leaq 0x1054e0(%rip), %rcx    # 0x254230
movq 0x18(%rcx), %rcx
movl 0x10(%r13), %edx
movl (%rcx,%rdx,8), %ecx
movl %ecx, 0xc(%rsp)
xorl %ebx, %ebx
movq %r13, 0x38(%rsp)
movl %ebx, %ebx
cmpq %rbx, %rax
jbe 0x14ef76
movq 0x58(%r13), %rax
movq %rbx, %r14
shlq $0x5, %r14
leaq (%rax,%r14), %rcx
cmpw $0x7fff, 0x14(%rax,%r14) # imm = 0x7FFF
sete %dl
movl 0x1c(%rax,%r14), %ebp
testl %ebp, %ebp
sete %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x14edac
xorl %ebp, %ebp
cmpw $0x0, 0x12(%rcx)
js 0x14ef6b
movl 0x18(%rcx), %ecx
addq %rcx, %rcx
addq 0x70(%r13), %rcx
movq %rcx, 0x40(%rsp)
movq (%rdi), %r12
movq 0x8(%rdi), %rcx
cmpq 0x10(%rdi), %rcx
jne 0x14edfa
leaq (%rcx,%rcx), %rax
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rax
movq %rax, 0x10(%rdi)
imulq $0x28, %rax, %rsi
movq %rdi, %r15
movq %r12, %rdi
callq 0x2370
movq %r15, %rdi
movq %rax, %r12
movq %rax, (%r15)
movq 0x8(%r15), %rcx
movq 0x58(%r13), %rax
movl %ebp, %r15d
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rdi)
imulq $0x28, %rcx, %rbp
movl (%r13), %ecx
movl 0x10(%r13), %edx
shlq $0x20, %rcx
movl %edx, 0xc(%r12,%rbp)
movslq (%rax,%r14), %rdx
orq %rcx, %rdx
movq %rdx, (%r12,%rbp)
movl 0x4(%rax,%r14), %ecx
incl %ecx
movl %ecx, 0x8(%r12,%rbp)
movl 0x8(%rax,%r14), %ecx
movl %ecx, 0x10(%r12,%rbp)
movl 0xc(%rax,%r14), %eax
incl %eax
movl %eax, 0x14(%r12,%rbp)
movl 0x1c(%r13), %eax
shll $0x1f, %eax
movq 0x18(%r12,%rbp), %rcx
movabsq $-0x80000001, %rdx      # imm = 0xFFFFFFFF7FFFFFFF
andq %rdx, %rcx
orq %rax, %rcx
movq %rcx, 0x18(%r12,%rbp)
movq 0x18(%rdi), %rax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shlq $0x20, %rax
movabsq $-0x7fffffff00000001, %rdx # imm = 0x80000000FFFFFFFF
andq %rdx, %rcx
orq %rax, %rcx
movq %rcx, 0x18(%r12,%rbp)
movq 0x18(%rdi), %rcx
leaq (%rcx,%r15), %rdx
movq 0x28(%rdi), %rax
cmpq %rdx, 0x20(%rdi)
jae 0x14eef5
decq %rdx
movq %rdx, %rcx
shrq %rcx
orq %rdx, %rcx
movq %rcx, %rdx
shrq $0x2, %rdx
orq %rcx, %rdx
movq %rdx, %rcx
shrq $0x4, %rcx
orq %rdx, %rcx
movq %rcx, %rdx
shrq $0x8, %rdx
orq %rcx, %rdx
movq %rdx, %rcx
shrq $0x10, %rcx
orq %rdx, %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x20(%rdi)
leaq 0x2(,%rcx,2), %rsi
movq %rdi, %r13
movq %rax, %rdi
callq 0x2370
movq %rax, 0x28(%r13)
movq 0x18(%r13), %rcx
jmp 0x14eef8
movq %rdi, %r13
addq %rbp, %r12
leaq (%rax,%rcx,2), %rdi
leaq (%r15,%r15), %rdx
movq 0x40(%rsp), %rsi
callq 0x2160
addq 0x18(%r13), %r15
movq %r15, 0x18(%r13)
movq 0x18(%r12), %rax
movq %rax, %rcx
shrq $0x20, %rcx
subl %ecx, %r15d
andl $0x3fffffff, %r15d      # imm = 0x3FFFFFFF
movq %rax, %rcx
andq $-0x40000000, %rcx      # imm = 0xC0000000
orq %r15, %rcx
movq %rcx, 0x18(%r12)
testl %eax, %eax
movq %r13, %rdi
movq 0x38(%rsp), %r13
jns 0x14ef6b
movq 0x58(%r13), %rax
movl 0xc(%rax,%r14), %ecx
notl %ecx
movl 0xc(%rsp), %edx
addl %edx, %ecx
movl %ecx, 0x10(%r12)
movl %edx, %ecx
subl 0x8(%rax,%r14), %ecx
movl %ecx, 0x14(%r12)
incl %ebx
movq 0x48(%r13), %rax
jmp 0x14ed66
movq 0x30(%rsp), %rcx
incl %ecx
jmp 0x14ed10
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq