// File: /workspace/github_cpp_makefile_star2_O1/Eba-M[P]E3DC-Control/cJSON.c
// Function: print_string_ptr(unsigned char const*, printbuffer*)
static cJSON_bool print_string_ptr(const unsigned char * const input, printbuffer * const output_buffer)
{
    const unsigned char *input_pointer = NULL;
    unsigned char *output = NULL;
    unsigned char *output_pointer = NULL;
    size_t output_length = 0;
    /* numbers of additional characters needed for escaping */
    size_t escape_characters = 0;

    if (output_buffer == NULL)
    {
        return false;
    }

    /* empty string */
    if (input == NULL)
    {
        output = ensure(output_buffer, sizeof("\"\""));
        if (output == NULL)
        {
            return false;
        }
        strcpy((char*)output, "\"\"");

        return true;
    }

    /* set "flag" to 1 if something needs to be escaped */
    for (input_pointer = input; *input_pointer; input_pointer++)
    {
        switch (*input_pointer)
        {
            case '\"':
            case '\\':
            case '\b':
            case '\f':
            case '\n':
            case '\r':
            case '\t':
                /* one character escape sequence */
                escape_characters++;
                break;
            default:
                if (*input_pointer < 32)
                {
                    /* UTF-16 escape sequence uXXXX */
                    escape_characters += 5;
                }
                break;
        }
    }
    output_length = (size_t)(input_pointer - input) + escape_characters;

    output = ensure(output_buffer, output_length + sizeof("\"\""));
    if (output == NULL)
    {
        return false;
    }

    /* no characters have to be escaped */
    if (escape_characters == 0)
    {
        output[0] = '\"';
        memcpy(output + 1, input, output_length);
        output[output_length + 1] = '\"';
        output[output_length + 2] = '\0';

        return true;
    }

    output[0] = '\"';
    output_pointer = output + 1;
    /* copy the string */
    for (input_pointer = input; *input_pointer != '\0'; (void)input_pointer++, output_pointer++)
    {
        if ((*input_pointer > 31) && (*input_pointer != '\"') && (*input_pointer != '\\'))
        {
            /* normal character, copy */
            *output_pointer = *input_pointer;
        }
        else
        {
            /* character needs to be escaped */
            *output_pointer++ = '\\';
            switch (*input_pointer)
            {
                case '\\':
                    *output_pointer = '\\';
                    break;
                case '\"':
                    *output_pointer = '\"';
                    break;
                case '\b':
                    *output_pointer = 'b';
                    break;
                case '\f':
                    *output_pointer = 'f';
                    break;
                case '\n':
                    *output_pointer = 'n';
                    break;
                case '\r':
                    *output_pointer = 'r';
                    break;
                case '\t':
                    *output_pointer = 't';
                    break;
                default:
                    /* escape and print as unicode codepoint */
                    sprintf((char*)output_pointer, "u%04x", *input_pointer);
                    output_pointer += 4;
                    break;
            }
        }
    }
    output[output_length + 1] = '\"';
    output[output_length + 2] = '\0';

    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rax
testq %rdi, %rdi
je 0x2ee5e
movq %rdi, %rbx
xorl %r12d, %r12d
movabsq $0x400003700, %rcx      # imm = 0x400003700
xorl %r13d, %r13d
movzbl (%rbx,%r12), %edx
cmpq $0x22, %rdx
ja 0x2ed82
btq %rdx, %rcx
jae 0x2ed7d
incq %r13
incq %r12
jmp 0x2ed64
testq %rdx, %rdx
je 0x2ed94
cmpl $0x5c, %edx
je 0x2ed75
leaq 0x5(%r13), %rsi
cmpb $0x20, %dl
cmovbq %rsi, %r13
jmp 0x2ed78
leaq (%r12,%r13), %rsi
addq $0x3, %rsi
movq %rax, %rdi
callq 0x2ec64
testq %rax, %rax
je 0x2ee7b
movq %rax, %r15
movb $0x22, (%rax)
testq %r13, %r13
je 0x2ee7f
movb (%rbx), %al
testb %al, %al
je 0x2ee8f
incq %rbx
leaq 0x3d10(%rip), %rbp      # 0x32ae0
movq %r15, %r14
cmpb $0x20, %al
jb 0x2ede3
cmpb $0x22, %al
je 0x2ede3
movzbl %al, %ecx
cmpl $0x5c, %ecx
jne 0x2ee16
leaq 0x2(%r14), %rdi
movb $0x5c, 0x1(%r14)
movzbl -0x1(%rbx), %edx
leal -0x8(%rdx), %eax
cmpl $0x5, %eax
ja 0x2ee07
movslq (%rbp,%rax,4), %rax
addq %rbp, %rax
jmpq *%rax
movb $0x62, (%rdi)
jmp 0x2ee4c
cmpl $0x22, %edx
je 0x2ee49
cmpl $0x5c, %edx
jne 0x2ee1e
movb $0x5c, (%rdi)
jmp 0x2ee4c
incq %r14
movb %al, (%r14)
jmp 0x2ee30
leaq 0x3cfe(%rip), %rsi      # 0x32b23
xorl %eax, %eax
callq 0x2050
addq $0x6, %r14
movq %r14, %rdi
jmp 0x2ee4c
movb $0x74, (%rdi)
jmp 0x2ee4c
movb $0x6e, (%rdi)
jmp 0x2ee4c
movb $0x66, (%rdi)
jmp 0x2ee4c
movb $0x72, (%rdi)
jmp 0x2ee4c
movb $0x22, (%rdi)
movb (%rbx), %al
incq %rbx
movq %rdi, %r14
testb %al, %al
jne 0x2edd3
jmp 0x2ee8f
movl $0x3, %esi
movq %rax, %rdi
callq 0x2ec64
testq %rax, %rax
je 0x2ee7b
movb $0x0, 0x2(%rax)
movw $0x2222, (%rax)         # imm = 0x2222
jmp 0x2ee9a
xorl %eax, %eax
jmp 0x2ee9f
leaq (%r12,%r13), %rdx
leaq 0x1(%r15), %rdi
movq %rbx, %rsi
callq 0x21f0
addq %r13, %r15
movw $0x22, 0x1(%r12,%r15)
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop