// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
addq 0x10(%rcx), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
addq 0x10(%rcx), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x22, %eax
je 0x98fb
jmp 0x9b99
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x28(%rbp), %rcx
movq -0x18(%rbp), %rax
movq (%rax), %rax
subq %rax, %rcx
movq -0x18(%rbp), %rdx
xorl %eax, %eax
cmpq 0x8(%rdx), %rcx
movb %al, -0x4a(%rbp)
jae 0x9938
movq -0x28(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x22, %eax
setne %al
movb %al, -0x4a(%rbp)
movb -0x4a(%rbp), %al
testb $0x1, %al
jne 0x9941
jmp 0x9997
movq -0x28(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x5c, %eax
jne 0x9986
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq -0x18(%rbp), %rcx
movq (%rcx), %rcx
subq %rcx, %rax
movq -0x18(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jb 0x996e
jmp 0x9b99
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x990b
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
movq (%rcx), %rcx
subq %rcx, %rax
movq -0x18(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jae 0x99bb
movq -0x28(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x22, %eax
je 0x99c0
jmp 0x9b99
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
movq (%rcx), %rcx
movq -0x18(%rbp), %rdx
addq 0x10(%rdx), %rcx
subq %rcx, %rax
subq -0x48(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x40(%rbp), %rdi
addq $0x1, %rdi
callq *%rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x9a00
jmp 0x9b99
movq -0x38(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x9b4c
movq -0x20(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x5c, %eax
je 0x9a49
movq -0x20(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x20(%rbp)
movb (%rax), %cl
movq -0x30(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x30(%rbp)
movb %cl, (%rax)
jmp 0x9b47
movb $0x2, -0x49(%rbp)
movq -0x28(%rbp), %rax
movq -0x20(%rbp), %rcx
subq %rcx, %rax
cmpq $0x1, %rax
jge 0x9a63
jmp 0x9b99
movq -0x20(%rbp), %rax
movzbl 0x1(%rax), %eax
addl $-0x22, %eax
movl %eax, %ecx
movq %rcx, -0x58(%rbp)
subl $0x53, %eax
ja 0x9b33
movq -0x58(%rbp), %rax
leaq 0x3018(%rip), %rcx      # 0xcaa0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x30(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x30(%rbp)
movb $0x8, (%rax)
jmp 0x9b35
movq -0x30(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x30(%rbp)
movb $0xc, (%rax)
jmp 0x9b35
movq -0x30(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x30(%rbp)
movb $0xa, (%rax)
jmp 0x9b35
movq -0x30(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x30(%rbp)
movb $0xd, (%rax)
jmp 0x9b35
movq -0x30(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x30(%rbp)
movb $0x9, (%rax)
jmp 0x9b35
movq -0x20(%rbp), %rax
movb 0x1(%rax), %cl
movq -0x30(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x30(%rbp)
movb %cl, (%rax)
jmp 0x9b35
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
leaq -0x30(%rbp), %rdx
callq 0xa390
movb %al, -0x49(%rbp)
movzbl -0x49(%rbp), %eax
cmpl $0x0, %eax
jne 0x9b31
jmp 0x9b99
jmp 0x9b35
jmp 0x9b99
movzbl -0x49(%rbp), %ecx
movq -0x20(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
jmp 0x9a08
movq -0x30(%rbp), %rax
movb $0x0, (%rax)
movq -0x10(%rbp), %rax
movl $0x10, 0x18(%rax)
movq -0x38(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x28(%rbp), %rcx
movq -0x18(%rbp), %rax
movq (%rax), %rax
subq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x10(%rax)
movl $0x1, -0x4(%rbp)
jmp 0x9bd2
cmpq $0x0, -0x38(%rbp)
je 0x9bae
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x38(%rbp), %rdi
callq *%rax
cmpq $0x0, -0x20(%rbp)
je 0x9bcb
movq -0x20(%rbp), %rcx
movq -0x18(%rbp), %rax
movq (%rax), %rax
subq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)