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

```asm
<rsa_pss_to_ctx>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x68,%rsp
  mov    %rdi,-0x58(%rbp)
  mov    %rsi,-0x60(%rbp)
  mov    %rdx,-0x68(%rbp)
  mov    %rcx,-0x70(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x18(%rbp)
  xor    %eax,%eax
  movl   $0xffffffff,-0x48(%rbp)
  movq   $0x0,-0x30(%rbp)
  movq   $0x0,-0x28(%rbp)
  mov    -0x68(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,%edi
  call   <OBJ_obj2nid@plt>
  mov    D92(%rip),%rdx
  mov    (%rdx),%rdx
  cmp    %rdx,%rax
  je     L201
  mov    D119(%rip),%rax
  mov    (%rax),%edx
  mov    D27(%rip),%rax
  mov    (%rax),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  call   <RSAerr@plt>
  mov    $0xffffffff,%eax
  jmp    L26
L201:
  lea    -0x40(%rbp),%rdx
  mov    -0x68(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <rsa_pss_decode@plt>
  mov    %rax,-0x20(%rbp)
  cmpq   $0x0,-0x20(%rbp)
  jne    L208
  mov    D43(%rip),%rax
  mov    (%rax),%edx
  mov    D27(%rip),%rax
  mov    (%rax),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  call   <RSAerr@plt>
  jmp    L56
L208:
  mov    -0x40(%rbp),%rdx
  mov    -0x20(%rbp),%rax
  mov    0x14(%rax),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <rsa_mgf1_to_md@plt>
  mov    %rax,-0x30(%rbp)
  cmpq   $0x0,-0x30(%rbp)
  je     L121
  mov    -0x20(%rbp),%rax
  mov    0x10(%rax),%eax
  mov    %eax,%edi
  call   <rsa_algor_to_md@plt>
  mov    %rax,-0x28(%rbp)
  cmpq   $0x0,-0x28(%rbp)
  je     L161
  mov    -0x20(%rbp),%rax
  mov    0x8(%rax),%rax
  test   %rax,%rax
  je     L73
  mov    -0x20(%rbp),%rax
  mov    0x8(%rax),%rax
  mov    %rax,%rdi
  call   <ASN1_INTEGER_get@plt>
  mov    %eax,-0x44(%rbp)
  cmpl   $0x0,-0x44(%rbp)
  jns    L195
  mov    D80(%rip),%rax
  mov    (%rax),%edx
  mov    D27(%rip),%rax
  mov    (%rax),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  call   <RSAerr@plt>
  jmp    L56
L73:
  movl   $0x14,-0x44(%rbp)
L195:
  mov    -0x20(%rbp),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  je     L178
  mov    -0x20(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <ASN1_INTEGER_get@plt>
  cmp    $0x1,%eax
  je     L178
  mov    D44(%rip),%rax
  mov    (%rax),%edx
  mov    D27(%rip),%rax
  mov    (%rax),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  call   <RSAerr@plt>
  jmp    L56
L178:
  cmpq   $0x0,-0x70(%rbp)
  je     L253
  mov    -0x70(%rbp),%rcx
  mov    -0x28(%rbp),%rdx
  lea    -0x60(%rbp),%rsi
  mov    -0x58(%rbp),%rax
  mov    %rcx,%r8
  mov    $0x0,%ecx
  mov    %rax,%rdi
  call   <EVP_DigestVerifyInit@plt>
  test   %eax,%eax
  jne    L169
  jmp    L56
L253:
  mov    -0x60(%rbp),%rax
  lea    -0x38(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <EVP_PKEY_CTX_get_signature_md@plt>
  test   %rax,%rax
  jle    L100
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <EVP_MD_type@plt>
  mov    %rax,%rbx
  mov    -0x38(%rbp),%rax
  mov    %rax,%rdi
  call   <EVP_MD_type@plt>
  cmp    %rax,%rbx
  je     L169
  mov    D111(%rip),%rax
  mov    (%rax),%edx
  mov    D27(%rip),%rax
  mov    (%rax),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  call   <RSAerr@plt>
  jmp    L56
L169:
  mov    D52(%rip),%rax
  mov    (%rax),%edx
  mov    -0x60(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <EVP_PKEY_CTX_set_rsa_padding@plt>
  test   %rax,%rax
  jle    L90
  mov    -0x60(%rbp),%rax
  mov    -0x44(%rbp),%edx
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <EVP_PKEY_CTX_set_rsa_pss_saltlen@plt>
  test   %rax,%rax
  jle    L275
  mov    -0x60(%rbp),%rax
  mov    -0x30(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <EVP_PKEY_CTX_set_rsa_mgf1_md@plt>
  test   %rax,%rax
  jle    L74
  movl   $0x1,-0x48(%rbp)
  jmp    L56
L121:
  nop
  jmp    L56
L161:
  nop
  jmp    L56
L100:
  nop
  jmp    L56
L90:
  nop
  jmp    L56
L275:
  nop
  jmp    L56
L74:
  nop
L56:
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <RSA_PSS_PARAMS_free@plt>
  mov    -0x40(%rbp),%rax
  test   %rax,%rax
  je     L43
  mov    -0x40(%rbp),%rax
  mov    %rax,%rdi
  call   <X509_ALGOR_free@plt>
L43:
  mov    -0x48(%rbp),%eax
L26:
  mov    -0x18(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L173
  call   <__stack_chk_fail@plt>
L173:
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

assistant: ```c
int rsa_pss_to_ctx(EVP_MD_CTX *ctx, EVP_PKEY_CTX *pkctx, X509_ALGOR *sigalg, EVP_PKEY *pkey) {
  int rv = -1;
  int saltlen;
  const EVP_MD *mgf1md = NULL, *md = NULL;
  RSA_PSS_PARAMS *pss;
  X509_ALGOR *maskHash;
  if (OBJ_obj2nid(sigalg->algorithm) != NID_rsassaPss) {
    RSAerr(RSA_F_RSA_PSS_TO_CTX, RSA_R_UNSUPPORTED_SIGNATURE_TYPE);
    return -1;
  }
  pss = rsa_pss_decode(sigalg, &maskHash);
  if (pss == NULL) {
    RSAerr(RSA_F_RSA_PSS_TO_CTX, RSA_R_INVALID_PSS_PARAMETERS);
    goto err;
  }
  mgf1md = rsa_mgf1_to_md(pss->maskGenAlgorithm, maskHash);
  if (!mgf1md)
    goto err;
  md = rsa_algor_to_md(pss->hashAlgorithm);
  if (!md)
    goto err;
  if (pss->saltLength) {
    saltlen = ASN1_INTEGER_get(pss->saltLength);
    if (saltlen < 0) {
      RSAerr(RSA_F_RSA_PSS_TO_CTX, RSA_R_INVALID_SALT_LENGTH);
      goto err;
    }
  } else
    saltlen = 20;
  if (pss->trailerField && ASN1_INTEGER_get(pss->trailerField) != 1) {
    RSAerr(RSA_F_RSA_PSS_TO_CTX, RSA_R_INVALID_TRAILER);
    goto err;
  }
  if (pkey) {
    if (!EVP_DigestVerifyInit(ctx, &pkctx, md, NULL, pkey))
      goto err;
  } else {
    const EVP_MD *checkmd;
    if (EVP_PKEY_CTX_get_signature_md(pkctx, &checkmd) <= 0)
      goto err;
    if (EVP_MD_type(md) != EVP_MD_type(checkmd)) {
      RSAerr(RSA_F_RSA_PSS_TO_CTX, RSA_R_DIGEST_DOES_NOT_MATCH);
      goto err;
    }
  }
  if (EVP_PKEY_CTX_set_rsa_padding(pkctx, RSA_PKCS1_PSS_PADDING) <= 0)
    goto err;
  if (EVP_PKEY_CTX_set_rsa_pss_saltlen(pkctx, saltlen) <= 0)
    goto err;
  if (EVP_PKEY_CTX_set_rsa_mgf1_md(pkctx, mgf1md) <= 0)
    goto err;
  rv = 1;
err:
  RSA_PSS_PARAMS_free(pss);
  if (maskHash)
    X509_ALGOR_free(maskHash);
  return rv;
}
```