user: Converte this assembly snippet into its equivalent C code:

```asm
<PKCS5_v2_PBKDF2_keyivgen>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  mov    %rcx,%r15
  push   %r14
  push   %r13
  mov    %rdi,%r13
  push   %r12
  push   %rbx
  sub    $0x48,%rsp
  mov    %rsi,-0x60(%rbp)
  mov    %edx,-0x64(%rbp)
  mov    %rsp,%rdi
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  mov    D64(%rip),%rax
  movslq (%rax),%rbx
  lea    0xf(%rbx),%rax
  mov    %rax,%rsi
  and    $0xfffffffffffff000,%rax
  sub    %rax,%rdi
  and    $0xfffffffffffffff0,%rsi
  cmp    %rdi,%rsp
  je     L12
L82:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rdi,%rsp
  jne    L82
L12:
  and    $0xfff,%esi
  sub    %rsi,%rsp
  test   %rsi,%rsi
  jne    L1
L25:
  mov    %r13,%rdi
  mov    %rsp,-0x58(%rbp)
  call   <EVP_CIPHER_CTX_cipher@plt>
  mov    %rax,%r14
  test   %rax,%rax
  je     L233
  mov    %r13,%rdi
  call   <EVP_CIPHER_CTX_key_length@plt>
  xor    %edi,%edi
  mov    %eax,%r12d
  mov    %eax,%eax
  cmp    %rax,%rbx
  setae  %dil
  call   <OPENSSL_assert@plt>
  test   %r15,%r15
  je     L128
  mov    D144(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,(%r15)
  je     L223
L128:
  mov    D77(%rip),%rax
  xor    %r14d,%r14d
  xor    %r15d,%r15d
  mov    (%rax),%esi
  mov    D46(%rip),%rax
  mov    (%rax),%edi
  call   <EVPerr@plt>
L115:
  mov    -0x58(%rbp),%rdi
  mov    %r12d,%esi
  call   <OPENSSL_cleanse@plt>
  mov    %r14,%rdi
  call   <PBKDF2PARAM_free@plt>
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L81
  lea    -0x28(%rbp),%rsp
  mov    %r15d,%eax
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
  nopl   0x0(%rax)
L223:
  mov    0x8(%r15),%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,%r14
  test   %rax,%rax
  je     L114
  mov    %r13,%rdi
  call   <EVP_CIPHER_CTX_key_length@plt>
  mov    0x18(%r14),%rdi
  mov    %eax,%r12d
  test   %rdi,%rdi
  jne    L112
L182:
  mov    0x10(%r14),%rax
  test   %rax,%rax
  je     L159
  mov    (%rax),%edi
  call   <OBJ_obj2nid@plt>
  mov    %eax,%esi
L106:
  mov    D33(%rip),%rax
  lea    -0x44(%rbp),%rcx
  xor    %r8d,%r8d
  xor    %edx,%edx
  mov    (%rax),%edi
  call   <EVP_PBE_find@plt>
  mov    %eax,%r15d
  test   %eax,%eax
  je     L194
  mov    -0x44(%rbp),%edi
  call   <EVP_get_digestbynid@plt>
  mov    %rax,%r9
  test   %rax,%rax
  je     L184
  mov    D19(%rip),%rdx
  mov    0x8(%r14),%rax
  mov    (%rdx),%rbx
  cmp    %rbx,(%rax)
  je     L193
  mov    D131(%rip),%rax
L77:
  mov    (%rax),%esi
  mov    D46(%rip),%rax
  xor    %r15d,%r15d
  mov    (%rax),%edi
  call   <EVPerr@plt>
  jmp    L115
  nop
L1:
  orq    $0x0,-0x8(%rsp,%rsi,1)
  jmp    L25
  nopl   0x0(%rax,%rax,1)
L233:
  mov    D89(%rip),%rax
  xor    %r12d,%r12d
  xor    %r15d,%r15d
  mov    (%rax),%esi
  mov    D46(%rip),%rax
  mov    (%rax),%edi
  call   <EVPerr@plt>
  jmp    L115
  nopw   0x0(%rax,%rax,1)
L159:
  mov    D44(%rip),%rax
  mov    (%rax),%esi
  jmp    L106
  cs nopw 0x0(%rax,%rax,1)
L112:
  call   <ASN1_INTEGER_get@plt>
  cmp    %r12d,%eax
  je     L182
  mov    D130(%rip),%rax
  jmp    L77
  nopw   0x0(%rax,%rax,1)
L194:
  mov    D149(%rip),%rax
  mov    (%rax),%esi
  mov    D46(%rip),%rax
  mov    (%rax),%edi
  call   <EVPerr@plt>
  jmp    L115
  nopl   0x0(%rax)
L193:
  mov    0x8(%rax),%rax
  mov    (%r14),%rdi
  mov    %r9,-0x70(%rbp)
  mov    0x8(%rax),%ecx
  mov    (%rax),%r15
  mov    %ecx,-0x68(%rbp)
  call   <ASN1_INTEGER_get@plt>
  mov    -0x58(%rbp),%rbx
  mov    -0x70(%rbp),%r9
  mov    %r15,%rdx
  mov    -0x68(%rbp),%ecx
  mov    -0x64(%rbp),%esi
  mov    %eax,%r8d
  push   %rbx
  mov    -0x60(%rbp),%rdi
  push   %r12
  call   <PKCS5_PBKDF2_HMAC@plt>
  mov    %eax,%r15d
  pop    %rax
  pop    %rdx
  test   %r15d,%r15d
  je     L115
  mov    0x10(%rbp),%r9d
  xor    %r8d,%r8d
  mov    %rbx,%rcx
  xor    %edx,%edx
  xor    %esi,%esi
  mov    %r13,%rdi
  call   <EVP_CipherInit_ex@plt>
  mov    %eax,%r15d
  jmp    L115
  nopl   (%rax)
L114:
  mov    D77(%rip),%rax
  jmp    L77
  nopl   0x0(%rax)
L184:
  mov    D149(%rip),%rax
  jmp    L77
L81:
  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);
    goto err;
  }
  keylen = EVP_CIPHER_CTX_key_length(ctx);
  OPENSSL_assert(keylen <= sizeof key);
  if (!param || (param->type != V_ASN1_SEQUENCE)) {
    EVPerr(EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN, EVP_R_DECODE_ERROR);
    goto err;
  }
  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);
    goto err;
  }
  keylen = EVP_CIPHER_CTX_key_length(ctx);
  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:
  OPENSSL_cleanse(key, keylen);
  PBKDF2PARAM_free(kdf);
  return rv;
}
```