// File: /workspace/github_c_makefile_star2_O0/lh3[P]minimap2/seed.c
// Function: mm_seed_select
void mm_seed_select(int32_t n, mm_seed_t *a, int len, int max_occ, int max_max_occ, int dist)
{ // for high-occ minimizers, choose up to max_high_occ in each high-occ streak
	extern void ks_heapdown_uint64_t(size_t i, size_t n, uint64_t*);
	extern void ks_heapmake_uint64_t(size_t n, uint64_t*);
	int32_t i, last0, m;
	uint64_t b[MAX_MAX_HIGH_OCC]; // this is to avoid a heap allocation

	if (n == 0 || n == 1) return;
	for (i = m = 0; i < n; ++i)
		if (a[i].n > max_occ) ++m;
	if (m == 0) return; // no high-frequency k-mers; do nothing
	for (i = 0, last0 = -1; i <= n; ++i) {
		if (i == n || a[i].n <= max_occ) {
			if (i - last0 > 1) {
				int32_t ps = last0 < 0? 0 : (uint32_t)a[last0].q_pos>>1;
				int32_t pe = i == n? len : (uint32_t)a[i].q_pos>>1;
				int32_t j, k, st = last0 + 1, en = i;
				int32_t max_high_occ = (int32_t)((double)(pe - ps) / dist + .499);
				if (max_high_occ > 0) {
					if (max_high_occ > MAX_MAX_HIGH_OCC)
						max_high_occ = MAX_MAX_HIGH_OCC;
					for (j = st, k = 0; j < en && k < max_high_occ; ++j, ++k)
						b[k] = (uint64_t)a[j].n<<32 | j;
					ks_heapmake_uint64_t(k, b); // initialize the binomial heap
					for (; j < en; ++j) { // if there are more, choose top max_high_occ
						if (a[j].n < (int32_t)(b[0]>>32)) { // then update the heap
							b[0] = (uint64_t)a[j].n<<32 | j;
							ks_heapdown_uint64_t(0, k, b);
						}
					}
					for (j = 0; j < k; ++j) a[(uint32_t)b[j]].flt = 1;
				}
				for (j = st; j < en; ++j) a[j].flt ^= 1;
				for (j = st; j < en; ++j)
					if (a[j].n > max_max_occ)
						a[j].flt = 1;
			}
			last0 = i;
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x460, %rsp            # imm = 0x460
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl %r8d, -0x1c(%rbp)
movl %r9d, -0x20(%rbp)
cmpl $0x0, -0x4(%rbp)
je 0x2cd8c
cmpl $0x1, -0x4(%rbp)
jne 0x2cd91
jmp 0x2d1a1
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x2cdd3
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
cmpl -0x18(%rbp), %eax
jbe 0x2cdc6
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x2cdc8
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x2cd9f
cmpl $0x0, -0x2c(%rbp)
jne 0x2cdde
jmp 0x2d1a1
movl $0x0, -0x24(%rbp)
movl $0xffffffff, -0x28(%rbp) # imm = 0xFFFFFFFF
movl -0x24(%rbp), %eax
cmpl -0x4(%rbp), %eax
jg 0x2d1a1
movl -0x24(%rbp), %eax
cmpl -0x4(%rbp), %eax
je 0x2ce1a
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
cmpl -0x18(%rbp), %eax
ja 0x2d191
movl -0x24(%rbp), %eax
subl -0x28(%rbp), %eax
cmpl $0x1, %eax
jle 0x2d18b
cmpl $0x0, -0x28(%rbp)
jge 0x2ce39
xorl %eax, %eax
movl %eax, -0x450(%rbp)
jmp 0x2ce53
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
shrl %eax
movl %eax, -0x450(%rbp)
movl -0x450(%rbp), %eax
movl %eax, -0x434(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x4(%rbp), %eax
jne 0x2ce72
movl -0x14(%rbp), %eax
movl %eax, -0x454(%rbp)
jmp 0x2ce8c
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
shrl %eax
movl %eax, -0x454(%rbp)
movl -0x454(%rbp), %eax
movl %eax, -0x438(%rbp)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x444(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x448(%rbp)
movl -0x438(%rbp), %eax
subl -0x434(%rbp), %eax
cvtsi2sd %eax, %xmm0
cvtsi2sdl -0x20(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd 0x2814a(%rip), %xmm1    # 0x55018
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x44c(%rbp)
cmpl $0x0, -0x44c(%rbp)
jle 0x2d0a2
cmpl $0x80, -0x44c(%rbp)
jle 0x2ceff
movl $0x80, -0x44c(%rbp)
movl -0x444(%rbp), %eax
movl %eax, -0x43c(%rbp)
movl $0x0, -0x440(%rbp)
movl -0x43c(%rbp), %ecx
xorl %eax, %eax
cmpl -0x448(%rbp), %ecx
movb %al, -0x455(%rbp)
jge 0x2cf40
movl -0x440(%rbp), %eax
cmpl -0x44c(%rbp), %eax
setl %al
movb %al, -0x455(%rbp)
movb -0x455(%rbp), %al
testb $0x1, %al
jne 0x2cf4c
jmp 0x2cfa2
movq -0x10(%rbp), %rax
movslq -0x43c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, %ecx
shlq $0x20, %rcx
movslq -0x43c(%rbp), %rax
orq %rax, %rcx
movslq -0x440(%rbp), %rax
movq %rcx, -0x430(%rbp,%rax,8)
movl -0x43c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x43c(%rbp)
movl -0x440(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x440(%rbp)
jmp 0x2cf15
movslq -0x440(%rbp), %rdi
leaq -0x430(%rbp), %rsi
callq 0x6410
movl -0x43c(%rbp), %eax
cmpl -0x448(%rbp), %eax
jge 0x2d03c
movq -0x10(%rbp), %rax
movslq -0x43c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movq -0x430(%rbp), %rcx
shrq $0x20, %rcx
cmpl %ecx, %eax
jae 0x2d026
movq -0x10(%rbp), %rax
movslq -0x43c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
shlq $0x20, %rax
movslq -0x43c(%rbp), %rcx
orq %rcx, %rax
movq %rax, -0x430(%rbp)
movslq -0x440(%rbp), %rsi
leaq -0x430(%rbp), %rdx
xorl %eax, %eax
movl %eax, %edi
callq 0x6350
jmp 0x2d028
movl -0x43c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x43c(%rbp)
jmp 0x2cfb5
movl $0x0, -0x43c(%rbp)
movl -0x43c(%rbp), %eax
cmpl -0x440(%rbp), %eax
jge 0x2d0a0
movq -0x10(%rbp), %rax
movslq -0x43c(%rbp), %rcx
movq -0x430(%rbp,%rcx,8), %rcx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movabsq $-0x80000001, %rcx      # imm = 0xFFFFFFFF7FFFFFFF
andq 0x8(%rax), %rcx
movabsq $0x80000000, %rdx       # imm = 0x80000000
orq %rdx, %rcx
movq %rcx, 0x8(%rax)
movl -0x43c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x43c(%rbp)
jmp 0x2d046
jmp 0x2d0a2
movl -0x444(%rbp), %eax
movl %eax, -0x43c(%rbp)
movl -0x43c(%rbp), %eax
cmpl -0x448(%rbp), %eax
jge 0x2d112
movq -0x10(%rbp), %rax
movslq -0x43c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rcx
shrq $0x1f, %rcx
andq $0x1, %rcx
xorl $0x1, %ecx
movl %ecx, %ecx
movl %ecx, %edx
movq 0x8(%rax), %rcx
andq $0x1, %rdx
shlq $0x1f, %rdx
movabsq $-0x80000001, %rsi      # imm = 0xFFFFFFFF7FFFFFFF
andq %rsi, %rcx
orq %rdx, %rcx
movq %rcx, 0x8(%rax)
movl -0x43c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x43c(%rbp)
jmp 0x2d0ae
movl -0x444(%rbp), %eax
movl %eax, -0x43c(%rbp)
movl -0x43c(%rbp), %eax
cmpl -0x448(%rbp), %eax
jge 0x2d189
movq -0x10(%rbp), %rax
movslq -0x43c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
cmpl -0x1c(%rbp), %eax
jbe 0x2d176
movq -0x10(%rbp), %rax
movslq -0x43c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movabsq $-0x80000001, %rcx      # imm = 0xFFFFFFFF7FFFFFFF
andq 0x8(%rax), %rcx
movabsq $0x80000000, %rdx       # imm = 0x80000000
orq %rdx, %rcx
movq %rcx, 0x8(%rax)
jmp 0x2d178
movl -0x43c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x43c(%rbp)
jmp 0x2d11e
jmp 0x2d18b
movl -0x24(%rbp), %eax
movl %eax, -0x28(%rbp)
jmp 0x2d193
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x2cdec
addq $0x460, %rsp            # imm = 0x460
popq %rbp
retq
nopw (%rax,%rax)