// File: /workspace/github_c_makefile_star2_O3/lengjingzju[P]json/dragonbox.c
// Function: dragonbox_convert
static inline void dragonbox_convert(diy_fp_t *v)
{
#define KAPPA_VALUE     2
#define SMALL_DIVISOR   100
#define BIG_DIVISOR     1000

    uint64_t f = v->f;
    int32_t e = v->e;
    int32_t kappa_plus = 0;
    const bool is_even = !(f & (uint64_t)1);

    const int32_t minus_k = floor_log10_pow2(e) - KAPPA_VALUE;
    const int32_t minus_1 = e + floor_log2_pow10(-minus_k); /* The range of e is [6, 9] */
    const u64x2_t pow10 = compute_pow10_double(-minus_k);
    const uint32_t delta = compute_delta(pow10, minus_1); /* The range of delta is [100, 999] */
    const uint64_t two_fc = (f << 1);
    const uint64_t two_fl = two_fc - 1;
    const uint64_t two_fr = two_fc + 1; /* 54 bits */
    const uint64_t zi = mul128_shift(two_fr << minus_1, pow10); // 2 mulx

    uint64_t q = zi / BIG_DIVISOR;
    uint32_t r = (uint32_t)zi - BIG_DIVISOR * (uint32_t)q; /* The range of r is [0, 999] */

    if (r < delta) {
        if (r != 0 || is_even || !is_integral_end_point(two_fr, e, minus_k)) {
            kappa_plus = 1;
            goto end;
        }

        /* q can't be 0 */
        --q;
        r = BIG_DIVISOR;
    } else if (r == delta) {
        if ((is_even && is_integral_end_point(two_fl, e, minus_k)) || compute_parity(two_fl, pow10, minus_1)) {
            kappa_plus = 1;
            goto end;
        }
    }

    {
        q = (q << 1) + (q << 3);

        const uint32_t dist = r - (delta >> 1) + (SMALL_DIVISOR >> 1);
        const uint32_t dist_q = dist / 100;
        q += dist_q;

        if (dist == dist_q * 100)
        {
            if (compute_parity(two_fc, pow10, minus_1) != ((dist & 1) != 0)) {
                --q;
            } else if ((q & (uint64_t)1) && is_integral_mid_point(two_fc, e, minus_k)) {
                --q;
            }
        }
    }

end:
    v->f = q;
    v->e = minus_k + KAPPA_VALUE + kappa_plus;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl 0x8(%rdi), %ebx
imull $0x134413, %ebx, %r11d  # imm = 0x134413
sarl $0x16, %r11d
movl $0x2, %eax
subl %r11d, %eax
imull $0x1a934f, %eax, %r8d   # imm = 0x1A934F
sarl $0x13, %r8d
addl %ebx, %r8d
movl $0x126, %eax            # imm = 0x126
subl %r11d, %eax
cltq
shlq $0x4, %rax
leaq 0x4e41(%rip), %rdx      # 0x8c00
movq (%rax,%rdx), %r12
movl %r8d, %ecx
notb %cl
movq %r12, %r13
shrq %cl, %r13
movq (%rdi), %r14
movq 0x8(%rax,%rdx), %r9
leaq 0x1(,%r14,2), %r15
movq %r15, %rsi
movl %r8d, %ecx
shlq %cl, %rsi
movq %rsi, %rax
mulq %r12
movq %rdx, %rcx
movq %rax, %r10
movq %rsi, %rax
mulq %r9
addq %r10, %rdx
adcq $0x0, %rcx
leal -0x2(%r11), %eax
movq %rax, -0x8(%rsp)
movq %rcx, %rax
shrq $0x3, %rax
movabsq $0x20c49ba5e353f7cf, %rdx # imm = 0x20C49BA5E353F7CF
mulq %rdx
movq %rdx, %rsi
shrq $0x4, %rsi
imull $0xfffffc18, %esi, %ebp # imm = 0xFFFFFC18
addl %ecx, %ebp
cmpl %r13d, %ebp
jae 0x3e67
movl $0x1, %r10d
cmpl $-0x2, %ebx
jl 0x3f5b
testl %ebp, %ebp
jne 0x3f5b
movl %r14d, %eax
andl $0x1, %eax
je 0x3f5b
cmpl $0xa, %ebx
jge 0x3f2f
decq %rsi
movl $0x3e8, %ebp            # imm = 0x3E8
jmp 0x3edc
jne 0x3edc
leaq -0x1(,%r14,2), %rcx
cmpl $-0x2, %ebx
setl %al
orb %r14b, %al
testb $0x1, %al
jne 0x3eb5
movl $0x1, %r10d
cmpl $0xa, %ebx
jl 0x3f5b
cmpl $0x56, %ebx
ja 0x3eb5
movslq -0x8(%rsp), %rax
shlq $0x4, %rax
leaq 0x740e(%rip), %rdx      # 0xb2b0
movq (%rax,%rdx), %r15
imulq %rcx, %r15
cmpq 0x8(%rax,%rdx), %r15
jbe 0x3f5b
movq %r12, %r10
imulq %rcx, %r10
movq %r9, %rax
mulq %rcx
addq %r10, %rdx
movb $0x40, %al
subb %r8b, %al
movzbl %al, %eax
movl $0x1, %r10d
btq %rax, %rdx
movl %r13d, %ebp
jb 0x3f5b
leaq (%rsi,%rsi,4), %rax
shrl %r13d
subl %r13d, %ebp
leal 0x32(%rbp), %edx
imulq $0x51eb851f, %rdx, %rcx # imm = 0x51EB851F
shrq $0x25, %rcx
leaq (%rcx,%rax,2), %rsi
imull $0x64, %ecx, %eax
xorl %r10d, %r10d
cmpl %eax, %edx
jne 0x3f5b
addq %r14, %r14
imulq %r14, %r12
movq %r9, %rax
mulq %r14
addq %r12, %rdx
movb $0x40, %al
subb %r8b, %al
movzbl %al, %eax
btq %rax, %rdx
setb %al
andb $0x1, %bpl
cmpb %bpl, %al
je 0x3f56
decq %rsi
jmp 0x3f5b
cmpl $0x56, %ebx
ja 0x3f5b
movslq -0x8(%rsp), %rax
shlq $0x4, %rax
leaq 0x736c(%rip), %rcx      # 0xb2b0
imulq (%rax,%rcx), %r15
cmpq 0x8(%rax,%rcx), %r15
jbe 0x3e5d
jmp 0x3f5b
testb $0x1, %cl
jne 0x3f70
movq %rsi, (%rdi)
addl %r11d, %r10d
movl %r10d, 0x8(%rdi)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $-0x5, %ebx
jg 0x3f9e
movq -0x8(%rsp), %rdx
subl %ebx, %edx
leal 0x1(%rdx), %ecx
movq $-0x1, %rax
shlq %cl, %rax
notq %rax
testq %rax, %r14
sete %al
cmpl $0x3f, %edx
setl %cl
testb %al, %cl
jne 0x3f2a
jmp 0x3f5b
cmpl $0xa, %ebx
jl 0x3f2a
cmpl $0x56, %ebx
ja 0x3f5b
movslq -0x8(%rsp), %rax
shlq $0x4, %rax
leaq 0x72f8(%rip), %rcx      # 0xb2b0
imulq (%rax,%rcx), %r14
cmpq 0x8(%rax,%rcx), %r14
jbe 0x3f2a
jmp 0x3f5b