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

```asm
<asn1_d2i_ex_primitive>:
  endbr64
  push   %r15
  pxor   %xmm0,%xmm0
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x78,%rsp
  mov    0xb0(%rsp),%eax
  mov    0xb8(%rsp),%r15
  mov    %eax,(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x68(%rsp)
  xor    %eax,%eax
  movb   $0x0,0x2b(%rsp)
  movq   $0x0,0x60(%rsp)
  movaps %xmm0,0x40(%rsp)
  movaps %xmm0,0x50(%rsp)
  test   %rdi,%rdi
  je     L400
  mov    D150(%rip),%rax
  mov    %rdx,%r10
  mov    %rdi,%r13
  mov    %rsi,%r12
  mov    D44(%rip),%rdx
  mov    %rcx,%rbp
  mov    %r8d,%ebx
  mov    %r9d,%r14d
  mov    (%rax),%eax
  mov    (%rdx),%rdi
  cmp    %rdi,(%rcx)
  je     L437
  mov    0x8(%rcx),%edx
  lea    0x38(%rsp),%rsi
  lea    0x30(%rsp),%r11
  mov    %rsi,0x8(%rsp)
  mov    %edx,0x2c(%rsp)
  cmp    %eax,%edx
  je     L170
L149:
  cmp    $0xffffffff,%ebx
  je     L322
L387:
  mov    (%r12),%rax
  lea    0x2a(%rsp),%rcx
  sub    $0x8,%rsp
  xor    %edx,%edx
  xor    %esi,%esi
  mov    %r11,%rdi
  mov    %rax,0x40(%rsp)
  push   %r15
  movsbl 0x10(%rsp),%eax
  push   %rax
  push   %r14
  push   %rbx
  push   %r10
  mov    0x38(%rsp),%r9
  lea    0x59(%rsp),%r8
  call   <asn1_check_tlen@plt>
  add    $0x30,%rsp
  mov    %eax,%r14d
  test   %eax,%eax
  je     L343
  cmp    $0xffffffff,%eax
  je     L331
  mov    D209(%rip),%rax
  mov    0x2c(%rsp),%ecx
  mov    (%rax),%edx
  mov    D47(%rip),%rax
  cmp    (%rax),%ecx
  je     L414
  mov    D203(%rip),%rax
  cmp    (%rax),%ecx
  je     L414
  cmp    %edx,%ecx
  je     L92
  cmpb   $0x0,0x29(%rsp)
  je     L185
  mov    D136(%rip),%rax
  cmp    (%rax),%ecx
  je     L198
  mov    D270(%rip),%rax
  cmp    (%rax),%ecx
  je     L198
  mov    D43(%rip),%rax
  cmp    (%rax),%ecx
  je     L198
  mov    D213(%rip),%rax
  cmp    (%rax),%ecx
  je     L198
  mov    D2(%rip),%rax
  cmp    (%rax),%ecx
  je     L198
  movb   $0x1,0x2b(%rsp)
  movsbl 0x2a(%rsp),%ecx
  lea    0x40(%rsp),%r14
  sub    $0x8,%rsp
  mov    D163(%rip),%rax
  mov    $0xffffffff,%r8d
  mov    %r14,%rdi
  movzbl (%rax),%r9d
  push   $0x0
  mov    0x40(%rsp),%rdx
  mov    0x18(%rsp),%rsi
  call   <asn1_collect@plt>
  pop    %rdx
  pop    %rcx
  test   %eax,%eax
  je     L188
  mov    0x40(%rsp),%rdx
  mov    %r14,%rdi
  lea    0x1(%rdx),%rsi
  mov    %rdx,(%rsp)
  call   <BUF_MEM_grow_clean@plt>
  mov    (%rsp),%rdx
  test   %eax,%eax
  mov    %eax,%r14d
  je     L67
  mov    0x48(%rsp),%r14
  mov    0x2c(%rsp),%ecx
  movq   $0x0,(%r14,%rdx,8)
  jmp    L435
L170:
  test   %r8d,%r8d
  js     L381
  mov    D222(%rip),%rax
  mov    (%rax),%esi
  mov    D96(%rip),%rax
  mov    (%rax),%edi
  call   <ASN1err@plt>
L194:
  xor    %r14d,%r14d
L331:
  mov    0x68(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L135
  add    $0x78,%rsp
  mov    %r14d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L414:
  cmp    %edx,%ecx
  je     L92
  cmpb   $0x0,0x29(%rsp)
  je     L417
L6:
  movsbl 0x2a(%rsp),%edx
  mov    (%r12),%r14
  mov    0x30(%rsp),%rsi
  test   %dl,%dl
  jne    L330
  mov    0x38(%rsp),%rax
  mov    %rax,%rdx
  add    %rsi,%rax
  mov    %rax,0x38(%rsp)
  sub    %r14,%rdx
  add    %rsi,%rdx
L435:
  mov    %rbp,%r9
  lea    0x2b(%rsp),%r8
  mov    %r14,%rsi
  mov    %r13,%rdi
  call   <asn1_ex_c2i@plt>
  test   %eax,%eax
  je     L188
  mov    0x38(%rsp),%rax
  mov    $0x1,%r14d
  mov    %rax,(%r12)
L189:
  cmpb   $0x0,0x2b(%rsp)
  je     L331
  mov    0x48(%rsp),%rdi
  call   <OPENSSL_free@plt>
  jmp    L331
  nopl   0x0(%rax,%rax,1)
L8:
  mov    $0xffffffff,%ebx
L381:
  cmpb   $0x0,(%rsp)
  jne    L47
  mov    (%r12),%rax
  lea    0x38(%rsp),%r9
  lea    0x30(%rsp),%r11
  xor    %ecx,%ecx
  mov    %r9,0x8(%rsp)
  lea    0x2c(%rsp),%rsi
  sub    $0x8,%rsp
  xor    %edi,%edi
  mov    %rax,0x40(%rsp)
  xor    %r8d,%r8d
  mov    %r11,%rdx
  push   %r15
  push   $0x0
  push   $0x0
  push   $0xffffffffffffffff
  push   %r10
  mov    %r10,0x48(%rsp)
  mov    %r11,0x40(%rsp)
  call   <asn1_check_tlen@plt>
  add    $0x30,%rsp
  mov    0x10(%rsp),%r11
  mov    0x18(%rsp),%r10
  test   %eax,%eax
  je     L98
  mov    D163(%rip),%rax
  movzbl (%rax),%eax
  cmp    %al,0x30(%rsp)
  je     L149
  mov    D209(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,0x2c(%rsp)
  jmp    L149
  nopw   0x0(%rax,%rax,1)
L437:
  mov    %r8d,0x2c(%rsp)
  cmp    %eax,%r8d
  je     L8
  lea    0x38(%rsp),%rax
  lea    0x30(%rsp),%r11
  mov    %rax,0x8(%rsp)
L336:
  mov    D163(%rip),%rax
  movzbl (%rax),%r14d
  jmp    L387
  nopl   (%rax)
L330:
  mov    0x8(%rsp),%rdi
  call   <asn1_find_end@plt>
  test   %eax,%eax
  je     L188
  mov    0x38(%rsp),%rdx
  mov    0x2c(%rsp),%ecx
  sub    %r14,%rdx
  jmp    L435
  nop
L47:
  mov    D15(%rip),%rax
  mov    (%rax),%esi
  mov    D96(%rip),%rax
  mov    (%rax),%edi
  call   <ASN1err@plt>
  jmp    L194
  nopl   0x0(%rax)
L188:
  xor    %r14d,%r14d
  jmp    L189
  nopl   0x0(%rax,%rax,1)
L343:
  mov    D172(%rip),%rax
  mov    (%rax),%esi
  mov    D96(%rip),%rax
  mov    (%rax),%edi
  call   <ASN1err@plt>
  jmp    L331
  nopl   0x0(%rax)
L92:
  test   %r15,%r15
  je     L6
  movq   $0x0,(%r15)
  jmp    L6
  nopl   (%rax)
L400:
  mov    D200(%rip),%rax
L58:
  mov    (%rax),%esi
  mov    D96(%rip),%rax
  mov    (%rax),%edi
  call   <ASN1err@plt>
  jmp    L194
  nopl   0x0(%rax)
L185:
  mov    0x38(%rsp),%r14
  mov    0x30(%rsp),%rdx
  lea    (%r14,%rdx,1),%rax
  mov    %rax,0x38(%rsp)
  jmp    L435
L417:
  mov    D112(%rip),%rax
  jmp    L58
  nopl   0x0(%rax)
L322:
  mov    0x2c(%rsp),%ebx
  jmp    L336
  nopl   0x0(%rax)
L198:
  mov    D168(%rip),%rax
  jmp    L58
  nopl   0x0(%rax)
L98:
  mov    D172(%rip),%rax
  mov    (%rax),%esi
  mov    D96(%rip),%rax
  mov    (%rax),%edi
  call   <ASN1err@plt>
  jmp    L194
L67:
  mov    D62(%rip),%rax
  mov    (%rax),%esi
  mov    D96(%rip),%rax
  mov    (%rax),%edi
  call   <ASN1err@plt>
  jmp    L189
L135:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int asn1_d2i_ex_primitive(ASN1_VALUE **pval, const unsigned char **in, long inlen, const ASN1_ITEM *it, int tag, int aclass, char opt, ASN1_TLC *ctx) {
  int ret = 0, utype;
  long plen;
  char cst, inf, free_cont = 0;
  const unsigned char *p;
  BUF_MEM buf = {0, NULL, 0, 0};
  const unsigned char *cont = NULL;
  long len;
  if (!pval) {
    ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ASN1_R_ILLEGAL_NULL);
    return 0;
  }
  if (it->itype == ASN1_ITYPE_MSTRING) {
    utype = tag;
    tag = -1;
  } else
    utype = it->utype;
  if (utype == V_ASN1_ANY) {
    unsigned char oclass;
    if (tag >= 0) {
      ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ASN1_R_ILLEGAL_TAGGED_ANY);
      return 0;
    }
    if (opt) {
      ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ASN1_R_ILLEGAL_OPTIONAL_ANY);
      return 0;
    }
    p = *in;
    ret = asn1_check_tlen(NULL, &utype, &oclass, NULL, NULL, &p, inlen, -1, 0, 0, ctx);
    if (!ret) {
      ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ERR_R_NESTED_ASN1_ERROR);
      return 0;
    }
    if (oclass != V_ASN1_UNIVERSAL)
      utype = V_ASN1_OTHER;
  }
  if (tag == -1) {
    tag = utype;
    aclass = V_ASN1_UNIVERSAL;
  }
  p = *in;
  ret = asn1_check_tlen(&plen, NULL, NULL, &inf, &cst, &p, inlen, tag, aclass, opt, ctx);
  if (!ret) {
    ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ERR_R_NESTED_ASN1_ERROR);
    return 0;
  } else if (ret == -1)
    return -1;
  ret = 0;
  if ((utype == V_ASN1_SEQUENCE) || (utype == V_ASN1_SET) || (utype == V_ASN1_OTHER)) {
    if (utype == V_ASN1_OTHER) {
      if (ctx)
        (ctx)->valid = 0;
    } else if (!cst) {
      ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ASN1_R_TYPE_NOT_CONSTRUCTED);
      return 0;
    }
    cont = *in;
    if (inf) {
      if (!asn1_find_end(&p, plen, inf))
        goto err;
      len = p - cont;
    } else {
      len = p - cont + plen;
      p += plen;
    }
  } else if (cst) {
    if (utype == V_ASN1_NULL || utype == V_ASN1_BOOLEAN || utype == V_ASN1_OBJECT || utype == V_ASN1_INTEGER || utype == V_ASN1_ENUMERATED) {
      ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ASN1_R_TYPE_NOT_PRIMITIVE);
      return 0;
    }
    free_cont = 1;
    if (!asn1_collect(&buf, &p, plen, inf, -1, V_ASN1_UNIVERSAL, 0)) {
      goto err;
    }
    len = buf.length;
    if (!BUF_MEM_grow_clean(&buf, len + 1)) {
      ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ERR_R_MALLOC_FAILURE);
      goto err;
    }
    buf.data[len] = 0;
    cont = (const unsigned char *)buf.data;
  } else {
    cont = p;
    len = plen;
    p += plen;
  }
  if (!asn1_ex_c2i(pval, cont, len, utype, &free_cont, it))
    goto err;
  *in = p;
  ret = 1;
err:
  if (free_cont)
    OPENSSL_free(buf.data);
  return ret;
}
```