#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*/ free(char *);
int /*<<< orphan*/ log_dbg_printf(char *, ...);
int /*<<< orphan*/ log_err_printf(char *);
int ssl_x509_fingerprint_sha1(int /*<<< orphan*/ *, unsigned char *);
char *ssl_x509_names_to_str(int /*<<< orphan*/ *);
char *ssl_x509_subject(int /*<<< orphan*/ *);
void pxy_debug_crt(X509 *crt) {
  char *sj = ssl_x509_subject(crt);
  if (sj) {
    log_dbg_printf("Subject DN: %s\n", sj);
    free(sj);
  }
  char *names = ssl_x509_names_to_str(crt);
  if (names) {
    log_dbg_printf("Common Names: %s\n", names);
    free(names);
  }
  unsigned char fpr[20];
  if (ssl_x509_fingerprint_sha1(crt, fpr) == -1) {
    log_err_printf("Warning: Error generating X509 fingerprint\n");
  } else {
    log_dbg_printf("Fingerprint: "
                   "%02x:%02x:%02x:%02x:"
                   "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:"
                   "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
                   fpr[0], fpr[1], fpr[2], fpr[3], fpr[4], fpr[5], fpr[6],
                   fpr[7], fpr[8], fpr[9], fpr[10], fpr[11], fpr[12], fpr[13],
                   fpr[14], fpr[15], fpr[16], fpr[17], fpr[18], fpr[19]);
  }
}


