user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<utf8_to_code>:
  endbr64
  mov    %rdi,%rax
  test   %rdi,%rdi
  je     L168
  movzbl (%rdi),%ecx
  test   %cl,%cl
  je     L226
  jns    L56
  cmp    $0xbf,%cl
  jbe    L157
  cmp    $0xdf,%cl
  ja     L51
  movzbl 0x1(%rdi),%edx
  lea    -0x80(%rdx),%eax
  cmp    $0x3f,%al
  ja     L157
  movzbl %cl,%eax
  add    $0xffffff80,%edx
  sub    $0xc0,%eax
  shl    $0x6,%eax
  or     %edx,%eax
  ret
  nop
L56:
  mov    $0x1,%eax
  test   %rsi,%rsi
  je     L153
  mov    %ecx,(%rsi)
  ret
  nopl   0x0(%rax)
L236:
  cmp    $0xfd,%cl
  ja     L157
  movzbl 0x1(%rdi),%edi
  lea    -0x80(%rdi),%edx
  cmp    $0x3f,%dl
  ja     L157
  movzbl 0x2(%rax),%esi
  lea    -0x80(%rsi),%edx
  cmp    $0x3f,%dl
  ja     L157
  movzbl 0x3(%rax),%r8d
  lea    -0x80(%r8),%edx
  cmp    $0x3f,%dl
  ja     L157
  movzbl 0x4(%rax),%edx
  lea    -0x80(%rdx),%r9d
  cmp    $0x3f,%r9b
  ja     L157
  movzbl 0x5(%rax),%r9d
  lea    -0x80(%r9),%eax
  cmp    $0x3f,%al
  ja     L157
  mov    %ecx,%eax
  shl    $0x18,%edi
  add    $0xffffff80,%edx
  lea    -0x80000000(%rdi),%ecx
  shl    $0x1e,%eax
  shl    $0x6,%edx
  or     %ecx,%eax
  movzbl %r9b,%ecx
  add    $0xffffff80,%ecx
  or     %ecx,%eax
  movzbl %sil,%ecx
  add    $0xffffff80,%ecx
  shl    $0x12,%ecx
  or     %ecx,%eax
  movzbl %r8b,%ecx
  add    $0xffffff80,%ecx
  shl    $0xc,%ecx
  or     %ecx,%eax
  or     %edx,%eax
L153:
  ret
  nopl   0x0(%rax,%rax,1)
L226:
  mov    D10(%rip),%rax
  movq   $0x0,(%rax)
  xor    %eax,%eax
  ret
  nopl   0x0(%rax)
L51:
  cmp    $0xef,%cl
  ja     L66
  movzbl 0x1(%rdi),%edx
  lea    -0x80(%rdx),%esi
  cmp    $0x3f,%sil
  jbe    L86
L157:
  mov    D12(%rip),%rax
  mov    (%rax),%rdx
  mov    D10(%rip),%rax
  mov    %rdx,(%rax)
  xor    %eax,%eax
  ret
  nopl   (%rax)
L168:
  mov    D20(%rip),%rax
  mov    (%rax),%rdx
  mov    D10(%rip),%rax
  mov    %rdx,(%rax)
  xor    %eax,%eax
  ret
  nop
L66:
  cmp    $0xf7,%cl
  jbe    L237
  cmp    $0xfb,%cl
  ja     L236
  movzbl 0x1(%rdi),%edx
  lea    -0x80(%rdx),%esi
  cmp    $0x3f,%sil
  ja     L157
  movzbl 0x2(%rdi),%esi
  lea    -0x80(%rsi),%edi
  cmp    $0x3f,%dil
  ja     L157
  movzbl 0x3(%rax),%edi
  lea    -0x80(%rdi),%r8d
  cmp    $0x3f,%r8b
  ja     L157
  movzbl 0x4(%rax),%r8d
  lea    -0x80(%r8),%eax
  cmp    $0x3f,%al
  ja     L157
  mov    %ecx,%eax
  add    $0xffffff80,%edx
  shl    $0x18,%eax
  shl    $0x12,%edx
  add    $0x8000000,%eax
  or     %edx,%eax
  movzbl %r8b,%edx
  add    $0xffffff80,%edx
  or     %edx,%eax
  movzbl %sil,%edx
  add    $0xffffff80,%edx
  shl    $0xc,%edx
  or     %edx,%eax
  movzbl %dil,%edx
  add    $0xffffff80,%edx
  shl    $0x6,%edx
  or     %edx,%eax
  ret
  nop
