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

/* Variables and functions */
int /*<<< orphan*/ *SSL_get_peer_certificate(int /*<<< orphan*/ *);
char *X509_NAME_oneline(int /*<<< orphan*/, int /*<<< orphan*/,
                        int /*<<< orphan*/);
int /*<<< orphan*/ X509_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ X509_get_issuer_name(int /*<<< orphan*/ *);
int /*<<< orphan*/ X509_get_subject_name(int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, ...);
void ShowCerts(SSL *ssl) {
  X509 *cert;
  char *line;
  cert = SSL_get_peer_certificate(ssl);
  if (cert != NULL) {
    printf("__:\n");
    line = X509_NAME_oneline(X509_get_subject_name(cert), 0, 0);
    printf("__: %s\n", line);
    free(line);
    line = X509_NAME_oneline(X509_get_issuer_name(cert), 0, 0);
    printf("__: %s\n", line);
    free(line);
    X509_free(cert);
  } else
    printf("__\n");
}


x86 assembly (clang, -O0):
<ShowCerts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1080 <SSL_get_peer_certificate@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1216 <ShowCerts+0xa6>
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1060 <X509_get_subject_name@plt>
mov    %eax,%edi
xor    %edx,%edx
mov    %edx,%esi
call   1040 <X509_NAME_oneline@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
call   1070 <X509_get_issuer_name@plt>
mov    %eax,%edi
xor    %edx,%edx
mov    %edx,%esi
call   1040 <X509_NAME_oneline@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
call   1090 <X509_free@plt>
jmp    1224 <ShowCerts+0xb4>
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ShowCerts>:
push   %r15
push   %r14
push   %rbx
call   1090 <SSL_get_peer_certificate@plt>
test   %rax,%rax
je     1208 <ShowCerts+0x88>
mov    %rax,%r14
lea    0xe72(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
call   1070 <X509_get_subject_name@plt>
mov    %eax,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <X509_NAME_oneline@plt>
mov    %rax,%rbx
lea    0xe45(%rip),%r15
mov    %r15,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1080 <X509_get_issuer_name@plt>
mov    %eax,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <X509_NAME_oneline@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    10a0 <X509_free@plt>
lea    0xdf9(%rip),%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"__:\0A\00"
@.str.1 = [8 x i8] c"__: %s\0A\00"
@.str.2 = [4 x i8] c"__\0A\00"
define void @ShowCerts(i32* %0) {
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i8*
store i32* %0, i32** %2
%5 = load i32*, i32** %2
%6 = call i32* @SSL_get_peer_certificate(i32* %5)
store i32* %6, i32** %3
%7 = load i32*, i32** %3
%8 = icmp ne i32* %7, null
br i1 %8, label %9, label %27
9: ; preds = %1
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%11 = load i32*, i32** %3
%12 = call i32 @X509_get_subject_name(i32* %11)
%13 = call i8* @X509_NAME_oneline(i32 %12, i32 0, i32 0)
store i8* %13, i8** %4
%14 = load i8*, i8** %4
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = load i8*, i8** %4
%17 = call i32 @free(i8* %16)
%18 = load i32*, i32** %3
%19 = call i32 @X509_get_issuer_name(i32* %18)
%20 = call i8* @X509_NAME_oneline(i32 %19, i32 0, i32 0)
store i8* %20, i8** %4
%21 = load i8*, i8** %4
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %21)
%23 = load i8*, i8** %4
%24 = call i32 @free(i8* %23)
%25 = load i32*, i32** %3
%26 = call i32 @X509_free(i32* %25)
br label %29
27: ; preds = %1
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %29
29: ; preds = %27, %9
ret void
}

LLVM IR (-O2):
@.str.1 = [8 x i8] c"__: %s\0A\00"
@str = [3 x i8] c"__\00"
@str.3 = [4 x i8] c"__:\00"
define void @ShowCerts(i32* %0) {
%2 = tail call i32* @SSL_get_peer_certificate(i32* %0)
%3 = icmp eq i32* %2, null
br i1 %3, label %15, label %4
4: ; preds = %1
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.3, i64 0, i64 0))
%6 = tail call i32 @X509_get_subject_name(i32* %2)
%7 = tail call i8* @X509_NAME_oneline(i32 %6, i32 0, i32 0)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%9 = tail call i32 @free(i8* %7)
%10 = tail call i32 @X509_get_issuer_name(i32* %2)
%11 = tail call i8* @X509_NAME_oneline(i32 %10, i32 0, i32 0)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = tail call i32 @free(i8* %11)
%14 = tail call i32 @X509_free(i32* %2)
br label %17
15: ; preds = %1
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
br label %17
17: ; preds = %15, %4
ret void
}