// File: /workspace/github_cpp_makefile_star2_O1/Eba-M[P]E3DC-Control/cJSON.c
// Function: cJSON_ParseWithLengthOpts
CJSON_PUBLIC(cJSON *) cJSON_ParseWithLengthOpts(const char *value, size_t buffer_length, 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 || 0 == buffer_length)
    {
        goto fail;
    }

    buffer.content = (const unsigned char*)value;
    buffer.length = buffer_length;
    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
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x40, %rsp
movl %ecx, %ebp
movq %rdx, %rbx
movq %rdi, %r14
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
movaps %xmm0, (%rsp)
xorl %r15d, %r15d
movq %r15, 0x30(%rsp)
movq %r15, 0x18e09(%rip)     # 0x45190
movq %r15, 0x18e0a(%rip)     # 0x45198
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
jne 0x2c4b0
movq %r14, (%rsp)
movq %rsi, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movups 0xcfd5(%rip), %xmm0     # 0x39390
movaps %xmm0, 0x20(%rsp)
movq 0xcfd9(%rip), %rax      # 0x393a0
movq %rax, 0x30(%rsp)
movl $0x40, %edi
callq *0xcfb9(%rip)           # 0x39390
testq %rax, %rax
je 0x2c4ad
movq %rax, %r15
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
movq (%rsp), %rdi
xorl %r12d, %r12d
testq %rdi, %rdi
je 0x2c432
cmpq $0x0, 0x10(%rsp)
jne 0x2c432
movq %rsp, %r12
cmpq $0x5, 0x8(%r12)
jb 0x2c432
leaq 0x66ea(%rip), %rsi      # 0x32b05
movl $0x3, %edx
callq 0x2110
testl %eax, %eax
jne 0x2c432
movq $0x3, 0x10(%rsp)
movq %r12, %rdi
callq 0x2c88a
movq %r15, %rdi
movq %rax, %rsi
callq 0x2c50d
testl %eax, %eax
je 0x2c4b0
testl %ebp, %ebp
je 0x2c49a
movq (%rsp), %rax
testq %rax, %rax
je 0x2c488
movq 0x8(%rsp), %rdx
movq 0x10(%rsp), %rcx
cmpq %rdx, %rcx
jae 0x2c488
cmpb $0x20, (%rax,%rcx)
ja 0x2c47b
incq %rcx
movq %rcx, 0x10(%rsp)
cmpq %rcx, %rdx
jne 0x2c465
movq %rdx, %rcx
cmpq %rdx, %rcx
jne 0x2c488
decq %rcx
movq %rcx, 0x10(%rsp)
movq 0x10(%rsp), %rcx
cmpq 0x8(%rsp), %rcx
jae 0x2c4b0
cmpb $0x0, (%rax,%rcx)
jne 0x2c4b0
testq %rbx, %rbx
je 0x2c4fd
movq (%rsp), %rax
addq 0x10(%rsp), %rax
movq %rax, (%rbx)
jmp 0x2c4fd
xorl %r15d, %r15d
testq %r15, %r15
je 0x2c4bd
movq %r15, %rdi
callq 0x2c1d6
testq %r14, %r14
je 0x2c4fa
movq 0x8(%rsp), %rcx
movq 0x10(%rsp), %rdx
xorl %eax, %eax
movq %rcx, %rsi
subq $0x1, %rsi
cmovaeq %rsi, %rax
cmpq %rcx, %rdx
cmovbq %rdx, %rax
testq %rbx, %rbx
je 0x2c4ec
leaq (%r14,%rax), %rcx
movq %rcx, (%rbx)
movq %r14, 0x18c9d(%rip)     # 0x45190
movq %rax, 0x18c9e(%rip)     # 0x45198
xorl %r15d, %r15d
movq %r15, %rax
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq