#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 */

/* Type definitions */
typedef int /*<<< orphan*/ EVP_PKEY_CTX;
typedef int /*<<< orphan*/ EVP_MD;
typedef int /*<<< orphan*/ BIGNUM;

/* Variables and functions */
int /*<<< orphan*/ BN_asc2bn(int /*<<< orphan*/ **, char const *);
int /*<<< orphan*/ BN_free(int /*<<< orphan*/ *);
int EVP_PKEY_CTX_set0_rsa_oaep_label(int /*<<< orphan*/ *, unsigned char *,
                                     long);
int EVP_PKEY_CTX_set_rsa_keygen_bits(int /*<<< orphan*/ *, int);
int EVP_PKEY_CTX_set_rsa_keygen_pubexp(int /*<<< orphan*/ *,
                                       int /*<<< orphan*/ *);
int EVP_PKEY_CTX_set_rsa_mgf1_md(int /*<<< orphan*/ *,
                                 int /*<<< orphan*/ const *);
int EVP_PKEY_CTX_set_rsa_oaep_md(int /*<<< orphan*/ *,
                                 int /*<<< orphan*/ const *);
int EVP_PKEY_CTX_set_rsa_padding(int /*<<< orphan*/ *, int);
int EVP_PKEY_CTX_set_rsa_pss_saltlen(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ *EVP_get_digestbyname(char const *);
int /*<<< orphan*/ OPENSSL_free(unsigned char *);
int /*<<< orphan*/ RSA_F_PKEY_RSA_CTRL_STR;
int RSA_NO_PADDING;
int RSA_PKCS1_OAEP_PADDING;
int RSA_PKCS1_PADDING;
int RSA_PKCS1_PSS_PADDING;
int /*<<< orphan*/ RSA_R_INVALID_DIGEST;
int /*<<< orphan*/ RSA_R_UNKNOWN_PADDING_TYPE;
int /*<<< orphan*/ RSA_R_VALUE_MISSING;
int RSA_SSLV23_PADDING;
int RSA_X931_PADDING;
int /*<<< orphan*/ RSAerr(int /*<<< orphan*/, int /*<<< orphan*/);
int atoi(char const *);
int /*<<< orphan*/ strcmp(char const *, char *);
unsigned char *string_to_hex(char const *, long *);
int pkey_rsa_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, const char *value) {
  if (!value) {
    RSAerr(RSA_F_PKEY_RSA_CTRL_STR, RSA_R_VALUE_MISSING);
    return 0;
  }
  if (!strcmp(type, "rsa_padding_mode")) {
    int pm;
    if (!strcmp(value, "pkcs1"))
      pm = RSA_PKCS1_PADDING;
    else if (!strcmp(value, "sslv23"))
      pm = RSA_SSLV23_PADDING;
    else if (!strcmp(value, "none"))
      pm = RSA_NO_PADDING;
    else if (!strcmp(value, "oeap"))
      pm = RSA_PKCS1_OAEP_PADDING;
    else if (!strcmp(value, "oaep"))
      pm = RSA_PKCS1_OAEP_PADDING;
    else if (!strcmp(value, "x931"))
      pm = RSA_X931_PADDING;
    else if (!strcmp(value, "pss"))
      pm = RSA_PKCS1_PSS_PADDING;
    else {
      RSAerr(RSA_F_PKEY_RSA_CTRL_STR, RSA_R_UNKNOWN_PADDING_TYPE);
      return -2;
    }
    return EVP_PKEY_CTX_set_rsa_padding(ctx, pm);
  }
  if (!strcmp(type, "rsa_pss_saltlen")) {
    int saltlen;
    saltlen = atoi(value);
    return EVP_PKEY_CTX_set_rsa_pss_saltlen(ctx, saltlen);
  }
  if (!strcmp(type, "rsa_keygen_bits")) {
    int nbits;
    nbits = atoi(value);
    return EVP_PKEY_CTX_set_rsa_keygen_bits(ctx, nbits);
  }
  if (!strcmp(type, "rsa_keygen_pubexp")) {
    int ret;
    BIGNUM *pubexp = NULL;
    if (!BN_asc2bn(&pubexp, value))
      return 0;
    ret = EVP_PKEY_CTX_set_rsa_keygen_pubexp(ctx, pubexp);
    if (ret <= 0)
      BN_free(pubexp);
    return ret;
  }
  if (!strcmp(type, "rsa_mgf1_md")) {
    const EVP_MD *md;
    if (!(md = EVP_get_digestbyname(value))) {
      RSAerr(RSA_F_PKEY_RSA_CTRL_STR, RSA_R_INVALID_DIGEST);
      return 0;
    }
    return EVP_PKEY_CTX_set_rsa_mgf1_md(ctx, md);
  }
  if (!strcmp(type, "rsa_oaep_md")) {
    const EVP_MD *md;
    if (!(md = EVP_get_digestbyname(value))) {
      RSAerr(RSA_F_PKEY_RSA_CTRL_STR, RSA_R_INVALID_DIGEST);
      return 0;
    }
    return EVP_PKEY_CTX_set_rsa_oaep_md(ctx, md);
  }
  if (!strcmp(type, "rsa_oaep_label")) {
    unsigned char *lab;
    long lablen;
    int ret;
    lab = string_to_hex(value, &lablen);
    if (!lab)
      return 0;
    ret = EVP_PKEY_CTX_set0_rsa_oaep_label(ctx, lab, lablen);
    if (ret <= 0)
      OPENSSL_free(lab);
    return ret;
  }
  return -2;
}


