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

```asm
<ezxml_str2utf8>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdi,%r15
  mov    %rsi,0x10(%rsp)
  mov    (%rdi),%rax
  movzbl (%rax),%edx
  cmp    $0xfe,%dl
  je     L91
  mov    $0x0,%eax
  cmp    $0xff,%dl
  jne    L138
  movl   $0x0,0x1c(%rsp)
L209:
  mov    0x10(%rsp),%r14
  mov    (%r14),%rbx
  mov    %rbx,%rdi
  call   <malloc@plt>
  mov    %rax,%rdi
  mov    (%r14),%rax
  mov    %rax,0x8(%rsp)
  sub    $0x1,%rax
  cmp    $0x2,%rax
  jbe    L187
  mov    $0x2,%r13d
  mov    $0x0,%r14d
  jmp    L4
L91:
  movl   $0x1,0x1c(%rsp)
  jmp    L209
L1:
  mov    (%r15),%rdx
  movsbl 0x1(%rdx,%r13,1),%ebp
  shl    $0x8,%ebp
  movzwl %bp,%ebp
  movzbl (%rdx,%r13,1),%edx
  or     %edx,%ebp
  movslq %ebp,%rbp
  jmp    L128
L81:
  mov    (%r15),%rcx
  movsbl 0x3(%rcx,%r13,1),%eax
  shl    $0x8,%eax
  movzwl %ax,%eax
  movzbl (%rcx,%rdx,1),%ecx
  or     %ecx,%eax
  cltq
  jmp    L148
L204:
  lea    0x6(%r14),%r12
  cmp    %rbx,%r12
  jbe    L163
L39:
  add    $0x400,%rbx
  mov    %rbx,%rsi
  call   <realloc@plt>
  mov    %rax,%rdi
  cmp    %r12,%rbx
  jb     L39
L163:
  cmp    $0x7f,%rbp
  jg     L168
  mov    %bpl,(%rdi,%r14,1)
  lea    0x1(%r14),%r14
L83:
  add    $0x2,%r13
  mov    0x10(%rsp),%rax
  mov    (%rax),%rax
  mov    %rax,0x8(%rsp)
  sub    $0x1,%rax
  cmp    %r13,%rax
  jbe    L151
L4:
  cmpl   $0x0,0x1c(%rsp)
  je     L1
  mov    (%r15),%rdx
  movsbl (%rdx,%r13,1),%ebp
  shl    $0x8,%ebp
  movzwl %bp,%ebp
  movzbl 0x1(%rdx,%r13,1),%edx
  or     %edx,%ebp
  movslq %ebp,%rbp
L128:
  lea    -0xd800(%rbp),%rdx
  cmp    $0x7ff,%rdx
  ja     L204
  lea    0x2(%r13),%rdx
  cmp    %rax,%rdx
  jae    L129
  cmpl   $0x0,0x1c(%rsp)
  je     L81
  mov    (%r15),%rcx
  movsbl (%rcx,%rdx,1),%eax
  shl    $0x8,%eax
  movzwl %ax,%eax
  movzbl 0x3(%rcx,%r13,1),%ecx
  or     %ecx,%eax
  cltq
L148:
  shl    $0xa,%rbp
  and    $0xffc00,%ebp
  and    $0x3ff,%eax
  or     %rax,%rbp
  add    $0x10000,%rbp
L129:
  lea    0x6(%r14),%r12
  mov    %rdx,%r13
  cmp    %rbx,%r12
  ja     L39
L168:
  mov    %rbp,%rcx
  mov    $0x0,%edx
L130:
  mov    %edx,%esi
  add    $0x1,%edx
  mov    %rcx,%rax
  shr    $0x3f,%rax
  add    %rcx,%rax
  sar    %rax
  mov    %rax,%rcx
  jne    L130
  lea    -0x1(%rsi),%eax
  movslq %eax,%rsi
  imul   $0x66666667,%rsi,%rsi
  sar    $0x21,%rsi
  sar    $0x1f,%eax
  sub    %eax,%esi
  lea    (%rsi,%rsi,2),%ecx
  lea    (%rcx,%rcx,1),%eax
  lea    0x1(%r14),%rdx
  mov    $0x7,%ecx
  sub    %esi,%ecx
  mov    $0xff,%r8d
  shl    %cl,%r8d
  mov    %rbp,%r9
  mov    %eax,%ecx
  sar    %cl,%r9
  or     %r9d,%r8d
  mov    %r8b,(%rdi,%r14,1)
  test   %esi,%esi
  je     L118
  sub    $0x1,%esi
  lea    -0x6(%rax),%ecx
  add    %rdi,%rdx
L97:
  mov    %rbp,%rax
  sar    %cl,%rax
  and    $0x3f,%eax
  or     $0xffffff80,%eax
  mov    %al,(%rdx)
  sub    $0x6,%ecx
  add    $0x1,%rdx
  cmp    $0xfffffffa,%ecx
  jne    L97
  mov    %esi,%esi
  lea    0x2(%r14,%rsi,1),%r14
  jmp    L83
L118:
  mov    %rdx,%r14
  jmp    L83
L187:
  mov    $0x0,%r14d
L151:
  mov    0x10(%rsp),%rax
  mov    %r14,(%rax)
  mov    %r14,%rsi
  call   <realloc@plt>
  mov    %rax,(%r15)
L138:
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
char *ezxml_str2utf8(char **s, size_t *len) {
  char *u;
  size_t l = 0, sl, max = *len;
  long c, d;
  int b, be = (**s == '\xFE') ? 1 : (**s == '\xFF') ? 0 : -1;
  if (be == -1)
    return NULL;
  u = (char *)malloc(max);
  for (sl = 2; sl < *len - 1; sl += 2) {
    c = (be) ? (((*s)[sl] & 0xFF) << 8) | ((*s)[sl + 1] & 0xFF) : (((*s)[sl + 1] & 0xFF) << 8) | ((*s)[sl] & 0xFF);
    if (c >= 0xD800 && c <= 0xDFFF && (sl += 2) < *len - 1) {
      d = (be) ? (((*s)[sl] & 0xFF) << 8) | ((*s)[sl + 1] & 0xFF) : (((*s)[sl + 1] & 0xFF) << 8) | ((*s)[sl] & 0xFF);
      c = (((c & 0x3FF) << 10) | (d & 0x3FF)) + 0x10000;
    }
    while (l + 6 > max)
      u = (char *)realloc(u, max += 1024);
    if (c < 0x80)
      u[l++] = (char)c;
    else {
      for (b = 0, d = c; d; d /= 2)
        b++;
      b = (b - 2) / 5;
      u[l++] = (char)((0xFF << (7 - b)) | (c >> (6 * b)));
      while (b)
        u[l++] = 0x80 | ((c >> (6 * --b)) & 0x3F);
    }
  }
  return *s = (char *)realloc(u, *len = l);
}
```