// File: 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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
shlq $0x4, %rax
movq -0x8(%rbp), %rcx
movq 0x98(%rcx), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x12148(%rax), %rax
shlq $0x2, %rax
addq -0x28(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x12168(%rax), %rax
shlq $0x3, %rax
addq -0x28(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x12188(%rax), %rax
shlq $0x0, %rax
addq -0x28(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x12258(%rax), %rax
shlq $0x3, %rax
addq -0x28(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movl 0x121e4(%rax), %eax
shlq $0x3, %rax
addq -0x28(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x121e8(%rax), %rax
shlq $0x5, %rax
addq -0x28(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x12200(%rax), %rax
shlq %rax
addq -0x28(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
imulq $0xa8, 0xa8(%rax), %rax
movq %rax, -0x30(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq 0xa8(%rcx), %rax
jge 0x1520f
movq -0x8(%rbp), %rax
movq 0xa0(%rax), %rax
imulq $0xa8, -0x18(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq 0x48(%rax), %rax
shlq $0x5, %rax
movq -0x48(%rbp), %rcx
movq 0x60(%rcx), %rcx
shlq %rcx
addq %rcx, %rax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x48(%rbp), %rax
movl 0x44(%rax), %eax
shll $0x3, %eax
movl %eax, %eax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x48(%rbp), %rax
movq 0x78(%rax), %rax
shlq $0x5, %rax
movq -0x48(%rbp), %rcx
movq 0x90(%rcx), %rcx
shlq %rcx
addq %rcx, %rax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x15174
movq -0x8(%rbp), %rax
imulq $0xa8, 0xc8(%rax), %rax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq 0xc8(%rcx), %rax
jge 0x152c9
movq -0x8(%rbp), %rax
movq 0xc0(%rax), %rax
imulq $0xa8, -0x18(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq 0x48(%rax), %rax
shlq $0x5, %rax
movq -0x50(%rbp), %rcx
movq 0x60(%rcx), %rcx
shlq %rcx
addq %rcx, %rax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x50(%rbp), %rax
movl 0x44(%rax), %eax
shll $0x3, %eax
movl %eax, %eax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x50(%rbp), %rax
movq 0x78(%rax), %rax
shlq $0x5, %rax
movq -0x50(%rbp), %rcx
movq 0x90(%rcx), %rcx
shlq %rcx
addq %rcx, %rax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x1522e
movq -0x8(%rbp), %rax
cmpq $0x0, 0xe0(%rax)
je 0x152ef
movq -0x8(%rbp), %rax
movq 0xe0(%rax), %rdi
callq 0x1a06d0
addq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0xe8(%rax)
je 0x15315
movq -0x8(%rbp), %rax
movq 0xe8(%rax), %rdi
callq 0x1a0880
addq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x1541e
movq -0x8(%rbp), %rax
movq 0x138(%rax), %rax
addq $0x40, %rax
movq -0x8(%rbp), %rcx
movq 0x118(%rcx), %rcx
shlq $0x2, %rcx
addq %rcx, %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x300(%rax), %rax
shlq $0x3, %rax
addq $0x8d80, %rax           # imm = 0x8D80
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x120c0(%rax), %rax
shlq $0x2, %rax
addq $0x8e10, %rax           # imm = 0x8E10
movq -0x8(%rbp), %rcx
movq 0x12100(%rcx), %rcx
shlq $0x2, %rcx
addq %rcx, %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movl 0x9054(%rax), %eax
imulq $0x18, %rax, %rax
addq $0x2e8, %rax            # imm = 0x2E8
movq -0x8(%rbp), %rcx
movl 0x9218(%rcx), %ecx
addq %rcx, %rax
movq -0x8(%rbp), %rcx
movl 0x9228(%rcx), %ecx
addq %rcx, %rax
movq -0x8(%rbp), %rcx
imulq $0x28, 0x9268(%rcx), %rcx
addq %rcx, %rax
movq -0x8(%rbp), %rcx
movq 0x9280(%rcx), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
addq $0x148, %rdi            # imm = 0x148
callq 0x154b0
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
addq $0x200, %rdi            # imm = 0x200
callq 0x154b0
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
shlq $0x0, %rax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
shlq $0x0, %rax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x15488
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x38(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x40(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x20(%rbp), %rax
addq -0x28(%rbp), %rax
addq -0x30(%rbp), %rax
addq -0x38(%rbp), %rax
addq -0x40(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)