// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/RNBasics/json.cpp
// Function: Json::valueToQuotedString[abi:cxx11](char const*)
std::string valueToQuotedString(const char* value) {
  if (value == NULL)
    return "";
  // 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 %rdi, %rbx
testq %rsi, %rsi
je 0x77124
movq %rsi, %r14
leaq 0x359b2(%rip), %rsi     # 0xac942
movq %r14, %rdi
callq 0x11a70
testq %rax, %rax
jne 0x76fb2
movq %r14, %rax
movb (%rax), %cl
incq %rax
cmpb $0x1f, %cl
ja 0x76fa0
testb %cl, %cl
je 0x7714d
movq %r14, %rdi
callq 0x11250
leaq 0x3(,%rax,2), %rsi
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
andq $0x0, 0x8(%rbx)
movb $0x0, 0x10(%rbx)
movq %rbx, %rdi
callq 0x11960
leaq 0x3596a(%rip), %rsi     # 0xac94b
movq %rbx, %rdi
callq 0x11b70
leaq 0x3595d(%rip), %r13     # 0xac94d
leaq 0x30(%rsp), %r12
leaq 0x10(%rsp), %r15
leaq 0x34d6f(%rip), %rbp     # 0xabd70
movzbl (%r14), %eax
cmpq $0xd, %rax
ja 0x77021
movslq (%rbp,%rax,4), %rcx
addq %rbp, %rcx
jmpq *%rcx
leaq 0x35934(%rip), %rsi     # 0xac950
jmp 0x770f6
cmpl $0x22, %eax
je 0x770ef
movq %r13, %rsi
cmpl $0x5c, %eax
je 0x770f6
leal -0x1(%rax), %ecx
cmpb $0x1e, %cl
ja 0x77106
movq %r12, %rdi
callq 0x11800
movq %r12, %rdi
leaq 0x3590b(%rip), %rsi     # 0xac95f
callq 0x115a0
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 0x11970
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq $0x4, 0x10(%rax,%rcx)
movsbl (%r14), %esi
movq %rax, %rdi
callq 0x11a50
movq %r15, %rdi
leaq 0x38(%rsp), %rsi
callq 0x119a0
movq %rbx, %rdi
movq %r15, %rsi
callq 0x11bd0
movq %r15, %rdi
callq 0x11270
movq %r12, %rdi
callq 0x11180
jmp 0x770fe
leaq 0x35881(%rip), %rsi     # 0xac953
jmp 0x770f6
leaq 0x3587e(%rip), %rsi     # 0xac959
jmp 0x770f6
leaq 0x35872(%rip), %rsi     # 0xac956
jmp 0x770f6
leaq 0x3586f(%rip), %rsi     # 0xac95c
jmp 0x770f6
leaq 0x35854(%rip), %rsi     # 0xac94a
movq %rbx, %rdi
callq 0x11b70
incq %r14
jmp 0x77001
movsbl %al, %esi
movq %rbx, %rdi
callq 0x114e0
jmp 0x770fe
leaq 0x35831(%rip), %rsi     # 0xac94b
movq %rbx, %rdi
callq 0x11b70
jmp 0x77138
leaq 0x32439(%rip), %rsi     # 0xa9564
leaq 0x30(%rsp), %rdx
movq %rbx, %rdi
callq 0x196d0
movq %rbx, %rax
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x357f7(%rip), %rsi     # 0xac94b
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x196d0
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movq %r14, %rdx
callq 0x1970b
leaq 0x357cf(%rip), %rdx     # 0xac94b
leaq 0x30(%rsp), %rsi
movq %rbx, %rdi
callq 0x1970b
leaq 0x30(%rsp), %rdi
callq 0x11270
leaq 0x10(%rsp), %rdi
callq 0x11270
jmp 0x77138
movq %rax, %r14
leaq 0x30(%rsp), %rdi
callq 0x11270
jmp 0x771b1
movq %rax, %r14
leaq 0x10(%rsp), %rdi
jmp 0x771e7
movq %rax, %r14
jmp 0x771ec
jmp 0x771e1
jmp 0x771e1
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x11270
jmp 0x771d5
jmp 0x771d2
movq %rax, %r14
leaq 0x30(%rsp), %rdi
callq 0x11180
jmp 0x771e4
movq %rax, %r14
movq %rbx, %rdi
callq 0x11270
movq %r14, %rdi
callq 0x11a80