// File: /workspace/github_cpp_makefile_star2_O2/Nallantli[P]Rossa/main/rossa/node_parser/node_parser.cpp
// Function: node_parser_t::parseLoadNode(std::vector<node_scope_t, std::allocator<node_scope_t>>*)
ptr_node_t node_parser_t::parseLoadNode(std::vector<node_scope_t> *scopes)
{
	nextToken();
	if (currentToken.type != TOK_STR_LIT)
		return logErrorN(_EXPECTED_FILE_, currentToken);
	std::string filename = currentToken.valueString + ".ra";
	nextToken();

	auto path = dir::findFile(currentFile.parent_path(), filename, &currentToken);

	if (std::find(dir::loaded.begin(), dir::loaded.end(), path) != dir::loaded.end())
	{
		if (currentToken.type != ';')
			return logErrorN(util::format(_EXPECTED_ERROR_, {";"}), currentToken);
		nextToken();
		return nullptr;
	}

	dir::loaded.push_back(path);

	std::string content = "";
	std::string line;
	std::ifstream myfile(path.string());
	if (myfile.is_open())
	{
		while (getline(myfile, line))
			content += line + "\n";
		myfile.close();
	}

	auto tokens = lexString(content, path.filename().string());
	node_parser_t np(tokens, path);
	auto n = np.parse(scopes, consts);

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

	return n;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x438, %rsp            # imm = 0x438
movq %rdx, 0x18(%rsp)
movq %rsi, %rbx
movq %rdi, 0x10(%rsp)
movq %rsi, %rdi
callq 0x22e24
leaq 0x58(%rbx), %r14
cmpl $-0x12, 0xd0(%rbx)
jne 0x2e372
leaq 0xb0(%rbx), %rsi
leaq 0x48a2c(%rip), %rdx     # 0x76ab7
leaq 0x138(%rsp), %rdi
callq 0x1cb3b
movq %rbx, %rdi
callq 0x22e24
leaq 0x28(%rbx), %rsi
leaq 0x230(%rsp), %rdi
callq 0x10750
leaq 0x88(%rsp), %rdi
leaq 0x230(%rsp), %rsi
leaq 0x138(%rsp), %rdx
movq %r14, 0x8(%rsp)
movq %r14, %rcx
callq 0x4baa4
leaq 0x230(%rsp), %rdi
callq 0x1ca5c
leaq 0x88e66(%rip), %r14     # 0xb6f50
movq (%r14), %rdi
movq 0x8(%r14), %rsi
leaq 0x88(%rsp), %rdx
callq 0x3524d
cmpq 0x8(%r14), %rax
je 0x2e129
cmpl $0x3b, 0xd0(%rbx)
jne 0x2e3a1
movq %rbx, %rdi
callq 0x22e24
xorps %xmm0, %xmm0
movq 0x10(%rsp), %rbx
movups %xmm0, (%rbx)
jmp 0x2e343
leaq 0x88e20(%rip), %rdi     # 0xb6f50
leaq 0x88(%rsp), %rsi
callq 0x2f20a
leaq 0x4806a(%rip), %rsi     # 0x761ae
leaq 0x68(%rsp), %rdi
leaq 0x230(%rsp), %rdx
callq 0x1c814
leaq 0xf0(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x158(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x1f1e6
leaq 0x230(%rsp), %rdi
leaq 0x158(%rsp), %rsi
pushq $0x8
popq %rdx
callq 0x10660
leaq 0x158(%rsp), %rdi
callq 0x101d0
leaq 0x2a8(%rsp), %rdi
callq 0x100c0
testb %al, %al
je 0x2e222
leaq 0x230(%rsp), %r13
leaq 0xe0(%rsp), %rbp
leaq 0x49951(%rip), %r14     # 0x77b1d
leaq 0x158(%rsp), %r12
leaq 0x68(%rsp), %r15
movq %r13, %rdi
movq %rbp, %rsi
callq 0x10090
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x2e215
movq %r12, %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x1cb3b
movq %r15, %rdi
movq %r12, %rsi
callq 0x10790
movq %r12, %rdi
callq 0x101d0
jmp 0x2e1d9
leaq 0x230(%rsp), %rdi
callq 0x100a0
leaq 0x20(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x2f236
leaq 0x48(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x1f1e6
leaq 0x158(%rsp), %rdi
leaq 0x48(%rsp), %rsi
pushq $0x2
popq %rdx
callq 0x2f2a8
leaq 0xc8(%rsp), %rdi
leaq 0x68(%rsp), %rsi
leaq 0x158(%rsp), %rdx
callq 0x218e6
leaq 0x158(%rsp), %rdi
callq 0x1ca5c
leaq 0x48(%rsp), %rdi
callq 0x101d0
leaq 0x20(%rsp), %rdi
callq 0x1ca5c
leaq 0x158(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
leaq 0x88(%rsp), %rdx
callq 0x22dd4
movq 0x8(%rbx), %rcx
leaq 0xb0(%rsp), %rdi
leaq 0x158(%rsp), %rsi
movq 0x18(%rsp), %rdx
callq 0x2e62e
cmpl $0x3b, 0xd0(%rbx)
jne 0x2e41c
movq %rbx, %rdi
callq 0x22e24
leaq 0xb8(%rsp), %rdi
movaps -0x8(%rdi), %xmm0
andq $0x0, (%rdi)
movq 0x10(%rsp), %rbx
movups %xmm0, (%rbx)
andq $0x0, -0x8(%rdi)
callq 0x1d786
leaq 0x158(%rsp), %rdi
callq 0x1f11e
leaq 0xc8(%rsp), %rdi
callq 0x1f142
leaq 0x230(%rsp), %rdi
callq 0x100f0
leaq 0xe0(%rsp), %rdi
callq 0x101d0
leaq 0x68(%rsp), %rdi
callq 0x101d0
leaq 0x88(%rsp), %rdi
callq 0x1ca5c
leaq 0x138(%rsp), %rdi
callq 0x101d0
movq %rbx, %rax
addq $0x438, %rsp            # imm = 0x438
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4871f(%rip), %rsi     # 0x76a98
leaq 0x230(%rsp), %rdi
leaq 0x158(%rsp), %rdx
callq 0x1c814
leaq 0x230(%rsp), %rdx
movq %rbx, %rsi
movq %r14, %rcx
callq 0x25932
leaq 0x484fc(%rip), %rsi     # 0x768a4
leaq 0x158(%rsp), %rdi
leaq 0xe0(%rsp), %rdx
callq 0x1c814
leaq 0x47d6e(%rip), %rsi     # 0x76132
leaq 0x20(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0x1c814
leaq 0x68(%rsp), %rdi
leaq 0x20(%rsp), %rsi
pushq $0x1
popq %rdx
leaq 0x100(%rsp), %rcx
callq 0x1f298
leaq 0x230(%rsp), %rdi
leaq 0x158(%rsp), %rsi
leaq 0x68(%rsp), %rdx
callq 0x3f724
leaq 0x230(%rsp), %rdx
movq %rbx, %rsi
movq 0x8(%rsp), %rcx
callq 0x25932
leaq 0x48481(%rip), %rsi     # 0x768a4
leaq 0x48(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x1c814
leaq 0x47cf9(%rip), %rsi     # 0x76132
leaq 0x100(%rsp), %rdi
leaq 0x6(%rsp), %rdx
callq 0x1c814
leaq 0x120(%rsp), %rdi
leaq 0x100(%rsp), %rsi
pushq $0x1
popq %rdx
leaq 0x5(%rsp), %rcx
callq 0x1f298
leaq 0x20(%rsp), %rdi
leaq 0x48(%rsp), %rsi
leaq 0x120(%rsp), %rdx
callq 0x3f724
leaq 0x20(%rsp), %rdx
movq %rbx, %rsi
movq 0x8(%rsp), %rcx
callq 0x25932
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x101d0
jmp 0x2e4a3
movq %rax, %rbx
leaq 0x120(%rsp), %rdi
callq 0x1cea0
jmp 0x2e4d6
movq %rax, %rbx
leaq 0x230(%rsp), %rdi
callq 0x101d0
jmp 0x2e4c7
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x1cea0
jmp 0x2e4e8
movq %rax, %rbx
leaq 0x100(%rsp), %rdi
callq 0x101d0
jmp 0x2e4f7
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x101d0
jmp 0x2e506
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x101d0
jmp 0x2e522
movq %rax, %rbx
leaq 0x158(%rsp), %rdi
jmp 0x2e606
jmp 0x2e5e4
jmp 0x2e51f
jmp 0x2e5b7
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x1d786
jmp 0x2e534
movq %rax, %rbx
leaq 0x158(%rsp), %rdi
callq 0x1f11e
jmp 0x2e546
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
callq 0x1f142
jmp 0x2e5e7
movq %rax, %rbx
leaq 0x158(%rsp), %rdi
callq 0x1ca5c
jmp 0x2e56d
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x101d0
jmp 0x2e57c
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x1ca5c
jmp 0x2e5e7
jmp 0x2e5e4
movq %rax, %rbx
leaq 0x158(%rsp), %rdi
callq 0x101d0
jmp 0x2e5f4
movq %rax, %rbx
jmp 0x2e5f4
jmp 0x2e5b7
movq %rax, %rbx
leaq 0x230(%rsp), %rdi
jmp 0x2e620
movq %rax, %rbx
jmp 0x2e625
jmp 0x2e5b7
movq %rax, %rbx
jmp 0x2e60b
movq %rax, %rbx
leaq 0x230(%rsp), %rdi
jmp 0x2e613
jmp 0x2e5cb
movq %rax, %rbx
jmp 0x2e618
movq %rax, %rbx
leaq 0x158(%rsp), %rdi
callq 0x101d0
jmp 0x2e5e7
jmp 0x2e5e4
movq %rax, %rbx
leaq 0x230(%rsp), %rdi
callq 0x100f0
leaq 0xe0(%rsp), %rdi
callq 0x101d0
leaq 0x68(%rsp), %rdi
callq 0x101d0
leaq 0x88(%rsp), %rdi
callq 0x1ca5c
leaq 0x138(%rsp), %rdi
callq 0x101d0
movq %rbx, %rdi
callq 0x106f0
nop