user: Please show me the C implementation that matches the assembly code listed below:

```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,-0x30(%rbp)
  cmpq   $0x0,-0x50(%rbp)
  jne    L160
  mov    $0x0,%eax
  jmp    L223
L160:
  mov    -0x30(%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     L62
  movq   $0xffffffffffffffff,-0x30(%rbp)
L62:
  mov    -0x48(%rbp),%rax
  mov    %rax,-0x38(%rbp)
  jmp    L157
L244:
  mov    -0x38(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L261
  mov    -0x38(%rbp),%rax
  cmp    -0x30(%rbp),%rax
  jbe    L96
  mov    -0x30(%rbp),%rax
  mov    %rax,-0x38(%rbp)
L96:
  mov    -0x38(%rbp),%rax
  sub    -0x48(%rbp),%rax
  jmp    L223
L261:
  addq   $0x1,-0x38(%rbp)
L157:
  mov    -0x38(%rbp),%rax
  and    $0x7,%eax
  test   %rax,%rax
  jne    L244
  mov    -0x38(%rbp),%rax
  mov    %rax,-0x28(%rbp)
  mov    $0x80808080,%eax
  mov    %rax,-0x20(%rbp)
  movq   $0x1010101,-0x18(%rbp)
  mov    -0x20(%rbp),%rax
  shl    $0x20,%rax
  or     %rax,-0x20(%rbp)
  mov    -0x18(%rbp),%rax
  shl    $0x20,%rax
  or     %rax,-0x18(%rbp)
  jmp    L220
L179:
  mov    -0x28(%rbp),%rax
  lea    0x8(%rax),%rdx
  mov    %rdx,-0x28(%rbp)
  mov    (%rax),%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x10(%rbp),%rax
  sub    -0x18(%rbp),%rax
  and    -0x20(%rbp),%rax
  test   %rax,%rax
  je     L277
  mov    -0x28(%rbp),%rax
  sub    $0x8,%rax
  mov    %rax,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  mov    %rax,-0x38(%rbp)
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L141
  mov    -0x8(%rbp),%rax
  add    $0x1,%rax
  mov    %rax,-0x38(%rbp)
  mov    -0x8(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L92
  mov    -0x8(%rbp),%rax
  add    $0x2,%rax
  mov    %rax,-0x38(%rbp)
  mov    -0x8(%rbp),%rax
  add    $0x2,%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L239
  mov    -0x8(%rbp),%rax
  add    $0x3,%rax
  mov    %rax,-0x38(%rbp)
  mov    -0x8(%rbp),%rax
  add    $0x3,%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L101
  mov    -0x8(%rbp),%rax
  add    $0x4,%rax
  mov    %rax,-0x38(%rbp)
  mov    -0x8(%rbp),%rax
  add    $0x4,%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L256
  mov    -0x8(%rbp),%rax
  add    $0x5,%rax
  mov    %rax,-0x38(%rbp)
  mov    -0x8(%rbp),%rax
  add    $0x5,%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L193
  mov    -0x8(%rbp),%rax
  add    $0x6,%rax
  mov    %rax,-0x38(%rbp)
  mov    -0x8(%rbp),%rax
  add    $0x6,%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L30
  mov    -0x8(%rbp),%rax
  add    $0x7,%rax
  mov    %rax,-0x38(%rbp)
  mov    -0x8(%rbp),%rax
  add    $0x7,%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L14
L277:
  mov    -0x30(%rbp),%rax
  mov    %rax,-0x38(%rbp)
L220:
  mov    -0x28(%rbp),%rax
  cmp    -0x30(%rbp),%rax
  jb     L179
  jmp    L110
L141:
  nop
  jmp    L110
L92:
  nop
  jmp    L110
L239:
  nop
  jmp    L110
L101:
  nop
  jmp    L110
L256:
  nop
  jmp    L110
L193:
  nop
  jmp    L110
L30:
  nop
  jmp    L110
L14:
  nop
L110:
  mov    -0x38(%rbp),%rax
  cmp    -0x30(%rbp),%rax
  jbe    L13
  mov    -0x30(%rbp),%rax
  mov    %rax,-0x38(%rbp)
L13:
  mov    -0x38(%rbp),%rax
  sub    -0x48(%rbp),%rax
L223:
  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, 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;
  himagic = 0x80808080L;
  lomagic = 0x01010101L;
  if (sizeof(longword) > 4) {
    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;
}
```