// File: /workspace/github_c_makefile_star2_O0/lh3[P]minimap2/hit.c
// Function: mm_set_inv_mapq
static void mm_set_inv_mapq(void *km, int n_regs, mm_reg1_t *regs)
{
	int i, n_aux;
	mm128_t *aux;
	if (n_regs < 3) return;
	for (i = 0; i < n_regs; ++i)
		if (regs[i].inv) break;
	if (i == n_regs) return; // no inversion hits

	aux = (mm128_t*)kmalloc(km, n_regs * 16);
	for (i = n_aux = 0; i < n_regs; ++i)
		if (regs[i].parent == i || regs[i].parent < 0)
			aux[n_aux].y = i, aux[n_aux++].x = (uint64_t)regs[i].rid << 32 | regs[i].rs;
	radix_sort_128x(aux, aux + n_aux);

	for (i = 1; i < n_aux - 1; ++i) {
		mm_reg1_t *inv = &regs[aux[i].y];
		if (inv->inv) {
			mm_reg1_t *l = &regs[aux[i-1].y];
			mm_reg1_t *r = &regs[aux[i+1].y];
			inv->mapq = l->mapq < r->mapq? l->mapq : r->mapq;
		}
	}
	kfree(km, aux);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
cmpl $0x3, -0xc(%rbp)
jge 0x2c48e
jmp 0x2c6c4
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x2c4c9
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movl 0x3c(%rax), %eax
shrl $0xb, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x2c4bc
jmp 0x2c4c9
jmp 0x2c4be
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x2c495
movl -0x1c(%rbp), %eax
cmpl -0xc(%rbp), %eax
jne 0x2c4d6
jmp 0x2c6c4
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %eax
shll $0x4, %eax
movslq %eax, %rsi
callq 0x1aae0
movq %rax, -0x28(%rbp)
movl $0x0, -0x20(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x2c5a2
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movl 0x20(%rax), %eax
cmpl -0x1c(%rbp), %eax
je 0x2c532
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0x20(%rax)
jge 0x2c592
movslq -0x1c(%rbp), %rcx
movq -0x28(%rbp), %rax
movslq -0x20(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movslq 0x8(%rax), %rcx
shlq $0x20, %rcx
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rdx
imulq $0x50, %rdx, %rdx
addq %rdx, %rax
movslq 0x18(%rax), %rax
orq %rax, %rcx
movq -0x28(%rbp), %rax
movl -0x20(%rbp), %edx
movl %edx, %esi
addl $0x1, %esi
movl %esi, -0x20(%rbp)
movslq %edx, %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
jmp 0x2c594
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x2c4fa
movq -0x28(%rbp), %rdi
movq -0x28(%rbp), %rsi
movslq -0x20(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rsi
callq 0x5ad0
movl $0x1, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movl -0x20(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x2c6b7
movq -0x18(%rbp), %rax
movq -0x28(%rbp), %rcx
movslq -0x1c(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
imulq $0x50, 0x8(%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movl 0x3c(%rax), %eax
shrl $0xb, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x2c6a7
movq -0x18(%rbp), %rax
movq -0x28(%rbp), %rcx
movl -0x1c(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
imulq $0x50, 0x8(%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movq -0x28(%rbp), %rcx
movl -0x1c(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
imulq $0x50, 0x8(%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
movl 0x3c(%rax), %eax
andl $0xff, %eax
movq -0x40(%rbp), %rcx
movl 0x3c(%rcx), %ecx
andl $0xff, %ecx
cmpl %ecx, %eax
jge 0x2c67d
movq -0x38(%rbp), %rax
movl 0x3c(%rax), %eax
andl $0xff, %eax
movl %eax, -0x44(%rbp)
jmp 0x2c68c
movq -0x40(%rbp), %rax
movl 0x3c(%rax), %eax
andl $0xff, %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %edx
movq -0x30(%rbp), %rax
movl 0x3c(%rax), %ecx
andl $0xff, %edx
andl $0xffffff00, %ecx       # imm = 0xFFFFFF00
orl %edx, %ecx
movl %ecx, 0x3c(%rax)
jmp 0x2c6a9
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x2c5c1
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x1a8c0
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)