// File: 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:
subq $0x48, %rsp
movq %rdi, 0x38(%rsp)
movq %rsi, 0x30(%rsp)
movq $0x0, 0x28(%rsp)
movq $0x0, 0x20(%rsp)
movq $0x0, 0x18(%rsp)
movq $0x0, 0x10(%rsp)
movq $0x0, 0x8(%rsp)
cmpq $0x0, 0x30(%rsp)
jne 0x5e290
movl $0x0, 0x44(%rsp)
jmp 0x5e58c
cmpq $0x0, 0x38(%rsp)
jne 0x5e2df
movq 0x30(%rsp), %rdi
movl $0x3, %esi
callq 0x5d750
movq %rax, 0x20(%rsp)
cmpq $0x0, 0x20(%rsp)
jne 0x5e2c1
movl $0x0, 0x44(%rsp)
jmp 0x5e58c
movq 0x20(%rsp), %rdi
leaq 0x469f(%rip), %rsi      # 0x6296c
callq 0x2290
movl $0x1, 0x44(%rsp)
jmp 0x5e58c
movq 0x38(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rax
cmpb $0x0, (%rax)
je 0x5e36f
movq 0x28(%rsp), %rax
movzbl (%rax), %eax
movl %eax, 0x4(%rsp)
addl $-0x8, %eax
subl $0x3, %eax
jb 0x5e32d
jmp 0x5e309
movl 0x4(%rsp), %eax
addl $-0xc, %eax
subl $0x2, %eax
jb 0x5e32d
jmp 0x5e317
movl 0x4(%rsp), %eax
subl $0x22, %eax
je 0x5e32d
jmp 0x5e322
movl 0x4(%rsp), %eax
subl $0x5c, %eax
jne 0x5e33d
jmp 0x5e32d
movq 0x8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x8(%rsp)
jmp 0x5e35a
movq 0x28(%rsp), %rax
movzbl (%rax), %eax
cmpl $0x20, %eax
jge 0x5e358
movq 0x8(%rsp), %rax
addq $0x5, %rax
movq %rax, 0x8(%rsp)
jmp 0x5e35a
jmp 0x5e35c
movq 0x28(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x28(%rsp)
jmp 0x5e2e9
movq 0x28(%rsp), %rax
movq 0x38(%rsp), %rcx
subq %rcx, %rax
addq 0x8(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x30(%rsp), %rdi
movq 0x10(%rsp), %rsi
addq $0x3, %rsi
callq 0x5d750
movq %rax, 0x20(%rsp)
cmpq $0x0, 0x20(%rsp)
jne 0x5e3b3
movl $0x0, 0x44(%rsp)
jmp 0x5e58c
cmpq $0x0, 0x8(%rsp)
jne 0x5e406
movq 0x20(%rsp), %rax
movb $0x22, (%rax)
movq 0x20(%rsp), %rdi
addq $0x1, %rdi
movq 0x38(%rsp), %rsi
movq 0x10(%rsp), %rdx
callq 0x2220
movq 0x20(%rsp), %rax
movq 0x10(%rsp), %rcx
movb $0x22, 0x1(%rax,%rcx)
movq 0x20(%rsp), %rax
movq 0x10(%rsp), %rcx
movb $0x0, 0x2(%rax,%rcx)
movl $0x1, 0x44(%rsp)
jmp 0x5e58c
movq 0x20(%rsp), %rax
movb $0x22, (%rax)
movq 0x20(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x18(%rsp)
movq 0x38(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rax
movzbl (%rax), %eax
cmpl $0x0, %eax
je 0x5e566
movq 0x28(%rsp), %rax
movzbl (%rax), %eax
cmpl $0x1f, %eax
jle 0x5e471
movq 0x28(%rsp), %rax
movzbl (%rax), %eax
cmpl $0x22, %eax
je 0x5e471
movq 0x28(%rsp), %rax
movzbl (%rax), %eax
cmpl $0x5c, %eax
je 0x5e471
movq 0x28(%rsp), %rax
movb (%rax), %cl
movq 0x18(%rsp), %rax
movb %cl, (%rax)
jmp 0x5e543
movq 0x18(%rsp), %rax
movq %rax, %rcx
incq %rcx
movq %rcx, 0x18(%rsp)
movb $0x5c, (%rax)
movq 0x28(%rsp), %rax
movzbl (%rax), %eax
movl %eax, (%rsp)
subl $0x8, %eax
je 0x5e4e6
jmp 0x5e496
movl (%rsp), %eax
subl $0x9, %eax
je 0x5e50e
jmp 0x5e4a0
movl (%rsp), %eax
subl $0xa, %eax
je 0x5e4fa
jmp 0x5e4aa
movl (%rsp), %eax
subl $0xc, %eax
je 0x5e4f0
jmp 0x5e4b4
movl (%rsp), %eax
subl $0xd, %eax
je 0x5e504
jmp 0x5e4be
movl (%rsp), %eax
subl $0x22, %eax
je 0x5e4dc
jmp 0x5e4c8
movl (%rsp), %eax
subl $0x5c, %eax
jne 0x5e518
jmp 0x5e4d2
movq 0x18(%rsp), %rax
movb $0x5c, (%rax)
jmp 0x5e541
movq 0x18(%rsp), %rax
movb $0x22, (%rax)
jmp 0x5e541
movq 0x18(%rsp), %rax
movb $0x62, (%rax)
jmp 0x5e541
movq 0x18(%rsp), %rax
movb $0x66, (%rax)
jmp 0x5e541
movq 0x18(%rsp), %rax
movb $0x6e, (%rax)
jmp 0x5e541
movq 0x18(%rsp), %rax
movb $0x72, (%rax)
jmp 0x5e541
movq 0x18(%rsp), %rax
movb $0x74, (%rax)
jmp 0x5e541
movq 0x18(%rsp), %rdi
movq 0x28(%rsp), %rax
movzbl (%rax), %edx
leaq 0x4443(%rip), %rsi      # 0x6296f
movb $0x0, %al
callq 0x2060
movq 0x18(%rsp), %rax
addq $0x4, %rax
movq %rax, 0x18(%rsp)
jmp 0x5e543
jmp 0x5e545
movq 0x28(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x28(%rsp)
movq 0x18(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x18(%rsp)
jmp 0x5e426
movq 0x20(%rsp), %rax
movq 0x10(%rsp), %rcx
movb $0x22, 0x1(%rax,%rcx)
movq 0x20(%rsp), %rax
movq 0x10(%rsp), %rcx
movb $0x0, 0x2(%rax,%rcx)
movl $0x1, 0x44(%rsp)
movl 0x44(%rsp), %eax
addq $0x48, %rsp
retq
nopw %cs:(%rax,%rax)