user: 请从给定的汇编指令推导出C源代码:

```asm
<pkcs7_encode_rinfo>:
  endbr64
  push   %r15
  push   %r14
  mov    %edx,%r14d
  push   %r13
  mov    %rsi,%r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x28,%rsp
  mov    0x4(%rdi),%edi
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  call   <X509_get_pubkey@plt>
  test   %rax,%rax
  je     L79
  xor    %esi,%esi
  mov    %rax,%rdi
  mov    %rax,%rbp
  call   <EVP_PKEY_CTX_new@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L79
  mov    %rax,%rdi
  call   <EVP_PKEY_encrypt_init@plt>
  test   %rax,%rax
  jle    L101
  mov    D21(%rip),%rax
  xor    %r8d,%r8d
  mov    %rbx,%r9
  mov    %r12,%rdi
  mov    $0xffffffff,%esi
  mov    (%rax),%ecx
  mov    D49(%rip),%rax
  mov    (%rax),%edx
  call   <EVP_PKEY_CTX_ctrl@plt>
  test   %rax,%rax
  jle    L58
  lea    0x10(%rsp),%rdx
  xor    %esi,%esi
  mov    %r14d,%r8d
  mov    %r13,%rcx
  mov    %r12,%rdi
  mov    %rdx,0x8(%rsp)
  call   <EVP_PKEY_encrypt@plt>
  test   %rax,%rax
  jle    L101
  mov    0x10(%rsp),%rdi
  call   <OPENSSL_malloc@plt>
  mov    0x8(%rsp),%rdx
  test   %rax,%rax
  mov    %rax,%r15
  je     L50
  mov    %r14d,%r8d
  mov    %r13,%rcx
  mov    %rax,%rsi
  mov    %r12,%rdi
  call   <EVP_PKEY_encrypt@plt>
  test   %rax,%rax
  jle    L52
  mov    0x10(%rsp),%rdx
  mov    (%rbx),%edi
  mov    %r15,%rsi
  call   <ASN1_STRING_set0@plt>
  mov    %rbp,%rdi
  call   <EVP_PKEY_free@plt>
  mov    %r12,%rdi
  call   <EVP_PKEY_CTX_free@plt>
  mov    $0x1,%eax
  jmp    L7
  xchg   %ax,%ax
L52:
  mov    %rbp,%rdi
  call   <EVP_PKEY_free@plt>
  mov    %r12,%rdi
  call   <EVP_PKEY_CTX_free@plt>
  mov    %r15,%rdi
  call   <OPENSSL_free@plt>
L79:
  xor    %eax,%eax
L7:
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L5
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L58:
  mov    D51(%rip),%rax
  mov    (%rax),%esi
  mov    D5(%rip),%rax
  mov    (%rax),%edi
  call   <PKCS7err@plt>
  nopw   0x0(%rax,%rax,1)
L101:
  mov    %rbp,%rdi
  call   <EVP_PKEY_free@plt>
  mov    %r12,%rdi
  call   <EVP_PKEY_CTX_free@plt>
  xor    %eax,%eax
  jmp    L7
  nopl   0x0(%rax)
L50:
  mov    D10(%rip),%rax
  mov    (%rax),%esi
  mov    D5(%rip),%rax
  mov    (%rax),%edi
  call   <PKCS7err@plt>
  jmp    L101
L5:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int pkcs7_encode_rinfo(PKCS7_RECIP_INFO *ri, unsigned char *key, int keylen) {
  EVP_PKEY_CTX *pctx = NULL;
  EVP_PKEY *pkey = NULL;
  unsigned char *ek = NULL;
  int ret = 0;
  size_t eklen;
  pkey = X509_get_pubkey(ri->cert);
  if (!pkey)
    return 0;
  pctx = EVP_PKEY_CTX_new(pkey, NULL);
  if (!pctx)
    return 0;
  if (EVP_PKEY_encrypt_init(pctx) <= 0)
    goto err;
  if (EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_ENCRYPT, EVP_PKEY_CTRL_PKCS7_ENCRYPT, 0, ri) <= 0) {
    PKCS7err(PKCS7_F_PKCS7_ENCODE_RINFO, PKCS7_R_CTRL_ERROR);
    goto err;
  }
  if (EVP_PKEY_encrypt(pctx, NULL, &eklen, key, keylen) <= 0)
    goto err;
  ek = OPENSSL_malloc(eklen);
  if (ek == NULL) {
    PKCS7err(PKCS7_F_PKCS7_ENCODE_RINFO, ERR_R_MALLOC_FAILURE);
    goto err;
  }
  if (EVP_PKEY_encrypt(pctx, ek, &eklen, key, keylen) <= 0)
    goto err;
  ASN1_STRING_set0(ri->enc_key, ek, eklen);
  ek = NULL;
  ret = 1;
err:
  if (pkey)
    EVP_PKEY_free(pkey);
  if (pctx)
    EVP_PKEY_CTX_free(pctx);
  if (ek)
    OPENSSL_free(ek);
  return ret;
}
```