// File: /workspace/github_c_makefile_star2_O1/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, %rbp
movq %rdi, %r15
movq 0xd8(%rsp), %rbx
movl 0xd0(%rsp), %edx
movaps 0xe0(%rsp), %xmm0
movq 0xf0(%rsp), %rsi
movl 0xdc(%rbp), %r8d
movl 0xe0(%rbp), %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), %r12
movq %r12, %rsi
movl %eax, %r9d
callq 0x1db09
movq %rax, 0x38(%rsp)
movq (%rbx), %rsi
shlq $0x4, %rsi
movq %r15, 0x78(%rsp)
movq %r15, %rdi
callq 0x126e9
movq %rax, 0x68(%rsp)
movq $0x0, (%rbx)
movslq (%r12), %rax
movq %rax, 0x80(%rsp)
testq %rax, %rax
jle 0xc997
movq %r14, %r9
movabsq $0x7fffffff00000000, %r10 # imm = 0x7FFFFFFF00000000
movl 0xd0(%rsp), %eax
decl %eax
movl %eax, 0x64(%rsp)
xorl %eax, %eax
movq %rax, 0x88(%rsp)
leaq (%rax,%rax,2), %rax
movq 0x38(%rsp), %rcx
movl (%rcx,%rax,8), %ebx
testq %rbx, %rbx
je 0xc97e
movq 0x38(%rsp), %rcx
leaq (%rcx,%rax,8), %r15
movq 0x10(%rcx,%rax,8), %r12
xorl %r14d, %r14d
movq %rbx, 0x50(%rsp)
movq %r15, 0x48(%rsp)
movq %r12, 0x40(%rsp)
testq %r9, %r9
sete %al
movq (%r12,%r14,8), %r11
movq (%rbp), %r13
testb $0x3, %r13b
sete %dl
xorl %ecx, %ecx
orb %al, %dl
je 0xc776
testl $0x300000, %r13d        # imm = 0x300000
je 0xc846
movl %r11d, %eax
andl $0x1, %eax
movl 0x4(%r15), %edx
andl $0x1, %edx
cmpl %edx, %eax
jne 0xc83f
btl $0x15, %r13d
jae 0xc846
jmp 0xc84a
movq %rbp, %r12
movq 0x70(%rsp), %rax
movq 0x20(%rax), %rbx
movq %r11, 0x58(%rsp)
movq %r11, %rax
shrq $0x20, %rax
leaq (%rax,%rax,2), %rbp
movq (%rbx,%rbp,8), %rsi
movq %r9, %r15
movq %r9, %rdi
callq 0x2240
xorl %ecx, %ecx
testb $0x1, %r13b
je 0xc808
testl %eax, %eax
jne 0xc808
leaq (%rbx,%rbp,8), %rdx
movl 0xd0(%rsp), %esi
cmpl %esi, 0x10(%rdx)
movq %r15, %r9
movq %r12, %rbp
movabsq $0x7fffffff00000000, %r10 # imm = 0x7FFFFFFF00000000
movq 0x50(%rsp), %rbx
movq 0x48(%rsp), %r15
movq 0x40(%rsp), %r12
movq 0x58(%rsp), %r11
jne 0xc82c
movl 0x4(%r15), %esi
movl %esi, %edi
xorl %r11d, %edi
xorl %ecx, %ecx
movl $0x0, %edx
cmpl $0x2, %edi
jb 0xc84c
movl %r11d, %edx
andl $0x1, %edx
andl $0x1, %esi
xorl %ecx, %ecx
cmpl %esi, %edx
sete %cl
jmp 0xc82c
movq %r15, %r9
movq %r12, %rbp
movabsq $0x7fffffff00000000, %r10 # imm = 0x7FFFFFFF00000000
movq 0x50(%rsp), %rbx
movq 0x48(%rsp), %r15
movq 0x40(%rsp), %r12
movq 0x58(%rsp), %r11
testb $0x2, %r13b
je 0xc744
testl %eax, %eax
jg 0xc84a
jmp 0xc744
btl $0x14, %r13d
jb 0xc84a
movb $0x1, %dl
jmp 0xc84c
xorl %edx, %edx
testb %dl, %dl
je 0xc972
shrl %r11d
movq 0xd8(%rsp), %rsi
movq (%rsi), %rax
leaq 0x1(%rax), %rdx
movq %rdx, (%rsi)
shlq $0x4, %rax
addq 0x68(%rsp), %rax
movq (%r12,%r14,8), %rsi
movl %esi, %edi
andl $0x1, %edi
movl 0x4(%r15), %edx
movl %edx, %r8d
andl $0x1, %r8d
cmpl %r8d, %edi
jne 0xc8a6
movabsq $-0x100000000, %rdi     # imm = 0xFFFFFFFF00000000
andq %rdi, %rsi
movl %r11d, %edi
orq %rsi, %rdi
movq %rdi, (%rax)
jmp 0xc928
testb $0x1, 0x4(%rbp)
jne 0xc8dd
andq %r10, %rsi
movl %r11d, %edi
movabsq $-0x8000000000000000, %r8 # imm = 0x8000000000000000
orq %r8, %rsi
orq %rdi, %rsi
movq %rsi, (%rax)
movq 0x8(%r15), %rsi
movl %esi, %edi
andl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
addl 0x64(%rsp), %edi
shrl %edx
notl %edx
addl %edi, %edx
jmp 0xc92e
movq 0x70(%rsp), %rdi
movq 0x20(%rdi), %rdi
movq %rsi, %r8
shrq $0x20, %r8
leaq (%r8,%r8,2), %r8
movl 0x10(%rdi,%r8,8), %edi
andq %r10, %rsi
movl 0x8(%r15), %r8d
movq %r11, %r13
movl $0x7fffffff, %r11d      # imm = 0x7FFFFFFF
andl %r11d, %r8d
subl %r13d, %edi
addl %r8d, %edi
addl $-0x2, %edi
movslq %edi, %rdi
movabsq $-0x8000000000000000, %r8 # imm = 0x8000000000000000
orq %r8, %rsi
orq %rdi, %rsi
movq %rsi, (%rax)
movq 0x8(%r15), %rsi
shrl %edx
shlq $0x20, %rsi
andq %r10, %rsi
movl %edx, %edi
orq %rsi, %rdi
movq %rdi, 0x8(%rax)
movq 0x8(%r15), %rdx
shlq $0x10, %rdx
movabsq $-0x1000000000000, %rsi # imm = 0xFFFF000000000000
andq %rsi, %rdx
orq %rdi, %rdx
movq %rdx, 0x8(%rax)
cmpq $0x0, 0x8(%r15)
jns 0xc96a
btsq $0x2a, %rdx
movq %rdx, 0x8(%rax)
testl %ecx, %ecx
je 0xc972
orb $0x8, 0xd(%rax)
incq %r14
cmpq %r14, %rbx
jne 0xc729
movq 0x88(%rsp), %rax
incq %rax
cmpq 0x80(%rsp), %rax
jne 0xc6ec
movq 0x78(%rsp), %rdi
movq 0x38(%rsp), %rsi
callq 0x1261e
movq 0xd8(%rsp), %rax
movq (%rax), %rax
shlq $0x4, %rax
movq 0x68(%rsp), %rbx
movq %rbx, %rsi
addq %rax, %rsi
movq %rbx, %rdi
callq 0x5ae1
movq %rbx, %rax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq