// File: /workspace/github_c_makefile_star2_O1/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 0x48(%rsp), %r12
movq 0x40(%rsp), %rbx
movq %rdx, %r10
subq %rdi, %r10
negl %ecx
movl $0x1, %r9d
shlq %cl, %r9
leaq -0x1(%r9), %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
movl $0xcccccccd, %r13d      # imm = 0xCCCCCCCD
movq %r9, -0x10(%rsp)
subl $0x1, %ebp
jb 0x89ad
movl %esi, %eax
xorl %edx, %edx
divl %r15d
cmpl %esi, %r15d
jbe 0x8900
cmpl $0x0, (%rbx)
je 0x8915
addb $0x30, %al
movslq (%rbx), %rsi
leal 0x1(%rsi), %r8d
movl %r8d, (%rbx)
movq 0x38(%rsp), %r8
movb %al, (%r8,%rsi)
movl %edx, %eax
shlq %cl, %rax
addq %r11, %rax
movq %r14, %r8
movl %r15d, %esi
subq %rax, %r8
jae 0x8935
imulq %r13, %rsi
shrq $0x23, %rsi
movl %esi, %r15d
jmp 0x899d
addl %ebp, (%r12)
shlq %cl, %rsi
cmpq %r10, %rax
jae 0x899d
cmpq %rsi, %r8
jb 0x899d
movslq (%rbx), %r13
movq %r10, %rbx
subq %rax, %rbx
leaq (%rax,%rsi), %r12
movq %r14, %r8
subq %r12, %r8
cmpq %r10, %r12
jb 0x8967
leaq (%rdi,%r12), %r9
cmpq %r9, %rbx
jbe 0x8988
movq 0x38(%rsp), %r9
decb -0x1(%r9,%r13)
subq %rsi, %r8
setb %r9b
cmpq %r10, %r12
jae 0x8988
subq %rsi, %rbx
addq %rsi, %r12
testb %r9b, %r9b
je 0x8959
movq -0x10(%rsp), %r9
movq 0x40(%rsp), %rbx
movq 0x48(%rsp), %r12
movl $0xcccccccd, %r13d      # imm = 0xCCCCCCCD
movl %edx, %esi
cmpq %rax, %r14
jb 0x88e6
jmp 0x8a6e
movl $0x1, %eax
xorl %esi, %esi
movq -0x8(%rsp), %r15
movq %rax, %rdx
addq %r11, %r11
leaq (%r11,%r11,4), %r11
movq %r11, %rax
shrq %cl, %rax
testl %eax, %eax
jne 0x89d2
cmpl $0x0, (%rbx)
je 0x89e7
addb $0x30, %al
movslq (%rbx), %rdi
leal 0x1(%rdi), %r8d
movl %r8d, (%rbx)
movq 0x38(%rsp), %r8
movb %al, (%r8,%rdi)
movq %r14, %rdi
addq %r14, %rdi
leaq (%rdi,%rdi,4), %r14
leaq (%rdx,%rdx), %rax
leaq (%rax,%rax,4), %rax
andq %r15, %r11
decl %esi
movq %r14, %r8
subq %r11, %r8
jbe 0x89b9
addl %esi, (%r12)
imulq %r10, %rax
movq %rax, %rcx
subq %r11, %rcx
setbe %sil
cmpq %r9, %r8
setb %r8b
orb %sil, %r8b
jne 0x8a6e
movslq (%rbx), %rsi
leaq (%rdi,%rdi,4), %rdi
addq %r9, %r11
subq %r11, %rdi
imulq %rdx, %r10
addq %r10, %r10
leaq (%r10,%r10,4), %rdx
negq %rdx
cmpq %rax, %r11
jb 0x8a4d
leaq (%rdx,%r11), %r8
cmpq %r8, %rcx
jbe 0x8a6e
movq 0x38(%rsp), %r8
decb -0x1(%r8,%rsi)
subq %r9, %rdi
setb %r8b
cmpq %rax, %r11
jae 0x8a6e
subq %r9, %rcx
addq %r9, %r11
testb %r8b, %r8b
je 0x8a3f
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq