// File: /workspace/github_cpp_makefile_star2_O2/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, %rbp
movq %rsi, %rdi
callq 0x22e24
xorps %xmm0, %xmm0
movaps %xmm0, 0x90(%rsp)
andq $0x0, 0xa0(%rsp)
leaq 0x58(%r15), %rbx
movl 0xd0(%r15), %eax
addl $0x39, %eax
cmpl $0x37, %eax
ja 0x27536
movabsq $0x80000080080031, %rcx # imm = 0x80000080080031
btq %rax, %rcx
jae 0x27536
leaq 0xb0(%r15), %rsi
leaq 0x8f7c1(%rip), %rdi     # 0xb6908
callq 0x1efb0
movq %rax, 0x30(%rsp)
leaq 0xb8(%rsp), %r13
movq %rax, -0x8(%r13)
xorps %xmm0, %xmm0
movups %xmm0, (%r13)
andq $0x0, 0x10(%r13)
leaq 0xb0(%rsp), %rsi
movq %r12, %rdi
callq 0x1fe52
movq %r13, %rdi
callq 0x1f5c4
movq %r15, %rdi
callq 0x22e24
leaq 0xb0(%rsp), %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x26714
movq 0xc8(%rsp), %rax
cmpq 0xd0(%rsp), %rax
je 0x271bf
cmpb $0x1, (%rax)
jne 0x271bf
cmpq $0x0, 0x8(%rax)
sete %r14b
jmp 0x271c2
xorl %r14d, %r14d
leaq 0xc8(%rsp), %r13
cmpl $0x7b, 0xd0(%r15)
jne 0x2724d
movq %rbp, 0xe0(%rsp)
movq %rbx, 0x38(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
andq $0x0, 0x70(%rsp)
movq %r15, %rdi
callq 0x22e24
leaq 0x48(%rsp), %rbp
leaq 0x40(%rsp), %r13
leaq 0x60(%rsp), %rbx
movl 0xd0(%r15), %eax
cmpl $0x7d, %eax
je 0x272b7
testl %eax, %eax
je 0x27409
movq %r13, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x23390
cmpq $0x0, 0x40(%rsp)
je 0x27478
movq %rbx, %rdi
movq %r13, %rsi
callq 0x2e880
movq %rbp, %rdi
callq 0x1d786
jmp 0x27206
leaq 0x78(%rsp), %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x25798
cmpq $0x0, 0x78(%rsp)
je 0x274a3
cmpl $0x3b, 0xd0(%r15)
jne 0x274c9
movq %r15, %rdi
callq 0x22e24
movq %r12, %rdi
callq 0x2eb8e
testb %r14b, %r14b
je 0x27325
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
leaq 0x78(%rsp), %rcx
leaq 0x90(%rsp), %r8
movq %r12, %rsi
movq %rbx, %r9
callq 0x2eba6
jmp 0x27353
movq %r15, %rdi
callq 0x22e24
leaq 0x40(%rsp), %rcx
movb $0x1, (%rcx)
leaq 0x10(%rsp), %rdi
leaq 0x60(%rsp), %rdx
movq %r12, %rsi
movq 0x38(%rsp), %rbx
movq %rbx, %r8
callq 0x2e811
movq 0xe0(%rsp), %rbp
leaq 0xc8(%rsp), %r15
movq %r12, %rdi
callq 0x2eb8e
testb %r14b, %r14b
je 0x2737d
leaq 0x40(%rsp), %rdi
leaq 0x30(%rsp), %rdx
leaq 0x10(%rsp), %rcx
leaq 0x90(%rsp), %r8
movq %r12, %rsi
movq %rbx, %r9
callq 0x2ec0c
jmp 0x273ab
leaq 0x90(%rsp), %rax
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
leaq 0xb0(%rsp), %rcx
leaq 0x78(%rsp), %r9
movq %r12, %rsi
movq %r13, %r8
pushq %rbx
pushq %rax
callq 0x2ebd4
popq %rax
popq %rcx
leaq 0x18(%rsp), %rdi
movaps -0x8(%rdi), %xmm0
andq $0x0, (%rdi)
movups %xmm0, (%rbp)
andq $0x0, -0x8(%rdi)
callq 0x1d786
leaq 0x80(%rsp), %rdi
callq 0x1d786
jmp 0x273da
leaq 0x90(%rsp), %rax
leaq 0x40(%rsp), %rdi
leaq 0x30(%rsp), %rdx
leaq 0xb0(%rsp), %rcx
leaq 0x10(%rsp), %r9
movq %r12, %rsi
movq %r15, %r8
pushq %rbx
pushq %rax
callq 0x2ec3a
popq %rax
popq %rcx
leaq 0x48(%rsp), %rdi
movaps -0x8(%rdi), %xmm0
andq $0x0, (%rdi)
movups %xmm0, (%rbp)
andq $0x0, -0x8(%rdi)
callq 0x1d786
leaq 0x18(%rsp), %rdi
callq 0x1d786
leaq 0x60(%rsp), %rdi
callq 0x2e838
leaq 0xb0(%rsp), %rdi
callq 0x2ec72
leaq 0x90(%rsp), %rdi
callq 0x1f5c4
movq %rbp, %rax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4f494(%rip), %rsi     # 0x768a4
leaq 0x40(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x1c814
leaq 0x5349b(%rip), %rsi     # 0x7a8c1
leaq 0xe8(%rsp), %rdi
leaq 0xe(%rsp), %rdx
callq 0x1c814
leaq 0x78(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
pushq $0x1
popq %rdx
leaq 0xd(%rsp), %rcx
callq 0x1f298
leaq 0x10(%rsp), %rdi
leaq 0x40(%rsp), %rsi
leaq 0x78(%rsp), %rdx
callq 0x3f724
leaq 0x10(%rsp), %rdx
movq %r15, %rsi
movq 0x38(%rsp), %rcx
callq 0x25932
leaq 0x4f4bb(%rip), %rsi     # 0x7693a
leaq 0x10(%rsp), %rdi
leaq 0xe8(%rsp), %rdx
callq 0x1c814
leaq 0x10(%rsp), %rdx
movq %r15, %rsi
movq 0x38(%rsp), %rcx
callq 0x25932
leaq 0x4f490(%rip), %rsi     # 0x7693a
leaq 0x10(%rsp), %rdi
leaq 0x40(%rsp), %rdx
callq 0x1c814
leaq 0x10(%rsp), %rdx
movq %r15, %rsi
movq %rbx, %rcx
callq 0x25932
leaq 0x4f3d4(%rip), %rsi     # 0x768a4
leaq 0x40(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x1c814
leaq 0x4ec4c(%rip), %rsi     # 0x76132
leaq 0xe8(%rsp), %rdi
leaq 0xe(%rsp), %rdx
callq 0x1c814
leaq 0x60(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
pushq $0x1
popq %rdx
leaq 0xd(%rsp), %rcx
callq 0x1f298
leaq 0x10(%rsp), %rdi
leaq 0x40(%rsp), %rsi
leaq 0x60(%rsp), %rdx
callq 0x3f724
leaq 0x10(%rsp), %rdx
movq %r15, %rsi
movq %rbx, %rcx
callq 0x25932
leaq 0x4f3e6(%rip), %rsi     # 0x76923
leaq 0xb0(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x1c814
leaq 0xb0(%rsp), %rdx
movq %r15, %rsi
movq %rbx, %rcx
callq 0x25932
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x101d0
jmp 0x27574
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x1cea0
jmp 0x27583
movq %rax, %rbx
leaq 0xe8(%rsp), %rdi
callq 0x101d0
jmp 0x275af
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0x101d0
jmp 0x2768d
jmp 0x2763f
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
jmp 0x275d3
jmp 0x275b8
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
jmp 0x2766c
jmp 0x275e1
jmp 0x275e1
jmp 0x275e1
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x101d0
jmp 0x275e4
jmp 0x275e1
jmp 0x27673
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x1d786
jmp 0x27680
movq %rax, %rbx
jmp 0x27680
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x101d0
jmp 0x27610
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x1cea0
jmp 0x27630
jmp 0x27673
jmp 0x2763f
movq %rax, %rbx
movq %r13, %rdi
callq 0x1f5c4
jmp 0x2768d
movq %rax, %rbx
leaq 0xe8(%rsp), %rdi
callq 0x101d0
jmp 0x27647
movq %rax, %rbx
jmp 0x2768d
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x101d0
jmp 0x27676
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x101d0
jmp 0x27669
jmp 0x27666
jmp 0x27673
movq %rax, %rbx
movq %rbp, %rdi
callq 0x1d786
jmp 0x27676
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x2e838
leaq 0xb0(%rsp), %rdi
callq 0x2ec72
leaq 0x90(%rsp), %rdi
callq 0x1f5c4
movq %rbx, %rdi
callq 0x106f0