user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<asn1_check_tlen>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %rdi,(%rsp)
  mov    %rsi,0x8(%rsp)
  mov    %rdx,0x10(%rsp)
  mov    %rcx,0x18(%rsp)
  mov    %r8,%r12
  mov    %r9,%rbp
  mov    0x98(%rsp),%r15d
  mov    0xa0(%rsp),%rbx
  mov    %fs:0x28,%rax
  mov    %rax,0x38(%rsp)
  xor    %eax,%eax
  mov    (%r9),%r13
  mov    %r13,0x30(%rsp)
  test   %rbx,%rbx
  je     L191
  cmpl   $0x0,(%rbx)
  je     L41
  mov    0x4(%rbx),%eax
  mov    0x8(%rbx),%rdx
  mov    %rdx,0x28(%rsp)
  mov    0x10(%rbx),%edx
  mov    %edx,0x24(%rsp)
  mov    0x14(%rbx),%edx
  mov    %edx,0x20(%rsp)
  movslq 0x18(%rbx),%rdx
  add    %r13,%rdx
  mov    %rdx,0x30(%rsp)
L36:
  test   $0x80,%al
  jne    L205
L197:
  cmpl   $0x0,0x88(%rsp)
  js     L199
  mov    0x88(%rsp),%edi
  cmp    %edi,0x20(%rsp)
  je     L69
L99:
  mov    $0xffffffff,%r14d
  test   %r15b,%r15b
  jne    L145
  test   %rbx,%rbx
  je     L161
  movl   $0x0,(%rbx)
L161:
  mov    D81(%rip),%rax
  mov    (%rax),%esi
  mov    D73(%rip),%rax
  mov    (%rax),%edi
  call   <ASN1err@plt>
  mov    $0x0,%r14d
  jmp    L145
L69:
  mov    0x90(%rsp),%ecx
  cmp    %ecx,0x24(%rsp)
  jne    L99
  test   %rbx,%rbx
  je     L199
  movl   $0x0,(%rbx)
L199:
  test   $0x1,%al
  je     L100
  sub    0x30(%rsp),%r13
  mov    0x80(%rsp),%rbx
  lea    0x0(%r13,%rbx,1),%rdx
  mov    %rdx,0x28(%rsp)
L100:
  mov    0x18(%rsp),%rsi
  test   %rsi,%rsi
  je     L81
  mov    %eax,%edx
  and    $0x1,%edx
  mov    %dl,(%rsi)
L81:
  test   %r12,%r12
  je     L179
  mov    D80(%rip),%rdx
  and    (%rdx),%al
  mov    %al,(%r12)
L179:
  mov    (%rsp),%rdi
  test   %rdi,%rdi
  je     L82
  mov    0x28(%rsp),%rax
  mov    %rax,(%rdi)
L82:
  mov    0x10(%rsp),%rcx
  test   %rcx,%rcx
  je     L139
  mov    0x24(%rsp),%eax
  mov    %al,(%rcx)
L139:
  mov    0x8(%rsp),%rsi
  test   %rsi,%rsi
  je     L95
  mov    0x20(%rsp),%eax
  mov    %eax,(%rsi)
L95:
  mov    0x30(%rsp),%rax
  mov    %rax,0x0(%rbp)
  mov    $0x1,%r14d
L145:
  mov    0x38(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L55
  mov    %r14d,%eax
  add    $0x48,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L205:
  mov    D67(%rip),%rax
  mov    (%rax),%esi
  mov    D73(%rip),%rax
  mov    (%rax),%edi
  call   <ASN1err@plt>
  movl   $0x0,(%rbx)
  mov    $0x0,%r14d
  jmp    L145
L191:
  lea    0x24(%rsp),%rcx
  lea    0x20(%rsp),%rdx
  lea    0x28(%rsp),%rsi
  lea    0x30(%rsp),%rdi
  mov    0x80(%rsp),%r8
  call   <ASN1_get_object@plt>
  test   $0x80,%al
  je     L197
  mov    D67(%rip),%rax
  mov    (%rax),%esi
  mov    D73(%rip),%rax
  mov    (%rax),%edi
  call   <ASN1err@plt>
  mov    $0x0,%r14d
  jmp    L145
L41:
  lea    0x24(%rsp),%rcx
  lea    0x20(%rsp),%rdx
  lea    0x28(%rsp),%rsi
  lea    0x30(%rsp),%rdi
  mov    0x80(%rsp),%r8
  call   <ASN1_get_object@plt>
  mov    %eax,0x4(%rbx)
  mov    0x28(%rsp),%rcx
  mov    %rcx,0x8(%rbx)
  mov    0x24(%rsp),%edx
  mov    %edx,0x10(%rbx)
  mov    0x20(%rsp),%edx
  mov    %edx,0x14(%rbx)
  mov    0x30(%rsp),%rdx
  sub    %r13,%rdx
  mov    %edx,0x18(%rbx)
  movl   $0x1,(%rbx)
  mov    %eax,%r14d
  and    $0x81,%r14d
  jne    L36
  movslq %edx,%rdx
  add    %rcx,%rdx
  cmp    0x80(%rsp),%rdx
  jle    L36
  mov    D82(%rip),%rax
  mov    (%rax),%esi
  mov    D73(%rip),%rax
  mov    (%rax),%edi
  call   <ASN1err@plt>
  movl   $0x0,(%rbx)
  jmp    L145
L55:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int asn1_check_tlen(long *olen, int *otag, unsigned char *oclass, char *inf, char *cst, const unsigned char **in, long len, int exptag, int expclass, char opt, ASN1_TLC *ctx) {
  int i;
  int ptag, pclass;
  long plen;
  const unsigned char *p, *q;
  p = *in;
  q = p;
  if (ctx && ctx->valid) {
    i = ctx->ret;
    plen = ctx->plen;
    pclass = ctx->pclass;
    ptag = ctx->ptag;
    p += ctx->hdrlen;
  } else {
    i = ASN1_get_object(&p, &plen, &ptag, &pclass, len);
    if (ctx) {
      ctx->ret = i;
      ctx->plen = plen;
      ctx->pclass = pclass;
      ctx->ptag = ptag;
      ctx->hdrlen = p - q;
      ctx->valid = 1;
      if (!(i & 0x81) && ((plen + ctx->hdrlen) > len)) {
        ASN1err(ASN1_F_ASN1_CHECK_TLEN, ASN1_R_TOO_LONG);
        if (ctx)
          (ctx)->valid = 0;
        return 0;
      }
    }
  }
  if (i & 0x80) {
    ASN1err(ASN1_F_ASN1_CHECK_TLEN, ASN1_R_BAD_OBJECT_HEADER);
    if (ctx)
      (ctx)->valid = 0;
    return 0;
  }
  if (exptag >= 0) {
    if ((exptag != ptag) || (expclass != pclass)) {
      if (opt)
        return -1;
      if (ctx)
        (ctx)->valid = 0;
      ASN1err(ASN1_F_ASN1_CHECK_TLEN, ASN1_R_WRONG_TAG);
      return 0;
    }
    if (ctx)
      (ctx)->valid = 0;
  }
  if (i & 1)
    plen = len - (p - q);
  if (inf)
    *inf = i & 1;
  if (cst)
    *cst = i & V_ASN1_CONSTRUCTED;
  if (olen)
    *olen = plen;
  if (oclass)
    *oclass = pclass;
  if (otag)
    *otag = ptag;
  *in = p;
  return 1;
}
```