// File: emr4378[P]FAT-File-System/Shell.cpp
// Function: Shell::createFileSystem(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
int Shell::createFileSystem(string name) {
	int ret = -1;
	int num;
	bool condMet;
	string input;
	int fileSize;
	int clusterSize;

	do {
		condMet = true;
		cout << "Are you sure you want to create a new file system[Y]? ";
		getline(cin, input);
		if (input != "" && input[0] != 'Y' && input[0] != 'N') {
			condMet = false;
			cout << "Please enter Y or N" << endl;
		}
	} while (!condMet && !cin.eof());

	if (input[0] == 'N') {
		ret = -1;
	} else {
		do {
			condMet = true;
			cout << "Enter the maximum size for this file system in MB [10]: ";
			getline(cin, input);
			if (input == "") {
				num = 10;
			} else {
				num = atoi(input.c_str());
				if (num > MAX_FILE_SIZE || num < MIN_FILE_SIZE) {
					condMet = false;
					cout << "Please enter integer between " << MIN_FILE_SIZE;
					cout << " and " << MAX_FILE_SIZE << endl;
				}
			}
		} while (!condMet && !cin.eof());

		fileSize = num;

		do {
			condMet = true;
			cout << "Enter the cluster size for this file system in KB [8]:";
			getline(cin, input);
			if (input == "") {
				num = 8;
			} else {
				num = atoi(input.c_str());
				if (num > MAX_CLUSTER_SIZE || num < MIN_CLUSTER_SIZE) {
					condMet = false;
					cout << "Please enter integer between " << MIN_CLUSTER_SIZE;
					cout << " and " << MAX_CLUSTER_SIZE << endl;
				}
			}
		} while (!condMet && !cin.eof());

		clusterSize = num;

		ret = fileSystem->createFileSys(name, fileSize, clusterSize);
	}

	return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rsi, -0x88(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x80(%rbp)
movl $0xffffffff, -0x14(%rbp) # imm = 0xFFFFFFFF
leaq -0x40(%rbp), %rdi
callq 0x3430
movb $0x1, -0x19(%rbp)
movq 0x6d23(%rip), %rdi      # 0xffd0
leaq 0x2e68(%rip), %rsi      # 0xc11c
callq 0x3290
jmp 0x92bb
movq 0x6d1e(%rip), %rdi      # 0xffe0
leaq -0x40(%rbp), %rsi
callq 0x3070
jmp 0x92cd
leaq 0x2f34(%rip), %rsi      # 0xc208
leaq -0x40(%rbp), %rdi
callq 0xb610
movb %al, -0x89(%rbp)
jmp 0x92e5
movb -0x89(%rbp), %al
testb $0x1, %al
jne 0x92f4
jmp 0x9386
xorl %eax, %eax
movl %eax, %esi
leaq -0x40(%rbp), %rdi
callq 0x35c0
movq %rax, -0x98(%rbp)
jmp 0x930a
movq -0x98(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x59, %eax
je 0x9386
xorl %eax, %eax
movl %eax, %esi
leaq -0x40(%rbp), %rdi
callq 0x35c0
movq %rax, -0xa0(%rbp)
jmp 0x932f
movq -0xa0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x4e, %eax
je 0x9386
movb $0x0, -0x19(%rbp)
movq 0x6c87(%rip), %rdi      # 0xffd0
leaq 0x2e03(%rip), %rsi      # 0xc153
callq 0x3290
movq %rax, -0xa8(%rbp)
jmp 0x935e
movq -0xa8(%rbp), %rdi
movq 0x6c54(%rip), %rsi      # 0xffc0
callq 0x32e0
jmp 0x9373
jmp 0x9386
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x9730
jmp 0x9388
xorl %eax, %eax
testb $0x1, -0x19(%rbp)
movb %al, -0xa9(%rbp)
jne 0x93c2
movq 0x6c43(%rip), %rdi      # 0xffe0
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x3570
movb %al, -0xaa(%rbp)
jmp 0x93b4
movb -0xaa(%rbp), %al
xorb $-0x1, %al
movb %al, -0xa9(%rbp)
movb -0xa9(%rbp), %al
testb $0x1, %al
jne 0x92a2
xorl %eax, %eax
movl %eax, %esi
leaq -0x40(%rbp), %rdi
callq 0x35c0
movq %rax, -0xb8(%rbp)
jmp 0x93e6
movq -0xb8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x4e, %eax
jne 0x9401
movl $0xffffffff, -0x14(%rbp) # imm = 0xFFFFFFFF
jmp 0x970f
jmp 0x9403
movb $0x1, -0x19(%rbp)
movq 0x6bc2(%rip), %rdi      # 0xffd0
leaq 0x2d52(%rip), %rsi      # 0xc167
callq 0x3290
jmp 0x941c
movq 0x6bbd(%rip), %rdi      # 0xffe0
leaq -0x40(%rbp), %rsi
callq 0x3070
jmp 0x942e
leaq 0x2dd3(%rip), %rsi      # 0xc208
leaq -0x40(%rbp), %rdi
callq 0x6c90
movb %al, -0xb9(%rbp)
jmp 0x9446
movb -0xb9(%rbp), %al
testb $0x1, %al
jne 0x9452
jmp 0x945e
movl $0xa, -0x18(%rbp)
jmp 0x9504
leaq -0x40(%rbp), %rdi
callq 0x3110
movq %rax, %rdi
callq 0x34b0
movl %eax, -0x18(%rbp)
cmpl $0x32, -0x18(%rbp)
jg 0x9482
cmpl $0x5, -0x18(%rbp)
jge 0x9502
movb $0x0, -0x19(%rbp)
movq 0x6b43(%rip), %rdi      # 0xffd0
leaq 0x2d0c(%rip), %rsi      # 0xc1a0
callq 0x3290
movq %rax, -0xc8(%rbp)
jmp 0x94a2
movq -0xc8(%rbp), %rdi
movl $0x5, %esi
callq 0x3520
jmp 0x94b5
movq 0x6b14(%rip), %rdi      # 0xffd0
leaq 0x2cfb(%rip), %rsi      # 0xc1be
callq 0x3290
movq %rax, -0xd0(%rbp)
jmp 0x94d1
movq -0xd0(%rbp), %rdi
movl $0x32, %esi
callq 0x3520
movq %rax, -0xd8(%rbp)
jmp 0x94eb
movq -0xd8(%rbp), %rdi
movq 0x6ac7(%rip), %rsi      # 0xffc0
callq 0x32e0
jmp 0x9500
jmp 0x9502
jmp 0x9504
jmp 0x9506
xorl %eax, %eax
testb $0x1, -0x19(%rbp)
movb %al, -0xd9(%rbp)
jne 0x9540
movq 0x6ac5(%rip), %rdi      # 0xffe0
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x3570
movb %al, -0xda(%rbp)
jmp 0x9532
movb -0xda(%rbp), %al
xorb $-0x1, %al
movb %al, -0xd9(%rbp)
movb -0xd9(%rbp), %al
testb $0x1, %al
jne 0x9403
movl -0x18(%rbp), %eax
movl %eax, -0x44(%rbp)
movb $0x1, -0x19(%rbp)
movq 0x6a71(%rip), %rdi      # 0xffd0
leaq 0x2c5e(%rip), %rsi      # 0xc1c4
callq 0x3290
jmp 0x956d
movq 0x6a6c(%rip), %rdi      # 0xffe0
leaq -0x40(%rbp), %rsi
callq 0x3070
jmp 0x957f
leaq 0x2c82(%rip), %rsi      # 0xc208
leaq -0x40(%rbp), %rdi
callq 0x6c90
movb %al, -0xdb(%rbp)
jmp 0x9597
movb -0xdb(%rbp), %al
testb $0x1, %al
jne 0x95a3
jmp 0x95af
movl $0x8, -0x18(%rbp)
jmp 0x9655
leaq -0x40(%rbp), %rdi
callq 0x3110
movq %rax, %rdi
callq 0x34b0
movl %eax, -0x18(%rbp)
cmpl $0x10, -0x18(%rbp)
jg 0x95d3
cmpl $0x8, -0x18(%rbp)
jge 0x9653
movb $0x0, -0x19(%rbp)
movq 0x69f2(%rip), %rdi      # 0xffd0
leaq 0x2bbb(%rip), %rsi      # 0xc1a0
callq 0x3290
movq %rax, -0xe8(%rbp)
jmp 0x95f3
movq -0xe8(%rbp), %rdi
movl $0x8, %esi
callq 0x3520
jmp 0x9606
movq 0x69c3(%rip), %rdi      # 0xffd0
leaq 0x2baa(%rip), %rsi      # 0xc1be
callq 0x3290
movq %rax, -0xf0(%rbp)
jmp 0x9622
movq -0xf0(%rbp), %rdi
movl $0x10, %esi
callq 0x3520
movq %rax, -0xf8(%rbp)
jmp 0x963c
movq -0xf8(%rbp), %rdi
movq 0x6976(%rip), %rsi      # 0xffc0
callq 0x32e0
jmp 0x9651
jmp 0x9653
jmp 0x9655
jmp 0x9657
xorl %eax, %eax
testb $0x1, -0x19(%rbp)
movb %al, -0xf9(%rbp)
jne 0x9691
movq 0x6974(%rip), %rdi      # 0xffe0
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x3570
movb %al, -0xfa(%rbp)
jmp 0x9683
movb -0xfa(%rbp), %al
xorb $-0x1, %al
movb %al, -0xf9(%rbp)
movb -0xf9(%rbp), %al
testb $0x1, %al
jne 0x9554
movq -0x88(%rbp), %rsi
movq -0x80(%rbp), %rax
movl -0x18(%rbp), %ecx
movl %ecx, -0x48(%rbp)
movq 0x18(%rax), %rax
movq %rax, -0x108(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x3120
jmp 0x96c6
movq -0x108(%rbp), %rdi
movl -0x44(%rbp), %edx
movl -0x48(%rbp), %ecx
leaq -0x78(%rbp), %rsi
callq 0x3c30
movl %eax, -0x10c(%rbp)
jmp 0x96e4
movl -0x10c(%rbp), %eax
movl %eax, -0x14(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x3180
jmp 0x970f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x3180
jmp 0x9730
movl -0x14(%rbp), %eax
movl %eax, -0x110(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x3180
movl -0x110(%rbp), %eax
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
leaq -0x40(%rbp), %rdi
callq 0x3180
movq -0x50(%rbp), %rdi
callq 0x3530
nopw %cs:(%rax,%rax)