x86 assembly (clang, -O0):
<pkey_rsa_ctrl_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1232 <pkey_rsa_ctrl_str+0x42>
mov    0x2d92(%rip),%rax
mov    (%rax),%edi
mov    0x2d99(%rip),%rax
mov    (%rax),%esi
call   10d0 <RSAerr@plt>
movl   $0x0,-0x4(%rbp)
jmp    15f3 <pkey_rsa_ctrl_str+0x403>
mov    -0x18(%rbp),%rdi
lea    0xdc3(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    13c6 <pkey_rsa_ctrl_str+0x1d6>
mov    -0x20(%rbp),%rdi
lea    0xdbb(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1275 <pkey_rsa_ctrl_str+0x85>
mov    0x2d2d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    13b2 <pkey_rsa_ctrl_str+0x1c2>
mov    -0x20(%rbp),%rdi
lea    0xd97(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    129f <pkey_rsa_ctrl_str+0xaf>
mov    0x2d2b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    13ad <pkey_rsa_ctrl_str+0x1bd>
mov    -0x20(%rbp),%rdi
lea    0xd74(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    12c9 <pkey_rsa_ctrl_str+0xd9>
mov    0x2d19(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    13a8 <pkey_rsa_ctrl_str+0x1b8>
mov    -0x20(%rbp),%rdi
lea    0xd4f(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    12f3 <pkey_rsa_ctrl_str+0x103>
mov    0x2ce7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    13a3 <pkey_rsa_ctrl_str+0x1b3>
mov    -0x20(%rbp),%rdi
lea    0xd2a(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    131d <pkey_rsa_ctrl_str+0x12d>
mov    0x2cbd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    139e <pkey_rsa_ctrl_str+0x1ae>
mov    -0x20(%rbp),%rdi
lea    0xd05(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1347 <pkey_rsa_ctrl_str+0x157>
mov    0x2ca3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    1399 <pkey_rsa_ctrl_str+0x1a9>
mov    -0x20(%rbp),%rdi
lea    0xce0(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1371 <pkey_rsa_ctrl_str+0x181>
mov    0x2c29(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    1394 <pkey_rsa_ctrl_str+0x1a4>
mov    0x2c30(%rip),%rax
mov    (%rax),%edi
mov    0x2c6f(%rip),%rax
mov    (%rax),%esi
call   10d0 <RSAerr@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    15f3 <pkey_rsa_ctrl_str+0x403>
jmp    1399 <pkey_rsa_ctrl_str+0x1a9>
jmp    139e <pkey_rsa_ctrl_str+0x1ae>
jmp    13a3 <pkey_rsa_ctrl_str+0x1b3>
jmp    13a8 <pkey_rsa_ctrl_str+0x1b8>
jmp    13ad <pkey_rsa_ctrl_str+0x1bd>
jmp    13b2 <pkey_rsa_ctrl_str+0x1c2>
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   10c0 <EVP_PKEY_CTX_set_rsa_padding@plt>
mov    %eax,-0x4(%rbp)
jmp    15f3 <pkey_rsa_ctrl_str+0x403>
mov    -0x18(%rbp),%rdi
lea    0xc65(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    13ff <pkey_rsa_ctrl_str+0x20f>
mov    -0x20(%rbp),%rdi
call   10e0 <atoi@plt>
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%esi
call   1100 <EVP_PKEY_CTX_set_rsa_pss_saltlen@plt>
mov    %eax,-0x4(%rbp)
jmp    15f3 <pkey_rsa_ctrl_str+0x403>
mov    -0x18(%rbp),%rdi
lea    0xc3c(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1438 <pkey_rsa_ctrl_str+0x248>
mov    -0x20(%rbp),%rdi
call   10e0 <atoi@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1060 <EVP_PKEY_CTX_set_rsa_keygen_bits@plt>
mov    %eax,-0x4(%rbp)
jmp    15f3 <pkey_rsa_ctrl_str+0x403>
mov    -0x18(%rbp),%rdi
lea    0xc13(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    14a9 <pkey_rsa_ctrl_str+0x2b9>
movq   $0x0,-0x38(%rbp)
mov    -0x20(%rbp),%rsi
lea    -0x38(%rbp),%rdi
call   1030 <BN_asc2bn@plt>
cmp    $0x0,%eax
jne    147b <pkey_rsa_ctrl_str+0x28b>
movl   $0x0,-0x4(%rbp)
jmp    15f3 <pkey_rsa_ctrl_str+0x403>
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1090 <EVP_PKEY_CTX_set_rsa_keygen_pubexp@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
jg     149e <pkey_rsa_ctrl_str+0x2ae>
mov    -0x38(%rbp),%rdi
call   1040 <BN_free@plt>
mov    -0x30(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    15f3 <pkey_rsa_ctrl_str+0x403>
mov    -0x18(%rbp),%rdi
lea    0xbb4(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1511 <pkey_rsa_ctrl_str+0x321>
mov    -0x20(%rbp),%rdi
call   1080 <EVP_get_digestbyname@plt>
mov    %rax,-0x40(%rbp)
cmp    $0x0,%rax
jne    14fc <pkey_rsa_ctrl_str+0x30c>
mov    0x2ac8(%rip),%rax
mov    (%rax),%edi
mov    0x2ac7(%rip),%rax
mov    (%rax),%esi
call   10d0 <RSAerr@plt>
movl   $0x0,-0x4(%rbp)
jmp    15f3 <pkey_rsa_ctrl_str+0x403>
mov    -0x10(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   10b0 <EVP_PKEY_CTX_set_rsa_mgf1_md@plt>
mov    %eax,-0x4(%rbp)
jmp    15f3 <pkey_rsa_ctrl_str+0x403>
mov    -0x18(%rbp),%rdi
lea    0xb58(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1579 <pkey_rsa_ctrl_str+0x389>
mov    -0x20(%rbp),%rdi
call   1080 <EVP_get_digestbyname@plt>
mov    %rax,-0x48(%rbp)
cmp    $0x0,%rax
jne    1564 <pkey_rsa_ctrl_str+0x374>
mov    0x2a60(%rip),%rax
mov    (%rax),%edi
mov    0x2a5f(%rip),%rax
mov    (%rax),%esi
call   10d0 <RSAerr@plt>
movl   $0x0,-0x4(%rbp)
jmp    15f3 <pkey_rsa_ctrl_str+0x403>
mov    -0x10(%rbp),%rdi
mov    -0x48(%rbp),%rsi
call   1070 <EVP_PKEY_CTX_set_rsa_oaep_md@plt>
mov    %eax,-0x4(%rbp)
jmp    15f3 <pkey_rsa_ctrl_str+0x403>
mov    -0x18(%rbp),%rdi
lea    0xafc(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    15ec <pkey_rsa_ctrl_str+0x3fc>
mov    -0x20(%rbp),%rdi
lea    -0x58(%rbp),%rsi
call   10a0 <string_to_hex@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    15ba <pkey_rsa_ctrl_str+0x3ca>
movl   $0x0,-0x4(%rbp)
jmp    15f3 <pkey_rsa_ctrl_str+0x403>
mov    -0x10(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    -0x58(%rbp),%rdx
call   1110 <EVP_PKEY_CTX_set0_rsa_oaep_label@plt>
mov    %eax,-0x5c(%rbp)
cmpl   $0x0,-0x5c(%rbp)
jg     15e1 <pkey_rsa_ctrl_str+0x3f1>
mov    -0x50(%rbp),%rdi
call   10f0 <OPENSSL_free@plt>
mov    -0x5c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    15f3 <pkey_rsa_ctrl_str+0x403>
movl   $0xfffffffe,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pkey_rsa_ctrl_str>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
test   %rdx,%rdx
je     12e2 <pkey_rsa_ctrl_str+0xf2>
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xdee(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1307 <pkey_rsa_ctrl_str+0x117>
lea    0xe0d(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     13d0 <pkey_rsa_ctrl_str+0x1e0>
lea    0xe06(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     13eb <pkey_rsa_ctrl_str+0x1fb>
lea    0xdff(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     140f <pkey_rsa_ctrl_str+0x21f>
lea    0xdfa(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     145c <pkey_rsa_ctrl_str+0x26c>
lea    0xdef(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1497 <pkey_rsa_ctrl_str+0x2a7>
lea    0xde4(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
mov    $0xfffffffe,%ebx
test   %eax,%eax
jne    12fb <pkey_rsa_ctrl_str+0x10b>
lea    0x8(%rsp),%rsi
mov    %r15,%rdi
call   10a0 <string_to_hex@plt>
test   %rax,%rax
je     12f9 <pkey_rsa_ctrl_str+0x109>
mov    %rax,%r15
mov    0x8(%rsp),%rdx
mov    %r14,%rdi
mov    %rax,%rsi
call   1110 <EVP_PKEY_CTX_set0_rsa_oaep_label@plt>
mov    %eax,%ebx
test   %eax,%eax
jg     12fb <pkey_rsa_ctrl_str+0x10b>
mov    %r15,%rdi
call   10f0 <OPENSSL_free@plt>
jmp    12fb <pkey_rsa_ctrl_str+0x10b>
mov    0x2cbf(%rip),%rax
mov    (%rax),%edi
mov    0x2cc6(%rip),%rax
mov    (%rax),%esi
call   10d0 <RSAerr@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xd03(%rip),%rsi
mov    %r15,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1406 <pkey_rsa_ctrl_str+0x216>
lea    0xcf2(%rip),%rsi
mov    %r15,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1453 <pkey_rsa_ctrl_str+0x263>
lea    0xce2(%rip),%rsi
mov    %r15,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     147d <pkey_rsa_ctrl_str+0x28d>
lea    0xcd0(%rip),%rsi
mov    %r15,%rdi
call   1050 <strcmp@plt>
mov    0x2c6e(%rip),%rbx
test   %eax,%eax
je     1484 <pkey_rsa_ctrl_str+0x294>
lea    0xcb7(%rip),%rsi
mov    %r15,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1484 <pkey_rsa_ctrl_str+0x294>
lea    0xca5(%rip),%rsi
mov    %r15,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     14cd <pkey_rsa_ctrl_str+0x2dd>
lea    0xc93(%rip),%rsi
mov    %r15,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     14d6 <pkey_rsa_ctrl_str+0x2e6>
mov    0x2bf2(%rip),%rax
mov    (%rax),%edi
mov    0x2c31(%rip),%rax
mov    (%rax),%esi
call   10d0 <RSAerr@plt>
mov    $0xfffffffe,%ebx
jmp    12fb <pkey_rsa_ctrl_str+0x10b>
mov    %r15,%rdi
call   10e0 <atoi@plt>
mov    %r14,%rdi
mov    %eax,%esi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1100 <EVP_PKEY_CTX_set_rsa_pss_saltlen@plt>
mov    %r15,%rdi
call   10e0 <atoi@plt>
mov    %r14,%rdi
mov    %eax,%esi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1060 <EVP_PKEY_CTX_set_rsa_keygen_bits@plt>
mov    0x2b8b(%rip),%rbx
jmp    1484 <pkey_rsa_ctrl_str+0x294>
movq   $0x0,0x8(%rsp)
lea    0x8(%rsp),%rdi
mov    %r15,%rsi
call   1030 <BN_asc2bn@plt>
test   %eax,%eax
je     12f9 <pkey_rsa_ctrl_str+0x109>
mov    0x8(%rsp),%rsi
mov    %r14,%rdi
call   1090 <EVP_PKEY_CTX_set_rsa_keygen_pubexp@plt>
mov    %eax,%ebx
test   %eax,%eax
jg     12fb <pkey_rsa_ctrl_str+0x10b>
mov    0x8(%rsp),%rdi
call   1040 <BN_free@plt>
jmp    12fb <pkey_rsa_ctrl_str+0x10b>
mov    0x2b66(%rip),%rbx
jmp    1484 <pkey_rsa_ctrl_str+0x294>
mov    %r15,%rdi
call   1080 <EVP_get_digestbyname@plt>
test   %rax,%rax
je     14b8 <pkey_rsa_ctrl_str+0x2c8>
mov    %r14,%rdi
mov    %rax,%rsi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    10b0 <EVP_PKEY_CTX_set_rsa_mgf1_md@plt>
mov    0x2b54(%rip),%rbx
mov    (%rbx),%esi
mov    %r14,%rdi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    10c0 <EVP_PKEY_CTX_set_rsa_padding@plt>
mov    %r15,%rdi
call   1080 <EVP_get_digestbyname@plt>
test   %rax,%rax
je     14b8 <pkey_rsa_ctrl_str+0x2c8>
mov    %r14,%rdi
mov    %rax,%rsi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1070 <EVP_PKEY_CTX_set_rsa_oaep_md@plt>
mov    0x2ae9(%rip),%rax
mov    (%rax),%edi
mov    0x2ae8(%rip),%rax
jmp    12f2 <pkey_rsa_ctrl_str+0x102>
mov    0x2b0c(%rip),%rbx
jmp    1484 <pkey_rsa_ctrl_str+0x294>
mov    0x2ab3(%rip),%rbx
jmp    1484 <pkey_rsa_ctrl_str+0x294>

LLVM IR (-O0):
@RSA_F_PKEY_RSA_CTRL_STR = global i32 0
@RSA_R_VALUE_MISSING = global i32 0
@.str = [17 x i8] c"rsa_padding_mode\00"
@.str.1 = [6 x i8] c"pkcs1\00"
@RSA_PKCS1_PADDING = global i32 0
@.str.2 = [7 x i8] c"sslv23\00"
@RSA_SSLV23_PADDING = global i32 0
@.str.3 = [5 x i8] c"none\00"
@RSA_NO_PADDING = global i32 0
@.str.4 = [5 x i8] c"oeap\00"
@RSA_PKCS1_OAEP_PADDING = global i32 0
@.str.5 = [5 x i8] c"oaep\00"
@.str.6 = [5 x i8] c"x931\00"
@RSA_X931_PADDING = global i32 0
@.str.7 = [4 x i8] c"pss\00"
@RSA_PKCS1_PSS_PADDING = global i32 0
@RSA_R_UNKNOWN_PADDING_TYPE = global i32 0
@.str.8 = [16 x i8] c"rsa_pss_saltlen\00"
@.str.9 = [16 x i8] c"rsa_keygen_bits\00"
@.str.10 = [18 x i8] c"rsa_keygen_pubexp\00"
@.str.11 = [12 x i8] c"rsa_mgf1_md\00"
@RSA_R_INVALID_DIGEST = global i32 0
@.str.12 = [12 x i8] c"rsa_oaep_md\00"
@.str.13 = [15 x i8] c"rsa_oaep_label\00"
define i32 @pkey_rsa_ctrl_str(i32* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i8*
%16 = alloca i64
%17 = alloca i32
store i32* %0, i32** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%18 = load i8*, i8** %7
%19 = icmp ne i8* %18, null
br i1 %19, label %24, label %20
20: ; preds = %3
%21 = load i32, i32* @RSA_F_PKEY_RSA_CTRL_STR
%22 = load i32, i32* @RSA_R_VALUE_MISSING
%23 = call i32 @RSAerr(i32 %21, i32 %22)
store i32 0, i32* %4
br label %179
24: ; preds = %3
%25 = load i8*, i8** %6
%26 = call i32 @strcmp(i8* %25, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%27 = icmp ne i32 %26, 0
br i1 %27, label %84, label %28
28: ; preds = %24
%29 = load i8*, i8** %7
%30 = call i32 @strcmp(i8* %29, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%31 = icmp ne i32 %30, 0
br i1 %31, label %34, label %32
32: ; preds = %28
%33 = load i32, i32* @RSA_PKCS1_PADDING
store i32 %33, i32* %8
br label %80
34: ; preds = %28
%35 = load i8*, i8** %7
%36 = call i32 @strcmp(i8* %35, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%37 = icmp ne i32 %36, 0
br i1 %37, label %40, label %38
38: ; preds = %34
%39 = load i32, i32* @RSA_SSLV23_PADDING
store i32 %39, i32* %8
br label %79
40: ; preds = %34
%41 = load i8*, i8** %7
%42 = call i32 @strcmp(i8* %41, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%43 = icmp ne i32 %42, 0
br i1 %43, label %46, label %44
44: ; preds = %40
%45 = load i32, i32* @RSA_NO_PADDING
store i32 %45, i32* %8
br label %78
46: ; preds = %40
%47 = load i8*, i8** %7
%48 = call i32 @strcmp(i8* %47, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%49 = icmp ne i32 %48, 0
br i1 %49, label %52, label %50
50: ; preds = %46
%51 = load i32, i32* @RSA_PKCS1_OAEP_PADDING
store i32 %51, i32* %8
br label %77
52: ; preds = %46
%53 = load i8*, i8** %7
%54 = call i32 @strcmp(i8* %53, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%55 = icmp ne i32 %54, 0
br i1 %55, label %58, label %56
56: ; preds = %52
%57 = load i32, i32* @RSA_PKCS1_OAEP_PADDING
store i32 %57, i32* %8
br label %76
58: ; preds = %52
%59 = load i8*, i8** %7
%60 = call i32 @strcmp(i8* %59, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%61 = icmp ne i32 %60, 0
br i1 %61, label %64, label %62
62: ; preds = %58
%63 = load i32, i32* @RSA_X931_PADDING
store i32 %63, i32* %8
br label %75
64: ; preds = %58
%65 = load i8*, i8** %7
%66 = call i32 @strcmp(i8* %65, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%67 = icmp ne i32 %66, 0
br i1 %67, label %70, label %68
68: ; preds = %64
%69 = load i32, i32* @RSA_PKCS1_PSS_PADDING
store i32 %69, i32* %8
br label %74
70: ; preds = %64
%71 = load i32, i32* @RSA_F_PKEY_RSA_CTRL_STR
%72 = load i32, i32* @RSA_R_UNKNOWN_PADDING_TYPE
%73 = call i32 @RSAerr(i32 %71, i32 %72)
store i32 -2, i32* %4
br label %179
74: ; preds = %68
br label %75
75: ; preds = %74, %62
br label %76
76: ; preds = %75, %56
br label %77
77: ; preds = %76, %50
br label %78
78: ; preds = %77, %44
br label %79
79: ; preds = %78, %38
br label %80
80: ; preds = %79, %32
%81 = load i32*, i32** %5
%82 = load i32, i32* %8
%83 = call i32 @EVP_PKEY_CTX_set_rsa_padding(i32* %81, i32 %82)
store i32 %83, i32* %4
br label %179
84: ; preds = %24
%85 = load i8*, i8** %6
%86 = call i32 @strcmp(i8* %85, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0))
%87 = icmp ne i32 %86, 0
br i1 %87, label %94, label %88
88: ; preds = %84
%89 = load i8*, i8** %7
%90 = call i32 @atoi(i8* %89)
store i32 %90, i32* %9
%91 = load i32*, i32** %5
%92 = load i32, i32* %9
%93 = call i32 @EVP_PKEY_CTX_set_rsa_pss_saltlen(i32* %91, i32 %92)
store i32 %93, i32* %4
br label %179
94: ; preds = %84
%95 = load i8*, i8** %6
%96 = call i32 @strcmp(i8* %95, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
%97 = icmp ne i32 %96, 0
br i1 %97, label %104, label %98
98: ; preds = %94
%99 = load i8*, i8** %7
%100 = call i32 @atoi(i8* %99)
store i32 %100, i32* %10
%101 = load i32*, i32** %5
%102 = load i32, i32* %10
%103 = call i32 @EVP_PKEY_CTX_set_rsa_keygen_bits(i32* %101, i32 %102)
store i32 %103, i32* %4
br label %179
104: ; preds = %94
%105 = load i8*, i8** %6
%106 = call i32 @strcmp(i8* %105, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0))
%107 = icmp ne i32 %106, 0
br i1 %107, label %124, label %108
108: ; preds = %104
store i32* null, i32** %12
%109 = load i8*, i8** %7
%110 = call i32 @BN_asc2bn(i32** %12, i8* %109)
%111 = icmp ne i32 %110, 0
br i1 %111, label %113, label %112
112: ; preds = %108
store i32 0, i32* %4
br label %179
113: ; preds = %108
%114 = load i32*, i32** %5
%115 = load i32*, i32** %12
%116 = call i32 @EVP_PKEY_CTX_set_rsa_keygen_pubexp(i32* %114, i32* %115)
store i32 %116, i32* %11
%117 = load i32, i32* %11
%118 = icmp sle i32 %117, 0
br i1 %118, label %119, label %122
119: ; preds = %113
%120 = load i32*, i32** %12
%121 = call i32 @BN_free(i32* %120)
br label %122
122: ; preds = %119, %113
%123 = load i32, i32* %11
store i32 %123, i32* %4
br label %179
124: ; preds = %104
%125 = load i8*, i8** %6
%126 = call i32 @strcmp(i8* %125, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0))
%127 = icmp ne i32 %126, 0
br i1 %127, label %140, label %128
128: ; preds = %124
%129 = load i8*, i8** %7
%130 = call i32* @EVP_get_digestbyname(i8* %129)
store i32* %130, i32** %13
%131 = icmp ne i32* %130, null
br i1 %131, label %136, label %132
132: ; preds = %128
%133 = load i32, i32* @RSA_F_PKEY_RSA_CTRL_STR
%134 = load i32, i32* @RSA_R_INVALID_DIGEST
%135 = call i32 @RSAerr(i32 %133, i32 %134)
store i32 0, i32* %4
br label %179
136: ; preds = %128
%137 = load i32*, i32** %5
%138 = load i32*, i32** %13
%139 = call i32 @EVP_PKEY_CTX_set_rsa_mgf1_md(i32* %137, i32* %138)
store i32 %139, i32* %4
br label %179
140: ; preds = %124
%141 = load i8*, i8** %6
%142 = call i32 @strcmp(i8* %141, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0))
%143 = icmp ne i32 %142, 0
br i1 %143, label %156, label %144
144: ; preds = %140
%145 = load i8*, i8** %7
%146 = call i32* @EVP_get_digestbyname(i8* %145)
store i32* %146, i32** %14
%147 = icmp ne i32* %146, null
br i1 %147, label %152, label %148
148: ; preds = %144
%149 = load i32, i32* @RSA_F_PKEY_RSA_CTRL_STR
%150 = load i32, i32* @RSA_R_INVALID_DIGEST
%151 = call i32 @RSAerr(i32 %149, i32 %150)
store i32 0, i32* %4
br label %179
152: ; preds = %144
%153 = load i32*, i32** %5
%154 = load i32*, i32** %14
%155 = call i32 @EVP_PKEY_CTX_set_rsa_oaep_md(i32* %153, i32* %154)
store i32 %155, i32* %4
br label %179
156: ; preds = %140
%157 = load i8*, i8** %6
%158 = call i32 @strcmp(i8* %157, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.13, i64 0, i64 0))
%159 = icmp ne i32 %158, 0
br i1 %159, label %178, label %160
160: ; preds = %156
%161 = load i8*, i8** %7
%162 = call i8* @string_to_hex(i8* %161, i64* %16)
store i8* %162, i8** %15
%163 = load i8*, i8** %15
%164 = icmp ne i8* %163, null
br i1 %164, label %166, label %165
165: ; preds = %160
store i32 0, i32* %4
br label %179
166: ; preds = %160
%167 = load i32*, i32** %5
%168 = load i8*, i8** %15
%169 = load i64, i64* %16
%170 = call i32 @EVP_PKEY_CTX_set0_rsa_oaep_label(i32* %167, i8* %168, i64 %169)
store i32 %170, i32* %17
%171 = load i32, i32* %17
%172 = icmp sle i32 %171, 0
br i1 %172, label %173, label %176
173: ; preds = %166
%174 = load i8*, i8** %15
%175 = call i32 @OPENSSL_free(i8* %174)
br label %176
176: ; preds = %173, %166
%177 = load i32, i32* %17
store i32 %177, i32* %4
br label %179
178: ; preds = %156
store i32 -2, i32* %4
br label %179
179: ; preds = %178, %176, %165, %152, %148, %136, %132, %122, %112, %98, %88, %80, %70, %20
%180 = load i32, i32* %4
ret i32 %180
}

LLVM IR (-O2):
@RSA_F_PKEY_RSA_CTRL_STR = global i32 0
@RSA_R_VALUE_MISSING = global i32 0
@.str = [17 x i8] c"rsa_padding_mode\00"
@.str.1 = [6 x i8] c"pkcs1\00"
@RSA_PKCS1_PADDING = global i32 0
@.str.2 = [7 x i8] c"sslv23\00"
@RSA_SSLV23_PADDING = global i32 0
@.str.3 = [5 x i8] c"none\00"
@RSA_NO_PADDING = global i32 0
@.str.4 = [5 x i8] c"oeap\00"
@RSA_PKCS1_OAEP_PADDING = global i32 0
@.str.5 = [5 x i8] c"oaep\00"
@.str.6 = [5 x i8] c"x931\00"
@RSA_X931_PADDING = global i32 0
@.str.7 = [4 x i8] c"pss\00"
@RSA_PKCS1_PSS_PADDING = global i32 0
@RSA_R_UNKNOWN_PADDING_TYPE = global i32 0
@.str.8 = [16 x i8] c"rsa_pss_saltlen\00"
@.str.9 = [16 x i8] c"rsa_keygen_bits\00"
@.str.10 = [18 x i8] c"rsa_keygen_pubexp\00"
@.str.11 = [12 x i8] c"rsa_mgf1_md\00"
@RSA_R_INVALID_DIGEST = global i32 0
@.str.12 = [12 x i8] c"rsa_oaep_md\00"
@.str.13 = [15 x i8] c"rsa_oaep_label\00"
define i32 @pkey_rsa_ctrl_str(i32* %0, i8* nocapture %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i64
%6 = icmp eq i8* %2, null
br i1 %6, label %7, label %11
7: ; preds = %3
%8 = load i32, i32* @RSA_F_PKEY_RSA_CTRL_STR
%9 = load i32, i32* @RSA_R_VALUE_MISSING
%10 = tail call i32 @RSAerr(i32 %8, i32 %9)
br label %110
11: ; preds = %3
%12 = tail call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(17) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %43
14: ; preds = %11
%15 = tail call i32 @strcmp(i8* %2, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i32 %15, 0
br i1 %16, label %39, label %17
17: ; preds = %14
%18 = tail call i32 @strcmp(i8* %2, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i32 %18, 0
br i1 %19, label %39, label %20
20: ; preds = %17
%21 = tail call i32 @strcmp(i8* %2, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%22 = icmp eq i32 %21, 0
br i1 %22, label %39, label %23
23: ; preds = %20
%24 = tail call i32 @strcmp(i8* %2, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%25 = icmp eq i32 %24, 0
br i1 %25, label %39, label %26
26: ; preds = %23
%27 = tail call i32 @strcmp(i8* %2, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%28 = icmp eq i32 %27, 0
br i1 %28, label %39, label %29
29: ; preds = %26
%30 = tail call i32 @strcmp(i8* %2, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%31 = icmp eq i32 %30, 0
br i1 %31, label %39, label %32
32: ; preds = %29
%33 = tail call i32 @strcmp(i8* %2, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%34 = icmp eq i32 %33, 0
br i1 %34, label %39, label %35
35: ; preds = %32
%36 = load i32, i32* @RSA_F_PKEY_RSA_CTRL_STR
%37 = load i32, i32* @RSA_R_UNKNOWN_PADDING_TYPE
%38 = tail call i32 @RSAerr(i32 %36, i32 %37)
br label %110
39: ; preds = %32, %29, %26, %23, %20, %17, %14
%40 = phi i32* [ @RSA_PKCS1_PADDING, %14 ], [ @RSA_SSLV23_PADDING, %17 ], [ @RSA_NO_PADDING, %20 ], [ @RSA_PKCS1_OAEP_PADDING, %23 ], [ @RSA_PKCS1_OAEP_PADDING, %26 ], [ @RSA_X931_PADDING, %29 ], [ @RSA_PKCS1_PSS_PADDING, %32 ]
%41 = load i32, i32* %40
%42 = tail call i32 @EVP_PKEY_CTX_set_rsa_padding(i32* %0, i32 %41)
br label %110
43: ; preds = %11
%44 = tail call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(16) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0))
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %49
46: ; preds = %43
%47 = tail call i32 @atoi(i8* %2)
%48 = tail call i32 @EVP_PKEY_CTX_set_rsa_pss_saltlen(i32* %0, i32 %47)
br label %110
49: ; preds = %43
%50 = tail call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(16) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
%51 = icmp eq i32 %50, 0
br i1 %51, label %52, label %55
52: ; preds = %49
%53 = tail call i32 @atoi(i8* %2)
%54 = tail call i32 @EVP_PKEY_CTX_set_rsa_keygen_bits(i32* %0, i32 %53)
br label %110
55: ; preds = %49
%56 = tail call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(18) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0))
%57 = icmp eq i32 %56, 0
br i1 %57, label %58, label %71
58: ; preds = %55
%59 = bitcast i32** %4 to i8*
store i32* null, i32** %4
%60 = call i32 @BN_asc2bn(i32** %4, i8* %2)
%61 = icmp eq i32 %60, 0
br i1 %61, label %69, label %62
62: ; preds = %58
%63 = load i32*, i32** %4
%64 = call i32 @EVP_PKEY_CTX_set_rsa_keygen_pubexp(i32* %0, i32* %63)
%65 = icmp slt i32 %64, 1
br i1 %65, label %66, label %69
66: ; preds = %62
%67 = load i32*, i32** %4
%68 = call i32 @BN_free(i32* %67)
br label %69
69: ; preds = %62, %66, %58
%70 = phi i32 [ 0, %58 ], [ %64, %66 ], [ %64, %62 ]
br label %110
71: ; preds = %55
%72 = tail call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(12) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0))
%73 = icmp eq i32 %72, 0
br i1 %73, label %74, label %83
74: ; preds = %71
%75 = tail call i32* @EVP_get_digestbyname(i8* %2)
%76 = icmp eq i32* %75, null
br i1 %76, label %77, label %81
77: ; preds = %74
%78 = load i32, i32* @RSA_F_PKEY_RSA_CTRL_STR
%79 = load i32, i32* @RSA_R_INVALID_DIGEST
%80 = tail call i32 @RSAerr(i32 %78, i32 %79)
br label %110
81: ; preds = %74
%82 = tail call i32 @EVP_PKEY_CTX_set_rsa_mgf1_md(i32* %0, i32* %75)
br label %110
83: ; preds = %71
%84 = tail call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(12) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0))
%85 = icmp eq i32 %84, 0
br i1 %85, label %86, label %95
86: ; preds = %83
%87 = tail call i32* @EVP_get_digestbyname(i8* %2)
%88 = icmp eq i32* %87, null
br i1 %88, label %89, label %93
89: ; preds = %86
%90 = load i32, i32* @RSA_F_PKEY_RSA_CTRL_STR
%91 = load i32, i32* @RSA_R_INVALID_DIGEST
%92 = tail call i32 @RSAerr(i32 %90, i32 %91)
br label %110
93: ; preds = %86
%94 = tail call i32 @EVP_PKEY_CTX_set_rsa_oaep_md(i32* %0, i32* %87)
br label %110
95: ; preds = %83
%96 = tail call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(15) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.13, i64 0, i64 0))
%97 = icmp eq i32 %96, 0
br i1 %97, label %98, label %110
98: ; preds = %95
%99 = bitcast i64* %5 to i8*
%100 = call i8* @string_to_hex(i8* %2, i64* %5)
%101 = icmp eq i8* %100, null
br i1 %101, label %108, label %102
102: ; preds = %98
%103 = load i64, i64* %5
%104 = call i32 @EVP_PKEY_CTX_set0_rsa_oaep_label(i32* %0, i8* %100, i64 %103)
%105 = icmp slt i32 %104, 1
br i1 %105, label %106, label %108
106: ; preds = %102
%107 = call i32 @OPENSSL_free(i8* %100)
br label %108
108: ; preds = %102, %106, %98
%109 = phi i32 [ 0, %98 ], [ %104, %106 ], [ %104, %102 ]
br label %110
110: ; preds = %95, %89, %93, %77, %81, %35, %39, %108, %69, %52, %46, %7
%111 = phi i32 [ %109, %108 ], [ %70, %69 ], [ %54, %52 ], [ %48, %46 ], [ 0, %7 ], [ -2, %35 ], [ %42, %39 ], [ %82, %81 ], [ 0, %77 ], [ %94, %93 ], [ 0, %89 ], [ -2, %95 ]
ret i32 %111
}