// File: /workspace/github_cpp_makefile_star2_O1/emr4378[P]FAT-File-System/Shell.cpp
// Function: Shell::runFakeCommand(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*)
int Shell::runFakeCommand(string tokens[]) {
	int ret = -1;
	int i;
	string cmd = tokens[0];
	if (cmd == "ls") {
		fileSystem->printDirectoryTable();
		ret = 0;
	} else if (cmd == "touch") {
		if (tokens[1].size() > fakeFilePath->size() + 1) {
			ret = fileSystem->createFile(tokens[1].substr(fakeFilePath->size() + 1));
		}
	} else if (cmd == "cp" || cmd == "mv") {
		string sourceFile;
		string destFile;

		i = 1;
		while (!tokens[i].empty() && destFile.empty()) {
			if (tokens[i][0] != '-') {
				if (sourceFile.empty()) {
					sourceFile = tokens[i];
				} else {
					destFile = tokens[i];
				}
			}
			i++;
		}
		if (destFile.empty()) {
			ret = -1;
		} else {
			bool sourceInFake = false;
			bool destInFake = false;
			if (tokens[1].find(*fakeFilePath) == 0) {
				if (tokens[1].size() > fakeFilePath->size() + 1) {
					sourceFile = sourceFile.substr(fakeFilePath->size() + 1);
				} else {
					sourceFile = "";
				}
				sourceInFake = true;
			}

			if (tokens[2].find(*fakeFilePath) == 0) {
				if (tokens[2].size() >= fakeFilePath->size() + 1) {
					destFile = destFile.substr(fakeFilePath->size() + 1);
					destInFake = true;
				} else {
					destFile = "";
				}
				destInFake = true;
			}
		
			if (cmd == "cp") {
				ret = fileSystem->copyFile(sourceFile, destFile, 
											sourceInFake, destInFake);
			} else if (cmd == "mv") {
				ret = fileSystem->moveFile(sourceFile, destFile, 
											sourceInFake, destInFake);
			}
		}
	} else if (cmd == "rm") {
		if (tokens[1].size() > fakeFilePath->size() + 1) {
			ret = fileSystem->removeFile(tokens[1].substr(fakeFilePath->size() + 1));
		}
	} else if (cmd == "df") {
		fileSystem->printInfo(6, NULL);
		ret = 0;
	} else if (cmd == "cat" && !tokens[1].empty()) {
		if (tokens[1].size() > fakeFilePath->size() + 1) {
			ret = fileSystem->printFile(tokens[1].substr(fakeFilePath->size() + 1));
		}
	} else {
		cout << cmd << " command not supported by fake filesystem." << endl;
		ret = -1;
	}

	return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x168, %rsp            # imm = 0x168
movq %rsi, %r15
movq %rdi, %r14
leaq 0x58(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq (%rsi), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq 0x48(%rsp), %rbx
movq %rbx, %rdi
callq 0x4e76
leaq 0x1636(%rip), %rsi      # 0x8036
movq %rbx, %rdi
callq 0x2070
testl %eax, %eax
je 0x6ae5
leaq 0x1830(%rip), %rsi      # 0x8247
leaq 0x48(%rsp), %rdi
callq 0x2070
testl %eax, %eax
je 0x6bf2
leaq 0x181d(%rip), %rsi      # 0x824d
leaq 0x48(%rsp), %rdi
callq 0x2070
testl %eax, %eax
je 0x6af5
leaq 0x1807(%rip), %rsi      # 0x8250
leaq 0x48(%rsp), %rdi
callq 0x2070
testl %eax, %eax
je 0x6af5
leaq 0x17f1(%rip), %rsi      # 0x8253
leaq 0x48(%rsp), %rdi
callq 0x2070
testl %eax, %eax
je 0x6c5e
leaq 0x17db(%rip), %rsi      # 0x8256
leaq 0x48(%rsp), %rdi
callq 0x2070
testl %eax, %eax
je 0x6cca
leaq 0x17c5(%rip), %rsi      # 0x8259
leaq 0x48(%rsp), %rdi
callq 0x2070
testl %eax, %eax
je 0x6f67
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq 0x4519(%rip), %rdi      # 0xafd0
callq 0x2240
movq %rax, %r14
leaq 0x17b5(%rip), %rsi      # 0x827b
movl $0x2a, %edx
movq %rax, %rdi
callq 0x2240
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq %r14, %rdi
callq 0x20c0
jmp 0x6f3c
movq 0x18(%r14), %rdi
xorl %ebx, %ebx
callq 0x4d02
jmp 0x6f3c
leaq 0x38(%rsp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x18(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
cmpq %rax, 0x28(%r15)
je 0x6b59
leaq 0x20(%r15), %rbx
leaq 0x28(%rsp), %r12
leaq 0x8(%rsp), %r13
movq (%rbx), %rax
cmpb $0x2d, (%rax)
je 0x6b46
cmpq $0x0, 0x30(%rsp)
movq %r13, %rdi
cmoveq %r12, %rdi
movq %rbx, %rsi
callq 0x20f0
cmpq $0x0, 0x28(%rbx)
je 0x6b59
addq $0x20, %rbx
cmpq $0x0, 0x10(%rsp)
je 0x6b29
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpq $0x0, 0x10(%rsp)
je 0x6f04
leaq 0x20(%r15), %rdi
movq (%r14), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rcx
xorl %edx, %edx
callq 0x23a0
movq %rax, %r12
testq %rax, %rax
jne 0x6cf2
movq (%r14), %rax
movq 0x8(%rax), %rcx
incq %rcx
cmpq %rcx, 0x28(%r15)
jbe 0x6ce1
movq 0x8(%rax), %rdx
incq %rdx
leaq 0x68(%rsp), %rdi
leaq 0x28(%rsp), %rsi
movq $-0x1, %rcx
callq 0x2210
leaq 0x28(%rsp), %rdi
leaq 0x68(%rsp), %r13
movq %r13, %rsi
callq 0x2280
movq (%r13), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x6cf2
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0x6cf2
movq (%r14), %rax
movq 0x8(%rax), %rdx
incq %rdx
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpq %rdx, 0x28(%r15)
jbe 0x6f3c
addq $0x20, %r15
movq 0x18(%r14), %rbx
leaq 0x148(%rsp), %rdi
movq %r15, %rsi
movq $-0x1, %rcx
callq 0x2210
leaq 0x148(%rsp), %rsi
movq %rbx, %rdi
callq 0x31cc
movl %eax, %ebx
leaq 0x158(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6f3c
movq 0x158(%rsp), %rsi
jmp 0x6f34
movq (%r14), %rax
movq 0x8(%rax), %rdx
incq %rdx
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpq %rdx, 0x28(%r15)
jbe 0x6f3c
addq $0x20, %r15
movq 0x18(%r14), %rbx
leaq 0xe8(%rsp), %rdi
movq %r15, %rsi
movq $-0x1, %rcx
callq 0x2210
leaq 0xe8(%rsp), %rsi
movq %rbx, %rdi
callq 0x4110
movl %eax, %ebx
leaq 0xf8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6f3c
movq 0xf8(%rsp), %rsi
jmp 0x6f34
movq 0x18(%r14), %rdi
xorl %ebx, %ebx
movl $0x6, %esi
xorl %edx, %edx
callq 0x498e
jmp 0x6f3c
leaq 0x1520(%rip), %rsi      # 0x8208
leaq 0x28(%rsp), %rdi
callq 0x22c0
leaq 0x40(%r15), %rdi
movq (%r14), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rcx
xorl %edx, %edx
callq 0x23a0
movq %rax, %r13
testq %rax, %rax
jne 0x6d7b
movq (%r14), %rax
movq 0x8(%rax), %rcx
incq %rcx
cmpq %rcx, 0x48(%r15)
jae 0x6d32
leaq 0x14e2(%rip), %rsi      # 0x8208
leaq 0x8(%rsp), %rdi
callq 0x22c0
jmp 0x6d7b
movq 0x8(%rax), %rdx
incq %rdx
leaq 0x68(%rsp), %rdi
leaq 0x8(%rsp), %rsi
movq $-0x1, %rcx
callq 0x2210
leaq 0x8(%rsp), %rdi
leaq 0x68(%rsp), %r15
movq %r15, %rsi
callq 0x2280
movq (%r15), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x6d7b
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x21f0
leaq 0x14cb(%rip), %rsi      # 0x824d
leaq 0x48(%rsp), %rdi
callq 0x2070
testl %eax, %eax
je 0x6e53
leaq 0x14b5(%rip), %rsi      # 0x8250
leaq 0x48(%rsp), %rdi
callq 0x2070
testl %eax, %eax
jne 0x6f04
movq 0x18(%r14), %rbx
leaq 0x118(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
addq %rsi, %rdx
leaq 0x108(%rsp), %rdi
callq 0x4e76
leaq 0x98(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0x88(%rsp), %rdi
callq 0x4e76
xorl %r8d, %r8d
testq %r13, %r13
sete %r8b
xorl %ecx, %ecx
testq %r12, %r12
sete %cl
leaq 0x108(%rsp), %rsi
leaq 0x88(%rsp), %rdx
movq %rbx, %rdi
callq 0x425a
movl %eax, %ebx
movq 0x88(%rsp), %rdi
cmpq %r15, %rdi
je 0x6e46
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0x108(%rsp), %rdi
jmp 0x6ef4
movq 0x18(%r14), %rbx
leaq 0x138(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
addq %rsi, %rdx
leaq 0x128(%rsp), %rdi
callq 0x4e76
leaq 0xb8(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0xa8(%rsp), %rdi
callq 0x4e76
xorl %r8d, %r8d
testq %r13, %r13
sete %r8b
xorl %ecx, %ecx
testq %r12, %r12
sete %cl
leaq 0x128(%rsp), %rsi
leaq 0xa8(%rsp), %rdx
movq %rbx, %rdi
callq 0x346a
movl %eax, %ebx
movq 0xa8(%rsp), %rdi
cmpq %r15, %rdi
je 0x6eec
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0x128(%rsp), %rdi
cmpq %r14, %rdi
je 0x6f04
movq (%r14), %rsi
incq %rsi
callq 0x21f0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x6f20
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x6f3c
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0x48(%rsp), %rdi
cmpq %rbp, %rdi
je 0x6f53
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x21f0
movl %ebx, %eax
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x28(%r15), %rax
testq %rax, %rax
je 0x6aa6
movq (%r14), %rcx
movq 0x8(%rcx), %rdx
incq %rdx
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpq %rdx, %rax
jbe 0x6f3c
addq $0x20, %r15
movq 0x18(%r14), %rbx
leaq 0xc8(%rsp), %rdi
movq %r15, %rsi
movq $-0x1, %rcx
callq 0x2210
leaq 0xc8(%rsp), %rsi
movq %rbx, %rdi
callq 0x43e6
movl %eax, %ebx
leaq 0xd8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6f3c
movq 0xd8(%rsp), %rsi
jmp 0x6f34
movq %rax, %rbx
leaq 0xd8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x710f
movq 0xd8(%rsp), %rsi
jmp 0x7107
jmp 0x70d4
jmp 0x70d4
movq %rax, %rbx
leaq 0xf8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x710f
movq 0xf8(%rsp), %rsi
jmp 0x7107
movq %rax, %rbx
movq 0x88(%rsp), %rdi
cmpq %r15, %rdi
je 0x7054
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0x7054
movq %rax, %rbx
movq 0x108(%rsp), %rdi
cmpq %r14, %rdi
je 0x70d7
movq 0x118(%rsp), %rsi
jmp 0x70a5
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
cmpq %r15, %rdi
je 0x7090
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0x7090
movq %rax, %rbx
movq 0x128(%rsp), %rdi
cmpq %r14, %rdi
je 0x70d7
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0x70d7
movq %rax, %rbx
leaq 0x158(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x710f
movq 0x158(%rsp), %rsi
jmp 0x7107
jmp 0x70d4
movq %rax, %rbx
jmp 0x710f
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x70f3
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x710f
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0x48(%rsp), %rdi
cmpq %rbp, %rdi
je 0x7126
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x21f0
movq %rbx, %rdi
callq 0x23b0