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

/* Variables and functions */
int /*<<< orphan*/ *PEM_read_RSAPrivateKey(int /*<<< orphan*/ *,
                                           int /*<<< orphan*/ *,
                                           int /*<<< orphan*/ *,
                                           int /*<<< orphan*/ *);
int /*<<< orphan*/ *RSA_new();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
RSA *RSA_read_privatekey(char *pszSource_file) {
  FILE *pfkey;
  RSA *pRsa;
  if ((pfkey = fopen(pszSource_file, "rb")) == NULL) {
    printf("\nopen file [ %s ] error!\n\n", pszSource_file);
    exit(0);
  }
  pRsa = RSA_new();
  pRsa = PEM_read_RSAPrivateKey(pfkey, NULL, NULL, NULL);
  return pRsa;
}


x86 assembly (clang, -O0):
<RSA_read_privatekey>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe99(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    1191 <RSA_read_privatekey+0x41>
mov    -0x8(%rbp),%rsi
lea    0xe7e(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    $0x0,%al
call   1050 <RSA_new@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rsi
mov    %rcx,%rdx
call   1040 <PEM_read_RSAPrivateKey@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RSA_read_privatekey>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xea2(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1187 <RSA_read_privatekey+0x37>
mov    %rax,%rbx
xor    %eax,%eax
call   1050 <RSA_new@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <PEM_read_RSAPrivateKey@plt>
lea    0xe75(%rip),%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@.str.1 = [27 x i8] c"\0Aopen file [ %s ] error!\0A\0A\00"
define i32* @RSA_read_privatekey(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %6, i32** %3
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = call i32 @exit(i32 0)
unreachable
12: ; preds = %1
%13 = call i32* (...) @RSA_new()
store i32* %13, i32** %4
%14 = load i32*, i32** %3
%15 = call i32* @PEM_read_RSAPrivateKey(i32* %14, i32* null, i32* null, i32* null)
store i32* %15, i32** %4
%16 = load i32*, i32** %4
ret i32* %16
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.1 = [27 x i8] c"\0Aopen file [ %s ] error!\0A\0A\00"
define i32* @RSA_read_privatekey(i8* %0) {
%2 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%6 = tail call i32 @exit(i32 0)
unreachable
7: ; preds = %1
%8 = tail call i32* (...) @RSA_new()
%9 = tail call i32* @PEM_read_RSAPrivateKey(i32* %2, i32* null, i32* null, i32* null)
ret i32* %9
}