// File: /workspace/github_cpp_makefile_star2_O2/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 0xefea7
movsd %xmm0, 0x10(%rsp)
movq (%rbx), %rax
movq 0x8(%rbx), %rdi
movq 0x10(%rbx), %rsi
movq 0x8(%rax), %rdx
callq 0x8a9be
movq %rax, 0x108(%rbx)
movq 0x8(%rbx), %rsi
movq 0x10(%rbx), %rdx
movq %r14, %rdi
callq 0x885ac
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 0x478(%rip), %rsi       # 0x19f2a9
movq %rbx, %rdx
callq 0xc67c0
movq 0x8(%rbx), %rcx
movq 0x88(%rbx), %rax
xorl %edx, %edx
cmpq (%rcx), %rdx
jae 0x19ee5e
movq (%rax,%rdx,8), %rsi
addq %r14, %rsi
movq %r14, (%rax,%rdx,8)
incq %rdx
movq %rsi, %r14
jmp 0x19ee46
movq %r14, (%rax,%rdx,8)
movl %r14d, 0x6c(%rbx)
movl %r14d, 0x68(%rbx)
movl %r14d, %eax
imulq $0x18, %rax, %rdi
callq 0x2280
movq %rax, 0x70(%rbx)
andq $0x0, 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 0x3f7(%rip), %rsi       # 0x19f2a9
movq %rbx, %rdx
callq 0xc67c0
movl 0x68(%rbx), %r15d
movl %r15d, 0x94(%rbx)
movl %r15d, 0x90(%rbx)
imulq $0x18, %r15, %rdi
callq 0x2280
movq %rax, 0x98(%rbx)
movabsq $0x100000000, %r8       # imm = 0x100000000
xorl %eax, %eax
xorl %ecx, %ecx
movl %r15d, %edx
cmpq %rdx, %rcx
jae 0x19ef47
movq 0x70(%rbx), %rdx
movq 0x98(%rbx), %rsi
movq 0x10(%rdx,%rax), %rdi
movq %rdi, 0x10(%rsi,%rax)
movupd (%rdx,%rax), %xmm0
movupd %xmm0, (%rsi,%rax)
movq 0x98(%rbx), %rdx
movl 0x8(%rdx,%rax), %esi
addq %r14, %rsi
movq %rsi, 0x8(%rdx,%rax)
movq 0x98(%rbx), %rdx
andq $-0x80000000, 0x8(%rdx,%rax) # imm = 0x80000000
incq %rcx
movl 0x90(%rbx), %r15d
addq $0x18, %rax
addq %r8, %r14
jmp 0x19eeea
movq 0x98(%rbx), %rdi
imulq $0x18, %rdx, %rsi
addq %rdi, %rsi
callq 0x15a8b9
pushq $0x1
popq %rbp
xorl %r14d, %r14d
xorl %r15d, %r15d
xorl %eax, %eax
xorl %r13d, %r13d
movl 0x90(%rbx), %ecx
cmpq %rcx, %rbp
ja 0x19f035
je 0x19ef96
movq 0x98(%rbx), %rcx
imulq $0x18, %r14, %rdx
movq (%rcx,%rdx), %rdx
imulq $0x18, %rbp, %rsi
cmpq (%rcx,%rsi), %rdx
je 0x19f02d
imulq $0x18, %r14, %rcx
movq %r14, %rdx
cmpq %rbp, %rdx
jae 0x19eff4
movq 0x70(%rbx), %rdi
movq 0x98(%rbx), %rsi
movq (%rsi,%rcx), %r9
movq 0x8(%rsi,%rcx), %r8
rolq $0x20, %r8
btrq $0x3f, %r8
imulq $0x18, %r8, %r8
cmpq (%rdi,%r8), %r9
jne 0x19f28a
addq %rcx, %rsi
addq %r8, %rdi
movq 0x10(%rdi), %r9
movq %r9, 0x10(%rsi)
movupd (%rdi), %xmm0
movupd %xmm0, (%rsi)
movq 0x70(%rbx), %rsi
movq %rdx, (%rsi,%r8)
incq %rdx
addq $0x18, %rcx
jmp 0x19ef9d
cmpq %rax, %r13
jne 0x19f01d
leaq (%rax,%rax), %r12
testq %rax, %rax
pushq $0x2
popq %rax
cmoveq %rax, %r12
leaq (,%r12,8), %rsi
movq %r15, %rdi
callq 0x2370
movq %rax, %r15
movq %r12, %rax
movq %rbp, %rcx
subq %r14, %rcx
movq %rcx, (%r15,%r13,8)
incq %r13
movq %rbp, %r14
incq %rbp
jmp 0x19ef68
testq %r13, %r13
je 0x19f0bf
leaq (%r15,%r13,8), %rsi
movq %r15, %rdi
callq 0x156b0d
movq %r13, %xmm0
punpckldq 0x44219(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x44221(%rip), %xmm0    # 0x1e3280
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x529ed(%rip), %xmm1    # 0x1f1a60
cvttsd2si %xmm1, %rax
movq %rax, %rcx
subsd 0x44215(%rip), %xmm1    # 0x1e3298
sarq $0x3f, %rcx
cvttsd2si %xmm1, %rdx
andq %rcx, %rdx
orq %rax, %rdx
leaq -0x1(%rdx), %rax
negq %rdx
cmpq %r13, %rax
pushq $-0x1
popq %rax
cmovbq %rdx, %rax
addq %r13, %rax
movq (%r15,%rax,8), %rax
incq %rax
movslq 0xbc(%rbx), %rcx
cmpq %rcx, %rax
jae 0x19f0bf
movl %eax, 0xbc(%rbx)
movq %r15, %rdi
callq 0x2220
movabsq $0x100000000, %r15      # imm = 0x100000000
movq %r15, 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 0x1a1(%rip), %rsi       # 0x19f2a9
movq %rbx, %rdx
callq 0xc67c0
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
callq 0x19e9fc
movslq 0xb0(%rbx), %rdx
testq %rdx, %rdx
movl $0x0, %eax
cmovgq %rdx, %rax
imulq $0x68, %rax, %rax
cmpq %r14, %rax
je 0x19f149
movq 0x20(%rbx), %rcx
andq $0x0, 0x20(%rcx,%r14)
addq $0x68, %r14
jmp 0x19f134
movq %r15, 0xb4(%rbx)
movq 0x100(%rbx), %rdi
shlq $0x2, %rdx
xorl %r14d, %r14d
xorl %esi, %esi
callq 0x20e0
movl 0xb0(%rbx), %edi
movq 0x8(%rbx), %rax
movq (%rax), %rcx
leaq 0x538(%rip), %rsi       # 0x19f6b1
movq %rbx, %rdx
callq 0xc67c0
xorl %r15d, %r15d
movslq 0xb0(%rbx), %rax
cmpq %rax, %r15
jge 0x19f1cf
movq 0x18(%rbx), %rax
movq (%rax,%r15,8), %rdi
callq 0xc5d1
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
addq $0x68, %r14
jmp 0x19f184
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 0x8abfa
movq 0x108(%rbx), %rdi
callq 0x2220
pushq $0x18
popq %r14
xorl %r15d, %r15d
movslq 0xb0(%rbx), %rax
cmpq %rax, %r15
jge 0x19f23a
movq 0x20(%rbx), %rax
movq (%rax,%r14), %rdi
callq 0x2220
incq %r15
addq $0x68, %r14
jmp 0x19f218
movq 0x98(%rbx), %rdi
callq 0x2220
movq 0x20(%rbx), %rdi
callq 0x2220
movq 0xb3d8a(%rip), %rax     # 0x252fe0
movq (%rax), %rbx
callq 0xefea7
subsd 0x10(%rsp), %xmm0
leaq 0x4f0f4(%rip), %rsi     # 0x1ee35f
leaq 0x578f7(%rip), %rdx     # 0x1f6b69
movq %rbx, %rdi
movb $0x1, %al
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x22b0
leaq 0x57719(%rip), %rdi     # 0x1f69aa
leaq 0x5288b(%rip), %rsi     # 0x1f1b23
leaq 0x57882(%rip), %rcx     # 0x1f6b21
movl $0x5777, %edx           # imm = 0x5777
callq 0x2110