// File: /workspace/github_c_makefile_star2_O3/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
subq $0x18, %rsp
movq %rsi, %rbx
movq (%rsi), %rax
movq 0x10(%rsi), %rbp
leaq (%rax,%rbp), %r15
incq %r15
cmpb $0x22, -0x1(%r15)
jne 0x71ed
movq 0x8(%rbx), %rcx
movq %r15, %rdx
subq %rax, %rdx
cmpq %rcx, %rdx
jae 0x71ed
movq %rdi, %r12
addq %rax, %rbp
movl $0x1, %r14d
xorl %edx, %edx
movq %r15, %r13
movzbl (%rbp,%r14), %esi
cmpl $0x5c, %esi
je 0x71c3
cmpl $0x22, %esi
jne 0x71d8
jmp 0x7205
leaq (%r14,%rbp), %rsi
incq %rsi
subq %rax, %rsi
cmpq %rcx, %rsi
jae 0x71ed
incq %r14
incq %rdx
leaq (%r14,%rbp), %r13
incq %r13
incq %r14
movq %r13, %rsi
subq %rax, %rsi
cmpq %rcx, %rsi
jb 0x71b1
subq (%rbx), %r15
xorl %eax, %eax
movq %r15, 0x10(%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq %rbp, %rdx
movq %r13, %rdi
subq %rdx, %rdi
incq %rdi
callq *0x20(%rbx)
testq %rax, %rax
je 0x71ed
movq %rax, %r10
movq %r12, 0x10(%rsp)
movq %rax, %r12
cmpq $0x2, %r14
jl 0x743d
addq %r14, %rbp
leaq 0x16e0(%rip), %r11      # 0x8918
movq %r10, %r12
movb (%r15), %al
cmpb $0x5c, %al
jne 0x7281
movq %r13, %rcx
subq %r15, %rcx
testq %rcx, %rcx
jle 0x7465
movb 0x1(%r15), %dl
movzbl %dl, %eax
cmpl $0x61, %eax
jg 0x7295
cmpl $0x22, %eax
je 0x7270
cmpl $0x2f, %eax
je 0x7270
cmpl $0x5c, %eax
jne 0x7465
movb %dl, (%r12)
incq %r12
movl $0x2, %eax
addq %rax, %r15
jmp 0x728b
incq %r15
movb %al, (%r12)
incq %r12
cmpq %rbp, %r15
jb 0x723b
jmp 0x743d
leal -0x6e(%rax), %edx
cmpl $0x7, %edx
ja 0x72ad
movslq (%r11,%rdx,4), %rax
addq %r11, %rax
jmpq *%rax
movb $0xa, (%r12)
jmp 0x7274
cmpl $0x66, %eax
je 0x733f
cmpl $0x62, %eax
jne 0x7465
movb $0x8, (%r12)
jmp 0x7274
cmpq $0x6, %rcx
jb 0x7465
movq %r10, %r14
leaq 0x2(%r15), %rdi
callq 0x7606
movl %eax, %esi
andl $0xfffffc00, %eax       # imm = 0xFFFFFC00
cmpl $0xd800, %eax           # imm = 0xD800
je 0x7349
cmpl $0xdc00, %eax           # imm = 0xDC00
movq %r14, %r10
leaq 0x161f(%rip), %r11      # 0x8918
je 0x7465
cmpl $0x80, %esi
jb 0x73fd
movl $0x6, %eax
cmpl $0x800, %esi            # imm = 0x800
jae 0x7415
movl $0xc0, %ecx
movl $0x2, %edx
jmp 0x73c8
movb $0x9, (%r12)
jmp 0x7274
movb $0xd, (%r12)
jmp 0x7274
movb $0xc, (%r12)
jmp 0x7274
leaq 0x6(%r15), %rax
movq %r13, %rcx
subq %rax, %rcx
cmpq $0x6, %rcx
movq %r14, %r10
jl 0x7465
cmpb $0x5c, (%rax)
jne 0x7465
cmpb $0x75, 0x7(%r15)
jne 0x7465
leaq 0x8(%r15), %rdi
movq %rsi, 0x8(%rsp)
callq 0x7606
movq 0x8(%rsp), %rsi
leaq 0x158a(%rip), %r11      # 0x8918
movq %r14, %r10
leal -0xe000(%rax), %ecx
cmpl $0xfffffc00, %ecx       # imm = 0xFFFFFC00
jb 0x7465
shll $0xa, %esi
andl $0xffc00, %esi          # imm = 0xFFC00
andl $0x3ff, %eax            # imm = 0x3FF
addl %eax, %esi
addl $0x10000, %esi          # imm = 0x10000
movl $0xf0, %ecx
movl $0x4, %edx
movl $0xc, %eax
movl %esi, %esi
leal -0x1(%rdx), %edi
movzbl %dil, %edi
decq %rdi
movq %rdi, %r8
movl %esi, %r9d
andb $0x3f, %r9b
orb $-0x80, %r9b
movb %r9b, 0x1(%r12,%rdi)
shrq $0x6, %rsi
decq %r8
testb %dil, %dil
movq %r8, %rdi
jne 0x73d7
orq %rcx, %rsi
movl %edx, %ecx
jmp 0x7409
movl %esi, %esi
movl $0x1, %ecx
movl $0x6, %eax
movb %sil, (%r12)
addq %rcx, %r12
jmp 0x727c
cmpl $0x10000, %esi          # imm = 0x10000
jae 0x7429
movl $0xe0, %ecx
movl $0x3, %edx
jmp 0x73c8
cmpl $0x10ffff, %esi         # imm = 0x10FFFF
ja 0x7465
movl $0xf0, %ecx
movl $0x4, %edx
jmp 0x73c8
movb $0x0, (%r12)
movq 0x10(%rsp), %rax
movl $0x10, 0x18(%rax)
movq %r10, 0x20(%rax)
subq (%rbx), %r13
incq %r13
movl $0x1, %eax
movq %r13, %r15
jmp 0x71f2
movq %r10, %rdi
callq *0x28(%rbx)
jmp 0x71ed