// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/Assembly.cpp
// Function: ha_overlap_cal(int, int)
void ha_overlap_cal(int round, int read_from_store)
{
	int i, hom_cov, het_cov;
	ha_ovec_buf_t **b;
    ha_flt_tab_hp = ha_idx_hp = NULL;

	// overlap and correct reads
	CALLOC(b, asm_opt.thread_num);
	for (i = 0; i < asm_opt.thread_num; ++i)
		b[i] = ha_ovec_init(0, (round == asm_opt.number_of_round - 1),0);
    if(ha_idx) hom_cov = asm_opt.hom_cov;
	if(ha_idx == NULL) ha_idx = ha_pt_gen(&asm_opt, ha_flt_tab, ((round == 0)&&(read_from_store == 0))?0:1, 0, &R_INF, &hom_cov, &het_cov); // build the index
	///debug_adapter(&asm_opt, &R_INF);
    if (/**round == 0 &&**/ ha_flt_tab == 0) // then asm_opt.hom_cov hasn't been updated
		ha_opt_update_cov(&asm_opt, hom_cov);
    het_cnt = NULL;
    if(round == asm_opt.number_of_round-1 && asm_opt.is_dbg_het_cnt) CALLOC(het_cnt, R_INF.total_reads);
    // fprintf(stderr, "[M::%s-start]\n", __func__);
	kt_for(asm_opt.thread_num, worker_ovec_cal0, b, R_INF.total_reads);///debug_for_fix
    // fprintf(stderr, "[M::%s-end]\n", __func__);

	ha_pt_destroy(ha_idx);
	ha_idx = NULL;

    if(het_cnt) {
        print_het_cnt_log(het_cnt); free(het_cnt); het_cnt = NULL;
    }

	// collect statistics
	for (i = 0; i < asm_opt.thread_num; ++i) {
		asm_opt.num_bases += b[i]->num_read_base;
		asm_opt.num_corrected_bases += b[i]->num_correct_base;
		asm_opt.num_recorrected_bases += b[i]->num_recorrect_base;
		asm_opt.mem_buf += ha_ovec_mem(b[i], NULL);
		ha_ovec_destroy(b[i]);
	}
	free(b);
    asm_opt.hom_cov = hom_cov;
    asm_opt.het_cov = het_cov;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movl %esi, %r14d
movl %edi, %ebp
leaq 0x25bc25(%rip), %rax    # 0x296448
xorl %ecx, %ecx
movq %rcx, (%rax)
leaq 0x25bc11(%rip), %rax    # 0x296440
movq %rcx, (%rax)
leaq 0x25af1f(%rip), %r12    # 0x295758
movslq 0x7c(%r12), %r15
movl $0x8, %esi
movq %r15, %rdi
callq 0x2120
movq %rax, %rbx
testq %r15, %r15
jle 0x3a882
xorl %r15d, %r15d
movl 0xf8(%r12), %eax
decl %eax
xorl %esi, %esi
cmpl %ebp, %eax
sete %sil
xorl %edi, %edi
xorl %edx, %edx
callq 0x387f4
movq %rax, (%rbx,%r15,8)
incq %r15
movslq 0x7c(%r12), %rax
cmpq %rax, %r15
jl 0x3a856
leaq 0x25bbaf(%rip), %r15    # 0x296438
cmpq $0x0, (%r15)
je 0x3a89d
movl 0xd0(%r12), %eax
movl %eax, 0x8(%rsp)
jmp 0x3a8d5
leaq 0x25bb8c(%rip), %rax    # 0x296430
movq (%rax), %rsi
xorl %edx, %edx
orl %ebp, %r14d
setne %dl
leaq 0xc(%rsp), %rax
movq %rax, (%rsp)
leaq 0x25ae99(%rip), %rdi    # 0x295758
leaq 0x25b96a(%rip), %r8     # 0x296230
leaq 0x8(%rsp), %r9
xorl %ecx, %ecx
callq 0x13d74
movq %rax, (%r15)
leaq 0x25bb54(%rip), %rax    # 0x296430
cmpq $0x0, (%rax)
jne 0x3a8f2
movl 0x8(%rsp), %esi
leaq 0x25ae6b(%rip), %rdi    # 0x295758
callq 0x2f59
movq $0x0, 0x25baeb(%rip) # 0x2963e8
movl 0xf8(%r12), %eax
decl %eax
movq 0x25b972(%rip), %r14    # 0x296280
cmpl %ebp, %eax
jne 0x3a931
cmpb $0x0, 0x248(%r12)
je 0x3a931
movl $0x4, %esi
movq %r14, %rdi
callq 0x2120
movq %rax, 0x25bab7(%rip)    # 0x2963e8
movl 0x7c(%r12), %edi
leaq 0xce(%rip), %rsi        # 0x3aa0b
movq %rbx, %rdx
movq %r14, %rcx
callq 0x108f2c
movq (%r15), %rdi
callq 0x1193ff
movq $0x0, (%r15)
movq 0x25ba8a(%rip), %rdi    # 0x2963e8
testq %rdi, %rdi
je 0x3a97f
callq 0x39f10
movq 0x25ba79(%rip), %rdi    # 0x2963e8
callq 0x2220
movq $0x0, 0x25ba69(%rip) # 0x2963e8
cmpl $0x0, 0x7c(%r12)
jle 0x3a9de
xorl %r14d, %r14d
movq (%rbx,%r14,8), %rdi
movdqu 0x190(%r12), %xmm0
paddq 0xf0(%rdi), %xmm0
movdqu %xmm0, 0x190(%r12)
movq 0x100(%rdi), %rax
addq %rax, 0x1a0(%r12)
xorl %esi, %esi
callq 0x38c68
addq %rax, 0x1a8(%r12)
movq (%rbx,%r14,8), %rdi
callq 0x38b4b
incq %r14
movslq 0x7c(%r12), %rax
cmpq %rax, %r14
jl 0x3a98a
movq %rbx, %rdi
callq 0x2220
movl 0x8(%rsp), %eax
movl %eax, 0xd0(%r12)
movl 0xc(%rsp), %eax
movl %eax, 0xd4(%r12)
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq