// File: 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
subq $0x280, %rsp            # imm = 0x280
movq %rdi, -0x1a8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x4100
leaq -0x70(%rbp), %rax
movq %rax, %rcx
addq $0x40, %rcx
movq %rcx, -0x1a0(%rbp)
movq %rax, -0x198(%rbp)
movq -0x198(%rbp), %rdi
movq %rdi, -0x1b0(%rbp)
callq 0x3310
movq -0x1b0(%rbp), %rax
movq -0x1a0(%rbp), %rcx
addq $0x20, %rax
cmpq %rcx, %rax
movq %rax, -0x198(%rbp)
jne 0x366c
leaq -0x50(%rbp), %rdi
leaq 0x595c(%rip), %rsi      # 0x9004
callq 0x3300
jmp 0x36af
movq -0x1a8(%rbp), %rdi
movq $0x0, -0x88(%rbp)
leaq 0x5abf(%rip), %rsi      # 0x9187
xorl %eax, %eax
movl %eax, %edx
callq 0x33e0
cmpq $-0x1, %rax
je 0x3743
movq -0x1a8(%rbp), %rdi
leaq 0x5aa2(%rip), %rsi      # 0x9187
xorl %eax, %eax
movl %eax, %edx
movq %rdx, -0x1b8(%rbp)
callq 0x33e0
movq -0x1a8(%rbp), %rsi
movq -0x1b8(%rbp), %rdx
movq %rax, %rcx
leaq -0xa8(%rbp), %rdi
callq 0x3250
jmp 0x3714
leaq -0x70(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x32e0
leaq -0xa8(%rbp), %rdi
callq 0x3140
jmp 0x3757
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x3e3d
movq -0x1a8(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x3040
jmp 0x3755
jmp 0x3757
movq -0x1a8(%rbp), %rdi
callq 0x3330
movq %rax, -0x1c0(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x3330
movq %rax, %rcx
movq -0x1c0(%rbp), %rax
cmpq %rcx, %rax
jbe 0x37ee
movq -0x1a8(%rbp), %rdi
leaq 0x59f7(%rip), %rsi      # 0x9187
xorl %eax, %eax
movl %eax, %edx
callq 0x33e0
movq -0x1a8(%rbp), %rdi
incq %rax
movq %rax, -0x1c8(%rbp)
callq 0x3330
movq -0x1a8(%rbp), %rsi
movq -0x1c8(%rbp), %rdx
movq %rax, %rcx
leaq -0xc8(%rbp), %rdi
callq 0x3250
jmp 0x37ce
leaq -0x70(%rbp), %rdi
addq $0x20, %rdi
leaq -0xc8(%rbp), %rsi
callq 0x32e0
leaq -0xc8(%rbp), %rdi
callq 0x3140
leaq -0x70(%rbp), %rdi
leaq 0x580d(%rip), %rsi      # 0x9006
callq 0x30a0
cmpl $0x0, %eax
jne 0x3813
movq -0x10(%rbp), %rdi
callq 0x6730
jmp 0x380e
jmp 0x3dda
movq -0x10(%rbp), %rax
testb $0x1, 0x10(%rax)
jne 0x385d
movq 0x97ac(%rip), %rdi      # 0xcfd0
leaq 0x57e0(%rip), %rsi      # 0x900b
callq 0x3220
movq %rax, -0x1d0(%rbp)
jmp 0x3839
movq -0x1d0(%rbp), %rdi
movq 0x9779(%rip), %rsi      # 0xcfc0
callq 0x3270
jmp 0x384e
movl $0x1, -0xcc(%rbp)
jmp 0x3de4
leaq -0x70(%rbp), %rdi
leaq 0x57d2(%rip), %rsi      # 0x903a
callq 0x30a0
cmpl $0x0, %eax
jne 0x3882
movq -0x10(%rbp), %rdi
callq 0x64e0
jmp 0x387d
jmp 0x3dd6
leaq -0x70(%rbp), %rdi
leaq 0x57b0(%rip), %rsi      # 0x903d
callq 0x30a0
cmpl $0x0, %eax
jne 0x3949
leaq -0x70(%rbp), %rdi
addq $0x20, %rdi
leaq 0x575a(%rip), %rsi      # 0x9004
callq 0x30a0
cmpl $0x0, %eax
jne 0x38e7
movq 0x9715(%rip), %rdi      # 0xcfd0
leaq 0x577e(%rip), %rsi      # 0x9040
callq 0x3220
movq %rax, -0x1d8(%rbp)
jmp 0x38d0
movq -0x1d8(%rbp), %rdi
movq 0x96e2(%rip), %rsi      # 0xcfc0
callq 0x3270
jmp 0x38e5
jmp 0x3944
movq -0x10(%rbp), %rax
movq %rax, -0x1e0(%rbp)
leaq -0x50(%rbp), %rsi
leaq -0xf0(%rbp), %rdi
callq 0x30f0
jmp 0x3904
movq -0x1e0(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x6790
jmp 0x3919
leaq -0xf0(%rbp), %rdi
callq 0x3140
jmp 0x3944
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x3140
jmp 0x3e3d
jmp 0x3dd4
leaq -0x70(%rbp), %rdi
leaq 0x5702(%rip), %rsi      # 0x9056
callq 0x30a0
cmpl $0x0, %eax
jne 0x3a10
leaq -0x70(%rbp), %rdi
addq $0x20, %rdi
leaq 0x5693(%rip), %rsi      # 0x9004
callq 0x30a0
cmpl $0x0, %eax
jne 0x39ae
movq 0x964e(%rip), %rdi      # 0xcfd0
leaq 0x56d4(%rip), %rsi      # 0x905d
callq 0x3220
movq %rax, -0x1e8(%rbp)
jmp 0x3997
movq -0x1e8(%rbp), %rdi
movq 0x961b(%rip), %rsi      # 0xcfc0
callq 0x3270
jmp 0x39ac
jmp 0x3a0b
movq -0x10(%rbp), %rax
movq %rax, -0x1f0(%rbp)
leaq -0x50(%rbp), %rsi
leaq -0x110(%rbp), %rdi
callq 0x30f0
jmp 0x39cb
movq -0x1f0(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x7000
jmp 0x39e0
leaq -0x110(%rbp), %rdi
callq 0x3140
jmp 0x3a0b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x3140
jmp 0x3e3d
jmp 0x3dd2
leaq -0x70(%rbp), %rdi
leaq 0x5657(%rip), %rsi      # 0x9072
callq 0x30a0
cmpl $0x0, %eax
jne 0x3ad7
leaq -0x70(%rbp), %rdi
addq $0x20, %rdi
leaq 0x55cc(%rip), %rsi      # 0x9004
callq 0x30a0
cmpl $0x0, %eax
jne 0x3a75
movq 0x9587(%rip), %rdi      # 0xcfd0
leaq 0x5629(%rip), %rsi      # 0x9079
callq 0x3220
movq %rax, -0x1f8(%rbp)
jmp 0x3a5e
movq -0x1f8(%rbp), %rdi
movq 0x9554(%rip), %rsi      # 0xcfc0
callq 0x3270
jmp 0x3a73
jmp 0x3ad2
movq -0x10(%rbp), %rax
movq %rax, -0x200(%rbp)
leaq -0x50(%rbp), %rsi
leaq -0x130(%rbp), %rdi
callq 0x30f0
jmp 0x3a92
movq -0x200(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x6de0
jmp 0x3aa7
leaq -0x130(%rbp), %rdi
callq 0x3140
jmp 0x3ad2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x130(%rbp), %rdi
callq 0x3140
jmp 0x3e3d
jmp 0x3dd0
leaq -0x70(%rbp), %rdi
leaq 0x55ac(%rip), %rsi      # 0x908e
callq 0x30a0
cmpl $0x0, %eax
jne 0x3b9e
leaq -0x70(%rbp), %rdi
addq $0x20, %rdi
leaq 0x5505(%rip), %rsi      # 0x9004
callq 0x30a0
cmpl $0x0, %eax
jne 0x3b3c
movq 0x94c0(%rip), %rdi      # 0xcfd0
leaq 0x557d(%rip), %rsi      # 0x9094
callq 0x3220
movq %rax, -0x208(%rbp)
jmp 0x3b25
movq -0x208(%rbp), %rdi
movq 0x948d(%rip), %rsi      # 0xcfc0
callq 0x3270
jmp 0x3b3a
jmp 0x3b99
movq -0x10(%rbp), %rax
movq %rax, -0x210(%rbp)
leaq -0x50(%rbp), %rsi
leaq -0x150(%rbp), %rdi
callq 0x30f0
jmp 0x3b59
movq -0x210(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x6bd0
jmp 0x3b6e
leaq -0x150(%rbp), %rdi
callq 0x3140
jmp 0x3b99
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x150(%rbp), %rdi
callq 0x3140
jmp 0x3e3d
jmp 0x3dce
leaq -0x70(%rbp), %rdi
leaq 0x5504(%rip), %rsi      # 0x90ad
callq 0x30a0
cmpl $0x0, %eax
jne 0x3c65
leaq -0x70(%rbp), %rdi
addq $0x20, %rdi
leaq 0x543e(%rip), %rsi      # 0x9004
callq 0x30a0
cmpl $0x0, %eax
jne 0x3c03
movq 0x93f9(%rip), %rdi      # 0xcfd0
leaq 0x54b6(%rip), %rsi      # 0x9094
callq 0x3220
movq %rax, -0x218(%rbp)
jmp 0x3bec
movq -0x218(%rbp), %rdi
movq 0x93c6(%rip), %rsi      # 0xcfc0
callq 0x3270
jmp 0x3c01
jmp 0x3c60
movq -0x10(%rbp), %rax
movq %rax, -0x220(%rbp)
leaq -0x50(%rbp), %rsi
leaq -0x170(%rbp), %rdi
callq 0x30f0
jmp 0x3c20
movq -0x220(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x69b0
jmp 0x3c35
leaq -0x170(%rbp), %rdi
callq 0x3140
jmp 0x3c60
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x170(%rbp), %rdi
callq 0x3140
jmp 0x3e3d
jmp 0x3dcc
leaq -0x70(%rbp), %rdi
leaq 0x5443(%rip), %rsi      # 0x90b3
callq 0x30a0
cmpl $0x0, %eax
jne 0x3d2c
leaq -0x70(%rbp), %rdi
addq $0x20, %rdi
leaq 0x5377(%rip), %rsi      # 0x9004
callq 0x30a0
cmpl $0x0, %eax
jne 0x3cca
movq 0x9332(%rip), %rdi      # 0xcfd0
leaq 0x5413(%rip), %rsi      # 0x90b8
callq 0x3220
movq %rax, -0x228(%rbp)
jmp 0x3cb3
movq -0x228(%rbp), %rdi
movq 0x92ff(%rip), %rsi      # 0xcfc0
callq 0x3270
jmp 0x3cc8
jmp 0x3d27
movq -0x10(%rbp), %rax
movq %rax, -0x230(%rbp)
leaq -0x50(%rbp), %rsi
leaq -0x190(%rbp), %rdi
callq 0x30f0
jmp 0x3ce7
movq -0x230(%rbp), %rdi
leaq -0x190(%rbp), %rsi
callq 0x7190
jmp 0x3cfc
leaq -0x190(%rbp), %rdi
callq 0x3140
jmp 0x3d27
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x190(%rbp), %rdi
callq 0x3140
jmp 0x3e3d
jmp 0x3dca
leaq -0x70(%rbp), %rdi
leaq 0x539e(%rip), %rsi      # 0x90d5
callq 0x30a0
cmpl $0x0, %eax
jne 0x3d79
movq 0x9288(%rip), %rdi      # 0xcfd0
leaq 0x538b(%rip), %rsi      # 0x90da
callq 0x3220
movq %rax, -0x238(%rbp)
jmp 0x3d5d
movq -0x238(%rbp), %rdi
movq 0x9255(%rip), %rsi      # 0xcfc0
callq 0x3270
jmp 0x3d72
xorl %edi, %edi
callq 0x32d0
movq -0x1a8(%rbp), %rsi
movq 0x9249(%rip), %rdi      # 0xcfd0
callq 0x31f0
movq %rax, -0x240(%rbp)
jmp 0x3d95
movq -0x240(%rbp), %rdi
leaq 0x5342(%rip), %rsi      # 0x90e5
callq 0x3220
movq %rax, -0x248(%rbp)
jmp 0x3db1
movq -0x248(%rbp), %rdi
movq 0x9201(%rip), %rsi      # 0xcfc0
callq 0x3270
jmp 0x3dc6
jmp 0x3dc8
jmp 0x3dca
jmp 0x3dcc
jmp 0x3dce
jmp 0x3dd0
jmp 0x3dd2
jmp 0x3dd4
jmp 0x3dd6
jmp 0x3dd8
jmp 0x3dda
movl $0x0, -0xcc(%rbp)
leaq -0x70(%rbp), %rax
movq %rax, -0x258(%rbp)
addq $0x40, %rax
movq %rax, -0x250(%rbp)
movq -0x250(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x260(%rbp)
callq 0x3140
movq -0x258(%rbp), %rcx
movq -0x260(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x250(%rbp)
jne 0x3dfa
leaq -0x28(%rbp), %rdi
callq 0x4120
addq $0x280, %rsp            # imm = 0x280
popq %rbp
retq
leaq -0x70(%rbp), %rax
movq %rax, -0x270(%rbp)
addq $0x40, %rax
movq %rax, -0x268(%rbp)
movq -0x268(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x278(%rbp)
callq 0x3140
movq -0x270(%rbp), %rcx
movq -0x278(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x268(%rbp)
jne 0x3e53
leaq -0x28(%rbp), %rdi
callq 0x4120
movq -0x78(%rbp), %rdi
callq 0x3380
nopw %cs:(%rax,%rax)