// File: /workspace/github_c_makefile_star2_O2/lengjingzju[P]json/dragonbox.c
// Function: dragonbox_dtoa
int dragonbox_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 */

    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;
        }
        break;

    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) */
            dragonbox_convert(&v);
        } 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 (0 <= -v.e && -v.e <= DP_SIGNIFICAND_SIZE && ((v.f & (((uint64_t)1 << -v.e) - 1)) == 0)) {
            /* small integer. */
            v.f >>= -v.e;
            v.e = 0;
        } else if (significand == 0 && exponent > 1) {
            /* Shorter interval case; proceed like Schubfach. */
            dragonbox_convert_asymmetric(&v);
        } else {
            dragonbox_convert(&v);
        }
        break;
    }

    s = dragonbox_format(s, v.f, v.e);
    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, %rcx  # imm = 0xFFFFFFFFFFFFF
movq %xmm0, %rdx
movq %rdx, %rax
shrq $0x3f, %rax
movq %rdx, %rdi
shrq $0x34, %rdi
andl $0x7ff, %edi            # imm = 0x7FF
movq %rbx, %r14
testq %rdx, %rdx
jns 0x2bd9
leaq 0x1(%rbx), %r14
movb $0x2d, (%rbx)
andq %rcx, %rdx
testl %edi, %edi
je 0x2bff
cmpl $0x7ff, %edi            # imm = 0x7FF
jne 0x2c1a
testq %rdx, %rdx
je 0x2d8b
movl $0x6e616e, (%rbx)       # imm = 0x6E616E
pushq $0x3
popq %rax
jmp 0x2f3f
testq %rdx, %rdx
je 0x2d94
movq %rdx, 0x8(%rsp)
movl $0xfffffbce, 0x10(%rsp) # imm = 0xFFFFFBCE
jmp 0x2d16
leaq (%rcx,%rdx), %r15
incq %r15
movq %r15, 0x8(%rsp)
leal -0x433(%rdi), %esi
movl %esi, 0x10(%rsp)
leal -0x3ff(%rdi), %eax
cmpl $0x34, %eax
ja 0x2c54
movl $0x433, %ecx            # imm = 0x433
subl %edi, %ecx
pushq $-0x1
popq %rax
shlq %cl, %rax
notq %rax
testq %rax, %r15
je 0x2e07
testq %rdx, %rdx
sete %al
cmpl $0x2, %edi
setae %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x2d16
imull $0x134413, %esi, %r13d  # imm = 0x134413
addl $0xfff80101, %r13d      # imm = 0xFFF80101
sarl $0x16, %r13d
imull $0xffe56cb1, %r13d, %r8d # imm = 0xFFE56CB1
sarl $0x13, %r8d
addl %esi, %r8d
movl $0x124, %eax            # imm = 0x124
subl %r13d, %eax
shlq $0x4, %rax
leaq 0x4f62(%rip), %rcx      # 0x7c00
movq (%rax,%rcx), %rdi
movq %rdi, %rax
shrq $0x36, %rax
movq %rdi, %rdx
subq %rax, %rdx
movb $0xb, %cl
subb %r8b, %cl
shrq %cl, %rdx
movq %rdi, %rax
shrq $0x35, %rax
addq %rdi, %rax
shrq %cl, %rax
movl %esi, %ecx
andl $-0x2, %ecx
xorl %r9d, %r9d
cmpl $0x2, %ecx
setne %r9b
addq %rdx, %r9
pushq $0xa
popq %rcx
xorl %edx, %edx
divq %rcx
movq %rax, %r15
imulq $0xa, %rax, %rax
cmpq %r9, %rax
jae 0x2dff
movb $0xa, %cl
subb %r8b, %cl
shrq %cl, %rdi
incq %rdi
shrq %rdi
movq %rdi, %rax
andq $-0x2, %rax
cmpq %r9, %rdi
adcq $0x0, %rdi
cmpl $-0x4d, %esi
cmoveq %rax, %rdi
movq %rdi, %r15
jmp 0x2d2c
leaq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x3011
movq (%r12), %r15
movl 0x8(%r12), %r13d
movabsq $0x2386f26fc0ffff, %rax # imm = 0x2386F26FC0FFFF
cmpq %rax, %r15
jbe 0x2e0d
movabsq $0x2386f26fc10000, %rcx # imm = 0x2386F26FC10000
movq %r15, %rax
xorl %edx, %edx
divq %rcx
movabsq $-0x2386f26fc10000, %r12 # imm = 0xFFDC790D903F0000
imulq %rax, %r12
addl $0x30, %eax
leaq 0x1(%r14), %rdi
movb %al, (%r14)
addq %r15, %r12
je 0x2da3
cmpq $0x5f5e0ff, %r12        # imm = 0x5F5E0FF
ja 0x2db9
movabsq $0x3030303030303030, %rax # imm = 0x3030303030303030
movq %rax, 0x1(%r14)
leaq 0x9(%r14), %rdi
jmp 0x2de9
movl $0x666e69, (%r14)       # imm = 0x666E69
jmp 0x2d9b
movl $0x302e30, (%r14)       # imm = 0x302E30
addl $0x3, %eax
jmp 0x2f3f
movdqa 0x1255(%rip), %xmm0     # 0x4000
movdqu %xmm0, (%rdi)
movl $0x10, 0x4(%rsp)
jmp 0x2df6
movl $0x5f5e100, %ecx        # imm = 0x5F5E100
movq %r12, %rax
xorl %edx, %edx
divq %rcx
movl $0xfa0a1f00, %r15d      # imm = 0xFA0A1F00
imull %eax, %r15d
leaq 0x4(%rsp), %rdx
movl %eax, %esi
callq 0x3301
leaq 0x9(%r14), %rdi
addl %r15d, %r12d
je 0x2f4e
leaq 0x4(%rsp), %rdx
movl %r12d, %esi
callq 0x3301
pushq $0x11
popq %r12
jmp 0x2e86
incl %r13d
jmp 0x2d2c
shrq %cl, %r15
xorl %r13d, %r13d
cmpq $0x5f5e0ff, %r15        # imm = 0x5F5E0FF
ja 0x2e2b
leaq 0x4(%rsp), %rdx
movq %r14, %rdi
movl %r15d, %esi
callq 0x327c
movl %eax, %r12d
jmp 0x2e86
movl $0x5f5e100, %ecx        # imm = 0x5F5E100
movq %r15, %rax
xorl %edx, %edx
divq %rcx
movl $0xfa0a1f00, %ebp       # imm = 0xFA0A1F00
imull %eax, %ebp
leaq 0x4(%rsp), %rdx
movq %r14, %rdi
movl %eax, %esi
callq 0x327c
movslq %eax, %r12
addq %r14, %r12
addl %ebp, %r15d
je 0x2e6c
leaq 0x4(%rsp), %rdx
movq %r12, %rdi
movl %r15d, %esi
callq 0x3301
jmp 0x2e7f
addl $0x8, 0x4(%rsp)
movabsq $0x3030303030303030, %rax # imm = 0x3030303030303030
movq %rax, (%r12)
subl %r14d, %r12d
addl $0x8, %r12d
movslq 0x4(%rsp), %rax
movslq %r12d, %rdi
movq %rdi, %r15
subq %rax, %r15
leal (%rdi,%r13), %ebp
leal (%rdi,%r13), %eax
decl %eax
cmpl $0x11, %eax
jae 0x2ef6
movl %r15d, %eax
subl %ebp, %eax
jle 0x2ed2
movl %ebp, %esi
leaq (%r14,%rsi), %r12
incq %r12
addq %r14, %rsi
movslq %eax, %rdx
movq %r12, %rdi
callq 0x10a0
movb $0x2e, -0x1(%r12)
movl %r15d, %eax
addq %r14, %rax
incq %rax
jmp 0x2f3a
testl %r13d, %r13d
jle 0x2ee5
addq %r14, %rdi
movl %r13d, %edx
pushq $0x30
popq %rsi
callq 0x1080
movl %ebp, %eax
addq %r14, %rax
addq $0x2, %rax
movw $0x302e, -0x2(%rax)     # imm = 0x302E
jmp 0x2f3a
leal 0x6(%rbp), %eax
cmpl $0x6, %eax
ja 0x2f65
movslq %ebp, %rax
negq %rax
leaq (%r14,%rax), %rdi
addq $0x2, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x10a0
pushq $0x2
popq %r12
subl %ebp, %r12d
pushq $0x30
popq %rsi
movq %r14, %rdi
movq %r12, %rdx
callq 0x1080
movb $0x2e, 0x1(%r14)
addl %r15d, %r12d
movslq %r12d, %rax
addq %r14, %rax
movb $0x0, (%rax)
subl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movabsq $0x3030303030303030, %rax # imm = 0x3030303030303030
movq %rax, (%rdi)
addl $0x8, 0x4(%rsp)
jmp 0x2df6
cmpl $0x1, %r15d
je 0x2f8a
leaq 0x2(%r14), %rdi
leaq 0x1(%r14), %rsi
leal -0x1(%r15), %eax
movslq %eax, %rdx
callq 0x10a0
movb $0x2e, 0x1(%r14)
movslq %r15d, %rax
addq %rax, %r14
leaq 0x2(%r14), %rax
movb $0x65, 0x1(%r14)
leal -0x1(%rbp), %edx
testl %ebp, %ebp
setle %sil
addb %sil, %sil
addb $0x2b, %sil
movl %edx, %ecx
negl %ecx
cmovsl %edx, %ecx
movb %sil, 0x2(%r14)
cmpl $0x63, %ecx
ja 0x2fc3
cmpl $0x9, %ecx
ja 0x2ff4
orb $0x30, %cl
movb %cl, 0x3(%r14)
pushq $0x2
jmp 0x3008
imull $0x147b, %ecx, %edx     # imm = 0x147B
shrl $0x13, %edx
imull $0x7fffff9c, %edx, %esi # imm = 0x7FFFFF9C
addl %ecx, %esi
addb $0x30, %dl
movb %dl, 0x3(%r14)
addl %esi, %esi
movslq %esi, %rcx
leaq 0x7459(%rip), %rdx      # 0xa440
movzwl (%rcx,%rdx), %ecx
movw %cx, 0x4(%r14)
pushq $0x4
jmp 0x3008
movl %ecx, %ecx
leaq 0x7443(%rip), %rdx      # 0xa440
movzwl (%rdx,%rcx,2), %ecx
movw %cx, 0x3(%r14)
pushq $0x3
popq %rcx
addq %rcx, %rax
jmp 0x2f3a