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

/* 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 *, ...);
void logSSLErr(const char *msg, FILE *log) {
  fprintf(log, msg);
  fprintf(log, "Error: %s\n", ERR_reason_error_string(ERR_get_error()));
  fprintf(log, "%s\n", ERR_error_string(ERR_get_error(), NULL));
  ERR_print_errors_fp(log);
}


x86 assembly (clang, -O0):
<logSSLErr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1060 <ERR_get_error@plt>
mov    %eax,%edi
call   1030 <ERR_reason_error_string@plt>
mov    -0x20(%rbp),%rdi
mov    %rax,%rdx
lea    0xe6d(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%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    -0x18(%rbp),%rdi
mov    %rax,%rdx
lea    0xe45(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1070 <ERR_print_errors_fp@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<logSSLErr>:
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1060 <ERR_get_error@plt>
mov    %eax,%edi
call   1030 <ERR_reason_error_string@plt>
lea    0xe8a(%rip),%rsi
mov    %rbx,%rdi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1060 <ERR_get_error@plt>
mov    %eax,%edi
xor    %esi,%esi
call   1050 <ERR_error_string@plt>
lea    0xe6d(%rip),%rsi
mov    %rbx,%rdi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1070 <ERR_print_errors_fp@plt>

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

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