// File: /workspace/github_cpp_makefile_star2_O1/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, %r15
movl %edx, 0x2c(%rsp)
movl %esi, 0x28(%rsp)
movq %rdi, %r13
movq (%rcx), %rbx
movq 0x8(%rcx), %r14
movq %rbx, %rdi
callq 0x41b0
movq %r15, %rdi
xorl %esi, %esi
movq %r14, %rdx
movq %rbx, %rcx
movq %rax, %r8
callq 0x4660
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x4b0c(%rip), %rdx      # 0xf563
leaq 0x8(%rsp), %rdi
movq %rdx, %rsi
callq 0x9376
movq (%r15), %rax
cmpb $0x2f, (%rax)
je 0xac2c
leaq 0x40(%rsp), %r14
movq %r14, -0x10(%r14)
movq $0x0, -0x8(%r14)
movb $0x0, (%r14)
cmpl $-0x64, 0x2c(%rsp)
jne 0xaaf0
leaq 0x100(%rsp), %rdi
callq 0x4530
leaq 0x4c17(%rip), %rsi      # 0xf6b7
leaq 0x100(%rsp), %rdi
movl $0x6, %edx
callq 0x4460
leaq 0x100(%rsp), %rdi
movl 0x28(%rsp), %esi
callq 0x4760
leaq 0x4e1a(%rip), %rsi      # 0xf8e4
leaq 0x100(%rsp), %rdi
movl $0x4, %edx
callq 0x4460
leaq 0x108(%rsp), %rsi
leaq 0x50(%rsp), %rdi
callq 0x4690
jmp 0xab63
leaq 0x100(%rsp), %rdi
callq 0x4530
leaq 0x4bb3(%rip), %rsi      # 0xf6b7
leaq 0x100(%rsp), %rdi
movl $0x6, %edx
callq 0x4460
leaq 0x100(%rsp), %rdi
movl 0x28(%rsp), %esi
callq 0x4760
leaq 0x49d4(%rip), %rsi      # 0xf502
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 0xab8f
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x43e0
movq %r15, %rbp
movq 0x942f(%rip), %rsi      # 0x13fc8
leaq 0x100(%rsp), %rdi
callq 0x4220
leaq 0x170(%rsp), %rdi
callq 0x4160
leaq 0xf0(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
addq %rsi, %rdx
leaq 0xe0(%rsp), %rdi
callq 0x8ff2
leaq 0xe0(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0xa8e0
movl %eax, %ebx
movq 0xe0(%rsp), %rdi
cmpq %r15, %rdi
je 0xac0a
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x43e0
testb %bl, %bl
movq %rbp, %r15
je 0xb06a
movq 0x30(%rsp), %rdi
cmpq %r14, %rdi
je 0xac2c
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x43e0
movq %r13, 0xd0(%rsp)
leaq 0x100(%rsp), %rdi
movq %r15, 0xd8(%rsp)
movq %r15, %rsi
movl $0x18, %edx
callq 0x46a0
leaq 0x40(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x60(%rsp), %r14
leaq 0x30(%rsp), %r13
leaq 0x8(%rsp), %r15
leaq 0xb0(%rsp), %r12
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 0xaf77
movq %r13, %rdi
leaq 0x48b6(%rip), %rsi      # 0xf563
callq 0x4110
testl %eax, %eax
je 0xad7d
movq %r13, %rdi
leaq 0x4c26(%rip), %rsi      # 0xf8ea
callq 0x4110
testl %eax, %eax
je 0xad7d
movq %r13, %rdi
leaq 0x4c0e(%rip), %rsi      # 0xf8e9
callq 0x4110
testl %eax, %eax
je 0xad18
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rcx
cmpb $0x2f, -0x1(%rax,%rcx)
je 0xad04
movq %r15, %rdi
leaq 0x4980(%rip), %rsi      # 0xf67f
callq 0x47c0
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
movq %r15, %rdi
callq 0x4130
jmp 0xad7d
movq %r15, %rdi
movl $0x2f, %esi
movq $-0x1, %rdx
callq 0x47f0
cmpq $-0x1, %rax
je 0xad64
movq %r15, %rdi
movl $0x2f, %esi
movq $-0x1, %rdx
callq 0x47f0
movq 0x10(%rsp), %rcx
cmpq %rax, %rcx
jb 0xb0dd
movq %rax, 0x10(%rsp)
movq 0x8(%rsp), %rcx
movb $0x0, (%rcx,%rax)
jmp 0xad7d
movq 0x10(%rsp), %rdx
movq %r15, %rdi
xorl %esi, %esi
leaq 0x47ee(%rip), %rcx      # 0xf563
xorl %r8d, %r8d
callq 0x4660
movq %r14, 0x50(%rsp)
movq $0x0, 0x58(%rsp)
movb $0x0, 0x60(%rsp)
movq %r15, %rdi
leaq 0x4b52(%rip), %rsi      # 0xf8ec
callq 0x4110
movl %eax, %ebx
testl %eax, %eax
je 0xaddb
leaq 0xc0(%rsp), %rax
movq %rax, 0xb0(%rsp)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x8ff2
movq %r12, %rdi
leaq 0x50(%rsp), %rsi
callq 0xa8e0
movl %eax, %ebp
jmp 0xaddd
xorl %ebp, %ebp
testl %ebx, %ebx
je 0xae06
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
je 0xae06
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x43e0
testb %bpl, %bpl
je 0xaf57
movq 0x50(%rsp), %rax
cmpb $0x2f, (%rax)
je 0xaeb3
movq %r15, %rdi
movl $0x2f, %esi
movq $-0x1, %rdx
callq 0x47f0
cmpq $-0x1, %rax
je 0xaeb3
movq %r15, %rdi
movl $0x2f, %esi
movq $-0x1, %rdx
callq 0x47f0
movq 0x10(%rsp), %rcx
cmpq %rax, %rcx
jb 0xb0c5
movq %rax, 0x10(%rsp)
movq 0x8(%rsp), %rcx
movb $0x0, (%rcx,%rax)
leaq 0x70(%rsp), %rdi
leaq 0x480c(%rip), %rsi      # 0xf67f
leaq 0x50(%rsp), %rdx
callq 0xb2b9
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 0xaec0
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x43e0
jmp 0xaec0
movq %r15, %rdi
leaq 0x50(%rsp), %rsi
callq 0x4230
leaq 0xa0(%rsp), %rax
movq %rax, 0x90(%rsp)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0x90(%rsp), %rbx
movq %rbx, %rdi
callq 0x8ff2
leaq 0x70(%rsp), %rbp
movq %rbp, %rdi
movl 0x28(%rsp), %esi
movl 0x2c(%rsp), %edx
movq %rbx, %rcx
callq 0xaa05
movq %r15, %rdi
movq %rbp, %rsi
callq 0x44b0
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0xaf32
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x43e0
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0xaf57
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x43e0
movq 0x50(%rsp), %rdi
cmpq %r14, %rdi
je 0xac7c
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x43e0
jmp 0xac7c
movq 0xd8(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
cmpb $0x2f, -0x1(%rax,%rcx)
jne 0xafaf
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rcx
cmpb $0x2f, -0x1(%rax,%rcx)
je 0xafaf
leaq 0x46da(%rip), %rsi      # 0xf67f
leaq 0x8(%rsp), %rdi
callq 0x47c0
movq 0xd0(%rsp), %r13
leaq 0x10(%r13), %rax
movq %rax, (%r13)
movq 0x8(%rsp), %rcx
leaq 0x18(%rsp), %r12
cmpq %r12, %rcx
je 0xafdd
movq %rcx, (%r13)
movq 0x18(%rsp), %rax
movq %rax, 0x10(%r13)
jmp 0xafe5
movups (%r12), %xmm0
movups %xmm0, (%rax)
movq 0x10(%rsp), %rax
movq %rax, 0x8(%r13)
movq %r12, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movb $0x0, 0x18(%rsp)
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0xb01d
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x43e0
movq 0x8f6c(%rip), %rsi      # 0x13f90
leaq 0x100(%rsp), %rdi
callq 0x42d0
leaq 0x180(%rsp), %rdi
callq 0x4160
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0xb055
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 (%r15), %rdx
leaq 0x10(%r15), %rax
cmpq %rax, %rdx
je 0xb08b
movq %rdx, (%r13)
movq (%rax), %rcx
movq %rcx, 0x10(%r13)
jmp 0xb091
movups (%rax), %xmm0
movups %xmm0, (%rcx)
movq 0x8(%r15), %rcx
movq %rcx, 0x8(%r13)
movq %rax, (%r15)
movq $0x0, 0x8(%r15)
movb $0x0, 0x10(%r15)
movq 0x30(%rsp), %rdi
cmpq %r14, %rdi
je 0xb03e
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x43e0
jmp 0xb03e
leaq 0x482b(%rip), %rdi      # 0xf8f7
leaq 0x485b(%rip), %rsi      # 0xf92e
movq %rax, %rdx
xorl %eax, %eax
callq 0x4630
leaq 0x4813(%rip), %rdi      # 0xf8f7
leaq 0x4843(%rip), %rsi      # 0xf92e
movq %rax, %rdx
xorl %eax, %eax
callq 0x4630
jmp 0xb11b
jmp 0xb11b
movq %rax, %rbx
movq 0xe0(%rsp), %rdi
cmpq %r15, %rdi
je 0xb14e
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x43e0
jmp 0xb14e
movq %rax, %rbx
jmp 0xb14e
movq %rax, %rbx
jmp 0xb240
jmp 0xb12a
movq %rax, %rbx
movq 0x8e94(%rip), %rsi      # 0x13fc8
leaq 0x100(%rsp), %rdi
callq 0x4220
leaq 0x170(%rsp), %rdi
callq 0x4160
movq 0x30(%rsp), %rdi
cmpq %r14, %rdi
je 0xb240
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x43e0
jmp 0xb240
jmp 0xb200
jmp 0xb1e4
jmp 0xb1e4
movq %rax, %rbx
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0xb1e7
movq 0x80(%rsp), %rsi
jmp 0xb1da
movq %rax, %rbx
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0xb1e7
movq 0xa0(%rsp), %rsi
jmp 0xb1da
jmp 0xb1e4
movq %rax, %rbx
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
je 0xb1e7
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x43e0
jmp 0xb1e7
movq %rax, %rbx
movq 0x50(%rsp), %rdi
cmpq %r14, %rdi
je 0xb203
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x43e0
jmp 0xb203
movq %rax, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0xb21f
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x43e0
movq 0x8d6a(%rip), %rsi      # 0x13f90
leaq 0x100(%rsp), %rdi
callq 0x42d0
leaq 0x180(%rsp), %rdi
callq 0x4160
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0xb25c
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x43e0
movq %rbx, %rdi
callq 0x4770