user: What is the c source code of the assembly code below:

```asm
<ucs2_to_utf8>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  test   %edx,%edx
  js     L26
  mov    %rdi,%r12
  mov    %rsi,%rbx
  test   %rsi,%rsi
  je     L35
  mov    %edx,%ebp
  test   %edx,%edx
  je     L35
  mov    %edx,%r13d
  and    $0x1,%r13d
  jne    L26
  xor    %eax,%eax
  nopl   0x0(%rax)
L29:
  cmpb   $0x0,(%rbx,%rax,1)
  jne    L117
  cmpb   $0x0,0x1(%rbx,%rax,1)
  je     L26
L117:
  add    $0x2,%rax
  cmp    %eax,%ebp
  jg     L29
  movzbl (%rbx),%edx
  cmp    $0xff,%dl
  je     L298
  mov    %edx,%edi
  cmp    $0xfe,%dl
  je     L100
L150:
  xor    %esi,%esi
  xor    %ecx,%ecx
  mov    $0x2,%eax
  jmp    L359
  nopl   0x0(%rax,%rax,1)
L99:
  movzbl (%rbx,%rax,1),%edi
  add    $0x2,%rax
L359:
  cmp    $0x20,%dil
  sbb    $0xffffffff,%ecx
  cmpb   $0x20,-0x1(%rbx,%rax,1)
  sbb    $0xffffffff,%esi
  cmp    %eax,%ebp
  jg     L99
  test   %ecx,%ecx
  je     L282
  test   %esi,%esi
  jg     L26
  xor    %r14d,%r14d
L235:
  mov    $0x2,%ecx
  jmp    L354
  nopl   (%rax)
L155:
  shl    $0x8,%edx
  or     %edx,%eax
  cmp    $0x7f,%eax
  jg     L1
L68:
  add    $0x1,%r13d
  cmp    %ecx,%ebp
  jle    L9
L249:
  movzbl (%rbx,%rcx,1),%edx
  add    $0x2,%rcx
L354:
  movzbl -0x1(%rbx,%rcx,1),%eax
  test   %r14d,%r14d
  jne    L155
  shl    $0x8,%eax
  or     %edx,%eax
  cmp    $0x7f,%eax
  jle    L68
L1:
  mov    %r13d,%edx
  xor    %r13d,%r13d
  cmp    $0x7ff,%eax
  setg   %r13b
  lea    0x2(%r13,%rdx,1),%r13d
  cmp    %ecx,%ebp
  jg     L249
L9:
  test   %r12,%r12
  je     L137
  lea    0x1(%r13),%edi
  call   <xmalloc@plt>
  xor    %edx,%edx
  mov    %rax,%rdi
  mov    %rax,%rcx
  jmp    L163
  nopw   0x0(%rax,%rax,1)
L305:
  shl    $0x8,%esi
  or     %esi,%eax
  cmp    $0x7f,%eax
  jg     L209
L18:
  mov    %al,(%rcx)
  add    $0x1,%rcx
L368:
  add    $0x2,%rdx
  cmp    %edx,%ebp
  jle    L129
L163:
  movzbl 0x1(%rbx,%rdx,1),%eax
  movzbl (%rbx,%rdx,1),%esi
  test   %r14d,%r14d
  jne    L305
  shl    $0x8,%eax
  or     %esi,%eax
  cmp    $0x7f,%eax
  jle    L18
L209:
  mov    %eax,%r8d
  mov    %eax,%esi
  and    $0x3f,%r8d
  sar    $0x6,%esi
  or     $0xffffff80,%r8d
  cmp    $0x7ff,%eax
  jg     L352
  or     $0xffffffc0,%esi
  add    $0x2,%rdx
  mov    %r8b,0x1(%rcx)
  add    $0x2,%rcx
  mov    %sil,-0x2(%rcx)
  cmp    %edx,%ebp
  jg     L163
L129:
  movb   $0x0,(%rcx)
  mov    %r13d,%eax
  mov    %rdi,(%r12)
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nopl   (%rax)
L26:
  mov    $0xffffffff,%r13d
L137:
  pop    %rbx
  mov    %r13d,%eax
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nopw   0x0(%rax,%rax,1)
L35:
  xor    %r13d,%r13d
  test   %r12,%r12
  je     L137
  movq   $0x0,(%r12)
  mov    %r13d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nopl   0x0(%rax)
L100:
  cmpb   $0xff,0x1(%rbx)
  jne    L150
  lea    0x2(%rbx),%rax
  sub    $0x2,%ebp
  mov    $0x1,%r14d
  jmp    L7
  nopl   0x0(%rax)
L352:
  sar    $0xc,%eax
  and    $0x3f,%esi
  mov    %r8b,0x2(%rcx)
  add    $0x3,%rcx
  or     $0xffffffe0,%eax
  or     $0xffffff80,%esi
  mov    %al,-0x3(%rcx)
  mov    %sil,-0x2(%rcx)
  jmp    L368
L298:
  cmpb   $0xfe,0x1(%rbx)
  mov    $0xffffffff,%edi
  jne    L150
  lea    0x2(%rbx),%rax
  sub    $0x2,%ebp
  xor    %r14d,%r14d
L7:
  test   %ebp,%ebp
  jle    L193
  movzbl 0x2(%rbx),%edx
  mov    %rax,%rbx
  jmp    L235
  nopl   0x0(%rax)
L282:
  mov    $0x1,%r14d
  jmp    L235
L193:
  test   %r12,%r12
  je     L137
  mov    $0x1,%edi
  call   <xmalloc@plt>
  mov    %rax,%rcx
  mov    %rax,%rdi
  jmp    L129
```

