user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<asn1_header_encode>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  mov    %edx,-0x20(%rbp)
  mov    %ecx,-0x24(%rbp)
  mov    %r8,-0x30(%rbp)
  mov    -0x30(%rbp),%rax
  mov    (%rax),%eax
  cmp    $0x1,%eax
  ja     L52
  mov    D7(%rip),%rax
  mov    (%rax),%eax
  neg    %eax
  jmp    L65
L52:
  mov    -0x18(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,-0x8(%rbp)
  mov    -0x30(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x1c(%rbp),%eax
  shl    $0x6,%eax
  mov    %eax,%edx
  mov    -0x20(%rbp),%eax
  shl    $0x5,%eax
  and    $0x20,%eax
  mov    %edx,%esi
  or     %eax,%esi
  mov    -0x24(%rbp),%eax
  and    $0x1f,%eax
  mov    %eax,%ecx
  mov    -0x8(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x8(%rbp)
  or     %ecx,%esi
  mov    %esi,%edx
  mov    %dl,(%rax)
  subl   $0x1,-0xc(%rbp)
  mov    -0xc(%rbp),%eax
  sub    $0x1,%eax
  cmp    $0x7f,%eax
  ja     L4
  subl   $0x1,-0xc(%rbp)
  mov    -0xc(%rbp),%eax
  mov    %eax,%ecx
  mov    -0x8(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x8(%rbp)
  and    $0x7f,%ecx
  mov    %ecx,%edx
  mov    %dl,(%rax)
  jmp    L96
L4:
  mov    -0xc(%rbp),%eax
  sub    $0x2,%eax
  cmp    $0xff,%eax
  ja     L51
  subl   $0x2,-0xc(%rbp)
  mov    -0x8(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x8(%rbp)
  movb   $0x81,(%rax)
  mov    -0x8(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x8(%rbp)
  mov    -0xc(%rbp),%edx
  mov    %dl,(%rax)
  jmp    L96
L51:
  mov    -0xc(%rbp),%eax
  sub    $0x3,%eax
  cmp    $0xffff,%eax
  ja     L3
  subl   $0x3,-0xc(%rbp)
  mov    -0x8(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x8(%rbp)
  movb   $0x82,(%rax)
  mov    -0xc(%rbp),%eax
  shr    $0x8,%eax
  mov    %eax,%ecx
  mov    -0x8(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x8(%rbp)
  mov    %ecx,%edx
  mov    %dl,(%rax)
  mov    -0x8(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x8(%rbp)
  mov    -0xc(%rbp),%edx
  mov    %dl,(%rax)
  jmp    L96
L3:
  mov    -0xc(%rbp),%eax
  sub    $0x4,%eax
  cmp    $0xffffff,%eax
  ja     L58
  subl   $0x4,-0xc(%rbp)
  mov    -0x8(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x8(%rbp)
  movb   $0x83,(%rax)
  mov    -0xc(%rbp),%eax
  shr    $0x10,%eax
  mov    %eax,%ecx
  mov    -0x8(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x8(%rbp)
  mov    %ecx,%edx
  mov    %dl,(%rax)
  mov    -0xc(%rbp),%eax
  shr    $0x8,%eax
  mov    %eax,%ecx
  mov    -0x8(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x8(%rbp)
  mov    %ecx,%edx
  mov    %dl,(%rax)
  mov    -0x8(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x8(%rbp)
  mov    -0xc(%rbp),%edx
  mov    %dl,(%rax)
  jmp    L96
L58:
  subl   $0x5,-0xc(%rbp)
  mov    -0x8(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x8(%rbp)
  movb   $0x84,(%rax)
  mov    -0xc(%rbp),%eax
  shr    $0x18,%eax
  mov    %eax,%ecx
  mov    -0x8(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x8(%rbp)
  mov    %ecx,%edx
  mov    %dl,(%rax)
  mov    -0xc(%rbp),%eax
  shr    $0x10,%eax
  mov    %eax,%ecx
  mov    -0x8(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x8(%rbp)
  mov    %ecx,%edx
  mov    %dl,(%rax)
  mov    -0xc(%rbp),%eax
  shr    $0x8,%eax
  mov    %eax,%ecx
  mov    -0x8(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x8(%rbp)
  mov    %ecx,%edx
  mov    %dl,(%rax)
  mov    -0x8(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x8(%rbp)
  mov    -0xc(%rbp),%edx
  mov    %dl,(%rax)
L96:
  mov    -0x18(%rbp),%rax
  mov    -0x8(%rbp),%rdx
  mov    %rdx,(%rax)
  mov    -0x30(%rbp),%rax
  mov    -0xc(%rbp),%edx
  mov    %edx,(%rax)
  mov    $0x0,%eax
L65:
  pop    %rbp
  ret
```

assistant: ```c
int asn1_header_encode(unsigned char **buf, unsigned int cls, unsigned int con, unsigned int tag, unsigned int *len) {
  unsigned char *loc;
  unsigned int r_len;
  if (*len < 2)
    return -EINVAL;
  loc = *buf;
  r_len = *len;
  *loc++ = ((cls & 0x3) << 6) | ((con & 0x1) << 5) | (tag & 0x1F);
  r_len -= 1;
  if (r_len - 1 < (1 << 7)) {
    r_len -= 1;
    *loc++ = (unsigned char)(r_len & 0x7F);
  } else if (r_len - 2 < (1 << 8)) {
    r_len -= 2;
    *loc++ = 0x81;
    *loc++ = (unsigned char)(r_len & 0xFF);
  } else if (r_len - 3 < (1 << 16)) {
    r_len -= 3;
    *loc++ = 0x82;
    *loc++ = (unsigned char)((r_len >> 8) & 0xFF);
    *loc++ = (unsigned char)(r_len & 0xFF);
  } else if (r_len - 4 < (1 << 24)) {
    r_len -= 4;
    *loc++ = 0x83;
    *loc++ = (unsigned char)((r_len >> 16) & 0xFF);
    *loc++ = (unsigned char)((r_len >> 8) & 0xFF);
    *loc++ = (unsigned char)(r_len & 0xFF);
  } else {
    r_len -= 5;
    *loc++ = 0x84;
    *loc++ = (unsigned char)((r_len >> 24) & 0xFF);
    *loc++ = (unsigned char)((r_len >> 16) & 0xFF);
    *loc++ = (unsigned char)((r_len >> 8) & 0xFF);
    *loc++ = (unsigned char)(r_len & 0xFF);
  }
  *buf = loc;
  *len = r_len;
  return 0;
}
```