// File: /workspace/github_cpp_makefile_star2_O3/emr4378[P]FAT-File-System/Shell.cpp
// Function: Shell::getAbsoluteFromRelativePath(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*)
void Shell::getAbsoluteFromRelativePath(string relPath, string *absPath) {
	int j;
	string tempStr;
	string subToks[256];
	string newArg;
	struct stat st_buf;

	tempStr = relPath;
	if (relPath[0] != '/') {
		newArg = *filePath;
	} else {
		newArg = "/";
	}
	getTokens(tempStr, "/", subToks);
	
	j = 0;
	while (!subToks[j].empty()) {
		if (subToks[j] == "..") {
			int num = newArg.find_last_of("/");
			newArg = newArg.substr(0, num);
		} else if (subToks[j] != ".") {
			if (newArg[newArg.length()-1] != '/') {
				newArg += "/";
			}
			newArg += subToks[j];
		} 
		if (newArg.length() <= 0) {
			newArg += "/";
		}
		
		j++;
	}
	if (newArg[newArg.size()-1] != '/' && newArg != *fakeFilePath) {
		stat(newArg.c_str(), &st_buf);
		if (S_ISDIR(st_buf.st_mode)) {
			newArg += "/";
		}
	}
	*absPath = newArg;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2148, %rsp           # imm = 0x2148
movq %rdx, %r13
movq %rsi, %rbx
movq %rdi, %rbp
leaq 0x30(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movl $0x10, %eax
leaq (%rsp,%rax), %rcx
addq $0x140, %rcx            # imm = 0x140
movq %rcx, -0x10(%rcx)
movq $0x0, -0x8(%rcx)
movb $0x0, (%rcx)
addq $0x20, %rax
cmpq $0x2010, %rax           # imm = 0x2010
jne 0x550d
leaq 0x10(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x20(%rsp), %rdi
movq %rbx, %rsi
callq 0x20f0
movq (%rbx), %rax
cmpb $0x2f, (%rax)
jne 0x5579
movq %rsp, %rdi
movq 0x8(%rdi), %rdx
leaq 0x2ba2(%rip), %rcx      # 0x810c
movl $0x1, %r8d
xorl %esi, %esi
callq 0x2320
jmp 0x5585
movq 0x8(%rbp), %rsi
movq %rsp, %rdi
callq 0x20f0
leaq 0x80(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
addq %rsi, %rdx
leaq 0x70(%rsp), %rdi
callq 0x4e42
leaq 0x60(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x2b53(%rip), %rsi      # 0x810c
leaq 0x2b4d(%rip), %rdx      # 0x810d
leaq 0x50(%rsp), %rdi
callq 0x50cc
leaq 0x70(%rsp), %rsi
leaq 0x50(%rsp), %rdx
leaq 0x140(%rsp), %r15
movq %r15, %rcx
callq 0x6320
movq %rbp, 0x40(%rsp)
movq %r13, 0x48(%rsp)
movq 0x50(%rsp), %rdi
cmpq %r12, %rdi
je 0x5605
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0x70(%rsp), %rdi
cmpq %r14, %rdi
je 0x561f
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x21f0
cmpq $0x0, 0x148(%rsp)
je 0x5715
leaq 0x2c71(%rip), %r12      # 0x82a6
leaq 0x2ad0(%rip), %r13      # 0x810c
movq %rsp, %rbp
leaq 0x90(%rsp), %rbx
leaq 0x2c59(%rip), %r14      # 0x82a7
movq %r15, %rdi
movq %r12, %rsi
callq 0x2070
testl %eax, %eax
je 0x569c
movq %r15, %rdi
movq %r14, %rsi
callq 0x2070
testl %eax, %eax
je 0x56f3
movq (%rsp), %rax
movq 0x8(%rsp), %rcx
cmpb $0x2f, -0x1(%rax,%rcx)
je 0x568b
movq %rbp, %rdi
movq %r13, %rsi
callq 0x23f0
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq %rbp, %rdi
callq 0x2080
jmp 0x56f3
movl $0x1, %ecx
movq %rbp, %rdi
movq %r13, %rsi
movq $-0x1, %rdx
callq 0x2430
movslq %eax, %rcx
movq %rbx, %rdi
movq %rbp, %rsi
xorl %edx, %edx
callq 0x2210
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x2280
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x56f3
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x21f0
cmpq $0x0, 0x8(%rsp)
jne 0x5706
movq %rbp, %rdi
movq %r13, %rsi
callq 0x23f0
cmpq $0x0, 0x28(%r15)
leaq 0x20(%r15), %r15
jne 0x564e
movq (%rsp), %rbx
movq 0x8(%rsp), %rdx
cmpb $0x2f, -0x1(%rbx,%rdx)
movq 0x48(%rsp), %r15
movq 0x40(%rsp), %rax
je 0x577e
movq (%rax), %rax
cmpq 0x8(%rax), %rdx
jne 0x574c
testq %rdx, %rdx
je 0x577e
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x2200
testl %eax, %eax
je 0x577e
leaq 0xb0(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2180
movl $0xf000, %eax           # imm = 0xF000
andl 0x18(%r14), %eax
cmpl $0x4000, %eax           # imm = 0x4000
jne 0x577e
leaq 0x2996(%rip), %rsi      # 0x810c
movq %rsp, %rdi
callq 0x23f0
movq %rsp, %rsi
movq %r15, %rdi
callq 0x20f0
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x57a4
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21f0
movq $-0x2000, %rbx          # imm = 0xE000
leaq 0x2130(%rsp), %r14
movq -0x10(%r14), %rdi
cmpq %rdi, %r14
je 0x57c7
movq (%r14), %rsi
incq %rsi
callq 0x21f0
addq $-0x20, %r14
addq $0x20, %rbx
jne 0x57b3
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x57ed
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x21f0
addq $0x2148, %rsp           # imm = 0x2148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x50(%rsp), %rdi
cmpq %r12, %rdi
je 0x581e
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0x581e
movq %rax, %rbx
movq 0x70(%rsp), %rdi
cmpq %r14, %rdi
je 0x5841
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0x5841
jmp 0x583e
jmp 0x583e
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x585c
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21f0
movq $-0x2000, %r14          # imm = 0xE000
leaq 0x2130(%rsp), %r15
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0x587f
movq (%r15), %rsi
incq %rsi
callq 0x21f0
addq $-0x20, %r15
addq $0x20, %r14
jne 0x586b
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x58a5
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x21f0
movq %rbx, %rdi
callq 0x23b0
nop