// File: /workspace/github_cpp_makefile_star2_O2/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
andq $0x0, 0x20(%rsp)
movq %rdi, %r14
andq $0x0, 0x1a0a4(%rip)     # 0x421b0
andq $0x0, 0x1a0a4(%rip)     # 0x421b8
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
je 0x28135
xorl %r12d, %r12d
testq %r14, %r14
jne 0x281ff
jmp 0x2822f
movq %rsi, %r12
movq %r14, 0x8(%rsp)
movq %rsi, 0x10(%rsp)
andq $0x0, 0x18(%rsp)
movups 0xe261(%rip), %xmm0     # 0x363b0
movups %xmm0, 0x28(%rsp)
movq 0xe265(%rip), %rax      # 0x363c0
movq %rax, 0x38(%rsp)
pushq $0x40
popq %rdi
callq *0xe247(%rip)           # 0x363b0
testq %rax, %rax
je 0x281ff
movq %rax, %r15
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
cmpq $0x5, %r12
jb 0x281aa
cmpb $-0x11, (%r14)
jne 0x281aa
cmpb $-0x45, 0x1(%r14)
jne 0x281aa
cmpb $-0x41, 0x2(%r14)
jne 0x281aa
movq $0x3, 0x18(%rsp)
leaq 0x8(%rsp), %rdi
callq 0x286d8
movq %r15, %rdi
movq %rax, %rsi
callq 0x28256
testl %eax, %eax
je 0x281eb
testl %ebp, %ebp
je 0x28242
leaq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x286d8
movq 0x10(%r12), %rax
cmpq 0x8(%r12), %rax
jae 0x281eb
movq 0x8(%rsp), %rcx
cmpb $0x0, (%rcx,%rax)
je 0x28242
movq %r15, %rdi
callq 0x27f56
movq 0x10(%rsp), %r12
movq 0x18(%rsp), %rax
jmp 0x28201
xorl %eax, %eax
xorl %ecx, %ecx
movq %r12, %rdx
subq $0x1, %rdx
cmovaeq %rdx, %rcx
cmpq %r12, %rax
cmovbq %rax, %rcx
testq %rbx, %rbx
je 0x28221
leaq (%r14,%rcx), %rax
movq %rax, (%rbx)
movq %r14, 0x19f88(%rip)     # 0x421b0
movq %rcx, 0x19f89(%rip)     # 0x421b8
xorl %r15d, %r15d
movq %r15, %rax
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
testq %rbx, %rbx
je 0x28232
movq 0x8(%rsp), %rax
addq 0x18(%rsp), %rax
movq %rax, (%rbx)
jmp 0x28232