// File: /workspace/github_cpp_makefile_star2_O2/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 $0x28, %rsp
movq %rsi, %r12
movq %rdi, %r14
movq 0x58(%rdi), %rax
movq 0xa8(%rdi), %rdx
shlq $0x4, %rax
movq 0x12148(%rdi), %rcx
movq 0x12258(%rdi), %r13
movl 0x121e4(%rdi), %esi
movq 0x121e8(%rdi), %rdi
addq 0x12168(%r14), %r13
movq 0x12200(%r14), %r8
addq %rsi, %r13
addq 0x98(%r14), %rdi
shlq $0x5, %rdi
leaq (%rax,%rcx,4), %rax
addq 0x12188(%r14), %rax
leaq (%rax,%r8,2), %rbp
addq %rdi, %rbp
imulq $0xa8, %rdx, %rax
xorl %ecx, %ecx
testq %rdx, %rdx
cmovgq %rdx, %rcx
pushq $0x44
popq %rdx
subq $0x1, %rcx
jb 0xc793
movq 0xa0(%r14), %rsi
movl (%rsi,%rdx), %edi
shll $0x3, %edi
movq 0x4c(%rsi,%rdx), %r8
addq 0x1c(%rsi,%rdx), %r8
movq 0x34(%rsi,%rdx), %r9
addq 0x4(%rsi,%rdx), %r9
shlq $0x5, %r9
addq %rdi, %rax
addq %r9, %rax
leaq (%rax,%r8,2), %rax
addq $0xa8, %rdx
jmp 0xc755
shlq $0x3, %r13
movq 0xc8(%r14), %rcx
imulq $0xa8, %rcx, %rbx
addq %rax, %rbx
xorl %eax, %eax
testq %rcx, %rcx
cmovgq %rcx, %rax
pushq $0x44
popq %rcx
subq $0x1, %rax
jb 0xc7f2
movq 0xc0(%r14), %rdx
movl (%rdx,%rcx), %esi
shll $0x3, %esi
movq 0x4c(%rdx,%rcx), %rdi
addq 0x1c(%rdx,%rcx), %rdi
movq 0x34(%rdx,%rcx), %r8
addq 0x4(%rdx,%rcx), %r8
shlq $0x5, %r8
addq %rsi, %rbx
addq %r8, %rbx
leaq (%rbx,%rdi,2), %rbx
addq $0xa8, %rcx
jmp 0xc7b4
movq 0xe0(%r14), %rdi
testq %rdi, %rdi
je 0xc808
callq 0xe39f1
movq %rax, %r15
jmp 0xc80b
xorl %r15d, %r15d
movq 0xe8(%r14), %rdi
testq %rdi, %rdi
je 0xc81f
callq 0xe3ada
addq %rax, %r15
cmpl $0x0, (%r14)
je 0xc82c
xorl %eax, %eax
jmp 0xc8e3
movq %rbp, 0x10(%rsp)
movq 0x120c0(%r14), %rbp
movl 0x9054(%r14), %eax
movl 0x9218(%r14), %ecx
movq %r13, 0x18(%rsp)
imulq $0x18, %rax, %r13
movl 0x9228(%r14), %eax
imulq $0x28, 0x9268(%r14), %rdx
addq %rax, %rdx
movq %rdx, (%rsp)
movq 0x9280(%r14), %rax
addq 0x300(%r14), %rax
movq %rax, 0x8(%rsp)
addq 0x118(%r14), %rbp
addq 0x12100(%r14), %rbp
leaq 0x148(%r14), %rdi
addq 0x138(%r14), %r13
addq %rcx, %r13
callq 0xc929
movq %r12, 0x20(%rsp)
movq %rax, %r12
leaq 0x200(%r14), %rdi
callq 0xc929
leaq (,%rbp,4), %rcx
addq %r13, %rcx
movq 0x10(%rsp), %rbp
movq 0x18(%rsp), %r13
addq (%rsp), %r12
addq %rax, %r12
addq %rcx, %r12
movq 0x8(%rsp), %rax
leaq (%r12,%rax,8), %rax
addq $0x11eb8, %rax          # imm = 0x11EB8
movq 0x20(%rsp), %r12
addq %r13, %rbp
movq 0x38(%r14), %rcx
addq 0x18(%r14), %rcx
testq %r12, %r12
je 0xc90b
movq %r15, (%r12)
movq %rbp, 0x8(%r12)
movq %rbx, 0x10(%r12)
movq %rax, 0x18(%r12)
movq %rcx, 0x20(%r12)
addq %rbp, %rbx
addq %rax, %r15
addq %rbx, %r15
addq %rcx, %r15
movq %r15, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq