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

```asm
<stereo_to_mono>:
  endbr64
  mov    %rdi,%r8
  push   %rbx
  mov    %rsi,%rdi
  cmp    $0x3,%edx
  jle    L31
  sub    $0x4,%edx
  mov    %edx,%r10d
  shr    $0x2,%r10d
  lea    0x1(%r10),%ecx
  mov    %rcx,%rax
  mov    %rcx,%r9
  lea    (%r8,%rcx,8),%rcx
  shl    $0x4,%rax
  add    %rsi,%rax
  cmp    %rax,%r8
  setae  %al
  cmp    %rcx,%rsi
  setae  %cl
  or     %cl,%al
  je     L1
  cmp    $0x3,%edx
  jbe    L1
  mov    %rsi,%rax
  mov    %r9d,%esi
  pxor   %xmm4,%xmm4
  mov    %r8,%rcx
  shr    %esi
  sub    $0x1,%esi
  shl    $0x5,%rsi
  lea    0x20(%rdi,%rsi,1),%rsi
  nopl   0x0(%rax,%rax,1)
L70:
  movdqu (%rax),%xmm0
  movdqu 0x10(%rax),%xmm3
  add    $0x20,%rax
  add    $0x10,%rcx
  movdqa %xmm0,%xmm2
  movdqa %xmm0,%xmm1
  punpcklwd %xmm3,%xmm0
  punpcklwd %xmm3,%xmm2
  punpckhwd %xmm3,%xmm1
  movdqa %xmm4,%xmm3
  movdqa %xmm2,%xmm5
  punpcklwd %xmm1,%xmm0
  punpcklwd %xmm1,%xmm2
  punpckhwd %xmm1,%xmm5
  punpcklwd %xmm5,%xmm2
  punpckhwd %xmm5,%xmm0
  movdqa %xmm4,%xmm5
  pcmpgtw %xmm2,%xmm5
  pcmpgtw %xmm0,%xmm3
  movdqa %xmm2,%xmm6
  movdqa %xmm0,%xmm1
  punpckhwd %xmm5,%xmm2
  punpcklwd %xmm5,%xmm6
  punpcklwd %xmm3,%xmm1
  punpckhwd %xmm3,%xmm0
  paddd  %xmm6,%xmm1
  paddd  %xmm2,%xmm0
  psrad  $0x1,%xmm1
  psrad  $0x1,%xmm0
  movdqa %xmm1,%xmm2
  punpcklwd %xmm0,%xmm1
  punpckhwd %xmm0,%xmm2
  movdqa %xmm1,%xmm0
  punpcklwd %xmm2,%xmm1
  punpckhwd %xmm2,%xmm0
  punpcklwd %xmm0,%xmm1
  movups %xmm1,-0x10(%rcx)
  cmp    %rsi,%rax
  jne    L70
  mov    %r9d,%ecx
  and    $0xfffffffe,%ecx
  mov    %ecx,%esi
  mov    %rsi,%rax
  lea    (%r8,%rsi,8),%rsi
  shl    $0x4,%rax
  add    %rdi,%rax
  cmp    %ecx,%r9d
  je     L6
  movswl 0x2(%rax),%r11d
  movswl (%rax),%ecx
  add    %r11d,%ecx
  sar    %ecx
  mov    %cx,(%rsi)
  movswl 0x6(%rax),%r11d
  movswl 0x4(%rax),%ecx
  add    %r11d,%ecx
  sar    %ecx
  mov    %cx,0x2(%rsi)
  movswl 0x8(%rax),%ecx
  movswl 0xa(%rax),%r11d
  add    %r11d,%ecx
  sar    %ecx
  mov    %cx,0x4(%rsi)
  movswl 0xc(%rax),%ecx
  movswl 0xe(%rax),%eax
  add    %ecx,%eax
  sar    %eax
  mov    %ax,0x6(%rsi)
L6:
  mov    %r9d,%r9d
  neg    %r10d
  mov    %r9,%rax
  lea    (%r8,%r9,8),%r8
  lea    (%rdx,%r10,4),%edx
  shl    $0x4,%rax
  add    %rax,%rdi
L31:
  test   %edx,%edx
  jle    L16
  movswl (%rdi),%eax
  movswl 0x2(%rdi),%ecx
  add    %ecx,%eax
  sar    %eax
  mov    %ax,(%r8)
  sub    $0x1,%edx
  je     L16
  movswl 0x4(%rdi),%eax
  movswl 0x6(%rdi),%ecx
  add    %ecx,%eax
  sar    %eax
  mov    %ax,0x2(%r8)
  cmp    $0x1,%edx
  je     L16
  movswl 0x8(%rdi),%eax
  movswl 0xa(%rdi),%edx
  add    %edx,%eax
  sar    %eax
  mov    %ax,0x4(%r8)
L16:
  pop    %rbx
  ret
  nopl   0x0(%rax,%rax,1)
L1:
  mov    %r9d,%eax
  mov    %r8,%rcx
  lea    (%r8,%rax,8),%r11
  mov    %rdi,%rax
  nopl   (%rax)
L90:
  movswl 0x2(%rax),%ebx
  movswl (%rax),%esi
  add    $0x8,%rcx
  add    $0x10,%rax
  add    %ebx,%esi
  sar    %esi
  mov    %si,-0x8(%rcx)
  movswl -0xa(%rax),%ebx
  movswl -0xc(%rax),%esi
  add    %ebx,%esi
  sar    %esi
  mov    %si,-0x6(%rcx)
  movswl -0x6(%rax),%ebx
  movswl -0x8(%rax),%esi
  add    %ebx,%esi
  sar    %esi
  mov    %si,-0x4(%rcx)
  movswl -0x4(%rax),%esi
  movswl -0x2(%rax),%ebx
  add    %ebx,%esi
  sar    %esi
  mov    %si,-0x2(%rcx)
  cmp    %rcx,%r11
  jne    L90
  jmp    L6
```

assistant: ```c
void stereo_to_mono(short *output, short *input, int n1) {
  short *p, *q;
  int n = n1;
  p = input;
  q = output;
  while (n >= 4) {
    q[0] = (p[0] + p[1]) >> 1;
    q[1] = (p[2] + p[3]) >> 1;
    q[2] = (p[4] + p[5]) >> 1;
    q[3] = (p[6] + p[7]) >> 1;
    q += 4;
    p += 8;
    n -= 4;
  }
  while (n > 0) {
    q[0] = (p[0] + p[1]) >> 1;
    q++;
    p += 2;
    n--;
  }
}
```