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

```asm
<modestr>:
  endbr64
  push   %r12
  mov    %rsi,%r12
  push   %rbx
  mov    %edi,%ebx
  sub    $0x8,%rsp
  call   <S_ISBLK@plt>
  mov    %rax,%r8
  mov    $0x62,%eax
  test   %r8,%r8
  je     L9
L36:
  mov    %al,(%r12)
  mov    D18(%rip),%rax
  movb   $0x0,0xa(%r12)
  mov    (%rax),%edx
  and    %ebx,%edx
  cmp    $0x1,%edx
  sbb    %eax,%eax
  and    $0xffffffbb,%eax
  add    $0x72,%eax
  mov    %al,0x1(%r12)
  mov    D2(%rip),%rax
  mov    (%rax),%ecx
  and    %ebx,%ecx
  cmp    $0x1,%ecx
  sbb    %eax,%eax
  and    $0xffffffb6,%eax
  add    $0x77,%eax
  mov    %al,0x2(%r12)
  mov    D40(%rip),%rax
  mov    (%rax),%edx
  and    %ebx,%edx
  cmp    $0x1,%edx
  sbb    %eax,%eax
  and    $0xffffffb5,%eax
  add    $0x78,%eax
  mov    %al,0x3(%r12)
  mov    D45(%rip),%rax
  mov    (%rax),%ecx
  and    %ebx,%ecx
  cmp    $0x1,%ecx
  sbb    %eax,%eax
  and    $0xffffffbb,%eax
  add    $0x72,%eax
  mov    %al,0x4(%r12)
  mov    D64(%rip),%rax
  mov    (%rax),%esi
  and    %ebx,%esi
  cmp    $0x1,%esi
  sbb    %eax,%eax
  and    $0xffffffb6,%eax
  add    $0x77,%eax
  mov    %al,0x5(%r12)
  mov    D80(%rip),%rax
  mov    (%rax),%edi
  and    %ebx,%edi
  cmp    $0x1,%edi
  sbb    %eax,%eax
  and    $0xffffffb5,%eax
  add    $0x78,%eax
  mov    %al,0x6(%r12)
  mov    D32(%rip),%rax
  mov    (%rax),%edx
  and    %ebx,%edx
  cmp    $0x1,%edx
  sbb    %eax,%eax
  and    $0xffffffbb,%eax
  add    $0x72,%eax
  mov    %al,0x7(%r12)
  mov    D13(%rip),%rax
  mov    (%rax),%ecx
  and    %ebx,%ecx
  cmp    $0x1,%ecx
  sbb    %eax,%eax
  and    $0xffffffb6,%eax
  add    $0x77,%eax
  mov    %al,0x8(%r12)
  mov    D4(%rip),%rax
  and    (%rax),%ebx
  cmp    $0x1,%ebx
  sbb    %eax,%eax
  and    $0xffffffb5,%eax
  add    $0x78,%eax
  mov    %al,0x9(%r12)
  add    $0x8,%rsp
  mov    %r12,%rax
  pop    %rbx
  pop    %r12
  ret
  nopl   0x0(%rax)
L9:
  mov    %ebx,%edi
  call   <S_ISCHR@plt>
  mov    %rax,%r8
  mov    $0x63,%eax
  test   %r8,%r8
  jne    L36
  mov    %ebx,%edi
  call   <S_ISDIR@plt>
  mov    %rax,%r8
  mov    $0x64,%eax
  test   %r8,%r8
  jne    L36
  mov    %ebx,%edi
  call   <S_ISLNK@plt>
  mov    %rax,%r8
  mov    $0x6c,%eax
  test   %r8,%r8
  jne    L36
  mov    %ebx,%edi
  call   <S_ISFIFO@plt>
  mov    %rax,%r8
  mov    $0x70,%eax
  test   %r8,%r8
  jne    L36
  mov    %ebx,%edi
  call   <S_ISSOCK@plt>
  cmp    $0x1,%rax
  sbb    %eax,%eax
  and    $0xffffffba,%eax
  add    $0x73,%eax
  jmp    L36
```

assistant: ```c
char *modestr(mode_t mode_bits, char *mode_str) {
  if (S_ISBLK(mode_bits))
    mode_str[0] = 'b';
  else if (S_ISCHR(mode_bits))
    mode_str[0] = 'c';
  else if (S_ISDIR(mode_bits))
    mode_str[0] = 'd';
  else if (S_ISLNK(mode_bits))
    mode_str[0] = 'l';
  else if (S_ISFIFO(mode_bits))
    mode_str[0] = 'p';
  else if (S_ISSOCK(mode_bits))
    mode_str[0] = 's';
  else
    mode_str[0] = '-';
  mode_str[1] = S_IRUSR & mode_bits ? 'r' : '-';
  mode_str[2] = S_IWUSR & mode_bits ? 'w' : '-';
  mode_str[3] = S_IXUSR & mode_bits ? 'x' : '-';
  mode_str[4] = S_IRGRP & mode_bits ? 'r' : '-';
  mode_str[5] = S_IWGRP & mode_bits ? 'w' : '-';
  mode_str[6] = S_IXGRP & mode_bits ? 'x' : '-';
  mode_str[7] = S_IROTH & mode_bits ? 'r' : '-';
  mode_str[8] = S_IWOTH & mode_bits ? 'w' : '-';
  mode_str[9] = S_IXOTH & mode_bits ? 'x' : '-';
  mode_str[10] = '\0';
  return mode_str;
}
```