// File: /workspace/github_c_makefile_star2_O0/ToniWestbrook[P]paladin/bwamem.c
// Function: mem_collect_intv
static void mem_collect_intv(const mem_opt_t *opt, const bwt_t *bwt, int len, const uint8_t *seq, smem_aux_t *a)
{
	int i, k, x = 0, old_n;
	int start_width = (opt->flag & MEM_F_SELF_OVLP)? 2 : 1;
	int split_len = (int)(opt->min_seed_len * opt->split_factor + .499);
	a->mem.n = 0;
	// first pass: find all SMEMs
	while (x < len) {
		if (seq[x] < VALUE_DEFINED) {
			x = bwt_smem1(bwt, len, seq, x, start_width, &a->mem1, a->tmpv);
			for (i = 0; i < a->mem1.n; ++i) {
				bwtintv_t *p = &a->mem1.a[i];
				int slen = (uint32_t)p->info - (p->info>>32); // seed length
				if (slen >= opt->min_seed_len)
					kv_push(bwtintv_t, a->mem, *p);
			}
		} else ++x;
	}

	// second pass: find MEMs inside a long SMEM
	old_n = a->mem.n;
	for (k = 0; k < old_n; ++k) {
		bwtintv_t *p = &a->mem.a[k];
		int start = p->info>>32, end = (int32_t)p->info;
		if (end - start < split_len || p->x[2] > opt->split_width) continue;

		bwt_smem1(bwt, len, seq, (start + end)>>1, p->x[2]+1, &a->mem1, a->tmpv);
		for (i = 0; i < a->mem1.n; ++i)
			if ((uint32_t)a->mem1.a[i].info - (a->mem1.a[i].info>>32) >= opt->min_seed_len)
				kv_push(bwtintv_t, a->mem, a->mem1.a[i]);
	}

	// third pass: LAST-like
	if (opt->max_mem_intv > 0) {
		x = 0;
		while (x < len) {
			if (seq[x] < VALUE_DEFINED) {
				if (1) {
					bwtintv_t m;
					x = bwt_seed_strategy1(bwt, len, seq, x, opt->min_seed_len, opt->max_mem_intv, &m);
					if (m.x[2] > 0) kv_push(bwtintv_t, a->mem, m);
				} else { // for now, we never come to this block which is slower
					x = bwt_smem1a(bwt, len, seq, x, start_width, opt->max_mem_intv, &a->mem1, a->tmpv);
					for (i = 0; i < a->mem1.n; ++i)
						kv_push(bwtintv_t, a->mem, a->mem1.a[i]);
				}
			} else ++x;
		}
	}

	// sort
	ks_introsort(mem_intv, a->mem.n, a->mem.a);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x8(%rbp), %rax
movl 0x48(%rax), %edx
andl $0x40, %edx
movl $0x1, %eax
movl $0x2, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x3c(%rbp)
movq -0x8(%rbp), %rax
cvtsi2ssl 0x78(%rax), %xmm0
movq -0x8(%rbp), %rax
mulss 0x84(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x19ec5(%rip), %xmm1    # 0x377a8
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x40(%rbp)
movq -0x28(%rbp), %rax
movq $0x0, (%rax)
movl -0x34(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x1da8e
movq -0x20(%rbp), %rax
movslq -0x34(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x16, %eax
jge 0x1da80
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movq -0x20(%rbp), %rdx
movl -0x34(%rbp), %ecx
movl -0x3c(%rbp), %r8d
movq -0x28(%rbp), %r9
addq $0x18, %r9
movq -0x28(%rbp), %rax
addq $0x30, %rax
movq %rax, (%rsp)
callq 0x157c0
movl %eax, -0x34(%rbp)
movl $0x0, -0x2c(%rbp)
movslq -0x2c(%rbp), %rax
movq -0x28(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jae 0x1da7e
movq -0x28(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x2c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rax
movl %eax, %eax
movq -0x48(%rbp), %rcx
movq 0x18(%rcx), %rcx
shrq $0x20, %rcx
subq %rcx, %rax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x78(%rcx), %eax
jl 0x1da6e
jmp 0x1d9a6
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq -0x28(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x1da2a
movq -0x28(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x1d9d6
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0x88(%rbp)
jmp 0x1d9e4
movl $0x2, %eax
movq %rax, -0x88(%rbp)
jmp 0x1d9e4
movq -0x88(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rsi
shlq $0x5, %rsi
leaq 0x1ccaa(%rip), %rdx     # 0x3a6b8
movl $0xc9, %ecx
leaq 0x1d570(%rip), %r8      # 0x3af8a
callq 0x31d40
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x28(%rbp), %rdx
movq (%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, (%rdx)
shlq $0x5, %rcx
addq %rcx, %rax
movq -0x48(%rbp), %rcx
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq 0x10(%rcx), %rdx
movq %rdx, 0x10(%rax)
movq 0x18(%rcx), %rcx
movq %rcx, 0x18(%rax)
jmp 0x1da6e
jmp 0x1da70
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x1d94f
jmp 0x1da89
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x1d8f9
movq -0x28(%rbp), %rax
movq (%rax), %rax
movl %eax, -0x38(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x38(%rbp), %eax
jge 0x1dc99
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x30(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq 0x18(%rax), %rax
shrq $0x20, %rax
movl %eax, -0x5c(%rbp)
movq -0x58(%rbp), %rax
movq 0x18(%rax), %rax
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %eax
subl -0x5c(%rbp), %eax
cmpl -0x40(%rbp), %eax
jl 0x1daff
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x8(%rbp), %rcx
movslq 0x88(%rcx), %rcx
cmpq %rcx, %rax
jbe 0x1db04
jmp 0x1dc8b
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movq -0x20(%rbp), %rdx
movl -0x5c(%rbp), %ecx
addl -0x60(%rbp), %ecx
sarl %ecx
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rax
addq $0x1, %rax
movl %eax, %r8d
movq -0x28(%rbp), %r9
addq $0x18, %r9
movq -0x28(%rbp), %rax
addq $0x30, %rax
movq %rax, (%rsp)
callq 0x157c0
movl $0x0, -0x2c(%rbp)
movslq -0x2c(%rbp), %rax
movq -0x28(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jae 0x1dc89
movq -0x28(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x2c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
movl %eax, %eax
movq -0x28(%rbp), %rcx
movq 0x28(%rcx), %rcx
movslq -0x2c(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movq 0x18(%rcx), %rcx
shrq $0x20, %rcx
subq %rcx, %rax
movq -0x8(%rbp), %rcx
movslq 0x78(%rcx), %rcx
cmpq %rcx, %rax
jb 0x1dc79
jmp 0x1dba2
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq -0x28(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x1dc26
movq -0x28(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x1dbd2
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0x90(%rbp)
jmp 0x1dbe0
movl $0x2, %eax
movq %rax, -0x90(%rbp)
jmp 0x1dbe0
movq -0x90(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rsi
shlq $0x5, %rsi
leaq 0x1caae(%rip), %rdx     # 0x3a6b8
movl $0xd8, %ecx
leaq 0x1d374(%rip), %r8      # 0x3af8a
callq 0x31d40
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x28(%rbp), %rdx
movq (%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, (%rdx)
shlq $0x5, %rcx
addq %rcx, %rax
movq -0x28(%rbp), %rcx
movq 0x28(%rcx), %rcx
movslq -0x2c(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq 0x10(%rcx), %rdx
movq %rdx, 0x10(%rax)
movq 0x18(%rcx), %rcx
movq %rcx, 0x18(%rax)
jmp 0x1dc79
jmp 0x1dc7b
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x1db46
jmp 0x1dc8b
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x1da9f
movq -0x8(%rbp), %rax
cmpq $0x0, 0x30(%rax)
jbe 0x1dde5
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x1dde3
movq -0x20(%rbp), %rax
movslq -0x34(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x16, %eax
jge 0x1ddd5
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movq -0x20(%rbp), %rdx
movl -0x34(%rbp), %ecx
movq -0x8(%rbp), %rax
movl 0x78(%rax), %r8d
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movl %eax, %r9d
leaq -0x80(%rbp), %rax
movq %rax, (%rsp)
callq 0x15820
movl %eax, -0x34(%rbp)
cmpq $0x0, -0x70(%rbp)
jbe 0x1ddd3
jmp 0x1dd0e
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq -0x28(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x1dd92
movq -0x28(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x1dd3e
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0x98(%rbp)
jmp 0x1dd4c
movl $0x2, %eax
movq %rax, -0x98(%rbp)
jmp 0x1dd4c
movq -0x98(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rsi
shlq $0x5, %rsi
leaq 0x1c942(%rip), %rdx     # 0x3a6b8
movl $0xe3, %ecx
leaq 0x1d208(%rip), %r8      # 0x3af8a
callq 0x31d40
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x28(%rbp), %rdx
movq (%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, (%rdx)
shlq $0x5, %rcx
addq %rcx, %rax
movq -0x80(%rbp), %rcx
movq %rcx, (%rax)
movq -0x78(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x70(%rbp), %rcx
movq %rcx, 0x10(%rax)
movq -0x68(%rbp), %rcx
movq %rcx, 0x18(%rax)
jmp 0x1ddd3
jmp 0x1ddde
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x1dcaf
jmp 0x1dde5
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x1be00
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)