#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*/ X509;
typedef int /*<<< orphan*/ EVP_PKEY_CTX;
typedef int /*<<< orphan*/ EVP_PKEY_ASN1_METHOD;
typedef int /*<<< orphan*/ EVP_PKEY;
typedef int /*<<< orphan*/ BIO;

/* Variables and functions */
int /*<<< orphan*/ BIO_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *BIO_new_file(char const *, char *);
int /*<<< orphan*/ BIO_printf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ BIO_puts(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ BIO_reset(int /*<<< orphan*/ *);
int /*<<< orphan*/ ERR_print_errors(int /*<<< orphan*/ *);
int /*<<< orphan*/ EVP_PKEY_CTX_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *EVP_PKEY_CTX_new(int /*<<< orphan*/ *,
                                     int /*<<< orphan*/ *);
int /*<<< orphan*/ *EVP_PKEY_CTX_new_id(int, int /*<<< orphan*/ *);
scalar_t__ EVP_PKEY_CTX_set_rsa_keygen_bits(int /*<<< orphan*/ *, long);
int EVP_PKEY_RSA;
int /*<<< orphan*/ *EVP_PKEY_asn1_find(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ *EVP_PKEY_asn1_find_str(int /*<<< orphan*/ *, char const *,
                                           int);
int /*<<< orphan*/ EVP_PKEY_asn1_get0_info(int /*<<< orphan*/ *, int *,
                                           int /*<<< orphan*/ *,
                                           int /*<<< orphan*/ *, char const **,
                                           int /*<<< orphan*/ const *);
int EVP_PKEY_base_id(int /*<<< orphan*/ *);
long EVP_PKEY_bits(int /*<<< orphan*/ *);
int /*<<< orphan*/ EVP_PKEY_free(int /*<<< orphan*/ *);
int EVP_PKEY_id(int /*<<< orphan*/ *);
scalar_t__ EVP_PKEY_keygen_init(int /*<<< orphan*/ *);
int /*<<< orphan*/ LONG_MAX;
int /*<<< orphan*/ *PEM_read_bio_Parameters(int /*<<< orphan*/ *,
                                            int /*<<< orphan*/ *);
int /*<<< orphan*/ *PEM_read_bio_X509(int /*<<< orphan*/ *,
                                      int /*<<< orphan*/ *,
                                      int /*<<< orphan*/ *,
                                      int /*<<< orphan*/ *);
int /*<<< orphan*/ X509_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *X509_get_pubkey(int /*<<< orphan*/ *);
char *strchr(char const *, char);
char *strdup(char const *);
int strlen(char const *);
int /*<<< orphan*/ strncmp(char const *, char *, int);
long strtonum(char const *, int /*<<< orphan*/, int /*<<< orphan*/,
              char const **);
EVP_PKEY_CTX *set_keygen_ctx(BIO *err, const char *gstr, int *pkey_type,
                             long *pkeylen, char **palgnam) {
  EVP_PKEY_CTX *gctx = NULL;
  EVP_PKEY *param = NULL;
  long keylen = -1;
  BIO *pbio = NULL;
  const char *paramfile = NULL;
  const char *errstr;
  if (gstr == NULL) {
    *pkey_type = EVP_PKEY_RSA;
    keylen = *pkeylen;
  } else if (gstr[0] >= '0' && gstr[0] <= '9') {
    *pkey_type = EVP_PKEY_RSA;
    keylen = strtonum(gstr, 0, LONG_MAX, &errstr);
    if (errstr) {
      BIO_printf(err, "bad algorithm %s: %s\n", gstr, errstr);
      return NULL;
    }
    *pkeylen = keylen;
  } else if (!strncmp(gstr, "param:", 6))
    paramfile = gstr + 6;
  else {
    const char *p = strchr(gstr, ':');
    int len;
    const EVP_PKEY_ASN1_METHOD *ameth;
    if (p)
      len = p - gstr;
    else
      len = strlen(gstr);
    ameth = EVP_PKEY_asn1_find_str(NULL, gstr, len);
    if (!ameth) {
      BIO_printf(err, "Unknown algorithm %.*s\n", len, gstr);
      return NULL;
    }
    EVP_PKEY_asn1_get0_info(NULL, pkey_type, NULL, NULL, NULL, ameth);
    if (*pkey_type == EVP_PKEY_RSA) {
      if (p) {
        keylen = strtonum(p + 1, 0, LONG_MAX, &errstr);
        if (errstr) {
          BIO_printf(err, "bad algorithm %s: %s\n", p + 1, errstr);
          return NULL;
        }
        *pkeylen = keylen;
      } else
        keylen = *pkeylen;
    } else if (p)
      paramfile = p + 1;
  }
  if (paramfile) {
    pbio = BIO_new_file(paramfile, "r");
    if (!pbio) {
      BIO_printf(err, "Can't open parameter file %s\n", paramfile);
      return NULL;
    }
    param = PEM_read_bio_Parameters(pbio, NULL);
    if (!param) {
      X509 *x;
      (void)BIO_reset(pbio);
      x = PEM_read_bio_X509(pbio, NULL, NULL, NULL);
      if (x) {
        param = X509_get_pubkey(x);
        X509_free(x);
      }
    }
    BIO_free(pbio);
    if (!param) {
      BIO_printf(err, "Error reading parameter file %s\n", paramfile);
      return NULL;
    }
    if (*pkey_type == -1)
      *pkey_type = EVP_PKEY_id(param);
    else if (*pkey_type != EVP_PKEY_base_id(param)) {
      BIO_printf(err, "Key Type does not match parameters\n");
      EVP_PKEY_free(param);
      return NULL;
    }
  }
  if (palgnam) {
    const EVP_PKEY_ASN1_METHOD *ameth;
    const char *anam;
    ameth = EVP_PKEY_asn1_find(NULL, *pkey_type);
    if (!ameth) {
      BIO_puts(err, "Internal error: can't find key algorithm\n");
      return NULL;
    }
    EVP_PKEY_asn1_get0_info(NULL, NULL, NULL, NULL, &anam, ameth);
    *palgnam = strdup(anam);
  }
  if (param) {
    gctx = EVP_PKEY_CTX_new(param, NULL);
    *pkeylen = EVP_PKEY_bits(param);
    EVP_PKEY_free(param);
  } else
    gctx = EVP_PKEY_CTX_new_id(*pkey_type, NULL);
  if (!gctx) {
    BIO_puts(err, "Error allocating keygen context\n");
    ERR_print_errors(err);
    return NULL;
  }
  if (EVP_PKEY_keygen_init(gctx) <= 0) {
    BIO_puts(err, "Error initializing keygen context\n");
    ERR_print_errors(err);
    return NULL;
  }
  if ((*pkey_type == EVP_PKEY_RSA) && (keylen != -1)) {
    if (EVP_PKEY_CTX_set_rsa_keygen_bits(gctx, keylen) <= 0) {
      BIO_puts(err, "Error setting RSA keysize\n");
      ERR_print_errors(err);
      EVP_PKEY_CTX_free(gctx);
      return NULL;
    }
  }
  return gctx;
}


x86 assembly (clang, -O0):
<set_keygen_ctx>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0xffffffffffffffff,-0x48(%rbp)
ff
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x58(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1321 <set_keygen_ctx+0x71>
mov    0x2cdf(%rip),%rax
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x48(%rbp)
jmp    153a <set_keygen_ctx+0x28a>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jl     13ae <set_keygen_ctx+0xfe>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x39,%eax
jg     13ae <set_keygen_ctx+0xfe>
mov    0x2ca0(%rip),%rax
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rdi
mov    0x2c7d(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
lea    -0x60(%rbp),%rcx
call   1120 <strtonum@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x60(%rbp)
je     139e <set_keygen_ctx+0xee>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x60(%rbp),%rcx
lea    0xc76(%rip),%rsi
mov    $0x0,%al
call   10a0 <BIO_printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1849 <set_keygen_ctx+0x599>
mov    -0x48(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
jmp    1535 <set_keygen_ctx+0x285>
mov    -0x18(%rbp),%rdi
lea    0xc5d(%rip),%rsi
mov    $0x6,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%eax
jne    13dd <set_keygen_ctx+0x12d>
mov    -0x18(%rbp),%rax
add    $0x6,%rax
mov    %rax,-0x58(%rbp)
jmp    1530 <set_keygen_ctx+0x280>
mov    -0x18(%rbp),%rdi
mov    $0x3a,%esi
call   1090 <strchr@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x68(%rbp)
je     140d <set_keygen_ctx+0x15d>
mov    -0x68(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x6c(%rbp)
jmp    1419 <set_keygen_ctx+0x169>
mov    -0x18(%rbp),%rdi
call   1070 <strlen@plt>
mov    %eax,-0x6c(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x6c(%rbp),%edx
xor    %eax,%eax
mov    %eax,%edi
call   1080 <EVP_PKEY_asn1_find_str@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x78(%rbp)
jne    145e <set_keygen_ctx+0x1ae>
mov    -0x10(%rbp),%rdi
mov    -0x6c(%rbp),%edx
mov    -0x18(%rbp),%rcx
lea    0xbd3(%rip),%rsi
mov    $0x0,%al
call   10a0 <BIO_printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1849 <set_keygen_ctx+0x599>
mov    -0x20(%rbp),%rsi
mov    -0x78(%rbp),%r9
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rdi
mov    %r8,%rdx
mov    %r8,%rcx
call   1130 <EVP_PKEY_asn1_get0_info@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    0x2b62(%rip),%rcx
cmp    (%rcx),%eax
jne    150f <set_keygen_ctx+0x25f>
cmpq   $0x0,-0x68(%rbp)
je     14ff <set_keygen_ctx+0x24f>
mov    -0x68(%rbp),%rdi
add    $0x1,%rdi
mov    0x2b30(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
lea    -0x60(%rbp),%rcx
call   1120 <strtonum@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x60(%rbp)
je     14ef <set_keygen_ctx+0x23f>
mov    -0x10(%rbp),%rdi
mov    -0x68(%rbp),%rdx
add    $0x1,%rdx
mov    -0x60(%rbp),%rcx
lea    0xb25(%rip),%rsi
mov    $0x0,%al
call   10a0 <BIO_printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1849 <set_keygen_ctx+0x599>
mov    -0x48(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
jmp    150a <set_keygen_ctx+0x25a>
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x48(%rbp)
jmp    152b <set_keygen_ctx+0x27b>
cmpq   $0x0,-0x68(%rbp)
je     1526 <set_keygen_ctx+0x276>
mov    -0x68(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x58(%rbp)
jmp    152b <set_keygen_ctx+0x27b>
jmp    1530 <set_keygen_ctx+0x280>
jmp    1535 <set_keygen_ctx+0x285>
jmp    153a <set_keygen_ctx+0x28a>
cmpq   $0x0,-0x58(%rbp)
je     169a <set_keygen_ctx+0x3ea>
mov    -0x58(%rbp),%rdi
lea    0xae5(%rip),%rsi
call   11c0 <BIO_new_file@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    1587 <set_keygen_ctx+0x2d7>
mov    -0x10(%rbp),%rdi
mov    -0x58(%rbp),%rdx
lea    0xac4(%rip),%rsi
mov    $0x0,%al
call   10a0 <BIO_printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1849 <set_keygen_ctx+0x599>
mov    -0x50(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1110 <PEM_read_bio_Parameters@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    15e9 <set_keygen_ctx+0x339>
mov    -0x50(%rbp),%rdi
call   1180 <BIO_reset@plt>
mov    -0x50(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rsi
mov    %rcx,%rdx
call   1190 <PEM_read_bio_X509@plt>
mov    %rax,-0x80(%rbp)
cmpq   $0x0,-0x80(%rbp)
je     15e4 <set_keygen_ctx+0x334>
mov    -0x80(%rbp),%rdi
call   10d0 <X509_get_pubkey@plt>
mov    %rax,-0x40(%rbp)
mov    -0x80(%rbp),%rdi
call   1140 <X509_free@plt>
jmp    15e9 <set_keygen_ctx+0x339>
mov    -0x50(%rbp),%rdi
call   10f0 <BIO_free@plt>
cmpq   $0x0,-0x40(%rbp)
jne    1620 <set_keygen_ctx+0x370>
mov    -0x10(%rbp),%rdi
mov    -0x58(%rbp),%rdx
lea    0xa49(%rip),%rsi
mov    $0x0,%al
call   10a0 <BIO_printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1849 <set_keygen_ctx+0x599>
mov    -0x20(%rbp),%rax
cmpl   $0xffffffff,(%rax)
jne    1643 <set_keygen_ctx+0x393>
mov    -0x40(%rbp),%rdi
call   11b0 <EVP_PKEY_id@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
jmp    1695 <set_keygen_ctx+0x3e5>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x94(%rbp)
mov    -0x40(%rbp),%rdi
call   1040 <EVP_PKEY_base_id@plt>
mov    %eax,%ecx
mov    -0x94(%rbp),%eax
cmp    %ecx,%eax
je     1690 <set_keygen_ctx+0x3e0>
mov    -0x10(%rbp),%rdi
lea    0xa03(%rip),%rsi
mov    $0x0,%al
call   10a0 <BIO_printf@plt>
mov    -0x40(%rbp),%rdi
call   10b0 <EVP_PKEY_free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1849 <set_keygen_ctx+0x599>
jmp    1695 <set_keygen_ctx+0x3e5>
jmp    169a <set_keygen_ctx+0x3ea>
cmpq   $0x0,-0x30(%rbp)
je     171c <set_keygen_ctx+0x46c>
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
xor    %eax,%eax
mov    %eax,%edi
call   1100 <EVP_PKEY_asn1_find@plt>
mov    %rax,-0x88(%rbp)
cmpq   $0x0,-0x88(%rbp)
jne    16e6 <set_keygen_ctx+0x436>
mov    -0x10(%rbp),%rdi
lea    0x9c6(%rip),%rsi
call   1170 <BIO_puts@plt>
movq   $0x0,-0x8(%rbp)
jmp    1849 <set_keygen_ctx+0x599>
mov    -0x88(%rbp),%r9
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x90(%rbp),%r8
mov    %rcx,%rdi
mov    %rcx,%rsi
mov    %rcx,%rdx
call   1130 <EVP_PKEY_asn1_get0_info@plt>
mov    -0x90(%rbp),%rdi
call   11a0 <strdup@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x40(%rbp)
je     1759 <set_keygen_ctx+0x4a9>
mov    -0x40(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <EVP_PKEY_CTX_new@plt>
mov    %rax,-0x38(%rbp)
mov    -0x40(%rbp),%rdi
call   1160 <EVP_PKEY_bits@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x40(%rbp),%rdi
call   10b0 <EVP_PKEY_free@plt>
jmp    176c <set_keygen_ctx+0x4bc>
mov    -0x20(%rbp),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
call   10e0 <EVP_PKEY_CTX_new_id@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    179d <set_keygen_ctx+0x4ed>
mov    -0x10(%rbp),%rdi
lea    0x942(%rip),%rsi
call   1170 <BIO_puts@plt>
mov    -0x10(%rbp),%rdi
call   1060 <ERR_print_errors@plt>
movq   $0x0,-0x8(%rbp)
jmp    1849 <set_keygen_ctx+0x599>
mov    -0x38(%rbp),%rdi
call   1150 <EVP_PKEY_keygen_init@plt>
cmp    $0x0,%rax
jg     17d6 <set_keygen_ctx+0x526>
mov    -0x10(%rbp),%rdi
lea    0x92a(%rip),%rsi
call   1170 <BIO_puts@plt>
mov    -0x10(%rbp),%rdi
call   1060 <ERR_print_errors@plt>
movq   $0x0,-0x8(%rbp)
jmp    1849 <set_keygen_ctx+0x599>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    0x2805(%rip),%rcx
cmp    (%rcx),%eax
jne    1841 <set_keygen_ctx+0x591>
cmpq   $0xffffffffffffffff,-0x48(%rbp)
je     1841 <set_keygen_ctx+0x591>
mov    -0x38(%rbp),%rdi
mov    -0x48(%rbp),%rsi
call   10c0 <EVP_PKEY_CTX_set_rsa_keygen_bits@plt>
cmp    $0x0,%rax
jg     183c <set_keygen_ctx+0x58c>
mov    -0x10(%rbp),%rdi
lea    0x8f0(%rip),%rsi
call   1170 <BIO_puts@plt>
mov    -0x10(%rbp),%rdi
call   1060 <ERR_print_errors@plt>
mov    -0x38(%rbp),%rdi
call   11d0 <EVP_PKEY_CTX_free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1849 <set_keygen_ctx+0x599>
jmp    1841 <set_keygen_ctx+0x591>
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_keygen_ctx>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8,%r12
mov    %rcx,%rbp
mov    %rdx,%r13
mov    %rdi,%r15
test   %rsi,%rsi
je     132d <set_keygen_ctx+0x7d>
mov    %rsi,%rbx
mov    (%rsi),%al
add    $0xd0,%al
cmp    $0x9,%al
ja     13ec <set_keygen_ctx+0x13c>
mov    0x2d03(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x0(%r13)
mov    0x2ce6(%rip),%rax
mov    (%rax),%edx
lea    0x18(%rsp),%rcx
mov    %rbx,%rdi
xor    %esi,%esi
call   1120 <strtonum@plt>
mov    0x18(%rsp),%rcx
test   %rcx,%rcx
je     142a <set_keygen_ctx+0x17a>
lea    0xce8(%rip),%rsi
xor    %r12d,%r12d
mov    %r15,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   10a0 <BIO_printf@plt>
jmp    16aa <set_keygen_ctx+0x3fa>
mov    0x2cb4(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x0(%r13)
mov    %rbp,0x10(%rsp)
mov    0x0(%rbp),%rbp
xor    %r14d,%r14d
test   %r12,%r12
jne    162c <set_keygen_ctx+0x37c>
test   %r14,%r14
je     1668 <set_keygen_ctx+0x3b8>
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <EVP_PKEY_CTX_new@plt>
mov    %rax,%r12
mov    %r14,%rdi
call   1160 <EVP_PKEY_bits@plt>
mov    0x10(%rsp),%rcx
mov    %rax,(%rcx)
mov    %r14,%rdi
call   10b0 <EVP_PKEY_free@plt>
test   %r12,%r12
je     167f <set_keygen_ctx+0x3cf>
mov    %r12,%rdi
call   1150 <EVP_PKEY_keygen_init@plt>
test   %rax,%rax
jle    1450 <set_keygen_ctx+0x1a0>
mov    0x0(%r13),%eax
mov    0x2c46(%rip),%rcx
cmp    (%rcx),%eax
jne    16aa <set_keygen_ctx+0x3fa>
cmp    $0xffffffffffffffff,%rbp
je     16aa <set_keygen_ctx+0x3fa>
mov    %r12,%rdi
mov    %rbp,%rsi
call   10c0 <EVP_PKEY_CTX_set_rsa_keygen_bits@plt>
test   %rax,%rax
jg     16aa <set_keygen_ctx+0x3fa>
lea    0xd39(%rip),%rsi
mov    %r15,%rdi
call   1170 <BIO_puts@plt>
mov    %r15,%rdi
call   1060 <ERR_print_errors@plt>
mov    %r12,%rdi
call   11d0 <EVP_PKEY_CTX_free@plt>
jmp    16a7 <set_keygen_ctx+0x3f7>
lea    0xc23(%rip),%rsi
mov    %rbx,%rdi
mov    $0x6,%edx
call   1050 <strncmp@plt>
test   %eax,%eax
mov    %r15,0x8(%rsp)
mov    %rbp,0x10(%rsp)
je     1447 <set_keygen_ctx+0x197>
mov    %rbx,%rdi
mov    $0x3a,%esi
call   1090 <strchr@plt>
mov    %rax,%r14
test   %rax,%rax
je     145c <set_keygen_ctx+0x1ac>
mov    %r14d,%ebp
sub    %ebx,%ebp
jmp    1466 <set_keygen_ctx+0x1b6>
mov    %rbp,0x10(%rsp)
mov    %rax,0x0(%rbp)
xor    %r14d,%r14d
mov    %rax,%rbp
test   %r12,%r12
jne    162c <set_keygen_ctx+0x37c>
jmp    134f <set_keygen_ctx+0x9f>
add    $0x6,%rbx
jmp    1517 <set_keygen_ctx+0x267>
lea    0xc8e(%rip),%rsi
jmp    1686 <set_keygen_ctx+0x3d6>
mov    %rbx,%rdi
call   1070 <strlen@plt>
mov    %eax,%ebp
xor    %edi,%edi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1080 <EVP_PKEY_asn1_find_str@plt>
test   %rax,%rax
je     14e7 <set_keygen_ctx+0x237>
xor    %edi,%edi
mov    %r13,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
mov    %rax,%r9
call   1130 <EVP_PKEY_asn1_get0_info@plt>
mov    0x0(%r13),%eax
mov    0x2b52(%rip),%rcx
cmp    (%rcx),%eax
jne    1507 <set_keygen_ctx+0x257>
test   %r14,%r14
je     1607 <set_keygen_ctx+0x357>
add    $0x1,%r14
mov    0x2b2a(%rip),%rax
mov    (%rax),%edx
lea    0x18(%rsp),%rcx
mov    %r14,%rdi
xor    %esi,%esi
call   1120 <strtonum@plt>
mov    0x18(%rsp),%rcx
test   %rcx,%rcx
mov    0x8(%rsp),%r15
je     16bc <set_keygen_ctx+0x40c>
lea    0xb27(%rip),%rsi
xor    %r12d,%r12d
mov    %r15,%rdi
mov    %r14,%rdx
jmp    1321 <set_keygen_ctx+0x71>
lea    0xb2f(%rip),%rsi
xor    %r12d,%r12d
mov    0x8(%rsp),%rdi
mov    %ebp,%edx
mov    %rbx,%rcx
xor    %eax,%eax
call   10a0 <BIO_printf@plt>
jmp    16aa <set_keygen_ctx+0x3fa>
test   %r14,%r14
je     1614 <set_keygen_ctx+0x364>
add    $0x1,%r14
mov    %r14,%rbx
lea    0xb17(%rip),%rsi
mov    %rbx,%rdi
call   11c0 <BIO_new_file@plt>
test   %rax,%rax
je     158f <set_keygen_ctx+0x2df>
mov    %rax,%r15
mov    %rax,%rdi
xor    %esi,%esi
call   1110 <PEM_read_bio_Parameters@plt>
test   %rax,%rax
je     15ad <set_keygen_ctx+0x2fd>
mov    %rax,%r14
mov    %r15,%rdi
call   10f0 <BIO_free@plt>
mov    0x0(%r13),%ebx
mov    %r14,%rdi
cmp    $0xffffffff,%ebx
je     15fc <set_keygen_ctx+0x34c>
call   1040 <EVP_PKEY_base_id@plt>
mov    $0xffffffffffffffff,%rbp
cmp    %eax,%ebx
je     161e <set_keygen_ctx+0x36e>
lea    0xb03(%rip),%rsi
xor    %r12d,%r12d
mov    0x8(%rsp),%rdi
xor    %eax,%eax
call   10a0 <BIO_printf@plt>
mov    %r14,%rdi
call   10b0 <EVP_PKEY_free@plt>
jmp    16aa <set_keygen_ctx+0x3fa>
lea    0xaa1(%rip),%rsi
xor    %r12d,%r12d
mov    0x8(%rsp),%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   10a0 <BIO_printf@plt>
jmp    16aa <set_keygen_ctx+0x3fa>
mov    %r15,%rdi
call   1180 <BIO_reset@plt>
mov    %r15,%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1190 <PEM_read_bio_X509@plt>
test   %rax,%rax
je     16cc <set_keygen_ctx+0x41c>
mov    %rax,%rbp
mov    %rax,%rdi
call   10d0 <X509_get_pubkey@plt>
mov    %rax,%r14
mov    %rbp,%rdi
call   1140 <X509_free@plt>
mov    %r15,%rdi
call   10f0 <BIO_free@plt>
test   %r14,%r14
jne    1548 <set_keygen_ctx+0x298>
lea    0xa5b(%rip),%rsi
jmp    1596 <set_keygen_ctx+0x2e6>
call   11b0 <EVP_PKEY_id@plt>
mov    %eax,0x0(%r13)
jmp    1617 <set_keygen_ctx+0x367>
mov    0x10(%rsp),%rax
mov    (%rax),%rbp
xor    %r14d,%r14d
jmp    161e <set_keygen_ctx+0x36e>
xor    %r14d,%r14d
mov    $0xffffffffffffffff,%rbp
mov    0x8(%rsp),%r15
test   %r12,%r12
je     134f <set_keygen_ctx+0x9f>
mov    0x0(%r13),%esi
xor    %edi,%edi
call   1100 <EVP_PKEY_asn1_find@plt>
test   %rax,%rax
je     1698 <set_keygen_ctx+0x3e8>
lea    0x20(%rsp),%r8
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %rax,%r9
call   1130 <EVP_PKEY_asn1_get0_info@plt>
mov    0x20(%rsp),%rdi
call   11a0 <strdup@plt>
mov    %rax,(%r12)
test   %r14,%r14
jne    1358 <set_keygen_ctx+0xa8>
mov    0x0(%r13),%edi
xor    %esi,%esi
call   10e0 <EVP_PKEY_CTX_new_id@plt>
mov    %rax,%r12
test   %r12,%r12
jne    1386 <set_keygen_ctx+0xd6>
lea    0xa3e(%rip),%rsi
mov    %r15,%rdi
call   1170 <BIO_puts@plt>
mov    %r15,%rdi
call   1060 <ERR_print_errors@plt>
jmp    16a7 <set_keygen_ctx+0x3f7>
lea    0x9fb(%rip),%rsi
mov    %r15,%rdi
call   1170 <BIO_puts@plt>
xor    %r12d,%r12d
mov    %r12,%rax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rax,%rbp
mov    0x10(%rsp),%rax
mov    %rbp,(%rax)
jmp    1343 <set_keygen_ctx+0x93>
mov    %r15,%rdi
call   10f0 <BIO_free@plt>
lea    0x97a(%rip),%rsi
jmp    1596 <set_keygen_ctx+0x2e6>

LLVM IR (-O0):
@EVP_PKEY_RSA = global i32 0
@LONG_MAX = global i32 0
@.str = [22 x i8] c"bad algorithm %s: %s\0A\00"
@.str.1 = [7 x i8] c"param:\00"
@.str.2 = [24 x i8] c"Unknown algorithm %.*s\0A\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [30 x i8] c"Can't open parameter file %s\0A\00"
@.str.5 = [33 x i8] c"Error reading parameter file %s\0A\00"
@.str.6 = [36 x i8] c"Key Type does not match parameters\0A\00"
@.str.7 = [42 x i8] c"Internal error: can't find key algorithm\0A\00"
@.str.8 = [33 x i8] c"Error allocating keygen context\0A\00"
@.str.9 = [35 x i8] c"Error initializing keygen context\0A\00"
@.str.10 = [27 x i8] c"Error setting RSA keysize\0A\00"
define i32* @set_keygen_ctx(i32* %0, i8* %1, i32* %2, i64* %3, i8** %4) {
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca i64*
%11 = alloca i8**
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i64
%15 = alloca i32*
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i8*
%19 = alloca i32
%20 = alloca i32*
%21 = alloca i32*
%22 = alloca i32*
%23 = alloca i8*
store i32* %0, i32** %7
store i8* %1, i8** %8
store i32* %2, i32** %9
store i64* %3, i64** %10
store i8** %4, i8*** %11
store i32* null, i32** %12
store i32* null, i32** %13
store i64 -1, i64* %14
store i32* null, i32** %15
store i8* null, i8** %16
%24 = load i8*, i8** %8
%25 = icmp eq i8* %24, null
br i1 %25, label %26, label %31
26: ; preds = %5
%27 = load i32, i32* @EVP_PKEY_RSA
%28 = load i32*, i32** %9
store i32 %27, i32* %28
%29 = load i64*, i64** %10
%30 = load i64, i64* %29
store i64 %30, i64* %14
br label %133
31: ; preds = %5
%32 = load i8*, i8** %8
%33 = getelementptr inbounds i8, i8* %32, i64 0
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp sge i32 %35, 48
br i1 %36, label %37, label %59
37: ; preds = %31
%38 = load i8*, i8** %8
%39 = getelementptr inbounds i8, i8* %38, i64 0
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp sle i32 %41, 57
br i1 %42, label %43, label %59
43: ; preds = %37
%44 = load i32, i32* @EVP_PKEY_RSA
%45 = load i32*, i32** %9
store i32 %44, i32* %45
%46 = load i8*, i8** %8
%47 = load i32, i32* @LONG_MAX
%48 = call i64 @strtonum(i8* %46, i32 0, i32 %47, i8** %17)
store i64 %48, i64* %14
%49 = load i8*, i8** %17
%50 = icmp ne i8* %49, null
br i1 %50, label %51, label %56
51: ; preds = %43
%52 = load i32*, i32** %7
%53 = load i8*, i8** %8
%54 = load i8*, i8** %17
%55 = call i32 (i32*, i8*, ...) @BIO_printf(i32* %52, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %53, i8* %54)
store i32* null, i32** %6
br label %266
56: ; preds = %43
%57 = load i64, i64* %14
%58 = load i64*, i64** %10
store i64 %57, i64* %58
br label %132
59: ; preds = %37, %31
%60 = load i8*, i8** %8
%61 = call i32 @strncmp(i8* %60, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 6)
%62 = icmp ne i32 %61, 0
br i1 %62, label %66, label %63
63: ; preds = %59
%64 = load i8*, i8** %8
%65 = getelementptr inbounds i8, i8* %64, i64 6
store i8* %65, i8** %16
br label %131
66: ; preds = %59
%67 = load i8*, i8** %8
%68 = call i8* @strchr(i8* %67, i8 signext 58)
store i8* %68, i8** %18
%69 = load i8*, i8** %18
%70 = icmp ne i8* %69, null
br i1 %70, label %71, label %78
71: ; preds = %66
%72 = load i8*, i8** %18
%73 = load i8*, i8** %8
%74 = ptrtoint i8* %72 to i64
%75 = ptrtoint i8* %73 to i64
%76 = sub i64 %74, %75
%77 = trunc i64 %76 to i32
store i32 %77, i32* %19
br label %81
78: ; preds = %66
%79 = load i8*, i8** %8
%80 = call i32 @strlen(i8* %79)
store i32 %80, i32* %19
br label %81
81: ; preds = %78, %71
%82 = load i8*, i8** %8
%83 = load i32, i32* %19
%84 = call i32* @EVP_PKEY_asn1_find_str(i32* null, i8* %82, i32 %83)
store i32* %84, i32** %20
%85 = load i32*, i32** %20
%86 = icmp ne i32* %85, null
br i1 %86, label %92, label %87
87: ; preds = %81
%88 = load i32*, i32** %7
%89 = load i32, i32* %19
%90 = load i8*, i8** %8
%91 = call i32 (i32*, i8*, ...) @BIO_printf(i32* %88, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %89, i8* %90)
store i32* null, i32** %6
br label %266
92: ; preds = %81
%93 = load i32*, i32** %9
%94 = load i32*, i32** %20
%95 = call i32 @EVP_PKEY_asn1_get0_info(i32* null, i32* %93, i32* null, i32* null, i8** null, i32* %94)
%96 = load i32*, i32** %9
%97 = load i32, i32* %96
%98 = load i32, i32* @EVP_PKEY_RSA
%99 = icmp eq i32 %97, %98
br i1 %99, label %100, label %123
100: ; preds = %92
%101 = load i8*, i8** %18
%102 = icmp ne i8* %101, null
br i1 %102, label %103, label %119
103: ; preds = %100
%104 = load i8*, i8** %18
%105 = getelementptr inbounds i8, i8* %104, i64 1
%106 = load i32, i32* @LONG_MAX
%107 = call i64 @strtonum(i8* %105, i32 0, i32 %106, i8** %17)
store i64 %107, i64* %14
%108 = load i8*, i8** %17
%109 = icmp ne i8* %108, null
br i1 %109, label %110, label %116
110: ; preds = %103
%111 = load i32*, i32** %7
%112 = load i8*, i8** %18
%113 = getelementptr inbounds i8, i8* %112, i64 1
%114 = load i8*, i8** %17
%115 = call i32 (i32*, i8*, ...) @BIO_printf(i32* %111, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %113, i8* %114)
store i32* null, i32** %6
br label %266
116: ; preds = %103
%117 = load i64, i64* %14
%118 = load i64*, i64** %10
store i64 %117, i64* %118
br label %122
119: ; preds = %100
%120 = load i64*, i64** %10
%121 = load i64, i64* %120
store i64 %121, i64* %14
br label %122
122: ; preds = %119, %116
br label %130
123: ; preds = %92
%124 = load i8*, i8** %18
%125 = icmp ne i8* %124, null
br i1 %125, label %126, label %129
126: ; preds = %123
%127 = load i8*, i8** %18
%128 = getelementptr inbounds i8, i8* %127, i64 1
store i8* %128, i8** %16
br label %129
129: ; preds = %126, %123
br label %130
130: ; preds = %129, %122
br label %131
131: ; preds = %130, %63
br label %132
132: ; preds = %131, %56
br label %133
133: ; preds = %132, %26
%134 = load i8*, i8** %16
%135 = icmp ne i8* %134, null
br i1 %135, label %136, label %193
136: ; preds = %133
%137 = load i8*, i8** %16
%138 = call i32* @BIO_new_file(i8* %137, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %138, i32** %15
%139 = load i32*, i32** %15
%140 = icmp ne i32* %139, null
br i1 %140, label %145, label %141
141: ; preds = %136
%142 = load i32*, i32** %7
%143 = load i8*, i8** %16
%144 = call i32 (i32*, i8*, ...) @BIO_printf(i32* %142, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %143)
store i32* null, i32** %6
br label %266
145: ; preds = %136
%146 = load i32*, i32** %15
%147 = call i32* @PEM_read_bio_Parameters(i32* %146, i32* null)
store i32* %147, i32** %13
%148 = load i32*, i32** %13
%149 = icmp ne i32* %148, null
br i1 %149, label %163, label %150
150: ; preds = %145
%151 = load i32*, i32** %15
%152 = call i32 @BIO_reset(i32* %151)
%153 = load i32*, i32** %15
%154 = call i32* @PEM_read_bio_X509(i32* %153, i32* null, i32* null, i32* null)
store i32* %154, i32** %21
%155 = load i32*, i32** %21
%156 = icmp ne i32* %155, null
br i1 %156, label %157, label %162
157: ; preds = %150
%158 = load i32*, i32** %21
%159 = call i32* @X509_get_pubkey(i32* %158)
store i32* %159, i32** %13
%160 = load i32*, i32** %21
%161 = call i32 @X509_free(i32* %160)
br label %162
162: ; preds = %157, %150
br label %163
163: ; preds = %162, %145
%164 = load i32*, i32** %15
%165 = call i32 @BIO_free(i32* %164)
%166 = load i32*, i32** %13
%167 = icmp ne i32* %166, null
br i1 %167, label %172, label %168
168: ; preds = %163
%169 = load i32*, i32** %7
%170 = load i8*, i8** %16
%171 = call i32 (i32*, i8*, ...) @BIO_printf(i32* %169, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i8* %170)
store i32* null, i32** %6
br label %266
172: ; preds = %163
%173 = load i32*, i32** %9
%174 = load i32, i32* %173
%175 = icmp eq i32 %174, -1
br i1 %175, label %176, label %180
176: ; preds = %172
%177 = load i32*, i32** %13
%178 = call i32 @EVP_PKEY_id(i32* %177)
%179 = load i32*, i32** %9
store i32 %178, i32* %179
br label %192
180: ; preds = %172
%181 = load i32*, i32** %9
%182 = load i32, i32* %181
%183 = load i32*, i32** %13
%184 = call i32 @EVP_PKEY_base_id(i32* %183)
%185 = icmp ne i32 %182, %184
br i1 %185, label %186, label %191
186: ; preds = %180
%187 = load i32*, i32** %7
%188 = call i32 (i32*, i8*, ...) @BIO_printf(i32* %187, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0))
%189 = load i32*, i32** %13
%190 = call i32 @EVP_PKEY_free(i32* %189)
store i32* null, i32** %6
br label %266
191: ; preds = %180
br label %192
192: ; preds = %191, %176
br label %193
193: ; preds = %192, %133
%194 = load i8**, i8*** %11
%195 = icmp ne i8** %194, null
br i1 %195, label %196, label %211
196: ; preds = %193
%197 = load i32*, i32** %9
%198 = load i32, i32* %197
%199 = call i32* @EVP_PKEY_asn1_find(i32* null, i32 %198)
store i32* %199, i32** %22
%200 = load i32*, i32** %22
%201 = icmp ne i32* %200, null
br i1 %201, label %205, label %202
202: ; preds = %196
%203 = load i32*, i32** %7
%204 = call i32 @BIO_puts(i32* %203, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0))
store i32* null, i32** %6
br label %266
205: ; preds = %196
%206 = load i32*, i32** %22
%207 = call i32 @EVP_PKEY_asn1_get0_info(i32* null, i32* null, i32* null, i32* null, i8** %23, i32* %206)
%208 = load i8*, i8** %23
%209 = call i8* @strdup(i8* %208)
%210 = load i8**, i8*** %11
store i8* %209, i8** %210
br label %211
211: ; preds = %205, %193
%212 = load i32*, i32** %13
%213 = icmp ne i32* %212, null
br i1 %213, label %214, label %222
214: ; preds = %211
%215 = load i32*, i32** %13
%216 = call i32* @EVP_PKEY_CTX_new(i32* %215, i32* null)
store i32* %216, i32** %12
%217 = load i32*, i32** %13
%218 = call i64 @EVP_PKEY_bits(i32* %217)
%219 = load i64*, i64** %10
store i64 %218, i64* %219
%220 = load i32*, i32** %13
%221 = call i32 @EVP_PKEY_free(i32* %220)
br label %226
222: ; preds = %211
%223 = load i32*, i32** %9
%224 = load i32, i32* %223
%225 = call i32* @EVP_PKEY_CTX_new_id(i32 %224, i32* null)
store i32* %225, i32** %12
br label %226
226: ; preds = %222, %214
%227 = load i32*, i32** %12
%228 = icmp ne i32* %227, null
br i1 %228, label %234, label %229
229: ; preds = %226
%230 = load i32*, i32** %7
%231 = call i32 @BIO_puts(i32* %230, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0))
%232 = load i32*, i32** %7
%233 = call i32 @ERR_print_errors(i32* %232)
store i32* null, i32** %6
br label %266
234: ; preds = %226
%235 = load i32*, i32** %12
%236 = call i64 @EVP_PKEY_keygen_init(i32* %235)
%237 = icmp sle i64 %236, 0
br i1 %237, label %238, label %243
238: ; preds = %234
%239 = load i32*, i32** %7
%240 = call i32 @BIO_puts(i32* %239, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0))
%241 = load i32*, i32** %7
%242 = call i32 @ERR_print_errors(i32* %241)
store i32* null, i32** %6
br label %266
243: ; preds = %234
%244 = load i32*, i32** %9
%245 = load i32, i32* %244
%246 = load i32, i32* @EVP_PKEY_RSA
%247 = icmp eq i32 %245, %246
br i1 %247, label %248, label %264
248: ; preds = %243
%249 = load i64, i64* %14
%250 = icmp ne i64 %249, -1
br i1 %250, label %251, label %264
251: ; preds = %248
%252 = load i32*, i32** %12
%253 = load i64, i64* %14
%254 = call i64 @EVP_PKEY_CTX_set_rsa_keygen_bits(i32* %252, i64 %253)
%255 = icmp sle i64 %254, 0
br i1 %255, label %256, label %263
256: ; preds = %251
%257 = load i32*, i32** %7
%258 = call i32 @BIO_puts(i32* %257, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0))
%259 = load i32*, i32** %7
%260 = call i32 @ERR_print_errors(i32* %259)
%261 = load i32*, i32** %12
%262 = call i32 @EVP_PKEY_CTX_free(i32* %261)
store i32* null, i32** %6
br label %266
263: ; preds = %251
br label %264
264: ; preds = %263, %248, %243
%265 = load i32*, i32** %12
store i32* %265, i32** %6
br label %266
266: ; preds = %264, %256, %238, %229, %202, %186, %168, %141, %110, %87, %51
%267 = load i32*, i32** %6
ret i32* %267
}

LLVM IR (-O2):
@EVP_PKEY_RSA = global i32 0
@LONG_MAX = global i32 0
@.str = [22 x i8] c"bad algorithm %s: %s\0A\00"
@.str.1 = [7 x i8] c"param:\00"
@.str.2 = [24 x i8] c"Unknown algorithm %.*s\0A\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [30 x i8] c"Can't open parameter file %s\0A\00"
@.str.5 = [33 x i8] c"Error reading parameter file %s\0A\00"
@.str.6 = [36 x i8] c"Key Type does not match parameters\0A\00"
@.str.7 = [42 x i8] c"Internal error: can't find key algorithm\0A\00"
@.str.8 = [33 x i8] c"Error allocating keygen context\0A\00"
@.str.9 = [35 x i8] c"Error initializing keygen context\0A\00"
@.str.10 = [27 x i8] c"Error setting RSA keysize\0A\00"
define i32* @set_keygen_ctx(i32* %0, i8* %1, i32* %2, i64* nocapture %3, i8** writeonly %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = bitcast i8** %6 to i8*
%9 = icmp eq i8* %1, null
br i1 %9, label %10, label %13
10: ; preds = %5
%11 = load i32, i32* @EVP_PKEY_RSA
store i32 %11, i32* %2
%12 = load i64, i64* %3
br label %102
13: ; preds = %5
%14 = load i8, i8* %1
%15 = add i8 %14, -48
%16 = icmp ult i8 %15, 10
br i1 %16, label %17, label %26
17: ; preds = %13
%18 = load i32, i32* @EVP_PKEY_RSA
store i32 %18, i32* %2
%19 = load i32, i32* @LONG_MAX
%20 = call i64 @strtonum(i8* %1, i32 0, i32 %19, i8** %6)
%21 = load i8*, i8** %6
%22 = icmp eq i8* %21, null
br i1 %22, label %25, label %23
23: ; preds = %17
%24 = call i32 (i32*, i8*, ...) @BIO_printf(i32* %0, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %21)
br label %151
25: ; preds = %17
store i64 %20, i64* %3
br label %102
26: ; preds = %13
%27 = tail call i32 @strncmp(i8* %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 6)
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = getelementptr inbounds i8, i8* %1, i64 6
br label %66
31: ; preds = %26
%32 = tail call i8* @strchr(i8* %1, i8 signext 58)
%33 = icmp eq i8* %32, null
br i1 %33, label %39, label %34
34: ; preds = %31
%35 = ptrtoint i8* %32 to i64
%36 = ptrtoint i8* %1 to i64
%37 = sub i64 %35, %36
%38 = trunc i64 %37 to i32
br label %41
39: ; preds = %31
%40 = tail call i32 @strlen(i8* %1)
br label %41
41: ; preds = %39, %34
%42 = phi i32 [ %38, %34 ], [ %40, %39 ]
%43 = tail call i32* @EVP_PKEY_asn1_find_str(i32* null, i8* %1, i32 %42)
%44 = icmp eq i32* %43, null
br i1 %44, label %45, label %47
45: ; preds = %41
%46 = tail call i32 (i32*, i8*, ...) @BIO_printf(i32* %0, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %42, i8* %1)
br label %151
47: ; preds = %41
%48 = tail call i32 @EVP_PKEY_asn1_get0_info(i32* null, i32* %2, i32* null, i32* null, i8** null, i32* %43)
%49 = load i32, i32* %2
%50 = load i32, i32* @EVP_PKEY_RSA
%51 = icmp eq i32 %49, %50
br i1 %51, label %52, label %64
52: ; preds = %47
br i1 %33, label %62, label %53
53: ; preds = %52
%54 = getelementptr inbounds i8, i8* %32, i64 1
%55 = load i32, i32* @LONG_MAX
%56 = call i64 @strtonum(i8* %54, i32 0, i32 %55, i8** %6)
%57 = load i8*, i8** %6
%58 = icmp eq i8* %57, null
br i1 %58, label %61, label %59
59: ; preds = %53
%60 = call i32 (i32*, i8*, ...) @BIO_printf(i32* %0, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %54, i8* %57)
br label %151
61: ; preds = %53
store i64 %56, i64* %3
br label %102
62: ; preds = %52
%63 = load i64, i64* %3
br label %102
64: ; preds = %47
%65 = getelementptr inbounds i8, i8* %32, i64 1
br i1 %33, label %102, label %66
66: ; preds = %64, %29
%67 = phi i8* [ %30, %29 ], [ %65, %64 ]
%68 = tail call i32* @BIO_new_file(i8* %67, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%69 = icmp eq i32* %68, null
br i1 %69, label %70, label %72
70: ; preds = %66
%71 = tail call i32 (i32*, i8*, ...) @BIO_printf(i32* %0, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %67)
br label %151
72: ; preds = %66
%73 = tail call i32* @PEM_read_bio_Parameters(i32* %68, i32* null)
%74 = icmp eq i32* %73, null
br i1 %74, label %77, label %75
75: ; preds = %72
%76 = tail call i32 @BIO_free(i32* %68)
br label %90
77: ; preds = %72
%78 = tail call i32 @BIO_reset(i32* %68)
%79 = tail call i32* @PEM_read_bio_X509(i32* %68, i32* null, i32* null, i32* null)
%80 = icmp eq i32* %79, null
br i1 %80, label %81, label %83
81: ; preds = %77
%82 = tail call i32 @BIO_free(i32* %68)
br label %88
83: ; preds = %77
%84 = tail call i32* @X509_get_pubkey(i32* %79)
%85 = tail call i32 @X509_free(i32* %79)
%86 = tail call i32 @BIO_free(i32* %68)
%87 = icmp eq i32* %84, null
br i1 %87, label %88, label %90
88: ; preds = %81, %83
%89 = tail call i32 (i32*, i8*, ...) @BIO_printf(i32* %0, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i8* %67)
br label %151
90: ; preds = %75, %83
%91 = phi i32* [ %73, %75 ], [ %84, %83 ]
%92 = load i32, i32* %2
%93 = icmp eq i32 %92, -1
br i1 %93, label %94, label %96
94: ; preds = %90
%95 = tail call i32 @EVP_PKEY_id(i32* %91)
store i32 %95, i32* %2
br label %102
96: ; preds = %90
%97 = tail call i32 @EVP_PKEY_base_id(i32* %91)
%98 = icmp eq i32 %92, %97
br i1 %98, label %102, label %99
99: ; preds = %96
%100 = tail call i32 (i32*, i8*, ...) @BIO_printf(i32* %0, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0))
%101 = tail call i32 @EVP_PKEY_free(i32* %91)
br label %151
102: ; preds = %64, %61, %62, %25, %10, %94, %96
%103 = phi i64 [ -1, %94 ], [ -1, %96 ], [ %20, %25 ], [ %12, %10 ], [ %56, %61 ], [ %63, %62 ], [ -1, %64 ]
%104 = phi i32* [ %91, %94 ], [ %91, %96 ], [ null, %25 ], [ null, %10 ], [ null, %61 ], [ null, %62 ], [ null, %64 ]
%105 = icmp eq i8** %4, null
br i1 %105, label %117, label %106
106: ; preds = %102
%107 = bitcast i8** %7 to i8*
%108 = load i32, i32* %2
%109 = call i32* @EVP_PKEY_asn1_find(i32* null, i32 %108)
%110 = icmp eq i32* %109, null
br i1 %110, label %111, label %113
111: ; preds = %106
%112 = call i32 @BIO_puts(i32* %0, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0))
br label %151
113: ; preds = %106
%114 = call i32 @EVP_PKEY_asn1_get0_info(i32* null, i32* null, i32* null, i32* null, i8** %7, i32* %109)
%115 = load i8*, i8** %7
%116 = call i8* @strdup(i8* %115)
store i8* %116, i8** %4
br label %117
117: ; preds = %113, %102
%118 = icmp eq i32* %104, null
br i1 %118, label %123, label %119
119: ; preds = %117
%120 = call i32* @EVP_PKEY_CTX_new(i32* %104, i32* null)
%121 = call i64 @EVP_PKEY_bits(i32* %104)
store i64 %121, i64* %3
%122 = call i32 @EVP_PKEY_free(i32* %104)
br label %126
123: ; preds = %117
%124 = load i32, i32* %2
%125 = call i32* @EVP_PKEY_CTX_new_id(i32 %124, i32* null)
br label %126
126: ; preds = %123, %119
%127 = phi i32* [ %120, %119 ], [ %125, %123 ]
%128 = icmp eq i32* %127, null
br i1 %128, label %129, label %132
129: ; preds = %126
%130 = call i32 @BIO_puts(i32* %0, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0))
%131 = call i32 @ERR_print_errors(i32* %0)
br label %151
132: ; preds = %126
%133 = call i64 @EVP_PKEY_keygen_init(i32* %127)
%134 = icmp slt i64 %133, 1
br i1 %134, label %135, label %138
135: ; preds = %132
%136 = call i32 @BIO_puts(i32* %0, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0))
%137 = call i32 @ERR_print_errors(i32* %0)
br label %151
138: ; preds = %132
%139 = load i32, i32* %2
%140 = load i32, i32* @EVP_PKEY_RSA
%141 = icmp eq i32 %139, %140
%142 = icmp ne i64 %103, -1
%143 = select i1 %141, i1 %142, i1 false
br i1 %143, label %144, label %151
144: ; preds = %138
%145 = call i64 @EVP_PKEY_CTX_set_rsa_keygen_bits(i32* %127, i64 %103)
%146 = icmp slt i64 %145, 1
br i1 %146, label %147, label %151
147: ; preds = %144
%148 = call i32 @BIO_puts(i32* %0, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0))
%149 = call i32 @ERR_print_errors(i32* %0)
%150 = call i32 @EVP_PKEY_CTX_free(i32* %127)
br label %151
151: ; preds = %111, %45, %59, %138, %144, %147, %135, %129, %99, %88, %70, %23
%152 = phi i32* [ null, %135 ], [ null, %147 ], [ null, %129 ], [ null, %99 ], [ null, %88 ], [ null, %70 ], [ null, %23 ], [ %127, %144 ], [ %127, %138 ], [ null, %59 ], [ null, %45 ], [ null, %111 ]
ret i32* %152
}