// File: /workspace/github_cpp_makefile_star2_O3/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, %r12
movq %rdi, %rbx
callq 0x1365ef
movq %xmm0, 0x8(%rsp)
movq (%rbx), %rax
movq 0x8(%rbx), %rdi
movq 0x10(%rbx), %rsi
movq 0x8(%rax), %rdx
callq 0xc6eb8
movq %rax, 0x108(%rbx)
movq 0x8(%rbx), %rsi
movq 0x10(%rbx), %rdx
movq %r12, %rdi
callq 0xc49f6
movq %r12, 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 0x4d9(%rip), %rsi       # 0x1ea2d2
movq %rbx, %rdx
callq 0x108f2c
movq 0x8(%rbx), %rcx
movq 0x88(%rbx), %rax
cmpq $0x0, (%rcx)
jne 0x1e9e16
xorl %edx, %edx
jmp 0x1e9e30
xorl %edx, %edx
xorl %esi, %esi
movq (%rax,%rdx,8), %r14
addq %rsi, %r14
movq %rsi, (%rax,%rdx,8)
incq %rdx
movq %r14, %rsi
cmpq (%rcx), %rdx
jb 0x1e9e1a
movq %r14, (%rax,%rdx,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 %r14d, %r14d
xorl %esi, %esi
callq 0x20e0
movl 0xb0(%rbx), %edi
movq 0x8(%rbx), %rax
movq (%rax), %rcx
leaq 0x447(%rip), %rsi       # 0x1ea2d2
movq %rbx, %rdx
callq 0x108f2c
movl 0x68(%rbx), %r15d
movl %r15d, 0x94(%rbx)
movl %r15d, 0x90(%rbx)
leaq (,%r15,8), %rax
leaq (%rax,%rax,2), %rdi
callq 0x2280
movq %rax, 0x98(%rbx)
movabsq $0x100000000, %r13      # imm = 0x100000000
testq %r15, %r15
je 0x1e9f31
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)
movdqu (%rsi,%rcx), %xmm0
movdqu %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 %r13, %rax
cmpq %r14, %rdx
jb 0x1e9ed2
movq 0x98(%rbx), %rax
leaq (%r14,%r14,2), %rcx
leaq (%rax,%rcx,8), %rsi
movq %rax, %rdi
callq 0x1a1df3
movl 0x90(%rbx), %esi
testq %rsi, %rsi
jne 0x1e9f53
xorl %edi, %edi
jmp 0x1ea060
movq %r12, (%rsp)
movl $0x1, %ebp
xorl %r15d, %r15d
movl %esi, %edx
xorl %r14d, %r14d
xorl %eax, %eax
xorl %ecx, %ecx
cmpq %rsi, %rbp
je 0x1e9f91
movq 0x98(%rbx), %rsi
leaq (%rcx,%rcx,2), %rdi
movq (%rsi,%rdi,8), %rdi
leaq (,%rbp,2), %r8
addq %rbp, %r8
cmpq (%rsi,%r8,8), %rdi
je 0x1ea030
movq %rbp, %r12
subq %rcx, %r12
jbe 0x1e9ffb
movq 0x70(%rbx), %rsi
leaq (,%rcx,8), %rdx
leaq (%rdx,%rdx,2), %rdx
movq 0x98(%rbx), %rdi
movq (%rdi,%rdx), %r9
movq 0x8(%rdi,%rdx), %r8
rolq $0x20, %r8
btrq $0x3f, %r8
leaq (%r8,%r8,2), %r8
cmpq (%rsi,%r8,8), %r9
jne 0x1ea2b3
addq %rdx, %rdi
leaq (%rsi,%r8,8), %rsi
movq 0x10(%rsi), %r9
movq %r9, 0x10(%rdi)
movdqu (%rsi), %xmm0
movdqu %xmm0, (%rdi)
movq 0x70(%rbx), %rsi
movq %rcx, (%rsi,%r8,8)
incq %rcx
addq $0x18, %rdx
cmpq %rcx, %rbp
jne 0x1e9fa9
cmpq %r14, %r15
jne 0x1ea020
leaq (%r15,%r15), %r14
testq %r15, %r15
movl $0x2, %ecx
cmoveq %rcx, %r14
leaq (,%r14,8), %rsi
movq %rax, %rdi
callq 0x2370
movq %r12, (%rax,%r15,8)
incq %r15
movl 0x90(%rbx), %edx
movq %rbp, %rcx
leaq 0x1(%rbp), %rdi
movl %edx, %esi
cmpq %rsi, %rbp
movq %rdi, %rbp
jb 0x1e9f68
leaq 0x10(%rsp), %r12
movq %r15, %rdi
movq %rax, %rsi
movq %rbx, %rdx
movq %r12, %rcx
callq 0x2a547
movq (%r12), %rdi
movq (%rsp), %r12
callq 0x2220
movq %r13, 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 0x239(%rip), %rsi       # 0x1ea2d2
movq %rbx, %rdx
callq 0x108f2c
movq %rbx, %rdi
movq %r12, %rsi
callq 0x1e98e0
movslq 0xb0(%rbx), %rdx
testq %rdx, %rdx
jle 0x1ea162
movq 0x20(%rbx), %rax
leal 0x1(%rdx), %ecx
leaq -0x1(%rdx), %rsi
movq %rsi, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
shrl %ecx
imulq $0xd0, %rcx, %rcx
movdqa 0x471ee(%rip), %xmm1    # 0x2312d0
xorl %esi, %esi
movdqa 0x471f4(%rip), %xmm2    # 0x2312e0
pxor %xmm2, %xmm0
pcmpeqd %xmm3, %xmm3
movdqa 0x47404(%rip), %xmm4    # 0x231500
movdqa %xmm1, %xmm5
pxor %xmm2, %xmm5
movdqa %xmm5, %xmm6
pcmpgtd %xmm0, %xmm6
pcmpeqd %xmm0, %xmm5
pshufd $0xf5, %xmm5, %xmm7     # xmm7 = xmm5[1,1,3,3]
pand %xmm6, %xmm7
pshufd $0xf5, %xmm6, %xmm5     # xmm5 = xmm6[1,1,3,3]
por %xmm7, %xmm5
movd %xmm5, %edi
notl %edi
testb $0x1, %dil
je 0x1ea137
movq $0x0, 0x20(%rax,%rsi)
pxor %xmm3, %xmm5
pextrw $0x4, %xmm5, %edi
testb $0x1, %dil
je 0x1ea152
movq $0x0, 0x88(%rax,%rsi)
paddq %xmm4, %xmm1
addq $0xd0, %rsi
cmpq %rsi, %rcx
jne 0x1ea0fc
movq %r13, 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 0x55c(%rip), %rsi       # 0x1ea6eb
movq %rbx, %rdx
callq 0x108f2c
cmpl $0x0, 0xb0(%rbx)
jle 0x1ea1ef
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x18(%rbx), %rax
movq (%rax,%r15,8), %rdi
callq 0x38b4b
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 0x1ea1a6
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 0xc7129
movq 0x108(%rbx), %rdi
callq 0x2220
cmpl $0x0, 0xb0(%rbx)
jle 0x1ea263
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 0x1ea243
movq 0x98(%rbx), %rdi
callq 0x2220
movq 0x20(%rbx), %rdi
callq 0x2220
movq 0xaad61(%rip), %rax     # 0x294fe0
movq (%rax), %rbx
callq 0x1365ef
subsd 0x8(%rsp), %xmm0
leaq 0x521db(%rip), %rsi     # 0x23c46f
leaq 0x5aa06(%rip), %rdx     # 0x244ca1
movq %rbx, %rdi
movb $0x1, %al
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x22b0
leaq 0x5a828(%rip), %rdi     # 0x244ae2
leaq 0x5599a(%rip), %rsi     # 0x23fc5b
leaq 0x5a991(%rip), %rcx     # 0x244c59
movl $0x5777, %edx           # imm = 0x5777
callq 0x2110