user: 请将以下的汇编代码转换成C语言代码：

```asm
<xmlSerializeHexCharRef>:
  endbr64
  mov    %esi,%edx
  movb   $0x26,(%rdi)
  movb   $0x23,0x1(%rdi)
  movb   $0x78,0x2(%rdi)
  cmp    $0xf,%esi
  jle    L18
  lea    0x4(%rdi),%rax
  cmp    $0xff,%esi
  jle    L99
  lea    0x5(%rdi),%rax
  cmp    $0xfff,%esi
  jle    L99
  lea    0x6(%rdi),%rax
  cmp    $0xffff,%esi
  jle    L99
  cmp    $0xfffff,%esi
  setg   %al
  movzbl %al,%eax
  lea    0x7(%rax,%rdi,1),%rax
  jmp    L99
L18:
  lea    0x3(%rdi),%rax
  test   %esi,%esi
  jle    L90
L99:
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rax,%rsi
  lea    D8(%rip),%rdi
  mov    $0x46,%r14d
  mov    $0x45,%r13d
  mov    $0x44,%r12d
  mov    $0x43,%ebp
  mov    $0x42,%ebx
  mov    $0x41,%r11d
  mov    $0x39,%r10d
  mov    $0x38,%r9d
  mov    $0x37,%r8d
  jmp    L133
  lea    -0x1(%rsi),%r15
  mov    $0x30,%ecx
L217:
  mov    %cl,(%rsi)
  sar    $0x4,%edx
  test   %edx,%edx
  jle    L3
  mov    %r15,%rsi
L133:
  mov    %edx,%ecx
  and    $0xf,%ecx
  movslq (%rdi,%rcx,4),%rcx
  add    %rdi,%rcx
  notrack jmp *%rcx
  lea    -0x1(%rsi),%r15
  mov    $0x31,%ecx
  jmp    L217
  lea    -0x1(%rsi),%r15
  mov    $0x32,%ecx
  jmp    L217
  lea    -0x1(%rsi),%r15
  mov    $0x33,%ecx
  jmp    L217
  lea    -0x1(%rsi),%r15
  mov    $0x34,%ecx
  jmp    L217
  lea    -0x1(%rsi),%r15
  mov    $0x35,%ecx
  jmp    L217
  lea    -0x1(%rsi),%r15
  mov    $0x36,%ecx
  jmp    L217
  lea    -0x1(%rsi),%r15
  mov    %r8d,%ecx
  jmp    L217
  lea    -0x1(%rsi),%r15
  mov    %r9d,%ecx
  jmp    L217
  lea    -0x1(%rsi),%r15
  mov    %r10d,%ecx
  jmp    L217
  lea    -0x1(%rsi),%r15
  mov    %r11d,%ecx
  jmp    L217
  lea    -0x1(%rsi),%r15
  mov    %ebx,%ecx
  jmp    L217
  lea    -0x1(%rsi),%r15
  mov    %ebp,%ecx
  jmp    L217
  lea    -0x1(%rsi),%r15
  mov    %r12d,%ecx
  jmp    L217
  lea    -0x1(%rsi),%r15
  mov    %r13d,%ecx
  jmp    L217
  lea    -0x1(%rsi),%r15
  mov    %r14d,%ecx
  jmp    L217
L3:
  movb   $0x3b,0x1(%rax)
  movb   $0x0,0x2(%rax)
  add    $0x2,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L90:
  movb   $0x3b,0x1(%rax)
  movb   $0x0,0x2(%rax)
  add    $0x2,%rax
  ret
```

assistant: ```c
unsigned char *xmlSerializeHexCharRef(unsigned char *out, int val) {
  unsigned char *ptr;
  *out++ = '&';
  *out++ = '#';
  *out++ = 'x';
  if (val < 0x10)
    ptr = out;
  else if (val < 0x100)
    ptr = out + 1;
  else if (val < 0x1000)
    ptr = out + 2;
  else if (val < 0x10000)
    ptr = out + 3;
  else if (val < 0x100000)
    ptr = out + 4;
  else
    ptr = out + 5;
  out = ptr + 1;
  while (val > 0) {
    switch (val & 0xF) {
    case 0:
      *ptr-- = '0';
      break;
    case 1:
      *ptr-- = '1';
      break;
    case 2:
      *ptr-- = '2';
      break;
    case 3:
      *ptr-- = '3';
      break;
    case 4:
      *ptr-- = '4';
      break;
    case 5:
      *ptr-- = '5';
      break;
    case 6:
      *ptr-- = '6';
      break;
    case 7:
      *ptr-- = '7';
      break;
    case 8:
      *ptr-- = '8';
      break;
    case 9:
      *ptr-- = '9';
      break;
    case 0xA:
      *ptr-- = 'A';
      break;
    case 0xB:
      *ptr-- = 'B';
      break;
    case 0xC:
      *ptr-- = 'C';
      break;
    case 0xD:
      *ptr-- = 'D';
      break;
    case 0xE:
      *ptr-- = 'E';
      break;
    case 0xF:
      *ptr-- = 'F';
      break;
    default:
      *ptr-- = '0';
      break;
    }
    val >>= 4;
  }
  *out++ = ';';
  *out = 0;
  return (out);
}
```