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

```asm
<asn1_template_ex_d2i>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  test   %rdi,%rdi
  je     L31
  mov    %rdi,%r12
  mov    %rsi,%r13
  mov    %rdx,%rsi
  mov    %rcx,%rbp
  mov    %r9,%r14
  mov    (%rcx),%edx
  mov    D95(%rip),%rax
  mov    (%rax),%eax
  mov    0x0(%r13),%rcx
  mov    %rcx,0x10(%rsp)
  mov    D3(%rip),%rcx
  mov    %edx,%ebx
  and    (%rcx),%ebx
  je     L58
  lea    0x6(%rsp),%rcx
  lea    0x8(%rsp),%rdi
  sub    $0x8,%rsp
  push   %r9
  movsbl %r8b,%r8d
  push   %r8
  and    %edx,%eax
  push   %rax
  mov    0x4(%rbp),%eax
  push   %rax
  push   %rsi
  lea    0x40(%rsp),%r9
  lea    0x37(%rsp),%r8
  mov    $0x0,%edx
  mov    $0x0,%esi
  call   <asn1_check_tlen@plt>
  mov    %eax,%ebx
  mov    0x40(%rsp),%r15
  add    $0x30,%rsp
  test   %eax,%eax
  je     L66
  cmp    $0xffffffff,%eax
  je     L115
  cmpb   $0x0,0x7(%rsp)
  je     L15
  lea    0x10(%rsp),%rsi
  mov    %r14,%r9
  mov    $0x0,%r8d
  mov    %rbp,%rcx
  mov    0x8(%rsp),%rdx
  mov    %r12,%rdi
  call   <asn1_template_noexp_d2i@plt>
  mov    %eax,%ebx
  test   %eax,%eax
  je     L129
  mov    %r15,%rsi
  sub    0x10(%rsp),%rsi
  add    0x8(%rsp),%rsi
  mov    %rsi,0x8(%rsp)
  cmpb   $0x0,0x6(%rsp)
  jne    L26
  test   %rsi,%rsi
  jne    L128
L166:
  mov    0x10(%rsp),%rax
  mov    %rax,0x0(%r13)
  mov    $0x1,%ebx
  jmp    L115
L66:
  mov    D31(%rip),%rax
  mov    (%rax),%esi
  mov    D99(%rip),%rax
  mov    (%rax),%edi
  call   <ASN1err@plt>
  jmp    L115
L15:
  mov    D111(%rip),%rax
  mov    (%rax),%esi
  mov    D99(%rip),%rax
  mov    (%rax),%edi
  call   <ASN1err@plt>
  mov    $0x0,%ebx
  jmp    L115
L129:
  mov    D31(%rip),%rax
  mov    (%rax),%esi
  mov    D99(%rip),%rax
  mov    (%rax),%edi
  call   <ASN1err@plt>
  jmp    L115
L26:
  lea    0x10(%rsp),%rdi
  call   <asn1_check_eoc@plt>
  test   %eax,%eax
  jne    L166
  mov    D70(%rip),%rax
  mov    (%rax),%esi
  mov    D99(%rip),%rax
  mov    (%rax),%edi
  call   <ASN1err@plt>
  jmp    L16
L128:
  mov    D58(%rip),%rax
  mov    (%rax),%esi
  mov    D99(%rip),%rax
  mov    (%rax),%edi
  call   <ASN1err@plt>
L16:
  mov    %rbp,%rsi
  mov    %r12,%rdi
  call   <ASN1_template_free@plt>
  movq   $0x0,(%r12)
  mov    $0x0,%ebx
  jmp    L115
L58:
  movsbl %r8b,%r8d
  mov    %rbp,%rcx
  mov    %rsi,%rdx
  mov    %r13,%rsi
  call   <asn1_template_noexp_d2i@plt>
  mov    %eax,%ebx
L115:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L101
  mov    %ebx,%eax
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L31:
  mov    $0x0,%ebx
  jmp    L115
L101:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int asn1_template_ex_d2i(ASN1_VALUE **val, const unsigned char **in, long inlen, const ASN1_TEMPLATE *tt, char opt, ASN1_TLC *ctx) {
  int flags, aclass;
  int ret;
  long len;
  const unsigned char *p, *q;
  char exp_eoc;
  if (!val)
    return 0;
  flags = tt->flags;
  aclass = flags & ASN1_TFLG_TAG_CLASS;
  p = *in;
  if (flags & ASN1_TFLG_EXPTAG) {
    char cst;
    ret = asn1_check_tlen(&len, NULL, NULL, &exp_eoc, &cst, &p, inlen, tt->tag, aclass, opt, ctx);
    q = p;
    if (!ret) {
      ASN1err(ASN1_F_ASN1_TEMPLATE_EX_D2I, ERR_R_NESTED_ASN1_ERROR);
      return 0;
    } else if (ret == -1)
      return -1;
    if (!cst) {
      ASN1err(ASN1_F_ASN1_TEMPLATE_EX_D2I, ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED);
      return 0;
    }
    ret = asn1_template_noexp_d2i(val, &p, len, tt, 0, ctx);
    if (!ret) {
      ASN1err(ASN1_F_ASN1_TEMPLATE_EX_D2I, ERR_R_NESTED_ASN1_ERROR);
      return 0;
    }
    len -= p - q;
    if (exp_eoc) {
      if (!asn1_check_eoc(&p, len)) {
        ASN1err(ASN1_F_ASN1_TEMPLATE_EX_D2I, ASN1_R_MISSING_EOC);
        goto err;
      }
    } else {
      if (len) {
        ASN1err(ASN1_F_ASN1_TEMPLATE_EX_D2I, ASN1_R_EXPLICIT_LENGTH_MISMATCH);
        goto err;
      }
    }
  } else
    return asn1_template_noexp_d2i(val, in, inlen, tt, opt, ctx);
  *in = p;
  return 1;
err:
  ASN1_template_free(val, tt);
  *val = NULL;
  return 0;
}
```