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

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0xa0,%rsp
  mov    %edi,-0x94(%rbp)
  mov    %rsi,-0xa0(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  cmpl   $0x2,-0x94(%rbp)
  jg     L159
  lea    D141(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  lea    D136(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  lea    D97(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  mov    $0xa,%edi
  call   <putchar@plt>
  lea    D161(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  mov    $0x1,%edi
  call   <exit@plt>
L159:
  mov    -0xa0(%rbp),%rax
  add    $0x8,%rax
  mov    (%rax),%rax
  lea    D90(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x30(%rbp)
  cmpq   $0x0,-0x30(%rbp)
  jne    L208
  mov    -0xa0(%rbp),%rax
  add    $0x8,%rax
  mov    (%rax),%rax
  mov    %rax,%rsi
  lea    D106(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x2,%edi
  call   <exit@plt>
L208:
  cmpl   $0x3,-0x94(%rbp)
  jle    L190
  mov    -0xa0(%rbp),%rax
  add    $0x18,%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <atoi@plt>
  mov    %rax,-0x58(%rbp)
  jmp    L89
L190:
  movq   $0x0,-0x58(%rbp)
L89:
  lea    -0x14(%rbp),%rdx
  mov    -0x30(%rbp),%rax
  lea    D226(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <fscanf@plt>
  lea    -0x70(%rbp),%rdx
  mov    -0x30(%rbp),%rax
  lea    D210(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <fscanf@plt>
  lea    -0x10(%rbp),%rdx
  mov    -0x30(%rbp),%rax
  lea    D210(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <fscanf@plt>
  lea    -0xc(%rbp),%rdx
  mov    -0x30(%rbp),%rax
  lea    D210(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <fscanf@plt>
  lea    -0x70(%rbp),%rdx
  mov    -0x30(%rbp),%rax
  lea    D210(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <fscanf@plt>
  lea    -0x88(%rbp),%rdx
  mov    -0x30(%rbp),%rax
  lea    D206(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <fscanf@plt>
  lea    -0x86(%rbp),%rdx
  mov    -0x30(%rbp),%rax
  lea    D206(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <fscanf@plt>
  lea    -0x68(%rbp),%rdx
  mov    -0x30(%rbp),%rax
  lea    D210(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <fscanf@plt>
  lea    -0x60(%rbp),%rdx
  mov    -0x30(%rbp),%rax
  lea    D210(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <fscanf@plt>
  lea    -0x84(%rbp),%rdx
  mov    -0x30(%rbp),%rax
  lea    D206(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <fscanf@plt>
  lea    -0x82(%rbp),%rdx
  mov    -0x30(%rbp),%rax
  lea    D206(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <fscanf@plt>
  movl   $0x0,-0x7c(%rbp)
  jmp    L175
L80:
  lea    -0x80(%rbp),%rdx
  mov    -0x30(%rbp),%rax
  lea    D175(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <fscanf@plt>
  addl   $0x1,-0x7c(%rbp)
L175:
  mov    -0x7c(%rbp),%eax
  cltq
  mov    -0x70(%rbp),%rdx
  sub    $0x10,%rdx
  cmp    %rdx,%rax
  jb     L80
  lea    -0xc(%rbp),%rdx
  mov    -0x30(%rbp),%rax
  lea    D210(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <fscanf@plt>
  lea    -0x70(%rbp),%rdx
  mov    -0x30(%rbp),%rax
  lea    D210(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <fscanf@plt>
  cmpq   $0x0,-0x58(%rbp)
  jne    L163
  mov    -0x68(%rbp),%rax
  mov    %rax,-0x58(%rbp)
L163:
  mov    -0x68(%rbp),%rax
  cmp    %rax,-0x58(%rbp)
  jbe    L40
  mov    -0x68(%rbp),%rdx
  mov    -0x58(%rbp),%rax
  mov    %rax,%rsi
  lea    D69(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  lea    D164(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  mov    $0x4,%edi
  call   <exit@plt>
L40:
  mov    -0xa0(%rbp),%rax
  add    $0x10,%rax
  mov    (%rax),%rax
  lea    D147(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x28(%rbp)
  cmpq   $0x0,-0x28(%rbp)
  jne    L88
  mov    -0xa0(%rbp),%rax
  add    $0x10,%rax
  mov    (%rax),%rax
  mov    %rax,%rsi
  lea    D6(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x3,%edi
  call   <exit@plt>
L88:
  movzwl -0x82(%rbp),%eax
  lea    0x7(%rax),%edx
  test   %ax,%ax
  cmovs  %edx,%eax
  sar    $0x3,%ax
  cwtl
  mov    %eax,-0x78(%rbp)
  mov    -0x70(%rbp),%rax
  movzwl -0x86(%rbp),%edx
  movswl %dx,%edx
  imul   -0x78(%rbp),%edx
  movslq %edx,%rsi
  mov    $0x0,%edx
  div    %rsi
  mov    %eax,-0x74(%rbp)
  mov    -0x68(%rbp),%rax
  test   %rax,%rax
  js     L127
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  jmp    L164
L127:
  mov    %rax,%rdx
  shr    %rdx
  and    $0x1,%eax
  or     %rax,%rdx
  pxor   %xmm0,%xmm0
  cvtsi2sd %rdx,%xmm0
  addsd  %xmm0,%xmm0
L164:
  movsd  %xmm0,-0x20(%rbp)
  mov    -0x58(%rbp),%rax
  test   %rax,%rax
  js     L182
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  jmp    L110
L182:
  mov    %rax,%rdx
  shr    %rdx
  and    $0x1,%eax
  or     %rax,%rdx
  pxor   %xmm0,%xmm0
  cvtsi2sd %rdx,%xmm0
  addsd  %xmm0,%xmm0
L110:
  movsd  -0x20(%rbp),%xmm1
  divsd  %xmm0,%xmm1
  movsd  %xmm1,-0x20(%rbp)
  pxor   %xmm0,%xmm0
  movsd  %xmm0,-0x48(%rbp)
  pxor   %xmm0,%xmm0
  movsd  %xmm0,-0x40(%rbp)
  pxor   %xmm0,%xmm0
  movsd  %xmm0,-0x50(%rbp)
  jmp    L169
L30:
  pxor   %xmm0,%xmm0
  movsd  %xmm0,-0x38(%rbp)
  pxor   %xmm0,%xmm0
  comisd -0x48(%rbp),%xmm0
  jbe    L64
  movsd  -0x48(%rbp),%xmm0
  movq   D184(%rip),%xmm1
  xorpd  %xmm1,%xmm0
  mulsd  -0x40(%rbp),%xmm0
  movsd  -0x38(%rbp),%xmm1
  addsd  %xmm1,%xmm0
  movsd  %xmm0,-0x38(%rbp)
L64:
  movsd  -0x48(%rbp),%xmm0
  addsd  -0x20(%rbp),%xmm0
  movsd  %xmm0,-0x48(%rbp)
  jmp    L167
L181:
  movzwl -0x86(%rbp),%eax
  movswl %ax,%edx
  mov    -0x78(%rbp),%ecx
  mov    -0x30(%rbp),%rax
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <nextSample@plt>
  movq   %xmm0,%rax
  mov    %rax,-0x40(%rbp)
  movsd  -0x48(%rbp),%xmm0
  movsd  D195(%rip),%xmm1
  comisd %xmm1,%xmm0
  jb     L125
  movsd  -0x38(%rbp),%xmm0
  addsd  -0x40(%rbp),%xmm0
  movsd  %xmm0,-0x38(%rbp)
  jmp    L2
L125:
  movsd  -0x40(%rbp),%xmm0
  mulsd  -0x48(%rbp),%xmm0
  movsd  -0x38(%rbp),%xmm1
  addsd  %xmm1,%xmm0
  movsd  %xmm0,-0x38(%rbp)
L2:
  movsd  -0x48(%rbp),%xmm0
  movsd  D195(%rip),%xmm1
  subsd  %xmm1,%xmm0
  movsd  %xmm0,-0x48(%rbp)
L167:
  movsd  -0x48(%rbp),%xmm0
  pxor   %xmm1,%xmm1
  comisd %xmm1,%xmm0
  ja     L181
  movsd  -0x38(%rbp),%xmm0
  divsd  -0x20(%rbp),%xmm0
  movsd  %xmm0,-0x38(%rbp)
  mov    -0x38(%rbp),%rax
  movq   %rax,%xmm0
  call   <round@plt>
  mov    %al,-0x89(%rbp)
  mov    -0x28(%rbp),%rdx
  lea    -0x89(%rbp),%rax
  mov    %rdx,%rcx
  mov    $0x1,%edx
  mov    $0x1,%esi
  mov    %rax,%rdi
  call   <fwrite@plt>
  movsd  -0x50(%rbp),%xmm0
  addsd  -0x20(%rbp),%xmm0
  movsd  %xmm0,-0x50(%rbp)
L169:
  pxor   %xmm0,%xmm0
  cvtsi2sdl -0x74(%rbp),%xmm0
  comisd -0x50(%rbp),%xmm0
  ja     L30
  mov    -0x30(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  mov    $0x0,%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L187
  call   <__stack_chk_fail@plt>
L187:
  leave
  ret
```

tool_calls: name: read_data
arguments: data_tag: D141
type_guessed: string
name: read_data
arguments: data_tag: D136
type_guessed: string
name: read_data
arguments: data_tag: D97
type_guessed: string
name: read_data
arguments: data_tag: D161
type_guessed: string
name: read_data
arguments: data_tag: D90
type_guessed: string
name: read_data
arguments: data_tag: D106
type_guessed: string
name: read_data
arguments: data_tag: D226
type_guessed: string
name: read_data
arguments: data_tag: D210
type_guessed: string
name: read_data
arguments: data_tag: D206
type_guessed: string
name: read_data
arguments: data_tag: D175
type_guessed: string
name: read_data
arguments: data_tag: D69
type_guessed: string
name: read_data
arguments: data_tag: D164
type_guessed: string
name: read_data
arguments: data_tag: D147
type_guessed: string
name: read_data
arguments: data_tag: D6
type_guessed: string
name: read_data
arguments: data_tag: D184
type_guessed: f32[2]
name: read_data
arguments: data_tag: D195
type_guessed: f32[2]

tool: D141: Usage: wav2raw sourceWavFile destRawFile <outRate>

tool: D136: Output rate is given in Hand should be <= to the input sample sample.

tool: D97: Success returns errorlevel 0. Error return greater than zero.

tool: D161: Ex: wav2raw input.wav output.raw 11025

tool: D90: rb

tool: D106: The source file %s was not opened


tool: D226: %4s

tool: D210: %4c

tool: D206: %2c

tool: D175: %1c

tool: D69: Output rate (%ld) cannot be above input rate (%ld)


tool: D164: Use lower output rate value or higher input rate file

tool: D147: w

tool: D6: The output file %s was not opened


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

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

assistant: ```c
int main(int argc, char *argv[]) {
  FILE *infile, *outfile;
  char prefix[4];
  char fileFormat[4];
  char ckID[4];
  unsigned long nChunkSize;
  short wFormatTag;
  short nChannels;
  unsigned long nSamplesPerSecond;
  unsigned long nBytesPerSecond;
  unsigned long nOutputSamplesPerSecond;
  short nBlockAlign;
  short nBitsPerSample;
  int i, j;
  if (argc < 3) {
    printf("Usage: wav2raw sourceWavFile destRawFile <outRate>\n");
    printf("Output rate is given in Hand should be <= to the input sample sample.\n");
    printf("Success returns errorlevel 0. Error return greater than zero.\n");
    printf("\n");
    printf("Ex: wav2raw input.wav output.raw 11025\n");
    exit(1);
  }
  if ((infile = fopen(argv[1], "rb")) == NULL) {
    printf("The source file %s was not opened\n", argv[1]);
    exit(2);
  }
  if (argc > 3)
    nOutputSamplesPerSecond = atoi(argv[3]);
  else
    nOutputSamplesPerSecond = 0;
  fscanf(infile, "%4s", prefix);
  fscanf(infile, "%4c", &nChunkSize);
  fscanf(infile, "%4c", fileFormat);
  fscanf(infile, "%4c", ckID);
  fscanf(infile, "%4c", &nChunkSize);
  fscanf(infile, "%2c", &wFormatTag);
  fscanf(infile, "%2c", &nChannels);
  fscanf(infile, "%4c", &nSamplesPerSecond);
  fscanf(infile, "%4c", &nBytesPerSecond);
  fscanf(infile, "%2c", &nBlockAlign);
  fscanf(infile, "%2c", &nBitsPerSample);
  for (i = 0; i < nChunkSize - 0x10; i++)
    fscanf(infile, "%1c", &j);
  fscanf(infile, "%4c", ckID);
  fscanf(infile, "%4c", &nChunkSize);
  if (nOutputSamplesPerSecond == 0)
    nOutputSamplesPerSecond = nSamplesPerSecond;
  if (nSamplesPerSecond < nOutputSamplesPerSecond) {
    printf("Output rate (%ld) cannot be above input rate (%ld)\n", nOutputSamplesPerSecond, nSamplesPerSecond);
    printf("Use lower output rate value or higher input rate file\n");
    exit(4);
  }
  if ((outfile = fopen(argv[2], "w")) == NULL) {
    printf("The output file %s was not opened\n", argv[2]);
    exit(3);
  }
  int nBytesPerSample = nBitsPerSample / 8;
  int size = nChunkSize / (nChannels * nBytesPerSample);
  double offset;
  double step;
  double value;
  double lastSample;
  step = nSamplesPerSecond;
  step /= nOutputSamplesPerSecond;
  value = 0;
  lastSample = 0;
  for (offset = 0; offset < size; offset += step) {
    char byte;
    double sample = 0;
    if (value < 0)
      sample += lastSample * -value;
    value += step;
    while (value > 0) {
      lastSample = nextSample(infile, nBytesPerSample, nChannels);
      if (value >= 1)
        sample += lastSample;
      else
        sample += lastSample * value;
      value--;
    }
    sample /= step;
    byte = round(sample);
    fwrite(&byte, 1, 1, outfile);
  }
  fclose(infile);
  fclose(outfile);
  return 0;
}
```