user: Translate the below assembly code into C programming language:

```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    L36
  mov    %ecx,%r14d
  lea    (%rcx,%rcx,1),%ebx
L35:
  lea    D38(%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    D11(%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    D37(%rip),%rdi
  call   <fwrite@plt>
  mov    %rbp,%rcx
  mov    $0x4,%edx
  mov    $0x1,%esi
  lea    D7(%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    D33(%rip),%rdi
  call   <fwrite@plt>
  mov    %rbp,%rdx
  mov    $0x4,%esi
  mov    %r15d,%edi
  call   <write_little_endian@plt>
  test   %r12,%r12
  je     L6
  cs nopw 0x0(%rax,%rax,1)
L22:
  movswl 0x0(%r13,%rbx,2),%edi
  mov    %rbp,%rdx
  mov    $0x2,%esi
  add    $0x1,%rbx
  call   <write_little_endian@plt>
  cmp    %rbx,%r12
  jne    L22
L6:
  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)
L36:
  mov    $0x15888,%ebx
  mov    $0xac44,%r14d
  jmp    L35
```

tool_calls: name: read_data
arguments: data_label: D38
type_guessed: string
name: read_data
arguments: data_label: D11
type_guessed: string
name: read_data
arguments: data_label: D37
type_guessed: string
name: read_data
arguments: data_label: D7
type_guessed: string
name: read_data
arguments: data_label: D33
type_guessed: string

tool: D38: w

tool: D11: RIFF

tool: D37: WAVE

tool: D7: fmt 

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