user: Converte this assembly snippet into its equivalent C code:

```asm
<qd_to_digits>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  add    $0xffffffffffffff80,%rsp
  mov    %rdi,-0x68(%rbp)
  mov    %rsi,-0x70(%rbp)
  mov    %rdx,-0x78(%rbp)
  mov    %ecx,-0x7c(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x7c(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,-0x58(%rbp)
  lea    -0x50(%rbp),%rdx
  mov    -0x68(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <qd_abs@plt>
  mov    -0x68(%rbp),%rax
  movsd  (%rax),%xmm0
  pxor   %xmm1,%xmm1
  ucomisd %xmm1,%xmm0
  jp     L317
  pxor   %xmm1,%xmm1
  ucomisd %xmm1,%xmm0
  jne    L317
  movq   $0x0,-0x78(%rbp)
  movl   $0x0,-0x60(%rbp)
  jmp    L220
L165:
  mov    -0x60(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  movb   $0x30,(%rax)
  addl   $0x1,-0x60(%rbp)
L220:
  mov    -0x60(%rbp),%eax
  cmp    -0x7c(%rbp),%eax
  jl     L165
  jmp    L312
L317:
  mov    -0x68(%rbp),%rax
  mov    (%rax),%rax
  movq   %rax,%xmm0
  call   <fabs@plt>
  mov    %eax,%edi
  call   <log10@plt>
  mov    %eax,%edi
  call   <floor@plt>
  mov    %eax,-0x5c(%rbp)
  cmpl   $0xfffffed4,-0x5c(%rbp)
  jge    L60
  lea    -0x30(%rbp),%rdx
  mov    D13(%rip),%rax
  mov    %rdx,%rdi
  movq   %rax,%xmm0
  call   <qd_real@plt>
  lea    -0x30(%rbp),%rdx
  lea    -0x30(%rbp),%rax
  mov    $0x12c,%esi
  mov    %rax,%rdi
  call   <qd_npwr@plt>
  lea    -0x50(%rbp),%rdx
  lea    -0x30(%rbp),%rcx
  lea    -0x50(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <qd_mul@plt>
  lea    -0x30(%rbp),%rdx
  mov    D13(%rip),%rax
  mov    %rdx,%rdi
  movq   %rax,%xmm0
  call   <qd_real@plt>
  mov    -0x5c(%rbp),%eax
  lea    0x12c(%rax),%ecx
  lea    -0x30(%rbp),%rdx
  lea    -0x30(%rbp),%rax
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <qd_npwr@plt>
  lea    -0x50(%rbp),%rdx
  lea    -0x30(%rbp),%rcx
  lea    -0x50(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <qd_div@plt>
  jmp    L318
L60:
  cmpl   $0x12c,-0x5c(%rbp)
  jle    L149
  lea    -0x50(%rbp),%rax
  mov    $0xffffffcb,%esi
  mov    %rax,%rdi
  call   <qd_ldexp@plt>
  lea    -0x30(%rbp),%rdx
  mov    D13(%rip),%rax
  mov    %rdx,%rdi
  movq   %rax,%xmm0
  call   <qd_real@plt>
  lea    -0x30(%rbp),%rdx
  mov    -0x5c(%rbp),%ecx
  lea    -0x30(%rbp),%rax
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <qd_npwr@plt>
  lea    -0x50(%rbp),%rdx
  lea    -0x30(%rbp),%rcx
  lea    -0x50(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <qd_div@plt>
  lea    -0x50(%rbp),%rax
  mov    $0x35,%esi
  mov    %rax,%rdi
  call   <qd_ldexp@plt>
  jmp    L318
L149:
  lea    -0x30(%rbp),%rdx
  mov    D13(%rip),%rax
  mov    %rdx,%rdi
  movq   %rax,%xmm0
  call   <qd_real@plt>
  lea    -0x30(%rbp),%rdx
  mov    -0x5c(%rbp),%ecx
  lea    -0x30(%rbp),%rax
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <qd_npwr@plt>
  lea    -0x50(%rbp),%rdx
  lea    -0x30(%rbp),%rcx
  lea    -0x50(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <qd_div@plt>
L318:
  mov    D13(%rip),%rdx
  lea    -0x50(%rbp),%rax
  movq   %rdx,%xmm0
  mov    %rax,%rdi
  call   <qd_gt_qd_d@plt>
  cmp    $0x1,%eax
  jne    L274
  lea    -0x50(%rbp),%rcx
  mov    D13(%rip),%rdx
  lea    -0x50(%rbp),%rax
  mov    %rcx,%rsi
  movq   %rdx,%xmm0
  mov    %rax,%rdi
  call   <qd_div_qd_d@plt>
  addl   $0x1,-0x5c(%rbp)
  jmp    L4
L274:
  mov    D51(%rip),%rdx
  lea    -0x50(%rbp),%rax
  movq   %rdx,%xmm0
  mov    %rax,%rdi
  call   <qd_lt_qd_d@plt>
  cmp    $0x1,%eax
  jne    L4
  lea    -0x50(%rbp),%rcx
  mov    D13(%rip),%rdx
  lea    -0x50(%rbp),%rax
  mov    %rcx,%rsi
  movq   %rdx,%xmm0
  mov    %rax,%rdi
  call   <qd_mul_d@plt>
  subl   $0x1,-0x5c(%rbp)
L4:
  mov    D13(%rip),%rdx
  lea    -0x50(%rbp),%rax
  movq   %rdx,%xmm0
  mov    %rax,%rdi
  call   <qd_geq_qd_d@plt>
  cmp    $0x1,%eax
  je     L296
  mov    D51(%rip),%rdx
  lea    -0x50(%rbp),%rax
  movq   %rdx,%xmm0
  mov    %rax,%rdi
  call   <qd_lt_qd_d@plt>
  cmp    $0x1,%eax
  jne    L229
L296:
  lea    D47(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  jmp    L312
L229:
  movl   $0x0,-0x60(%rbp)
  jmp    L217
L203:
  movsd  -0x50(%rbp),%xmm0
  cvttsd2si %xmm0,%eax
  mov    %eax,-0x54(%rbp)
  pxor   %xmm2,%xmm2
  cvtsi2sdl -0x54(%rbp),%xmm2
  movq   %xmm2,%rdx
  lea    -0x50(%rbp),%rcx
  lea    -0x50(%rbp),%rax
  mov    %rcx,%rsi
  movq   %rdx,%xmm0
  mov    %rax,%rdi
  call   <qd_sub_qd_d@plt>
  lea    -0x50(%rbp),%rcx
  mov    D13(%rip),%rdx
  lea    -0x50(%rbp),%rax
  mov    %rcx,%rsi
  movq   %rdx,%xmm0
  mov    %rax,%rdi
  call   <qd_mul_d@plt>
  mov    -0x54(%rbp),%eax
  lea    0x30(%rax),%ecx
  mov    -0x60(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  mov    %ecx,%edx
  mov    %dl,(%rax)
  addl   $0x1,-0x60(%rbp)
L217:
  mov    -0x60(%rbp),%eax
  cmp    -0x58(%rbp),%eax
  jl     L203
  mov    -0x58(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0x60(%rbp)
  jmp    L56
L254:
  mov    -0x60(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x2f,%al
  jg     L307
  mov    -0x60(%rbp),%eax
  cltq
  lea    -0x1(%rax),%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%edx
  sub    $0x1,%edx
  mov    %dl,(%rax)
  mov    -0x60(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  lea    0xa(%rax),%ecx
  mov    -0x60(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  mov    %ecx,%edx
  mov    %dl,(%rax)
  jmp    L300
L307:
  mov    -0x60(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x39,%al
  jle    L300
  mov    -0x60(%rbp),%eax
  cltq
  lea    -0x1(%rax),%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%edx
  add    $0x1,%edx
  mov    %dl,(%rax)
  mov    -0x60(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  lea    -0xa(%rax),%ecx
  mov    -0x60(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  mov    %ecx,%edx
  mov    %dl,(%rax)
L300:
  subl   $0x1,-0x60(%rbp)
L56:
  cmpl   $0x0,-0x60(%rbp)
  jg     L254
  mov    -0x70(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x30,%al
  jg     L219
  lea    D21(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  jmp    L312
L219:
  mov    -0x58(%rbp),%eax
  cltq
  lea    -0x1(%rax),%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x34,%al
  jle    L281
  mov    -0x58(%rbp),%eax
  cltq
  lea    -0x2(%rax),%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%edx
  add    $0x1,%edx
  mov    %dl,(%rax)
  mov    -0x58(%rbp),%eax
  sub    $0x2,%eax
  mov    %eax,-0x60(%rbp)
  jmp    L276
L224:
  mov    -0x60(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  lea    -0xa(%rax),%ecx
  mov    -0x60(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  mov    %ecx,%edx
  mov    %dl,(%rax)
  subl   $0x1,-0x60(%rbp)
  mov    -0x60(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%edx
  add    $0x1,%edx
  mov    %dl,(%rax)
L276:
  cmpl   $0x0,-0x60(%rbp)
  jle    L281
  mov    -0x60(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x39,%al
  jg     L224
L281:
  mov    -0x70(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x39,%al
  jle    L78
  addl   $0x1,-0x5c(%rbp)
  mov    -0x7c(%rbp),%eax
  mov    %eax,-0x60(%rbp)
  jmp    L151
L297:
  mov    -0x60(%rbp),%eax
  cltq
  lea    -0x1(%rax),%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  mov    -0x60(%rbp),%edx
  movslq %edx,%rcx
  mov    -0x70(%rbp),%rdx
  add    %rcx,%rdx
  movzbl (%rax),%eax
  mov    %al,(%rdx)
  subl   $0x1,-0x60(%rbp)
L151:
  cmpl   $0x1,-0x60(%rbp)
  jg     L297
  mov    -0x70(%rbp),%rax
  movb   $0x31,(%rax)
  mov    -0x70(%rbp),%rax
  add    $0x1,%rax
  movb   $0x30,(%rax)
L78:
  mov    -0x7c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    -0x78(%rbp),%rax
  mov    -0x5c(%rbp),%edx
  mov    %edx,(%rax)
L312:
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L57
  call   <__stack_chk_fail@plt>
L57:
  leave
  ret
```

