user: Please show me the C implementation that matches the assembly code listed below:

```asm
<convert_stereo_to_mono_u16le>:
  endbr64
  mov    %edx,%r8d
  mov    (%rsi),%rdx
  test   %r8d,%r8d
  lea    0x3(%r8),%esi
  cmovns %r8d,%esi
  sar    $0x2,%esi
  cmp    $0x3,%r8d
  jle    L8
  mov    %esi,%ecx
  test   %rcx,%rcx
  sete   %al
  mov    %eax,%ecx
  or     %cl,%al
  je     L45
  cmp    $0xf,%r8d
  jle    L45
  mov    %esi,%ecx
  xor    %eax,%eax
  pxor   %xmm3,%xmm3
  shr    $0x2,%ecx
  shl    $0x4,%rcx
  nopl   (%rax)
L48:
  movdqu (%rdx,%rax,2),%xmm1
  movdqu 0x10(%rdx,%rax,2),%xmm4
  movdqa %xmm1,%xmm2
  shufps $0xdd,%xmm4,%xmm1
  shufps $0x88,%xmm4,%xmm2
  movdqa %xmm2,%xmm0
  pslld  $0x8,%xmm2
  psrad  $0x8,%xmm0
  por    %xmm2,%xmm0
  movdqa %xmm1,%xmm2
  psrad  $0x8,%xmm2
  pslld  $0x8,%xmm1
  por    %xmm2,%xmm1
  paddd  %xmm1,%xmm0
  movdqa %xmm3,%xmm1
  pcmpgtd %xmm0,%xmm1
  psubd  %xmm1,%xmm0
  movdqa %xmm0,%xmm1
  psrad  $0x9,%xmm0
  psrad  $0x1,%xmm1
  pslld  $0x8,%xmm1
  por    %xmm1,%xmm0
  movups %xmm0,(%rdx,%rax,1)
  add    $0x10,%rax
  cmp    %rax,%rcx
  jne    L48
  mov    %esi,%edi
  and    $0xfffffffc,%edi
  mov    %edi,%eax
  shl    $0x2,%rax
  add    %rax,%rdx
  add    %rdx,%rax
  cmp    %edi,%esi
  je     L8
  mov    (%rax),%ecx
  mov    %ecx,%r10d
  shl    $0x8,%ecx
  sar    $0x8,%r10d
  or     %ecx,%r10d
  mov    0x4(%rax),%ecx
  mov    %ecx,%r9d
  shl    $0x8,%ecx
  sar    $0x8,%r9d
  or     %ecx,%r9d
  add    %r10d,%r9d
  mov    %r9d,%ecx
  shr    $0x1f,%ecx
  add    %r9d,%ecx
  mov    %ecx,%r9d
  sar    $0x9,%ecx
  sar    %r9d
  shl    $0x8,%r9d
  or     %r9d,%ecx
  mov    %ecx,(%rdx)
  lea    0x1(%rdi),%ecx
  cmp    %ecx,%esi
  jle    L8
  mov    0x8(%rax),%ecx
  add    $0x2,%edi
  mov    %ecx,%r10d
  shl    $0x8,%ecx
  sar    $0x8,%r10d
  or     %ecx,%r10d
  mov    0xc(%rax),%ecx
  mov    %ecx,%r9d
  shl    $0x8,%ecx
  sar    $0x8,%r9d
  or     %ecx,%r9d
  add    %r10d,%r9d
  mov    %r9d,%ecx
  shr    $0x1f,%ecx
  add    %r9d,%ecx
  mov    %ecx,%r9d
  sar    $0x9,%ecx
  sar    %r9d
  shl    $0x8,%r9d
  or     %r9d,%ecx
  mov    %ecx,0x4(%rdx)
  cmp    %edi,%esi
  jle    L8
  mov    0x10(%rax),%ecx
  mov    0x14(%rax),%eax
  mov    %ecx,%esi
  shl    $0x8,%ecx
  sar    $0x8,%esi
  or     %ecx,%esi
  mov    %eax,%ecx
  shl    $0x8,%eax
  sar    $0x8,%ecx
  or     %eax,%ecx
  add    %esi,%ecx
  mov    %ecx,%eax
  shr    $0x1f,%eax
  add    %ecx,%eax
  mov    %eax,%ecx
  sar    $0x9,%eax
  sar    %ecx
  shl    $0x8,%ecx
  or     %ecx,%eax
  mov    %eax,0x8(%rdx)
L8:
  mov    %r8d,%eax
  shr    $0x1f,%eax
  add    %r8d,%eax
  sar    %eax
  ret
L45:
  xor    %edi,%edi
  nopw   0x0(%rax,%rax,1)
L36:
  mov    (%rdx,%rdi,8),%eax
  mov    %eax,%r9d
  shl    $0x8,%eax
  sar    $0x8,%r9d
  or     %eax,%r9d
  mov    0x4(%rdx,%rdi,8),%eax
  mov    %eax,%ecx
  shl    $0x8,%eax
  sar    $0x8,%ecx
  or     %eax,%ecx
  add    %r9d,%ecx
  mov    %ecx,%eax
  shr    $0x1f,%eax
  add    %ecx,%eax
  mov    %eax,%ecx
  sar    $0x9,%eax
  sar    %ecx
  shl    $0x8,%ecx
  or     %ecx,%eax
  mov    %eax,(%rdx,%rdi,4)
  add    $0x1,%rdi
  cmp    %edi,%esi
  jg     L36
  mov    %r8d,%eax
  shr    $0x1f,%eax
  add    %r8d,%eax
  sar    %eax
  ret
```

assistant: ```c
int convert_stereo_to_mono_u16le(struct xmms_convert_buffers *buf, void **data, int length) {
  uint16_t *output = *data, *input = *data;
  int i;
  for (i = 0; i < length / 4; i++) {
    uint32_t tmp;
    uint16_t stmp;
    tmp = (((uint16_t)((uint16_t)((uint16_t)(*input) >> 8) | (uint16_t)((uint16_t)(*input) << 8))));
    input++;
    tmp += (((uint16_t)((uint16_t)((uint16_t)(*input) >> 8) | (uint16_t)((uint16_t)(*input) << 8))));
    input++;
    stmp = tmp / 2;
    *output++ = (((uint16_t)((uint16_t)((uint16_t)(stmp) >> 8) | (uint16_t)((uint16_t)(stmp) << 8))));
  }
  return length / 2;
}
```