// File: /workspace/github_c_makefile_star2_O2/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
movq %rdi, %rbx
testq %rdx, %rdx
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
jne 0x469a
movq 0x10(%rdx), %r15
testq %r15, %r15
je 0x469a
movq 0x18(%rdx), %r12
testq %r12, %r12
je 0x469a
cmpl $0x0, (%rdx)
je 0x46ca
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
movups %xmm0, (%rbx)
movups %xmm0, 0x10(%r14)
movups %xmm0, (%r14)
andq $0x0, 0x20(%r14)
movl $0x1, (%rbx)
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x4(%rdx), %eax
movq 0x8(%rdx), %r13
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r14)
movups %xmm0, (%r14)
andq $0x0, 0x20(%r14)
testq %r13, %r13
leaq 0x7b44(%rip), %rcx      # 0xc230
movq %rcx, -0x48(%rbp)
cmoveq %rcx, %r13
movq $0x0, -0x40(%rbp)
leaq 0x3e81(%rip), %rcx      # 0x8584
movq $0x0, -0x38(%rbp)
xorl %edi, %edi
xorl %r9d, %r9d
xorl %edx, %edx
movq $0x0, -0x30(%rbp)
xorl %r11d, %r11d
movq %r15, %r8
movq %r12, %r10
testq %r12, %r12
je 0x4906
movzbl (%r15), %esi
testq %rsi, %rsi
cmoveq %rsi, %r8
cmoveq %rsi, %r10
movzbl (%r13,%rsi), %esi
cmpq $0xe, %rsi
ja 0x48fb
movslq (%rcx,%rsi,4), %rsi
addq %rcx, %rsi
jmpq *%rsi
cmpl $0x2, %eax
jne 0x48fb
decq %rdx
movq %rdx, 0x10(%r14)
jmp 0x48f8
decl %r11d
leaq 0x7cbd(%rip), %rsi      # 0xc430
cmoveq %rsi, %r13
jmp 0x48fb
leaq 0x7dad(%rip), %r13      # 0xc530
pushq $0x3
jmp 0x48ab
cmpl $0x1, %eax
je 0x4969
decq %r15
incq %r12
jmp 0x4899
leaq 0x7e8b(%rip), %r13      # 0xc630
jmp 0x48fb
cmpl $0x2, %eax
jl 0x48af
jne 0x47bc
incq %rdx
movq %rdx, 0x10(%r14)
incq %r9
movq %r9, 0x18(%r14)
jmp 0x48b4
decl %eax
cmpl $0x1, %eax
jne 0x48fb
movq %r15, %rax
movq -0x38(%rbp), %rsi
subq %rsi, %rax
incq %rax
movq %rax, 0x8(%r14)
testq %rsi, %rsi
jne 0x49a3
movq $0x0, -0x38(%rbp)
xorl %edi, %edi
movq $0x0, -0x30(%rbp)
jmp 0x4895
cmpl $0x2, %eax
je 0x48b8
cmpl $0x1, %eax
jne 0x48bf
movq %r15, (%r14)
movq %r15, -0x40(%rbp)
movq %r15, -0x38(%rbp)
movq %r15, %rdi
movq %r15, -0x30(%rbp)
leaq 0x7c01(%rip), %r13      # 0xc430
jmp 0x4895
cmpl $0x2, %eax
je 0x48cf
cmpl $0x1, %eax
jne 0x48d6
movq %r15, (%r14)
movq %r15, -0x40(%rbp)
movq %r15, -0x38(%rbp)
movq %r15, %rdi
movq %r15, -0x30(%rbp)
leaq 0x7ad4(%rip), %r13      # 0xc330
jmp 0x4895
leaq 0x7ccb(%rip), %r13      # 0xc530
pushq $0x1
jmp 0x48ab
cmpl $0x1, %eax
jne 0x4899
movq %r15, %rax
subq %rdi, %rax
incq %rax
movq %rax, 0x8(%r14)
testq %rdi, %rdi
jne 0x49a7
xorl %edi, %edi
movq $0x0, -0x30(%rbp)
leaq 0x799b(%rip), %r13      # 0xc230
pushq $0x1
jmp 0x48fa
leaq 0x7990(%rip), %r13      # 0xc230
jmp 0x48fb
leaq 0x7c87(%rip), %r13      # 0xc530
pushq $0x2
popq %r11
jmp 0x48fb
cmpl $0x1, %eax
je 0x48e6
incl %eax
jmp 0x48fb
incq %rdx
movq %rdx, 0x10(%r14)
incq %r9
movq %r9, 0x18(%r14)
leaq 0x7b63(%rip), %r13      # 0xc430
jmp 0x48fb
incq %rdx
movq %rdx, 0x10(%r14)
incq %r9
movq %r9, 0x18(%r14)
leaq 0x7a4c(%rip), %r13      # 0xc330
jmp 0x48fb
movq %r15, (%r14)
movq %r15, -0x40(%rbp)
movq %r15, -0x38(%rbp)
movq %r15, %rdi
movq %r15, -0x30(%rbp)
pushq $0x2
popq %rax
incq %r15
decq %r12
jmp 0x4723
testl %eax, %eax
je 0x4921
andl $0x0, (%rbx)
movl %eax, 0x4(%rbx)
movq %r13, 0x8(%rbx)
movq %r8, 0x10(%rbx)
movq %r10, 0x18(%rbx)
jmp 0x46b8
movq -0x40(%rbp), %rax
testq %rax, %rax
je 0x494d
notq %rax
addq %r15, %rax
movq %rax, 0x8(%r14)
movq %r14, %rdi
callq 0x49e8
movl %eax, 0x20(%r14)
cmpl $0x4, %eax
jne 0x494d
movq %r14, %rdi
callq 0x4a4f
andq $0x0, (%rbx)
movq %r13, 0x8(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
jmp 0x46b8
movl $0x1, (%rbx)
jmp 0x490d
movq %r15, %rax
subq -0x30(%rbp), %rax
movq %rax, 0x8(%r14)
movq %r14, %rdi
callq 0x49e8
movl %eax, 0x20(%r14)
cmpl $0x4, %eax
jne 0x498d
movq %r14, %rdi
callq 0x4a4f
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, (%rbx)
leaq 0x788f(%rip), %rax      # 0xc230
jmp 0x49d7
movq %r13, -0x48(%rbp)
incq %r15
decq %r12
movq %r14, %rdi
callq 0x49e8
movl %eax, 0x20(%r14)
cmpl $0x4, %eax
jne 0x49c6
movq %r14, %rdi
callq 0x4a4f
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, (%rbx)
movq -0x48(%rbp), %rax
movq %rax, 0x8(%rbx)
movq %r15, 0x10(%rbx)
movq %r12, 0x18(%rbx)
jmp 0x46b8