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

/* Variables and functions */
int /*<<< orphan*/ BIO_snprintf(char *, int, char *, unsigned long, char *,
                                char const *, int, char const *);
unsigned long CRYPTO_thread_id();
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 *);
size_t strlen(char *);
void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u),
                         void *u) {
  unsigned long l;
  char buf[256];
  char buf2[4096];
  const char *file, *data;
  int line, flags;
  unsigned long es;
  es = CRYPTO_thread_id();
  while ((l = ERR_get_error_line_data(&file, &line, &data, &flags)) != 0) {
    ERR_error_string_n(l, buf, sizeof buf);
    BIO_snprintf(buf2, sizeof(buf2), "%lu:%s:%s:%d:%s\n", es, buf, file, line,
                 (flags & ERR_TXT_STRING) ? data : "");
    if (cb(buf2, strlen(buf2), u) <= 0)
      break;
  }
}


x86 assembly (clang, -O0):
<ERR_print_errors_cb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1190,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1060 <CRYPTO_thread_id@plt>
mov    %rax,-0x1140(%rbp)
lea    -0x1128(%rbp),%rdi
lea    -0x1134(%rbp),%rsi
lea    -0x1130(%rbp),%rdx
lea    -0x1138(%rbp),%rcx
call   1070 <ERR_get_error_line_data@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     12ca <ERR_print_errors_cb+0x17a>
mov    -0x18(%rbp),%rdi
lea    -0x120(%rbp),%rsi
mov    $0x100,%edx
call   1040 <ERR_error_string_n@plt>
lea    -0x1120(%rbp),%rax
mov    %rax,-0x1168(%rbp)
mov    -0x1140(%rbp),%rax
mov    %rax,-0x1160(%rbp)
lea    -0x120(%rbp),%rax
mov    %rax,-0x1158(%rbp)
mov    -0x1128(%rbp),%rax
mov    %rax,-0x1150(%rbp)
mov    -0x1134(%rbp),%eax
mov    %eax,-0x1144(%rbp)
mov    -0x1138(%rbp),%eax
mov    0x2df2(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1224 <ERR_print_errors_cb+0xd4>
mov    -0x1130(%rbp),%rax
mov    %rax,-0x1170(%rbp)
jmp    1237 <ERR_print_errors_cb+0xe7>
lea    0xde5(%rip),%rax
mov    %rax,-0x1170(%rbp)
jmp    1237 <ERR_print_errors_cb+0xe7>
mov    -0x1144(%rbp),%r10d
mov    -0x1150(%rbp),%r9
mov    -0x1158(%rbp),%r8
mov    -0x1160(%rbp),%rcx
mov    -0x1168(%rbp),%rdi
mov    -0x1170(%rbp),%rax
mov    $0x1000,%esi
lea    0xd93(%rip),%rdx
mov    %r10d,(%rsp)
mov    %rax,0x8(%rsp)
call   1050 <BIO_snprintf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x1178(%rbp)
lea    -0x1120(%rbp),%rax
mov    %rax,-0x1180(%rbp)
lea    -0x1120(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x1180(%rbp),%rdi
mov    %rax,%rsi
mov    -0x1178(%rbp),%rax
mov    -0x10(%rbp),%rdx
call   *%rax
cmp    $0x0,%eax
jg     12c5 <ERR_print_errors_cb+0x175>
jmp    12ca <ERR_print_errors_cb+0x17a>
jmp    1171 <ERR_print_errors_cb+0x21>
add    $0x1190,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ERR_print_errors_cb>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1128,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
xor    %eax,%eax
call   1060 <CRYPTO_thread_id@plt>
mov    %rax,%rbx
lea    0x20(%rsp),%r13
lea    0x120(%rsp),%r12
jmp    11c1 <ERR_print_errors_cb+0x71>
mov    0x18(%rsp),%r9
mov    0xc(%rsp),%ebp
mov    %r12,%rdi
mov    $0x1000,%esi
lea    0xe68(%rip),%rdx
mov    %rbx,%rcx
mov    %r13,%r8
push   %rax
push   %rbp
call   1050 <BIO_snprintf@plt>
add    $0x10,%rsp
mov    %r12,%rdi
call   1030 <strlen@plt>
mov    %r12,%rdi
mov    %rax,%rsi
mov    %r14,%rdx
call   *%r15
test   %eax,%eax
jle    1213 <ERR_print_errors_cb+0xc3>
lea    0x18(%rsp),%rdi
lea    0xc(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   1070 <ERR_get_error_line_data@plt>
test   %rax,%rax
je     1213 <ERR_print_errors_cb+0xc3>
mov    %rax,%rdi
mov    %r13,%rsi
mov    $0x100,%edx
call   1040 <ERR_error_string_n@plt>
mov    0x2e02(%rip),%rax
mov    (%rax),%ecx
lea    0xe11(%rip),%rax
and    0x8(%rsp),%ecx
je     1180 <ERR_print_errors_cb+0x30>
mov    0x10(%rsp),%rax
jmp    1180 <ERR_print_errors_cb+0x30>
add    $0x1128,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"%lu:%s:%s:%d:%s\0A\00"
@ERR_TXT_STRING = global i32 0
@.str.1 = [1 x i8] zeroinitializer
define void @ERR_print_errors_cb(i32 (i8*, i64, i8*)* %0, i8* %1) {
%3 = alloca i32 (i8*, i64, i8*)*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca [256 x i8]
%7 = alloca [4096 x i8]
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i64
store i32 (i8*, i64, i8*)* %0, i32 (i8*, i64, i8*)** %3
store i8* %1, i8** %4
%13 = call i64 (...) @CRYPTO_thread_id()
store i64 %13, i64* %12
br label %14
14: ; preds = %44, %2
%15 = call i64 @ERR_get_error_line_data(i8** %8, i32* %10, i8** %9, i32* %11)
store i64 %15, i64* %5
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %45
17: ; preds = %14
%18 = load i64, i64* %5
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%20 = call i32 @ERR_error_string_n(i64 %18, i8* %19, i32 256)
%21 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%22 = load i64, i64* %12
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%24 = load i8*, i8** %8
%25 = load i32, i32* %10
%26 = load i32, i32* %11
%27 = load i32, i32* @ERR_TXT_STRING
%28 = and i32 %26, %27
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %17
%31 = load i8*, i8** %9
br label %33
32: ; preds = %17
br label %33
33: ; preds = %32, %30
%34 = phi i8* [ %31, %30 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), %32 ]
%35 = call i32 @BIO_snprintf(i8* %21, i32 4096, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 %22, i8* %23, i8* %24, i32 %25, i8* %34)
%36 = load i32 (i8*, i64, i8*)*, i32 (i8*, i64, i8*)** %3
%37 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%38 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%39 = call i64 @strlen(i8* %38)
%40 = load i8*, i8** %4
%41 = call i32 %36(i8* %37, i64 %39, i8* %40)
%42 = icmp sle i32 %41, 0
br i1 %42, label %43, label %44
43: ; preds = %33
br label %45
44: ; preds = %33
br label %14
45: ; preds = %43, %14
ret void
}

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