user: 请从给定的汇编指令推导出C源代码:

```asm
<utf16_literal_to_utf8>:
  endbr64
  mov    %rsi,%rax
  push   %r14
  sub    %rdi,%rax
  push   %r13
  mov    %rcx,%r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbx
  cmp    $0x5,%rax
  jg     L116
L101:
  mov    %rbx,0x0(%r13)
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nopl   (%rax)
L116:
  lea    0x2(%rdi),%rdi
  mov    %rsi,%rbp
  mov    %rdx,%r14
  call   <parse_hex4@plt>
  mov    %eax,%r12d
  lea    -0xdc00(%rax),%eax
  cmp    $0x3ff,%eax
  jbe    L101
  test   %r12d,%r12d
  je     L101
  lea    -0xd800(%r12),%eax
  cmp    $0x3ff,%eax
  ja     L104
  lea    0x6(%rbx),%rax
  sub    %rax,%rbp
  cmp    $0x5,%rbp
  jle    L101
  cmpb   $0x5c,0x6(%rbx)
  jne    L101
  cmpb   $0x75,0x7(%rbx)
  jne    L101
  lea    0x8(%rbx),%rdi
  call   <parse_hex4@plt>
  lea    -0xdc00(%rax),%edx
  cmp    $0x3ff,%edx
  ja     L101
  shl    $0xa,%r12d
  and    $0x3ff,%eax
  and    $0xffc00,%r12d
  or     %r12d,%eax
  lea    0x10000(%rax),%ecx
  mov    $0xc,%eax
L147:
  mov    $0x4,%edi
  mov    $0x3,%esi
  mov    $0xfffffff0,%r8d
  jmp    L22
  cs nopw 0x0(%rax,%rax,1)
L104:
  mov    %r12d,%ecx
  cmp    $0x7f,%r12d
  ja     L50
  mov    (%r14),%rax
  mov    $0x1,%edi
  mov    %r12b,(%rax)
  mov    $0x6,%eax
L5:
  add    %rdi,(%r14)
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nopl   (%rax)
L50:
  cmp    $0x7ff,%rcx
  ja     L71
  mov    (%r14),%rax
  and    $0x3f,%r12d
  shr    $0x6,%rcx
  mov    $0x2,%edi
  or     $0xffffff80,%r12d
  mov    %rcx,%rdx
  mov    $0xffffffc0,%r8d
  mov    %r12b,0x1(%rax)
  mov    $0x6,%eax
L83:
  mov    (%r14),%rcx
  or     %r8d,%edx
  mov    %dl,(%rcx)
  jmp    L5
  nopl   0x0(%rax)
L71:
  cmp    $0xffff,%rcx
  ja     L146
  mov    $0x3,%edi
  mov    $0x6,%eax
  mov    $0x2,%esi
  mov    $0xffffffe0,%r8d
L22:
  mov    %ecx,%edx
  mov    (%r14),%r10
  movzbl %sil,%r9d
  sub    $0x1,%esi
  and    $0x3f,%edx
  or     $0xffffff80,%edx
  mov    %dl,(%r10,%r9,1)
  mov    %rcx,%rdx
  mov    (%r14),%r10
  movzbl %sil,%r9d
  shr    $0x6,%rdx
  and    $0x3f,%edx
  or     $0xffffff80,%edx
  mov    %dl,(%r10,%r9,1)
  mov    %rcx,%rdx
  shr    $0xc,%rdx
  cmp    $0x1,%sil
  je     L83
  mov    (%r14),%rsi
  and    $0x3f,%edx
  shr    $0x12,%rcx
  or     $0xffffff80,%edx
  mov    %dl,0x1(%rsi)
  mov    %rcx,%rdx
  jmp    L83
  cs nopw 0x0(%rax,%rax,1)
L146:
  cmp    $0x10ffff,%rcx
  ja     L101
  mov    $0x6,%eax
  jmp    L147
```

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;
}
```