// File: /workspace/github_c_makefile_star2_O2/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
subq $0x38, %rsp
movq %rdi, %r9
movq (%rdi), %r10
movl 0x8(%rdi), %esi
imull $0x134413, %esi, %r13d  # imm = 0x134413
sarl $0x16, %r13d
pushq $0x2
popq %rax
subl %r13d, %eax
imull $0x1a934f, %eax, %r12d  # imm = 0x1A934F
sarl $0x13, %r12d
addl %esi, %r12d
movl $0x126, %eax            # imm = 0x126
subl %r13d, %eax
cltq
shlq $0x4, %rax
leaq 0x4ba4(%rip), %rdx      # 0x7c00
movq (%rax,%rdx), %rbx
movl %r12d, %ecx
notb %cl
movq %rbx, %r15
shrq %cl, %r15
leal -0x2(%r13), %ecx
movq %rcx, 0x10(%rsp)
movq 0x8(%rax,%rdx), %r14
leaq 0x1(,%r10,2), %rdi
movq %rdi, %r11
movl %r12d, %ecx
shlq %cl, %r11
movq %r11, %rax
mulq %rbx
movq %rdx, %rcx
movq %rax, %r8
movq %r11, %rax
movq %r14, 0x30(%rsp)
mulq %r14
addq %r8, %rdx
adcq $0x0, %rcx
movl $0x3e8, %r8d            # imm = 0x3E8
movq %rcx, %rax
xorl %edx, %edx
divq %r8
movq %rax, %r14
imull $0xfffffc18, %r14d, %r8d # imm = 0xFFFFFC18
addl %ecx, %r8d
cmpl %r15d, %r8d
jae 0x3119
testb $0x1, %r10b
sete %al
testl %r8d, %r8d
setne %cl
orb %al, %cl
pushq $0x1
popq %rbp
jne 0x31e1
movq 0x10(%rsp), %rdx
movq %r9, 0x20(%rsp)
movq %r10, 0x18(%rsp)
movl %esi, 0xc(%rsp)
callq 0x324c
movl 0xc(%rsp), %esi
movq 0x18(%rsp), %r10
movq 0x20(%rsp), %r9
testb %al, %al
je 0x31e1
decq %r14
movl $0x3e8, %r8d            # imm = 0x3E8
jmp 0x3188
jne 0x3188
leaq -0x1(,%r10,2), %rdi
pushq $0x1
popq %rbp
testb $0x1, %r10b
jne 0x3165
movq %rdi, 0x28(%rsp)
movq 0x28(%rsp), %rdi
movq 0x10(%rsp), %rdx
movq %r9, 0x20(%rsp)
movq %r10, 0x18(%rsp)
movl %esi, 0xc(%rsp)
callq 0x324c
movq 0x28(%rsp), %rdi
movl 0xc(%rsp), %esi
movq 0x18(%rsp), %r10
movq 0x20(%rsp), %r9
testb %al, %al
jne 0x31e1
movq %rbx, %rcx
movq 0x30(%rsp), %rax
mulq %rdi
imulq %rdi, %rcx
addq %rcx, %rdx
movb $0x40, %al
subb %r12b, %al
movzbl %al, %eax
btq %rax, %rdx
movl %r15d, %r8d
jb 0x31e1
imulq $0xa, %r14, %r14
shrl %r15d
subl %r15d, %r8d
leal 0x32(%r8), %edi
xorl %ebp, %ebp
pushq $0x64
popq %rcx
movl %edi, %eax
xorl %edx, %edx
divl %ecx
movl %eax, %ecx
addq %rcx, %r14
imull $0x64, %eax, %eax
cmpl %eax, %edi
jne 0x31e1
addq %r10, %r10
imulq %r10, %rbx
movq 0x30(%rsp), %rax
mulq %r10
addq %rbx, %rdx
movb $0x40, %al
subb %r12b, %al
movzbl %al, %eax
btq %rax, %rdx
setb %al
andb $0x1, %r8b
cmpb %r8b, %al
je 0x31dc
decq %r14
jmp 0x31e1
testb $0x1, %cl
jne 0x31fa
movq %r14, (%r9)
addl %r13d, %ebp
movl %ebp, 0x8(%r9)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $-0x5, %esi
jg 0x3224
movq 0x10(%rsp), %rdx
subl %esi, %edx
leal 0x1(%rdx), %ecx
pushq $-0x1
popq %rax
shlq %cl, %rax
notq %rax
testq %rax, %r10
sete %al
cmpl $0x3f, %edx
setl %cl
testb %al, %cl
jne 0x31d7
jmp 0x31e1
cmpl $0xa, %esi
jl 0x31d7
cmpl $0x56, %esi
ja 0x31e1
movslq 0x10(%rsp), %rax
shlq $0x4, %rax
leaq 0x7072(%rip), %rcx      # 0xa2b0
imulq (%rax,%rcx), %r10
cmpq 0x8(%rax,%rcx), %r10
jbe 0x31d7
jmp 0x31e1