// File: /workspace/github_cpp_makefile_star2_O3/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, 0x20(%rsp)
leaq 0xa0(%r14), %r13
leaq 0xc0(%r14), %r8
leaq 0x48(%r14), %r9
leaq 0x25bc27(%rip), %rax    # 0x295758
movl 0xe8(%rax), %eax
movq %rax, (%rsp)
leaq 0x12160(%r14), %rax
movq %rax, 0x8(%rsp)
leaq (,%rsi,8), %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0x25c74e(%rip), %r10    # 0x2962a8
addq %rcx, %r10
movq 0x25c74c(%rip), %r11    # 0x2962b0
movq %rcx, 0x18(%rsp)
addq %rcx, %r11
leaq 0x121a0(%r14), %r12
leaq 0x12250(%r14), %rbp
subq $0x8, %rsp
xorl %ebx, %ebx
movsd 0x1f4490(%rip), %xmm0   # 0x22e018
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 0x12a53a
addq $0x50, %rsp
leaq 0x108(%r14), %r12
movq %r12, %rdi
callq 0x475fb
leaq 0x9330(%r14), %rbp
movq %rbp, %rdi
callq 0x4758d
leaq 0x2c0(%r14), %rcx
leaq 0x28(%r14), %r8
leaq 0x148(%r14), %r9
leaq 0x200(%r14), %rax
leaq 0x9040(%r14), %rbx
leaq 0x121e8(%r14), %r10
leaq 0x10(%rsp), %r11
movq %r13, (%rsp)
movq %r13, %rdi
leaq 0x25c630(%rip), %rsi    # 0x296230
movq 0x20(%rsp), %rdx
pushq %r11
leaq 0x1c(%rsp), %r11
pushq %r11
movl $0x1, %r11d
pushq %r11
pushq $0x0
pushq %r10
pushq 0x30(%rsp)
pushq %rbp
movq %rbx, 0x40(%rsp)
pushq %rbx
pushq %r12
pushq %rax
callq 0x582c6
addq $0x50, %rsp
movq 0x10(%r14), %rax
movq 0x120(%r14), %rdx
addq %rax, 0xf0(%r14)
movq 0x2e0(%r14), %rax
addq %rax, 0xf8(%r14)
movq 0x9350(%r14), %rax
addq %rax, 0x100(%r14)
movq 0x25c632(%rip), %rax    # 0x296298
leaq (%r15,%r15,4), %r12
leaq (%rax,%r12,8), %r13
movl 0xc(%r13), %eax
movq (%r13), %rdi
cmpq %rax, %rdx
jbe 0x39ca8
movl %edx, 0xc(%r13)
shlq $0x2, %rdx
movabsq $0x3fffffffc, %rbx      # imm = 0x3FFFFFFFC
andq %rbx, %rdx
movq %rdx, %rsi
callq 0x2370
movq %rax, %rdi
movq %rax, (%r13)
movq 0x120(%r14), %rdx
jmp 0x39cb2
movabsq $0x3fffffffc, %rbx      # imm = 0x3FFFFFFFC
movl %edx, 0x8(%r13)
movq 0x110(%r14), %rsi
shlq $0x2, %rdx
callq 0x2160
movq 0x140(%r14), %rdx
movl 0x1c(%r13), %eax
cmpq %rax, %rdx
jbe 0x39cf5
movl %edx, 0x1c(%r13)
movq 0x10(%r13), %rdi
movl %edx, %esi
callq 0x2370
movq %rax, %rdi
movq %rax, 0x10(%r13)
movq 0x140(%r14), %rdx
jmp 0x39cf9
movq 0x10(%r13), %rdi
movl %edx, 0x18(%r13)
movq 0x130(%r14), %rsi
callq 0x2160
movl 0x128(%r14), %eax
movl %eax, 0x20(%r13)
movq 0x25c585(%rip), %rax    # 0x2962a0
movq 0x120c8(%r14), %rdx
leaq (%rax,%r12,8), %r12
movl 0xc(%r12), %eax
movq (%r12), %rdi
cmpq %rax, %rdx
jbe 0x39d56
movl %edx, 0xc(%r12)
shlq $0x2, %rdx
andq %rbx, %rdx
movq %rdx, %rsi
callq 0x2370
movq %rax, %rdi
movq %rax, (%r12)
movq 0x120c8(%r14), %rdx
movl %edx, 0x8(%r12)
movq 0x120b8(%r14), %rsi
shlq $0x2, %rdx
callq 0x2160
movq 0x120e8(%r14), %rdx
movl 0x1c(%r12), %eax
cmpq %rax, %rdx
jbe 0x39d9e
movl %edx, 0x1c(%r12)
movq 0x10(%r12), %rdi
movl %edx, %esi
callq 0x2370
movq %rax, %rdi
movq %rax, 0x10(%r12)
movq 0x120e8(%r14), %rdx
jmp 0x39da3
movq 0x10(%r12), %rdi
movl %edx, 0x18(%r12)
movq 0x120d8(%r14), %rsi
callq 0x2160
movl 0x120d0(%r14), %eax
movl %eax, 0x20(%r12)
movq 0x25c4e1(%rip), %rax    # 0x2962a8
leaq (%r15,%r15,2), %rcx
movb $0x0, 0x10(%rax,%rcx,8)
cmpl $0x0, 0x14(%rsp)
je 0x39e62
movq 0x120(%r14), %rdx
testq %rdx, %rdx
jle 0x39e19
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 0x39df3
testl %r8d, %r8d
jne 0x39e62
movq 0x120c8(%r14), %rdx
testq %rdx, %rdx
jle 0x39e57
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 0x39e31
testl %r8d, %r8d
jne 0x39e62
leaq (%rax,%rcx,8), %rdx
addq $0x10, %rdx
movb $0x1, (%rdx)
movb 0x10(%rsp), %dl
movb %dl, 0x11(%rax,%rcx,8)
movq 0x25c3e7(%rip), %rax    # 0x296258
movb $0x0, (%rax,%r15)
movq 0x25c3db(%rip), %rax    # 0x296258
cmpb $0x0, (%rax,%r15)
jne 0x39e8b
cmpl $0x0, 0x4(%r14)
je 0x39ee7
leaq 0x25b8c6(%rip), %rax    # 0x295758
movl 0xf8(%rax), %ebp
notl %ebp
andl $0x1, %ebp
leaq 0x25c38c(%rip), %r12    # 0x296230
movq 0x25c3fd(%rip), %rdi    # 0x2962a8
movq 0x18(%rsp), %r14
addq %r14, %rdi
movq (%rsp), %rbx
movq %rbx, %rsi
movl $0x1, %edx
movq %r12, %rcx
movl %ebp, %r8d
callq 0x38249
addq 0x25c3df(%rip), %r14    # 0x2962b0
movq %r14, %rdi
movq %rbx, %rsi
movl $0x2, %edx
movq %r12, %rcx
movl %ebp, %r8d
callq 0x38249
movq 0x25c4fa(%rip), %rbx    # 0x2963e8
testq %rbx, %rbx
je 0x39f01
movq 0x8(%rsp), %rdi
callq 0x38f0d
movl %eax, (%rbx,%r15,4)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq