// File: /workspace/github_c_makefile_star2_O0/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:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
leaq -0xc0(%rbp), %rax
movq %rax, -0xc8(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x53e4
cmpq $0x0, -0x18(%rbp)
je 0x53e4
movq -0x18(%rbp), %rax
cmpq $0x0, (%rax)
je 0x53e4
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x53f0
movl $0x0, -0x4(%rbp)
jmp 0x56f1
leaq -0xc0(%rbp), %rdi
leaq 0x721a(%rip), %rsi      # 0xc618
movl $0x28, %edx
callq 0x21e0
leaq -0xc0(%rbp), %rdi
addq $0x28, %rdi
leaq 0x71fe(%rip), %rsi      # 0xc618
movl $0x28, %edx
callq 0x21e0
leaq -0xc0(%rbp), %rdi
addq $0x50, %rdi
leaq 0x71e2(%rip), %rsi      # 0xc618
movl $0x28, %edx
callq 0x21e0
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rcx
movq -0xc8(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x55b1
movq -0x28(%rbp), %rax
movzbl (%rax), %eax
leaq 0xb29f(%rip), %rcx      # 0x10720
movb (%rax,%rcx), %al
movb %al, -0xc9(%rbp)
movsbl -0xc9(%rbp), %eax
movl %eax, %ecx
movq %rcx, -0xd8(%rbp)
subl $0x4, %eax
ja 0x5590
movq -0xd8(%rbp), %rax
leaq 0x7117(%rip), %rcx      # 0xc5c8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x0, -0x4(%rbp)
jmp 0x56f1
cmpq $0x0, -0x98(%rbp)
je 0x54dc
movl $0x0, -0x4(%rbp)
jmp 0x56f1
cmpq $0x0, -0x70(%rbp)
je 0x54ef
movl $0x0, -0x4(%rbp)
jmp 0x56f1
movq -0x28(%rbp), %rcx
movq -0xc8(%rbp), %rax
movq (%rax), %rax
subq %rax, %rcx
movq -0xc8(%rbp), %rax
movq %rcx, 0x8(%rax)
leaq -0xc0(%rbp), %rax
addq $0x28, %rax
movq %rax, -0xc8(%rbp)
movq -0x28(%rbp), %rcx
addq $0x1, %rcx
movq -0xc8(%rbp), %rax
movq %rcx, (%rax)
jmp 0x5592
cmpq $0x0, -0x70(%rbp)
je 0x5544
movl $0x0, -0x4(%rbp)
jmp 0x56f1
movq -0x28(%rbp), %rcx
movq -0xc8(%rbp), %rax
movq (%rax), %rax
subq %rax, %rcx
movq -0xc8(%rbp), %rax
movq %rcx, 0x8(%rax)
leaq -0xc0(%rbp), %rax
addq $0x50, %rax
movq %rax, -0xc8(%rbp)
movq -0x28(%rbp), %rcx
addq $0x1, %rcx
movq -0xc8(%rbp), %rax
movq %rcx, (%rax)
jmp 0x5592
movq $0x1, -0x20(%rbp)
jmp 0x5592
jmp 0x5592
jmp 0x5594
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x5468
movq -0x28(%rbp), %rcx
movq -0xc8(%rbp), %rax
movq (%rax), %rax
subq %rax, %rcx
movq -0xc8(%rbp), %rax
movq %rcx, 0x8(%rax)
leaq -0xc0(%rbp), %rdi
callq 0x5700
movsd %xmm0, -0x30(%rbp)
leaq -0xc0(%rbp), %rdi
addq $0x28, %rdi
callq 0x5860
movsd %xmm0, -0x38(%rbp)
leaq -0xc0(%rbp), %rdi
addq $0x50, %rdi
callq 0x5700
movsd %xmm0, -0x40(%rbp)
xorps %xmm0, %xmm0
ucomisd -0x40(%rbp), %xmm0
jbe 0x5638
movsd -0x40(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0xe0(%rbp)
jmp 0x5645
movsd -0x40(%rbp), %xmm0
movsd %xmm0, -0xe0(%rbp)
movsd -0xe0(%rbp), %xmm0
cvttsd2si %xmm0, %rax
movl %eax, %esi
movl $0xa, %edi
callq 0x5950
movsd %xmm0, -0x48(%rbp)
xorps %xmm0, %xmm0
ucomisd -0x40(%rbp), %xmm0
jbe 0x567f
movsd 0x6f33(%rip), %xmm0     # 0xc5a8
divsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x30(%rbp), %xmm0
movsd %xmm0, -0xe8(%rbp)
xorps %xmm0, %xmm0
ucomisd -0x30(%rbp), %xmm0
jbe 0x56bc
movsd -0x38(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0xf0(%rbp)
jmp 0x56c9
movsd -0x38(%rbp), %xmm0
movsd %xmm0, -0xf0(%rbp)
movsd -0xe8(%rbp), %xmm0
movsd -0xf0(%rbp), %xmm1
addsd %xmm1, %xmm0
mulsd -0x48(%rbp), %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, (%rax)
movl $0x3, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xf0, %rsp
popq %rbp
retq
nopl (%rax)