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

```asm
<_xos_utf8_put_char>:
  endbr64
  mov    %esi,%eax
  cmp    $0x7f,%esi
  jg     L55
  lea    0x1(%rdi),%rdx
  mov    %sil,(%rdi)
L2:
  mov    %rdx,%rax
  ret
L55:
  cmp    $0x7ff,%esi
  jg     L36
  mov    %esi,%edx
  sar    $0x6,%edx
  or     $0xffffffc0,%edx
  mov    %dl,(%rdi)
  lea    0x2(%rdi),%rdx
  and    $0x3f,%eax
  or     $0xffffff80,%eax
  mov    %al,0x1(%rdi)
  jmp    L2
L36:
  cmp    $0xffff,%esi
  jg     L42
  mov    %esi,%edx
  sar    $0xc,%edx
  or     $0xffffffe0,%edx
  mov    %dl,(%rdi)
  mov    %esi,%edx
  sar    $0x6,%edx
  and    $0x3f,%edx
  or     $0xffffff80,%edx
  mov    %dl,0x1(%rdi)
  lea    0x3(%rdi),%rdx
  and    $0x3f,%eax
  or     $0xffffff80,%eax
  mov    %al,0x2(%rdi)
  jmp    L2
L42:
  cmp    $0x1fffff,%esi
  jg     L76
  mov    %esi,%edx
  sar    $0x12,%edx
  or     $0xfffffff0,%edx
  mov    %dl,(%rdi)
  mov    %esi,%edx
  sar    $0xc,%edx
  and    $0x3f,%edx
  or     $0xffffff80,%edx
  mov    %dl,0x1(%rdi)
  mov    %esi,%edx
  sar    $0x6,%edx
  and    $0x3f,%edx
  or     $0xffffff80,%edx
  mov    %dl,0x2(%rdi)
  lea    0x4(%rdi),%rdx
  and    $0x3f,%eax
  or     $0xffffff80,%eax
  mov    %al,0x3(%rdi)
  jmp    L2
L76:
  cmp    $0x3ffffff,%esi
  jg     L87
  mov    %esi,%edx
  sar    $0x18,%edx
  or     $0xfffffff8,%edx
  mov    %dl,(%rdi)
  mov    %esi,%edx
  sar    $0x12,%edx
  and    $0x3f,%edx
  or     $0xffffff80,%edx
  mov    %dl,0x1(%rdi)
  mov    %esi,%edx
  sar    $0xc,%edx
  and    $0x3f,%edx
  or     $0xffffff80,%edx
  mov    %dl,0x2(%rdi)
  mov    %esi,%edx
  sar    $0x6,%edx
  and    $0x3f,%edx
  or     $0xffffff80,%edx
  mov    %dl,0x3(%rdi)
  lea    0x5(%rdi),%rdx
  and    $0x3f,%eax
  or     $0xffffff80,%eax
  mov    %al,0x4(%rdi)
  jmp    L2
L87:
  mov    %esi,%edx
  sar    $0x1e,%edx
  or     $0xfffffffc,%edx
  mov    %dl,(%rdi)
  mov    %esi,%edx
  sar    $0x18,%edx
  and    $0x3f,%edx
  or     $0xffffff80,%edx
  mov    %dl,0x1(%rdi)
  mov    %esi,%edx
  sar    $0x12,%edx
  and    $0x3f,%edx
  or     $0xffffff80,%edx
  mov    %dl,0x2(%rdi)
  mov    %esi,%edx
  sar    $0xc,%edx
  and    $0x3f,%edx
  or     $0xffffff80,%edx
  mov    %dl,0x3(%rdi)
  mov    %esi,%edx
  sar    $0x6,%edx
  and    $0x3f,%edx
  or     $0xffffff80,%edx
  mov    %dl,0x4(%rdi)
  lea    0x6(%rdi),%rdx
  and    $0x3f,%eax
  or     $0xffffff80,%eax
  mov    %al,0x5(%rdi)
  jmp    L2
```

assistant: ```c
char *_xos_utf8_put_char(char *out, int chr) {
  if (chr < 0x80) {
    *out++ = chr;
  } else if (chr < 0x800) {
    *out++ = 0xc0 | ((chr >> 6) & 0x1f);
    *out++ = 0x80 | (chr & 0x3f);
  } else if (chr < 0x10000) {
    *out++ = 0xe0 | ((chr >> 12) & 0x0f);
    *out++ = 0x80 | ((chr >> 6) & 0x3f);
    *out++ = 0x80 | (chr & 0x3f);
  } else if (chr < 0x200000) {
    *out++ = 0xf0 | ((chr >> 18) & 0x07);
    *out++ = 0x80 | ((chr >> 12) & 0x3f);
    *out++ = 0x80 | ((chr >> 6) & 0x3f);
    *out++ = 0x80 | (chr & 0x3f);
  } else if (chr < 0x4000000) {
    *out++ = 0xf8 | ((chr >> 24) & 0x03);
    *out++ = 0x80 | ((chr >> 18) & 0x3f);
    *out++ = 0x80 | ((chr >> 12) & 0x3f);
    *out++ = 0x80 | ((chr >> 6) & 0x3f);
    *out++ = 0x80 | (chr & 0x3f);
  } else if (chr < 0x80000000) {
    *out++ = 0xfc | ((chr >> 30) & 0x01);
    *out++ = 0x80 | ((chr >> 24) & 0x3f);
    *out++ = 0x80 | ((chr >> 18) & 0x3f);
    *out++ = 0x80 | ((chr >> 12) & 0x3f);
    *out++ = 0x80 | ((chr >> 6) & 0x3f);
    *out++ = 0x80 | (chr & 0x3f);
  }
  return out;
}
```