// File: /workspace/github_c_makefile_star2_O1/lengjingzju[P]json/jnum.c
// Function: jnum_dtoa
int jnum_dtoa(double num, char *buffer)
{
    diy_fp_t v;
    char *s = buffer;
    union {double d; uint64_t n;} u = {.d = num};
    int32_t signbit = u.n >> (DIY_SIGNIFICAND_SIZE - 1);
    int32_t exponent = (u.n & DP_EXPONENT_MASK) >> DP_SIGNIFICAND_SIZE; /* Exponent */
    uint64_t significand = u.n & DP_SIGNIFICAND_MASK; /* Mantissa */
    int32_t num_digits, vnum_digits;

    if (signbit) {
        *s++ = '-';
    }

    switch (exponent) {
    case DP_EXPONENT_MAX:
        if (significand) {
            memcpy(buffer, "nan", 4);
            return 3;
        } else {
            memcpy(s, "inf", 4);
            return signbit + 3;
        }

    case 0:
        if (significand) {
            /* no-normalized double */
            v.f = significand; /* Non-normalized double doesn't have a extra integer bit for Mantissa */
            v.e = 1 - DP_EXPONENT_OFFSET - DP_SIGNIFICAND_SIZE; /* Fixed Exponent: -1022, divisor of Mantissa: pow(2,52) */
            num_digits = ldouble_convert_n(&v, s + 1, &vnum_digits);
        } else {
            memcpy(s, "0.0", 4);
            return signbit + 3;
        }
        break;

    default:
        /* normalized double */
        v.f = significand + DP_HIDDEN_BIT; /* Normalized double has a extra integer bit for Mantissa */
        v.e = exponent - DP_EXPONENT_OFFSET - DP_SIGNIFICAND_SIZE; /* Exponent offset: -1023, divisor of Mantissa: pow(2,52) */

        if (v.e >= -DP_SIGNIFICAND_SIZE && v.e <= 0 \
            && (v.f & (((uint64_t)1 << -v.e) - 1)) == 0) {
            /* small integer. */
            int32_t tz, n;
            n = fill_1_16_digits(s, v.f >> -v.e, &tz);
            memcpy(s + n, ".0", 3);
            return n + 2 + signbit;
        }
        if (v.e > 0 && v.e <= (63 - DP_SIGNIFICAND_SIZE)) {
            /* big integer. */
            int32_t tz, n;
            n = fill_1_20_digits(s, v.f << v.e, &tz);
            memcpy(s + n, ".0", 3);
            return n + 2 + signbit;
        }
        /* (-1022 - 52) <= e <= (1023 - 52) */
        num_digits = ldouble_convert(&v, s + 1, &vnum_digits);
        break;
    }

    s = ldouble_format(s, num_digits, vnum_digits, num_digits + v.e);
    *s = '\0';
    return (int)(s - buffer);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movabsq $0xfffffffffffff, %rdx  # imm = 0xFFFFFFFFFFFFF
movq %xmm0, %rcx
movq %rcx, %r12
shrq $0x3f, %r12
movq %rcx, %rax
shrq $0x34, %rax
andl $0x7ff, %eax            # imm = 0x7FF
movq %rdi, %r14
testq %rcx, %rcx
jns 0x87af
leaq 0x1(%rbx), %r14
movb $0x2d, (%rbx)
andq %rdx, %rcx
testl %eax, %eax
je 0x87d7
cmpl $0x7ff, %eax            # imm = 0x7FF
jne 0x8807
testq %rcx, %rcx
je 0x890c
movl $0x6e616e, (%rbx)       # imm = 0x6E616E
movl $0x3, %r12d
jmp 0x8d92
testq %rcx, %rcx
je 0x8915
shlq $0x6, %rcx
orq $0x20, %rcx
cmpq $0x4000000, %rcx        # imm = 0x4000000
ja 0x8925
movl $0xc5a05278, %eax       # imm = 0xC5A05278
imulq %rax, %rcx
shrq $0x20, %rcx
jmp 0x8938
leaq (%rdx,%rcx), %rsi
incq %rsi
leal -0x3ff(%rax), %ecx
cmpl $0x34, %ecx
ja 0x8835
movb $0x33, %cl
subb %al, %cl
movq $-0x1, %rdx
shlq %cl, %rdx
movb $0x33, %cl
notq %rdx
testq %rdx, %rsi
je 0x8a35
leal -0x433(%rax), %r15d
addl $0xfffffbcc, %eax       # imm = 0xFFFFFBCC
cmpl $0xa, %eax
ja 0x885e
movl %r15d, %ecx
shlq %cl, %rsi
leaq 0x10(%rsp), %rdx
movq %r14, %rdi
callq 0x7ffe
jmp 0x8a47
movl %r15d, %eax
andl $0x3, %eax
leaq 0x2399(%rip), %rcx      # 0xac04
movzbl (%rax,%rcx), %edi
movl %edi, %ecx
shlq %cl, %rsi
movl $0xc5a05278, %r8d       # imm = 0xC5A05278
leal -0x1(%rdi), %ecx
movl $0x1, %eax
shlq %cl, %rax
addq %rsi, %rax
subl %edi, %r15d
sarl $0x2, %r15d
leal 0x110(%r15), %ecx
leaq 0x2373(%rip), %rdx      # 0xac10
movq (%rdx,%rcx,8), %r9
leaq 0x3388(%rip), %rdx      # 0xbc30
movsbl (%rcx,%rdx), %r10d
mulq %r9
movq %rdx, %rsi
negb %dil
movl %edi, %ecx
shrq %cl, %r9
subl %r10d, %r15d
movabsq $0x16345785d89ffff, %rax # imm = 0x16345785D89FFFF
cmpq %rax, %rdx
ja 0x89d4
movabsq $-0x3333333333333333, %rcx # imm = 0xCCCCCCCCCCCCCCCD
movq %rsi, %rax
mulq %rcx
movq %rdx, %rcx
shrq $0x3, %rcx
leal 0x3a5fad7e(%r8), %eax
imull %ecx, %eax
addl %eax, %esi
incl %r15d
cmpl $0x13, %r9d
ja 0x8a62
addl $0xa, %esi
cmpl %r9d, %esi
jmp 0x8a25
movl $0x666e69, (%r14)       # imm = 0x666E69
jmp 0x891c
movl $0x302e30, (%r14)       # imm = 0x302E30
addl $0x3, %r12d
jmp 0x8d92
movabsq $-0x3a5fad889de41d6c, %rdx # imm = 0xC5A05277621BE294
movq %rcx, %rax
mulq %rdx
movq %rdx, %rcx
movabsq $0x51eb851eb851eb9, %rdx # imm = 0x51EB851EB851EB9
movq %rcx, %rax
mulq %rdx
shrq %rdx
imulq $-0x64, %rdx, %rsi
addq %rcx, %rsi
cmpq $0x64, %rcx
setae %dil
cmpq $0x32, %rsi
setb %r8b
xorl %eax, %eax
testb %r8b, %dil
je 0x8974
movl $0xfffffebd, %r15d      # imm = 0xFFFFFEBD
xorl %r13d, %r13d
jmp 0x898a
leaq 0x2155(%rip), %rdi      # 0xaad0
movsbq (%rdi,%rsi,2), %r13
addq $-0x30, %r13
movl $0xfffffebc, %r15d      # imm = 0xFFFFFEBC
leaq 0x1(%r14), %r12
movl $0x0, 0xc(%rsp)
cmpq $0x64, %rcx
jb 0x89af
leaq 0xc(%rsp), %rax
movq %r12, %rdi
movq %rdx, %rsi
movq %rax, %rdx
callq 0x8e4a
testq %r13, %r13
je 0x89c9
addb $0x30, %r13b
movslq %eax, %rcx
incl %eax
movb %r13b, (%r12,%rcx)
movl $0x0, 0xc(%rsp)
movl %eax, %ebp
subl 0xc(%rsp), %ebp
jmp 0x8cbc
movabsq $0xde0b6b3a763ffff, %rax # imm = 0xDE0B6B3A763FFFF
cmpq %rax, %rsi
ja 0x8a87
movq %rsi, %rax
shrq $0x2, %rax
movabsq $0x28f5c28f5c28f5c3, %rcx # imm = 0x28F5C28F5C28F5C3
mulq %rcx
movq %rdx, %rcx
shrq $0x2, %rcx
leal 0x3a5fad24(%r8), %eax
imull %ecx, %eax
addl %eax, %esi
addl $0x2, %r15d
cmpl $0xc7, %r9d
ja 0x8ac6
addl $0x64, %esi
cmpl %r9d, %esi
setbe %al
andb %cl, %al
movzbl %al, %eax
subq %rax, %rcx
jmp 0x8af4
subb %al, %cl
shrq %cl, %rsi
leaq 0x14(%rsp), %rdx
movq %r14, %rdi
callq 0x8e4a
cltq
movw $0x302e, (%r14,%rax)    # imm = 0x302E
movb $0x0, 0x2(%r14,%rax)
addl %eax, %r12d
addl $0x2, %r12d
jmp 0x8d92
movabsq $0x199999999999999a, %rdx # imm = 0x199999999999999A
movq %rcx, %rax
mulq %rdx
addq %rdx, %rdx
leaq (%rdx,%rdx,4), %rax
movq %rcx, %rdx
subq %rax, %rdx
leal (%rdx,%rdx,4), %eax
leal (%rsi,%rax,2), %eax
jmp 0x8ae8
movq %rsi, %rax
shrq $0x3, %rax
movabsq $0x20c49ba5e353f7cf, %rcx # imm = 0x20C49BA5E353F7CF
mulq %rcx
movq %rdx, %rcx
shrq $0x4, %rcx
addl $0x3, %r15d
btl $0x4, %edx
jae 0x8af4
leal 0x3a5fa9a0(%r8), %eax
imull %ecx, %eax
addl %esi, %eax
addl $0x3e8, %eax            # imm = 0x3E8
cmpl %eax, %r9d
adcq $-0x1, %rcx
jmp 0x8af4
movabsq $0x199999999999999a, %rdx # imm = 0x199999999999999A
movq %rcx, %rax
mulq %rdx
addq %rdx, %rdx
leaq (%rdx,%rdx,4), %rax
movq %rcx, %rdx
subq %rax, %rdx
imull $0x64, %edx, %eax
addl %esi, %eax
xorl %esi, %esi
cmpl %r9d, %eax
cmovbeq %rdx, %rsi
subq %rsi, %rcx
movabsq $-0x543388ee7b9e3103, %rdx # imm = 0xABCC77118461CEFD
movq %rcx, %rax
mulq %rdx
shrq $0x1a, %rdx
movl %edx, %eax
addq $0x3469cc88, %r8        # imm = 0x3469CC88
imulq %rdx, %r8
addq %rcx, %r8
imulq $0x68db8bb, %rax, %rax  # imm = 0x68DB8BB
shrq $0x28, %rax
imull $0xffffd8f0, %eax, %esi # imm = 0xFFFFD8F0
addl %edx, %esi
imull $0x147b, %eax, %edx     # imm = 0x147B
shrl $0x13, %edx
imull $-0x64, %edx, %edi
addl %eax, %edi
leaq 0x1f90(%rip), %rcx      # 0xaad0
movzwl (%rcx,%rdx,2), %eax
movw %ax, 0x1(%r14)
leal (%rdi,%rdi), %eax
movzwl (%rax,%rcx), %eax
movw %ax, 0x3(%r14)
leaq 0x2044(%rip), %rax      # 0xaba0
testl %edi, %edi
je 0x8b68
movl %edi, %edx
movzbl (%rdx,%rax), %edx
jmp 0x8b6f
movzbl (%rdx,%rax), %edx
addl $0x2, %edx
testl %esi, %esi
je 0x8ba2
imull $0x147b, %esi, %edx     # imm = 0x147B
shrl $0x13, %edx
imull $-0x64, %edx, %edi
addl %esi, %edi
movzwl (%rcx,%rdx,2), %esi
movw %si, 0x5(%r14)
leal (%rdi,%rdi), %esi
movzwl (%rsi,%rcx), %esi
movw %si, 0x7(%r14)
testl %edi, %edi
je 0x8baf
movl %edi, %edx
movzbl (%rdx,%rax), %edx
jmp 0x8bb6
movl $0x30303030, 0x5(%r14)  # imm = 0x30303030
addl $0x4, %edx
jmp 0x8bb6
movzbl (%rdx,%rax), %edx
addl $0x2, %edx
testl %r8d, %r8d
je 0x8c00
cmpl $0x270f, %r8d           # imm = 0x270F
ja 0x8c16
movl $0x30303030, 0x9(%r14)  # imm = 0x30303030
imull $0x147b, %r8d, %edx     # imm = 0x147B
shrl $0x13, %edx
imull $-0x64, %edx, %esi
addl %r8d, %esi
movzwl (%rcx,%rdx,2), %edi
movw %di, 0xd(%r14)
leal (%rsi,%rsi), %edi
movzwl (%rdi,%rcx), %ecx
movw %cx, 0xf(%r14)
testl %esi, %esi
je 0x8c9c
movl %esi, %ecx
jmp 0x8c96
movabsq $0x3030303030303030, %rax # imm = 0x3030303030303030
movq %rax, 0x9(%r14)
addl $0x8, %edx
jmp 0x8cb0
movl %r8d, %edx
imulq $0x68db8bb, %rdx, %r9   # imm = 0x68DB8BB
shrq $0x28, %r9
imull $0xffffd8f0, %r9d, %esi # imm = 0xFFFFD8F0
addl %r8d, %esi
imull $0x147b, %r9d, %edx     # imm = 0x147B
shrl $0x13, %edx
imull $-0x64, %edx, %edi
addl %r9d, %edi
movzwl (%rcx,%rdx,2), %r8d
movw %r8w, 0x9(%r14)
leal (%rdi,%rdi), %r8d
movzwl (%r8,%rcx), %r8d
movw %r8w, 0xb(%r14)
testl %edi, %edi
je 0x8c62
movl %edi, %edx
movzbl (%rdx,%rax), %edx
jmp 0x8c69
movzbl (%rdx,%rax), %edx
addl $0x2, %edx
testl %esi, %esi
je 0x8ca5
imull $0x147b, %esi, %edx     # imm = 0x147B
shrl $0x13, %edx
imull $-0x64, %edx, %edi
addl %esi, %edi
movzwl (%rcx,%rdx,2), %esi
movw %si, 0xd(%r14)
leal (%rdi,%rdi), %esi
movzwl (%rsi,%rcx), %ecx
movw %cx, 0xf(%r14)
testl %edi, %edi
je 0x8c9c
movl %edi, %ecx
movzbl (%rcx,%rax), %edx
jmp 0x8cb0
movzbl (%rdx,%rax), %edx
addl $0x2, %edx
jmp 0x8cb0
movl $0x30303030, 0xd(%r14)  # imm = 0x30303030
addl $0x4, %edx
movl $0x10, %eax
movl $0x10, %ebp
subl %edx, %ebp
leal (%rax,%r15), %r13d
leal (%rax,%r15), %ecx
decl %ecx
cmpl $0x11, %ecx
jae 0x8d1e
leaq 0x1(%r14), %rsi
cmpl %ebp, %r13d
jge 0x8cf6
movslq %r13d, %r15
movq %r14, %rdi
movq %r15, %rdx
callq 0x11a0
movb $0x2e, (%r14,%r15)
movslq %ebp, %rax
leaq (%r14,%rax), %r12
incq %r12
jmp 0x8d8a
testl %r15d, %r15d
jle 0x8d6c
movslq %eax, %r12
movq %r14, %rdi
movq %r12, %rdx
callq 0x11a0
addq %r14, %r12
movl %r15d, %edx
movq %r12, %rdi
movl $0x30, %esi
callq 0x1100
jmp 0x8d77
leal 0x6(%r13), %eax
cmpl $0x6, %eax
ja 0x8da4
movslq %r13d, %rax
negq %rax
leaq (%r14,%rax), %rdi
addq $0x2, %rdi
leaq 0x1(%r14), %rsi
movslq %ebp, %rdx
callq 0x11a0
movl $0x2, %eax
subl %r13d, %eax
movslq %eax, %r15
movq %r14, %rdi
movl $0x30, %esi
movq %r15, %rdx
callq 0x1100
movb $0x2e, 0x1(%r14)
addl %ebp, %r15d
movslq %r15d, %r12
addq %r14, %r12
jmp 0x8d8a
movslq %r13d, %rdx
movq %r14, %rdi
callq 0x11a0
movslq %r13d, %rax
leaq (%r14,%rax), %r12
addq $0x2, %r12
movw $0x302e, -0x2(%r12)     # imm = 0x302E
movb $0x0, (%r12)
subl %ebx, %r12d
movl %r12d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1(%r14), %rax
movb 0x1(%r14), %cl
movb %cl, (%r14)
cmpl $0x1, %ebp
je 0x8dbd
movb $0x2e, (%rax)
movslq %ebp, %rcx
addq %rcx, %rax
leaq 0x1(%rax), %r12
movb $0x65, (%rax)
testl %r13d, %r13d
jle 0x8dd6
decl %r13d
movb $0x2b, (%r12)
movl %r13d, %ecx
jmp 0x8de3
movb $0x2d, (%r12)
movl $0x1, %ecx
subl %r13d, %ecx
cmpl $0x63, %ecx
jg 0x8dfa
cmpl $0x9, %ecx
jg 0x8e2c
addb $0x30, %cl
movb %cl, 0x2(%rax)
movl $0x2, %eax
jmp 0x8e42
imull $0x147b, %ecx, %edx     # imm = 0x147B
shrl $0x13, %edx
imull $0x7fffff9c, %edx, %esi # imm = 0x7FFFFF9C
addl %ecx, %esi
addb $0x30, %dl
movb %dl, 0x2(%rax)
addl %esi, %esi
movslq %esi, %rcx
leaq 0x1cb3(%rip), %rdx      # 0xaad0
movzwl (%rcx,%rdx), %ecx
movw %cx, 0x3(%rax)
movl $0x4, %eax
jmp 0x8e42
movl %ecx, %ecx
leaq 0x1c9b(%rip), %rdx      # 0xaad0
movzwl (%rdx,%rcx,2), %ecx
movw %cx, 0x2(%rax)
movl $0x3, %eax
addq %rax, %r12
jmp 0x8d8a