// File: /workspace/github_cpp_makefile_star2_O2/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, %r14
leaq 0x40(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movq %rsi, %rbx
movq %rdi, %r15
movb $0x0, (%rax)
pushq $0x10
popq %rax
leaq (%rsp,%rax), %rcx
addq $0x140, %rcx            # imm = 0x140
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
movb $0x0, (%rcx)
addq $0x20, %rax
cmpq $0x2010, %rax           # imm = 0x2010
jne 0x49fa
leaq 0x10(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x30(%rsp), %rdi
movq %rbx, %rsi
callq 0x2140
movq (%rbx), %rax
cmpb $0x2f, (%rax)
jne 0x4a54
leaq 0x16c2(%rip), %rsi      # 0x610c
movq %rsp, %rdi
callq 0x2410
jmp 0x4a60
movq 0x8(%r15), %rsi
movq %rsp, %rdi
callq 0x2140
leaq 0x70(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x22f0
leaq 0x1696(%rip), %rsi      # 0x610c
leaq 0x50(%rsp), %rdi
leaq 0x90(%rsp), %rdx
callq 0x4444
movq %r15, 0x20(%rsp)
movq %r14, 0x28(%rsp)
leaq 0x70(%rsp), %rsi
leaq 0x50(%rsp), %rdx
leaq 0x140(%rsp), %r15
movq %r15, %rcx
callq 0x5332
leaq 0x50(%rsp), %rdi
callq 0x2100
leaq 0x70(%rsp), %rdi
callq 0x2100
leaq 0x17df(%rip), %r12      # 0x62a6
leaq 0x163e(%rip), %r13      # 0x610c
movq %rsp, %rbp
leaq 0x90(%rsp), %r14
leaq 0x17c7(%rip), %rbx      # 0x62a7
cmpq $0x0, 0x8(%r15)
je 0x4b7e
movq %r15, %rdi
movq %r12, %rsi
callq 0x43fc
testb %al, %al
je 0x4b2d
movq %rbp, %rdi
movq %r13, %rsi
pushq $-0x1
popq %rdx
callq 0x2200
movslq %eax, %rcx
movq %r14, %rdi
movq %rbp, %rsi
xorl %edx, %edx
callq 0x2250
movq %rbp, %rdi
movq %r14, %rsi
callq 0x22b0
movq %r14, %rdi
callq 0x2100
jmp 0x4b62
movq %r15, %rdi
movq %rbx, %rsi
callq 0x5dba
testb %al, %al
je 0x4b62
movq (%rsp), %rax
movq 0x8(%rsp), %rcx
cmpb $0x2f, -0x1(%rax,%rcx)
je 0x4b57
movq %rbp, %rdi
movq %r13, %rsi
callq 0x2400
movq %rbp, %rdi
movq %r15, %rsi
callq 0x2430
cmpq $0x0, 0x8(%rsp)
jne 0x4b75
movq %rbp, %rdi
movq %r13, %rsi
callq 0x2400
addq $0x20, %r15
jmp 0x4ae0
movq (%rsp), %rax
movq 0x8(%rsp), %rcx
cmpb $0x2f, -0x1(%rax,%rcx)
movq 0x28(%rsp), %r14
movq 0x20(%rsp), %rax
je 0x4bd9
movq (%rax), %rsi
movq %rsp, %rdi
callq 0x43f2
testb %al, %al
je 0x4bd9
movq (%rsp), %rdi
leaq 0xb0(%rsp), %rbx
movq %rbx, %rsi
callq 0x21d0
movl $0xf000, %eax           # imm = 0xF000
andl 0x18(%rbx), %eax
cmpl $0x4000, %eax           # imm = 0x4000
jne 0x4bd9
leaq 0x153b(%rip), %rsi      # 0x610c
movq %rsp, %rdi
callq 0x2400
movq %rsp, %rsi
movq %r14, %rdi
callq 0x2140
movq %rsp, %rdi
callq 0x2100
movl $0x1fe0, %ebx           # imm = 0x1FE0
leaq (%rsp,%rbx), %rdi
addq $0x140, %rdi            # imm = 0x140
callq 0x2100
addq $-0x20, %rbx
cmpq $-0x20, %rbx
jne 0x4bf1
leaq 0x30(%rsp), %rdi
callq 0x2100
addq $0x2148, %rsp           # imm = 0x2148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x2100
jmp 0x4c39
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x2100
jmp 0x4c4c
jmp 0x4c49
jmp 0x4c49
movq %rax, %rbx
movq %rsp, %rdi
callq 0x2100
movl $0x1fe0, %r14d          # imm = 0x1FE0
leaq (%rsp,%r14), %rdi
addq $0x140, %rdi            # imm = 0x140
callq 0x2100
addq $-0x20, %r14
cmpq $-0x20, %r14
jne 0x4c5a
leaq 0x30(%rsp), %rdi
callq 0x2100
movq %rbx, %rdi
callq 0x23d0