// File: /workspace/github_c_makefile_star2_O1/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, %r12d
movl %r8d, %r15d
movl %ecx, %ebp
movl %edx, (%rsp)
movq %rsi, 0x10(%rsp)
movq %rdi, %r14
movq 0x78(%rsp), %rbx
movq 0x70(%rsp), %rax
movq 0x58(%rsp), %r13
movl $0x0, (%rax)
movq (%r13), %rsi
shlq $0x3, %rsi
callq 0x126e9
movq %rax, (%rbx)
leaq 0x4(%rsp), %rbx
movq %r14, %rdi
movq 0x50(%rsp), %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x1d730
movq %rax, %r11
testl %r12d, %r12d
setg %al
cmpl %ebp, %r15d
setg %cl
movslq (%rbx), %rdi
testb %al, %cl
movq %r11, 0x8(%rsp)
je 0x1dbab
movq %r11, %rsi
movl (%rsp), %edx
movl %ebp, %ecx
movl %r15d, %r8d
movl %r12d, %r9d
callq 0x1d89d
movq 0x8(%rsp), %r11
movq 0x68(%rsp), %r8
movq 0x70(%rsp), %r9
movq 0x60(%rsp), %r10
jmp 0x1dbd7
testl %edi, %edi
movq 0x68(%rsp), %r8
movq 0x70(%rsp), %r9
movq 0x60(%rsp), %r10
je 0x1dbd7
movq %r11, %rax
addq $0x8, %rax
cmpl %ebp, -0x8(%rax)
jbe 0x1dbce
orb $-0x80, 0x3(%rax)
addq $0x18, %rax
decq %rdi
jne 0x1dbc5
movl $0x0, (%r8)
movq $0x0, (%r10)
movslq 0x4(%rsp), %r13
testq %r13, %r13
je 0x1dccd
xorl %ebp, %ebp
movq %r11, %r15
xorl %r14d, %r14d
xorl %r12d, %r12d
xorl %ebx, %ebx
movq 0x78(%rsp), %rdi
leaq 0x17d1c(%rip), %rax     # 0x35928
testb $0x20, (%rax)
jne 0x1dca2
movq 0x8(%r15), %rcx
testl %ecx, %ecx
js 0x1dc66
movl (%r15), %eax
addq %rax, (%r10)
movq 0x8(%r15), %rax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shlq $0x20, %rax
movl 0x4(%r15), %ecx
shrl %ecx
orq %rax, %rcx
movq (%rdi), %rax
movslq (%r9), %rdx
leal 0x1(%rdx), %esi
movl %esi, (%r9)
movq %rcx, (%rax,%rdx,8)
movslq %ebx, %rax
incl %ebx
leaq (%rax,%rax,2), %rax
movq 0x10(%r15), %rcx
movq %rcx, 0x10(%r11,%rax,8)
movups (%r15), %xmm0
movups %xmm0, (%r11,%rax,8)
jmp 0x1dc8e
movl 0x4(%r15), %eax
shrl %eax
incl %eax
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl %eax, %edx
subl %ecx, %edx
cmpl %r12d, %edx
jle 0x1dc8b
addl %r12d, %ebp
addl %ebp, (%r8)
movl %eax, %r12d
movl %edx, %r14d
jmp 0x1dc8e
movl %eax, %r12d
movl %r14d, %ebp
negl %ebp
addq $0x18, %r15
decq %r13
jne 0x1dc05
jmp 0x1dcc8
movq %r15, %rdi
callq 0x32ed
movq 0x8(%rsp), %r11
movq 0x60(%rsp), %r10
movq 0x70(%rsp), %r9
movq 0x78(%rsp), %rdi
movq 0x68(%rsp), %r8
jmp 0x1dc15
subl %r14d, %r12d
jmp 0x1dcd2
xorl %ebx, %ebx
xorl %r12d, %r12d
addl %r12d, (%r8)
movq 0x10(%rsp), %rax
movl %ebx, (%rax)
movq %r11, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop