// File: /workspace/github_c_makefile_star2_O2/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 $0x148, %rsp            # imm = 0x148
movl %r9d, -0x38(%rbp)
movq %rcx, -0x58(%rbp)
testb $0x1, %cl
sete %al
movl %edx, -0x90(%rbp)
testl %edx, %edx
setne %cl
testb %al, %cl
jne 0xabf8
movl %r8d, %r12d
xorl %eax, %eax
testl %edi, %edi
movl $0x0, %ebx
cmovgl %edi, %ebx
cmpq %rax, %rbx
je 0xa753
movq (%rsi,%rax,8), %rcx
movq 0x28(%rcx), %rcx
movq 0x10(%rcx), %rdx
cmpq 0x28(%rcx), %rdx
jne 0xa736
movq 0x18(%rcx), %rdx
incq %rax
cmpq 0x20(%rcx), %rdx
je 0xa712
leaq 0xf6b2(%rip), %rdi      # 0x19def
leaq 0xf5ec(%rip), %rsi      # 0x19d30
leaq 0xf652(%rip), %rcx      # 0x19d9d
pushq $0x67
popq %rdx
callq 0x2120
movq %rsi, -0x88(%rbp)
movslq %edi, %rax
imulq $0xc0, %rax, %rcx
shlq $0x5, %rax
movq %rsp, %rdx
subq %rax, %rdx
movq %rdx, -0x70(%rbp)
movq %rdx, %rsp
movq %rsp, %rax
subq %rcx, %rax
movq %rax, -0x78(%rbp)
movq %rax, %rsp
movq -0x58(%rbp), %rcx
movslq %ecx, %rdx
movq %rsp, %r15
movq %rdx, -0x60(%rbp)
leaq 0x11(%rdx), %r14
andq $-0x10, %r14
movq %r15, %rax
subq %r14, %rax
movq %rax, %rsp
negq %r14
movl %ecx, %eax
movl %edi, -0x4c(%rbp)
imull %edi, %eax
xorl %r13d, %r13d
testl %eax, %eax
je 0xa7fe
imull $0x6, %eax, %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, -0x30(%rbp)
shlq $0x5, %rdi
callq 0x2220
jmp 0xa808
movq $0x0, -0x30(%rbp)
xorl %eax, %eax
leaq (%r15,%r14), %rcx
incq %rcx
movq %rcx, -0x80(%rbp)
leal (%r12,%r12), %ecx
addb $-0x2, %cl
movl -0x38(%rbp), %edx
sarl %cl, %edx
movl %r12d, %ecx
shll $0x8, %ecx
andl $0x3, %edx
addl %edx, %ecx
incl %ecx
movslq %ecx, %rcx
movq %rcx, -0x48(%rbp)
testl %r12d, %r12d
cmovlel %r13d, %r12d
movq %r12, -0x68(%rbp)
movq %rbx, -0x98(%rbp)
cmpq %rbx, %r13
movq -0x30(%rbp), %rcx
je 0xa929
cmpq %rcx, %r13
jne 0xa878
leaq (%rcx,%rcx), %rbx
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rbx
movq %rbx, %rsi
shlq $0x5, %rsi
movq %rax, %rdi
callq 0x2260
movq %rbx, -0x30(%rbp)
movq %r13, %rdx
shlq $0x5, %rdx
andq $0x0, 0x18(%rax,%rdx)
leaq (%rax,%rdx), %r15
xorps %xmm0, %xmm0
movups %xmm0, (%rax,%rdx)
movq -0x88(%rbp), %rcx
movq %r13, -0x40(%rbp)
movq (%rcx,%r13,8), %rcx
movq 0x28(%rcx), %rcx
movq (%rcx), %rcx
movq %rcx, 0x10(%rax,%rdx)
xorl %r12d, %r12d
movq -0x68(%rbp), %rcx
movl %ecx, %ebx
subl $0x1, %ebx
jb 0xa90e
movq -0x88(%rbp), %rcx
movq -0x40(%rbp), %rdx
movq (%rcx,%rdx,8), %rdi
movq %r15, %rsi
movq %rax, %r14
leaq -0x170(%rbp), %r13
movq %r13, %rdx
pushq $0x1
popq %rcx
callq 0x39db
movq %r14, %rax
movl -0x38(%rbp), %ecx
movl %ecx, %edx
movl %r12d, %ecx
sarl %cl, %edx
andl $0x3, %edx
shll $0x5, %edx
movups 0x20(%rdx,%r13), %xmm0
movups 0x30(%rdx,%r13), %xmm1
movups %xmm0, (%r15)
movups %xmm1, 0x10(%r15)
addl $0x2, %r12d
jmp 0xa8b4
movq -0x40(%rbp), %r13
incq %r13
movq -0x48(%rbp), %rcx
movq %rcx, 0x18(%r15)
movq -0x98(%rbp), %rbx
jmp 0xa845
movq %rax, %r8
movl -0x68(%rbp), %eax
movq -0x58(%rbp), %rcx
leal -0x1(%rcx), %edx
addq %rax, %rax
xorl %ecx, %ecx
leaq 0xf2fd(%rip), %rsi      # 0x19c3f
movq -0x80(%rbp), %r9
cmpq %rcx, %rax
je 0xa966
movl -0x38(%rbp), %edi
sarl %cl, %edi
andl $0x3, %edi
movb (%rdi,%rsi), %dil
movslq %edx, %rdx
movb %dil, (%r9,%rdx)
decl %edx
addq $0x2, %rcx
jmp 0xa946
movq -0x80(%rbp), %rax
movq -0x60(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq -0x58(%rbp), %rax
sarl %eax
movl %eax, -0x8c(%rbp)
movl -0x4c(%rbp), %esi
shlq $0x5, %rsi
addq -0x70(%rbp), %rsi
movq -0x78(%rbp), %rax
leaq 0x10(%rax), %rcx
movq %rcx, -0xa8(%rbp)
addq $0x20, %rax
movq %rax, -0xa0(%rbp)
movq %rbx, %r9
movq %r8, %rdi
movq -0x30(%rbp), %rcx
movq %rsi, -0x60(%rbp)
testq %r9, %r9
je 0xabe4
movq %rcx, -0x30(%rbp)
movl $0x1e, -0x170(%rbp)
movq %r9, %rax
shlq $0x5, %rax
movq %rdi, -0x40(%rbp)
addq %rdi, %rax
pushq $-0x20
popq %rcx
movl -0x4c(%rbp), %edx
testl %edx, %edx
jle 0xa9fd
decq %r9
movups (%rax,%rcx), %xmm0
movups 0x10(%rax,%rcx), %xmm1
movups %xmm1, 0x10(%rsi,%rcx)
movups %xmm0, (%rsi,%rcx)
decl %edx
addq $-0x20, %rcx
jmp 0xa9dc
movq -0x70(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, %rdx
shrq $0x8, %rdx
movq -0x58(%rbp), %rcx
movq %rdx, -0x48(%rbp)
subl %edx, %ecx
jge 0xaa22
movq -0x40(%rbp), %rdi
movq -0x30(%rbp), %rcx
jmp 0xa9b1
movzbl %al, %eax
leaq 0xf563(%rip), %rdx      # 0x19f8f
movb (%rax,%rdx), %al
movslq %ecx, %rcx
movq -0x80(%rbp), %rdx
leaq (%rdx,%rcx), %rsi
movq %rsi, -0x38(%rbp)
movb %al, (%rdx,%rcx)
movq -0xa8(%rbp), %r12
xorl %r15d, %r15d
movq -0x78(%rbp), %r13
movq %r9, %r14
cmpq %rbx, %r15
je 0xaab4
movq -0x88(%rbp), %rax
movq (%rax,%r15,8), %rdi
movq %r15, %rsi
shlq $0x5, %rsi
addq -0x70(%rbp), %rsi
movq %r13, %rdx
pushq $0x1
popq %rcx
callq 0x39db
movl -0x170(%rbp), %eax
movq %r12, %rcx
xorl %edx, %edx
movq %r14, %r9
cmpq $0x6, %rdx
je 0xaaa4
cmpq $0x0, (%rcx)
jne 0xaa9b
btrl %edx, %eax
movl %eax, -0x170(%rbp)
incq %rdx
addq $0x20, %rcx
jmp 0xaa86
incq %r15
movl $0xc0, %eax
addq %rax, %r13
addq %rax, %r12
jmp 0xaa4f
subq $0x8, %rsp
movq 0x18(%rbp), %rdi
movl 0x20(%rbp), %esi
movq -0x48(%rbp), %r15
movl %r15d, %edx
movq -0x38(%rbp), %rcx
movq -0x70(%rbp), %r8
movq -0x78(%rbp), %r9
leaq -0x170(%rbp), %rax
pushq %rax
callq *0x10(%rbp)
addq $0x10, %rsp
xorl %eax, %eax
cmpl %r15d, -0x8c(%rbp)
setne %al
shll $0x8, %r15d
addl $0x100, %r15d           # imm = 0x100
movq %r15, -0x48(%rbp)
cmpl $0x0, -0x90(%rbp)
leaq 0x3(%rax,%rax), %rcx
pushq $0x5
popq %rax
cmoveq %rax, %rcx
movq %rcx, -0x68(%rbp)
movq -0xa0(%rbp), %rdx
pushq $0x1
popq %r8
movq -0x40(%rbp), %rdi
movq -0x30(%rbp), %rcx
movq -0x60(%rbp), %rsi
movq %r14, %r9
cmpq -0x68(%rbp), %r8
je 0xa9b1
movl -0x170(%rbp), %eax
btl %r8d, %eax
jae 0xabd8
movq -0x48(%rbp), %rax
movq %r8, -0x30(%rbp)
orl %r8d, %eax
movslq %eax, %rsi
movq %r9, %r15
shlq $0x5, %r15
movl %ebx, %r14d
movq %rdx, -0x38(%rbp)
movq %rdx, %rbx
movq %rsi, -0x40(%rbp)
subl $0x1, %r14d
jb 0xabc5
cmpq %rcx, %r9
jne 0xab9f
leaq (%rcx,%rcx), %r12
testq %rcx, %rcx
pushq $0x2
popq %rax
cmoveq %rax, %r12
movq %r12, %rsi
shlq $0x5, %rsi
movq %r9, %r13
callq 0x2260
movq -0x40(%rbp), %rsi
movq %r13, %r9
movq %rax, %rdi
movq %r12, %rcx
incq %r9
movq 0x10(%rbx), %rax
movq %rax, 0x10(%rdi,%r15)
movups (%rbx), %xmm0
movups %xmm0, (%rdi,%r15)
movq %rsi, 0x18(%rdi,%r15)
addq $0x20, %r15
addq $0xc0, %rbx
jmp 0xab6a
movq -0x98(%rbp), %rbx
movq -0x60(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x30(%rbp), %r8
incq %r8
addq $0x20, %rdx
jmp 0xab2d
callq 0x2040
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xf11b(%rip), %rdi      # 0x19d1a
leaq 0xf12a(%rip), %rsi      # 0x19d30
leaq 0xf190(%rip), %rcx      # 0x19d9d
pushq $0x65
jmp 0xa74d