// File: /workspace/github_c_makefile_star2_O1/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), %r12
incq %r12
cmpb $0x22, -0x1(%r12)
jne 0x7397
movq %rdi, %r11
addq %rax, %rbp
movq 0x8(%rbx), %rdx
movq %r12, %rcx
subq %rax, %rcx
cmpq %rdx, %rcx
setb %sil
jae 0x739e
movl $0x1, %r14d
xorl %ecx, %ecx
movq %r12, %r13
movzbl (%rbp,%r14), %edi
cmpl $0x5c, %edi
je 0x7367
cmpl $0x22, %edi
jne 0x737c
jmp 0x73ab
leaq (%r14,%rbp), %rsi
incq %rsi
subq %rax, %rsi
cmpq %rdx, %rsi
jae 0x73d9
incq %r14
incq %rcx
leaq (%r14,%rbp), %r13
incq %r13
incq %r14
movq %r13, %rsi
subq %rax, %rsi
cmpq %rdx, %rsi
setb %sil
jb 0x7355
jmp 0x73d9
xorl %edi, %edi
jmp 0x7645
xorl %edi, %edi
movl $0x1, %r14d
movq %r12, %r13
jmp 0x73db
testb $0x1, %sil
je 0x73d9
cmpb $0x22, (%rbp,%r14)
jne 0x73d9
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 0x73dd
xorl %edi, %edi
xorl %eax, %eax
testb %al, %al
je 0x7645
movq %rdi, %r15
cmpq $0x2, %r14
jl 0x7657
addq %r14, %rbp
leaq 0x151c(%rip), %r14      # 0x8918
movq %rdi, %r15
movb (%r12), %al
cmpb $0x5c, %al
jne 0x7439
movq %r13, %rsi
subq %r12, %rsi
testq %rsi, %rsi
jle 0x75d8
movb 0x1(%r12), %cl
movzbl %cl, %edx
xorl %eax, %eax
cmpl $0x61, %edx
jg 0x7447
cmpl $0x22, %edx
je 0x7483
cmpl $0x2f, %edx
je 0x7483
cmpl $0x5c, %edx
je 0x7483
jmp 0x75da
incq %r12
movb %al, (%r15)
incq %r15
jmp 0x75de
leal -0x6e(%rdx), %ecx
cmpl $0x7, %ecx
ja 0x745c
movslq (%r14,%rcx,4), %rcx
addq %r14, %rcx
jmpq *%rcx
movb $0xa, %cl
jmp 0x7483
movb $0x8, %cl
cmpl $0x62, %edx
je 0x7483
cmpl $0x66, %edx
jne 0x75da
movb $0xc, %cl
jmp 0x7483
cmpq $0x6, %rsi
jge 0x7498
xorl %eax, %eax
jmp 0x75d0
movb $0xd, %cl
jmp 0x7483
movb $0x9, %cl
movb %cl, (%r15)
incq %r15
movb $0x2, %al
movzbl %al, %eax
addq %rax, %r12
movb $0x1, %al
jmp 0x75da
movq %rdi, 0x8(%rsp)
movq %r11, %r14
leaq 0x2(%r12), %rdi
callq 0x7842
movl %eax, %ecx
andl $0xfffffc00, %ecx       # imm = 0xFFFFFC00
cmpl $0xdc00, %ecx           # imm = 0xDC00
je 0x7512
cmpl $0xd800, %ecx           # imm = 0xD800
jne 0x7528
leaq 0x6(%r12), %rdx
movq %r13, %rcx
subq %rdx, %rcx
cmpq $0x6, %rcx
movq %r14, %r11
movq 0x8(%rsp), %rdi
jl 0x753d
cmpb $0x5c, (%rdx)
jne 0x753d
cmpb $0x75, 0x7(%r12)
jne 0x753d
movq %rax, 0x10(%rsp)
leaq 0x8(%r12), %rdi
callq 0x7842
leal -0xe000(%rax), %ecx
cmpl $0xfffffc00, %ecx       # imm = 0xFFFFFC00
jae 0x761b
xorl %ecx, %ecx
xorl %edx, %edx
jmp 0x7638
xorl %eax, %eax
movq %r14, %r11
movq 0x8(%rsp), %rdi
leaq 0x13f5(%rip), %r14      # 0x8918
jmp 0x75d0
movl %eax, %ecx
movb $0x6, %al
movq %r14, %r11
movq 0x8(%rsp), %rdi
leaq 0x13dd(%rip), %r14      # 0x8918
jmp 0x7552
xorl %ecx, %ecx
xorl %edx, %edx
movb $0xc, %al
testb %dl, %dl
leaq 0x13cc(%rip), %r14      # 0x8918
je 0x7476
cmpl $0x80, %ecx
jb 0x7572
cmpl $0x800, %ecx            # imm = 0x800
jae 0x75e9
movl $0xc0, %esi
movl $0x2, %edx
jmp 0x7579
movl $0x1, %edx
xorl %esi, %esi
movl %edx, %r8d
movq %rcx, %rdi
decb %r8b
je 0x75b0
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 0x7591
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 0x748b
xorl %eax, %eax
testb %al, %al
je 0x7645
cmpq %rbp, %r12
jb 0x73ff
jmp 0x7657
cmpl $0x10000, %ecx          # imm = 0x10000
jae 0x7600
movl $0xe0, %esi
movl $0x3, %edx
jmp 0x7579
cmpl $0x10ffff, %ecx         # imm = 0x10FFFF
ja 0x7476
movl $0xf0, %esi
movl $0x4, %edx
jmp 0x7579
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 0x7541
testq %rdi, %rdi
je 0x764d
callq *0x28(%rbx)
subq (%rbx), %r12
xorl %eax, %eax
movq %r12, %r13
jmp 0x7672
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