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

```asm
<__strnlen>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x48(%rbp)
  mov    %rsi,-0x50(%rbp)
  mov    -0x48(%rbp),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x38(%rbp)
  cmpq   $0x0,-0x50(%rbp)
  jne    L218
  mov    $0x0,%eax
  jmp    L61
L218:
  mov    -0x38(%rbp),%rax
  cmp    -0x48(%rbp),%rax
  setb   %al
  movzbl %al,%eax
  mov    $0x0,%esi
  mov    %eax,%edi
  call   <__builtin_expect@plt>
  test   %rax,%rax
  je     L149
  movq   $0xffffffffffffffff,-0x38(%rbp)
L149:
  mov    -0x48(%rbp),%rax
  mov    %rax,-0x40(%rbp)
  jmp    L143
L234:
  mov    -0x40(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L187
  mov    -0x40(%rbp),%rax
  cmp    -0x38(%rbp),%rax
  jbe    L80
  mov    -0x38(%rbp),%rax
  mov    %rax,-0x40(%rbp)
L80:
  mov    -0x40(%rbp),%rax
  sub    -0x48(%rbp),%rax
  jmp    L61
L187:
  addq   $0x1,-0x40(%rbp)
L143:
  mov    -0x40(%rbp),%rax
  and    $0x7,%eax
  test   %rax,%rax
  jne    L234
  mov    -0x40(%rbp),%rax
  mov    %rax,-0x30(%rbp)
  movq   $0x7efefeff,-0x28(%rbp)
  mov    $0x80808080,%eax
  mov    %rax,-0x20(%rbp)
  movq   $0x1010101,-0x18(%rbp)
  movabs $0x7efefefefefefeff,%rax
  mov    %rax,-0x28(%rbp)
  mov    -0x20(%rbp),%rax
  shl    $0x20,%rax
  or     %rax,-0x20(%rbp)
  mov    -0x18(%rbp),%rax
  shl    $0x20,%rax
  or     %rax,-0x18(%rbp)
  jmp    L138
L240:
  mov    -0x30(%rbp),%rax
  lea    0x8(%rax),%rdx
  mov    %rdx,-0x30(%rbp)
  mov    (%rax),%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x10(%rbp),%rax
  sub    -0x18(%rbp),%rax
  and    -0x20(%rbp),%rax
  test   %rax,%rax
  je     L126
  mov    -0x30(%rbp),%rax
  sub    $0x8,%rax
  mov    %rax,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  mov    %rax,-0x40(%rbp)
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L42
  mov    -0x8(%rbp),%rax
  add    $0x1,%rax
  mov    %rax,-0x40(%rbp)
  mov    -0x8(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L73
  mov    -0x8(%rbp),%rax
  add    $0x2,%rax
  mov    %rax,-0x40(%rbp)
  mov    -0x8(%rbp),%rax
  add    $0x2,%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L35
  mov    -0x8(%rbp),%rax
  add    $0x3,%rax
  mov    %rax,-0x40(%rbp)
  mov    -0x8(%rbp),%rax
  add    $0x3,%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L271
  mov    -0x8(%rbp),%rax
  add    $0x4,%rax
  mov    %rax,-0x40(%rbp)
  mov    -0x8(%rbp),%rax
  add    $0x4,%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L180
  mov    -0x8(%rbp),%rax
  add    $0x5,%rax
  mov    %rax,-0x40(%rbp)
  mov    -0x8(%rbp),%rax
  add    $0x5,%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L257
  mov    -0x8(%rbp),%rax
  add    $0x6,%rax
  mov    %rax,-0x40(%rbp)
  mov    -0x8(%rbp),%rax
  add    $0x6,%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L227
  mov    -0x8(%rbp),%rax
  add    $0x7,%rax
  mov    %rax,-0x40(%rbp)
  mov    -0x8(%rbp),%rax
  add    $0x7,%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L134
L126:
  mov    -0x38(%rbp),%rax
  mov    %rax,-0x40(%rbp)
L138:
  mov    -0x30(%rbp),%rax
  cmp    -0x38(%rbp),%rax
  jb     L240
  jmp    L119
L42:
  nop
  jmp    L119
L73:
  nop
  jmp    L119
L35:
  nop
  jmp    L119
L271:
  nop
  jmp    L119
L180:
  nop
  jmp    L119
L257:
  nop
  jmp    L119
L227:
  nop
  jmp    L119
L134:
  nop
L119:
  mov    -0x40(%rbp),%rax
  cmp    -0x38(%rbp),%rax
  jbe    L243
  mov    -0x38(%rbp),%rax
  mov    %rax,-0x40(%rbp)
L243:
  mov    -0x40(%rbp),%rax
  sub    -0x48(%rbp),%rax
L61:
  leave
  ret
```

assistant: ```c
size_t __strnlen(const char *str, size_t maxlen) {
  const char *char_ptr, *end_ptr = str + maxlen;
  const unsigned long int *longword_ptr;
  unsigned long int longword, magic_bits, himagic, lomagic;
  if (maxlen == 0)
    return 0;
  if (__builtin_expect(end_ptr < str, 0))
    end_ptr = (const char *)~0UL;
  for (char_ptr = str; ((unsigned long int)char_ptr & (sizeof(longword) - 1)) != 0; ++char_ptr)
    if (*char_ptr == '\0') {
      if (char_ptr > end_ptr)
        char_ptr = end_ptr;
      return char_ptr - str;
    }
  longword_ptr = (unsigned long int *)char_ptr;
  magic_bits = 0x7efefeffL;
  himagic = 0x80808080L;
  lomagic = 0x01010101L;
  if (sizeof(longword) > 4) {
    magic_bits = ((0x7efefefeL << 16) << 16) | 0xfefefeffL;
    himagic = ((himagic << 16) << 16) | himagic;
    lomagic = ((lomagic << 16) << 16) | lomagic;
  }
  if (sizeof(longword) > 8)
    abort();
  while (longword_ptr < (unsigned long int *)end_ptr) {
    longword = *longword_ptr++;
    if ((longword - lomagic) & himagic) {
      const char *cp = (const char *)(longword_ptr - 1);
      char_ptr = cp;
      if (cp[0] == 0)
        break;
      char_ptr = cp + 1;
      if (cp[1] == 0)
        break;
      char_ptr = cp + 2;
      if (cp[2] == 0)
        break;
      char_ptr = cp + 3;
      if (cp[3] == 0)
        break;
      if (sizeof(longword) > 4) {
        char_ptr = cp + 4;
        if (cp[4] == 0)
          break;
        char_ptr = cp + 5;
        if (cp[5] == 0)
          break;
        char_ptr = cp + 6;
        if (cp[6] == 0)
          break;
        char_ptr = cp + 7;
        if (cp[7] == 0)
          break;
      }
    }
    char_ptr = end_ptr;
  }
  if (char_ptr > end_ptr)
    char_ptr = end_ptr;
  return char_ptr - str;
}
```