// File: demon386[P]git-store/./libs/filesystem/src/operations.cpp
// Function: boost::filesystem::detail::permissions(boost::filesystem::path const&, boost::filesystem::perms, boost::system::error_code*)
BOOST_FILESYSTEM_DECL
  void permissions(const path& p, perms prms, system::error_code* ec)
  {
    BOOST_ASSERT_MSG(!((prms & add_perms) && (prms & remove_perms)),
      "add_perms and remove_perms are mutually exclusive");

    if ((prms & add_perms) && (prms & remove_perms))  // precondition failed
      return;

# ifdef BOOST_POSIX_API
    error_code local_ec;
    file_status current_status((prms & symlink_perms)
                               ? fs::symlink_status(p, local_ec)
                               : fs::status(p, local_ec));
    if (local_ec)
    {
      if (ec == 0)
      BOOST_FILESYSTEM_THROW(filesystem_error(
          "boost::filesystem::permissions", p, local_ec));
      else
        *ec = local_ec;
      return;
    }

    if (prms & add_perms)
      prms |= current_status.permissions();
    else if (prms & remove_perms)
      prms = current_status.permissions() & ~prms;

    // Mac OS X Lion and some other platforms don't support fchmodat().
    // Solaris (SunPro and gcc) only support fchmodat() on Solaris 11 and higher,
    // and a runtime check is too much trouble.
    // Linux does not support permissions on symbolic links and has no plans to
    // support them in the future.  The chmod() code is thus more practical,
    // rather than always hitting ENOTSUP when sending in AT_SYMLINK_NO_FOLLOW.
    //  - See the 3rd paragraph of
    // "Symbolic link ownership, permissions, and timestamps" at:
    //   "http://man7.org/linux/man-pages/man7/symlink.7.html"
    //  - See the fchmodat() Linux man page:
    //   "http://man7.org/linux/man-pages/man2/fchmodat.2.html"
#   if defined(AT_FDCWD) && defined(AT_SYMLINK_NOFOLLOW) \
      && !(defined(__SUNPRO_CC) || defined(__sun) || defined(sun)) \
      && !(defined(linux) || defined(__linux) || defined(__linux__))
      if (::fchmodat(AT_FDCWD, p.c_str(), mode_cast(prms),
           !(prms & symlink_perms) ? 0 : AT_SYMLINK_NOFOLLOW))
#   else  // fallback if fchmodat() not supported
      if (::chmod(p.c_str(), mode_cast(prms)))
#   endif
    {
      if (ec == 0)
      BOOST_FILESYSTEM_THROW(filesystem_error(
          "boost::filesystem::permissions", p,
          error_code(errno, system::generic_category())));
      else
        ec->assign(errno, system::generic_category());
    }

# else  // Windows

    // if not going to alter FILE_ATTRIBUTE_READONLY, just return
    if (!(!((prms & (add_perms | remove_perms)))
      || (prms & (owner_write|group_write|others_write))))
      return;

    DWORD attr = ::GetFileAttributesW(p.c_str());

    if (error(attr == 0 ? BOOST_ERRNO : 0, p, ec, "boost::filesystem::permissions"))
      return;

    if (prms & add_perms)
      attr &= ~FILE_ATTRIBUTE_READONLY;
    else if (prms & remove_perms)
      attr |= FILE_ATTRIBUTE_READONLY;
    else if (prms & (owner_write|group_write|others_write))
      attr &= ~FILE_ATTRIBUTE_READONLY;
    else
      attr |= FILE_ATTRIBUTE_READONLY;

    error(::SetFileAttributesW(p.c_str(), attr) == 0 ? BOOST_ERRNO : 0,
      p, ec, "boost::filesystem::permissions");
# endif
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl -0xc(%rbp), %edi
movl $0x1000, %esi           # imm = 0x1000
callq 0x4ddc0
cmpl $0x0, %eax
je 0x4ae24
movl -0xc(%rbp), %edi
movl $0x2000, %esi           # imm = 0x2000
callq 0x4ddc0
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0xc2(%rbp)
jne 0x4ae2e
movb $0x1, %al
movb %al, -0xc2(%rbp)
jmp 0x4ae2e
movb -0xc2(%rbp), %al
testb $0x1, %al
jne 0x4ae3a
jmp 0x4ae3c
jmp 0x4ae5b
leaq 0x1801b(%rip), %rdi     # 0x62e5e
leaq 0x17cdd(%rip), %rsi     # 0x62b27
movl $0x562, %edx            # imm = 0x562
leaq 0x18070(%rip), %rcx     # 0x62ec6
callq 0xd400
movl -0xc(%rbp), %edi
movl $0x1000, %esi           # imm = 0x1000
callq 0x4ddc0
cmpl $0x0, %eax
je 0x4ae84
movl -0xc(%rbp), %edi
movl $0x2000, %esi           # imm = 0x2000
callq 0x4ddc0
cmpl $0x0, %eax
je 0x4ae84
jmp 0x4b1ad
leaq -0x28(%rbp), %rdi
callq 0x4d4a0
movl -0xc(%rbp), %edi
movl $0x4000, %esi           # imm = 0x4000
callq 0x4ddc0
cmpl $0x0, %eax
je 0x4aeb2
movq -0x8(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x4da10
movq %rax, -0x30(%rbp)
jmp 0x4aec3
movq -0x8(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x4d640
movq %rax, -0x30(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x4d830
cmpq $0x0, %rax
je 0x4afcb
cmpq $0x0, -0x18(%rbp)
jne 0x4afb3
movb $0x1, -0x81(%rbp)
movl $0x50, %edi
callq 0xd2b0
movq %rax, -0xd8(%rbp)
leaq -0x51(%rbp), %rdi
movq %rdi, -0xd0(%rbp)
callq 0xdb50
movq -0xd0(%rbp), %rdx
leaq 0x18006(%rip), %rsi     # 0x62f1d
leaq -0x50(%rbp), %rdi
callq 0xd8b0
jmp 0x4af22
movq -0xd8(%rbp), %rdi
movq -0x8(%rbp), %rdx
movups -0x28(%rbp), %xmm0
movaps %xmm0, -0x80(%rbp)
movl -0x80(%rbp), %ecx
movq -0x78(%rbp), %r8
leaq -0x50(%rbp), %rsi
callq 0x4d6b0
movq -0xd8(%rbp), %rdi
movb $0x0, -0x81(%rbp)
leaq 0x425fe(%rip), %rsi     # 0x8d558
leaq 0x285f(%rip), %rdx      # 0x4d7c0
callq 0xdad0
jmp 0x4b1bf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x4af8e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x50(%rbp), %rdi
callq 0xdca8
leaq -0x51(%rbp), %rdi
callq 0xd6b0
testb $0x1, -0x81(%rbp)
jne 0x4afa2
jmp 0x4afae
movq -0xd8(%rbp), %rdi
callq 0xd460
jmp 0x4b1b6
movq -0x18(%rbp), %rax
movq -0x28(%rbp), %rcx
movq %rcx, (%rax)
movq -0x20(%rbp), %rcx
movq %rcx, 0x8(%rax)
jmp 0x4b1ad
movl -0xc(%rbp), %edi
movl $0x1000, %esi           # imm = 0x1000
callq 0x4ddc0
cmpl $0x0, %eax
je 0x4aff3
leaq -0x30(%rbp), %rdi
callq 0x4de10
movl %eax, %esi
leaq -0xc(%rbp), %rdi
callq 0x4dde0
jmp 0x4b02e
movl -0xc(%rbp), %edi
movl $0x2000, %esi           # imm = 0x2000
callq 0x4ddc0
cmpl $0x0, %eax
je 0x4b02c
leaq -0x30(%rbp), %rdi
callq 0x4de10
movl %eax, -0xdc(%rbp)
movl -0xc(%rbp), %edi
callq 0x4de30
movl -0xdc(%rbp), %edi
movl %eax, %esi
callq 0x4ddc0
movl %eax, -0xc(%rbp)
jmp 0x4b02e
movq -0x8(%rbp), %rdi
callq 0x4dc70
movq %rax, -0xe8(%rbp)
movl -0xc(%rbp), %edi
callq 0x4de40
movq -0xe8(%rbp), %rdi
movl %eax, %esi
callq 0xd5a0
cmpl $0x0, %eax
je 0x4b1ad
cmpq $0x0, -0x18(%rbp)
jne 0x4b179
movb $0x1, -0xc1(%rbp)
movl $0x50, %edi
callq 0xd2b0
movq %rax, -0xf8(%rbp)
leaq -0xa9(%rbp), %rdi
movq %rdi, -0xf0(%rbp)
callq 0xdb50
movq -0xf0(%rbp), %rdx
leaq 0x17e7c(%rip), %rsi     # 0x62f1d
leaq -0xa8(%rbp), %rdi
callq 0xd8b0
jmp 0x4b0af
movq -0x8(%rbp), %rax
movq %rax, -0x100(%rbp)
callq 0xd070
movl (%rax), %eax
movl %eax, -0x104(%rbp)
callq 0x53e50
movl -0x104(%rbp), %esi
movq %rax, %rdx
leaq -0xc0(%rbp), %rdi
callq 0x4d680
movq -0x100(%rbp), %rdx
movq -0xf8(%rbp), %rdi
movl -0xc0(%rbp), %ecx
movq -0xb8(%rbp), %r8
leaq -0xa8(%rbp), %rsi
callq 0x4d6b0
movq -0xf8(%rbp), %rdi
movb $0x0, -0xc1(%rbp)
leaq 0x4243b(%rip), %rsi     # 0x8d558
leaq 0x269c(%rip), %rdx      # 0x4d7c0
callq 0xdad0
jmp 0x4b1bf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x4b154
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0xdca8
leaq -0xa9(%rbp), %rdi
callq 0xd6b0
testb $0x1, -0xc1(%rbp)
jne 0x4b16b
jmp 0x4b177
movq -0xf8(%rbp), %rdi
callq 0xd460
jmp 0x4b1b6
movq -0x18(%rbp), %rax
movq %rax, -0x110(%rbp)
callq 0xd070
movl (%rax), %eax
movl %eax, -0x108(%rbp)
callq 0x53e50
movq -0x110(%rbp), %rdi
movl -0x108(%rbp), %esi
movq %rax, %rdx
callq 0x4d800
jmp 0x4b1ad
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
movq -0x60(%rbp), %rdi
callq 0xdb30
nop