// File: 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
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xa0(%rbp)
movl $0x1, -0x1c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x3430
movq -0x18(%rbp), %rdi
movslq -0x1c(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rdi
callq 0x3510
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0xa1(%rbp)
jne 0xa210
leaq -0x40(%rbp), %rdi
callq 0x3510
movb %al, -0xa1(%rbp)
movb -0xa1(%rbp), %al
testb $0x1, %al
jne 0xa21f
jmp 0xa2dd
movq -0x18(%rbp), %rdi
movslq -0x1c(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x35c0
movq %rax, -0xb0(%rbp)
jmp 0xa240
movq -0xb0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
je 0xa2d8
movq -0x18(%rbp), %rsi
movslq -0x1c(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rsi
leaq -0x70(%rbp), %rdi
callq 0x3120
jmp 0xa26d
movq -0xa0(%rbp), %rdi
leaq -0x70(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x8cf0
jmp 0xa283
leaq -0x70(%rbp), %rdi
callq 0x3180
movq -0xa0(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x40(%rbp), %rsi
callq 0x3050
jmp 0xa2a2
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xa2d8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0xa4a6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x3180
jmp 0xa4a6
jmp 0xa1de
movq -0xa0(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0x90(%rbp), %rdi
callq 0x3120
jmp 0xa2f6
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0xb4f0
movb %al, -0xb1(%rbp)
jmp 0xa311
movb -0xb1(%rbp), %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0xb2(%rbp)
jne 0xa376
jmp 0xa326
movq -0xa0(%rbp), %rax
movq 0x8(%rax), %rdi
movq (%rax), %rsi
callq 0x6bd0
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0xb3(%rbp)
jne 0xa34a
jmp 0xa36a
movq -0xa0(%rbp), %rax
movq (%rax), %rdi
callq 0x3510
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
sete %al
movb %al, -0xb3(%rbp)
movb -0xb3(%rbp), %al
movb %al, -0xb2(%rbp)
movb -0xb2(%rbp), %al
movb %al, -0xb4(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x3180
movb -0xb4(%rbp), %al
testb $0x1, %al
jne 0xa39a
jmp 0xa3ea
movq -0xa0(%rbp), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdi
callq 0x3050
jmp 0xa3b0
movq -0xa0(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x3110
movq %rax, %rdi
callq 0x3450
jmp 0xa480
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x3180
jmp 0xa4a6
movq 0x5bdf(%rip), %rdi      # 0xffd0
leaq 0x1eb1(%rip), %rsi      # 0xc2a9
callq 0x3290
movq %rax, -0xc0(%rbp)
jmp 0xa406
movq -0xc0(%rbp), %rdi
movq -0xa0(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x3220
movq %rax, -0xc8(%rbp)
jmp 0xa426
movq -0xc8(%rbp), %rdi
leaq 0x1e7a(%rip), %rsi      # 0xc2ae
callq 0x3290
movq %rax, -0xd0(%rbp)
jmp 0xa442
movq -0xd0(%rbp), %rdi
movq 0x5b70(%rip), %rsi      # 0xffc0
callq 0x32e0
jmp 0xa457
movq -0xa0(%rbp), %rax
movq 0x8(%rax), %rdi
movq 0x10(%rax), %rsi
callq 0x3050
jmp 0xa46d
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x94(%rbp)
jmp 0xa491
movl $0x0, -0x4(%rbp)
movl $0x1, -0x94(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x3180
movl -0x4(%rbp), %eax
addq $0xd0, %rsp
popq %rbp
retq
leaq -0x40(%rbp), %rdi
callq 0x3180
movq -0x48(%rbp), %rdi
callq 0x3530
nopl (%rax,%rax)