// File: /workspace/github_cpp_makefile_star2_O1/Eba-M[P]E3DC-Control/cJSON.c
// Function: parse_object(cJSON*, parse_buffer*)
static cJSON_bool parse_object(cJSON * const item, parse_buffer * const input_buffer)
{
    cJSON *head = NULL; /* linked list head */
    cJSON *current_item = NULL;

    if (input_buffer->depth >= CJSON_NESTING_LIMIT)
    {
        return false; /* to deeply nested */
    }
    input_buffer->depth++;

    if (cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != '{'))
    {
        goto fail; /* not an object */
    }

    input_buffer->offset++;
    buffer_skip_whitespace(input_buffer);
    if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '}'))
    {
        goto success; /* empty object */
    }

    /* check if we skipped to the end of the buffer */
    if (cannot_access_at_index(input_buffer, 0))
    {
        input_buffer->offset--;
        goto fail;
    }

    /* step back to character in front of the first element */
    input_buffer->offset--;
    /* loop through the comma separated array elements */
    do
    {
        /* allocate next item */
        cJSON *new_item = cJSON_New_Item(&(input_buffer->hooks));
        if (new_item == NULL)
        {
            goto fail; /* allocation failure */
        }

        /* attach next item to list */
        if (head == NULL)
        {
            /* start the linked list */
            current_item = head = new_item;
        }
        else
        {
            /* add to the end and advance */
            current_item->next = new_item;
            new_item->prev = current_item;
            current_item = new_item;
        }

        /* parse the name of the child */
        input_buffer->offset++;
        buffer_skip_whitespace(input_buffer);
        if (!parse_string(current_item, input_buffer))
        {
            goto fail; /* failed to parse name */
        }
        buffer_skip_whitespace(input_buffer);

        /* swap valuestring and string, because we parsed the name */
        current_item->string = current_item->valuestring;
        current_item->valuestring = NULL;

        if (cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != ':'))
        {
            goto fail; /* invalid object */
        }

        /* parse the value */
        input_buffer->offset++;
        buffer_skip_whitespace(input_buffer);
        if (!parse_value(current_item, input_buffer))
        {
            goto fail; /* failed to parse value */
        }
        buffer_skip_whitespace(input_buffer);
    }
    while (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == ','));

    if (cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != '}'))
    {
        goto fail; /* expected end of object */
    }

success:
    input_buffer->depth--;

    if (head != NULL) {
        head->prev = current_item;
    }

    item->type = cJSON_Object;
    item->child = head;

    input_buffer->offset++;
    return true;

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

    return false;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0x18(%rsi), %rax
xorl %ebx, %ebx
cmpq $0x3e7, %rax            # imm = 0x3E7
ja 0x2ec03
movq %rsi, %r14
incq %rax
movq %rax, 0x18(%rsi)
movq 0x10(%rsi), %rax
xorl %ebx, %ebx
cmpq 0x8(%rsi), %rax
jae 0x2ebf3
movq (%r14), %rcx
cmpb $0x7b, (%rcx,%rax)
jne 0x2ebf3
movq %rdi, %r15
incq %rax
movq %rax, 0x10(%r14)
movq %r14, %rdi
callq 0x2c88a
movq 0x8(%r14), %rcx
movq 0x10(%r14), %rax
cmpq %rcx, %rax
jae 0x2ebec
movq (%r14), %rdx
cmpb $0x7d, (%rdx,%rax)
jne 0x2eae8
xorl %r12d, %r12d
xorl %ebp, %ebp
decq 0x18(%r14)
testq %r12, %r12
je 0x2eace
movq %rbp, 0x8(%r12)
movl $0x40, 0x18(%r15)
movq %r12, 0x10(%r15)
incq 0x10(%r14)
movl $0x1, %ebx
jmp 0x2ec03
cmpq %rcx, %rax
jae 0x2ebec
decq %rax
movq %rax, 0x10(%r14)
xorl %r12d, %r12d
xorl %ebp, %ebp
movl $0x40, %edi
callq *0x20(%r14)
testq %rax, %rax
je 0x2ebb8
movq %rax, %r13
movq %rbp, %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%r13)
movups %xmm0, 0x20(%r13)
movups %xmm0, 0x10(%r13)
movups %xmm0, (%r13)
movq %r13, %rbp
testq %r12, %r12
je 0x2eb3e
movq %r13, (%rax)
movq %rax, 0x8(%r13)
movq %r12, %rbp
incq 0x10(%r14)
movq %r14, %rdi
callq 0x2c88a
movq %r13, %rdi
movq %r14, %rsi
callq 0x2e6d0
testl %eax, %eax
je 0x2ebae
movq %r14, %rdi
callq 0x2c88a
movq 0x20(%r13), %rax
movq %rax, 0x38(%r13)
movq $0x0, 0x20(%r13)
movq 0x10(%r14), %rax
cmpq 0x8(%r14), %rax
jae 0x2ebae
movq (%r14), %rcx
cmpb $0x3a, (%rcx,%rax)
jne 0x2ebae
incq %rax
movq %rax, 0x10(%r14)
movq %r14, %rdi
callq 0x2c88a
movq %r13, %rdi
movq %r14, %rsi
callq 0x2c50d
testl %eax, %eax
je 0x2ebae
movq %r14, %rdi
callq 0x2c88a
movb $0x1, %al
jmp 0x2ebb0
xorl %eax, %eax
movq %rbp, %r12
movq %r13, %rbp
jmp 0x2ebba
xorl %eax, %eax
testb %al, %al
je 0x2ebf6
movq 0x8(%r14), %rcx
movq 0x10(%r14), %rax
cmpq %rcx, %rax
jae 0x2ebf6
movq (%r14), %rdx
cmpb $0x2c, (%rdx,%rax)
je 0x2eafd
cmpq %rcx, %rax
jae 0x2ebf6
movq (%r14), %rcx
cmpb $0x7d, (%rcx,%rax)
je 0x2eac0
jmp 0x2ebf6
decq %rax
movq %rax, 0x10(%r14)
xorl %r12d, %r12d
testq %r12, %r12
je 0x2ec03
movq %r12, %rdi
callq 0x2c1d6
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq