// File: /workspace/github_c_makefile_star2_O0/lengjingzju[P]json/grisu2.c
// Function: grisu2
static inline void grisu2(double value, char* buffer, int* length, int* K)
{
    diy_fp_t v, w_v, w_m, w_p, c_mk, Wv, Wm, Wp;
    int z_v, z_p;

    /* convert double to diy_fp */
    union {double d; uint64_t n;} u = {.d = value};
    int biased_e = (u.n & DP_EXPONENT_MASK) >> DP_SIGNIFICAND_SIZE; /* Exponent */
    uint64_t significand = u.n & DP_SIGNIFICAND_MASK; /* Mantissa */

    if (biased_e != 0) { /* normalized double */
        v.f = significand + DP_HIDDEN_BIT; /* Normalized double has a extra integer bit for Mantissa */
        v.e = biased_e - DP_EXPONENT_OFFSET - DP_SIGNIFICAND_SIZE; /* Exponent offset: -1023, divisor of Mantissa: pow(2,52) */
    } else { /* 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) */
    }

    /* normalize v and boundaries */
    z_v = get_u64_prefix0(v.f);
    w_v.f = v.f << z_v;
    w_v.e = v.e - z_v;

    w_p.f = (v.f << 1) + 1;
    w_p.e = v.e - 1;
    z_p = get_u64_prefix0(w_p.f);
    w_p.f <<= z_p;
    w_p.e -= z_p;

    if (v.f == DP_HIDDEN_BIT) {
        w_m.f = (v.f << 2) - 1;
        w_m.e = v.e - 2;
    } else {
        w_m.f = (v.f << 1) - 1;
        w_m.e = v.e - 1;
    }
    w_m.f <<= w_m.e - w_p.e;
    w_m.e = w_p.e;

    c_mk = cached_power(w_p.e, K);
    Wv   = diy_fp_multiply(w_v, c_mk);
    Wp   = diy_fp_multiply(w_p, c_mk);
    Wm   = diy_fp_multiply(w_m, c_mk);

    ++Wm.f;
    --Wp.f;
    digit_gen(Wv, Wp, Wp.f - Wm.f, buffer, length, K);
}

// Assembly:
subq $0x118, %rsp            # imm = 0x118
movsd %xmm0, 0x110(%rsp)
movq %rdi, 0x108(%rsp)
movq %rsi, 0x100(%rsp)
movq %rdx, 0xf8(%rsp)
movsd 0x110(%rsp), %xmm0
movsd %xmm0, 0x68(%rsp)
movabsq $0x7ff0000000000000, %rax # imm = 0x7FF0000000000000
andq 0x68(%rsp), %rax
shrq $0x34, %rax
movl %eax, 0x64(%rsp)
movabsq $0xfffffffffffff, %rax  # imm = 0xFFFFFFFFFFFFF
andq 0x68(%rsp), %rax
movq %rax, 0x58(%rsp)
cmpl $0x0, 0x64(%rsp)
je 0x4275
movabsq $0x10000000000000, %rax # imm = 0x10000000000000
addq 0x58(%rsp), %rax
movq %rax, 0xe8(%rsp)
movl 0x64(%rsp), %eax
subl $0x3ff, %eax            # imm = 0x3FF
subl $0x34, %eax
movl %eax, 0xf0(%rsp)
jmp 0x428d
movq 0x58(%rsp), %rax
movq %rax, 0xe8(%rsp)
movl $0xfffffbce, 0xf0(%rsp) # imm = 0xFFFFFBCE
movq 0xe8(%rsp), %rdi
callq 0x4780
movl %eax, 0x74(%rsp)
movq 0xe8(%rsp), %rax
movl 0x74(%rsp), %ecx
shlq %cl, %rax
movq %rax, 0xd8(%rsp)
movl 0xf0(%rsp), %eax
subl 0x74(%rsp), %eax
movl %eax, 0xe0(%rsp)
movq 0xe8(%rsp), %rax
shlq %rax
addq $0x1, %rax
movq %rax, 0xb8(%rsp)
movl 0xf0(%rsp), %eax
subl $0x1, %eax
movl %eax, 0xc0(%rsp)
movq 0xb8(%rsp), %rdi
callq 0x4780
movl %eax, 0x70(%rsp)
movl 0x70(%rsp), %ecx
movq 0xb8(%rsp), %rax
movl %ecx, %ecx
shlq %cl, %rax
movq %rax, 0xb8(%rsp)
movl 0x70(%rsp), %ecx
movl 0xc0(%rsp), %eax
subl %ecx, %eax
movl %eax, 0xc0(%rsp)
movabsq $0x10000000000000, %rax # imm = 0x10000000000000
cmpq %rax, 0xe8(%rsp)
jne 0x436c
movq 0xe8(%rsp), %rax
shlq $0x2, %rax
subq $0x1, %rax
movq %rax, 0xc8(%rsp)
movl 0xf0(%rsp), %eax
subl $0x2, %eax
movl %eax, 0xd0(%rsp)
jmp 0x4394
movq 0xe8(%rsp), %rax
shlq %rax
subq $0x1, %rax
movq %rax, 0xc8(%rsp)
movl 0xf0(%rsp), %eax
subl $0x1, %eax
movl %eax, 0xd0(%rsp)
movl 0xd0(%rsp), %ecx
subl 0xc0(%rsp), %ecx
movq 0xc8(%rsp), %rax
movl %ecx, %ecx
shlq %cl, %rax
movq %rax, 0xc8(%rsp)
movl 0xc0(%rsp), %eax
movl %eax, 0xd0(%rsp)
movl 0xc0(%rsp), %edi
movq 0xf8(%rsp), %rsi
callq 0x47a0
movq %rax, 0x48(%rsp)
movl %edx, 0x50(%rsp)
movq 0x48(%rsp), %rax
movq %rax, 0xa8(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0xb0(%rsp)
movq 0xd8(%rsp), %rdi
movl 0xe0(%rsp), %esi
movq 0xa8(%rsp), %rdx
movl 0xb0(%rsp), %ecx
callq 0x4810
movq %rax, 0x38(%rsp)
movl %edx, 0x40(%rsp)
movq 0x38(%rsp), %rax
movq %rax, 0x98(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0xa0(%rsp)
movq 0xb8(%rsp), %rdi
movl 0xc0(%rsp), %esi
movq 0xa8(%rsp), %rdx
movl 0xb0(%rsp), %ecx
callq 0x4810
movq %rax, 0x28(%rsp)
movl %edx, 0x30(%rsp)
movq 0x28(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0x30(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0xc8(%rsp), %rdi
movl 0xd0(%rsp), %esi
movq 0xa8(%rsp), %rdx
movl 0xb0(%rsp), %ecx
callq 0x4810
movq %rax, 0x18(%rsp)
movl %edx, 0x20(%rsp)
movq 0x18(%rsp), %rax
movq %rax, 0x88(%rsp)
movq 0x20(%rsp), %rax
movq %rax, 0x90(%rsp)
movq 0x88(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x88(%rsp)
movq 0x78(%rsp), %rax
addq $-0x1, %rax
movq %rax, 0x78(%rsp)
movq 0x78(%rsp), %r8
subq 0x88(%rsp), %r8
movq 0x108(%rsp), %r9
movq 0x100(%rsp), %r10
movq 0xf8(%rsp), %rax
movq 0x98(%rsp), %rdi
movl 0xa0(%rsp), %esi
movq 0x78(%rsp), %rdx
movl 0x80(%rsp), %ecx
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x48a0
addq $0x118, %rsp            # imm = 0x118
retq
nopw %cs:(%rax,%rax)
nopl (%rax)