user: Please show me the C implementation that matches the assembly code listed below:

```asm
<PKCS12_PBE_keyivgen>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x48,%rsp
  mov    %rdi,-0x60(%rbp)
  mov    %rsi,-0x50(%rbp)
  mov    %edx,-0x54(%rbp)
  mov    %rcx,%rdx
  mov    %r8,-0x48(%rbp)
  mov    %r9,%r12
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  mov    D64(%rip),%rax
  movslq (%rax),%rax
  add    $0xf,%rax
  mov    %rax,%rsi
  and    $0xfffffffffffffff0,%rsi
  and    $0xfffffffffffff000,%rax
  mov    %rsp,%rcx
  sub    %rax,%rcx
L112:
  cmp    %rcx,%rsp
  je     L185
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L112
L185:
  mov    %rsi,%rax
  and    $0xfff,%eax
  sub    %rax,%rsp
  test   %rax,%rax
  je     L170
  orq    $0x0,-0x8(%rsp,%rax,1)
L170:
  mov    %rsp,%r14
  mov    D125(%rip),%rax
  movslq (%rax),%rax
  add    $0xf,%rax
  mov    %rax,%rsi
  and    $0xfffffffffffffff0,%rsi
  and    $0xfffffffffffff000,%rax
  mov    %rsp,%rcx
  sub    %rax,%rcx
L122:
  cmp    %rcx,%rsp
  je     L12
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L122
L12:
  mov    %rsi,%rax
  and    $0xfff,%eax
  sub    %rax,%rsp
  test   %rax,%rax
  je     L11
  orq    $0x0,-0x8(%rsp,%rax,1)
L11:
  mov    %rsp,-0x70(%rbp)
  test   %rdx,%rdx
  je     L94
  mov    D34(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,(%rdx)
  jne    L94
  mov    0x8(%rdx),%rax
  test   %rax,%rax
  je     L94
  mov    (%rax),%rdx
  mov    %rdx,-0x40(%rbp)
  mov    0x8(%rax),%edx
  lea    -0x40(%rbp),%rsi
  mov    $0x0,%edi
  call   <d2i_PBEPARAM@plt>
  mov    %rax,%r13
  test   %rax,%rax
  je     L29
  mov    0x8(%rax),%edi
  movl   $0x1,-0x58(%rbp)
  test   %edi,%edi
  jne    L132
L142:
  mov    0x0(%r13),%rax
  mov    (%rax),%rbx
  mov    %rbx,-0x68(%rbp)
  mov    0x8(%rax),%r15d
  mov    -0x48(%rbp),%rdi
  call   <EVP_CIPHER_key_length@plt>
  sub    $0x8,%rsp
  push   %r12
  push   %r14
  push   %rax
  mov    -0x58(%rbp),%r9d
  mov    D45(%rip),%rax
  mov    (%rax),%r8d
  mov    %r15d,%ecx
  mov    %rbx,%rdx
  mov    -0x54(%rbp),%esi
  mov    -0x50(%rbp),%rdi
  call   <PKCS12_key_gen@plt>
  mov    %eax,%ebx
  add    $0x20,%rsp
  test   %eax,%eax
  je     L126
  mov    -0x48(%rbp),%rdi
  call   <EVP_CIPHER_iv_length@plt>
  sub    $0x8,%rsp
  push   %r12
  push   -0x70(%rbp)
  push   %rax
  mov    -0x58(%rbp),%r9d
  mov    D87(%rip),%rax
  mov    (%rax),%r8d
  mov    %r15d,%ecx
  mov    -0x68(%rbp),%rdx
  mov    -0x54(%rbp),%esi
  mov    -0x50(%rbp),%rdi
  call   <PKCS12_key_gen@plt>
  mov    %eax,%ebx
  add    $0x20,%rsp
  test   %eax,%eax
  je     L24
  mov    %r13,%rdi
  call   <PBEPARAM_free@plt>
  mov    0x10(%rbp),%r9d
  mov    -0x70(%rbp),%r15
  mov    %r15,%r8
  mov    %r14,%rcx
  mov    $0x0,%edx
  mov    -0x48(%rbp),%rsi
  mov    -0x60(%rbp),%rdi
  call   <EVP_CipherInit_ex@plt>
  mov    %eax,%ebx
  mov    D64(%rip),%rax
  mov    (%rax),%esi
  mov    %r14,%rdi
  call   <explicit_bzero@plt>
  mov    D125(%rip),%rax
  mov    (%rax),%esi
  mov    %r15,%rdi
  call   <explicit_bzero@plt>
  jmp    L153
L94:
  mov    D55(%rip),%rax
  mov    (%rax),%esi
  mov    D90(%rip),%rax
  mov    (%rax),%edi
  call   <PKCS12err@plt>
  mov    $0x0,%ebx
L153:
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L108
  mov    %ebx,%eax
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
L29:
  mov    D55(%rip),%rax
  mov    (%rax),%esi
  mov    D90(%rip),%rax
  mov    (%rax),%edi
  call   <PKCS12err@plt>
  mov    $0x0,%ebx
  jmp    L153
L132:
  call   <ASN1_INTEGER_get@plt>
  mov    %eax,-0x58(%rbp)
  jmp    L142
L126:
  mov    D76(%rip),%rax
  mov    (%rax),%esi
  mov    D90(%rip),%rax
  mov    (%rax),%edi
  call   <PKCS12err@plt>
  mov    %r13,%rdi
  call   <PBEPARAM_free@plt>
  jmp    L153
L24:
  mov    D13(%rip),%rax
  mov    (%rax),%esi
  mov    D90(%rip),%rax
  mov    (%rax),%edi
  call   <PKCS12err@plt>
  mov    %r13,%rdi
  call   <PBEPARAM_free@plt>
  jmp    L153
L108:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md, int en_de) {
  PBEPARAM *pbe;
  int saltlen, iter, ret;
  unsigned char *salt;
  const unsigned char *pbuf;
  unsigned char key[EVP_MAX_KEY_LENGTH], iv[EVP_MAX_IV_LENGTH];
  if (param == NULL || param->type != V_ASN1_SEQUENCE || param->value.sequence == NULL) {
    PKCS12err(PKCS12_F_PKCS12_PBE_KEYIVGEN, PKCS12_R_DECODE_ERROR);
    return 0;
  }
  pbuf = param->value.sequence->data;
  if (!(pbe = d2i_PBEPARAM(NULL, &pbuf, param->value.sequence->length))) {
    PKCS12err(PKCS12_F_PKCS12_PBE_KEYIVGEN, PKCS12_R_DECODE_ERROR);
    return 0;
  }
  if (!pbe->iter)
    iter = 1;
  else
    iter = ASN1_INTEGER_get(pbe->iter);
  salt = pbe->salt->data;
  saltlen = pbe->salt->length;
  if (!PKCS12_key_gen(pass, passlen, salt, saltlen, PKCS12_KEY_ID, iter, EVP_CIPHER_key_length(cipher), key, md)) {
    PKCS12err(PKCS12_F_PKCS12_PBE_KEYIVGEN, PKCS12_R_KEY_GEN_ERROR);
    PBEPARAM_free(pbe);
    return 0;
  }
  if (!PKCS12_key_gen(pass, passlen, salt, saltlen, PKCS12_IV_ID, iter, EVP_CIPHER_iv_length(cipher), iv, md)) {
    PKCS12err(PKCS12_F_PKCS12_PBE_KEYIVGEN, PKCS12_R_IV_GEN_ERROR);
    PBEPARAM_free(pbe);
    return 0;
  }
  PBEPARAM_free(pbe);
  ret = EVP_CipherInit_ex(ctx, cipher, NULL, key, iv, en_de);
  explicit_bzero(key, EVP_MAX_KEY_LENGTH);
  explicit_bzero(iv, EVP_MAX_IV_LENGTH);
  return ret;
}
```