// File: Nallantli[P]Rossa/main/rossa/node/node.cpp
// Function: IfElseNode::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 IfElseNode::fold(const std::vector<std::pair<std::vector<hash_ull>, symbol_t>> &consts) const
{
	auto nifs = ifs->fold(consts);
	auto nbody = body->fold(consts);
	ptr_node_t nelses = nullptr;
	if (elses)
		nelses = elses->fold(consts);

	if (nifs->isConst() && nbody->isConst() && (!nelses || nelses->isConst()))
	{
		auto i = genParser();
		object_t newScope(static_cast<hash_ull>(0));
		trace_t stack_trace;
		auto r = i->evaluate(&newScope, stack_trace);
		return std::make_shared<ContainerNode>(path, r, token);
	}

	auto ret = std::make_shared<IfElseNode>(path, nifs, nbody, token);
	if (nelses)
		ret->setElse(nelses);
	return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0xf8(%rbp)
movq %rdi, %rax
movq %rax, -0xf0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
addq $0xa8, %rdi
callq 0x2d030
movq %rax, %rsi
movq -0x18(%rbp), %rdx
movq (%rsi), %rax
movq 0x18(%rax), %rax
leaq -0x28(%rbp), %rdi
callq *%rax
movq -0xe8(%rbp), %rdi
addq $0xb8, %rdi
callq 0x2d030
movq %rax, %rsi
movq -0x18(%rbp), %rdx
movq (%rsi), %rax
movq 0x18(%rax), %rax
leaq -0x38(%rbp), %rdi
callq *%rax
jmp 0xe013c
leaq -0x58(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x58bf0
movq -0xe8(%rbp), %rdi
addq $0xc8, %rdi
callq 0x57630
testb $0x1, %al
jne 0xe0162
jmp 0xe01c5
movq -0xe8(%rbp), %rdi
addq $0xc8, %rdi
callq 0x2d030
movq %rax, %rsi
movq -0x18(%rbp), %rdx
movq (%rsi), %rax
movq 0x18(%rax), %rax
leaq -0x68(%rbp), %rdi
callq *%rax
jmp 0xe018b
leaq -0x58(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x58f60
leaq -0x68(%rbp), %rdi
callq 0x24b20
jmp 0xe01c5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xe045c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xe044a
leaq -0x28(%rbp), %rdi
callq 0x2d030
movq %rax, %rdi
movq (%rdi), %rax
movq 0x8(%rax), %rax
callq *%rax
movb %al, -0xf9(%rbp)
jmp 0xe01e2
movb -0xf9(%rbp), %al
testb $0x1, %al
jne 0xe01f1
jmp 0xe03a7
leaq -0x38(%rbp), %rdi
callq 0x2d030
movq %rax, %rdi
movq (%rdi), %rax
movq 0x8(%rax), %rax
callq *%rax
movb %al, -0xfa(%rbp)
jmp 0xe020e
movb -0xfa(%rbp), %al
testb $0x1, %al
jne 0xe021d
jmp 0xe03a7
leaq -0x58(%rbp), %rdi
callq 0x57630
testb $0x1, %al
jne 0xe022c
jmp 0xe0258
leaq -0x58(%rbp), %rdi
callq 0x2d030
movq %rax, %rdi
movq (%rdi), %rax
movq 0x8(%rax), %rax
callq *%rax
movb %al, -0xfb(%rbp)
jmp 0xe0249
movb -0xfb(%rbp), %al
testb $0x1, %al
jne 0xe0258
jmp 0xe03a7
movq -0xe8(%rbp), %rsi
movq (%rsi), %rax
movq (%rax), %rax
leaq -0x78(%rbp), %rdi
callq *%rax
jmp 0xe026d
movq $0x0, -0x90(%rbp)
leaq -0x88(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x7d410
jmp 0xe028d
leaq -0xa8(%rbp), %rdi
movq %rdi, -0x108(%rbp)
callq 0x24b80
leaq -0x78(%rbp), %rdi
callq 0x2d300
movq -0x108(%rbp), %rcx
movq %rax, %rsi
movq (%rsi), %rax
movq (%rax), %rax
leaq -0xb8(%rbp), %rdi
leaq -0x88(%rbp), %rdx
callq *%rax
jmp 0xe02cb
movq -0xe8(%rbp), %rcx
movq %rcx, %rsi
addq $0x8, %rsi
addq $0x28, %rcx
leaq -0xc8(%rbp), %rdi
leaq -0xb8(%rbp), %rdx
callq 0xe5670
jmp 0xe02f2
movq -0xf8(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x571a0
leaq -0xc8(%rbp), %rdi
callq 0x571d0
movl $0x1, -0xcc(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x86dc0
leaq -0xa8(%rbp), %rdi
callq 0x24e60
leaq -0x88(%rbp), %rdi
callq 0x7d790
leaq -0x78(%rbp), %rdi
callq 0x2a4e0
jmp 0xe041f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xe0399
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xe0381
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x86dc0
leaq -0xa8(%rbp), %rdi
callq 0x24e60
leaq -0x88(%rbp), %rdi
callq 0x7d790
leaq -0x78(%rbp), %rdi
callq 0x2a4e0
jmp 0xe044a
movq -0xe8(%rbp), %r8
movq %r8, %rsi
addq $0x8, %rsi
addq $0x28, %r8
leaq -0xe0(%rbp), %rdi
leaq -0x28(%rbp), %rdx
leaq -0x38(%rbp), %rcx
callq 0xe9570
jmp 0xe03cf
leaq -0x58(%rbp), %rdi
callq 0x57630
testb $0x1, %al
jne 0xe03de
jmp 0xe03f6
leaq -0xe0(%rbp), %rdi
callq 0x59910
movq %rax, %rdi
leaq -0x58(%rbp), %rsi
callq 0xdfac0
movq -0xf8(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x59930
movl $0x1, -0xcc(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x59960
leaq -0x58(%rbp), %rdi
callq 0x24b20
leaq -0x38(%rbp), %rdi
callq 0x24b20
leaq -0x28(%rbp), %rdi
callq 0x24b20
movq -0xf0(%rbp), %rax
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
leaq -0x58(%rbp), %rdi
callq 0x24b20
leaq -0x38(%rbp), %rdi
callq 0x24b20
leaq -0x28(%rbp), %rdi
callq 0x24b20
movq -0x40(%rbp), %rdi
callq 0x119c0
nop