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

```asm
<write_wav>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  mov    %rdx,%r13
  push   %r12
  mov    %rsi,%r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  test   %ecx,%ecx
  jle    L14
  mov    %ecx,%r14d
  lea    (%rcx,%rcx,1),%ebx
L10:
  lea    D46(%rip),%rsi
  lea    (%r12,%r12,1),%r15d
  call   <fopen@plt>
  mov    %rax,%rbp
  mov    %rax,%rdi
  call   <assert@plt>
  mov    %rbp,%rcx
  mov    $0x4,%edx
  mov    $0x1,%esi
  lea    D4(%rip),%rdi
  call   <fwrite@plt>
  lea    0x24(%r15),%edi
  mov    %rbp,%rdx
  mov    $0x4,%esi
  call   <write_little_endian@plt>
  mov    %rbp,%rcx
  mov    $0x4,%edx
  mov    $0x1,%esi
  lea    D47(%rip),%rdi
  call   <fwrite@plt>
  mov    %rbp,%rcx
  mov    $0x4,%edx
  mov    $0x1,%esi
  lea    D13(%rip),%rdi
  call   <fwrite@plt>
  mov    %rbp,%rdx
  mov    $0x4,%esi
  mov    $0x10,%edi
  call   <write_little_endian@plt>
  mov    %rbp,%rdx
  mov    $0x2,%esi
  mov    $0x1,%edi
  call   <write_little_endian@plt>
  mov    %rbp,%rdx
  mov    $0x2,%esi
  mov    $0x1,%edi
  call   <write_little_endian@plt>
  mov    %rbp,%rdx
  mov    $0x4,%esi
  mov    %r14d,%edi
  call   <write_little_endian@plt>
  mov    %ebx,%edi
  mov    %rbp,%rdx
  mov    $0x4,%esi
  call   <write_little_endian@plt>
  mov    %rbp,%rdx
  mov    $0x2,%esi
  xor    %ebx,%ebx
  mov    $0x2,%edi
  call   <write_little_endian@plt>
  mov    %rbp,%rdx
  mov    $0x2,%esi
  mov    $0x10,%edi
  call   <write_little_endian@plt>
  mov    %rbp,%rcx
  mov    $0x4,%edx
  mov    $0x1,%esi
  lea    D43(%rip),%rdi
  call   <fwrite@plt>
  mov    %rbp,%rdx
  mov    $0x4,%esi
  mov    %r15d,%edi
  call   <write_little_endian@plt>
  test   %r12,%r12
  je     L30
  cs nopw 0x0(%rax,%rax,1)
L1:
  movswl 0x0(%r13,%rbx,2),%edi
  mov    %rbp,%rdx
  mov    $0x2,%esi
  add    $0x1,%rbx
  call   <write_little_endian@plt>
  cmp    %rbx,%r12
  jne    L1
L30:
  add    $0x8,%rsp
  mov    %rbp,%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    1090 <fclose@plt>
  nopw   0x0(%rax,%rax,1)
L14:
  mov    $0x15888,%ebx
  mov    $0xac44,%r14d
  jmp    L10
```

tool_calls: name: extract_symbolic_data
arguments: data_label: D46
data_type: string
name: extract_symbolic_data
arguments: data_label: D4
data_type: string
name: extract_symbolic_data
arguments: data_label: D47
data_type: string
name: extract_symbolic_data
arguments: data_label: D13
data_type: string
name: extract_symbolic_data
arguments: data_label: D43
data_type: string

tool: D46: w

tool: D4: RIFF

tool: D47: WAVE

tool: D13: fmt 

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