// File: /workspace/github_cpp_makefile_star2_O1/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 0x18ce3
movl %edx, %r15d
movq %rsi, %r14
testl %edx, %edx
je 0x18d01
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 0x89e0
leaq 0x51c2d(%rip), %rsi     # 0x6a683
movq %rbx, %rdi
callq 0x8c20
movl %r15d, %r15d
addq %r14, %r15
leaq 0x51721(%rip), %r12     # 0x6a18c
movzbl (%r14), %r13d
leal -0x8(%r13), %eax
cmpl $0x5, %eax
ja 0x18a8d
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
leaq 0x51c00(%rip), %rsi     # 0x6a688
jmp 0x18b17
leaq 0x51bf1(%rip), %rsi     # 0x6a685
cmpl $0x5c, %r13d
je 0x18b17
cmpl $0x22, %r13d
jne 0x18aa9
leaq 0x51bdb(%rip), %rsi     # 0x6a682
jmp 0x18b17
testb %r13b, %r13b
jns 0x18bde
cmpb $-0x21, %r13b
ja 0x18b30
movq %r15, %rax
subq %r14, %rax
cmpq $0x2, %rax
jl 0x18b94
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 0x18bde
leaq 0x51b98(%rip), %rsi     # 0x6a694
jmp 0x18b17
leaq 0x51b89(%rip), %rsi     # 0x6a68e
jmp 0x18b17
leaq 0x51b7d(%rip), %rsi     # 0x6a68b
jmp 0x18b17
leaq 0x51b7a(%rip), %rsi     # 0x6a691
movq %rbx, %rdi
callq 0x8c20
incq %r14
cmpq %r15, %r14
jne 0x18a6b
jmp 0x18ccf
cmpb $-0x11, %r13b
ja 0x18b7c
movq %r15, %rax
subq %r14, %rax
cmpq $0x3, %rax
jl 0x18b94
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 0x18b6a
cmpl $0xd7ff, %eax           # imm = 0xD7FF
ja 0x18b94
movzbl (%r14), %r13d
andl $0x3f, %r13d
orl %eax, %r13d
cmpl $0x800, %eax            # imm = 0x800
jmp 0x18bd5
cmpb $-0x8, %r13b
setae %al
movq %r15, %rcx
subq %r14, %rcx
cmpq $0x4, %rcx
setl %cl
orb %al, %cl
je 0x18b9c
movl $0xfffd, %r13d          # imm = 0xFFFD
jmp 0x18bde
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
leal -0x20(%r13), %eax
cmpl $0x5f, %eax
ja 0x18bf8
movsbl %r13b, %esi
movq %rbx, %rdi
callq 0x8530
jmp 0x18b1f
cmpl $0xffff, %r13d          # imm = 0xFFFF
ja 0x18c31
movq %rbx, %rdi
leaq 0x51a8c(%rip), %rsi     # 0x6a697
callq 0x8c20
leaq -0x48(%rbp), %rdi
movl %r13d, %esi
callq 0x1c4c9
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq %rbx, %rdi
callq 0x81f0
jmp 0x18cb4
movq %rbx, %rdi
leaq 0x51a5c(%rip), %rsi     # 0x6a697
callq 0x8c20
leal -0x10000(%r13), %esi
shrl $0xa, %esi
addl $0xd800, %esi           # imm = 0xD800
leaq -0x48(%rbp), %rdi
callq 0x1c4c9
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 0x18c7b
callq 0x85d0
movq %rbx, %rdi
leaq 0x51a12(%rip), %rsi     # 0x6a697
callq 0x8c20
andl $0x3ff, %r13d           # imm = 0x3FF
orl $0xdc00, %r13d          # imm = 0xDC00
leaq -0x48(%rbp), %rdi
movl %r13d, %esi
callq 0x1c4c9
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 0x18b1f
callq 0x85d0
jmp 0x18b1f
leaq 0x519ad(%rip), %rsi     # 0x6a683
movq %rbx, %rdi
callq 0x8c20
jmp 0x18ddb
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x51904(%rip), %rdx     # 0x6a5f5
movq %rbx, %rdi
movq %rdx, %rsi
callq 0x1126a
jmp 0x18ddb
leaq -0x60(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x51973(%rip), %rsi     # 0x6a683
leaq 0x5196d(%rip), %rdx     # 0x6a684
leaq -0x70(%rbp), %rdi
callq 0x1126a
leaq -0x70(%rbp), %rdi
movq %r14, %rsi
callq 0x8c20
leaq -0x38(%rbp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x18d51
movq %rdx, -0x48(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x38(%rbp)
jmp 0x18d59
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 0x51908(%rip), %rsi     # 0x6a683
callq 0x8c20
leaq 0x10(%rbx), %rdx
movq %rdx, (%rbx)
movq (%rax), %rsi
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rsi
je 0x18da2
movq %rsi, (%rbx)
movq (%rcx), %rdx
movq %rdx, 0x10(%rbx)
jmp 0x18da8
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 0x18dcd
callq 0x85d0
movq -0x70(%rbp), %rdi
cmpq %r15, %rdi
je 0x18ddb
callq 0x85d0
movq %rbx, %rax
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 0x18e03
callq 0x85d0
jmp 0x18e03
movq %rax, %r14
movq -0x70(%rbp), %rdi
cmpq %r15, %rdi
jne 0x18e46
jmp 0x18e4b
movq %rax, %r14
jmp 0x18e4b
jmp 0x18e3a
jmp 0x18e1d
jmp 0x18e3a
jmp 0x18e1d
jmp 0x18e3a
movq %rax, %r14
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x18e3d
callq 0x85d0
jmp 0x18e3d
jmp 0x18e3a
jmp 0x18e3a
jmp 0x18e3a
movq %rax, %r14
movq (%rbx), %rdi
cmpq -0x50(%rbp), %rdi
je 0x18e4b
callq 0x85d0
movq %r14, %rdi
callq 0x8b40
nop