user: 请将以下的汇编代码转换成C语言代码:

```asm
<wav16_samples_max>:
  endbr64
  xor    %r9d,%r9d
  test   %esi,%esi
  je     L201
  mov    %rdi,%rax
  mov    D6(%rip),%rdi
  mov    (%rdi),%r8d
  mov    D9(%rip),%rdi
  mov    (%rdi),%edi
  jle    L130
  test   %ecx,%ecx
  jne    L28
  cmp    $0x2,%edx
  je     L183
  sub    $0x1,%esi
  shr    %esi
  lea    0x1(%rsi),%edx
  lea    (%rax,%rdx,2),%rcx
  jmp    L12
  nopw   0x0(%rax,%rax,1)
L32:
  cmp    %edx,%r8d
  cmovg  %edx,%r8d
  add    $0x2,%rax
  cmp    %rcx,%rax
  je     L18
L12:
  movswl (%rax),%edx
  cmp    %edx,%edi
  jge    L32
  add    $0x2,%rax
  mov    %edx,%edi
  cmp    %rcx,%rax
  jne    L12
L18:
  sub    %r8d,%edi
  mov    %edi,%r9d
L201:
  mov    %r9d,%eax
  ret
  nopl   0x0(%rax)
L28:
  cmp    $0x2,%edx
  je     L36
  sub    $0x1,%esi
  shr    %esi
  lea    0x1(%rsi),%edx
  lea    (%rax,%rdx,2),%r9
  nopl   0x0(%rax)
L176:
  movzwl (%rax),%ecx
  xor    %edx,%edx
  movzbl %ch,%esi
  mov    %sil,%dl
  mov    %cl,%dh
  movswl %dx,%edx
  cmp    %edx,%r8d
  mov    %edx,%ecx
  cmovle %r8d,%ecx
  cmp    %edx,%edi
  cmovl  %edx,%edi
  cmovge %ecx,%r8d
  add    $0x2,%rax
  cmp    %r9,%rax
  jne    L176
  sub    %r8d,%edi
  mov    %edi,%r9d
  jmp    L201
  nopl   0x0(%rax,%rax,1)
L36:
  lea    -0x1(%rsi),%edx
  push   %r14
  mov    %edi,%ecx
  mov    %r8d,%esi
  shr    $0x2,%edx
  push   %rbx
  add    $0x1,%edx
  lea    (%rax,%rdx,4),%r10
  nopl   (%rax)
L119:
  movzwl (%rax),%r9d
  xor    %edx,%edx
  movzwl 0x2(%rax),%r14d
  mov    %r9d,%ebx
  movzbl %bh,%ebx
  mov    %bl,%dl
  mov    %r9d,%ebx
  mov    %r8d,%r9d
  mov    %bl,%dh
  mov    %r14d,%ebx
  movswl %dx,%edx
  movzbl %bh,%ebx
  cmp    %r8d,%edx
  cmovle %edx,%r9d
  cmp    %edi,%edx
  cmovle %r9d,%r8d
  cmp    %edx,%edi
  mov    %esi,%r9d
  cmovl  %edx,%edi
  xor    %edx,%edx
  mov    %bl,%dl
  mov    %r14d,%ebx
  mov    %bl,%dh
  movswl %dx,%edx
  cmp    %esi,%edx
  cmovle %edx,%r9d
  cmp    %ecx,%edx
  cmovle %r9d,%esi
  cmp    %edx,%ecx
  cmovl  %edx,%ecx
  add    $0x4,%rax
  cmp    %rax,%r10
  jne    L119
  sub    %r8d,%edi
  sub    %esi,%ecx
  pop    %rbx
  pop    %r14
  mov    %edi,%r9d
  cmp    %ecx,%edi
  cmovl  %ecx,%r9d
  mov    %r9d,%eax
  ret
  nopl   0x0(%rax)
L183:
  lea    -0x1(%rsi),%edx
  mov    %edi,%ecx
  mov    %r8d,%esi
  shr    $0x2,%edx
  add    $0x1,%edx
  lea    (%rax,%rdx,4),%r10
  jmp    L206
  nopl   0x0(%rax)
L188:
  cmp    %r9d,%r8d
  cmovg  %r9d,%r8d
  cmp    %edx,%ecx
  jl     L112
L209:
  cmp    %edx,%esi
  cmovg  %edx,%esi
L186:
  add    $0x4,%rax
  cmp    %r10,%rax
  je     L84
L206:
  movswl (%rax),%r9d
  movswl 0x2(%rax),%edx
  cmp    %edi,%r9d
  jle    L188
  mov    %r9d,%edi
  cmp    %edx,%ecx
  jge    L209
L112:
  mov    %edx,%ecx
  jmp    L186
  nopl   0x0(%rax)
L130:
  mov    %edi,%r9d
  sub    %r8d,%r9d
  cmp    $0x2,%edx
  jne    L201
  mov    %edi,%ecx
  mov    %r8d,%esi
  jmp    L128
  xchg   %ax,%ax
L84:
  sub    %r8d,%edi
  mov    %edi,%r9d
L128:
  sub    %esi,%ecx
  cmp    %ecx,%r9d
  cmovl  %ecx,%r9d
  jmp    L201
```

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;
}
```