// File: /workspace/github_cpp_makefile_star2_O3/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 $0xe8, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x347d(%rip), %rsi      # 0xe174
movq %r14, %rdi
callq 0x3080
movq %rbx, -0x30(%rbp)
movq 0x8(%rbx), %rbx
testl %eax, %eax
je 0xaf73
movq (%r14), %rsi
cmpb $0x2f, (%rsi)
jne 0xad1e
movq -0x30(%rbp), %rax
movq (%rax), %rbx
leaq -0xe0(%rbp), %r15
movq %r15, -0x10(%r15)
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq -0xf0(%rbp), %rdi
callq 0x392c
leaq -0xc0(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x34b4(%rip), %rsi      # 0xe203
leaq 0x34ae(%rip), %rdx      # 0xe204
leaq -0xd0(%rbp), %rdi
callq 0xab8a
movq %rbx, %r14
leaq -0xb0(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
leaq -0xd0(%rbp), %rdx
callq 0x34ec
movq -0xd0(%rbp), %rdi
cmpq %r12, %rdi
je 0xad90
callq 0x31a0
movq -0xf0(%rbp), %rdi
cmpq %r15, %rdi
je 0xada1
callq 0x31a0
movq -0xb0(%rbp), %r13
movq -0xa8(%rbp), %rax
movq %rax, -0x58(%rbp)
cmpq %rax, %r13
je 0xaf7b
leaq -0x50(%rbp), %r15
leaq -0x110(%rbp), %rbx
leaq -0x40(%rbp), %rax
movq %rax, -0x50(%rbp)
movq (%r13), %rsi
movq 0x8(%r13), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x392c
movq %rbx, %rdi
movq %r15, %rsi
callq 0x35f2
movq %r15, %rdi
movq %rbx, %rsi
callq 0x3210
movq -0x110(%rbp), %rdi
leaq -0x100(%rbp), %rax
cmpq %rax, %rdi
je 0xae10
callq 0x31a0
movq %r15, %rdi
leaq 0x335a(%rip), %rsi      # 0xe174
callq 0x3080
movl $0x3, %ebx
testl %eax, %eax
je 0xaf41
movq %r15, %rdi
leaq 0x33dd(%rip), %rsi      # 0xe213
callq 0x3080
testl %eax, %eax
je 0xaf41
movq %r15, %rdi
leaq 0x33c5(%rip), %rsi      # 0xe212
callq 0x3080
testl %eax, %eax
je 0xaf05
leaq -0x88(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
addq %rsi, %rdx
leaq -0x98(%rbp), %rbx
movq %rbx, %rdi
callq 0x392c
movq %r14, %r12
movq %r14, %rdi
movq %rbx, %rsi
callq 0xbcda
movl %eax, %r14d
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0xaeab
callq 0x31a0
movl $0x1, %ebx
testb %r14b, %r14b
je 0xaf3e
leaq -0x68(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
addq %rsi, %rdx
leaq -0x78(%rbp), %rbx
movq %rbx, %rdi
callq 0x392c
movq %r12, %rdi
movq %rbx, %rsi
callq 0xc41c
testq %rax, %rax
je 0xaf1d
movq %rax, %rdi
leaq 0x7e7e(%rip), %rsi      # 0x12d70
leaq 0x7e87(%rip), %rdx      # 0x12d80
xorl %ecx, %ecx
callq 0x31f0
movq %rax, %r14
jmp 0xaf20
movq -0x30(%rbp), %rax
cmpq (%rax), %r14
je 0xaf41
movq %r14, %rdi
callq 0xbbf8
movq %rax, %r14
xorl %ebx, %ebx
jmp 0xaf41
xorl %r14d, %r14d
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0xaf32
callq 0x31a0
xorl %ebx, %ebx
testq %r14, %r14
sete %bl
cmovneq %r14, %r12
movq %r12, %r14
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0xaf53
callq 0x31a0
cmpl $0x3, %ebx
je 0xaf5c
testl %ebx, %ebx
jne 0xaf78
addq $0x20, %r13
cmpq -0x58(%rbp), %r13
leaq -0x110(%rbp), %rbx
jne 0xadc7
jmp 0xaf7b
movq %rbx, %r14
jmp 0xaf87
xorl %r14d, %r14d
leaq -0xb0(%rbp), %rdi
callq 0x36b8
movq %r14, %rax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdx, %rbx
movq %rax, %r14
movq -0xd0(%rbp), %rdi
cmpq %r12, %rdi
je 0xafbb
callq 0x31a0
jmp 0xafbb
movq %rdx, %rbx
movq %rax, %r14
movq -0xf0(%rbp), %rdi
cmpq %r15, %rdi
je 0xb036
callq 0x31a0
jmp 0xb036
movq %rdx, %rbx
movq %rax, %r14
jmp 0xb036
movq %rdx, %rbx
movq %rax, %r14
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
jmp 0xaffc
jmp 0xb012
movq %rdx, %rbx
movq %rax, %r14
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0xb018
callq 0x31a0
jmp 0xb018
jmp 0xb012
movq %rdx, %rbx
movq %rax, %r14
jmp 0xb02a
movq %rdx, %rbx
movq %rax, %r14
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0xb02a
callq 0x31a0
leaq -0xb0(%rbp), %rdi
callq 0x36b8
movq %r14, %rdi
cmpl $0x1, %ebx
jne 0xb050
callq 0x30c0
callq 0x3280
xorl %r14d, %r14d
jmp 0xaf87
callq 0x32b0
nop