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

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

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

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

    /* 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 next 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 array */
    }

success:
    input_buffer->depth--;

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

    item->type = cJSON_Array;
    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 0x5cd7c
movl $0x0, 0x34(%rsp)
jmp 0x5cff4
movq 0x20(%rsp), %rax
movq 0x18(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x18(%rax)
movq 0x20(%rsp), %rax
movq (%rax), %rax
movq 0x20(%rsp), %rcx
movq 0x10(%rcx), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x5b, %eax
je 0x5cdac
jmp 0x5cfda
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 0x5ce06
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rax
addq $0x0, %rax
movq 0x20(%rsp), %rcx
cmpq 0x8(%rcx), %rax
jae 0x5ce06
movq 0x20(%rsp), %rax
movq (%rax), %rax
movq 0x20(%rsp), %rcx
movq 0x10(%rcx), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x5d, %eax
jne 0x5ce06
jmp 0x5cf7e
cmpq $0x0, 0x20(%rsp)
je 0x5ce26
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rax
addq $0x0, %rax
movq 0x20(%rsp), %rcx
cmpq 0x8(%rcx), %rax
jb 0x5ce3c
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x10(%rax)
jmp 0x5cfda
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 0x5ce6d
jmp 0x5cfda
cmpq $0x0, 0x18(%rsp)
jne 0x5ce86
movq 0x8(%rsp), %rax
movq %rax, 0x18(%rsp)
movq %rax, 0x10(%rsp)
jmp 0x5ceab
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 0x59540
cmpl $0x0, %eax
jne 0x5cedf
jmp 0x5cfda
movq 0x20(%rsp), %rdi
callq 0x59830
xorl %eax, %eax
cmpq $0x0, 0x20(%rsp)
movb %al, 0x7(%rsp)
je 0x5cf34
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 0x5cf34
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 0x5ce4d
cmpq $0x0, 0x20(%rsp)
je 0x5cf7a
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rax
addq $0x0, %rax
movq 0x20(%rsp), %rcx
cmpq 0x8(%rcx), %rax
jae 0x5cf7a
movq 0x20(%rsp), %rax
movq (%rax), %rax
movq 0x20(%rsp), %rcx
movq 0x10(%rcx), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x5d, %eax
je 0x5cf7c
jmp 0x5cfda
jmp 0x5cf7e
movq 0x20(%rsp), %rax
movq 0x18(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x18(%rax)
cmpq $0x0, 0x18(%rsp)
je 0x5cfa5
movq 0x10(%rsp), %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x28(%rsp), %rax
movl $0x20, 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 0x5cff4
cmpq $0x0, 0x18(%rsp)
je 0x5cfec
movq 0x18(%rsp), %rdi
callq 0x58fa0
movl $0x0, 0x34(%rsp)
movl 0x34(%rsp), %eax
addq $0x38, %rsp
retq
nopl (%rax)