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

```asm
<do_x_filter16>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x38,%rsp
  mov    %rsi,0x18(%rsp)
  mov    %edx,0x20(%rsp)
  mov    %ecx,0x24(%rsp)
  mov    %r8,0x8(%rsp)
  mov    %r9d,(%rsp)
  test   %rdi,%rdi
  je     L176
  mov    %rsi,%rdi
  test   %rsi,%rsi
  je     L176
  mov    %ecx,%r14d
  imul   %edx,%ecx
  xor    %esi,%esi
  mov    %ecx,%edx
  add    %edx,%edx
  call   <memset@plt>
  test   %r14d,%r14d
  mov    (%rsp),%r9d
  mov    0x8(%rsp),%r8
  jle    L46
  mov    %r9d,%eax
  mov    0x20(%rsp),%edx
  shr    $0x1f,%eax
  add    %r9d,%eax
  sar    %eax
  sub    %eax,%edx
  cmp    %eax,%edx
  jle    L46
  lea    -0x1(%r9),%edi
  mov    %r9d,%ecx
  sub    %eax,%edx
  mov    %r9d,%r12d
  mov    %edi,0x8(%rsp)
  shr    $0x3,%ecx
  movslq %eax,%rdi
  lea    -0x1(%rdx),%eax
  lea    -0x1(%rcx),%r10d
  mov    %rdi,0x28(%rsp)
  and    $0xfffffff8,%r12d
  xor    %ebp,%ebp
  movl   $0x0,0x14(%rsp)
  add    $0x1,%r10
  mov    %rax,(%rsp)
  shl    $0x4,%r10
  nopl   0x0(%rax,%rax,1)
L120:
  mov    0x18(%rsp),%rdi
  movslq %ebp,%rax
  lea    (%rbx,%rax,2),%rsi
  add    0x28(%rsp),%rax
  lea    (%rdi,%rax,2),%r13
  xor    %edi,%edi
  nopw   0x0(%rax,%rax,1)
L45:
  xor    %eax,%eax
  test   %r9d,%r9d
  jle    L146
  cmpl   $0x6,0x8(%rsp)
  mov    %edi,%edx
  jbe    L31
  xor    %eax,%eax
  pxor   %xmm1,%xmm1
  xchg   %ax,%ax
L122:
  movdqu (%rsi,%rax,1),%xmm0
  movdqu (%r8,%rax,1),%xmm2
  add    $0x10,%rax
  pmaddwd %xmm2,%xmm0
  paddd  %xmm0,%xmm1
  cmp    %rax,%r10
  jne    L122
  movdqa %xmm1,%xmm0
  psrldq $0x8,%xmm0
  paddd  %xmm0,%xmm1
  movdqa %xmm1,%xmm0
  psrldq $0x4,%xmm0
  paddd  %xmm0,%xmm1
  movd   %xmm1,%eax
  cmp    %r9d,%r12d
  je     L66
  mov    %r12d,%ecx
L145:
  lea    (%rcx,%rdx,1),%r11d
  movslq %ecx,%r15
  add    %ebp,%r11d
  lea    (%r15,%r15,1),%r14
  movswl (%r8,%r15,2),%r15d
  movslq %r11d,%r11
  movswl (%rbx,%r11,2),%r11d
  imul   %r15d,%r11d
  add    %r11d,%eax
  lea    0x1(%rcx),%r11d
  cmp    %r11d,%r9d
  jle    L66
  add    %edx,%r11d
  movswl 0x2(%r8,%r14,1),%r15d
  add    %ebp,%r11d
  movslq %r11d,%r11
  movswl (%rbx,%r11,2),%r11d
  imul   %r15d,%r11d
  add    %r11d,%eax
  lea    0x2(%rcx),%r11d
  cmp    %r11d,%r9d
  jle    L66
  add    %edx,%r11d
  movswl 0x4(%r8,%r14,1),%r15d
  add    %ebp,%r11d
  movslq %r11d,%r11
  movswl (%rbx,%r11,2),%r11d
  imul   %r15d,%r11d
  add    %r11d,%eax
  lea    0x3(%rcx),%r11d
  cmp    %r11d,%r9d
  jle    L66
  add    %edx,%r11d
  movswl 0x6(%r8,%r14,1),%r15d
  add    %ebp,%r11d
  movslq %r11d,%r11
  movswl (%rbx,%r11,2),%r11d
  imul   %r15d,%r11d
  add    %r11d,%eax
  lea    0x4(%rcx),%r11d
  cmp    %r11d,%r9d
  jle    L66
  add    %edx,%r11d
  movswl 0x8(%r8,%r14,1),%r15d
  add    %ebp,%r11d
  movslq %r11d,%r11
  movswl (%rbx,%r11,2),%r11d
  imul   %r15d,%r11d
  add    %r11d,%eax
  lea    0x5(%rcx),%r11d
  cmp    %r11d,%r9d
  jle    L66
  add    %edx,%r11d
  movswl 0xa(%r8,%r14,1),%r15d
  add    $0x6,%ecx
  add    %ebp,%r11d
  movslq %r11d,%r11
  movswl (%rbx,%r11,2),%r11d
  imul   %r15d,%r11d
  add    %r11d,%eax
  cmp    %ecx,%r9d
  jle    L66
  add    %ecx,%edx
  movswl 0xc(%r8,%r14,1),%ecx
  add    %ebp,%edx
  movslq %edx,%rdx
  movswl (%rbx,%rdx,2),%edx
  imul   %ecx,%edx
  add    %edx,%eax
L66:
  cltd
  idivl  0x70(%rsp)
L146:
  mov    %ax,0x0(%r13,%rdi,2)
  add    $0x2,%rsi
  lea    0x1(%rdi),%rax
  cmp    (%rsp),%rdi
  je     L52
  mov    %rax,%rdi
  jmp    L45
L176:
  add    $0x38,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L52:
  addl   $0x1,0x14(%rsp)
  add    0x20(%rsp),%ebp
  mov    0x14(%rsp),%eax
  cmp    %eax,0x24(%rsp)
  jne    L120
L46:
  add    $0x38,%rsp
  mov    $0x1,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L31:
  xor    %eax,%eax
  xor    %ecx,%ecx
  jmp    L145
```

assistant: ```c
int do_x_filter16(short *src, short *dst, int w, int h, short *mask, int mw, int norm) {
  int i, j, s;
  int tmp;
  if (src == NULL || dst == NULL)
    return 0;
  memset(dst, 0, h * w * sizeof(short));
  for (j = 0; j < h; j++) {
    for (i = mw / 2; i < w - mw / 2; i++) {
      tmp = 0;
      for (s = 0; s < mw; s++) {
        tmp += mask[s] * src[j * w + (i - mw / 2 + s)];
      }
      dst[j * w + i] = (short)(tmp / norm);
    }
  }
  return 1;
}
```