// File: /workspace/github_c_makefile_star2_O3/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 $0x98, %rsp
movq %r8, %r14
movq %rcx, %r10
movl %edx, %ecx
movq %rsi, %r12
movq %rdi, %r15
movq 0xd8(%rsp), %rbx
movl 0xd0(%rsp), %edx
movaps 0xe0(%rsp), %xmm0
movq 0xf0(%rsp), %rsi
movl 0xdc(%r12), %r8d
movl 0xe0(%r12), %eax
movq %rsi, 0x28(%rsp)
movups %xmm0, 0x18(%rsp)
movq %rbx, 0x10(%rsp)
movq %r9, 0x8(%rsp)
movq %r10, 0x70(%rsp)
movq %r10, (%rsp)
leaq 0x94(%rsp), %r13
movq %r13, %rsi
movl %eax, %r9d
callq 0x1db42
movq %rax, 0x38(%rsp)
movq (%rbx), %rsi
shlq $0x4, %rsi
movq %r15, 0x78(%rsp)
movq %r15, %rdi
callq 0x1264d
movq %rax, 0x68(%rsp)
movq $0x0, (%rbx)
movslq (%r13), %rax
movq %rax, 0x80(%rsp)
testq %rax, %rax
jle 0xc8c4
movq %r14, %rdi
movabsq $0x7fffffff00000000, %r9 # imm = 0x7FFFFFFF00000000
movl 0xd0(%rsp), %eax
decl %eax
movl %eax, 0x64(%rsp)
xorl %eax, %eax
movq %r12, 0x40(%rsp)
movq %rax, 0x88(%rsp)
leaq (%rax,%rax,2), %rax
movq 0x38(%rsp), %rcx
movl (%rcx,%rax,8), %r11d
testq %r11, %r11
je 0xc8ab
movq 0x38(%rsp), %rcx
leaq (%rcx,%rax,8), %r15
movq 0x10(%rcx,%rax,8), %rbp
xorl %r14d, %r14d
movq %r11, 0x58(%rsp)
movq %r15, 0x50(%rsp)
movq %rbp, 0x48(%rsp)
testq %rdi, %rdi
sete %al
movq (%rbp,%r14,8), %r13
movq (%r12), %rbx
testb $0x3, %bl
sete %cl
orb %al, %cl
movb $0x1, %r10b
je 0xc65a
movl 0x4(%r15), %eax
testl $0x300000, %ebx         # imm = 0x300000
je 0xc6f1
movl %r13d, %ecx
andl $0x1, %ecx
movl %eax, %esi
andl $0x1, %esi
cmpl %esi, %ecx
jne 0xc6f8
btl $0x15, %ebx
jae 0xc702
jmp 0xc874
movq 0x70(%rsp), %rax
movq 0x20(%rax), %rbp
movq %r13, %rax
shrq $0x20, %rax
leaq (%rax,%rax,2), %r12
movq (%rbp,%r12,8), %rsi
movq %rdi, %r15
callq 0x2240
testb $0x1, %bl
je 0xc788
testl %eax, %eax
jne 0xc788
leaq (,%r12,8), %rax
addq %rbp, %rax
movl 0xd0(%rsp), %ecx
cmpl %ecx, 0x10(%rax)
movq %r15, %rdi
movq 0x40(%rsp), %r12
movabsq $0x7fffffff00000000, %r9 # imm = 0x7FFFFFFF00000000
movq 0x58(%rsp), %r11
movq 0x50(%rsp), %r15
movq 0x48(%rsp), %rbp
movb $0x1, %r10b
jne 0xc628
movl 0x4(%r15), %eax
movl %eax, %ecx
xorl %r13d, %ecx
cmpl $0x2, %ecx
jb 0xc874
movl %r13d, %ecx
andl $0x1, %ecx
andl $0x1, %eax
cmpl %eax, %ecx
setne %r10b
jmp 0xc628
movl %eax, %esi
andl $0x1, %esi
jmp 0xc702
btl $0x14, %ebx
jb 0xc874
shrl %r13d
movq 0xd8(%rsp), %r8
movq (%r8), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%r8)
shlq $0x4, %rcx
addq 0x68(%rsp), %rcx
movq (%rbp,%r14,8), %rdx
movl %edx, %r8d
andl $0x1, %r8d
cmpl %esi, %r8d
jne 0xc74c
movabsq $-0x100000000, %rsi     # imm = 0xFFFFFFFF00000000
andq %rsi, %rdx
movl %r13d, %esi
orq %rdx, %rsi
movq %rsi, (%rcx)
jmp 0xc810
testb $0x1, 0x4(%r12)
jne 0xc7c2
andq %r9, %rdx
movl %r13d, %esi
movabsq $-0x8000000000000000, %r8 # imm = 0x8000000000000000
orq %r8, %rdx
orq %rsi, %rdx
movq %rdx, (%rcx)
movq 0x8(%r15), %rdx
movl %edx, %esi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
addl 0x64(%rsp), %esi
shrl %eax
notl %eax
addl %esi, %eax
jmp 0xc816
testb $0x2, %bl
je 0xc882
testl %eax, %eax
movq %r15, %rdi
movq 0x40(%rsp), %r12
movabsq $0x7fffffff00000000, %r9 # imm = 0x7FFFFFFF00000000
movq 0x58(%rsp), %r11
movq 0x50(%rsp), %r15
movq 0x48(%rsp), %rbp
movb $0x1, %r10b
jg 0xc874
jmp 0xc628
movq 0x70(%rsp), %rsi
movq 0x20(%rsi), %rsi
movq %rdx, %r8
shrq $0x20, %r8
leaq (%r8,%r8,2), %r8
movl 0x10(%rsi,%r8,8), %esi
andq %r9, %rdx
movl 0x8(%r15), %r8d
movl %r10d, %ebx
movl $0x7fffffff, %r10d      # imm = 0x7FFFFFFF
andl %r10d, %r8d
movl %ebx, %r10d
subl %r13d, %esi
addl %r8d, %esi
addl $-0x2, %esi
movslq %esi, %rsi
movabsq $-0x8000000000000000, %r8 # imm = 0x8000000000000000
orq %r8, %rdx
orq %rsi, %rdx
movq %rdx, (%rcx)
movq 0x8(%r15), %rdx
shrl %eax
shlq $0x20, %rdx
andq %r9, %rdx
movl %eax, %esi
orq %rdx, %rsi
movq %rsi, 0x8(%rcx)
movq 0x8(%r15), %rax
shlq $0x10, %rax
movabsq $-0x1000000000000, %rdx # imm = 0xFFFF000000000000
andq %rdx, %rax
orq %rsi, %rax
movq %rax, 0x8(%rcx)
movq 0x8(%r15), %rdx
testq %rdx, %rdx
setns %sil
testb %r10b, %sil
jne 0xc874
movq %rax, %rsi
btsq $0x2a, %rsi
testq %rdx, %rdx
cmovnsq %rax, %rsi
movq %rsi, %rax
btsq $0x2b, %rax
testb %r10b, %r10b
cmovneq %rsi, %rax
movq %rax, 0x8(%rcx)
incq %r14
cmpq %r14, %r11
jne 0xc60c
jmp 0xc8ab
movq %r15, %rdi
movq 0x40(%rsp), %r12
movabsq $0x7fffffff00000000, %r9 # imm = 0x7FFFFFFF00000000
movq 0x58(%rsp), %r11
movq 0x50(%rsp), %r15
movq 0x48(%rsp), %rbp
movb $0x1, %r10b
jmp 0xc628
movq 0x88(%rsp), %rax
incq %rax
cmpq 0x80(%rsp), %rax
jne 0xc5ce
movq 0x78(%rsp), %rdi
movq 0x38(%rsp), %rsi
callq 0x12587
movq 0xd8(%rsp), %rax
movq (%rax), %rax
shlq $0x4, %rax
movq 0x68(%rsp), %rbx
movq %rbx, %rsi
addq %rax, %rsi
movq %rbx, %rdi
callq 0x5a49
movq %rbx, %rax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq