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    D59(%rip),%rax
  movsd  D86(%rip),%xmm5
  movsd  %xmm4,0x18(%rsp)
  movq   %rax,%xmm2
  movq   %xmm5,%r14
L127:
  mov    D59(%rip),%rax
  mov    $0x1f5,%ebx
  movq   %rax,%xmm1
L75:
  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    L68
  movsd  %xmm1,0x18(%rsp)
  movq   %xmm2,%r15
  movq   %xmm0,%r14
L68:
  addsd  D31(%rip),%xmm1
  sub    $0x1,%ebx
  jne    L75
  addsd  D31(%rip),%xmm2
  sub    $0x1,%ebp
  jne    L127
  movq   %r15,%xmm0
  lea    D47(%rip),%rdi
  mov    $0x1,%eax
  xor    %ebx,%ebx
  call   <printf@plt>
  movsd  0x18(%rsp),%xmm0
  lea    D8(%rip),%rdi
  mov    $0x1,%eax
  lea    D102(%rip),%rbp
  call   <printf@plt>
  movq   %r14,%xmm0
  mov    $0x1,%eax
  lea    D57(%rip),%rdi
  call   <printf@plt>
  lea    D117(%rip),%rdi
  call   <puts@plt>
  jmp    L98
L170:
  mov    %eax,%esi
  mov    %rbp,%rdi
  xor    %eax,%eax
  call   <printf@plt>
  cmp    $0x3f,%ebx
  je     L161
  mov    $0x2c,%edi
  call   <putchar@plt>
  cmp    $0x7,%r13d
  je     L161
L63:
  add    $0x1,%ebx
  cmp    $0x40,%ebx
  je     L58
L98:
  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    L170
  mov    $0x20,%edi
  call   <putchar@plt>
  xor    %eax,%eax
  mov    %r12d,%esi
  mov    %rbp,%rdi
  call   <printf@plt>
  cmp    $0x3f,%ebx
  je     L161
  mov    $0x2c,%edi
  add    $0x1,%ebx
  call   <putchar@plt>
  cmp    $0x40,%ebx
  jne    L98
L58:
  lea    D77(%rip),%r13
  xor    %ebx,%ebx
  mov    %r13,%rdi
  call   <puts@plt>
  lea    D104(%rip),%rdi
  call   <puts@plt>
  jmp    L14
L149:
  mov    %eax,%esi
  mov    %rbp,%rdi
  xor    %eax,%eax
  call   <printf@plt>
  cmp    $0x12c,%ebx
  je     L143
  mov    $0x2c,%edi
  call   <putchar@plt>
  cmp    $0x7,%r12d
  je     L143
L31:
  add    $0x1,%ebx
  cmp    $0x12d,%ebx
  je     L186
L14:
  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     L143
  mov    $0x2c,%edi
  add    $0x1,%ebx
  call   <putchar@plt>
  cmp    $0x12d,%ebx
  jne    L14
L186:
  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
L161:
  mov    $0xa,%edi
  call   <putchar@plt>
  jmp    L63
L143:
  mov    $0xa,%edi
  call   <putchar@plt>
  jmp    L31
```

tool_calls: name: extract_symbolic_data
arguments: tag: D59
datatype: f64
name: extract_symbolic_data
arguments: tag: D86
datatype: f64
name: extract_symbolic_data
arguments: tag: D31
datatype: f64
name: extract_symbolic_data
arguments: tag: D47
datatype: string
name: extract_symbolic_data
arguments: tag: D8
datatype: string
name: extract_symbolic_data
arguments: tag: D102
datatype: string
name: extract_symbolic_data
arguments: tag: D57
datatype: string
name: extract_symbolic_data
arguments: tag: D117
datatype: string
name: extract_symbolic_data
arguments: tag: D77
datatype: string
name: extract_symbolic_data
arguments: tag: D104
datatype: string

tool: D59: 1

tool: D86: 1000000000000

tool: D31: 0.001

tool: D47: gamma0 = %f


tool: D8: gamma1 = %f


tool: D102: %6d

tool: D57: err = %f


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

tool: D77: };

tool: D104: 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;
}
```