// File: /workspace/github_c_makefile_star2_O3/lengjingzju[P]json/jnum.c
// Function: jnum_parse_num
int jnum_parse_num(const char *str, jnum_type_t *type, jnum_value_t *value)
{
#define IS_DIGIT(c)     ((c) >= '0' && (c) <= '9')
    const char *s = str;
    int32_t eneg = 0, e = 0, k = 0, ek = 0, b = 0, i = 0, z = 0;
    uint64_t neg = 0, m = 0, n = 0;

    switch (*s) {
    case '-':
        neg = 1;
        FALLTHROUGH_ATTR;
    case '+':
        ++s;
        break;
    case '0':
        if ((*(s + 1) == 'x' || *(s + 1) == 'X')) {
            int len = jnum_parse_hex(s, type, value);
            if (len == 2) {
                *type = JNUM_INT;
                value->vint = 0;
                return 1;
            }
            return len;
        }
        break;
    default:
        break;
    }

    if (!IS_DIGIT(*s) && (*s != '.')) {
        *type = JNUM_NULL;
        value->vint = 0;
        return 0;
    }

    /* ---------- Parse integer ---------- */
    while (*s == '0')
        ++s;
    while (IS_DIGIT(*s)) {
        m = (m << 3) + (m << 1) + (*s++ - '0');
        ++k;
    }
    if (k >= 20) {
        goto overflow1;
    }

    if (*s != '.') {
        if (*s != 'e' && *s != 'E') {
            goto end1;
        }
    } else {
        /* ---------- Parse decimal ---------- */
        ++s;
        if (m == 0) {
            while (*s == '0') {
                ++s;
                --z;
            }
        } else {
            n = m;
            b = k;
        }

        while (IS_DIGIT(*s)) {
            m = (m << 3) + (m << 1) + (*s++ - '0');
            ++k;
            --i;
        }
        if (k >= 20) {
            goto overflow2;
        }

        if (*s != 'e' && *s != 'E') {
            goto end2;
        }
    }

end3:
    /* ---------- Parse Exponent ---------- */
    switch (*(s + 1)) {
    case '-':
        eneg = 1;
        FALLTHROUGH_ATTR;
    case '+':
        if (IS_DIGIT(*(s + 2))) {
            s += 2;
            break;
        }
        if (i)
            goto end2;
        else
            goto end1;
    case '0': case '1': case '2': case '3': case '4':
    case '5': case '6': case '7': case '8': case '9':
        ++s;
        break;
    default:
        if (i)
            goto end2;
        else
            goto end1;
    }

    while (*s == '0')
        ++s;
    ek = 0;
    while (IS_DIGIT(*s)) {
        e = (e << 3) + (e << 1) + (*s++ - '0');
        ++ek;
        if (ek == 4)
            break;
    }
    while (IS_DIGIT(*s))
        ++s;
    i += eneg == 0 ? e : -e;

end2:
    *type = JNUM_DOUBLE;
    if (m == 0) {
        value->vlhex = neg << 63;
    } else {
        value->vdbl = ldouble_rconvert(m, i + z);
        value->vlhex |= neg << 63;
    }
    return (int)(s - str);

end1:
    if (m <= 2147483647U /*INT_MAX*/) {
        *type = JNUM_INT;
        value->vint = neg == 0 ? (int32_t)m : -((int32_t)m);
    } else if (m <= 9223372036854775807U /*LLONG_MAX*/) {
        *type = JNUM_LINT;
        value->vlint = neg == 0 ? (int64_t)m : -((int64_t)m);
    } else {
        if (m == 9223372036854775808U && neg == 1) {
            *type = JNUM_LINT;
#if defined(_MSC_VER)
            value->vlint = -9223372036854775807 - 1;
#else
            value->vlint = -m;
#endif
        } else {
            *type = JNUM_DOUBLE;
            value->vdbl = neg == 0 ? (double)m : -((double)m);
        }
    }
    return (int)(s - str);

overflow1:
    s -= k;
    m = 0;
    k = 0;
    while (IS_DIGIT(*s)) {
        m = (m << 3) + (m << 1) + (*s++ - '0');
        ++k;
        if (k == 19)
            break;
    }

    while (1) {
        switch (*s) {
        case '0': case '1': case '2': case '3': case '4':
        case '5': case '6': case '7': case '8': case '9':
            ++s;
            ++i;
            break;
        case '.':
            ++s;
            while (IS_DIGIT(*s))
                ++s;
            if (*s == 'e' || *s == 'E') {
                goto end3;
            }
            goto end2;
        case 'e': case 'E':
            goto end3;
        default:
            goto end2;
        }
    }

overflow2:
    s -= k - b;
    m = n;
    k = b;
    i = 0;

    while (IS_DIGIT(*s)) {
        m = (m << 3) + (m << 1) + (*s++ - '0');
        ++k;
        --i;
        if (k == 19)
            break;
    }
    while (IS_DIGIT(*s))
        ++s;

    if (*s == 'e' || *s == 'E') {
        goto end3;
    }
    goto end2;
}

// Assembly:
movq %rdx, %r8
movzbl (%rdi), %eax
xorl %r10d, %r10d
cmpl $0x2b, %eax
je 0x8ef1
cmpl $0x30, %eax
je 0x8fb4
movq %rdi, %rdx
cmpl $0x2d, %eax
jne 0x8ef8
movl $0x1, %r10d
leaq 0x1(%rdi), %rdx
movb 0x1(%rdi), %al
leal -0x30(%rax), %ecx
cmpb $0xa, %cl
setae %cl
cmpb $0x2e, %al
setne %al
testb %cl, %al
jne 0x8fa6
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %rbx
movb (%rdx), %r9b
incq %rdx
cmpb $0x30, %r9b
je 0x8f16
leal -0x30(%r9), %eax
xorl %ecx, %ecx
cmpb $0x9, %al
ja 0x9031
xorl %r11d, %r11d
movl $0x13, %r14d
xorl %eax, %eax
leaq (%rax,%rax,4), %rax
addb $-0x30, %r9b
movzbl %r9b, %r9d
leaq (%r9,%rax,2), %rax
movb 0x1(%rbx), %r9b
incq %rbx
leal -0x30(%r9), %ebp
decl %r11d
decq %r14
cmpb $0xa, %bpl
jb 0x8f3e
cmpl $-0x13, %r11d
jae 0x9038
addq %r14, %rbx
movq $-0x1, %rcx
xorl %eax, %eax
movb (%rdx,%rcx), %r9b
addb $-0x30, %r9b
cmpb $0x9, %r9b
ja 0x90d6
leaq (%rax,%rax,4), %rax
movzbl %r9b, %r9d
leaq (%r9,%rax,2), %rax
incq %rcx
cmpl $0x12, %ecx
jne 0x8f7b
jmp 0x90dc
xorl %r9d, %r9d
movl %r9d, (%rsi)
movl %r9d, (%r8)
jmp 0x94b1
movzbl 0x1(%rdi), %eax
orl $0x20, %eax
cmpl $0x78, %eax
jne 0x90a0
movl $0x2, %r9d
xorl %eax, %eax
movabsq $0x7e0000007e03ff, %rcx # imm = 0x7E0000007E03FF
leaq 0x488f(%rip), %rdx      # 0xd86c
movb (%rdi,%r9), %r10b
leal -0x30(%r10), %r11d
cmpb $0x36, %r11b
ja 0x9016
movzbl %r11b, %r11d
btq %r11, %rcx
jae 0x9016
addb (%r11,%rdx), %r10b
movq %rax, %r11
shlq $0x4, %r11
movzbl %r10b, %eax
addq %r11, %rax
incq %r9
cmpq $0x12, %r9
jl 0x8fdd
movl $0x12, %r9d
movq %rax, %rcx
shrq $0x20, %rcx
je 0x90ab
movl $0x5, (%rsi)
movq %rax, (%r8)
jmp 0x90b4
xorl %eax, %eax
xorl %r11d, %r11d
jmp 0x903b
negl %r11d
cmpb $0x65, %r9b
je 0x906f
movzbl %r9b, %edx
cmpl $0x45, %edx
je 0x906f
cmpl $0x2e, %edx
jne 0x9079
leaq 0x1(%rbx), %r9
xorl %ecx, %ecx
movb 0x1(%rbx), %r15b
testq %rax, %rax
je 0x915d
movl %r11d, %ebx
xorl %edx, %edx
movq %rax, %r14
jmp 0x9175
movq %rbx, %r9
xorl %edx, %edx
jmp 0x920f
movq %rbx, %r9
cmpq $0x7fffffff, %rax       # imm = 0x7FFFFFFF
ja 0x913c
movl $0x2, (%rsi)
movl %eax, %ecx
negl %ecx
testq %r10, %r10
cmovel %eax, %ecx
movl %ecx, (%r8)
jmp 0x94a6
xorl %r10d, %r10d
movq %rdi, %rdx
jmp 0x8f0e
movl $0x3, (%rsi)
movl %eax, (%r8)
cmpl $0x2, %r9d
jne 0x94b1
movl $0x2, (%rsi)
movl $0x0, (%r8)
movl $0x1, %r9d
jmp 0x94b1
addq %rcx, %rdx
movq %rdx, %rbx
xorl %ecx, %ecx
movzbl (%rbx,%rcx), %edx
leal -0x30(%rdx), %r9d
cmpl $0xa, %r9d
jae 0x90f1
incq %rcx
jmp 0x90de
cmpl $0x65, %edx
je 0x912f
cmpl $0x45, %edx
je 0x912f
addq %rcx, %rbx
cmpl $0x2e, %edx
jne 0x94b5
movq %rbx, %r9
movzbl 0x1(%r9), %edx
incq %r9
leal -0x30(%rdx), %r11d
cmpb $0xa, %r11b
jb 0x910a
orl $0x20, %edx
cmpl $0x65, %edx
je 0x9072
xorl %edx, %edx
jmp 0x9293
addq %rcx, %rbx
xorl %edx, %edx
movq %rbx, %r9
jmp 0x920f
testq %rax, %rax
js 0x94bf
movl $0x4, (%rsi)
movq %rax, %rcx
negq %rcx
testq %r10, %r10
cmoveq %rax, %rcx
jmp 0x94d9
xorl %ebx, %ebx
xorl %edx, %edx
cmpb $0x30, %r15b
jne 0x9172
decl %edx
movb 0x1(%r9), %r15b
incq %r9
jmp 0x9161
xorl %r14d, %r14d
leal -0x30(%r15), %ebp
cmpb $0x9, %bpl
ja 0x91a7
xorl %ecx, %ecx
leaq (%rax,%rax,4), %rax
addb $-0x30, %r15b
movzbl %r15b, %r15d
leaq (%r15,%rax,2), %rax
decl %ecx
movb 0x1(%r9), %r15b
incq %r9
leal -0x30(%r15), %ebp
cmpb $0xa, %bpl
jb 0x9181
subl %ecx, %r11d
cmpl $0x13, %r11d
jbe 0x91fd
subl %ebx, %r11d
subq %r11, %r9
addl $-0x13, %ebx
xorl %ecx, %ecx
movb (%r9), %al
addb $-0x30, %al
cmpb $0x9, %al
ja 0x91d7
leaq (%r14,%r14,4), %r11
incq %r9
movzbl %al, %eax
leaq (%rax,%r11,2), %r14
decl %ecx
cmpl %ecx, %ebx
jne 0x91b8
movl %ebx, %ecx
movq %r14, %rax
decq %r9
movzbl 0x1(%r9), %r11d
incq %r9
leal -0x30(%r11), %ebx
cmpb $0xa, %bl
jb 0x91dd
orl $0x20, %r11d
cmpl $0x65, %r11d
je 0x920f
jmp 0x9293
movzbl %r15b, %r11d
orl $0x20, %r11d
cmpl $0x65, %r11d
jne 0x9293
movzbl 0x1(%r9), %ebx
movb $0x1, %r11b
leal -0x30(%rbx), %ebp
cmpl $0xa, %ebp
jae 0x932b
incq %r9
movq %r9, %r14
leaq 0x4(%r9), %rbx
movq %rbx, %r9
cmpb $0x30, (%r14)
leaq 0x1(%r14), %r14
leaq 0x1(%rbx), %rbx
je 0x922d
xorl %ebx, %ebx
movq $-0x1, %r15
movb (%r14,%r15), %bpl
addb $-0x30, %bpl
cmpb $0x9, %bpl
ja 0x926b
leal (%rbx,%rbx,4), %ebx
movzbl %bpl, %r12d
leal (%r12,%rbx,2), %ebx
incq %r15
cmpl $0x3, %r15d
jne 0x9247
jmp 0x9271
addq %r15, %r14
movq %r14, %r9
decq %r9
movb 0x1(%r9), %bpl
incq %r9
addb $-0x30, %bpl
cmpb $0xa, %bpl
jb 0x9274
movl %ebx, %ebp
negl %ebp
testb %r11b, %r11b
cmovnel %ebx, %ebp
addl %ecx, %ebp
movl %ebp, %ecx
movl $0x6, (%rsi)
testq %rax, %rax
je 0x930a
addl %ecx, %edx
cmpl $-0x13, %edx
jl 0x9316
testl %edx, %edx
js 0x935a
cmpl $0x13, %edx
ja 0x93ae
movq %rax, %xmm0
movq 0x17bd(%rip), %xmm1     # 0xaa80
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x17c1(%rip), %xmm2     # 0xaa90
subpd %xmm2, %xmm0
movapd %xmm0, %xmm3
unpckhpd %xmm0, %xmm3            # xmm3 = xmm3[1],xmm0[1]
addsd %xmm0, %xmm3
movl %edx, %eax
leaq 0x2b58(%rip), %rcx      # 0xbe40
movq (%rcx,%rax,8), %xmm4
punpckldq %xmm1, %xmm4    # xmm4 = xmm4[0],xmm1[0],xmm4[1],xmm1[1]
subpd %xmm2, %xmm4
movapd %xmm4, %xmm0
unpckhpd %xmm4, %xmm0            # xmm0 = xmm0[1],xmm4[1]
addsd %xmm4, %xmm0
mulsd %xmm3, %xmm0
jmp 0x9497
shlq $0x3f, %r10
movq %r10, %rax
jmp 0x94a3
pxor %xmm0, %xmm0
cmpl $0xfffffea9, %edx       # imm = 0xFFFFFEA9
jae 0x93ba
jmp 0x9497
cmpl $0x2b, %ebx
je 0x9338
cmpl $0x2d, %ebx
jne 0x934d
xorl %r11d, %r11d
movb 0x2(%r9), %bl
addb $-0x30, %bl
cmpb $0xa, %bl
jae 0x934d
addq $0x2, %r9
jmp 0x9226
testl %ecx, %ecx
jne 0x9293
jmp 0x907c
movq %rax, %xmm1
movq 0x1719(%rip), %xmm2     # 0xaa80
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x171d(%rip), %xmm3     # 0xaa90
subpd %xmm3, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
negl %edx
leaq 0x2ab4(%rip), %rax      # 0xbe40
movq (%rax,%rdx,8), %xmm1
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
subpd %xmm3, %xmm1
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
divsd %xmm2, %xmm0
jmp 0x9497
cmpl $0x134, %edx            # imm = 0x134
ja 0x948f
addl $0x158, %edx            # imm = 0x158
leaq 0x2b19(%rip), %rsi      # 0xbee0
leaq 0x3f82(%rip), %rcx      # 0xd350
movswl (%rcx,%rdx,2), %r11d
bsrq %rax, %rcx
xorq $0x3f, %rcx
shlq %cl, %rax
mulq (%rsi,%rdx,8)
bsrq %rdx, %rsi
xorq $0x3f, %rsi
subl %esi, %r11d
subl %ecx, %r11d
leal 0x4b(%r11), %eax
movb $0xa, %cl
subb %sil, %cl
movzbl %cl, %ebx
movb $0xb, %cl
subb %sil, %cl
movq %rdx, %rsi
shrq %cl, %rsi
btq %rbx, %rdx
jae 0x9436
incq %rsi
addl $0x4c, %r11d
movabsq $0xfffffffffffff, %rcx  # imm = 0xFFFFFFFFFFFFF
incq %rcx
movabsq $0x20000000000000, %rdx # imm = 0x20000000000000
cmpq %rdx, %rsi
cmovel %r11d, %eax
cmoveq %rcx, %rsi
cmpl $0xfffffbcf, %eax       # imm = 0xFFFFFBCF
jl 0x9464
cmpl $0x3cb, %eax            # imm = 0x3CB
jg 0x948f
addl $0x433, %eax            # imm = 0x433
movabsq $0xfffffffffffff, %rcx  # imm = 0xFFFFFFFFFFFFF
andq %rcx, %rsi
shlq $0x34, %rax
orq %rsi, %rax
movq %rax, %xmm0
jmp 0x9497
pxor %xmm0, %xmm0
cmpl $0xfffffb9a, %eax       # imm = 0xFFFFFB9A
jb 0x9497
movb $-0x32, %cl
subb %al, %cl
movq %rsi, %rdx
shrq %cl, %rdx
movl $0xfffffbcd, %ecx       # imm = 0xFFFFFBCD
subl %eax, %ecx
btq %rcx, %rsi
adcq $0x0, %rdx
movq %rdx, %xmm0
jmp 0x9497
movq 0x1629(%rip), %xmm0     # 0xaac0
shlq $0x3f, %r10
movq %xmm0, %rax
orq %r10, %rax
movq %rax, (%r8)
subl %edi, %r9d
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
movl %r9d, %eax
retq
xorl %edx, %edx
movq %rbx, %r9
jmp 0x9293
testq %r10, %r10
je 0x94de
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
cmpq %rcx, %rax
jne 0x94de
movl $0x4, (%rsi)
movq %rcx, (%r8)
jmp 0x94a6
movl $0x6, (%rsi)
movq %rax, %xmm1
punpckldq 0x158f(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x1597(%rip), %xmm1     # 0xaa90
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
testq %r10, %r10
je 0x9512
xorpd 0x158e(%rip), %xmm0     # 0xaaa0
movsd %xmm0, (%r8)
jmp 0x94a6