// File: /workspace/github_c_makefile_star2_O0/lh3[P]minimap/map.c
// Function: mm_map
const mm_reg1_t *mm_map(const mm_idx_t *mi, int l_seq, const char *seq, int *n_regs, mm_tbuf_t *b, const mm_mapopt_t *opt, const char *name)
{
	int j, n_dreg = 0, u = 0;
	const uint64_t *dreg = 0;

	b->mini.n = b->coef.n = 0;
	mm_sketch(seq, l_seq, mi->w, mi->k, 0, &b->mini);
	if (opt->sdust_thres > 0)
		dreg = sdust_core((const uint8_t*)seq, l_seq, opt->sdust_thres, 64, &n_dreg, b->sdb);
	for (j = 0; j < b->mini.n; ++j) {
		int k, n;
		const uint64_t *r;
		int32_t qpos = (uint32_t)b->mini.a[j].y>>1, strand = b->mini.a[j].y&1;
		b->mini.a[j].y = b->mini.a[j].y<<32>>32; // clear the rid field
		if (dreg && n_dreg) { // test complexity
			int s = qpos - (mi->k - 1), e = s + mi->k;
			while (u < n_dreg && (uint32_t)dreg[u] <= s) ++u;
			if (u < n_dreg && dreg[u]>>32 < e) {
				int v, l = 0;
				for (v = u; v < n_dreg && dreg[v]>>32 < e; ++v) { // iterate over LCRs overlapping this minimizer
					int ss = s > dreg[v]>>32? s : dreg[v]>>32;
					int ee = e < (uint32_t)dreg[v]? e : (uint32_t)dreg[v];
					l += ee - ss;
				}
				if (l > mi->k>>1) continue;
			}
		}
		r = mm_idx_get(mi, b->mini.a[j].x, &n);
		if (n > mi->max_occ) continue;
		for (k = 0; k < n; ++k) {
			int32_t rpos = (uint32_t)r[k] >> 1;
			mm128_t *p;
			if (name && (opt->flag&MM_F_NO_SELF) && mi->name && strcmp(name, mi->name[r[k]>>32]) == 0 && rpos == qpos)
				continue;
			if (name && (opt->flag&MM_F_AVA) && mi->name && strcmp(name, mi->name[r[k]>>32]) > 0)
				continue;
			kv_pushp(mm128_t, b->coef, &p);
			if ((r[k]&1) == strand) { // forward strand
				p->x = (uint64_t)r[k] >> 32 << 32 | (0x80000000U + rpos - qpos);
				p->y = (uint64_t)j << 32 | rpos;
			} else { // reverse strand
				p->x = (uint64_t)r[k] >> 32 << 32 | (rpos + qpos) | 1ULL<<63;
				p->y = (uint64_t)j << 32 | rpos;
			}
		}
	}
	radix_sort_128x(b->coef.a, b->coef.a + b->coef.n);
	b->reg.n = 0;
	get_reg(b, opt->radius, mi->k, opt->min_cnt, opt->max_gap, opt->merge_frac, opt->flag);
	*n_regs = b->reg.n;
	return b->reg.a;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movl $0x0, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x28(%rbp), %rax
movq $0x0, 0x18(%rax)
movq -0x28(%rbp), %rax
movq $0x0, (%rax)
movq -0x18(%rbp), %rdi
movl -0xc(%rbp), %esi
movq -0x8(%rbp), %rax
movl 0x4(%rax), %edx
movq -0x8(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x28(%rbp), %r9
xorl %r8d, %r8d
callq 0x9bb0
movq -0x30(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jle 0x7666
movq -0x18(%rbp), %rdi
movl -0xc(%rbp), %esi
movq -0x30(%rbp), %rax
movl 0x10(%rax), %edx
movq -0x28(%rbp), %rax
movq 0x78(%rax), %r9
movl $0x40, %ecx
leaq -0x38(%rbp), %r8
callq 0xa700
movq %rax, -0x48(%rbp)
movl $0x0, -0x34(%rbp)
movslq -0x34(%rbp), %rax
movq -0x28(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x7afd
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x34(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
shrl %eax
movl %eax, -0x5c(%rbp)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x34(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
andq $0x1, %rax
movl %eax, -0x60(%rbp)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x34(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rcx
shlq $0x20, %rcx
shrq $0x20, %rcx
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x34(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
cmpq $0x0, -0x48(%rbp)
je 0x7889
cmpl $0x0, -0x38(%rbp)
je 0x7889
movl -0x5c(%rbp), %eax
movq -0x8(%rbp), %rcx
movl 0x8(%rcx), %ecx
subl $0x1, %ecx
subl %ecx, %eax
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %eax
movq -0x8(%rbp), %rcx
addl 0x8(%rcx), %eax
movl %eax, -0x68(%rbp)
movl -0x3c(%rbp), %ecx
xorl %eax, %eax
cmpl -0x38(%rbp), %ecx
movb %al, -0x89(%rbp)
jge 0x774a
movq -0x48(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
cmpl -0x64(%rbp), %eax
setbe %al
movb %al, -0x89(%rbp)
movb -0x89(%rbp), %al
testb $0x1, %al
jne 0x7756
jmp 0x7761
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x7722
movl -0x3c(%rbp), %eax
cmpl -0x38(%rbp), %eax
jge 0x7887
movq -0x48(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movslq -0x68(%rbp), %rcx
cmpq %rcx, %rax
jae 0x7887
movl $0x0, -0x70(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x6c(%rbp)
movl -0x6c(%rbp), %ecx
xorl %eax, %eax
cmpl -0x38(%rbp), %ecx
movb %al, -0x8a(%rbp)
jge 0x77c7
movq -0x48(%rbp), %rax
movslq -0x6c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movslq -0x68(%rbp), %rcx
cmpq %rcx, %rax
setb %al
movb %al, -0x8a(%rbp)
movb -0x8a(%rbp), %al
testb $0x1, %al
jne 0x77d6
jmp 0x7870
movslq -0x64(%rbp), %rax
movq -0x48(%rbp), %rcx
movslq -0x6c(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
cmpq %rcx, %rax
jbe 0x77fc
movslq -0x64(%rbp), %rax
movq %rax, -0x98(%rbp)
jmp 0x7813
movq -0x48(%rbp), %rax
movslq -0x6c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
movl %eax, -0x74(%rbp)
movl -0x68(%rbp), %eax
movq -0x48(%rbp), %rcx
movslq -0x6c(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
cmpl %ecx, %eax
jae 0x783b
movl -0x68(%rbp), %eax
movl %eax, -0x9c(%rbp)
jmp 0x784d
movq -0x48(%rbp), %rax
movslq -0x6c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
movl %eax, -0x78(%rbp)
movl -0x78(%rbp), %eax
subl -0x74(%rbp), %eax
addl -0x70(%rbp), %eax
movl %eax, -0x70(%rbp)
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x7797
movl -0x70(%rbp), %eax
movq -0x8(%rbp), %rcx
movl 0x8(%rcx), %ecx
sarl %ecx
cmpl %ecx, %eax
jle 0x7885
jmp 0x7aef
jmp 0x7887
jmp 0x7889
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x34(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rsi
leaq -0x50(%rbp), %rdx
callq 0x47c0
movq %rax, -0x58(%rbp)
movl -0x50(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jbe 0x78c1
jmp 0x7aef
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x50(%rbp), %eax
jge 0x7aed
movq -0x58(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrl %eax
movl %eax, -0x7c(%rbp)
cmpq $0x0, 0x10(%rbp)
je 0x793d
movq -0x30(%rbp), %rax
movl 0x14(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x793d
movq -0x8(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x793d
movq 0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x58(%rbp), %rcx
movslq -0x4c(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
movq (%rax,%rcx,8), %rsi
callq 0x2160
cmpl $0x0, %eax
jne 0x793d
movl -0x7c(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jne 0x793d
jmp 0x7adf
cmpq $0x0, 0x10(%rbp)
je 0x798d
movq -0x30(%rbp), %rax
movl 0x14(%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x798d
movq -0x8(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x798d
movq 0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x58(%rbp), %rcx
movslq -0x4c(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
movq (%rax,%rcx,8), %rsi
callq 0x2160
cmpl $0x0, %eax
jle 0x798d
jmp 0x7adf
jmp 0x798f
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x28(%rbp), %rcx
cmpq 0x20(%rcx), %rax
jne 0x7a01
movq -0x28(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x79c0
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rax
shlq %rax
movq %rax, -0xa8(%rbp)
jmp 0x79ce
movl $0x2, %eax
movq %rax, -0xa8(%rbp)
jmp 0x79ce
movq -0xa8(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x28(%rbp), %rax
movq 0x28(%rax), %rdi
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rsi
shlq $0x4, %rsi
callq 0x2200
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x28(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x28(%rbp), %rdx
movq 0x18(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x18(%rdx)
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x88(%rbp)
movq -0x58(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
andq $0x1, %rax
movslq -0x60(%rbp), %rcx
cmpq %rcx, %rax
jne 0x7a8d
movq -0x58(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
shrq $0x20, %rcx
shlq $0x20, %rcx
movl -0x7c(%rbp), %eax
addl $0x80000000, %eax       # imm = 0x80000000
subl -0x5c(%rbp), %eax
movl %eax, %eax
orq %rax, %rcx
movq -0x88(%rbp), %rax
movq %rcx, (%rax)
movslq -0x34(%rbp), %rcx
shlq $0x20, %rcx
movslq -0x7c(%rbp), %rax
orq %rax, %rcx
movq -0x88(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x7add
movq -0x58(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
shrq $0x20, %rcx
shlq $0x20, %rcx
movl -0x7c(%rbp), %eax
addl -0x5c(%rbp), %eax
cltq
orq %rax, %rcx
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
orq %rax, %rcx
movq -0x88(%rbp), %rax
movq %rcx, (%rax)
movslq -0x34(%rbp), %rcx
shlq $0x20, %rcx
movslq -0x7c(%rbp), %rax
orq %rax, %rcx
movq -0x88(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x7adf
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x78c8
jmp 0x7aef
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x766d
movq -0x28(%rbp), %rax
movq 0x28(%rax), %rdi
movq -0x28(%rbp), %rax
movq 0x28(%rax), %rsi
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rax
shlq $0x4, %rax
addq %rax, %rsi
callq 0x33e0
movq -0x28(%rbp), %rax
movq $0x0, 0xa0(%rax)
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rax
movl (%rax), %esi
movq -0x8(%rbp), %rax
movl 0x8(%rax), %edx
movq -0x30(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x30(%rbp), %rax
movl 0x4(%rax), %r8d
movq -0x30(%rbp), %rax
movss 0x18(%rax), %xmm0
movq -0x30(%rbp), %rax
movl 0x14(%rax), %r9d
callq 0x7b90
movq -0x28(%rbp), %rax
movq 0xa0(%rax), %rax
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x28(%rbp), %rax
movq 0xb0(%rax), %rax
addq $0xb0, %rsp
popq %rbp
retq
nopl (%rax)