// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0xa8, %rsp
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movl 0x10(%rbp), %eax
movq %rdi, -0x20(%rbp)
movq %rsi, -0x28(%rbp)
movl %edx, -0x2c(%rbp)
movq %rcx, -0x38(%rbp)
movq %r8, -0x40(%rbp)
movq %r9, -0x48(%rbp)
movq -0x20(%rbp), %rdi
movl 0x10(%rbp), %edx
movl -0x2c(%rbp), %ecx
movq -0x28(%rbp), %rax
movl 0xdc(%rax), %r8d
movq -0x28(%rbp), %rax
movl 0xe0(%rax), %r9d
movq -0x38(%rbp), %r15
movq -0x48(%rbp), %r14
movq 0x18(%rbp), %rbx
movq 0x20(%rbp), %r11
movq 0x28(%rbp), %r10
movq 0x30(%rbp), %rax
leaq -0x50(%rbp), %rsi
movq %r15, (%rsp)
movq %r14, 0x8(%rsp)
movq %rbx, 0x10(%rsp)
movq %r11, 0x18(%rsp)
movq %r10, 0x20(%rsp)
movq %rax, 0x28(%rsp)
callq 0x2d1b0
movq %rax, -0x58(%rbp)
movq -0x20(%rbp), %rdi
movq 0x18(%rbp), %rax
movq (%rax), %rsi
shlq $0x4, %rsi
callq 0x1aae0
movq %rax, -0x60(%rbp)
movl $0x0, -0x4c(%rbp)
movq 0x18(%rbp), %rax
movq $0x0, (%rax)
movl -0x4c(%rbp), %eax
cmpl -0x50(%rbp), %eax
jge 0x11720
movq -0x58(%rbp), %rax
movslq -0x4c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x70(%rbp)
movl $0x0, -0x74(%rbp)
movl -0x74(%rbp), %eax
movq -0x68(%rbp), %rcx
cmpl (%rcx), %eax
jae 0x11710
movq -0x70(%rbp), %rax
movl -0x74(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrl %eax
movl %eax, -0x7c(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rax
movl %eax, %edi
movq -0x70(%rbp), %rax
movl -0x74(%rbp), %ecx
movq (%rax,%rcx,8), %rsi
movq -0x68(%rbp), %rdx
movq -0x40(%rbp), %rcx
movl 0x10(%rbp), %r8d
movq -0x38(%rbp), %r9
leaq -0x78(%rbp), %rax
movq %rax, (%rsp)
callq 0x13140
cmpl $0x0, %eax
je 0x114a2
jmp 0x11702
movq -0x60(%rbp), %rax
movq 0x18(%rbp), %rdx
movq (%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, (%rdx)
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x88(%rbp)
movq -0x70(%rbp), %rax
movl -0x74(%rbp), %ecx
movq (%rax,%rcx,8), %rax
andq $0x1, %rax
movq -0x68(%rbp), %rcx
movl 0x4(%rcx), %ecx
andl $0x1, %ecx
movl %ecx, %ecx
cmpq %rcx, %rax
jne 0x11541
movq -0x70(%rbp), %rax
movl -0x74(%rbp), %ecx
movl %ecx, %edx
movabsq $-0x100000000, %rcx     # imm = 0xFFFFFFFF00000000
andq (%rax,%rdx,8), %rcx
movslq -0x7c(%rbp), %rax
orq %rax, %rcx
movq -0x88(%rbp), %rax
movq %rcx, (%rax)
movq -0x68(%rbp), %rax
movq 0x8(%rax), %rax
andq $0x7fffffff, %rax       # imm = 0x7FFFFFFF
movl %eax, %eax
movl %eax, %ecx
shlq $0x20, %rcx
movq -0x68(%rbp), %rax
movl 0x4(%rax), %eax
shrl %eax
movl %eax, %eax
orq %rax, %rcx
movq -0x88(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x1168e
movq -0x28(%rbp), %rcx
movabsq $0x100000000, %rax      # imm = 0x100000000
andq (%rcx), %rax
cmpq $0x0, %rax
jne 0x115e1
movq -0x70(%rbp), %rax
movl -0x74(%rbp), %ecx
movl %ecx, %edx
movabsq $-0x100000000, %rcx     # imm = 0xFFFFFFFF00000000
andq (%rax,%rdx,8), %rcx
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
orq %rax, %rcx
movslq -0x7c(%rbp), %rax
orq %rax, %rcx
movq -0x88(%rbp), %rax
movq %rcx, (%rax)
movq -0x68(%rbp), %rax
movq 0x8(%rax), %rax
andq $0x7fffffff, %rax       # imm = 0x7FFFFFFF
movl %eax, %eax
movl %eax, %ecx
shlq $0x20, %rcx
movl 0x10(%rbp), %eax
movq -0x68(%rbp), %rdx
movl 0x4(%rdx), %edx
shrl %edx
addl $0x1, %edx
movq -0x68(%rbp), %rsi
movq 0x8(%rsi), %rsi
andq $0x7fffffff, %rsi       # imm = 0x7FFFFFFF
subl %esi, %edx
subl %edx, %eax
subl $0x1, %eax
movl %eax, %eax
orq %rax, %rcx
movq -0x88(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x1168c
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x70(%rbp), %rcx
movl -0x74(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movl %eax, -0x8c(%rbp)
movq -0x70(%rbp), %rax
movl -0x74(%rbp), %ecx
movl %ecx, %edx
movabsq $-0x100000000, %rcx     # imm = 0xFFFFFFFF00000000
andq (%rax,%rdx,8), %rcx
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
orq %rax, %rcx
movl -0x8c(%rbp), %eax
movl -0x7c(%rbp), %edx
addl $0x1, %edx
movq -0x68(%rbp), %rsi
movq 0x8(%rsi), %rsi
andq $0x7fffffff, %rsi       # imm = 0x7FFFFFFF
subl %esi, %edx
subl %edx, %eax
subl $0x1, %eax
cltq
orq %rax, %rcx
movq -0x88(%rbp), %rax
movq %rcx, (%rax)
movq -0x68(%rbp), %rax
movq 0x8(%rax), %rax
andq $0x7fffffff, %rax       # imm = 0x7FFFFFFF
movl %eax, %eax
movl %eax, %ecx
shlq $0x20, %rcx
movq -0x68(%rbp), %rax
movl 0x4(%rax), %eax
shrl %eax
movl %eax, %eax
orq %rax, %rcx
movq -0x88(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x1168e
movq -0x68(%rbp), %rax
movq 0x8(%rax), %rax
shrq $0x20, %rax
andq $0x7fffffff, %rax       # imm = 0x7FFFFFFF
movl %eax, %eax
movl %eax, %ecx
shlq $0x30, %rcx
movq -0x88(%rbp), %rax
orq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq -0x68(%rbp), %rax
movq 0x8(%rax), %rax
shrq $0x3f, %rax
cmpl $0x0, %eax
je 0x116e1
movq -0x88(%rbp), %rax
movabsq $0x40000000000, %rcx    # imm = 0x40000000000
orq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
cmpl $0x0, -0x78(%rbp)
je 0x11700
movq -0x88(%rbp), %rax
movabsq $0x80000000000, %rcx    # imm = 0x80000000000
orq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
jmp 0x11702
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x11448
jmp 0x11712
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x11416
movq -0x20(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x1a8c0
movq -0x60(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq 0x18(%rbp), %rax
movq (%rax), %rax
shlq $0x4, %rax
addq %rax, %rsi
callq 0x5ad0
movq -0x60(%rbp), %rax
addq $0xa8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nopw (%rax,%rax)