// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %rax
movq %rsi, %rbx
movq (%rsi), %rcx
movq 0x10(%rsi), %rax
leaq (%rcx,%rax), %r13
incq %r13
cmpb $0x22, -0x1(%r13)
jne 0x2a092
movq %rdi, %r14
addq %rcx, %rax
movq 0x8(%rbx), %rsi
xorl %edx, %edx
movq %r13, %rbp
movq %rbp, %rdi
subq %rcx, %rdi
cmpq %rsi, %rdi
jae 0x2a092
movzbl (%rbp), %edi
cmpl $0x5c, %edi
je 0x29e65
cmpl $0x22, %edi
jne 0x29e7a
jmp 0x29e7f
incq %rbp
movq %rbp, %rdi
subq %rcx, %rdi
cmpq %rsi, %rdi
jae 0x2a092
incq %rdx
incq %rbp
jmp 0x29e46
addq %rax, %rdx
movq %rbp, %rdi
subq %rdx, %rdi
incq %rdi
callq *0x20(%rbx)
testq %rax, %rax
je 0x2a092
pushq $0x2
popq %r11
leaq 0x3a3e(%rip), %rdi      # 0x2d8e0
movq %rax, (%rsp)
movq %rax, %r15
cmpq %rbp, %r13
jae 0x2a0aa
movb (%r13), %al
cmpb $0x5c, %al
jne 0x29f02
movq %rbp, %rcx
subq %r13, %rcx
testq %rcx, %rcx
jle 0x2a08b
movb 0x1(%r13), %dl
movzbl %dl, %eax
leal -0x6e(%rax), %esi
cmpl $0x7, %esi
jbe 0x29f0d
cmpl $0x22, %eax
je 0x29f1c
cmpl $0x2f, %eax
je 0x29f1c
cmpl $0x5c, %eax
je 0x29f1c
cmpl $0x66, %eax
je 0x29f8a
cmpl $0x62, %eax
jne 0x2a08b
movb $0x8, (%r15)
jmp 0x29f8e
incq %r13
movb %al, (%r15)
incq %r15
jmp 0x29ea9
movslq (%rdi,%rsi,4), %rax
addq %rdi, %rax
jmpq *%rax
movb $0xa, (%r15)
jmp 0x29f8e
movb %dl, (%r15)
jmp 0x29f8e
movb $0xd, (%r15)
jmp 0x29f8e
cmpq $0x6, %rcx
jb 0x2a08b
leaq 0x2(%r13), %rdi
callq 0x2a0cc
movl %eax, %r12d
andl $0xfffffc00, %eax       # imm = 0xFFFFFC00
cmpl $0xd800, %eax           # imm = 0xD800
je 0x29f9c
cmpl $0xdc00, %eax           # imm = 0xDC00
pushq $0x2
popq %r11
je 0x2a08b
cmpl $0x80, %r12d
jb 0x2a00c
movl $0xc0, %edx
movb $0x1, %cl
cmpl $0x800, %r12d           # imm = 0x800
jae 0x2a062
pushq $0x6
popq %rax
movq %r11, %rsi
jmp 0x2a016
movb $0x9, (%r15)
jmp 0x29f8e
movb $0xc, (%r15)
incq %r15
movq %r11, %rax
addq %rax, %r13
jmp 0x29ea9
leaq 0x6(%r13), %rax
movq %rbp, %rcx
subq %rax, %rcx
cmpq $0x6, %rcx
jl 0x2a08b
cmpb $0x5c, (%rax)
jne 0x2a08b
cmpb $0x75, 0x7(%r13)
jne 0x2a08b
leaq 0x8(%r13), %rdi
callq 0x2a0cc
pushq $0x2
popq %r11
leal -0xe000(%rax), %ecx
cmpl $0xfffffc00, %ecx       # imm = 0xFFFFFC00
jb 0x2a08b
shll $0xa, %r12d
andl $0xffc00, %r12d         # imm = 0xFFC00
andl $0x3ff, %eax            # imm = 0x3FF
addl %eax, %r12d
addl $0x10000, %r12d         # imm = 0x10000
movl $0xf0, %edx
movb $0x1, %cl
pushq $0xc
popq %rax
pushq $0x4
popq %rsi
jmp 0x2a016
xorl %ecx, %ecx
pushq $0x6
popq %rax
pushq $0x1
popq %rsi
xorl %edx, %edx
movl %r12d, %edi
leaq -0x1(%rsi), %r9
movq %r9, %r8
subq $0x1, %r8
jb 0x2a03e
movl %edi, %r10d
andb $0x3f, %r10b
orb $-0x80, %r10b
movb %r10b, (%r15,%r9)
shrq $0x6, %rdi
movq %r8, %r9
jmp 0x2a020
movl %edi, %r8d
andb $0x7f, %r8b
orl %edx, %edi
movzbl %r8b, %edx
testb %cl, %cl
cmovnel %edi, %edx
movb %dl, (%r15)
addq %rsi, %r15
leaq 0x3883(%rip), %rdi      # 0x2d8e0
jmp 0x29f94
movl $0xe0, %edx
cmpl $0x10000, %r12d         # imm = 0x10000
jae 0x2a077
pushq $0x6
popq %rax
pushq $0x3
jmp 0x2a009
movl $0xf0, %edx
pushq $0x6
popq %rax
pushq $0x4
popq %rsi
cmpl $0x10ffff, %r12d        # imm = 0x10FFFF
jbe 0x2a016
movq (%rsp), %rdi
callq *0x28(%rbx)
subq (%rbx), %r13
xorl %eax, %eax
movq %r13, 0x10(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x0, (%r15)
movl $0x10, 0x18(%r14)
movq (%rsp), %rax
movq %rax, 0x20(%r14)
subq (%rbx), %rbp
incq %rbp
pushq $0x1
popq %rax
movq %rbp, %r13
jmp 0x2a097