#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*/ FILE;
typedef int /*<<< orphan*/ BIGNUM;

/* Variables and functions */
char *BN_bn2hex(int /*<<< orphan*/ const *);
int /*<<< orphan*/ OPENSSL_free(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
void fdumpbn(FILE *fp, const BIGNUM *bn) {
  char *buf;
  buf = BN_bn2hex(bn);
  fprintf(fp, "%s\n", buf ? buf : "0");
  if (buf)
    OPENSSL_free(buf);
}


x86 assembly (clang, -O0):
<fdumpbn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <BN_bn2hex@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     116d <fdumpbn+0x3d>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    117d <fdumpbn+0x4d>
lea    0xe90(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    117d <fdumpbn+0x4d>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xe74(%rip),%rsi
call   1030 <fprintf@plt>
cmpq   $0x0,-0x18(%rbp)
je     11a5 <fdumpbn+0x75>
mov    -0x18(%rbp),%rdi
call   1050 <OPENSSL_free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fdumpbn>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    %rsi,%rdi
call   1040 <BN_bn2hex@plt>
mov    %rax,%rbx
test   %rax,%rax
lea    0xeb8(%rip),%rdx
cmovne %rax,%rdx
lea    0xea9(%rip),%rsi
mov    %r14,%rdi
call   1030 <fprintf@plt>
test   %rbx,%rbx
je     1173 <fdumpbn+0x43>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <OPENSSL_free@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [2 x i8] c"0\00"
define void @fdumpbn(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i8*
store i32* %0, i32** %3
store i32* %1, i32** %4
%6 = load i32*, i32** %4
%7 = call i8* @BN_bn2hex(i32* %6)
store i8* %7, i8** %5
%8 = load i32*, i32** %3
%9 = load i8*, i8** %5
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = load i8*, i8** %5
br label %14
13: ; preds = %2
br label %14
14: ; preds = %13, %11
%15 = phi i8* [ %12, %11 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), %13 ]
%16 = call i32 @fprintf(i32* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = load i8*, i8** %5
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %22
19: ; preds = %14
%20 = load i8*, i8** %5
%21 = call i32 @OPENSSL_free(i8* %20)
br label %22
22: ; preds = %19, %14
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [2 x i8] c"0\00"
define void @fdumpbn(i32* nocapture %0, i32* %1) {
%3 = tail call i8* @BN_bn2hex(i32* %1)
%4 = icmp eq i8* %3, null
%5 = select i1 %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %3
%6 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %5)
br i1 %4, label %9, label %7
7: ; preds = %2
%8 = tail call i32 @OPENSSL_free(i8* %3)
br label %9
9: ; preds = %7, %2
ret void
}