// File: /workspace/github_cpp_makefile_star2_O2/Nallantli[P]Rossa/main/rossa/node_parser/node_parser.cpp
// Function: node_parser_t::parseLambdaNode(std::vector<node_scope_t, std::allocator<node_scope_t>>*)
ptr_node_t node_parser_t::parseLambdaNode(std::vector<node_scope_t> *scopes)
{
	nextToken();
	scopes->push_back({ROSSA_HASH("<LAM@" + std::to_string(scope_i++) + ">")});

	bool isVargs = false;
	auto sig = parseSigNode(scopes);
	if (!sig.second.empty() && sig.second[0].first == 1 && sig.second[0].second == 0)
		isVargs = true;

	int i = 0;
	std::vector<hash_ull> captures;
	if (currentToken.type == '[')
	{
		nextToken();
		while (currentToken.type != ']')
		{
			if (i++ > 0)
			{
				if (currentToken.type != ',')
					return logErrorN(util::format(_EXPECTED_ERROR_, {","}), currentToken);
				nextToken();
			}

			std::string arg;

			if (currentToken.type == TOK_IDF)
				arg = currentToken.valueString;
			else
				return logErrorN("Expected variable identifier", currentToken);
			nextToken();

			captures.push_back(ROSSA_HASH(arg));
		}
		nextToken();
	}

	if (currentToken.type != '{')
	{
		auto body = parseEquNode(scopes);

		if (!body)
			return logErrorN(_FAILURE_PARSE_CODE_, currentToken);

		scopes->pop_back();
		if (isVargs)
			return std::make_shared<VargDefineNode>(*scopes, 0, body, captures, currentToken);
		else
			return std::make_shared<DefineNode>(*scopes, 0, sig.first, sig.second, body, captures, currentToken);
	}
	else
	{
		std::vector<ptr_node_t> vbody;

		nextToken();
		while (currentToken.type != NULL_TOK)
		{
			if (currentToken.type == NULL_TOK || currentToken.type == '}')
				break;

			if (auto e = parseExprNode(scopes))
				vbody.push_back(e);
			else
				return logErrorN(_FAILURE_PARSE_CODE_, currentToken);
		}
		if (currentToken.type != '}')
			return logErrorN(util::format(_EXPECTED_ERROR_, {"}"}), currentToken);
		nextToken();

		auto body = std::make_shared<VectorNode>(*scopes, vbody, true, currentToken);

		scopes->pop_back();
		if (isVargs)
			return std::make_shared<VargDefineNode>(*scopes, 0, body, captures, currentToken);
		else
			return std::make_shared<DefineNode>(*scopes, 0, sig.first, sig.second, body, captures, currentToken);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdx, %rbp
movq %rsi, %r14
movq %rdi, %r12
movq %rsi, %rdi
callq 0x22e24
movq (%r14), %rsi
leaq 0x1(%rsi), %rax
movq %rax, (%r14)
leaq 0x68(%rsp), %rbx
movq %rbx, %rdi
callq 0x2ecd6
leaq 0x4edd6(%rip), %rsi     # 0x7696c
leaq 0x30(%rsp), %rdi
movq %rbx, %rdx
callq 0x1ca9c
leaq 0x4e7c4(%rip), %rdx     # 0x7636e
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x1ca7d
leaq 0x8ed48(%rip), %rdi     # 0xb6908
leaq 0x10(%rsp), %rsi
callq 0x1efb0
leaq 0xd8(%rsp), %r15
movq %rax, -0x8(%r15)
xorps %xmm0, %xmm0
movups %xmm0, (%r15)
andq $0x0, 0x10(%r15)
leaq 0xd0(%rsp), %rsi
movq %rbp, %rdi
callq 0x1fe52
movq %r15, %rdi
callq 0x1f5c4
leaq 0x10(%rsp), %rdi
callq 0x101d0
leaq 0x30(%rsp), %rdi
callq 0x101d0
leaq 0x68(%rsp), %rdi
callq 0x101d0
leaq 0xd0(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
movq %rbp, %rdx
callq 0x26714
movq 0x18(%rbx), %rax
cmpq 0x20(%rbx), %rax
movq %r12, 0x60(%rsp)
je 0x27c4d
cmpb $0x1, (%rax)
jne 0x27c4d
cmpq $0x0, 0x8(%rax)
sete %r12b
jmp 0x27c50
xorl %r12d, %r12d
xorps %xmm0, %xmm0
andq $0x0, 0xc0(%rsp)
movaps %xmm0, 0xb0(%rsp)
leaq 0x58(%r14), %r13
movl 0xd0(%r14), %eax
cmpl $0x5b, %eax
movq %r13, 0x58(%rsp)
jne 0x27d5c
movl %r12d, 0x8c(%rsp)
movq %rbp, 0xc8(%rsp)
movq %r14, %rdi
callq 0x22e24
leaq 0xb0(%r14), %r13
xorl %r15d, %r15d
leaq 0x10(%rsp), %rbp
leaq 0xb0(%rsp), %rbx
leaq 0x30(%rsp), %r12
movl 0xd0(%r14), %eax
cmpl $0x5d, %eax
je 0x27d38
subl $0x1, %r15d
jb 0x27cdb
cmpl $0x2c, %eax
jne 0x2804a
movq %r14, %rdi
callq 0x22e24
movl 0xd0(%r14), %eax
leaq 0x20(%rsp), %rcx
movq %rcx, 0x10(%rsp)
andq $0x0, 0x18(%rsp)
movb $0x0, 0x20(%rsp)
cmpl $-0x2, %eax
jne 0x27f8b
movq %rbp, %rdi
movq %r13, %rsi
callq 0x10220
movq %r14, %rdi
callq 0x22e24
leaq 0x8ebf5(%rip), %rdi     # 0xb6908
movq %rbp, %rsi
callq 0x1efb0
movq %rax, 0x30(%rsp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x31afa
movq %rbp, %rdi
callq 0x101d0
jmp 0x27cb1
movq %r14, %rdi
callq 0x22e24
movl 0xd0(%r14), %eax
movq 0x58(%rsp), %r13
movq 0xc8(%rsp), %rbp
movl 0x8c(%rsp), %r12d
leaq 0xe8(%rsp), %rbx
cmpl $0x7b, %eax
jne 0x27dde
xorps %xmm0, %xmm0
movaps %xmm0, 0x90(%rsp)
andq $0x0, 0xa0(%rsp)
movq %r14, %rdi
callq 0x22e24
leaq 0x38(%rsp), %r13
leaq 0x30(%rsp), %rbx
leaq 0x90(%rsp), %r15
movl 0xd0(%r14), %eax
cmpl $0x7d, %eax
je 0x27e35
testl %eax, %eax
je 0x27fb3
movq %rbx, %rdi
movq %r14, %rsi
movq %rbp, %rdx
callq 0x23390
cmpq $0x0, 0x30(%rsp)
je 0x28022
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2e880
movq %r13, %rdi
callq 0x1d786
jmp 0x27d97
leaq 0x30(%rsp), %rdi
movq %r14, %rsi
movq %rbp, %rdx
callq 0x25798
cmpq $0x0, 0x30(%rsp)
je 0x280bc
movq %rbp, %rdi
callq 0x2eb8e
leaq 0x68(%rsp), %rdx
testb %r12b, %r12b
je 0x27ea1
andl $0x0, (%rdx)
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rcx
leaq 0xb0(%rsp), %r8
movq %rbp, %rsi
movq %r13, %r9
callq 0x2ed18
jmp 0x27ece
movq %r14, %rdi
callq 0x22e24
leaq 0x30(%rsp), %rcx
movb $0x1, (%rcx)
leaq 0x10(%rsp), %rdi
leaq 0x90(%rsp), %rdx
movq %rbp, %rsi
movq 0x58(%rsp), %r13
movq %r13, %r8
callq 0x2e811
leaq 0xe8(%rsp), %rbx
movq %rbp, %rdi
callq 0x2eb8e
leaq 0x68(%rsp), %rdx
testb %r12b, %r12b
je 0x27ef9
andl $0x0, (%rdx)
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rcx
leaq 0xb0(%rsp), %r8
movq %rbp, %rsi
movq %r13, %r9
callq 0x2ed7e
jmp 0x27f26
andl $0x0, (%rdx)
leaq 0xb0(%rsp), %rax
leaq 0x10(%rsp), %rdi
leaq 0xd0(%rsp), %rcx
leaq 0x30(%rsp), %r9
movq %rbp, %rsi
movq %rbx, %r8
pushq %r13
pushq %rax
callq 0x2ed46
popq %rax
popq %rcx
leaq 0x18(%rsp), %rdi
movaps -0x8(%rdi), %xmm0
andq $0x0, (%rdi)
movq 0x60(%rsp), %rbx
movups %xmm0, (%rbx)
andq $0x0, -0x8(%rdi)
callq 0x1d786
leaq 0x38(%rsp), %rdi
callq 0x1d786
jmp 0x27f5c
andl $0x0, (%rdx)
leaq 0xb0(%rsp), %rax
leaq 0x30(%rsp), %rdi
leaq 0xd0(%rsp), %rcx
leaq 0x10(%rsp), %r9
movq %rbp, %rsi
movq %rbx, %r8
pushq %r13
pushq %rax
callq 0x2edac
popq %rax
popq %rcx
leaq 0x38(%rsp), %rdi
movaps -0x8(%rdi), %xmm0
andq $0x0, (%rdi)
movq 0x60(%rsp), %rbx
movups %xmm0, (%rbx)
andq $0x0, -0x8(%rdi)
callq 0x1d786
leaq 0x18(%rsp), %rdi
callq 0x1d786
leaq 0x90(%rsp), %rdi
callq 0x2e838
leaq 0xb0(%rsp), %rdi
callq 0x1f5c4
leaq 0xd0(%rsp), %rdi
callq 0x2ec72
movq %rbx, %rax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4e974(%rip), %rsi     # 0x76906
leaq 0x30(%rsp), %rdi
leaq 0x68(%rsp), %rdx
callq 0x1c814
leaq 0x30(%rsp), %rdx
movq %r14, %rsi
movq 0x58(%rsp), %rcx
callq 0x25932
leaq 0x4e8ea(%rip), %rsi     # 0x768a4
leaq 0x30(%rsp), %rdi
leaq 0xe(%rsp), %rdx
callq 0x1c814
leaq 0x528f1(%rip), %rsi     # 0x7a8c1
leaq 0x68(%rsp), %rdi
leaq 0xd(%rsp), %rdx
callq 0x1c814
leaq 0x100(%rsp), %rdi
leaq 0x68(%rsp), %rsi
pushq $0x1
popq %rdx
leaq 0xf(%rsp), %rcx
callq 0x1f298
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x100(%rsp), %rdx
callq 0x3f724
leaq 0x10(%rsp), %rdx
movq %r14, %rsi
movq 0x58(%rsp), %rcx
callq 0x25932
leaq 0x4e911(%rip), %rsi     # 0x7693a
leaq 0x10(%rsp), %rdi
leaq 0x68(%rsp), %rdx
callq 0x1c814
leaq 0x10(%rsp), %rdx
movq %r14, %rsi
movq 0x58(%rsp), %rcx
callq 0x25932
leaq 0x4e853(%rip), %rsi     # 0x768a4
leaq 0x30(%rsp), %rdi
leaq 0x100(%rsp), %rdx
callq 0x1c814
leaq 0x4ea9a(%rip), %rsi     # 0x76b04
leaq 0x68(%rsp), %rdi
leaq 0xe(%rsp), %rdx
callq 0x1c814
leaq 0x90(%rsp), %rdi
leaq 0x68(%rsp), %rsi
pushq $0x1
popq %rdx
leaq 0xd(%rsp), %rcx
callq 0x1f298
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x90(%rsp), %rdx
callq 0x3f724
leaq 0x10(%rsp), %rdx
movq %r14, %rsi
movq 0x58(%rsp), %rcx
callq 0x25932
leaq 0x4e877(%rip), %rsi     # 0x7693a
leaq 0x10(%rsp), %rdi
leaq 0x68(%rsp), %rdx
callq 0x1c814
leaq 0x10(%rsp), %rdx
movq %r14, %rsi
movq %r13, %rcx
callq 0x25932
jmp 0x280e4
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
jmp 0x2820e
jmp 0x28104
jmp 0x28104
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x101d0
jmp 0x28107
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x1d786
jmp 0x28236
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x101d0
jmp 0x28128
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x1cea0
jmp 0x28165
jmp 0x28215
jmp 0x281f2
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x101d0
jmp 0x28153
movq %rax, %rbx
leaq 0x100(%rsp), %rdi
callq 0x1cea0
jmp 0x281b8
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x101d0
jmp 0x281c7
jmp 0x28215
jmp 0x281f2
movq %rax, %rbx
movq %r15, %rdi
callq 0x1f5c4
jmp 0x28188
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x101d0
jmp 0x28197
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x101d0
jmp 0x281a6
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x101d0
jmp 0x28250
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x101d0
jmp 0x281d1
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
jmp 0x28231
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x101d0
jmp 0x28218
jmp 0x281f2
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x101d0
jmp 0x2820b
jmp 0x28208
jmp 0x28215
movq %rax, %rbx
jmp 0x28236
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x101d0
jmp 0x2822c
jmp 0x28229
movq %rax, %rbx
movq %r13, %rdi
callq 0x1d786
jmp 0x28218
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x2e838
jmp 0x28236
jmp 0x28229
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x101d0
leaq 0xb0(%rsp), %rdi
callq 0x1f5c4
leaq 0xd0(%rsp), %rdi
callq 0x2ec72
movq %rbx, %rdi
callq 0x106f0