// File: /workspace/github_c_makefile_star2_O3/JesseBuesking[P]omnomnum/grisu2/grisu2.c
// Function: digit_gen
void digit_gen(diy_fp_t W, diy_fp_t Mp, diy_fp_t delta,
	       char* buffer, int* len, int* K) {
  uint32_t div; int d,kappa; diy_fp_t one, wp_w;
  wp_w = minus(Mp, W);
  one.f = ((uint64_t) 1) << -Mp.e; one.e = Mp.e;
  uint32_t p1 = Mp.f >> -one.e; /// Mp_cut
  uint64_t p2 = Mp.f & (one.f - 1);
  *len = 0; kappa = 10; div = TEN9;
  while (kappa > 0) {
    d = p1 / div;
    if (d || *len) buffer[(*len)++] = '0' + d; /// Mp_inv1
    p1 %= div; kappa--;
    uint64_t tmp = (((uint64_t)p1)<<-one.e)+p2;
    if (tmp <= delta.f) { /// Mp_delta
      *K += kappa;
      grisu_round(buffer, *len, delta.f, tmp, ((uint64_t)div) << -one.e, wp_w.f);
      return;
    }
    div /= 10;
  }
  uint64_t unit = 1;
  while (1) {
    p2 *= 10; delta.f *= 10; unit *= 10;
    d = p2 >> -one.e;
    if (d || *len) buffer[(*len)++] = '0' + d;
    p2 &= one.f - 1; kappa--;
    if (p2 < delta.f) {
      *K += kappa;
      grisu_round(buffer, *len, delta.f, p2, one.f, wp_w.f*unit);
      return;
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %r8, %r14
movq %rdx, %rsi
movq 0x40(%rsp), %rbx
movq %rdx, %r10
subq %rdi, %r10
negl %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, -0x18(%rsp)
leaq -0x1(%rax), %r11
movq %r11, -0x8(%rsp)
andq %rdx, %r11
subq %rdx, %rdi
shrq %cl, %rsi
movl $0x0, (%rbx)
movl $0x3b9aca00, %r15d      # imm = 0x3B9ACA00
movl $0xa, %ebp
movq %rcx, -0x10(%rsp)
subl $0x1, %ebp
jb 0x8995
cmpl %esi, %r15d
seta %al
movl (%rbx), %r8d
testl %r8d, %r8d
sete %dl
testb %dl, %al
jne 0x88ed
movslq %r8d, %r9
movl %esi, %eax
xorl %edx, %edx
divl %r15d
addb $0x30, %al
leal 0x1(%r8), %edx
movl %edx, (%rbx)
movq 0x38(%rsp), %rdx
movb %al, (%rdx,%r9)
movl %esi, %eax
xorl %edx, %edx
divl %r15d
movl %edx, %esi
movq %rsi, %rax
shlq %cl, %rax
addq %r11, %rax
movq %r14, %r8
movl %r15d, %edx
subq %rax, %r8
jae 0x891d
movl $0xcccccccd, %r8d       # imm = 0xCCCCCCCD
imulq %r8, %rdx
shrq $0x23, %rdx
movl %edx, %r15d
jmp 0x8987
movq 0x48(%rsp), %r9
addl %ebp, (%r9)
shlq %cl, %rdx
cmpq %r10, %rax
jae 0x8a64
cmpq %rdx, %r8
jb 0x8a64
movq %rbx, %rcx
movslq (%rbx), %r13
movq %r10, %rbx
subq %rax, %rbx
leaq (%rax,%rdx), %r12
movq %r14, %r8
subq %r12, %r8
cmpq %r10, %r12
jb 0x895e
leaq (%rdi,%r12), %r9
cmpq %r9, %rbx
jbe 0x897f
movq 0x38(%rsp), %r9
decb -0x1(%r9,%r13)
subq %rdx, %r8
setb %r9b
cmpq %r10, %r12
jae 0x897f
subq %rdx, %rbx
addq %rdx, %r12
testb %r9b, %r9b
je 0x8950
movq %rcx, %rbx
movq -0x10(%rsp), %rcx
cmpq %rax, %r14
jb 0x88b6
jmp 0x8a64
movl $0x1, %eax
xorl %esi, %esi
movq -0x8(%rsp), %r9
addq %r11, %r11
leaq (%r11,%r11,4), %r11
movq %r11, %rdi
shrq %cl, %rdi
movq %rax, %rdx
movl (%rbx), %eax
movl %edi, %r8d
orl %eax, %r8d
je 0x89cf
movslq %eax, %r8
addb $0x30, %dil
incl %eax
movl %eax, (%rbx)
movq 0x38(%rsp), %rax
movb %dil, (%rax,%r8)
movq %r14, %rdi
addq %r14, %rdi
leaq (%rdi,%rdi,4), %r14
leaq (%rdx,%rdx), %rax
leaq (%rax,%rax,4), %rax
andq %r9, %r11
decl %esi
movq %r14, %r8
subq %r11, %r8
jbe 0x89a1
movq 0x48(%rsp), %rcx
addl %esi, (%rcx)
imulq %r10, %rax
movq %rax, %rcx
subq %r11, %rcx
setbe %sil
cmpq -0x18(%rsp), %r8
setb %r8b
orb %sil, %r8b
jne 0x8a64
movslq (%rbx), %rsi
leaq (%rdi,%rdi,4), %rdi
addq -0x18(%rsp), %r11
subq %r11, %rdi
imulq %rdx, %r10
addq %r10, %r10
leaq (%r10,%r10,4), %rdx
negq %rdx
movq -0x18(%rsp), %r9
cmpq %rax, %r11
jb 0x8a41
leaq (%rdx,%r11), %r8
cmpq %r8, %rcx
jbe 0x8a64
movq 0x38(%rsp), %r8
decb -0x1(%r8,%rsi)
subq -0x18(%rsp), %rdi
setb %r8b
cmpq %rax, %r11
jae 0x8a64
subq %r9, %rcx
addq %r9, %r11
testb %r8b, %r8b
je 0x8a33
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq