// File: /workspace/github_cpp_makefile_star2_O3/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 $0x48, %rsp
movq %rdi, %rbx
testq %rsi, %rsi
je 0x18677
movl %edx, %r15d
movq %rsi, %r14
testl %edx, %edx
je 0x1869e
leal 0x3(,%r15,2), %esi
leaq 0x10(%rbx), %rax
movq %rax, -0x50(%rbp)
movq %rax, (%rbx)
movq $0x0, 0x8(%rbx)
movb $0x0, 0x10(%rbx)
movq %rbx, %rdi
callq 0x89d0
leaq 0x522ad(%rip), %rsi     # 0x6a683
movq %rbx, %rdi
callq 0x8c10
movl %r15d, %r12d
addq %r14, %r12
movzbl (%r14), %r13d
leal -0x8(%r13), %eax
cmpl $0x5, %eax
ja 0x1840a
leaq 0x51d94(%rip), %rcx     # 0x6a18c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x52280(%rip), %rsi     # 0x6a688
jmp 0x18464
leaq 0x52274(%rip), %rsi     # 0x6a685
cmpl $0x5c, %r13d
je 0x18464
cmpl $0x22, %r13d
jne 0x18426
leaq 0x5225e(%rip), %rsi     # 0x6a682
jmp 0x18464
testb %r13b, %r13b
js 0x1848e
leal -0x20(%r13), %eax
cmpl $0x5f, %eax
ja 0x1847d
movsbl %r13b, %esi
movq %rbx, %rdi
callq 0x8530
jmp 0x1846c
leaq 0x5224b(%rip), %rsi     # 0x6a694
jmp 0x18464
leaq 0x5223c(%rip), %rsi     # 0x6a68e
jmp 0x18464
leaq 0x52230(%rip), %rsi     # 0x6a68b
jmp 0x18464
leaq 0x5222d(%rip), %rsi     # 0x6a691
movq %rbx, %rdi
callq 0x8c10
incq %r14
cmpq %r12, %r14
jne 0x183e4
jmp 0x18663
cmpl $0xffff, %r13d          # imm = 0xFFFF
ja 0x184db
movl %r13d, %r15d
jmp 0x185d6
cmpb $-0x21, %r13b
ja 0x18563
movq %r12, %rax
subq %r14, %rax
movl $0xfffd, %r15d          # imm = 0xFFFD
cmpq $0x2, %rax
jl 0x185d6
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 0x1842b
movq %rbx, %rdi
leaq 0x521b2(%rip), %rsi     # 0x6a697
callq 0x8c10
leal -0x10000(%r13), %esi
shrl $0xa, %esi
addl $0xd800, %esi           # imm = 0xD800
leaq -0x48(%rbp), %rdi
callq 0x1be7f
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq %rbx, %rdi
callq 0x81f0
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x18525
callq 0x85d0
movq %rbx, %rdi
leaq 0x52168(%rip), %rsi     # 0x6a697
callq 0x8c10
andl $0x3ff, %r13d           # imm = 0x3FF
orl $0xdc00, %r13d          # imm = 0xDC00
leaq -0x48(%rbp), %rdi
movl %r13d, %esi
callq 0x1be7f
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq %rbx, %rdi
callq 0x81f0
jmp 0x18601
cmpb $-0x11, %r13b
ja 0x185b8
movq %r12, %rax
subq %r14, %rax
movl $0xfffd, %r15d          # imm = 0xFFFD
cmpq $0x3, %rax
jl 0x185d6
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 0x185a3
cmpl $0xd7ff, %eax           # imm = 0xD7FF
ja 0x185d6
movzbl (%r14), %r13d
andl $0x3f, %r13d
orl %eax, %r13d
cmpl $0x800, %eax            # imm = 0x800
jmp 0x18655
cmpb $-0x8, %r13b
setae %al
movq %r12, %rcx
subq %r14, %rcx
cmpq $0x4, %rcx
setl %cl
orb %al, %cl
movl $0xfffd, %r15d          # imm = 0xFFFD
je 0x1861c
movq %rbx, %rdi
leaq 0x520b7(%rip), %rsi     # 0x6a697
callq 0x8c10
leaq -0x48(%rbp), %rdi
movl %r15d, %esi
callq 0x1be7f
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq %rbx, %rdi
callq 0x81f0
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x1846c
callq 0x85d0
jmp 0x1846c
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 0x1842b
leaq 0x52019(%rip), %rsi     # 0x6a683
movq %rbx, %rdi
callq 0x8c10
jmp 0x18778
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x51f70(%rip), %rdx     # 0x6a5f5
movq %rbx, %rdi
movq %rdx, %rsi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1100a
leaq -0x60(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x51fd6(%rip), %rsi     # 0x6a683
leaq 0x51fd0(%rip), %rdx     # 0x6a684
leaq -0x70(%rbp), %rdi
callq 0x1100a
leaq -0x70(%rbp), %rdi
movq %r14, %rsi
callq 0x8c10
leaq -0x38(%rbp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x186ee
movq %rdx, -0x48(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x38(%rbp)
jmp 0x186f6
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
leaq -0x48(%rbp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x51f6b(%rip), %rsi     # 0x6a683
callq 0x8c10
leaq 0x10(%rbx), %rdx
movq %rdx, (%rbx)
movq (%rax), %rsi
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rsi
je 0x1873f
movq %rsi, (%rbx)
movq (%rcx), %rdx
movq %rdx, 0x10(%rbx)
jmp 0x18745
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
movq 0x8(%rax), %rdx
movq %rdx, 0x8(%rbx)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x1876a
callq 0x85d0
movq -0x70(%rbp), %rdi
cmpq %r15, %rdi
je 0x18778
callq 0x85d0
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x1879d
callq 0x85d0
jmp 0x1879d
movq %rax, %r14
movq -0x70(%rbp), %rdi
cmpq %r15, %rdi
jne 0x187e0
jmp 0x187e5
movq %rax, %r14
jmp 0x187e5
jmp 0x187b7
jmp 0x187d4
jmp 0x187b7
jmp 0x187d4
jmp 0x187d4
movq %rax, %r14
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x187d7
callq 0x85d0
jmp 0x187d7
jmp 0x187d4
jmp 0x187d4
jmp 0x187d4
movq %rax, %r14
movq (%rbx), %rdi
cmpq -0x50(%rbp), %rdi
je 0x187e5
callq 0x85d0
movq %r14, %rdi
callq 0x8b30
nop