user: Translate the below assembly code into C programming language:

```asm
<makeutf8>:
  endbr64
  lea    (%rdx,%rdx,1),%r10d
  xor    %r8d,%r8d
  test   %r10d,%r10d
  jle    L8
  push   %r13
  mov    %rsi,%r9
  xor    %esi,%esi
  push   %r12
  push   %rbp
  push   %rbx
L35:
  lea    0x1(%rsi),%eax
  cltq
  add    %r9,%rax
L70:
  movsbl (%rax),%r11d
  mov    %rax,%rdx
  mov    %r8d,%ebx
  sub    %r9,%rdx
  lea    (%rdi,%rbx,1),%rbp
  mov    %r11d,%r13d
  lea    -0x1(%rdx),%r12
  lea    0x2(%rsi),%edx
  mov    %r11d,%ecx
  and    $0xf8,%r13d
  je     L19
  cmp    $0xd8,%r13d
  je     L113
  shr    $0x4,%cl
  lea    0x1(%r8),%ebx
  lea    0x2(%r8),%esi
  add    $0x3,%r8d
  sub    $0x20,%ecx
  mov    %cl,0x0(%rbp)
  movsbl (%rax),%ecx
  movzbl -0x1(%rax),%r11d
  shl    $0x2,%ecx
  and    $0x3c,%ecx
  shr    $0x6,%r11b
  lea    -0x80(%rcx,%r11,1),%ecx
  mov    %cl,(%rdi,%rbx,1)
  movzbl -0x1(%rax),%ecx
  and    $0x3f,%ecx
  add    $0xffffff80,%ecx
  mov    %cl,(%rdi,%rsi,1)
  cmp    %edx,%r10d
  jle    L94
L50:
  add    $0x2,%rax
  mov    %edx,%esi
  jmp    L70
  nopl   0x0(%rax)
L19:
  movzbl -0x1(%rax),%esi
  lea    0x1(%r8),%ebx
  test   %sil,%sil
  js     L68
  test   %r11b,%r11b
  je     L82
L68:
  shl    $0x2,%r11d
  shr    $0x6,%sil
  add    $0x2,%r8d
  and    $0x3c,%r11d
  lea    -0x40(%r11,%rsi,1),%r11d
  mov    %r11b,0x0(%rbp)
  movzbl -0x1(%rax),%ecx
  and    $0x3f,%ecx
  add    $0xffffff80,%ecx
  mov    %cl,(%rdi,%rbx,1)
  cmp    %edx,%r10d
  jg     L50
L94:
  mov    %r8d,%eax
  pop    %rbx
  pop    %rbp
  movb   $0x0,(%rdi,%rax,1)
  pop    %r12
  mov    %r8d,%eax
  pop    %r13
  ret
  cs nopw 0x0(%rax,%rax,1)
L82:
  mov    %sil,0x0(%rbp)
  mov    %ebx,%r8d
  cmp    %edx,%r10d
  jg     L50
  jmp    L94
  xchg   %ax,%ax
L113:
  test   $0x4,%r11b
  jne    L105
  add    %r9,%r12
  lea    0x2(%r8),%ebx
  movsbl (%r12),%eax
  lea    (%rdi,%rbx,1),%r11
  and    $0xc0,%eax
  cmp    $0xc0,%eax
  sete   %al
  and    $0x7,%ecx
  lea    -0x10(%rax,%rcx,1),%eax
  lea    0x1(%r8),%ecx
  mov    %al,0x0(%rbp)
  movsbl (%r12),%eax
  add    $0x40,%eax
  shr    $0x2,%al
  add    $0xffffff80,%eax
  mov    %al,(%rdi,%rcx,1)
  movzbl (%r12),%ebp
  cmp    %edx,%r10d
  jle    L105
  movslq %edx,%rdx
  add    $0x4,%esi
  movzbl 0x1(%r9,%rdx,1),%eax
  mov    %eax,%ecx
  and    $0xfc,%ecx
  cmp    $0xdc,%ecx
  je     L124
L105:
  xor    %r8d,%r8d
  movb   $0x0,(%rdi,%rbx,1)
  pop    %rbx
  mov    %r8d,%eax
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax)
L124:
  shl    $0x2,%eax
  add    %r9,%rdx
  shl    $0x4,%ebp
  lea    0x3(%r8),%ebx
  movzbl (%rdx),%ecx
  and    $0xc,%eax
  and    $0x30,%ebp
  add    $0x4,%r8d
  shr    $0x6,%cl
  lea    -0x80(%rcx,%rax,1),%eax
  add    %ebp,%eax
  mov    %al,(%r11)
  movzbl (%rdx),%eax
  and    $0x3f,%eax
  add    $0xffffff80,%eax
  mov    %al,(%rdi,%rbx,1)
  cmp    %esi,%r10d
  jg     L35
  jmp    L94
L8:
  movb   $0x0,(%rdi)
  mov    %r8d,%eax
  ret
```

assistant: ```c
unsigned int makeutf8(char *utf8, const char *utf16, int length) {
  int i;
  unsigned int size;
  unsigned int rem;
  enum { BASE, SURR, ERR } state;
  size = 0;
  rem = 0;
  state = BASE;
  for (i = 0; i < 2 * length; i += 2) {
    switch (state) {
    case BASE:
      if (utf16[i + 1] & 0xf8) {
        if ((utf16[i + 1] & 0xf8) == 0xd8) {
          if (utf16[i + 1] & 4)
            state = ERR;
          else {
            utf8[size++] = 0xf0 + (utf16[i + 1] & 7) + ((utf16[i] & 0xc0) == 0xc0);
            utf8[size++] = 0x80 + (((utf16[i] + 64) >> 2) & 63);
            rem = utf16[i] & 3;
            state = SURR;
          }
        } else {
          utf8[size++] = 0xe0 + ((utf16[i + 1] >> 4) & 15);
          utf8[size++] = 0x80 + ((utf16[i + 1] & 15) << 2) + ((utf16[i] >> 6) & 3);
          utf8[size++] = 0x80 + (utf16[i] & 63);
        }
      } else if ((utf16[i] & 0x80) || utf16[i + 1]) {
        utf8[size++] = 0xc0 + ((utf16[i + 1] & 15) << 2) + ((utf16[i] >> 6) & 3);
        utf8[size++] = 0x80 + (utf16[i] & 63);
      } else
        utf8[size++] = utf16[i];
      break;
    case SURR:
      if ((utf16[i + 1] & 0xfc) == 0xdc) {
        utf8[size++] = 0x80 + (rem << 4) + ((utf16[i + 1] & 3) << 2) + ((utf16[i] >> 6) & 3);
        utf8[size++] = 0x80 + (utf16[i] & 63);
        state = BASE;
      } else
        state = ERR;
      break;
    case ERR:
      break;
    }
  }
  utf8[size] = 0;
  if (state != BASE)
    state = ERR;
  return (state == ERR ? 0 : size);
}
```