// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/Assembly.cpp
// Function: ha_assemble_pair()
int ha_assemble_pair(void)
{
	extern void ha_extract_print_list(const All_reads *rs, int n_rounds, const char *o);
	int r = 0, hom_cov = -1, ovlp_loaded = 0; memset((&R_INF), 0, sizeof(R_INF));

	if (asm_opt.load_index_from_disk && load_all_data_from_disk(&R_INF.paf, &R_INF.reverse_paf, asm_opt.output_file_name)) {
		ovlp_loaded = 1;
		fprintf(stderr, "[M::%s::%.3f*%.2f] ==> loaded corrected reads and overlaps from disk\n", __func__, yak_realtime(), yak_cpu_usage());
		if (asm_opt.extract_list) {
			ha_extract_print_list(&R_INF, asm_opt.extract_iter, asm_opt.extract_list);
			exit(0);
		}
		if (asm_opt.flag & HA_F_WRITE_EC) Output_corrected_reads();
		if (asm_opt.flag & HA_F_WRITE_PAF) Output_PAF();
        if (asm_opt.het_cov == -1024) hap_recalculate_peaks(asm_opt.output_file_name), ovlp_loaded = 2;
	}


	if (!ovlp_loaded) {
        
        if(!append_All_reads(&R_INF, asm_opt.output_file_name, 0)) {
            fprintf(stderr, "[M::%s::] Cannot load %s.0\n", __func__, asm_opt.output_file_name); 
            exit(1);
        }

        if(!append_All_reads(&R_INF, asm_opt.output_file_name, 1)) {
            fprintf(stderr, "[M::%s::] Cannot load %s.1\n", __func__, asm_opt.output_file_name); 
            exit(1);
        }
        // Output_corrected_reads(); exit(0);

        ha_flt_tab = ha_idx = NULL; r = asm_opt.number_of_round - 1;
        if((asm_opt.flag & HA_F_VERBOSE_GFA)) load_pt_index(&ha_flt_tab, &ha_idx, &R_INF, &asm_opt, asm_opt.output_file_name), load_ct_index(&ha_ct_table, asm_opt.output_file_name);

        // construct hash table for high occurrence k-mers
        if (!(asm_opt.flag & HA_F_NO_KMER_FLT) && ha_flt_tab == NULL) {
            ha_flt_tab = ha_ft_gen(&asm_opt, &R_INF, &hom_cov, 0, 1);
            ha_opt_update_cov(&asm_opt, hom_cov);
        }
        // error correction
        assert(asm_opt.number_of_round > 0);
        ha_opt_reset_to_round(&asm_opt, r); // this update asm_opt.roundID and a few other fields
        ha_overlap_cal(r, 1);
        fprintf(stderr, "[M::%s] size of buffer: %.3fGB\n", __func__, asm_opt.mem_buf / 1073741824.0);
        fprintf(stderr, "[M::%s::%.3f*%.2f@%.3fGB] ==> found overlaps for the final round\n", __func__, yak_realtime(),
				yak_cpu_usage(), yak_peakrss_in_gb());
        

        if (asm_opt.flag & HA_F_WRITE_EC) Output_corrected_reads();
        ha_print_ovlp_stat(R_INF.paf, R_INF.reverse_paf, R_INF.total_reads);
        ha_ft_destroy(ha_flt_tab);
        if (asm_opt.flag & HA_F_WRITE_PAF) Output_PAF();
        ha_triobin(&asm_opt);

	}
    if(ovlp_loaded == 2) ovlp_loaded = 0;
    ha_opt_update_cov_min(&asm_opt, asm_opt.hom_cov, MIN_N_CHAIN);

    build_string_graph_without_clean(asm_opt.min_overlap_coverage, R_INF.paf, R_INF.reverse_paf, 
        R_INF.total_reads, R_INF.read_length, asm_opt.min_overlap_Len, asm_opt.max_hang_Len, asm_opt.clean_round, 
        asm_opt.gap_fuzz, asm_opt.min_drop_rate, asm_opt.max_drop_rate, asm_opt.output_file_name, asm_opt.large_pop_bubble_size, 0, !ovlp_loaded);
	destory_All_reads(&R_INF);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movl $0xffffffff, 0x8(%rsp)  # imm = 0xFFFFFFFF
leaq 0x25a36e(%rip), %rdi    # 0x296230
movl $0x88, %edx
xorl %esi, %esi
callq 0x20e0
leaq 0x259883(%rip), %rbx    # 0x295758
cmpl $0x0, 0xf0(%rbx)
je 0x3befd
movq 0x10(%rbx), %rdx
leaq 0x25a3bf(%rip), %rdi    # 0x2962a8
leaq 0x25a3c0(%rip), %rsi    # 0x2962b0
callq 0xe1530
testl %eax, %eax
jne 0x3bfe9
movq 0x10(%rbx), %rsi
leaq 0x25a328(%rip), %rdi    # 0x296230
xorl %edx, %edx
callq 0x3236e
testl %eax, %eax
je 0x3c097
movq 0x10(%rbx), %rsi
leaq 0x25a30e(%rip), %rdi    # 0x296230
movl $0x1, %edx
callq 0x3236e
testl %eax, %eax
je 0x3c09c
leaq 0x25a4fd(%rip), %rax    # 0x296438
xorl %ecx, %ecx
movq %rcx, (%rax)
leaq 0x25a4e9(%rip), %r14    # 0x296430
movq %rcx, (%r14)
movl (%rbx), %eax
movl 0xf8(%rbx), %ebp
movb $0x1, %cl
testb $0x4, %al
je 0x3bf8e
movq 0x10(%rbx), %r8
leaq 0x25a4d5(%rip), %rsi    # 0x296438
leaq 0x25a2c6(%rip), %rdx    # 0x296230
movq %r14, %rdi
movq %rbx, %rcx
callq 0x11b1e8
movq 0x10(%rbx), %rsi
leaq 0x25a4d0(%rip), %rdi    # 0x296450
callq 0x11ad58
movl (%rbx), %eax
cmpq $0x0, (%r14)
sete %cl
testb $0x2, %al
jne 0x3bfcb
testb %cl, %cl
je 0x3bfcb
leaq 0x2597bb(%rip), %r15    # 0x295758
leaq 0x25a28c(%rip), %rsi    # 0x296230
leaq 0x8(%rsp), %r12
movq %r15, %rdi
movq %r12, %rdx
xorl %ecx, %ecx
movl $0x1, %r8d
callq 0x1390f
movq %rax, (%r14)
movl (%r12), %esi
movq %r15, %rdi
callq 0x2f59
cmpl $0x0, 0xf8(%rbx)
jle 0x3c0a1
decl %ebp
movl %ebp, %edi
callq 0x4bac
movl $0x1, %r15d
jmp 0x3bff9
leaq 0xc(%rsp), %r14
movq %r14, %rdi
callq 0x4b04
movl (%r14), %r15d
movl 0xd0(%rbx), %esi
movq %rbx, %rdi
movl $0x64, %edx
callq 0x2fa8
movl 0x118(%rbx), %edi
leaq 0x25a217(%rip), %r14    # 0x296230
movq 0x25a288(%rip), %rsi    # 0x2962a8
movq 0x25a289(%rip), %rdx    # 0x2962b0
movq 0x25a252(%rip), %rcx    # 0x296280
movq 0x25a213(%rip), %r8     # 0x296248
movslq 0x114(%rbx), %r9
movslq 0x10c(%rbx), %rax
movslq 0x104(%rbx), %r10
movslq 0x110(%rbx), %r11
movss 0x15c(%rbx), %xmm0
movss 0x160(%rbx), %xmm1
subq $0x8, %rsp
pushq %r15
pushq $0x0
pushq 0x188(%rbx)
pushq 0x10(%rbx)
pushq %r11
pushq %r10
pushq %rax
callq 0x104e53
addq $0x40, %rsp
movq %r14, %rdi
callq 0x31ca8
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq 0x4cd1
callq 0x4c9e
leaq 0x1f4e4d(%rip), %rdi    # 0x230ef5
leaq 0x1f4e62(%rip), %rsi    # 0x230f11
leaq 0x1f5009(%rip), %rcx    # 0x2310bf
movl $0x878, %edx            # imm = 0x878
callq 0x2110