user: 这段汇编代码用C语言表示是什么样的：

```asm
<__strnlen>:
  endbr64
  mov    %rsi,%rax
  test   %rsi,%rsi
  jne    L42
  ret
  nopl   (%rax)
L42:
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  sub    $0x8,%rsp
  add    %rdi,%rax
  setb   %dil
  xor    %esi,%esi
  mov    %rax,%rbx
  movzbl %dil,%edi
  call   <__builtin_expect@plt>
  mov    %rbp,%rdx
  test   %rax,%rax
  mov    $0xffffffffffffffff,%rax
  cmovne %rax,%rbx
  test   $0x7,%bpl
  jne    L164
  jmp    L61
  nopw   0x0(%rax,%rax,1)
L124:
  add    $0x1,%rdx
  test   $0x7,%dl
  je     L61
L164:
  cmpb   $0x0,(%rdx)
  jne    L124
  cmp    %rdx,%rbx
  cmova  %rdx,%rbx
  add    $0x8,%rsp
  mov    %rbx,%rax
  pop    %rbx
  sub    %rbp,%rax
  pop    %rbp
  ret
  nopw   0x0(%rax,%rax,1)
L61:
  cmp    %rdx,%rbx
  jbe    L85
  movabs $0xfefefefefefefeff,%rdi
  movabs $0x8080808080808080,%rsi
  nopl   (%rax)
L137:
  mov    %rdx,%rcx
  mov    (%rdx),%rax
  add    $0x8,%rdx
  add    %rdi,%rax
  test   %rsi,%rax
  je     L148
  cmpb   $0x0,-0x8(%rdx)
  je     L19
  cmpb   $0x0,-0x7(%rdx)
  je     L228
  cmpb   $0x0,-0x6(%rdx)
  je     L34
  cmpb   $0x0,-0x5(%rdx)
  je     L203
  cmpb   $0x0,-0x4(%rdx)
  je     L166
  cmpb   $0x0,-0x3(%rdx)
  je     L33
  cmpb   $0x0,-0x2(%rdx)
  je     L5
  cmpb   $0x0,-0x1(%rdx)
  je     L11
L148:
  cmp    %rdx,%rbx
  ja     L137
L156:
  mov    %rbx,%rax
  add    $0x8,%rsp
  sub    %rbp,%rax
  pop    %rbx
  pop    %rbp
  ret
L11:
  add    $0x7,%rcx
L19:
  cmp    %rcx,%rbx
  cmova  %rcx,%rbx
  jmp    L156
L228:
  add    $0x1,%rcx
  cmp    %rcx,%rbx
  cmova  %rcx,%rbx
  jmp    L156
L34:
  add    $0x2,%rcx
  cmp    %rcx,%rbx
  cmova  %rcx,%rbx
  jmp    L156
L203:
  add    $0x3,%rcx
  cmp    %rcx,%rbx
  cmova  %rcx,%rbx
  jmp    L156
L166:
  add    $0x4,%rcx
  cmp    %rcx,%rbx
  cmova  %rcx,%rbx
  jmp    L156
L33:
  add    $0x5,%rcx
  cmp    %rcx,%rbx
  cmova  %rcx,%rbx
  jmp    L156
L5:
  add    $0x6,%rcx
  cmp    %rcx,%rbx
  cmova  %rcx,%rbx
  jmp    L156
L85:
  cmova  %rdx,%rbx
  jmp    L156
```

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;
}
```