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

```asm
<wav16_samples_max>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  add    $0xffffffffffffff80,%rsp
  mov    %rdi,-0x68(%rbp)
  mov    %esi,-0x6c(%rbp)
  mov    %edx,-0x70(%rbp)
  mov    %ecx,-0x74(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    D10(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,-0x50(%rbp)
  mov    D15(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,-0x4c(%rbp)
  mov    D10(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,-0x48(%rbp)
  mov    D15(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,-0x44(%rbp)
  cmpl   $0x0,-0x6c(%rbp)
  jne    L117
  mov    $0x0,%eax
  jmp    L60
L117:
  mov    -0x68(%rbp),%rax
  mov    %rax,-0x38(%rbp)
  mov    -0x38(%rbp),%rax
  add    $0x2,%rax
  mov    %rax,-0x30(%rbp)
  jmp    L134
L47:
  mov    -0x38(%rbp),%rax
  movzwl (%rax),%eax
  mov    %ax,-0x56(%rbp)
  mov    -0x30(%rbp),%rax
  movzwl (%rax),%eax
  mov    %ax,-0x54(%rbp)
  cmpl   $0x0,-0x74(%rbp)
  je     L93
  movzwl -0x56(%rbp),%eax
  mov    %ax,-0x52(%rbp)
  lea    -0x56(%rbp),%rax
  mov    %rax,-0x28(%rbp)
  lea    -0x52(%rbp),%rax
  mov    %rax,-0x20(%rbp)
  mov    -0x20(%rbp),%rax
  movzbl 0x1(%rax),%edx
  mov    -0x28(%rbp),%rax
  mov    %dl,(%rax)
  mov    -0x28(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    -0x20(%rbp),%rax
  movzbl (%rax),%eax
  mov    %al,(%rdx)
  movzwl -0x54(%rbp),%eax
  mov    %ax,-0x52(%rbp)
  lea    -0x54(%rbp),%rax
  mov    %rax,-0x18(%rbp)
  lea    -0x52(%rbp),%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x10(%rbp),%rax
  movzbl 0x1(%rax),%edx
  mov    -0x18(%rbp),%rax
  mov    %dl,(%rax)
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    -0x10(%rbp),%rax
  movzbl (%rax),%eax
  mov    %al,(%rdx)
L93:
  movzwl -0x56(%rbp),%eax
  cwtl
  cmp    %eax,-0x4c(%rbp)
  jge    L108
  movzwl -0x56(%rbp),%eax
  cwtl
  mov    %eax,-0x4c(%rbp)
  jmp    L112
L108:
  movzwl -0x56(%rbp),%eax
  cwtl
  cmp    %eax,-0x50(%rbp)
  jle    L112
  movzwl -0x56(%rbp),%eax
  cwtl
  mov    %eax,-0x50(%rbp)
L112:
  mov    -0x6c(%rbp),%eax
  sub    $0x2,%eax
  mov    %eax,-0x6c(%rbp)
  addq   $0x2,-0x38(%rbp)
  cmpl   $0x2,-0x70(%rbp)
  jne    L134
  movzwl -0x54(%rbp),%eax
  cwtl
  cmp    %eax,-0x44(%rbp)
  jge    L136
  movzwl -0x54(%rbp),%eax
  cwtl
  mov    %eax,-0x44(%rbp)
  jmp    L4
L136:
  movzwl -0x54(%rbp),%eax
  cwtl
  cmp    %eax,-0x48(%rbp)
  jle    L4
  movzwl -0x54(%rbp),%eax
  cwtl
  mov    %eax,-0x48(%rbp)
L4:
  mov    -0x6c(%rbp),%eax
  sub    $0x2,%eax
  mov    %eax,-0x6c(%rbp)
  addq   $0x2,-0x38(%rbp)
  mov    -0x38(%rbp),%rax
  add    $0x2,%rax
  mov    %rax,-0x30(%rbp)
L134:
  cmpl   $0x0,-0x6c(%rbp)
  jg     L47
  mov    -0x4c(%rbp),%eax
  sub    -0x50(%rbp),%eax
  mov    %eax,-0x40(%rbp)
  cmpl   $0x2,-0x70(%rbp)
  jne    L70
  mov    -0x44(%rbp),%eax
  sub    -0x48(%rbp),%eax
  mov    %eax,-0x3c(%rbp)
  mov    -0x3c(%rbp),%edx
  mov    -0x40(%rbp),%eax
  cmp    %eax,%edx
  cmovge %edx,%eax
  jmp    L60
L70:
  mov    -0x40(%rbp),%eax
L60:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L69
  call   <__stack_chk_fail@plt>
L69:
  leave
  ret
```

assistant: ```c
int wav16_samples_max(const unsigned char *buf, int len, int channels, int bswap) {
  const short int *left;
  const short int *right;
  short int l;
  short int r;
  int lavg;
  int ravg;
  int lmin = SHRT_MAX;
  int lmax = SHRT_MIN;
  int rmin = SHRT_MAX;
  int rmax = SHRT_MIN;
  if (len == 0) {
    return 0;
  }
  left = (short int *)buf;
  right = left + 1;
  while (len > 0) {
    l = *left;
    r = *right;
    if (bswap) {
      {
        unsigned short t = (unsigned short)(l);
        unsigned char *o = (unsigned char *)&(l);
        unsigned char *i = (unsigned char *)&t;
        o[0] = i[1];
        o[1] = i[0];
      };
      {
        unsigned short t = (unsigned short)(r);
        unsigned char *o = (unsigned char *)&(r);
        unsigned char *i = (unsigned char *)&t;
        o[0] = i[1];
        o[1] = i[0];
      };
    }
    if (l > lmax) {
      lmax = l;
    } else if (l < lmin) {
      lmin = l;
    }
    len -= sizeof(l);
    left++;
    if (channels == 2) {
      if (r > rmax) {
        rmax = r;
      } else if (r < rmin) {
        rmin = r;
      }
      len -= sizeof(r);
      left++;
      right = left + 1;
    }
  }
  lavg = lmax - lmin;
  if (channels == 2) {
    ravg = rmax - rmin;
    return lavg > ravg ? lavg : ravg;
  }
  return lavg;
}
```