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

```asm
<SDL_imageFilterMultDivby2>:
  endbr64
  push   %r13
  mov    %rdx,%r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  test   %rsi,%rsi
  sete   %al
  test   %rdx,%rdx
  sete   %dl
  or     %dl,%al
  jne    L38
  mov    %rdi,%rbp
  test   %rdi,%rdi
  je     L38
  mov    %ecx,%r12d
  test   %ecx,%ecx
  jne    L235
L15:
  xor    %eax,%eax
L210:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   (%rax)
L235:
  xor    %eax,%eax
  mov    %rsi,%rbx
  call   <SDL_imageFilterMMXdetect@plt>
  test   %rax,%rax
  je     L133
  cmp    $0x7,%r12d
  ja     L50
L133:
  xor    %r8d,%r8d
L194:
  mov    %r12d,%edi
  lea    0x1(%r8),%esi
  lea    0x1(%rbx),%rcx
  sub    %r8d,%edi
  lea    -0x1(%rdi),%eax
  cmp    $0xe,%eax
  seta   %al
  cmp    %esi,%r12d
  setae  %dl
  and    %edx,%eax
  mov    %r13,%rdx
  sub    %rcx,%rdx
  cmp    $0xe,%rdx
  seta   %dl
  test   %dl,%al
  je     L124
  lea    0x1(%rbp),%rdx
  mov    %r13,%rax
  sub    %rdx,%rax
  cmp    $0xe,%rax
  jbe    L124
  cmp    %esi,%r12d
  pxor   %xmm4,%xmm4
  pxor   %xmm5,%xmm5
  mov    $0x1,%eax
  cmovb  %eax,%edi
  xor    %eax,%eax
  xor    %edx,%edx
  movdqa D6(%rip),%xmm6
  movdqa D18(%rip),%xmm3
  lea    -0x10(%rdi),%ecx
  shr    $0x4,%ecx
  add    $0x1,%ecx
  nopl   0x0(%rax)
L99:
  movdqu 0x0(%rbp,%rax,1),%xmm1
  movdqu (%rbx,%rax,1),%xmm2
  add    $0x1,%edx
  psrlw  $0x1,%xmm1
  movdqa %xmm2,%xmm7
  punpckhbw %xmm4,%xmm2
  pand   %xmm6,%xmm1
  punpcklbw %xmm4,%xmm7
  movdqa %xmm1,%xmm0
  punpckhbw %xmm4,%xmm1
  punpcklbw %xmm4,%xmm0
  pmullw %xmm1,%xmm2
  pmullw %xmm0,%xmm7
  movdqa %xmm2,%xmm1
  movdqa %xmm7,%xmm0
  psubusw %xmm3,%xmm1
  psubusw %xmm3,%xmm0
  pcmpeqw %xmm5,%xmm1
  pcmpeqw %xmm5,%xmm0
  pand   %xmm1,%xmm2
  pandn  %xmm3,%xmm1
  pand   %xmm0,%xmm7
  pandn  %xmm3,%xmm0
  por    %xmm2,%xmm1
  por    %xmm7,%xmm0
  pand   %xmm3,%xmm1
  pand   %xmm3,%xmm0
  packuswb %xmm1,%xmm0
  movups %xmm0,0x0(%r13,%rax,1)
  add    $0x10,%rax
  cmp    %edx,%ecx
  ja     L99
  shl    $0x4,%ecx
  mov    %ecx,%eax
  add    %rax,%rbp
  add    %rax,%rbx
  add    %r13,%rax
  cmp    %ecx,%edi
  je     L15
  movzbl 0x0(%rbp),%edx
  movzbl (%rbx),%edi
  shr    %dl
  movzbl %dl,%edx
  imul   %edi,%edx
  mov    $0xff,%edi
  cmp    %edi,%edx
  cmovg  %edi,%edx
  add    %esi,%ecx
  mov    %dl,(%rax)
  cmp    %ecx,%r12d
  jbe    L15
  movzbl 0x1(%rbp),%edx
  movzbl 0x1(%rbx),%esi
  shr    %dl
  movzbl %dl,%edx
  imul   %esi,%edx
  mov    $0xff,%esi
  cmp    %esi,%edx
  cmovg  %esi,%edx
  mov    %dl,0x1(%rax)
  lea    0x1(%rcx),%edx
  cmp    %edx,%r12d
  jbe    L15
  movzbl 0x2(%rbp),%edx
  movzbl 0x2(%rbx),%esi
  shr    %dl
  movzbl %dl,%edx
  imul   %esi,%edx
  mov    $0xff,%esi
  cmp    %esi,%edx
  cmovg  %esi,%edx
  mov    %dl,0x2(%rax)
  lea    0x2(%rcx),%edx
  cmp    %edx,%r12d
  jbe    L15
  movzbl 0x3(%rbp),%edx
  movzbl 0x3(%rbx),%esi
  shr    %dl
  movzbl %dl,%edx
  imul   %esi,%edx
  mov    $0xff,%esi
  cmp    %esi,%edx
  cmovg  %esi,%edx
  mov    %dl,0x3(%rax)
  lea    0x3(%rcx),%edx
  cmp    %edx,%r12d
  jbe    L15
  movzbl 0x4(%rbp),%edx
  movzbl 0x4(%rbx),%esi
  shr    %dl
  movzbl %dl,%edx
  imul   %esi,%edx
  mov    $0xff,%esi
  cmp    %esi,%edx
  cmovg  %esi,%edx
  mov    %dl,0x4(%rax)
  lea    0x4(%rcx),%edx
  cmp    %edx,%r12d
  jbe    L15
  movzbl 0x5(%rbp),%edx
  movzbl 0x5(%rbx),%esi
  shr    %dl
  movzbl %dl,%edx
  imul   %esi,%edx
  mov    $0xff,%esi
  cmp    %esi,%edx
  cmovg  %esi,%edx
  mov    %dl,0x5(%rax)
  lea    0x5(%rcx),%edx
  cmp    %edx,%r12d
  jbe    L15
  movzbl 0x6(%rbp),%edx
  movzbl 0x6(%rbx),%esi
  shr    %dl
  movzbl %dl,%edx
  imul   %esi,%edx
  mov    $0xff,%esi
  cmp    %esi,%edx
  cmovg  %esi,%edx
  mov    %dl,0x6(%rax)
  lea    0x6(%rcx),%edx
  cmp    %edx,%r12d
  jbe    L15
  movzbl 0x7(%rbp),%edx
  movzbl 0x7(%rbx),%esi
  shr    %dl
  movzbl %dl,%edx
  imul   %esi,%edx
  mov    $0xff,%esi
  cmp    %esi,%edx
  cmovg  %esi,%edx
  mov    %dl,0x7(%rax)
  lea    0x7(%rcx),%edx
  cmp    %edx,%r12d
  jbe    L15
  movzbl 0x8(%rbp),%edx
  movzbl 0x8(%rbx),%esi
  shr    %dl
  movzbl %dl,%edx
  imul   %esi,%edx
  mov    $0xff,%esi
  cmp    %esi,%edx
  cmovg  %esi,%edx
  mov    %dl,0x8(%rax)
  lea    0x8(%rcx),%edx
  cmp    %edx,%r12d
  jbe    L15
  movzbl 0x9(%rbp),%edx
  movzbl 0x9(%rbx),%esi
  shr    %dl
  movzbl %dl,%edx
  imul   %esi,%edx
  mov    $0xff,%esi
  cmp    %esi,%edx
  cmovg  %esi,%edx
  mov    %dl,0x9(%rax)
  lea    0x9(%rcx),%edx
  cmp    %edx,%r12d
  jbe    L15
  movzbl 0xa(%rbp),%edx
  movzbl 0xa(%rbx),%esi
  shr    %dl
  movzbl %dl,%edx
  imul   %esi,%edx
  mov    $0xff,%esi
  cmp    %esi,%edx
  cmovg  %esi,%edx
  mov    %dl,0xa(%rax)
  lea    0xa(%rcx),%edx
  cmp    %edx,%r12d
  jbe    L15
  movzbl 0xb(%rbp),%edx
  movzbl 0xb(%rbx),%esi
  shr    %dl
  movzbl %dl,%edx
  imul   %esi,%edx
  mov    $0xff,%esi
  cmp    %esi,%edx
  cmovg  %esi,%edx
  mov    %dl,0xb(%rax)
  lea    0xb(%rcx),%edx
  cmp    %edx,%r12d
  jbe    L15
  movzbl 0xc(%rbp),%edx
  movzbl 0xc(%rbx),%esi
  shr    %dl
  movzbl %dl,%edx
  imul   %esi,%edx
  mov    $0xff,%esi
  cmp    %esi,%edx
  cmovg  %esi,%edx
  mov    %dl,0xc(%rax)
  lea    0xc(%rcx),%edx
  cmp    %edx,%r12d
  jbe    L15
  movzbl 0xd(%rbp),%edx
  movzbl 0xd(%rbx),%esi
  shr    %dl
  movzbl %dl,%edx
  imul   %esi,%edx
  mov    $0xff,%esi
  cmp    %esi,%edx
  cmovg  %esi,%edx
  add    $0xd,%ecx
  mov    %dl,0xd(%rax)
  cmp    %ecx,%r12d
  jbe    L15
  movzbl 0xe(%rbp),%edx
  movzbl 0xe(%rbx),%ecx
  shr    %dl
  movzbl %dl,%edx
  imul   %ecx,%edx
  mov    $0xff,%ecx
  cmp    %ecx,%edx
  cmovg  %ecx,%edx
  mov    %dl,0xe(%rax)
  jmp    L15
  nopl   0x0(%rax,%rax,1)
L124:
  xor    %edx,%edx
  nopw   0x0(%rax,%rax,1)
L289:
  movzbl 0x0(%rbp,%rdx,1),%eax
  movzbl (%rbx,%rdx,1),%ecx
  shr    %al
  movzbl %al,%eax
  imul   %ecx,%eax
  mov    $0xff,%ecx
  cmp    %ecx,%eax
  cmovg  %ecx,%eax
  mov    %al,0x0(%r13,%rdx,1)
  add    $0x1,%rdx
  lea    (%r8,%rdx,1),%eax
  cmp    %eax,%r12d
  ja     L289
  jmp    L15
  nopw   0x0(%rax,%rax,1)
L50:
  mov    %r12d,%ecx
  mov    %r13,%rdx
  mov    %rbx,%rsi
  mov    %rbp,%rdi
  call   <SDL_imageFilterMultDivby2MMX@plt>
  test   $0x7,%r12b
  je     L15
  mov    %r12d,%r8d
  and    $0xfffffff8,%r8d
  cmp    %r8d,%r12d
  jbe    L15
  mov    %r8d,%eax
  add    %rax,%rbp
  add    %rax,%rbx
  add    %rax,%r13
  jmp    L194
L38:
  mov    $0xffffffff,%eax
  jmp    L210
```

