// File: /workspace/github_c_makefile_star2_O3/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
testq %rax, %rax
jle 0x1559a
movq %rax, %r14
xorl %eax, %eax
movabsq $0x800400003700, %rcx   # imm = 0x800400003700
xorl %edi, %edi
movzbl (%rbx,%rax), %esi
movl $0x2, %edx
cmpq $0x2f, %rsi
ja 0x154ec
btq %rsi, %rcx
jae 0x154ec
addq %rdx, %rdi
incq %rax
cmpq %rax, %r14
jne 0x154ca
jmp 0x154f8
cmpl $0x5c, %esi
je 0x154df
movl $0x1, %edx
jmp 0x154df
incq %rdi
callq 0xd4c0
testq %r14, %r14
jle 0x155a4
xorl %edx, %edx
movabsq $0x400000000002001, %rsi # imm = 0x400000000002001
leaq 0x19af4(%rip), %rdi     # 0x2f010
xorl %ecx, %ecx
movb (%rbx,%rdx), %r8b
movzbl %r8b, %r9d
leal -0x8(%r9), %r10d
cmpl $0x5, %r10d
ja 0x15542
movslq (%rdi,%r10,4), %r9
addq %rdi, %r9
jmpq *%r9
movw $0x625c, (%rax,%rcx)    # imm = 0x625C
jmp 0x15587
addl $-0x22, %r9d
cmpl $0x3a, %r9d
ja 0x1555d
btq %r9, %rsi
jae 0x1555d
movb $0x5c, (%rax,%rcx)
movb %r8b, 0x1(%rax,%rcx)
jmp 0x15587
movb %r8b, (%rax,%rcx)
movl $0x1, %r8d
jmp 0x1558d
movw $0x665c, (%rax,%rcx)    # imm = 0x665C
jmp 0x15587
movw $0x745c, (%rax,%rcx)    # imm = 0x745C
jmp 0x15587
movw $0x725c, (%rax,%rcx)    # imm = 0x725C
jmp 0x15587
movw $0x6e5c, (%rax,%rcx)    # imm = 0x6E5C
movl $0x2, %r8d
addq %r8, %rcx
incq %rdx
cmpq %rdx, %r14
jne 0x1551e
jmp 0x155a6
movl $0x1, %edi
callq 0xd4c0
xorl %ecx, %ecx
movb $0x0, (%rax,%rcx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq