// File: /workspace/github_c_makefile_star2_O0/lh3[P]minigraph/map-algo.c
// Function: collect_seed_hits
static mg128_t *collect_seed_hits(void *km, const mg_mapopt_t *opt, int max_occ, const mg_idx_t *gi, const char *qname, const mg128_v *mv, int qlen, int64_t *n_a, int *rep_len,
								  int *n_mini_pos, int32_t **mini_pos)
{
	int i, n_m;
	mg_match_t *m;
	mg128_t *a;
	m = collect_matches(km, &n_m, max_occ, gi, mv, n_a, rep_len, n_mini_pos, mini_pos);
	a = (mg128_t*)kmalloc(km, *n_a * sizeof(mg128_t));
	for (i = 0, *n_a = 0; i < n_m; ++i) {
		mg_match_t *q = &m[i];
		const uint64_t *r = q->cr;
		uint32_t k;
		for (k = 0; k < q->n; ++k) {
			int32_t rpos = (uint32_t)r[k] >> 1;
			mg128_t *p;
			if (qname && (opt->flag & MG_M_NO_DIAG)) {
				const gfa_seg_t *s = &gi->g->seg[r[k]>>32];
				const char *gname = s->snid >= 0 && gi->g->sseq? gi->g->sseq[s->snid].name : s->name;
				int32_t g_pos;
				if (s->snid >= 0 && gi->g->sseq)
					gname = gi->g->sseq[s->snid].name, g_pos = s->soff + (uint32_t)r[k];
				else
					gname = s->name, g_pos = (uint32_t)r[k];
				if (g_pos == q->q_pos && strcmp(qname, gname) == 0)
					continue;
			}
			p = &a[(*n_a)++];
			if ((r[k]&1) == (q->q_pos&1)) // forward strand
				p->x = r[k]>>32<<33 | rpos;
			else // reverse strand
				p->x = r[k]>>32<<33 | 1ULL<<32 | (gi->g->seg[r[k]>>32].len - (rpos + 1 - q->q_span) - 1);
			p->y = (uint64_t)q->q_span << 32 | q->q_pos >> 1;
			p->y |= (uint64_t)q->seg_id << MG_SEED_SEG_SHIFT;
			if (q->is_tandem) p->y |= MG_SEED_TANDEM;
			p->y |= (uint64_t)(q->n < 255? q->n : 255) << MG_SEED_OCC_SHIFT;
		}
	}
	kfree(km, m);
	radix_sort_128x(a, a + (*n_a));
	return a;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %edx
movq -0x20(%rbp), %rcx
movq -0x30(%rbp), %r8
movq 0x18(%rbp), %r9
movq 0x20(%rbp), %r11
movq 0x28(%rbp), %r10
movq 0x30(%rbp), %rax
leaq -0x38(%rbp), %rsi
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x2f290
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq 0x18(%rbp), %rax
movq (%rax), %rsi
shlq $0x4, %rsi
callq 0x2890
movq %rax, -0x48(%rbp)
movl $0x0, -0x34(%rbp)
movq 0x18(%rbp), %rax
movq $0x0, (%rax)
movl -0x34(%rbp), %eax
cmpl -0x38(%rbp), %eax
jge 0x2e605
movq -0x40(%rbp), %rax
movslq -0x34(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x58(%rbp)
movl $0x0, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movq -0x50(%rbp), %rcx
cmpl (%rcx), %eax
jae 0x2e5f5
movq -0x58(%rbp), %rax
movl -0x5c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrl %eax
movl %eax, -0x60(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x2e47a
movq -0x10(%rbp), %rax
movq (%rax), %rax
andq $0x400000, %rax         # imm = 0x400000
cmpq $0x0, %rax
je 0x2e47a
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq -0x58(%rbp), %rcx
movl -0x5c(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jl 0x2e3cf
movq -0x20(%rbp), %rax
movq (%rax), %rax
cmpq $0x0, 0x28(%rax)
je 0x2e3cf
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq 0x28(%rax), %rax
movq -0x70(%rbp), %rcx
movslq 0x8(%rcx), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0x88(%rbp)
jmp 0x2e3de
movq -0x70(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x70(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jl 0x2e43b
movq -0x20(%rbp), %rax
movq (%rax), %rax
cmpq $0x0, 0x28(%rax)
je 0x2e43b
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq 0x28(%rax), %rax
movq -0x70(%rbp), %rcx
movslq 0x8(%rcx), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x70(%rbp), %rax
movl 0xc(%rax), %eax
movq -0x58(%rbp), %rcx
movl -0x5c(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
addl %ecx, %eax
movl %eax, -0x7c(%rbp)
jmp 0x2e455
movq -0x70(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x58(%rbp), %rax
movl -0x5c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
movq -0x50(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jne 0x2e478
movq -0x28(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0x21f0
cmpl $0x0, %eax
jne 0x2e478
jmp 0x2e5e7
jmp 0x2e47a
movq -0x48(%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, -0x68(%rbp)
movq -0x58(%rbp), %rax
movl -0x5c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
andq $0x1, %rax
movq -0x50(%rbp), %rcx
movl 0x4(%rcx), %ecx
andl $0x1, %ecx
movl %ecx, %ecx
cmpq %rcx, %rax
jne 0x2e4dd
movq -0x58(%rbp), %rax
movl -0x5c(%rbp), %ecx
movq (%rax,%rcx,8), %rcx
shrq $0x20, %rcx
shlq $0x21, %rcx
movslq -0x60(%rbp), %rax
orq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rcx, (%rax)
jmp 0x2e53e
movq -0x58(%rbp), %rax
movl -0x5c(%rbp), %ecx
movq (%rax,%rcx,8), %rcx
shrq $0x20, %rcx
shlq $0x21, %rcx
movabsq $0x100000000, %rax      # imm = 0x100000000
orq %rax, %rcx
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq -0x58(%rbp), %rdx
movl -0x5c(%rbp), %esi
movq (%rdx,%rsi,8), %rdx
shrq $0x20, %rdx
shlq $0x6, %rdx
addq %rdx, %rax
movl (%rax), %eax
movl -0x60(%rbp), %edx
addl $0x1, %edx
movq -0x50(%rbp), %rsi
subl 0x8(%rsi), %edx
subl %edx, %eax
subl $0x1, %eax
movl %eax, %eax
orq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rcx, (%rax)
movq -0x50(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, %ecx
shlq $0x20, %rcx
movq -0x50(%rbp), %rax
movl 0x4(%rax), %eax
shrl %eax
movl %eax, %eax
orq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x50(%rbp), %rax
movl 0xc(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movl %eax, %ecx
shlq $0x30, %rcx
movq -0x68(%rbp), %rax
orq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq -0x50(%rbp), %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x2e5a6
movq -0x68(%rbp), %rax
movabsq $0x40000000000, %rcx    # imm = 0x40000000000
orq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq -0x50(%rbp), %rax
cmpl $0xff, (%rax)
jae 0x2e5c0
movq -0x50(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x8c(%rbp)
jmp 0x2e5cd
movl $0xff, %eax
movl %eax, -0x8c(%rbp)
jmp 0x2e5cd
movl -0x8c(%rbp), %eax
movl %eax, %eax
movl %eax, %ecx
shlq $0x38, %rcx
movq -0x68(%rbp), %rax
orq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x2e32b
jmp 0x2e5f7
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x2e2f9
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x2670
movq -0x48(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq 0x18(%rbp), %rax
movq (%rax), %rax
shlq $0x4, %rax
addq %rax, %rsi
callq 0x15f50
movq -0x48(%rbp), %rax
addq $0xb0, %rsp
popq %rbp
retq
nopw (%rax,%rax)