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

/* Variables and functions */
int /*<<< orphan*/ BIO_NOCLOSE;
int /*<<< orphan*/ BIO_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *BIO_new(int /*<<< orphan*/);
int /*<<< orphan*/ BIO_s_file();
int /*<<< orphan*/ BIO_set_fp(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                              int /*<<< orphan*/);
int BN_print(int /*<<< orphan*/ *, int /*<<< orphan*/ const *);
int BN_print_fp(FILE *fp, const BIGNUM *a) {
  BIO *b;
  int ret;
  if ((b = BIO_new(BIO_s_file())) == NULL)
    return (0);
  BIO_set_fp(b, fp, BIO_NOCLOSE);
  ret = BN_print(b, a);
  BIO_free(b);
  return (ret);
}


x86 assembly (clang, -O0):
<BN_print_fp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    $0x0,%al
call   1070 <BIO_s_file@plt>
mov    %eax,%edi
call   1040 <BIO_new@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1188 <BN_print_fp+0x38>
movl   $0x0,-0x4(%rbp)
jmp    11bd <BN_print_fp+0x6d>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    0x2e51(%rip),%rax
mov    (%rax),%edx
call   1060 <BIO_set_fp@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <BN_print@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <BIO_free@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BN_print_fp>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
xor    %eax,%eax
call   1070 <BIO_s_file@plt>
mov    %eax,%edi
call   1040 <BIO_new@plt>
test   %rax,%rax
je     11a0 <BN_print_fp+0x50>
mov    %rax,%rbx
mov    0x2e6e(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <BIO_set_fp@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <BN_print@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1050 <BIO_free@plt>
mov    %ebp,%eax
jmp    11a2 <BN_print_fp+0x52>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@BIO_NOCLOSE = global i32 0
define i32 @BN_print_fp(i32* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
%8 = call i32 (...) @BIO_s_file()
%9 = call i32* @BIO_new(i32 %8)
store i32* %9, i32** %6
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 0, i32* %3
br label %23
12: ; preds = %2
%13 = load i32*, i32** %6
%14 = load i32*, i32** %4
%15 = load i32, i32* @BIO_NOCLOSE
%16 = call i32 @BIO_set_fp(i32* %13, i32* %14, i32 %15)
%17 = load i32*, i32** %6
%18 = load i32*, i32** %5
%19 = call i32 @BN_print(i32* %17, i32* %18)
store i32 %19, i32* %7
%20 = load i32*, i32** %6
%21 = call i32 @BIO_free(i32* %20)
%22 = load i32, i32* %7
store i32 %22, i32* %3
br label %23
23: ; preds = %12, %11
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
@BIO_NOCLOSE = global i32 0
define i32 @BN_print_fp(i32* %0, i32* %1) {
%3 = tail call i32 (...) @BIO_s_file()
%4 = tail call i32* @BIO_new(i32 %3)
%5 = icmp eq i32* %4, null
br i1 %5, label %11, label %6
6: ; preds = %2
%7 = load i32, i32* @BIO_NOCLOSE
%8 = tail call i32 @BIO_set_fp(i32* %4, i32* %0, i32 %7)
%9 = tail call i32 @BN_print(i32* %4, i32* %1)
%10 = tail call i32 @BIO_free(i32* %4)
br label %11
11: ; preds = %2, %6
%12 = phi i32 [ %9, %6 ], [ 0, %2 ]
ret i32 %12
}