tool_calls: name: parse_data
arguments: data_label: D13
type: f64
name: parse_data
arguments: data_label: D51
type: f64
name: parse_data
arguments: data_label: D47
type: string
name: parse_data
arguments: data_label: D21
type: string

tool: D13: 10

tool: D51: 1

tool: D47: qd_to_digits: cannot compute exponent

tool: D21: qd_to_digits: nonpositive leading digit

assistant: ```c
void qd_to_digits(const double *a, char *s, int *expn, int precision) {
  int D = precision + 1;
  double acc[4];
  double tmp[4];
  int i, d, e;
  qd_abs(a, acc);
  if (a[0] == 0.0) {
    expn = 0;
    for (i = 0; i < precision; i++)
      s[i] = '0';
    return;
  }
  e = (int)(floor(log10(fabs(a[0]))));
  if (e < -300) {
    qd_real(10.0, tmp);
    qd_npwr(tmp, 300, tmp);
    qd_mul(acc, tmp, acc);
    qd_real(10.0, tmp);
    qd_npwr(tmp, e + 300, tmp);
    qd_div(acc, tmp, acc);
  } else if (e > 300) {
    qd_ldexp(acc, -53);
    qd_real(10.0, tmp);
    qd_npwr(tmp, e, tmp);
    qd_div(acc, tmp, acc);
    qd_ldexp(acc, 53);
  } else {
    qd_real(10.0, tmp);
    qd_npwr(tmp, e, tmp);
    qd_div(acc, tmp, acc);
  }
  if (qd_gt_qd_d(acc, 10.0) == 1) {
    qd_div_qd_d(acc, 10.0, acc);
    e++;
  } else if (qd_lt_qd_d(acc, 1.0) == 1) {
    qd_mul_d(acc, 10.0, acc);
    e--;
  }
  if ((qd_geq_qd_d(acc, 10.0) == 1) || (qd_lt_qd_d(acc, 1.0) == 1)) {
    printf("qd_to_digits: cannot compute exponent");
    return;
  }
  for (i = 0; i < D; i++) {
    d = ((int)acc[0]);
    qd_sub_qd_d(acc, (double)d, acc);
    qd_mul_d(acc, 10.0, acc);
    s[i] = ((char)(d + '0'));
  }
  for (i = D - 1; i > 0; i--) {
    if (s[i] < '0') {
      s[i - 1]--;
      s[i] += 10;
    } else if (s[i] > '9') {
      s[i - 1]++;
      s[i] -= 10;
    }
  }
  if (s[0] <= '0') {
    printf("qd_to_digits: nonpositive leading digit");
    return;
  }
  if (s[D - 1] >= '5') {
    s[D - 2]++;
    i = D - 2;
    while (i > 0 && s[i] > '9') {
      s[i] -= 10;
      s[--i]++;
    }
  }
  if (s[0] > '9') {
    e++;
    for (i = precision; i >= 2; i--)
      s[i] = s[i - 1];
    s[0] = '1';
    s[1] = '0';
  }
  s[precision] = 0;
  *expn = e;
}
```