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

```asm
<cms_copy_content>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x1018(%rsp)
  xor    %eax,%eax
  mov    %rdi,%r13
  mov    %rsi,%rbp
  mov    %edx,%r14d
  test   %rdi,%rdi
  je     L6
  mov    D54(%rip),%rax
  mov    %edx,%ecx
  movb   $0x0,0xf(%rsp)
  mov    %rdi,%r12
  and    (%rax),%ecx
  jne    L93
L177:
  lea    0x10(%rsp),%rbx
  jmp    L168
  nopl   0x0(%rax,%rax,1)
L142:
  mov    %eax,%edx
  mov    %rbx,%rsi
  mov    %r12,%rdi
  call   <BIO_write@plt>
  cmp    %r15d,%eax
  jne    L13
L168:
  mov    $0x1000,%edx
  mov    %rbx,%rsi
  mov    %rbp,%rdi
  call   <BIO_read@plt>
  mov    %eax,%r15d
  test   %eax,%eax
  jg     L142
  mov    %rbp,%rdi
  call   <BIO_method_type@plt>
  mov    D47(%rip),%rdx
  cmp    (%rdx),%rax
  je     L23
L163:
  test   %r15d,%r15d
  jne    L13
  mov    D54(%rip),%rax
  and    (%rax),%r14d
  jne    L133
L70:
  mov    $0x1,%r13d
  jmp    L5
  nopw   0x0(%rax,%rax,1)
L23:
  mov    %rbp,%rdi
  call   <BIO_get_cipher_status@plt>
  test   %eax,%eax
  jne    L163
  nopl   0x0(%rax)
L13:
  xor    %r13d,%r13d
L5:
  cmpb   $0x0,0xf(%rsp)
  je     L18
  mov    %r12,%rdi
  call   <BIO_free@plt>
L18:
  mov    0x1018(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L47
  add    $0x1028,%rsp
  mov    %r13d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  cs nopw 0x0(%rax,%rax,1)
L93:
  xor    %eax,%eax
  call   <BIO_s_mem@plt>
  mov    %eax,%edi
  call   <BIO_new@plt>
  xor    %esi,%esi
  mov    %rax,%rdi
  mov    %rax,%r12
  call   <BIO_set_mem_eof_return@plt>
L101:
  test   %r12,%r12
  je     L128
  cmp    %r13,%r12
  setne  0xf(%rsp)
  jmp    L177
  nopl   (%rax)
L133:
  mov    %r13,%rsi
  mov    %r12,%rdi
  call   <SMIME_text@plt>
  mov    %eax,%r13d
  test   %eax,%eax
  jne    L70
  mov    D58(%rip),%rax
  mov    (%rax),%esi
  mov    D53(%rip),%rax
  mov    (%rax),%edi
  call   <CMSerr@plt>
  jmp    L5
  nopw   0x0(%rax,%rax,1)
L6:
  call   <BIO_s_null@plt>
  mov    %eax,%edi
  call   <BIO_new@plt>
  mov    %rax,%r12
  jmp    L101
  nopl   0x0(%rax)
L128:
  mov    D26(%rip),%rax
  xor    %r13d,%r13d
  mov    (%rax),%esi
  mov    D53(%rip),%rax
  mov    (%rax),%edi
  call   <CMSerr@plt>
  jmp    L18
L47:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int cms_copy_content(BIO *out, BIO *in, unsigned int flags) {
  unsigned char buf[4096];
  int r = 0, i;
  BIO *tmpout = NULL;
  if (out == NULL)
    tmpout = BIO_new(BIO_s_null());
  else if (flags & CMS_TEXT) {
    tmpout = BIO_new(BIO_s_mem());
    BIO_set_mem_eof_return(tmpout, 0);
  } else
    tmpout = out;
  if (!tmpout) {
    CMSerr(CMS_F_CMS_COPY_CONTENT, ERR_R_MALLOC_FAILURE);
    goto err;
  }
  for (;;) {
    i = BIO_read(in, buf, sizeof(buf));
    if (i <= 0) {
      if (BIO_method_type(in) == BIO_TYPE_CIPHER) {
        if (!BIO_get_cipher_status(in))
          goto err;
      }
      if (i < 0)
        goto err;
      break;
    }
    if (tmpout && (BIO_write(tmpout, buf, i) != i))
      goto err;
  }
  if (flags & CMS_TEXT) {
    if (!SMIME_text(tmpout, out)) {
      CMSerr(CMS_F_CMS_COPY_CONTENT, CMS_R_SMIME_TEXT_ERROR);
      goto err;
    }
  }
  r = 1;
err:
  if (tmpout && (tmpout != out))
    BIO_free(tmpout);
  return r;
}
```