L86:
  movzbl 0x2(%rdi),%esi
  lea    -0x80(%rsi),%eax
  cmp    $0x3f,%al
  ja     L157
  movzbl %cl,%eax
  add    $0xffffff80,%edx
  sub    $0xe0,%eax
  shl    $0x6,%edx
  shl    $0xc,%eax
  or     %edx,%eax
  movzbl %sil,%edx
  add    $0xffffff80,%edx
  or     %edx,%eax
  ret
  nopl   0x0(%rax)
L237:
  movzbl 0x1(%rdi),%edx
  lea    -0x80(%rdx),%esi
  cmp    $0x3f,%sil
  ja     L157
  movzbl 0x2(%rdi),%esi
  lea    -0x80(%rsi),%edi
  cmp    $0x3f,%dil
  ja     L157
  movzbl 0x3(%rax),%edi
  lea    -0x80(%rdi),%eax
  cmp    $0x3f,%al
  ja     L157
  movzbl %cl,%eax
  add    $0xffffff80,%edx
  sub    $0xf0,%eax
  shl    $0xc,%edx
  shl    $0x12,%eax
  or     %edx,%eax
  movzbl %dil,%edx
  add    $0xffffff80,%edx
  or     %edx,%eax
  movzbl %sil,%edx
  add    $0xffffff80,%edx
  shl    $0x6,%edx
  or     %edx,%eax
  ret
```

assistant: ```c
size_t utf8_to_code(const unsigned char *const buffer, unsigned int *const codeptr) {
  if (!buffer) {
    errno = EINVAL;
    return 0;
  }
  if (*buffer == 0U) {
    errno = 0;
    return 0;
  }
  if (*buffer < 128U) {
    if (codeptr)
      *codeptr = buffer[0];
    return 1;
  }
  if (*buffer < 192U) {
    errno = EILSEQ;
    return 0;
  }
  if (*buffer < 224U) {
    if (buffer[1] >= 128U && buffer[1] < 192U)
      return ((buffer[0] - 192U) << 6U) | (buffer[1] - 128U);
    errno = EILSEQ;
    return 0;
  }
  if (*buffer < 240U) {
    if (buffer[1] >= 128U && buffer[1] < 192U && buffer[2] >= 128U && buffer[2] < 192U)
      return ((buffer[0] - 224U) << 12U) | ((buffer[1] - 128U) << 6U) | (buffer[2] - 128U);
    errno = EILSEQ;
    return 0;
  }
  if (*buffer < 248U) {
    if (buffer[1] >= 128U && buffer[1] < 192U && buffer[2] >= 128U && buffer[2] < 192U && buffer[3] >= 128U && buffer[3] < 192U)
      return ((buffer[0] - 240U) << 18U) | ((buffer[1] - 128U) << 12U) | ((buffer[2] - 128U) << 6U) | (buffer[3] - 128U);
    errno = EILSEQ;
    return 0;
  }
  if (*buffer < 252U) {
    if (buffer[1] >= 128U && buffer[1] < 192U && buffer[2] >= 128U && buffer[2] < 192U && buffer[3] >= 128U && buffer[3] < 192U && buffer[4] >= 128U && buffer[4] < 192U)
      return ((buffer[0] - 248U) << 24U) | ((buffer[1] - 128U) << 18U) | ((buffer[2] - 128U) << 12U) | ((buffer[3] - 128U) << 6U) | (buffer[4] - 128U);
    errno = EILSEQ;
    return 0;
  }
  if (*buffer < 254U) {
    if (buffer[1] >= 128U && buffer[1] < 192U && buffer[2] >= 128U && buffer[2] < 192U && buffer[3] >= 128U && buffer[3] < 192U && buffer[4] >= 128U && buffer[4] < 192U && buffer[5] >= 128U && buffer[5] < 192U)
      return ((buffer[0] - 252U) << 30U) | ((buffer[1] - 128U) << 24U) | ((buffer[2] - 128U) << 18U) | ((buffer[3] - 128U) << 12U) | ((buffer[4] - 128U) << 6U) | (buffer[5] - 128U);
    errno = EILSEQ;
    return 0;
  }
  errno = EILSEQ;
  return 0;
}
```