user: Please show me the C implementation that matches the assembly code listed below:

```asm
<gcvt>:
  endbr64
  mov    %rsi,%r8
  cmp    $0xffffffff,%edi
  je     L61
  mov    $0x14,%eax
  cmp    %rax,%rdi
  cmovbe %rdi,%rax
  mov    %rax,%r10
  pxor   %xmm1,%xmm1
  mov    %rsi,%rdi
  mov    $0x0,%r9d
  comisd %xmm0,%xmm1
  jbe    L344
L103:
  xorpd  D60(%rip),%xmm0
  lea    0x1(%r8),%rdi
  mov    $0x1,%r9d
L344:
  mov    %r10d,%eax
  test   %r10d,%r10d
  jle    L42
L171:
  movsd  D80(%rip),%xmm1
  movsd  D150(%rip),%xmm2
L77:
  mulsd  %xmm2,%xmm1
  sub    $0x1,%eax
  test   %eax,%eax
  jg     L77
  movsd  D85(%rip),%xmm2
  divsd  %xmm1,%xmm2
  addsd  %xmm0,%xmm2
  comisd D90(%rip),%xmm2
  jae    L292
  cvttsd2si %xmm2,%rcx
L74:
  test   %rcx,%rcx
  js     L41
  pxor   %xmm2,%xmm2
  cvtsi2sd %rcx,%xmm2
L16:
  movapd %xmm0,%xmm3
  subsd  %xmm2,%xmm3
  ucomisd D5(%rip),%xmm0
  jp     L256
  je     L97
L256:
  push   %rbp
  push   %rbx
  mov    $0x1,%esi
  movsd  D150(%rip),%xmm2
  comisd %xmm2,%xmm0
  jb     L23
L302:
  divsd  %xmm2,%xmm0
  add    $0x1,%esi
  comisd %xmm2,%xmm0
  jae    L302
L23:
  mov    %rcx,%rdx
  mov    $0x1,%r11d
  movabs $0xcccccccccccccccd,%rbx
L230:
  cmp    $0x9,%rdx
  jbe    L28
  add    $0x1,%r11d
  mov    %rdx,%rax
  mul    %rbx
  shr    $0x3,%rdx
  jmp    L230
L30:
  mov    $0x5,%r10d
  jmp    L103
L42:
  ucomisd D5(%rip),%xmm0
  jp     L196
  jne    L196
  lea    0x1(%rdi),%rax
  movb   $0x30,(%rdi)
  test   %r10,%r10
  je     L228
  jmp    L119
L196:
  movapd %xmm0,%xmm1
  addsd  D85(%rip),%xmm1
  comisd D90(%rip),%xmm1
  jae    L265
  cvttsd2si %xmm1,%rcx
L20:
  test   %rcx,%rcx
  js     L206
  pxor   %xmm1,%xmm1
  cvtsi2sd %rcx,%xmm1
L350:
  movapd %xmm0,%xmm3
  subsd  %xmm1,%xmm3
  movsd  D80(%rip),%xmm1
  jmp    L256
L265:
  subsd  D90(%rip),%xmm1
  cvttsd2si %xmm1,%rcx
  btc    $0x3f,%rcx
  jmp    L20
L206:
  mov    %rcx,%rax
  shr    %rax
  mov    %rcx,%rdx
  and    $0x1,%edx
  or     %rdx,%rax
  pxor   %xmm1,%xmm1
  cvtsi2sd %rax,%xmm1
  addsd  %xmm1,%xmm1
  jmp    L350
L135:
  movslq %esi,%rsi
  lea    0x2(%r10,%rsi,1),%rbx
  add    %rdi,%rbx
L232:
  movb   $0x0,(%rbx)
  test   %r10,%r10
  je     L46
  lea    -0x1(%rbx),%r11
  mulsd  %xmm1,%xmm3
  addsd  D85(%rip),%xmm3
  comisd D90(%rip),%xmm3
  jae    L314
  cvttsd2si %xmm3,%rsi
L254:
  mov    %r10,%rax
  not    %rax
  add    %rax,%rbx
  mov    %r11,%rdi
  movabs $0xcccccccccccccccd,%rbp
L186:
  sub    $0x1,%rdi
  mov    %rsi,%rax
  mul    %rbp
  shr    $0x3,%rdx
  lea    (%rdx,%rdx,4),%rax
  add    %rax,%rax
  sub    %rax,%rsi
  add    $0x30,%esi
  mov    %sil,0x1(%rdi)
  mov    %rdx,%rsi
  cmp    %rdi,%rbx
  jne    L186
  mov    %r10,%rdi
  not    %rdi
  add    %r11,%rdi
  sub    %r10,%r11
  movb   $0x2e,(%r11)
L2:
  movabs $0xcccccccccccccccd,%r10
L62:
  sub    $0x1,%rdi
  mov    %rcx,%rax
  mul    %r10
  shr    $0x3,%rdx
  lea    (%rdx,%rdx,4),%rsi
  add    %rsi,%rsi
  mov    %rcx,%rax
  sub    %rsi,%rax
  add    $0x30,%eax
  mov    %al,0x1(%rdi)
  mov    %rcx,%rax
  mov    %rdx,%rcx
  cmp    $0x9,%rax
  ja     L62
  test   %r9d,%r9d
  je     L96
  movb   $0x2d,(%rdi)
L96:
  mov    %r8,%rax
  pop    %rbx
  pop    %rbp
  ret
L314:
  subsd  D90(%rip),%xmm3
  cvttsd2si %xmm3,%rsi
  btc    $0x3f,%rsi
  jmp    L254
L46:
  lea    -0x2(%rbx),%rdi
  movb   $0x0,-0x1(%rbx)
  jmp    L2
L28:
  cmp    %esi,%r11d
  jg     L135
  movslq %esi,%rsi
  lea    0x1(%r10,%rsi,1),%rbx
  add    %rdi,%rbx
  jmp    L232
L97:
  movb   $0x30,(%rdi)
L119:
  lea    0x2(%rdi),%rdx
  movb   $0x2e,0x1(%rdi)
  mov    $0x0,%eax
L307:
  movb   $0x30,0x2(%rdi,%rax,1)
  add    $0x1,%rax
  cmp    %r10,%rax
  jb     L307
  test   %r10,%r10
  mov    $0x1,%eax
  cmovne %r10,%rax
  add    %rdx,%rax
L228:
  movb   $0x0,(%rax)
  mov    %r8,%rax
  ret
L292:
  subsd  D90(%rip),%xmm2
  cvttsd2si %xmm2,%rcx
  btc    $0x3f,%rcx
  jmp    L74
L41:
  mov    %rcx,%rax
  shr    %rax
  mov    %rcx,%rdx
  and    $0x1,%edx
  or     %rdx,%rax
  pxor   %xmm2,%xmm2
  cvtsi2sd %rax,%xmm2
  addsd  %xmm2,%xmm2
  jmp    L16
L61:
  pxor   %xmm1,%xmm1
  comisd %xmm0,%xmm1
  ja     L30
  mov    %rsi,%rdi
  mov    $0x0,%r9d
  mov    $0x5,%r10d
  mov    $0x5,%eax
  jmp    L171
```

