// File: /workspace/github_cpp_makefile_star2_O3/demon386[P]git-store/./libs/program_options/src/convert.cpp
// Function: std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t>> boost::detail::convert<wchar_t, char, boost::_bi::bind_t<std::codecvt_base::result, boost::_mfi::cmf7<std::codecvt_base::result, std::__codecvt_abstract_base<wchar_t, char, __mbstate_t>, __mbstate_t&, char const*, char const*, char const*&, wchar_t*, wchar_t*, wchar_t*&>, boost::_bi::list8<boost::_bi::value<std::codecvt<wchar_t, char, __mbstate_t> const*>, boost::arg<1>, boost::arg<2>, boost::arg<3>, boost::arg<4>, boost::arg<5>, boost::arg<6>, boost::arg<7>>>>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, boost::_bi::bind_t<std::codecvt_base::result, boost::_mfi::cmf7<std::codecvt_base::result, std::__codecvt_abstract_base<wchar_t, char, __mbstate_t>, __mbstate_t&, char const*, char const*, char const*&, wchar_t*, wchar_t*, wchar_t*&>, boost::_bi::list8<boost::_bi::value<std::codecvt<wchar_t, char, __mbstate_t> const*>, boost::arg<1>, boost::arg<2>, boost::arg<3>, boost::arg<4>, boost::arg<5>, boost::arg<6>, boost::arg<7>>>)
std::basic_string<ToChar>
    convert(const std::basic_string<FromChar>& s, Fun fun)
        
    {
        std::basic_string<ToChar> result;
        
        std::mbstate_t state = std::mbstate_t();

        const FromChar* from = s.data();
        const FromChar* from_end = s.data() + s.size();
        // The interface of cvt is not really iterator-like, and it's
        // not possible the tell the required output size without the conversion.
        // All we can is convert data by pieces.
        while(from != from_end) {
            
            // std::basic_string does not provide non-const pointers to the data,
            // so converting directly into string is not possible.
            ToChar buffer[32];
            
            ToChar* to_next = buffer;
            // Need variable because boost::bind doesn't work with rvalues.
            ToChar* to_end = buffer + 32;
            std::codecvt_base::result r = 
                fun(state, from, from_end, from, buffer, to_end, to_next);
            
            if (r == std::codecvt_base::error)
                boost::throw_exception(
                    std::logic_error("character conversion failed"));
            // 'partial' is not an error, it just means not all source
            // characters were converted. However, we need to check that at
            // least one new target character was produced. If not, it means
            // the source data is incomplete, and since we don't have extra
            // data to add to source, it's error.
            if (to_next == buffer)
                boost::throw_exception(
                    std::logic_error("character conversion failed"));
            
            // Add converted characters
            result.append(buffer, to_next);
        }
        
        return result;        
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rdi, %rbx
leaq 0x10(%rdi), %rax
movq %rax, -0x48(%rbp)
movq %rax, (%rdi)
xorl %eax, %eax
movq %rax, 0x8(%rdi)
movl $0x0, 0x10(%rdi)
movq %rax, -0x58(%rbp)
movq (%rsi), %rax
movq %rax, -0x40(%rbp)
movq 0x8(%rsi), %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
testq %rcx, %rcx
je 0x14afd
leaq 0x10(%rbp), %rax
leaq 0x10(%rax), %r15
leaq -0x110(%rbp), %r12
leaq -0x40(%rbp), %r14
leaq -0x90(%rbp), %r13
movq %r12, -0x30(%rbp)
leaq -0x90(%rbp), %rax
movq %rax, -0x50(%rbp)
leaq -0x58(%rbp), %rax
movq %rax, -0x90(%rbp)
movq %r14, -0x88(%rbp)
leaq -0x38(%rbp), %rax
movq %rax, -0x80(%rbp)
movq %r14, -0x78(%rbp)
movq %r12, -0x70(%rbp)
leaq -0x50(%rbp), %rax
movq %rax, -0x68(%rbp)
leaq -0x30(%rbp), %rax
movq %rax, -0x60(%rbp)
movq %r15, %rdi
leaq 0x10(%rbp), %rsi
movq %r13, %rdx
xorl %ecx, %ecx
callq 0x14dd4
cmpl $0x2, %eax
je 0x14b12
movq -0x30(%rbp), %r8
subq %r12, %r8
je 0x14b31
movq 0x8(%rbx), %rsi
sarq $0x2, %r8
movq %rbx, %rdi
xorl %edx, %edx
movq %r12, %rcx
callq 0xb130
movq -0x40(%rbp), %rax
cmpq -0x38(%rbp), %rax
jne 0x14a7e
movq %rbx, %rax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1e744(%rip), %rsi     # 0x3325d
leaq -0x90(%rbp), %rdi
callq 0xb650
leaq -0x90(%rbp), %rdi
callq 0x14d00
leaq 0x1e725(%rip), %rsi     # 0x3325d
leaq -0x90(%rbp), %rdi
callq 0xb650
leaq -0x90(%rbp), %rdi
callq 0x14d00
jmp 0x14b54
jmp 0x14b67
movq %rax, %r14
leaq -0x90(%rbp), %rdi
callq 0xb930
jmp 0x14b6a
jmp 0x14b67
movq %rax, %r14
movq (%rbx), %rdi
cmpq -0x48(%rbp), %rdi
je 0x14b78
callq 0xb430
movq %r14, %rdi
callq 0xb7f0