#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*/ pem_password_cb;
typedef int /*<<< orphan*/ FILE;
typedef int /*<<< orphan*/ EVP_PKEY;
typedef int /*<<< orphan*/ EVP_CIPHER;
typedef int /*<<< orphan*/ BIO;

/* Variables and functions */
int /*<<< orphan*/ BIO_NOCLOSE;
int /*<<< orphan*/ BIO_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *BIO_new_fp(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ ERR_R_BUF_LIB;
int /*<<< orphan*/ PEM_F_DO_PK8PKEY_FP;
int /*<<< orphan*/ PEMerr(int /*<<< orphan*/, int /*<<< orphan*/);
int do_pk8pkey(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int, int,
               int /*<<< orphan*/ const *, char *, int, int /*<<< orphan*/ *,
               void *);
int do_pk8pkey_fp(FILE *fp, EVP_PKEY *x, int isder, int nid,
                  const EVP_CIPHER *enc, char *kstr, int klen,
                  pem_password_cb *cb, void *u) {
  BIO *bp;
  int ret;
  if (!(bp = BIO_new_fp(fp, BIO_NOCLOSE))) {
    PEMerr(PEM_F_DO_PK8PKEY_FP, ERR_R_BUF_LIB);
    return (0);
  }
  ret = do_pk8pkey(bp, x, isder, nid, enc, kstr, klen, cb, u);
  BIO_free(bp);
  return ret;
}


x86 assembly (clang, -O0):
<do_pk8pkey_fp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%eax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e6c(%rip),%rax
mov    (%rax),%esi
call   1030 <BIO_new_fp@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    11ac <do_pk8pkey_fp+0x6c>
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
mov    0x2e5f(%rip),%rax
mov    (%rax),%esi
call   1040 <PEMerr@plt>
movl   $0x0,-0x4(%rbp)
jmp    11f3 <do_pk8pkey_fp+0xb3>
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    -0x28(%rbp),%r8
mov    -0x30(%rbp),%r9
mov    0x10(%rbp),%r11d
mov    0x18(%rbp),%r10
mov    0x20(%rbp),%rax
mov    %r11d,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1050 <do_pk8pkey@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x38(%rbp),%rdi
call   1060 <BIO_free@plt>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_pk8pkey_fp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%r14
mov    %r8,%r15
mov    %ecx,%r12d
mov    %edx,%r13d
mov    %rsi,%rbp
mov    0x2e7f(%rip),%rax
mov    (%rax),%esi
call   1030 <BIO_new_fp@plt>
test   %rax,%rax
je     11aa <do_pk8pkey_fp+0x6a>
mov    %rax,%rbx
mov    0x40(%rsp),%eax
sub    $0x8,%rsp
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r13d,%edx
mov    %r12d,%ecx
mov    %r15,%r8
mov    %r14,%r9
push   0x58(%rsp)
push   0x58(%rsp)
push   %rax
call   1050 <do_pk8pkey@plt>
add    $0x20,%rsp
mov    %eax,%ebp
mov    %rbx,%rdi
call   1060 <BIO_free@plt>
mov    %ebp,%eax
jmp    11c3 <do_pk8pkey_fp+0x83>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
mov    0x2e3e(%rip),%rax
mov    (%rax),%esi
call   1040 <PEMerr@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@BIO_NOCLOSE = global i32 0
@PEM_F_DO_PK8PKEY_FP = global i32 0
@ERR_R_BUF_LIB = global i32 0
define i32 @do_pk8pkey_fp(i32* %0, i32* %1, i32 %2, i32 %3, i32* %4, i8* %5, i32 %6, i32* %7, i8* %8) {
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32*
%16 = alloca i8*
%17 = alloca i32
%18 = alloca i32*
%19 = alloca i8*
%20 = alloca i32*
%21 = alloca i32
store i32* %0, i32** %11
store i32* %1, i32** %12
store i32 %2, i32* %13
store i32 %3, i32* %14
store i32* %4, i32** %15
store i8* %5, i8** %16
store i32 %6, i32* %17
store i32* %7, i32** %18
store i8* %8, i8** %19
%22 = load i32*, i32** %11
%23 = load i32, i32* @BIO_NOCLOSE
%24 = call i32* @BIO_new_fp(i32* %22, i32 %23)
store i32* %24, i32** %20
%25 = icmp ne i32* %24, null
br i1 %25, label %30, label %26
26: ; preds = %9
%27 = load i32, i32* @PEM_F_DO_PK8PKEY_FP
%28 = load i32, i32* @ERR_R_BUF_LIB
%29 = call i32 @PEMerr(i32 %27, i32 %28)
store i32 0, i32* %10
br label %44
30: ; preds = %9
%31 = load i32*, i32** %20
%32 = load i32*, i32** %12
%33 = load i32, i32* %13
%34 = load i32, i32* %14
%35 = load i32*, i32** %15
%36 = load i8*, i8** %16
%37 = load i32, i32* %17
%38 = load i32*, i32** %18
%39 = load i8*, i8** %19
%40 = call i32 @do_pk8pkey(i32* %31, i32* %32, i32 %33, i32 %34, i32* %35, i8* %36, i32 %37, i32* %38, i8* %39)
store i32 %40, i32* %21
%41 = load i32*, i32** %20
%42 = call i32 @BIO_free(i32* %41)
%43 = load i32, i32* %21
store i32 %43, i32* %10
br label %44
44: ; preds = %30, %26
%45 = load i32, i32* %10
ret i32 %45
}

LLVM IR (-O2):
@BIO_NOCLOSE = global i32 0
@PEM_F_DO_PK8PKEY_FP = global i32 0
@ERR_R_BUF_LIB = global i32 0
define i32 @do_pk8pkey_fp(i32* %0, i32* %1, i32 %2, i32 %3, i32* %4, i8* %5, i32 %6, i32* %7, i8* %8) {
%10 = load i32, i32* @BIO_NOCLOSE
%11 = tail call i32* @BIO_new_fp(i32* %0, i32 %10)
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = load i32, i32* @PEM_F_DO_PK8PKEY_FP
%15 = load i32, i32* @ERR_R_BUF_LIB
%16 = tail call i32 @PEMerr(i32 %14, i32 %15)
br label %20
17: ; preds = %9
%18 = tail call i32 @do_pk8pkey(i32* %11, i32* %1, i32 %2, i32 %3, i32* %4, i8* %5, i32 %6, i32* %7, i8* %8)
%19 = tail call i32 @BIO_free(i32* %11)
br label %20
20: ; preds = %17, %13
%21 = phi i32 [ %18, %17 ], [ 0, %13 ]
ret i32 %21
}