// File: /workspace/github_c_makefile_star2_O1/lh3[P]minimap2/hit.c
// Function: mm_select_sub
void mm_select_sub(void *km, float pri_ratio, int min_diff, int best_n, int check_strand, int min_strand_sc, int *n_, mm_reg1_t *r)
{
	if (pri_ratio > 0.0f && *n_ > 0) {
		int i, k, n = *n_, n_2nd = 0;
		for (i = k = 0; i < n; ++i) {
			int p = r[i].parent;
			if (p == i || r[i].inv) { // primary or inversion
				r[k++] = r[i];
			} else if ((r[i].score >= r[p].score * pri_ratio || r[i].score + min_diff >= r[p].score) && n_2nd < best_n) {
				if (!(r[i].qs == r[p].qs && r[i].qe == r[p].qe && r[i].rid == r[p].rid && r[i].rs == r[p].rs && r[i].re == r[p].re)) // not identical hits
					r[k++] = r[i], ++n_2nd;
				else if (r[i].p) free(r[i].p);
			} else if (check_strand && n_2nd < best_n && r[i].score > min_strand_sc && r[i].rev != r[p].rev) {
				r[i].strand_retained = 1;
				r[k++] = r[i], ++n_2nd;
			} else if (r[i].p) free(r[i].p);
		}
		if (k != n) mm_sync_regs(km, k, r); // removing hits requires sync()
		*n_ = k;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %ecx, 0xc(%rsp)
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x1ca14
movslq (%r9), %r15
testq %r15, %r15
jle 0x1ca14
movl %edx, %ebp
movl %esi, %r10d
movq %rdi, 0x18(%rsp)
movq %r9, 0x20(%rsp)
movq 0x60(%rsp), %rdx
xorl %r13d, %r13d
movq %rdx, %r14
xorl %r9d, %r9d
xorl %ebx, %ebx
movq %r10, 0x10(%rsp)
movss %xmm0, (%rsp)
movl %ebp, 0x8(%rsp)
movl 0x20(%r14), %eax
cmpq %rax, %r13
je 0x1c949
movl 0x3c(%r14), %ecx
btl $0xb, %ecx
jb 0x1c949
movl 0xc(%r14), %r11d
xorps %xmm2, %xmm2
cvtsi2ss %r11d, %xmm2
cltq
leaq (%rax,%rax,4), %rsi
shlq $0x4, %rsi
leaq (%rdx,%rsi), %rax
movl 0xc(%rdx,%rsi), %esi
xorps %xmm1, %xmm1
cvtsi2ss %esi, %xmm1
mulss %xmm0, %xmm1
ucomiss %xmm1, %xmm2
setae %dil
movl %r9d, %r12d
leal (%r11,%r10), %r9d
cmpl %esi, %r9d
movl %r12d, %r9d
setge %sil
orb %dil, %sil
cmpl %ebp, %r12d
setl %dil
andb %sil, %dil
cmpb $0x1, %dil
jne 0x1c979
movl 0x10(%r14), %ecx
cmpl 0x10(%rax), %ecx
jne 0x1c9d9
movl 0x14(%r14), %ecx
cmpl 0x14(%rax), %ecx
jne 0x1c9d9
movl 0x8(%r14), %ecx
cmpl 0x8(%rax), %ecx
jne 0x1c9d9
movl 0x18(%r14), %ecx
cmpl 0x18(%rax), %ecx
jne 0x1c9d9
movl 0x1c(%r14), %ecx
cmpl 0x1c(%rax), %ecx
jne 0x1c9d9
movq 0x48(%r14), %rdi
testq %rdi, %rdi
je 0x1c964
movl %r8d, 0x4(%rsp)
callq 0x2040
movl %r12d, %r9d
movq 0x60(%rsp), %rdx
movss (%rsp), %xmm0
movq 0x10(%rsp), %r10
movl 0x4(%rsp), %r8d
jmp 0x1c964
movslq %ebx, %rax
incl %ebx
leaq (%rax,%rax,4), %rdi
shlq $0x4, %rdi
addq %rdx, %rdi
movl $0xa, %ecx
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
incq %r13
addq $0x50, %r14
cmpq %r13, %r15
jne 0x1c869
jmp 0x1c9fc
cmpl %ebp, %r9d
setge %sil
cmpl $0x0, 0xc(%rsp)
sete %dil
orb %sil, %dil
cmpl %r8d, %r11d
setle %sil
orb %dil, %sil
jne 0x1c9a3
movl 0x3c(%rax), %eax
xorl %ecx, %eax
btl $0xa, %eax
jb 0x1c9cf
movq 0x48(%r14), %rdi
testq %rdi, %rdi
je 0x1c964
movl %r8d, %ebp
callq 0x2040
movl %r12d, %r9d
movq 0x60(%rsp), %rdx
movss (%rsp), %xmm0
movq 0x10(%rsp), %r10
movl %ebp, %r8d
movl 0x8(%rsp), %ebp
jmp 0x1c964
orl $0x4000000, %ecx        # imm = 0x4000000
movl %ecx, 0x3c(%r14)
movslq %ebx, %rax
incl %ebx
leaq (%rax,%rax,4), %rdi
shlq $0x4, %rdi
addq %rdx, %rdi
movl $0xa, %ecx
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
incl %r9d
jmp 0x1c964
cmpl %r15d, %ebx
je 0x1ca0d
movq 0x18(%rsp), %rdi
movl %ebx, %esi
callq 0x1c717
movq 0x20(%rsp), %rax
movl %ebx, (%rax)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq