// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x40, %rsp
movl %esi, %r12d
notl %r12d
testw $0x3000, %r12w          # imm = 0x3000
je 0x23926
movq %rdx, %r14
movl %esi, %r15d
movq %rdi, %rbx
andl $0x0, -0x38(%rbp)
callq 0x2761f
movq %rax, -0x30(%rbp)
leaq -0x38(%rbp), %rsi
movq %rbx, %rdi
btl $0xe, %r15d
jb 0x238ac
callq 0x23f1a
jmp 0x238b1
callq 0x224cc
cmpl $0x0, -0x38(%rbp)
je 0x238ca
testq %r14, %r14
je 0x23945
movups -0x38(%rbp), %xmm0
movups %xmm0, (%r14)
jmp 0x23919
shrq $0x20, %rax
btl $0xc, %r15d
jb 0x238e1
btl $0xd, %r15d
jae 0x238e7
andl %r12d, %eax
jmp 0x238e4
orl %r15d, %eax
movl %eax, %r15d
movq (%rbx), %rdi
andl 0x25d2f(%rip), %r15d    # 0x49620
movl %r15d, %esi
callq 0xc480
testl %eax, %eax
je 0x23919
testq %r14, %r14
je 0x23992
callq 0xc060
movl (%rax), %ebx
callq 0x275dc
movl %ebx, (%r14)
movq %rax, 0x8(%r14)
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0xc524(%rip), %rdi      # 0x2fe51
leaq 0xc255(%rip), %rsi      # 0x2fb89
leaq 0xc57e(%rip), %rcx      # 0x2feb9
movl $0x562, %edx            # imm = 0x562
callq 0xc350
pushq $0x50
popq %rdi
callq 0xc250
movq %rax, %r14
leaq 0xc5b9(%rip), %rsi      # 0x2ff10
leaq -0x58(%rbp), %rdi
leaq -0x21(%rbp), %rdx
callq 0xc1b0
movl -0x38(%rbp), %ecx
movq -0x30(%rbp), %r8
leaq -0x58(%rbp), %rsi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x24a48
leaq 0x24c07(%rip), %rsi     # 0x48588
leaq 0x1160(%rip), %rdx      # 0x24ae8
movq %r14, %rdi
callq 0xc810
jmp 0x239e9
pushq $0x50
popq %rdi
callq 0xc250
movq %rax, %r14
leaq 0xc56c(%rip), %rsi      # 0x2ff10
leaq -0x58(%rbp), %rdi
leaq -0x21(%rbp), %rdx
callq 0xc1b0
callq 0xc060
movl (%rax), %r15d
callq 0x275dc
leaq -0x58(%rbp), %rsi
movq %r14, %rdi
movq %rbx, %rdx
movl %r15d, %ecx
movq %rax, %r8
callq 0x24a48
leaq 0x24bae(%rip), %rsi     # 0x48588
leaq 0x1107(%rip), %rdx      # 0x24ae8
movq %r14, %rdi
callq 0xc810
jmp 0x239ed
jmp 0x239fb
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0xc9a0
jmp 0x23a06
movq %rax, %rbx
movq %r14, %rdi
callq 0xc390
movq %rbx, %rdi
callq 0xc850