#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;

/* Variables and functions */
int /*<<< orphan*/ X509_NAME_oneline(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ X509_get_issuer_name(int /*<<< orphan*/ *);
int /*<<< orphan*/ X509_get_subject_name(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
void print_certificate(X509 *cert) {
  char subj[1024 + 1];
  char issuer[1024 + 1];
  X509_NAME_oneline(X509_get_subject_name(cert), subj, 1024);
  X509_NAME_oneline(X509_get_issuer_name(cert), issuer, 1024);
  printf("certificate: %s\n", subj);
  printf("\tissuer: %s\n\n", issuer);
}


x86 assembly (clang, -O0):
<print_certificate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <X509_get_subject_name@plt>
mov    %eax,%edi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
call   1030 <X509_NAME_oneline@plt>
mov    -0x8(%rbp),%rdi
call   1060 <X509_get_issuer_name@plt>
mov    %eax,%edi
lea    -0x820(%rbp),%rsi
mov    $0x400,%edx
call   1030 <X509_NAME_oneline@plt>
lea    -0x410(%rbp),%rsi
lea    0xe6b(%rip),%rdi
call   1040 <printf@plt>
lea    -0x820(%rbp),%rsi
lea    0xe69(%rip),%rdi
call   1040 <printf@plt>
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_certificate>:
push   %r14
push   %rbx
sub    $0x818,%rsp
mov    %rdi,%rbx
call   1050 <X509_get_subject_name@plt>
lea    0x410(%rsp),%r14
mov    %eax,%edi
mov    %r14,%rsi
mov    $0x400,%edx
call   1030 <X509_NAME_oneline@plt>
mov    %rbx,%rdi
call   1060 <X509_get_issuer_name@plt>
mov    %rsp,%rbx
mov    %eax,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
call   1030 <X509_NAME_oneline@plt>
lea    0xe76(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
lea    0xe78(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
add    $0x818,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [17 x i8] c"certificate: %s\0A\00"
@.str.1 = [14 x i8] c"\09issuer: %s\0A\0A\00"
define void @print_certificate(i32* %0) {
%2 = alloca i32*
%3 = alloca [1025 x i8]
%4 = alloca [1025 x i8]
store i32* %0, i32** %2
%5 = load i32*, i32** %2
%6 = call i32 @X509_get_subject_name(i32* %5)
%7 = getelementptr inbounds [1025 x i8], [1025 x i8]* %3, i64 0, i64 0
%8 = call i32 @X509_NAME_oneline(i32 %6, i8* %7, i32 1024)
%9 = load i32*, i32** %2
%10 = call i32 @X509_get_issuer_name(i32* %9)
%11 = getelementptr inbounds [1025 x i8], [1025 x i8]* %4, i64 0, i64 0
%12 = call i32 @X509_NAME_oneline(i32 %10, i8* %11, i32 1024)
%13 = getelementptr inbounds [1025 x i8], [1025 x i8]* %3, i64 0, i64 0
%14 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = getelementptr inbounds [1025 x i8], [1025 x i8]* %4, i64 0, i64 0
%16 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %15)
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"certificate: %s\0A\00"
@.str.1 = [14 x i8] c"\09issuer: %s\0A\0A\00"
define void @print_certificate(i32* %0) {
%2 = alloca [1025 x i8]
%3 = alloca [1025 x i8]
%4 = getelementptr inbounds [1025 x i8], [1025 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [1025 x i8], [1025 x i8]* %3, i64 0, i64 0
%6 = tail call i32 @X509_get_subject_name(i32* %0)
%7 = call i32 @X509_NAME_oneline(i32 %6, i8* %4, i32 1024)
%8 = call i32 @X509_get_issuer_name(i32* %0)
%9 = call i32 @X509_NAME_oneline(i32 %8, i8* %5, i32 1024)
%10 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %4)
%11 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %5)
ret void
}