// File: /workspace/github_cpp_makefile_star2_O1/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 0x3425(%rip), %rsi      # 0xe174
movq %r14, %rdi
callq 0x3080
movq %rbx, -0x30(%rbp)
movq 0x8(%rbx), %rbx
testl %eax, %eax
je 0xafcb
movq (%r14), %rsi
cmpb $0x2f, (%rsi)
jne 0xad76
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 0x3954
leaq -0xc0(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x345c(%rip), %rsi      # 0xe203
leaq 0x3456(%rip), %rdx      # 0xe204
leaq -0xd0(%rbp), %rdi
callq 0xabe4
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 0xade8
callq 0x31a0
movq -0xf0(%rbp), %rdi
cmpq %r15, %rdi
je 0xadf9
callq 0x31a0
movq -0xb0(%rbp), %r13
movq -0xa8(%rbp), %rax
movq %rax, -0x58(%rbp)
cmpq %rax, %r13
je 0xafd3
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 0x3954
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 0xae68
callq 0x31a0
movq %r15, %rdi
leaq 0x3302(%rip), %rsi      # 0xe174
callq 0x3080
movl $0x3, %ebx
testl %eax, %eax
je 0xaf99
movq %r15, %rdi
leaq 0x3385(%rip), %rsi      # 0xe213
callq 0x3080
testl %eax, %eax
je 0xaf99
movq %r15, %rdi
leaq 0x336d(%rip), %rsi      # 0xe212
callq 0x3080
testl %eax, %eax
je 0xaf5d
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 0x3954
movq %r14, %r12
movq %r14, %rdi
movq %rbx, %rsi
callq 0xbd50
movl %eax, %r14d
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0xaf03
callq 0x31a0
movl $0x1, %ebx
testb %r14b, %r14b
je 0xaf96
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 0x3954
movq %r12, %rdi
movq %rbx, %rsi
callq 0xc488
testq %rax, %rax
je 0xaf75
movq %rax, %rdi
leaq 0x7e26(%rip), %rsi      # 0x12d70
leaq 0x7e2f(%rip), %rdx      # 0x12d80
xorl %ecx, %ecx
callq 0x31f0
movq %rax, %r14
jmp 0xaf78
movq -0x30(%rbp), %rax
cmpq (%rax), %r14
je 0xaf99
movq %r14, %rdi
callq 0xbc70
movq %rax, %r14
xorl %ebx, %ebx
jmp 0xaf99
xorl %r14d, %r14d
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0xaf8a
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 0xafab
callq 0x31a0
cmpl $0x3, %ebx
je 0xafb4
testl %ebx, %ebx
jne 0xafd0
addq $0x20, %r13
cmpq -0x58(%rbp), %r13
leaq -0x110(%rbp), %rbx
jne 0xae1f
jmp 0xafd3
movq %rbx, %r14
jmp 0xafdf
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 0xb013
callq 0x31a0
jmp 0xb013
movq %rdx, %rbx
movq %rax, %r14
movq -0xf0(%rbp), %rdi
cmpq %r15, %rdi
je 0xb08e
callq 0x31a0
jmp 0xb08e
movq %rdx, %rbx
movq %rax, %r14
jmp 0xb08e
movq %rdx, %rbx
movq %rax, %r14
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
jmp 0xb054
jmp 0xb06a
movq %rdx, %rbx
movq %rax, %r14
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0xb070
callq 0x31a0
jmp 0xb070
jmp 0xb06a
movq %rdx, %rbx
movq %rax, %r14
jmp 0xb082
movq %rdx, %rbx
movq %rax, %r14
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0xb082
callq 0x31a0
leaq -0xb0(%rbp), %rdi
callq 0x36b8
movq %r14, %rdi
cmpl $0x1, %ebx
jne 0xb0a8
callq 0x30c0
callq 0x3280
xorl %r14d, %r14d
jmp 0xafdf
callq 0x32b0
nop