// File: /workspace/github_c_makefile_star2_O2/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, %ebx
movl %edx, %r12d
movq %rsi, 0x48(%rsp)
movq %rdi, 0x20(%rsp)
movq 0x190(%rsp), %r15
movq 0x188(%rsp), %r14
pushq $0x40
popq %rdi
callq 0x2220
movq %rax, %r13
movups (%r14), %xmm0
movups %xmm0, (%rax)
movq 0x10(%r14), %rax
movq %rax, 0x10(%r13)
andq $0x0, 0x18(%r13)
andq $0x0, (%r15)
movslq %ebx, %rax
movslq %r12d, %rcx
movq %rax, 0x58(%rsp)
movq %rcx, 0x40(%rsp)
addl %ecx, %eax
pushq $0x2
popq %rcx
cltd
idivl %ecx
cltq
movq %rax, 0x38(%rsp)
movl %ebp, 0xc(%rsp)
movslq %ebp, %r12
pushq $0x1
popq %r15
pushq $0x2
popq %rdx
movq $0x0, (%rsp)
movq %r12, 0x30(%rsp)
testq %r15, %r15
je 0x5bae
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
movq %rdx, 0x28(%rsp)
jb 0x59e1
movl %eax, %ecx
shrl %ecx
addb $-0x2, %cl
andb $-0x2, %cl
pushq $0x3
popq %rdx
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)
movq 0x190(%rsp), %rbx
shrq $0x2, %rax
cmpq 0x58(%rsp), %rax
jne 0x5a31
movq (%rbx), %rax
movq 0x10(%rbx), %rdi
cmpq 0x8(%rbx), %rax
jne 0x5aeb
leaq (%rax,%rax), %rsi
testq %rax, %rax
pushq $0x2
popq %rax
cmoveq %rax, %rsi
movq %rsi, 0x8(%rbx)
shlq $0x3, %rsi
callq 0x2260
movq %rax, 0x18(%rsp)
movq %rax, 0x10(%rbx)
movq (%rbx), %rax
jmp 0x5af0
addq 0x40(%rsp), %rax
xorl %ebx, %ebx
cmpq 0x38(%rsp), %rax
setne %bl
movq 0x20(%rsp), %rdi
leaq 0x60(%rsp), %rsi
leaq 0x80(%rsp), %rdx
pushq $0x1
popq %rcx
callq 0x39db
leaq 0x2(,%rbx,2), %rbx
leaq 0xb8(%rsp), %r14
xorl %ebp, %ebp
movq 0x28(%rsp), %rdx
cmpq %rbp, %rbx
je 0x597f
cmpq %r12, -0x8(%r14)
jb 0x5ae2
movq 0x78(%rsp), %rax
andq $-0x4, %rax
addq $0x4, %rax
orq %rbp, %rax
movq %rax, (%r14)
cmpq %rdx, %r15
jne 0x5ac0
leaq (%rdx,%rdx), %r12
testq %rdx, %rdx
pushq $0x2
popq %rax
cmoveq %rax, %r12
movq %r12, %rsi
shlq $0x5, %rsi
movq %r13, %rdi
callq 0x2260
movq %rax, %r13
movq %r12, %rdx
movq 0x30(%rsp), %r12
leaq -0x18(%r14), %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
incq %rbp
addq $0x20, %r14
jmp 0x5a71
movq %rdi, 0x18(%rsp)
movq %rax, 0x50(%rsp)
incq %rax
movq %rax, (%rbx)
movq 0x20(%rsp), %rbp
movq %rbp, %rdi
leaq 0x60(%rsp), %rsi
leaq 0x80(%rsp), %rbx
movq %rbx, %rdx
pushq $0x1
popq %rcx
callq 0x39db
movq 0x48(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
movl 0x10(%rsp), %r12d
movl %r12d, %edx
movl 0x180(%rsp), %ecx
movl 0xc(%rsp), %ebx
movl %ebx, %r8d
callq 0x5736
movl %eax, 0x14(%rsp)
movq %rbp, %rdi
leaq 0x60(%rsp), %rsi
leaq 0x80(%rsp), %rdx
xorl %ecx, %ecx
callq 0x39db
movq %r14, %rdi
leaq 0x80(%rsp), %rsi
movl %r12d, %edx
movl 0x180(%rsp), %ecx
movl %ebx, %r8d
callq 0x5736
movq (%rsp), %rcx
shlq $0x1c, %rcx
shll $0xe, %eax
cltq
movslq 0x14(%rsp), %rdx
orq %rcx, %rdx
orq %rax, %rdx
movq 0x18(%rsp), %rax
movq 0x50(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x30(%rsp), %r12
movq 0x28(%rsp), %rdx
jmp 0x597f
movq %r13, %rdi
callq 0x2040
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq