// File: /workspace/github_cpp_makefile_star2_O1/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 $0x38, %rsp
movq (%rdi), %rax
movq (%rax), %rbx
movslq %edx, %rax
imulq $0x5c0, %rax, %r14      # imm = 0x5C0
leaq (%rbx,%r14), %rcx
movq %rcx, 0x18(%rsp)
leaq (%rax,%rax,2), %rbp
shlq $0x4, %rbp
addq 0x8(%rdi), %rbp
leaq 0xfda5e(%rip), %r13     # 0x28a758
cvtsi2sdl 0xd0(%r13), %xmm0
movsd 0xa1c85(%rip), %xmm1    # 0x22e990
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %rax
leaq 0x14(%rsp), %rdx
movl %eax, (%rdx)
mulsd 0xa07ad(%rip), %xmm0    # 0x22d4d0
cvttsd2si %xmm0, %rax
leaq 0x10(%rsp), %rdx
movl %eax, (%rdx)
movl 0x10(%rdi), %r12d
addq %rsi, %r12
leaq 0xfe4f3(%rip), %rsi     # 0x28b230
movq %rcx, %rdi
movq %r12, %rdx
callq 0x33cf8
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), %r11
addq $0x40, %r11
xorl %eax, %eax
cmpq $0x0, 0x2a8(%r13)
sete %al
leaq 0xa4f81(%rip), %rsi     # 0x231d10
movsd (%rsi,%rax,8), %xmm0
movl 0xe8(%r13), %eax
leaq (%rbx,%r14), %rsi
addq $0x568, %rsi            # imm = 0x568
subq $0x80, %rsp
movl $0x1, %r10d
movl %r10d, 0x58(%rsp)
movl %r10d, 0x50(%rsp)
leaq 0x90(%rsp), %r13
movq %r13, 0x48(%rsp)
leaq 0x94(%rsp), %r13
movq %r13, 0x40(%rsp)
movq %rsi, 0x38(%rsp)
xorpd %xmm1, %xmm1
movupd %xmm1, 0x28(%rsp)
movl %r10d, 0x20(%rsp)
movl %eax, 0x18(%rsp)
movq %r11, 0x10(%rsp)
movq %r11, %r13
movq %r15, 0x8(%rsp)
leaq 0xfe42d(%rip), %rax     # 0x28b230
movq %rax, (%rsp)
movq $0xc00, 0x78(%rsp)      # imm = 0xC00
movl $0x20, 0x70(%rsp)
movl $0x2, 0x68(%rsp)
movq $0x3, 0x60(%rsp)
movsd 0x9866f(%rip), %xmm1    # 0x2254a0
movl %r12d, %esi
callq 0x129c88
addq $0x80, %rsp
movq %r15, %rdi
callq 0x179530
leaq (%rbx,%r14), %r8
addq $0x20, %r8
leaq (%rbx,%r14), %r9
addq $0x3e0, %r9             # imm = 0x3E0
leaq 0xfd8f6(%rip), %rcx     # 0x28a758
movsd 0xc0(%rcx), %xmm0
cmpq $0x0, 0x2a8(%rcx)
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
leaq (%r12,%r12,2), %r14
shlq $0x3, %r14
leaq 0xfe38b(%rip), %rdx     # 0x28b230
addq 0x78(%rdx), %r14
movsd 0x98687(%rip), %xmm1    # 0x225538
movq %r15, 0x28(%rsp)
movq %r15, %rdi
movq %r13, %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 0x180c3c
addq $0x50, %rsp
cmpq $0x0, 0x68(%r13)
je 0x18d13d
xorl %ecx, %ecx
movq 0x28(%rsp), %rax
movq (%rax), %rsi
movq %rcx, 0x30(%rsp)
imulq $0xa8, %rcx, %rax
cmpq $0x0, 0x48(%rsi,%rax)
je 0x18d124
addq %rax, %rsi
cmpq $0x0, 0x48(%rsi)
je 0x18d124
leaq 0xfe312(%rip), %rax     # 0x28b230
movq 0x18(%rax), %rax
movl 0x10(%rsi), %ecx
movl (%rax,%rcx,8), %eax
movl %eax, 0x8(%rsp)
movl $0x1, %edi
xorl %r13d, %r13d
movq %rsi, 0x20(%rsp)
movq 0x58(%rsi), %rcx
shlq $0x5, %r13
leaq (%rcx,%r13), %rax
cmpw $0x7fff, 0x14(%rcx,%r13) # imm = 0x7FFF
jne 0x18cf60
cmpl $0x0, 0x1c(%rax)
jne 0x18cf60
cmpw $0x0, 0x12(%rax)
js 0x18d115
movl %edi, 0xc(%rsp)
movl 0x18(%rax), %r12d
addq %r12, %r12
addq 0x70(%rsi), %r12
movl 0x1c(%rax), %ebx
movq 0x10(%rbp), %rax
cmpq %rax, 0x8(%rbp)
jne 0x18cfaa
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rcx
movq %rcx, 0x10(%rbp)
movq (%rbp), %rdi
shlq $0x3, %rcx
leaq (%rcx,%rcx,4), %rsi
callq 0x2370
movq 0x20(%rsp), %rsi
movq %rax, (%rbp)
movq (%rbp), %r14
movq 0x8(%rbp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rbp)
leaq (%rax,%rax,4), %r15
movl (%rsi), %eax
shlq $0x20, %rax
movq %rax, (%r14,%r15,8)
movl 0x10(%rsi), %ecx
movl %ecx, 0xc(%r14,%r15,8)
movq 0x58(%rsi), %rcx
movslq (%rcx,%r13), %rdx
orq %rax, %rdx
movq %rdx, (%r14,%r15,8)
movl 0x4(%rcx,%r13), %eax
incl %eax
movl %eax, 0x8(%r14,%r15,8)
movl 0x8(%rcx,%r13), %eax
movl %eax, 0x10(%r14,%r15,8)
movl 0xc(%rcx,%r13), %eax
incl %eax
movl %eax, 0x14(%r14,%r15,8)
movl 0x1c(%rsi), %eax
shll $0x1f, %eax
movq 0x18(%r14,%r15,8), %rcx
movabsq $-0x80000001, %rdx      # imm = 0xFFFFFFFF7FFFFFFF
andq %rdx, %rcx
orq %rax, %rcx
movq %rcx, 0x18(%r14,%r15,8)
movq 0x18(%rbp), %rax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shlq $0x20, %rax
movabsq $-0x7fffffff00000001, %rdx # imm = 0x80000000FFFFFFFF
andq %rdx, %rcx
orq %rax, %rcx
movq %rcx, 0x18(%r14,%r15,8)
movq 0x18(%rbp), %rax
addq %rbx, %rax
cmpq %rax, 0x20(%rbp)
jae 0x18d0a1
decq %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x10, %rcx
orq %rax, %rcx
leaq 0x1(%rcx), %rax
movq %rax, 0x20(%rbp)
movq 0x28(%rbp), %rdi
leaq 0x2(,%rcx,2), %rsi
callq 0x2370
movq %rax, 0x28(%rbp)
leaq (%r14,%r15,8), %r14
movq 0x18(%rbp), %rdi
addq %rdi, %rdi
addq 0x28(%rbp), %rdi
leaq (%rbx,%rbx), %rdx
movq %r12, %rsi
callq 0x2160
addq 0x18(%rbp), %rbx
movq %rbx, 0x18(%rbp)
movq 0x18(%r14), %rax
movq %rax, %rcx
shrq $0x20, %rcx
subl %ecx, %ebx
andl $0x3fffffff, %ebx       # imm = 0x3FFFFFFF
movq %rax, %rcx
andq $-0x40000000, %rcx      # imm = 0xC0000000
orq %rbx, %rcx
movq %rcx, 0x18(%r14)
testl %eax, %eax
movq 0x20(%rsp), %rsi
movl 0xc(%rsp), %edi
jns 0x18d115
movq 0x58(%rsi), %rax
movl 0xc(%rax,%r13), %ecx
notl %ecx
movl 0x8(%rsp), %edx
addl %edx, %ecx
movl %ecx, 0x10(%r14)
movl %edx, %ecx
subl 0x8(%rax,%r13), %ecx
movl %ecx, 0x14(%r14)
movl %edi, %r13d
incl %edi
cmpq %r13, 0x48(%rsi)
ja 0x18cf39
movq 0x30(%rsp), %rcx
incl %ecx
movq 0x18(%rsp), %rax
cmpq %rcx, 0xa8(%rax)
ja 0x18cee9
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq