#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*/ uint64_t;
typedef int /*<<< orphan*/ uint32_t;
typedef int /*<<< orphan*/ RSA;
typedef int /*<<< orphan*/ BN_CTX;
typedef int /*<<< orphan*/ const BIGNUM;

/* Variables and functions */
int /*<<< orphan*/ *BN_CTX_new();
int /*<<< orphan*/ BN_copy(int /*<<< orphan*/ const *,
                           int /*<<< orphan*/ const *);
int /*<<< orphan*/ BN_exp(int /*<<< orphan*/ const *,
                          int /*<<< orphan*/ const *,
                          int /*<<< orphan*/ const *, int /*<<< orphan*/ *);
int /*<<< orphan*/ BN_free(int /*<<< orphan*/ const *);
int /*<<< orphan*/ BN_get_word(int /*<<< orphan*/ const *);
int /*<<< orphan*/ BN_mod(int /*<<< orphan*/ const *,
                          int /*<<< orphan*/ const *,
                          int /*<<< orphan*/ const *, int /*<<< orphan*/ *);
int /*<<< orphan*/ BN_mod_inverse(int /*<<< orphan*/ const *,
                                  int /*<<< orphan*/ const *,
                                  int /*<<< orphan*/ const *,
                                  int /*<<< orphan*/ *);
int /*<<< orphan*/ BN_mul(int /*<<< orphan*/ const *,
                          int /*<<< orphan*/ const *,
                          int /*<<< orphan*/ const *, int /*<<< orphan*/ *);
int /*<<< orphan*/ const *BN_new();
long BN_num_bits(int /*<<< orphan*/ const *);
int /*<<< orphan*/ BN_set_word(int /*<<< orphan*/ const *, long);
int /*<<< orphan*/ BN_sub(int /*<<< orphan*/ const *,
                          int /*<<< orphan*/ const *,
                          int /*<<< orphan*/ const *);
int ENOMEM;
int /*<<< orphan*/ RSA_get0_key(int /*<<< orphan*/ *,
                                int /*<<< orphan*/ const **,
                                int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ rsa_get_exponent(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int rsa_get_params(RSA *key, uint64_t *exponent, uint32_t *n0_invp,
                   BIGNUM **modulusp, BIGNUM **r_squaredp) {
  BIGNUM *big1, *big2, *big32, *big2_32;
  BIGNUM *n, *r, *r_squared, *tmp;
  const BIGNUM *key_n;
  BN_CTX *bn_ctx = BN_CTX_new();
  int ret = 0;
  big1 = BN_new();
  big2 = BN_new();
  big32 = BN_new();
  r = BN_new();
  r_squared = BN_new();
  tmp = BN_new();
  big2_32 = BN_new();
  n = BN_new();
  if (!big1 || !big2 || !big32 || !r || !r_squared || !tmp || !big2_32 || !n) {
    fprintf(stderr, "Out of memory (bignum)\n");
    return -ENOMEM;
  }
  if (0 != rsa_get_exponent(key, exponent))
    ret = -1;
  RSA_get0_key(key, &key_n, NULL, NULL);
  if (!BN_copy(n, key_n) || !BN_set_word(big1, 1L) || !BN_set_word(big2, 2L) ||
      !BN_set_word(big32, 32L))
    ret = -1;
  if (!BN_exp(big2_32, big2, big32, bn_ctx))
    ret = -1;
  if (!BN_mod_inverse(tmp, n, big2_32, bn_ctx) || !BN_sub(tmp, big2_32, tmp))
    ret = -1;
  *n0_invp = BN_get_word(tmp);
  if (!BN_set_word(tmp, BN_num_bits(n)) || !BN_exp(r, big2, tmp, bn_ctx))
    ret = -1;
  if (!BN_copy(r_squared, r) || !BN_mul(tmp, r_squared, r, bn_ctx) ||
      !BN_mod(r_squared, tmp, n, bn_ctx))
    ret = -1;
  *modulusp = n;
  *r_squaredp = r_squared;
  BN_free(big1);
  BN_free(big2);
  BN_free(big32);
  BN_free(r);
  BN_free(tmp);
  BN_free(big2_32);
  if (ret) {
    fprintf(stderr, "Bignum operations failed\n");
    return -ENOMEM;
  }
  return ret;
}


x86 assembly (clang, -O0):
<rsa_get_params>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    $0x0,%al
call   10e0 <BN_CTX_new@plt>
mov    %rax,-0x80(%rbp)
movl   $0x0,-0x84(%rbp)
mov    $0x0,%al
call   1050 <BN_new@plt>
mov    %rax,-0x38(%rbp)
mov    $0x0,%al
call   1050 <BN_new@plt>
mov    %rax,-0x40(%rbp)
mov    $0x0,%al
call   1050 <BN_new@plt>
mov    %rax,-0x48(%rbp)
mov    $0x0,%al
call   1050 <BN_new@plt>
mov    %rax,-0x60(%rbp)
mov    $0x0,%al
call   1050 <BN_new@plt>
mov    %rax,-0x68(%rbp)
mov    $0x0,%al
call   1050 <BN_new@plt>
mov    %rax,-0x70(%rbp)
mov    $0x0,%al
call   1050 <BN_new@plt>
mov    %rax,-0x50(%rbp)
mov    $0x0,%al
call   1050 <BN_new@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     12d4 <rsa_get_params+0xe4>
cmpq   $0x0,-0x40(%rbp)
je     12d4 <rsa_get_params+0xe4>
cmpq   $0x0,-0x48(%rbp)
je     12d4 <rsa_get_params+0xe4>
cmpq   $0x0,-0x60(%rbp)
je     12d4 <rsa_get_params+0xe4>
cmpq   $0x0,-0x68(%rbp)
je     12d4 <rsa_get_params+0xe4>
cmpq   $0x0,-0x70(%rbp)
je     12d4 <rsa_get_params+0xe4>
cmpq   $0x0,-0x50(%rbp)
je     12d4 <rsa_get_params+0xe4>
cmpq   $0x0,-0x58(%rbp)
jne    12fc <rsa_get_params+0x10c>
mov    0x2cfd(%rip),%rax
mov    (%rax),%edi
lea    0xd1c(%rip),%rsi
call   10d0 <fprintf@plt>
xor    %eax,%eax
mov    0x2cee(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    154f <rsa_get_params+0x35f>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1110 <rsa_get_exponent@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     1321 <rsa_get_params+0x131>
movl   $0xffffffff,-0x84(%rbp)
ff ff ff
mov    -0x10(%rbp),%rdi
lea    -0x78(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rdx
call   1100 <RSA_get0_key@plt>
mov    -0x58(%rbp),%rdi
mov    -0x78(%rbp),%rsi
call   10c0 <BN_copy@plt>
cmp    $0x0,%eax
je     1390 <rsa_get_params+0x1a0>
mov    -0x38(%rbp),%rdi
mov    $0x1,%esi
call   1030 <BN_set_word@plt>
cmp    $0x0,%eax
je     1390 <rsa_get_params+0x1a0>
mov    -0x40(%rbp),%rdi
mov    $0x2,%esi
call   1030 <BN_set_word@plt>
cmp    $0x0,%eax
je     1390 <rsa_get_params+0x1a0>
mov    -0x48(%rbp),%rdi
mov    $0x20,%esi
call   1030 <BN_set_word@plt>
cmp    $0x0,%eax
jne    139a <rsa_get_params+0x1aa>
movl   $0xffffffff,-0x84(%rbp)
ff ff ff
mov    -0x50(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x48(%rbp),%rdx
mov    -0x80(%rbp),%rcx
call   1080 <BN_exp@plt>
cmp    $0x0,%eax
jne    13c2 <rsa_get_params+0x1d2>
movl   $0xffffffff,-0x84(%rbp)
ff ff ff
mov    -0x70(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    -0x50(%rbp),%rdx
mov    -0x80(%rbp),%rcx
call   1040 <BN_mod_inverse@plt>
cmp    $0x0,%eax
je     13fa <rsa_get_params+0x20a>
mov    -0x70(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    -0x70(%rbp),%rdx
call   1090 <BN_sub@plt>
cmp    $0x0,%eax
jne    1404 <rsa_get_params+0x214>
movl   $0xffffffff,-0x84(%rbp)
ff ff ff
mov    -0x70(%rbp),%rdi
call   1060 <BN_get_word@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x70(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x58(%rbp),%rdi
call   1070 <BN_num_bits@plt>
mov    -0x90(%rbp),%rdi
mov    %rax,%rsi
call   1030 <BN_set_word@plt>
cmp    $0x0,%eax
je     145f <rsa_get_params+0x26f>
mov    -0x60(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x70(%rbp),%rdx
mov    -0x80(%rbp),%rcx
call   1080 <BN_exp@plt>
cmp    $0x0,%eax
jne    1469 <rsa_get_params+0x279>
movl   $0xffffffff,-0x84(%rbp)
ff ff ff
mov    -0x68(%rbp),%rdi
mov    -0x60(%rbp),%rsi
call   10c0 <BN_copy@plt>
cmp    $0x0,%eax
je     14bb <rsa_get_params+0x2cb>
mov    -0x70(%rbp),%rdi
mov    -0x68(%rbp),%rsi
mov    -0x60(%rbp),%rdx
mov    -0x80(%rbp),%rcx
call   10a0 <BN_mul@plt>
cmp    $0x0,%eax
je     14bb <rsa_get_params+0x2cb>
mov    -0x68(%rbp),%rdi
mov    -0x70(%rbp),%rsi
mov    -0x58(%rbp),%rdx
mov    -0x80(%rbp),%rcx
call   10f0 <BN_mod@plt>
cmp    $0x0,%eax
jne    14c5 <rsa_get_params+0x2d5>
movl   $0xffffffff,-0x84(%rbp)
ff ff ff
mov    -0x58(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x68(%rbp),%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x38(%rbp),%rdi
call   10b0 <BN_free@plt>
mov    -0x40(%rbp),%rdi
call   10b0 <BN_free@plt>
mov    -0x48(%rbp),%rdi
call   10b0 <BN_free@plt>
mov    -0x60(%rbp),%rdi
call   10b0 <BN_free@plt>
mov    -0x70(%rbp),%rdi
call   10b0 <BN_free@plt>
mov    -0x50(%rbp),%rdi
call   10b0 <BN_free@plt>
cmpl   $0x0,-0x84(%rbp)
je     1546 <rsa_get_params+0x356>
mov    0x2ab3(%rip),%rax
mov    (%rax),%edi
lea    0xaea(%rip),%rsi
call   10d0 <fprintf@plt>
xor    %eax,%eax
mov    0x2aa4(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    154f <rsa_get_params+0x35f>
mov    -0x84(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rsa_get_params>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %r8,0x38(%rsp)
mov    %rcx,0x58(%rsp)
mov    %rdx,0x48(%rsp)
mov    %rsi,0x18(%rsp)
mov    %rdi,%rbx
xor    %ebp,%ebp
xor    %eax,%eax
call   10e0 <BN_CTX_new@plt>
mov    %rax,0x50(%rsp)
xor    %eax,%eax
call   1050 <BN_new@plt>
mov    %rax,%r12
xor    %eax,%eax
call   1050 <BN_new@plt>
mov    %rax,0x8(%rsp)
xor    %eax,%eax
call   1050 <BN_new@plt>
mov    %rax,0x10(%rsp)
xor    %eax,%eax
call   1050 <BN_new@plt>
mov    %rax,0x40(%rsp)
xor    %eax,%eax
call   1050 <BN_new@plt>
mov    %rax,0x20(%rsp)
xor    %eax,%eax
call   1050 <BN_new@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1050 <BN_new@plt>
mov    %rax,%r13
xor    %eax,%eax
call   1050 <BN_new@plt>
mov    %rax,(%rsp)
test   %r12,%r12
je     13af <rsa_get_params+0x1bf>
cmpq   $0x0,0x8(%rsp)
je     13af <rsa_get_params+0x1bf>
cmpq   $0x0,0x10(%rsp)
je     13af <rsa_get_params+0x1bf>
cmpq   $0x0,0x40(%rsp)
je     13af <rsa_get_params+0x1bf>
cmpq   $0x0,0x20(%rsp)
je     13af <rsa_get_params+0x1bf>
test   %r14,%r14
je     13af <rsa_get_params+0x1bf>
test   %r13,%r13
je     13af <rsa_get_params+0x1bf>
cmpq   $0x0,(%rsp)
je     13af <rsa_get_params+0x1bf>
mov    %r12,%r15
mov    %r13,0x30(%rsp)
mov    %rbx,%rdi
mov    0x18(%rsp),%rsi
call   1110 <rsa_get_exponent@plt>
neg    %rax
sbb    %ebp,%ebp
lea    0x60(%rsp),%rsi
mov    %rbx,%rdi
xor    %edx,%edx
xor    %ecx,%ecx
call   1100 <RSA_get0_key@plt>
mov    0x60(%rsp),%rsi
mov    (%rsp),%rdi
call   10c0 <BN_copy@plt>
test   %eax,%eax
je     1346 <rsa_get_params+0x156>
mov    $0x1,%esi
mov    %r15,%rdi
call   1030 <BN_set_word@plt>
test   %eax,%eax
je     1346 <rsa_get_params+0x156>
mov    $0x2,%esi
mov    0x8(%rsp),%rdi
call   1030 <BN_set_word@plt>
test   %eax,%eax
je     1346 <rsa_get_params+0x156>
mov    $0x20,%esi
mov    0x10(%rsp),%rdi
call   1030 <BN_set_word@plt>
test   %eax,%eax
jne    134b <rsa_get_params+0x15b>
mov    $0xffffffff,%ebp
mov    %ebp,0x2c(%rsp)
mov    %r15,0x18(%rsp)
mov    0x30(%rsp),%r15
mov    %r15,%rdi
mov    0x8(%rsp),%rsi
mov    0x10(%rsp),%rdx
mov    0x50(%rsp),%rbp
mov    %rbp,%rcx
call   1080 <BN_exp@plt>
mov    %eax,%ebx
mov    %r14,%rdi
mov    (%rsp),%rsi
mov    %r15,%rdx
mov    %rbp,%rcx
call   1040 <BN_mod_inverse@plt>
test   %eax,%eax
mov    0x40(%rsp),%r13
je     13d0 <rsa_get_params+0x1e0>
cmp    $0x1,%ebx
sbb    %r12d,%r12d
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1090 <BN_sub@plt>
test   %eax,%eax
je     13d0 <rsa_get_params+0x1e0>
or     0x2c(%rsp),%r12d
jmp    13d6 <rsa_get_params+0x1e6>
mov    0x2c22(%rip),%rax
mov    (%rax),%edi
lea    0xc41(%rip),%rsi
call   10d0 <fprintf@plt>
mov    0x2c15(%rip),%rax
jmp    14ce <rsa_get_params+0x2de>
mov    $0xffffffff,%r12d
mov    0x38(%rsp),%r15
mov    0x20(%rsp),%rbx
mov    %r14,%rdi
call   1060 <BN_get_word@plt>
mov    0x48(%rsp),%rcx
mov    %eax,(%rcx)
mov    (%rsp),%rdi
call   1070 <BN_num_bits@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <BN_set_word@plt>
test   %eax,%eax
je     141e <rsa_get_params+0x22e>
mov    %r13,%rdi
mov    0x8(%rsp),%rsi
mov    %r14,%rdx
mov    %rbp,%rcx
call   1080 <BN_exp@plt>
test   %eax,%eax
jne    1424 <rsa_get_params+0x234>
mov    $0xffffffff,%r12d
mov    %rbx,%rdi
mov    %r13,%rsi
call   10c0 <BN_copy@plt>
test   %eax,%eax
je     145e <rsa_get_params+0x26e>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
mov    %rbp,%rcx
call   10a0 <BN_mul@plt>
test   %eax,%eax
je     145e <rsa_get_params+0x26e>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    (%rsp),%rdx
mov    %rbp,%rcx
call   10f0 <BN_mod@plt>
test   %eax,%eax
jne    1464 <rsa_get_params+0x274>
mov    $0xffffffff,%r12d
mov    0x58(%rsp),%rax
mov    (%rsp),%rcx
mov    %rcx,(%rax)
mov    %rbx,(%r15)
mov    0x18(%rsp),%rdi
call   10b0 <BN_free@plt>
mov    0x8(%rsp),%rdi
call   10b0 <BN_free@plt>
mov    0x10(%rsp),%rdi
call   10b0 <BN_free@plt>
mov    %r13,%rdi
call   10b0 <BN_free@plt>
mov    %r14,%rdi
call   10b0 <BN_free@plt>
mov    0x30(%rsp),%rdi
call   10b0 <BN_free@plt>
test   %r12d,%r12d
je     14e1 <rsa_get_params+0x2f1>
mov    0x2b21(%rip),%rax
mov    (%rax),%edi
lea    0xb58(%rip),%rsi
call   10d0 <fprintf@plt>
mov    0x2b14(%rip),%rax
xor    %ebp,%ebp
sub    (%rax),%ebp
mov    %ebp,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebp,%ebp
jmp    14d0 <rsa_get_params+0x2e0>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [24 x i8] c"Out of memory (bignum)\0A\00"
@ENOMEM = global i32 0
@.str.1 = [26 x i8] c"Bignum operations failed\0A\00"
define i32 @rsa_get_params(i32* %0, i32* %1, i32* %2, i32** %3, i32** %4) {
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32**
%11 = alloca i32**
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca i32*
%17 = alloca i32*
%18 = alloca i32*
%19 = alloca i32*
%20 = alloca i32*
%21 = alloca i32*
%22 = alloca i32
store i32* %0, i32** %7
store i32* %1, i32** %8
store i32* %2, i32** %9
store i32** %3, i32*** %10
store i32** %4, i32*** %11
%23 = call i32* (...) @BN_CTX_new()
store i32* %23, i32** %21
store i32 0, i32* %22
%24 = call i32* (...) @BN_new()
store i32* %24, i32** %12
%25 = call i32* (...) @BN_new()
store i32* %25, i32** %13
%26 = call i32* (...) @BN_new()
store i32* %26, i32** %14
%27 = call i32* (...) @BN_new()
store i32* %27, i32** %17
%28 = call i32* (...) @BN_new()
store i32* %28, i32** %18
%29 = call i32* (...) @BN_new()
store i32* %29, i32** %19
%30 = call i32* (...) @BN_new()
store i32* %30, i32** %15
%31 = call i32* (...) @BN_new()
store i32* %31, i32** %16
%32 = load i32*, i32** %12
%33 = icmp ne i32* %32, null
br i1 %33, label %34, label %55
34: ; preds = %5
%35 = load i32*, i32** %13
%36 = icmp ne i32* %35, null
br i1 %36, label %37, label %55
37: ; preds = %34
%38 = load i32*, i32** %14
%39 = icmp ne i32* %38, null
br i1 %39, label %40, label %55
40: ; preds = %37
%41 = load i32*, i32** %17
%42 = icmp ne i32* %41, null
br i1 %42, label %43, label %55
43: ; preds = %40
%44 = load i32*, i32** %18
%45 = icmp ne i32* %44, null
br i1 %45, label %46, label %55
46: ; preds = %43
%47 = load i32*, i32** %19
%48 = icmp ne i32* %47, null
br i1 %48, label %49, label %55
49: ; preds = %46
%50 = load i32*, i32** %15
%51 = icmp ne i32* %50, null
br i1 %51, label %52, label %55
52: ; preds = %49
%53 = load i32*, i32** %16
%54 = icmp ne i32* %53, null
br i1 %54, label %60, label %55
55: ; preds = %52, %49, %46, %43, %40, %37, %34, %5
%56 = load i32, i32* @stderr
%57 = call i32 @fprintf(i32 %56, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%58 = load i32, i32* @ENOMEM
%59 = sub nsw i32 0, %58
store i32 %59, i32* %6
br label %171
60: ; preds = %52
%61 = load i32*, i32** %7
%62 = load i32*, i32** %8
%63 = call i64 @rsa_get_exponent(i32* %61, i32* %62)
%64 = icmp ne i64 0, %63
br i1 %64, label %65, label %66
65: ; preds = %60
store i32 -1, i32* %22
br label %66
66: ; preds = %65, %60
%67 = load i32*, i32** %7
%68 = call i32 @RSA_get0_key(i32* %67, i32** %20, i32* null, i32* null)
%69 = load i32*, i32** %16
%70 = load i32*, i32** %20
%71 = call i32 @BN_copy(i32* %69, i32* %70)
%72 = icmp ne i32 %71, 0
br i1 %72, label %73, label %85
73: ; preds = %66
%74 = load i32*, i32** %12
%75 = call i32 @BN_set_word(i32* %74, i64 1)
%76 = icmp ne i32 %75, 0
br i1 %76, label %77, label %85
77: ; preds = %73
%78 = load i32*, i32** %13
%79 = call i32 @BN_set_word(i32* %78, i64 2)
%80 = icmp ne i32 %79, 0
br i1 %80, label %81, label %85
81: ; preds = %77
%82 = load i32*, i32** %14
%83 = call i32 @BN_set_word(i32* %82, i64 32)
%84 = icmp ne i32 %83, 0
br i1 %84, label %86, label %85
85: ; preds = %81, %77, %73, %66
store i32 -1, i32* %22
br label %86
86: ; preds = %85, %81
%87 = load i32*, i32** %15
%88 = load i32*, i32** %13
%89 = load i32*, i32** %14
%90 = load i32*, i32** %21
%91 = call i32 @BN_exp(i32* %87, i32* %88, i32* %89, i32* %90)
%92 = icmp ne i32 %91, 0
br i1 %92, label %94, label %93
93: ; preds = %86
store i32 -1, i32* %22
br label %94
94: ; preds = %93, %86
%95 = load i32*, i32** %19
%96 = load i32*, i32** %16
%97 = load i32*, i32** %15
%98 = load i32*, i32** %21
%99 = call i32 @BN_mod_inverse(i32* %95, i32* %96, i32* %97, i32* %98)
%100 = icmp ne i32 %99, 0
br i1 %100, label %101, label %107
101: ; preds = %94
%102 = load i32*, i32** %19
%103 = load i32*, i32** %15
%104 = load i32*, i32** %19
%105 = call i32 @BN_sub(i32* %102, i32* %103, i32* %104)
%106 = icmp ne i32 %105, 0
br i1 %106, label %108, label %107
107: ; preds = %101, %94
store i32 -1, i32* %22
br label %108
108: ; preds = %107, %101
%109 = load i32*, i32** %19
%110 = call i32 @BN_get_word(i32* %109)
%111 = load i32*, i32** %9
store i32 %110, i32* %111
%112 = load i32*, i32** %19
%113 = load i32*, i32** %16
%114 = call i64 @BN_num_bits(i32* %113)
%115 = call i32 @BN_set_word(i32* %112, i64 %114)
%116 = icmp ne i32 %115, 0
br i1 %116, label %117, label %124
117: ; preds = %108
%118 = load i32*, i32** %17
%119 = load i32*, i32** %13
%120 = load i32*, i32** %19
%121 = load i32*, i32** %21
%122 = call i32 @BN_exp(i32* %118, i32* %119, i32* %120, i32* %121)
%123 = icmp ne i32 %122, 0
br i1 %123, label %125, label %124
124: ; preds = %117, %108
store i32 -1, i32* %22
br label %125
125: ; preds = %124, %117
%126 = load i32*, i32** %18
%127 = load i32*, i32** %17
%128 = call i32 @BN_copy(i32* %126, i32* %127)
%129 = icmp ne i32 %128, 0
br i1 %129, label %130, label %144
130: ; preds = %125
%131 = load i32*, i32** %19
%132 = load i32*, i32** %18
%133 = load i32*, i32** %17
%134 = load i32*, i32** %21
%135 = call i32 @BN_mul(i32* %131, i32* %132, i32* %133, i32* %134)
%136 = icmp ne i32 %135, 0
br i1 %136, label %137, label %144
137: ; preds = %130
%138 = load i32*, i32** %18
%139 = load i32*, i32** %19
%140 = load i32*, i32** %16
%141 = load i32*, i32** %21
%142 = call i32 @BN_mod(i32* %138, i32* %139, i32* %140, i32* %141)
%143 = icmp ne i32 %142, 0
br i1 %143, label %145, label %144
144: ; preds = %137, %130, %125
store i32 -1, i32* %22
br label %145
145: ; preds = %144, %137
%146 = load i32*, i32** %16
%147 = load i32**, i32*** %10
store i32* %146, i32** %147
%148 = load i32*, i32** %18
%149 = load i32**, i32*** %11
store i32* %148, i32** %149
%150 = load i32*, i32** %12
%151 = call i32 @BN_free(i32* %150)
%152 = load i32*, i32** %13
%153 = call i32 @BN_free(i32* %152)
%154 = load i32*, i32** %14
%155 = call i32 @BN_free(i32* %154)
%156 = load i32*, i32** %17
%157 = call i32 @BN_free(i32* %156)
%158 = load i32*, i32** %19
%159 = call i32 @BN_free(i32* %158)
%160 = load i32*, i32** %15
%161 = call i32 @BN_free(i32* %160)
%162 = load i32, i32* %22
%163 = icmp ne i32 %162, 0
br i1 %163, label %164, label %169
164: ; preds = %145
%165 = load i32, i32* @stderr
%166 = call i32 @fprintf(i32 %165, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%167 = load i32, i32* @ENOMEM
%168 = sub nsw i32 0, %167
store i32 %168, i32* %6
br label %171
169: ; preds = %145
%170 = load i32, i32* %22
store i32 %170, i32* %6
br label %171
171: ; preds = %169, %164, %55
%172 = load i32, i32* %6
ret i32 %172
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [24 x i8] c"Out of memory (bignum)\0A\00"
@ENOMEM = global i32 0
@.str.1 = [26 x i8] c"Bignum operations failed\0A\00"
define i32 @rsa_get_params(i32* %0, i32* %1, i32* nocapture writeonly %2, i32** nocapture writeonly %3, i32** nocapture writeonly %4) {
%6 = alloca i32*
%7 = bitcast i32** %6 to i8*
%8 = tail call i32* (...) @BN_CTX_new()
%9 = tail call i32* (...) @BN_new()
%10 = tail call i32* (...) @BN_new()
%11 = tail call i32* (...) @BN_new()
%12 = tail call i32* (...) @BN_new()
%13 = tail call i32* (...) @BN_new()
%14 = tail call i32* (...) @BN_new()
%15 = tail call i32* (...) @BN_new()
%16 = tail call i32* (...) @BN_new()
%17 = icmp ne i32* %9, null
%18 = icmp ne i32* %10, null
%19 = select i1 %17, i1 %18, i1 false
%20 = icmp ne i32* %11, null
%21 = select i1 %19, i1 %20, i1 false
%22 = icmp ne i32* %12, null
%23 = select i1 %21, i1 %22, i1 false
%24 = icmp ne i32* %13, null
%25 = select i1 %23, i1 %24, i1 false
%26 = icmp ne i32* %14, null
%27 = select i1 %25, i1 %26, i1 false
%28 = icmp ne i32* %15, null
%29 = select i1 %27, i1 %28, i1 false
%30 = icmp ne i32* %16, null
%31 = select i1 %29, i1 %30, i1 false
br i1 %31, label %37, label %32
32: ; preds = %5
%33 = load i32, i32* @stderr
%34 = tail call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%35 = load i32, i32* @ENOMEM
%36 = sub nsw i32 0, %35
br label %101
37: ; preds = %5
%38 = tail call i64 @rsa_get_exponent(i32* %0, i32* %1)
%39 = icmp ne i64 %38, 0
%40 = sext i1 %39 to i32
%41 = call i32 @RSA_get0_key(i32* %0, i32** %6, i32* null, i32* null)
%42 = load i32*, i32** %6
%43 = call i32 @BN_copy(i32* %16, i32* %42)
%44 = icmp eq i32 %43, 0
br i1 %44, label %54, label %45
45: ; preds = %37
%46 = call i32 @BN_set_word(i32* %9, i64 1)
%47 = icmp eq i32 %46, 0
br i1 %47, label %54, label %48
48: ; preds = %45
%49 = call i32 @BN_set_word(i32* %10, i64 2)
%50 = icmp eq i32 %49, 0
br i1 %50, label %54, label %51
51: ; preds = %48
%52 = call i32 @BN_set_word(i32* %11, i64 32)
%53 = icmp eq i32 %52, 0
br i1 %53, label %54, label %55
54: ; preds = %51, %48, %45, %37
br label %55
55: ; preds = %54, %51
%56 = phi i32 [ %40, %51 ], [ -1, %54 ]
%57 = call i32 @BN_exp(i32* %15, i32* %10, i32* %11, i32* %8)
%58 = call i32 @BN_mod_inverse(i32* %14, i32* %16, i32* %15, i32* %8)
%59 = icmp eq i32 %58, 0
br i1 %59, label %65, label %60
60: ; preds = %55
%61 = icmp eq i32 %57, 0
%62 = select i1 %61, i32 -1, i32 %56
%63 = call i32 @BN_sub(i32* %14, i32* %15, i32* %14)
%64 = icmp eq i32 %63, 0
br i1 %64, label %65, label %66
65: ; preds = %60, %55
br label %66
66: ; preds = %65, %60
%67 = phi i32 [ %62, %60 ], [ -1, %65 ]
%68 = call i32 @BN_get_word(i32* %14)
store i32 %68, i32* %2
%69 = call i64 @BN_num_bits(i32* %16)
%70 = call i32 @BN_set_word(i32* %14, i64 %69)
%71 = icmp eq i32 %70, 0
br i1 %71, label %75, label %72
72: ; preds = %66
%73 = call i32 @BN_exp(i32* %12, i32* %10, i32* %14, i32* %8)
%74 = icmp eq i32 %73, 0
br i1 %74, label %75, label %76
75: ; preds = %72, %66
br label %76
76: ; preds = %75, %72
%77 = phi i32 [ %67, %72 ], [ -1, %75 ]
%78 = call i32 @BN_copy(i32* %13, i32* %12)
%79 = icmp eq i32 %78, 0
br i1 %79, label %86, label %80
80: ; preds = %76
%81 = call i32 @BN_mul(i32* %14, i32* %13, i32* %12, i32* %8)
%82 = icmp eq i32 %81, 0
br i1 %82, label %86, label %83
83: ; preds = %80
%84 = call i32 @BN_mod(i32* %13, i32* %14, i32* %16, i32* %8)
%85 = icmp eq i32 %84, 0
br i1 %85, label %86, label %87
86: ; preds = %83, %80, %76
br label %87
87: ; preds = %86, %83
%88 = phi i32 [ %77, %83 ], [ -1, %86 ]
store i32* %16, i32** %3
store i32* %13, i32** %4
%89 = call i32 @BN_free(i32* %9)
%90 = call i32 @BN_free(i32* %10)
%91 = call i32 @BN_free(i32* %11)
%92 = call i32 @BN_free(i32* %12)
%93 = call i32 @BN_free(i32* %14)
%94 = call i32 @BN_free(i32* %15)
%95 = icmp eq i32 %88, 0
br i1 %95, label %101, label %96
96: ; preds = %87
%97 = load i32, i32* @stderr
%98 = call i32 @fprintf(i32 %97, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%99 = load i32, i32* @ENOMEM
%100 = sub nsw i32 0, %99
br label %101
101: ; preds = %87, %96, %32
%102 = phi i32 [ %100, %96 ], [ %36, %32 ], [ 0, %87 ]
ret i32 %102
}