// File: /workspace/github_cpp_makefile_star2_O2/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 %r12
pushq %rbx
subq $0xb0, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movl $0x1000, %edi           # imm = 0x1000
callq 0x22e0
movq %rax, %r15
leaq 0x20(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movl $0x1000, %esi           # imm = 0x1000
movq %r15, %rdi
callq 0x2120
pushq $0x20
popq %rdi
callq 0x2230
movq %rax, %r12
leaq 0xf(%rsp), %rdx
movq %rax, %rdi
movq %r15, %rsi
callq 0x4444
movq %r12, 0x8(%rbx)
pushq $0x20
popq %rdi
callq 0x2230
movq %rax, %r12
leaq 0xf(%rsp), %rdx
movq %rax, %rdi
movq %r15, %rsi
callq 0x4444
movq %r12, 0x10(%rbx)
pushq $0x20
popq %rdi
callq 0x2230
movq %rax, %rcx
addq $0x10, %rcx
movq %rcx, (%rax)
andq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq %rax, (%rbx)
movq %r15, %rdi
callq 0x2290
pushq $0x60
popq %rdi
callq 0x2230
movq %rax, %rcx
addq $0x10, %rcx
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rax)
movaps %xmm0, 0x30(%rax)
movaps %xmm0, 0x20(%rax)
movaps %xmm0, 0x10(%rax)
movq %rcx, (%rax)
andq $0x0, 0x8(%rax)
andq $0x0, 0x50(%rax)
movups %xmm0, 0x40(%rax)
movq %rax, 0x18(%rbx)
testq %r14, %r14
je 0x4949
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x2410
leaq 0x70(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x22f0
leaq 0x70(%rsp), %rsi
leaq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x49cc
leaq 0x70(%rsp), %rdi
callq 0x2100
leaq 0x90(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x22f0
leaq 0x90(%rsp), %r15
movq %r15, %rsi
callq 0x4c86
movl %eax, %ebp
movq %r15, %rdi
callq 0x2100
testb %bpl, %bpl
je 0x48e9
movq 0x18(%rbx), %r15
leaq 0x50(%rsp), %rdi
leaq 0xf(%rsp), %rdx
movq %r14, %rsi
callq 0x4444
leaq 0x50(%rsp), %rsi
movq %r15, %rdi
callq 0x266c
movl %eax, %ebp
leaq 0x50(%rsp), %rdi
jmp 0x490f
leaq 0x30(%rsp), %rdi
leaq 0xf(%rsp), %rdx
movq %r14, %rsi
callq 0x4444
leaq 0x30(%rsp), %rsi
movq %rbx, %rdi
callq 0x4ca8
movl %eax, %ebp
leaq 0x30(%rsp), %rdi
callq 0x2100
testl %ebp, %ebp
jne 0x4949
leaq 0x17ed(%rip), %r15      # 0x610c
movq %r15, %rdi
callq 0x2310
movq (%rbx), %rdi
movq %r15, %rsi
callq 0x2410
movq (%rbx), %rdi
movq %r14, %rsi
callq 0x2400
movq (%rbx), %rsi
movq 0x8(%rbx), %rdi
callq 0x2140
movq 0x4680(%rip), %rdi      # 0x8fd0
leaq 0x17b7(%rip), %rsi      # 0x610e
callq 0x2210
movq %rax, %rdi
callq 0x2110
leaq 0x10(%rsp), %rdi
callq 0x2100
addq $0xb0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
jmp 0x499e
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
jmp 0x499e
jmp 0x49b7
jmp 0x49b7
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x2100
jmp 0x49ba
jmp 0x49a7
movq %rax, %rbx
pushq $0x20
popq %rsi
movq %r12, %rdi
callq 0x2240
jmp 0x49ba
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x2100
movq %rbx, %rdi
callq 0x23d0