// File: /workspace/github_cpp_makefile_star2_O2/zeeev[P]DASVC/bamtools/src/third_party/jsoncpp/json_writer.cpp
// Function: Json::valueToQuotedString[abi:cxx11](char const*)
std::string valueToQuotedString( const char *value )
{
   // Not sure how to handle unicode...
   if (strpbrk(value, "\"\\\b\f\n\r\t") == NULL && !containsControlCharacter( value ))
      return std::string("\"") + value + "\"";
   // We have to walk value and escape any special characters.
   // Appending to std::string is not efficient, but this should be rare.
   // (Note: forward slashes are *not* rare, but I am not escaping them.)
   std::string::size_type maxsize = strlen(value)*2 + 3; // allescaped+quotes+NULL
   std::string result;
   result.reserve(maxsize); // to avoid lots of mallocs
   result += "\"";
   for (const char* c=value; *c != 0; ++c)
   {
      switch(*c)
      {
         case '\"':
            result += "\\\"";
            break;
         case '\\':
            result += "\\\\";
            break;
         case '\b':
            result += "\\b";
            break;
         case '\f':
            result += "\\f";
            break;
         case '\n':
            result += "\\n";
            break;
         case '\r':
            result += "\\r";
            break;
         case '\t':
            result += "\\t";
            break;
         //case '/':
            // Even though \/ is considered a legal escape in JSON, a bare
            // slash is also legal, so I see no reason to escape it.
            // (I hope I am not misunderstanding something.
            // blep notes: actually escaping \/ may be useful in javascript to avoid </ 
            // sequence.
            // Should add a flag to allow this compatibility mode and prevent this 
            // sequence from occurring.
         default:
            if ( isControlCharacter( *c ) )
            {
               std::ostringstream oss;
               oss << "\\u" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << static_cast<int>(*c);
               result += oss.str();
            }
            else
            {
               result += *c;
            }
            break;
      }
   }
   result += "\"";
   return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x780d(%rip), %rsi      # 0x767f0
movq %r14, %rdi
callq 0x35b30
testq %rax, %rax
jne 0x6f005
movq %r14, %rax
movb (%rax), %cl
incq %rax
cmpb $0x1f, %cl
ja 0x6eff3
testb %cl, %cl
je 0x6f18a
movq %r14, %rdi
callq 0x352d0
leaq 0x3(,%rax,2), %rsi
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
andq $0x0, 0x8(%rbx)
movb $0x0, 0x10(%rbx)
movq %rbx, %rdi
callq 0x35980
leaq 0x22fd(%rip), %rsi      # 0x71331
movq %rbx, %rdi
callq 0x35c30
leaq 0x77b5(%rip), %r13      # 0x767f8
leaq 0x30(%rsp), %r12
leaq 0x10(%rsp), %r15
leaq 0x76c4(%rip), %rbp      # 0x76718
movzbl (%r14), %eax
cmpq $0xd, %rax
ja 0x6f074
movslq (%rbp,%rax,4), %rcx
addq %rbp, %rcx
jmpq *%rcx
leaq 0x778c(%rip), %rsi      # 0x767fb
jmp 0x6f149
cmpl $0x22, %eax
je 0x6f142
movq %r13, %rsi
cmpl $0x5c, %eax
je 0x6f149
leal -0x1(%rax), %ecx
cmpb $0x1e, %cl
ja 0x6f159
movq %r12, %rdi
callq 0x357f0
movq %r12, %rdi
leaq 0x7763(%rip), %rsi      # 0x7680a
callq 0x355b0
movq (%rax), %rcx
movq -0x18(%rcx), %rdx
movl 0x18(%rax,%rdx), %esi
andl $-0x4b, %esi
orl $0x8, %esi
movl %esi, 0x18(%rax,%rdx)
movq -0x18(%rcx), %rcx
orl $0x4000, 0x18(%rax,%rcx) # imm = 0x4000
movq %rax, %rdi
pushq $0x30
popq %rsi
callq 0x35990
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq $0x4, 0x10(%rax,%rcx)
movsbl (%r14), %esi
movq %rax, %rdi
callq 0x35b00
movq %r15, %rdi
leaq 0x38(%rsp), %rsi
callq 0x359c0
movq %rbx, %rdi
movq %r15, %rsi
callq 0x35c60
movq %r15, %rdi
callq 0x35730
movq %r12, %rdi
callq 0x35160
jmp 0x6f151
leaq 0x76d9(%rip), %rsi      # 0x767fe
jmp 0x6f149
leaq 0x76d6(%rip), %rsi      # 0x76804
jmp 0x6f149
leaq 0x76ca(%rip), %rsi      # 0x76801
jmp 0x6f149
leaq 0x76c7(%rip), %rsi      # 0x76807
jmp 0x6f149
leaq 0x2260(%rip), %rsi      # 0x713a9
movq %rbx, %rdi
callq 0x35c30
incq %r14
jmp 0x6f054
movsbl %al, %esi
movq %rbx, %rdi
callq 0x354e0
jmp 0x6f151
leaq 0x21c4(%rip), %rsi      # 0x71331
movq %rbx, %rdi
callq 0x35c30
movq %rbx, %rax
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x21a0(%rip), %rsi      # 0x71331
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x35280
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movq %r14, %rdx
callq 0x3ab7a
leaq 0x2178(%rip), %rdx      # 0x71331
leaq 0x30(%rsp), %rsi
movq %rbx, %rdi
callq 0x3ab7a
leaq 0x30(%rsp), %rdi
callq 0x35730
leaq 0x10(%rsp), %rdi
callq 0x35730
jmp 0x6f175
movq %rax, %r14
leaq 0x30(%rsp), %rdi
callq 0x35730
jmp 0x6f1f3
movq %rax, %r14
jmp 0x6f22e
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x35730
jmp 0x6f22e
jmp 0x6f223
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x35730
jmp 0x6f217
jmp 0x6f214
jmp 0x6f223
movq %rax, %r14
leaq 0x30(%rsp), %rdi
callq 0x35160
jmp 0x6f226
movq %rax, %r14
movq %rbx, %rdi
callq 0x35730
movq %r14, %rdi
callq 0x35b50
movq %rax, %rdi
callq 0x3a198