// File: 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
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movq %rdi, -0x120(%rbp)
movq %rdi, %rax
movq %rax, -0x118(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x110(%rbp)
movb $0x1, -0x19(%rbp)
addq $0x8, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
callq 0xe4e60
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rdi
callq 0xe4e90
movq %rax, -0x38(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0xe4ec0
testb $0x1, %al
jne 0xd407f
jmp 0xd4107
leaq -0x30(%rbp), %rdi
callq 0xe4f00
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
addq $0x8, %rdi
callq 0x2e5d0
movq %rax, -0x50(%rbp)
movq -0x40(%rbp), %rdi
addq $0x8, %rdi
callq 0x2e600
movq -0x110(%rbp), %rdx
movq %rax, -0x58(%rbp)
addq $0xa8, %rdx
movq -0x50(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0xe5a10
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rdi
addq $0x8, %rdi
callq 0x2e600
movq %rax, -0x60(%rbp)
leaq -0x48(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0xe4f20
testb $0x1, %al
jne 0xd40f1
jmp 0xd40f7
movb $0x0, -0x19(%rbp)
jmp 0xd4107
jmp 0xd40f9
leaq -0x30(%rbp), %rdi
callq 0xe4fa0
jmp 0xd4069
testb $0x1, -0x19(%rbp)
je 0xd4379
movq -0x18(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
callq 0xe5a60
movq %rax, -0x70(%rbp)
movq -0x68(%rbp), %rdi
callq 0xe5a90
movq %rax, -0x78(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0xe5ac0
testb $0x1, %al
jne 0xd4149
jmp 0xd4377
leaq -0x70(%rbp), %rdi
callq 0xe5b00
movq %rax, -0x80(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x2ccf0
movq -0x110(%rbp), %rax
addq $0x8, %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rdi
callq 0xe4e60
movq %rax, -0xa8(%rbp)
movq -0xa0(%rbp), %rdi
callq 0xe4e90
movq %rax, -0xb0(%rbp)
leaq -0xa8(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0xe4ec0
testb $0x1, %al
jne 0xd41b3
jmp 0xd4202
leaq -0xa8(%rbp), %rdi
callq 0xe4f00
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rsi
leaq -0x98(%rbp), %rdi
callq 0x5a2f0
jmp 0xd41db
jmp 0xd41dd
leaq -0xa8(%rbp), %rdi
callq 0xe4fa0
jmp 0xd419a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0xd4369
jmp 0xd4204
jmp 0xd4206
leaq -0xe0(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x2e3e0
jmp 0xd421b
movq -0x110(%rbp), %rsi
addq $0xa8, %rsi
leaq -0xe0(%rbp), %rdi
callq 0x5a2f0
jmp 0xd4237
movq -0x80(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0xe5b20
movb %al, -0x121(%rbp)
jmp 0xd424f
movb -0x121(%rbp), %al
testb $0x1, %al
jne 0xd425b
jmp 0xd42d1
movq -0x110(%rbp), %rcx
movq %rcx, %rsi
addq $0x8, %rsi
movq -0x80(%rbp), %rdx
addq $0x18, %rdx
addq $0x28, %rcx
leaq -0xf0(%rbp), %rdi
callq 0xe5180
jmp 0xd4283
movq -0x120(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x571a0
leaq -0xf0(%rbp), %rdi
callq 0x571d0
movl $0x1, -0xf4(%rbp)
jmp 0xd4305
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x2ce90
jmp 0xd4369
leaq -0x98(%rbp), %rdi
callq 0xe5ba0
testb $0x1, %al
jne 0xd42e3
jmp 0xd42ef
movl $0x9, -0xf4(%rbp)
jmp 0xd4305
leaq -0x98(%rbp), %rdi
callq 0xe5be0
movl $0x0, -0xf4(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x2ce90
movl -0xf4(%rbp), %eax
movl %eax, -0x128(%rbp)
testl %eax, %eax
je 0xd4330
jmp 0xd4323
movl -0x128(%rbp), %eax
subl $0x9, %eax
je 0xd4335
jmp 0xd433f
jmp 0xd4204
movl $0x0, -0xf4(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x2ce90
movl -0xf4(%rbp), %eax
testl %eax, %eax
je 0xd4359
jmp 0xd4357
jmp 0xd43c0
jmp 0xd435b
leaq -0x70(%rbp), %rdi
callq 0xe5c10
jmp 0xd4133
leaq -0x98(%rbp), %rdi
callq 0x2ce90
jmp 0xd43d0
jmp 0xd4379
movq -0x110(%rbp), %rcx
movq %rcx, %rsi
addq $0x8, %rsi
movq %rcx, %rdx
addq $0xa8, %rdx
addq $0x28, %rcx
leaq -0x108(%rbp), %rdi
callq 0xe5c30
movq -0x120(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x57270
leaq -0x108(%rbp), %rdi
callq 0x572a0
movq -0x118(%rbp), %rax
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
movq -0xc0(%rbp), %rdi
callq 0x119c0
nopl (%rax)