// File: /workspace/github_cpp_makefile_star2_O3/Nallantli[P]Rossa/main/rossa/node_parser/node_parser.cpp
// Function: node_parser_t::parseDefineNode(std::vector<node_scope_t, std::allocator<node_scope_t>>*)
ptr_node_t node_parser_t::parseDefineNode(std::vector<node_scope_t> *scopes)
{
	nextToken();

	std::vector<hash_ull> captures;

	if (currentToken.type == NULL_TOK || (currentToken.type != TOK_IDF && currentToken.type != TOK_LENGTH && currentToken.type != TOK_ALLOC && currentToken.type != TOK_CHARN && currentToken.type != TOK_CHARS && currentToken.type != TOK_PARSE))
		return logErrorN(_EXPECTED_FUNCTION_NAME_, currentToken);
	auto key = ROSSA_HASH(currentToken.valueString);
	scopes->push_back({key});
	nextToken();

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

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

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

		if (currentToken.type != ';')
			return logErrorN(util::format(_EXPECTED_ERROR_, {";"}), currentToken);
		nextToken();

		scopes->pop_back();
		if (isVargs)
			return std::make_shared<VargDefineNode>(*scopes, key, body, captures, currentToken);
		else
			return std::make_shared<DefineNode>(*scopes, key, 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, key, body, captures, currentToken);
		else
			return std::make_shared<DefineNode>(*scopes, key, sig.first, sig.second, body, captures, currentToken);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %r14
movq %rsi, %rdi
callq 0x2549e
xorps %xmm0, %xmm0
movaps %xmm0, 0x90(%rsp)
movq $0x0, 0xa0(%rsp)
leaq 0x58(%r15), %rax
movq %rax, 0x8(%rsp)
movl 0xd0(%r15), %eax
addl $0x39, %eax
cmpl $0x37, %eax
ja 0x2bf6d
movabsq $0x80000080080031, %rcx # imm = 0x80000080080031
btq %rax, %rcx
jae 0x2bf6d
leaq 0xb0(%r15), %r13
leaq 0x89ed9(%rip), %rbx     # 0xb58f8
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
movq %r13, %rdx
callq 0x20d1b
movq 0x8(%rbx), %rsi
cmpq %rsi, %rax
je 0x2ba4e
movq (%rbx), %rbp
movq %rbp, %rdi
movq %r13, %rdx
callq 0x20d1b
subq %rbp, %rax
sarq $0x5, %rax
jmp 0x2ba6f
leaq 0x89ea3(%rip), %rbp     # 0xb58f8
movq %rbp, %rdi
movq %r13, %rsi
callq 0x20cde
movq 0x8(%rbp), %rax
subq (%rbp), %rax
sarq $0x5, %rax
decq %rax
movq %rax, 0x58(%rsp)
leaq 0x60(%rsp), %rsi
movq %rax, (%rsi)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rsi)
movq $0x0, 0x18(%rsi)
movq %r12, %rdi
callq 0x216b8
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x2baaa
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x103d0
movq %r15, %rdi
callq 0x2549e
leaq 0x60(%rsp), %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x2aaec
movq 0x78(%rsp), %rax
cmpq 0x80(%rsp), %rax
je 0x2bae0
cmpb $0x1, (%rax)
jne 0x2bae0
cmpq $0x0, 0x8(%rax)
sete %bl
jmp 0x2bae2
xorl %ebx, %ebx
leaq 0x78(%rsp), %rbp
cmpl $0x7b, 0xd0(%r15)
jne 0x2bb6b
xorps %xmm0, %xmm0
movaps %xmm0, 0xb0(%rsp)
movq $0x0, 0xc0(%rsp)
movq %r15, %rdi
callq 0x2549e
leaq 0x30(%rsp), %r13
leaq 0xb0(%rsp), %rbp
movl 0xd0(%r15), %eax
cmpl $0x7d, %eax
je 0x2bc13
testl %eax, %eax
je 0x2bddb
movq %r13, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x25dc8
cmpq $0x0, 0x30(%rsp)
je 0x2be71
movq %rbp, %rdi
movq %r13, %rsi
callq 0x36d3e
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x2bb1d
callq 0x1e5bc
jmp 0x2bb1d
leaq 0xf0(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x2946a
cmpq $0x0, 0xf0(%rsp)
je 0x2bea4
cmpl $0x3b, 0xd0(%r15)
jne 0x2bed7
movq %r15, %rdi
callq 0x2549e
movq 0x8(%r12), %rax
leaq -0x20(%rax), %rcx
movq %rcx, 0x8(%r12)
movq -0x18(%rax), %rdi
testq %rdi, %rdi
je 0x2bbc9
movq -0x8(%rax), %rsi
subq %rdi, %rsi
callq 0x103d0
leaq 0x18(%rsp), %rdi
testb %bl, %bl
je 0x2bccf
movq $0x0, -0x8(%rdi)
leaq 0x90(%rsp), %rax
leaq 0x10(%rsp), %rsi
leaq 0x30(%rsp), %rdx
leaq 0x58(%rsp), %r8
leaq 0xf0(%rsp), %r9
movq %r12, %rcx
pushq 0x8(%rsp)
pushq %rax
callq 0x392e8
addq $0x10, %rsp
jmp 0x2bd07
movq %r15, %rdi
callq 0x2549e
leaq 0xd0(%rsp), %r9
movb $0x1, (%r9)
leaq 0x18(%rsp), %rdi
movq $0x0, -0x8(%rdi)
subq $0x8, %rsp
leaq 0x18(%rsp), %r15
leaq 0x38(%rsp), %rdx
leaq 0xb8(%rsp), %r8
movq %r15, %rsi
movq %r12, %rcx
pushq 0x10(%rsp)
callq 0x37f5a
addq $0x10, %rsp
leaq 0x78(%rsp), %r13
movq 0x8(%r12), %rax
leaq -0x20(%rax), %rcx
movq %rcx, 0x8(%r12)
movq -0x18(%rax), %rdi
testq %rdi, %rdi
je 0x2bc85
movq -0x8(%rax), %rsi
subq %rdi, %rsi
callq 0x103d0
leaq 0x38(%rsp), %rdi
testb %bl, %bl
je 0x2bd24
movq $0x0, -0x8(%rdi)
leaq 0x90(%rsp), %rax
leaq 0x30(%rsp), %rsi
leaq 0xd0(%rsp), %rdx
leaq 0x58(%rsp), %r8
leaq 0x10(%rsp), %r9
movq %r12, %rcx
pushq 0x8(%rsp)
pushq %rax
callq 0x39634
addq $0x10, %rsp
jmp 0x2bd60
movq $0x0, -0x8(%rdi)
leaq 0x90(%rsp), %rax
leaq 0x10(%rsp), %rsi
leaq 0x30(%rsp), %rdx
leaq 0x58(%rsp), %r8
leaq 0x60(%rsp), %r9
movq %r12, %rcx
pushq 0x8(%rsp)
pushq %rax
pushq %r13
pushq %rbp
callq 0x39474
addq $0x20, %rsp
movaps 0x10(%rsp), %xmm0
movups %xmm0, (%r14)
movq 0xf8(%rsp), %rdi
testq %rdi, %rdi
je 0x2bd85
callq 0x1e5bc
jmp 0x2bd85
movq $0x0, -0x8(%rdi)
leaq 0x90(%rsp), %rax
leaq 0x30(%rsp), %rsi
leaq 0xd0(%rsp), %rdx
leaq 0x58(%rsp), %r8
leaq 0x60(%rsp), %r9
movq %r12, %rcx
pushq 0x8(%rsp)
pushq %rax
pushq %r15
pushq %r13
callq 0x39758
addq $0x20, %rsp
movaps 0x30(%rsp), %xmm0
movups %xmm0, (%r14)
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x2bd78
callq 0x1e5bc
leaq 0xb0(%rsp), %rdi
callq 0x36cf0
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x2bd9f
movq 0x88(%rsp), %rsi
subq %rdi, %rsi
callq 0x103d0
leaq 0x60(%rsp), %rdi
callq 0x36f28
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x2bdc6
movq 0xa0(%rsp), %rsi
subq %rdi, %rsi
callq 0x103d0
movq %r14, %rax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x40(%rsp), %r14
movq %r14, -0x10(%r14)
movabsq $0x6465746365707845, %rax # imm = 0x6465746365707845
movq %rax, (%r14)
movabsq $0x607d307b60206465, %rax # imm = 0x607D307B60206465
movq %rax, 0x6(%r14)
movq $0xe, -0x8(%r14)
movb $0x0, 0xe(%r14)
leaq 0xe0(%rsp), %r12
movq %r12, -0x10(%r12)
movw $0x7d, (%r12)
movq $0x1, -0x8(%r12)
leaq 0xf0(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
leaq 0x7(%rsp), %rcx
movl $0x1, %edx
callq 0x20b38
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0xf0(%rsp), %rdx
callq 0x47db4
leaq 0x10(%rsp), %rdx
movq %r15, %rsi
movq 0x8(%rsp), %rcx
callq 0x29658
leaq 0x20(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x57a98(%rip), %rsi     # 0x83919
leaq 0x57aa6(%rip), %rdx     # 0x8392e
leaq 0x10(%rsp), %rdi
callq 0x1e698
leaq 0x10(%rsp), %rdx
movq %r15, %rsi
movq 0x8(%rsp), %rcx
callq 0x29658
leaq 0x20(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x57a65(%rip), %rsi     # 0x83919
leaq 0x57a73(%rip), %rdx     # 0x8392e
leaq 0x10(%rsp), %rdi
callq 0x1e698
leaq 0x10(%rsp), %rdx
movq %r15, %rsi
movq 0x8(%rsp), %rcx
callq 0x29658
leaq 0x40(%rsp), %r14
movq %r14, -0x10(%r14)
movabsq $0x6465746365707845, %rax # imm = 0x6465746365707845
movq %rax, (%r14)
movabsq $0x607d307b60206465, %rax # imm = 0x607D307B60206465
movq %rax, 0x6(%r14)
movq $0xe, -0x8(%r14)
movb $0x0, 0xe(%r14)
leaq 0xe0(%rsp), %r12
movq %r12, -0x10(%r12)
movw $0x3b, (%r12)
movq $0x1, -0x8(%r12)
leaq 0xb0(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
leaq 0x7(%rsp), %rcx
movl $0x1, %edx
callq 0x20b38
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0xb0(%rsp), %rdx
callq 0x47db4
leaq 0x10(%rsp), %rdx
movq %r15, %rsi
movq 0x8(%rsp), %rcx
callq 0x29658
leaq 0x70(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x57985(%rip), %rsi     # 0x83902
leaq 0x57994(%rip), %rdx     # 0x83918
leaq 0x60(%rsp), %rdi
callq 0x1e698
leaq 0x60(%rsp), %rdx
movq %r15, %rsi
movq 0x8(%rsp), %rcx
callq 0x29658
movq %rax, %rbx
movq 0x60(%rsp), %rdi
cmpq %r14, %rdi
je 0x2c174
movq 0x70(%rsp), %rsi
incq %rsi
jmp 0x2c0ab
jmp 0x2c0b5
movq %rax, %rbx
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2bfe6
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x103d0
jmp 0x2bfe6
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0x1db60
jmp 0x2c014
jmp 0x2bff7
movq %rax, %rbx
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x2c15d
jmp 0x2c153
jmp 0x2c065
jmp 0x2c065
movq %rax, %rbx
movq 0xd0(%rsp), %rdi
cmpq %r12, %rdi
je 0x2c031
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x103d0
movq 0x30(%rsp), %rdi
cmpq %r14, %rdi
je 0x2c068
movq 0x40(%rsp), %rsi
jmp 0x2c054
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r14, %rdi
je 0x2c068
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x103d0
jmp 0x2c068
jmp 0x2c065
jmp 0x2c15a
movq %rax, %rbx
movq 0xf8(%rsp), %rdi
testq %rdi, %rdi
je 0x2c16a
callq 0x1e5bc
jmp 0x2c16a
movq %rax, %rbx
jmp 0x2c16a
jmp 0x2c15a
jmp 0x2c0b5
movq %rax, %rbx
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x2c174
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x103d0
jmp 0x2c174
movq %rax, %rbx
jmp 0x2c174
movq %rax, %rbx
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2c0e0
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x103d0
jmp 0x2c0e0
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
callq 0x1db60
jmp 0x2c110
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r14, %rdi
je 0x2c149
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x103d0
jmp 0x2c149
jmp 0x2c146
movq %rax, %rbx
movq 0xd0(%rsp), %rdi
cmpq %r12, %rdi
je 0x2c12d
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x103d0
movq 0x30(%rsp), %rdi
cmpq %r14, %rdi
je 0x2c15d
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x103d0
jmp 0x2c15d
movq %rax, %rbx
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x2c15d
callq 0x1e5bc
jmp 0x2c15d
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0x36cf0
leaq 0x60(%rsp), %rdi
callq 0x36f98
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x2c191
movq 0xa0(%rsp), %rsi
subq %rdi, %rsi
callq 0x103d0
movq %rbx, %rdi
callq 0x106f0
nop