// File: /workspace/github_c_makefile_star2_O2/lh3[P]minimap2/seed.c
// Function: mm_collect_matches
mm_seed_t *mm_collect_matches(void *km, int *_n_m, int qlen, int max_occ, int max_max_occ, int dist, const mm_idx_t *mi, const mm128_v *mv, int64_t *n_a, int *rep_len, int *n_mini_pos, uint64_t **mini_pos)
{
	int rep_st = 0, rep_en = 0, n_m, n_m0;
	size_t i;
	mm_seed_t *m;
	*n_mini_pos = 0;
	*mini_pos = (uint64_t*)kmalloc(km, mv->n * sizeof(uint64_t));
	m = mm_seed_collect_all(km, mi, mv, &n_m0);
	if (dist > 0 && max_max_occ > max_occ) {
		mm_seed_select(n_m0, m, qlen, max_occ, max_max_occ, dist);
	} else {
		for (i = 0; i < n_m0; ++i)
			if (m[i].n > max_occ)
				m[i].flt = 1;
	}
	for (i = 0, n_m = 0, *rep_len = 0, *n_a = 0; i < n_m0; ++i) {
		mm_seed_t *q = &m[i];
		if (mm_dbg_flag & MM_DBG_SEED_FREQ)
			fprintf(stderr, "SF\t%d\t%d\t%d\n", q->q_pos>>1, q->n, q->flt);
		if (q->flt) {
			int en = (q->q_pos >> 1) + 1, st = en - q->q_span;
			if (st > rep_en) {
				*rep_len += rep_en - rep_st;
				rep_st = st, rep_en = en;
			} else rep_en = en;
		} else {
			*n_a += q->n;
			(*mini_pos)[(*n_mini_pos)++] = (uint64_t)q->q_span<<32 | q->q_pos>>1;
			m[n_m++] = *q;
		}
	}
	*rep_len += rep_en - rep_st;
	*_n_m = n_m;
	return m;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %r9d, %r13d
movl %r8d, %r12d
movl %ecx, %ebp
movl %edx, 0x4(%rsp)
movq %rsi, 0x8(%rsp)
movq %rdi, %r14
movq 0x78(%rsp), %rbx
movq 0x70(%rsp), %rax
andl $0x0, (%rax)
movq 0x58(%rsp), %rax
movq (%rax), %rsi
shlq $0x3, %rsi
callq 0x10afc
movq %rax, (%rbx)
leaq 0x14(%rsp), %r15
movq %r14, %rdi
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rdx
movq %r15, %rcx
callq 0x1ab94
movl %r12d, %r8d
movq %rax, %r12
testl %r13d, %r13d
setg %al
cmpl %ebp, %r8d
setg %cl
movslq (%r15), %r15
testb %al, %cl
je 0x1b0af
movl %r15d, %edi
movq %r12, %rsi
movl 0x4(%rsp), %edx
movl %ebp, %ecx
movl %r13d, %r9d
callq 0x1acf3
movq 0x68(%rsp), %r8
movq 0x78(%rsp), %r9
movq 0x70(%rsp), %r10
movq 0x60(%rsp), %r11
andl $0x0, (%r8)
andq $0x0, (%r11)
movq %r12, %r14
addq $0x8, %r14
xorl %ebx, %ebx
xorl %ebp, %ebp
xorl %r13d, %r13d
subq $0x1, %r15
jb 0x1b090
leaq 0x17968(%rip), %rax     # 0x32928
testb $0x20, (%rax)
jne 0x1b04e
movq (%r14), %rdx
testl %edx, %edx
js 0x1b01f
leaq -0x8(%r14), %rax
movl -0x8(%r14), %ecx
addq %rcx, (%r11)
movq (%r14), %rcx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
shlq $0x20, %rcx
movl -0x4(%r14), %edx
shrl %edx
orq %rcx, %rdx
movq (%r9), %rcx
movslq (%r10), %rsi
leal 0x1(%rsi), %edi
movl %edi, (%r10)
movq %rdx, (%rcx,%rsi,8)
movslq %ebx, %rcx
incl %ebx
imulq $0x18, %rcx, %rcx
movq 0x10(%rax), %rdx
movq %rdx, 0x10(%r12,%rcx)
movups (%rax), %xmm0
movups %xmm0, (%r12,%rcx)
movl %ebp, %eax
jmp 0x1b03d
movl -0x4(%r14), %eax
shrl %eax
incl %eax
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movl %eax, %ecx
subl %edx, %ecx
cmpl %ebp, %ecx
jle 0x1b03d
subl %r13d, %ebp
addl %ebp, (%r8)
jmp 0x1b040
movl %r13d, %ecx
addq $0x18, %r14
movl %eax, %ebp
movl %ecx, %r13d
jmp 0x1afaf
movq 0x16fa3(%rip), %rax     # 0x31ff8
movq (%rax), %rdi
movl -0x8(%r14), %ecx
movl -0x4(%r14), %edx
shrl %edx
movl (%r14), %r8d
shrl $0x1f, %r8d
leaq 0xe9dc(%rip), %rsi      # 0x29a4c
xorl %eax, %eax
callq 0x2260
movq 0x60(%rsp), %r11
movq 0x70(%rsp), %r10
movq 0x78(%rsp), %r9
movq 0x68(%rsp), %r8
jmp 0x1afc9
subl %r13d, %ebp
addl %ebp, (%r8)
movq 0x8(%rsp), %rax
movl %ebx, (%rax)
movq %r12, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x8(%r12), %rax
movq %r15, %rcx
movq 0x68(%rsp), %r8
movq 0x78(%rsp), %r9
movq 0x70(%rsp), %r10
movq 0x60(%rsp), %r11
subq $0x1, %rcx
jb 0x1af99
cmpl %ebp, -0x8(%rax)
jbe 0x1b0de
orb $-0x80, 0x3(%rax)
addq $0x18, %rax
jmp 0x1b0cb