// File: /workspace/github_c_makefile_star2_O3/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, 0x10(%rsp)
movq %rsi, (%rsp)
movq %rdi, %r14
movq 0x78(%rsp), %r15
movq 0x70(%rsp), %rax
movq 0x58(%rsp), %rbx
movl $0x0, (%rax)
movq (%rbx), %rsi
shlq $0x3, %rsi
callq 0x1264d
movq %rax, (%r15)
leaq 0x14(%rsp), %r15
movq %r14, %rdi
movq 0x50(%rsp), %rsi
movq %rbx, %rdx
movq %r15, %rcx
callq 0x1d769
testl %r13d, %r13d
setg %dl
cmpl %ebp, %r12d
setg %cl
movslq (%r15), %r15
testb %dl, %cl
movq %rax, 0x8(%rsp)
je 0x1dbe8
movl %r15d, %edi
movq %rax, %rsi
movl 0x10(%rsp), %edx
movl %ebp, %ecx
movl %r12d, %r8d
movl %r13d, %r9d
callq 0x1d8de
movq 0x68(%rsp), %rdi
movq 0x78(%rsp), %r8
movq 0x70(%rsp), %r9
movq 0x60(%rsp), %r11
movq (%rsp), %rdx
jmp 0x1dc22
testl %r15d, %r15d
je 0x1dd24
addq $0x8, %rax
movq %r15, %rcx
movq 0x68(%rsp), %rdi
movq 0x78(%rsp), %r8
movq 0x70(%rsp), %r9
movq 0x60(%rsp), %r11
movq (%rsp), %rdx
cmpl %ebp, -0x8(%rax)
jbe 0x1dc19
orb $-0x80, 0x3(%rax)
addq $0x18, %rax
decq %rcx
jne 0x1dc10
movl $0x0, (%rdi)
movq $0x0, (%r11)
testl %r15d, %r15d
je 0x1dd19
xorl %r13d, %r13d
movq 0x8(%rsp), %rax
movq %rax, %r12
xorl %r14d, %r14d
xorl %ebp, %ebp
xorl %ebx, %ebx
leaq 0x18cd7(%rip), %rcx     # 0x36928
testb $0x20, (%rcx)
jne 0x1dcec
movq 0x8(%r12), %rcx
testl %ecx, %ecx
js 0x1dcb1
movl (%r12), %ecx
addq %rcx, (%r11)
movq 0x8(%r12), %rdx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
shlq $0x20, %rdx
movl 0x4(%r12), %ecx
shrl %ecx
orq %rdx, %rcx
movq (%r8), %r10
movslq (%r9), %rdx
leal 0x1(%rdx), %esi
movl %esi, (%r9)
movq %rcx, (%r10,%rdx,8)
movslq %ebx, %rcx
incl %ebx
leaq (%rcx,%rcx,2), %rdx
movq 0x10(%r12), %rcx
movq %rcx, 0x10(%rax,%rdx,8)
movups (%r12), %xmm0
movups %xmm0, (%rax,%rdx,8)
jmp 0x1dcd7
movl 0x4(%r12), %esi
shrl %esi
incl %esi
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl %esi, %edx
subl %ecx, %edx
cmpl %ebp, %edx
jle 0x1dcd5
addl %ebp, %r13d
addl %r13d, (%rdi)
movl %esi, %ebp
movl %edx, %r14d
jmp 0x1dcd7
movl %esi, %ebp
movl %r14d, %r13d
negl %r13d
addq $0x18, %r12
decq %r15
jne 0x1dc4a
jmp 0x1dd12
movq %r12, %rdi
callq 0x32c7
movq 0x60(%rsp), %r11
movq 0x8(%rsp), %rax
movq 0x70(%rsp), %r9
movq 0x78(%rsp), %r8
movq 0x68(%rsp), %rdi
jmp 0x1dc5a
subl %r14d, %ebp
addl (%rdi), %ebp
jmp 0x1dd39
xorl %ebx, %ebx
xorl %ebp, %ebp
movq 0x8(%rsp), %rax
jmp 0x1dd3d
movq 0x60(%rsp), %rcx
movq $0x0, (%rcx)
xorl %ebx, %ebx
xorl %ebp, %ebp
movq 0x68(%rsp), %rdi
movq (%rsp), %rdx
movl %ebp, (%rdi)
movl %ebx, (%rdx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq