// File: /workspace/github_c_makefile_star2_O2/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 $0x38, %rsp
movl %r8d, 0x1c(%rsp)
movl %ecx, 0x18(%rsp)
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x19fb3
movslq (%r9), %r13
testq %r13, %r13
jle 0x19fb3
movl %esi, %ebp
movq %rdi, 0x20(%rsp)
movq %r9, 0x28(%rsp)
movq 0x70(%rsp), %rbx
xorl %r12d, %r12d
pushq $0xa
popq %r11
movq %rbx, %r14
xorl %r15d, %r15d
xorl %r9d, %r9d
movss %xmm0, 0x10(%rsp)
movq %r13, 0x30(%rsp)
cmpq %r12, %r13
je 0x19f96
movl 0x20(%r14), %ecx
movslq %r15d, %rax
cmpq %rcx, %r12
je 0x19ef4
movl 0x3c(%r14), %r10d
btl $0xb, %r10d
jb 0x19ef4
movl 0xc(%r14), %esi
cvtsi2ss %esi, %xmm2
movslq %ecx, %rcx
imulq $0x50, %rcx, %rdi
leaq (%rbx,%rdi), %rcx
movl 0xc(%rbx,%rdi), %edi
cvtsi2ss %edi, %xmm1
mulss %xmm0, %xmm1
ucomiss %xmm1, %xmm2
setae %r8b
movl %r9d, 0xc(%rsp)
leal (%rsi,%rbp), %r9d
cmpl %edi, %r9d
movl 0xc(%rsp), %r9d
setge %dil
orb %r8b, %dil
cmpl %edx, %r9d
setl %r8b
andb %dil, %r8b
cmpb $0x1, %r8b
jne 0x19f14
movl 0x10(%r14), %esi
cmpl 0x10(%rcx), %esi
jne 0x19f7a
movl 0x14(%r14), %esi
cmpl 0x14(%rcx), %esi
jne 0x19f7a
movl 0x8(%r14), %esi
cmpl 0x8(%rcx), %esi
jne 0x19f7a
movl 0x18(%r14), %esi
cmpl 0x18(%rcx), %esi
jne 0x19f7a
movl 0x1c(%r14), %esi
cmpl 0x1c(%rcx), %esi
jne 0x19f7a
movq 0x48(%r14), %rdi
movl %edx, 0x14(%rsp)
callq 0x2040
movl 0xc(%rsp), %r9d
pushq $0xa
popq %r11
movss 0x10(%rsp), %xmm0
movl 0x14(%rsp), %edx
jmp 0x19f08
leal 0x1(%rax), %r15d
imulq $0x50, %rax, %rdi
addq %rbx, %rdi
movq %r11, %rcx
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
incq %r12
addq $0x50, %r14
jmp 0x19e17
cmpl %edx, %r9d
setge %dil
cmpl $0x0, 0x18(%rsp)
sete %r8b
orb %dil, %r8b
cmpl 0x1c(%rsp), %esi
setle %sil
orb %r8b, %sil
jne 0x19f40
movl 0x3c(%rcx), %ecx
xorl %r10d, %ecx
btl $0xa, %ecx
jb 0x19f6f
movq 0x48(%r14), %rdi
movq %rbx, %r13
movq %rbp, %rbx
movl %edx, %ebp
callq 0x2040
movl 0xc(%rsp), %r9d
pushq $0xa
popq %r11
movss 0x10(%rsp), %xmm0
movl %ebp, %edx
movq %rbx, %rbp
movq %r13, %rbx
movq 0x30(%rsp), %r13
jmp 0x19f08
orl $0x4000000, %r10d       # imm = 0x4000000
movl %r10d, 0x3c(%r14)
leal 0x1(%rax), %r15d
imulq $0x50, %rax, %rdi
addq %rbx, %rdi
movq %r11, %rcx
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
incl %r9d
jmp 0x19f08
cmpl %r13d, %r15d
je 0x19fab
movq 0x20(%rsp), %rdi
movl %r15d, %esi
movq %rbx, %rdx
callq 0x19ce0
movq 0x28(%rsp), %rax
movl %r15d, (%rax)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq