user: Converte this assembly snippet into its equivalent C code:

```asm
<_hs_text_decode_utf8>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  mov    %rdx,%r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdi,(%rsp)
  mov    %rsi,0x8(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  mov    (%rsi),%rax
  movl   $0x0,0x10(%rsp)
  lea    (%rdi,%rax,8),%rbx
  cmp    %rcx,%rdx
  jae    L22
  xor    %eax,%eax
  mov    0x0(%r13),%edx
  mov    %rcx,%rbp
  lea    0x14(%rsp),%r15
  lea    0x10(%rsp),%r14
  lea    -0x10(%rcx),%r12
  test   %eax,%eax
  je     L153
L31:
  mov    %r15,%rsi
  mov    %r14,%rdi
  call   <decode@plt>
  test   %rax,%rax
  je     L148
  mov    0x10(%rsp),%eax
  cmp    $0xc,%eax
  jne    L28
L22:
  mov    %r13,%r9
L154:
  mov    0x8(%rsp),%rax
  sub    (%rsp),%rbx
  sar    $0x3,%rbx
  mov    %rbx,(%rax)
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L89
  add    $0x28,%rsp
  mov    %r9,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L148:
  movslq 0x14(%rsp),%rax
  cmp    $0xffff,%eax
  jg     L121
  mov    %rax,(%rbx)
  add    $0x8,%rbx
L150:
  mov    0x10(%rsp),%eax
L28:
  lea    0x4(%r13),%r9
  cmp    %r9,%rbp
  jbe    L83
  mov    %r9,%r13
  mov    0x0(%r13),%edx
  test   %eax,%eax
  jne    L31
L153:
  cmp    %r12,%r13
  jb     L27
  jmp    L31
  nopl   0x0(%rax)
L18:
  movzbl %dl,%eax
  add    $0x20,%rbx
  lea    0x10(%r13),%rsi
  mov    %rax,-0x20(%rbx)
  movzbl %dh,%eax
  cltq
  mov    %rax,-0x18(%rbx)
  mov    %edx,%eax
  sar    $0x10,%eax
  movzbl %al,%eax
  mov    %rax,-0x10(%rbx)
  mov    %edx,%eax
  shr    $0x18,%eax
  mov    %rax,-0x8(%rbx)
  cmp    %r12,%rsi
  jae    L55
  mov    %rsi,%r13
L27:
  mov    0x0(%r13),%edx
  test   $0x80808080,%edx
  je     L18
  mov    %edx,0x14(%rsp)
  jmp    L31
  nopw   0x0(%rax,%rax,1)
L121:
  mov    %eax,%edx
  and    $0x3ff,%eax
  add    $0x10,%rbx
  sar    $0xa,%edx
  add    $0xdc00,%rax
  add    $0xd7c0,%edx
  mov    %rax,-0x8(%rbx)
  movslq %edx,%rdx
  mov    %rdx,-0x10(%rbx)
  jmp    L150
  nopw   0x0(%rax,%rax,1)
L83:
  test   %eax,%eax
  je     L154
  jmp    L22
  nopl   (%rax)
L55:
  mov    %edx,0x14(%rsp)
  mov    0x10(%r13),%edx
  mov    %rsi,%r13
  jmp    L31
L89:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
uint8_t const *_hs_text_decode_utf8(uint16_t *dest, size_t *destoff, const uint8_t const *src, const uint8_t const *srcend) {
  uint16_t *d = dest + *destoff;
  const uint8_t const *s = src;
  uint32_t state = 0;
  while (s < srcend) {
    uint32_t codepoint;
    if (state == 0) {
      while (s < srcend - 4) {
        codepoint = *((uint32_t *)s);
        if ((codepoint & 0x80808080) != 0)
          break;
        s += 4;
        *d++ = (uint16_t)(codepoint & 0xff);
        *d++ = (uint16_t)((codepoint >> 8) & 0xff);
        *d++ = (uint16_t)((codepoint >> 16) & 0xff);
        *d++ = (uint16_t)((codepoint >> 24) & 0xff);
      }
    }
    if (decode(&state, &codepoint, *s++) != 0) {
      if (state != 12)
        continue;
      break;
    }
    if (codepoint <= 0xffff)
      *d++ = (uint16_t)codepoint;
    else {
      *d++ = (uint16_t)(0xD7C0 + (codepoint >> 10));
      *d++ = (uint16_t)(0xDC00 + (codepoint & 0x3FF));
    }
  }
  if (state != 0)
    s -= 1;
  *destoff = d - dest;
  return s;
}
```