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

/* Variables and functions */
char *ERR_error_string(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ ERR_get_error();
int /*<<< orphan*/ ERR_print_errors_fp(int /*<<< orphan*/);
char *ERR_reason_error_string(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char const *, ...);
int /*<<< orphan*/ stderr;
void printSSLErr(const char *msg) {
  fprintf(stderr, msg);
  fprintf(stderr, "Error: %s\n", ERR_reason_error_string(ERR_get_error()));
  fprintf(stderr, "%s\n", ERR_error_string(ERR_get_error(), NULL));
  ERR_print_errors_fp(stderr);
}


x86 assembly (clang, -O0):
<printSSLErr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e7d(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e69(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1060 <ERR_get_error@plt>
mov    %eax,%edi
call   1030 <ERR_reason_error_string@plt>
mov    -0x10(%rbp),%edi
mov    %rax,%rdx
lea    0xe69(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e3b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1060 <ERR_get_error@plt>
mov    %eax,%edi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <ERR_error_string@plt>
mov    -0xc(%rbp),%edi
mov    %rax,%rdx
lea    0xe3e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
call   1070 <ERR_print_errors_fp@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printSSLErr>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rsi
mov    0x2e82(%rip),%r14
mov    (%r14),%edi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r14),%ebx
xor    %eax,%eax
call   1060 <ERR_get_error@plt>
mov    %eax,%edi
call   1030 <ERR_reason_error_string@plt>
lea    0xe80(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r14),%ebx
xor    %eax,%eax
call   1060 <ERR_get_error@plt>
mov    %eax,%edi
xor    %esi,%esi
call   1050 <ERR_error_string@plt>
lea    0xe61(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r14),%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1070 <ERR_print_errors_fp@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [11 x i8] c"Error: %s\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define void @printSSLErr(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i32, i32* @stderr
%4 = load i8*, i8** %2
%5 = call i32 (i32, i8*, ...) @fprintf(i32 %3, i8* %4)
%6 = load i32, i32* @stderr
%7 = call i32 (...) @ERR_get_error()
%8 = call i8* @ERR_reason_error_string(i32 %7)
%9 = call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i32, i32* @stderr
%11 = call i32 (...) @ERR_get_error()
%12 = call i8* @ERR_error_string(i32 %11, i32* null)
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = load i32, i32* @stderr
%15 = call i32 @ERR_print_errors_fp(i32 %14)
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [11 x i8] c"Error: %s\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define void @printSSLErr(i8* %0) {
%2 = load i32, i32* @stderr
%3 = tail call i32 (i32, i8*, ...) @fprintf(i32 %2, i8* %0)
%4 = load i32, i32* @stderr
%5 = tail call i32 (...) @ERR_get_error()
%6 = tail call i8* @ERR_reason_error_string(i32 %5)
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i32, i32* @stderr
%9 = tail call i32 (...) @ERR_get_error()
%10 = tail call i8* @ERR_error_string(i32 %9, i32* null)
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = load i32, i32* @stderr
%13 = tail call i32 @ERR_print_errors_fp(i32 %12)
ret void
}