user: 请将以下的汇编代码转换成C语言代码:

```asm
<write_wav>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %rdx,-0x38(%rbp)
  mov    %ecx,-0x3c(%rbp)
  movl   $0x1,-0x1c(%rbp)
  movl   $0x2,-0x18(%rbp)
  cmpl   $0x0,-0x3c(%rbp)
  jg     L35
  movl   $0xac44,-0x20(%rbp)
  jmp    L16
L35:
  mov    -0x3c(%rbp),%eax
  mov    %eax,-0x20(%rbp)
L16:
  mov    -0x20(%rbp),%eax
  imul   -0x1c(%rbp),%eax
  mov    -0x18(%rbp),%edx
  imul   %edx,%eax
  mov    %eax,-0x14(%rbp)
  mov    -0x28(%rbp),%rax
  lea    D37(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <assert@plt>
  mov    -0x8(%rbp),%rax
  mov    %rax,%rcx
  mov    $0x4,%edx
  mov    $0x1,%esi
  lea    D34(%rip),%rax
  mov    %rax,%rdi
  call   <fwrite@plt>
  mov    -0x30(%rbp),%rax
  imul   -0x18(%rbp),%eax
  imul   -0x1c(%rbp),%eax
  lea    0x24(%rax),%ecx
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdx
  mov    $0x4,%esi
  mov    %ecx,%edi
  call   <write_little_endian@plt>
  mov    -0x8(%rbp),%rax
  mov    %rax,%rcx
  mov    $0x4,%edx
  mov    $0x1,%esi
  lea    D35(%rip),%rax
  mov    %rax,%rdi
  call   <fwrite@plt>
  mov    -0x8(%rbp),%rax
  mov    %rax,%rcx
  mov    $0x4,%edx
  mov    $0x1,%esi
  lea    D47(%rip),%rax
  mov    %rax,%rdi
  call   <fwrite@plt>
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdx
  mov    $0x4,%esi
  mov    $0x10,%edi
  call   <write_little_endian@plt>
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdx
  mov    $0x2,%esi
  mov    $0x1,%edi
  call   <write_little_endian@plt>
  mov    -0x8(%rbp),%rdx
  mov    -0x1c(%rbp),%eax
  mov    $0x2,%esi
  mov    %eax,%edi
  call   <write_little_endian@plt>
  mov    -0x8(%rbp),%rdx
  mov    -0x20(%rbp),%eax
  mov    $0x4,%esi
  mov    %eax,%edi
  call   <write_little_endian@plt>
  mov    -0x8(%rbp),%rdx
  mov    -0x14(%rbp),%eax
  mov    $0x4,%esi
  mov    %eax,%edi
  call   <write_little_endian@plt>
  mov    -0x1c(%rbp),%eax
  imul   -0x18(%rbp),%eax
  mov    -0x8(%rbp),%rdx
  mov    $0x2,%esi
  mov    %eax,%edi
  call   <write_little_endian@plt>
  mov    -0x18(%rbp),%eax
  lea    0x0(,%rax,8),%ecx
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdx
  mov    $0x2,%esi
  mov    %ecx,%edi
  call   <write_little_endian@plt>
  mov    -0x8(%rbp),%rax
  mov    %rax,%rcx
  mov    $0x4,%edx
  mov    $0x1,%esi
  lea    D25(%rip),%rax
  mov    %rax,%rdi
  call   <fwrite@plt>
  mov    -0x30(%rbp),%rax
  imul   -0x18(%rbp),%eax
  imul   -0x1c(%rbp),%eax
  mov    -0x8(%rbp),%rdx
  mov    $0x4,%esi
  mov    %eax,%edi
  call   <write_little_endian@plt>
  movq   $0x0,-0x10(%rbp)
  jmp    L26
L29:
  mov    -0x10(%rbp),%rax
  lea    (%rax,%rax,1),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  movzwl (%rax),%eax
  cwtl
  mov    -0x8(%rbp),%rdx
  mov    -0x18(%rbp),%ecx
  mov    %ecx,%esi
  mov    %eax,%edi
  call   <write_little_endian@plt>
  addq   $0x1,-0x10(%rbp)
L26:
  mov    -0x10(%rbp),%rax
  cmp    -0x30(%rbp),%rax
  jb     L29
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  nop
  leave
  ret
```

tool_calls: name: extract_symbolic_data
arguments: label: D37
datatype: string
name: extract_symbolic_data
arguments: label: D34
datatype: string
name: extract_symbolic_data
arguments: label: D35
datatype: string
name: extract_symbolic_data
arguments: label: D47
datatype: string
name: extract_symbolic_data
arguments: label: D25
datatype: string

tool: D37: w

tool: D34: RIFF

tool: D35: WAVE

tool: D47: fmt 

tool: D25: data

assistant: ```c
void write_wav(char *filename, unsigned long num_samples, short int *data, int s_rate) {
  FILE *wav_file;
  unsigned int sample_rate;
  unsigned int num_channels;
  unsigned int bytes_per_sample;
  unsigned int byte_rate;
  unsigned long i;
  num_channels = 1;
  bytes_per_sample = 2;
  if (s_rate <= 0)
    sample_rate = 44100;
  else
    sample_rate = (unsigned int)s_rate;
  byte_rate = sample_rate * num_channels * bytes_per_sample;
  wav_file = fopen(filename, "w");
  assert(wav_file);
  fwrite("RIFF", 1, 4, wav_file);
  write_little_endian(36 + bytes_per_sample * num_samples * num_channels, 4, wav_file);
  fwrite("WAVE", 1, 4, wav_file);
  fwrite("fmt ", 1, 4, wav_file);
  write_little_endian(16, 4, wav_file);
  write_little_endian(1, 2, wav_file);
  write_little_endian(num_channels, 2, wav_file);
  write_little_endian(sample_rate, 4, wav_file);
  write_little_endian(byte_rate, 4, wav_file);
  write_little_endian(num_channels * bytes_per_sample, 2, wav_file);
  write_little_endian(8 * bytes_per_sample, 2, wav_file);
  fwrite("data", 1, 4, wav_file);
  write_little_endian(bytes_per_sample * num_samples * num_channels, 4, wav_file);
  for (i = 0; i < num_samples; i++) {
    write_little_endian((unsigned int)(data[i]), bytes_per_sample, wav_file);
  }
  fclose(wav_file);
}
```