// File: 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:
subq $0x38, %rsp
movq %rdi, 0x28(%rsp)
movq %rsi, 0x20(%rsp)
movq $0x0, 0x18(%rsp)
movq $0x0, 0x10(%rsp)
movq 0x20(%rsp), %rax
cmpq $0x3e8, 0x18(%rax)      # imm = 0x3E8
jb 0x5d03c
movl $0x0, 0x34(%rsp)
jmp 0x5d370
movq 0x20(%rsp), %rax
movq 0x18(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x18(%rax)
cmpq $0x0, 0x20(%rsp)
je 0x5d087
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rax
addq $0x0, %rax
movq 0x20(%rsp), %rcx
cmpq 0x8(%rcx), %rax
jae 0x5d087
movq 0x20(%rsp), %rax
movq (%rax), %rax
movq 0x20(%rsp), %rcx
movq 0x10(%rcx), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x7b, %eax
je 0x5d08c
jmp 0x5d356
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x10(%rax)
movq 0x20(%rsp), %rdi
callq 0x59830
cmpq $0x0, 0x20(%rsp)
je 0x5d0e6
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rax
addq $0x0, %rax
movq 0x20(%rsp), %rcx
cmpq 0x8(%rcx), %rax
jae 0x5d0e6
movq 0x20(%rsp), %rax
movq (%rax), %rax
movq 0x20(%rsp), %rcx
movq 0x10(%rcx), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x7d, %eax
jne 0x5d0e6
jmp 0x5d2fa
cmpq $0x0, 0x20(%rsp)
je 0x5d106
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rax
addq $0x0, %rax
movq 0x20(%rsp), %rcx
cmpq 0x8(%rcx), %rax
jb 0x5d11c
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x10(%rax)
jmp 0x5d356
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x10(%rax)
movq 0x20(%rsp), %rdi
addq $0x20, %rdi
callq 0x59500
movq %rax, 0x8(%rsp)
cmpq $0x0, 0x8(%rsp)
jne 0x5d14d
jmp 0x5d356
cmpq $0x0, 0x18(%rsp)
jne 0x5d166
movq 0x8(%rsp), %rax
movq %rax, 0x18(%rsp)
movq %rax, 0x10(%rsp)
jmp 0x5d18b
movq 0x8(%rsp), %rcx
movq 0x10(%rsp), %rax
movq %rcx, (%rax)
movq 0x10(%rsp), %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x8(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x10(%rax)
movq 0x20(%rsp), %rdi
callq 0x59830
movq 0x10(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0x5c750
cmpl $0x0, %eax
jne 0x5d1bf
jmp 0x5d356
movq 0x20(%rsp), %rdi
callq 0x59830
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x38(%rax)
movq 0x10(%rsp), %rax
movq $0x0, 0x20(%rax)
cmpq $0x0, 0x20(%rsp)
je 0x5d222
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rax
addq $0x0, %rax
movq 0x20(%rsp), %rcx
cmpq 0x8(%rcx), %rax
jae 0x5d222
movq 0x20(%rsp), %rax
movq (%rax), %rax
movq 0x20(%rsp), %rcx
movq 0x10(%rcx), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x3a, %eax
je 0x5d227
jmp 0x5d356
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x10(%rax)
movq 0x20(%rsp), %rdi
callq 0x59830
movq 0x10(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0x59540
cmpl $0x0, %eax
jne 0x5d25b
jmp 0x5d356
movq 0x20(%rsp), %rdi
callq 0x59830
xorl %eax, %eax
cmpq $0x0, 0x20(%rsp)
movb %al, 0x7(%rsp)
je 0x5d2b0
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rcx
addq $0x0, %rcx
movq 0x20(%rsp), %rdx
xorl %eax, %eax
cmpq 0x8(%rdx), %rcx
movb %al, 0x7(%rsp)
jae 0x5d2b0
movq 0x20(%rsp), %rax
movq (%rax), %rax
movq 0x20(%rsp), %rcx
movq 0x10(%rcx), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x2c, %eax
sete %al
movb %al, 0x7(%rsp)
movb 0x7(%rsp), %al
testb $0x1, %al
jne 0x5d12d
cmpq $0x0, 0x20(%rsp)
je 0x5d2f6
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rax
addq $0x0, %rax
movq 0x20(%rsp), %rcx
cmpq 0x8(%rcx), %rax
jae 0x5d2f6
movq 0x20(%rsp), %rax
movq (%rax), %rax
movq 0x20(%rsp), %rcx
movq 0x10(%rcx), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x7d, %eax
je 0x5d2f8
jmp 0x5d356
jmp 0x5d2fa
movq 0x20(%rsp), %rax
movq 0x18(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x18(%rax)
cmpq $0x0, 0x18(%rsp)
je 0x5d321
movq 0x10(%rsp), %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x28(%rsp), %rax
movl $0x40, 0x18(%rax)
movq 0x18(%rsp), %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x10(%rax)
movl $0x1, 0x34(%rsp)
jmp 0x5d370
cmpq $0x0, 0x18(%rsp)
je 0x5d368
movq 0x18(%rsp), %rdi
callq 0x58fa0
movl $0x0, 0x34(%rsp)
movl 0x34(%rsp), %eax
addq $0x38, %rsp
retq
nopl (%rax)