// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/inter.cpp
// Function: gen_trans_base_count_mmhap_comp_rmap(ug_trans_t*, kv_u_trans_t*)
void gen_trans_base_count_mmhap_comp_rmap(ug_trans_t *p, kv_u_trans_t *res)
{
	double index_time = yak_realtime();
	uint64_t i, k, l, occ, m, cc; 
	p->ccov = gen_ug_rid_cov_t(p->ug, p->rg, p->uopt->sources);
	clean_u_trans_t_idx_adv(res, p->ug, p->rg); p->filter = res;

	p->is_cnt = 1; p->is_ovlp = 0; 
	memset(p->free_cnt, 0, sizeof((*(p->free_cnt)))*p->n_thread);
	kt_for(p->n_thread, worker_for_trans_ovlp_mmhap_adv, p, p->ug->u.n);
	for (i = l = 0; i < p->ug->u.n; i++) {
		occ = p->idx_n.a[i]; p->idx_n.a[i] = l; l += occ;
	}

	p->idx_n.a[i] = l;
	p->idx_a.n = p->idx_a.m = l; MALLOC(p->idx_a.a, p->idx_a.n);
	p->is_cnt = 0; p->is_ovlp = 0; 
	memset(p->free_cnt, 0, sizeof((*(p->free_cnt)))*p->n_thread);
	kt_for(p->n_thread, worker_for_trans_ovlp_mmhap_adv, p, p->ug->u.n);
	p->srt_a.n = p->srt_a.m = p->idx_a.n; MALLOC(p->srt_a.a, p->srt_a.n);
	
	for (i = 0; i < p->srt_a.n; i++) {
		p->srt_a.a[i] = p->idx_a.a[i];
		p->srt_a.a[i].pos = (uint32_t)i;
		p->srt_a.a[i].rid = i>>32;
	}
	radix_sort_ha_mzl_t_srt(p->srt_a.a, p->srt_a.a + p->srt_a.n);
	kvec_t(uint64_t) cut; kv_init(cut);
	for (k = 1, l = 0; k <= p->srt_a.n; k++) {
		if(k == p->srt_a.n || p->srt_a.a[l].x != p->srt_a.a[k].x) {
			for (i = l; i < k; i++) {
				m = p->srt_a.a[i].rid; m <<= 32; m |= p->srt_a.a[i].pos;
				assert(p->srt_a.a[i].x == p->idx_a.a[m].x);
				p->srt_a.a[i] = p->idx_a.a[m]; p->idx_a.a[m].x = i;
			}
			kv_push(uint64_t, cut, (k - l));
			l = k;
		}
	}

	if(cut.n > 0) {
		radix_sort_gfa64(cut.a, cut.a + cut.n);
		m = cut.n * 0.0002; cc = cut.a[cut.n-1] + 1;
		if(m > 0 && m <= cut.n) cc = cut.a[cut.n-m] + 1;
		if(cc < (uint64_t)p->mini_cut) p->mini_cut = cc;
	}
	kv_destroy(cut);
	
	p->is_cnt = 0; p->is_ovlp = 1; 
	memset(p->free_cnt, 0, sizeof((*(p->free_cnt)))*p->n_thread);
	kt_for(p->n_thread, worker_for_trans_ovlp_mmhap_adv, p, p->ug->u.n);

	clean_trans_base_count_mmhap_comp_rmap(p, res);

	for (i = 0; (int64_t)i < p->n_thread; i++) p->ll[i].tk.n = 0;

	p->is_cnt = 0; p->is_ovlp = 1; 
	memset(p->free_cnt, 0, sizeof((*(p->free_cnt)))*p->n_thread);
	kt_for(p->n_thread, worker_for_trans_chain_mmhap_adv, p, p->ug->u.n);





	for (i = 0; (int64_t)i < p->n_thread; i++) {
		ha_ovec_destroy(p->hab[i]);
		free(p->ll[i].lo.a); free(p->ll[i].srt.a.a); free(p->ll[i].tc.a);
	}
	free(p->idx_a.a); free(p->idx_n.a); free(p->hab); free(p->free_cnt);
	destory_ug_rid_cov_t(p->ccov); free(p->ccov);






	



	for (i = 0; (int64_t)i < p->n_thread; i++) free(p->ll[i].tk.a);
	free(p->srt_a.a); free(p->ll);
	fprintf(stderr, "[M::%s::%.3f] ==> Qualification\n", __func__, yak_realtime()-index_time);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r14
movq %rdi, %rbx
callq 0x1303c7
movsd %xmm0, 0x10(%rsp)
movq (%rbx), %rax
movq 0x8(%rbx), %rdi
movq 0x10(%rbx), %rsi
movq 0x8(%rax), %rdx
callq 0xc610d
movq %rax, 0x108(%rbx)
movq 0x8(%rbx), %rsi
movq 0x10(%rbx), %rdx
movq %r14, %rdi
callq 0xc3b24
movq %r14, 0x8(%rsp)
movq %r14, 0xf8(%rbx)
movq $0x1, 0xb4(%rbx)
movq 0x100(%rbx), %rdi
movslq 0xb0(%rbx), %rdx
shlq $0x2, %rdx
xorl %r14d, %r14d
xorl %esi, %esi
callq 0x20e0
movl 0xb0(%rbx), %edi
movq 0x8(%rbx), %rax
movq (%rax), %rcx
leaq 0x4c8(%rip), %rsi       # 0x1df838
movq %rbx, %rdx
callq 0x1047b4
movq 0x8(%rbx), %rcx
cmpq $0x0, (%rcx)
jne 0x1df386
xorl %eax, %eax
jmp 0x1df3a7
movq 0x88(%rbx), %rdx
xorl %eax, %eax
xorl %esi, %esi
movq (%rdx,%rax,8), %r14
addq %rsi, %r14
movq %rsi, (%rdx,%rax,8)
incq %rax
movq %r14, %rsi
cmpq (%rcx), %rax
jb 0x1df391
movq 0x88(%rbx), %rcx
movq %r14, (%rcx,%rax,8)
movl %r14d, 0x6c(%rbx)
movl %r14d, 0x68(%rbx)
movl %r14d, %eax
shlq $0x3, %rax
leaq (%rax,%rax,2), %rdi
callq 0x2280
movq %rax, 0x70(%rbx)
movq $0x0, 0xb4(%rbx)
movq 0x100(%rbx), %rdi
movslq 0xb0(%rbx), %rdx
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x20e0
movl 0xb0(%rbx), %edi
movq 0x8(%rbx), %rax
movq (%rax), %rcx
leaq 0x432(%rip), %rsi       # 0x1df838
movq %rbx, %rdx
callq 0x1047b4
movl 0x68(%rbx), %r14d
movl %r14d, 0x94(%rbx)
movl %r14d, 0x90(%rbx)
leaq (,%r14,8), %rax
leaq (%rax,%rax,2), %rdi
callq 0x2280
movq %rax, 0x98(%rbx)
movabsq $0x100000000, %r9       # imm = 0x100000000
testq %r14, %r14
je 0x1df4a5
xorl %eax, %eax
xorl %ecx, %ecx
xorl %edx, %edx
movq 0x70(%rbx), %rsi
movq 0x98(%rbx), %rdi
movq 0x10(%rsi,%rcx), %r8
movq %r8, 0x10(%rdi,%rcx)
movupd (%rsi,%rcx), %xmm0
movupd %xmm0, (%rdi,%rcx)
movq 0x98(%rbx), %rsi
movl 0x8(%rsi,%rcx), %edi
addq %rax, %rdi
movq %rdi, 0x8(%rsi,%rcx)
movq 0x98(%rbx), %rsi
andq $-0x80000000, 0x8(%rsi,%rcx) # imm = 0x80000000
incq %rdx
movl 0x90(%rbx), %r14d
addq $0x18, %rcx
addq %r9, %rax
cmpq %r14, %rdx
jb 0x1df44d
movq 0x98(%rbx), %rdi
leaq (%r14,%r14,2), %rax
leaq (%rdi,%rax,8), %rsi
callq 0x19910c
movl 0x90(%rbx), %edx
xorl %r15d, %r15d
movl $0x0, %r13d
testq %rdx, %rdx
je 0x1df5b8
movl $0x1, %r14d
xorl %r13d, %r13d
xorl %eax, %eax
xorl %r15d, %r15d
xorl %ecx, %ecx
cmpq %rdx, %r14
je 0x1df503
movq 0x98(%rbx), %rdx
leaq (%rcx,%rcx,2), %rsi
movq (%rdx,%rsi,8), %rsi
leaq (%r14,%r14,2), %rdi
cmpq (%rdx,%rdi,8), %rsi
je 0x1df5a2
movq %r14, %rbp
subq %rcx, %rbp
jbe 0x1df56d
leaq (,%rcx,8), %rdx
leaq (%rdx,%rdx,2), %rdx
movq 0x70(%rbx), %rdi
movq 0x98(%rbx), %rsi
movq (%rsi,%rdx), %r9
movq 0x8(%rsi,%rdx), %r8
rolq $0x20, %r8
btrq $0x3f, %r8
leaq (%r8,%r8,2), %r8
cmpq (%rdi,%r8,8), %r9
jne 0x1df819
addq %rdx, %rsi
leaq (%rdi,%r8,8), %rdi
movq 0x10(%rdi), %r9
movq %r9, 0x10(%rsi)
movupd (%rdi), %xmm0
movupd %xmm0, (%rsi)
movq 0x70(%rbx), %rsi
movq %rcx, (%rsi,%r8,8)
incq %rcx
addq $0x18, %rdx
cmpq %rcx, %r14
jne 0x1df517
cmpq %rax, %r13
jne 0x1df598
leaq (%rax,%rax), %r12
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %r12
leaq (,%r12,8), %rsi
movq %r15, %rdi
callq 0x2370
movq %rax, %r15
movq %r12, %rax
movq %rbp, (%r15,%r13,8)
incq %r13
movq %r14, %rcx
leaq 0x1(%r14), %rsi
movl 0x90(%rbx), %edx
cmpq %rdx, %r14
movq %rsi, %r14
jb 0x1df4e1
testq %r13, %r13
je 0x1df646
leaq (%r15,%r13,8), %rsi
movq %r15, %rdi
callq 0x194fef
movq %r13, %xmm0
punpckldq 0x45c66(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x45c6e(%rip), %xmm0    # 0x225250
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x542ca(%rip), %xmm1    # 0x2338c0
cvttsd2si %xmm1, %rax
movq %rax, %rcx
subsd 0x45c62(%rip), %xmm1    # 0x225268
sarq $0x3f, %rcx
cvttsd2si %xmm1, %rdx
andq %rcx, %rdx
orq %rax, %rdx
leaq -0x1(%rdx), %rax
negq %rdx
cmpq %r13, %rax
movq $-0x1, %rax
cmovbq %rdx, %rax
addq %r13, %rax
movq (%r15,%rax,8), %rax
incq %rax
movslq 0xbc(%rbx), %rcx
cmpq %rcx, %rax
jae 0x1df646
movl %eax, 0xbc(%rbx)
movq %r15, %rdi
callq 0x2220
movabsq $0x100000000, %r14      # imm = 0x100000000
movq %r14, 0xb4(%rbx)
movq 0x100(%rbx), %rdi
movslq 0xb0(%rbx), %rdx
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x20e0
movl 0xb0(%rbx), %edi
movq 0x8(%rbx), %rax
movq (%rax), %rcx
leaq 0x1ac(%rip), %rsi       # 0x1df838
movq %rbx, %rdx
callq 0x1047b4
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
callq 0x1dee4d
movslq 0xb0(%rbx), %rdx
testq %rdx, %rdx
jle 0x1df6c8
movq 0x20(%rbx), %rax
addq $0x20, %rax
movq %rdx, %rcx
movq $0x0, (%rax)
addq $0x68, %rax
decq %rcx
jne 0x1df6b8
movq %r14, 0xb4(%rbx)
movq 0x100(%rbx), %rdi
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x20e0
movl 0xb0(%rbx), %edi
movq 0x8(%rbx), %rax
movq (%rax), %rcx
leaq 0x542(%rip), %rsi       # 0x1dfc37
movq %rbx, %rdx
callq 0x1047b4
cmpl $0x0, 0xb0(%rbx)
jle 0x1df755
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x18(%rbx), %rax
movq (%rax,%r15,8), %rdi
callq 0x395cd
movq 0x20(%rbx), %rax
movq (%rax,%r14), %rdi
callq 0x2220
movq 0x20(%rbx), %rax
movq 0x58(%rax,%r14), %rdi
callq 0x2220
movq 0x20(%rbx), %rax
movq 0x30(%rax,%r14), %rdi
callq 0x2220
incq %r15
movslq 0xb0(%rbx), %rax
addq $0x68, %r14
cmpq %rax, %r15
jl 0x1df70c
movq 0x70(%rbx), %rdi
callq 0x2220
movq 0x88(%rbx), %rdi
callq 0x2220
movq 0x18(%rbx), %rdi
callq 0x2220
movq 0x100(%rbx), %rdi
callq 0x2220
movq 0x108(%rbx), %rdi
callq 0xc637e
movq 0x108(%rbx), %rdi
callq 0x2220
cmpl $0x0, 0xb0(%rbx)
jle 0x1df7c9
movl $0x18, %r14d
xorl %r15d, %r15d
movq 0x20(%rbx), %rax
movq (%rax,%r14), %rdi
callq 0x2220
incq %r15
movslq 0xb0(%rbx), %rax
addq $0x68, %r14
cmpq %rax, %r15
jl 0x1df7a9
movq 0x98(%rbx), %rdi
callq 0x2220
movq 0x20(%rbx), %rdi
callq 0x2220
movq 0xaa7fb(%rip), %rax     # 0x289fe0
movq (%rax), %rbx
callq 0x1303c7
subsd 0x10(%rsp), %xmm0
leaq 0x50a69(%rip), %rsi     # 0x230263
leaq 0x591d0(%rip), %rdx     # 0x2389d1
movq %rbx, %rdi
movb $0x1, %al
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x22b0
leaq 0x58ff2(%rip), %rdi     # 0x238812
leaq 0x54164(%rip), %rsi     # 0x23398b
leaq 0x5915b(%rip), %rcx     # 0x238989
movl $0x5777, %edx           # imm = 0x5777
callq 0x2110