// File: /workspace/github_cpp_makefile_star2_O1/Eba-M[P]E3DC-Control/cJSON.c
// Function: parse_string(cJSON*, parse_buffer*)
static cJSON_bool parse_string(cJSON * const item, parse_buffer * const input_buffer)
{
    const unsigned char *input_pointer = buffer_at_offset(input_buffer) + 1;
    const unsigned char *input_end = buffer_at_offset(input_buffer) + 1;
    unsigned char *output_pointer = NULL;
    unsigned char *output = NULL;

    /* not a string */
    if (buffer_at_offset(input_buffer)[0] != '\"')
    {
        goto fail;
    }

    {
        /* calculate approximate size of the output (overestimate) */
        size_t allocation_length = 0;
        size_t skipped_bytes = 0;
        while (((size_t)(input_end - input_buffer->content) < input_buffer->length) && (*input_end != '\"'))
        {
            /* is escape sequence */
            if (input_end[0] == '\\')
            {
                if ((size_t)(input_end + 1 - input_buffer->content) >= input_buffer->length)
                {
                    /* prevent buffer overflow when last input character is a backslash */
                    goto fail;
                }
                skipped_bytes++;
                input_end++;
            }
            input_end++;
        }
        if (((size_t)(input_end - input_buffer->content) >= input_buffer->length) || (*input_end != '\"'))
        {
            goto fail; /* string ended unexpectedly */
        }

        /* This is at most how much we need for the output */
        allocation_length = (size_t) (input_end - buffer_at_offset(input_buffer)) - skipped_bytes;
        output = (unsigned char*)input_buffer->hooks.allocate(allocation_length + sizeof(""));
        if (output == NULL)
        {
            goto fail; /* allocation failure */
        }
    }

    output_pointer = output;
    /* loop through the string literal */
    while (input_pointer < input_end)
    {
        if (*input_pointer != '\\')
        {
            *output_pointer++ = *input_pointer++;
        }
        /* escape sequence */
        else
        {
            unsigned char sequence_length = 2;
            if ((input_end - input_pointer) < 1)
            {
                goto fail;
            }

            switch (input_pointer[1])
            {
                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;
                case '\"':
                case '\\':
                case '/':
                    *output_pointer++ = input_pointer[1];
                    break;

                /* UTF-16 literal */
                case 'u':
                    sequence_length = utf16_literal_to_utf8(input_pointer, input_end, &output_pointer);
                    if (sequence_length == 0)
                    {
                        /* failed to convert UTF16-literal to UTF-8 */
                        goto fail;
                    }
                    break;

                default:
                    goto fail;
            }
            input_pointer += sequence_length;
        }
    }

    /* zero terminate the output */
    *output_pointer = '\0';

    item->type = cJSON_String;
    item->valuestring = (char*)output;

    input_buffer->offset = (size_t) (input_end - input_buffer->content);
    input_buffer->offset++;

    return true;

fail:
    if (output != NULL)
    {
        input_buffer->hooks.deallocate(output);
    }

    if (input_pointer != NULL)
    {
        input_buffer->offset = (size_t)(input_pointer - input_buffer->content);
    }

    return false;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movq (%rsi), %rax
movq 0x10(%rsi), %rbp
leaq (%rax,%rbp), %r12
incq %r12
cmpb $0x22, -0x1(%r12)
jne 0x2e75d
movq %rdi, %r11
addq %rax, %rbp
movq 0x8(%rbx), %rdx
movq %r12, %rcx
subq %rax, %rcx
cmpq %rdx, %rcx
setb %sil
jae 0x2e764
movl $0x1, %r14d
xorl %ecx, %ecx
movq %r12, %r13
movzbl (%rbp,%r14), %edi
cmpl $0x5c, %edi
je 0x2e72d
cmpl $0x22, %edi
jne 0x2e742
jmp 0x2e771
leaq (%r14,%rbp), %rsi
incq %rsi
subq %rax, %rsi
cmpq %rdx, %rsi
jae 0x2e79f
incq %r14
incq %rcx
leaq (%r14,%rbp), %r13
incq %r13
incq %r14
movq %r13, %rsi
subq %rax, %rsi
cmpq %rdx, %rsi
setb %sil
jb 0x2e71b
jmp 0x2e79f
xorl %edi, %edi
jmp 0x2ea0b
xorl %edi, %edi
movl $0x1, %r14d
movq %r12, %r13
jmp 0x2e7a1
testb $0x1, %sil
je 0x2e79f
cmpb $0x22, (%rbp,%r14)
jne 0x2e79f
addq %rbp, %rcx
movq %r13, %rdi
subq %rcx, %rdi
incq %rdi
movq %r11, %r15
callq *0x20(%rbx)
movq %r15, %r11
movq %rax, %rdi
testq %rax, %rax
setne %al
jmp 0x2e7a3
xorl %edi, %edi
xorl %eax, %eax
testb %al, %al
je 0x2ea0b
movq %rdi, %r15
cmpq $0x2, %r14
jl 0x2ea1d
addq %r14, %rbp
leaq 0x42fe(%rip), %r14      # 0x32ac0
movq %rdi, %r15
movb (%r12), %al
cmpb $0x5c, %al
jne 0x2e7ff
movq %r13, %rsi
subq %r12, %rsi
testq %rsi, %rsi
jle 0x2e99e
movb 0x1(%r12), %cl
movzbl %cl, %edx
xorl %eax, %eax
cmpl $0x61, %edx
jg 0x2e80d
cmpl $0x22, %edx
je 0x2e849
cmpl $0x2f, %edx
je 0x2e849
cmpl $0x5c, %edx
je 0x2e849
jmp 0x2e9a0
incq %r12
movb %al, (%r15)
incq %r15
jmp 0x2e9a4
leal -0x6e(%rdx), %ecx
cmpl $0x7, %ecx
ja 0x2e822
movslq (%r14,%rcx,4), %rcx
addq %r14, %rcx
jmpq *%rcx
movb $0xa, %cl
jmp 0x2e849
movb $0x8, %cl
cmpl $0x62, %edx
je 0x2e849
cmpl $0x66, %edx
jne 0x2e9a0
movb $0xc, %cl
jmp 0x2e849
cmpq $0x6, %rsi
jge 0x2e85e
xorl %eax, %eax
jmp 0x2e996
movb $0xd, %cl
jmp 0x2e849
movb $0x9, %cl
movb %cl, (%r15)
incq %r15
movb $0x2, %al
movzbl %al, %eax
addq %rax, %r12
movb $0x1, %al
jmp 0x2e9a0
movq %rdi, 0x8(%rsp)
movq %r11, %r14
leaq 0x2(%r12), %rdi
callq 0x2ec14
movl %eax, %ecx
andl $0xfffffc00, %ecx       # imm = 0xFFFFFC00
cmpl $0xdc00, %ecx           # imm = 0xDC00
je 0x2e8d8
cmpl $0xd800, %ecx           # imm = 0xD800
jne 0x2e8ee
leaq 0x6(%r12), %rdx
movq %r13, %rcx
subq %rdx, %rcx
cmpq $0x6, %rcx
movq %r14, %r11
movq 0x8(%rsp), %rdi
jl 0x2e903
cmpb $0x5c, (%rdx)
jne 0x2e903
cmpb $0x75, 0x7(%r12)
jne 0x2e903
movq %rax, 0x10(%rsp)
leaq 0x8(%r12), %rdi
callq 0x2ec14
leal -0xe000(%rax), %ecx
cmpl $0xfffffc00, %ecx       # imm = 0xFFFFFC00
jae 0x2e9e1
xorl %ecx, %ecx
xorl %edx, %edx
jmp 0x2e9fe
xorl %eax, %eax
movq %r14, %r11
movq 0x8(%rsp), %rdi
leaq 0x41d7(%rip), %r14      # 0x32ac0
jmp 0x2e996
movl %eax, %ecx
movb $0x6, %al
movq %r14, %r11
movq 0x8(%rsp), %rdi
leaq 0x41bf(%rip), %r14      # 0x32ac0
jmp 0x2e918
xorl %ecx, %ecx
xorl %edx, %edx
movb $0xc, %al
testb %dl, %dl
leaq 0x41ae(%rip), %r14      # 0x32ac0
je 0x2e83c
cmpl $0x80, %ecx
jb 0x2e938
cmpl $0x800, %ecx            # imm = 0x800
jae 0x2e9af
movl $0xc0, %esi
movl $0x2, %edx
jmp 0x2e93f
movl $0x1, %edx
xorl %esi, %esi
movl %edx, %r8d
movq %rcx, %rdi
decb %r8b
je 0x2e976
movzbl %r8b, %r8d
decq %r8
movq %rcx, %rdi
movq %r8, %r9
movl %edi, %r10d
andb $0x3f, %r10b
orb $-0x80, %r10b
movb %r10b, 0x1(%r15,%r8)
shrq $0x6, %rdi
decq %r9
testb %r8b, %r8b
movq %r9, %r8
jne 0x2e957
movl %edi, %r8d
andb $0x7f, %r8b
orl %esi, %edi
cmpl $0x7f, %ecx
movzbl %r8b, %ecx
cmoval %edi, %ecx
movb %cl, (%r15)
movl %edx, %ecx
addq %rcx, %r15
movq 0x8(%rsp), %rdi
testb %al, %al
jne 0x2e851
xorl %eax, %eax
testb %al, %al
je 0x2ea0b
cmpq %rbp, %r12
jb 0x2e7c5
jmp 0x2ea1d
cmpl $0x10000, %ecx          # imm = 0x10000
jae 0x2e9c6
movl $0xe0, %esi
movl $0x3, %edx
jmp 0x2e93f
cmpl $0x10ffff, %ecx         # imm = 0x10FFFF
ja 0x2e83c
movl $0xf0, %esi
movl $0x4, %edx
jmp 0x2e93f
movq 0x10(%rsp), %rcx
shll $0xa, %ecx
andl $0xffc00, %ecx          # imm = 0xFFC00
andl $0x3ff, %eax            # imm = 0x3FF
addl %eax, %ecx
addl $0x10000, %ecx          # imm = 0x10000
movb $0x1, %dl
movq %r14, %r11
movq 0x8(%rsp), %rdi
jmp 0x2e907
testq %rdi, %rdi
je 0x2ea13
callq *0x28(%rbx)
subq (%rbx), %r12
xorl %eax, %eax
movq %r12, %r13
jmp 0x2ea38
movb $0x0, (%r15)
movl $0x10, 0x18(%r11)
movq %rdi, 0x20(%r11)
subq (%rbx), %r13
incq %r13
movl $0x1, %eax
movq %r13, 0x10(%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq