#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */
typedef struct TYPE_11__ TYPE_2__;
typedef struct TYPE_10__ TYPE_1__;

/* Type definitions */
struct TYPE_10__ {
  int /*<<< orphan*/ algorithm;
};
typedef TYPE_1__ X509_ALGOR;
struct TYPE_11__ {
  scalar_t__ trailerField;
  scalar_t__ saltLength;
  int /*<<< orphan*/ hashAlgorithm;
  int /*<<< orphan*/ maskGenAlgorithm;
};
typedef TYPE_2__ RSA_PSS_PARAMS;
typedef int /*<<< orphan*/ EVP_PKEY_CTX;
typedef int /*<<< orphan*/ EVP_PKEY;
typedef int /*<<< orphan*/ EVP_MD_CTX;
typedef int /*<<< orphan*/ EVP_MD;

/* Variables and functions */
int ASN1_INTEGER_get(scalar_t__);
int /*<<< orphan*/ EVP_DigestVerifyInit(int /*<<< orphan*/ *,
                                        int /*<<< orphan*/ **,
                                        int /*<<< orphan*/ const *,
                                        int /*<<< orphan*/ *,
                                        int /*<<< orphan*/ *);
scalar_t__ EVP_MD_type(int /*<<< orphan*/ const *);
scalar_t__ EVP_PKEY_CTX_get_signature_md(int /*<<< orphan*/ *,
                                         int /*<<< orphan*/ const **);
scalar_t__ EVP_PKEY_CTX_set_rsa_mgf1_md(int /*<<< orphan*/ *,
                                        int /*<<< orphan*/ const *);
scalar_t__ EVP_PKEY_CTX_set_rsa_padding(int /*<<< orphan*/ *,
                                        int /*<<< orphan*/);
scalar_t__ EVP_PKEY_CTX_set_rsa_pss_saltlen(int /*<<< orphan*/ *, int);
scalar_t__ NID_rsassaPss;
scalar_t__ OBJ_obj2nid(int /*<<< orphan*/);
int /*<<< orphan*/ RSA_F_RSA_PSS_TO_CTX;
int /*<<< orphan*/ RSA_PKCS1_PSS_PADDING;
int /*<<< orphan*/ RSA_PSS_PARAMS_free(TYPE_2__ *);
int /*<<< orphan*/ RSA_R_DIGEST_DOES_NOT_MATCH;
int /*<<< orphan*/ RSA_R_INVALID_PSS_PARAMETERS;
int /*<<< orphan*/ RSA_R_INVALID_SALT_LENGTH;
int /*<<< orphan*/ RSA_R_INVALID_TRAILER;
int /*<<< orphan*/ RSA_R_UNSUPPORTED_SIGNATURE_TYPE;
int /*<<< orphan*/ RSAerr(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ X509_ALGOR_free(TYPE_1__ *);
int /*<<< orphan*/ *rsa_algor_to_md(int /*<<< orphan*/);
int /*<<< orphan*/ *rsa_mgf1_to_md(int /*<<< orphan*/, TYPE_1__ *);
TYPE_2__ *rsa_pss_decode(TYPE_1__ *, TYPE_1__ **);
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;
}


x86 assembly (clang, -O0):
<rsa_pss_to_ctx>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movl   $0xffffffff,-0x2c(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%edi
call   1040 <OBJ_obj2nid@plt>
mov    0x2daf(%rip),%rcx
cmp    (%rcx),%rax
je     124d <rsa_pss_to_ctx+0x6d>
mov    0x2db7(%rip),%rax
mov    (%rax),%edi
mov    0x2d6e(%rip),%rax
mov    (%rax),%esi
call   10e0 <RSAerr@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1475 <rsa_pss_to_ctx+0x295>
mov    -0x20(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1070 <rsa_pss_decode@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    1285 <rsa_pss_to_ctx+0xa5>
mov    0x2d78(%rip),%rax
mov    (%rax),%edi
mov    0x2d47(%rip),%rax
mov    (%rax),%esi
call   10e0 <RSAerr@plt>
jmp    1452 <rsa_pss_to_ctx+0x272>
mov    -0x48(%rbp),%rax
mov    0x14(%rax),%edi
mov    -0x50(%rbp),%rsi
call   1030 <rsa_mgf1_to_md@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    12a9 <rsa_pss_to_ctx+0xc9>
jmp    1452 <rsa_pss_to_ctx+0x272>
mov    -0x48(%rbp),%rax
mov    0x10(%rax),%edi
call   10f0 <rsa_algor_to_md@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    12c9 <rsa_pss_to_ctx+0xe9>
jmp    1452 <rsa_pss_to_ctx+0x272>
mov    -0x48(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     1313 <rsa_pss_to_ctx+0x133>
mov    -0x48(%rbp),%rax
mov    0x8(%rax),%rdi
call   10a0 <ASN1_INTEGER_get@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
jge    130e <rsa_pss_to_ctx+0x12e>
mov    0x2cef(%rip),%rax
mov    (%rax),%edi
mov    0x2cae(%rip),%rax
mov    (%rax),%esi
call   10e0 <RSAerr@plt>
jmp    1452 <rsa_pss_to_ctx+0x272>
jmp    131a <rsa_pss_to_ctx+0x13a>
movl   $0x14,-0x30(%rbp)
mov    -0x48(%rbp),%rax
cmpq   $0x0,(%rax)
je     1359 <rsa_pss_to_ctx+0x179>
mov    -0x48(%rbp),%rax
mov    (%rax),%rdi
call   10a0 <ASN1_INTEGER_get@plt>
cmp    $0x1,%eax
je     1359 <rsa_pss_to_ctx+0x179>
mov    0x2ca4(%rip),%rax
mov    (%rax),%edi
mov    0x2c8b(%rip),%rax
mov    (%rax),%esi
call   10e0 <RSAerr@plt>
jmp    1452 <rsa_pss_to_ctx+0x272>
cmpq   $0x0,-0x28(%rbp)
je     1390 <rsa_pss_to_ctx+0x1b0>
mov    -0x10(%rbp),%rdi
mov    -0x40(%rbp),%rdx
mov    -0x28(%rbp),%r8
lea    -0x18(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
call   1080 <EVP_DigestVerifyInit@plt>
cmp    $0x0,%eax
jne    138b <rsa_pss_to_ctx+0x1ab>
jmp    1452 <rsa_pss_to_ctx+0x272>
jmp    13f3 <rsa_pss_to_ctx+0x213>
mov    -0x18(%rbp),%rdi
lea    -0x58(%rbp),%rsi
call   1050 <EVP_PKEY_CTX_get_signature_md@plt>
cmp    $0x0,%rax
jg     13ac <rsa_pss_to_ctx+0x1cc>
jmp    1452 <rsa_pss_to_ctx+0x272>
mov    -0x40(%rbp),%rdi
call   10b0 <EVP_MD_type@plt>
mov    %rax,-0x60(%rbp)
mov    -0x58(%rbp),%rdi
call   10b0 <EVP_MD_type@plt>
mov    %rax,%rcx
mov    -0x60(%rbp),%rax
cmp    %rcx,%rax
je     13ee <rsa_pss_to_ctx+0x20e>
mov    0x2c0f(%rip),%rax
mov    (%rax),%edi
mov    0x2c0e(%rip),%rax
mov    (%rax),%esi
call   10e0 <RSAerr@plt>
jmp    1452 <rsa_pss_to_ctx+0x272>
jmp    13f3 <rsa_pss_to_ctx+0x213>
mov    -0x18(%rbp),%rdi
mov    0x2ba2(%rip),%rax
mov    (%rax),%esi
call   10d0 <EVP_PKEY_CTX_set_rsa_padding@plt>
cmp    $0x0,%rax
jg     1414 <rsa_pss_to_ctx+0x234>
jmp    1452 <rsa_pss_to_ctx+0x272>
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%esi
call   1100 <EVP_PKEY_CTX_set_rsa_pss_saltlen@plt>
cmp    $0x0,%rax
jg     142f <rsa_pss_to_ctx+0x24f>
jmp    1452 <rsa_pss_to_ctx+0x272>
mov    -0x18(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   10c0 <EVP_PKEY_CTX_set_rsa_mgf1_md@plt>
cmp    $0x0,%rax
jg     144b <rsa_pss_to_ctx+0x26b>
jmp    1452 <rsa_pss_to_ctx+0x272>
movl   $0x1,-0x2c(%rbp)
mov    -0x48(%rbp),%rdi
call   1060 <RSA_PSS_PARAMS_free@plt>
cmpq   $0x0,-0x50(%rbp)
je     146f <rsa_pss_to_ctx+0x28f>
mov    -0x50(%rbp),%rdi
call   1090 <X509_ALGOR_free@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rsa_pss_to_ctx>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rcx,%r12
mov    %rdx,%rbx
mov    %rsi,%rbp
mov    %rdi,%r13
mov    %rsi,(%rsp)
mov    (%rdx),%edi
call   1040 <OBJ_obj2nid@plt>
mov    0x2dc4(%rip),%rcx
cmp    (%rcx),%rax
jne    1282 <rsa_pss_to_ctx+0xa2>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <rsa_pss_decode@plt>
mov    %rax,%rbx
test   %rax,%rax
je     12a4 <rsa_pss_to_ctx+0xc4>
mov    0x14(%rbx),%edi
mov    0x10(%rsp),%rsi
call   1030 <rsa_mgf1_to_md@plt>
mov    $0xffffffff,%r15d
test   %rax,%rax
je     1317 <rsa_pss_to_ctx+0x137>
mov    %rax,0x18(%rsp)
mov    0x10(%rbx),%edi
call   10f0 <rsa_algor_to_md@plt>
test   %rax,%rax
je     1317 <rsa_pss_to_ctx+0x137>
mov    %rax,%r14
mov    0x8(%rbx),%rdi
test   %rdi,%rdi
je     12c3 <rsa_pss_to_ctx+0xe3>
call   10a0 <ASN1_INTEGER_get@plt>
test   %eax,%eax
jns    12c8 <rsa_pss_to_ctx+0xe8>
mov    0x2d74(%rip),%rax
mov    (%rax),%edi
mov    0x2d33(%rip),%rax
jmp    1310 <rsa_pss_to_ctx+0x130>
mov    0x2d5f(%rip),%rax
mov    (%rax),%edi
mov    0x2d16(%rip),%rax
mov    (%rax),%esi
call   10e0 <RSAerr@plt>
mov    $0xffffffff,%r15d
jmp    132e <rsa_pss_to_ctx+0x14e>
mov    0x2d3d(%rip),%rax
mov    (%rax),%edi
mov    0x2d0c(%rip),%rax
mov    (%rax),%esi
call   10e0 <RSAerr@plt>
mov    $0xffffffff,%r15d
jmp    1317 <rsa_pss_to_ctx+0x137>
mov    $0x14,%eax
mov    %eax,0xc(%rsp)
mov    (%rbx),%rdi
test   %rdi,%rdi
je     12de <rsa_pss_to_ctx+0xfe>
call   10a0 <ASN1_INTEGER_get@plt>
cmp    $0x1,%eax
jne    1300 <rsa_pss_to_ctx+0x120>
test   %r12,%r12
je     1340 <rsa_pss_to_ctx+0x160>
mov    %rsp,%rsi
mov    %r13,%rdi
mov    %r14,%rdx
xor    %ecx,%ecx
mov    %r12,%r8
call   1080 <EVP_DigestVerifyInit@plt>
test   %eax,%eax
je     1317 <rsa_pss_to_ctx+0x137>
mov    (%rsp),%rbp
jmp    136c <rsa_pss_to_ctx+0x18c>
mov    0x2ce1(%rip),%rax
mov    (%rax),%edi
mov    0x2cc8(%rip),%rax
mov    (%rax),%esi
call   10e0 <RSAerr@plt>
mov    %rbx,%rdi
call   1060 <RSA_PSS_PARAMS_free@plt>
mov    0x10(%rsp),%rdi
test   %rdi,%rdi
je     132e <rsa_pss_to_ctx+0x14e>
call   1090 <X509_ALGOR_free@plt>
mov    %r15d,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x20(%rsp),%rsi
mov    %rbp,%rdi
call   1050 <EVP_PKEY_CTX_get_signature_md@plt>
test   %rax,%rax
jle    1317 <rsa_pss_to_ctx+0x137>
mov    %r14,%rdi
call   10b0 <EVP_MD_type@plt>
mov    %rax,%r14
mov    0x20(%rsp),%rdi
call   10b0 <EVP_MD_type@plt>
cmp    %rax,%r14
jne    13b7 <rsa_pss_to_ctx+0x1d7>
mov    0x2c2d(%rip),%rax
mov    (%rax),%esi
mov    %rbp,%rdi
call   10d0 <EVP_PKEY_CTX_set_rsa_padding@plt>
test   %rax,%rax
jle    1317 <rsa_pss_to_ctx+0x137>
mov    (%rsp),%rdi
mov    0xc(%rsp),%esi
call   1100 <EVP_PKEY_CTX_set_rsa_pss_saltlen@plt>
test   %rax,%rax
jle    1317 <rsa_pss_to_ctx+0x137>
mov    (%rsp),%rdi
mov    0x18(%rsp),%rsi
call   10c0 <EVP_PKEY_CTX_set_rsa_mgf1_md@plt>
xor    %ecx,%ecx
test   %rax,%rax
setg   %cl
lea    (%rcx,%rcx,1),%r15d
add    $0xffffffff,%r15d
jmp    1317 <rsa_pss_to_ctx+0x137>
mov    0x2c2a(%rip),%rax
mov    (%rax),%edi
mov    0x2c29(%rip),%rax
jmp    1310 <rsa_pss_to_ctx+0x130>

LLVM IR (-O0):
%struct.TYPE_10__ = type { i32 }
%struct.TYPE_11__ = type { i64, i64, i32, i32 }
@NID_rsassaPss = global i64 0
@RSA_F_RSA_PSS_TO_CTX = global i32 0
@RSA_R_UNSUPPORTED_SIGNATURE_TYPE = global i32 0
@RSA_R_INVALID_PSS_PARAMETERS = global i32 0
@RSA_R_INVALID_SALT_LENGTH = global i32 0
@RSA_R_INVALID_TRAILER = global i32 0
@RSA_R_DIGEST_DOES_NOT_MATCH = global i32 0
@RSA_PKCS1_PSS_PADDING = global i32 0
define i32 @rsa_pss_to_ctx(i32* %0, i32* %1, %struct.TYPE_10__* %2, i32* %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca %struct.TYPE_10__*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca %struct.TYPE_11__*
%15 = alloca %struct.TYPE_10__*
%16 = alloca i32*
store i32* %0, i32** %6
store i32* %1, i32** %7
store %struct.TYPE_10__* %2, %struct.TYPE_10__** %8
store i32* %3, i32** %9
store i32 -1, i32* %10
store i32* null, i32** %12
store i32* null, i32** %13
%17 = load %struct.TYPE_10__*, %struct.TYPE_10__** %8
%18 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %17, i32 0, i32 0
%19 = load i32, i32* %18
%20 = call i64 @OBJ_obj2nid(i32 %19)
%21 = load i64, i64* @NID_rsassaPss
%22 = icmp ne i64 %20, %21
br i1 %22, label %23, label %27
23: ; preds = %4
%24 = load i32, i32* @RSA_F_RSA_PSS_TO_CTX
%25 = load i32, i32* @RSA_R_UNSUPPORTED_SIGNATURE_TYPE
%26 = call i32 @RSAerr(i32 %24, i32 %25)
store i32 -1, i32* %5
br label %142
27: ; preds = %4
%28 = load %struct.TYPE_10__*, %struct.TYPE_10__** %8
%29 = call %struct.TYPE_11__* @rsa_pss_decode(%struct.TYPE_10__* %28, %struct.TYPE_10__** %15)
store %struct.TYPE_11__* %29, %struct.TYPE_11__** %14
%30 = load %struct.TYPE_11__*, %struct.TYPE_11__** %14
%31 = icmp eq %struct.TYPE_11__* %30, null
br i1 %31, label %32, label %36
32: ; preds = %27
%33 = load i32, i32* @RSA_F_RSA_PSS_TO_CTX
%34 = load i32, i32* @RSA_R_INVALID_PSS_PARAMETERS
%35 = call i32 @RSAerr(i32 %33, i32 %34)
br label %132
36: ; preds = %27
%37 = load %struct.TYPE_11__*, %struct.TYPE_11__** %14
%38 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %37, i32 0, i32 3
%39 = load i32, i32* %38
%40 = load %struct.TYPE_10__*, %struct.TYPE_10__** %15
%41 = call i32* @rsa_mgf1_to_md(i32 %39, %struct.TYPE_10__* %40)
store i32* %41, i32** %12
%42 = load i32*, i32** %12
%43 = icmp ne i32* %42, null
br i1 %43, label %45, label %44
44: ; preds = %36
br label %132
45: ; preds = %36
%46 = load %struct.TYPE_11__*, %struct.TYPE_11__** %14
%47 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %46, i32 0, i32 2
%48 = load i32, i32* %47
%49 = call i32* @rsa_algor_to_md(i32 %48)
store i32* %49, i32** %13
%50 = load i32*, i32** %13
%51 = icmp ne i32* %50, null
br i1 %51, label %53, label %52
52: ; preds = %45
br label %132
53: ; preds = %45
%54 = load %struct.TYPE_11__*, %struct.TYPE_11__** %14
%55 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %54, i32 0, i32 1
%56 = load i64, i64* %55
%57 = icmp ne i64 %56, 0
br i1 %57, label %58, label %70
58: ; preds = %53
%59 = load %struct.TYPE_11__*, %struct.TYPE_11__** %14
%60 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %59, i32 0, i32 1
%61 = load i64, i64* %60
%62 = call i32 @ASN1_INTEGER_get(i64 %61)
store i32 %62, i32* %11
%63 = load i32, i32* %11
%64 = icmp slt i32 %63, 0
br i1 %64, label %65, label %69
65: ; preds = %58
%66 = load i32, i32* @RSA_F_RSA_PSS_TO_CTX
%67 = load i32, i32* @RSA_R_INVALID_SALT_LENGTH
%68 = call i32 @RSAerr(i32 %66, i32 %67)
br label %132
69: ; preds = %58
br label %71
70: ; preds = %53
store i32 20, i32* %11
br label %71
71: ; preds = %70, %69
%72 = load %struct.TYPE_11__*, %struct.TYPE_11__** %14
%73 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %72, i32 0, i32 0
%74 = load i64, i64* %73
%75 = icmp ne i64 %74, 0
br i1 %75, label %76, label %86
76: ; preds = %71
%77 = load %struct.TYPE_11__*, %struct.TYPE_11__** %14
%78 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %77, i32 0, i32 0
%79 = load i64, i64* %78
%80 = call i32 @ASN1_INTEGER_get(i64 %79)
%81 = icmp ne i32 %80, 1
br i1 %81, label %82, label %86
82: ; preds = %76
%83 = load i32, i32* @RSA_F_RSA_PSS_TO_CTX
%84 = load i32, i32* @RSA_R_INVALID_TRAILER
%85 = call i32 @RSAerr(i32 %83, i32 %84)
br label %132
86: ; preds = %76, %71
%87 = load i32*, i32** %9
%88 = icmp ne i32* %87, null
br i1 %88, label %89, label %97
89: ; preds = %86
%90 = load i32*, i32** %6
%91 = load i32*, i32** %13
%92 = load i32*, i32** %9
%93 = call i32 @EVP_DigestVerifyInit(i32* %90, i32** %7, i32* %91, i32* null, i32* %92)
%94 = icmp ne i32 %93, 0
br i1 %94, label %96, label %95
95: ; preds = %89
br label %132
96: ; preds = %89
br label %113
97: ; preds = %86
%98 = load i32*, i32** %7
%99 = call i64 @EVP_PKEY_CTX_get_signature_md(i32* %98, i32** %16)
%100 = icmp sle i64 %99, 0
br i1 %100, label %101, label %102
101: ; preds = %97
br label %132
102: ; preds = %97
%103 = load i32*, i32** %13
%104 = call i64 @EVP_MD_type(i32* %103)
%105 = load i32*, i32** %16
%106 = call i64 @EVP_MD_type(i32* %105)
%107 = icmp ne i64 %104, %106
br i1 %107, label %108, label %112
108: ; preds = %102
%109 = load i32, i32* @RSA_F_RSA_PSS_TO_CTX
%110 = load i32, i32* @RSA_R_DIGEST_DOES_NOT_MATCH
%111 = call i32 @RSAerr(i32 %109, i32 %110)
br label %132
112: ; preds = %102
br label %113
113: ; preds = %112, %96
%114 = load i32*, i32** %7
%115 = load i32, i32* @RSA_PKCS1_PSS_PADDING
%116 = call i64 @EVP_PKEY_CTX_set_rsa_padding(i32* %114, i32 %115)
%117 = icmp sle i64 %116, 0
br i1 %117, label %118, label %119
118: ; preds = %113
br label %132
119: ; preds = %113
%120 = load i32*, i32** %7
%121 = load i32, i32* %11
%122 = call i64 @EVP_PKEY_CTX_set_rsa_pss_saltlen(i32* %120, i32 %121)
%123 = icmp sle i64 %122, 0
br i1 %123, label %124, label %125
124: ; preds = %119
br label %132
125: ; preds = %119
%126 = load i32*, i32** %7
%127 = load i32*, i32** %12
%128 = call i64 @EVP_PKEY_CTX_set_rsa_mgf1_md(i32* %126, i32* %127)
%129 = icmp sle i64 %128, 0
br i1 %129, label %130, label %131
130: ; preds = %125
br label %132
131: ; preds = %125
store i32 1, i32* %10
br label %132
132: ; preds = %131, %130, %124, %118, %108, %101, %95, %82, %65, %52, %44, %32
%133 = load %struct.TYPE_11__*, %struct.TYPE_11__** %14
%134 = call i32 @RSA_PSS_PARAMS_free(%struct.TYPE_11__* %133)
%135 = load %struct.TYPE_10__*, %struct.TYPE_10__** %15
%136 = icmp ne %struct.TYPE_10__* %135, null
br i1 %136, label %137, label %140
137: ; preds = %132
%138 = load %struct.TYPE_10__*, %struct.TYPE_10__** %15
%139 = call i32 @X509_ALGOR_free(%struct.TYPE_10__* %138)
br label %140
140: ; preds = %137, %132
%141 = load i32, i32* %10
store i32 %141, i32* %5
br label %142
142: ; preds = %140, %23
%143 = load i32, i32* %5
ret i32 %143
}

LLVM IR (-O2):
%struct.TYPE_10__ = type { i32 }
%struct.TYPE_11__ = type { i64, i64, i32, i32 }
@NID_rsassaPss = global i64 0
@RSA_F_RSA_PSS_TO_CTX = global i32 0
@RSA_R_UNSUPPORTED_SIGNATURE_TYPE = global i32 0
@RSA_R_INVALID_PSS_PARAMETERS = global i32 0
@RSA_R_INVALID_SALT_LENGTH = global i32 0
@RSA_R_INVALID_TRAILER = global i32 0
@RSA_R_DIGEST_DOES_NOT_MATCH = global i32 0
@RSA_PKCS1_PSS_PADDING = global i32 0
define i32 @rsa_pss_to_ctx(i32* %0, i32* %1, %struct.TYPE_10__* %2, i32* %3) {
%5 = alloca i32*
%6 = alloca %struct.TYPE_10__*
%7 = alloca i32*
store i32* %1, i32** %5
%8 = bitcast %struct.TYPE_10__** %6 to i8*
%9 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %2, i64 0, i32 0
%10 = load i32, i32* %9
%11 = tail call i64 @OBJ_obj2nid(i32 %10)
%12 = load i64, i64* @NID_rsassaPss
%13 = icmp eq i64 %11, %12
br i1 %13, label %18, label %14
14: ; preds = %4
%15 = load i32, i32* @RSA_F_RSA_PSS_TO_CTX
%16 = load i32, i32* @RSA_R_UNSUPPORTED_SIGNATURE_TYPE
%17 = tail call i32 @RSAerr(i32 %15, i32 %16)
br label %102
18: ; preds = %4
%19 = call %struct.TYPE_11__* @rsa_pss_decode(%struct.TYPE_10__* %2, %struct.TYPE_10__** %6)
%20 = icmp eq %struct.TYPE_11__* %19, null
br i1 %20, label %21, label %25
21: ; preds = %18
%22 = load i32, i32* @RSA_F_RSA_PSS_TO_CTX
%23 = load i32, i32* @RSA_R_INVALID_PSS_PARAMETERS
%24 = call i32 @RSAerr(i32 %22, i32 %23)
br label %95
25: ; preds = %18
%26 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %19, i64 0, i32 3
%27 = load i32, i32* %26
%28 = load %struct.TYPE_10__*, %struct.TYPE_10__** %6
%29 = call i32* @rsa_mgf1_to_md(i32 %27, %struct.TYPE_10__* %28)
%30 = icmp eq i32* %29, null
br i1 %30, label %95, label %31
31: ; preds = %25
%32 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %19, i64 0, i32 2
%33 = load i32, i32* %32
%34 = call i32* @rsa_algor_to_md(i32 %33)
%35 = icmp eq i32* %34, null
br i1 %35, label %95, label %36
36: ; preds = %31
%37 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %19, i64 0, i32 1
%38 = load i64, i64* %37
%39 = icmp eq i64 %38, 0
br i1 %39, label %47, label %40
40: ; preds = %36
%41 = call i32 @ASN1_INTEGER_get(i64 %38)
%42 = icmp slt i32 %41, 0
br i1 %42, label %43, label %47
43: ; preds = %40
%44 = load i32, i32* @RSA_F_RSA_PSS_TO_CTX
%45 = load i32, i32* @RSA_R_INVALID_SALT_LENGTH
%46 = call i32 @RSAerr(i32 %44, i32 %45)
br label %95
47: ; preds = %36, %40
%48 = phi i32 [ %41, %40 ], [ 20, %36 ]
%49 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %19, i64 0, i32 0
%50 = load i64, i64* %49
%51 = icmp eq i64 %50, 0
br i1 %51, label %59, label %52
52: ; preds = %47
%53 = call i32 @ASN1_INTEGER_get(i64 %50)
%54 = icmp eq i32 %53, 1
br i1 %54, label %59, label %55
55: ; preds = %52
%56 = load i32, i32* @RSA_F_RSA_PSS_TO_CTX
%57 = load i32, i32* @RSA_R_INVALID_TRAILER
%58 = call i32 @RSAerr(i32 %56, i32 %57)
br label %95
59: ; preds = %52, %47
%60 = icmp eq i32* %3, null
br i1 %60, label %66, label %61
61: ; preds = %59
%62 = call i32 @EVP_DigestVerifyInit(i32* %0, i32** %5, i32* %34, i32* null, i32* %3)
%63 = icmp eq i32 %62, 0
br i1 %63, label %95, label %64
64: ; preds = %61
%65 = load i32*, i32** %5
br label %81
66: ; preds = %59
%67 = bitcast i32** %7 to i8*
%68 = call i64 @EVP_PKEY_CTX_get_signature_md(i32* %1, i32** %7)
%69 = icmp slt i64 %68, 1
br i1 %69, label %79, label %70
70: ; preds = %66
%71 = call i64 @EVP_MD_type(i32* %34)
%72 = load i32*, i32** %7
%73 = call i64 @EVP_MD_type(i32* %72)
%74 = icmp eq i64 %71, %73
br i1 %74, label %80, label %75
75: ; preds = %70
%76 = load i32, i32* @RSA_F_RSA_PSS_TO_CTX
%77 = load i32, i32* @RSA_R_DIGEST_DOES_NOT_MATCH
%78 = call i32 @RSAerr(i32 %76, i32 %77)
br label %79
79: ; preds = %75, %66
br label %95
80: ; preds = %70
br label %81
81: ; preds = %64, %80
%82 = phi i32* [ %65, %64 ], [ %1, %80 ]
%83 = load i32, i32* @RSA_PKCS1_PSS_PADDING
%84 = call i64 @EVP_PKEY_CTX_set_rsa_padding(i32* %82, i32 %83)
%85 = icmp slt i64 %84, 1
br i1 %85, label %95, label %86
86: ; preds = %81
%87 = load i32*, i32** %5
%88 = call i64 @EVP_PKEY_CTX_set_rsa_pss_saltlen(i32* %87, i32 %48)
%89 = icmp slt i64 %88, 1
br i1 %89, label %95, label %90
90: ; preds = %86
%91 = load i32*, i32** %5
%92 = call i64 @EVP_PKEY_CTX_set_rsa_mgf1_md(i32* %91, i32* %29)
%93 = icmp slt i64 %92, 1
%94 = select i1 %93, i32 -1, i32 1
br label %95
95: ; preds = %79, %90, %86, %81, %61, %31, %25, %55, %43, %21
%96 = phi i32 [ -1, %21 ], [ -1, %43 ], [ -1, %55 ], [ -1, %81 ], [ -1, %86 ], [ -1, %61 ], [ -1, %31 ], [ -1, %25 ], [ %94, %90 ], [ -1, %79 ]
%97 = call i32 @RSA_PSS_PARAMS_free(%struct.TYPE_11__* %19)
%98 = load %struct.TYPE_10__*, %struct.TYPE_10__** %6
%99 = icmp eq %struct.TYPE_10__* %98, null
br i1 %99, label %102, label %100
100: ; preds = %95
%101 = call i32 @X509_ALGOR_free(%struct.TYPE_10__* %98)
br label %102
102: ; preds = %95, %100, %14
%103 = phi i32 [ -1, %14 ], [ %96, %100 ], [ %96, %95 ]
ret i32 %103
}