user: Translate the below assembly code into C programming language:

```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     L311
  mov    D190(%rip),%rax
  mov    %rdx,%r10
  mov    %rdi,%r13
  mov    %rsi,%r12
  mov    D173(%rip),%rdx
  mov    %rcx,%rbp
  mov    %r8d,%ebx
  mov    %r9d,%r14d
  mov    (%rax),%eax
  mov    (%rdx),%rdi
  cmp    %rdi,(%rcx)
  je     L59
  mov    0x8(%rcx),%edx
  lea    0x38(%rsp),%rsi
  lea    0x30(%rsp),%r11
  mov    %rsi,0x8(%rsp)
  mov    %edx,0x2c(%rsp)
  cmp    %eax,%edx
  je     L102
L275:
  cmp    $0xffffffff,%ebx
  je     L321
L407:
  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     L73
  cmp    $0xffffffff,%eax
  je     L22
  mov    D248(%rip),%rax
  mov    0x2c(%rsp),%ecx
  mov    (%rax),%edx
  mov    D202(%rip),%rax
  cmp    (%rax),%ecx
  je     L362
  mov    D148(%rip),%rax
  cmp    (%rax),%ecx
  je     L362
  cmp    %edx,%ecx
  je     L439
  cmpb   $0x0,0x29(%rsp)
  je     L52
  mov    D253(%rip),%rax
  cmp    (%rax),%ecx
  je     L246
  mov    D255(%rip),%rax
  cmp    (%rax),%ecx
  je     L246
  mov    D21(%rip),%rax
  cmp    (%rax),%ecx
  je     L246
  mov    D69(%rip),%rax
  cmp    (%rax),%ecx
  je     L246
  mov    D118(%rip),%rax
  cmp    (%rax),%ecx
  je     L246
  movb   $0x1,0x2b(%rsp)
  movsbl 0x2a(%rsp),%ecx
  lea    0x40(%rsp),%r14
  sub    $0x8,%rsp
  mov    D225(%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     L244
  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     L308
  mov    0x48(%rsp),%r14
  mov    0x2c(%rsp),%ecx
  movq   $0x0,(%r14,%rdx,8)
  jmp    L95
L102:
  test   %r8d,%r8d
  js     L371
  mov    D109(%rip),%rax
  mov    (%rax),%esi
  mov    D128(%rip),%rax
  mov    (%rax),%edi
  call   <ASN1err@plt>
L156:
  xor    %r14d,%r14d
L22:
  mov    0x68(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L384
  add    $0x78,%rsp
  mov    %r14d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L362:
  cmp    %edx,%ecx
  je     L439
  cmpb   $0x0,0x29(%rsp)
  je     L227
L35:
  movsbl 0x2a(%rsp),%edx
  mov    (%r12),%r14
  mov    0x30(%rsp),%rsi
  test   %dl,%dl
  jne    L357
  mov    0x38(%rsp),%rax
  mov    %rax,%rdx
  add    %rsi,%rax
  mov    %rax,0x38(%rsp)
  sub    %r14,%rdx
  add    %rsi,%rdx
L95:
  mov    %rbp,%r9
  lea    0x2b(%rsp),%r8
  mov    %r14,%rsi
  mov    %r13,%rdi
  call   <asn1_ex_c2i@plt>
  test   %eax,%eax
  je     L244
  mov    0x38(%rsp),%rax
  mov    $0x1,%r14d
  mov    %rax,(%r12)
L208:
  cmpb   $0x0,0x2b(%rsp)
  je     L22
  mov    0x48(%rsp),%rdi
  call   <OPENSSL_free@plt>
  jmp    L22
  nopl   0x0(%rax,%rax,1)
L241:
  mov    $0xffffffff,%ebx
L371:
  cmpb   $0x0,(%rsp)
  jne    L358
  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     L367
  mov    D225(%rip),%rax
  movzbl (%rax),%eax
  cmp    %al,0x30(%rsp)
  je     L275
  mov    D248(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,0x2c(%rsp)
  jmp    L275
  nopw   0x0(%rax,%rax,1)
L59:
  mov    %r8d,0x2c(%rsp)
  cmp    %eax,%r8d
  je     L241
  lea    0x38(%rsp),%rax
  lea    0x30(%rsp),%r11
  mov    %rax,0x8(%rsp)
L53:
  mov    D225(%rip),%rax
  movzbl (%rax),%r14d
  jmp    L407
  nopl   (%rax)
L357:
  mov    0x8(%rsp),%rdi
  call   <asn1_find_end@plt>
  test   %eax,%eax
  je     L244
  mov    0x38(%rsp),%rdx
  mov    0x2c(%rsp),%ecx
  sub    %r14,%rdx
  jmp    L95
  nop
L358:
  mov    D161(%rip),%rax
  mov    (%rax),%esi
  mov    D128(%rip),%rax
  mov    (%rax),%edi
  call   <ASN1err@plt>
  jmp    L156
  nopl   0x0(%rax)
L244:
  xor    %r14d,%r14d
  jmp    L208
  nopl   0x0(%rax,%rax,1)
L73:
  mov    D43(%rip),%rax
  mov    (%rax),%esi
  mov    D128(%rip),%rax
  mov    (%rax),%edi
  call   <ASN1err@plt>
  jmp    L22
  nopl   0x0(%rax)
L439:
  test   %r15,%r15
  je     L35
  movq   $0x0,(%r15)
  jmp    L35
  nopl   (%rax)
L311:
  mov    D265(%rip),%rax
L284:
  mov    (%rax),%esi
  mov    D128(%rip),%rax
  mov    (%rax),%edi
  call   <ASN1err@plt>
  jmp    L156
  nopl   0x0(%rax)
L52:
  mov    0x38(%rsp),%r14
  mov    0x30(%rsp),%rdx
  lea    (%r14,%rdx,1),%rax
  mov    %rax,0x38(%rsp)
  jmp    L95
L227:
  mov    D136(%rip),%rax
  jmp    L284
  nopl   0x0(%rax)
L321:
  mov    0x2c(%rsp),%ebx
  jmp    L53
  nopl   0x0(%rax)
L246:
  mov    D111(%rip),%rax
  jmp    L284
  nopl   0x0(%rax)
L367:
  mov    D43(%rip),%rax
  mov    (%rax),%esi
  mov    D128(%rip),%rax
  mov    (%rax),%edi
  call   <ASN1err@plt>
  jmp    L156
L308:
  mov    D67(%rip),%rax
  mov    (%rax),%esi
  mov    D128(%rip),%rax
  mov    (%rax),%edi
  call   <ASN1err@plt>
  jmp    L208
L384:
  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;
}
```