// File: /workspace/github_c_makefile_star2_O0/lh3[P]miniprot/hit.c
// Function: mp_select_sub
void mp_select_sub(void *km, float pri_ratio, int min_diff, int best_n, int *n_, mp_reg1_t *r)
{
	if (pri_ratio > 0.0f && *n_ > 0) {
		int i, k, n = *n_, n_2nd = 0, chn_sc_ungap = -1;
		for (i = 0; i < n; ++i) // find the largest chn_sc_ungap
			chn_sc_ungap = chn_sc_ungap > r[i].chn_sc_ungap? chn_sc_ungap : r[i].chn_sc_ungap;
		for (i = k = 0; i < n; ++i) {
			int p = r[i].parent;
			int sci = r[i].p? r[i].p->dp_max : r[i].chn_sc;
			int scp = r[p].p? r[p].p->dp_max : r[p].chn_sc;
			if (p == i) { // primary or inversion
				r[k++] = r[i];
			} else if ((sci >= scp * pri_ratio || sci + min_diff >= scp) && n_2nd < best_n) {
				if (!(r[i].qs == r[p].qs && r[i].qe == r[p].qe && r[i].vid == r[p].vid && r[i].vs == r[p].vs && r[i].ve == r[p].ve)) // not identical hits
					r[k++] = r[i], ++n_2nd;
				else if (r[i].p) { free(r[i].p); free(r[i].feat); }
			} else if (r[i].p == 0 && r[p].p == 0 && chn_sc_ungap > 0 && r[i].chn_sc_ungap >= chn_sc_ungap * pri_ratio && n_2nd < best_n) {
				if (!(r[i].qs == r[p].qs && r[i].qe == r[p].qe && r[i].vid == r[p].vid && r[i].vs == r[p].vs && r[i].ve == r[p].ve)) // not identical hits
					r[k++] = r[i], ++n_2nd;
			} else if (r[i].p) { free(r[i].p); free(r[i].feat); }
		}
		if (k != n) mp_sync_regs(km, k, r); // removing hits requires sync()
		*n_ = k;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movss %xmm0, -0xc(%rbp)
movl %esi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movss -0xc(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x1b7bb
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
jle 0x1b7bb
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
movl $0xffffffff, -0x3c(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x1b348
movl -0x3c(%rbp), %eax
movq -0x28(%rbp), %rcx
movslq -0x2c(%rbp), %rdx
imulq $0x68, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x28(%rcx), %eax
jle 0x1b322
movl -0x3c(%rbp), %eax
movl %eax, -0x4c(%rbp)
jmp 0x1b337
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movl 0x28(%rax), %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x1b2fb
movl $0x0, -0x30(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x1b79a
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
movl %eax, -0x40(%rbp)
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, 0x60(%rax)
je 0x1b3a8
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movq 0x60(%rax), %rax
movl 0x4(%rax), %eax
movl %eax, -0x50(%rbp)
jmp 0x1b3bd
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movl 0x24(%rax), %eax
movl %eax, -0x50(%rbp)
movl -0x50(%rbp), %eax
movl %eax, -0x44(%rbp)
movq -0x28(%rbp), %rax
movslq -0x40(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, 0x60(%rax)
je 0x1b3f4
movq -0x28(%rbp), %rax
movslq -0x40(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movq 0x60(%rax), %rax
movl 0x4(%rax), %eax
movl %eax, -0x54(%rbp)
jmp 0x1b409
movq -0x28(%rbp), %rax
movslq -0x40(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movl 0x24(%rax), %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
movl %eax, -0x48(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jne 0x1b44d
movq -0x28(%rbp), %rdi
movl -0x30(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x30(%rbp)
cltq
imulq $0x68, %rax, %rax
addq %rax, %rdi
movq -0x28(%rbp), %rsi
movslq -0x2c(%rbp), %rax
imulq $0x68, %rax, %rax
addq %rax, %rsi
movl $0x68, %edx
callq 0x2200
jmp 0x1b78a
cvtsi2ssl -0x44(%rbp), %xmm0
cvtsi2ssl -0x48(%rbp), %xmm1
mulss -0xc(%rbp), %xmm1
ucomiss %xmm1, %xmm0
jae 0x1b470
movl -0x44(%rbp), %eax
addl -0x10(%rbp), %eax
cmpl -0x48(%rbp), %eax
jl 0x1b5cb
movl -0x38(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x1b5cb
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movl 0x34(%rax), %eax
movq -0x28(%rbp), %rcx
movslq -0x40(%rbp), %rdx
imulq $0x68, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x34(%rcx), %eax
jne 0x1b542
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movl 0x38(%rax), %eax
movq -0x28(%rbp), %rcx
movslq -0x40(%rbp), %rdx
imulq $0x68, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x38(%rcx), %eax
jne 0x1b542
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movl 0x30(%rax), %eax
movq -0x28(%rbp), %rcx
movslq -0x40(%rbp), %rdx
imulq $0x68, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x30(%rcx), %eax
jne 0x1b542
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movq 0x40(%rax), %rax
movq -0x28(%rbp), %rcx
movslq -0x40(%rbp), %rdx
imulq $0x68, %rdx, %rdx
addq %rdx, %rcx
cmpq 0x40(%rcx), %rax
jne 0x1b542
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movq 0x48(%rax), %rax
movq -0x28(%rbp), %rcx
movslq -0x40(%rbp), %rdx
imulq $0x68, %rdx, %rdx
addq %rdx, %rcx
cmpq 0x48(%rcx), %rax
je 0x1b57e
movq -0x28(%rbp), %rdi
movl -0x30(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x30(%rbp)
cltq
imulq $0x68, %rax, %rax
addq %rax, %rdi
movq -0x28(%rbp), %rsi
movslq -0x2c(%rbp), %rax
imulq $0x68, %rax, %rax
addq %rax, %rsi
movl $0x68, %edx
callq 0x2200
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x1b5c6
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, 0x60(%rax)
je 0x1b5c4
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movq 0x60(%rax), %rdi
callq 0x2040
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movq 0x58(%rax), %rdi
callq 0x2040
jmp 0x1b5c6
jmp 0x1b788
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, 0x60(%rax)
jne 0x1b73e
movq -0x28(%rbp), %rax
movslq -0x40(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, 0x60(%rax)
jne 0x1b73e
cmpl $0x0, -0x3c(%rbp)
jle 0x1b73e
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
cvtsi2ssl 0x28(%rax), %xmm0
cvtsi2ssl -0x3c(%rbp), %xmm1
mulss -0xc(%rbp), %xmm1
ucomiss %xmm1, %xmm0
jb 0x1b73e
movl -0x38(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x1b73e
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movl 0x34(%rax), %eax
movq -0x28(%rbp), %rcx
movslq -0x40(%rbp), %rdx
imulq $0x68, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x34(%rcx), %eax
jne 0x1b702
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movl 0x38(%rax), %eax
movq -0x28(%rbp), %rcx
movslq -0x40(%rbp), %rdx
imulq $0x68, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x38(%rcx), %eax
jne 0x1b702
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movl 0x30(%rax), %eax
movq -0x28(%rbp), %rcx
movslq -0x40(%rbp), %rdx
imulq $0x68, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x30(%rcx), %eax
jne 0x1b702
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movq 0x40(%rax), %rax
movq -0x28(%rbp), %rcx
movslq -0x40(%rbp), %rdx
imulq $0x68, %rdx, %rdx
addq %rdx, %rcx
cmpq 0x40(%rcx), %rax
jne 0x1b702
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movq 0x48(%rax), %rax
movq -0x28(%rbp), %rcx
movslq -0x40(%rbp), %rdx
imulq $0x68, %rdx, %rdx
addq %rdx, %rcx
cmpq 0x48(%rcx), %rax
je 0x1b73c
movq -0x28(%rbp), %rdi
movl -0x30(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x30(%rbp)
cltq
imulq $0x68, %rax, %rax
addq %rax, %rdi
movq -0x28(%rbp), %rsi
movslq -0x2c(%rbp), %rax
imulq $0x68, %rax, %rax
addq %rax, %rsi
movl $0x68, %edx
callq 0x2200
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x1b786
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, 0x60(%rax)
je 0x1b784
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movq 0x60(%rax), %rdi
callq 0x2040
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movq 0x58(%rax), %rdi
callq 0x2040
jmp 0x1b786
jmp 0x1b788
jmp 0x1b78a
jmp 0x1b78c
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x1b356
movl -0x30(%rbp), %eax
cmpl -0x34(%rbp), %eax
je 0x1b7b2
movq -0x8(%rbp), %rdi
movl -0x30(%rbp), %esi
movq -0x28(%rbp), %rdx
callq 0x1b0e0
movl -0x30(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)