// File: /workspace/github_cpp_makefile_star2_O3/Nallantli[P]Rossa/main/rossa/node/node.cpp
// Function: InsNode::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 InsNode::fold(const std::vector<std::pair<std::vector<hash_ull>, symbol_t>> &consts) const
{
	if (arg->getType() == ID_NODE)
	{
		std::vector<hash_ull> apath;
		auto curr = callee;
		while (true)
		{
			if (curr->getType() == ID_NODE)
			{
				apath.push_back(reinterpret_cast<IDNode *>(curr.get())->getKey());
				break;
			}
			else if (curr->getType() == INS_NODE)
			{
				InsNode *inn = reinterpret_cast<InsNode *>(curr.get());
				if (inn->getArg()->getType() == ID_NODE)
				{
					apath.push_back(reinterpret_cast<IDNode *>(inn->getArg().get())->getKey());
					curr = inn->getCallee();
				}
				else
				{
					return std::make_shared<InsNode>(path, callee->fold(consts), arg->fold(consts), token);
				}
			}
			else
			{
				return std::make_shared<InsNode>(path, callee->fold(consts), arg->fold(consts), token);
			}
		}
		std::vector<hash_ull> fpath;
		while (!apath.empty())
		{
			fpath.push_back(apath.back());
			apath.pop_back();
		}
		fpath.push_back(reinterpret_cast<IDNode *>(arg.get())->getKey());

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

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

	return std::make_shared<InsNode>(path, callee->fold(consts), arg->fold(consts), token);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rdx, %rbx
movq %rsi, %rbp
movq %rdi, 0x90(%rsp)
movq 0xb8(%rsi), %rax
cmpl $0xc, 0x20(%rax)
jne 0x625b6
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movq $0x0, 0x60(%rsp)
movq 0xa8(%rbp), %rax
movq %rax, 0xa0(%rsp)
movq 0xb0(%rbp), %rax
movq %rax, 0xa8(%rsp)
testq %rax, %rax
je 0x61ff9
movq 0x52fa5(%rip), %rcx     # 0xb4f90
cmpb $0x0, (%rcx)
je 0x61ff5
incl 0x8(%rax)
jmp 0x61ff9
lock
incl 0x8(%rax)
movq %rbx, 0x88(%rsp)
movq %rbp, 0x98(%rsp)
leaq 0xa8(%rsp), %rbx
leaq 0x18(%rsp), %r14
movq 0x52f73(%rip), %rbp     # 0xb4f90
movq 0xa0(%rsp), %r15
movl 0x20(%r15), %eax
cmpl $0x5, %eax
jne 0x6213f
movq 0xb8(%r15), %rax
movq 0xc0(%r15), %rdi
testq %rdi, %rdi
je 0x62050
cmpb $0x0, (%rbp)
je 0x6205b
incl 0x8(%rdi)
jmp 0x6205f
cmpl $0xc, 0x20(%rax)
je 0x62091
jmp 0x621ea
lock
incl 0x8(%rdi)
movl 0x20(%rax), %r12d
callq 0x1e5bc
cmpl $0xc, %r12d
jne 0x621ea
movq 0xb8(%r15), %rax
movq 0xc0(%r15), %r13
testq %r13, %r13
je 0x62091
cmpb $0x0, (%rbp)
je 0x62099
incl 0x8(%r13)
jmp 0x6209e
movb $0x1, %r12b
xorl %r13d, %r13d
jmp 0x620a1
lock
incl 0x8(%r13)
xorl %r12d, %r12d
movq 0xa8(%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x58(%rsp), %rsi
cmpq 0x60(%rsp), %rsi
je 0x620c7
movq %rax, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x58(%rsp)
jmp 0x620d6
leaq 0x50(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x391c8
testb %r12b, %r12b
jne 0x620e3
movq %r13, %rdi
callq 0x1e5bc
movq 0xa8(%r15), %rax
movq %rax, 0x10(%rsp)
movq 0xb0(%r15), %rcx
movq %rcx, 0x18(%rsp)
testq %rcx, %rcx
je 0x62114
cmpb $0x0, (%rbp)
je 0x6210b
incl 0x8(%rcx)
jmp 0x62114
lock
incl 0x8(%rcx)
movq 0x10(%rsp), %rax
movq %rax, 0xa0(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3775e
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x6201d
callq 0x1e5bc
jmp 0x6201d
cmpl $0xc, %eax
jne 0x62179
movq 0xa8(%r15), %rax
movq %rax, 0x10(%rsp)
movq 0x58(%rsp), %rsi
cmpq 0x60(%rsp), %rsi
movq 0x98(%rsp), %rbp
je 0x6229b
movq %rax, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x58(%rsp)
jmp 0x622af
movq 0x98(%rsp), %rbp
movq 0xa8(%rbp), %rsi
movq (%rsi), %rax
leaq 0x30(%rsp), %rdi
movq 0x88(%rsp), %rbx
movq %rbx, %rdx
callq *0x18(%rax)
movq 0xb8(%rbp), %rsi
movq (%rsi), %rax
leaq 0x70(%rsp), %rdi
movq %rbx, %rdx
callq *0x18(%rax)
leaq 0x8(%rbp), %rcx
leaq 0x28(%rbp), %rax
leaq 0x18(%rsp), %rdi
movq $0x0, -0x8(%rdi)
movq %rax, (%rsp)
leaq 0x10(%rsp), %rsi
leaq 0xb0(%rsp), %rdx
leaq 0x30(%rsp), %r8
leaq 0x70(%rsp), %r9
callq 0x6bb6c
jmp 0x62259
movq 0x98(%rsp), %rbp
movq 0xa8(%rbp), %rsi
movq (%rsi), %rax
leaq 0x30(%rsp), %rdi
movq 0x88(%rsp), %rbx
movq %rbx, %rdx
callq *0x18(%rax)
movq 0xb8(%rbp), %rsi
movq (%rsi), %rax
leaq 0x70(%rsp), %rdi
movq %rbx, %rdx
callq *0x18(%rax)
leaq 0x8(%rbp), %rcx
leaq 0x28(%rbp), %rax
leaq 0x18(%rsp), %rdi
movq $0x0, -0x8(%rdi)
movq %rax, (%rsp)
leaq 0x10(%rsp), %rsi
leaq 0xb0(%rsp), %rdx
leaq 0x30(%rsp), %r8
leaq 0x70(%rsp), %r9
callq 0x6bb6c
movaps 0x10(%rsp), %xmm0
xorl %eax, %eax
movq %rax, 0x18(%rsp)
movq 0x90(%rsp), %rcx
movups %xmm0, (%rcx)
movq %rax, 0x10(%rsp)
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x62284
callq 0x1e5bc
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x62293
callq 0x1e5bc
xorl %r13d, %r13d
jmp 0x62584
leaq 0x50(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x391c8
movq 0x58(%rsp), %rsi
movq 0x88(%rsp), %r14
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq 0x50(%rsp), %rcx
cmpq %rsi, %rcx
je 0x62348
leaq 0x10(%rsp), %rbx
leaq -0x8(%rsi), %rdx
movq 0x18(%rsp), %rax
cmpq 0x20(%rsp), %rax
je 0x622f8
movq (%rdx), %rdx
movq %rdx, (%rax)
addq $0x8, %rax
movq %rax, 0x18(%rsp)
jmp 0x6230d
movq %rbx, %rdi
movq %rax, %rsi
callq 0x3bf30
movq 0x50(%rsp), %rcx
movq 0x58(%rsp), %rsi
addq $-0x8, %rsi
movq %rsi, 0x58(%rsp)
cmpq %rsi, %rcx
jne 0x622d7
movq 0x18(%rsp), %rsi
movq 0xb8(%rbp), %rax
movq 0xa8(%rax), %rax
movq %rax, 0x30(%rsp)
cmpq 0x20(%rsp), %rsi
je 0x6235d
movq %rax, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x6236c
movq 0xb8(%rbp), %rax
movq 0xa8(%rax), %rax
movq %rax, 0x30(%rsp)
xorl %esi, %esi
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x391c8
movq (%r14), %r12
movq 0x8(%r14), %rax
movq %rax, 0xc8(%rsp)
cmpq %rax, %r12
je 0x62562
leaq 0x8(%rbp), %rax
movq %rax, 0xd8(%rsp)
leaq 0x28(%rbp), %rax
movq %rax, 0xd0(%rsp)
leaq 0x70(%rsp), %r15
leaq 0x30(%rsp), %r14
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
movq 0x8(%rbp), %rbx
movq 0x10(%rbp), %r13
cmpq %r13, %rbx
je 0x623f2
movq 0x38(%rsp), %rsi
cmpq 0x40(%rsp), %rsi
je 0x623e1
movq (%rbx), %rax
movq %rax, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x38(%rsp)
jmp 0x623ec
movq %r14, %rdi
movq %rbx, %rdx
callq 0x3bf30
addq $0x20, %rbx
jmp 0x623bf
leaq 0x18(%r12), %rax
movq %rax, 0xe0(%rsp)
movq %r15, %rdi
movq %r14, %rsi
callq 0x20fee
movq 0x10(%rsp), %rbp
movq 0x18(%rsp), %rbx
cmpq %rbx, %rbp
je 0x6244b
movq 0x78(%rsp), %rsi
cmpq 0x80(%rsp), %rsi
je 0x6243a
movq (%rbp), %rax
movq %rax, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x78(%rsp)
jmp 0x62445
movq %r15, %rdi
movq %rbp, %rdx
callq 0x3bf30
addq $0x8, %rbp
jmp 0x62414
movq (%r12), %rdi
movq 0x8(%r12), %rax
movq %rax, %rdx
subq %rdi, %rdx
movq 0x70(%rsp), %rbp
movq 0x78(%rsp), %rcx
subq %rbp, %rcx
cmpq %rcx, %rdx
jne 0x6247d
cmpq %rdi, %rax
je 0x62499
movq %rbp, %rsi
callq 0x10400
testl %eax, %eax
je 0x62499
movq 0x38(%rsp), %rax
xorl %ebx, %ebx
cmpq %rax, 0x30(%rsp)
je 0x624f9
addq $-0x8, %rax
movq %rax, 0x38(%rsp)
movb $0x1, %r13b
jmp 0x62501
movq $0x0, 0xb0(%rsp)
leaq 0xb8(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
leaq 0x6f(%rsp), %rdx
movq 0xd8(%rsp), %rcx
movq 0xe0(%rsp), %r8
movq 0xd0(%rsp), %r9
callq 0x672e2
movaps 0xb0(%rsp), %xmm0
movq 0x90(%rsp), %rax
movups %xmm0, (%rax)
movl $0x1, %ebx
xorl %r13d, %r13d
movq 0x70(%rsp), %rbp
jmp 0x62501
movl $0xb, %ebx
xorl %r13d, %r13d
testq %rbp, %rbp
je 0x62519
movq 0x80(%rsp), %rsi
subq %rbp, %rsi
movq %rbp, %rdi
callq 0x103d0
testl %ebx, %ebx
je 0x623ff
cmpl $0xb, %ebx
jne 0x62529
movb $0x1, %r13b
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
movq 0x98(%rsp), %rbp
je 0x62548
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x103d0
addq $0x28, %r12
cmpq 0xc8(%rsp), %r12
setne %al
testb %al, %r13b
jne 0x623a6
jmp 0x62565
movb $0x1, %r13b
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x6257c
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x103d0
movq 0x88(%rsp), %rbx
movq 0xa8(%rsp), %rdi
testq %rdi, %rdi
je 0x62596
callq 0x1e5bc
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x625ad
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x103d0
testb %r13b, %r13b
je 0x6264c
movq 0xa8(%rbp), %rsi
movq (%rsi), %rax
leaq 0x10(%rsp), %rdi
movq %rbx, %rdx
callq *0x18(%rax)
movq 0xb8(%rbp), %rsi
movq (%rsi), %rax
leaq 0x30(%rsp), %rdi
movq %rbx, %rdx
callq *0x18(%rax)
leaq 0x8(%rbp), %rcx
addq $0x28, %rbp
leaq 0x58(%rsp), %rdi
movq $0x0, -0x8(%rdi)
movq %rbp, (%rsp)
leaq 0x50(%rsp), %rsi
leaq 0x70(%rsp), %rdx
leaq 0x10(%rsp), %r8
leaq 0x30(%rsp), %r9
callq 0x6bb6c
movaps 0x50(%rsp), %xmm0
xorl %eax, %eax
movq %rax, 0x58(%rsp)
movq 0x90(%rsp), %rcx
movups %xmm0, (%rcx)
movq %rax, 0x50(%rsp)
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x6263d
callq 0x1e5bc
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x6264c
callq 0x1e5bc
movq 0x90(%rsp), %rax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x62696
jmp 0x626cd
jmp 0x62670
jmp 0x62684
jmp 0x62696
movq %rax, %rbx
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x62687
callq 0x1e5bc
jmp 0x62687
movq %rax, %rbx
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
jne 0x626dd
jmp 0x62738
movq %rax, %rbx
jmp 0x62738
movq %rax, %rbx
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x626b5
callq 0x1e5bc
jmp 0x626b5
movq %rax, %rbx
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x62761
callq 0x1e5bc
jmp 0x62761
movq %rax, %rbx
jmp 0x62721
movq %rax, %rbx
testb %r12b, %r12b
jne 0x62738
movq %r13, %rdi
callq 0x1e5bc
jmp 0x62738
jmp 0x626ed
jmp 0x626e8
movq %rax, %rbx
jmp 0x6270a
movq %rax, %rbx
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x6270a
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x103d0
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x62721
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x103d0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x62738
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x103d0
movq 0xa8(%rsp), %rdi
testq %rdi, %rdi
je 0x6274a
callq 0x1e5bc
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x62761
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x103d0
movq %rbx, %rdi
callq 0x106f0
nop