// File: /workspace/github_c_makefile_star2_O3/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, -0x98(%rbp)
testl %edx, %edx
setne %cl
testb %al, %cl
jne 0xc5a6
movl %r8d, %r13d
movl %edi, %r15d
movl %edi, %r14d
testl %edi, %edi
jle 0xc066
xorl %eax, %eax
movq (%rsi,%rax,8), %rcx
movq 0x28(%rcx), %rcx
movq 0x10(%rcx), %rdx
cmpq 0x28(%rcx), %rdx
jne 0xc587
movq 0x18(%rcx), %rdx
cmpq 0x20(%rcx), %rdx
jne 0xc587
incq %rax
cmpq %rax, %r14
jne 0xc03a
movslq %r15d, %rax
movq %rax, %rcx
shlq $0x5, %rcx
movq %rsp, %rdx
subq %rcx, %rdx
movq %rdx, -0x68(%rbp)
movq %rdx, %rsp
shlq $0x6, %rax
leaq (%rax,%rax,2), %rax
movq %rsp, %rcx
subq %rax, %rcx
movq %rcx, -0x78(%rbp)
movq %rcx, %rsp
movq -0x58(%rbp), %rcx
movslq %ecx, %rdx
movq %rsp, %rdi
movq %rdx, -0x88(%rbp)
addq $0x11, %rdx
andq $-0x10, %rdx
movq %rdi, -0x60(%rbp)
movq %rdi, %rax
subq %rdx, %rax
movq %rax, %rsp
movl %ecx, %eax
imull %r15d, %eax
testl %eax, %eax
movl %r9d, -0x30(%rbp)
movq %rsi, -0x70(%rbp)
je 0xc12a
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, %rbx
shrq $0x10, %rbx
orq %rax, %rbx
incq %rbx
movq %rbx, %rdi
shlq $0x5, %rdi
movq %rdx, %r12
callq 0x2220
movq %r12, %rdx
movq -0x70(%rbp), %rsi
movq %rbx, %r8
movl -0x30(%rbp), %r9d
movq %rax, %rdi
jmp 0xc12f
xorl %r8d, %r8d
xorl %edi, %edi
negq %rdx
testl %r15d, %r15d
movl %r15d, -0x34(%rbp)
movq %r14, -0xa0(%rbp)
jle 0xc272
movq %rdx, -0x80(%rbp)
movl %r13d, %eax
leal (,%r13,2), %ecx
addb $-0x2, %cl
movl %r9d, %edx
sarl %cl, %edx
shll $0x8, %eax
andl $0x3, %edx
addl %edx, %eax
incl %eax
cltq
movq %rax, -0x90(%rbp)
xorl %ebx, %ebx
movq %r13, -0x48(%rbp)
cmpq %r8, %rbx
jne 0xc1a1
leaq (%rbx,%rbx), %rsi
testq %rbx, %rbx
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, -0x40(%rbp)
shlq $0x5, %rsi
callq 0x2260
movq -0x70(%rbp), %rsi
movq %rax, %rdi
jmp 0xc1a5
movq %r8, -0x40(%rbp)
movq %rbx, %rax
shlq $0x5, %rax
leaq (%rdi,%rax), %r12
movq $0x0, 0x18(%rdi,%rax)
xorps %xmm0, %xmm0
movups %xmm0, (%rdi,%rax)
movq (%rsi,%rbx,8), %rcx
movq 0x28(%rcx), %rcx
movq (%rcx), %rcx
movq %rdi, -0x50(%rbp)
movq %rcx, 0x10(%rdi,%rax)
testl %r13d, %r13d
movl -0x30(%rbp), %r13d
jle 0xc236
xorl %r15d, %r15d
movq -0x48(%rbp), %rax
movl %eax, %r14d
movq (%rsi,%rbx,8), %rdi
movq %r12, %rsi
leaq -0x180(%rbp), %rdx
movl $0x1, %ecx
callq 0x4ef6
leaq -0x180(%rbp), %rdx
movq -0x70(%rbp), %rsi
movl %r13d, %eax
movl %r15d, %ecx
sarl %cl, %eax
andl $0x3, %eax
shll $0x5, %eax
movups 0x20(%rax,%rdx), %xmm0
movups 0x30(%rax,%rdx), %xmm1
movups %xmm0, (%r12)
movups %xmm1, 0x10(%r12)
addl $0x2, %r15d
decl %r14d
jne 0xc1e7
incq %rbx
movq -0x90(%rbp), %rax
movq %rax, 0x18(%r12)
movq -0xa0(%rbp), %r14
cmpq %r14, %rbx
movl -0x34(%rbp), %r15d
movq -0x40(%rbp), %r8
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %r13
jne 0xc176
movq %r14, %r10
movl -0x30(%rbp), %r9d
movq -0x80(%rbp), %rdx
jmp 0xc275
xorl %r10d, %r10d
movq -0x60(%rbp), %rax
leaq (%rax,%rdx), %r11
incq %r11
testl %r13d, %r13d
jle 0xc2b8
movl %r13d, %eax
movq -0x58(%rbp), %rcx
leal -0x1(%rcx), %edx
addq %rax, %rax
xorl %ecx, %ecx
leaq 0x11a54(%rip), %rsi     # 0x1dcef
movl %r9d, %ebx
sarl %cl, %ebx
andl $0x3, %ebx
movb (%rbx,%rsi), %bl
movslq %edx, %rdx
movb %bl, (%r11,%rdx)
decl %edx
addq $0x2, %rcx
cmpq %rcx, %rax
jne 0xc29b
movq -0x88(%rbp), %rax
movb $0x0, (%r11,%rax)
testq %r10, %r10
je 0xc573
movq -0x58(%rbp), %rax
sarl %eax
movl %eax, -0x94(%rbp)
leaq 0x1(%r14), %rax
movq %rax, -0xc0(%rbp)
movq %r14, %rsi
shlq $0x5, %rsi
addq -0x68(%rbp), %rsi
movq %r14, %rax
negq %rax
movq %rax, -0xb8(%rbp)
movq -0x78(%rbp), %rax
leaq 0x10(%rax), %rcx
movq %rcx, -0xa8(%rbp)
addq $0x20, %rax
movq %rax, -0xb0(%rbp)
movq %r11, -0x60(%rbp)
movq %rsi, -0x80(%rbp)
movl $0x1e, -0x180(%rbp)
testl %r15d, %r15d
jle 0xc370
movq -0xb8(%rbp), %rax
addq %r10, %rax
shlq $0x5, %r10
addq %rdi, %r10
movq $-0x20, %rcx
movq -0xc0(%rbp), %rdx
movups (%r10,%rcx), %xmm0
movups 0x10(%r10,%rcx), %xmm1
movups %xmm1, 0x10(%rsi,%rcx)
movups %xmm0, (%rsi,%rcx)
decq %rdx
addq $-0x20, %rcx
cmpq $0x1, %rdx
jg 0xc34c
movq %rax, %r10
movq -0x68(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, %rdx
shrq $0x8, %rdx
movq -0x58(%rbp), %rcx
subl %edx, %ecx
jl 0xc55b
movq %rdx, %r13
movq %r10, -0x48(%rbp)
movq %rdi, -0x50(%rbp)
movq %r8, -0x40(%rbp)
movslq %ecx, %rdx
movzbl %al, %eax
leaq 0x11c98(%rip), %rcx     # 0x1e03f
movb (%rax,%rcx), %al
movq %rdx, -0x30(%rbp)
movb %al, (%r11,%rdx)
testl %r15d, %r15d
jle 0xc41f
movq -0xa8(%rbp), %r15
xorl %r12d, %r12d
movq -0x78(%rbp), %rbx
movq -0x70(%rbp), %rax
movq (%rax,%r12,8), %rdi
movq %r12, %rsi
shlq $0x5, %rsi
addq -0x68(%rbp), %rsi
movq %rbx, %rdx
movl $0x1, %ecx
callq 0x4ef6
movl -0x180(%rbp), %eax
movq %r15, %rcx
xorl %edx, %edx
cmpq $0x0, (%rcx)
jne 0xc3ff
btrl %edx, %eax
movl %eax, -0x180(%rbp)
incq %rdx
addq $0x20, %rcx
cmpq $0x6, %rdx
jne 0xc3f0
incq %r12
movl $0xc0, %eax
addq %rax, %rbx
addq %rax, %r15
cmpq %r14, %r12
jne 0xc3c5
movq -0x30(%rbp), %rcx
addq -0x60(%rbp), %rcx
subq $0x8, %rsp
movq 0x18(%rbp), %rdi
movl 0x20(%rbp), %esi
movl %r13d, %edx
movq -0x68(%rbp), %r8
movq -0x78(%rbp), %r9
leaq -0x180(%rbp), %rax
pushq %rax
callq *0x10(%rbp)
addq $0x10, %rsp
xorl %eax, %eax
cmpl %r13d, -0x94(%rbp)
setne %al
shll $0x8, %r13d
addl $0x100, %r13d           # imm = 0x100
movq %r13, -0x88(%rbp)
cmpl $0x0, -0x98(%rbp)
leaq 0x3(%rax,%rax), %rcx
movl $0x5, %eax
cmoveq %rax, %rcx
movq %rcx, -0x90(%rbp)
movl $0x1, %edx
movq -0xb0(%rbp), %r14
movl -0x34(%rbp), %r15d
movq -0x40(%rbp), %r8
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %r10
testl %r15d, %r15d
setle %al
movl -0x180(%rbp), %ecx
btl %edx, %ecx
setae %cl
orb %al, %cl
movq %rdx, -0x50(%rbp)
movq %r14, -0x30(%rbp)
jne 0xc53b
movq -0x88(%rbp), %rax
orl %edx, %eax
movslq %eax, %rcx
leaq (%r10,%r10), %r13
movq %r10, %r12
shlq $0x5, %r12
movq %rcx, -0x40(%rbp)
cmpq %r8, %r10
jne 0xc50d
testq %r10, %r10
movq %r13, %rbx
movl $0x2, %eax
cmoveq %rax, %rbx
movq %rbx, %rsi
shlq $0x5, %rsi
movq %r10, -0x48(%rbp)
callq 0x2260
movq -0x40(%rbp), %rcx
movq -0x48(%rbp), %r10
movq %rbx, %r8
movq %rax, %rdi
incq %r10
movq 0x10(%r14), %rax
movq %rax, 0x10(%rdi,%r12)
movups (%r14), %xmm0
movups %xmm0, (%rdi,%r12)
movq %rcx, 0x18(%rdi,%r12)
addq $0xc0, %r14
addq $0x2, %r13
addq $0x20, %r12
decl %r15d
jne 0xc4db
movq -0x50(%rbp), %rdx
incq %rdx
movq -0x30(%rbp), %r14
addq $0x20, %r14
cmpq -0x90(%rbp), %rdx
movl -0x34(%rbp), %r15d
jne 0xc4a2
testq %r10, %r10
movq -0xa0(%rbp), %r14
movq -0x60(%rbp), %r11
movq -0x80(%rbp), %rsi
jne 0xc31e
callq 0x2040
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x11911(%rip), %rdi     # 0x1de9f
leaq 0x1184b(%rip), %rsi     # 0x1dde0
leaq 0x118b1(%rip), %rcx     # 0x1de4d
movl $0x67, %edx
callq 0x2120
leaq 0x1181d(%rip), %rdi     # 0x1ddca
leaq 0x1182c(%rip), %rsi     # 0x1dde0
leaq 0x11892(%rip), %rcx     # 0x1de4d
movl $0x65, %edx
callq 0x2120