#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*/ EC_POINT;
typedef int /*<<< orphan*/ EC_KEY;
typedef int /*<<< orphan*/ EC_GROUP;
typedef int /*<<< orphan*/ BN_CTX;
typedef int /*<<< orphan*/ BIO;
typedef int /*<<< orphan*/ const BIGNUM;

/* Variables and functions */
int /*<<< orphan*/ ASN1_bn_print(int /*<<< orphan*/ *, char *,
                                 int /*<<< orphan*/ const *, unsigned char *,
                                 int);
int /*<<< orphan*/ BIO_indent(int /*<<< orphan*/ *, int, int);
scalar_t__ BIO_printf(int /*<<< orphan*/ *, char *, char const *,
                      int /*<<< orphan*/);
int /*<<< orphan*/ BN_CTX_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *BN_CTX_new();
int /*<<< orphan*/ BN_free(int /*<<< orphan*/ const *);
int /*<<< orphan*/ const *BN_new();
int /*<<< orphan*/ BN_num_bits(int /*<<< orphan*/ const *);
scalar_t__ BN_num_bytes(int /*<<< orphan*/ const *);
int /*<<< orphan*/ ECPKParameters_print(int /*<<< orphan*/ *,
                                        int /*<<< orphan*/ const *, int);
int /*<<< orphan*/ EC_F_DO_EC_KEY_PRINT;
int /*<<< orphan*/ EC_GROUP_get_order(int /*<<< orphan*/ const *,
                                      int /*<<< orphan*/ const *,
                                      int /*<<< orphan*/ *);
int /*<<< orphan*/ *EC_KEY_get0_group(int /*<<< orphan*/ const *);
int /*<<< orphan*/ const *EC_KEY_get0_private_key(int /*<<< orphan*/ const *);
int /*<<< orphan*/ *EC_KEY_get0_public_key(int /*<<< orphan*/ const *);
int /*<<< orphan*/ EC_KEY_get_conv_form(int /*<<< orphan*/ const *);
int /*<<< orphan*/ const *EC_POINT_point2bn(int /*<<< orphan*/ const *,
                                            int /*<<< orphan*/ const *,
                                            int /*<<< orphan*/,
                                            int /*<<< orphan*/ *,
                                            int /*<<< orphan*/ *);
int /*<<< orphan*/ ECerr(int /*<<< orphan*/, int);
int ERR_R_BIO_LIB;
int ERR_R_EC_LIB;
int ERR_R_MALLOC_FAILURE;
int ERR_R_PASSED_NULL_PARAMETER;
int /*<<< orphan*/ free(unsigned char *);
unsigned char *malloc(size_t);
int do_EC_KEY_print(BIO *bp, const EC_KEY *x, int off, int ktype) {
  unsigned char *buffer = NULL;
  const char *ecstr;
  size_t buf_len = 0, i;
  int ret = 0, reason = ERR_R_BIO_LIB;
  BIGNUM *pub_key = NULL, *order = NULL;
  BN_CTX *ctx = NULL;
  const EC_GROUP *group;
  const EC_POINT *public_key;
  const BIGNUM *priv_key;
  if (x == NULL || (group = EC_KEY_get0_group(x)) == NULL) {
    reason = ERR_R_PASSED_NULL_PARAMETER;
    goto err;
  }
  ctx = BN_CTX_new();
  if (ctx == NULL) {
    reason = ERR_R_MALLOC_FAILURE;
    goto err;
  }
  if (ktype > 0) {
    public_key = EC_KEY_get0_public_key(x);
    if ((pub_key = EC_POINT_point2bn(group, public_key, EC_KEY_get_conv_form(x),
                                     NULL, ctx)) == NULL) {
      reason = ERR_R_EC_LIB;
      goto err;
    }
    if (pub_key)
      buf_len = (size_t)BN_num_bytes(pub_key);
  }
  if (ktype == 2) {
    priv_key = EC_KEY_get0_private_key(x);
    if (priv_key && (i = (size_t)BN_num_bytes(priv_key)) > buf_len)
      buf_len = i;
  } else
    priv_key = NULL;
  if (ktype > 0) {
    buf_len += 10;
    if ((buffer = malloc(buf_len)) == NULL) {
      reason = ERR_R_MALLOC_FAILURE;
      goto err;
    }
  }
  if (ktype == 2)
    ecstr = "Private-Key";
  else if (ktype == 1)
    ecstr = "Public-Key";
  else
    ecstr = "ECDSA-Parameters";
  if (!BIO_indent(bp, off, 128))
    goto err;
  if ((order = BN_new()) == NULL)
    goto err;
  if (!EC_GROUP_get_order(group, order, NULL))
    goto err;
  if (BIO_printf(bp, "%s: (%d bit)\n", ecstr, BN_num_bits(order)) <= 0)
    goto err;
  if ((priv_key != NULL) && !ASN1_bn_print(bp, "priv:", priv_key, buffer, off))
    goto err;
  if ((pub_key != NULL) && !ASN1_bn_print(bp, "pub: ", pub_key, buffer, off))
    goto err;
  if (!ECPKParameters_print(bp, group, off))
    goto err;
  ret = 1;
err:
  if (!ret)
    ECerr(EC_F_DO_EC_KEY_PRINT, reason);
  BN_free(pub_key);
  BN_free(order);
  BN_CTX_free(ctx);
  free(buffer);
  return (ret);
}


