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

```asm
<ts_nit_add_frequency_list_descriptor>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %esi,-0x2c(%rbp)
  mov    %edx,-0x30(%rbp)
  mov    %ecx,-0x34(%rbp)
  mov    %r8,-0x40(%rbp)
  mov    %r9d,-0x38(%rbp)
  cmpl   $0x0,-0x38(%rbp)
  je     L5
  cmpl   $0x3f,-0x38(%rbp)
  jle    L30
L5:
  mov    $0x0,%eax
  jmp    L45
L30:
  mov    -0x38(%rbp),%eax
  shl    $0x2,%eax
  add    $0x3,%eax
  mov    %eax,-0x10(%rbp)
  mov    -0x10(%rbp),%eax
  mov    %eax,%esi
  mov    $0x1,%edi
  call   <calloc@plt>
  mov    %rax,-0x8(%rbp)
  movl   $0x0,-0x14(%rbp)
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movl   $0x62,(%rax)
  mov    -0x14(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    -0x10(%rbp),%edx
  sub    $0x2,%edx
  mov    %edx,(%rax)
  mov    -0x14(%rbp),%eax
  cltq
  add    $0x2,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    -0x34(%rbp),%edx
  or     $0xfc,%dl
  mov    %edx,(%rax)
  addl   $0x3,-0x14(%rbp)
  movl   $0x0,-0x18(%rbp)
  jmp    L3
L14:
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    -0xc(%rbp),%edx
  sar    $0x18,%edx
  mov    %edx,(%rax)
  mov    -0xc(%rbp),%eax
  shr    $0x10,%eax
  mov    %eax,%ecx
  mov    -0x14(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rax,%rdx
  movzbl %cl,%eax
  mov    %eax,(%rdx)
  mov    -0xc(%rbp),%eax
  shr    $0x8,%eax
  mov    %eax,%ecx
  mov    -0x14(%rbp),%eax
  cltq
  add    $0x2,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rax,%rdx
  movzbl %cl,%eax
  mov    %eax,(%rdx)
  mov    -0x14(%rbp),%eax
  cltq
  add    $0x3,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rax,%rdx
  mov    -0xc(%rbp),%eax
  movzbl %al,%eax
  mov    %eax,(%rdx)
  addl   $0x4,-0x14(%rbp)
  addl   $0x1,-0x18(%rbp)
L3:
  mov    -0x18(%rbp),%eax
  cmp    -0x38(%rbp),%eax
  jl     L14
  mov    -0x10(%rbp),%edi
  mov    -0x8(%rbp),%rcx
  mov    -0x30(%rbp),%edx
  mov    -0x2c(%rbp),%esi
  mov    -0x28(%rbp),%rax
  mov    %edi,%r8d
  mov    %rax,%rdi
  call   <ts_nit_add_stream@plt>
L45:
  leave
  ret
```

assistant: ```c
int ts_nit_add_frequency_list_descriptor(struct ts_nit *nit, uint16_t ts_id, uint16_t org_net_id, uint8_t freq_type, uint32_t *freqs, uint8_t num_freqs) {
  uint8_t i;
  if (!num_freqs || num_freqs > 63)
    return 0;
  int desc_size = 2 + 1 + num_freqs * 4;
  uint8_t *desc = calloc(1, desc_size);
  int dpos = 0;
  desc[dpos + 0] = 0x62;
  desc[dpos + 1] = desc_size - 2;
  desc[dpos + 2] = 0xfc | freq_type;
  dpos += 3;
  for (i = 0; i < num_freqs; i++) {
    uint32_t freq = freqs[i];
    desc[dpos + 0] = ((freq & ~0x00ffffff) >> 24);
    desc[dpos + 1] = ((freq & ~0xff00ffff) >> 16);
    desc[dpos + 2] = ((freq & ~0xffff00ff) >> 8);
    desc[dpos + 3] = (freq & ~0xffffff00);
    dpos += 4;
  }
  return ts_nit_add_stream(nit, ts_id, org_net_id, desc, desc_size);
}
```