// File: /workspace/github_c_makefile_star2_O2/rikuu[P]kermit/miniasm/hit.c
// Function: ma_hit_flt
size_t ma_hit_flt(const ma_sub_t *sub, int max_hang, int min_ovlp, size_t n, ma_hit_t *a, float *cov)
{
	size_t i, m;
	asg_arc_t t;
	uint64_t tot_dp = 0, tot_len = 0;
	for (i = m = 0; i < n; ++i) {
		ma_hit_t *h = &a[i];
		const ma_sub_t *sq = &sub[h->qns>>32], *st = &sub[h->tn];
		int r;
		if (sq->del || st->del) continue;
		r = ma_hit2arc(h, sq->e - sq->s, st->e - st->s, max_hang, .5, min_ovlp, &t);
		if (r >= 0 || r == MA_HT_QCONT || r == MA_HT_TCONT)
			a[m++] = *h, tot_dp += r >= 0? r : r == MA_HT_QCONT? sq->e - sq->s : st->e - st->s;
	}
	for (i = 1; i <= m; ++i)
		if (i == m || a[i].qns>>32 != a[i-1].qns>>32)
			tot_len += sub[a[i-1].qns>>32].e - sub[a[i-1].qns>>32].s;
	*cov = (double)tot_dp / tot_len;
	if (ma_verbose >= 3)
		fprintf(stderr, "[M::%s::%s] %ld hits remain after filtering; crude coverage after filtering: %.2f\n", __func__, sys_timestamp(), m, *cov);
	return m;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, 0x18(%rsp)
movq %r8, %rbp
movq %rcx, %r13
movl %edx, 0xc(%rsp)
movl %esi, 0x8(%rsp)
movq %rdi, %r12
movq $0x0, 0x10(%rsp)
movq %r8, %r15
xorl %ebx, %ebx
subq $0x1, %r13
jb 0x48a1
movl 0x4(%r15), %ecx
movl (%r12,%rcx,8), %eax
testl %eax, %eax
js 0x4898
movl 0xc(%r15), %edx
leaq (%r12,%rdx,8), %r14
movl (%r14), %edi
testl %edi, %edi
js 0x4898
leaq (%r12,%rcx,8), %rcx
movq %rcx, 0x20(%rsp)
movl 0x4(%rcx), %esi
subl %eax, %esi
movl 0x4(%r14), %edx
subl %edi, %edx
movq %r15, %rdi
movl 0x8(%rsp), %ecx
movss 0x4abc(%rip), %xmm0     # 0x92f0
movl 0xc(%rsp), %r8d
leaq 0x28(%rsp), %r9
callq 0x49a1
testl %eax, %eax
sets %cl
leal 0x3(%rax), %edx
cmpl $0x2, %edx
setae %dl
testb %dl, %cl
jne 0x4898
movq %rbx, %rcx
shlq $0x5, %rcx
movups (%r15), %xmm0
movups 0x10(%r15), %xmm1
movups %xmm1, 0x10(%rbp,%rcx)
movups %xmm0, (%rbp,%rcx)
testl %eax, %eax
jns 0x488e
cmpl $-0x2, %eax
movq 0x20(%rsp), %rcx
je 0x4880
movq %r14, %rcx
movl 0x4(%rcx), %eax
movl (%rcx), %ecx
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andl %edx, %ecx
subl %ecx, %eax
incq %rbx
movl %eax, %eax
addq %rax, 0x10(%rsp)
addq $0x20, %r15
jmp 0x47e4
movq %rbx, %rax
shlq $0x5, %rax
leaq (%rax,%rbp), %rcx
addq $-0x20, %rcx
addq $0x20, %rbp
pushq $0x1
popq %rdx
xorl %eax, %eax
movl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
movq 0x18(%rsp), %r15
cmpq %rbx, %rdx
ja 0x48fe
jne 0x48cf
movq (%rcx), %rdi
jmp 0x48e0
movq -0x20(%rbp), %rdi
movq (%rbp), %r8
xorq %rdi, %r8
shrq $0x20, %r8
je 0x48f5
shrq $0x20, %rdi
movl 0x4(%r12,%rdi,8), %r8d
movl (%r12,%rdi,8), %edi
andl %esi, %edi
subl %edi, %r8d
addq %r8, %rax
incq %rdx
addq $0x20, %rbp
jmp 0x48c3
movsd 0x10(%rsp), %xmm0
movsd 0x49b4(%rip), %xmm1     # 0x92c0
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x49b9(%rip), %xmm2     # 0x92d0
subpd %xmm2, %xmm0
movapd %xmm0, %xmm3
unpckhpd %xmm0, %xmm3            # xmm3 = xmm3[1],xmm0[1]
addsd %xmm0, %xmm3
movq %rax, %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
subpd %xmm2, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
divsd %xmm1, %xmm3
cvtsd2ss %xmm3, %xmm0
movss %xmm0, (%r15)
leaq 0x97e4(%rip), %rax      # 0xe138
cmpl $0x3, (%rax)
jge 0x496b
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x9686(%rip), %rax      # 0xdff8
movq (%rax), %r14
xorl %eax, %eax
callq 0x1412
cvtss2sd (%r15), %xmm0
leaq 0x4aea(%rip), %rsi      # 0x9472
leaq 0x4b36(%rip), %rdx      # 0x94c5
movq %r14, %rdi
movq %rax, %rcx
movq %rbx, %r8
movb $0x1, %al
callq 0x1120
jmp 0x4959