// File: demon386[P]git-store/./libs/filesystem/src/operations.cpp
// Function: boost::filesystem::detail::read_symlink(boost::filesystem::path const&, boost::system::error_code*)
BOOST_FILESYSTEM_DECL
  path read_symlink(const path& p, system::error_code* ec)
  {
    path symlink_path;

#   ifdef BOOST_POSIX_API

    for (std::size_t path_max = 64;; path_max *= 2)// loop 'til buffer large enough
    {
      boost::scoped_array<char> buf(new char[path_max]);
      ssize_t result;
      if ((result=::readlink(p.c_str(), buf.get(), path_max))== -1)
      {
        if (ec == 0)
          BOOST_FILESYSTEM_THROW(filesystem_error("boost::filesystem::read_symlink",
            p, error_code(errno, system_category())));
        else ec->assign(errno, system_category());
        break;
      }
      else
      {
        if(result != static_cast<ssize_t>(path_max))
        {
          symlink_path.assign(buf.get(), buf.get() + result);
          if (ec != 0) ec->clear();
          break;
        }
      }
    }

#   elif _WIN32_WINNT < 0x0600  // SDK earlier than Vista and Server 2008
    error(BOOST_ERROR_NOT_SUPPORTED, p, ec,
          "boost::filesystem::read_symlink");
#   else  // Vista and Server 2008 SDK, or later

    union info_t
    {
      char buf[REPARSE_DATA_BUFFER_HEADER_SIZE+MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
      REPARSE_DATA_BUFFER rdb;
    } info;

    handle_wrapper h(
      create_file_handle(p.c_str(), GENERIC_READ, 0, 0, OPEN_EXISTING,
        FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT, 0));

    if (error(h.handle == INVALID_HANDLE_VALUE ? BOOST_ERRNO : 0,
      p, ec, "boost::filesystem::read_symlink"))
        return symlink_path;

    DWORD sz;

    if (!error(::DeviceIoControl(h.handle, FSCTL_GET_REPARSE_POINT,
          0, 0, info.buf, sizeof(info), &sz, 0) == 0 ? BOOST_ERRNO : 0, p, ec,
          "boost::filesystem::read_symlink" ))
      symlink_path.assign(
        static_cast<wchar_t*>(info.rdb.SymbolicLinkReparseBuffer.PathBuffer)
        + info.rdb.SymbolicLinkReparseBuffer.PrintNameOffset/sizeof(wchar_t),
        static_cast<wchar_t*>(info.rdb.SymbolicLinkReparseBuffer.PathBuffer)
        + info.rdb.SymbolicLinkReparseBuffer.PrintNameOffset/sizeof(wchar_t)
        + info.rdb.SymbolicLinkReparseBuffer.PrintNameLength/sizeof(wchar_t));
#     endif
    return symlink_path;
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x98(%rbp)
movq %rdi, %rax
movq %rax, -0x90(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movb $0x0, -0x19(%rbp)
callq 0x4d620
movq $0x40, -0x28(%rbp)
movq -0x28(%rbp), %rdi
callq 0xd030
movq %rax, -0xa0(%rbp)
jmp 0x487bb
movq -0xa0(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x4dd00
movq -0x10(%rbp), %rdi
callq 0x4dc70
movq %rax, -0xa8(%rbp)
jmp 0x487dd
leaq -0x30(%rbp), %rdi
callq 0x4dd20
movq -0xa8(%rbp), %rdi
movq %rax, %rsi
movq -0x28(%rbp), %rdx
callq 0xd690
movq %rax, -0x48(%rbp)
cmpq $-0x1, %rax
jne 0x4896e
cmpq $0x0, -0x18(%rbp)
jne 0x48930
movb $0x1, -0x81(%rbp)
movl $0x50, %edi
callq 0xd2b0
movq %rax, -0xb8(%rbp)
leaq -0x69(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
callq 0xdb50
movq -0xb0(%rbp), %rdx
leaq 0x1a6f4(%rip), %rsi     # 0x62f3c
leaq -0x68(%rbp), %rdi
callq 0xd8b0
jmp 0x48853
movq -0x10(%rbp), %rax
movq %rax, -0xc0(%rbp)
callq 0xd070
movl (%rax), %eax
movl %eax, -0xc4(%rbp)
callq 0x53ec0
movl -0xc4(%rbp), %esi
movq %rax, %rdx
leaq -0x80(%rbp), %rdi
callq 0x4d680
movq -0xc0(%rbp), %rdx
movq -0xb8(%rbp), %rdi
movl -0x80(%rbp), %ecx
movq -0x78(%rbp), %r8
leaq -0x68(%rbp), %rsi
callq 0x4d6b0
movq -0xb8(%rbp), %rdi
movb $0x0, -0x81(%rbp)
leaq 0x44ca3(%rip), %rsi     # 0x8d558
leaq 0x4f04(%rip), %rdx      # 0x4d7c0
callq 0xdad0
jmp 0x48a5b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x48a46
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x48a0b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x4890b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x68(%rbp), %rdi
callq 0xdca8
leaq -0x69(%rbp), %rdi
callq 0xd6b0
testb $0x1, -0x81(%rbp)
jne 0x4891f
jmp 0x4892b
movq -0xb8(%rbp), %rdi
callq 0xd460
jmp 0x48a0b
movq -0x18(%rbp), %rax
movq %rax, -0xd0(%rbp)
callq 0xd070
movl (%rax), %eax
movl %eax, -0xc8(%rbp)
callq 0x53ec0
movq -0xd0(%rbp), %rdi
movl -0xc8(%rbp), %esi
movq %rax, %rdx
callq 0x4d800
movl $0x2, -0x88(%rbp)
jmp 0x489e2
movq -0x48(%rbp), %rax
cmpq -0x28(%rbp), %rax
je 0x489d6
leaq -0x30(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x4dd20
movq -0xe0(%rbp), %rdi
movq %rax, -0xd8(%rbp)
callq 0x4dd20
movq -0x98(%rbp), %rdi
movq -0xd8(%rbp), %rsi
movq %rax, %rdx
movq -0x48(%rbp), %rax
addq %rax, %rdx
callq 0x4de60
jmp 0x489ba
cmpq $0x0, -0x18(%rbp)
je 0x489ca
movq -0x18(%rbp), %rdi
callq 0x4d9e0
movl $0x2, -0x88(%rbp)
jmp 0x489e2
jmp 0x489d8
movl $0x0, -0x88(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x4dd70
movl -0x88(%rbp), %eax
testl %eax, %eax
je 0x489f9
jmp 0x489f7
jmp 0x48a16
jmp 0x489fb
movq -0x28(%rbp), %rax
shlq %rax
movq %rax, -0x28(%rbp)
jmp 0x487a9
leaq -0x30(%rbp), %rdi
callq 0x4dd70
jmp 0x48a46
movb $0x1, -0x19(%rbp)
movl $0x1, -0x88(%rbp)
testb $0x1, -0x19(%rbp)
jne 0x48a36
movq -0x98(%rbp), %rdi
callq 0x4d550
movq -0x90(%rbp), %rax
addq $0xe0, %rsp
popq %rbp
retq
movq -0x98(%rbp), %rdi
callq 0x4d550
movq -0x38(%rbp), %rdi
callq 0xdb30
nopl (%rax,%rax)