// File: /workspace/github_c_makefile_star2_O3/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
movq %rcx, %r13
movl %edx, %ebp
movq %r9, 0x18(%rsp)
movq (%r9), %rax
movq %rax, 0x20(%rsp)
movq %rdi, 0x60(%rsp)
movq 0x20(%rdi), %r10
movslq %r8d, %r15
movzbl (%rcx,%r15), %ecx
movq (%r10,%rcx,8), %rdx
movq %rdx, 0x30(%rsp)
movq 0x8(%r10,%rcx,8), %rdi
leal -0x1(%rcx), %r11d
movl $0x5, %r9d
subl %ecx, %r9d
cmpb $0x4, %r11b
cmovaeq %rcx, %r9
incl %r15d
subq %rdx, %rdi
movq %rdi, 0x40(%rsp)
movl %r9d, %ecx
movq (%r10,%rcx,8), %rcx
movq %rcx, 0x38(%rsp)
movslq %r15d, %rbx
movq %rbx, 0x48(%rsp)
je 0x19989
movq %r8, 0x8(%rsp)
movq 0x320(%rsp), %r14
movq $0x0, (%r14)
movslq %esi, %rcx
movq %rcx, 0x58(%rsp)
cmpl %ebp, %r15d
jge 0x19604
incq %rbx
movzbl -0x1(%r13,%rbx), %eax
leal -0x1(%rax), %ecx
movl $0x5, %r12d
subl %eax, %r12d
cmpb $0x4, %cl
cmovaeq %rax, %r12
movq 0x60(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x80(%rsp), %rdx
xorl %ecx, %ecx
callq 0x4ef6
movl %r12d, %eax
shlq $0x5, %rax
leaq (%rsp,%rax), %r12
addq $0x80, %r12
movq 0x10(%r12), %rax
cmpq 0x40(%rsp), %rax
je 0x195da
movq (%r14), %rcx
movq 0x10(%r14), %rax
cmpq 0x8(%r14), %rcx
jne 0x195b0
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r14)
shlq $0x5, %rsi
movq %rax, %rdi
callq 0x2260
movq %rax, 0x10(%r14)
movq (%r14), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%r14)
shlq $0x5, %rcx
movups 0x30(%rsp), %xmm0
movups 0x40(%rsp), %xmm1
movups %xmm1, 0x10(%rax,%rcx)
movups %xmm0, (%rax,%rcx)
movq 0x58(%rsp), %rax
cmpq %rax, 0x10(%r12)
jb 0x19604
movq 0x10(%r12), %rax
movq %rax, 0x40(%rsp)
movups (%r12), %xmm0
movaps %xmm0, 0x30(%rsp)
movq %rbx, 0x48(%rsp)
incl %r15d
incq %rbx
cmpl %r15d, %ebp
jne 0x1952c
jmp 0x19609
cmpl %ebp, %r15d
jne 0x1965e
movq (%r14), %rcx
cmpq 0x8(%r14), %rcx
jne 0x1963c
leaq (%rcx,%rcx), %rax
testq %rcx, %rcx
movl $0x2, %esi
cmovneq %rax, %rsi
movq %rsi, 0x8(%r14)
movq 0x10(%r14), %rdi
shlq $0x5, %rsi
callq 0x2260
movq %rax, 0x10(%r14)
movq (%r14), %rcx
jmp 0x19640
movq 0x10(%r14), %rax
leaq 0x1(%rcx), %rdx
movq %rdx, (%r14)
shlq $0x5, %rcx
movaps 0x30(%rsp), %xmm0
movaps 0x40(%rsp), %xmm1
movups %xmm1, 0x10(%rax,%rcx)
movups %xmm0, (%rax,%rcx)
movq %r13, 0x68(%rsp)
cmpq $0x0, 0x8(%r14)
je 0x196d6
movq (%r14), %rdx
testq %rdx, %rdx
je 0x196d6
cmpq $0x1, %rdx
je 0x196d6
movq 0x10(%r14), %rax
movq %rdx, %rcx
shrq %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 0x1968d
movq 0x328(%rsp), %r12
movq 0x10(%r14), %rax
movl 0x18(%rax), %eax
movq %rax, 0x10(%rsp)
movq 0x18(%rsp), %rcx
movq 0x8(%rsp), %rsi
testl %esi, %esi
js 0x198f6
movq %r14, %r13
leal -0x1(%rsi), %edi
testl %esi, %esi
je 0x19717
movl %edi, %eax
movq 0x68(%rsp), %rdx
movzbl (%rdx,%rax), %eax
movl %eax, 0x4(%rsp)
jmp 0x1971f
movl $0x0, 0x4(%rsp)
movq $0x0, (%r12)
cmpq $0x0, (%r13)
je 0x198f6
movl %edi, 0x2c(%rsp)
movl 0x4(%rsp), %eax
shll $0x5, %eax
addq %rsp, %rax
addq $0x80, %rax
movq %rax, 0x8(%rsp)
movl %esi, %eax
movq %rax, 0x70(%rsp)
shlq $0x20, %rax
movq %rax, 0x78(%rsp)
xorl %ebp, %ebp
xorl %r15d, %r15d
movq 0x10(%r13), %rbx
leaq (%rbx,%rbp), %r14
movq 0x60(%rsp), %rdi
movq %r14, %rsi
leaq 0x80(%rsp), %rdx
movl $0x1, %ecx
callq 0x4ef6
cmpl $0x0, 0x4(%rsp)
je 0x1979d
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rdx
cmpq 0x58(%rsp), %rdx
jae 0x1984d
cmpq $0x0, (%r12)
jne 0x198c9
movq 0x18(%rsp), %rax
movq (%rax), %rcx
movq 0x10(%rax), %rax
cmpq 0x20(%rsp), %rcx
je 0x197d4
imulq $0x1a0, %rcx, %rdx      # imm = 0x1A0
movq 0x70(%rsp), %rsi
cmpl %esi, -0x184(%rax,%rdx)
jbe 0x198c9
movq 0x18(%rsp), %rbx
cmpq 0x8(%rbx), %rcx
jne 0x19809
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rdx
movq %rdx, 0x8(%rbx)
imulq $0x1a0, %rdx, %rsi      # imm = 0x1A0
movq %rax, %rdi
callq 0x2260
movq %rax, 0x10(%rbx)
movq (%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%rbx)
imulq $0x1a0, %rcx, %rcx      # imm = 0x1A0
movups (%r14), %xmm0
movups 0x10(%r14), %xmm1
leaq (%rax,%rcx), %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 0x198c9
movq (%r12), %rcx
movq 0x10(%r12), %rax
testq %rcx, %rcx
je 0x19869
movq %rcx, %rsi
shlq $0x5, %rsi
cmpq -0x10(%rax,%rsi), %rdx
je 0x198c9
movq 0x18(%rbx,%rbp), %rdx
movq 0x8(%rsp), %rsi
movq %rdx, 0x18(%rsi)
cmpq 0x8(%r12), %rcx
jne 0x198a8
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r12)
shlq $0x5, %rsi
movq %rax, %rdi
callq 0x2260
movq %rax, 0x10(%r12)
movq (%r12), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%r12)
shlq $0x5, %rcx
movq 0x8(%rsp), %rdx
movups (%rdx), %xmm0
movups 0x10(%rdx), %xmm1
movups %xmm1, 0x10(%rax,%rcx)
movups %xmm0, (%rax,%rcx)
incq %r15
addq $0x20, %rbp
cmpq %r15, (%r13)
ja 0x19760
cmpq $0x0, (%r12)
movl 0x2c(%rsp), %eax
movl %eax, %esi
movq %r12, %r14
movq %r13, %r12
movq 0x18(%rsp), %rcx
jne 0x196f4
cmpq $0x0, 0x8(%rcx)
je 0x19984
movq (%rcx), %rax
movq %rax, %r12
subq 0x20(%rsp), %r12
jbe 0x19984
cmpq $0x2, %r12
jb 0x19984
movq 0x10(%rcx), %rcx
imulq $0x1a0, 0x20(%rsp), %rbx # imm = 0x1A0
addq %rcx, %rbx
shrq %r12
imulq $0x1a0, %rax, %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 0x19941
movq 0x10(%rsp), %r15
movl %r15d, %eax
addq $0x2e8, %rsp            # imm = 0x2E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq