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

/* Variables and functions */
int /*<<< orphan*/ *BIO_new_mem_buf(char *, int /*<<< orphan*/);
int /*<<< orphan*/ BIO_vfree(int /*<<< orphan*/ *);
int /*<<< orphan*/ EVP_cleanup();
int /*<<< orphan*/ OpenSSL_add_all_algorithms();
int /*<<< orphan*/ *PEM_read_bio_PrivateKey(int /*<<< orphan*/ *,
                                            int /*<<< orphan*/ *,
                                            int /*<<< orphan*/ *,
                                            int /*<<< orphan*/ *);
int /*<<< orphan*/ strlen(char const *);
EVP_PKEY *parseKey(const char *keyStr) {
  BIO *bio = BIO_new_mem_buf((char *)keyStr, strlen(keyStr));
  OpenSSL_add_all_algorithms();
  EVP_PKEY *key = PEM_read_bio_PrivateKey(bio, NULL, NULL, NULL);
  EVP_cleanup();
  BIO_vfree(bio);
  return key;
}


x86 assembly (clang, -O0):
<parseKey>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%esi
call   1070 <BIO_new_mem_buf@plt>
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1050 <OpenSSL_add_all_algorithms@plt>
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rsi
mov    %rcx,%rdx
call   1080 <PEM_read_bio_PrivateKey@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1060 <EVP_cleanup@plt>
mov    -0x10(%rbp),%rdi
call   1030 <BIO_vfree@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseKey>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1070 <BIO_new_mem_buf@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1050 <OpenSSL_add_all_algorithms@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1080 <PEM_read_bio_PrivateKey@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1060 <EVP_cleanup@plt>
mov    %rbx,%rdi
call   1030 <BIO_vfree@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32* @parseKey(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @strlen(i8* %6)
%8 = call i32* @BIO_new_mem_buf(i8* %5, i32 %7)
store i32* %8, i32** %3
%9 = call i32 (...) @OpenSSL_add_all_algorithms()
%10 = load i32*, i32** %3
%11 = call i32* @PEM_read_bio_PrivateKey(i32* %10, i32* null, i32* null, i32* null)
store i32* %11, i32** %4
%12 = call i32 (...) @EVP_cleanup()
%13 = load i32*, i32** %3
%14 = call i32 @BIO_vfree(i32* %13)
%15 = load i32*, i32** %4
ret i32* %15
}

LLVM IR (-O2):
define i32* @parseKey(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = tail call i32* @BIO_new_mem_buf(i8* %0, i32 %2)
%4 = tail call i32 (...) @OpenSSL_add_all_algorithms()
%5 = tail call i32* @PEM_read_bio_PrivateKey(i32* %3, i32* null, i32* null, i32* null)
%6 = tail call i32 (...) @EVP_cleanup()
%7 = tail call i32 @BIO_vfree(i32* %3)
ret i32* %5
}