// File: /workspace/github_cpp_makefile_star2_O3/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, 0x10(%rsp)
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
addq 0x8(%rdi), %rax
movq %rax, 0x18(%rsp)
leaq 0xffc33(%rip), %r13     # 0x295758
cvtsi2sdl 0xd0(%r13), %xmm0
movsd 0xa506a(%rip), %xmm1    # 0x23aba0
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %rax
leaq 0xc(%rsp), %rdx
movl %eax, (%rdx)
mulsd 0xa3b92(%rip), %xmm0    # 0x2396e0
cvttsd2si %xmm0, %rax
leaq 0x8(%rsp), %rdx
movl %eax, (%rdx)
movl 0x10(%rdi), %r12d
addq %rsi, %r12
leaq 0x1006c8(%rip), %rsi    # 0x296230
movq %rcx, %rdi
movq %r12, %rdx
callq 0x333e0
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 0xa83a6(%rip), %rsi     # 0x23df60
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 0x88(%rsp), %r11
movq %r11, 0x48(%rsp)
leaq 0x8c(%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 0x100605(%rip), %rax    # 0x296230
movq %rax, (%rsp)
movq $0xc00, 0x78(%rsp)      # imm = 0xC00
movl $0x20, 0x70(%rsp)
movl $0x2, 0x68(%rsp)
movq $0x3, 0x60(%rsp)
movsd 0x9b947(%rip), %xmm1    # 0x2315a0
movl %r12d, %esi
callq 0x12fd4b
addq $0x80, %rsp
movq %r15, %rdi
callq 0x18019c
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
leaq (%r12,%r12,2), %r14
shlq $0x3, %r14
leaq 0x100569(%rip), %rdx    # 0x296230
addq 0x78(%rdx), %r14
movsd 0x9b965(%rip), %xmm1    # 0x231638
movq %r15, 0x20(%rsp)
movq %r15, %rdi
movq %rbp, %rsi
movq 0x10(%rsp), %rcx
pushq $-0x1
pushq $0x0
pushq %r14
pushq %rbx
pushq %r11
pushq $0x1
pushq $0x1f
pushq %r12
pushq %r10
pushq %rax
callq 0x18815a
addq $0x50, %rsp
movq 0x68(%rbp), %rax
testq %rax, %rax
je 0x195f7d
xorl %edx, %edx
movq 0x20(%rsp), %rcx
movq (%rcx), %rbx
imulq $0xa8, %rdx, %rcx
cmpq $0x0, 0x48(%rbx,%rcx)
je 0x195f72
movq %rdx, 0x28(%rsp)
addq %rcx, %rbx
leaq 0x1004f9(%rip), %rax    # 0x296230
movq 0x18(%rax), %rax
movl 0x10(%rbx), %ecx
movl (%rax,%rcx,8), %eax
movl %eax, (%rsp)
movl $0x1, %r8d
xorl %r15d, %r15d
movq 0x18(%rsp), %rdi
movq %rbx, 0x30(%rsp)
movq 0x58(%rbx), %rax
shlq $0x5, %r15
leaq (%rax,%r15), %rcx
cmpw $0x7fff, 0x14(%rax,%r15) # imm = 0x7FFF
sete %dl
movl 0x1c(%rax,%r15), %ebp
testl %ebp, %ebp
sete %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x195d8f
xorl %ebp, %ebp
cmpw $0x0, 0x12(%rcx)
js 0x195f51
movl 0x18(%rcx), %r12d
addq %r12, %r12
addq 0x70(%rbx), %r12
movq (%rdi), %r13
movq 0x8(%rdi), %rcx
cmpq 0x10(%rdi), %rcx
movl %r8d, 0x4(%rsp)
jne 0x195de3
leaq (%rcx,%rcx), %rax
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rax
movq %rax, 0x10(%rdi)
shlq $0x3, %rax
leaq (%rax,%rax,4), %rsi
movq %r13, %rdi
callq 0x2370
movq 0x18(%rsp), %rdi
movq %rax, %r13
movq %rax, (%rdi)
movq 0x8(%rdi), %rcx
movq 0x58(%rbx), %rax
movl %ebp, %r14d
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rdi)
leaq (%rcx,%rcx,4), %rbp
movl (%rbx), %ecx
movl 0x10(%rbx), %edx
shlq $0x20, %rcx
movl %edx, 0xc(%r13,%rbp,8)
movslq (%rax,%r15), %rdx
orq %rcx, %rdx
movq %rdx, (%r13,%rbp,8)
movl 0x4(%rax,%r15), %ecx
incl %ecx
movl %ecx, 0x8(%r13,%rbp,8)
movl 0x8(%rax,%r15), %ecx
movl %ecx, 0x10(%r13,%rbp,8)
movl 0xc(%rax,%r15), %eax
incl %eax
movl %eax, 0x14(%r13,%rbp,8)
movl 0x1c(%rbx), %eax
shll $0x1f, %eax
movq 0x18(%r13,%rbp,8), %rcx
movabsq $-0x80000001, %rdx      # imm = 0xFFFFFFFF7FFFFFFF
andq %rdx, %rcx
orq %rax, %rcx
movq %rcx, 0x18(%r13,%rbp,8)
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(%r13,%rbp,8)
movq 0x18(%rdi), %rcx
leaq (%rcx,%r14), %rdx
movq 0x28(%rdi), %rax
cmpq %rdx, 0x20(%rdi)
jae 0x195edb
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, %rbx
movq %rax, %rdi
callq 0x2370
movq %rax, 0x28(%rbx)
movq 0x18(%rbx), %rcx
jmp 0x195ede
movq %rdi, %rbx
leaq (%r13,%rbp,8), %r13
leaq (%rax,%rcx,2), %rdi
leaq (%r14,%r14), %rdx
movq %r12, %rsi
callq 0x2160
addq 0x18(%rbx), %r14
movq %r14, 0x18(%rbx)
movq 0x18(%r13), %rax
movq %rax, %rcx
shrq $0x20, %rcx
subl %ecx, %r14d
andl $0x3fffffff, %r14d      # imm = 0x3FFFFFFF
movq %rax, %rcx
andq $-0x40000000, %rcx      # imm = 0xC0000000
orq %r14, %rcx
movq %rcx, 0x18(%r13)
testl %eax, %eax
movq %rbx, %rdi
movq 0x30(%rsp), %rbx
movl 0x4(%rsp), %r8d
jns 0x195f51
movq 0x58(%rbx), %rax
movl 0xc(%rax,%r15), %ecx
notl %ecx
movl (%rsp), %edx
addl %edx, %ecx
movl %ecx, 0x10(%r13)
movl %edx, %ecx
subl 0x8(%rax,%r15), %ecx
movl %ecx, 0x14(%r13)
movl %r8d, %r15d
incl %r8d
cmpq %r15, 0x48(%rbx)
ja 0x195d57
movq 0x10(%rsp), %rax
movq 0xa8(%rax), %rax
movq 0x28(%rsp), %rdx
incl %edx
cmpq %rdx, %rax
ja 0x195d0d
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq