// File: 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
movq %rsp, %rbp
subq $0x40, %rsp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
leaq 0x3add03(%rip), %rax    # 0x3c54e8
movq $0x0, (%rax)
leaq 0x3adced(%rip), %rax    # 0x3c54e0
movq $0x0, (%rax)
leaq 0x3acff7(%rip), %rax    # 0x3c47f8
movslq 0x7c(%rax), %rdi
movl $0x8, %esi
callq 0x2140
movq %rax, -0x20(%rbp)
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
leaq 0x3acfd4(%rip), %rcx    # 0x3c47f8
cmpl 0x7c(%rcx), %eax
jge 0x17869
movl -0x4(%rbp), %eax
leaq 0x3acfc5(%rip), %rcx    # 0x3c47f8
movl 0xf8(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
sete %al
andb $0x1, %al
movzbl %al, %esi
xorl %edx, %edx
movl %edx, %edi
callq 0x14c90
movq %rax, %rdx
movq -0x20(%rbp), %rax
movslq -0xc(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x1781a
leaq 0x3adc68(%rip), %rax    # 0x3c54d8
cmpq $0x0, (%rax)
je 0x17886
leaq 0x3acf7b(%rip), %rax    # 0x3c47f8
movl 0xd0(%rax), %eax
movl %eax, -0x10(%rbp)
leaq 0x3adc4b(%rip), %rax    # 0x3c54d8
cmpq $0x0, (%rax)
jne 0x178f8
leaq 0x3adc36(%rip), %rax    # 0x3c54d0
movq (%rax), %rax
movq %rax, -0x30(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x4(%rbp)
movb %al, -0x21(%rbp)
jne 0x178b6
cmpl $0x0, -0x8(%rbp)
sete %al
movb %al, -0x21(%rbp)
movq -0x30(%rbp), %rsi
movb -0x21(%rbp), %cl
movl $0x1, %edx
xorl %eax, %eax
testb $0x1, %cl
cmovnel %eax, %edx
leaq 0x3acf27(%rip), %rdi    # 0x3c47f8
xorl %ecx, %ecx
leaq 0x3ad9f6(%rip), %r8     # 0x3c52d0
leaq -0x10(%rbp), %r9
leaq -0x14(%rbp), %rax
movq %rax, (%rsp)
callq 0x18a180
movq %rax, %rcx
leaq 0x3adbe3(%rip), %rax    # 0x3c54d8
movq %rcx, (%rax)
leaq 0x3adbd1(%rip), %rax    # 0x3c54d0
cmpq $0x0, (%rax)
jne 0x17914
movl -0x10(%rbp), %esi
leaq 0x3acee9(%rip), %rdi    # 0x3c47f8
callq 0x3b60
movq $0x0, 0x3adb69(%rip) # 0x3c5488
movl -0x4(%rbp), %eax
leaq 0x3acecf(%rip), %rcx    # 0x3c47f8
movl 0xf8(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x1795e
leaq 0x3acebb(%rip), %rax    # 0x3c47f8
cmpb $0x0, 0x248(%rax)
je 0x1795e
movq 0x3ad9d3(%rip), %rdi    # 0x3c5320
movl $0x4, %esi
callq 0x2140
movq %rax, 0x3adb2a(%rip)    # 0x3c5488
leaq 0x3ace93(%rip), %rax    # 0x3c47f8
movl 0x7c(%rax), %edi
movq -0x20(%rbp), %rdx
movq 0x3ad9ad(%rip), %rcx    # 0x3c5320
leaq 0x186(%rip), %rsi       # 0x17b00
callq 0x16d710
leaq 0x3adb52(%rip), %rax    # 0x3c54d8
movq (%rax), %rdi
callq 0x187660
leaq 0x3adb43(%rip), %rax    # 0x3c54d8
movq $0x0, (%rax)
cmpq $0x0, 0x3adae4(%rip)    # 0x3c5488
je 0x179c9
movq 0x3adadb(%rip), %rdi    # 0x3c5488
callq 0x16930
movq 0x3adacf(%rip), %rdi    # 0x3c5488
callq 0x2210
movq $0x0, 0x3adabf(%rip) # 0x3c5488
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
leaq 0x3ace1e(%rip), %rcx    # 0x3c47f8
cmpl 0x7c(%rcx), %eax
jge 0x17ac3
movq -0x20(%rbp), %rax
movslq -0xc(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0xf0(%rax), %rcx
leaq 0x3acdfb(%rip), %rax    # 0x3c47f8
addq 0x190(%rax), %rcx
leaq 0x3acded(%rip), %rax    # 0x3c47f8
movq %rcx, 0x190(%rax)
movq -0x20(%rbp), %rax
movslq -0xc(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0xf8(%rax), %rcx
leaq 0x3acdcc(%rip), %rax    # 0x3c47f8
addq 0x198(%rax), %rcx
leaq 0x3acdbe(%rip), %rax    # 0x3c47f8
movq %rcx, 0x198(%rax)
movq -0x20(%rbp), %rax
movslq -0xc(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x100(%rax), %rcx
leaq 0x3acd9d(%rip), %rax    # 0x3c47f8
addq 0x1a0(%rax), %rcx
leaq 0x3acd8f(%rip), %rax    # 0x3c47f8
movq %rcx, 0x1a0(%rax)
movq -0x20(%rbp), %rax
movslq -0xc(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x15070
movq %rax, %rcx
leaq 0x3acd69(%rip), %rax    # 0x3c47f8
addq 0x1a8(%rax), %rcx
leaq 0x3acd5b(%rip), %rax    # 0x3c47f8
movq %rcx, 0x1a8(%rax)
movq -0x20(%rbp), %rax
movslq -0xc(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x14f00
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x179d0
movq -0x20(%rbp), %rdi
callq 0x2210
movl -0x10(%rbp), %ecx
leaq 0x3acd22(%rip), %rax    # 0x3c47f8
movl %ecx, 0xd0(%rax)
movl -0x14(%rbp), %ecx
leaq 0x3acd12(%rip), %rax    # 0x3c47f8
movl %ecx, 0xd4(%rax)
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)