// File: /workspace/github_cpp_makefile_star2_O1/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 0x2565a
xorps %xmm0, %xmm0
movaps %xmm0, 0x90(%rsp)
movq $0x0, 0xa0(%rsp)
leaq 0x58(%r15), %rax
movq %rax, 0x10(%rsp)
movl 0xd0(%r15), %eax
addl $0x39, %eax
cmpl $0x37, %eax
ja 0x2c261
movabsq $0x80000080080031, %rcx # imm = 0x80000080080031
btq %rax, %rcx
jae 0x2c261
leaq 0xb0(%r15), %r13
leaq 0x8bc0b(%rip), %rbx     # 0xb78f8
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
movq %r13, %rdx
callq 0x20e41
movq 0x8(%rbx), %rsi
cmpq %rsi, %rax
je 0x2bd1c
movq (%rbx), %rbp
movq %rbp, %rdi
movq %r13, %rdx
callq 0x20e41
subq %rbp, %rax
sarq $0x5, %rax
jmp 0x2bd3d
leaq 0x8bbd5(%rip), %rbp     # 0xb78f8
movq %rbp, %rdi
movq %r13, %rsi
callq 0x20e04
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 0x21808
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x2bd78
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x103d0
movq %r15, %rdi
callq 0x2565a
leaq 0x60(%rsp), %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x2ad62
movq 0x78(%rsp), %rax
cmpq 0x80(%rsp), %rax
je 0x2bdae
cmpb $0x1, (%rax)
jne 0x2bdae
cmpq $0x0, 0x8(%rax)
sete %bl
jmp 0x2bdb0
xorl %ebx, %ebx
leaq 0x78(%rsp), %rbp
cmpl $0x7b, 0xd0(%r15)
jne 0x2be39
xorps %xmm0, %xmm0
movaps %xmm0, 0xb0(%rsp)
movq $0x0, 0xc0(%rsp)
movq %r15, %rdi
callq 0x2565a
leaq 0x38(%rsp), %r13
leaq 0xb0(%rsp), %rbp
movl 0xd0(%r15), %eax
cmpl $0x7d, %eax
je 0x2bee1
testl %eax, %eax
je 0x2c0cf
movq %r13, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x25fda
cmpq $0x0, 0x38(%rsp)
je 0x2c165
movq %rbp, %rdi
movq %r13, %rsi
callq 0x3725c
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x2bdeb
callq 0x1e6ee
jmp 0x2bdeb
leaq 0xf0(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x296b0
cmpq $0x0, 0xf0(%rsp)
je 0x2c198
cmpl $0x3b, 0xd0(%r15)
jne 0x2c1cb
movq %r15, %rdi
callq 0x2565a
movq 0x8(%r12), %rax
leaq -0x20(%rax), %rcx
movq %rcx, 0x8(%r12)
movq -0x18(%rax), %rdi
testq %rdi, %rdi
je 0x2be97
movq -0x8(%rax), %rsi
subq %rdi, %rsi
callq 0x103d0
leaq 0x20(%rsp), %rdi
testb %bl, %bl
je 0x2bf9d
movq $0x0, -0x8(%rdi)
leaq 0x90(%rsp), %rax
leaq 0x18(%rsp), %rsi
leaq 0x38(%rsp), %rdx
leaq 0x58(%rsp), %r8
leaq 0xf0(%rsp), %r9
movq %r12, %rcx
pushq 0x10(%rsp)
pushq %rax
callq 0x39876
addq $0x10, %rsp
jmp 0x2bfd5
movq %r15, %rdi
callq 0x2565a
leaq 0xd0(%rsp), %r9
movb $0x1, (%r9)
leaq 0x20(%rsp), %rdi
movq $0x0, -0x8(%rdi)
subq $0x8, %rsp
leaq 0x20(%rsp), %r15
leaq 0x40(%rsp), %rdx
leaq 0xb8(%rsp), %r8
movq %r15, %rsi
movq %r12, %rcx
pushq 0x18(%rsp)
callq 0x38494
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 0x2bf53
movq -0x8(%rax), %rsi
subq %rdi, %rsi
callq 0x103d0
leaq 0x40(%rsp), %rdi
testb %bl, %bl
je 0x2c005
movq $0x0, -0x8(%rdi)
leaq 0x90(%rsp), %rax
leaq 0x38(%rsp), %rsi
leaq 0xd0(%rsp), %rdx
leaq 0x58(%rsp), %r8
leaq 0x18(%rsp), %r9
movq %r12, %rcx
pushq 0x10(%rsp)
pushq %rax
callq 0x39bce
addq $0x10, %rsp
jmp 0x2c041
movq $0x0, -0x8(%rdi)
leaq 0x90(%rsp), %rax
leaq 0x18(%rsp), %rsi
leaq 0x38(%rsp), %rdx
leaq 0x58(%rsp), %r8
leaq 0x60(%rsp), %r9
movq %r12, %rcx
pushq 0x10(%rsp)
pushq %rax
pushq %r13
pushq %rbp
callq 0x39a08
addq $0x20, %rsp
movq 0x18(%rsp), %rax
movq %rax, (%r14)
xorl %eax, %eax
movq %rax, 0x8(%r14)
movq 0x20(%rsp), %rcx
movq %rax, 0x20(%rsp)
movq %rcx, 0x8(%r14)
movq 0xf8(%rsp), %rdi
testq %rdi, %rdi
je 0x2c079
callq 0x1e6ee
jmp 0x2c079
movq $0x0, -0x8(%rdi)
leaq 0x90(%rsp), %rax
leaq 0x38(%rsp), %rsi
leaq 0xd0(%rsp), %rdx
leaq 0x58(%rsp), %r8
leaq 0x60(%rsp), %r9
movq %r12, %rcx
pushq 0x10(%rsp)
pushq %rax
pushq %r15
pushq %r13
callq 0x39cf2
addq $0x20, %rsp
movq 0x38(%rsp), %rax
movq %rax, (%r14)
xorl %eax, %eax
movq %rax, 0x8(%r14)
movq 0x40(%rsp), %rcx
movq %rax, 0x40(%rsp)
movq %rcx, 0x8(%r14)
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x2c06c
callq 0x1e6ee
leaq 0xb0(%rsp), %rdi
callq 0x37214
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x2c093
movq 0x88(%rsp), %rsi
subq %rdi, %rsi
callq 0x103d0
leaq 0x60(%rsp), %rdi
callq 0x3743a
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x2c0ba
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 0x48(%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 0xf(%rsp), %rcx
movl $0x1, %edx
callq 0x20c5e
leaq 0x18(%rsp), %rdi
leaq 0x38(%rsp), %rsi
leaq 0xf0(%rsp), %rdx
callq 0x48694
leaq 0x18(%rsp), %rdx
movq %r15, %rsi
movq 0x10(%rsp), %rcx
callq 0x29894
leaq 0x28(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x58784(%rip), %rsi     # 0x848f9
leaq 0x58792(%rip), %rdx     # 0x8490e
leaq 0x18(%rsp), %rdi
callq 0x1e7ca
leaq 0x18(%rsp), %rdx
movq %r15, %rsi
movq 0x10(%rsp), %rcx
callq 0x29894
leaq 0x28(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x58751(%rip), %rsi     # 0x848f9
leaq 0x5875f(%rip), %rdx     # 0x8490e
leaq 0x18(%rsp), %rdi
callq 0x1e7ca
leaq 0x18(%rsp), %rdx
movq %r15, %rsi
movq 0x10(%rsp), %rcx
callq 0x29894
leaq 0x48(%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 0xf(%rsp), %rcx
movl $0x1, %edx
callq 0x20c5e
leaq 0x18(%rsp), %rdi
leaq 0x38(%rsp), %rsi
leaq 0xb0(%rsp), %rdx
callq 0x48694
leaq 0x18(%rsp), %rdx
movq %r15, %rsi
movq 0x10(%rsp), %rcx
callq 0x29894
leaq 0x70(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x58671(%rip), %rsi     # 0x848e2
leaq 0x58680(%rip), %rdx     # 0x848f8
leaq 0x60(%rsp), %rdi
callq 0x1e7ca
leaq 0x60(%rsp), %rdx
movq %r15, %rsi
movq 0x10(%rsp), %rcx
callq 0x29894
movq %rax, %rbx
movq 0x60(%rsp), %rdi
cmpq %r14, %rdi
je 0x2c468
movq 0x70(%rsp), %rsi
incq %rsi
jmp 0x2c39f
jmp 0x2c3a9
movq %rax, %rbx
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2c2da
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x103d0
jmp 0x2c2da
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0x1dca2
jmp 0x2c308
jmp 0x2c2eb
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x2c451
jmp 0x2c447
jmp 0x2c359
jmp 0x2c359
movq %rax, %rbx
movq 0xd0(%rsp), %rdi
cmpq %r12, %rdi
je 0x2c325
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x103d0
movq 0x38(%rsp), %rdi
cmpq %r14, %rdi
je 0x2c35c
movq 0x48(%rsp), %rsi
jmp 0x2c348
movq %rax, %rbx
movq 0x18(%rsp), %rdi
cmpq %r14, %rdi
je 0x2c35c
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x103d0
jmp 0x2c35c
jmp 0x2c359
jmp 0x2c44e
movq %rax, %rbx
movq 0xf8(%rsp), %rdi
testq %rdi, %rdi
je 0x2c45e
callq 0x1e6ee
jmp 0x2c45e
movq %rax, %rbx
jmp 0x2c45e
jmp 0x2c44e
jmp 0x2c3a9
movq %rax, %rbx
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x2c468
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x103d0
jmp 0x2c468
movq %rax, %rbx
jmp 0x2c468
movq %rax, %rbx
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2c3d4
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x103d0
jmp 0x2c3d4
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
callq 0x1dca2
jmp 0x2c404
movq %rax, %rbx
movq 0x18(%rsp), %rdi
cmpq %r14, %rdi
je 0x2c43d
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x103d0
jmp 0x2c43d
jmp 0x2c43a
movq %rax, %rbx
movq 0xd0(%rsp), %rdi
cmpq %r12, %rdi
je 0x2c421
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x103d0
movq 0x38(%rsp), %rdi
cmpq %r14, %rdi
je 0x2c451
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x103d0
jmp 0x2c451
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x2c451
callq 0x1e6ee
jmp 0x2c451
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0x37214
leaq 0x60(%rsp), %rdi
callq 0x374a8
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x2c485
movq 0xa0(%rsp), %rsi
subq %rdi, %rsi
callq 0x103d0
movq %rbx, %rdi
callq 0x106f0
nop