// File: /workspace/github_c_makefile_star2_O0/lh3[P]minimap2/hit.c
// Function: mm_hit_sort
void mm_hit_sort(void *km, int *n_regs, mm_reg1_t *r, float alt_diff_frac)
{
	int32_t i, n_aux, n = *n_regs, has_cigar = 0, no_cigar = 0;
	mm128_t *aux;
	mm_reg1_t *t;

	if (n <= 1) return;
	aux = (mm128_t*)kmalloc(km, n * 16);
	t = (mm_reg1_t*)kmalloc(km, n * sizeof(mm_reg1_t));
	for (i = n_aux = 0; i < n; ++i) {
		if (r[i].inv || r[i].cnt > 0) { // squeeze out elements with cnt==0 (soft deleted)
			int score;
			if (r[i].p) score = r[i].p->dp_max, has_cigar = 1;
			else score = r[i].score, no_cigar = 1;
			if (r[i].is_alt) score = mm_alt_score(score, alt_diff_frac);
			aux[n_aux].x = (uint64_t)score << 32 | r[i].hash;
			aux[n_aux++].y = i;
		} else if (r[i].p) {
			free(r[i].p);
			r[i].p = 0;
		}
	}
	assert(has_cigar + no_cigar == 1);
	radix_sort_128x(aux, aux + n_aux);
	for (i = n_aux - 1; i >= 0; --i)
		t[n_aux - 1 - i] = r[aux[i].y];
	memcpy(r, t, sizeof(mm_reg1_t) * n_aux);
	*n_regs = n_aux;
	kfree(km, aux);
	kfree(km, t);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movss %xmm0, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
cmpl $0x1, -0x28(%rbp)
jg 0x2ab1b
jmp 0x2ad91
movq -0x8(%rbp), %rdi
movl -0x28(%rbp), %eax
shll $0x4, %eax
movslq %eax, %rsi
callq 0x1aae0
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movslq -0x28(%rbp), %rax
imulq $0x50, %rax, %rsi
callq 0x1aae0
movq %rax, -0x40(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x2acc0
movq -0x18(%rbp), %rax
movslq -0x20(%rbp), %rcx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movl 0x3c(%rax), %eax
shrl $0xb, %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x2ab96
movq -0x18(%rbp), %rax
movslq -0x20(%rbp), %rcx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0x4(%rax)
jle 0x2ac69
movq -0x18(%rbp), %rax
movslq -0x20(%rbp), %rcx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, 0x48(%rax)
je 0x2abce
movq -0x18(%rbp), %rax
movslq -0x20(%rbp), %rcx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movq 0x48(%rax), %rax
movl 0x8(%rax), %eax
movl %eax, -0x44(%rbp)
movl $0x1, -0x2c(%rbp)
jmp 0x2abea
movq -0x18(%rbp), %rax
movslq -0x20(%rbp), %rcx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
movl %eax, -0x44(%rbp)
movl $0x1, -0x30(%rbp)
movq -0x18(%rbp), %rax
movslq -0x20(%rbp), %rcx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movl 0x3c(%rax), %eax
shrl $0x19, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x2ac17
movl -0x44(%rbp), %edi
movss -0x1c(%rbp), %xmm0
callq 0x2aa70
movl %eax, -0x44(%rbp)
movslq -0x44(%rbp), %rcx
shlq $0x20, %rcx
movq -0x18(%rbp), %rax
movslq -0x20(%rbp), %rdx
imulq $0x50, %rdx, %rdx
addq %rdx, %rax
movl 0x40(%rax), %eax
orq %rax, %rcx
movq -0x38(%rbp), %rax
movslq -0x24(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movslq -0x20(%rbp), %rcx
movq -0x38(%rbp), %rax
movl -0x24(%rbp), %edx
movl %edx, %esi
addl $0x1, %esi
movl %esi, -0x24(%rbp)
movslq %edx, %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
jmp 0x2acb0
movq -0x18(%rbp), %rax
movslq -0x20(%rbp), %rcx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, 0x48(%rax)
je 0x2acae
movq -0x18(%rbp), %rax
movslq -0x20(%rbp), %rcx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movq 0x48(%rax), %rdi
callq 0x2040
movq -0x18(%rbp), %rax
movslq -0x20(%rbp), %rcx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movq $0x0, 0x48(%rax)
jmp 0x2acb0
jmp 0x2acb2
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x2ab54
movl -0x2c(%rbp), %eax
addl -0x30(%rbp), %eax
cmpl $0x1, %eax
jne 0x2accd
jmp 0x2acec
leaq 0x2d884(%rip), %rdi     # 0x58558
leaq 0x2d897(%rip), %rsi     # 0x58572
movl $0xd2, %edx
leaq 0x2d891(%rip), %rcx     # 0x58578
callq 0x21a0
movq -0x38(%rbp), %rdi
movq -0x38(%rbp), %rsi
movslq -0x24(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rsi
callq 0x5ad0
movl -0x24(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jl 0x2ad59
movq -0x40(%rbp), %rdi
movl -0x24(%rbp), %eax
subl $0x1, %eax
subl -0x20(%rbp), %eax
cltq
imulq $0x50, %rax, %rax
addq %rax, %rdi
movq -0x18(%rbp), %rsi
movq -0x38(%rbp), %rax
movslq -0x20(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
imulq $0x50, 0x8(%rax), %rax
addq %rax, %rsi
movl $0x50, %edx
callq 0x2290
movl -0x20(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x2ad0d
movq -0x18(%rbp), %rdi
movq -0x40(%rbp), %rsi
movslq -0x24(%rbp), %rax
imulq $0x50, %rax, %rdx
callq 0x2290
movl -0x24(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x1a8c0
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x1a8c0
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)