// File: /workspace/github_cpp_makefile_star2_O1/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
movq %rsi, %r15
movslq %edx, %rax
movq (%rdi,%rax,8), %r14
movq 0xe0(%r14), %rdi
leaq 0x8(%r14), %rdx
movq %rdx, 0x18(%rsp)
leaq 0xa0(%r14), %r13
leaq 0xc0(%r14), %r8
leaq 0x48(%r14), %r9
leaq 0x2501a7(%rip), %rax    # 0x28a758
movl 0xe8(%rax), %eax
movq %rax, (%rsp)
leaq 0x12160(%r14), %rax
movq %rax, 0x20(%rsp)
leaq (,%rsi,8), %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0x250cce(%rip), %r10    # 0x28b2a8
addq %rcx, %r10
movq 0x250ccc(%rip), %r11    # 0x28b2b0
movq %rcx, 0x10(%rsp)
addq %rcx, %r11
leaq 0x121a0(%r14), %r12
leaq 0x12250(%r14), %rbp
subq $0x8, %rsp
xorl %ebx, %ebx
movsd 0x1e7a10(%rip), %xmm0   # 0x222018
movq %r13, %rcx
pushq %rbp
pushq %rbx
pushq %r12
pushq %r11
pushq %r10
pushq %rax
pushq %rbx
movl $0x1, %eax
pushq %rax
pushq 0x48(%rsp)
callq 0x1245e4
addq $0x50, %rsp
leaq 0x108(%r14), %r12
movq %r12, %rdi
callq 0x48007
leaq 0x9330(%r14), %rbp
movq %rbp, %rdi
callq 0x47f99
leaq 0x2c0(%r14), %rcx
leaq 0x28(%r14), %r8
leaq 0x148(%r14), %r9
leaq 0x200(%r14), %rax
leaq 0x9040(%r14), %rdx
leaq 0x121e8(%r14), %r10
leaq 0x8(%rsp), %r11
leaq 0xc(%rsp), %rbx
movq %r13, (%rsp)
movq %r13, %rdi
movq %rdx, %r13
leaq 0x250ba8(%rip), %rsi    # 0x28b230
movq 0x18(%rsp), %rdx
pushq %r11
pushq %rbx
movq %r15, %rbx
movl $0x1, %r11d
pushq %r11
pushq $0x0
pushq %r10
pushq 0x48(%rsp)
pushq %rbp
pushq %r13
pushq %r12
pushq %rax
callq 0x58e58
addq $0x50, %rsp
movq 0x10(%r14), %rax
movq 0x120(%r14), %rsi
addq %rax, 0xf0(%r14)
movq 0x2e0(%r14), %rax
addq %rax, 0xf8(%r14)
movq 0x9350(%r14), %rax
addq %rax, 0x100(%r14)
movq 0x250bb1(%rip), %rax    # 0x28b298
leaq (%r15,%r15,4), %r15
leaq (%rax,%r15,8), %r12
movl 0xc(%r12), %eax
cmpq %rax, %rsi
jbe 0x3a71c
movl %esi, 0xc(%r12)
movq (%r12), %rdi
shlq $0x2, %rsi
movabsq $0x3fffffffc, %rax      # imm = 0x3FFFFFFFC
andq %rax, %rsi
callq 0x2370
movq %rax, (%r12)
movq 0x120(%r14), %rdx
movl %edx, 0x8(%r12)
movq (%r12), %rdi
movq 0x110(%r14), %rsi
shlq $0x2, %rdx
callq 0x2160
movq 0x140(%r14), %rax
movl 0x1c(%r12), %ecx
cmpq %rcx, %rax
jbe 0x3a763
movl %eax, 0x1c(%r12)
movq 0x10(%r12), %rdi
movl %eax, %esi
callq 0x2370
movq %rax, 0x10(%r12)
movq 0x140(%r14), %rdx
movl %edx, 0x18(%r12)
movq 0x10(%r12), %rdi
movq 0x130(%r14), %rsi
callq 0x2160
movl 0x128(%r14), %eax
movl %eax, 0x20(%r12)
movq 0x250b0d(%rip), %rax    # 0x28b2a0
movq 0x120c8(%r14), %rsi
leaq (%rax,%r15,8), %r15
movl 0xc(%r15), %eax
cmpq %rax, %rsi
jbe 0x3a7c7
movl %esi, 0xc(%r15)
movq (%r15), %rdi
shlq $0x2, %rsi
movabsq $0x3fffffffc, %rax      # imm = 0x3FFFFFFFC
andq %rax, %rsi
callq 0x2370
movq %rax, (%r15)
movq 0x120c8(%r14), %rdx
movl %edx, 0x8(%r15)
movq (%r15), %rdi
movq 0x120b8(%r14), %rsi
shlq $0x2, %rdx
callq 0x2160
movq 0x120e8(%r14), %rax
movl 0x1c(%r15), %ecx
cmpq %rcx, %rax
jbe 0x3a808
movl %eax, 0x1c(%r15)
movq 0x10(%r15), %rdi
movl %eax, %esi
callq 0x2370
movq %rax, 0x10(%r15)
movq 0x120e8(%r14), %rdx
movl %edx, 0x18(%r15)
movq 0x10(%r15), %rdi
movq 0x120d8(%r14), %rsi
callq 0x2160
movl 0x120d0(%r14), %eax
movl %eax, 0x20(%r15)
movq 0x250a73(%rip), %rax    # 0x28b2a8
leaq (%rbx,%rbx,2), %rcx
movb $0x0, 0x10(%rax,%rcx,8)
cmpl $0x0, 0xc(%rsp)
je 0x3a8d0
movq 0x120(%r14), %rdx
testq %rdx, %rdx
jle 0x3a887
movq 0x110(%r14), %rsi
xorl %edi, %edi
xorl %r8d, %r8d
movl (%rsi,%rdi,4), %r9d
movl %r9d, %r10d
andl $0x3, %r10d
shrl $0x2, %r9d
testl %r10d, %r10d
cmovel %r10d, %r9d
addl %r9d, %r8d
incq %rdi
cmpq %rdi, %rdx
jne 0x3a861
testl %r8d, %r8d
jne 0x3a8d0
movq 0x120c8(%r14), %rdx
testq %rdx, %rdx
jle 0x3a8c5
movq 0x120b8(%r14), %rsi
xorl %edi, %edi
xorl %r8d, %r8d
movl (%rsi,%rdi,4), %r9d
movl %r9d, %r10d
andl $0x3, %r10d
shrl $0x2, %r9d
testl %r10d, %r10d
cmovel %r10d, %r9d
addl %r9d, %r8d
incq %rdi
cmpq %rdi, %rdx
jne 0x3a89f
testl %r8d, %r8d
jne 0x3a8d0
leaq (%rax,%rcx,8), %rdx
addq $0x10, %rdx
movb $0x1, (%rdx)
movb 0x8(%rsp), %dl
movb %dl, 0x11(%rax,%rcx,8)
movq 0x250979(%rip), %rax    # 0x28b258
movb $0x0, (%rax,%rbx)
movq 0x25096e(%rip), %rax    # 0x28b258
cmpb $0x0, (%rax,%rbx)
jne 0x3a8f7
cmpl $0x0, 0x4(%r14)
je 0x3a953
leaq 0x24fe5a(%rip), %rax    # 0x28a758
movl 0xf8(%rax), %ebp
notl %ebp
andl $0x1, %ebp
leaq 0x250920(%rip), %r12    # 0x28b230
movq 0x250991(%rip), %rdi    # 0x28b2a8
movq 0x10(%rsp), %r15
addq %r15, %rdi
movq (%rsp), %r14
movq %r14, %rsi
movl $0x1, %edx
movq %r12, %rcx
movl %ebp, %r8d
callq 0x38c89
addq 0x250973(%rip), %r15    # 0x28b2b0
movq %r15, %rdi
movq %r14, %rsi
movl $0x2, %edx
movq %r12, %rcx
movl %ebp, %r8d
callq 0x38c89
movq 0x250a8e(%rip), %r14    # 0x28b3e8
testq %r14, %r14
je 0x3a96b
movq %r13, %rdi
callq 0x3998f
movl %eax, (%r14,%rbx,4)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq