// File: /workspace/github_cpp_makefile_star2_O2/DoubleString[P]RtConverter/src/Json/json_writer.cpp
// Function: Json::valueToQuotedStringN[abi:cxx11](char const*, unsigned int)
static JSONCPP_STRING valueToQuotedStringN(const char* value, unsigned length) {
  if (value == NULL)
    return "";

  if (!isAnyCharRequiredQuoting(value, length))
    return JSONCPP_STRING("\"") + value + "\"";
  // We have to walk value and escape any special characters.
  // Appending to JSONCPP_STRING is not efficient, but this should be rare.
  // (Note: forward slashes are *not* rare, but I am not escaping them.)
  JSONCPP_STRING::size_type maxsize = length * 2 + 3; // allescaped+quotes+NULL
  JSONCPP_STRING result;
  result.reserve(maxsize); // to avoid lots of mallocs
  result += "\"";
  char const* end = value + length;
  for (const char* c = value; c != end; ++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: {
      unsigned int cp = utf8ToCodepoint(c, end);
      // don't escape non-control characters
      // (short escape sequence are applied above)
      if (cp < 0x80 && cp >= 0x20)
        result += static_cast<char>(cp);
      else if (cp < 0x10000) { // codepoint is in Basic Multilingual Plane
        result += "\\u";
        result += toHex16Bit(cp);
      } else { // codepoint is not in Basic Multilingual Plane
               // convert to surrogate pair first
        cp -= 0x10000;
        result += "\\u";
        result += toHex16Bit((cp >> 10) + 0xD800);
        result += "\\u";
        result += toHex16Bit((cp & 0x3FF) + 0xDC00);
      }
    } break;
    }
  }
  result += "\"";
  return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %rbx
