user: 请从给定的汇编指令推导出C源代码：

```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    L16
  mov    $0x0,%eax
  jmp    L240
L16:
  mov    -0x30(%rbp),%rax
  cmp    -0x48(%rbp),%rax
  setb   %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <__glibc_unlikely@plt>
  test   %rax,%rax
  je     L87
  movq   $0xffffffffffffffff,-0x30(%rbp)
L87:
  mov    -0x48(%rbp),%rax
  mov    %rax,-0x38(%rbp)
  jmp    L176
L148:
  mov    -0x38(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L262
  mov    -0x38(%rbp),%rax
  cmp    -0x30(%rbp),%rax
  jbe    L207
  mov    -0x30(%rbp),%rax
  mov    %rax,-0x38(%rbp)
L207:
  mov    -0x38(%rbp),%rax
  sub    -0x48(%rbp),%rax
  jmp    L240
L262:
  addq   $0x1,-0x38(%rbp)
L176:
  mov    -0x38(%rbp),%rax
  and    $0x7,%eax
  test   %rax,%rax
  jne    L148
  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    L242
L127:
  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     L108
  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     L184
  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     L185
  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     L83
  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     L11
  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     L165
  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     L174
  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     L65
  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     L221
L108:
  mov    -0x30(%rbp),%rax
  mov    %rax,-0x38(%rbp)
L242:
  mov    -0x28(%rbp),%rax
  cmp    -0x30(%rbp),%rax
  jb     L127
  jmp    L79
L184:
  nop
  jmp    L79
L185:
  nop
  jmp    L79
L83:
  nop
  jmp    L79
L11:
  nop
  jmp    L79
L165:
  nop
  jmp    L79
L174:
  nop
  jmp    L79
L65:
  nop
  jmp    L79
L221:
  nop
L79:
  mov    -0x38(%rbp),%rax
  cmp    -0x30(%rbp),%rax
  jbe    L50
  mov    -0x30(%rbp),%rax
  mov    %rax,-0x38(%rbp)
L50:
  mov    -0x38(%rbp),%rax
  sub    -0x48(%rbp),%rax
L240:
  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 (__glibc_unlikely(end_ptr < str))
    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;
}
```