// File: /workspace/github_c_makefile_star2_O1/justy989[P]ce/ce_clangd.c
// Function: convert_string_to_json_string
static char* _convert_string_to_json_string(const char* string){
     char* result = NULL;
     int64_t string_len = strlen(string);
     int64_t result_len = 0;

     // Count how big we need to allocate the string.
     for(int64_t i = 0; i < string_len; i++){
          if(string[i] == '"' ||
             string[i] == '\\' ||
             string[i] == '/' ||
             string[i] == '\b' ||
             string[i] == '\f' ||
             string[i] == '\n' ||
             string[i] == '\r' ||
             string[i] == '\t'){
             // TODO: support \u
               result_len += 2;
          }else{
               result_len++;
          }
     }

     // Allocate and populate the new string with valid
     result = malloc(result_len + 1);
     int64_t r = 0;
     for(int64_t i = 0; i < string_len; i++){
          switch(string[i]){
          case '"':
          case '\\':
          case '/':
               result[r] = '\\';
               r++;
               result[r] = string[i];
               r++;
               break;
          case '\b':
               result[r] = '\\';
               r++;
               result[r] = 'b';
               r++;
               break;
          case '\f':
               result[r] = '\\';
               r++;
               result[r] = 'f';
               r++;
               break;
          case '\n':
               result[r] = '\\';
               r++;
               result[r] = 'n';
               r++;
               break;
          case '\r':
               result[r] = '\\';
               r++;
               result[r] = 'r';
               r++;
               break;
          case '\t':
               result[r] = '\\';
               r++;
               result[r] = 't';
               r++;
               break;
          default:
               result[r] = string[i];
               r++;
               break;
          }
     }
     // End with null terminator
     result[r] = 0;
     return result;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0xd210
movq %rax, %r14
testq %rax, %rax
jle 0x15898
xorl %eax, %eax
movabsq $0x800400003700, %rcx   # imm = 0x800400003700
xorl %edi, %edi
movzbl (%rbx,%rax), %esi
movl $0x2, %edx
cmpq $0x2f, %rsi
ja 0x15887
btq %rsi, %rcx
jae 0x15887
addq %rdx, %rdi
incq %rax
cmpq %rax, %r14
jne 0x15865
jmp 0x15893
cmpl $0x5c, %esi
je 0x1587a
movl $0x1, %edx
jmp 0x1587a
incq %rdi
jmp 0x1589d
movl $0x1, %edi
callq 0xd4c0
testq %r14, %r14
jle 0x1593c
xorl %edx, %edx
movabsq $0x400000000002001, %rsi # imm = 0x400000000002001
leaq 0x1a752(%rip), %rdi     # 0x30010
xorl %ecx, %ecx
movb (%rbx,%rdx), %r8b
movzbl %r8b, %r9d
leal -0x8(%r9), %r10d
cmpl $0x5, %r10d
ja 0x158e4
movslq (%rdi,%r10,4), %r9
addq %rdi, %r9
jmpq *%r9
movw $0x625c, (%rax,%rcx)    # imm = 0x625C
jmp 0x15929
addl $-0x22, %r9d
cmpl $0x3a, %r9d
ja 0x158ff
btq %r9, %rsi
jae 0x158ff
movb $0x5c, (%rax,%rcx)
movb %r8b, 0x1(%rax,%rcx)
jmp 0x15929
movb %r8b, (%rax,%rcx)
movl $0x1, %r8d
jmp 0x1592f
movw $0x665c, (%rax,%rcx)    # imm = 0x665C
jmp 0x15929
movw $0x745c, (%rax,%rcx)    # imm = 0x745C
jmp 0x15929
movw $0x725c, (%rax,%rcx)    # imm = 0x725C
jmp 0x15929
movw $0x6e5c, (%rax,%rcx)    # imm = 0x6E5C
movl $0x2, %r8d
addq %r8, %rcx
incq %rdx
cmpq %rdx, %r14
jne 0x158c0
jmp 0x1593e
xorl %ecx, %ecx
movb $0x0, (%rax,%rcx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq