// File: 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
movq %rsp, %rbp
subq $0x2210, %rsp           # imm = 0x2210
movq %rsi, -0x2188(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x2180(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x3430
leaq -0x2040(%rbp), %rax
movq %rax, %rcx
addq $0x2000, %rcx           # imm = 0x2000
movq %rcx, -0x2178(%rbp)
movq %rax, -0x2170(%rbp)
movq -0x2170(%rbp), %rdi
movq %rdi, -0x2190(%rbp)
callq 0x3430
movq -0x2190(%rbp), %rax
movq -0x2178(%rbp), %rcx
addq $0x20, %rax
cmpq %rcx, %rax
movq %rax, -0x2170(%rbp)
jne 0x8d41
leaq -0x2060(%rbp), %rdi
callq 0x3430
movq -0x2188(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0x3050
jmp 0x8d90
movq -0x2188(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x35c0
movq %rax, -0x2198(%rbp)
jmp 0x8da9
movq -0x2198(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2f, %eax
je 0x8dea
movq -0x2180(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0x2060(%rbp), %rdi
callq 0x3050
jmp 0x8dd1
jmp 0x8e01
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20f8(%rbp)
movl %eax, -0x20fc(%rbp)
jmp 0x9197
leaq 0x331b(%rip), %rsi      # 0xc10c
leaq -0x2060(%rbp), %rdi
callq 0x3420
jmp 0x8dff
jmp 0x8e01
leaq -0x2120(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x3120
jmp 0x8e13
leaq -0x2141(%rbp), %rdi
movq %rdi, -0x21a0(%rbp)
callq 0x3540
movq -0x21a0(%rbp), %rdx
leaq 0x32d8(%rip), %rsi      # 0xc10c
leaq -0x2140(%rbp), %rdi
callq 0x6e60
jmp 0x8e42
movq -0x2180(%rbp), %rdi
leaq -0x2120(%rbp), %rsi
leaq -0x2140(%rbp), %rdx
leaq -0x2040(%rbp), %rcx
callq 0x9ff0
jmp 0x8e65
leaq -0x2140(%rbp), %rdi
callq 0x3180
leaq -0x2141(%rbp), %rdi
callq 0x3300
leaq -0x2120(%rbp), %rdi
callq 0x3180
movl $0x0, -0x1c(%rbp)
movslq -0x1c(%rbp), %rax
leaq -0x2040(%rbp), %rdi
shlq $0x5, %rax
addq %rax, %rdi
callq 0x3510
xorb $-0x1, %al
testb $0x1, %al
jne 0x8eb2
jmp 0x907c
movslq -0x1c(%rbp), %rax
shlq $0x5, %rax
leaq -0x2040(%rbp,%rax), %rdi
leaq 0x33dd(%rip), %rsi      # 0xc2a6
callq 0x6c90
movb %al, -0x21a1(%rbp)
jmp 0x8ed6
movb -0x21a1(%rbp), %al
testb $0x1, %al
jne 0x8ee5
jmp 0x8f9f
leaq 0x3220(%rip), %rsi      # 0xc10c
leaq -0x2060(%rbp), %rdi
movq %rdi, -0x21b0(%rbp)
movq $-0x1, %rdx
callq 0x3270
movq -0x21b0(%rbp), %rsi
movl %eax, -0x2148(%rbp)
movslq -0x2148(%rbp), %rcx
xorl %eax, %eax
movl %eax, %edx
leaq -0x2168(%rbp), %rdi
callq 0x32d0
jmp 0x8f2c
leaq -0x2060(%rbp), %rdi
leaq -0x2168(%rbp), %rsi
callq 0x3390
leaq -0x2168(%rbp), %rdi
callq 0x3180
jmp 0x9045
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20f8(%rbp)
movl %eax, -0x20fc(%rbp)
jmp 0x8f82
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20f8(%rbp)
movl %eax, -0x20fc(%rbp)
leaq -0x2140(%rbp), %rdi
callq 0x3180
leaq -0x2141(%rbp), %rdi
callq 0x3300
leaq -0x2120(%rbp), %rdi
callq 0x3180
jmp 0x9197
movslq -0x1c(%rbp), %rax
shlq $0x5, %rax
leaq -0x2040(%rbp,%rax), %rdi
leaq 0x32f1(%rip), %rsi      # 0xc2a7
callq 0xb610
movb %al, -0x21b1(%rbp)
jmp 0x8fc3
movb -0x21b1(%rbp), %al
testb $0x1, %al
jne 0x8fcf
jmp 0x9043
leaq -0x2060(%rbp), %rdi
movq %rdi, -0x21c8(%rbp)
callq 0x3470
movq -0x21c8(%rbp), %rdi
movq %rax, %rsi
decq %rsi
callq 0x35c0
movq %rax, -0x21c0(%rbp)
jmp 0x8ffd
movq -0x21c0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2f, %eax
je 0x9023
leaq 0x30f9(%rip), %rsi      # 0xc10c
leaq -0x2060(%rbp), %rdi
callq 0x3280
jmp 0x9021
jmp 0x9023
movslq -0x1c(%rbp), %rax
shlq $0x5, %rax
leaq -0x2040(%rbp,%rax), %rsi
leaq -0x2060(%rbp), %rdi
callq 0x33c0
jmp 0x9041
jmp 0x9043
jmp 0x9045
leaq -0x2060(%rbp), %rdi
callq 0x3470
cmpq $0x0, %rax
ja 0x906e
leaq 0x30ae(%rip), %rsi      # 0xc10c
leaq -0x2060(%rbp), %rdi
callq 0x3280
jmp 0x906c
jmp 0x906e
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x8e90
leaq -0x2060(%rbp), %rdi
movq %rdi, -0x21d8(%rbp)
callq 0x31a0
movq -0x21d8(%rbp), %rdi
movq %rax, %rsi
decq %rsi
callq 0x35c0
movq %rax, -0x21d0(%rbp)
jmp 0x90aa
movq -0x21d0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2f, %eax
je 0x911b
movq -0x2180(%rbp), %rax
movq (%rax), %rsi
leaq -0x2060(%rbp), %rdi
callq 0x6c60
testb $0x1, %al
jne 0x90d5
jmp 0x911b
leaq -0x2060(%rbp), %rdi
callq 0x3110
movq %rax, %rdi
leaq -0x20f0(%rbp), %rsi
callq 0x3240
movl -0x20d8(%rbp), %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0x4000, %eax           # imm = 0x4000
jne 0x9119
leaq 0x3003(%rip), %rsi      # 0xc10c
leaq -0x2060(%rbp), %rdi
callq 0x3280
jmp 0x9117
jmp 0x9119
jmp 0x911b
movq -0x18(%rbp), %rdi
leaq -0x2060(%rbp), %rsi
callq 0x3050
jmp 0x912d
leaq -0x2060(%rbp), %rdi
callq 0x3180
leaq -0x2040(%rbp), %rax
movq %rax, -0x21e8(%rbp)
addq $0x2000, %rax           # imm = 0x2000
movq %rax, -0x21e0(%rbp)
movq -0x21e0(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x21f0(%rbp)
callq 0x3180
movq -0x21e8(%rbp), %rcx
movq -0x21f0(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x21e0(%rbp)
jne 0x9154
leaq -0x40(%rbp), %rdi
callq 0x3180
addq $0x2210, %rsp           # imm = 0x2210
popq %rbp
retq
leaq -0x2060(%rbp), %rdi
callq 0x3180
leaq -0x2040(%rbp), %rax
movq %rax, -0x2200(%rbp)
addq $0x2000, %rax           # imm = 0x2000
movq %rax, -0x21f8(%rbp)
movq -0x21f8(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x2208(%rbp)
callq 0x3180
movq -0x2200(%rbp), %rcx
movq -0x2208(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x21f8(%rbp)
jne 0x91be
leaq -0x40(%rbp), %rdi
callq 0x3180
movq -0x20f8(%rbp), %rdi
callq 0x3530
nopw %cs:(%rax,%rax)