// File: /workspace/github_c_makefile_star2_O3/lh3[P]fermi2/correct.c
// Function: fmc_collect1
void fmc_collect1(const rld_t *e, uint8_t *qtab[2], int suf_len, int depth, int min_occ, int max_ec_depth, int q1_depth, const rldintv_t *start, fmc64_v *a)
{
	rldintv_v stack = {0,0,0};
	uint64_t x = 0, *p;

	kv_push(rldintv_t, stack, *start);
	stack.a[0].info = 0;
	a->n = 0;
	while (stack.n) {
		rldintv_t top = kv_pop(stack);
		if (top.info>>2 > 0) {
			int shift = ((top.info>>2) - 1) << 1;
			x = (x & ~(3ULL<<shift)) | (uint64_t)(top.info&3)<<shift;
		}
		if (top.info>>2 == depth) { // reach the length; collect info at the two tips
			rldintv_t t[6];
			int val[2];
			kv_pushp(uint64_t, *a, &p);
			rld_extend(e, &top, t, 1); // backward tip
			val[0] = fmc_intv2tip(qtab, t, max_ec_depth, q1_depth, min_occ);
			rld_extend(e, &top, t, 0); // forward tip
			val[1] = fmc_intv2tip(qtab, t, max_ec_depth, q1_depth, min_occ);
			*p = fmc_cell_set_keyval(x, val[0], val[1]);
		} else {
			int c, end = (suf_len + (top.info>>2)) == (suf_len + depth) / 2? 2 : 4;
			rldintv_t t[6];
			rld_extend(e, &top, t, 1);
			for (c = 1; c <= end; ++c) {
				if (t[c].x[2] < min_occ) continue;
				t[c].info = ((top.info>>2) + 1) << 2 | (c - 1);
				kv_push(rldintv_t, stack, t[c]);
			}
		}
	}
	free(stack.a);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movl %r9d, 0x20(%rsp)
movl %r8d, %ebp
movl %ecx, %ebx
movl %edx, %r12d
movq %rsi, 0x48(%rsp)
movq %rdi, 0x10(%rsp)
movq 0x190(%rsp), %r15
movq 0x188(%rsp), %r14
movl $0x40, %edi
callq 0x2220
movq %rax, %r13
movups (%r14), %xmm0
movups %xmm0, (%rax)
movq 0x10(%r14), %rax
movq %rax, 0x10(%r13)
xorl %eax, %eax
movq %rax, 0x18(%r13)
movq $0x0, 0x8(%rsp)
movq %rax, (%r15)
movslq %ebx, %rax
movslq %r12d, %rcx
movq %rax, 0x58(%rsp)
movq %rcx, 0x40(%rsp)
addl %ecx, %eax
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
sarl %ecx
movslq %ecx, %rax
movq %rax, 0x38(%rsp)
movl %ebp, 0x1c(%rsp)
movslq %ebp, %rax
movq %rax, 0x30(%rsp)
movl $0x1, %r15d
movl $0x2, %ebp
decq %r15
movq %r15, %rax
shlq $0x5, %rax
movups (%r13,%rax), %xmm0
movups 0x10(%r13,%rax), %xmm1
movaps %xmm1, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movq 0x78(%rsp), %rax
cmpq $0x4, %rax
jb 0x6dcb
movl %eax, %ecx
shrl %ecx
addb $-0x2, %cl
andb $-0x2, %cl
movl $0x3, %edx
shlq %cl, %rdx
notq %rdx
movq 0x8(%rsp), %rsi
andq %rdx, %rsi
movl %eax, %edx
andl $0x3, %edx
shlq %cl, %rdx
orq %rdx, %rsi
movq %rsi, 0x8(%rsp)
movq 0x190(%rsp), %rbx
shrq $0x2, %rax
cmpq 0x58(%rsp), %rax
jne 0x6e1d
movq (%rbx), %rax
movq 0x10(%rbx), %rdi
cmpq 0x8(%rbx), %rax
jne 0x6edb
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x8(%rbx)
shlq $0x3, %rsi
callq 0x2260
movq %rax, 0x28(%rsp)
movq %rax, 0x10(%rbx)
movq (%rbx), %rax
jmp 0x6ee0
addq 0x40(%rsp), %rax
xorl %ebx, %ebx
cmpq 0x38(%rsp), %rax
setne %bl
movq 0x10(%rsp), %rdi
leaq 0x60(%rsp), %rsi
leaq 0x80(%rsp), %rdx
movl $0x1, %ecx
callq 0x4ef6
leaq 0x2(,%rbx,2), %rbx
xorl %r14d, %r14d
leaq 0xb8(%rsp), %r12
movq 0x30(%rsp), %rdx
cmpq %rdx, -0x8(%r12)
jb 0x6eca
movq 0x78(%rsp), %rax
andq $-0x4, %rax
addq $0x4, %rax
orq %r14, %rax
movq %rax, (%r12)
cmpq %rbp, %r15
jne 0x6ea7
leaq (%r15,%r15), %rbp
testq %r15, %r15
movl $0x2, %eax
cmoveq %rax, %rbp
movq %rbp, %rsi
shlq $0x5, %rsi
movq %r13, %rdi
callq 0x2260
movq 0x30(%rsp), %rdx
movq %rax, %r13
leaq -0x18(%r12), %rax
leaq 0x1(%r15), %rcx
shlq $0x5, %r15
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups %xmm1, 0x10(%r13,%r15)
movups %xmm0, (%r13,%r15)
movq %rcx, %r15
addq $0x20, %r12
incq %r14
cmpq %r14, %rbx
jne 0x6e60
jmp 0x6f8f
movq %rdi, 0x28(%rsp)
movq %rax, 0x50(%rsp)
incq %rax
movq %rax, (%rbx)
movq 0x10(%rsp), %rdi
leaq 0x60(%rsp), %rsi
leaq 0x80(%rsp), %rbx
movq %rbx, %rdx
movl $0x1, %ecx
callq 0x4ef6
movq 0x48(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
movl 0x20(%rsp), %ebx
movl %ebx, %edx
movl 0x180(%rsp), %ecx
movl 0x1c(%rsp), %r14d
movl %r14d, %r8d
callq 0x6b0a
movl %eax, 0x24(%rsp)
movq 0x10(%rsp), %rdi
leaq 0x60(%rsp), %rsi
leaq 0x80(%rsp), %rdx
xorl %ecx, %ecx
callq 0x4ef6
movq %r12, %rdi
leaq 0x80(%rsp), %rsi
movl %ebx, %edx
movl 0x180(%rsp), %ecx
movl %r14d, %r8d
callq 0x6b0a
movq 0x8(%rsp), %rcx
shlq $0x1c, %rcx
shll $0xe, %eax
cltq
movslq 0x24(%rsp), %rdx
orq %rcx, %rdx
orq %rax, %rdx
movq 0x28(%rsp), %rax
movq 0x50(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
testq %r15, %r15
jne 0x6d73
movq %r13, %rdi
callq 0x2040
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq