#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 ERR_TXT_STRING;
char *ERR_error_string(unsigned long, char *);
unsigned long ERR_get_error_line_data(char const **, int *, char const **,
                                      int *);
int /*<<< orphan*/ printf(char *, ...);
void print_errors(void) {
  int flags, line;
  const char *data, *file;
  unsigned long code;
  char str[1024];
  char *errstr;
  code = ERR_get_error_line_data(&file, &line, &data, &flags);
  while (code) {
    printf("error code; %lu in %s line %d.\n", code, file, line);
    if (data && (flags & ERR_TXT_STRING))
      printf("error data: %s\n", data);
    code = ERR_get_error_line_data(&file, &line, &data, &flags);
    errstr = ERR_error_string(code, str);
    printf(" (%s)\n", errstr);
  }
}


x86 assembly (clang, -O0):
<print_errors>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
lea    -0x18(%rbp),%rdi
lea    -0x8(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x4(%rbp),%rcx
call   1050 <ERR_get_error_line_data@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11f4 <print_errors+0xc4>
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x8(%rbp),%ecx
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0x0,-0x10(%rbp)
je     11aa <print_errors+0x7a>
mov    -0x4(%rbp),%eax
mov    0x2e6b(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11aa <print_errors+0x7a>
mov    -0x10(%rbp),%rsi
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x18(%rbp),%rdi
lea    -0x8(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x4(%rbp),%rcx
call   1050 <ERR_get_error_line_data@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x420(%rbp),%rsi
call   1040 <ERR_error_string@plt>
mov    %rax,-0x428(%rbp)
mov    -0x428(%rbp),%rsi
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1154 <print_errors+0x24>
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    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
lea    0x18(%rsp),%rdx
lea    0xc(%rsp),%rcx
call   1050 <ERR_get_error_line_data@plt>
test   %rax,%rax
je     1206 <print_errors+0xd6>
mov    %rax,%r15
lea    0x8(%rsp),%r12
lea    0x18(%rsp),%r13
lea    0xc(%rsp),%rbx
lea    0x20(%rsp),%rbp
lea    0xeaf(%rip),%r14
jmp    11c3 <print_errors+0x93>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0x10(%rsp),%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %rbx,%rcx
call   1050 <ERR_get_error_line_data@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    %rbp,%rsi
call   1040 <ERR_error_string@plt>
mov    %r14,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
test   %r15,%r15
je     1206 <print_errors+0xd6>
mov    0x10(%rsp),%rdx
mov    0x8(%rsp),%ecx
lea    0xe2d(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x18(%rsp),%rsi
test   %rsi,%rsi
je     1190 <print_errors+0x60>
mov    0x2e0a(%rip),%rax
mov    (%rax),%eax
test   %eax,0xc(%rsp)
je     1190 <print_errors+0x60>
lea    0xe23(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1190 <print_errors+0x60>
add    $0x428,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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