// File: /workspace/github_c_makefile_star2_O1/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 $0x18, %rsp
movq %rsi, %r14
movq %rdi, %rbx
testq %rdx, %rdx
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
jne 0x4871
movq 0x10(%rdx), %rax
testq %rax, %rax
je 0x4871
movq 0x18(%rdx), %rcx
testq %rcx, %rcx
je 0x4871
cmpl $0x0, (%rdx)
je 0x48a4
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
movups %xmm0, (%rbx)
movups %xmm0, 0x10(%r14)
movups %xmm0, (%r14)
movq $0x0, 0x20(%r14)
movl $0x1, (%rbx)
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x4(%rdx), %esi
movq %rsi, -0x30(%rbp)
movq 0x8(%rdx), %r11
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r14)
movups %xmm0, (%r14)
movq $0x0, 0x20(%r14)
testq %r11, %r11
leaq 0x8963(%rip), %r8       # 0xd230
cmoveq %r8, %r11
xorl %esi, %esi
leaq 0x4cf2(%rip), %r9       # 0x95cc
leaq 0x8b4f(%rip), %r10      # 0xd430
movq %rax, %r13
movq %rcx, %r12
xorl %edi, %edi
movzbl (%r13), %edx
testq %rdx, %rdx
cmoveq %rdx, %rax
cmoveq %rdx, %rcx
movzbl (%r11,%rdx), %edx
cmpq $0xe, %rdx
ja 0x4b48
movslq (%r9,%rdx,4), %rdx
addq %r9, %rdx
jmpq *%rdx
movl $0x1, (%rbx)
movq -0x30(%rbp), %rdx
movl %edx, 0x4(%rbx)
movq %r11, 0x8(%rbx)
movq %rax, 0x10(%rbx)
movq %rcx, 0x18(%rbx)
movl $0x1, %edi
movq %r13, %r15
movl $0x1, %edx
jmp 0x4b4d
decl %esi
cmoveq %r10, %r11
jmp 0x4b48
movl $0x1, %esi
jmp 0x4981
movl $0x3, %esi
jmp 0x4981
movq -0x30(%rbp), %rdx
cmpl $0x2, %edx
je 0x4b2c
cmpl $0x1, %edx
jne 0x4b30
movq %r13, (%r14)
movl $0x1, %edx
movq %rdx, -0x30(%rbp)
jmp 0x4b34
movl $0x2, %esi
leaq 0x8ba8(%rip), %r11      # 0xd530
jmp 0x4b48
movq -0x30(%rbp), %rdx
decl %edx
cmpl $0x1, %edx
jne 0x4a1d
movl %esi, -0x40(%rbp)
movq (%r14), %rsi
movq %r13, %rdx
subq %rsi, %rdx
incq %rdx
movq %rdx, 0x8(%r14)
movl $0x7, %edx
movq %r8, %r15
movq %r10, %r8
movl %edi, %r10d
movq %r11, %rdi
movl $0x1, %r11d
movq %r11, -0x30(%rbp)
movq %rdi, %r11
movl %r10d, %edi
movq %r8, %r10
movq %r15, %r8
testq %rsi, %rsi
movl -0x40(%rbp), %esi
jne 0x4b4a
jmp 0x4b48
movq -0x30(%rbp), %r15
cmpl $0x2, %r15d
jl 0x49fb
jne 0x49f7
incq 0x10(%r14)
incq 0x18(%r14)
leal 0x1(%r15), %edx
cmpl $0x1, %r15d
jne 0x4a08
movq %r13, (%r14)
jmp 0x4a1d
cmpl $0x2, -0x30(%rbp)
jne 0x4b48
decq 0x10(%r14)
movl $0x2, %edx
movq %rdx, -0x30(%rbp)
jmp 0x4b48
cmpl $0x1, -0x30(%rbp)
jne 0x4b27
movl %esi, %r15d
movq (%r14), %rsi
movq %r13, %rdx
subq %rsi, %rdx
incq %rdx
movq %rdx, 0x8(%r14)
movl $0x7, %edx
movl $0x1, %r11d
movq %r11, -0x30(%rbp)
movq %r8, %r11
testq %rsi, %rsi
movl %r15d, %esi
je 0x4b48
movq %r8, %r11
jmp 0x4b4a
leaq 0x8bc0(%rip), %r11      # 0xd630
jmp 0x4b48
cmpl $0x1, -0x30(%rbp)
jne 0x4b21
movl %esi, -0x40(%rbp)
movl %edi, -0x34(%rbp)
movq (%r14), %rax
movq %r13, %r15
movq %rax, -0x30(%rbp)
subq %rax, %r15
movq %r15, 0x8(%r14)
movq %r14, %rdi
callq 0x4c2f
movl %eax, 0x20(%r14)
cmpl $0x4, %eax
jne 0x4ac2
movq -0x30(%rbp), %rax
cmpb $0x22, (%rax)
jne 0x4ac2
movq -0x30(%rbp), %rax
incq %rax
movq %rax, (%r14)
addq $-0x2, %r15
movq %r15, 0x8(%r14)
movl -0x34(%rbp), %edi
movl %edi, (%rbx)
movl $0x1, 0x4(%rbx)
leaq 0x875b(%rip), %r8       # 0xd230
movq %r8, 0x8(%rbx)
movq %r13, 0x10(%rbx)
movq %r12, 0x18(%rbx)
movl $0x1, %eax
movq %rax, -0x30(%rbp)
movq %r13, %r15
movl $0x1, %edx
movq %r13, %rax
movq %r12, %rcx
leaq 0x4acd(%rip), %r9       # 0x95cc
leaq 0x892a(%rip), %r10      # 0xd430
movq %r8, %r11
movl -0x40(%rbp), %esi
jmp 0x4b4d
movq -0x30(%rbp), %rdx
cmpl $0x2, %edx
je 0x4b39
cmpl $0x1, %edx
jne 0x4b3d
movq %r13, (%r14)
jmp 0x4b41
decq %r13
incq %r12
movq %r8, %r11
jmp 0x4b48
incq 0x10(%r14)
incq 0x18(%r14)
movq %r10, %r11
jmp 0x4b48
incq 0x10(%r14)
incq 0x18(%r14)
leaq 0x87e8(%rip), %r11      # 0xd330
xorl %edx, %edx
movq %r13, %r15
testl %edx, %edx
jne 0x4b7c
leaq 0x1(%r15), %r13
decq %r12
jne 0x48e9
movq -0x30(%rbp), %rdx
testl %edx, %edx
je 0x4bd5
movl %edi, (%rbx)
movl %edx, 0x4(%rbx)
movq %r11, 0x8(%rbx)
movq %rax, 0x10(%rbx)
movq %rcx, 0x18(%rbx)
jmp 0x4892
cmpl $0x7, %edx
jne 0x4892
movq %r11, -0x40(%rbp)
movl %edi, %r13d
incq %r15
decq %r12
movq %r14, %rdi
callq 0x4c2f
movl %eax, 0x20(%r14)
cmpl $0x4, %eax
jne 0x4bb6
movq (%r14), %rax
cmpb $0x22, (%rax)
jne 0x4bb6
incq %rax
movq %rax, (%r14)
addq $-0x2, 0x8(%r14)
movl %r13d, (%rbx)
movq -0x30(%rbp), %rax
movl %eax, 0x4(%rbx)
movq -0x40(%rbp), %rax
movq %rax, 0x8(%rbx)
movq %r15, 0x10(%rbx)
movq %r12, 0x18(%rbx)
jmp 0x4892
movq (%r14), %r12
testq %r12, %r12
je 0x4c16
subq %r12, %r15
movq %r15, 0x8(%r14)
movl %edi, -0x34(%rbp)
movq %r14, %rdi
movq %r11, %r13
callq 0x4c2f
movq %r13, %r11
movl -0x34(%rbp), %edi
movl %eax, 0x20(%r14)
cmpl $0x4, %eax
jne 0x4c16
cmpb $0x22, (%r12)
jne 0x4c16
incq %r12
movq %r12, (%r14)
addq $-0x2, %r15
movq %r15, 0x8(%r14)
movl %edi, (%rbx)
movl $0x0, 0x4(%rbx)
movq %r11, 0x8(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
jmp 0x4892