// File: /workspace/github_c_makefile_star2_O3/mruby-zest[P]osc-bridge/src/mm_json.h
// Function: mm_json_load
MM_JSON_API enum mm_json_status
mm_json_load(struct mm_json_token *toks, mm_json_size max, mm_json_size *read,
            const mm_json_char *json, mm_json_size length)
{
    enum mm_json_status status = MM_JSON_OK;
    struct mm_json_token tok;
    struct mm_json_iter iter;

    MM_JSON_ASSERT(toks);
    MM_JSON_ASSERT(json);
    MM_JSON_ASSERT(length);
    MM_JSON_ASSERT(max);
    MM_JSON_ASSERT(read);

    if (!toks || !json || !length || !max || !read)
        return MM_JSON_INVAL;
    if (*read >= max)
        return MM_JSON_OUT_OF_TOKEN;

    iter = mm_json_begin(json, length);
    iter = mm_json_read(&tok, &iter);
    if (iter.err && iter.len)
        return MM_JSON_PARSING_ERROR;

    while (iter.len) {
        toks[*read] = tok;
        *read += 1;
        if (*read > max) return MM_JSON_OUT_OF_TOKEN;
        if (toks[*read-1].type == MM_JSON_OBJECT ||  toks[*read-1].type == MM_JSON_ARRAY) {
            status = mm_json_load(toks, max, read, toks[*read-1].str, toks[*read-1].len);
            if (status != MM_JSON_OK) return status;
        }

        iter = mm_json_read(&tok, &iter);
        if (iter.err && iter.src && iter.len)
            return MM_JSON_PARSING_ERROR;
    }
    return status;
}

// Assembly:
movl $0x1, %eax
testq %rdx, %rdx
je 0x4efc
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rsi, %r15
testq %rsi, %rsi
je 0x4eee
movq %rdi, %r12
testq %rdi, %rdi
je 0x4eee
movq %rcx, %rbx
testq %rcx, %rcx
je 0x4eee
movq %r8, %r13
testq %r8, %r8
je 0x4eee
movq %rdx, %r14
movl $0x2, %eax
cmpq %r15, (%rdx)
jae 0x4eee
xorps %xmm0, %xmm0
leaq -0x50(%rbp), %rax
movaps %xmm0, (%rax)
callq 0x4240
leaq -0x50(%rbp), %rdx
movq %rbx, 0x10(%rdx)
movq %r13, 0x18(%rdx)
leaq -0x70(%rbp), %rbx
leaq -0x98(%rbp), %rsi
movq %rbx, %rdi
movq %rdx, %r13
callq 0x4816
movups (%rbx), %xmm0
movups 0x10(%rbx), %xmm1
movaps %xmm1, 0x10(%r13)
movaps %xmm0, (%r13)
cmpl $0x0, (%r13)
setne %cl
movq 0x18(%r13), %rax
testq %rax, %rax
setne %dl
testb %dl, %cl
jne 0x4ee9
leaq -0x50(%rbp), %r13
testq %rax, %rax
je 0x4efd
movq (%r14), %rax
leaq (%rax,%rax,4), %rax
movq -0x78(%rbp), %rcx
movq %rcx, 0x20(%r12,%rax,8)
movups -0x98(%rbp), %xmm0
movups -0x88(%rbp), %xmm1
movups %xmm1, 0x10(%r12,%rax,8)
movups %xmm0, (%r12,%rax,8)
movq (%r14), %rcx
leaq 0x1(%rcx), %rax
movq %rax, (%r14)
cmpq %r15, %rax
ja 0x4f01
leaq (%rcx,%rcx,4), %rcx
movl 0x20(%r12,%rcx,8), %ecx
decl %ecx
cmpl $0x1, %ecx
ja 0x4ea1
leaq (%rax,%rax,4), %rax
movq -0x28(%r12,%rax,8), %rcx
movq -0x20(%r12,%rax,8), %r8
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x4d6c
testl %eax, %eax
jne 0x4eee
movq %rbx, %rdi
leaq -0x98(%rbp), %rsi
movq %r13, %rdx
callq 0x4816
movups -0x70(%rbp), %xmm0
movups -0x60(%rbp), %xmm1
movaps %xmm1, -0x40(%rbp)
movaps %xmm0, -0x50(%rbp)
cmpl $0x0, -0x50(%rbp)
setne %cl
movq -0x38(%rbp), %rax
cmpq $0x0, -0x40(%rbp)
setne %dl
andb %cl, %dl
testq %rax, %rax
setne %cl
andb %dl, %cl
cmpb $0x1, %cl
jne 0x4e2c
movl $0x3, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
jmp 0x4eee
movl $0x2, %eax
jmp 0x4eee