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

/* Variables and functions */
int /*<<< orphan*/ BN_bn2bin(int /*<<< orphan*/ *, unsigned char *);
int BN_num_bytes(int /*<<< orphan*/ *);
int /*<<< orphan*/ free(unsigned char *);
unsigned char *malloc(int);
int /*<<< orphan*/ print_buffer(char *, unsigned char *, int);
void pp_a_bignum(char *str, BIGNUM *bn) {
  unsigned char *buf;
  int len;
  len = BN_num_bytes(bn);
  if ((buf = malloc(len)) == NULL) {
    return;
  }
  BN_bn2bin(bn, buf);
  print_buffer(str, buf, len);
  free(buf);
}


x86 assembly (clang, -O0):
<pp_a_bignum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <BN_num_bytes@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1187 <pp_a_bignum+0x37>
jmp    11ad <pp_a_bignum+0x5d>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <BN_bn2bin@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1070 <print_buffer@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pp_a_bignum>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1050 <BN_num_bytes@plt>
mov    %eax,%r15d
mov    %eax,%edi
call   1040 <malloc@plt>
test   %rax,%rax
je     11a2 <pp_a_bignum+0x52>
mov    %rax,%rbp
mov    %rbx,%rdi
mov    %rax,%rsi
call   1060 <BN_bn2bin@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
mov    %r15d,%edx
call   1070 <print_buffer@plt>
mov    %rbp,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @pp_a_bignum(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %3
store i32* %1, i32** %4
%7 = load i32*, i32** %4
%8 = call i32 @BN_num_bytes(i32* %7)
store i32 %8, i32* %6
%9 = load i32, i32* %6
%10 = call i8* @malloc(i32 %9)
store i8* %10, i8** %5
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %13
12: ; preds = %2
br label %23
13: ; preds = %2
%14 = load i32*, i32** %4
%15 = load i8*, i8** %5
%16 = call i32 @BN_bn2bin(i32* %14, i8* %15)
%17 = load i8*, i8** %3
%18 = load i8*, i8** %5
%19 = load i32, i32* %6
%20 = call i32 @print_buffer(i8* %17, i8* %18, i32 %19)
%21 = load i8*, i8** %5
%22 = call i32 @free(i8* %21)
br label %23
23: ; preds = %13, %12
ret void
}

LLVM IR (-O2):
define void @pp_a_bignum(i8* %0, i32* %1) {
%3 = tail call i32 @BN_num_bytes(i32* %1)
%4 = tail call i8* @malloc(i32 %3)
%5 = icmp eq i8* %4, null
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = tail call i32 @BN_bn2bin(i32* %1, i8* %4)
%8 = tail call i32 @print_buffer(i8* %0, i8* %4, i32 %3)
%9 = tail call i32 @free(i8* %4)
br label %10
10: ; preds = %2, %6
ret void
}