// File: /workspace/github_cpp_makefile_star2_O1/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 0x2501df(%rip), %rax    # 0x28b448
xorl %ecx, %ecx
movq %rcx, (%rax)
leaq 0x2501cb(%rip), %rax    # 0x28b440
movq %rcx, (%rax)
leaq 0x24f4d9(%rip), %r12    # 0x28a758
movslq 0x7c(%r12), %r15
movl $0x8, %esi
movq %r15, %rdi
callq 0x2120
movq %rax, %rbx
testq %r15, %r15
jle 0x3b2c8
xorl %r15d, %r15d
movl 0xf8(%r12), %eax
decl %eax
xorl %esi, %esi
cmpl %ebp, %eax
sete %sil
xorl %edi, %edi
xorl %edx, %edx
callq 0x39240
movq %rax, (%rbx,%r15,8)
incq %r15
movslq 0x7c(%r12), %rax
cmpq %rax, %r15
jl 0x3b29c
leaq 0x250169(%rip), %r15    # 0x28b438
cmpq $0x0, (%r15)
je 0x3b2e3
movl 0xd0(%r12), %eax
movl %eax, 0x8(%rsp)
jmp 0x3b31b
leaq 0x250146(%rip), %rax    # 0x28b430
movq (%rax), %rsi
xorl %edx, %edx
orl %ebp, %r14d
setne %dl
leaq 0xc(%rsp), %rax
movq %rax, (%rsp)
leaq 0x24f453(%rip), %rdi    # 0x28a758
leaq 0x24ff24(%rip), %r8     # 0x28b230
leaq 0x8(%rsp), %r9
xorl %ecx, %ecx
callq 0x1448a
movq %rax, (%r15)
leaq 0x25010e(%rip), %rax    # 0x28b430
cmpq $0x0, (%rax)
jne 0x3b338
movl 0x8(%rsp), %esi
leaq 0x24f425(%rip), %rdi    # 0x28a758
callq 0x2f59
movq $0x0, 0x2500a5(%rip) # 0x28b3e8
movl 0xf8(%r12), %eax
decl %eax
cmpl %ebp, %eax
jne 0x3b374
cmpb $0x0, 0x248(%r12)
je 0x3b374
movq 0x24ff1d(%rip), %rdi    # 0x28b280
movl $0x4, %esi
callq 0x2120
movq %rax, 0x250074(%rip)    # 0x28b3e8
movl 0x7c(%r12), %edi
movq 0x24ff00(%rip), %rcx    # 0x28b280
leaq 0xcd(%rip), %rsi        # 0x3b454
movq %rbx, %rdx
callq 0x1047b4
movq (%r15), %rdi
callq 0x113930
movq $0x0, (%r15)
movq 0x250043(%rip), %rdi    # 0x28b3e8
testq %rdi, %rdi
je 0x3b3c6
callq 0x3a97a
movq 0x250032(%rip), %rdi    # 0x28b3e8
callq 0x2220
movq $0x0, 0x250022(%rip) # 0x28b3e8
cmpl $0x0, 0x7c(%r12)
jle 0x3b427
xorl %r14d, %r14d
movq (%rbx,%r14,8), %rdi
movq 0xf0(%rdi), %rax
addq %rax, 0x190(%r12)
movq 0xf8(%rdi), %rax
addq %rax, 0x198(%r12)
movq 0x100(%rdi), %rax
addq %rax, 0x1a0(%r12)
xorl %esi, %esi
callq 0x396ea
addq %rax, 0x1a8(%r12)
movq (%rbx,%r14,8), %rdi
callq 0x395cd
incq %r14
movslq 0x7c(%r12), %rax
cmpq %rax, %r14
jl 0x3b3d1
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