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

```asm
<main>:
  endbr64
  push   %r15
  pxor   %xmm4,%xmm4
  push   %r14
  movq   %xmm4,%r15
  push   %r13
  push   %r12
  push   %rbp
  mov    $0x1f5,%ebp
  push   %rbx
  sub    $0x28,%rsp
  mov    D58(%rip),%rax
  movsd  D85(%rip),%xmm5
  movsd  %xmm4,0x18(%rsp)
  movq   %rax,%xmm2
  movq   %xmm5,%r14
L159:
  mov    D58(%rip),%rax
  mov    $0x1f5,%ebx
  movq   %rax,%xmm1
L122:
  movapd %xmm2,%xmm0
  movsd  %xmm1,0x10(%rsp)
  movsd  %xmm2,0x8(%rsp)
  call   <calcError@plt>
  movq   %r14,%xmm3
  movsd  0x8(%rsp),%xmm2
  movsd  0x10(%rsp),%xmm1
  comisd %xmm0,%xmm3
  jbe    L49
  movsd  %xmm1,0x18(%rsp)
  movq   %xmm2,%r15
  movq   %xmm0,%r14
L49:
  addsd  D35(%rip),%xmm1
  sub    $0x1,%ebx
  jne    L122
  addsd  D35(%rip),%xmm2
  sub    $0x1,%ebp
  jne    L159
  movq   %r15,%xmm0
  lea    D26(%rip),%rdi
  mov    $0x1,%eax
  xor    %ebx,%ebx
  call   <printf@plt>
  movsd  0x18(%rsp),%xmm0
  lea    D96(%rip),%rdi
  mov    $0x1,%eax
  lea    D104(%rip),%rbp
  call   <printf@plt>
  movq   %r14,%xmm0
  mov    $0x1,%eax
  lea    D89(%rip),%rdi
  call   <printf@plt>
  lea    D51(%rip),%rdi
  call   <puts@plt>
  jmp    L135
L87:
  mov    %eax,%esi
  mov    %rbp,%rdi
  xor    %eax,%eax
  call   <printf@plt>
  cmp    $0x3f,%ebx
  je     L69
  mov    $0x2c,%edi
  call   <putchar@plt>
  cmp    $0x7,%r13d
  je     L69
L65:
  add    $0x1,%ebx
  cmp    $0x40,%ebx
  je     L110
L135:
  mov    %ebx,%edi
  mov    %ebx,%r13d
  call   <calcTEDSound@plt>
  movsd  0x18(%rsp),%xmm1
  movq   %r15,%xmm0
  mov    %eax,%edi
  call   <calcDistortion@plt>
  mov    %eax,%r12d
  and    $0x7,%r13d
  jne    L87
  mov    $0x20,%edi
  call   <putchar@plt>
  xor    %eax,%eax
  mov    %r12d,%esi
  mov    %rbp,%rdi
  call   <printf@plt>
  cmp    $0x3f,%ebx
  je     L69
  mov    $0x2c,%edi
  add    $0x1,%ebx
  call   <putchar@plt>
  cmp    $0x40,%ebx
  jne    L135
L110:
  lea    D39(%rip),%r13
  xor    %ebx,%ebx
  mov    %r13,%rdi
  call   <puts@plt>
  lea    D19(%rip),%rdi
  call   <puts@plt>
  jmp    L54
L149:
  mov    %eax,%esi
  mov    %rbp,%rdi
  xor    %eax,%eax
  call   <printf@plt>
  cmp    $0x12c,%ebx
  je     L35
  mov    $0x2c,%edi
  call   <putchar@plt>
  cmp    $0x7,%r12d
  je     L35
L114:
  add    $0x1,%ebx
  cmp    $0x12d,%ebx
  je     L179
L54:
  movsd  0x18(%rsp),%xmm1
  movq   %r15,%xmm0
  mov    %ebx,%edi
  mov    %ebx,%r12d
  call   <calcDistortion@plt>
  mov    %eax,%r14d
  and    $0x7,%r12d
  jne    L149
  mov    $0x20,%edi
  call   <putchar@plt>
  xor    %eax,%eax
  mov    %r14d,%esi
  mov    %rbp,%rdi
  call   <printf@plt>
  cmp    $0x12c,%ebx
  je     L35
  mov    $0x2c,%edi
  add    $0x1,%ebx
  call   <putchar@plt>
  cmp    $0x12d,%ebx
  jne    L54
L179:
  mov    %r13,%rdi
  call   <puts@plt>
  add    $0x28,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L69:
  mov    $0xa,%edi
  call   <putchar@plt>
  jmp    L65
L35:
  mov    $0xa,%edi
  call   <putchar@plt>
  jmp    L114
```

tool_calls: name: parse_data
arguments: tag: D58
datatype: f64
name: parse_data
arguments: tag: D85
datatype: f64
name: parse_data
arguments: tag: D35
datatype: f64
name: parse_data
arguments: tag: D26
datatype: string
name: parse_data
arguments: tag: D96
datatype: string
name: parse_data
arguments: tag: D104
datatype: string
name: parse_data
arguments: tag: D89
datatype: string
name: parse_data
arguments: tag: D51
datatype: string
name: parse_data
arguments: tag: D39
datatype: string
name: parse_data
arguments: tag: D19
datatype: string

tool: D58: 1

tool: D85: 1000000000000

tool: D35: 0.001

tool: D26: gamma0 = %f


tool: D96: gamma1 = %f


tool: D104: %6d

tool: D89: err = %f


tool: D51: static const int16_t soundVolumeTable[64] = {

tool: D39: };

tool: D19: static const int16_t tedSoundDistortionTable[301] = {

assistant: ```c
int main(int argc, char **argv) {
  double bestError = 1000000000000.0;
  double bestGamma0 = 0.0;
  double bestGamma1 = 0.0;
  double gamma0 = 1.0;
  int i;
  do {
    double gamma1 = 1.0;
    do {
      double err = calcError(gamma0, gamma1);
      if (err < bestError) {
        bestGamma0 = gamma0;
        bestGamma1 = gamma1;
        bestError = err;
      }
      gamma1 = gamma1 + 0.001;
    } while (gamma1 < 1.5);
    gamma0 = gamma0 + 0.001;
  } while (gamma0 < 1.5);
  printf("gamma0 = %f\n", bestGamma0);
  printf("gamma1 = %f\n", bestGamma1);
  printf("err = %f\n", bestError);
  printf("static const int16_t soundVolumeTable[64] = {\n");
  for (i = 0; i < 64; i++) {
    int tmp2 = calcDistortion(calcTEDSound(i), bestGamma0, bestGamma1);
    if (!(i & 7))
      printf(" ");
    printf("%6d", tmp2);
    if (i != 63)
      printf(",");
    if ((i & 7) == 7)
      printf("\n");
  }
  printf("};\n");
  printf("static const int16_t tedSoundDistortionTable[301] = {\n");
  for (i = 0; i <= 300; i++) {
    int tmp2 = calcDistortion(i, bestGamma0, bestGamma1);
    if (!(i & 7))
      printf(" ");
    printf("%6d", tmp2);
    if (i != 300)
      printf(",");
    if ((i & 7) == 7 || i == 300)
      printf("\n");
  }
  printf("};\n");
  return 0;
}
```