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

```asm
<utf16_literal_to_utf8>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbx
  mov    %rcx,%r13
  mov    %rsi,%rax
  sub    %rdi,%rax
  cmp    $0x5,%rax
  jg     L174
  mov    %rdi,0x0(%r13)
  mov    $0x0,%r8d
L103:
  mov    %r8d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L174:
  mov    %rsi,%r12
  mov    %rdx,%rbp
  lea    0x2(%rdi),%rdi
  call   <parse_hex4@plt>
  mov    %eax,%r14d
  lea    -0xdc00(%rax),%eax
  cmp    $0x3ff,%eax
  jbe    L110
  test   %r14d,%r14d
  je     L110
  lea    -0xd800(%r14),%eax
  cmp    $0x3ff,%eax
  ja     L200
  lea    0x6(%rbx),%rax
  sub    %rax,%r12
  cmp    $0x5,%r12
  jle    L137
  cmpb   $0x5c,0x6(%rbx)
  jne    L140
  cmpb   $0x75,0x7(%rbx)
  je     L53
L140:
  mov    %rbx,0x0(%r13)
  mov    $0x0,%r8d
  jmp    L103
L110:
  mov    %rbx,0x0(%r13)
  mov    $0x0,%r8d
  jmp    L103
L137:
  mov    %rbx,0x0(%r13)
  mov    $0x0,%r8d
  jmp    L103
L53:
  lea    0x8(%rbx),%rdi
  call   <parse_hex4@plt>
  lea    -0xdc00(%rax),%edx
  cmp    $0x3ff,%edx
  ja     L61
  mov    %r14d,%ecx
  shl    $0xa,%ecx
  and    $0xffc00,%ecx
  and    $0x3ff,%eax
  or     %eax,%ecx
  add    $0x10000,%ecx
  mov    %ecx,%ecx
  mov    $0xc,%r8d
  mov    $0xfffffff0,%r10d
  mov    $0x4,%r9d
  jmp    L201
L61:
  mov    %rbx,0x0(%r13)
  mov    $0x0,%r8d
  jmp    L103
L200:
  mov    %r14d,%ecx
  cmp    $0x7f,%r14d
  ja     L119
  mov    0x0(%rbp),%rax
  mov    %r14b,(%rax)
  mov    $0x6,%r8d
  mov    $0x1,%r9d
  jmp    L228
L119:
  cmp    $0x7ff,%rcx
  ja     L98
  mov    $0x6,%r8d
  mov    $0xffffffc0,%r10d
  mov    $0x2,%r9d
L201:
  lea    -0x1(%r9),%eax
L86:
  movzbl %al,%esi
  mov    0x0(%rbp),%rdi
  mov    %ecx,%edx
  and    $0x3f,%edx
  or     $0xffffff80,%edx
  mov    %dl,(%rdi,%rsi,1)
  shr    $0x6,%rcx
  sub    $0x1,%al
  jne    L86
  mov    0x0(%rbp),%rdx
  mov    %r10d,%eax
  or     %ecx,%eax
  mov    %al,(%rdx)
L228:
  movzbl %r9b,%r9d
  add    %r9,0x0(%rbp)
  jmp    L103
L98:
  cmp    $0xffff,%rcx
  ja     L213
  mov    $0x6,%r8d
  mov    $0xffffffe0,%r10d
  mov    $0x3,%r9d
  jmp    L201
L213:
  cmp    $0x10ffff,%rcx
  jbe    L190
  mov    %rbx,0x0(%r13)
  mov    $0x0,%r8d
  jmp    L103
L190:
  mov    $0x6,%r8d
  mov    $0xfffffff0,%r10d
  mov    $0x4,%r9d
  jmp    L201
```

assistant: ```c
unsigned char utf16_literal_to_utf8(const unsigned char *const input_pointer, const unsigned char *const input_end, unsigned char **output_pointer, const unsigned char **error_pointer) {
  long unsigned int codepoint = 0;
  unsigned int first_code = 0;
  const unsigned char *first_sequence = input_pointer;
  unsigned char utf8_length = 0;
  unsigned char utf8_position = 0;
  unsigned char sequence_length = 0;
  unsigned char first_byte_mark = 0;
  if ((input_end - first_sequence) < 6) {
    *error_pointer = first_sequence;
    goto fail;
  }
  first_code = parse_hex4(first_sequence + 2);
  if (((first_code >= 0xDC00) && (first_code <= 0xDFFF)) || (first_code == 0)) {
    *error_pointer = first_sequence;
    goto fail;
  }
  if ((first_code >= 0xD800) && (first_code <= 0xDBFF)) {
    const unsigned char *second_sequence = first_sequence + 6;
    unsigned int second_code = 0;
    sequence_length = 12;
    if ((input_end - second_sequence) < 6) {
      *error_pointer = first_sequence;
      goto fail;
    }
    if ((second_sequence[0] != '\\') || (second_sequence[1] != 'u')) {
      *error_pointer = first_sequence;
      goto fail;
    }
    second_code = parse_hex4(second_sequence + 2);
    if ((second_code < 0xDC00) || (second_code > 0xDFFF)) {
      *error_pointer = first_sequence;
      goto fail;
    }
    codepoint = 0x10000 + (((first_code & 0x3FF) << 10) | (second_code & 0x3FF));
  } else {
    sequence_length = 6;
    codepoint = first_code;
  }
  if (codepoint < 0x80) {
    utf8_length = 1;
  } else if (codepoint < 0x800) {
    utf8_length = 2;
    first_byte_mark = 0xC0;
  } else if (codepoint < 0x10000) {
    utf8_length = 3;
    first_byte_mark = 0xE0;
  } else if (codepoint <= 0x10FFFF) {
    utf8_length = 4;
    first_byte_mark = 0xF0;
  } else {
    *error_pointer = first_sequence;
    goto fail;
  }
  for (utf8_position = (unsigned char)(utf8_length - 1); utf8_position > 0; utf8_position--) {
    (*output_pointer)[utf8_position] = (unsigned char)((codepoint | 0x80) & 0xBF);
    codepoint >>= 6;
  }
  if (utf8_length > 1) {
    (*output_pointer)[0] = (unsigned char)((codepoint | first_byte_mark) & 0xFF);
  } else {
    (*output_pointer)[0] = (unsigned char)(codepoint & 0x7F);
  }
  *output_pointer += utf8_length;
  return sequence_length;
fail:
  return 0;
}
```