#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*/ BIO;

/* Variables and functions */
int /*<<< orphan*/ BIO_puts(int /*<<< orphan*/ *, char *);
char *X509_NAME_oneline(int /*<<< orphan*/, int /*<<< orphan*/ *,
                        int /*<<< orphan*/);
int /*<<< orphan*/ X509_get_issuer_name(int /*<<< orphan*/ *);
int /*<<< orphan*/ X509_get_subject_name(int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int dump_cert_text(BIO *out, X509 *x) {
  char *p;
  p = X509_NAME_oneline(X509_get_subject_name(x), NULL, 0);
  BIO_puts(out, "subject=");
  BIO_puts(out, p);
  free(p);
  p = X509_NAME_oneline(X509_get_issuer_name(x), NULL, 0);
  BIO_puts(out, "\nissuer=");
  BIO_puts(out, p);
  BIO_puts(out, "\n");
  free(p);
  return 0;
}


x86 assembly (clang, -O0):
<dump_cert_text>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <X509_get_subject_name@plt>
mov    %eax,%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1040 <X509_NAME_oneline@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe7b(%rip),%rsi
call   1070 <BIO_puts@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <BIO_puts@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
call   1060 <X509_get_issuer_name@plt>
mov    %eax,%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1040 <X509_NAME_oneline@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe44(%rip),%rsi
call   1070 <BIO_puts@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <BIO_puts@plt>
mov    -0x8(%rbp),%rdi
lea    0xe30(%rip),%rsi
call   1070 <BIO_puts@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_cert_text>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rsi,%rdi
call   1050 <X509_get_subject_name@plt>
mov    %eax,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1040 <X509_NAME_oneline@plt>
mov    %rax,%rbx
lea    0xe88(%rip),%rsi
mov    %r15,%rdi
call   1070 <BIO_puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <BIO_puts@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1060 <X509_get_issuer_name@plt>
mov    %eax,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1040 <X509_NAME_oneline@plt>
mov    %rax,%rbx
lea    0xe59(%rip),%rsi
mov    %r15,%rdi
call   1070 <BIO_puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <BIO_puts@plt>
lea    0xe48(%rip),%rsi
mov    %r15,%rdi
call   1070 <BIO_puts@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [9 x i8] c"subject=\00"
@.str.1 = [9 x i8] c"\0Aissuer=\00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @dump_cert_text(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i8*
store i32* %0, i32** %3
store i32* %1, i32** %4
%6 = load i32*, i32** %4
%7 = call i32 @X509_get_subject_name(i32* %6)
%8 = call i8* @X509_NAME_oneline(i32 %7, i32* null, i32 0)
store i8* %8, i8** %5
%9 = load i32*, i32** %3
%10 = call i32 @BIO_puts(i32* %9, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%11 = load i32*, i32** %3
%12 = load i8*, i8** %5
%13 = call i32 @BIO_puts(i32* %11, i8* %12)
%14 = load i8*, i8** %5
%15 = call i32 @free(i8* %14)
%16 = load i32*, i32** %4
%17 = call i32 @X509_get_issuer_name(i32* %16)
%18 = call i8* @X509_NAME_oneline(i32 %17, i32* null, i32 0)
store i8* %18, i8** %5
%19 = load i32*, i32** %3
%20 = call i32 @BIO_puts(i32* %19, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%21 = load i32*, i32** %3
%22 = load i8*, i8** %5
%23 = call i32 @BIO_puts(i32* %21, i8* %22)
%24 = load i32*, i32** %3
%25 = call i32 @BIO_puts(i32* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%26 = load i8*, i8** %5
%27 = call i32 @free(i8* %26)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"subject=\00"
@.str.1 = [9 x i8] c"\0Aissuer=\00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @dump_cert_text(i32* %0, i32* %1) {
%3 = tail call i32 @X509_get_subject_name(i32* %1)
%4 = tail call i8* @X509_NAME_oneline(i32 %3, i32* null, i32 0)
%5 = tail call i32 @BIO_puts(i32* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @BIO_puts(i32* %0, i8* %4)
%7 = tail call i32 @free(i8* %4)
%8 = tail call i32 @X509_get_issuer_name(i32* %1)
%9 = tail call i8* @X509_NAME_oneline(i32 %8, i32* null, i32 0)
%10 = tail call i32 @BIO_puts(i32* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%11 = tail call i32 @BIO_puts(i32* %0, i8* %9)
%12 = tail call i32 @BIO_puts(i32* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%13 = tail call i32 @free(i8* %9)
ret i32 0
}