#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*/ 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*/ ERR_R_BUF_LIB;
int /*<<< orphan*/ PEM_F_PEM_READ_PRIVATEKEY;
int /*<<< orphan*/ *PEM_read_bio_PrivateKey(int /*<<< orphan*/ *,
                                            int /*<<< orphan*/ **,
                                            int /*<<< orphan*/ *, void *);
int /*<<< orphan*/ PEMerr(int /*<<< orphan*/, int /*<<< orphan*/);
EVP_PKEY *PEM_read_PrivateKey(FILE *fp, EVP_PKEY **x, pem_password_cb *cb,
                              void *u) {
  BIO *b;
  EVP_PKEY *ret;
  if ((b = BIO_new(BIO_s_file())) == NULL) {
    PEMerr(PEM_F_PEM_READ_PRIVATEKEY, ERR_R_BUF_LIB);
    return (0);
  }
  BIO_set_fp(b, fp, BIO_NOCLOSE);
  ret = PEM_read_bio_PrivateKey(b, x, cb, u);
  BIO_free(b);
  return (ret);
}


x86 assembly (clang, -O0):
<PEM_read_PrivateKey>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    $0x0,%al
call   1080 <BIO_s_file@plt>
mov    %eax,%edi
call   1040 <BIO_new@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    11b8 <PEM_read_PrivateKey+0x58>
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
mov    0x2e54(%rip),%rax
mov    (%rax),%esi
call   1030 <PEMerr@plt>
movq   $0x0,-0x8(%rbp)
jmp    11f8 <PEM_read_PrivateKey+0x98>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    0x2e11(%rip),%rax
mov    (%rax),%edx
call   1060 <BIO_set_fp@plt>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1070 <PEM_read_bio_PrivateKey@plt>
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
call   1050 <BIO_free@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PEM_read_PrivateKey>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r13
xor    %eax,%eax
call   1080 <BIO_s_file@plt>
mov    %eax,%edi
call   1040 <BIO_new@plt>
test   %rax,%rax
je     11c0 <PEM_read_PrivateKey+0x60>
mov    %rax,%rbx
mov    0x2e46(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    %r13,%rsi
call   1060 <BIO_set_fp@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   1070 <PEM_read_bio_PrivateKey@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1050 <BIO_free@plt>
mov    %r14,%rax
jmp    11d9 <PEM_read_PrivateKey+0x79>
mov    0x2e21(%rip),%rax
mov    (%rax),%edi
mov    0x2e28(%rip),%rax
mov    (%rax),%esi
call   1030 <PEMerr@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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