// File: demon386[P]git-store/./libs/filesystem/src/path_traits.cpp
// Function: boost::filesystem::path_traits::convert(wchar_t const*, wchar_t const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, std::codecvt<wchar_t, char, __mbstate_t> const&)
BOOST_FILESYSTEM_DECL
  void convert(const wchar_t* from,
                const wchar_t* from_end,  // 0 for null terminated MBCS
                std::string & to,
                const codecvt_type & cvt)
  {
    BOOST_ASSERT(from);

    if (!from_end)  // null terminated
    {
      from_end = from + std::wcslen(from);
    }

    if (from == from_end) return;

    //  The codecvt length functions may not be implemented, and I don't really
    //  understand them either. Thus this code is just a guess; if it turns
    //  out the buffer is too small then an error will be reported and the code
    //  will have to be fixed.
    std::size_t buf_size = (from_end - from) * 4;  // perhaps too large, but that's OK
    buf_size += 4;  // encodings like shift-JIS need some prefix space

    //  dynamically allocate a buffer only if source is unusually large
    if (buf_size > default_codecvt_buf_size)
    {
      boost::scoped_array< char > buf(new char [buf_size]);
      convert_aux(from, from_end, buf.get(), buf.get()+buf_size, to, cvt);
    }
    else
    {
      char buf[default_codecvt_buf_size];
      convert_aux(from, from_end, buf, buf+default_codecvt_buf_size, to, cvt);
    }
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x528b4
jmp 0x528d3
leaq 0x10d77(%rip), %rdi     # 0x63632
leaq 0x11277(%rip), %rsi     # 0x63b39
movl $0xac, %edx
leaq 0x11300(%rip), %rcx     # 0x63bce
callq 0xd400
cmpq $0x0, -0x10(%rbp)
jne 0x52903
movq -0x8(%rbp), %rax
movq %rax, -0x148(%rbp)
movq -0x8(%rbp), %rdi
callq 0xd520
movq %rax, %rcx
movq -0x148(%rbp), %rax
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
cmpq -0x10(%rbp), %rax
jne 0x52912
jmp 0x52a0e
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rcx
subq %rcx, %rax
sarq $0x2, %rax
shlq $0x2, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x28(%rbp)
cmpq $0x100, -0x28(%rbp)     # imm = 0x100
jbe 0x529e4
movq -0x28(%rbp), %rdi
callq 0xd030
movq %rax, %rsi
leaq -0x30(%rbp), %rdi
movq %rdi, -0x168(%rbp)
callq 0x4dd00
movq -0x168(%rbp), %rdi
movq -0x8(%rbp), %rax
movq %rax, -0x160(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x158(%rbp)
callq 0x4dd20
movq -0x168(%rbp), %rdi
movq %rax, -0x150(%rbp)
callq 0x4dd20
movq -0x160(%rbp), %rdi
movq -0x158(%rbp), %rsi
movq -0x150(%rbp), %rdx
movq %rax, %rcx
movq -0x28(%rbp), %rax
addq %rax, %rcx
movq -0x18(%rbp), %r8
movq -0x20(%rbp), %r9
callq 0x52a20
jmp 0x529c2
leaq -0x30(%rbp), %rdi
callq 0x4dd70
jmp 0x52a0e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x4dd70
jmp 0x52a17
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x140(%rbp), %rdx
leaq -0x140(%rbp), %rcx
addq $0x100, %rcx            # imm = 0x100
movq -0x18(%rbp), %r8
movq -0x20(%rbp), %r9
callq 0x52a20
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
movq -0x38(%rbp), %rdi
callq 0xdb30