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

```asm
<iec958_build_dtsframe>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %rsi,0x8(%rsp)
  mov    %rdx,0x18(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  test   %rsi,%rsi
  je     L21
  mov    %rdi,%r12
  lea    0x20(%rsp),%r14
  lea    0x24(%rsp),%r13
  mov    %rdx,%r15
L76:
  mov    %r14,%rdx
  mov    %r13,%rsi
  mov    %r12,%rdi
  call   <dts_decode_header@plt>
  mov    %eax,%ebp
  test   %eax,%eax
  js     L21
  movdqa D6(%rip),%xmm0
  mov    0x20(%rsp),%ebx
  lea    0x0(,%rax,8),%eax
  movups %xmm0,(%r15)
  cmp    $0x20,%ebx
  je     L41
  cmp    $0x40,%ebx
  je     L58
  cmp    $0x10,%ebx
  je     L37
L21:
  xor    %eax,%eax
L13:
  mov    0x28(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L66
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L37:
  lea    0x14(%r15),%rdx
  mov    $0xb,%esi
L51:
  mov    %esi,0x10(%r15)
  lea    0xc(%rdx),%r15
  mov    %r12,%rdi
  mov    %eax,0x4(%rdx)
  sar    $0x8,%eax
  mov    %r15,%rsi
  movl   $0x0,(%rdx)
  mov    %eax,0x8(%rdx)
  mov    %ebp,%edx
  call   <swab@plt>
  movslq %ebp,%r8
  lea    0x0(,%r8,4),%rdi
  mov    %r8,0x10(%rsp)
  add    %rdi,%r12
  test   $0x1,%bpl
  jne    L36
  shl    $0x7,%ebx
  add    %r15,%rdi
  mov    %ebx,%edx
  sub    %ebp,%edx
L1:
  xor    %esi,%esi
  movslq %ebx,%rbx
  call   <memset@plt>
  mov    0x10(%rsp),%r8
  sub    %r8,0x8(%rsp)
  lea    -0x20(%r15,%rbx,4),%r15
  jne    L76
  mov    %r15,%r9
  sub    0x18(%rsp),%r9
  sar    $0x2,%r9
  lea    0x3(%r9),%rax
  cmovns %r9,%rax
  sar    $0x2,%rax
  jmp    L13
  nopl   0x0(%rax)
L36:
  mov    (%r12),%eax
  shl    $0x7,%ebx
  add    %r15,%rdi
  mov    %ebx,%edx
  mov    %eax,(%rdi)
  sub    %ebp,%edx
  jmp    L1
  nopw   0x0(%rax,%rax,1)
L58:
  lea    0x14(%r15),%rdx
  mov    $0xd,%esi
  jmp    L51
  cs nopw 0x0(%rax,%rax,1)
L41:
  lea    0x14(%r15),%rdx
  mov    $0xc,%esi
  jmp    L51
L66:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: label: D6
datatype: byte[16]

tool: {"D6": [0x72,0x00,0x00,0x00,0xf8,0x00,0x00,0x00,0x1f,0x00,0x00,0x00,0x4e,0x00,0x00,0x00]}

assistant: ```c
int iec958_build_dtsframe(const uint8_t *src, size_t srclen, uint8_t *dst) {
  int nblks, fsize, rate, burst_len, nr_samples;
  uint8_t *dst0 = dst;
  while (srclen > 0) {
    if ((fsize = dts_decode_header(src, &rate, &nblks)) < 0)
      return 0;
    burst_len = fsize * 8;
    nr_samples = nblks * 32;
    *dst++ = 0x72;
    *dst++ = 0xf8;
    *dst++ = 0x1f;
    *dst++ = 0x4e;
    switch (nr_samples) {
    case 512:
      *dst++ = 11;
      break;
    case 1024:
      *dst++ = 12;
      break;
    case 2048:
      *dst++ = 13;
      break;
    default:
      return 0;
    }
    *dst++ = 0;
    *dst++ = burst_len;
    *dst++ = burst_len >> 8;
    swab(src, dst, fsize);
    if (fsize & 1)
      dst[fsize] = src[fsize];
    memset(dst + fsize, 0, nr_samples * 4 - fsize);
    dst += nr_samples * 4 - 8;
    srclen -= fsize;
    src += fsize;
  }
  return (dst - dst0) / 4;
}
```