#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_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*/ ECerror(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 (public_key != NULL) {
      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)
    ECerror(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    0x2d61(%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   1100 <EC_KEY_get0_group@plt>
mov    %rax,-0x60(%rbp)
cmp    $0x0,%rax
jne    12b7 <do_EC_KEY_print+0x87>
mov    0x2d23(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
jmp    1577 <do_EC_KEY_print+0x347>
mov    $0x0,%al
call   10f0 <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    1577 <do_EC_KEY_print+0x347>
cmpl   $0x0,-0x18(%rbp)
jle    1371 <do_EC_KEY_print+0x141>
mov    -0x10(%rbp),%rdi
call   1080 <EC_KEY_get0_public_key@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x68(%rbp)
je     136c <do_EC_KEY_print+0x13c>
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    134f <do_EC_KEY_print+0x11f>
mov    0x2c9b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
jmp    1577 <do_EC_KEY_print+0x347>
cmpq   $0x0,-0x48(%rbp)
je     1367 <do_EC_KEY_print+0x137>
mov    -0x48(%rbp),%rdi
call   1130 <BN_num_bytes@plt>
mov    %rax,-0x30(%rbp)
jmp    136c <do_EC_KEY_print+0x13c>
jmp    1371 <do_EC_KEY_print+0x141>
cmpl   $0x2,-0x18(%rbp)
jne    13b7 <do_EC_KEY_print+0x187>
mov    -0x10(%rbp),%rdi
call   10a0 <EC_KEY_get0_private_key@plt>
mov    %rax,-0x70(%rbp)
cmpq   $0x0,-0x70(%rbp)
je     13b2 <do_EC_KEY_print+0x182>
mov    -0x70(%rbp),%rdi
call   1130 <BN_num_bytes@plt>
mov    %rax,-0x38(%rbp)
cmp    -0x30(%rbp),%rax
jbe    13b2 <do_EC_KEY_print+0x182>
mov    -0x38(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    13bf <do_EC_KEY_print+0x18f>
movq   $0x0,-0x70(%rbp)
cmpl   $0x0,-0x18(%rbp)
jle    1402 <do_EC_KEY_print+0x1d2>
mov    -0x30(%rbp),%rax
add    $0xa,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1110 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    13fd <do_EC_KEY_print+0x1cd>
mov    0x2bf5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
jmp    1577 <do_EC_KEY_print+0x347>
jmp    1402 <do_EC_KEY_print+0x1d2>
cmpl   $0x2,-0x18(%rbp)
jne    141c <do_EC_KEY_print+0x1ec>
lea    0xbed(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    1446 <do_EC_KEY_print+0x216>
cmpl   $0x1,-0x18(%rbp)
jne    1436 <do_EC_KEY_print+0x206>
lea    0xbdf(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    1441 <do_EC_KEY_print+0x211>
lea    0xbda(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    1446 <do_EC_KEY_print+0x216>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    $0x80,%edx
call   1050 <BIO_indent@plt>
cmp    $0x0,%eax
jne    1465 <do_EC_KEY_print+0x235>
jmp    1577 <do_EC_KEY_print+0x347>
mov    $0x0,%al
call   1070 <BN_new@plt>
mov    %rax,-0x50(%rbp)
cmp    $0x0,%rax
jne    147f <do_EC_KEY_print+0x24f>
jmp    1577 <do_EC_KEY_print+0x347>
mov    -0x60(%rbp),%rdi
mov    -0x50(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   10d0 <EC_GROUP_get_order@plt>
cmp    $0x0,%eax
jne    149e <do_EC_KEY_print+0x26e>
jmp    1577 <do_EC_KEY_print+0x347>
mov    -0x8(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x50(%rbp),%rdi
call   1090 <BN_num_bits@plt>
mov    -0x90(%rbp),%rdi
mov    -0x88(%rbp),%rdx
mov    %eax,%ecx
lea    0xb54(%rip),%rsi
call   10b0 <BIO_printf@plt>
cmp    $0x0,%rax
jg     14e8 <do_EC_KEY_print+0x2b8>
jmp    1577 <do_EC_KEY_print+0x347>
cmpq   $0x0,-0x70(%rbp)
je     151d <do_EC_KEY_print+0x2ed>
mov    -0x8(%rbp),%rdi
mov    -0x70(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x14(%rbp),%r8d
lea    0xb2c(%rip),%rsi
call   1150 <ASN1_bn_print@plt>
cmp    $0x0,%eax
jne    151d <do_EC_KEY_print+0x2ed>
jmp    1577 <do_EC_KEY_print+0x347>
cmpq   $0x0,-0x48(%rbp)
je     1552 <do_EC_KEY_print+0x322>
mov    -0x8(%rbp),%rdi
mov    -0x48(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x14(%rbp),%r8d
lea    0xafd(%rip),%rsi
call   1150 <ASN1_bn_print@plt>
cmp    $0x0,%eax
jne    1552 <do_EC_KEY_print+0x322>
jmp    1577 <do_EC_KEY_print+0x347>
mov    -0x8(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1120 <ECPKParameters_print@plt>
cmp    $0x0,%eax
jne    1570 <do_EC_KEY_print+0x340>
jmp    1577 <do_EC_KEY_print+0x347>
movl   $0x1,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jne    1589 <do_EC_KEY_print+0x359>
mov    -0x40(%rbp),%edi
call   1060 <ECerror@plt>
mov    -0x48(%rbp),%rdi
call   10e0 <BN_free@plt>
mov    -0x50(%rbp),%rdi
call   10e0 <BN_free@plt>
mov    -0x58(%rbp),%rdi
call   10c0 <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     12f9 <do_EC_KEY_print+0xc9>
mov    %ecx,%r14d
mov    %edx,%r13d
mov    %rsi,%rbx
mov    %rdi,%r15
mov    0x2d6e(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
mov    %rsi,%rdi
call   1100 <EC_KEY_get0_group@plt>
test   %rax,%rax
je     12f9 <do_EC_KEY_print+0xc9>
mov    %rax,%rbp
xor    %eax,%eax
call   10f0 <BN_CTX_new@plt>
mov    %rax,0x10(%rsp)
test   %rax,%rax
je     1345 <do_EC_KEY_print+0x115>
test   %r14d,%r14d
mov    %rbp,0x20(%rsp)
jle    134e <do_EC_KEY_print+0x11e>
mov    %rbx,%rdi
call   1080 <EC_KEY_get0_public_key@plt>
test   %rax,%rax
je     1361 <do_EC_KEY_print+0x131>
mov    %rax,%r12
mov    %rbx,%rdi
call   1140 <EC_KEY_get_conv_form@plt>
mov    0x20(%rsp),%rdi
mov    %r12,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
mov    0x10(%rsp),%r8
call   1040 <EC_POINT_point2bn@plt>
test   %rax,%rax
je     1511 <do_EC_KEY_print+0x2e1>
mov    %rax,%rbp
mov    %r15,0x18(%rsp)
mov    %r13d,0xc(%rsp)
mov    %rax,%rdi
call   1130 <BN_num_bytes@plt>
mov    %rax,%r13
mov    %rbp,%r15
cmp    $0x2,%r14d
jne    1398 <do_EC_KEY_print+0x168>
jmp    1377 <do_EC_KEY_print+0x147>
mov    0x2cd0(%rip),%rax
mov    (%rax),%edi
xor    %r12d,%r12d
xor    %ebx,%ebx
xor    %r13d,%r13d
xor    %r15d,%r15d
call   1060 <ECerror@plt>
xor    %ebp,%ebp
mov    %r15,%rdi
call   10e0 <BN_free@plt>
mov    %r13,%rdi
call   10e0 <BN_free@plt>
mov    %rbx,%rdi
call   10c0 <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    0x2c9c(%rip),%rax
jmp    1300 <do_EC_KEY_print+0xd0>
lea    0xcc2(%rip),%r14
xor    %r12d,%r12d
xor    %ebp,%ebp
xor    %ebx,%ebx
jmp    13e4 <do_EC_KEY_print+0x1b4>
mov    %r15,0x18(%rsp)
mov    %r13d,0xc(%rsp)
xor    %r13d,%r13d
xor    %r15d,%r15d
cmp    $0x2,%r14d
jne    1398 <do_EC_KEY_print+0x168>
mov    %rbx,%rdi
call   10a0 <EC_KEY_get0_private_key@plt>
test   %rax,%rax
je     1398 <do_EC_KEY_print+0x168>
mov    %rax,%rbx
mov    %rax,%rdi
call   1130 <BN_num_bytes@plt>
cmp    %r13,%rax
cmova  %rax,%r13
jmp    139a <do_EC_KEY_print+0x16a>
xor    %ebx,%ebx
add    $0xa,%r13
mov    %r13,%rdi
call   1110 <malloc@plt>
test   %rax,%rax
je     14f8 <do_EC_KEY_print+0x2c8>
mov    %rax,%r12
mov    %r15,%rbp
cmp    $0x1,%r14d
lea    0xc4c(%rip),%rax
lea    0xc50(%rip),%rcx
cmove  %rax,%rcx
cmp    $0x2,%r14d
lea    0xc2a(%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     14d6 <do_EC_KEY_print+0x2a6>
mov    %r15,0x18(%rsp)
mov    %r13d,0xc(%rsp)
xor    %eax,%eax
call   1070 <BN_new@plt>
test   %rax,%rax
je     14d6 <do_EC_KEY_print+0x2a6>
mov    %rax,%r13
mov    0x20(%rsp),%rdi
mov    %rax,%rsi
xor    %edx,%edx
call   10d0 <EC_GROUP_get_order@plt>
test   %eax,%eax
mov    %rbp,%r15
je     14ea <do_EC_KEY_print+0x2ba>
mov    %r13,%rdi
call   1090 <BN_num_bits@plt>
lea    0xbe6(%rip),%rsi
mov    0x18(%rsp),%rdi
mov    %r14,%rdx
mov    %eax,%ecx
call   10b0 <BIO_printf@plt>
test   %rax,%rax
jle    14ea <do_EC_KEY_print+0x2ba>
test   %rbx,%rbx
je     147f <do_EC_KEY_print+0x24f>
lea    0xbd0(%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     14ea <do_EC_KEY_print+0x2ba>
test   %r15,%r15
mov    0x10(%rsp),%rbx
je     14ad <do_EC_KEY_print+0x27d>
lea    0xbac(%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     152d <do_EC_KEY_print+0x2fd>
mov    0x18(%rsp),%rdi
mov    0x20(%rsp),%rsi
mov    0xc(%rsp),%edx
call   1120 <ECPKParameters_print@plt>
mov    $0x1,%ebp
test   %eax,%eax
mov    0x8(%rsp),%edi
jne    1314 <do_EC_KEY_print+0xe4>
jmp    130d <do_EC_KEY_print+0xdd>
xor    %r13d,%r13d
mov    0x8(%rsp),%edi
mov    0x10(%rsp),%rbx
mov    %rbp,%r15
jmp    130d <do_EC_KEY_print+0xdd>
mov    0x8(%rsp),%edi
mov    0x10(%rsp),%rbx
jmp    130d <do_EC_KEY_print+0xdd>
mov    0x2ae9(%rip),%rax
mov    (%rax),%edi
xor    %r12d,%r12d
xor    %r13d,%r13d
mov    0x10(%rsp),%rbx
jmp    130d <do_EC_KEY_print+0xdd>
mov    0x2ac8(%rip),%rax
mov    (%rax),%edi
xor    %r12d,%r12d
xor    %r13d,%r13d
xor    %r15d,%r15d
mov    0x10(%rsp),%rbx
jmp    130d <do_EC_KEY_print+0xdd>
mov    0x8(%rsp),%edi
jmp    130d <do_EC_KEY_print+0xdd>

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"
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 %155
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 %155
36: ; preds = %30
%37 = load i32, i32* %8
%38 = icmp sgt i32 %37, 0
br i1 %38, label %39, label %62
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** %19
%43 = icmp ne i32* %42, null
br i1 %43, label %44, label %61
44: ; preds = %39
%45 = load i32*, i32** %18
%46 = load i32*, i32** %19
%47 = load i32*, i32** %6
%48 = call i32 @EC_KEY_get_conv_form(i32* %47)
%49 = load i32*, i32** %17
%50 = call i32* @EC_POINT_point2bn(i32* %45, i32* %46, i32 %48, i32* null, i32* %49)
store i32* %50, i32** %15
%51 = icmp eq i32* %50, null
br i1 %51, label %52, label %54
52: ; preds = %44
%53 = load i32, i32* @ERR_R_EC_LIB
store i32 %53, i32* %14
br label %155
54: ; preds = %44
%55 = load i32*, i32** %15
%56 = icmp ne i32* %55, null
br i1 %56, label %57, label %60
57: ; preds = %54
%58 = load i32*, i32** %15
%59 = call i64 @BN_num_bytes(i32* %58)
store i64 %59, i64* %11
br label %60
60: ; preds = %57, %54
br label %61
61: ; preds = %60, %39
br label %62
62: ; preds = %61, %36
%63 = load i32, i32* %8
%64 = icmp eq i32 %63, 2
br i1 %64, label %65, label %78
65: ; preds = %62
%66 = load i32*, i32** %6
%67 = call i32* @EC_KEY_get0_private_key(i32* %66)
store i32* %67, i32** %20
%68 = load i32*, i32** %20
%69 = icmp ne i32* %68, null
br i1 %69, label %70, label %77
70: ; preds = %65
%71 = load i32*, i32** %20
%72 = call i64 @BN_num_bytes(i32* %71)
store i64 %72, i64* %12
%73 = load i64, i64* %11
%74 = icmp ugt i64 %72, %73
br i1 %74, label %75, label %77
75: ; preds = %70
%76 = load i64, i64* %12
store i64 %76, i64* %11
br label %77
77: ; preds = %75, %70, %65
br label %79
78: ; preds = %62
store i32* null, i32** %20
br label %79
79: ; preds = %78, %77
%80 = load i32, i32* %8
%81 = icmp sgt i32 %80, 0
br i1 %81, label %82, label %91
82: ; preds = %79
%83 = load i64, i64* %11
%84 = add i64 %83, 10
store i64 %84, i64* %11
%85 = load i64, i64* %11
%86 = call i8* @malloc(i64 %85)
store i8* %86, i8** %9
%87 = icmp eq i8* %86, null
br i1 %87, label %88, label %90
88: ; preds = %82
%89 = load i32, i32* @ERR_R_MALLOC_FAILURE
store i32 %89, i32* %14
br label %155
90: ; preds = %82
br label %91
91: ; preds = %90, %79
%92 = load i32, i32* %8
%93 = icmp eq i32 %92, 2
br i1 %93, label %94, label %95
94: ; preds = %91
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %10
br label %101
95: ; preds = %91
%96 = load i32, i32* %8
%97 = icmp eq i32 %96, 1
br i1 %97, label %98, label %99
98: ; preds = %95
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8** %10
br label %100
99: ; preds = %95
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8** %10
br label %100
100: ; preds = %99, %98
br label %101
101: ; preds = %100, %94
%102 = load i32*, i32** %5
%103 = load i32, i32* %7
%104 = call i32 @BIO_indent(i32* %102, i32 %103, i32 128)
%105 = icmp ne i32 %104, 0
br i1 %105, label %107, label %106
106: ; preds = %101
br label %155
107: ; preds = %101
%108 = call i32* (...) @BN_new()
store i32* %108, i32** %16
%109 = icmp eq i32* %108, null
br i1 %109, label %110, label %111
110: ; preds = %107
br label %155
111: ; preds = %107
%112 = load i32*, i32** %18
%113 = load i32*, i32** %16
%114 = call i32 @EC_GROUP_get_order(i32* %112, i32* %113, i32* null)
%115 = icmp ne i32 %114, 0
br i1 %115, label %117, label %116
116: ; preds = %111
br label %155
117: ; preds = %111
%118 = load i32*, i32** %5
%119 = load i8*, i8** %10
%120 = load i32*, i32** %16
%121 = call i32 @BN_num_bits(i32* %120)
%122 = call i64 @BIO_printf(i32* %118, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %119, i32 %121)
%123 = icmp sle i64 %122, 0
br i1 %123, label %124, label %125
124: ; preds = %117
br label %155
125: ; preds = %117
%126 = load i32*, i32** %20
%127 = icmp ne i32* %126, null
br i1 %127, label %128, label %136
128: ; preds = %125
%129 = load i32*, i32** %5
%130 = load i32*, i32** %20
%131 = load i8*, i8** %9
%132 = load i32, i32* %7
%133 = call i32 @ASN1_bn_print(i32* %129, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %130, i8* %131, i32 %132)
%134 = icmp ne i32 %133, 0
br i1 %134, label %136, label %135
135: ; preds = %128
br label %155
136: ; preds = %128, %125
%137 = load i32*, i32** %15
%138 = icmp ne i32* %137, null
br i1 %138, label %139, label %147
139: ; preds = %136
%140 = load i32*, i32** %5
%141 = load i32*, i32** %15
%142 = load i8*, i8** %9
%143 = load i32, i32* %7
%144 = call i32 @ASN1_bn_print(i32* %140, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* %141, i8* %142, i32 %143)
%145 = icmp ne i32 %144, 0
br i1 %145, label %147, label %146
146: ; preds = %139
br label %155
147: ; preds = %139, %136
%148 = load i32*, i32** %5
%149 = load i32*, i32** %18
%150 = load i32, i32* %7
%151 = call i32 @ECPKParameters_print(i32* %148, i32* %149, i32 %150)
%152 = icmp ne i32 %151, 0
br i1 %152, label %154, label %153
153: ; preds = %147
br label %155
154: ; preds = %147
store i32 1, i32* %13
br label %155
155: ; preds = %154, %153, %146, %135, %124, %116, %110, %106, %88, %52, %34, %28
%156 = load i32, i32* %13
%157 = icmp ne i32 %156, 0
br i1 %157, label %161, label %158
158: ; preds = %155
%159 = load i32, i32* %14
%160 = call i32 @ECerror(i32 %159)
br label %161
161: ; preds = %158, %155
%162 = load i32*, i32** %15
%163 = call i32 @BN_free(i32* %162)
%164 = load i32*, i32** %16
%165 = call i32 @BN_free(i32* %164)
%166 = load i32*, i32** %17
%167 = call i32 @BN_CTX_free(i32* %166)
%168 = load i8*, i8** %9
%169 = call i32 @free(i8* %168)
%170 = load i32, i32* %13
ret i32 %170
}

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"
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 %83
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 %83
17: ; preds = %12
%18 = icmp sgt i32 %3, 0
br i1 %18, label %19, label %53
19: ; preds = %17
%20 = tail call i32* @EC_KEY_get0_public_key(i32* %1)
%21 = icmp eq i32* %20, null
br i1 %21, label %30, label %22
22: ; preds = %19
%23 = tail call i32 @EC_KEY_get_conv_form(i32* %1)
%24 = tail call i32* @EC_POINT_point2bn(i32* %8, i32* %20, i32 %23, i32* null, i32* %13)
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = load i32, i32* @ERR_R_EC_LIB
br label %83
28: ; preds = %22
%29 = tail call i64 @BN_num_bytes(i32* %24)
br label %30
30: ; preds = %19, %28
%31 = phi i64 [ %29, %28 ], [ 0, %19 ]
%32 = phi i32* [ %24, %28 ], [ null, %19 ]
%33 = icmp eq i32 %3, 2
br i1 %33, label %34, label %41
34: ; preds = %30
%35 = tail call i32* @EC_KEY_get0_private_key(i32* %1)
%36 = icmp eq i32* %35, null
br i1 %36, label %41, label %37
37: ; preds = %34
%38 = tail call i64 @BN_num_bytes(i32* %35)
%39 = icmp ugt i64 %38, %31
%40 = select i1 %39, i64 %38, i64 %31
br label %41
41: ; preds = %37, %30, %34
%42 = phi i64 [ %31, %30 ], [ %40, %37 ], [ %31, %34 ]
%43 = phi i32* [ null, %30 ], [ %35, %37 ], [ null, %34 ]
%44 = add i64 %42, 10
%45 = tail call i8* @malloc(i64 %44)
%46 = icmp eq i8* %45, null
br i1 %46, label %47, label %49
47: ; preds = %41
%48 = load i32, i32* @ERR_R_MALLOC_FAILURE
br label %83
49: ; preds = %41
%50 = icmp eq i32 %3, 1
%51 = select i1 %50, 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)
%52 = select i1 %33, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %51
br label %53
53: ; preds = %49, %17
%54 = phi i8* [ null, %17 ], [ %45, %49 ]
%55 = phi i32* [ null, %17 ], [ %32, %49 ]
%56 = phi i32* [ null, %17 ], [ %43, %49 ]
%57 = phi i8* [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), %17 ], [ %52, %49 ]
%58 = tail call i32 @BIO_indent(i32* %0, i32 %2, i32 128)
%59 = icmp eq i32 %58, 0
br i1 %59, label %83, label %60
60: ; preds = %53
%61 = tail call i32* (...) @BN_new()
%62 = icmp eq i32* %61, null
br i1 %62, label %83, label %63
63: ; preds = %60
%64 = tail call i32 @EC_GROUP_get_order(i32* %8, i32* %61, i32* null)
%65 = icmp eq i32 %64, 0
br i1 %65, label %83, label %66
66: ; preds = %63
%67 = tail call i32 @BN_num_bits(i32* %61)
%68 = tail call i64 @BIO_printf(i32* %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %57, i32 %67)
%69 = icmp slt i64 %68, 1
br i1 %69, label %83, label %70
70: ; preds = %66
%71 = icmp eq i32* %56, 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.4, i64 0, i64 0), i32* %56, i8* %54, i32 %2)
%74 = icmp eq i32 %73, 0
br i1 %74, label %83, label %75
75: ; preds = %72, %70
%76 = icmp eq i32* %55, null
br i1 %76, label %80, label %77
77: ; preds = %75
%78 = tail call i32 @ASN1_bn_print(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* %55, i8* %54, i32 %2)
%79 = icmp eq i32 %78, 0
br i1 %79, label %83, label %80
80: ; preds = %75, %77
%81 = tail call i32 @ECPKParameters_print(i32* %0, i32* %8, i32 %2)
%82 = icmp eq i32 %81, 0
br i1 %82, label %83, label %90
83: ; preds = %10, %15, %26, %47, %53, %60, %63, %66, %72, %77, %80
%84 = phi i8* [ %54, %80 ], [ null, %10 ], [ null, %15 ], [ null, %26 ], [ null, %47 ], [ %54, %53 ], [ %54, %60 ], [ %54, %63 ], [ %54, %66 ], [ %54, %72 ], [ %54, %77 ]
%85 = phi i32* [ %13, %80 ], [ null, %10 ], [ null, %15 ], [ %13, %26 ], [ %13, %47 ], [ %13, %53 ], [ %13, %60 ], [ %13, %63 ], [ %13, %66 ], [ %13, %72 ], [ %13, %77 ]
%86 = phi i32* [ %61, %80 ], [ null, %10 ], [ null, %15 ], [ null, %26 ], [ null, %47 ], [ null, %53 ], [ null, %60 ], [ %61, %63 ], [ %61, %66 ], [ %61, %72 ], [ %61, %77 ]
%87 = phi i32* [ %55, %80 ], [ null, %10 ], [ null, %15 ], [ null, %26 ], [ %32, %47 ], [ %55, %53 ], [ %55, %60 ], [ %55, %63 ], [ %55, %66 ], [ %55, %72 ], [ %55, %77 ]
%88 = phi i32 [ %5, %80 ], [ %11, %10 ], [ %16, %15 ], [ %27, %26 ], [ %48, %47 ], [ %5, %53 ], [ %5, %60 ], [ %5, %63 ], [ %5, %66 ], [ %5, %72 ], [ %5, %77 ]
%89 = tail call i32 @ECerror(i32 %88)
br label %90
90: ; preds = %83, %80
%91 = phi i8* [ %84, %83 ], [ %54, %80 ]
%92 = phi i32* [ %85, %83 ], [ %13, %80 ]
%93 = phi i32* [ %86, %83 ], [ %61, %80 ]
%94 = phi i32* [ %87, %83 ], [ %55, %80 ]
%95 = phi i32 [ 0, %83 ], [ 1, %80 ]
%96 = tail call i32 @BN_free(i32* %94)
%97 = tail call i32 @BN_free(i32* %93)
%98 = tail call i32 @BN_CTX_free(i32* %92)
%99 = tail call i32 @free(i8* %91)
ret i32 %95
}