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

/* Variables and functions */
#define SSL_ERROR_NONE 136
#define SSL_ERROR_SSL 135
#define SSL_ERROR_SYSCALL 134
#define SSL_ERROR_WANT_ACCEPT 133
#define SSL_ERROR_WANT_CONNECT 132
#define SSL_ERROR_WANT_READ 131
#define SSL_ERROR_WANT_WRITE 130
#define SSL_ERROR_WANT_X509_LOOKUP 129
#define SSL_ERROR_ZERO_RETURN 128
int SSL_get_error(int /*<<< orphan*/ const *const, int);
const char *ssl_strerror(const SSL *const ssl, int ret) {
  int code = SSL_get_error(ssl, ret);
  switch (code) {
  case SSL_ERROR_NONE:
    return "SSL_ERROR_NONE";
  case SSL_ERROR_ZERO_RETURN:
    return "SSL_ERROR_ZERO_RETURN";
  case SSL_ERROR_WANT_READ:
    return "SSL_ERROR_WANT_READ";
  case SSL_ERROR_WANT_WRITE:
    return "SSL_ERROR_WANT_WRITE";
  case SSL_ERROR_WANT_CONNECT:
    return "SSL_ERROR_WANT_CONNECT";
  case SSL_ERROR_WANT_ACCEPT:
    return "SSL_ERROR_WANT_ACCEPT";
  case SSL_ERROR_WANT_X509_LOOKUP:
    return "SSL_ERROR_WANT_X509_LOOKUP";
  case SSL_ERROR_SYSCALL:
    return "SSL_ERROR_SYSCALL";
  case SSL_ERROR_SSL:
    return "SSL_ERROR_SSL";
  }
  return "Unknown SSL error ocurred";
}


x86 assembly (clang, -O0):
<ssl_strerror>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <SSL_get_error@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x8,%eax
ja     11e7 <ssl_strerror+0xd7>
mov    -0x20(%rbp),%rax
lea    0xeb2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xec6(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f2 <ssl_strerror+0xe2>
lea    0xec5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f2 <ssl_strerror+0xe2>
lea    0xecb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f2 <ssl_strerror+0xe2>
lea    0xecf(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f2 <ssl_strerror+0xe2>
lea    0xed4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f2 <ssl_strerror+0xe2>
lea    0xedb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f2 <ssl_strerror+0xe2>
lea    0xee1(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f2 <ssl_strerror+0xe2>
lea    0xeec(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f2 <ssl_strerror+0xe2>
lea    0xeee(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f2 <ssl_strerror+0xe2>
lea    0xeec(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ssl_strerror>:
push   %rax
call   1030 <SSL_get_error@plt>
add    $0xffffff80,%eax
cmp    $0x8,%eax
ja     1130 <ssl_strerror+0x20>
cltq
lea    0xfa9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
pop    %rcx
ret
lea    0xf7f(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"SSL_ERROR_NONE\00"
@.str.1 = [22 x i8] c"SSL_ERROR_ZERO_RETURN\00"
@.str.2 = [20 x i8] c"SSL_ERROR_WANT_READ\00"
@.str.3 = [21 x i8] c"SSL_ERROR_WANT_WRITE\00"
@.str.4 = [23 x i8] c"SSL_ERROR_WANT_CONNECT\00"
@.str.5 = [22 x i8] c"SSL_ERROR_WANT_ACCEPT\00"
@.str.6 = [27 x i8] c"SSL_ERROR_WANT_X509_LOOKUP\00"
@.str.7 = [18 x i8] c"SSL_ERROR_SYSCALL\00"
@.str.8 = [14 x i8] c"SSL_ERROR_SSL\00"
@.str.9 = [26 x i8] c"Unknown SSL error ocurred\00"
define i8* @ssl_strerror(i32* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
%7 = load i32*, i32** %4
%8 = load i32, i32* %5
%9 = call i32 @SSL_get_error(i32* %7, i32 %8)
store i32 %9, i32* %6
%10 = load i32, i32* %6
switch i32 %10, label %20 [
i32 136, label %11
i32 128, label %12
i32 131, label %13
i32 130, label %14
i32 132, label %15
i32 133, label %16
i32 129, label %17
i32 134, label %18
i32 135, label %19
]
11: ; preds = %2
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8** %3
br label %21
12: ; preds = %2
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %21
13: ; preds = %2
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %21
14: ; preds = %2
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8** %3
br label %21
15: ; preds = %2
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8** %3
br label %21
16: ; preds = %2
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8** %3
br label %21
17: ; preds = %2
store i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i8** %3
br label %21
18: ; preds = %2
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i8** %3
br label %21
19: ; preds = %2
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), i8** %3
br label %21
20: ; preds = %2
store i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0), i8** %3
br label %21
21: ; preds = %20, %19, %18, %17, %16, %15, %14, %13, %12, %11
%22 = load i8*, i8** %3
ret i8* %22
}

LLVM IR (-O2):
@.str = [15 x i8] c"SSL_ERROR_NONE\00"
@.str.1 = [22 x i8] c"SSL_ERROR_ZERO_RETURN\00"
@.str.2 = [20 x i8] c"SSL_ERROR_WANT_READ\00"
@.str.3 = [21 x i8] c"SSL_ERROR_WANT_WRITE\00"
@.str.4 = [23 x i8] c"SSL_ERROR_WANT_CONNECT\00"
@.str.5 = [22 x i8] c"SSL_ERROR_WANT_ACCEPT\00"
@.str.6 = [27 x i8] c"SSL_ERROR_WANT_X509_LOOKUP\00"
@.str.7 = [18 x i8] c"SSL_ERROR_SYSCALL\00"
@.str.8 = [14 x i8] c"SSL_ERROR_SSL\00"
@.str.9 = [26 x i8] c"Unknown SSL error ocurred\00"
@reltable.ssl_strerror = [9 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([22 x i8]* @.str.1 to i64), i64 ptrtoint ([9 x i32]* @reltable.ssl_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([27 x i8]* @.str.6 to i64), i64 ptrtoint ([9 x i32]* @reltable.ssl_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([21 x i8]* @.str.3 to i64), i64 ptrtoint ([9 x i32]* @reltable.ssl_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([20 x i8]* @.str.2 to i64), i64 ptrtoint ([9 x i32]* @reltable.ssl_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([23 x i8]* @.str.4 to i64), i64 ptrtoint ([9 x i32]* @reltable.ssl_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([22 x i8]* @.str.5 to i64), i64 ptrtoint ([9 x i32]* @reltable.ssl_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.7 to i64), i64 ptrtoint ([9 x i32]* @reltable.ssl_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.8 to i64), i64 ptrtoint ([9 x i32]* @reltable.ssl_strerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str to i64), i64 ptrtoint ([9 x i32]* @reltable.ssl_strerror to i64)) to i32)]
define i8* @ssl_strerror(i32* %0, i32 %1) {
%3 = tail call i32 @SSL_get_error(i32* %0, i32 %1)
%4 = add i32 %3, -128
%5 = icmp ult i32 %4, 9
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = sext i32 %4 to i64
%8 = shl i64 %7, 2
%9 = call i8* @llvm.load.relative.i64(i8* bitcast ([9 x i32]* @reltable.ssl_strerror to i8*), i64 %8)
br label %10
10: ; preds = %2, %6
%11 = phi i8* [ %9, %6 ], [ getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0), %2 ]
ret i8* %11
}