// File: /workspace/github_c_makefile_star2_O1/lh3[P]fermi2/dfs.c
// Function: fm_dfs2_core
void fm_dfs2_core(int n, rld_t *const*e, int is_half, int max_k, int suf_len, int suf, fmdfs2_f func, void *data, int tid)
{ // this is the bidirectional version of fm_dfs_core(), requiring a bidirectional FM-index
	int i, j, c;
	rldintv_t *t, *o;
	char *_path, *path;
	kvec_t(rldintv_t) stack = {0,0,0};

	// check if the input is correct
	assert((max_k&1) || !is_half);
	for (i = 0; i < n; ++i) // check bidirectionality
		assert(e[i]->mcnt[2] == e[i]->mcnt[5] && e[i]->mcnt[3] == e[i]->mcnt[4]);
	// allocation
	t = alloca(sizeof(rldintv_t) * n);
	o = alloca(sizeof(rldintv_t) * n * 6);
	_path = alloca(max_k + 2);
	path = _path + 1;
	kv_resize(rldintv_t, stack, n * max_k * 6);
	// descend
	for (i = 0; i < n; ++i) {
		rldintv_t *p, t[6];
		kv_pushp(rldintv_t, stack, &p);
		p->x[0] = p->x[1] = p->info = 0, p->x[2] = e[i]->mcnt[0];
		for (j = 0; j < suf_len; ++j) {
			rld_extend(e[i], p, t, 1);
			*p = t[(suf>>j*2&3) + 1];
		}
		p->info = suf_len<<8 | ((suf>>(suf_len-1)*2&3) + 1);
	}
	for (j = 0; j < suf_len; ++j)
		path[max_k - j - 1] = "ACGT"[suf>>j*2&3];
	path[max_k] = 0;
	// traverse
	while (stack.n) {
		int end, cont = 0x1E, depth;
		rldintv_t *oi;
		for (i = n - 1; i >= 0; --i) t[i] = kv_pop(stack);
		depth = t->info>>8;
		if (depth > max_k) continue;
		path[max_k - depth] = "\0ACGTN"[t->info&0xff];
		for (i = 0, oi = o; i < n; ++i, oi += 6) {
			rld_extend(e[i], &t[i], oi, 1);
			for (c = 0; c < 6; ++c)
				if (oi[c].x[2] == 0) cont &= ~(1<<c);
		}
		func(data, tid, depth, path + (max_k - depth), t, o, &cont);
		end = depth == max_k>>1 && is_half? 2 : 4;
		for (c = 1; c <= end; ++c) {
			if ((cont>>c&1) == 0) continue;
			for (i = 0, oi = o; i < n; ++i, oi += 6) {
				rldintv_t *p;
				kv_pushp(rldintv_t, stack, &p);
				*p = oi[c];
				p->info = (depth + 1) << 8 | c;
			}
		}
	}
	free(stack.a);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movq %rcx, -0x58(%rbp)
testb $0x1, %cl
sete %al
movl %edx, -0xa0(%rbp)
testl %edx, %edx
setne %cl
testb %al, %cl
jne 0xc0b2
movl %r8d, %r15d
movl %edi, %eax
movq %rax, -0x70(%rbp)
movl %edi, -0x2c(%rbp)
testl %edi, %edi
jle 0xbb9d
xorl %eax, %eax
movq (%rsi,%rax,8), %rcx
movq 0x28(%rcx), %rcx
movq 0x10(%rcx), %rdx
cmpq 0x28(%rcx), %rdx
jne 0xc093
movq 0x18(%rcx), %rdx
cmpq 0x20(%rcx), %rdx
jne 0xc093
incq %rax
cmpq %rax, -0x70(%rbp)
jne 0xbb70
movq %rsi, -0x80(%rbp)
movl -0x2c(%rbp), %edx
movslq %edx, %rax
movq %rax, %rcx
shlq $0x5, %rcx
movq %rsp, %rsi
subq %rcx, %rsi
movq %rsi, -0x68(%rbp)
movq %rsi, %rsp
shlq $0x6, %rax
leaq (%rax,%rax,2), %rax
movq %rsp, %rcx
subq %rax, %rcx
movq %rcx, -0x90(%rbp)
movq %rcx, %rsp
movq -0x58(%rbp), %rcx
movslq %ecx, %rsi
movq %rsp, %rdi
movq %rsi, -0x60(%rbp)
leaq 0x11(%rsi), %rbx
andq $-0x10, %rbx
movq %rdi, -0x98(%rbp)
movq %rdi, %rax
subq %rbx, %rax
movq %rax, %rsp
movl %ecx, %eax
imull %edx, %eax
testl %eax, %eax
movl %r9d, -0x40(%rbp)
je 0xbc5a
addl %eax, %eax
leal (%rax,%rax,2), %eax
cltq
decq %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rdi
shrq $0x10, %rdi
orq %rax, %rdi
incq %rdi
movq %rdi, -0x38(%rbp)
shlq $0x5, %rdi
callq 0x2220
movl -0x40(%rbp), %r9d
movq %rax, %rdi
jmp 0xbc64
movq $0x0, -0x38(%rbp)
xorl %edi, %edi
negq %rbx
movq %rbx, -0x88(%rbp)
cmpl $0x0, -0x2c(%rbp)
jle 0xbd81
movl %r15d, %eax
leal (%r15,%r15), %ecx
addb $-0x2, %cl
movl %r9d, %edx
sarl %cl, %edx
shll $0x8, %eax
andl $0x3, %edx
addl %edx, %eax
incl %eax
cltq
movq %rax, -0x48(%rbp)
xorl %r12d, %r12d
leaq -0x180(%rbp), %r14
movq -0x80(%rbp), %r11
movq %r15, -0x78(%rbp)
movq -0x38(%rbp), %rax
cmpq %rax, %r12
jne 0xbcdd
leaq (%rax,%rax), %rbx
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rbx
movq %rbx, %rsi
shlq $0x5, %rsi
callq 0x2260
movq -0x80(%rbp), %r11
movl -0x40(%rbp), %r9d
movq %rax, %rdi
movq %rbx, -0x38(%rbp)
movq %r12, %rax
shlq $0x5, %rax
leaq (%rdi,%rax), %r13
movq $0x0, 0x18(%rdi,%rax)
xorps %xmm0, %xmm0
movups %xmm0, (%rdi,%rax)
movq (%r11,%r12,8), %rcx
movq 0x28(%rcx), %rcx
movq (%rcx), %rcx
movq %rdi, -0x50(%rbp)
movq %rcx, 0x10(%rdi,%rax)
testl %r15d, %r15d
jle 0xbd62
xorl %r15d, %r15d
movq -0x78(%rbp), %rax
movl %eax, %ebx
movq (%r11,%r12,8), %rdi
movq %r13, %rsi
movq %r14, %rdx
movl $0x1, %ecx
callq 0x5027
movq -0x80(%rbp), %r11
movl -0x40(%rbp), %r9d
movl %r9d, %eax
movl %r15d, %ecx
sarl %cl, %eax
andl $0x3, %eax
shll $0x5, %eax
movups 0x20(%rax,%r14), %xmm0
movups 0x30(%rax,%r14), %xmm1
movups %xmm0, (%r13)
movups %xmm1, 0x10(%r13)
addl $0x2, %r15d
decl %ebx
jne 0xbd1a
incq %r12
movq -0x48(%rbp), %rax
movq %rax, 0x18(%r13)
cmpq -0x70(%rbp), %r12
movq -0x50(%rbp), %rdi
movq -0x78(%rbp), %r15
jne 0xbca9
jmp 0xbd84
xorl %r12d, %r12d
movq -0x98(%rbp), %rax
movq -0x88(%rbp), %rcx
leaq (%rax,%rcx), %r10
incq %r10
testl %r15d, %r15d
jle 0xbdd4
movl %r15d, %eax
movq -0x58(%rbp), %rcx
leal -0x1(%rcx), %edx
addq %rax, %rax
xorl %ecx, %ecx
leaq 0x10dc3(%rip), %rsi     # 0x1cb77
movl %r9d, %r8d
sarl %cl, %r8d
andl $0x3, %r8d
movb (%r8,%rsi), %r8b
movslq %edx, %rdx
movb %r8b, (%r10,%rdx)
decl %edx
addq $0x2, %rcx
cmpq %rcx, %rax
jne 0xbdb4
movq -0x60(%rbp), %rax
movb $0x0, (%r10,%rax)
testq %r12, %r12
je 0xc07f
movq -0x58(%rbp), %rax
sarl %eax
movl %eax, -0x9c(%rbp)
movq -0x70(%rbp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, -0x88(%rbp)
movq %rax, %r8
shlq $0x5, %r8
addq -0x68(%rbp), %r8
negq %rax
movq %rax, -0xb8(%rbp)
movq -0x90(%rbp), %rax
leaq 0x10(%rax), %rcx
movq %rcx, -0xa8(%rbp)
addq $0x20, %rax
movq %rax, -0xb0(%rbp)
movl -0x2c(%rbp), %r14d
movq -0x38(%rbp), %rsi
movq %r10, -0x60(%rbp)
movq %r8, -0x98(%rbp)
movl $0x1e, -0x180(%rbp)
testl %r14d, %r14d
jle 0xbe9a
movq -0xb8(%rbp), %rax
addq %r12, %rax
shlq $0x5, %r12
addq %rdi, %r12
movq $-0x20, %rcx
movq -0x88(%rbp), %rdx
movups (%r12,%rcx), %xmm0
movups 0x10(%r12,%rcx), %xmm1
movups %xmm1, 0x10(%r8,%rcx)
movups %xmm0, (%r8,%rcx)
decq %rdx
addq $-0x20, %rcx
cmpq $0x1, %rdx
jg 0xbe74
movq %rax, %r12
movq -0x68(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, %rdx
shrq $0x8, %rdx
movq -0x58(%rbp), %rcx
movq %rdx, -0x48(%rbp)
subl %edx, %ecx
jl 0xc06b
movq %rsi, -0x38(%rbp)
movq %rdi, -0x50(%rbp)
movslq %ecx, %rdx
movzbl %al, %eax
leaq 0x10ff9(%rip), %rcx     # 0x1cec7
movb (%rax,%rcx), %al
movq %rdx, -0x40(%rbp)
movb %al, (%r10,%rdx)
testl %r14d, %r14d
jle 0xbf4a
movq -0xa8(%rbp), %rbx
xorl %r15d, %r15d
movq -0x90(%rbp), %r13
movq -0x80(%rbp), %rax
movq (%rax,%r15,8), %rdi
movq %r15, %rsi
shlq $0x5, %rsi
addq -0x68(%rbp), %rsi
movq %r13, %rdx
movl $0x1, %ecx
callq 0x5027
movl -0x180(%rbp), %eax
movq %rbx, %rcx
xorl %edx, %edx
cmpq $0x0, (%rcx)
jne 0xbf29
btrl %edx, %eax
movl %eax, -0x180(%rbp)
incq %rdx
addq $0x20, %rcx
cmpq $0x6, %rdx
jne 0xbf1a
incq %r15
movl $0xc0, %eax
addq %rax, %r13
addq %rax, %rbx
cmpq -0x70(%rbp), %r15
jne 0xbeef
movq -0x40(%rbp), %rcx
addq -0x60(%rbp), %rcx
subq $0x8, %rsp
movq 0x18(%rbp), %rdi
movl 0x20(%rbp), %esi
movq -0x48(%rbp), %rbx
movl %ebx, %edx
movq -0x68(%rbp), %r8
movq -0x90(%rbp), %r9
leaq -0x180(%rbp), %rax
pushq %rax
callq *0x10(%rbp)
addq $0x10, %rsp
xorl %eax, %eax
cmpl %ebx, -0x9c(%rbp)
setne %al
shll $0x8, %ebx
addl $0x100, %ebx            # imm = 0x100
movq %rbx, -0x48(%rbp)
cmpl $0x0, -0xa0(%rbp)
leaq 0x3(%rax,%rax), %rcx
movl $0x5, %eax
cmoveq %rax, %rcx
movq %rcx, -0x78(%rbp)
movl $0x1, %edx
movq -0xb0(%rbp), %rbx
movq -0x50(%rbp), %rdi
movq -0x38(%rbp), %rsi
testl %r14d, %r14d
setle %al
movl -0x180(%rbp), %ecx
btl %edx, %ecx
setae %cl
orb %al, %cl
movq %rdx, -0x50(%rbp)
movq %rbx, -0x38(%rbp)
jne 0xc04e
movq -0x48(%rbp), %rax
orl %edx, %eax
cltq
movq %r12, %r13
shlq $0x5, %r13
cmpq %rsi, %r12
jne 0xc024
leaq (%rsi,%rsi), %r15
testq %rsi, %rsi
movq %r12, -0x40(%rbp)
movq %rax, %r12
movl $0x2, %eax
cmoveq %rax, %r15
movq %r15, %rsi
shlq $0x5, %rsi
callq 0x2260
movq %rax, %rdi
movq %r12, %rax
movq -0x40(%rbp), %r12
movq %r15, %rsi
incq %r12
movups (%rbx), %xmm0
movups 0x10(%rbx), %xmm1
movups %xmm1, 0x10(%rdi,%r13)
movups %xmm0, (%rdi,%r13)
movq %rax, 0x18(%rdi,%r13)
addq $0xc0, %rbx
addq $0x20, %r13
decl %r14d
jne 0xbfef
movq -0x50(%rbp), %rdx
incq %rdx
movq -0x38(%rbp), %rbx
addq $0x20, %rbx
cmpq -0x78(%rbp), %rdx
movl -0x2c(%rbp), %r14d
jne 0xbfc2
testq %r12, %r12
movq -0x60(%rbp), %r10
movq -0x98(%rbp), %r8
jne 0xbe46
callq 0x2040
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x10c8d(%rip), %rdi     # 0x1cd27
leaq 0x10bc7(%rip), %rsi     # 0x1cc68
leaq 0x10c2d(%rip), %rcx     # 0x1ccd5
movl $0x67, %edx
callq 0x2120
leaq 0x10b99(%rip), %rdi     # 0x1cc52
leaq 0x10ba8(%rip), %rsi     # 0x1cc68
leaq 0x10c0e(%rip), %rcx     # 0x1ccd5
movl $0x65, %edx
callq 0x2120