// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/Assembly.cpp
// Function: worker_ovec(void*, long, int)
static void worker_ovec(void *data, long i, int tid)
{
	ha_ovec_buf_t *b = ((ha_ovec_buf_t**)data)[tid];
	int fully_cov, abnormal;
    // if(i != 12578) return;
    // fprintf(stderr, "[M::%s-beg] rid->%ld\n", __func__, i);
    // if (memcmp("7897e875-76e5-42c8-bc37-94b370c4cc8d", Get_NAME((R_INF), i), Get_NAME_LENGTH((R_INF),i)) == 0) {
    //     fprintf(stderr, "[M::%s-beg] rid->%ld\n", __func__, i);
    // } else {
    //     return;
    // }

    ha_get_candidates_interface(b->ab, i, &b->self_read, &b->olist, &b->olist_hp, &b->clist, 
    0.02, asm_opt.max_n_chain, 1, NULL/**&(b->k_flag)**/, &b->r_buf, &(R_INF.paf[i]), &(R_INF.reverse_paf[i]), &(b->tmp_region), NULL, &(b->sp));

    // prt_chain(&b->olist);
    // return;

	clear_Cigar_record(&b->cigar1);
	clear_Round2_alignment(&b->round2);

	correct_overlap(&b->olist, &R_INF, &b->self_read, &b->correct, &b->ovlp_read, &b->POA_Graph, &b->DAGCon,
			&b->cigar1, &b->hap, &b->round2, &b->r_buf, &(b->tmp_region.w_list), 0, 1, &fully_cov, &abnormal);

	b->num_read_base += b->self_read.length;
	b->num_correct_base += b->correct.corrected_base;
	b->num_recorrect_base += b->round2.dumy.corrected_base;

	push_cigar(R_INF.cigars, i, &b->cigar1);
	push_cigar(R_INF.second_round_cigar, i, &b->round2.cigar);

	R_INF.paf[i].is_fully_corrected = 0;
	if (fully_cov) {
		if (get_cigar_errors(&b->cigar1) == 0 && get_cigar_errors(&b->round2.cigar) == 0)
			R_INF.paf[i].is_fully_corrected = 1;
	}
	R_INF.paf[i].is_abnormal = abnormal;

    R_INF.trio_flag[i] = AMBIGU;
    
    ///need to be fixed in r305
    // if(ha_idx_hp == NULL)
    // {
    //     R_INF.trio_flag[i] += collect_hp_regions(&b->olist, &R_INF, &(b->k_flag), RESEED_HP_RATE, Get_READ_LENGTH(R_INF, i), NULL);
    // }

    if (R_INF.trio_flag[i] != AMBIGU || b->save_ov) {
		int is_rev = (asm_opt.number_of_round % 2 == 0);
		push_overlaps(&(R_INF.paf[i]), &b->olist, 1, &R_INF, is_rev);
		push_overlaps(&(R_INF.reverse_paf[i]), &b->olist, 2, &R_INF, is_rev);
	}

    if(het_cnt) het_cnt[i] = get_het_cnt(&b->hap);
    // fprintf(stderr, "[M::%s-end] rid->%ld\n", __func__, i);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movslq %edx, %rax
movq (%rdi,%rax,8), %r14
movq 0xe0(%r14), %rdi
leaq 0x8(%r14), %rdx
movq %rdx, 0x18(%rsp)
leaq 0xa0(%r14), %rbp
leaq 0xc0(%r14), %r8
leaq 0x48(%r14), %r9
leaq 0x2463f5(%rip), %rax    # 0x253758
movl 0xe8(%rax), %ebx
leaq 0x12160(%r14), %rax
movq %rax, (%rsp)
imulq $0x18, %rsi, %r15
movq %rsi, 0x20(%rsp)
movq 0x246f24(%rip), %r10    # 0x2542a8
addq %r15, %r10
movq 0x246f22(%rip), %r11    # 0x2542b0
addq %r15, %r11
leaq 0x121a0(%r14), %r12
leaq 0x12250(%r14), %r13
subq $0x8, %rsp
movsd 0x1d2c6d(%rip), %xmm0   # 0x1e0018
movq %rbp, %rcx
pushq %r13
pushq $0x0
pushq %r12
pushq %r11
pushq %r10
pushq %rax
pushq $0x0
pushq $0x1
popq %rax
pushq %rax
pushq %rbx
callq 0xe53a4
addq $0x50, %rsp
leaq 0x108(%r14), %r13
movq %r13, %rdi
callq 0x1b25d
leaq 0x9330(%r14), %r12
movq %r12, %rdi
callq 0x1b1e8
leaq 0x2c0(%r14), %rcx
leaq 0x28(%r14), %r8
leaq 0x148(%r14), %r9
leaq 0x200(%r14), %rax
leaq 0x9040(%r14), %r11
leaq 0x121e8(%r14), %r10
leaq 0xc(%rsp), %rbx
movq %rbp, 0x10(%rsp)
movq %rbp, %rdi
leaq 0x246e0e(%rip), %rsi    # 0x254230
movq 0x18(%rsp), %rdx
leaq 0x8(%rsp), %rbp
pushq %rbp
pushq %rbx
movq 0x30(%rsp), %rbx
pushq $0x1
popq %rbp
pushq %rbp
pushq $0x0
pushq %r10
pushq 0x28(%rsp)
pushq %r12
movq %r11, 0x38(%rsp)
pushq %r11
pushq %r13
pushq %rax
callq 0x29192
addq $0x50, %rsp
movq 0x10(%r14), %rax
addq %rax, 0xf0(%r14)
movq 0x2e0(%r14), %rax
addq %rax, 0xf8(%r14)
movq 0x9350(%r14), %rax
addq %rax, 0x100(%r14)
movq 0x246e16(%rip), %rdi    # 0x254298
movq %rbx, %rsi
movq %r13, %rdx
callq 0x10ab7
movq 0x246e0c(%rip), %rdi    # 0x2542a0
leaq 0x120b0(%r14), %r12
movq %rbx, %rsi
movq %r12, %rdx
callq 0x10ab7
movq 0x246dfb(%rip), %rcx    # 0x2542a8
movb $0x0, 0x10(%rcx,%r15)
leaq 0xc(%rsp), %rax
cmpl $0x0, (%rax)
je 0xd4eb
movq %r13, %rdi
callq 0x10b4a
testl %eax, %eax
je 0xd4d2
movq 0x246dd8(%rip), %rcx    # 0x2542a8
jmp 0xd4eb
movq %r12, %rdi
callq 0x10b4a
movq 0x246dc7(%rip), %rcx    # 0x2542a8
testl %eax, %eax
jne 0xd4eb
movb $0x1, 0x10(%rcx,%r15)
movb 0x8(%rsp), %al
movb %al, 0x11(%rcx,%r15)
movq 0x246d5d(%rip), %rax    # 0x254258
movb $0x0, (%rax,%rbx)
movq 0x246d52(%rip), %rax    # 0x254258
cmpb $0x0, (%rax,%rbx)
jne 0xd513
cmpl $0x0, 0x4(%r14)
je 0xd567
leaq 0x24623e(%rip), %rax    # 0x253758
movl 0xf8(%rax), %ebp
notl %ebp
andl $0x1, %ebp
leaq 0x246d04(%rip), %r12    # 0x254230
movq 0x246d75(%rip), %rdi    # 0x2542a8
addq %r15, %rdi
pushq $0x1
popq %rdx
movq 0x10(%rsp), %r14
movq %r14, %rsi
movq %r12, %rcx
movl %ebp, %r8d
callq 0xbedb
addq 0x246d5d(%rip), %r15    # 0x2542b0
pushq $0x2
popq %rdx
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rcx
movl %ebp, %r8d
callq 0xbedb
movq 0x246e7a(%rip), %r14    # 0x2543e8
testq %r14, %r14
je 0xd580
movq (%rsp), %rdi
callq 0xc980
movl %eax, (%r14,%rbx,4)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq