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

/* Variables and functions */
int ERR_TXT_STRING;
int /*<<< orphan*/ ERR_error_string_n(unsigned long, char *, int);
unsigned long ERR_get_error_line_data(char const **, int *, char const **,
                                      int *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char const *,
                           int, ...);
int /*<<< orphan*/ stderr;
void print_errors(void) {
  unsigned long err;
  char buffer[1024];
  const char *file;
  const char *data;
  int line;
  int flags;
  while ((err = ERR_get_error_line_data(&file, &line, &data, &flags)) != 0) {
    ERR_error_string_n(err, buffer, sizeof(buffer));
    if (flags & ERR_TXT_STRING)
      fprintf(stderr, "Error: %s:%s:%d:%s\n", buffer, file, line, data);
    else
      fprintf(stderr, "Error: %s:%s:%d\n", buffer, file, line);
  }
}


x86 assembly (clang, -O0):
<print_errors>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
lea    -0x418(%rbp),%rdi
lea    -0x424(%rbp),%rsi
lea    -0x420(%rbp),%rdx
lea    -0x428(%rbp),%rcx
call   1050 <ERR_get_error_line_data@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
je     1200 <print_errors+0xd0>
mov    -0x8(%rbp),%rdi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
call   1030 <ERR_error_string_n@plt>
mov    -0x428(%rbp),%eax
mov    0x2e6c(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11cf <print_errors+0x9f>
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
lea    -0x410(%rbp),%rdx
mov    -0x418(%rbp),%rcx
mov    -0x424(%rbp),%r8d
mov    -0x420(%rbp),%r9
lea    0xe3d(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    11fb <print_errors+0xcb>
mov    0x2e02(%rip),%rax
mov    (%rax),%edi
lea    -0x410(%rbp),%rdx
mov    -0x418(%rbp),%rcx
mov    -0x424(%rbp),%r8d
lea    0xe20(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    113b <print_errors+0xb>
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_errors>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x428,%rsp
lea    0x18(%rsp),%rdi
lea    0xc(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   1050 <ERR_get_error_line_data@plt>
test   %rax,%rax
je     11fb <print_errors+0xcb>
lea    0x20(%rsp),%rbx
mov    0x2e69(%rip),%r14
lea    0x18(%rsp),%r15
lea    0xc(%rsp),%r12
lea    0x10(%rsp),%r13
lea    0x8(%rsp),%rbp
jmp    11b7 <print_errors+0x87>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xe7d(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %rbp,%rcx
call   1050 <ERR_get_error_line_data@plt>
test   %rax,%rax
je     11fb <print_errors+0xcb>
mov    %rax,%rdi
mov    %rbx,%rsi
mov    $0x400,%edx
call   1030 <ERR_error_string_n@plt>
mov    0x2e2a(%rip),%rax
mov    (%rax),%eax
mov    (%r14),%edi
mov    0x18(%rsp),%rcx
mov    0xc(%rsp),%r8d
test   %eax,0x8(%rsp)
je     1190 <print_errors+0x60>
mov    0x10(%rsp),%r9
lea    0xe11(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    11a1 <print_errors+0x71>
add    $0x428,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@ERR_TXT_STRING = global i32 0
@stderr = global i32 0
@.str = [20 x i8] c"Error: %s:%s:%d:%s\0A\00"
@.str.1 = [17 x i8] c"Error: %s:%s:%d\0A\00"
define void @print_errors() {
%1 = alloca i64
%2 = alloca [1024 x i8]
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
br label %7
7: ; preds = %31, %0
%8 = call i64 @ERR_get_error_line_data(i8** %3, i32* %5, i8** %4, i32* %6)
store i64 %8, i64* %1
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %32
10: ; preds = %7
%11 = load i64, i64* %1
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%13 = call i32 @ERR_error_string_n(i64 %11, i8* %12, i32 1024)
%14 = load i32, i32* %6
%15 = load i32, i32* @ERR_TXT_STRING
%16 = and i32 %14, %15
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %25
18: ; preds = %10
%19 = load i32, i32* @stderr
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%21 = load i8*, i8** %3
%22 = load i32, i32* %5
%23 = load i8*, i8** %4
%24 = call i32 (i32, i8*, i8*, i8*, i32, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %20, i8* %21, i32 %22, i8* %23)
br label %31
25: ; preds = %10
%26 = load i32, i32* @stderr
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%28 = load i8*, i8** %3
%29 = load i32, i32* %5
%30 = call i32 (i32, i8*, i8*, i8*, i32, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %27, i8* %28, i32 %29)
br label %31
31: ; preds = %25, %18
br label %7
32: ; preds = %7
ret void
}

LLVM IR (-O2):
@ERR_TXT_STRING = global i32 0
@stderr = global i32 0
@.str = [20 x i8] c"Error: %s:%s:%d:%s\0A\00"
@.str.1 = [17 x i8] c"Error: %s:%s:%d\0A\00"
define void @print_errors() {
%1 = alloca [1024 x i8]
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%7 = bitcast i8** %2 to i8*
%8 = bitcast i8** %3 to i8*
%9 = bitcast i32* %4 to i8*
%10 = bitcast i32* %5 to i8*
%11 = call i64 @ERR_get_error_line_data(i8** %2, i32* %4, i8** %3, i32* %5)
%12 = icmp eq i64 %11, 0
br i1 %12, label %31, label %13
13: ; preds = %0, %28
%14 = phi i64 [ %29, %28 ], [ %11, %0 ]
%15 = call i32 @ERR_error_string_n(i64 %14, i8* %6, i32 1024)
%16 = load i32, i32* %5
%17 = load i32, i32* @ERR_TXT_STRING
%18 = and i32 %17, %16
%19 = icmp eq i32 %18, 0
%20 = load i32, i32* @stderr
%21 = load i8*, i8** %2
%22 = load i32, i32* %4
br i1 %19, label %26, label %23
23: ; preds = %13
%24 = load i8*, i8** %3
%25 = call i32 (i32, i8*, i8*, i8*, i32, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %6, i8* %21, i32 %22, i8* %24)
br label %28
26: ; preds = %13
%27 = call i32 (i32, i8*, i8*, i8*, i32, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %6, i8* %21, i32 %22)
br label %28
28: ; preds = %26, %23
%29 = call i64 @ERR_get_error_line_data(i8** %2, i32* %4, i8** %3, i32* %5)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %13
31: ; preds = %28, %0
ret void
}