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

```asm
<patch_hdr>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  add    $0xffffffffffffff80,%rsp
  mov    %rdi,-0x58(%rbp)
  mov    %rsi,-0x60(%rbp)
  mov    %rdx,-0x68(%rbp)
  mov    %rcx,-0x70(%rbp)
  mov    %r8,-0x78(%rbp)
  mov    %r9,-0x80(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    -0x30(%rbp),%r9
  lea    -0x38(%rbp),%r8
  lea    -0x40(%rbp),%rcx
  lea    -0x48(%rbp),%rdx
  mov    -0x60(%rbp),%rsi
  mov    -0x58(%rbp),%rax
  sub    $0x8,%rsp
  lea    -0x18(%rbp),%rdi
  push   %rdi
  lea    -0x20(%rbp),%rdi
  push   %rdi
  lea    -0x28(%rbp),%rdi
  push   %rdi
  mov    %rax,%rdi
  call   <parse_hdr@plt>
  add    $0x20,%rsp
  cmp    %rax,-0x60(%rbp)
  je     L88
  mov    $0x0,%eax
  jmp    L28
L88:
  mov    -0x40(%rbp),%rax
  add    $0x1c,%rax
  cmp    %rax,-0x60(%rbp)
  je     L9
  mov    $0x0,%eax
  jmp    L28
L9:
  mov    -0x40(%rbp),%rax
  cmp    $0x10,%rax
  jbe    L20
  mov    -0x40(%rbp),%rax
  lea    0x14(%rax),%rdx
  mov    -0x58(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x58(%rbp),%rax
  add    $0x24,%rax
  mov    $0x8,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memmove@plt>
  mov    -0x58(%rbp),%rax
  add    $0x10,%rax
  movb   $0x10,(%rax)
  mov    -0x58(%rbp),%rax
  add    $0x11,%rax
  movb   $0x0,(%rax)
  mov    -0x58(%rbp),%rax
  add    $0x12,%rax
  movb   $0x0,(%rax)
  mov    -0x58(%rbp),%rax
  add    $0x13,%rax
  movb   $0x0,(%rax)
  movq   $0x10,-0x40(%rbp)
  movq   $0x2c,-0x60(%rbp)
L20:
  mov    -0x20(%rbp),%rax
  add    $0x7,%rax
  shr    $0x3,%rax
  mov    %rax,%rdx
  mov    -0x30(%rbp),%rax
  imul   %rdx,%rax
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x78(%rbp)
  jne    L79
  mov    -0x28(%rbp),%rax
  mov    -0x68(%rbp),%rdx
  imul   %rdx,%rax
  mov    %rax,-0x78(%rbp)
  mov    -0x28(%rbp),%rax
  shr    $0x2,%rax
  movabs $0x28f5c28f5c28f5c3,%rdx
  mul    %rdx
  mov    %rdx,%rcx
  shr    $0x2,%rcx
  mov    -0x70(%rbp),%rax
  movabs $0xcccccccccccccccd,%rdx
  mul    %rdx
  mov    %rdx,%rax
  shr    $0x3,%rax
  imul   %rcx,%rax
  shr    $0x3,%rax
  movabs $0x20c49ba5e353f7cf,%rdx
  mul    %rdx
  mov    %rdx,%rax
  shr    $0x4,%rax
  add    %rax,-0x78(%rbp)
L79:
  cmpq   $0x0,-0x78(%rbp)
  je     L34
  mov    -0x78(%rbp),%rax
  imul   -0x10(%rbp),%rax
  mov    %rax,-0x18(%rbp)
  mov    -0x18(%rbp),%rax
  add    $0x24,%rax
  mov    %rax,-0x48(%rbp)
  jmp    L33
L34:
  mov    $0xffffffff,%eax
  mov    %rax,-0x48(%rbp)
  mov    -0x48(%rbp),%rax
  sub    $0x24,%rax
  mov    %rax,-0x18(%rbp)
L33:
  cmpq   $0x0,-0x80(%rbp)
  je     L59
  mov    -0x18(%rbp),%rdx
  mov    -0x80(%rbp),%rax
  mov    %rdx,(%rax)
L59:
  mov    -0x48(%rbp),%rdx
  mov    -0x58(%rbp),%rax
  add    $0x4,%rax
  mov    %dl,(%rax)
  mov    -0x48(%rbp),%rax
  shr    $0x8,%rax
  mov    %rax,%rdx
  mov    -0x58(%rbp),%rax
  add    $0x5,%rax
  mov    %dl,(%rax)
  mov    -0x48(%rbp),%rax
  shr    $0x10,%rax
  mov    %rax,%rdx
  mov    -0x58(%rbp),%rax
  add    $0x6,%rax
  mov    %dl,(%rax)
  mov    -0x48(%rbp),%rax
  shr    $0x18,%rax
  mov    %rax,%rdx
  mov    -0x58(%rbp),%rax
  add    $0x7,%rax
  mov    %dl,(%rax)
  mov    -0x18(%rbp),%rdx
  mov    -0x58(%rbp),%rax
  add    $0x28,%rax
  mov    %dl,(%rax)
  mov    -0x18(%rbp),%rax
  shr    $0x8,%rax
  mov    %rax,%rdx
  mov    -0x58(%rbp),%rax
  add    $0x29,%rax
  mov    %dl,(%rax)
  mov    -0x18(%rbp),%rax
  shr    $0x10,%rax
  mov    %rax,%rdx
  mov    -0x58(%rbp),%rax
  add    $0x2a,%rax
  mov    %dl,(%rax)
  mov    -0x18(%rbp),%rax
  shr    $0x18,%rax
  mov    %rax,%rdx
  mov    -0x58(%rbp),%rax
  add    $0x2b,%rax
  mov    %dl,(%rax)
  mov    -0x60(%rbp),%rax
L28:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L3
  call   <__stack_chk_fail@plt>
L3:
  leave
  ret
```