tool_calls: name: disassemble_data
arguments: tag: D6
data_type: byte[16]
name: disassemble_data
arguments: tag: D18
data_type: byte[16]

tool: {"D6": [0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f]}

tool: {"D18": [0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00]}

assistant: ```c
int SDL_imageFilterMultDivby2(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length) {
  unsigned int i, istart;
  unsigned char *cursrc1, *cursrc2, *curdst;
  int result;
  if ((Src1 == NULL) || (Src2 == NULL) || (Dest == NULL))
    return (-1);
  if (length == 0)
    return (0);
  if ((SDL_imageFilterMMXdetect()) && (length > 7)) {
    SDL_imageFilterMultDivby2MMX(Src1, Src2, Dest, length);
    if ((length & 7) > 0) {
      istart = length & 0xfffffff8;
      cursrc1 = &Src1[istart];
      cursrc2 = &Src2[istart];
      curdst = &Dest[istart];
    } else {
      return (0);
    }
  } else {
    istart = 0;
    cursrc1 = Src1;
    cursrc2 = Src2;
    curdst = Dest;
  }
  for (i = istart; i < length; i++) {
    result = ((int)*cursrc1 / 2) * (int)*cursrc2;
    if (result > 255)
      result = 255;
    *curdst = (unsigned char)result;
    cursrc1++;
    cursrc2++;
    curdst++;
  }
  return (0);
}
```