// File: /workspace/github_cpp_makefile_star2_O1/emr4378[P]FAT-File-System/Shell.cpp
// Function: Shell::Shell(char*)
Shell::Shell(char *name) {
	char *dir = (char*)malloc(sizeof(char)*FILENAME_MAX);
	int fileSysUse = -1;
	string tempName;

	getcwd(dir, sizeof(char)*FILENAME_MAX);
	filePath = new string(dir);
	oldFilePath = new string(dir);
	fakeFilePath = new string();
	free(dir);

	fileSystem = new FileSys();

	if (name != NULL) {
		tempName = name;
		getAbsoluteFromRelativePath(tempName, &tempName);
		if (checkIfExists(tempName)) {
			fileSysUse = fileSystem->openFileSys(name);
		} else {
			fileSysUse = createFileSystem(name);
		}
	}
	
	if (fileSysUse == 0) {
		chdir("/");
		*fakeFilePath = "/";
		*fakeFilePath += name;
		*filePath = *fakeFilePath;
	}

	cout << "Shell Created" << endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %rsi, %r14
movq %rdi, %rbx
movl $0x1000, %edi           # imm = 0x1000
callq 0x22b0
movq %rax, %r15
leaq 0x18(%rsp), %r13
movq %r13, -0x10(%r13)
movq $0x0, -0x8(%r13)
movb $0x0, (%r13)
movl $0x1000, %esi           # imm = 0x1000
movq %rax, %rdi
callq 0x20d0
movl $0x20, %edi
callq 0x21e0
movq %rax, %r12
leaq 0xa8(%rsp), %rdx
movq %rax, %rdi
movq %r15, %rsi
callq 0x733e
movq %r12, 0x8(%rbx)
movl $0x20, %edi
callq 0x21e0
movq %rax, %r12
leaq 0xa8(%rsp), %rdx
movq %rax, %rdi
movq %r15, %rsi
callq 0x733e
movq %r12, 0x10(%rbx)
movl $0x20, %edi
callq 0x21e0
movq %rax, %rcx
addq $0x10, %rcx
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq %rax, (%rbx)
movq %r15, %rdi
callq 0x2260
movl $0x60, %edi
callq 0x21e0
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
movaps %xmm0, 0x10(%rax)
movaps %xmm0, 0x50(%rax)
movaps %xmm0, 0x30(%rax)
movaps %xmm0, 0x20(%rax)
movaps %xmm0, 0x40(%rax)
movq %rax, %rcx
addq $0x10, %rcx
movq %rcx, (%rax)
xorl %ecx, %ecx
movq %rcx, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq %rcx, 0x50(%rax)
movq %rax, 0x18(%rbx)
testq %r14, %r14
je 0x538f
leaq 0x8(%rsp), %r15
movq 0x8(%r15), %r12
movq %r14, %rdi
callq 0x20b0
movq %r15, %rdi
xorl %esi, %esi
movq %r12, %rdx
movq %r14, %rcx
movq %rax, %r8
callq 0x2320
leaq 0x38(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0x28(%rsp), %rdi
callq 0x4e76
leaq 0x28(%rsp), %rsi
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
callq 0x5508
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x52f4
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21f0
leaq 0x98(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0x88(%rsp), %rdi
callq 0x4e76
movq 0x88(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x2180
movl %eax, %ebp
movq 0x88(%rsp), %rdi
cmpq %r15, %rdi
je 0x534e
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x21f0
testl %ebp, %ebp
js 0x5396
movq 0x18(%rbx), %r15
leaq 0x78(%rsp), %r12
movq %r12, -0x10(%r12)
movq %r14, %rdi
callq 0x20b0
leaq (%rax,%r14), %rdx
leaq 0x68(%rsp), %rdi
movq %r14, %rsi
callq 0x50f4
leaq 0x68(%rsp), %rsi
movq %r15, %rdi
callq 0x2670
movl %eax, %ebp
movq 0x68(%rsp), %rdi
jmp 0x53cd
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x53de
leaq 0x58(%rsp), %r12
movq %r12, -0x10(%r12)
movq %r14, %rdi
callq 0x20b0
leaq (%rax,%r14), %rdx
leaq 0x48(%rsp), %rdi
movq %r14, %rsi
callq 0x50f4
leaq 0x48(%rsp), %rsi
movq %rbx, %rdi
callq 0x58fe
movl %eax, %ebp
movq 0x48(%rsp), %rdi
cmpq %r12, %rdi
je 0x53de
movq (%r12), %rsi
incq %rsi
callq 0x21f0
testl %ebp, %ebp
jne 0x541f
leaq 0x2d23(%rip), %r15      # 0x810c
movq %r15, %rdi
callq 0x22d0
movq (%rbx), %rdi
movq 0x8(%rdi), %rdx
movl $0x1, %r8d
xorl %esi, %esi
movq %r15, %rcx
callq 0x2320
movq (%rbx), %rdi
movq %r14, %rsi
callq 0x23f0
movq (%rbx), %rsi
movq 0x8(%rbx), %rdi
callq 0x20f0
movq 0x5baa(%rip), %rbx      # 0xafd0
leaq 0x2ce1(%rip), %rsi      # 0x810e
movl $0xd, %edx
movq %rbx, %rdi
callq 0x2240
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq 0x5b78(%rip), %rdi      # 0xafd0
callq 0x2050
movq %rax, %rdi
callq 0x2120
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x547c
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21f0
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r12, %rdi
je 0x54e8
movq 0x58(%rsp), %rsi
jmp 0x54cc
jmp 0x54e5
movq %rax, %rbx
movq 0x68(%rsp), %rdi
cmpq %r12, %rdi
je 0x54e8
movq 0x78(%rsp), %rsi
jmp 0x54cc
jmp 0x54e5
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x54e8
movq 0x38(%rsp), %rsi
incq %rsi
jmp 0x54de
jmp 0x54d3
movq %rax, %rbx
movl $0x20, %esi
movq %r12, %rdi
callq 0x21f0
jmp 0x54e8
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x54ff
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21f0
movq %rbx, %rdi
callq 0x23b0
nop