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

```asm
<calculate_checksum>:
  endbr64
  push   %r14
  push   %r13
  mov    %rdi,%r13
  push   %r12
  movslq %esi,%r12
  mov    %r12d,%eax
  push   %rbp
  sar    $0x3,%eax
  push   %rbx
  test   %eax,%eax
  jle    L122
  movslq %eax,%rbp
  mov    %rdi,%r14
  xor    %ebx,%ebx
  nopl   0x0(%rax,%rax,1)
L98:
  mov    (%r14),%edi
  xor    %esi,%esi
  add    $0x4,%r14
  call   <_m_psadbw@plt>
  xor    %esi,%esi
  mov    %eax,%edi
  call   <_mm_extract_pi16@plt>
  add    %rax,%rbx
  sub    $0x1,%rbp
  jne    L98
L101:
  mov    %r12d,%edx
  and    $0xfffffff8,%edx
  movslq %edx,%rdx
  cmp    %r12,%rdx
  jge    L157
  mov    %r12,%rsi
  sub    %rdx,%rsi
  lea    -0x1(%rsi),%rax
  cmp    $0xe,%rax
  jbe    L158
  lea    0x0(%r13,%rdx,1),%rax
  pxor   %xmm5,%xmm5
  pxor   %xmm4,%xmm4
  mov    %rsi,%rcx
  and    $0xfffffffffffffff0,%rcx
  pxor   %xmm9,%xmm9
  pxor   %xmm3,%xmm3
  add    %rax,%rcx
  cs nopw 0x0(%rax,%rax,1)
L35:
  movdqu (%rax),%xmm1
  movdqa %xmm5,%xmm6
  movdqa %xmm4,%xmm7
  add    $0x10,%rax
  movdqa %xmm4,%xmm8
  pcmpgtb %xmm1,%xmm6
  movdqa %xmm1,%xmm2
  punpcklbw %xmm6,%xmm2
  punpckhbw %xmm6,%xmm1
  pcmpgtw %xmm2,%xmm7
  pcmpgtw %xmm1,%xmm8
  movdqa %xmm2,%xmm6
  punpcklwd %xmm7,%xmm6
  punpckhwd %xmm7,%xmm2
  movdqa %xmm1,%xmm7
  punpcklwd %xmm8,%xmm7
  punpckhwd %xmm8,%xmm1
  movdqa %xmm3,%xmm8
  pcmpgtd %xmm6,%xmm8
  movdqa %xmm6,%xmm0
  punpckldq %xmm8,%xmm0
  punpckhdq %xmm8,%xmm6
  movdqa %xmm2,%xmm8
  paddq  %xmm9,%xmm0
  paddq  %xmm6,%xmm0
  movdqa %xmm3,%xmm6
  pcmpgtd %xmm2,%xmm6
  punpckhdq %xmm6,%xmm2
  punpckldq %xmm6,%xmm8
  movdqa %xmm3,%xmm6
  pcmpgtd %xmm7,%xmm6
  paddq  %xmm8,%xmm0
  paddq  %xmm2,%xmm0
  movdqa %xmm7,%xmm2
  punpckldq %xmm6,%xmm2
  paddq  %xmm2,%xmm0
  movdqa %xmm7,%xmm2
  punpckhdq %xmm6,%xmm2
  movdqa %xmm1,%xmm6
  paddq  %xmm2,%xmm0
  movdqa %xmm3,%xmm2
  pcmpgtd %xmm1,%xmm2
  punpckldq %xmm2,%xmm6
  punpckhdq %xmm2,%xmm1
  paddq  %xmm6,%xmm0
  paddq  %xmm1,%xmm0
  movdqa %xmm0,%xmm9
  cmp    %rcx,%rax
  jne    L35
  psrldq $0x8,%xmm0
  paddq  %xmm9,%xmm0
  movq   %xmm0,%rax
  add    %rax,%rbx
  mov    %rsi,%rax
  and    $0xfffffffffffffff0,%rax
  add    %rax,%rdx
  cmp    %rsi,%rax
  je     L157
L158:
  movsbq 0x0(%r13,%rdx,1),%rax
  add    %rax,%rbx
  lea    0x1(%rdx),%rax
  cmp    %r12,%rax
  jge    L157
  movsbq 0x1(%r13,%rdx,1),%rax
  add    %rax,%rbx
  lea    0x2(%rdx),%rax
  cmp    %rax,%r12
  jle    L157
  movsbq 0x2(%r13,%rdx,1),%rax
  add    %rax,%rbx
  lea    0x3(%rdx),%rax
  cmp    %rax,%r12
  jle    L157
  movsbq 0x3(%r13,%rdx,1),%rax
  add    %rax,%rbx
  lea    0x4(%rdx),%rax
  cmp    %rax,%r12
  jle    L157
  movsbq 0x4(%r13,%rdx,1),%rax
  add    %rax,%rbx
  lea    0x5(%rdx),%rax
  cmp    %rax,%r12
  jle    L157
  movsbq 0x5(%r13,%rdx,1),%rax
  add    %rax,%rbx
  lea    0x6(%rdx),%rax
  cmp    %rax,%r12
  jle    L157
  movsbq 0x6(%r13,%rdx,1),%rax
  add    %rax,%rbx
  lea    0x7(%rdx),%rax
  cmp    %rax,%r12
  jle    L157
  movsbq 0x7(%r13,%rdx,1),%rax
  add    %rax,%rbx
  lea    0x8(%rdx),%rax
  cmp    %rax,%r12
  jle    L157
  movsbq 0x8(%r13,%rdx,1),%rax
  add    %rax,%rbx
  lea    0x9(%rdx),%rax
  cmp    %rax,%r12
  jle    L157
  movsbq 0x9(%r13,%rdx,1),%rax
  add    %rax,%rbx
  lea    0xa(%rdx),%rax
  cmp    %rax,%r12
  jle    L157
  movsbq 0xa(%r13,%rdx,1),%rax
  add    %rax,%rbx
  lea    0xb(%rdx),%rax
  cmp    %rax,%r12
  jle    L157
  movsbq 0xb(%r13,%rdx,1),%rax
  add    %rax,%rbx
  lea    0xc(%rdx),%rax
  cmp    %rax,%r12
  jle    L157
  movsbq 0xc(%r13,%rdx,1),%rax
  add    %rax,%rbx
  lea    0xd(%rdx),%rax
  cmp    %rax,%r12
  jle    L157
  movsbq 0xd(%r13,%rdx,1),%rax
  add    %rax,%rbx
  lea    0xe(%rdx),%rax
  cmp    %rax,%r12
  jle    L157
  movsbq 0xe(%r13,%rdx,1),%rax
  add    %rax,%rbx
L157:
  movzbl %bl,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nopl   0x0(%rax)
L122:
  xor    %ebx,%ebx
  jmp    L101
```

assistant: ```c
int calculate_checksum(const char *buf, int buf_len) {
  register long int sum = 0;
  register long int ii;
  int extra;
  __m64 zero = (__m64)0LL;
  __m64 dest;
  __m64 *pointer;
  extra = buf_len & 0x07;
  ii = buf_len >> 3;
  pointer = (__m64 *)buf;
  while (ii > 0) {
    dest = _m_psadbw(*pointer, zero);
    sum += _mm_extract_pi16(dest, 0);
    ii--;
    pointer++;
  }
  for (ii = buf_len - extra; ii < buf_len; ii++)
    sum += buf[ii];
  return (int)(sum & 0xFF);
}
```