#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_n(unsigned long, char *, size_t);
unsigned long ERR_get_error();
unsigned long SSL_ERROR_NONE;
int ssl_get_error_description(unsigned long error, char *buffer,
                              size_t length) {
  if (SSL_ERROR_NONE == error)
    error = ERR_get_error();
  if (SSL_ERROR_NONE == error)
    return 0;
  ERR_error_string_n(error, buffer, length);
  return 1;
}


x86 assembly (clang, -O0):
<ssl_get_error_description>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    0x2ea5(%rip),%rax
mov    (%rax),%rax
cmp    -0x10(%rbp),%rax
jne    1153 <ssl_get_error_description+0x33>
mov    $0x0,%al
call   1040 <ERR_get_error@plt>
mov    %rax,-0x10(%rbp)
mov    0x2e86(%rip),%rax
mov    (%rax),%rax
cmp    -0x10(%rbp),%rax
jne    1173 <ssl_get_error_description+0x53>
movl   $0x0,-0x4(%rbp)
jmp    118b <ssl_get_error_description+0x6b>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <ERR_error_string_n@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ssl_get_error_description>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    0x2eae(%rip),%rbx
mov    (%rbx),%rcx
cmp    %rdi,%rcx
jne    1147 <ssl_get_error_description+0x27>
xor    %eax,%eax
call   1040 <ERR_get_error@plt>
mov    %rax,%rdi
mov    (%rbx),%rcx
xor    %eax,%eax
cmp    %rdi,%rcx
je     115e <ssl_get_error_description+0x3e>
mov    %r15,%rsi
mov    %r14,%rdx
call   1030 <ERR_error_string_n@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@SSL_ERROR_NONE = global i64 0
define i32 @ssl_get_error_description(i64 %0, i8* %1, i64 %2) {
%4 = alloca i32
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i64
store i64 %0, i64* %5
store i8* %1, i8** %6
store i64 %2, i64* %7
%8 = load i64, i64* @SSL_ERROR_NONE
%9 = load i64, i64* %5
%10 = icmp eq i64 %8, %9
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = call i64 (...) @ERR_get_error()
store i64 %12, i64* %5
br label %13
13: ; preds = %11, %3
%14 = load i64, i64* @SSL_ERROR_NONE
%15 = load i64, i64* %5
%16 = icmp eq i64 %14, %15
br i1 %16, label %17, label %18
17: ; preds = %13
store i32 0, i32* %4
br label %23
18: ; preds = %13
%19 = load i64, i64* %5
%20 = load i8*, i8** %6
%21 = load i64, i64* %7
%22 = call i32 @ERR_error_string_n(i64 %19, i8* %20, i64 %21)
store i32 1, i32* %4
br label %23
23: ; preds = %18, %17
%24 = load i32, i32* %4
ret i32 %24
}

LLVM IR (-O2):
@SSL_ERROR_NONE = global i64 0
define i32 @ssl_get_error_description(i64 %0, i8* %1, i64 %2) {
%4 = load i64, i64* @SSL_ERROR_NONE
%5 = icmp eq i64 %4, %0
br i1 %5, label %6, label %9
6: ; preds = %3
%7 = tail call i64 (...) @ERR_get_error()
%8 = load i64, i64* @SSL_ERROR_NONE
br label %9
9: ; preds = %6, %3
%10 = phi i64 [ %8, %6 ], [ %4, %3 ]
%11 = phi i64 [ %7, %6 ], [ %0, %3 ]
%12 = icmp eq i64 %10, %11
br i1 %12, label %15, label %13
13: ; preds = %9
%14 = tail call i32 @ERR_error_string_n(i64 %11, i8* %1, i64 %2)
br label %15
15: ; preds = %9, %13
%16 = phi i32 [ 1, %13 ], [ 0, %9 ]
ret i32 %16
}