// File: /workspace/github_cpp_makefile_star2_O2/talyerushalmy[P]SimpleFileSystem/src/FileSystem.cpp
// Function: FileSystem::getDirectoryFromPath(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
Directory* FileSystem::getDirectoryFromPath(std::string path)
{
	try
	{
		if (path == "")
			return &this->getWorkingDirectory();

		Directory* directory = &this->getWorkingDirectory();

		if (path[0] == '/')
			directory = &this->getRootDirectory();

		for (std::string name : StringTools::split(path, "/"))
		{
			name = StringTools::trim(name);
			if (name == "" || name == ".")
				continue;
			if (name == "..")
			{
				if (directory == &this->getRootDirectory())
					continue;
				directory = directory->getParent();
			}
			else if (directory->childExists(name))
			{
				if (Directory* d = dynamic_cast<Directory*>(directory->getChildByName(name)))
				{
					directory = d;
				}
				else return NULL;
			}
			else return NULL;
		}
		return directory;
	}
	catch(int e)
	{
		return NULL;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x2b9b(%rip), %rsi      # 0xb14c
movq %rbx, %rdi
callq 0x8386
movq %r14, -0x38(%rbp)
movq 0x8(%r14), %rcx
movq %rcx, -0x30(%rbp)
testb %al, %al
jne 0x8795
movq (%rbx), %rax
cmpb $0x2f, (%rax)
jne 0x85e0
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
leaq -0xb8(%rbp), %rdi
movq %rbx, %rsi
callq 0x3210
leaq 0x2be5(%rip), %rsi      # 0xb1db
leaq -0x98(%rbp), %rdi
leaq -0x78(%rbp), %rdx
callq 0x30a0
leaq -0x58(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
leaq -0x98(%rbp), %rdx
callq 0x348c
leaq -0x98(%rbp), %rdi
callq 0x30c0
leaq -0xb8(%rbp), %rdi
callq 0x30c0
movq -0x58(%rbp), %r15
movq -0x50(%rbp), %rax
movq %rax, -0x40(%rbp)
leaq -0x78(%rbp), %r12
leaq -0x118(%rbp), %r13
leaq -0xf8(%rbp), %rbx
cmpq -0x40(%rbp), %r15
je 0x878c
movq %r12, %rdi
movq %r15, %rsi
callq 0x3210
movq %r13, %rdi
movq %r12, %rsi
callq 0x3574
movq %r12, %rdi
movq %r13, %rsi
callq 0x31e0
movq %r13, %rdi
callq 0x30c0
movq %r12, %rdi
leaq 0x2abc(%rip), %rsi      # 0xb14c
callq 0x8386
testb %al, %al
jne 0x876a
movq %r12, %rdi
leaq 0x2b44(%rip), %rsi      # 0xb1eb
callq 0x8386
testb %al, %al
jne 0x876a
movq %r12, %rdi
leaq 0x2b2c(%rip), %rsi      # 0xb1ea
callq 0x8386
testb %al, %al
je 0x86e6
movq -0x38(%rbp), %rax
movq -0x30(%rbp), %rdi
cmpq (%rax), %rdi
je 0x876a
callq 0x901c
movq %rax, -0x30(%rbp)
jmp 0x876a
movq %rbx, %rdi
movq %r12, %rsi
callq 0x3210
movq -0x30(%rbp), %rdi
movq %rbx, %rsi
callq 0x90c2
movl %eax, %r14d
movq %rbx, %rdi
callq 0x30c0
testb %r14b, %r14b
je 0x877b
leaq -0xd8(%rbp), %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0x3210
movq -0x30(%rbp), %rdi
movq %r14, %rsi
callq 0x94a4
movq %rbx, %r14
testq %rax, %rax
je 0x8750
movq %rax, %rdi
leaq 0x862b(%rip), %rsi      # 0x10d68
leaq 0x8634(%rip), %rdx      # 0x10d78
xorl %ecx, %ecx
callq 0x31c0
movq %rax, %rbx
jmp 0x8752
xorl %ebx, %ebx
leaq -0xd8(%rbp), %rdi
callq 0x30c0
movq %rbx, -0x30(%rbp)
testq %rbx, %rbx
movq %r14, %rbx
je 0x877b
movq %r12, %rdi
callq 0x30c0
addq $0x20, %r15
jmp 0x8653
leaq -0x78(%rbp), %rdi
callq 0x30c0
movq $0x0, -0x30(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x3614
movq -0x30(%rbp), %rax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdx, %rbx
movq %rax, %r14
leaq -0x98(%rbp), %rdi
callq 0x30c0
jmp 0x87c5
movq %rdx, %rbx
movq %rax, %r14
leaq -0xb8(%rbp), %rdi
callq 0x30c0
jmp 0x8822
movq %rdx, %rbx
movq %rax, %r14
jmp 0x8822
movq %rdx, %rbx
movq %rax, %r14
leaq -0xd8(%rbp), %rdi
jmp 0x87f9
jmp 0x8802
movq %rdx, %rbx
movq %rax, %r14
leaq -0xf8(%rbp), %rdi
callq 0x30c0
jmp 0x8808
jmp 0x8802
movq %rdx, %rbx
movq %rax, %r14
leaq -0x78(%rbp), %rdi
callq 0x30c0
jmp 0x8819
movq %rdx, %rbx
movq %rax, %r14
leaq -0x58(%rbp), %rdi
callq 0x3614
movq %r14, %rdi
cmpl $0x1, %ebx
jne 0x8841
callq 0x30b0
callq 0x3270
movq $0x0, -0x30(%rbp)
jmp 0x8795
callq 0x3290