assistant: ```c
size_t patch_hdr(unsigned char *hdr, size_t hdr_len, unsigned long sec, unsigned long us, unsigned long samples, size_t *data_length_ret) {
  unsigned long chunk_data_length;
  unsigned long format_data_length;
  unsigned long compression_code;
  unsigned long channel_count;
  unsigned long sample_rate;
  unsigned long sample_bit_length;
  unsigned long data_length;
  unsigned long bytes_per_sample;
  if (parse_hdr(hdr, hdr_len, &chunk_data_length, &format_data_length, &compression_code, &channel_count, &sample_rate, &sample_bit_length, &data_length) != hdr_len)
    return 0;
  if (hdr_len != (20 + format_data_length + 8))
    return 0;
  if (format_data_length > 16) {
    memmove(hdr + 20 + 16, hdr + 20 + format_data_length, 8);
    hdr[16] = 16;
    hdr[17] = 0;
    hdr[18] = 0;
    hdr[19] = 0;
    format_data_length = 16;
    hdr_len = 44;
  }
  bytes_per_sample = channel_count * ((sample_bit_length + 7) / 8);
  if (samples == 0) {
    samples = sample_rate * sec;
    samples += ((sample_rate / 100) * (us / 10)) / 1000;
  }
  if (samples > 0) {
    data_length = samples * bytes_per_sample;
    chunk_data_length = data_length + 36;
  } else {
    chunk_data_length = 0xffffffff;
    data_length = chunk_data_length - 36;
  }
  if (data_length_ret != NULL)
    *data_length_ret = data_length;
  hdr[4] = chunk_data_length % 0x100;
  hdr[5] = (chunk_data_length >> 8) % 0x100;
  hdr[6] = (chunk_data_length >> 16) % 0x100;
  hdr[7] = (chunk_data_length >> 24) % 0x100;
  hdr[40] = data_length % 0x100;
  hdr[41] = (data_length >> 8) % 0x100;
  hdr[42] = (data_length >> 16) % 0x100;
  hdr[43] = (data_length >> 24) % 0x100;
  return hdr_len;
}
```