x86 assembly (clang, -O0):
<do_EC_KEY_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x30(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    0x2d59(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x58(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     12a6 <do_EC_KEY_print+0x76>
mov    -0x10(%rbp),%rdi
call   10f0 <EC_KEY_get0_group@plt>
mov    %rax,-0x60(%rbp)
cmp    $0x0,%rax
jne    12b7 <do_EC_KEY_print+0x87>
mov    0x2d1b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
jmp    1567 <do_EC_KEY_print+0x337>
mov    $0x0,%al
call   10e0 <BN_CTX_new@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    12de <do_EC_KEY_print+0xae>
mov    0x2d14(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
jmp    1567 <do_EC_KEY_print+0x337>
cmpl   $0x0,-0x18(%rbp)
jle    1361 <do_EC_KEY_print+0x131>
mov    -0x10(%rbp),%rdi
call   1070 <EC_KEY_get0_public_key@plt>
mov    %rax,-0x68(%rbp)
mov    -0x60(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x68(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x10(%rbp),%rdi
call   1140 <EC_KEY_get_conv_form@plt>
mov    -0x80(%rbp),%rdi
mov    -0x78(%rbp),%rsi
mov    %eax,%edx
mov    -0x58(%rbp),%r8
xor    %eax,%eax
mov    %eax,%ecx
call   1040 <EC_POINT_point2bn@plt>
mov    %rax,-0x48(%rbp)
cmp    $0x0,%rax
jne    1344 <do_EC_KEY_print+0x114>
mov    0x2ca6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
jmp    1567 <do_EC_KEY_print+0x337>
cmpq   $0x0,-0x48(%rbp)
je     135c <do_EC_KEY_print+0x12c>
mov    -0x48(%rbp),%rdi
call   1120 <BN_num_bytes@plt>
mov    %rax,-0x30(%rbp)
jmp    1361 <do_EC_KEY_print+0x131>
cmpl   $0x2,-0x18(%rbp)
jne    13a7 <do_EC_KEY_print+0x177>
mov    -0x10(%rbp),%rdi
call   1090 <EC_KEY_get0_private_key@plt>
mov    %rax,-0x70(%rbp)
cmpq   $0x0,-0x70(%rbp)
je     13a2 <do_EC_KEY_print+0x172>
mov    -0x70(%rbp),%rdi
call   1120 <BN_num_bytes@plt>
mov    %rax,-0x38(%rbp)
cmp    -0x30(%rbp),%rax
jbe    13a2 <do_EC_KEY_print+0x172>
mov    -0x38(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    13af <do_EC_KEY_print+0x17f>
movq   $0x0,-0x70(%rbp)
cmpl   $0x0,-0x18(%rbp)
jle    13f2 <do_EC_KEY_print+0x1c2>
mov    -0x30(%rbp),%rax
add    $0xa,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1100 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    13ed <do_EC_KEY_print+0x1bd>
mov    0x2c05(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
jmp    1567 <do_EC_KEY_print+0x337>
jmp    13f2 <do_EC_KEY_print+0x1c2>
cmpl   $0x2,-0x18(%rbp)
jne    140c <do_EC_KEY_print+0x1dc>
lea    0xbfd(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    1436 <do_EC_KEY_print+0x206>
cmpl   $0x1,-0x18(%rbp)
jne    1426 <do_EC_KEY_print+0x1f6>
lea    0xbef(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    1431 <do_EC_KEY_print+0x201>
lea    0xbea(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    1436 <do_EC_KEY_print+0x206>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    $0x80,%edx
call   1050 <BIO_indent@plt>
cmp    $0x0,%eax
jne    1455 <do_EC_KEY_print+0x225>
jmp    1567 <do_EC_KEY_print+0x337>
mov    $0x0,%al
call   1060 <BN_new@plt>
mov    %rax,-0x50(%rbp)
cmp    $0x0,%rax
jne    146f <do_EC_KEY_print+0x23f>
jmp    1567 <do_EC_KEY_print+0x337>
mov    -0x60(%rbp),%rdi
mov    -0x50(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   10c0 <EC_GROUP_get_order@plt>
cmp    $0x0,%eax
jne    148e <do_EC_KEY_print+0x25e>
jmp    1567 <do_EC_KEY_print+0x337>
mov    -0x8(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x50(%rbp),%rdi
call   1080 <BN_num_bits@plt>
mov    -0x90(%rbp),%rdi
mov    -0x88(%rbp),%rdx
mov    %eax,%ecx
lea    0xb64(%rip),%rsi
call   10a0 <BIO_printf@plt>
cmp    $0x0,%rax
jg     14d8 <do_EC_KEY_print+0x2a8>
jmp    1567 <do_EC_KEY_print+0x337>
cmpq   $0x0,-0x70(%rbp)
je     150d <do_EC_KEY_print+0x2dd>
mov    -0x8(%rbp),%rdi
mov    -0x70(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x14(%rbp),%r8d
lea    0xb3c(%rip),%rsi
call   1150 <ASN1_bn_print@plt>
cmp    $0x0,%eax
jne    150d <do_EC_KEY_print+0x2dd>
jmp    1567 <do_EC_KEY_print+0x337>
cmpq   $0x0,-0x48(%rbp)
je     1542 <do_EC_KEY_print+0x312>
mov    -0x8(%rbp),%rdi
mov    -0x48(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x14(%rbp),%r8d
lea    0xb0d(%rip),%rsi
call   1150 <ASN1_bn_print@plt>
cmp    $0x0,%eax
jne    1542 <do_EC_KEY_print+0x312>
jmp    1567 <do_EC_KEY_print+0x337>
mov    -0x8(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1110 <ECPKParameters_print@plt>
cmp    $0x0,%eax
jne    1560 <do_EC_KEY_print+0x330>
jmp    1567 <do_EC_KEY_print+0x337>
movl   $0x1,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jne    1582 <do_EC_KEY_print+0x352>
mov    0x2a58(%rip),%rax
mov    (%rax),%edi
mov    -0x40(%rbp),%esi
call   1130 <ECerr@plt>
mov    -0x48(%rbp),%rdi
call   10d0 <BN_free@plt>
mov    -0x50(%rbp),%rdi
call   10d0 <BN_free@plt>
mov    -0x58(%rbp),%rdi
call   10b0 <BN_CTX_free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x3c(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_EC_KEY_print>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
test   %rsi,%rsi
je     1311 <do_EC_KEY_print+0xe1>
mov    %ecx,%r14d
mov    %edx,%r13d
mov    %rsi,%rbx
mov    %rdi,%r15
mov    0x2d66(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
mov    %rsi,%rdi
call   10f0 <EC_KEY_get0_group@plt>
test   %rax,%rax
je     1311 <do_EC_KEY_print+0xe1>
mov    %rax,%rbp
xor    %eax,%eax
call   10e0 <BN_CTX_new@plt>
mov    %rax,0x10(%rsp)
test   %rax,%rax
je     1366 <do_EC_KEY_print+0x136>
test   %r14d,%r14d
mov    %rbp,0x20(%rsp)
jle    136f <do_EC_KEY_print+0x13f>
mov    %rbx,%rdi
call   1070 <EC_KEY_get0_public_key@plt>
mov    %rax,%r12
mov    %rbx,%rdi
call   1140 <EC_KEY_get_conv_form@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
mov    0x10(%rsp),%r8
call   1040 <EC_POINT_point2bn@plt>
test   %rax,%rax
je     14d5 <do_EC_KEY_print+0x2a5>
mov    %rax,%rbp
mov    %r15,0x18(%rsp)
mov    %r13d,0xc(%rsp)
mov    %rax,%rdi
call   1120 <BN_num_bytes@plt>
mov    %rax,%r13
cmp    $0x2,%r14d
mov    %rbp,%r15
jne    137f <do_EC_KEY_print+0x14f>
mov    %rbx,%rdi
call   1090 <EC_KEY_get0_private_key@plt>
test   %rax,%rax
je     137f <do_EC_KEY_print+0x14f>
mov    %rax,%rbx
mov    %rax,%rdi
call   1120 <BN_num_bytes@plt>
cmp    %r13,%rax
cmova  %rax,%r13
jmp    1381 <do_EC_KEY_print+0x151>
mov    0x2cb0(%rip),%rax
mov    (%rax),%esi
xor    %r12d,%r12d
xor    %ebx,%ebx
xor    %r13d,%r13d
xor    %r15d,%r15d
mov    0x2ca4(%rip),%rax
mov    (%rax),%edi
call   1130 <ECerr@plt>
xor    %ebp,%ebp
mov    %r15,%rdi
call   10d0 <BN_free@plt>
mov    %r13,%rdi
call   10d0 <BN_free@plt>
mov    %rbx,%rdi
call   10b0 <BN_CTX_free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c7b(%rip),%rax
jmp    1318 <do_EC_KEY_print+0xe8>
lea    0xca1(%rip),%r14
xor    %r12d,%r12d
xor    %ebp,%ebp
xor    %ebx,%ebx
jmp    13cb <do_EC_KEY_print+0x19b>
xor    %ebx,%ebx
add    $0xa,%r13
mov    %r13,%rdi
call   1100 <malloc@plt>
test   %rax,%rax
je     14ff <do_EC_KEY_print+0x2cf>
mov    %rax,%r12
mov    %r15,%rbp
cmp    $0x1,%r14d
lea    0xc65(%rip),%rax
lea    0xc69(%rip),%rcx
cmove  %rax,%rcx
cmp    $0x2,%r14d
lea    0xc43(%rip),%r14
cmovne %rcx,%r14
mov    0xc(%rsp),%r13d
mov    0x18(%rsp),%r15
mov    %r15,%rdi
mov    %r13d,%esi
mov    $0x80,%edx
call   1050 <BIO_indent@plt>
test   %eax,%eax
je     14c1 <do_EC_KEY_print+0x291>
mov    %r15,0x18(%rsp)
mov    %r13d,0xc(%rsp)
xor    %eax,%eax
call   1060 <BN_new@plt>
test   %rax,%rax
je     14c1 <do_EC_KEY_print+0x291>
mov    %rax,%r13
mov    0x20(%rsp),%rdi
mov    %rax,%rsi
xor    %edx,%edx
call   10c0 <EC_GROUP_get_order@plt>
test   %eax,%eax
mov    %rbp,%r15
je     14f1 <do_EC_KEY_print+0x2c1>
mov    %r13,%rdi
call   1080 <BN_num_bits@plt>
lea    0xbff(%rip),%rsi
mov    0x18(%rsp),%rdi
mov    %r14,%rdx
mov    %eax,%ecx
call   10a0 <BIO_printf@plt>
test   %rax,%rax
jle    14f1 <do_EC_KEY_print+0x2c1>
test   %rbx,%rbx
je     146a <do_EC_KEY_print+0x23a>
lea    0xbe9(%rip),%rsi
mov    0x18(%rsp),%rdi
mov    %rbx,%rdx
mov    %r12,%rcx
mov    0xc(%rsp),%r8d
call   1150 <ASN1_bn_print@plt>
test   %eax,%eax
je     14f1 <do_EC_KEY_print+0x2c1>
test   %r15,%r15
mov    0x10(%rsp),%rbx
je     1498 <do_EC_KEY_print+0x268>
lea    0xbc1(%rip),%rsi
mov    0x18(%rsp),%rdi
mov    %r15,%rdx
mov    %r12,%rcx
mov    0xc(%rsp),%r8d
call   1150 <ASN1_bn_print@plt>
test   %eax,%eax
je     1518 <do_EC_KEY_print+0x2e8>
mov    0x18(%rsp),%rdi
mov    0x20(%rsp),%rsi
mov    0xc(%rsp),%edx
call   1110 <ECPKParameters_print@plt>
mov    $0x1,%ebp
test   %eax,%eax
mov    0x8(%rsp),%esi
jne    1335 <do_EC_KEY_print+0x105>
jmp    1325 <do_EC_KEY_print+0xf5>
xor    %r13d,%r13d
mov    0x8(%rsp),%esi
mov    0x10(%rsp),%rbx
mov    %rbp,%r15
jmp    1325 <do_EC_KEY_print+0xf5>
mov    0x2b04(%rip),%rax
mov    (%rax),%esi
xor    %r12d,%r12d
xor    %r13d,%r13d
xor    %r15d,%r15d
mov    0x10(%rsp),%rbx
jmp    1325 <do_EC_KEY_print+0xf5>
mov    0x8(%rsp),%esi
mov    0x10(%rsp),%rbx
jmp    1325 <do_EC_KEY_print+0xf5>
mov    0x2ae2(%rip),%rax
mov    (%rax),%esi
xor    %r12d,%r12d
xor    %r13d,%r13d
mov    0x10(%rsp),%rbx
jmp    1325 <do_EC_KEY_print+0xf5>
mov    0x8(%rsp),%esi
jmp    1325 <do_EC_KEY_print+0xf5>

LLVM IR (-O0):
@ERR_R_BIO_LIB = global i32 0
@ERR_R_PASSED_NULL_PARAMETER = global i32 0
@ERR_R_MALLOC_FAILURE = global i32 0
@ERR_R_EC_LIB = global i32 0
@.str = [12 x i8] c"Private-Key\00"
@.str.1 = [11 x i8] c"Public-Key\00"
@.str.2 = [17 x i8] c"ECDSA-Parameters\00"
@.str.3 = [14 x i8] c"%s: (%d bit)\0A\00"
@.str.4 = [6 x i8] c"priv:\00"
@.str.5 = [6 x i8] c"pub: \00"
@EC_F_DO_EC_KEY_PRINT = global i32 0
define i32 @do_EC_KEY_print(i32* %0, i32* %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i64
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32*
%16 = alloca i32*
%17 = alloca i32*
%18 = alloca i32*
%19 = alloca i32*
%20 = alloca i32*
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i8* null, i8** %9
store i64 0, i64* %11
store i32 0, i32* %13
%21 = load i32, i32* @ERR_R_BIO_LIB
store i32 %21, i32* %14
store i32* null, i32** %15
store i32* null, i32** %16
store i32* null, i32** %17
%22 = load i32*, i32** %6
%23 = icmp eq i32* %22, null
br i1 %23, label %28, label %24
24: ; preds = %4
%25 = load i32*, i32** %6
%26 = call i32* @EC_KEY_get0_group(i32* %25)
store i32* %26, i32** %18
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %30
28: ; preds = %24, %4
%29 = load i32, i32* @ERR_R_PASSED_NULL_PARAMETER
store i32 %29, i32* %14
br label %151
30: ; preds = %24
%31 = call i32* (...) @BN_CTX_new()
store i32* %31, i32** %17
%32 = load i32*, i32** %17
%33 = icmp eq i32* %32, null
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = load i32, i32* @ERR_R_MALLOC_FAILURE
store i32 %35, i32* %14
br label %151
36: ; preds = %30
%37 = load i32, i32* %8
%38 = icmp sgt i32 %37, 0
br i1 %38, label %39, label %58
39: ; preds = %36
%40 = load i32*, i32** %6
%41 = call i32* @EC_KEY_get0_public_key(i32* %40)
store i32* %41, i32** %19
%42 = load i32*, i32** %18
%43 = load i32*, i32** %19
%44 = load i32*, i32** %6
%45 = call i32 @EC_KEY_get_conv_form(i32* %44)
%46 = load i32*, i32** %17
%47 = call i32* @EC_POINT_point2bn(i32* %42, i32* %43, i32 %45, i32* null, i32* %46)
store i32* %47, i32** %15
%48 = icmp eq i32* %47, null
br i1 %48, label %49, label %51
49: ; preds = %39
%50 = load i32, i32* @ERR_R_EC_LIB
store i32 %50, i32* %14
br label %151
51: ; preds = %39
%52 = load i32*, i32** %15
%53 = icmp ne i32* %52, null
br i1 %53, label %54, label %57
54: ; preds = %51
%55 = load i32*, i32** %15
%56 = call i64 @BN_num_bytes(i32* %55)
store i64 %56, i64* %11
br label %57
57: ; preds = %54, %51
br label %58
58: ; preds = %57, %36
%59 = load i32, i32* %8
%60 = icmp eq i32 %59, 2
br i1 %60, label %61, label %74
61: ; preds = %58
%62 = load i32*, i32** %6
%63 = call i32* @EC_KEY_get0_private_key(i32* %62)
store i32* %63, i32** %20
%64 = load i32*, i32** %20
%65 = icmp ne i32* %64, null
br i1 %65, label %66, label %73
66: ; preds = %61
%67 = load i32*, i32** %20
%68 = call i64 @BN_num_bytes(i32* %67)
store i64 %68, i64* %12
%69 = load i64, i64* %11
%70 = icmp ugt i64 %68, %69
br i1 %70, label %71, label %73
71: ; preds = %66
%72 = load i64, i64* %12
store i64 %72, i64* %11
br label %73
73: ; preds = %71, %66, %61
br label %75
74: ; preds = %58
store i32* null, i32** %20
br label %75
75: ; preds = %74, %73
%76 = load i32, i32* %8
%77 = icmp sgt i32 %76, 0
br i1 %77, label %78, label %87
78: ; preds = %75
%79 = load i64, i64* %11
%80 = add i64 %79, 10
store i64 %80, i64* %11
%81 = load i64, i64* %11
%82 = call i8* @malloc(i64 %81)
store i8* %82, i8** %9
%83 = icmp eq i8* %82, null
br i1 %83, label %84, label %86
84: ; preds = %78
%85 = load i32, i32* @ERR_R_MALLOC_FAILURE
store i32 %85, i32* %14
br label %151
86: ; preds = %78
br label %87
87: ; preds = %86, %75
%88 = load i32, i32* %8
%89 = icmp eq i32 %88, 2
br i1 %89, label %90, label %91
90: ; preds = %87
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %10
br label %97
91: ; preds = %87
%92 = load i32, i32* %8
%93 = icmp eq i32 %92, 1
br i1 %93, label %94, label %95
94: ; preds = %91
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8** %10
br label %96
95: ; preds = %91
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8** %10
br label %96
96: ; preds = %95, %94
br label %97
97: ; preds = %96, %90
%98 = load i32*, i32** %5
%99 = load i32, i32* %7
%100 = call i32 @BIO_indent(i32* %98, i32 %99, i32 128)
%101 = icmp ne i32 %100, 0
br i1 %101, label %103, label %102
102: ; preds = %97
br label %151
103: ; preds = %97
%104 = call i32* (...) @BN_new()
store i32* %104, i32** %16
%105 = icmp eq i32* %104, null
br i1 %105, label %106, label %107
106: ; preds = %103
br label %151
107: ; preds = %103
%108 = load i32*, i32** %18
%109 = load i32*, i32** %16
%110 = call i32 @EC_GROUP_get_order(i32* %108, i32* %109, i32* null)
%111 = icmp ne i32 %110, 0
br i1 %111, label %113, label %112
112: ; preds = %107
br label %151
113: ; preds = %107
%114 = load i32*, i32** %5
%115 = load i8*, i8** %10
%116 = load i32*, i32** %16
%117 = call i32 @BN_num_bits(i32* %116)
%118 = call i64 @BIO_printf(i32* %114, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %115, i32 %117)
%119 = icmp sle i64 %118, 0
br i1 %119, label %120, label %121
120: ; preds = %113
br label %151
121: ; preds = %113
%122 = load i32*, i32** %20
%123 = icmp ne i32* %122, null
br i1 %123, label %124, label %132
124: ; preds = %121
%125 = load i32*, i32** %5
%126 = load i32*, i32** %20
%127 = load i8*, i8** %9
%128 = load i32, i32* %7
%129 = call i32 @ASN1_bn_print(i32* %125, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %126, i8* %127, i32 %128)
%130 = icmp ne i32 %129, 0
br i1 %130, label %132, label %131
131: ; preds = %124
br label %151
132: ; preds = %124, %121
%133 = load i32*, i32** %15
%134 = icmp ne i32* %133, null
br i1 %134, label %135, label %143
135: ; preds = %132
%136 = load i32*, i32** %5
%137 = load i32*, i32** %15
%138 = load i8*, i8** %9
%139 = load i32, i32* %7
%140 = call i32 @ASN1_bn_print(i32* %136, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* %137, i8* %138, i32 %139)
%141 = icmp ne i32 %140, 0
br i1 %141, label %143, label %142
142: ; preds = %135
br label %151
143: ; preds = %135, %132
%144 = load i32*, i32** %5
%145 = load i32*, i32** %18
%146 = load i32, i32* %7
%147 = call i32 @ECPKParameters_print(i32* %144, i32* %145, i32 %146)
%148 = icmp ne i32 %147, 0
br i1 %148, label %150, label %149
149: ; preds = %143
br label %151
150: ; preds = %143
store i32 1, i32* %13
br label %151
151: ; preds = %150, %149, %142, %131, %120, %112, %106, %102, %84, %49, %34, %28
%152 = load i32, i32* %13
%153 = icmp ne i32 %152, 0
br i1 %153, label %158, label %154
154: ; preds = %151
%155 = load i32, i32* @EC_F_DO_EC_KEY_PRINT
%156 = load i32, i32* %14
%157 = call i32 @ECerr(i32 %155, i32 %156)
br label %158
158: ; preds = %154, %151
%159 = load i32*, i32** %15
%160 = call i32 @BN_free(i32* %159)
%161 = load i32*, i32** %16
%162 = call i32 @BN_free(i32* %161)
%163 = load i32*, i32** %17
%164 = call i32 @BN_CTX_free(i32* %163)
%165 = load i8*, i8** %9
%166 = call i32 @free(i8* %165)
%167 = load i32, i32* %13
ret i32 %167
}

LLVM IR (-O2):
@ERR_R_BIO_LIB = global i32 0
@ERR_R_PASSED_NULL_PARAMETER = global i32 0
@ERR_R_MALLOC_FAILURE = global i32 0
@ERR_R_EC_LIB = global i32 0
@.str = [12 x i8] c"Private-Key\00"
@.str.1 = [11 x i8] c"Public-Key\00"
@.str.2 = [17 x i8] c"ECDSA-Parameters\00"
@.str.3 = [14 x i8] c"%s: (%d bit)\0A\00"
@.str.4 = [6 x i8] c"priv:\00"
@.str.5 = [6 x i8] c"pub: \00"
@EC_F_DO_EC_KEY_PRINT = global i32 0
define i32 @do_EC_KEY_print(i32* %0, i32* %1, i32 %2, i32 %3) {
%5 = load i32, i32* @ERR_R_BIO_LIB
%6 = icmp eq i32* %1, null
br i1 %6, label %10, label %7
7: ; preds = %4
%8 = tail call i32* @EC_KEY_get0_group(i32* %1)
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %7, %4
%11 = load i32, i32* @ERR_R_PASSED_NULL_PARAMETER
br label %78
12: ; preds = %7
%13 = tail call i32* (...) @BN_CTX_new()
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = load i32, i32* @ERR_R_MALLOC_FAILURE
br label %78
17: ; preds = %12
%18 = icmp sgt i32 %3, 0
br i1 %18, label %19, label %48
19: ; preds = %17
%20 = tail call i32* @EC_KEY_get0_public_key(i32* %1)
%21 = tail call i32 @EC_KEY_get_conv_form(i32* %1)
%22 = tail call i32* @EC_POINT_point2bn(i32* %8, i32* %20, i32 %21, i32* null, i32* %13)
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %26
24: ; preds = %19
%25 = load i32, i32* @ERR_R_EC_LIB
br label %78
26: ; preds = %19
%27 = tail call i64 @BN_num_bytes(i32* %22)
%28 = icmp eq i32 %3, 2
br i1 %28, label %29, label %36
29: ; preds = %26
%30 = tail call i32* @EC_KEY_get0_private_key(i32* %1)
%31 = icmp eq i32* %30, null
br i1 %31, label %36, label %32
32: ; preds = %29
%33 = tail call i64 @BN_num_bytes(i32* %30)
%34 = icmp ugt i64 %33, %27
%35 = select i1 %34, i64 %33, i64 %27
br label %36
36: ; preds = %32, %26, %29
%37 = phi i64 [ %27, %26 ], [ %35, %32 ], [ %27, %29 ]
%38 = phi i32* [ null, %26 ], [ %30, %32 ], [ null, %29 ]
%39 = add i64 %37, 10
%40 = tail call i8* @malloc(i64 %39)
%41 = icmp eq i8* %40, null
br i1 %41, label %42, label %44
42: ; preds = %36
%43 = load i32, i32* @ERR_R_MALLOC_FAILURE
br label %78
44: ; preds = %36
%45 = icmp eq i32 %3, 1
%46 = select i1 %45, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0)
%47 = select i1 %28, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %46
br label %48
48: ; preds = %44, %17
%49 = phi i8* [ null, %17 ], [ %40, %44 ]
%50 = phi i32* [ null, %17 ], [ %22, %44 ]
%51 = phi i32* [ null, %17 ], [ %38, %44 ]
%52 = phi i8* [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), %17 ], [ %47, %44 ]
%53 = tail call i32 @BIO_indent(i32* %0, i32 %2, i32 128)
%54 = icmp eq i32 %53, 0
br i1 %54, label %78, label %55
55: ; preds = %48
%56 = tail call i32* (...) @BN_new()
%57 = icmp eq i32* %56, null
br i1 %57, label %78, label %58
58: ; preds = %55
%59 = tail call i32 @EC_GROUP_get_order(i32* %8, i32* %56, i32* null)
%60 = icmp eq i32 %59, 0
br i1 %60, label %78, label %61
61: ; preds = %58
%62 = tail call i32 @BN_num_bits(i32* %56)
%63 = tail call i64 @BIO_printf(i32* %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %52, i32 %62)
%64 = icmp slt i64 %63, 1
br i1 %64, label %78, label %65
65: ; preds = %61
%66 = icmp eq i32* %51, null
br i1 %66, label %70, label %67
67: ; preds = %65
%68 = tail call i32 @ASN1_bn_print(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %51, i8* %49, i32 %2)
%69 = icmp eq i32 %68, 0
br i1 %69, label %78, label %70
70: ; preds = %67, %65
%71 = icmp eq i32* %50, null
br i1 %71, label %75, label %72
72: ; preds = %70
%73 = tail call i32 @ASN1_bn_print(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* %50, i8* %49, i32 %2)
%74 = icmp eq i32 %73, 0
br i1 %74, label %78, label %75
75: ; preds = %70, %72
%76 = tail call i32 @ECPKParameters_print(i32* %0, i32* %8, i32 %2)
%77 = icmp eq i32 %76, 0
br i1 %77, label %78, label %86
78: ; preds = %10, %15, %24, %42, %48, %55, %58, %61, %67, %72, %75
%79 = phi i8* [ %49, %75 ], [ null, %10 ], [ null, %15 ], [ null, %24 ], [ null, %42 ], [ %49, %48 ], [ %49, %55 ], [ %49, %58 ], [ %49, %61 ], [ %49, %67 ], [ %49, %72 ]
%80 = phi i32* [ %13, %75 ], [ null, %10 ], [ null, %15 ], [ %13, %24 ], [ %13, %42 ], [ %13, %48 ], [ %13, %55 ], [ %13, %58 ], [ %13, %61 ], [ %13, %67 ], [ %13, %72 ]
%81 = phi i32* [ %56, %75 ], [ null, %10 ], [ null, %15 ], [ null, %24 ], [ null, %42 ], [ null, %48 ], [ null, %55 ], [ %56, %58 ], [ %56, %61 ], [ %56, %67 ], [ %56, %72 ]
%82 = phi i32* [ %50, %75 ], [ null, %10 ], [ null, %15 ], [ null, %24 ], [ %22, %42 ], [ %50, %48 ], [ %50, %55 ], [ %50, %58 ], [ %50, %61 ], [ %50, %67 ], [ %50, %72 ]
%83 = phi i32 [ %5, %75 ], [ %11, %10 ], [ %16, %15 ], [ %25, %24 ], [ %43, %42 ], [ %5, %48 ], [ %5, %55 ], [ %5, %58 ], [ %5, %61 ], [ %5, %67 ], [ %5, %72 ]
%84 = load i32, i32* @EC_F_DO_EC_KEY_PRINT
%85 = tail call i32 @ECerr(i32 %84, i32 %83)
br label %86
86: ; preds = %78, %75
%87 = phi i8* [ %79, %78 ], [ %49, %75 ]
%88 = phi i32* [ %80, %78 ], [ %13, %75 ]
%89 = phi i32* [ %81, %78 ], [ %56, %75 ]
%90 = phi i32* [ %82, %78 ], [ %50, %75 ]
%91 = phi i32 [ 0, %78 ], [ 1, %75 ]
%92 = tail call i32 @BN_free(i32* %90)
%93 = tail call i32 @BN_free(i32* %89)
%94 = tail call i32 @BN_CTX_free(i32* %88)
%95 = tail call i32 @free(i8* %87)
ret i32 %91
}