// File: /workspace/github_cpp_makefile_star2_O3/emr4378[P]FAT-File-System/Shell.cpp
// Function: Shell::runCommand(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
int Shell::runCommand(string cmdline) {
	int ret = 0;
	string tokens[256];
	int i;
	int j;
	bool usingFake = false;
	getTokens(cmdline, " \n", tokens);
	bool leastOnePath = false;
	if (!tokens[0].empty()) {
		if (tokens[0] == "cd") {
			changeDirectory(tokens);
		} else {

			if (isCommandSupported(tokens[0])) {
				i = 1;
				while (!tokens[i].empty()) {
					if ((tokens[i][0] == '/' 
								|| (tokens[i].size() >= 1 
									&& tokens[i][0] != '-'))) {
						string newArg;
						getAbsoluteFromRelativePath(tokens[i], &newArg);
						tokens[i] = newArg;
						leastOnePath = true;
					}

					if (fakeFilePath->empty() == false && 
						(tokens[i].substr(0, 
							fakeFilePath->size()) == *fakeFilePath)) {
						usingFake = true;
					}
					i++;
				}
				if (!leastOnePath) {
					tokens[1] = *filePath;
					tokens[2].clear();

					if (fakeFilePath->empty() == false && 
						!tokens[1].empty() &&
						tokens[1].substr(0, 
							fakeFilePath->size()) == * fakeFilePath) {
						usingFake = true;
					}
				} 
			}

			if (usingFake) {
				ret = runFakeCommand(tokens);
				if (ret == -2) {
					cout << "ERROR: Not enough space in filesystem" << endl;
				} else if (ret < 0) {
					cout << tokens[0] << ": error with command" << endl;
				}
			} else {
				ret = runRealCommand(tokens);
			}
		}
	}
	return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x20b8, %rsp           # imm = 0x20B8
movq %rdi, %r14
movl $0x10, %eax
leaq (%rsp,%rax), %rcx
addq $0xb0, %rcx
movq %rcx, -0x10(%rcx)
movq $0x0, -0x8(%rcx)
movb $0x0, (%rcx)
addq $0x20, %rax
cmpq $0x2010, %rax           # imm = 0x2010
jne 0x5dc7
leaq 0xa0(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rsi), %rax
movq 0x8(%rsi), %rdx
addq %rax, %rdx
leaq 0x90(%rsp), %rdi
movq %rax, %rsi
callq 0x4e42
leaq 0x80(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x23df(%rip), %rsi      # 0x8206
leaq 0x23da(%rip), %rdx      # 0x8208
leaq 0x70(%rsp), %rdi
callq 0x50cc
leaq 0x90(%rsp), %rsi
leaq 0x70(%rsp), %rdx
leaq 0xb0(%rsp), %rcx
callq 0x6320
movq 0x70(%rsp), %rdi
cmpq %r12, %rdi
je 0x5e6c
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0x90(%rsp), %rdi
cmpq %r15, %rdi
je 0x5e89
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x21f0
xorl %r12d, %r12d
cmpq $0x0, 0xb8(%rsp)
je 0x620d
leaq 0x2367(%rip), %rsi      # 0x8209
leaq 0xb0(%rsp), %rdi
callq 0x2070
testl %eax, %eax
je 0x6058
leaq 0x60(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0xb0(%rsp), %rsi
movq 0xb8(%rsp), %rdx
addq %rsi, %rdx
leaq 0x50(%rsp), %rdi
callq 0x4e42
leaq 0x50(%rsp), %rsi
callq 0x6780
movl %eax, %ebp
movq 0x50(%rsp), %rdi
cmpq %r15, %rdi
je 0x5f00
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x21f0
testb %bpl, %bpl
je 0x6200
movq 0xd8(%rsp), %rdx
testq %rdx, %rdx
je 0x606d
leaq 0xd0(%rsp), %r15
movq $0x0, 0x28(%rsp)
leaq 0x8(%rsp), %r12
xorl %ebx, %ebx
movq (%r15), %rsi
cmpb $0x2d, (%rsi)
je 0x5fc7
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movb $0x0, 0x18(%rsp)
leaq 0x40(%rsp), %rax
movq %rax, 0x30(%rsp)
addq %rsi, %rdx
leaq 0x30(%rsp), %rdi
callq 0x4e42
movq %r14, %rdi
leaq 0x30(%rsp), %rsi
movq %r12, %rdx
callq 0x54da
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x5f99
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x21f0
movq %r15, %rdi
movq %r12, %rsi
callq 0x20f0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x5fc0
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21f0
movb $0x1, %al
movq %rax, 0x28(%rsp)
movq (%r14), %rax
movq 0x8(%rax), %rcx
testq %rcx, %rcx
je 0x6035
movq %r12, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x2210
movq (%r14), %rax
movq 0x10(%rsp), %rdx
cmpq 0x8(%rax), %rdx
jne 0x600b
movq 0x8(%rsp), %rbp
testq %rdx, %rdx
je 0x6015
movq (%rax), %rsi
movq %rbp, %rdi
callq 0x2200
testl %eax, %eax
sete %r13b
jmp 0x6018
movq 0x8(%rsp), %rbp
xorl %r13d, %r13d
jmp 0x6018
movb $0x1, %r13b
leaq 0x18(%rsp), %rax
cmpq %rax, %rbp
je 0x6032
movq 0x18(%rsp), %rsi
incq %rsi
movq %rbp, %rdi
callq 0x21f0
orb %r13b, %bl
movq 0x28(%r15), %rdx
addq $0x20, %r15
testq %rdx, %rdx
jne 0x5f32
testb $0x1, 0x28(%rsp)
movl $0x0, %r12d
je 0x606f
jmp 0x60f6
leaq 0xb0(%rsp), %rsi
movq %r14, %rdi
callq 0x650e
jmp 0x620d
xorl %ebx, %ebx
movq 0x8(%r14), %rsi
leaq 0xd0(%rsp), %r15
movq %r15, %rdi
callq 0x20f0
movq $0x0, 0xf8(%rsp)
movq 0xf0(%rsp), %rax
movb $0x0, (%rax)
movq (%r14), %rax
movq 0x8(%rax), %rcx
testq %rcx, %rcx
je 0x60f6
cmpq $0x0, 0xd8(%rsp)
je 0x60f6
leaq 0x8(%rsp), %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x2210
movq (%r14), %rax
movq 0x10(%rsp), %rdx
cmpq 0x8(%rax), %rdx
jne 0x61cd
movq 0x8(%rsp), %r15
testq %rdx, %rdx
je 0x61d6
movq (%rax), %rsi
movq %r15, %rdi
callq 0x2200
testl %eax, %eax
sete %bpl
jmp 0x61d9
testb $0x1, %bl
je 0x6200
leaq 0xb0(%rsp), %rsi
movq %r14, %rdi
callq 0x6958
movl %eax, %r12d
cmpl $-0x2, %eax
jne 0x6168
movq 0x4eb2(%rip), %rbx      # 0xafd0
leaq 0x20e7(%rip), %rsi      # 0x820c
movl $0x25, %edx
movq %rbx, %rdi
callq 0x2240
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq 0x4e80(%rip), %rdi      # 0xafd0
callq 0x2050
movl $0xfffffffe, %r12d      # imm = 0xFFFFFFFE
movq %rax, %rdi
callq 0x2120
jmp 0x620d
testl %r12d, %r12d
jns 0x620d
movq 0xb0(%rsp), %rsi
movq 0xb8(%rsp), %rdx
movq 0x4e48(%rip), %rdi      # 0xafd0
callq 0x2240
movq %rax, %r14
leaq 0x209b(%rip), %rsi      # 0x8232
movl $0x14, %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
jmp 0x620d
movq 0x8(%rsp), %r15
xorl %ebp, %ebp
jmp 0x61d9
movb $0x1, %bpl
leaq 0x18(%rsp), %rax
cmpq %rax, %r15
je 0x61f3
movq 0x18(%rsp), %rsi
incq %rsi
movq %r15, %rdi
callq 0x21f0
orb %bl, %bpl
testb $0x1, %bpl
jne 0x60ff
leaq 0xb0(%rsp), %rsi
callq 0x70e0
movq $-0x2000, %rbx          # imm = 0xE000
leaq 0x20a0(%rsp), %r14
movq -0x10(%r14), %rdi
cmpq %rdi, %r14
je 0x6230
movq (%r14), %rsi
incq %rsi
callq 0x21f0
addq $-0x20, %r14
addq $0x20, %rbx
jne 0x621c
movl %r12d, %eax
addq $0x20b8, %rsp           # imm = 0x20B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x62c7
movq %rax, %rbx
movq 0x50(%rsp), %rdi
cmpq %r15, %rdi
je 0x62eb
movq 0x60(%rsp), %rsi
jmp 0x62e3
movq %rax, %rbx
movq 0x70(%rsp), %rdi
cmpq %r12, %rdi
je 0x628b
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0x628b
movq %rax, %rbx
movq 0x90(%rsp), %rdi
cmpq %r15, %rdi
je 0x62eb
movq 0xa0(%rsp), %rsi
jmp 0x62e3
jmp 0x62c7
jmp 0x62c7
movq %rax, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x62cf
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0x62cf
movq %rax, %rbx
jmp 0x62eb
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x62eb
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21f0
movq $-0x2000, %r14          # imm = 0xE000
leaq 0x20a0(%rsp), %r15
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0x630e
movq (%r15), %rsi
incq %rsi
callq 0x21f0
addq $-0x20, %r15
addq $0x20, %r14
jne 0x62fa
movq %rbx, %rdi
callq 0x23b0