// File: /workspace/github_c_makefile_star2_O3/mruby-zest[P]osc-bridge/src/mm_json.h
// Function: mm_json_read
MM_JSON_API struct mm_json_iter
mm_json_read(struct mm_json_token *obj, const struct mm_json_iter* prev)
{
    struct mm_json_iter iter;
    mm_json_size len;
    const mm_json_char *cur;
    mm_json_int utf8_remain = 0;

    MM_JSON_ASSERT(obj);
    MM_JSON_ASSERT(prev);
    if (!prev || !obj || !prev->src || !prev->len || prev->err) {
        /* case either invalid iterator or eof  */
        struct mm_json_iter it = MM_JSON_ITER_NULL;
        *obj = MM_JSON_TOKEN_NULL;
        it.err = 1;
        return it;
    }

    iter = *prev;
    *obj = MM_JSON_TOKEN_NULL;
    iter.err = 0;
    if (!iter.go) /* begin of parsing process */
        iter.go = mm_json_go_struct;

    len = iter.len;
    for (cur = iter.src; len; cur++, len--) {
        const unsigned char *tbl = (const unsigned char*)iter.go;
        unsigned char c = (unsigned char)*cur;
        if (c == '\0') {
            iter.src = 0;
            iter.len = 0;
        }
        switch (tbl[c]) {
        case MM_JSON_STATE_FAILED: {
            iter.err = 1;
            return iter;
        } break;
        case MM_JSON_STATE_LOOP: break;
        case MM_JSON_STATE_SEP: {
            if (iter.depth == 2)
                obj->children--;
        } break;
        case MM_JSON_STATE_UP: {
            if (iter.depth > 1) {
                if (iter.depth == 2)
                    obj->children++;
                obj->sub++;
            }
            if (iter.depth++ == 1)
                obj->str = cur;
        } break;
        case MM_JSON_STATE_DOWN: {
            if (--iter.depth == 1) {
                obj->len = (mm_json_size)(cur - obj->str) + 1;
                if (iter.depth != 1 || !obj->str)
                    goto l_loop;
                goto l_yield;
            }
        } break;
        case MM_JSON_STATE_QUP: {
            iter.go = mm_json_go_string;
            if (iter.depth == 1) {
                obj->str = cur;
            } else {
                if (iter.depth == 2)
                    obj->children++;
                obj->sub++;
            }
        } break;
        case MM_JSON_STATE_QDOWN: {
            iter.go = mm_json_go_struct;
            if (iter.depth == 1) {
                obj->len = (mm_json_size)(cur - obj->str) + 1;
                if (iter.depth != 1 || !obj->str)
                    goto l_loop;
                goto l_yield;
            }
        } break;
        case MM_JSON_STATE_ESC: {
            iter.go = mm_json_go_esc;
        } break;
        case MM_JSON_STATE_UNESC: {
            iter.go = mm_json_go_string;
        } break;
        case MM_JSON_STATE_BARE: {
            if (iter.depth == 1) {
                obj->str = cur;
            } else {
                if (iter.depth == 2)
                    obj->children++;
                obj->sub++;
            }
            iter.go = mm_json_go_bare;
        } break;
        case MM_JSON_STATE_UNBARE: {
            iter.go = mm_json_go_struct;
            if (iter.depth == 1) {
                obj->len = (mm_json_size)(cur - obj->str);
                obj->type = (enum mm_json_token_type)mm_json_type(obj);
                if (obj->type == MM_JSON_STRING)
                    mm_json_deq(obj);
                iter.src = cur;
                iter.len = len;
                return iter;
            }
            cur--; len++;
        } break;
        case MM_JSON_STATE_UTF8_2: {
            iter.go = mm_json_go_utf8;
            utf8_remain = 1;
        } break;
        case MM_JSON_STATE_UTF8_3: {
            iter.go = mm_json_go_utf8;
            utf8_remain = 2;
        } break;
        case MM_JSON_STATE_UTF8_4: {
            iter.go = mm_json_go_utf8;
            utf8_remain = 3;
        } break;
        case MM_JSON_STATE_UTF8_NEXT: {
            if (!--utf8_remain)
                iter.go = mm_json_go_string;
        } break;
        default:
            break;
        }
        l_loop:;
    }

    if (!iter.depth) {
        /* reached eof */
        iter.src = 0;
        iter.len = 0;
        if (obj->str) {
            obj->len = (mm_json_size)((cur-1) - obj->str);
            obj->type = (enum mm_json_token_type)mm_json_type(obj);
            if (obj->type == MM_JSON_STRING)
                mm_json_deq(obj);
        }
        return iter;
    }
    return iter;

l_yield:
    iter.src = cur + 1;
    iter.len = len - 1;
    obj->type = mm_json_type(obj);
    if (obj->type == MM_JSON_STRING)
        mm_json_deq(obj);
    return iter;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r14
testq %rdx, %rdx
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
jne 0x4851
movq 0x10(%rdx), %rax
testq %rax, %rax
je 0x4851
movq 0x18(%rdx), %rcx
testq %rcx, %rcx
je 0x4851
cmpl $0x0, (%rdx)
je 0x4884
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rdi)
movups %xmm0, (%rdi)
movups %xmm0, 0x10(%r14)
movups %xmm0, (%r14)
movq $0x0, 0x20(%r14)
movl $0x1, (%rdi)
movq %rdi, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdi, -0x38(%rbp)
movl 0x4(%rdx), %r10d
movq 0x8(%rdx), %r13
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r14)
movups %xmm0, (%r14)
movq $0x0, 0x20(%r14)
testq %r13, %r13
leaq 0x8982(%rip), %rdx      # 0xd230
movq %rdx, -0x48(%rbp)
cmoveq %rdx, %r13
movq $0x0, -0x30(%rbp)
leaq 0x4d07(%rip), %rdx      # 0x95cc
movq $0x0, -0x40(%rbp)
xorl %r9d, %r9d
xorl %r11d, %r11d
xorl %edi, %edi
xorl %esi, %esi
xorl %r8d, %r8d
movq %rax, %rbx
movq %rcx, %r15
movzbl (%rbx), %r12d
testq %r12, %r12
cmoveq %r12, %rax
cmoveq %r12, %rcx
movzbl (%r13,%r12), %r12d
cmpq $0xe, %r12
ja 0x4a9d
movslq (%rdx,%r12,4), %r12
addq %rdx, %r12
jmpq *%r12
cmpl $0x2, %r10d
jne 0x4a9d
decq %rdi
movq %rdi, 0x10(%r14)
movl $0x2, %r10d
jmp 0x4a9d
decl %r8d
leaq 0x8b01(%rip), %r12      # 0xd430
cmoveq %r12, %r13
jmp 0x4a9d
movl $0x3, %r8d
jmp 0x4a5d
cmpl $0x1, %r10d
je 0x4b46
decq %rbx
incq %r15
jmp 0x4a4e
leaq 0x8cd1(%rip), %r13      # 0xd630
jmp 0x4a9d
cmpl $0x2, %r10d
jl 0x4a66
jne 0x4977
incq %rdi
movq %rdi, 0x10(%r14)
incq %r11
movq %r11, 0x18(%r14)
jmp 0x4a6c
decl %r10d
cmpl $0x1, %r10d
jne 0x4a9d
movq %rbx, %r12
movq -0x40(%rbp), %rsi
subq %rsi, %r12
incq %r12
movq %r12, 0x8(%r14)
testq %rsi, %rsi
jne 0x4b93
movl $0x1, %r10d
movq $0x0, -0x40(%rbp)
xorl %r9d, %r9d
xorl %esi, %esi
jmp 0x4a9d
cmpl $0x2, %r10d
je 0x4a71
cmpl $0x1, %r10d
jne 0x4a78
movq %rbx, (%r14)
movl $0x1, %r10d
movq %rbx, %rsi
movq %rbx, -0x30(%rbp)
movq %rbx, -0x40(%rbp)
movq %rbx, %r9
jmp 0x4a7f
cmpl $0x2, %r10d
je 0x4a88
cmpl $0x1, %r10d
jne 0x4a8f
movq %rbx, (%r14)
movl $0x1, %r10d
movq %rbx, %rsi
movq %rbx, -0x30(%rbp)
movq %rbx, -0x40(%rbp)
movq %rbx, %r9
jmp 0x4a96
movl $0x1, %r8d
jmp 0x4a5d
cmpl $0x1, %r10d
jne 0x4a4e
movq %rbx, %r12
subq %r9, %r12
incq %r12
movq %r12, 0x8(%r14)
testq %r9, %r9
jne 0x4b97
movl $0x1, %r10d
xorl %r9d, %r9d
xorl %esi, %esi
leaq 0x87db(%rip), %r13      # 0xd230
jmp 0x4a9d
movl $0x2, %r8d
leaq 0x8acc(%rip), %r13      # 0xd530
jmp 0x4a9d
cmpl $0x1, %r10d
je 0x4aae
incl %r10d
jmp 0x4a9d
incq %rdi
movq %rdi, 0x10(%r14)
incq %r11
movq %r11, 0x18(%r14)
leaq 0x89aa(%rip), %r13      # 0xd430
jmp 0x4a9d
incq %rdi
movq %rdi, 0x10(%r14)
incq %r11
movq %r11, 0x18(%r14)
leaq 0x8893(%rip), %r13      # 0xd330
movq %rbx, %r12
incq %rbx
decq %r15
jne 0x48e0
jmp 0x4ac7
movq %rbx, (%r14)
movl $0x2, %r10d
movq %rbx, %rsi
movq %rbx, -0x30(%rbp)
movq %rbx, -0x40(%rbp)
movq %rbx, %r9
jmp 0x4a9d
testl %r10d, %r10d
je 0x4aeb
movq -0x38(%rbp), %rdi
movl $0x0, (%rdi)
movl %r10d, 0x4(%rdi)
movq %r13, 0x8(%rdi)
movq %rax, 0x10(%rdi)
movq %rcx, 0x18(%rdi)
jmp 0x4872
movq -0x30(%rbp), %rbx
testq %rbx, %rbx
je 0x4b1f
subq %rbx, %r12
movq %r12, 0x8(%r14)
movq %r14, %rdi
callq 0x4bef
movl %eax, 0x20(%r14)
cmpl $0x4, %eax
jne 0x4b1f
cmpb $0x22, (%rbx)
jne 0x4b1f
incq %rbx
movq %rbx, (%r14)
addq $-0x2, %r12
movq %r12, 0x8(%r14)
movq -0x38(%rbp), %rax
movq $0x0, (%rax)
movq %r13, 0x8(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
jmp 0x4875
movq -0x38(%rbp), %rdi
movl $0x1, (%rdi)
jmp 0x4ad6
movq %rbx, %r12
movq %rsi, %r13
subq %rsi, %r12
movq %r12, 0x8(%r14)
movq %r14, %rdi
callq 0x4bef
movl %eax, 0x20(%r14)
cmpl $0x4, %eax
jne 0x4b79
cmpb $0x22, (%r13)
jne 0x4b79
incq %r13
movq %r13, (%r14)
addq $-0x2, %r12
movq %r12, 0x8(%r14)
movabsq $0x100000000, %rax      # imm = 0x100000000
movq -0x38(%rbp), %rdi
movq %rax, (%rdi)
leaq 0x869f(%rip), %rax      # 0xd230
jmp 0x4bde
movq %r13, -0x48(%rbp)
incq %rbx
decq %r15
movq %r14, %rdi
callq 0x4bef
movl %eax, 0x20(%r14)
cmpl $0x4, %eax
jne 0x4bc9
movq -0x30(%rbp), %rax
cmpb $0x22, (%rax)
jne 0x4bc9
movq -0x30(%rbp), %rax
incq %rax
movq %rax, (%r14)
addq $-0x2, %r12
movq %r12, 0x8(%r14)
movabsq $0x100000000, %rax      # imm = 0x100000000
movq -0x38(%rbp), %rdi
movq %rax, (%rdi)
movq -0x48(%rbp), %rax
movq %rax, 0x8(%rdi)
movq %rbx, 0x10(%rdi)
movq %r15, 0x18(%rdi)
jmp 0x4872