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

```asm
<PKCS5_v2_PBKDF2_keyivgen>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  mov    %edx,%r14d
  push   %r13
  push   %r12
  mov    %rdi,%r12
  push   %rbx
  mov    %rcx,%rbx
  sub    $0x58,%rsp
  mov    %rsi,-0x58(%rbp)
  mov    %rsp,%rsi
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  mov    D114(%rip),%rax
  movslq (%rax),%r13
  lea    0xf(%r13),%rax
  mov    %rax,%rcx
  and    $0xfffffffffffff000,%rax
  sub    %rax,%rsi
  and    $0xfffffffffffffff0,%rcx
  cmp    %rsi,%rsp
  je     L211
L234:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rsi,%rsp
  jne    L234
L211:
  and    $0xfff,%ecx
  sub    %rcx,%rsp
  test   %rcx,%rcx
  jne    L138
L127:
  mov    %r12,%rdi
  mov    %rsp,-0x60(%rbp)
  call   <EVP_CIPHER_CTX_cipher@plt>
  test   %rax,%rax
  je     L45
  mov    %r12,%rdi
  call   <EVP_CIPHER_CTX_key_length@plt>
  mov    %eax,%r15d
  mov    %eax,%eax
  cmp    %rax,%r13
  jb     L243
  test   %rbx,%rbx
  je     L47
  mov    D55(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,(%rbx)
  je     L112
L47:
  mov    D15(%rip),%rax
L147:
  mov    (%rax),%esi
  mov    D115(%rip),%rax
  mov    (%rax),%edi
  call   <EVPerr@plt>
  xor    %r8d,%r8d
L18:
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L50
  lea    -0x28(%rbp),%rsp
  mov    %r8d,%eax
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
  nopw   0x0(%rax,%rax,1)
L138:
  orq    $0x0,-0x8(%rsp,%rcx,1)
  jmp    L127
  nopl   0x0(%rax,%rax,1)
L112:
  mov    0x8(%rbx),%rax
  lea    -0x40(%rbp),%rsi
  xor    %edi,%edi
  mov    (%rax),%rdx
  mov    %rdx,-0x40(%rbp)
  mov    0x8(%rax),%edx
  call   <d2i_PBKDF2PARAM@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  je     L47
  mov    0x18(%rax),%rdi
  test   %rdi,%rdi
  jne    L21
L23:
  mov    0x10(%rbx),%rax
  test   %rax,%rax
  je     L240
  mov    (%rax),%edi
  call   <OBJ_obj2nid@plt>
  mov    %eax,%esi
L246:
  mov    D69(%rip),%rax
  xor    %r8d,%r8d
  xor    %edx,%edx
  lea    -0x44(%rbp),%rcx
  mov    (%rax),%edi
  call   <EVP_PBE_find@plt>
  test   %eax,%eax
  je     L56
  mov    -0x44(%rbp),%edi
  call   <EVP_get_digestbynid@plt>
  mov    %rax,%r9
  test   %rax,%rax
  je     L161
  mov    D81(%rip),%rdx
  mov    0x8(%rbx),%rax
  mov    (%rdx),%rdx
  cmp    %rdx,(%rax)
  je     L194
  mov    D131(%rip),%rax
L2:
  mov    (%rax),%esi
  mov    D115(%rip),%rax
  mov    (%rax),%edi
  call   <EVPerr@plt>
  xor    %r8d,%r8d
  jmp    L97
  nopw   0x0(%rax,%rax,1)
L45:
  mov    D76(%rip),%rax
  jmp    L147
  nopl   0x0(%rax)
L243:
  mov    D126(%rip),%rax
  jmp    L147
  nopl   0x0(%rax)
L240:
  mov    D102(%rip),%rax
  mov    (%rax),%esi
  jmp    L246
  xchg   %ax,%ax
L21:
  call   <ASN1_INTEGER_get@plt>
  cmp    %r15d,%eax
  je     L23
  mov    D20(%rip),%rax
  jmp    L2
  nopw   0x0(%rax,%rax,1)
L56:
  mov    %eax,-0x58(%rbp)
  mov    D83(%rip),%rax
  mov    (%rax),%esi
  mov    D115(%rip),%rax
  mov    (%rax),%edi
  call   <EVPerr@plt>
  mov    -0x58(%rbp),%r8d
L97:
  mov    -0x60(%rbp),%rdi
  mov    %r15d,%esi
  mov    %r8d,-0x58(%rbp)
  call   <explicit_bzero@plt>
  mov    %rbx,%rdi
  call   <PBKDF2PARAM_free@plt>
  mov    -0x58(%rbp),%r8d
  jmp    L18
  nop
L194:
  mov    0x8(%rax),%rax
  mov    (%rbx),%rdi
  mov    %r9,-0x78(%rbp)
  mov    (%rax),%rdx
  mov    0x8(%rax),%ecx
  mov    %rdx,-0x70(%rbp)
  mov    %ecx,-0x64(%rbp)
  call   <ASN1_INTEGER_get@plt>
  mov    -0x60(%rbp),%r13
  mov    -0x70(%rbp),%rdx
  mov    %r14d,%esi
  mov    -0x78(%rbp),%r9
  mov    -0x64(%rbp),%ecx
  mov    %eax,%r8d
  push   %r13
  mov    -0x58(%rbp),%rdi
  push   %r15
  call   <PKCS5_PBKDF2_HMAC@plt>
  mov    %eax,%r8d
  pop    %rax
  pop    %rdx
  test   %r8d,%r8d
  je     L97
  mov    0x10(%rbp),%r9d
  xor    %r8d,%r8d
  mov    %r13,%rcx
  xor    %edx,%edx
  xor    %esi,%esi
  mov    %r12,%rdi
  call   <EVP_CipherInit_ex@plt>
  mov    %eax,%r8d
  jmp    L97
  nopw   0x0(%rax,%rax,1)
L161:
  mov    D83(%rip),%rax
  jmp    L2
L50:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int PKCS5_v2_PBKDF2_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, ASN1_TYPE *param, const EVP_CIPHER *c, const EVP_MD *md, int en_de) {
  unsigned char *salt, key[EVP_MAX_KEY_LENGTH];
  const unsigned char *pbuf;
  int saltlen, iter, plen;
  int rv = 0;
  unsigned int keylen = 0;
  int prf_nid, hmac_md_nid;
  PBKDF2PARAM *kdf = NULL;
  const EVP_MD *prfmd;
  if (EVP_CIPHER_CTX_cipher(ctx) == NULL) {
    EVPerr(EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN, EVP_R_NO_CIPHER_SET);
    return 0;
  }
  keylen = EVP_CIPHER_CTX_key_length(ctx);
  if (keylen > sizeof key) {
    EVPerr(EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN, EVP_R_BAD_KEY_LENGTH);
    return 0;
  }
  if (!param || (param->type != V_ASN1_SEQUENCE)) {
    EVPerr(EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN, EVP_R_DECODE_ERROR);
    return 0;
  }
  pbuf = param->value.sequence->data;
  plen = param->value.sequence->length;
  if (!(kdf = d2i_PBKDF2PARAM(NULL, &pbuf, plen))) {
    EVPerr(EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN, EVP_R_DECODE_ERROR);
    return 0;
  }
  if (kdf->keylength && (ASN1_INTEGER_get(kdf->keylength) != (int)keylen)) {
    EVPerr(EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN, EVP_R_UNSUPPORTED_KEYLENGTH);
    goto err;
  }
  if (kdf->prf)
    prf_nid = OBJ_obj2nid(kdf->prf->algorithm);
  else
    prf_nid = NID_hmacWithSHA1;
  if (!EVP_PBE_find(EVP_PBE_TYPE_PRF, prf_nid, NULL, &hmac_md_nid, 0)) {
    EVPerr(EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN, EVP_R_UNSUPPORTED_PRF);
    goto err;
  }
  prfmd = EVP_get_digestbynid(hmac_md_nid);
  if (prfmd == NULL) {
    EVPerr(EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN, EVP_R_UNSUPPORTED_PRF);
    goto err;
  }
  if (kdf->salt->type != V_ASN1_OCTET_STRING) {
    EVPerr(EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN, EVP_R_UNSUPPORTED_SALT_TYPE);
    goto err;
  }
  salt = kdf->salt->value.octet_string->data;
  saltlen = kdf->salt->value.octet_string->length;
  iter = ASN1_INTEGER_get(kdf->iter);
  if (!PKCS5_PBKDF2_HMAC(pass, passlen, salt, saltlen, iter, prfmd, keylen, key))
    goto err;
  rv = EVP_CipherInit_ex(ctx, NULL, NULL, key, NULL, en_de);
err:
  explicit_bzero(key, keylen);
  PBKDF2PARAM_free(kdf);
  return rv;
}
```