// File: /workspace/github_c_makefile_star2_O1/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 0x46c8
movq (%rsi), %rcx
testq %rcx, %rcx
je 0x46c8
movq 0x8(%rsi), %rdx
testq %rdx, %rdx
je 0x46c8
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x98, %rsp
movq %rdi, %rbx
leaq -0x88(%rbp), %rax
leaq -0x60(%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)
movapd %xmm0, -0x40(%r14)
movq $0x0, 0x20(%r14)
movq %rcx, -0x50(%r14)
movq -0x28(%r14), %r9
movq %rcx, %rsi
incq %rsi
leaq -0xb0(%rbp), %r10
leaq 0x922e(%rip), %rdi      # 0xd730
leaq 0x50af(%rip), %r8       # 0x95b8
movzbl -0x1(%rsi), %r11d
movzbl (%r11,%rdi), %r11d
cmpq $0x4, %r11
ja 0x455e
movslq (%r8,%r11,4), %r11
addq %r8, %r11
jmpq *%r11
movq -0x60(%rbp), %r11
orq %r9, %r11
jne 0x454f
movq %rcx, %r9
subq (%r10), %r9
movq %r9, 0x8(%r10)
movq %rsi, -0x88(%rbp)
movb $0x1, %r11b
movq %rsi, %r9
movq %rax, %r10
jmp 0x4577
cmpq $0x0, -0x60(%rbp)
je 0x4563
xorl %r11d, %r11d
jmp 0x4577
movb $0x1, %r11b
movl $0x1, %edx
jmp 0x4577
movb $0x1, %r11b
jmp 0x4577
movq %rcx, %r11
subq (%r10), %r11
movq %r11, 0x8(%r10)
movq %rsi, -0x60(%rbp)
movb $0x1, %r11b
movq %r14, %r10
testb %r11b, %r11b
je 0x46b9
incq %rsi
incq %rcx
decq %rdx
jne 0x4509
subq (%r10), %rcx
movq %rcx, 0x8(%r10)
leaq -0xb0(%rbp), %r15
movq %r15, %rdi
callq 0x46c9
movsd %xmm0, -0x20(%rbp)
movq 0x28(%r15), %rax
xorpd %xmm3, %xmm3
testq %rax, %rax
je 0x45fb
movq -0x80(%rbp), %rcx
testq %rcx, %rcx
je 0x45fb
movsd 0x4fc8(%rip), %xmm0     # 0x9590
xorl %edx, %edx
movapd %xmm0, %xmm1
movb (%rax,%rdx), %sil
addb $-0x30, %sil
cmpb $0x9, %sil
ja 0x45f3
movzbl %sil, %esi
xorps %xmm2, %xmm2
cvtsi2sd %esi, %xmm2
mulsd %xmm1, %xmm2
addsd %xmm2, %xmm3
mulsd %xmm0, %xmm1
incq %rdx
cmpq %rdx, %rcx
jne 0x45ce
movapd %xmm3, -0x30(%rbp)
movq %r14, %rdi
callq 0x46c9
movapd 0x4f60(%rip), %xmm1     # 0x9570
xorpd %xmm0, %xmm1
maxsd %xmm0, %xmm1
cvttsd2si %xmm1, %rax
movsd 0x4f73(%rip), %xmm1     # 0x9598
movapd %xmm1, %xmm2
testl %eax, %eax
je 0x4662
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 0x463e
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 0x4eed(%rip), %xmm1     # 0x9570
movapd -0x30(%rbp), %xmm5
xorpd %xmm5, %xmm1
movsd -0x20(%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
jmp 0x46bb
xorl %eax, %eax
addq $0x98, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq