user: Please show me the C implementation that matches the assembly code listed below:

```asm
<makeutf8>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %edx,-0x24(%rbp)
  movl   $0x0,-0xc(%rbp)
  movl   $0x0,-0x8(%rbp)
  movl   $0x0,-0x4(%rbp)
  movl   $0x0,-0x10(%rbp)
  jmp    L196
L149:
  cmpl   $0x2,-0x4(%rbp)
  je     L151
  cmpl   $0x2,-0x4(%rbp)
  ja     L174
  cmpl   $0x0,-0x4(%rbp)
  je     L211
  cmpl   $0x1,-0x4(%rbp)
  je     L106
  jmp    L174
L211:
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x1(%rax),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  and    $0xf8,%eax
  test   %eax,%eax
  je     L66
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x1(%rax),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  and    $0xf8,%eax
  cmp    $0xd8,%eax
  jne    L35
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x1(%rax),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  and    $0x4,%eax
  test   %eax,%eax
  je     L56
  movl   $0x2,-0x4(%rbp)
  jmp    L174
L56:
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x1(%rax),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  and    $0x7,%eax
  mov    %eax,%ecx
  mov    -0x10(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  and    $0xc0,%eax
  cmp    $0xc0,%eax
  sete   %al
  add    %ecx,%eax
  lea    -0x10(%rax),%ecx
  mov    -0xc(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0xc(%rbp)
  mov    %eax,%edx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    %ecx,%edx
  mov    %dl,(%rax)
  mov    -0x10(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  add    $0x40,%eax
  sar    $0x2,%eax
  and    $0x3f,%eax
  lea    -0x80(%rax),%ecx
  mov    -0xc(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0xc(%rbp)
  mov    %eax,%edx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    %ecx,%edx
  mov    %dl,(%rax)
  mov    -0x10(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  and    $0x3,%eax
  mov    %eax,-0x8(%rbp)
  movl   $0x1,-0x4(%rbp)
  jmp    L174
L35:
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x1(%rax),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  shr    $0x4,%al
  lea    -0x20(%rax),%ecx
  mov    -0xc(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0xc(%rbp)
  mov    %eax,%edx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    %ecx,%edx
  mov    %dl,(%rax)
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x1(%rax),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  shl    $0x2,%eax
  and    $0x3c,%eax
  mov    %eax,%ecx
  mov    -0x10(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  shr    $0x6,%al
  add    %ecx,%eax
  lea    -0x80(%rax),%ecx
  mov    -0xc(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0xc(%rbp)
  mov    %eax,%edx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    %ecx,%edx
  mov    %dl,(%rax)
  mov    -0x10(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  and    $0x3f,%eax
  lea    -0x80(%rax),%ecx
  mov    -0xc(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0xc(%rbp)
  mov    %eax,%edx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    %ecx,%edx
  mov    %dl,(%rax)
  jmp    L174
L66:
  mov    -0x10(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  test   %al,%al
  js     L83
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x1(%rax),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L10
L83:
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x1(%rax),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  shl    $0x2,%eax
  and    $0x3c,%eax
  mov    %eax,%ecx
  mov    -0x10(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  shr    $0x6,%al
  add    %ecx,%eax
  lea    -0x40(%rax),%ecx
  mov    -0xc(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0xc(%rbp)
  mov    %eax,%edx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    %ecx,%edx
  mov    %dl,(%rax)
  mov    -0x10(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  and    $0x3f,%eax
  lea    -0x80(%rax),%ecx
  mov    -0xc(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0xc(%rbp)
  mov    %eax,%edx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    %ecx,%edx
  mov    %dl,(%rax)
  jmp    L174
L10:
  mov    -0x10(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x20(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0xc(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0xc(%rbp)
  mov    %eax,%edx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  movzbl (%rcx),%eax
  mov    %al,(%rdx)
  jmp    L174
L106:
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x1(%rax),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  and    $0xfc,%eax
  cmp    $0xdc,%eax
  jne    L200
  mov    -0x8(%rbp),%eax
  shl    $0x4,%eax
  mov    %eax,%edx
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x1(%rax),%rcx
  mov    -0x20(%rbp),%rax
  add    %rcx,%rax
  movzbl (%rax),%eax
  shl    $0x2,%eax
  and    $0xc,%eax
  lea    (%rdx,%rax,1),%ecx
  mov    -0x10(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  shr    $0x6,%al
  add    %ecx,%eax
  lea    -0x80(%rax),%ecx
  mov    -0xc(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0xc(%rbp)
  mov    %eax,%edx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    %ecx,%edx
  mov    %dl,(%rax)
  mov    -0x10(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  and    $0x3f,%eax
  lea    -0x80(%rax),%ecx
  mov    -0xc(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0xc(%rbp)
  mov    %eax,%edx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    %ecx,%edx
  mov    %dl,(%rax)
  movl   $0x0,-0x4(%rbp)
  jmp    L174
L200:
  movl   $0x2,-0x4(%rbp)
  jmp    L174
L151:
  nop
L174:
  addl   $0x2,-0x10(%rbp)
L196:
  mov    -0x24(%rbp),%eax
  add    %eax,%eax
  cmp    %eax,-0x10(%rbp)
  jl     L149
  mov    -0xc(%rbp),%edx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  cmpl   $0x0,-0x4(%rbp)
  je     L159
  movl   $0x2,-0x4(%rbp)
L159:
  cmpl   $0x2,-0x4(%rbp)
  je     L25
  mov    -0xc(%rbp),%eax
  jmp    L143
L25:
  mov    $0x0,%eax
L143:
  pop    %rbp
  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);
}
```