// File: /workspace/github_c_makefile_star2_O2/lh3[P]minimap2/map.c
// Function: collect_seed_hits
static mm128_t *collect_seed_hits(void *km, const mm_mapopt_t *opt, int max_occ, const mm_idx_t *mi, const char *qname, const mm128_v *mv, int qlen, int64_t *n_a, int *rep_len,
								  int *n_mini_pos, uint64_t **mini_pos)
{
	int i, n_m;
	mm_seed_t *m;
	mm128_t *a;
	m = mm_collect_matches(km, &n_m, qlen, max_occ, opt->max_max_occ, opt->occ_dist, mi, mv, n_a, rep_len, n_mini_pos, mini_pos);
	a = (mm128_t*)kmalloc(km, *n_a * sizeof(mm128_t));
	for (i = 0, *n_a = 0; i < n_m; ++i) {
		mm_seed_t *q = &m[i];
		const uint64_t *r = q->cr;
		uint32_t k;
		for (k = 0; k < q->n; ++k) {
			int32_t is_self, rpos = (uint32_t)r[k] >> 1;
			mm128_t *p;
			if (skip_seed(opt->flag, r[k], q, qname, qlen, mi, &is_self)) continue;
			p = &a[(*n_a)++];
			if ((r[k]&1) == (q->q_pos&1)) { // forward strand
				p->x = (r[k]&0xffffffff00000000ULL) | rpos;
				p->y = (uint64_t)q->q_span << 32 | q->q_pos >> 1;
			} else if (!(opt->flag & MM_F_QSTRAND)) { // reverse strand and not in the query-strand mode
				p->x = 1ULL<<63 | (r[k]&0xffffffff00000000ULL) | rpos;
				p->y = (uint64_t)q->q_span << 32 | (qlen - ((q->q_pos>>1) + 1 - q->q_span) - 1);
			} else { // reverse strand; query-strand
				int32_t len = mi->seq[r[k]>>32].len;
				p->x = 1ULL<<63 | (r[k]&0xffffffff00000000ULL) | (len - (rpos + 1 - q->q_span) - 1); // coordinate only accurate for non-HPC seeds
				p->y = (uint64_t)q->q_span << 32 | q->q_pos >> 1;
			}
			p->y |= (uint64_t)q->seg_id << MM_SEED_SEG_SHIFT;
			if (q->is_tandem) p->y |= MM_SEED_TANDEM;
			if (is_self) p->y |= MM_SEED_SELF;
		}
	}
	kfree(km, m);
	radix_sort_128x(a, a + (*n_a));
	return a;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %r8, 0x68(%rsp)
movq %rcx, %r10
movl %edx, %ecx
movq %rsi, %r12
movq %rdi, %r14
movq 0xb8(%rsp), %rbx
movl 0xb0(%rsp), %r13d
movaps 0xc0(%rsp), %xmm0
movq 0xd0(%rsp), %rdx
movl 0xdc(%rsi), %r8d
movl 0xe0(%rsi), %eax
movq %rdx, 0x28(%rsp)
movups %xmm0, 0x18(%rsp)
movq %rbx, 0x10(%rsp)
movq %r9, 0x8(%rsp)
movq %r10, 0x48(%rsp)
movq %r10, (%rsp)
leaq 0x74(%rsp), %r15
movq %r15, %rsi
movl %r13d, %edx
movl %eax, %r9d
callq 0x1aef7
movq %rax, 0x38(%rsp)
movq (%rbx), %rsi
shlq $0x4, %rsi
movq %r14, 0x50(%rsp)
movq %r14, %rdi
callq 0x10afc
andq $0x0, (%rbx)
movq %rax, 0x40(%rsp)
movl (%r15), %eax
leal -0x1(%r13), %ecx
movl %ecx, 0x30(%rsp)
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
movq %rax, 0x58(%rsp)
cmpq 0x58(%rsp), %rcx
je 0xb2c2
movq %rcx, 0x60(%rsp)
imulq $0x18, %rcx, %rax
movq 0x38(%rsp), %rcx
leaq (%rcx,%rax), %rbp
movq 0x10(%rcx,%rax), %r13
movl (%rcx,%rax), %ebx
xorl %r14d, %r14d
cmpq %r14, %rbx
je 0xb2b5
movq (%r13,%r14,8), %r15
movl (%r12), %edi
leaq 0x34(%rsp), %rax
movq %rax, (%rsp)
movq %r15, %rsi
movq %rbp, %rdx
movq 0x68(%rsp), %rcx
movl 0xb0(%rsp), %r8d
movq 0x48(%rsp), %r9
callq 0xc60a
testl %eax, %eax
jne 0xb2ad
shrl %r15d
movq 0xb8(%rsp), %rdx
movq (%rdx), %rax
leaq 0x1(%rax), %rcx
movq %rcx, (%rdx)
shlq $0x4, %rax
addq 0x40(%rsp), %rax
movq (%r13,%r14,8), %rdx
movl %edx, %edi
andl $0x1, %edi
movl 0x4(%rbp), %ecx
movl %ecx, %r8d
andl $0x1, %r8d
movl %r15d, %esi
cmpl %r8d, %edi
jne 0xb1d6
movabsq $-0x100000000, %rdi     # imm = 0xFFFFFFFF00000000
andq %rdi, %rdx
orq %rdx, %rsi
movq %rsi, (%rax)
movq 0x8(%rbp), %rdx
shrl %ecx
movabsq $0x7fffffff00000000, %r8 # imm = 0x7FFFFFFF00000000
jmp 0xb261
testb $0x1, 0x4(%r12)
movabsq $0x7fffffff00000000, %r8 # imm = 0x7FFFFFFF00000000
jne 0xb216
andq %r8, %rdx
movabsq $-0x8000000000000000, %rdi # imm = 0x8000000000000000
orq %rdi, %rdx
orq %rsi, %rdx
movq %rdx, (%rax)
movq 0x8(%rbp), %rdx
movl %edx, %esi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
addl 0x30(%rsp), %esi
shrl %ecx
notl %ecx
addl %esi, %ecx
jmp 0xb261
movq 0x48(%rsp), %rsi
movq 0x20(%rsi), %rsi
movq %rdx, %rdi
shrq $0x20, %rdi
imulq $0x18, %rdi, %rdi
movl 0x10(%rsi,%rdi), %esi
andq %r8, %rdx
movl 0x8(%rbp), %edi
movl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
andl %r9d, %edi
subl %r15d, %esi
addl %edi, %esi
addl $-0x2, %esi
movslq %esi, %rsi
movabsq $-0x8000000000000000, %rdi # imm = 0x8000000000000000
orq %rdi, %rdx
orq %rsi, %rdx
movq %rdx, (%rax)
movq 0x8(%rbp), %rdx
shrl %ecx
shlq $0x20, %rdx
andq %r8, %rdx
movl %ecx, %esi
orq %rdx, %rsi
movq %rsi, 0x8(%rax)
movq 0x8(%rbp), %rcx
shlq $0x10, %rcx
movabsq $-0x1000000000000, %rdx # imm = 0xFFFF000000000000
andq %rdx, %rcx
orq %rsi, %rcx
movq %rcx, 0x8(%rax)
cmpq $0x0, 0x8(%rbp)
jns 0xb29d
btsq $0x2a, %rcx
movq %rcx, 0x8(%rax)
cmpl $0x0, 0x34(%rsp)
je 0xb2ad
btsq $0x2b, %rcx
movq %rcx, 0x8(%rax)
incq %r14
jmp 0xb134
movq 0x60(%rsp), %rcx
incq %rcx
jmp 0xb10c
movq 0x50(%rsp), %rdi
movq 0x38(%rsp), %rsi
callq 0x10a07
movq 0xb8(%rsp), %rax
movq (%rax), %rax
shlq $0x4, %rax
movq 0x40(%rsp), %rbx
movq %rbx, %rsi
addq %rax, %rsi
movq %rbx, %rdi
callq 0x47dc
movq %rbx, %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq