// File: demon386[P]git-store/./libs/filesystem/src/unique_path.cpp
// Function: boost::filesystem::detail::unique_path(boost::filesystem::path const&, boost::system::error_code*)
BOOST_FILESYSTEM_DECL
path unique_path(const path& model, system::error_code* ec)
{
  std::wstring s (model.wstring());  // std::string ng for MBCS encoded POSIX
  const wchar_t hex[] = L"0123456789abcdef";
  char ran[] = "123456789abcdef";  // init to avoid clang static analyzer message
                                   // see ticket #8954
  assert(sizeof(ran) == 16);
  const int max_nibbles = 2 * sizeof(ran);   // 4-bits per nibble

  int nibbles_used = max_nibbles;
  for(std::wstring::size_type i=0; i < s.size(); ++i)
  {
    if (s[i] == L'%')                        // digit request
    {
      if (nibbles_used == max_nibbles)
      {
        system_crypt_random(ran, sizeof(ran), ec);
        if (ec != 0 && *ec)
          return "";
        nibbles_used = 0;
      }
      int c = ran[nibbles_used/2];
      c >>= 4 * (nibbles_used++ & 1);  // if odd, shift right 1 nibble
      s[i] = hex[c & 0xf];             // convert to hex digit and replace
    }
  }

  if (ec != 0) ec->clear();

  return s;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0xc8(%rbp)
movq %rdi, %rax
movq %rax, -0xc0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x53450
leaq -0x80(%rbp), %rdi
leaq 0x10c80(%rip), %rsi     # 0x63d40
movl $0x44, %edx
callq 0xd4f0
movq 0x10cbf(%rip), %rax     # 0x63d90
movq %rax, -0x90(%rbp)
movq 0x10cb9(%rip), %rax     # 0x63d98
movq %rax, -0x88(%rbp)
movl $0x20, -0x94(%rbp)
movl $0x20, -0x98(%rbp)
movq $0x0, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0xd0(%rbp)
leaq -0x38(%rbp), %rdi
callq 0xd480
movq %rax, %rcx
movq -0xd0(%rbp), %rax
cmpq %rcx, %rax
jae 0x53273
movq -0xa0(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0xd7e0
movq %rax, -0xd8(%rbp)
jmp 0x53148
movq -0xd8(%rbp), %rax
cmpl $0x25, (%rax)
jne 0x5325a
cmpl $0x20, -0x98(%rbp)
jne 0x531dc
movq -0x18(%rbp), %rdx
leaq -0x90(%rbp), %rdi
movl $0x10, %esi
callq 0x532d0
jmp 0x53178
cmpq $0x0, -0x18(%rbp)
je 0x531d2
movq -0x18(%rbp), %rdi
callq 0x4d830
cmpq $0x0, %rax
je 0x531d2
movq -0xc8(%rbp), %rdi
leaq 0xccc5(%rip), %rsi      # 0x5fe61
callq 0x4df90
jmp 0x531a3
movl $0x1, -0xb0(%rbp)
jmp 0x532a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
leaq -0x38(%rbp), %rdi
callq 0xdcc0
jmp 0x532bc
movl $0x0, -0x98(%rbp)
movl -0x98(%rbp), %eax
movl %eax, %ecx
shrl $0x1f, %ecx
addl %ecx, %eax
sarl %eax
cltq
movsbl -0x90(%rbp,%rax), %eax
movl %eax, -0xb4(%rbp)
movl -0x98(%rbp), %ecx
movl %ecx, %eax
incl %eax
movl %eax, -0x98(%rbp)
movl -0xb4(%rbp), %eax
andb $0x1, %cl
shlb $0x2, %cl
sarl %cl, %eax
movl %eax, -0xb4(%rbp)
movl -0xb4(%rbp), %eax
andl $0xf, %eax
movl -0x80(%rbp,%rax,4), %eax
movl %eax, -0xe4(%rbp)
movq -0xa0(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0xd7e0
movq %rax, -0xe0(%rbp)
jmp 0x5324b
movq -0xe0(%rbp), %rax
movl -0xe4(%rbp), %ecx
movl %ecx, (%rax)
jmp 0x5325c
movq -0xa0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xa0(%rbp)
jmp 0x53105
cmpq $0x0, -0x18(%rbp)
je 0x53283
movq -0x18(%rbp), %rdi
callq 0x4d9e0
movq -0xc8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
leaq -0x38(%rbp), %rsi
callq 0x53520
jmp 0x53299
movl $0x1, -0xb0(%rbp)
leaq -0x38(%rbp), %rdi
callq 0xdcc0
movq -0xc0(%rbp), %rax
addq $0xf0, %rsp
popq %rbp
retq
movq -0xa8(%rbp), %rdi
callq 0xdb30
nopl (%rax,%rax)