// File: /workspace/github_cpp_makefile_star2_O2/dwburer[P]CSCI-3232-File-System/main.cpp
// Function: parseCommand(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, FileSystem&)
void parseCommand(string c, FileSystem &f) {
	vector<string> dirArgs;
	string arg[2];
	arg[1] = "/";
	size_t pos = 0;

	if(c.find(" ") != string::npos) {
		arg[0] = (c.substr(0, c.find(" ")));
	} else {
		arg[0] = c;
	}

	if(c.length() > arg[0].length()) {
		arg[1] = (c.substr((c.find(" ") + 1), c.length()));
	}

	if(!arg[0].compare("mkfs")) {
		f.makeFileSystem();
	} else if(!f.isFormatted) {
		cout << "Error: FileSystem must be formatted before use" << endl;
		return;
	} else if(!arg[0].compare("ls")) {
		f.list();
	} else if(!arg[0].compare("cd")) {
		if(!arg[1].compare("/")) {
			cout << "Usage: cd <directory>" << endl;
		} else {
 			f.changeDirectory(arg[1]);
		}
	} else if (!arg[0].compare("rmfile")) {
		if(!arg[1].compare("/")) {
			cout << "Usage: rmfile <file>" << endl;
		} else {
			f.removeFile(arg[1]); 
		}
	} else if (!arg[0].compare("mkfile")) {
		if(!arg[1].compare("/")) {
			cout << "Usage: mkfile <file>" << endl;
		} else {
			f.makeFile(arg[1]); 
		}
	} else if (!arg[0].compare("rmdir")) {
		if(!arg[1].compare("/")) {
			cout << "Usage: rmdir <directory>" << endl;
		} else {
			f.removeDirectory(arg[1]);
		}
	} else if (!arg[0].compare("mkdir")) {
		if(!arg[1].compare("/")) {
			cout << "Usage: rmdir <directory>" << endl;
		} else {
			f.makeDirectory(arg[1]);
		}
	} else if (!arg[0].compare("stat")) {
		if(!arg[1].compare("/")){
			cout << "Usage: stat <file|directory>" << endl;
		} else {
			f.stat(arg[1]);
		}
	} else if (!arg[0].compare("exit")) {
		cout << "Exiting..." << endl;
		exit(0);
	} else {
		cout << c << ": command not found." << endl;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x140, %rsp            # imm = 0x140
movq %rsi, %rbx
movq %rdi, %r15
xorps %xmm0, %xmm0
movaps %xmm0, -0x80(%rbp)
andq $0x0, -0x70(%rbp)
pushq $0x10
popq %rax
leaq (%rax,%rbp), %rcx
addq $-0x60, %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
movb $0x0, (%rcx)
addq $0x20, %rax
cmpq $0x50, %rax
jne 0x2513
leaq -0x40(%rbp), %r14
leaq 0x2ac8(%rip), %rsi      # 0x5004
movq %r14, %rdi
callq 0x22c0
leaq 0x2c3c(%rip), %rsi      # 0x5187
movq %r15, %rdi
xorl %edx, %edx
callq 0x22e0
cmpq $-0x1, %rax
je 0x259d
leaq 0x2c25(%rip), %rsi      # 0x5187
movq %r15, %rdi
xorl %edx, %edx
callq 0x22e0
leaq -0xa0(%rbp), %rdi
movq %r15, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x21d0
leaq -0x60(%rbp), %rdi
leaq -0xa0(%rbp), %r12
movq %r12, %rsi
callq 0x2210
movq %r12, %rdi
callq 0x20d0
jmp 0x25a9
leaq -0x60(%rbp), %rdi
movq %r15, %rsi
callq 0x20f0
movq 0x8(%r15), %rax
cmpq -0x58(%rbp), %rax
jbe 0x25f5
leaq 0x2bcd(%rip), %rsi      # 0x5187
movq %r15, %rdi
xorl %edx, %edx
callq 0x22e0
leaq 0x1(%rax), %rdx
movq 0x8(%r15), %rcx
leaq -0xa0(%rbp), %rdi
movq %r15, %rsi
callq 0x21d0
leaq -0xa0(%rbp), %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x2210
movq %r12, %rdi
callq 0x20d0
leaq 0x2a0a(%rip), %rsi      # 0x5006
leaq -0x60(%rbp), %rdi
callq 0x2080
testl %eax, %eax
je 0x26f9
movq 0x59bc(%rip), %r12      # 0x7fd0
cmpb $0x1, 0x10(%rbx)
jne 0x2706
leaq 0x2a15(%rip), %rsi      # 0x503a
leaq -0x60(%rbp), %rdi
callq 0x2080
testl %eax, %eax
je 0x2722
leaq 0x2a00(%rip), %rsi      # 0x503d
leaq -0x60(%rbp), %rdi
callq 0x2080
testl %eax, %eax
je 0x272f
leaq 0x2a01(%rip), %rsi      # 0x5056
leaq -0x60(%rbp), %rdi
callq 0x2080
testl %eax, %eax
je 0x2768
leaq 0x2a05(%rip), %rsi      # 0x5072
leaq -0x60(%rbp), %rdi
callq 0x2080
testl %eax, %eax
je 0x27a1
leaq 0x2a09(%rip), %rsi      # 0x508e
leaq -0x60(%rbp), %rdi
callq 0x2080
testl %eax, %eax
je 0x27e6
leaq 0x2a10(%rip), %rsi      # 0x50ad
leaq -0x60(%rbp), %rdi
callq 0x2080
testl %eax, %eax
je 0x2827
leaq 0x29fe(%rip), %rsi      # 0x50b3
leaq -0x60(%rbp), %rdi
callq 0x2080
testl %eax, %eax
je 0x2871
leaq 0x2a08(%rip), %rsi      # 0x50d5
leaq -0x60(%rbp), %rdi
callq 0x2080
testl %eax, %eax
je 0x28e8
movq 0x58eb(%rip), %rdi      # 0x7fd0
movq %r15, %rsi
callq 0x2180
movq %rax, %r12
leaq 0x29ee(%rip), %rsi      # 0x50e5
jmp 0x270d
movq %rbx, %rdi
callq 0x367c
jmp 0x28a9
leaq 0x28fe(%rip), %rsi      # 0x500b
movq %r12, %rdi
callq 0x21a0
movq %rax, %rdi
callq 0x20e0
jmp 0x28a9
movq %rbx, %rdi
callq 0x3526
jmp 0x28a9
leaq 0x28ce(%rip), %rsi      # 0x5004
movq %r14, %rdi
callq 0x2080
testl %eax, %eax
je 0x27da
leaq -0x160(%rbp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x2230
movq %rbx, %rdi
movq %r15, %rsi
callq 0x36ba
jmp 0x28a1
leaq 0x2895(%rip), %rsi      # 0x5004
movq %r14, %rdi
callq 0x2080
testl %eax, %eax
je 0x281b
leaq -0x140(%rbp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x2230
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3c20
jmp 0x28a1
leaq 0x285c(%rip), %rsi      # 0x5004
movq %r14, %rdi
callq 0x2080
testl %eax, %eax
je 0x2865
leaq -0x120(%rbp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x2230
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3ad4
jmp 0x28a1
leaq 0x285f(%rip), %rsi      # 0x5040
jmp 0x270d
leaq 0x2817(%rip), %rsi      # 0x5004
movq %r14, %rdi
callq 0x2080
testl %eax, %eax
je 0x2859
leaq -0x100(%rbp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x2230
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3968
jmp 0x28a1
leaq 0x283b(%rip), %rsi      # 0x505d
jmp 0x270d
leaq 0x27d6(%rip), %rsi      # 0x5004
movq %r14, %rdi
callq 0x2080
testl %eax, %eax
je 0x2859
leaq -0xe0(%rbp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x2230
movq %rbx, %rdi
movq %r15, %rsi
callq 0x381c
jmp 0x28a1
leaq 0x2834(%rip), %rsi      # 0x5094
jmp 0x270d
leaq 0x280d(%rip), %rsi      # 0x5079
jmp 0x270d
leaq 0x278c(%rip), %rsi      # 0x5004
movq %r14, %rdi
callq 0x2080
testl %eax, %eax
je 0x28dc
leaq -0xc0(%rbp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x2230
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3d48
movq %r15, %rdi
callq 0x20d0
pushq $0x20
popq %rbx
leaq (%rbx,%rbp), %rdi
addq $-0x60, %rdi
callq 0x20d0
addq $-0x20, %rbx
cmpq $-0x20, %rbx
jne 0x28ac
leaq -0x80(%rbp), %rdi
callq 0x2aea
addq $0x140, %rsp            # imm = 0x140
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x27d5(%rip), %rsi      # 0x50b8
jmp 0x270d
movq 0x56e1(%rip), %rdi      # 0x7fd0
leaq 0x27e4(%rip), %rsi      # 0x50da
callq 0x21a0
movq %rax, %rdi
callq 0x20e0
xorl %edi, %edi
callq 0x2200
movq %rax, %rbx
leaq -0xc0(%rbp), %rdi
jmp 0x2950
movq %rax, %rbx
leaq -0xe0(%rbp), %rdi
jmp 0x2950
movq %rax, %rbx
leaq -0x100(%rbp), %rdi
jmp 0x2950
movq %rax, %rbx
leaq -0x120(%rbp), %rdi
jmp 0x2950
movq %rax, %rbx
leaq -0x140(%rbp), %rdi
jmp 0x2950
movq %rax, %rbx
leaq -0x160(%rbp), %rdi
callq 0x20d0
jmp 0x2960
jmp 0x295d
jmp 0x295d
jmp 0x295d
movq %rax, %rbx
pushq $0x20
popq %r14
leaq (%r14,%rbp), %rdi
addq $-0x60, %rdi
callq 0x20d0
addq $-0x20, %r14
cmpq $-0x20, %r14
jne 0x2964
leaq -0x80(%rbp), %rdi
callq 0x2aea
movq %rbx, %rdi
callq 0x2290