x86 assembly (clang, -O0):
<pxy_debug_crt>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
mov    %rdi,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1060 <ssl_x509_subject@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     11ab <pxy_debug_crt+0x4b>
mov    -0x38(%rbp),%rsi
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1070 <log_dbg_printf@plt>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
mov    -0x30(%rbp),%rdi
call   1080 <ssl_x509_names_to_str@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     11de <pxy_debug_crt+0x7e>
mov    -0x40(%rbp),%rsi
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1070 <log_dbg_printf@plt>
mov    -0x40(%rbp),%rdi
call   1040 <free@plt>
mov    -0x30(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1030 <ssl_x509_fingerprint_sha1@plt>
cmp    $0xffffffff,%eax
jne    1205 <pxy_debug_crt+0xa5>
lea    0xe27(%rip),%rdi
call   1050 <log_err_printf@plt>
jmp    12d6 <pxy_debug_crt+0x176>
movzbl -0x60(%rbp),%esi
movzbl -0x5f(%rbp),%edx
movzbl -0x5e(%rbp),%ecx
movzbl -0x5d(%rbp),%r8d
movzbl -0x5c(%rbp),%r9d
movzbl -0x5b(%rbp),%eax
movzbl -0x5a(%rbp),%edi
mov    %edi,-0x7c(%rbp)
movzbl -0x59(%rbp),%edi
mov    %edi,-0x78(%rbp)
movzbl -0x58(%rbp),%edi
mov    %edi,-0x74(%rbp)
movzbl -0x57(%rbp),%edi
mov    %edi,-0x70(%rbp)
movzbl -0x56(%rbp),%edi
mov    %edi,-0x6c(%rbp)
movzbl -0x55(%rbp),%edi
mov    %edi,-0x68(%rbp)
movzbl -0x54(%rbp),%r13d
movzbl -0x53(%rbp),%r12d
movzbl -0x52(%rbp),%r15d
movzbl -0x51(%rbp),%r14d
movzbl -0x50(%rbp),%ebx
movzbl -0x4f(%rbp),%r11d
movzbl -0x4e(%rbp),%r10d
movzbl -0x4d(%rbp),%edi
mov    %edi,-0x64(%rbp)
lea    0xdd5(%rip),%rdi
mov    %eax,(%rsp)
mov    -0x7c(%rbp),%eax
mov    %eax,0x8(%rsp)
mov    -0x78(%rbp),%eax
mov    %eax,0x10(%rsp)
mov    -0x74(%rbp),%eax
mov    %eax,0x18(%rsp)
mov    -0x70(%rbp),%eax
mov    %eax,0x20(%rsp)
mov    -0x6c(%rbp),%eax
mov    %eax,0x28(%rsp)
mov    -0x68(%rbp),%eax
mov    %eax,0x30(%rsp)
mov    -0x64(%rbp),%eax
mov    %r13d,0x38(%rsp)
mov    %r12d,0x40(%rsp)
mov    %r15d,0x48(%rsp)
mov    %r14d,0x50(%rsp)
mov    %ebx,0x58(%rsp)
mov    %r11d,0x60(%rsp)
mov    %r10d,0x68(%rsp)
mov    %eax,0x70(%rsp)
mov    $0x0,%al
call   1070 <log_dbg_printf@plt>
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<pxy_debug_crt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rdi,%r14
call   1060 <ssl_x509_subject@plt>
test   %rax,%rax
je     1197 <pxy_debug_crt+0x37>
mov    %rax,%rbx
lea    0xe7b(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <log_dbg_printf@plt>
mov    %rbx,%rdi
call   1040 <free@plt>
mov    %r14,%rdi
call   1080 <ssl_x509_names_to_str@plt>
test   %rax,%rax
je     11c0 <pxy_debug_crt+0x60>
mov    %rax,%rbx
lea    0xe62(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <log_dbg_printf@plt>
mov    %rbx,%rdi
call   1040 <free@plt>
mov    %rsp,%rsi
mov    %r14,%rdi
call   1030 <ssl_x509_fingerprint_sha1@plt>
cmp    $0xffffffff,%eax
je     12b6 <pxy_debug_crt+0x156>
movzbl (%rsp),%esi
movzbl 0x1(%rsp),%edx
movzbl 0x2(%rsp),%ecx
movzbl 0x3(%rsp),%r8d
movzbl 0x4(%rsp),%r9d
movzbl 0x5(%rsp),%eax
mov    %rax,0x50(%rsp)
movzbl 0x6(%rsp),%eax
mov    %rax,0x48(%rsp)
movzbl 0x7(%rsp),%eax
mov    %rax,0x40(%rsp)
movzbl 0x8(%rsp),%eax
mov    %rax,0x38(%rsp)
movzbl 0x9(%rsp),%eax
mov    %rax,0x30(%rsp)
movzbl 0xa(%rsp),%eax
mov    %rax,0x28(%rsp)
movzbl 0xb(%rsp),%eax
mov    %rax,0x20(%rsp)
movzbl 0xc(%rsp),%ebp
movzbl 0xd(%rsp),%r10d
movzbl 0xe(%rsp),%r11d
movzbl 0xf(%rsp),%r14d
movzbl 0x10(%rsp),%r15d
movzbl 0x11(%rsp),%r12d
movzbl 0x12(%rsp),%r13d
movzbl 0x13(%rsp),%ebx
sub    $0x8,%rsp
lea    0xde1(%rip),%rdi
xor    %eax,%eax
push   %rbx
push   %r13
push   %r12
push   %r15
push   %r14
push   %r11
push   %r10
push   %rbp
push   0x68(%rsp)
push   0x78(%rsp)
push   0x88(%rsp)
push   0x98(%rsp)
push   0xa8(%rsp)
push   0xb8(%rsp)
push   0xc8(%rsp)
call   1070 <log_dbg_printf@plt>
add    $0x80,%rsp
jmp    12c2 <pxy_debug_crt+0x162>
lea    0xd65(%rip),%rdi
call   1050 <log_err_printf@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"Subject DN: %s\0A\00"
@.str.1 = [18 x i8] c"Common Names: %s\0A\00"
@.str.2 = [44 x i8] c"Warning: Error generating X509 fingerprint\0A\00"
@.str.3 = [114 x i8] c"Fingerprint: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\0A\00"
define void @pxy_debug_crt(i32* %0) {
%2 = alloca i32*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [20 x i8]
store i32* %0, i32** %2
%6 = load i32*, i32** %2
%7 = call i8* @ssl_x509_subject(i32* %6)
store i8* %7, i8** %3
%8 = load i8*, i8** %3
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %15
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = call i32 (i8*, ...) @log_dbg_printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = load i8*, i8** %3
%14 = call i32 @free(i8* %13)
br label %15
15: ; preds = %10, %1
%16 = load i32*, i32** %2
%17 = call i8* @ssl_x509_names_to_str(i32* %16)
store i8* %17, i8** %4
%18 = load i8*, i8** %4
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %25
20: ; preds = %15
%21 = load i8*, i8** %4
%22 = call i32 (i8*, ...) @log_dbg_printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %21)
%23 = load i8*, i8** %4
%24 = call i32 @free(i8* %23)
br label %25
25: ; preds = %20, %15
%26 = load i32*, i32** %2
%27 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%28 = call i32 @ssl_x509_fingerprint_sha1(i32* %26, i8* %27)
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %32
30: ; preds = %25
%31 = call i32 @log_err_printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0))
br label %94
32: ; preds = %25
%33 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%34 = load i8, i8* %33
%35 = zext i8 %34 to i32
%36 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 1
%37 = load i8, i8* %36
%38 = zext i8 %37 to i32
%39 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 2
%40 = load i8, i8* %39
%41 = zext i8 %40 to i32
%42 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 3
%43 = load i8, i8* %42
%44 = zext i8 %43 to i32
%45 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 4
%46 = load i8, i8* %45
%47 = zext i8 %46 to i32
%48 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 5
%49 = load i8, i8* %48
%50 = zext i8 %49 to i32
%51 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 6
%52 = load i8, i8* %51
%53 = zext i8 %52 to i32
%54 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 7
%55 = load i8, i8* %54
%56 = zext i8 %55 to i32
%57 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 8
%58 = load i8, i8* %57
%59 = zext i8 %58 to i32
%60 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 9
%61 = load i8, i8* %60
%62 = zext i8 %61 to i32
%63 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 10
%64 = load i8, i8* %63
%65 = zext i8 %64 to i32
%66 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 11
%67 = load i8, i8* %66
%68 = zext i8 %67 to i32
%69 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 12
%70 = load i8, i8* %69
%71 = zext i8 %70 to i32
%72 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 13
%73 = load i8, i8* %72
%74 = zext i8 %73 to i32
%75 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 14
%76 = load i8, i8* %75
%77 = zext i8 %76 to i32
%78 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 15
%79 = load i8, i8* %78
%80 = zext i8 %79 to i32
%81 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 16
%82 = load i8, i8* %81
%83 = zext i8 %82 to i32
%84 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 17
%85 = load i8, i8* %84
%86 = zext i8 %85 to i32
%87 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 18
%88 = load i8, i8* %87
%89 = zext i8 %88 to i32
%90 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 19
%91 = load i8, i8* %90
%92 = zext i8 %91 to i32
%93 = call i32 (i8*, ...) @log_dbg_printf(i8* getelementptr inbounds ([114 x i8], [114 x i8]* @.str.3, i64 0, i64 0), i32 %35, i32 %38, i32 %41, i32 %44, i32 %47, i32 %50, i32 %53, i32 %56, i32 %59, i32 %62, i32 %65, i32 %68, i32 %71, i32 %74, i32 %77, i32 %80, i32 %83, i32 %86, i32 %89, i32 %92)
br label %94
94: ; preds = %32, %30
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"Subject DN: %s\0A\00"
@.str.1 = [18 x i8] c"Common Names: %s\0A\00"
@.str.2 = [44 x i8] c"Warning: Error generating X509 fingerprint\0A\00"
@.str.3 = [114 x i8] c"Fingerprint: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\0A\00"
define void @pxy_debug_crt(i32* %0) {
%2 = alloca [20 x i8]
%3 = tail call i8* @ssl_x509_subject(i32* %0)
%4 = icmp eq i8* %3, null
br i1 %4, label %8, label %5
5: ; preds = %1
%6 = tail call i32 (i8*, ...) @log_dbg_printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %3)
%7 = tail call i32 @free(i8* %3)
br label %8
8: ; preds = %5, %1
%9 = tail call i8* @ssl_x509_names_to_str(i32* %0)
%10 = icmp eq i8* %9, null
br i1 %10, label %14, label %11
11: ; preds = %8
%12 = tail call i32 (i8*, ...) @log_dbg_printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%13 = tail call i32 @free(i8* %9)
br label %14
14: ; preds = %11, %8
%15 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%16 = call i32 @ssl_x509_fingerprint_sha1(i32* %0, i8* %15)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 @log_err_printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0))
br label %81
20: ; preds = %14
%21 = load i8, i8* %15
%22 = zext i8 %21 to i32
%23 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 1
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 2
%27 = load i8, i8* %26
%28 = zext i8 %27 to i32
%29 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 3
%30 = load i8, i8* %29
%31 = zext i8 %30 to i32
%32 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 4
%33 = load i8, i8* %32
%34 = zext i8 %33 to i32
%35 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 5
%36 = load i8, i8* %35
%37 = zext i8 %36 to i32
%38 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 6
%39 = load i8, i8* %38
%40 = zext i8 %39 to i32
%41 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 7
%42 = load i8, i8* %41
%43 = zext i8 %42 to i32
%44 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 8
%45 = load i8, i8* %44
%46 = zext i8 %45 to i32
%47 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 9
%48 = load i8, i8* %47
%49 = zext i8 %48 to i32
%50 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 10
%51 = load i8, i8* %50
%52 = zext i8 %51 to i32
%53 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 11
%54 = load i8, i8* %53
%55 = zext i8 %54 to i32
%56 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 12
%57 = load i8, i8* %56
%58 = zext i8 %57 to i32
%59 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 13
%60 = load i8, i8* %59
%61 = zext i8 %60 to i32
%62 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 14
%63 = load i8, i8* %62
%64 = zext i8 %63 to i32
%65 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 15
%66 = load i8, i8* %65
%67 = zext i8 %66 to i32
%68 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 16
%69 = load i8, i8* %68
%70 = zext i8 %69 to i32
%71 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 17
%72 = load i8, i8* %71
%73 = zext i8 %72 to i32
%74 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 18
%75 = load i8, i8* %74
%76 = zext i8 %75 to i32
%77 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 19
%78 = load i8, i8* %77
%79 = zext i8 %78 to i32
%80 = call i32 (i8*, ...) @log_dbg_printf(i8* getelementptr inbounds ([114 x i8], [114 x i8]* @.str.3, i64 0, i64 0), i32 %22, i32 %25, i32 %28, i32 %31, i32 %34, i32 %37, i32 %40, i32 %43, i32 %46, i32 %49, i32 %52, i32 %55, i32 %58, i32 %61, i32 %64, i32 %67, i32 %70, i32 %73, i32 %76, i32 %79)
br label %81
81: ; preds = %20, %18
ret void
}