#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*/ X509;
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_fp(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ CRYPTO_MEM_CHECK_ON;
int /*<<< orphan*/ CRYPTO_mem_ctrl(int /*<<< orphan*/);
int /*<<< orphan*/ CRYPTO_mem_leaks(int /*<<< orphan*/ *);
int /*<<< orphan*/ EVP_PKEY_free(int /*<<< orphan*/ *);
int /*<<< orphan*/
PEM_write_PrivateKey(int /*<<< orphan*/, int /*<<< orphan*/ *,
                     int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                     int /*<<< orphan*/, int /*<<< orphan*/ *,
                     int /*<<< orphan*/ *);
int /*<<< orphan*/ PEM_write_X509(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ X509_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ mkit(int /*<<< orphan*/ **, int /*<<< orphan*/ **, int,
                        int /*<<< orphan*/, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main() {
  BIO *bio_err;
  X509 *x509 = NULL;
  EVP_PKEY *pkey = NULL;
  CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
  bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
  mkit(&x509, &pkey, 512, 0, 365);
  PEM_write_PrivateKey(stdout, pkey, NULL, NULL, 0, NULL, NULL);
  PEM_write_X509(stdout, x509);
  X509_free(x509);
  EVP_PKEY_free(pkey);
  CRYPTO_mem_leaks(bio_err);
  BIO_free(bio_err);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
call   10a0 <CRYPTO_mem_ctrl@plt>
mov    0x2e0c(%rip),%rax
mov    (%rax),%edi
mov    0x2e13(%rip),%rax
mov    (%rax),%esi
call   1030 <BIO_new_fp@plt>
mov    %rax,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x200,%edx
xor    %ecx,%ecx
mov    $0x16d,%r8d
call   1050 <mkit@plt>
mov    0x2dcf(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%r9d
xor    %r8d,%r8d
mov    %r9,%rdx
mov    %r9,%rcx
movq   $0x0,(%rsp)
call   1090 <PEM_write_PrivateKey@plt>
mov    0x2da7(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
call   1060 <PEM_write_X509@plt>
mov    -0x18(%rbp),%rdi
call   1080 <X509_free@plt>
mov    -0x20(%rbp),%rdi
call   1040 <EVP_PKEY_free@plt>
mov    -0x10(%rbp),%rdi
call   10b0 <CRYPTO_mem_leaks@plt>
mov    -0x10(%rbp),%rdi
call   1070 <BIO_free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movq   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
mov    0x2e48(%rip),%rax
mov    (%rax),%edi
call   10a0 <CRYPTO_mem_ctrl@plt>
mov    0x2e12(%rip),%rax
mov    (%rax),%edi
mov    0x2e19(%rip),%rax
mov    (%rax),%esi
call   1030 <BIO_new_fp@plt>
mov    %rax,%rbx
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
mov    $0x200,%edx
xor    %ecx,%ecx
mov    $0x16d,%r8d
call   1050 <mkit@plt>
mov    0x2dd4(%rip),%r14
mov    (%r14),%edi
mov    0x8(%rsp),%rsi
movq   $0x0,(%rsp)
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1090 <PEM_write_PrivateKey@plt>
mov    (%r14),%edi
mov    0x10(%rsp),%rsi
call   1060 <PEM_write_X509@plt>
mov    0x10(%rsp),%rdi
call   1080 <X509_free@plt>
mov    0x8(%rsp),%rdi
call   1040 <EVP_PKEY_free@plt>
mov    %rbx,%rdi
call   10b0 <CRYPTO_mem_leaks@plt>
mov    %rbx,%rdi
call   1070 <BIO_free@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@CRYPTO_MEM_CHECK_ON = global i32 0
@stderr = global i32 0
@BIO_NOCLOSE = global i32 0
@stdout = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32*
store i32 0, i32* %1
store i32* null, i32** %3
store i32* null, i32** %4
%5 = load i32, i32* @CRYPTO_MEM_CHECK_ON
%6 = call i32 @CRYPTO_mem_ctrl(i32 %5)
%7 = load i32, i32* @stderr
%8 = load i32, i32* @BIO_NOCLOSE
%9 = call i32* @BIO_new_fp(i32 %7, i32 %8)
store i32* %9, i32** %2
%10 = call i32 @mkit(i32** %3, i32** %4, i32 512, i32 0, i32 365)
%11 = load i32, i32* @stdout
%12 = load i32*, i32** %4
%13 = call i32 @PEM_write_PrivateKey(i32 %11, i32* %12, i32* null, i32* null, i32 0, i32* null, i32* null)
%14 = load i32, i32* @stdout
%15 = load i32*, i32** %3
%16 = call i32 @PEM_write_X509(i32 %14, i32* %15)
%17 = load i32*, i32** %3
%18 = call i32 @X509_free(i32* %17)
%19 = load i32*, i32** %4
%20 = call i32 @EVP_PKEY_free(i32* %19)
%21 = load i32*, i32** %2
%22 = call i32 @CRYPTO_mem_leaks(i32* %21)
%23 = load i32*, i32** %2
%24 = call i32 @BIO_free(i32* %23)
ret i32 0
}

LLVM IR (-O2):
@CRYPTO_MEM_CHECK_ON = global i32 0
@stderr = global i32 0
@BIO_NOCLOSE = global i32 0
@stdout = global i32 0
define i32 @main() {
%1 = alloca i32*
%2 = alloca i32*
%3 = bitcast i32** %1 to i8*
store i32* null, i32** %1
%4 = bitcast i32** %2 to i8*
store i32* null, i32** %2
%5 = load i32, i32* @CRYPTO_MEM_CHECK_ON
%6 = tail call i32 @CRYPTO_mem_ctrl(i32 %5)
%7 = load i32, i32* @stderr
%8 = load i32, i32* @BIO_NOCLOSE
%9 = tail call i32* @BIO_new_fp(i32 %7, i32 %8)
%10 = call i32 @mkit(i32** %1, i32** %2, i32 512, i32 0, i32 365)
%11 = load i32, i32* @stdout
%12 = load i32*, i32** %2
%13 = call i32 @PEM_write_PrivateKey(i32 %11, i32* %12, i32* null, i32* null, i32 0, i32* null, i32* null)
%14 = load i32, i32* @stdout
%15 = load i32*, i32** %1
%16 = call i32 @PEM_write_X509(i32 %14, i32* %15)
%17 = load i32*, i32** %1
%18 = call i32 @X509_free(i32* %17)
%19 = load i32*, i32** %2
%20 = call i32 @EVP_PKEY_free(i32* %19)
%21 = call i32 @CRYPTO_mem_leaks(i32* %9)
%22 = call i32 @BIO_free(i32* %9)
ret i32 0
}