// File: 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:
subq $0x278, %rsp            # imm = 0x278
movq %rdi, 0x48(%rsp)
movq %rdi, %rax
movq %rax, 0x50(%rsp)
movq %rdi, 0x270(%rsp)
movq %rsi, 0x268(%rsp)
movq 0x268(%rsp), %rdi
leaq 0xa8c9(%rip), %rsi      # 0x134c6c
callq 0x86d70
cmpq $0x0, %rax
jne 0x12a4d2
movq 0x268(%rsp), %rdi
callq 0x12a890
testb $0x1, %al
jne 0x12a4d2
leaq 0x227(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x86da0
movq 0x40(%rsp), %rdx
leaq 0x409c(%rip), %rsi      # 0x12e481
leaq 0x228(%rsp), %rdi
callq 0x86a00
jmp 0x12a3f4
movq 0x268(%rsp), %rdx
leaq 0x248(%rsp), %rdi
leaq 0x228(%rsp), %rsi
callq 0x927c0
jmp 0x12a413
movq 0x48(%rsp), %rdi
leaq 0x4062(%rip), %rdx      # 0x12e481
leaq 0x248(%rsp), %rsi
callq 0x927c0
jmp 0x12a42e
leaq 0x248(%rsp), %rdi
callq 0x86f68
jmp 0x12a43d
leaq 0x228(%rsp), %rdi
callq 0x86f68
jmp 0x12a44c
leaq 0x227(%rsp), %rdi
callq 0x867b0
jmp 0x12a866
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x218(%rsp)
movl %eax, 0x214(%rsp)
jmp 0x12a4c0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x218(%rsp)
movl %eax, 0x214(%rsp)
jmp 0x12a4af
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x218(%rsp)
movl %eax, 0x214(%rsp)
leaq 0x248(%rsp), %rdi
callq 0x86f68
jmp 0x12a4ad
jmp 0x12a4af
leaq 0x228(%rsp), %rdi
callq 0x86f68
jmp 0x12a4be
jmp 0x12a4c0
leaq 0x227(%rsp), %rdi
callq 0x867b0
jmp 0x12a873
movq 0x268(%rsp), %rdi
callq 0x86360
movq 0x48(%rsp), %rdi
leaq 0x3(%rax,%rax), %rax
movq %rax, 0x208(%rsp)
movb $0x0, 0x207(%rsp)
callq 0x86a30
movq 0x48(%rsp), %rdi
movq 0x208(%rsp), %rsi
callq 0x86b80
jmp 0x12a512
movq 0x48(%rsp), %rdi
leaq 0x3f63(%rip), %rsi      # 0x12e481
callq 0x866c0
jmp 0x12a525
movq 0x268(%rsp), %rax
movq %rax, 0x1f8(%rsp)
movq 0x1f8(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x12a827
movq 0x1f8(%rsp), %rax
movsbl (%rax), %eax
movl %eax, 0x3c(%rsp)
subl $0x8, %eax
je 0x12a601
jmp 0x12a563
movl 0x3c(%rsp), %eax
subl $0x9, %eax
je 0x12a661
jmp 0x12a572
movl 0x3c(%rsp), %eax
subl $0xa, %eax
je 0x12a631
jmp 0x12a581
movl 0x3c(%rsp), %eax
subl $0xc, %eax
je 0x12a619
jmp 0x12a590
movl 0x3c(%rsp), %eax
subl $0xd, %eax
je 0x12a649
jmp 0x12a59f
movl 0x3c(%rsp), %eax
subl $0x22, %eax
je 0x12a5d1
jmp 0x12a5aa
movl 0x3c(%rsp), %eax
subl $0x5c, %eax
je 0x12a5e9
jmp 0x12a679
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x218(%rsp)
movl %eax, 0x214(%rsp)
jmp 0x12a858
movq 0x48(%rsp), %rdi
leaq 0x3f1c(%rip), %rsi      # 0x12e4f9
callq 0x866c0
jmp 0x12a5e4
jmp 0x12a80c
movq 0x48(%rsp), %rdi
leaq 0xa67f(%rip), %rsi      # 0x134c74
callq 0x866c0
jmp 0x12a5fc
jmp 0x12a80c
movq 0x48(%rsp), %rdi
leaq 0xa66a(%rip), %rsi      # 0x134c77
callq 0x866c0
jmp 0x12a614
jmp 0x12a80c
movq 0x48(%rsp), %rdi
leaq 0xa655(%rip), %rsi      # 0x134c7a
callq 0x866c0
jmp 0x12a62c
jmp 0x12a80c
movq 0x48(%rsp), %rdi
leaq 0xa640(%rip), %rsi      # 0x134c7d
callq 0x866c0
jmp 0x12a644
jmp 0x12a80c
movq 0x48(%rsp), %rdi
leaq 0xa62b(%rip), %rsi      # 0x134c80
callq 0x866c0
jmp 0x12a65c
jmp 0x12a80c
movq 0x48(%rsp), %rdi
leaq 0xa616(%rip), %rsi      # 0x134c83
callq 0x866c0
jmp 0x12a674
jmp 0x12a80c
movq 0x1f8(%rsp), %rax
movsbl (%rax), %edi
callq 0x12a8e0
movb %al, 0x3b(%rsp)
jmp 0x12a68f
movb 0x3b(%rsp), %al
testb $0x1, %al
jne 0x12a69c
jmp 0x12a7f1
leaq 0x80(%rsp), %rdi
callq 0x869d0
jmp 0x12a6ab
leaq 0xa5d4(%rip), %rsi      # 0x134c86
leaq 0x80(%rsp), %rdi
callq 0x86700
movq %rax, 0x30(%rsp)
jmp 0x12a6c6
movq 0x30(%rsp), %rdi
leaq 0x364e(%rip), %rsi      # 0x12dd20
callq 0x86290
movq %rax, 0x28(%rsp)
jmp 0x12a6de
movq 0x28(%rsp), %rdi
leaq 0x3656(%rip), %rsi      # 0x12dd40
callq 0x86290
movq %rax, 0x20(%rsp)
jmp 0x12a6f6
movl $0x30, %edi
callq 0x12dd60
movb %al, 0x1f(%rsp)
jmp 0x12a706
movq 0x20(%rsp), %rdi
movb 0x1f(%rsp), %al
movb %al, 0x7f(%rsp)
movzbl 0x7f(%rsp), %esi
callq 0x86b90
movq %rax, 0x10(%rsp)
jmp 0x12a724
movl $0x4, %edi
callq 0x12dd80
movl %eax, 0xc(%rsp)
jmp 0x12a734
movq 0x10(%rsp), %rdi
movl 0xc(%rsp), %eax
movl %eax, 0x78(%rsp)
movl 0x78(%rsp), %esi
callq 0x86860
movq %rax, (%rsp)
jmp 0x12a750
movq (%rsp), %rdi
movq 0x1f8(%rsp), %rax
movsbl (%rax), %esi
callq 0x86d40
jmp 0x12a766
leaq 0x58(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x86740
jmp 0x12a77a
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x86910
jmp 0x12a78b
leaq 0x58(%rsp), %rdi
callq 0x86f68
jmp 0x12a797
leaq 0x80(%rsp), %rdi
callq 0x861b0
jmp 0x12a7a6
jmp 0x12a80a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x218(%rsp)
movl %eax, 0x214(%rsp)
jmp 0x12a7e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x218(%rsp)
movl %eax, 0x214(%rsp)
leaq 0x58(%rsp), %rdi
callq 0x86f68
jmp 0x12a7de
jmp 0x12a7e0
leaq 0x80(%rsp), %rdi
callq 0x861b0
jmp 0x12a7ef
jmp 0x12a858
movq 0x48(%rsp), %rdi
movq 0x1f8(%rsp), %rax
movsbl (%rax), %esi
callq 0x86480
jmp 0x12a808
jmp 0x12a80a
jmp 0x12a80c
jmp 0x12a80e
movq 0x1f8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x1f8(%rsp)
jmp 0x12a535
movq 0x48(%rsp), %rdi
leaq 0x3c4e(%rip), %rsi      # 0x12e481
callq 0x866c0
jmp 0x12a83a
movb $0x1, 0x207(%rsp)
testb $0x1, 0x207(%rsp)
jne 0x12a856
movq 0x48(%rsp), %rdi
callq 0x86f68
jmp 0x12a866
movq 0x48(%rsp), %rdi
callq 0x86f68
jmp 0x12a864
jmp 0x12a873
movq 0x50(%rsp), %rax
addq $0x278, %rsp            # imm = 0x278
retq
movq 0x218(%rsp), %rdi
callq 0x86d80
movq %rax, %rdi
callq 0x91290
nopl (%rax,%rax)