// File: /workspace/github_cpp_makefile_star2_O3/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, %rbp
movl %edx, 0x2c(%rsp)
movl %esi, 0x28(%rsp)
movq %rdi, %r13
movq (%rcx), %rbx
movq 0x8(%rcx), %r14
movq %rbx, %rdi
callq 0x41b0
movq %rbp, %rdi
xorl %esi, %esi
movq %r14, %rdx
movq %rbx, %rcx
movq %rax, %r8
callq 0x4660
leaq 0x18(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x3cdd(%rip), %rdx      # 0xe563
leaq 0x8(%rsp), %rdi
movq %rdx, %rsi
callq 0x9234
movq (%rbp), %rax
cmpb $0x2f, (%rax)
je 0xaa57
leaq 0x40(%rsp), %r15
movq %r15, -0x10(%r15)
movq $0x0, -0x8(%r15)
movb $0x0, (%r15)
cmpl $-0x64, 0x2c(%rsp)
jne 0xa920
leaq 0x100(%rsp), %rdi
callq 0x4530
leaq 0x3de7(%rip), %rsi      # 0xe6b7
leaq 0x100(%rsp), %rdi
movl $0x6, %edx
callq 0x4460
leaq 0x100(%rsp), %rdi
movl 0x28(%rsp), %esi
callq 0x4760
leaq 0x3fea(%rip), %rsi      # 0xe8e4
leaq 0x100(%rsp), %rdi
movl $0x4, %edx
callq 0x4460
leaq 0x108(%rsp), %rsi
leaq 0x50(%rsp), %rdi
callq 0x4690
jmp 0xa993
leaq 0x100(%rsp), %rdi
callq 0x4530
leaq 0x3d83(%rip), %rsi      # 0xe6b7
leaq 0x100(%rsp), %rdi
movl $0x6, %edx
callq 0x4460
leaq 0x100(%rsp), %rdi
movl 0x28(%rsp), %esi
callq 0x4760
leaq 0x3ba4(%rip), %rsi      # 0xe502
leaq 0x100(%rsp), %rdi
movl $0x4, %edx
callq 0x4460
leaq 0x100(%rsp), %rdi
movl 0x2c(%rsp), %esi
callq 0x4760
leaq 0x108(%rsp), %rsi
leaq 0x50(%rsp), %rdi
callq 0x4690
leaq 0x30(%rsp), %rdi
leaq 0x50(%rsp), %rbx
movq %rbx, %rsi
callq 0x44b0
movq (%rbx), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0xa9bf
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x43e0
movq 0x8602(%rip), %rsi      # 0x12fc8
leaq 0x100(%rsp), %rdi
callq 0x4220
leaq 0x170(%rsp), %rdi
callq 0x4160
leaq 0xf0(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
addq %rsi, %rdx
leaq 0xe0(%rsp), %rdi
callq 0x8eda
leaq 0xe0(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0xa710
movl %eax, %ebx
movq 0xe0(%rsp), %rdi
cmpq %r12, %rdi
je 0xaa38
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x43e0
testb %bl, %bl
je 0xae9e
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0xaa57
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x43e0
movq %r13, 0x90(%rsp)
leaq 0x100(%rsp), %rdi
movq %rbp, 0xd8(%rsp)
movq %rbp, %rsi
movl $0x18, %edx
callq 0x46a0
leaq 0x40(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x60(%rsp), %r12
leaq 0x30(%rsp), %r13
leaq 0x8(%rsp), %r15
leaq 0xb8(%rsp), %rbp
leaq 0x100(%rsp), %rdi
movq %r13, %rsi
movl $0x2f, %edx
callq 0x47a0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0xad9d
movq %r13, %rdi
leaq 0x3a8b(%rip), %rsi      # 0xe563
callq 0x4110
testl %eax, %eax
je 0xaba8
movq %r13, %rdi
leaq 0x3dfb(%rip), %rsi      # 0xe8ea
callq 0x4110
testl %eax, %eax
je 0xaba8
movq %r13, %rdi
leaq 0x3de3(%rip), %rsi      # 0xe8e9
callq 0x4110
testl %eax, %eax
je 0xab43
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rcx
cmpb $0x2f, -0x1(%rax,%rcx)
je 0xab2f
movq %r15, %rdi
leaq 0x3b55(%rip), %rsi      # 0xe67f
callq 0x47c0
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
movq %r15, %rdi
callq 0x4130
jmp 0xaba8
movq %r15, %rdi
movl $0x2f, %esi
movq $-0x1, %rdx
callq 0x47f0
cmpq $-0x1, %rax
je 0xab8f
movq %r15, %rdi
movl $0x2f, %esi
movq $-0x1, %rdx
callq 0x47f0
movq 0x10(%rsp), %rcx
cmpq %rax, %rcx
jb 0xaf12
movq %rax, 0x10(%rsp)
movq 0x8(%rsp), %rcx
movb $0x0, (%rcx,%rax)
jmp 0xaba8
movq 0x10(%rsp), %rdx
movq %r15, %rdi
xorl %esi, %esi
leaq 0x39c3(%rip), %rcx      # 0xe563
xorl %r8d, %r8d
callq 0x4660
movq %r12, 0x50(%rsp)
movq $0x0, 0x58(%rsp)
movb $0x0, 0x60(%rsp)
movq %r15, %rdi
leaq 0x3d27(%rip), %rsi      # 0xe8ec
callq 0x4110
testl %eax, %eax
je 0xad7d
leaq 0xc8(%rsp), %rax
movq %rax, 0xb8(%rsp)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
movq %rbp, %rdi
callq 0x8eda
movq %rbp, %rdi
leaq 0x50(%rsp), %rsi
callq 0xa710
movl %eax, %r14d
movq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0xac2c
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x43e0
testb %r14b, %r14b
je 0xad7d
movq 0x50(%rsp), %rax
cmpb $0x2f, (%rax)
je 0xacd9
movq %r15, %rdi
movl $0x2f, %esi
movq $-0x1, %rdx
callq 0x47f0
cmpq $-0x1, %rax
je 0xacd9
movq %r15, %rdi
movl $0x2f, %esi
movq $-0x1, %rdx
callq 0x47f0
movq 0x10(%rsp), %rcx
cmpq %rax, %rcx
jb 0xaefa
movq %rax, 0x10(%rsp)
movq 0x8(%rsp), %rcx
movb $0x0, (%rcx,%rax)
leaq 0x70(%rsp), %rdi
leaq 0x39e6(%rip), %rsi      # 0xe67f
leaq 0x50(%rsp), %rdx
callq 0xb0f0
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rdx
movq %r15, %rdi
callq 0x4130
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0xace6
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x43e0
jmp 0xace6
movq %r15, %rdi
leaq 0x50(%rsp), %rsi
callq 0x4230
leaq 0xa8(%rsp), %rax
movq %rax, 0x98(%rsp)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0x98(%rsp), %r14
movq %r14, %rdi
callq 0x8eda
leaq 0x70(%rsp), %rbx
movq %rbx, %rdi
movl 0x28(%rsp), %esi
movl 0x2c(%rsp), %edx
movq %r14, %rcx
callq 0xa835
movq %r15, %rdi
movq %rbx, %rsi
callq 0x44b0
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0xad58
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x43e0
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0xad7d
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x43e0
movq 0x50(%rsp), %rdi
cmpq %r12, %rdi
je 0xaaa7
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x43e0
jmp 0xaaa7
movq 0xd8(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
cmpb $0x2f, -0x1(%rax,%rcx)
movq 0x8(%rsp), %rax
jne 0xade9
movq 0x10(%rsp), %rcx
cmpb $0x2f, -0x1(%rax,%rcx)
leaq 0x18(%rsp), %r14
movq 0x90(%rsp), %r13
je 0xadf6
leaq 0x38a7(%rip), %rsi      # 0xe67f
leaq 0x8(%rsp), %rdi
callq 0x47c0
movq 0x8(%rsp), %rax
jmp 0xadf6
leaq 0x18(%rsp), %r14
movq 0x90(%rsp), %r13
leaq 0x10(%r13), %rcx
movq %rcx, (%r13)
cmpq %r14, %rax
je 0xae12
movq %rax, (%r13)
movq 0x18(%rsp), %rax
movq %rax, 0x10(%r13)
jmp 0xae19
movups (%r14), %xmm0
movups %xmm0, (%rcx)
movq 0x10(%rsp), %rax
movq %rax, 0x8(%r13)
movq %r14, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movb $0x0, 0x18(%rsp)
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0xae51
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x43e0
movq 0x8138(%rip), %rsi      # 0x12f90
leaq 0x100(%rsp), %rdi
callq 0x42d0
leaq 0x180(%rsp), %rdi
callq 0x4160
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0xae89
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x43e0
movq %r13, %rax
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x10(%r13), %rcx
movq %rcx, (%r13)
movq (%rbp), %rdx
leaq 0x10(%rbp), %rax
cmpq %rax, %rdx
je 0xaec0
movq %rdx, (%r13)
movq (%rax), %rcx
movq %rcx, 0x10(%r13)
jmp 0xaec6
movups (%rax), %xmm0
movups %xmm0, (%rcx)
movq 0x8(%rbp), %rcx
movq %rcx, 0x8(%r13)
movq %rax, (%rbp)
movq $0x0, 0x8(%rbp)
movb $0x0, 0x10(%rbp)
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0xae72
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x43e0
jmp 0xae72
leaq 0x39f6(%rip), %rdi      # 0xe8f7
leaq 0x3a26(%rip), %rsi      # 0xe92e
movq %rax, %rdx
xorl %eax, %eax
callq 0x4630
leaq 0x39de(%rip), %rdi      # 0xe8f7
leaq 0x3a0e(%rip), %rsi      # 0xe92e
movq %rax, %rdx
xorl %eax, %eax
callq 0x4630
jmp 0xaf50
jmp 0xaf50
movq %rax, %r14
movq 0xe0(%rsp), %rdi
cmpq %r12, %rdi
je 0xaf83
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x43e0
jmp 0xaf83
movq %rax, %r14
jmp 0xaf83
movq %rax, %r14
jmp 0xb072
jmp 0xaf5f
movq %rax, %r14
movq 0x805f(%rip), %rsi      # 0x12fc8
leaq 0x100(%rsp), %rdi
callq 0x4220
leaq 0x170(%rsp), %rdi
callq 0x4160
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0xb072
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x43e0
jmp 0xb072
jmp 0xb016
jmp 0xb016
movq %rax, %r14
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0xb019
movq 0x80(%rsp), %rsi
jmp 0xb00c
jmp 0xb032
movq %rax, %r14
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0xb019
movq 0xa8(%rsp), %rsi
jmp 0xb00c
jmp 0xb016
movq %rax, %r14
movq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0xb019
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x43e0
jmp 0xb019
movq %rax, %r14
movq 0x50(%rsp), %rdi
cmpq %r12, %rdi
je 0xb035
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x43e0
jmp 0xb035
movq %rax, %r14
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0xb051
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x43e0
movq 0x7f38(%rip), %rsi      # 0x12f90
leaq 0x100(%rsp), %rdi
callq 0x42d0
leaq 0x180(%rsp), %rdi
callq 0x4160
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0xb08e
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x43e0
movq %r14, %rdi
callq 0x4770