// File: /workspace/github_c_makefile_star2_O2/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 (%r9), %r11
movq %rdi, 0x68(%rsp)
movq 0x20(%rdi), %rax
movslq %r8d, %r13
movq %rcx, 0x50(%rsp)
movzbl (%rcx,%r13), %ecx
movq (%rax,%rcx,8), %r14
movq %r14, 0x30(%rsp)
movq 0x8(%rax,%rcx,8), %rdi
leal -0x1(%rcx), %ebx
pushq $0x5
popq %r10
subl %ecx, %r10d
cmpb $0x4, %bl
cmovaeq %rcx, %r10
incl %r13d
subq %r14, %rdi
movq %rdi, 0x40(%rsp)
movl %r10d, %ecx
movq (%rax,%rcx,8), %rax
movq %rax, 0x38(%rsp)
movslq %r13d, %r14
movq %r14, 0x48(%rsp)
je 0x16896
movq %r8, 0x18(%rsp)
movq %r11, 0x58(%rsp)
movq %r9, 0x20(%rsp)
movq 0x328(%rsp), %rdi
movq %r13, %rax
movq 0x320(%rsp), %r13
andq $0x0, (%r13)
movslq %edx, %r15
cmpl %eax, %r15d
movl %edx, 0xc(%rsp)
cmovgl %edx, %eax
movq %rax, 0x10(%rsp)
movslq %esi, %rax
movq %rax, 0x60(%rsp)
leaq 0x80(%rsp), %rbp
movq %rdi, %r12
cmpq %r15, %r14
jge 0x16521
movq 0x50(%rsp), %rax
movzbl (%rax,%r14), %eax
leal -0x1(%rax), %ecx
pushq $0x5
popq %rdx
movl %edx, %ebx
subl %eax, %ebx
cmpb $0x4, %cl
cmovaeq %rax, %rbx
movq 0x68(%rsp), %rdi
leaq 0x30(%rsp), %rsi
movq %rbp, %rdx
xorl %ecx, %ecx
callq 0x39db
movq %r12, %rdi
movl %ebx, %eax
shlq $0x5, %rax
leaq (%rsp,%rax), %rbx
addq $0x80, %rbx
movq 0x10(%rbx), %rax
cmpq 0x40(%rsp), %rax
je 0x164fe
movq (%r13), %rcx
movq 0x10(%r13), %rax
cmpq 0x8(%r13), %rcx
jne 0x164d4
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r13)
shlq $0x5, %rsi
movq %rax, %rdi
callq 0x2260
movq %r12, %rdi
movq %rax, 0x10(%r13)
movq (%r13), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%r13)
shlq $0x5, %rcx
movups 0x30(%rsp), %xmm0
movups 0x40(%rsp), %xmm1
movups %xmm1, 0x10(%rax,%rcx)
movups %xmm0, (%rax,%rcx)
movq 0x60(%rsp), %rax
cmpq %rax, 0x10(%rbx)
jb 0x1651c
movq 0x10(%rbx), %rax
movq %rax, 0x40(%rsp)
movups (%rbx), %xmm0
movaps %xmm0, 0x30(%rsp)
incq %r14
movq %r14, 0x48(%rsp)
jmp 0x16446
movq %r14, 0x10(%rsp)
movl 0xc(%rsp), %eax
cmpl %eax, 0x10(%rsp)
movq 0x20(%rsp), %rbx
movq 0x18(%rsp), %r15
jne 0x1658b
movq (%r13), %rcx
movq 0x10(%r13), %rax
cmpq 0x8(%r13), %rcx
jne 0x1656c
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r13)
shlq $0x5, %rsi
movq %rax, %rdi
callq 0x2260
movq %r12, %rdi
movq %rax, 0x10(%r13)
movq (%r13), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%r13)
shlq $0x5, %rcx
movups 0x30(%rsp), %xmm0
movups 0x40(%rsp), %xmm1
movups %xmm1, 0x10(%rax,%rcx)
movups %xmm0, (%rax,%rcx)
cmpq $0x0, 0x8(%r13)
je 0x165fc
movq (%r13), %rdx
testq %rdx, %rdx
je 0x165fc
movq 0x10(%r13), %rax
movq %rdx, %rcx
shrq %rcx
shlq $0x5, %rdx
addq %rax, %rdx
addq $-0x20, %rdx
subq $0x1, %rcx
jb 0x165fc
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, %rdx
addq $0x20, %rax
jmp 0x165b0
movq 0x10(%r13), %rax
movl 0x18(%rax), %eax
movq %rax, 0x10(%rsp)
testl %r15d, %r15d
js 0x16800
movq %r13, %r14
leal -0x1(%r15), %eax
testl %r15d, %r15d
movl %eax, 0x2c(%rsp)
je 0x1662e
movl %eax, %eax
movq 0x50(%rsp), %rcx
movzbl (%rcx,%rax), %eax
jmp 0x16630
xorl %eax, %eax
andq $0x0, (%rdi)
movl %eax, 0xc(%rsp)
shll $0x5, %eax
addq %rsp, %rax
addq $0x80, %rax
movq %rax, 0x18(%rsp)
movl %r15d, %eax
movq %rax, 0x70(%rsp)
shlq $0x20, %rax
movq %rax, 0x78(%rsp)
xorl %ebp, %ebp
xorl %r15d, %r15d
cmpq %r15, (%r14)
jbe 0x167e4
movq %rdi, %rbx
movq 0x10(%r14), %r12
leaq (%r12,%rbp), %r13
movq 0x68(%rsp), %rdi
movq %r13, %rsi
leaq 0x80(%rsp), %rdx
pushq $0x1
popq %rcx
callq 0x39db
cmpl $0x0, 0xc(%rsp)
je 0x166a6
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rdx
cmpq 0x60(%rsp), %rdx
jae 0x1675f
movq %rbx, %rdi
cmpq $0x0, (%rbx)
jne 0x167d8
movq 0x20(%rsp), %rax
movq (%rax), %rcx
movq 0x10(%rax), %rax
cmpq 0x58(%rsp), %rcx
je 0x166df
imulq $0x1a0, %rcx, %rdx      # imm = 0x1A0
movq 0x70(%rsp), %rsi
cmpl %esi, -0x184(%rax,%rdx)
jbe 0x167d8
movq 0x20(%rsp), %r12
cmpq 0x8(%r12), %rcx
jne 0x16716
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rdx
movq %rdx, 0x8(%r12)
imulq $0x1a0, %rdx, %rsi      # imm = 0x1A0
movq %rax, %rdi
callq 0x2260
movq %rax, 0x10(%r12)
movq (%r12), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%r12)
imulq $0x1a0, %rcx, %rcx      # imm = 0x1A0
movups (%r13), %xmm0
movups 0x10(%r13), %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
movq %rbx, %rdi
jmp 0x167d8
movq %rbx, %rdi
movq (%rbx), %rcx
movq 0x10(%rbx), %rax
testq %rcx, %rcx
je 0x1677c
movq %rcx, %rsi
shlq $0x5, %rsi
cmpq -0x10(%rax,%rsi), %rdx
je 0x167d8
movq 0x18(%r12,%rbp), %rdx
movq 0x18(%rsp), %rsi
movq %rdx, 0x18(%rsi)
cmpq 0x8(%rdi), %rcx
jne 0x167b8
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%rdi)
shlq $0x5, %rsi
movq %rax, %rdi
callq 0x2260
movq %rbx, %rdi
movq %rax, 0x10(%rbx)
movq (%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%rdi)
shlq $0x5, %rcx
movq 0x18(%rsp), %rdx
movups (%rdx), %xmm0
movups 0x10(%rdx), %xmm1
movups %xmm1, 0x10(%rax,%rcx)
movups %xmm0, (%rax,%rcx)
incq %r15
addq $0x20, %rbp
jmp 0x1665f
cmpq $0x0, (%rdi)
movl 0x2c(%rsp), %eax
movl %eax, %r15d
movq %rdi, %r13
movq %r14, %rdi
movq 0x20(%rsp), %rbx
jne 0x16608
cmpq $0x0, 0x8(%rbx)
je 0x16891
movq (%rbx), %rax
movq %rax, %r12
movq 0x58(%rsp), %rdx
subq %rdx, %r12
movq 0x10(%rsp), %r13
jbe 0x16896
movq 0x10(%rbx), %rcx
imulq $0x1a0, %rdx, %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
subq $0x1, %r12
jb 0x16896
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, %r14           # imm = 0xFE60
addq $0x1a0, %rbx            # imm = 0x1A0
jmp 0x1684b
movq 0x10(%rsp), %r13
movl %r13d, %eax
addq $0x2e8, %rsp            # imm = 0x2E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq