// File: /workspace/github_c_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %r8
movzbl (%rdi), %eax
xorl %r10d, %r10d
cmpl $0x2b, %eax
je 0x747c
cmpl $0x30, %eax
je 0x752d
movq %rdi, %rcx
cmpl $0x2d, %eax
jne 0x7483
movabsq $0x1, %r10
leaq 0x1(%rdi), %rcx
movb 0x1(%rdi), %al
leal -0x30(%rax), %edx
cmpb $0xa, %dl
setae %dl
cmpb $0x2e, %al
setne %al
testb %dl, %al
jne 0x74df
leaq 0x13(%rcx), %rax
leaq 0x1(%rcx), %rdx
movq %rcx, %r9
movq %rax, %rbx
movq %rdx, %r14
movb (%rcx), %r11b
incq %rcx
incq %rax
incq %rdx
cmpb $0x30, %r11b
je 0x749d
xorl %edx, %edx
xorl %eax, %eax
leal -0x30(%r11), %ebp
cmpb $0x9, %bpl
ja 0x74ee
imulq $0xa, %rax, %r11
movzbl %bpl, %eax
addq %r11, %rax
incl %edx
movb 0x1(%r9), %r11b
incq %r9
incq %r14
jmp 0x74bc
andl $0x0, (%rsi)
andl $0x0, (%r8)
xorl %r9d, %r9d
jmp 0x7978
cmpl $0x13, %edx
jbe 0x75a6
movabsq $-0x1, %rdx
xorl %eax, %eax
movb (%rcx,%rdx), %r9b
addb $-0x30, %r9b
cmpb $0x9, %r9b
ja 0x75e1
imulq $0xa, %rax, %r11
movzbl %r9b, %eax
addq %r11, %rax
incq %rdx
cmpl $0x12, %edx
jne 0x7503
jmp 0x75e7
movzbl 0x1(%rdi), %eax
orl $0x20, %eax
cmpl $0x78, %eax
jne 0x7764
leaq 0x2(%rdi), %rcx
movabsq $0x2, %rdx
xorl %eax, %eax
movabsq $0x12, %r9
movabsq $0x7e0000007e03ff, %r10 # imm = 0x7E0000007E03FF
leaq 0x4304(%rip), %r11      # 0xb86c
cmpq $0x11, %rdx
jg 0x779d
movb (%rdi,%rdx), %bl
leal -0x30(%rbx), %ebp
cmpb $0x36, %bpl
ja 0x7792
movzbl %bpl, %r14d
btq %r14, %r10
jae 0x7797
addb (%r14,%r11), %bl
shlq $0x4, %rax
movzbl %bl, %ebx
addq %rbx, %rax
incq %rcx
incq %rdx
jmp 0x7568
xorl %ecx, %ecx
cmpb $0x65, %r11b
je 0x7633
movzbl %r11b, %r11d
cmpl $0x45, %r11d
je 0x7633
cmpl $0x2e, %r11d
jne 0x77ec
xorl %ecx, %ecx
testq %rax, %rax
je 0x7984
incq %r9
movl %edx, %ebx
xorl %r11d, %r11d
movq %rax, %r14
jmp 0x79a1
addq %rdx, %rcx
movq %rcx, %rbx
xorl %ecx, %ecx
movzbl (%rbx,%rcx), %edx
leal -0x30(%rdx), %r9d
cmpl $0xa, %r9d
jae 0x75fc
incq %rcx
jmp 0x75e9
cmpl $0x65, %edx
je 0x7638
cmpl $0x45, %edx
je 0x7638
addq %rcx, %rbx
cmpl $0x2e, %edx
jne 0x77d9
movq %rbx, %r9
movzbl 0x1(%r9), %edx
incq %r9
leal -0x30(%rdx), %r11d
cmpb $0xa, %r11b
jb 0x7615
orl $0x20, %edx
cmpl $0x65, %edx
jne 0x7a31
xorl %r11d, %r11d
jmp 0x7641
addq %rcx, %rbx
xorl %r11d, %r11d
movq %rbx, %r9
movzbl 0x1(%r9), %ebx
movb $0x1, %dl
leal -0x30(%rbx), %ebp
cmpl $0xa, %ebp
jae 0x7771
incq %r9
movq %r9, %r14
movabsq $-0x1, %r15
leaq 0x4(%r9), %rbx
movq %rbx, %r9
cmpb $0x30, (%r14)
leaq 0x1(%r14), %r14
leaq 0x1(%rbx), %rbx
je 0x7668
xorl %ebx, %ebx
movb (%r14,%r15), %bpl
addb $-0x30, %bpl
cmpb $0x9, %bpl
ja 0x769f
imull $0xa, %ebx, %r12d
movzbl %bpl, %ebx
addl %r12d, %ebx
incq %r15
cmpl $0x3, %r15d
jne 0x767b
jmp 0x76a5
addq %r15, %r14
movq %r14, %r9
decq %r9
movb 0x1(%r9), %bpl
incq %r9
addb $-0x30, %bpl
cmpb $0xa, %bpl
jb 0x76a8
movl %ebx, %ebp
negl %ebp
testb %dl, %dl
cmovnel %ebx, %ebp
addl %ecx, %ebp
movl %ebp, %ecx
movl $0x6, (%rsi)
testq %rax, %rax
je 0x7742
addl %ecx, %r11d
cmpl $-0x13, %r11d
jl 0x774e
testl %r11d, %r11d
js 0x780c
cmpl $0x13, %r11d
ja 0x7883
movq %rax, %xmm0
movq 0x1386(%rip), %xmm1     # 0x8a80
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x138a(%rip), %xmm2     # 0x8a90
subpd %xmm2, %xmm0
movapd %xmm0, %xmm3
unpckhpd %xmm0, %xmm3            # xmm3 = xmm3[1],xmm0[1]
addsd %xmm0, %xmm3
movl %r11d, %eax
leaq 0x2720(%rip), %rcx      # 0x9e40
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 0x7966
shlq $0x3f, %r10
movq %r10, %rax
jmp 0x7972
pxor %xmm0, %xmm0
cmpl $0xfffffea9, %r11d      # imm = 0xFFFFFEA9
jae 0x7890
jmp 0x7966
movb $0x30, %al
xorl %r10d, %r10d
movq %rdi, %rcx
jmp 0x7483
cmpl $0x2b, %ebx
je 0x777d
cmpl $0x2d, %ebx
jne 0x77e4
xorl %edx, %edx
movb 0x2(%r9), %bl
addb $-0x30, %bl
cmpb $0xa, %bl
jae 0x77e4
addq $0x2, %r9
jmp 0x7657
movq %rdx, %r9
jmp 0x779d
subq %rdi, %rcx
movq %rcx, %r9
movq %rax, %rcx
shrq $0x20, %rcx
je 0x77b1
movl $0x5, (%rsi)
movq %rax, (%r8)
jmp 0x77ba
movl $0x3, (%rsi)
movl %eax, (%r8)
cmpl $0x2, %r9d
jne 0x7978
movl $0x2, (%rsi)
andl $0x0, (%r8)
movl $0x1, %r9d
jmp 0x7978
xorl %r11d, %r11d
movq %rbx, %r9
jmp 0x76c6
testl %ecx, %ecx
jne 0x76c6
cmpq $0x7fffffff, %rax       # imm = 0x7FFFFFFF
ja 0x7862
movl $0x2, (%rsi)
movl %eax, %ecx
negl %ecx
testq %r10, %r10
cmovel %eax, %ecx
movl %ecx, (%r8)
jmp 0x7975
movq %rax, %xmm1
movq 0x1267(%rip), %xmm2     # 0x8a80
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x126b(%rip), %xmm3     # 0x8a90
subpd %xmm3, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
negl %r11d
leaq 0x2601(%rip), %rax      # 0x9e40
movq (%rax,%r11,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 0x7966
testq %rax, %rax
js 0x7a39
movl $0x4, (%rsi)
movq %rax, %rcx
negq %rcx
testq %r10, %r10
cmoveq %rax, %rcx
jmp 0x7a53
cmpl $0x134, %r11d           # imm = 0x134
ja 0x795e
addl $0x158, %r11d           # imm = 0x158
leaq 0x2642(%rip), %rdx      # 0x9ee0
bsrq %rax, %rcx
xorq $0x3f, %rcx
shlq %cl, %rax
mulq (%rdx,%r11,8)
leaq 0x3a9c(%rip), %rax      # 0xb350
movswl (%rax,%r11,2), %r11d
bsrq %rdx, %rbx
xorq $0x3f, %rbx
subl %ebx, %r11d
subl %ecx, %r11d
leal 0x4b(%r11), %eax
movb $0xa, %bpl
movb $0xb, %cl
subb %bl, %cl
movq %rdx, %rsi
shrq %cl, %rsi
subb %bl, %bpl
movzbl %bpl, %ecx
btq %rcx, %rdx
movabsq $0xfffffffffffff, %rcx  # imm = 0xFFFFFFFFFFFFF
jae 0x790f
incq %rsi
addl $0x4c, %r11d
leaq 0x1(%rcx), %rdx
movabsq $0x20000000000000, %rbx # imm = 0x20000000000000
cmpq %rbx, %rsi
cmovel %r11d, %eax
cmoveq %rdx, %rsi
cmpl $0xfffffbcf, %eax       # imm = 0xFFFFFBCF
jl 0x7933
cmpl $0x3cb, %eax            # imm = 0x3CB
jg 0x795e
addl $0x433, %eax            # imm = 0x433
andq %rcx, %rsi
shlq $0x34, %rax
orq %rsi, %rax
movq %rax, %xmm0
jmp 0x7966
pxor %xmm0, %xmm0
cmpl $0xfffffb9a, %eax       # imm = 0xFFFFFB9A
jb 0x7966
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 0x7966
movq 0x115a(%rip), %xmm0     # 0x8ac0
shlq $0x3f, %r10
movq %xmm0, %rax
orq %r10, %rax
movq %rax, (%r8)
subl %edi, %r9d
movl %r9d, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
xorl %r11d, %r11d
cmpb $0x30, (%r14,%r11)
jne 0x7993
incq %r11
jmp 0x7987
addq %r11, %r14
negl %r11d
xorl %ebx, %ebx
movq %r14, %r9
xorl %r14d, %r14d
movl %edx, %ebp
subl %ebx, %ebp
movzbl (%r9), %r15d
leal -0x30(%r15), %r12d
cmpb $0x9, %r12b
ja 0x79c7
imulq $0xa, %rax, %r15
incq %r9
movzbl %r12b, %eax
addq %r15, %rax
decl %ecx
incl %ebp
jmp 0x79a5
subl %ecx, %edx
cmpl $0x13, %edx
jbe 0x7a1e
movl %ebp, %eax
subq %rax, %r9
addl $-0x13, %ebx
xorl %ecx, %ecx
movb (%r9), %al
addb $-0x30, %al
cmpb $0x9, %al
ja 0x79f7
imulq $0xa, %r14, %rdx
incq %r9
movzbl %al, %r14d
addq %rdx, %r14
decl %ecx
cmpl %ecx, %ebx
jne 0x79d8
movl %ebx, %ecx
movq %r14, %rax
decq %r9
movzbl 0x1(%r9), %edx
incq %r9
leal -0x30(%rdx), %ebx
cmpb $0xa, %bl
jb 0x79fd
orl $0x20, %edx
cmpl $0x65, %edx
je 0x7641
jmp 0x76c6
orl $0x20, %r15d
cmpl $0x65, %r15d
je 0x7641
jmp 0x76c6
xorl %r11d, %r11d
jmp 0x76c6
testq %r10, %r10
je 0x7a5b
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
cmpq %rcx, %rax
jne 0x7a5b
movl $0x4, (%rsi)
movq %rcx, (%r8)
jmp 0x7975
movl $0x6, (%rsi)
movq %rax, %xmm1
punpckldq 0x1012(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x101a(%rip), %xmm1     # 0x8a90
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
testq %r10, %r10
je 0x7a8f
xorpd 0x1011(%rip), %xmm0     # 0x8aa0
movsd %xmm0, (%r8)
jmp 0x7975