// File: /workspace/github_cpp_makefile_star2_O1/emr4378[P]FAT-File-System/Shell.cpp
// Function: Shell::changeDirectory(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*)
int Shell::changeDirectory(string tokens[]) {
	int i;
	int j;
	i = 1;
	string absPath;
	while (!tokens[i].empty() && absPath.empty()) {
		if (tokens[i][0] != '-') {
			getAbsoluteFromRelativePath(tokens[i], &absPath);
			*filePath = absPath;
			i++;
		}
	}

	if (checkIfDirExists(*filePath) || 
		(*filePath == *fakeFilePath && fakeFilePath->empty() == false)){
			*oldFilePath = *filePath;
			chdir((*filePath).c_str());
	} else {
		cout << "cd: " << *filePath << ": No such directory" << endl;
		*filePath = *oldFilePath;
		return -1;
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, %rbx
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x28(%rsi), %rdx
testq %rdx, %rdx
je 0x65f4
movq %rsi, %r14
leaq 0x20(%rsi), %rax
movl $0x1, %r13d
leaq 0x58(%rsp), %rbp
leaq 0x48(%rsp), %r15
leaq 0x28(%rsp), %r12
movq (%rax), %rsi
cmpb $0x2d, (%rsi)
je 0x65d8
movq %rbp, 0x48(%rsp)
addq %rsi, %rdx
movq %r15, %rdi
callq 0x4e76
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x5508
movq 0x48(%rsp), %rdi
cmpq %rbp, %rdi
je 0x65c9
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0x8(%rbx), %rdi
movq %r12, %rsi
callq 0x20f0
incl %r13d
movslq %r13d, %rax
shlq $0x5, %rax
movq 0x8(%r14,%rax), %rdx
testq %rdx, %rdx
je 0x65f4
addq %r14, %rax
cmpq $0x0, 0x30(%rsp)
je 0x658c
movq 0x8(%rbx), %rax
leaq 0x18(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %rdi
callq 0x4e76
movq 0x8(%rsp), %rdi
callq 0x22f0
testq %rax, %rax
je 0x665b
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0x663b
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0x8(%rbx), %rsi
movq 0x10(%rbx), %rdi
callq 0x20f0
movq 0x8(%rbx), %rax
movq (%rax), %rdi
callq 0x22d0
xorl %ebx, %ebx
jmp 0x6737
movq (%rbx), %rcx
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rdx
movq 0x8(%rcx), %r15
cmpq %r15, %rdx
jne 0x6683
testq %rdx, %rdx
je 0x669c
movq (%rcx), %rsi
movq (%rax), %rdi
callq 0x2200
testl %eax, %eax
je 0x669c
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0x66b8
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0x66b8
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0x66b3
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21f0
testq %r15, %r15
jne 0x663b
movq 0x4911(%rip), %rdi      # 0xafd0
leaq 0x1be3(%rip), %rsi      # 0x82a9
movl $0x4, %edx
callq 0x2240
movq 0x8(%rbx), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq 0x48ee(%rip), %rdi      # 0xafd0
callq 0x2240
movq %rax, %r14
leaq 0x1bbd(%rip), %rsi      # 0x82ae
movl $0x13, %edx
movq %rax, %rdi
callq 0x2240
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2050
movq %rax, %rdi
callq 0x2120
movq 0x8(%rbx), %rdi
movq 0x10(%rbx), %rsi
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
callq 0x20f0
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x6753
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21f0
movl %ebx, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6782
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %rbp, %rdi
je 0x6785
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0x6785
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x67a1
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21f0
movq %rbx, %rdi
callq 0x23b0
nop