// File: /workspace/github_cpp_makefile_star2_O1/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, %r12
movq %rsi, %rbx
movq %rdi, 0x78(%rsp)
movq 0xb8(%rsi), %rax
cmpl $0xc, 0x20(%rax)
jne 0x63188
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movq $0x0, 0x60(%rsp)
movq 0xa8(%rbx), %rax
movq %rax, 0xc0(%rsp)
movq 0xb0(%rbx), %rax
movq %rax, 0xc8(%rsp)
testq %rax, %rax
je 0x62b7a
movq 0x54424(%rip), %rcx     # 0xb6f90
cmpb $0x0, (%rcx)
je 0x62b76
incl 0x8(%rax)
jmp 0x62b7a
lock
incl 0x8(%rax)
leaq 0x8(%rbx), %rax
movq %rax, 0xa8(%rsp)
leaq 0x28(%rbx), %rax
movq %rax, 0xa0(%rsp)
leaq 0x80(%rsp), %r14
xorl %r13d, %r13d
movq %r12, 0xd8(%rsp)
movq 0xc0(%rsp), %rbp
movl 0x20(%rbp), %eax
cmpl $0x5, %eax
jne 0x62d89
movq 0xb8(%rbp), %rax
movq 0xc0(%rbp), %rdi
testq %rdi, %rdi
je 0x62be1
movq 0x543bd(%rip), %rcx     # 0xb6f90
cmpb $0x0, (%rcx)
je 0x62bdd
incl 0x8(%rdi)
jmp 0x62be1
lock
incl 0x8(%rdi)
movl 0x20(%rax), %r15d
testq %rdi, %rdi
je 0x62bef
callq 0x1e6ee
cmpl $0xc, %r15d
jne 0x62c26
movq 0xb8(%rbp), %rax
movq 0xc0(%rbp), %r12
testq %r12, %r12
je 0x62cd0
movq 0x5437d(%rip), %rcx     # 0xb6f90
cmpb $0x0, (%rcx)
je 0x62cca
incl 0x8(%r12)
jmp 0x62cd0
movq 0xa8(%rbx), %rsi
movq (%rsi), %rax
leaq 0x30(%rsp), %rdi
movq %r12, %rdx
callq *0x18(%rax)
movq 0xb8(%rbx), %rsi
movq (%rsi), %rax
movq %r14, %rdi
movq %r12, %rdx
callq *0x18(%rax)
movq $0x0, 0x10(%rsp)
movq 0xa0(%rsp), %rax
movq %rax, (%rsp)
leaq 0x18(%rsp), %rdi
leaq 0x10(%rsp), %rsi
leaq 0xb0(%rsp), %rdx
movq 0xa8(%rsp), %rcx
leaq 0x30(%rsp), %r8
movq %r14, %r9
callq 0x6ca88
movq 0x10(%rsp), %rax
movq 0x78(%rsp), %rcx
movq %rax, (%rcx)
movq %r13, 0x8(%rcx)
movq 0x18(%rsp), %rax
movq %r13, 0x18(%rsp)
movq %rax, 0x8(%rcx)
movq %r13, 0x10(%rsp)
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x62cc0
callq 0x1e6ee
movq 0x38(%rsp), %rdi
jmp 0x62d70
lock
incl 0x8(%r12)
movq 0xa8(%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x58(%rsp), %rsi
cmpq 0x60(%rsp), %rsi
je 0x62cf6
movq %rax, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x58(%rsp)
jmp 0x62d05
leaq 0x50(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x39756
testq %r12, %r12
je 0x62d12
movq %r12, %rdi
callq 0x1e6ee
movq 0xa8(%rbp), %rax
movq %rax, 0x10(%rsp)
movq 0xb0(%rbp), %rax
movq %rax, 0x18(%rsp)
testq %rax, %rax
movq 0xd8(%rsp), %r12
je 0x62d4c
movq 0x54252(%rip), %rcx     # 0xb6f90
cmpb $0x0, (%rcx)
je 0x62d48
incl 0x8(%rax)
jmp 0x62d4c
lock
incl 0x8(%rax)
movq 0x10(%rsp), %rax
movq %rax, 0xc0(%rsp)
leaq 0xc8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x37c6e
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x62d7a
callq 0x1e6ee
cmpl $0xc, %r15d
je 0x62ba5
jmp 0x62e6f
cmpl $0xc, %eax
jne 0x62dbb
movq 0xa8(%rbp), %rax
movq %rax, 0x10(%rsp)
movq 0x58(%rsp), %rsi
cmpq 0x60(%rsp), %rsi
je 0x62e76
movq %rax, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x58(%rsp)
jmp 0x62e85
movq 0xa8(%rbx), %rsi
movq (%rsi), %rax
leaq 0x30(%rsp), %rdi
movq %r12, %rdx
callq *0x18(%rax)
movq 0xb8(%rbx), %rsi
movq (%rsi), %rax
leaq 0x80(%rsp), %rdi
movq %r12, %rdx
callq *0x18(%rax)
leaq 0x18(%rsp), %rdi
movq $0x0, -0x8(%rdi)
movq 0xa0(%rsp), %rax
movq %rax, (%rsp)
leaq 0x10(%rsp), %rsi
leaq 0xb0(%rsp), %rdx
leaq 0x30(%rsp), %r8
leaq 0x80(%rsp), %r9
movq 0xa8(%rsp), %rcx
callq 0x6ca88
movq 0x10(%rsp), %rax
movq 0x78(%rsp), %rdx
movq %rax, (%rdx)
xorl %eax, %eax
movq %rax, 0x8(%rdx)
movq 0x18(%rsp), %rcx
movq %rax, 0x18(%rsp)
movq %rcx, 0x8(%rdx)
movq %rax, 0x10(%rsp)
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x62e60
callq 0x1e6ee
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x62e6f
callq 0x1e6ee
xorl %ebp, %ebp
jmp 0x63155
leaq 0x50(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x39756
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq 0x58(%rsp), %rdx
cmpq %rdx, 0x50(%rsp)
je 0x62ee8
leaq 0x10(%rsp), %r15
addq $-0x8, %rdx
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x62ec8
movq (%rdx), %rax
movq %rax, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x62ed0
movq %r15, %rdi
callq 0x3c532
movq 0x50(%rsp), %rax
movq 0x58(%rsp), %rdx
addq $-0x8, %rdx
movq %rdx, 0x58(%rsp)
cmpq %rdx, %rax
jne 0x62ea7
movq 0xb8(%rbx), %rax
movq 0xa8(%rax), %rax
movq %rax, 0x30(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x62f15
movq %rax, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x62f24
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x39756
movq (%r12), %r14
movq 0x8(%r12), %rax
movq %rax, 0xe0(%rsp)
cmpq %rax, %r14
sete %al
movl %eax, 0x9c(%rsp)
je 0x6312f
leaq 0x80(%rsp), %r15
leaq 0x30(%rsp), %rbp
movq %rbx, 0xd0(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
movq 0x8(%rbx), %r12
movq 0x10(%rbx), %rbx
cmpq %rbx, %r12
je 0x62faa
movq 0x38(%rsp), %rsi
cmpq 0x40(%rsp), %rsi
je 0x62f99
movq (%r12), %rax
movq %rax, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x38(%rsp)
jmp 0x62fa4
movq %rbp, %rdi
movq %r12, %rdx
callq 0x3c532
addq $0x20, %r12
jmp 0x62f76
leaq 0x18(%r14), %r12
movq %r15, %rdi
movq %rbp, %rsi
callq 0x2115a
movq 0x10(%rsp), %r13
movq 0x18(%rsp), %rbx
cmpq %rbx, %r13
je 0x63000
movq 0x88(%rsp), %rsi
cmpq 0x90(%rsp), %rsi
je 0x62fef
movq (%r13), %rax
movq %rax, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x88(%rsp)
jmp 0x62ffa
movq %r15, %rdi
movq %r13, %rdx
callq 0x3c532
addq $0x8, %r13
jmp 0x62fc3
movq (%r14), %rdi
movq 0x8(%r14), %rax
movq %rax, %rdx
subq %rdi, %rdx
movq 0x80(%rsp), %rsi
movq 0x88(%rsp), %rcx
subq %rsi, %rcx
cmpq %rcx, %rdx
jne 0x63033
cmpq %rdi, %rax
je 0x6304f
callq 0x10400
testl %eax, %eax
je 0x6304f
movq 0x38(%rsp), %rax
xorl %ebx, %ebx
cmpq %rax, 0x30(%rsp)
je 0x630ba
addq $-0x8, %rax
movq %rax, 0x38(%rsp)
movb $0x1, %r13b
jmp 0x630c2
movq $0x0, 0xb0(%rsp)
leaq 0xb8(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
leaq 0x77(%rsp), %rdx
movq 0xa8(%rsp), %rcx
movq %r12, %r8
movq 0xa0(%rsp), %r9
callq 0x6807a
movq 0xb0(%rsp), %rax
movq 0x78(%rsp), %rcx
movq %rax, (%rcx)
xorl %r13d, %r13d
movq %r13, 0x8(%rcx)
movq 0xb8(%rsp), %rax
movq %r13, 0xb8(%rsp)
movq %rax, 0x8(%rcx)
movl $0x1, %ebx
jmp 0x630c2
movl $0xb, %ebx
xorl %r13d, %r13d
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x630df
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x103d0
testl %ebx, %ebx
je 0x62fae
cmpl $0xb, %ebx
jne 0x630ef
movb $0x1, %r13b
movq 0xd0(%rsp), %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x6310e
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x103d0
testb %r13b, %r13b
je 0x6312f
addq $0x28, %r14
cmpq 0xe0(%rsp), %r14
sete %al
movl %eax, 0x9c(%rsp)
jne 0x62f5d
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x63146
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x103d0
movq 0xd8(%rsp), %r12
movl 0x9c(%rsp), %ebp
movq 0xc8(%rsp), %rdi
testq %rdi, %rdi
je 0x63167
callq 0x1e6ee
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x6317e
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x103d0
testb $0x1, %bpl
je 0x6322b
movq 0xa8(%rbx), %rsi
movq (%rsi), %rax
leaq 0x10(%rsp), %rdi
movq %r12, %rdx
callq *0x18(%rax)
movq 0xb8(%rbx), %rsi
movq (%rsi), %rax
leaq 0x30(%rsp), %rdi
movq %r12, %rdx
callq *0x18(%rax)
leaq 0x8(%rbx), %rcx
addq $0x28, %rbx
leaq 0x58(%rsp), %rdi
movq $0x0, -0x8(%rdi)
movq %rbx, (%rsp)
leaq 0x50(%rsp), %rsi
leaq 0x80(%rsp), %rdx
leaq 0x10(%rsp), %r8
leaq 0x30(%rsp), %r9
callq 0x6ca88
movq 0x50(%rsp), %rax
movq 0x78(%rsp), %rdx
movq %rax, (%rdx)
xorl %eax, %eax
movq %rax, 0x8(%rdx)
movq 0x58(%rsp), %rcx
movq %rax, 0x58(%rsp)
movq %rcx, 0x8(%rdx)
movq %rax, 0x50(%rsp)
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x6321c
callq 0x1e6ee
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x6322b
callq 0x1e6ee
movq 0x78(%rsp), %rax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6328c
jmp 0x632a8
jmp 0x63291
jmp 0x632ad
jmp 0x632a8
movq %rax, %rbx
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x63263
callq 0x1e6ee
jmp 0x63263
movq %rax, %rbx
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x63341
callq 0x1e6ee
jmp 0x63341
movq %rax, %rbx
testq %r12, %r12
je 0x63318
movq %r12, %rdi
jmp 0x632ba
movq %rax, %rbx
jmp 0x63301
movq %rax, %rbx
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x632b0
callq 0x1e6ee
jmp 0x632b0
movq %rax, %rbx
jmp 0x63318
movq %rax, %rbx
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x63318
callq 0x1e6ee
jmp 0x63318
jmp 0x632ca
jmp 0x632c5
movq %rax, %rbx
jmp 0x632ea
movq %rax, %rbx
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x632ea
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x103d0
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x63301
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x103d0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x63318
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x103d0
movq 0xc8(%rsp), %rdi
testq %rdi, %rdi
je 0x6332a
callq 0x1e6ee
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x63341
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x103d0
movq %rbx, %rdi
callq 0x106f0
nop