// File: /workspace/github_c_makefile_star2_O1/lh3[P]fermi2/match.c
// Function: fmd_smem1_core
int fmd_smem1_core(const rld_t *e, int min_occ, int len, const uint8_t *q, int x, fmdsmem_v *mem, rldintv_v *curr, rldintv_v *prev)
{ // for more comments, see bwa/bwt.c
	int i, j, c, ret;
	rldintv_t ik, ok[6];
	rldintv_v *swap;
	size_t oldn = mem->n;

	fmd_set_intv(e, q[x], ik);
	ik.info = x + 1;
	if (ik.x[2] == 0) return x + 1;
	for (i = x + 1, curr->n = 0; i < len; ++i) { // forward extension
		c = fmd_comp(q[i]);
		rld_extend(e, &ik, ok, 0);
		if (ok[c].x[2] != ik.x[2]) {
			kv_push(rldintv_t, *curr, ik);
			if (ok[c].x[2] < min_occ) break;
		}
		ik = ok[c]; ik.info = i + 1;
	}
	if (i == len) kv_push(rldintv_t, *curr, ik);
	kv_reverse(rldintv_t, *curr, 0);
	ret = curr->a[0].info;
	swap = curr; curr = prev; prev = swap;

	for (i = x - 1; i >= -1; --i) {
		c = i < 0? 0 : q[i];
		for (j = 0, curr->n = 0; j < prev->n; ++j) {
			rldintv_t *p = &prev->a[j];
			rld_extend(e, p, ok, 1);
			if (c == 0 || ok[c].x[2] < min_occ) {
				if (curr->n == 0) {
					if (mem->n == oldn || i + 1 < mem->a[mem->n-1].ik.info>>32) {
						fmdsmem_t *q;
						kv_pushp(fmdsmem_t, *mem, &q);
						q->ik = *p; q->ik.info |= (uint64_t)(i + 1)<<32;
						memcpy(q->ok[0], ok, 6 * sizeof(rldintv_t));
					}
				}
			} else if (curr->n == 0 || ok[c].x[2] != curr->a[curr->n-1].x[2]) {
				ok[c].info = p->info;
				kv_push(rldintv_t, *curr, ok[c]);
			}
		}
		if (curr->n == 0) break;
		swap = curr; curr = prev; prev = swap;
	}

	kv_reverse(fmdsmem_t, *mem, oldn);
	return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2e8, %rsp            # imm = 0x2E8
movl %r8d, %r15d
movq %rcx, %r12
movl %edx, %ebp
movq %r9, 0x10(%rsp)
movq (%r9), %rax
movq %rax, 0x20(%rsp)
movq %rdi, 0x60(%rsp)
movq 0x20(%rdi), %r9
movslq %r8d, %r14
movzbl (%rcx,%r14), %ecx
movq (%r9,%rcx,8), %rdx
movq %rdx, 0x30(%rsp)
movq 0x8(%r9,%rcx,8), %rdx
leal -0x1(%rcx), %edi
movl $0x5, %r8d
subl %ecx, %r8d
cmpb $0x4, %dil
cmovaeq %rcx, %r8
incl %r14d
subq (%r9,%rcx,8), %rdx
movq %rdx, 0x40(%rsp)
movl %r8d, %ecx
movq (%r9,%rcx,8), %rcx
movq %rcx, 0x38(%rsp)
movslq %r14d, %rbx
movq %rbx, 0x48(%rsp)
je 0x18e3b
movq 0x320(%rsp), %r13
movq $0x0, (%r13)
movslq %esi, %rcx
movq %rcx, 0x58(%rsp)
cmpl %ebp, %r14d
jge 0x18a80
movq %r15, 0x8(%rsp)
incq %rbx
movzbl -0x1(%r12,%rbx), %eax
leal -0x1(%rax), %ecx
movl $0x5, %r15d
subl %eax, %r15d
cmpb $0x4, %cl
cmovaeq %rax, %r15
movq 0x60(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x80(%rsp), %rdx
xorl %ecx, %ecx
callq 0x5027
movl %r15d, %eax
shlq $0x5, %rax
leaq (%rsp,%rax), %r15
addq $0x80, %r15
movq 0x10(%r15), %rax
cmpq 0x40(%rsp), %rax
je 0x18a4d
movq 0x8(%r13), %rax
cmpq %rax, (%r13)
jne 0x18a1b
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x8(%r13)
movq 0x10(%r13), %rdi
shlq $0x5, %rsi
callq 0x2260
movq %rax, 0x10(%r13)
movq (%r13), %rax
movq 0x10(%r13), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%r13)
shlq $0x5, %rax
movups 0x30(%rsp), %xmm0
movups 0x40(%rsp), %xmm1
movups %xmm1, 0x10(%rcx,%rax)
movups %xmm0, (%rcx,%rax)
movq 0x58(%rsp), %rax
cmpq %rax, 0x10(%r15)
jb 0x18a7b
movups (%r15), %xmm0
movups 0x10(%r15), %xmm1
movaps %xmm1, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movq %rbx, 0x48(%rsp)
movq %r14, %rax
incl %eax
incq %rbx
movq %rax, %r14
cmpl %eax, %ebp
jne 0x1899d
movl %ebp, %r14d
movq 0x8(%rsp), %r15
cmpl %ebp, %r14d
movq 0x10(%rsp), %rbx
jne 0x18ae0
movq 0x8(%r13), %rax
cmpq %rax, (%r13)
jne 0x18ab9
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %esi
cmovneq %rcx, %rsi
movq %rsi, 0x8(%r13)
movq 0x10(%r13), %rdi
shlq $0x5, %rsi
callq 0x2260
movq %rax, 0x10(%r13)
movq (%r13), %rax
movq 0x10(%r13), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%r13)
shlq $0x5, %rax
movaps 0x30(%rsp), %xmm0
movaps 0x40(%rsp), %xmm1
movups %xmm1, 0x10(%rcx,%rax)
movups %xmm0, (%rcx,%rax)
movq %r12, 0x68(%rsp)
cmpq $0x0, 0x8(%r13)
je 0x18b61
movq (%r13), %rdx
testq %rdx, %rdx
je 0x18b61
cmpq $0x1, %rdx
je 0x18b61
movq 0x10(%r13), %rax
movq %rdx, %rcx
shrq %rcx
cmpq $0x1, %rcx
adcq $0x0, %rcx
shlq $0x5, %rdx
addq %rax, %rdx
addq $-0x20, %rdx
movups (%rdx), %xmm0
movups 0x10(%rdx), %xmm1
movaps %xmm1, 0x150(%rsp)
movaps %xmm0, 0x140(%rsp)
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups %xmm1, 0x10(%rdx)
movups %xmm0, (%rdx)
movaps 0x140(%rsp), %xmm0
movaps 0x150(%rsp), %xmm1
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
addq $0x20, %rax
addq $-0x20, %rdx
decq %rcx
jne 0x18b18
movq 0x328(%rsp), %r12
movq 0x10(%r13), %rax
movl 0x18(%rax), %eax
movq %rax, 0x18(%rsp)
testl %r15d, %r15d
js 0x18d97
movq %r13, %r14
leal -0x1(%r15), %eax
testl %r15d, %r15d
movl %eax, 0x2c(%rsp)
je 0x18b9f
movl %eax, %eax
movq 0x68(%rsp), %rcx
movzbl (%rcx,%rax), %eax
movl %eax, 0x4(%rsp)
jmp 0x18ba7
movl $0x0, 0x4(%rsp)
movq $0x0, (%r12)
cmpq $0x0, (%r14)
je 0x18d7a
movl 0x4(%rsp), %eax
shll $0x5, %eax
addq %rsp, %rax
addq $0x80, %rax
movq %rax, 0x8(%rsp)
movl %r15d, %eax
movq %rax, 0x70(%rsp)
shlq $0x20, %rax
movq %rax, 0x78(%rsp)
xorl %ebx, %ebx
xorl %r15d, %r15d
movq 0x10(%r14), %rbp
leaq (%rbx,%rbp), %r13
movq 0x60(%rsp), %rdi
movq %r13, %rsi
leaq 0x80(%rsp), %rdx
movl $0x1, %ecx
callq 0x5027
cmpl $0x0, 0x4(%rsp)
je 0x18c21
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rcx
cmpq 0x58(%rsp), %rcx
jae 0x18ce4
cmpq $0x0, (%r12)
jne 0x18d6a
movq 0x10(%rsp), %rax
movq (%rax), %rax
cmpq 0x20(%rsp), %rax
je 0x18c5d
movq 0x10(%rsp), %rcx
movq 0x10(%rcx), %rcx
imulq $0x1a0, %rax, %rdx      # imm = 0x1A0
movq 0x70(%rsp), %rsi
cmpl %esi, -0x184(%rcx,%rdx)
jbe 0x18d6a
movq 0x10(%rsp), %rbp
movq 0x8(%rbp), %rcx
cmpq %rcx, %rax
jne 0x18c93
leaq (%rcx,%rcx), %rax
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rax
movq %rax, 0x8(%rbp)
movq 0x10(%rbp), %rdi
imulq $0x1a0, %rax, %rsi      # imm = 0x1A0
callq 0x2260
movq %rax, 0x10(%rbp)
movq (%rbp), %rax
movq 0x10(%rbp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%rbp)
imulq $0x1a0, %rax, %rax      # imm = 0x1A0
movups (%r13), %xmm0
movups 0x10(%r13), %xmm1
leaq (%rcx,%rax), %rdi
addq $0x20, %rdi
movups %xmm1, -0x10(%rdi)
movups %xmm0, -0x20(%rdi)
movq 0x78(%rsp), %rax
orq %rax, -0x8(%rdi)
movl $0xc0, %edx
leaq 0x80(%rsp), %rsi
callq 0x21f0
jmp 0x18d6a
movq (%r12), %rax
testq %rax, %rax
je 0x18d00
movq 0x10(%r12), %rdx
movq %rax, %rsi
shlq $0x5, %rsi
cmpq -0x10(%rdx,%rsi), %rcx
je 0x18d6a
movq 0x18(%rbp,%rbx), %rcx
movq 0x8(%rsp), %rdx
movq %rcx, 0x18(%rdx)
movq 0x8(%r12), %rcx
cmpq %rcx, %rax
jne 0x18d40
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x8(%r12)
movq 0x10(%r12), %rdi
shlq $0x5, %rsi
callq 0x2260
movq %rax, 0x10(%r12)
movq (%r12), %rax
movq 0x10(%r12), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%r12)
shlq $0x5, %rax
movq 0x8(%rsp), %rdx
movups (%rdx), %xmm0
movups 0x10(%rdx), %xmm1
movups %xmm1, 0x10(%rcx,%rax)
movups %xmm0, (%rcx,%rax)
incq %r15
addq $0x20, %rbx
cmpq %r15, (%r14)
ja 0x18be4
cmpq $0x0, (%r12)
movl 0x2c(%rsp), %eax
movl %eax, %r15d
movq %r12, %r13
movq %r14, %r12
movq 0x10(%rsp), %rbx
jne 0x18b75
cmpq $0x0, 0x8(%rbx)
je 0x18e36
movq (%rbx), %rdx
movq %rdx, %r12
subq 0x20(%rsp), %r12
movq 0x18(%rsp), %r14
jbe 0x18e3b
cmpq $0x2, %r12
jb 0x18e3b
movq 0x10(%rbx), %rcx
imulq $0x1a0, 0x20(%rsp), %rbx # imm = 0x1A0
addq %rcx, %rbx
shrq %r12
cmpq $0x1, %r12
adcq $0x0, %r12
imulq $0x1a0, %rdx, %rax      # imm = 0x1A0
leaq (%rax,%rcx), %r14
addq $-0x1a0, %r14           # imm = 0xFE60
leaq 0x140(%rsp), %r15
movl $0x1a0, %edx            # imm = 0x1A0
movq %r15, %rdi
movq %r14, %rsi
callq 0x21f0
movl $0x1a0, %edx            # imm = 0x1A0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x21f0
movl $0x1a0, %edx            # imm = 0x1A0
movq %rbx, %rdi
movq %r15, %rsi
callq 0x21f0
addq $0x1a0, %rbx            # imm = 0x1A0
addq $-0x1a0, %r14           # imm = 0xFE60
decq %r12
jne 0x18df3
movq 0x18(%rsp), %r14
movl %r14d, %eax
addq $0x2e8, %rsp            # imm = 0x2E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq