// File: /workspace/github_c_makefile_star2_O1/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, 0x10(%rsp)
movl %r8d, %ebp
movl %ecx, %r12d
movl %edx, %r15d
movq %rsi, 0x40(%rsp)
movq %rdi, 0x18(%rsp)
movq 0x190(%rsp), %r14
movq 0x188(%rsp), %rbx
movl $0x40, %edi
callq 0x2220
movq %rax, %r13
movups (%rbx), %xmm0
movups 0x10(%rbx), %xmm1
movq %r14, %rbx
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
xorl %eax, %eax
movq %rax, 0x18(%r13)
movq $0x0, (%rsp)
movq %rax, (%r14)
movslq %r12d, %rax
movslq %r15d, %rcx
movq %rax, 0x58(%rsp)
movq %rcx, 0x38(%rsp)
addl %ecx, %eax
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
sarl %ecx
movslq %ecx, %rax
movq %rax, 0x30(%rsp)
movl %ebp, 0xc(%rsp)
movslq %ebp, %r15
movl $0x1, %r14d
movl $0x2, %edx
movq %r15, 0x28(%rsp)
decq %r14
movq %r14, %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
movq %rdx, 0x20(%rsp)
jb 0x7076
movl %eax, %ecx
shrl %ecx
addb $-0x2, %cl
andb $-0x2, %cl
movl $0x3, %edx
shlq %cl, %rdx
notq %rdx
movq (%rsp), %rsi
andq %rdx, %rsi
movl %eax, %edx
andl $0x3, %edx
shlq %cl, %rdx
orq %rdx, %rsi
movq %rsi, (%rsp)
shrq $0x2, %rax
cmpq 0x58(%rsp), %rax
jne 0x7180
movq 0x8(%rbx), %rax
cmpq %rax, (%rbx)
jne 0x70b3
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x8(%rbx)
movq 0x10(%rbx), %rdi
shlq $0x3, %rsi
callq 0x2260
movq %rax, 0x10(%rbx)
movq (%rbx), %rcx
movq %rcx, 0x48(%rsp)
movq 0x10(%rbx), %rax
movq %rax, 0x50(%rsp)
leaq 0x1(%rcx), %rax
movq %rax, (%rbx)
movq 0x18(%rsp), %rbx
movq %rbx, %rdi
leaq 0x60(%rsp), %rsi
leaq 0x80(%rsp), %r15
movq %r15, %rdx
movl $0x1, %ecx
callq 0x5027
movq 0x40(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
movl 0x10(%rsp), %r15d
movl %r15d, %edx
movl 0x180(%rsp), %ecx
movl 0xc(%rsp), %ebp
movl %ebp, %r8d
callq 0x6daa
movl %eax, 0x14(%rsp)
movq %rbx, %rdi
leaq 0x60(%rsp), %rsi
leaq 0x80(%rsp), %rdx
xorl %ecx, %ecx
callq 0x5027
movq %r12, %rdi
leaq 0x80(%rsp), %rsi
movl %r15d, %edx
movl 0x180(%rsp), %ecx
movl %ebp, %r8d
callq 0x6daa
movq (%rsp), %rcx
shlq $0x1c, %rcx
shll $0xe, %eax
cltq
movslq 0x14(%rsp), %rdx
orq %rcx, %rdx
orq %rax, %rdx
movq 0x50(%rsp), %rax
movq 0x48(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x28(%rsp), %r15
movq 0x20(%rsp), %rdx
jmp 0x723b
addq 0x38(%rsp), %rax
xorl %ebx, %ebx
cmpq 0x30(%rsp), %rax
setne %bl
movq 0x18(%rsp), %rdi
leaq 0x60(%rsp), %rsi
leaq 0x80(%rsp), %rdx
movl $0x1, %ecx
callq 0x5027
leaq 0x2(,%rbx,2), %rbx
xorl %ebp, %ebp
leaq 0xb8(%rsp), %r12
movq 0x20(%rsp), %rdx
cmpq %r15, -0x8(%r12)
jb 0x722f
movq 0x78(%rsp), %rax
andq $-0x4, %rax
addq $0x4, %rax
orq %rbp, %rax
movq %rax, (%r12)
cmpq %rdx, %r14
jne 0x720c
leaq (%rdx,%rdx), %r15
testq %rdx, %rdx
movl $0x2, %eax
cmoveq %rax, %r15
movq %r15, %rsi
shlq $0x5, %rsi
movq %r13, %rdi
callq 0x2260
movq %rax, %r13
movq %r15, %rdx
movq 0x28(%rsp), %r15
leaq -0x18(%r12), %rax
leaq 0x1(%r14), %rcx
shlq $0x5, %r14
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups %xmm1, 0x10(%r13,%r14)
movups %xmm0, (%r13,%r14)
movq %rcx, %r14
addq $0x20, %r12
incq %rbp
cmpq %rbp, %rbx
jne 0x71c2
testq %r14, %r14
movq 0x190(%rsp), %rbx
jne 0x701b
movq %r13, %rdi
callq 0x2040
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq