// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/inter.cpp
// Function: clean_trans_base_count_mmhap_comp_rmap(ug_trans_t*, kv_u_trans_t*)
void clean_trans_base_count_mmhap_comp_rmap(ug_trans_t *p, kv_u_trans_t *res)
{
	uint64_t i, k, l, occ, idx_n; ha_mzl_t *tz; u_trans_t *z; 
	kv_ul_ov_t *bl; double ww; ha_mzl_t *idx; 
	///make results consistent
	kv_resize(ha_mzl_t, p->srt_a, p->srt_a.n+p->ug->u.n); 
	idx = p->srt_a.a + p->srt_a.n; idx_n = p->ug->u.n;
	for (i = 0; i < idx_n; i++) {
		tz = &(idx[i]);
		tz->x = (uint64_t)-1; tz->rev = 0;
		tz->pos = tz->rid = tz->span = 0;
	}

	for (i = 0, occ = res->n; (int64_t)i < p->n_thread; i++) {
		bl = &(p->ll[i].tk); 
		if(!(bl->n)) continue;
		for (k = 1, l = 0; k <= bl->n; k++) {
			if(k == bl->n || bl->a[k].qn != bl->a[l].qn) {
				if(k > l) {
					tz = &(idx[bl->a[l].qn]);
					tz->x = bl->a[l].qn; tz->x <<= 32; tz->x |= i;
					tz->rid = l>>32; tz->pos = (uint32_t)l; tz->rev = 1;
					occ += (k - l);
				}
				l = k;
			}
		}
	}

	kv_resize(u_trans_t, *res, occ); 
	for (i = 0; i < idx_n; i++) {
		tz = &(idx[i]);
		if(!(tz->rev)) continue;
		bl = &(p->ll[(uint32_t)(tz->x)].tk);
		k = tz->rid; k <<= 32; k += tz->pos;
		assert(bl->a[k].qn == (tz->x>>32));
		for (; (k < bl->n) && (bl->a[k].qn == (tz->x>>32)); k++) {
			if(bl->a[k].qn == bl->a[k].tn) continue;
			ww = cal_trans_ov_w(&(bl->a[k])); 
			if(ww <= 0) continue;
			
			kv_pushp(u_trans_t, *res, &z);
			z->f = RC_3; z->rev = bl->a[k].rev; z->del = 0; 
			z->qn = bl->a[k].qn; z->qs = bl->a[k].qs; z->qe = bl->a[k].qe;
			z->tn = bl->a[k].tn; z->ts = bl->a[k].ts; z->te = bl->a[k].te;
			z->nw = ww;
		}
	}
	destory_ug_rid_cov_t(p->ccov); free(p->ccov); 
	p->ccov = gen_ug_rid_cov_t(p->ug, p->rg, p->uopt->sources);

	clean_u_trans_t_idx_filter_mmhap_adv(res, p->ug, p->rg, p->uopt->sources, p->ccov);
	gen_ug_rid_cov_t_by_ovlp(res, p->ccov);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %rbx
movq %rdi, %r13
movl 0x94(%rdi), %edx
movl 0x90(%rdi), %ecx
movq 0x8(%rdi), %rax
movq (%rax), %rsi
leaq (%rsi,%rcx), %rax
cmpq %rdx, %rax
jbe 0x19ea80
decl %eax
movl %eax, %ecx
shrl %ecx
orl %eax, %ecx
movl %ecx, %eax
shrl $0x2, %eax
orl %ecx, %eax
movl %eax, %ecx
shrl $0x4, %ecx
orl %eax, %ecx
movl %ecx, %eax
shrl $0x8, %eax
orl %ecx, %eax
movl %eax, %ecx
shrl $0x10, %ecx
orl %eax, %ecx
incl %ecx
movl %ecx, 0x94(%r13)
movq 0x98(%r13), %rdi
imulq $0x18, %rcx, %rsi
callq 0x2370
movq %rax, 0x98(%r13)
movl 0x90(%r13), %ecx
movq 0x8(%r13), %rdx
movq (%rdx), %rsi
jmp 0x19ea87
movq 0x98(%r13), %rax
imulq $0x18, %rcx, %rcx
leaq (%rax,%rcx), %r12
addq %rcx, %rax
addq $0x10, %rax
movq %rsi, %rcx
subq $0x1, %rcx
jb 0x19eab2
orq $-0x1, -0x10(%rax)
movb $0x0, (%rax)
andq $0x0, -0x8(%rax)
addq $0x18, %rax
jmp 0x19ea99
movq %rsi, 0x10(%rsp)
movq (%rbx), %rax
xorl %ecx, %ecx
pushq $0x1
popq %rdx
pushq $0x1c
popq %rsi
movslq 0xb0(%r13), %rdi
cmpq %rdi, %rcx
jge 0x19eb57
movq 0x20(%r13), %rdi
imulq $0x68, %rcx, %r8
movq 0x20(%rdi,%r8), %r11
testq %r11, %r11
je 0x19eb4f
addq %r8, %rdi
addq $0x18, %rdi
movq %rsi, %r8
xorl %r10d, %r10d
movq %rdx, %r9
cmpq %r11, %r9
ja 0x19eb4f
je 0x19eb0c
movq (%rdi), %r14
movl (%r14,%r8), %ebp
imulq $0x1c, %r10, %r15
cmpl (%r14,%r15), %ebp
je 0x19eb46
cmpq %r10, %r9
jbe 0x19eb43
movq (%rdi), %r11
imulq $0x1c, %r10, %r14
movl (%r11,%r14), %r11d
imulq $0x18, %r11, %r14
shlq $0x20, %r11
orq %rcx, %r11
movq %r11, (%r12,%r14)
subq %r10, %rax
rolq $0x20, %r10
btsq $0x1f, %r10
movq %r10, 0x8(%r12,%r14)
addq %r9, %rax
movq 0x8(%rdi), %r11
movq %r9, %r10
incq %r9
addq $0x1c, %r8
jmp 0x19eaf4
incq %rcx
jmp 0x19eac2
cmpq %rax, 0x8(%rbx)
jae 0x19eba9
decq %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x10, %rcx
orq %rax, %rcx
incq %rcx
movq %rcx, 0x8(%rbx)
movq 0x10(%rbx), %rdi
imulq $0x30, %rcx, %rsi
callq 0x2370
movq %rax, 0x10(%rbx)
xorl %eax, %eax
movq %r13, 0x8(%rsp)
cmpq 0x10(%rsp), %rax
je 0x19ed15
movq %rax, 0x20(%rsp)
imulq $0x18, %rax, %rbp
movq 0x8(%r12,%rbp), %rax
testl %eax, %eax
js 0x19ebdc
movq 0x20(%rsp), %rax
incq %rax
movq 0x8(%rsp), %r13
jmp 0x19ebb0
addq %r12, %rbp
movq 0x8(%rsp), %rcx
movq 0x20(%rcx), %rcx
movq (%rbp), %rsi
movl %esi, %edx
imulq $0x68, %rdx, %rdx
movq %rax, %r15
rolq $0x20, %r15
btrq $0x3f, %r15
movq 0x18(%rcx,%rdx), %rdi
imulq $0x1c, %r15, %r8
shrq $0x20, %rsi
cmpl (%rdi,%r8), %esi
jne 0x19ed81
leaq (%rcx,%rdx), %r14
addq $0x18, %r14
movq %rax, %rcx
shrq $0x20, %rcx
movabsq $0x1c00000000, %rdx     # imm = 0x1C00000000
imulq %rdx, %rax
imulq $0x1c, %rcx, %r13
addq %rax, %r13
cmpq 0x8(%r14), %r15
jae 0x19ebcd
movq (%r14), %rdi
movl (%rdi,%r13), %eax
cmpl %eax, 0x4(%rbp)
jne 0x19ebcd
cmpl 0xc(%rdi,%r13), %eax
je 0x19ed09
addq %r13, %rdi
callq 0x1a37c3
movapd %xmm0, %xmm1
xorpd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
jae 0x19ed09
movq (%rbx), %rcx
movq 0x10(%rbx), %rax
cmpq 0x8(%rbx), %rcx
jne 0x19ecae
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rdx
movq %rdx, 0x8(%rbx)
imulq $0x30, %rdx, %rsi
movq %rax, %rdi
movsd %xmm1, 0x18(%rsp)
callq 0x2370
movsd 0x18(%rsp), %xmm1
movq %rax, 0x10(%rbx)
movq (%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%rbx)
imulq $0x30, %rcx, %rcx
movb 0x28(%rax,%rcx), %dl
andb $-0x40, %dl
orb $0x3, %dl
movb %dl, 0x28(%rax,%rcx)
movq (%r14), %rdx
movl 0x18(%rdx,%r13), %edx
shrl $0x19, %edx
andb $0x40, %dl
orb $0x3, %dl
movb %dl, 0x28(%rax,%rcx)
movq (%r14), %rdx
movl (%rdx,%r13), %esi
movl %esi, 0x8(%rax,%rcx)
movq 0x4(%rdx,%r13), %rsi
movq %rsi, (%rax,%rcx)
movl 0xc(%rdx,%r13), %esi
movl %esi, 0x14(%rax,%rcx)
movq 0x10(%rdx,%r13), %rdx
movq %rdx, 0xc(%rax,%rcx)
movsd %xmm1, 0x20(%rax,%rcx)
incq %r15
addq $0x1c, %r13
jmp 0x19ec39
movq 0x108(%r13), %rdi
callq 0x8abfa
movq 0x108(%r13), %rdi
callq 0x2220
movq (%r13), %rax
movq 0x8(%r13), %rdi
movq 0x10(%r13), %rsi
movq 0x8(%rax), %rdx
callq 0x8a9be
movq %rax, 0x108(%r13)
movq (%r13), %rcx
movq 0x8(%r13), %rsi
movq 0x10(%r13), %rdx
movq 0x8(%rcx), %rcx
movq %rbx, %rdi
movq %rax, %r8
callq 0x8bc76
movq 0x108(%r13), %rsi
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x8bbee
leaq 0x49ede(%rip), %rdi     # 0x1e8c66
leaq 0x52d94(%rip), %rsi     # 0x1f1b23
leaq 0x57d41(%rip), %rcx     # 0x1f6ad7
movl $0x5743, %edx           # imm = 0x5743
callq 0x2110