// File: /workspace/github_cpp_makefile_star2_O1/Nallantli[P]Rossa/main/rossa/node/node.cpp
// Function: IDNode::fold(std::vector<std::pair<std::vector<unsigned long long, std::allocator<unsigned long long>>, symbol_t>, std::allocator<std::pair<std::vector<unsigned long long, std::allocator<unsigned long long>>, symbol_t>>> const&) const
const ptr_node_t IDNode::fold(const std::vector<std::pair<std::vector<hash_ull>, symbol_t>> &consts) const
{
	bool flag = true;
	for (auto &p : path)
	{
		if (std::find(p.var_ids.begin(), p.var_ids.end(), key) != p.var_ids.end())
		{
			flag = false;
			break;
		}
	}

	if (flag)
	{
		for (auto &c : consts)
		{
			std::vector<hash_ull> tpath;
			for (auto &p : path)
				tpath.push_back(p.id);
			while (true)
			{
				auto temp = tpath;
				temp.push_back({key});

				if (c.first == temp)
					return std::make_shared<ContainerNode>(path, c.second, token);
				if (tpath.empty())
					break;
				tpath.pop_back();
			}
		}
	}

	return std::make_shared<IDNode>(path, key, token);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdi, %rbx
leaq 0x8(%rsi), %rax
movq %rax, 0x50(%rsp)
movq 0x8(%rsi), %r13
movq %rsi, 0x28(%rsp)
movq 0x10(%rsi), %r12
cmpq %r12, %r13
je 0x5af78
movq %rdx, 0x30(%rsp)
movq 0x28(%rsp), %rax
leaq 0xa8(%rax), %r15
addq $0x20, %r13
movb $0x1, %bpl
xorl %r14d, %r14d
movq -0x18(%r13), %rdi
movq -0x10(%r13), %rsi
movq %r15, %rdx
callq 0x68886
movzbl %bpl, %ebp
cmpq -0x10(%r13), %rax
cmovnel %r14d, %ebp
jne 0x5af69
leaq 0x20(%r13), %rax
cmpq %r12, %r13
movq %rax, %r13
jne 0x5af3f
testb $0x1, %bpl
movq 0x30(%rsp), %rdx
je 0x5b132
movq (%rdx), %r13
movq 0x8(%rdx), %rax
movq %rax, 0x68(%rsp)
cmpq %rax, %r13
je 0x5b132
movq 0x28(%rsp), %rax
leaq 0xa8(%rax), %r12
addq $0x28, %rax
movq %rax, 0x70(%rsp)
leaq 0x10(%rsp), %rbp
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq 0x28(%rsp), %rax
movq 0x8(%rax), %r15
movq 0x10(%rax), %r14
cmpq %r14, %r15
je 0x5aff8
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x5afe7
movq (%r15), %rax
movq %rax, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x5aff2
movq %rbp, %rdi
movq %r15, %rdx
callq 0x3c532
addq $0x20, %r15
jmp 0x5afc5
leaq 0x18(%r13), %rax
movq %rax, 0x30(%rsp)
leaq 0x38(%rsp), %rdi
movq %rbp, %rsi
callq 0x2115a
movq 0x40(%rsp), %rsi
cmpq 0x48(%rsp), %rsi
je 0x5b02c
movq (%r12), %rax
movq %rax, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x40(%rsp)
jmp 0x5b039
leaq 0x38(%rsp), %rdi
movq %r12, %rdx
callq 0x3c532
movq (%r13), %rdi
movq 0x8(%r13), %rax
movq %rax, %rdx
subq %rdi, %rdx
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %rcx
subq %rsi, %rcx
cmpq %rcx, %rdx
jne 0x5b067
cmpq %rdi, %rax
je 0x5b084
callq 0x10400
testl %eax, %eax
je 0x5b084
movq 0x18(%rsp), %rax
xorl %r14d, %r14d
cmpq %rax, 0x10(%rsp)
je 0x5b0d5
addq $-0x8, %rax
movq %rax, 0x18(%rsp)
movb $0x1, %r15b
jmp 0x5b0de
movq $0x0, 0x58(%rsp)
leaq 0x60(%rsp), %rdi
leaq 0x58(%rsp), %rsi
leaq 0xf(%rsp), %rdx
movq 0x50(%rsp), %rcx
movq 0x30(%rsp), %r8
movq 0x70(%rsp), %r9
callq 0x6807a
movq 0x58(%rsp), %rax
movq %rax, (%rbx)
xorl %r15d, %r15d
movq %r15, 0x8(%rbx)
movq 0x60(%rsp), %rax
movq %r15, 0x60(%rsp)
movq %rax, 0x8(%rbx)
movl $0x1, %r14d
jmp 0x5b0de
movl $0x9, %r14d
xorl %r15d, %r15d
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x5b0f5
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
callq 0x103d0
testl %r14d, %r14d
je 0x5b001
cmpl $0x9, %r14d
jne 0x5b107
movb $0x1, %r15b
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x5b11e
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x103d0
testb %r15b, %r15b
je 0x5b17b
addq $0x28, %r13
cmpq 0x68(%rsp), %r13
jne 0x5afa7
movq 0x28(%rsp), %r9
leaq 0xa8(%r9), %r8
addq $0x28, %r9
xorl %r15d, %r15d
leaq 0x18(%rsp), %rdi
movq %r15, -0x8(%rdi)
leaq 0x10(%rsp), %r14
leaq 0x38(%rsp), %rdx
movq %r14, %rsi
movq 0x50(%rsp), %rcx
callq 0x68926
movq (%r14), %rax
movq %rax, (%rbx)
movq %r15, 0x8(%rbx)
movq 0x8(%r14), %rax
movq %r15, 0x8(%r14)
movq %rax, 0x8(%rbx)
movq %rbx, %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5b18f
movq %rax, %rbx
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x5b1b0
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
callq 0x103d0
jmp 0x5b1b0
jmp 0x5b1ad
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x5b1c7
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x103d0
movq %rbx, %rdi
callq 0x106f0
nop