// File: /workspace/github_c_makefile_star2_O2/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 %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
callq 0xd210
movq %rax, %r14
xorl %edi, %edi
testq %rax, %rax
cmovleq %rdi, %r14
pushq $0x2
popq %rax
pushq $0x1
popq %rcx
movabsq $0x800400003700, %rdx   # imm = 0x800400003700
xorl %esi, %esi
cmpq %rsi, %r14
je 0x14b7e
movzbl (%rbx,%rsi), %r8d
cmpq $0x2f, %r8
ja 0x14b70
btq %r8, %rdx
movq %rax, %r9
jae 0x14b70
addq %r9, %rdi
incq %rsi
jmp 0x14b4f
movq %rax, %r9
cmpl $0x5c, %r8d
je 0x14b68
movq %rcx, %r9
jmp 0x14b68
incq %rdi
callq 0xd4c0
xorl %ecx, %ecx
movabsq $0x400000000002001, %rdx # imm = 0x400000000002001
pushq $0x2
popq %rsi
pushq $0x1
popq %rdi
leaq 0x17471(%rip), %r8      # 0x2c010
xorl %r9d, %r9d
cmpq %r9, %r14
je 0x14c18
movb (%rbx,%r9), %r10b
movzbl %r10b, %r11d
leal -0x8(%r11), %r15d
cmpl $0x5, %r15d
ja 0x14bcb
movslq (%r8,%r15,4), %r11
addq %r8, %r11
jmpq *%r11
movw $0x625c, (%rax,%rcx)    # imm = 0x625C
jmp 0x14c0d
addl $-0x22, %r11d
cmpl $0x3a, %r11d
ja 0x14be6
btq %r11, %rdx
jae 0x14be6
movb $0x5c, (%rax,%rcx)
movb %r10b, 0x1(%rax,%rcx)
jmp 0x14c0d
movb %r10b, (%rax,%rcx)
movq %rdi, %r10
jmp 0x14c10
movw $0x665c, (%rax,%rcx)    # imm = 0x665C
jmp 0x14c0d
movw $0x745c, (%rax,%rcx)    # imm = 0x745C
jmp 0x14c0d
movw $0x725c, (%rax,%rcx)    # imm = 0x725C
jmp 0x14c0d
movw $0x6e5c, (%rax,%rcx)    # imm = 0x6E5C
movq %rsi, %r10
addq %r10, %rcx
incq %r9
jmp 0x14ba2
movb $0x0, (%rax,%rcx)
popq %rbx
popq %r14
popq %r15
retq