tool_calls: name: disassemble_data
arguments: tag: D60
data_type: f32[4]
name: disassemble_data
arguments: tag: D80
data_type: f32[2]
name: disassemble_data
arguments: tag: D150
data_type: f64
name: disassemble_data
arguments: tag: D85
data_type: f64
name: disassemble_data
arguments: tag: D90
data_type: f32[4]
name: disassemble_data
arguments: tag: D5
data_type: f32[2]

tool: {"D60": [0.0,-0.0,0.0,0.0]}

tool: {"D80": [0.0,1.875]}

tool: D150: 10

tool: D85: 0.5

tool: {"D90": [0.0,448.0,0.0,-0.0]}

tool: {"D5": [0.0,0.0]}

assistant: ```c
char *gcvt(double f, size_t ndigit, char *buf) {
  int i;
  int l1, l2;
  unsigned long long z, k, k2;
  int exp = 0;
  char *c = buf;
  double f2, t, scal;
  int sign = 0;
  if ((int)ndigit == -1)
    ndigit = 5;
  if (ndigit > 20)
    ndigit = 20;
  if (f < 0.0) {
    sign = 1;
    f = -f;
    buf++;
  }
  scal = 1;
  for (i = ndigit; i > 0; i--)
    scal *= 10;
  k = f + 0.5 / scal;
  f2 = f - k;
  if (!f) {
    (*(buf++) = ('0'));
    if (ndigit > 0)
      (*(buf++) = ('.'));
    for (i = 0; i < ndigit; i++)
      (*(buf++) = ('0'));
    (*(buf++) = (0));
    return c;
  }
  i = 1;
  while (f >= 10.0) {
    f /= 10.0;
    i++;
  }
  l1 = i;
  k2 = k;
  l2 = 1;
  do {
    if (k2 >= 10) {
      l2++;
    }
    k2 /= 10;
  } while (k2);
  if (l2 > l1) {
    buf += i + ndigit + 2;
  } else {
    buf += i + ndigit + 1;
  }
  (*(buf--) = (0));
  if (ndigit > 0) {
    t = f2 * scal;
    z = t + 0.5;
    for (i = 0; i < ndigit; i++) {
      (*(buf--) = ('0' + (z % 10)));
      z /= 10;
    }
    (*(buf--) = ('.'));
  } else
    (*(buf--) = (0));
  l2 = 1;
  do {
    (*(buf--) = ('0' + (k % 10)));
    if (k >= 10) {
      l2++;
    }
    k /= 10;
  } while (k);
  if (sign)
    (*(buf--) = ('-'));
  return c;
}
```