#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 */
int /*<<< orphan*/ ERR_error_string(int, char *);
int ERR_get_error_line(char const **, int *);
scalar_t__ ERR_peek_error();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
void display_openssl_errors(int l) {
  const char *file;
  char buf[120];
  int e, line;
  if (ERR_peek_error() == 0)
    return;
  fprintf(stderr, "At main.c:%d:\n", l);
  while ((e = ERR_get_error_line(&file, &line))) {
    ERR_error_string(e, buf);
    fprintf(stderr, "- SSL %s: %s:%d\n", buf, file, line);
  }
}


x86 assembly (clang, -O0):
<display_openssl_errors>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x0,%al
call   1030 <ERR_peek_error@plt>
cmp    $0x0,%rax
jne    1164 <display_openssl_errors+0x24>
jmp    11dd <display_openssl_errors+0x9d>
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%edx
lea    0xe89(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
lea    -0x10(%rbp),%rdi
lea    -0x98(%rbp),%rsi
call   1040 <ERR_get_error_line@plt>
mov    %eax,-0x94(%rbp)
cmp    $0x0,%eax
je     11dd <display_openssl_errors+0x9d>
mov    -0x94(%rbp),%edi
lea    -0x90(%rbp),%rsi
call   1060 <ERR_error_string@plt>
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
lea    -0x90(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x98(%rbp),%r8d
lea    0xe3e(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    117e <display_openssl_errors+0x3e>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_openssl_errors>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x90,%rsp
mov    %edi,%ebx
xor    %eax,%eax
call   1030 <ERR_peek_error@plt>
test   %rax,%rax
je     11e4 <display_openssl_errors+0xa4>
mov    0x2e77(%rip),%r13
mov    0x0(%r13),%edi
lea    0xe8c(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0x8(%rsp),%rdi
lea    0x4(%rsp),%rsi
call   1040 <ERR_get_error_line@plt>
test   %eax,%eax
je     11e4 <display_openssl_errors+0xa4>
lea    0x10(%rsp),%rbx
lea    0xe73(%rip),%r14
lea    0x8(%rsp),%r15
lea    0x4(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
mov    %eax,%edi
mov    %rbx,%rsi
call   1060 <ERR_error_string@plt>
mov    0x0(%r13),%edi
mov    0x8(%rsp),%rcx
mov    0x4(%rsp),%r8d
mov    %r14,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <ERR_get_error_line@plt>
test   %eax,%eax
jne    11b0 <display_openssl_errors+0x70>
add    $0x90,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [15 x i8] c"At main.c:%d:\0A\00"
@.str.1 = [17 x i8] c"- SSL %s: %s:%d\0A\00"
define void @display_openssl_errors(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [120 x i8]
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %2
%7 = call i64 (...) @ERR_peek_error()
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %1
br label %26
10: ; preds = %1
%11 = load i32, i32* @stderr
%12 = load i32, i32* %2
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %12)
br label %14
14: ; preds = %17, %10
%15 = call i32 @ERR_get_error_line(i8** %3, i32* %6)
store i32 %15, i32* %5
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %26
17: ; preds = %14
%18 = load i32, i32* %5
%19 = getelementptr inbounds [120 x i8], [120 x i8]* %4, i64 0, i64 0
%20 = call i32 @ERR_error_string(i32 %18, i8* %19)
%21 = load i32, i32* @stderr
%22 = getelementptr inbounds [120 x i8], [120 x i8]* %4, i64 0, i64 0
%23 = load i8*, i8** %3
%24 = load i32, i32* %6
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %22, i8* %23, i32 %24)
br label %14
26: ; preds = %9, %14
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [15 x i8] c"At main.c:%d:\0A\00"
@.str.1 = [17 x i8] c"- SSL %s: %s:%d\0A\00"
define void @display_openssl_errors(i32 %0) {
%2 = alloca i8*
%3 = alloca [120 x i8]
%4 = alloca i32
%5 = bitcast i8** %2 to i8*
%6 = getelementptr inbounds [120 x i8], [120 x i8]* %3, i64 0, i64 0
%7 = bitcast i32* %4 to i8*
%8 = tail call i64 (...) @ERR_peek_error()
%9 = icmp eq i64 %8, 0
br i1 %9, label %24, label %10
10: ; preds = %1
%11 = load i32, i32* @stderr
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %0)
%13 = call i32 @ERR_get_error_line(i8** %2, i32* %4)
%14 = icmp eq i32 %13, 0
br i1 %14, label %24, label %15
15: ; preds = %10, %15
%16 = phi i32 [ %22, %15 ], [ %13, %10 ]
%17 = call i32 @ERR_error_string(i32 %16, i8* %6)
%18 = load i32, i32* @stderr
%19 = load i8*, i8** %2
%20 = load i32, i32* %4
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %6, i8* %19, i32 %20)
%22 = call i32 @ERR_get_error_line(i8** %2, i32* %4)
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %15
24: ; preds = %15, %10, %1
ret void
}