// File: /workspace/github_cpp_makefile_star2_O2/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 $0x20a8, %rsp           # imm = 0x20A8
movq %rdi, %r14
pushq $0x10
popq %rax
leaq (%rsp,%rax), %rcx
addq $0xa0, %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
movb $0x0, (%rcx)
addq $0x20, %rax
cmpq $0x2010, %rax           # imm = 0x2010
jne 0x4ff5
leaq 0x60(%rsp), %rdi
callq 0x22f0
leaq 0x11dd(%rip), %rsi      # 0x6206
leaq 0x40(%rsp), %rdi
movq %rsp, %rdx
callq 0x4444
leaq 0x60(%rsp), %rsi
leaq 0x40(%rsp), %rdx
leaq 0xa0(%rsp), %rcx
callq 0x5332
leaq 0x40(%rsp), %rdi
callq 0x2100
leaq 0x60(%rsp), %rdi
callq 0x2100
xorl %r12d, %r12d
cmpq $0x0, 0xa8(%rsp)
je 0x5258
leaq 0x118f(%rip), %rsi      # 0x6209
leaq 0xa0(%rsp), %rdi
callq 0x43fc
testb %al, %al
je 0x50a0
leaq 0xa0(%rsp), %rsi
movq %r14, %rdi
callq 0x5486
jmp 0x5258
leaq 0x20(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x22f0
leaq 0x20(%rsp), %rsi
callq 0x5606
movl %eax, %ebp
leaq 0x20(%rsp), %rdi
callq 0x2100
testb %bpl, %bpl
je 0x524b
leaq 0xc0(%rsp), %r15
xorl %ebx, %ebx
movq %rsp, %r12
xorl %r13d, %r13d
cmpq $0x0, 0x8(%r15)
je 0x5181
movq (%r15), %rax
cmpb $0x2d, (%rax)
je 0x5147
leaq 0x10(%rsp), %rax
movq %rax, (%rsp)
andq $0x0, 0x8(%rsp)
movb $0x0, 0x10(%rsp)
leaq 0x80(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0x22f0
movq %r14, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x49cc
movq %r13, %rdi
callq 0x2100
movq %r15, %rdi
movq %r12, %rsi
callq 0x2140
movq %r12, %rdi
callq 0x2100
movb $0x1, %r13b
movq (%r14), %rax
movq 0x8(%rax), %rcx
testq %rcx, %rcx
je 0x5178
movq %r12, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x2250
movq (%r14), %rsi
movq %r12, %rdi
callq 0x43c9
movl %eax, %ebp
movq %r12, %rdi
callq 0x2100
orb %bpl, %bl
addq $0x20, %r15
jmp 0x50e1
testb $0x1, %r13b
movl $0x0, %r12d
je 0x51d6
testb $0x1, %bl
je 0x524b
leaq 0xa0(%rsp), %rsi
movq %r14, %rdi
callq 0x5762
movl %eax, %r12d
cmpl $-0x2, %eax
jne 0x528c
movq 0x3e17(%rip), %rdi      # 0x8fd0
leaq 0x104c(%rip), %rsi      # 0x620c
callq 0x2210
movq %rax, %rdi
callq 0x2110
pushq $-0x2
popq %r12
jmp 0x5258
movq 0x8(%r14), %rsi
leaq 0xc0(%rsp), %r15
movq %r15, %rdi
callq 0x2140
andq $0x0, 0xe8(%rsp)
movq 0xe0(%rsp), %rax
movb $0x0, (%rax)
movq (%r14), %rax
movq 0x8(%rax), %rcx
testq %rcx, %rcx
je 0x518d
cmpq $0x0, 0xc8(%rsp)
je 0x518d
movq %rsp, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x2250
movq (%r14), %rsi
movq %rsp, %r15
movq %r15, %rdi
callq 0x43c9
movl %eax, %ebp
movq %r15, %rdi
callq 0x2100
orb %bl, %bpl
testb $0x1, %bpl
jne 0x5196
leaq 0xa0(%rsp), %rsi
callq 0x5c40
movl $0x1fe0, %ebx           # imm = 0x1FE0
leaq (%rsp,%rbx), %rdi
addq $0xa0, %rdi
callq 0x2100
addq $-0x20, %rbx
cmpq $-0x20, %rbx
jne 0x525d
movl %r12d, %eax
addq $0x20a8, %rsp           # imm = 0x20A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testl %r12d, %r12d
jns 0x5258
movq 0x3d38(%rip), %rdi      # 0x8fd0
leaq 0xa0(%rsp), %rsi
callq 0x21b0
leaq 0xf86(%rip), %rsi       # 0x6232
movq %rax, %rdi
callq 0x2210
movq %rax, %rdi
callq 0x2110
jmp 0x5258
jmp 0x52f9
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
jmp 0x5304
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x2100
jmp 0x52dc
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
jmp 0x5304
jmp 0x52f9
jmp 0x52f9
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x2100
jmp 0x5301
movq %rax, %rbx
jmp 0x5309
movq %rax, %rbx
movq %rsp, %rdi
callq 0x2100
movl $0x1fe0, %r14d          # imm = 0x1FE0
leaq (%rsp,%r14), %rdi
addq $0xa0, %rdi
callq 0x2100
addq $-0x20, %r14
cmpq $-0x20, %r14
jne 0x530f
movq %rbx, %rdi
callq 0x23d0
nop