assistant: ```c
int ucs2_to_utf8(unsigned char **pu8str, const unsigned char *u16str, int u16len) {
  int i, out_count, c;
  int is_be = 0;
  const unsigned char *u16p = u16str;
  unsigned char *u8o = 0, *u8p = 0;
  if (u16len < 0)
    return -1;
  if (!u16str || !u16len) {
    if (pu8str)
      *pu8str = 0;
    return 0;
  }
  if ((u16len & 1))
    return -1;
  for (i = 0; i < u16len; i += 2) {
    if (!u16str[i] && !u16str[i + 1])
      return -1;
  }
  if (u16str[0] == 0xff && u16str[1] == 0xfe) {
    u16p = u16str + 2;
    u16len -= 2;
  } else if (u16str[0] == 0xfe && u16str[1] == 0xff) {
    u16p = u16str + 2;
    u16len -= 2;
    is_be = 1;
  } else {
    int count0 = 0;
    int count1 = 0;
    for (i = 0; i < u16len; i += 2) {
      if (u16str[i] >= ' ')
        ++count0;
      if (u16str[i + 1] >= ' ')
        ++count1;
    }
    if (count0 <= 0) {
      is_be = 1;
    }
    if (count0 > 0 && count1 > 0) {
      return -1;
    }
  }
  out_count = 0;
  for (i = 0; i < u16len; i += 2) {
    if (is_be) {
      c = (u16p[i] << 8) | u16p[i + 1];
    } else {
      c = (u16p[i + 1] << 8) | u16p[i];
    }
    if (c <= 0x7f) {
      out_count += 1;
    } else if (c <= 0x7ff) {
      out_count += 2;
    } else {
      out_count += 3;
    }
  }
  if (!pu8str)
    return out_count;
  u8o = (unsigned char *)xmalloc(out_count + 1);
  u8p = u8o;
  for (i = 0; i < u16len; i += 2) {
    if (is_be) {
      c = (u16p[i] << 8) | u16p[i + 1];
    } else {
      c = (u16p[i + 1] << 8) | u16p[i];
    }
    if (c <= 0x7f) {
      *u8p++ = c;
    } else if (c <= 0x7ff) {
      *u8p++ = (c >> 6) | 0xc0;
      *u8p++ = (c & 0x3f) | 0x80;
    } else {
      *u8p++ = (c >> 12) | 0xe0;
      *u8p++ = ((c >> 6) & 0x3f) | 0x80;
      *u8p++ = (c & 0x3f) | 0x80;
    }
  }
  *u8p = 0;
  *pu8str = u8o;
  return out_count;
}
```