// File: /workspace/github_cpp_makefile_star2_O1/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 0x553b
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 0x55a7
movq %rsp, %rdi
movq 0x8(%rdi), %rdx
leaq 0x2b74(%rip), %rcx      # 0x810c
movl $0x1, %r8d
xorl %esi, %esi
callq 0x2320
jmp 0x55b3
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 0x4e76
leaq 0x60(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x2b25(%rip), %rsi      # 0x810c
leaq 0x2b1f(%rip), %rdx      # 0x810d
leaq 0x50(%rsp), %rdi
callq 0x50f4
leaq 0x70(%rsp), %rsi
leaq 0x50(%rsp), %rdx
leaq 0x140(%rsp), %r15
movq %r15, %rcx
callq 0x6350
movq %rbp, 0x40(%rsp)
movq %r13, 0x48(%rsp)
movq 0x50(%rsp), %rdi
cmpq %r12, %rdi
je 0x5633
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0x70(%rsp), %rdi
cmpq %r14, %rdi
je 0x564d
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x21f0
cmpq $0x0, 0x148(%rsp)
je 0x5743
leaq 0x2c43(%rip), %r12      # 0x82a6
leaq 0x2aa2(%rip), %r13      # 0x810c
movq %rsp, %rbp
leaq 0x90(%rsp), %rbx
leaq 0x2c2b(%rip), %r14      # 0x82a7
movq %r15, %rdi
movq %r12, %rsi
callq 0x2070
testl %eax, %eax
je 0x56ca
movq %r15, %rdi
movq %r14, %rsi
callq 0x2070
testl %eax, %eax
je 0x5721
movq (%rsp), %rax
movq 0x8(%rsp), %rcx
cmpb $0x2f, -0x1(%rax,%rcx)
je 0x56b9
movq %rbp, %rdi
movq %r13, %rsi
callq 0x23f0
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq %rbp, %rdi
callq 0x2080
jmp 0x5721
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 0x5721
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x21f0
cmpq $0x0, 0x8(%rsp)
jne 0x5734
movq %rbp, %rdi
movq %r13, %rsi
callq 0x23f0
cmpq $0x0, 0x28(%r15)
leaq 0x20(%r15), %r15
jne 0x567c
movq (%rsp), %rbx
movq 0x8(%rsp), %rdx
cmpb $0x2f, -0x1(%rbx,%rdx)
movq 0x48(%rsp), %r15
movq 0x40(%rsp), %rax
je 0x57ac
movq (%rax), %rax
cmpq 0x8(%rax), %rdx
jne 0x577a
testq %rdx, %rdx
je 0x57ac
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x2200
testl %eax, %eax
je 0x57ac
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 0x57ac
leaq 0x2968(%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 0x57d2
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 0x57f5
movq (%r14), %rsi
incq %rsi
callq 0x21f0
addq $-0x20, %r14
addq $0x20, %rbx
jne 0x57e1
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x581b
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 0x584c
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0x584c
movq %rax, %rbx
movq 0x70(%rsp), %rdi
cmpq %r14, %rdi
je 0x586f
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0x586f
jmp 0x586c
jmp 0x586c
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x588a
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 0x58ad
movq (%r15), %rsi
incq %rsi
callq 0x21f0
addq $-0x20, %r15
addq $0x20, %r14
jne 0x5899
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x58d3
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x21f0
movq %rbx, %rdi
callq 0x23b0
nop