testq %rsi, %rsi
je 0x16495
movl %edx, %r15d
movq %rsi, %r14
testl %edx, %edx
je 0x164aa
leal 0x3(,%r15,2), %esi
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
andq $0x0, 0x8(%rbx)
movb $0x0, 0x10(%rbx)
movq %rbx, %rdi
movq %rbx, -0x30(%rbp)
callq 0x89c0
leaq 0x4a475(%rip), %rsi     # 0x60673
movq %rbx, %rdi
callq 0x8c20
movl %r15d, %eax
addq %r14, %rax
movq %rax, -0x40(%rbp)
leaq -0x60(%rbp), %rbx
cmpq -0x40(%rbp), %r14
je 0x16480
movzbl (%r14), %r13d
leal -0x8(%r13), %eax
cmpl $0x5, %eax
ja 0x16244
leaq 0x49f4a(%rip), %rcx     # 0x6017c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x4a436(%rip), %rsi     # 0x60678
jmp 0x1629f
leaq 0x4a42a(%rip), %rsi     # 0x60675
cmpl $0x5c, %r13d
je 0x1629f
cmpl $0x22, %r13d
jne 0x16260
leaq 0x4a414(%rip), %rsi     # 0x60672
jmp 0x1629f
testb %r13b, %r13b
js 0x162c1
leal -0x20(%r13), %eax
cmpl $0x5f, %eax
ja 0x162b0
movsbl %r13b, %esi
movq -0x30(%rbp), %rdi
callq 0x8530
jmp 0x162a8
leaq 0x4a400(%rip), %rsi     # 0x60684
jmp 0x1629f
leaq 0x4a3f1(%rip), %rsi     # 0x6067e
jmp 0x1629f
leaq 0x4a3e5(%rip), %rsi     # 0x6067b
jmp 0x1629f
leaq 0x4a3e2(%rip), %rsi     # 0x60681
movq -0x30(%rbp), %rdi
callq 0x8c20
incq %r14
jmp 0x16214
cmpl $0xffff, %r13d          # imm = 0xFFFF
ja 0x1630f
movl %r13d, %r12d
jmp 0x16402
cmpb $-0x21, %r13b
ja 0x1638d
movq -0x40(%rbp), %rax
subq %r14, %rax
movl $0xfffd, %r12d          # imm = 0xFFFD
cmpq $0x2, %rax
jl 0x16402
andl $0x1f, %r13d
shll $0x6, %r13d
movzbl 0x1(%r14), %eax
incq %r14
andl $0x3f, %eax
orl %r13d, %eax
cmpl $0x80, %r13d
movl $0xfffd, %ecx           # imm = 0xFFFD
cmovbl %ecx, %eax
movl %eax, %r13d
jmp 0x16265
movq -0x30(%rbp), %rdi
leaq 0x4a36d(%rip), %rsi     # 0x60687
callq 0x8c20
leal -0x10000(%r13), %esi
shrl $0xa, %esi
addl $0xd800, %esi           # imm = 0xD800
movq %rbx, %r15
movq %rbx, %rdi
callq 0x1925b
movq -0x30(%rbp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x8c60
movq %r15, %rdi
callq 0x82c0
movq %r12, %rdi
leaq 0x4a32c(%rip), %rsi     # 0x60687
callq 0x8c20
andl $0x3ff, %r13d           # imm = 0x3FF
orl $0xdc00, %r13d          # imm = 0xDC00
movq %rbx, %r15
movq %rbx, %rdi
movl %r13d, %esi
callq 0x1925b
movq -0x30(%rbp), %rdi
movq %r15, %rsi
callq 0x8c60
jmp 0x1642c
cmpb $-0x11, %r13b
ja 0x163e3
movq -0x40(%rbp), %rax
subq %r14, %rax
movl $0xfffd, %r12d          # imm = 0xFFFD
cmpq $0x3, %rax
jl 0x16402
shll $0xc, %r13d
movzwl %r13w, %ecx
movzbl 0x1(%r14), %eax
andl $0x3f, %eax
shll $0x6, %eax
orl %ecx, %eax
addq $0x2, %r14
cmpl $0xdfff, %ecx           # imm = 0xDFFF
ja 0x163ce
cmpl $0xd7ff, %eax           # imm = 0xD7FF
ja 0x16402
movzbl (%r14), %r13d
andl $0x3f, %r13d
orl %eax, %r13d
cmpl $0x800, %eax            # imm = 0x800
jmp 0x16472
cmpb $-0x8, %r13b
setae %al
movq -0x40(%rbp), %rcx
subq %r14, %rcx
cmpq $0x4, %rcx
setl %cl
orb %al, %cl
movl $0xfffd, %r12d          # imm = 0xFFFD
je 0x16439
movq -0x30(%rbp), %rdi
leaq 0x4a27a(%rip), %rsi     # 0x60687
callq 0x8c20
movq %rbx, %r15
movq %rbx, %rdi
movl %r12d, %esi
callq 0x1925b
movq -0x30(%rbp), %rdi
movq %r15, %rsi
callq 0x8c60
movq %r15, %rdi
callq 0x82c0
jmp 0x162a8
andl $0x7, %r13d
shll $0x12, %r13d
movzbl 0x1(%r14), %eax
andl $0x3f, %eax
shll $0xc, %eax
orl %r13d, %eax
movzbl 0x2(%r14), %ecx
andl $0x3f, %ecx
shll $0x6, %ecx
movzbl 0x3(%r14), %r13d
addq $0x3, %r14
andl $0x3f, %r13d
orl %ecx, %r13d
orl %eax, %r13d
cmpl $0x10000, %eax          # imm = 0x10000
movl $0xfffd, %eax           # imm = 0xFFFD
cmovbl %eax, %r13d
jmp 0x16265
leaq 0x4a1ec(%rip), %rsi     # 0x60673
movq -0x30(%rbp), %rbx
movq %rbx, %rdi
callq 0x8c20
jmp 0x164f3
leaq 0x4a149(%rip), %rsi     # 0x605e5
leaq -0x60(%rbp), %rdx
movq %rbx, %rdi
callq 0x8260
jmp 0x164f3
leaq 0x4a1c2(%rip), %rsi     # 0x60673
leaq -0x80(%rbp), %rdi
leaq -0x31(%rbp), %rdx
callq 0x8260
leaq -0x60(%rbp), %rdi
leaq -0x80(%rbp), %rsi
movq %r14, %rdx
callq 0xe884
leaq 0x4a19e(%rip), %rdx     # 0x60673
leaq -0x60(%rbp), %rsi
movq %rbx, %rdi
callq 0xe884
leaq -0x60(%rbp), %rdi
callq 0x82c0
leaq -0x80(%rbp), %rdi
callq 0x82c0
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
leaq -0x60(%rbp), %rdi
callq 0x82c0
jmp 0x16516
movq %rax, %r14
leaq -0x80(%rbp), %rdi
jmp 0x16546
movq %rax, %r14
jmp 0x1654b
jmp 0x1652b
jmp 0x1653f
jmp 0x1652b
jmp 0x1653f
jmp 0x1653f
movq %rax, %r14
leaq -0x60(%rbp), %rdi
callq 0x82c0
jmp 0x16542
jmp 0x1653f
jmp 0x1653f
jmp 0x1653f
movq %rax, %r14
movq -0x30(%rbp), %rdi
callq 0x82c0
movq %r14, %rdi
callq 0x8b30
nop