// File: /workspace/github_c_makefile_star2_O2/tomcatzh[P]RealityBenchmark/external/cJSON.c
// Function: parse_string
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 0x6c09
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 0x6c09
movzbl (%rbp), %edi
cmpl $0x5c, %edi
je 0x69dc
cmpl $0x22, %edi
jne 0x69f1
jmp 0x69f6
incq %rbp
movq %rbp, %rdi
subq %rcx, %rdi
cmpq %rsi, %rdi
jae 0x6c09
incq %rdx
incq %rbp
jmp 0x69bd
addq %rax, %rdx
movq %rbp, %rdi
subq %rdx, %rdi
incq %rdi
callq *0x20(%rbx)
testq %rax, %rax
je 0x6c09
pushq $0x2
popq %r11
leaq 0xf37(%rip), %rdi       # 0x7950
movq %rax, (%rsp)
movq %rax, %r15
cmpq %rbp, %r13
jae 0x6c21
movb (%r13), %al
cmpb $0x5c, %al
jne 0x6a79
movq %rbp, %rcx
subq %r13, %rcx
testq %rcx, %rcx
jle 0x6c02
movb 0x1(%r13), %dl
movzbl %dl, %eax
leal -0x6e(%rax), %esi
cmpl $0x7, %esi
jbe 0x6a84
cmpl $0x22, %eax
je 0x6a93
cmpl $0x2f, %eax
je 0x6a93
cmpl $0x5c, %eax
je 0x6a93
cmpl $0x66, %eax
je 0x6b01
cmpl $0x62, %eax
jne 0x6c02
movb $0x8, (%r15)
jmp 0x6b05
incq %r13
movb %al, (%r15)
incq %r15
jmp 0x6a20
movslq (%rdi,%rsi,4), %rax
addq %rdi, %rax
jmpq *%rax
movb $0xa, (%r15)
jmp 0x6b05
movb %dl, (%r15)
jmp 0x6b05
movb $0xd, (%r15)
jmp 0x6b05
cmpq $0x6, %rcx
jb 0x6c02
leaq 0x2(%r13), %rdi
callq 0x6c43
movl %eax, %r12d
andl $0xfffffc00, %eax       # imm = 0xFFFFFC00
cmpl $0xd800, %eax           # imm = 0xD800
je 0x6b13
cmpl $0xdc00, %eax           # imm = 0xDC00
pushq $0x2
popq %r11
je 0x6c02
cmpl $0x80, %r12d
jb 0x6b83
movl $0xc0, %edx
movb $0x1, %cl
cmpl $0x800, %r12d           # imm = 0x800
jae 0x6bd9
pushq $0x6
popq %rax
movq %r11, %rsi
jmp 0x6b8d
movb $0x9, (%r15)
jmp 0x6b05
movb $0xc, (%r15)
incq %r15
movq %r11, %rax
addq %rax, %r13
jmp 0x6a20
leaq 0x6(%r13), %rax
movq %rbp, %rcx
subq %rax, %rcx
cmpq $0x6, %rcx
jl 0x6c02
cmpb $0x5c, (%rax)
jne 0x6c02
cmpb $0x75, 0x7(%r13)
jne 0x6c02
leaq 0x8(%r13), %rdi
callq 0x6c43
pushq $0x2
popq %r11
leal -0xe000(%rax), %ecx
cmpl $0xfffffc00, %ecx       # imm = 0xFFFFFC00
jb 0x6c02
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 0x6b8d
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 0x6bb5
movl %edi, %r10d
andb $0x3f, %r10b
orb $-0x80, %r10b
movb %r10b, (%r15,%r9)
shrq $0x6, %rdi
movq %r8, %r9
jmp 0x6b97
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 0xd7c(%rip), %rdi       # 0x7950
jmp 0x6b0b
movl $0xe0, %edx
cmpl $0x10000, %r12d         # imm = 0x10000
jae 0x6bee
pushq $0x6
popq %rax
pushq $0x3
jmp 0x6b80
movl $0xf0, %edx
pushq $0x6
popq %rax
pushq $0x4
popq %rsi
cmpl $0x10ffff, %r12d        # imm = 0x10FFFF
jbe 0x6b8d
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 0x6c0e