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

```asm
<check>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x58(%rbp)
  mov    %rsi,-0x60(%rbp)
  mov    %edx,-0x64(%rbp)
  mov    %ecx,-0x68(%rbp)
  mov    %r8d,-0x6c(%rbp)
  movl   $0x0,-0x44(%rbp)
  movl   $0x0,-0x40(%rbp)
  mov    -0x58(%rbp),%rax
  mov    %rax,-0x30(%rbp)
  mov    -0x60(%rbp),%rax
  mov    %rax,-0x28(%rbp)
  mov    -0x58(%rbp),%rax
  mov    %rax,-0x20(%rbp)
  mov    -0x60(%rbp),%rax
  mov    %rax,-0x18(%rbp)
  mov    -0x58(%rbp),%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x60(%rbp),%rax
  mov    %rax,-0x8(%rbp)
  cmpl   $0x1,-0x64(%rbp)
  je     L137
  cmpl   $0x2,-0x64(%rbp)
  je     L137
  cmpl   $0x4,-0x64(%rbp)
  je     L137
  mov    $0x1,%eax
  (bad)
L137:
  cmpl   $0x0,-0x6c(%rbp)
  je     L136
  mov    -0x68(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0x3c(%rbp)
  movl   $0x0,-0x38(%rbp)
  movl   $0xffffffff,-0x34(%rbp)
  jmp    L109
L136:
  movl   $0x0,-0x3c(%rbp)
  mov    -0x68(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0x38(%rbp)
  movl   $0x1,-0x34(%rbp)
L109:
  mov    -0x3c(%rbp),%eax
  mov    %eax,-0x48(%rbp)
  jmp    L7
L96:
  cmpl   $0x4,-0x64(%rbp)
  je     L43
  cmpl   $0x4,-0x64(%rbp)
  jg     L78
  cmpl   $0x1,-0x64(%rbp)
  je     L37
  cmpl   $0x2,-0x64(%rbp)
  je     L0
  jmp    L78
L37:
  mov    -0x30(%rbp),%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    %eax,-0x44(%rbp)
  mov    -0x28(%rbp),%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    %eax,-0x40(%rbp)
  mov    -0x34(%rbp),%eax
  cltq
  add    %rax,-0x30(%rbp)
  mov    -0x34(%rbp),%eax
  cltq
  add    %rax,-0x28(%rbp)
  jmp    L78
L0:
  mov    -0x20(%rbp),%rax
  movzwl (%rax),%eax
  movzwl %ax,%eax
  mov    %eax,-0x44(%rbp)
  mov    -0x18(%rbp),%rax
  movzwl (%rax),%eax
  movzwl %ax,%eax
  mov    %eax,-0x40(%rbp)
  mov    -0x34(%rbp),%eax
  cltq
  add    %rax,%rax
  add    %rax,-0x20(%rbp)
  mov    -0x34(%rbp),%eax
  cltq
  add    %rax,%rax
  add    %rax,-0x18(%rbp)
  jmp    L78
L43:
  mov    -0x10(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,-0x44(%rbp)
  mov    -0x8(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,-0x40(%rbp)
  mov    -0x34(%rbp),%eax
  cltq
  shl    $0x2,%rax
  add    %rax,-0x10(%rbp)
  mov    -0x34(%rbp),%eax
  cltq
  shl    $0x2,%rax
  add    %rax,-0x8(%rbp)
  nop
L78:
  mov    -0x44(%rbp),%eax
  cmp    -0x40(%rbp),%eax
  je     L149
  mov    -0x48(%rbp),%eax
  jmp    L72
L149:
  mov    -0x34(%rbp),%eax
  add    %eax,-0x48(%rbp)
L7:
  cmpl   $0x1,-0x34(%rbp)
  jne    L46
  mov    -0x48(%rbp),%eax
  cmp    -0x38(%rbp),%eax
  jle    L96
L46:
  cmpl   $0xffffffff,-0x34(%rbp)
  jne    L23
  mov    -0x48(%rbp),%eax
  cmp    -0x38(%rbp),%eax
  jge    L96
L23:
  mov    $0xffffffff,%eax
L72:
  pop    %rbp
  ret
```

assistant: ```c
int check(void *p1, void *p2, int val_size, int n, int df) {
  int i;
  unsigned int a = 0, b = 0;
  unsigned char *p1_char = p1, *p2_char = p2;
  unsigned short *p1_short = p1, *p2_short = p2;
  unsigned int *p1_int = p1, *p2_int = p2;
  do {
    if (!(val_size == 1 || val_size == 2 || val_size == 4))
      asm volatile(".byte 0xd6" : : "a"(1));
  } while (0);
  int st, ed, step;
  if (df) {
    st = n - 1;
    ed = 0;
    step = -1;
  } else {
    st = 0;
    ed = n - 1;
    step = 1;
  }
  for (i = st; (step == 1 && i <= ed) || (step == -1 && i >= ed); i += step) {
    switch (val_size) {
    case 1:
      a = *p1_char;
      b = *p2_char;
      p1_char += step;
      p2_char += step;
      break;
    case 2:
      a = *p1_short;
      b = *p2_short;
      p1_short += step;
      p2_short += step;
      break;
    case 4:
      a = *p1_int;
      b = *p2_int;
      p1_int += step;
      p2_int += step;
      break;
    }
    if (a != b) {
      return i;
    }
  }
  return -1;
}
```