// File: /workspace/github_c_makefile_star2_O2/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 0x450f
movq (%rsi), %rcx
testq %rcx, %rcx
je 0x450f
movq 0x8(%rsi), %rdx
testq %rdx, %rdx
je 0x450f
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdi, %rbx
leaq -0x70(%rbp), %r14
xorpd %xmm0, %xmm0
movapd %xmm0, -0x50(%r14)
movapd %xmm0, -0x30(%r14)
movapd %xmm0, 0x10(%r14)
movapd %xmm0, (%r14)
movapd %xmm0, -0x10(%r14)
movapd %xmm0, -0x20(%r14)
andq $0x0, 0x20(%r14)
movapd %xmm0, -0x40(%r14)
movq %rcx, -0x50(%r14)
movq -0x28(%r14), %r8
leaq 0x1(%rcx), %rsi
leaq -0xc0(%rbp), %r12
xorl %eax, %eax
leaq 0x83d7(%rip), %rdi      # 0xc730
leaq 0x4210(%rip), %r11      # 0x8570
movq %rcx, %r9
xorl %r15d, %r15d
movq %rcx, %r13
testq %rdx, %rdx
je 0x43e6
movzbl -0x1(%rsi), %r10d
movzbl (%r10,%rdi), %r10d
cmpq $0x4, %r10
ja 0x43d8
movslq (%r11,%r10,4), %r10
addq %r11, %r10
jmpq *%r10
orq -0x70(%rbp), %r15
jne 0x44f5
movq %r9, %rax
subq %rcx, %rax
movq %rax, 0x8(%r12)
movq %rsi, %r8
movq %rsi, %rcx
xorl %eax, %eax
movq %rsi, %r15
leaq -0x98(%rbp), %r12
jmp 0x43d8
testq %rax, %rax
jne 0x44f5
movq %r9, %rax
subq %rcx, %rax
movq %rax, 0x8(%r12)
leaq 0x1(%r13), %rcx
movq %rsi, -0x70(%rbp)
movq %rsi, %rax
movq %r14, %r12
jmp 0x43d8
pushq $0x1
popq %rdx
incq %r13
decq %rdx
incq %r9
incq %rsi
jmp 0x4369
leaq -0xc0(%rbp), %rdi
movq %r8, 0x28(%rdi)
subq %rcx, %r9
movq %r9, 0x8(%r12)
callq 0x4510
xorpd %xmm3, %xmm3
testq %r15, %r15
movsd %xmm0, -0x30(%rbp)
je 0x444f
movq -0x90(%rbp), %rax
testq %rax, %rax
je 0x444f
movsd 0x4108(%rip), %xmm0     # 0x8528
xorl %ecx, %ecx
movapd %xmm0, %xmm1
cmpq %rcx, %rax
je 0x444f
movb (%r15,%rcx), %dl
addb $-0x30, %dl
cmpb $0x9, %dl
ja 0x444a
movsbl %dl, %edx
cvtsi2sd %edx, %xmm2
mulsd %xmm1, %xmm2
addsd %xmm2, %xmm3
mulsd %xmm0, %xmm1
incq %rcx
jmp 0x4426
movapd %xmm3, -0x40(%rbp)
movq %r14, %rdi
callq 0x4510
movapd 0x40ec(%rip), %xmm1     # 0x8550
xorpd %xmm0, %xmm1
maxsd %xmm0, %xmm1
cvttsd2si %xmm1, %rax
pushq $0x1
popq %rcx
pushq $0xa
popq %rdx
pushq $0x1
popq %rsi
testl %eax, %eax
je 0x4493
testb $0x1, %al
movl %edx, %edi
cmovel %esi, %edi
movslq %edi, %rdi
imulq %rdi, %rcx
shrl %eax
imull %edx, %edx
jmp 0x447a
cvtsi2sd %rcx, %xmm1
movsd 0x4090(%rip), %xmm2     # 0x8530
divsd %xmm1, %xmm2
xorpd %xmm3, %xmm3
cmpltsd %xmm3, %xmm0
andpd %xmm0, %xmm2
andnpd %xmm1, %xmm0
orpd %xmm2, %xmm0
movapd 0x408f(%rip), %xmm1     # 0x8550
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)
pushq $0x3
popq %rax
jmp 0x44fe
movq %r8, -0x98(%rbp)
xorl %eax, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq