// File: /workspace/github_c_makefile_star2_O0/tomcatzh[P]RealityBenchmark/external/cJSON.c
// Function: cJSON_ParseWithOpts
CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated)
{
    parse_buffer buffer = { 0, 0, 0, 0, { 0, 0, 0 } };
    cJSON *item = NULL;

    /* reset error position */
    global_error.json = NULL;
    global_error.position = 0;

    if (value == NULL)
    {
        goto fail;
    }

    buffer.content = (const unsigned char*)value;
    buffer.length = strlen((const char*)value) + sizeof("");
    buffer.offset = 0;
    buffer.hooks = global_hooks;

    item = cJSON_New_Item(&global_hooks);
    if (item == NULL) /* memory fail */
    {
        goto fail;
    }

    if (!parse_value(item, buffer_skip_whitespace(skip_utf8_bom(&buffer))))
    {
        /* parse failure. ep is set. */
        goto fail;
    }

    /* if we require null-terminated JSON without appended garbage, skip and then check for a null terminator */
    if (require_null_terminated)
    {
        buffer_skip_whitespace(&buffer);
        if ((buffer.offset >= buffer.length) || buffer_at_offset(&buffer)[0] != '\0')
        {
            goto fail;
        }
    }
    if (return_parse_end)
    {
        *return_parse_end = (const char*)buffer_at_offset(&buffer);
    }

    return item;

fail:
    if (item != NULL)
    {
        cJSON_Delete(item);
    }

    if (value != NULL)
    {
        error local_error;
        local_error.json = (const unsigned char*)value;
        local_error.position = 0;

        if (buffer.offset < buffer.length)
        {
            local_error.position = buffer.offset;
        }
        else if (buffer.length > 0)
        {
            local_error.position = buffer.length - 1;
        }

        if (return_parse_end != NULL)
        {
            *return_parse_end = (const char*)local_error.json + local_error.position;
        }

        global_error = local_error;
    }

    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
leaq -0x58(%rbp), %rdi
xorl %esi, %esi
movl $0x38, %edx
callq 0x2130
movq $0x0, -0x60(%rbp)
movq $0x0, 0x9977(%rip) # 0x102d0
movq $0x0, 0x9974(%rip) # 0x102d8
cmpq $0x0, -0x10(%rbp)
jne 0x6970
jmp 0x6a48
movq -0x10(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rdi
callq 0x20e0
addq $0x1, %rax
movq %rax, -0x50(%rbp)
movq $0x0, -0x48(%rbp)
movq 0x98a8(%rip), %rax      # 0x10240
movq %rax, -0x38(%rbp)
movq 0x98a5(%rip), %rax      # 0x10248
movq %rax, -0x30(%rbp)
movq 0x98a2(%rip), %rax      # 0x10250
movq %rax, -0x28(%rbp)
leaq 0x9887(%rip), %rdi      # 0x10240
callq 0x6ae0
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
jne 0x69cb
jmp 0x6a48
movq -0x60(%rbp), %rax
movq %rax, -0x78(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x6ec0
movq %rax, %rdi
callq 0x6e00
movq -0x78(%rbp), %rdi
movq %rax, %rsi
callq 0x6b20
cmpl $0x0, %eax
jne 0x69f7
jmp 0x6a48
cmpl $0x0, -0x1c(%rbp)
je 0x6a25
leaq -0x58(%rbp), %rdi
callq 0x6e00
movq -0x48(%rbp), %rax
cmpq -0x50(%rbp), %rax
jae 0x6a21
movq -0x58(%rbp), %rax
movq -0x48(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x6a23
jmp 0x6a48
jmp 0x6a25
cmpq $0x0, -0x18(%rbp)
je 0x6a3b
movq -0x58(%rbp), %rcx
addq -0x48(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x60(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x6acc
cmpq $0x0, -0x60(%rbp)
je 0x6a58
movq -0x60(%rbp), %rdi
callq 0x67e0
cmpq $0x0, -0x10(%rbp)
je 0x6ac4
movq -0x10(%rbp), %rax
movq %rax, -0x70(%rbp)
movq $0x0, -0x68(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x50(%rbp), %rax
jae 0x6a83
movq -0x48(%rbp), %rax
movq %rax, -0x68(%rbp)
jmp 0x6a98
cmpq $0x0, -0x50(%rbp)
jbe 0x6a96
movq -0x50(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x68(%rbp)
jmp 0x6a98
cmpq $0x0, -0x18(%rbp)
je 0x6aae
movq -0x70(%rbp), %rcx
addq -0x68(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x70(%rbp), %rax
movq %rax, 0x9817(%rip)      # 0x102d0
movq -0x68(%rbp), %rax
movq %rax, 0x9814(%rip)      # 0x102d8
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax)