// File: /workspace/github_c_makefile_star2_O1/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 0x4d81(%rip), %rdx      # 0x8c00
movq (%rax,%rdx), %r15
movl %r8d, %ecx
notb %cl
movq %r15, %r12
shrq %cl, %r12
movq (%rdi), %r14
movq 0x8(%rax,%rdx), %r13
leaq 0x1(,%r14,2), %r9
movq %r9, %rsi
movl %r8d, %ecx
shlq %cl, %rsi
movq %rsi, %rax
mulq %r15
movq %rdx, %rcx
movq %rax, %r10
movq %rsi, %rax
movq %r13, -0x8(%rsp)
mulq %r13
addq %r10, %rdx
adcq $0x0, %rcx
leal -0x2(%r11), %r10d
movq %rcx, %rax
shrq $0x3, %rax
movabsq $0x20c49ba5e353f7cf, %rdx # imm = 0x20C49BA5E353F7CF
mulq %rdx
movq %rdx, %rsi
shrq $0x4, %rsi
imull $0xfffffc18, %esi, %r13d # imm = 0xFFFFFC18
addl %ecx, %r13d
cmpl %r12d, %r13d
jae 0x3f2a
movl $0x1, %ebp
cmpl $-0x2, %ebx
jl 0x4083
testl %r13d, %r13d
jne 0x4083
movl %r14d, %eax
andl $0x1, %eax
je 0x4083
cmpl $0xa, %ebx
jge 0x3ffa
decq %rsi
movl $0x3e8, %r13d           # imm = 0x3E8
jmp 0x3f9e
jne 0x3f9e
leaq -0x1(,%r14,2), %rcx
cmpl $-0x2, %ebx
setl %al
orb %r14b, %al
testb $0x1, %al
jne 0x3f75
movl $0x1, %ebp
cmpl $0xa, %ebx
jl 0x4083
cmpl $0x56, %ebx
jg 0x3f75
movslq %r10d, %rax
shlq $0x4, %rax
leaq 0x734e(%rip), %rdx      # 0xb2b0
movq (%rax,%rdx), %r9
imulq %rcx, %r9
cmpq 0x8(%rax,%rdx), %r9
jbe 0x4083
movq %r15, %r9
movq -0x8(%rsp), %rax
mulq %rcx
imulq %rcx, %r9
addq %r9, %rdx
movb $0x40, %al
subb %r8b, %al
movzbl %al, %eax
movl $0x1, %ebp
btq %rax, %rdx
jb 0x4083
leaq (%rsi,%rsi,4), %rax
shrl %r12d
subl %r12d, %r13d
leal 0x32(%r13), %edx
imulq $0x51eb851f, %rdx, %rcx # imm = 0x51EB851F
shrq $0x25, %rcx
leaq (%rcx,%rax,2), %rsi
imull $0x64, %ecx, %eax
xorl %ebp, %ebp
cmpl %eax, %edx
jne 0x4083
addq %r14, %r14
imulq %r14, %r15
movq -0x8(%rsp), %rax
mulq %r14
addq %r15, %rdx
movb $0x40, %al
subb %r8b, %al
movzbl %al, %eax
btq %rax, %rdx
setb %al
andb $0x1, %r13b
cmpb %r13b, %al
je 0x4023
decq %rsi
jmp 0x4083
cmpl $0x56, %ebx
jg 0x4083
movslq %r10d, %rax
shlq $0x4, %rax
leaq 0x729f(%rip), %rcx      # 0xb2b0
imulq (%rax,%rcx), %r9
cmpq 0x8(%rax,%rcx), %r9
jbe 0x3f1f
jmp 0x4083
testb $0x1, %cl
je 0x4083
cmpl $-0x5, %ebx
jg 0x4052
subl %ebx, %r10d
leal 0x1(%r10), %ecx
movq $-0x1, %rax
shlq %cl, %rax
notq %rax
testq %rax, %r14
sete %cl
cmpl $0x3f, %r10d
setl %al
andb %cl, %al
jmp 0x407d
movb $0x1, %al
cmpl $0xa, %ebx
jl 0x407d
cmpl $0x56, %ebx
jg 0x407b
movslq %r10d, %rax
shlq $0x4, %rax
leaq 0x7244(%rip), %rcx      # 0xb2b0
imulq (%rax,%rcx), %r14
cmpq 0x8(%rax,%rcx), %r14
setbe %al
jmp 0x407d
xorl %eax, %eax
movzbl %al, %eax
subq %rax, %rsi
movq %rsi, (%rdi)
addl %r11d, %ebp
movl %ebp, 0x8(%rdi)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq