// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/Assembly.cpp
// Function: ha_ovec_mem(ha_ovec_buf_t const*, long*)
int64_t ha_ovec_mem(const ha_ovec_buf_t *b, int64_t *mem_a)
{
	int64_t i, mem_ab = 0, mem_clist, mem_olist, mem_hap = 0, mem_aux = 0;
	// mem_clist = b->clist.size * sizeof(k_mer_hit) + b->clist.chainDP.size * 7 * 4;
    mem_clist = (b->clist.size * sizeof(k_mer_hit)) + ((sizeof((*b->clist.chainDP.score)) + sizeof((*b->clist.chainDP.pre)) 
                    + sizeof((*b->clist.chainDP.indels)) + sizeof((*b->clist.chainDP.self_length)) 
                    + sizeof((*b->clist.chainDP.occ)) + sizeof((*b->clist.chainDP.tmp))) * b->clist.chainDP.size);
    mem_clist += sizeof(*(b->b_buf.a.a)) * b->b_buf.a.m;
    mem_clist += sizeof(*(b->r_buf.a.a)) * b->r_buf.a.m;
    mem_clist += sizeof(*(b->k_flag.a.a)) * b->k_flag.a.m;
    mem_clist += sizeof(*(b->sp.a)) * b->sp.m;
    mem_clist += sizeof(*(b->tmp_region.f_cigar.buffer)) * b->tmp_region.f_cigar.size;
    mem_clist += sizeof(*(b->tmp_region.w_list.a)) * b->tmp_region.w_list.n;
    mem_clist += sizeof(*(b->tmp_region.w_list.c.a)) * b->tmp_region.w_list.c.n;

	mem_olist = b->olist.size * sizeof(overlap_region);
	for (i = 0; i < (int64_t)b->olist.size; ++i) {
		const overlap_region *r = &b->olist.list[i];
		mem_olist += (r->w_list.n*sizeof(*(r->w_list.a))) + (r->w_list.c.n*sizeof(*(r->w_list.c.a)));
		mem_olist += r->f_cigar.size * 8;
		mem_olist += (r->boundary_cigars.n*sizeof(*(r->boundary_cigars.a))) 
                                    + (r->boundary_cigars.c.n*sizeof(*(r->boundary_cigars.c.a)));
	}

    mem_olist += b->olist_hp.size * sizeof(overlap_region);
	for (i = 0; i < (int64_t)b->olist_hp.size; ++i) {
		const overlap_region *r = &b->olist_hp.list[i];
		mem_olist += (r->w_list.n*sizeof(*(r->w_list.a))) + (r->w_list.c.n*sizeof(*(r->w_list.c.a)));
		mem_olist += r->f_cigar.size * 8;
		mem_olist += (r->boundary_cigars.n*sizeof(*(r->boundary_cigars.a))) 
                                    + (r->boundary_cigars.c.n*sizeof(*(r->boundary_cigars.c.a)));
	}

    if(b->ab) mem_ab += ha_abuf_mem(b->ab);
    if(b->abl) mem_ab += ha_abufl_mem(b->abl);

	if (!b->is_final) {
		mem_hap += sizeof(Cigar_record) + b->cigar1.lost_base_size + b->cigar1.size * 4;
		mem_hap += sizeof(Correct_dumy) + b->correct.size * 8;
		mem_hap += sizeof(Round2_alignment) + b->round2.cigar.size * 4 + b->round2.tmp_cigar.size * 4;
		mem_hap += sizeof(haplotype_evdience_alloc) + b->hap.size * sizeof(haplotype_evdience) + b->hap.snp_matrix_size + b->hap.r_snp_size + b->hap.snp_stat.m * sizeof(SnpStats) + b->hap.snp_srt.m * sizeof(uint64_t);
		mem_hap += ha_Graph_mem(&b->POA_Graph);
		mem_hap += ha_Graph_mem(&b->DAGCon);
	}
   

    mem_aux += sizeof(*(b->self_read.seq)) * b->self_read.size;
    mem_aux += sizeof(*(b->ovlp_read.seq)) * b->ovlp_read.size;

    if(mem_a) {
        mem_a[0] = mem_ab; mem_a[1] = mem_clist; mem_a[2] = mem_olist; 
        mem_a[3] = mem_hap; mem_a[4] = mem_aux;
    }

	return mem_ab + mem_clist + mem_olist + mem_hap + mem_aux;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %r14
movq 0x58(%rdi), %rax
movq 0xa8(%rdi), %rdx
shlq $0x4, %rax
movq 0x12148(%rdi), %rcx
imulq $0xa8, %rdx, %r9
testq %rdx, %rdx
movq %rsi, 0x30(%rsp)
jle 0x38cdc
movq 0xa0(%r14), %rdi
addq $0x44, %rdi
movl (%rdi), %r8d
shll $0x3, %r8d
addq %r9, %r8
movq 0x4c(%rdi), %rsi
addq 0x1c(%rdi), %rsi
movq 0x34(%rdi), %r9
addq 0x4(%rdi), %r9
shlq $0x5, %r9
addq %r8, %r9
leaq (%r9,%rsi,2), %r9
addq $0xa8, %rdi
decq %rdx
jne 0x38cab
movq 0x121e8(%r14), %r12
leaq (%rax,%rcx,4), %rbx
movq 0x12258(%r14), %r8
movq 0xc8(%r14), %rax
imulq $0xa8, %rax, %r13
addq %r9, %r13
testq %rax, %rax
jle 0x38d3e
movq 0xc0(%r14), %rcx
addq $0x44, %rcx
movl (%rcx), %edx
shll $0x3, %edx
addq %r13, %rdx
movq 0x4c(%rcx), %rsi
addq 0x1c(%rcx), %rsi
movq 0x34(%rcx), %rdi
addq 0x4(%rcx), %rdi
shlq $0x5, %rdi
addq %rdx, %rdi
leaq (%rdi,%rsi,2), %r13
addq $0xa8, %rcx
decq %rax
jne 0x38d0f
movl 0x121e4(%r14), %eax
movq %rax, 0x8(%rsp)
movq 0x12200(%r14), %rbp
addq 0x98(%r14), %r12
addq 0x12188(%r14), %rbx
addq 0x12168(%r14), %r8
movq %r8, 0x10(%rsp)
movq 0xe0(%r14), %rdi
testq %rdi, %rdi
je 0x38d81
callq 0x12892d
movq %rax, %r15
jmp 0x38d84
xorl %r15d, %r15d
shlq $0x5, %r12
leaq (%rbx,%rbp,2), %rbx
movq 0xe8(%r14), %rdi
testq %rdi, %rdi
je 0x38da0
callq 0x128a25
addq %rax, %r15
movq 0x10(%rsp), %rdx
addq 0x8(%rsp), %rdx
addq %r12, %rbx
cmpl $0x0, (%r14)
je 0x38dba
xorl %eax, %eax
jmp 0x38e75
movq 0x120c0(%r14), %r12
movl 0x9054(%r14), %eax
movl 0x9218(%r14), %ecx
leaq (%rax,%rax,2), %rbp
shlq $0x3, %rbp
movl 0x9228(%r14), %eax
movq %rax, 0x8(%rsp)
movq 0x9268(%r14), %rax
leaq (%rax,%rax,4), %rax
movq %rax, 0x20(%rsp)
movq 0x9280(%r14), %rax
addq 0x300(%r14), %rax
movq %rax, 0x28(%rsp)
addq 0x118(%r14), %r12
addq 0x12100(%r14), %r12
leaq 0x148(%r14), %rdi
addq 0x138(%r14), %rbp
addq %rcx, %rbp
movq %rdx, 0x10(%rsp)
callq 0x38ebc
movq %rax, 0x18(%rsp)
leaq 0x200(%r14), %rdi
callq 0x38ebc
movq 0x10(%rsp), %rdx
leaq (,%r12,4), %rcx
addq %rbp, %rcx
addq 0x8(%rsp), %rcx
movq 0x20(%rsp), %rsi
leaq (%rcx,%rsi,8), %rcx
addq 0x18(%rsp), %rax
addq %rcx, %rax
movq 0x28(%rsp), %rcx
leaq (%rax,%rcx,8), %rax
addq $0x11eb8, %rax          # imm = 0x11EB8
leaq (%rbx,%rdx,8), %rdx
movq 0x38(%r14), %rcx
addq 0x18(%r14), %rcx
movq 0x30(%rsp), %rsi
testq %rsi, %rsi
je 0x38e9e
movq %r15, (%rsi)
movq %rdx, 0x8(%rsi)
movq %r13, 0x10(%rsi)
movq %rax, 0x18(%rsi)
movq %rcx, 0x20(%rsi)
addq %rdx, %r13
addq %rax, %r15
addq %rcx, %r15
addq %r13, %r15
movq %r15, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq