// File: /workspace/github_c_makefile_star2_O3/mruby-zest[P]osc-bridge/src/mm_json.h
// Function: mm_json_convert
MM_JSON_API mm_json_int
mm_json_convert(mm_json_number *num, const struct mm_json_token *tok)
{
    mm_json_size len;
    const mm_json_char *cur;
    mm_json_number i, f, e, p;
    enum {INT, FLT, EXP, TOKS};
    struct mm_json_token nums[TOKS];
    struct mm_json_token *write = &nums[INT];

    MM_JSON_ASSERT(num);
    MM_JSON_ASSERT(tok);
    if (!num || !tok || !tok->str || !tok->len)
        return MM_JSON_NONE;

    nums[INT] = MM_JSON_TOKEN_NULL;
    nums[FLT] = MM_JSON_TOKEN_NULL;
    nums[EXP] = MM_JSON_TOKEN_NULL;
    len = tok->len;
    write->str = tok->str;

    for (cur = tok->str; len; cur++, len--) {
        char state =  mm_json_go_num[*(const unsigned char*)cur];
        switch (state) {
            case MM_JSON_STATE_NUM_FAILED: {
                return MM_JSON_NONE;
            } break;
            case MM_JSON_STATE_NUM_FLT: {
                if (nums[FLT].str)
                    return MM_JSON_NONE;
                if (nums[EXP].str)
                    return MM_JSON_NONE;
                write->len = (mm_json_size)(cur - write->str);
                write = &nums[FLT];
                write->str = cur + 1;
            } break;
            case MM_JSON_STATE_NUM_EXP: {
                if (nums[EXP].str)
                    return MM_JSON_NONE;
                write->len = (mm_json_size)(cur - write->str);
                write = &nums[EXP];
                write->str = cur + 1;
            } break;
            case MM_JSON_STATE_NUM_BREAK: {
                len = 1;
            } break;
            default: break;
        }
    }
    write->len = (mm_json_size)(cur - write->str);

    i = mm_json_stoi(&nums[INT]);
    f = mm_json_stof(&nums[FLT]);
    e = mm_json_stoi(&nums[EXP]);
    p = mm_json_ipow(10, (unsigned)((e < 0) ? -e : e));
    if (e < 0) p = (1 / p);
    *num = (i + ((i < 0) ? -f : f)) * p;
    return MM_JSON_NUMBER;
}

// Assembly:
testq %rdi, %rdi
sete %cl
testq %rsi, %rsi
sete %dl
xorl %eax, %eax
orb %cl, %dl
jne 0x46b7
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdi, %rbx
movq (%rsi), %rdi
testq %rdi, %rdi
je 0x46a6
movq 0x8(%rsi), %rcx
testq %rcx, %rcx
je 0x46a6
leaq -0x70(%rbp), %rdx
xorpd %xmm0, %xmm0
movapd %xmm0, -0x50(%rdx)
movapd %xmm0, -0x30(%rdx)
movapd %xmm0, 0x10(%rdx)
movapd %xmm0, (%rdx)
movapd %xmm0, -0x10(%rdx)
movapd %xmm0, -0x20(%rdx)
movapd %xmm0, -0x40(%rdx)
movq $0x0, 0x20(%rdx)
movq %rdi, -0x50(%rdx)
leaq -0xc0(%rbp), %r8
xorl %r13d, %r13d
movq 0x28(%r8), %r10
leaq 0x924f(%rip), %r11      # 0xd730
leaq 0x50d0(%rip), %r15      # 0x95b8
movq %rdi, %r12
movq %rdi, %r9
movq %rdi, %rsi
xorl %r14d, %r14d
movzbl (%rsi), %eax
movzbl (%rax,%r11), %eax
cmpq $0x4, %rax
ja 0x454e
movslq (%r15,%rax,4), %rax
addq %r15, %rax
jmpq *%rax
orq -0x70(%rbp), %r14
jne 0x4562
movq %r12, %rax
subq %r9, %rax
movq %rax, 0x8(%r8)
leaq 0x1(%rsi), %r10
movq %r10, %r9
xorl %r13d, %r13d
movq %r10, %r14
leaq -0x98(%rbp), %r8
jmp 0x454e
testq %r13, %r13
jne 0x4562
movq %r12, %rax
subq %r9, %rax
movq %rax, 0x8(%r8)
leaq 0x1(%rsi), %r9
movq %r9, -0x70(%rbp)
movq %r9, %r13
movq %rdx, %r8
incq %rsi
incq %r12
decq %rcx
jne 0x44f4
movq %r10, -0x98(%rbp)
jmp 0x457a
movq %r10, -0x98(%rbp)
xorl %eax, %eax
jmp 0x46a6
movq %r10, -0x98(%rbp)
incq %rsi
subq %r9, %rsi
movq %rsi, 0x8(%r8)
movq -0xb8(%rbp), %rsi
callq 0x46b8
movsd %xmm0, -0x30(%rbp)
movq -0x90(%rbp), %rax
testq %r14, %r14
sete %cl
testq %rax, %rax
sete %dl
orb %cl, %dl
xorpd %xmm3, %xmm3
jne 0x45e5
movsd 0x4fdb(%rip), %xmm0     # 0x9590
xorl %ecx, %ecx
movapd %xmm0, %xmm1
movb (%r14,%rcx), %dl
addb $-0x30, %dl
cmpb $0x9, %dl
ja 0x45dd
movsbl %dl, %edx
xorps %xmm2, %xmm2
cvtsi2sd %edx, %xmm2
mulsd %xmm1, %xmm2
addsd %xmm2, %xmm3
mulsd %xmm0, %xmm1
incq %rcx
cmpq %rcx, %rax
jne 0x45bb
movapd %xmm3, -0x40(%rbp)
movq -0x70(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x46b8
movapd 0x4f71(%rip), %xmm1     # 0x9570
xorpd %xmm0, %xmm1
maxsd %xmm0, %xmm1
cvttsd2si %xmm1, %rax
movsd 0x4f84(%rip), %xmm1     # 0x9598
movapd %xmm1, %xmm2
testl %eax, %eax
je 0x4651
movl $0xa, %edx
movl $0x1, %ecx
movl $0x1, %esi
movl %eax, %edi
testb $0x1, %al
movl %edx, %r8d
cmovel %esi, %r8d
movslq %r8d, %r8
imulq %r8, %rcx
shrl %edi
imull %edx, %edx
cmpl $0x1, %eax
movl %edi, %eax
ja 0x462d
xorps %xmm2, %xmm2
cvtsi2sd %rcx, %xmm2
divsd %xmm2, %xmm1
xorpd %xmm3, %xmm3
cmpltsd %xmm3, %xmm0
andpd %xmm0, %xmm1
andnpd %xmm2, %xmm0
orpd %xmm1, %xmm0
movapd 0x4efe(%rip), %xmm1     # 0x9570
movapd -0x40(%rbp), %xmm5
xorpd %xmm5, %xmm1
movsd -0x30(%rbp), %xmm4
movapd %xmm4, %xmm2
cmpltsd %xmm3, %xmm2
andpd %xmm2, %xmm1
andnpd %xmm5, %xmm2
orpd %xmm1, %xmm2
addsd %xmm4, %xmm2
mulsd %xmm0, %xmm2
movsd %xmm2, (%rbx)
movl $0x3, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq