// File: /workspace/github_cpp_makefile_star2_O3/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, %r14
xorps %xmm0, %xmm0
movaps %xmm0, -0x160(%rbp)
movq $0x0, -0x150(%rbp)
movl $0x10, %eax
leaq (%rax,%rbp), %rcx
addq $-0x60, %rcx
movq %rcx, -0x10(%rcx)
movq $0x0, -0x8(%rcx)
movb $0x0, (%rcx)
addq $0x20, %rax
cmpq $0x50, %rax
jne 0x250e
leaq -0x40(%rbp), %r15
movq 0x8(%r15), %rdx
leaq 0x2ac6(%rip), %rcx      # 0x5004
movl $0x1, %r8d
movq %r15, %rdi
xorl %esi, %esi
callq 0x2240
leaq 0x2c32(%rip), %rsi      # 0x5187
movl $0x1, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x2290
cmpq $-0x1, %rax
je 0x25bc
leaq 0x2c16(%rip), %rsi      # 0x5187
movl $0x1, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x2290
leaq -0x80(%rbp), %rdi
movq %r14, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x21c0
leaq -0x60(%rbp), %rdi
leaq -0x80(%rbp), %r12
movq %r12, %rsi
callq 0x2210
movq (%r12), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x25c8
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x21b0
jmp 0x25c8
leaq -0x60(%rbp), %rdi
movq %r14, %rsi
callq 0x20f0
movq 0x8(%r14), %rax
cmpq -0x58(%rbp), %rax
jbe 0x2624
leaq 0x2bae(%rip), %rsi      # 0x5187
movl $0x1, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x2290
leaq 0x1(%rax), %rdx
movq 0x8(%r14), %rcx
leaq -0x80(%rbp), %rdi
movq %r14, %rsi
callq 0x21c0
leaq -0x80(%rbp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x2210
movq (%r12), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x2624
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x21b0
leaq 0x29db(%rip), %rsi      # 0x5006
leaq -0x60(%rbp), %rdi
callq 0x2080
testl %eax, %eax
je 0x2735
cmpb $0x1, 0x10(%rbx)
jne 0x2742
leaq 0x29ed(%rip), %rsi      # 0x503a
leaq -0x60(%rbp), %rdi
callq 0x2080
testl %eax, %eax
je 0x278d
leaq 0x29d8(%rip), %rsi      # 0x503d
leaq -0x60(%rbp), %rdi
callq 0x2080
testl %eax, %eax
je 0x279a
leaq 0x29d9(%rip), %rsi      # 0x5056
leaq -0x60(%rbp), %rdi
callq 0x2080
testl %eax, %eax
je 0x27ee
leaq 0x29dd(%rip), %rsi      # 0x5072
leaq -0x60(%rbp), %rdi
callq 0x2080
testl %eax, %eax
je 0x2842
leaq 0x29e1(%rip), %rsi      # 0x508e
leaq -0x60(%rbp), %rdi
callq 0x2080
testl %eax, %eax
je 0x28a7
leaq 0x29e8(%rip), %rsi      # 0x50ad
leaq -0x60(%rbp), %rdi
callq 0x2080
testl %eax, %eax
je 0x2909
leaq 0x29d6(%rip), %rsi      # 0x50b3
leaq -0x60(%rbp), %rdi
callq 0x2080
testl %eax, %eax
je 0x298c
leaq 0x29e0(%rip), %rsi      # 0x50d5
leaq -0x60(%rbp), %rdi
callq 0x2080
testl %eax, %eax
je 0x2a41
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq 0x58bc(%rip), %rdi      # 0x7fd0
callq 0x21e0
movq %rax, %rbx
leaq 0x29c2(%rip), %rsi      # 0x50e5
movl $0x14, %edx
movq %rax, %rdi
callq 0x21e0
jmp 0x2982
movq %rbx, %rdi
callq 0x3aa4
jmp 0x29eb
movl $0x2e, %edx
leaq 0x28bd(%rip), %rsi      # 0x500b
movq 0x587b(%rip), %rbx      # 0x7fd0
movq %rbx, %rdi
callq 0x21e0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
movq 0x5855(%rip), %rdi      # 0x7fd0
callq 0x2030
movq %rax, %rdi
callq 0x2110
jmp 0x29eb
movq %rbx, %rdi
callq 0x3862
jmp 0x29eb
leaq 0x2863(%rip), %rsi      # 0x5004
movq %r15, %rdi
callq 0x2080
testl %eax, %eax
je 0x2896
leaq -0x130(%rbp), %r14
movq %r14, -0x10(%r14)
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
addq %rsi, %rdx
leaq -0x140(%rbp), %rdi
callq 0x2ed4
leaq -0x140(%rbp), %rsi
movq %rbx, %rdi
callq 0x3b0a
movq -0x140(%rbp), %rdi
jmp 0x29db
leaq 0x280f(%rip), %rsi      # 0x5004
movq %r15, %rdi
callq 0x2080
testl %eax, %eax
je 0x28fb
leaq -0x110(%rbp), %r14
movq %r14, -0x10(%r14)
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
addq %rsi, %rdx
leaq -0x120(%rbp), %rdi
callq 0x2ed4
leaq -0x120(%rbp), %rsi
movq %rbx, %rdi
callq 0x43ac
movq -0x120(%rbp), %rdi
jmp 0x29db
leaq 0x27bb(%rip), %rsi      # 0x5004
movq %r15, %rdi
callq 0x2080
testl %eax, %eax
je 0x2967
leaq -0xf0(%rbp), %r14
movq %r14, -0x10(%r14)
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
addq %rsi, %rdx
leaq -0x100(%rbp), %rdi
callq 0x2ed4
leaq -0x100(%rbp), %rsi
movq %rbx, %rdi
callq 0x41a2
movq -0x100(%rbp), %rdi
jmp 0x29db
movl $0x15, %edx
leaq 0x279e(%rip), %rsi      # 0x5040
jmp 0x274e
leaq 0x2756(%rip), %rsi      # 0x5004
movq %r15, %rdi
callq 0x2080
testl %eax, %eax
je 0x2959
leaq -0xd0(%rbp), %r14
movq %r14, -0x10(%r14)
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
addq %rsi, %rdx
leaq -0xe0(%rbp), %rdi
callq 0x2ed4
leaq -0xe0(%rbp), %rsi
movq %rbx, %rdi
callq 0x3f5a
movq -0xe0(%rbp), %rdi
jmp 0x29db
movl $0x14, %edx
leaq 0x2756(%rip), %rsi      # 0x505d
jmp 0x2973
leaq 0x26f4(%rip), %rsi      # 0x5004
movq %r15, %rdi
callq 0x2080
testl %eax, %eax
je 0x2959
leaq -0xb0(%rbp), %r14
movq %r14, -0x10(%r14)
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
addq %rsi, %rdx
leaq -0xc0(%rbp), %rdi
callq 0x2ed4
leaq -0xc0(%rbp), %rsi
movq %rbx, %rdi
callq 0x3d50
movq -0xc0(%rbp), %rdi
jmp 0x29db
movl $0x18, %edx
leaq 0x272f(%rip), %rsi      # 0x5094
jmp 0x2973
movl $0x14, %edx
leaq 0x2706(%rip), %rsi      # 0x5079
movq 0x5656(%rip), %rbx      # 0x7fd0
movq %rbx, %rdi
callq 0x21e0
movq %rbx, %rdi
callq 0x20e0
jmp 0x29eb
leaq 0x2671(%rip), %rsi      # 0x5004
movq %r15, %rdi
callq 0x2080
testl %eax, %eax
je 0x2a30
leaq -0x90(%rbp), %r14
movq %r14, -0x10(%r14)
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
addq %rsi, %rdx
leaq -0xa0(%rbp), %rdi
callq 0x2ed4
leaq -0xa0(%rbp), %rsi
movq %rbx, %rdi
callq 0x45a0
movq -0xa0(%rbp), %rdi
cmpq %r14, %rdi
je 0x29eb
movq (%r14), %rsi
incq %rsi
callq 0x21b0
movq $-0x40, %rbx
leaq -0x30(%rbp), %r14
movq -0x10(%r14), %rdi
cmpq %rdi, %r14
je 0x2a0a
movq (%r14), %rsi
incq %rsi
callq 0x21b0
addq $-0x20, %r14
addq $0x20, %rbx
jne 0x29f6
leaq -0x160(%rbp), %rdi
callq 0x2dc8
addq $0x140, %rsp            # imm = 0x140
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x1c, %edx
leaq 0x267c(%rip), %rsi      # 0x50b8
jmp 0x2973
movq 0x5588(%rip), %rdi      # 0x7fd0
leaq 0x268b(%rip), %rsi      # 0x50da
movl $0xa, %edx
callq 0x21e0
movq 0x5570(%rip), %rdi      # 0x7fd0
callq 0x20e0
xorl %edi, %edi
callq 0x2200
movq %rax, %rbx
movq -0xa0(%rbp), %rdi
cmpq %r14, %rdi
je 0x2b11
movq -0x90(%rbp), %rsi
jmp 0x2afe
movq %rax, %rbx
movq -0xc0(%rbp), %rdi
cmpq %r14, %rdi
je 0x2b11
movq -0xb0(%rbp), %rsi
jmp 0x2afe
movq %rax, %rbx
movq -0xe0(%rbp), %rdi
cmpq %r14, %rdi
je 0x2b11
movq -0xd0(%rbp), %rsi
jmp 0x2afe
movq %rax, %rbx
movq -0x100(%rbp), %rdi
cmpq %r14, %rdi
je 0x2b11
movq -0xf0(%rbp), %rsi
jmp 0x2afe
movq %rax, %rbx
movq -0x120(%rbp), %rdi
cmpq %r14, %rdi
je 0x2b11
movq -0x110(%rbp), %rsi
jmp 0x2afe
movq %rax, %rbx
movq -0x140(%rbp), %rdi
cmpq %r14, %rdi
je 0x2b11
movq -0x130(%rbp), %rsi
incq %rsi
callq 0x21b0
jmp 0x2b11
jmp 0x2b0e
jmp 0x2b0e
jmp 0x2b0e
movq %rax, %rbx
movq $-0x40, %r14
leaq -0x30(%rbp), %r15
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0x2b30
movq (%r15), %rsi
incq %rsi
callq 0x21b0
addq $-0x20, %r15
addq $0x20, %r14
jne 0x2b1c
leaq -0x160(%rbp), %rdi
callq 0x2dc8
movq %rbx, %rdi
callq 0x22a0