// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq 0x38(%rbp), %rax
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl %r8d, -0x1c(%rbp)
movl %r9d, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movq 0x30(%rbp), %rax
movl $0x0, (%rax)
movq -0x8(%rbp), %rdi
movq 0x18(%rbp), %rax
movq (%rax), %rsi
shlq $0x3, %rsi
callq 0x1aae0
movq %rax, %rcx
movq 0x38(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rdi
movq 0x10(%rbp), %rsi
movq 0x18(%rbp), %rdx
leaq -0x30(%rbp), %rcx
callq 0x2cb00
movq %rax, -0x40(%rbp)
cmpl $0x0, -0x20(%rbp)
jle 0x2d25f
movl -0x1c(%rbp), %eax
cmpl -0x18(%rbp), %eax
jle 0x2d25f
movl -0x30(%rbp), %edi
movq -0x40(%rbp), %rsi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
movl -0x1c(%rbp), %r8d
movl -0x20(%rbp), %r9d
callq 0x2cd60
jmp 0x2d2c4
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
movslq -0x30(%rbp), %rcx
cmpq %rcx, %rax
jae 0x2d2c2
movq -0x40(%rbp), %rax
imulq $0x18, -0x38(%rbp), %rcx
addq %rcx, %rax
movl (%rax), %eax
cmpl -0x18(%rbp), %eax
jbe 0x2d2b2
movq -0x40(%rbp), %rax
imulq $0x18, -0x38(%rbp), %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 0x2d2b4
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x2d267
jmp 0x2d2c4
movq $0x0, -0x38(%rbp)
movl $0x0, -0x2c(%rbp)
movq 0x28(%rbp), %rax
movl $0x0, (%rax)
movq 0x20(%rbp), %rax
movq $0x0, (%rax)
movq -0x38(%rbp), %rax
movslq -0x30(%rbp), %rcx
cmpq %rcx, %rax
jae 0x2d455
movq -0x40(%rbp), %rax
imulq $0x18, -0x38(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
leaq 0x31628(%rip), %rax     # 0x5e938
movl (%rax), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0x2d354
movq 0x30cd7(%rip), %rax     # 0x5dff8
movq (%rax), %rdi
movq -0x48(%rbp), %rax
movl 0x4(%rax), %edx
shrl %edx
movq -0x48(%rbp), %rax
movl (%rax), %ecx
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
shrq $0x1f, %rax
andq $0x1, %rax
movl %eax, %r8d
leaq 0x2b2ef(%rip), %rsi     # 0x5863c
movb $0x0, %al
callq 0x2250
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
shrq $0x1f, %rax
andq $0x1, %rax
cmpl $0x0, %eax
je 0x2d3be
movq -0x48(%rbp), %rax
movl 0x4(%rax), %eax
shrl %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movq -0x48(%rbp), %rcx
movq 0x8(%rcx), %rcx
andq $0x7fffffff, %rcx       # imm = 0x7FFFFFFF
subl %ecx, %eax
movl %eax, -0x50(%rbp)
movl -0x50(%rbp), %eax
cmpl -0x28(%rbp), %eax
jle 0x2d3b3
movl -0x28(%rbp), %ecx
subl -0x24(%rbp), %ecx
movq 0x28(%rbp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
movl -0x50(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x4c(%rbp), %eax
movl %eax, -0x28(%rbp)
jmp 0x2d3b9
movl -0x4c(%rbp), %eax
movl %eax, -0x28(%rbp)
jmp 0x2d442
movq -0x48(%rbp), %rax
movl (%rax), %eax
movl %eax, %ecx
movq 0x20(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
andq $0x7fffffff, %rax       # imm = 0x7FFFFFFF
movl %eax, %eax
movl %eax, %edx
shlq $0x20, %rdx
movq -0x48(%rbp), %rax
movl 0x4(%rax), %eax
shrl %eax
movl %eax, %eax
orq %rax, %rdx
movq 0x38(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rbp), %rsi
movl (%rsi), %ecx
movl %ecx, %edi
addl $0x1, %edi
movl %edi, (%rsi)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x40(%rbp), %rax
movl -0x2c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x2c(%rbp)
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq -0x48(%rbp), %rcx
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq 0x10(%rcx), %rcx
movq %rcx, 0x10(%rax)
jmp 0x2d444
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x2d2e8
movl -0x28(%rbp), %ecx
subl -0x24(%rbp), %ecx
movq 0x28(%rbp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
movl -0x2c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movq -0x40(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)