user: 这段汇编代码用C语言表示是什么样的?

```asm
<wma_utf16toutf8>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %esi,-0x3c(%rbp)
  mov    -0x38(%rbp),%rax
  mov    %rax,-0x18(%rbp)
  cmpl   $0x0,-0x3c(%rbp)
  jne    L12
  mov    $0x0,%eax
  jmp    L136
L12:
  mov    -0x3c(%rbp),%eax
  add    %eax,%eax
  add    $0x1,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  jne    L159
  mov    $0x0,%eax
  jmp    L136
L159:
  mov    -0x3c(%rbp),%eax
  add    %eax,%eax
  lea    0x1(%rax),%edx
  mov    -0x8(%rbp),%rax
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  mov    -0x8(%rbp),%rax
  mov    %rax,-0x10(%rbp)
  jmp    L142
L145:
  mov    -0x18(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  shl    $0x8,%eax
  mov    %eax,%edx
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  or     %edx,%eax
  mov    %eax,-0x24(%rbp)
  addq   $0x2,-0x18(%rbp)
  mov    -0x24(%rbp),%eax
  and    $0xfc00,%eax
  cmp    $0xd800,%eax
  jne    L77
  mov    -0x18(%rbp),%rax
  lea    0x2(%rax),%rdx
  mov    -0x3c(%rbp),%eax
  movslq %eax,%rcx
  mov    -0x38(%rbp),%rax
  add    %rcx,%rax
  cmp    %rax,%rdx
  jbe    L106
  lea    D19(%rip),%rax
  mov    %rax,%rdx
  mov    $0x8,%esi
  mov    $0x5,%edi
  call   <err_log@plt>
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    $0x0,%eax
  jmp    L136
L106:
  mov    -0x18(%rbp),%rax
  add    $0x3,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  shl    $0x8,%eax
  mov    %eax,%edx
  mov    -0x18(%rbp),%rax
  add    $0x2,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  or     %edx,%eax
  mov    %eax,-0x1c(%rbp)
  mov    -0x1c(%rbp),%eax
  and    $0xfc00,%eax
  cmp    $0xdc00,%eax
  je     L176
  lea    D19(%rip),%rax
  mov    %rax,%rdx
  mov    $0x8,%esi
  mov    $0x5,%edi
  call   <err_log@plt>
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    $0x0,%eax
  jmp    L136
L176:
  andl   $0x3ff,-0x24(%rbp)
  shll   $0xa,-0x24(%rbp)
  mov    -0x1c(%rbp),%eax
  and    $0x3ff,%eax
  or     %eax,-0x24(%rbp)
  addl   $0x10000,-0x24(%rbp)
L77:
  cmpl   $0x7f,-0x24(%rbp)
  ja     L65
  mov    -0x10(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x10(%rbp)
  mov    -0x24(%rbp),%edx
  mov    %dl,(%rax)
  movl   $0x0,-0x20(%rbp)
  jmp    L1
L65:
  cmpl   $0x7ff,-0x24(%rbp)
  ja     L173
  mov    -0x24(%rbp),%eax
  shr    $0x6,%eax
  or     $0xffffffc0,%eax
  mov    %eax,%ecx
  mov    -0x10(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x10(%rbp)
  mov    %ecx,%edx
  mov    %dl,(%rax)
  movl   $0x1,-0x20(%rbp)
  jmp    L1
L173:
  cmpl   $0xffff,-0x24(%rbp)
  ja     L33
  mov    -0x24(%rbp),%eax
  shr    $0xc,%eax
  or     $0xffffffe0,%eax
  mov    %eax,%ecx
  mov    -0x10(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x10(%rbp)
  mov    %ecx,%edx
  mov    %dl,(%rax)
  movl   $0x2,-0x20(%rbp)
  jmp    L1
L33:
  mov    -0x24(%rbp),%eax
  shr    $0x12,%eax
  or     $0xfffffff0,%eax
  mov    %eax,%ecx
  mov    -0x10(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x10(%rbp)
  mov    %ecx,%edx
  mov    %dl,(%rax)
  movl   $0x3,-0x20(%rbp)
  jmp    L1
L7:
  mov    -0x20(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    %edx,%eax
  add    %eax,%eax
  add    %edx,%eax
  add    %eax,%eax
  mov    %eax,%edx
  mov    -0x24(%rbp),%eax
  mov    %edx,%ecx
  shr    %cl,%eax
  and    $0x3f,%eax
  or     $0xffffff80,%eax
  mov    %eax,%ecx
  mov    -0x10(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x10(%rbp)
  mov    %ecx,%edx
  mov    %dl,(%rax)
  subl   $0x1,-0x20(%rbp)
L1:
  cmpl   $0x0,-0x20(%rbp)
  jne    L7
L142:
  mov    -0x18(%rbp),%rax
  lea    0x2(%rax),%rdx
  mov    -0x3c(%rbp),%eax
  movslq %eax,%rcx
  mov    -0x38(%rbp),%rax
  add    %rcx,%rax
  cmp    %rax,%rdx
  jbe    L145
  mov    -0x8(%rbp),%rax
L136:
  leave
  ret
```

tool_calls: name: retrieve_data
arguments: tag: D19
datatype: string

tool: D19: Invalid utf-16 in file


assistant: ```c
char *wma_utf16toutf8(unsigned char *utf16, int len) {
  char *utf8;
  unsigned char *src = utf16;
  char *dst;
  unsigned int w1, w2;
  int bytes;
  if (!len)
    return NULL;
  utf8 = (char *)malloc(len * 2 + 1);
  if (!utf8)
    return NULL;
  memset(utf8, 0x0, len * 2 + 1);
  dst = utf8;
  while ((src + 2) <= utf16 + len) {
    w1 = src[1] << 8 | src[0];
    src += 2;
    if ((w1 & 0xFC00) == 0xD800) {
      if (src + 2 > utf16 + len) {
        err_log(5, 0x00000008, "Invalid utf-16 in file\n");
        free(utf8);
        return NULL;
      }
      w2 = src[3] << 8 | src[2];
      if ((w2 & 0xFC00) != 0xDC00) {
        err_log(5, 0x00000008, "Invalid utf-16 in file\n");
        free(utf8);
        return NULL;
      }
      w1 = w1 & 0x03FF;
      w1 = w1 << 10;
      w1 = w1 | (w2 & 0x03FF);
      w1 += 0x10000;
    }
    if (w1 < 0x80) {
      *dst++ = w1;
      bytes = 0;
    } else if (w1 < 0x800) {
      *dst++ = 0xC0 | (w1 >> 6);
      bytes = 1;
    } else if (w1 < 0x10000) {
      *dst++ = 0xE0 | (w1 >> 12);
      bytes = 2;
    } else {
      *dst++ = 0xF0 | (w1 >> 18);
      bytes = 3;
    }
    while (bytes) {
      *dst++ = 0x80 | ((w1 >> (6 * (bytes - 1))) & 0x3f);
      bytes--;
    }
  }
  return utf8;
}
```