// File: /workspace/github_cpp_makefile_star2_O2/mniip[P]sandbox/path.cpp
// Function: canon_path_at(int, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
std::string canon_path_at(pid_t tid, int fd, std::string path)
{
	path = path.c_str();
	std::string real = "";
	if(*path.begin() != '/')
	{
		std::string proc;
		if(fd == AT_FDCWD)
			proc = ((std::ostringstream &)(std::ostringstream() << "/proc/" << tid << "/cwd")).str();
		else
			proc = ((std::ostringstream &)(std::ostringstream() << "/proc/" << tid << "/fd/" << fd)).str();
		if(!read_link(proc, real))
			return path;
	}

	std::stringstream s(path);
	std::string segment;
	while(std::getline(s, segment, '/'))
	{
		if(segment != "" && segment != ".")
		{
			if(segment != "..")
			{
				if(*real.rbegin() != '/')
					real += "/";
				real += segment;
			}
			else
				if(real.rfind('/') == std::string::npos)
					real = "";
				else
					real.erase(real.rfind('/'), std::string::npos);
		}
		std::string link;
		if(real != "/proc/self" && read_link(real, link))
		{
			if(*link.begin() == '/')
				real = link;
			else
				if(real.rfind('/') == std::string::npos)
					real = link;
				else
				{
					real.erase(real.rfind('/'), std::string::npos);
					real += "/" + link;
				}
			real = canon_path_at(tid, fd, real);
		}
	}
	if(*path.rbegin() == '/' && *real.rbegin() != '/')
		real += "/";
	return real;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x288, %rsp            # imm = 0x288
movq %rcx, %r14
movl %edx, 0xc(%rsp)
movl %esi, 0x8(%rsp)
movq %rdi, 0x30(%rsp)
movq (%rcx), %rsi
movq %rcx, %rdi
callq 0x47d0
leaq 0x3350(%rip), %rsi      # 0xc563
leaq 0x10(%rsp), %rdi
leaq 0x100(%rsp), %rdx
callq 0x5422
movq (%r14), %rax
cmpb $0x2f, (%rax)
je 0x9378
leaq 0x68(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
cmpl $-0x64, 0xc(%rsp)
jne 0x92a3
leaq 0x100(%rsp), %rdi
callq 0x4560
leaq 0x345a(%rip), %rsi      # 0xc6b7
leaq 0x100(%rsp), %rdi
callq 0x4400
leaq 0x100(%rsp), %rdi
movl 0x8(%rsp), %esi
callq 0x4760
leaq 0x3662(%rip), %rsi      # 0xc8e4
leaq 0x100(%rsp), %rdi
callq 0x4400
leaq 0x108(%rsp), %rsi
leaq 0x38(%rsp), %rdi
callq 0x4690
jmp 0x930c
leaq 0x100(%rsp), %rdi
callq 0x4560
leaq 0x3400(%rip), %rsi      # 0xc6b7
leaq 0x100(%rsp), %rdi
callq 0x4400
leaq 0x100(%rsp), %rdi
movl 0x8(%rsp), %esi
callq 0x4760
leaq 0x3226(%rip), %rsi      # 0xc502
leaq 0x100(%rsp), %rdi
callq 0x4400
leaq 0x100(%rsp), %rdi
movl 0xc(%rsp), %esi
callq 0x4760
leaq 0x108(%rsp), %rsi
leaq 0x38(%rsp), %rdi
callq 0x4690
leaq 0x58(%rsp), %rdi
leaq 0x38(%rsp), %rbx
movq %rbx, %rsi
callq 0x44c0
movq %rbx, %rdi
callq 0x4828
leaq 0x100(%rsp), %rdi
callq 0x40f0
leaq 0x80(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x4590
leaq 0x80(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x90e8
movl %eax, %ebx
leaq 0x80(%rsp), %rdi
callq 0x4828
testb %bl, %bl
je 0x964b
leaq 0x58(%rsp), %rdi
callq 0x4828
leaq 0x100(%rsp), %rdi
pushq $0x18
popq %rdx
movq %r14, 0x78(%rsp)
movq %r14, %rsi
callq 0x46a0
leaq 0x68(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x58(%rsp), %r13
leaq 0x10(%rsp), %rbp
leaq 0xe0(%rsp), %r15
leaq 0x38(%rsp), %r12
leaq 0x100(%rsp), %rdi
movq %r13, %rsi
pushq $0x2f
popq %rdx
callq 0x47a0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x95b5
movq %r13, %rdi
leaq 0x317c(%rip), %rsi      # 0xc563
callq 0x9767
testb %al, %al
je 0x9491
movq %r13, %rdi
leaq 0x34ec(%rip), %rsi      # 0xc8ea
callq 0x9767
testb %al, %al
je 0x9491
movq %r13, %rdi
leaq 0x34d4(%rip), %rsi      # 0xc8e9
callq 0x9767
testb %al, %al
je 0x944b
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
cmpb $0x2f, -0x1(%rax,%rcx)
je 0x943e
movq %rbp, %rdi
leaq 0x3246(%rip), %rsi      # 0xc67f
callq 0x47c0
movq %rbp, %rdi
movq %r13, %rsi
callq 0x47f0
jmp 0x9491
movq %rbp, %rdi
pushq $0x2f
popq %rbx
movl %ebx, %esi
pushq $-0x1
popq %r14
movq %r14, %rdx
callq 0x4810
cmpq $-0x1, %rax
je 0x9482
movq %rbp, %rdi
movl %ebx, %esi
movq %r14, %rdx
callq 0x4810
movq %rbp, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x40e0
jmp 0x9491
movq %rbp, %rdi
leaq 0x30d7(%rip), %rsi      # 0xc563
callq 0x47d0
leaq 0x48(%rsp), %rax
movq %rax, 0x38(%rsp)
andq $0x0, 0x40(%rsp)
movb $0x0, 0x48(%rsp)
movq %rbp, %rdi
leaq 0x343c(%rip), %rsi      # 0xc8ec
callq 0x9767
testb %al, %al
je 0x95a8
movq %r15, %rdi
movq %rbp, %rsi
callq 0x4590
movq %r15, %rdi
movq %r12, %rsi
callq 0x90e8
movl %eax, %r14d
movq %r15, %rdi
callq 0x4828
testb %r14b, %r14b
je 0x95a8
movq 0x38(%rsp), %rax
cmpb $0x2f, (%rax)
je 0x9554
movq %rbp, %rdi
pushq $0x2f
popq %rsi
pushq $-0x1
popq %rdx
callq 0x4810
cmpq $-0x1, %rax
je 0x9554
movq %rbp, %rdi
pushq $0x2f
popq %rsi
pushq $-0x1
popq %r14
movq %r14, %rdx
callq 0x4810
movq %rbp, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x40e0
leaq 0xa0(%rsp), %r14
movq %r14, %rdi
leaq 0x3148(%rip), %rsi      # 0xc67f
movq %r12, %rdx
callq 0x9771
movq %rbp, %rdi
movq %r14, %rsi
callq 0x47f0
movq %r14, %rdi
callq 0x4828
jmp 0x955f
movq %rbp, %rdi
movq %r12, %rsi
callq 0x4260
leaq 0xc0(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
callq 0x4590
leaq 0xa0(%rsp), %rbx
movq %rbx, %rdi
movl 0x8(%rsp), %esi
movl 0xc(%rsp), %edx
movq %r14, %rcx
callq 0x91e0
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x44c0
movq %rbx, %rdi
callq 0x4828
movq %r14, %rdi
callq 0x4828
movq %r12, %rdi
callq 0x4828
jmp 0x93b8
movq 0x78(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
cmpb $0x2f, -0x1(%rax,%rcx)
movq 0x10(%rsp), %rax
jne 0x95ef
movq 0x18(%rsp), %rcx
cmpb $0x2f, -0x1(%rax,%rcx)
je 0x95ef
leaq 0x309f(%rip), %rsi      # 0xc67f
leaq 0x10(%rsp), %rdi
callq 0x47c0
movq 0x10(%rsp), %rax
movq 0x30(%rsp), %rbx
leaq 0x10(%rbx), %rdx
movq %rdx, (%rbx)
leaq 0x20(%rsp), %rcx
cmpq %rcx, %rax
je 0x9613
movq %rax, (%rbx)
movq 0x20(%rsp), %rax
movq %rax, 0x10(%rbx)
jmp 0x9619
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
movq 0x18(%rsp), %rax
movq %rax, 0x8(%rbx)
movq %rcx, 0x10(%rsp)
andq $0x0, 0x18(%rsp)
movb $0x0, 0x20(%rsp)
leaq 0x58(%rsp), %rdi
callq 0x4828
leaq 0x100(%rsp), %rdi
callq 0x4300
jmp 0x9665
movq 0x30(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4500
leaq 0x58(%rsp), %rdi
callq 0x4828
leaq 0x10(%rsp), %rdi
callq 0x4828
movq %rbx, %rax
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x9703
jmp 0x969c
jmp 0x969c
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x4828
jmp 0x96b8
movq %rax, %rbx
jmp 0x96b8
movq %rax, %rbx
jmp 0x971d
jmp 0x96a8
movq %rax, %rbx
leaq 0x100(%rsp), %rdi
callq 0x40f0
leaq 0x58(%rsp), %rdi
callq 0x4828
jmp 0x971d
jmp 0x96f4
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
jmp 0x96ed
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
jmp 0x96ed
jmp 0x96f4
movq %rax, %rbx
leaq 0xe0(%rsp), %rdi
callq 0x4828
jmp 0x96f7
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x4828
jmp 0x9706
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x4828
leaq 0x100(%rsp), %rdi
callq 0x4300
leaq 0x10(%rsp), %rdi
callq 0x4828
movq %rbx, %rdi
callq 0x4770