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

/* 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 /*<<< orphan*/ EC_F_EC_KEY_PRINT_FP;
int EC_KEY_print(int /*<<< orphan*/ *, int /*<<< orphan*/ const *, int);
int /*<<< orphan*/ ECerr(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ ERR_R_BIO_LIB;
int EC_KEY_print_fp(FILE *fp, const EC_KEY *x, int off) {
  BIO *b;
  int ret;
  if ((b = BIO_new(BIO_s_file())) == NULL) {
    ECerr(EC_F_EC_KEY_PRINT_FP, ERR_R_BIO_LIB);
    return (0);
  }
  BIO_set_fp(b, fp, BIO_NOCLOSE);
  ret = EC_KEY_print(b, x, off);
  BIO_free(b);
  return (ret);
}


x86 assembly (clang, -O0):
<EC_KEY_print_fp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    $0x0,%al
call   1080 <BIO_s_file@plt>
mov    %eax,%edi
call   1030 <BIO_new@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    11b2 <EC_KEY_print_fp+0x52>
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
mov    0x2e31(%rip),%rax
mov    (%rax),%esi
call   1050 <ECerr@plt>
movl   $0x0,-0x4(%rbp)
jmp    11ea <EC_KEY_print_fp+0x8a>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    0x2e27(%rip),%rax
mov    (%rax),%edx
call   1060 <BIO_set_fp@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1070 <EC_KEY_print@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <BIO_free@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<EC_KEY_print_fp>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%rbp
xor    %eax,%eax
call   1080 <BIO_s_file@plt>
mov    %eax,%edi
call   1030 <BIO_new@plt>
test   %rax,%rax
je     11b6 <EC_KEY_print_fp+0x56>
mov    %rax,%rbx
mov    0x2e5b(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1060 <BIO_set_fp@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14d,%edx
call   1070 <EC_KEY_print@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <BIO_free@plt>
mov    %ebp,%eax
jmp    11cf <EC_KEY_print_fp+0x6f>
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
mov    0x2e0a(%rip),%rax
mov    (%rax),%esi
call   1050 <ECerr@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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