#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 */
char const *ERR_error_string(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ ERR_peek_last_error();
int /*<<< orphan*/ errno;
char const *strerror(int /*<<< orphan*/);
const char *err_ssl_str(int code) {
  if (code == 0)
    return "Try again";
  else if (code == -1)
    return "Connection closed";
  else if (code == -2)
    return "Want X509 lookup";
  else if (code == -3)
    return "Protocol violation with EOF";
  else if (code == -4)
    return "Protocol error";
  else if (code == -5)
    return strerror(errno);
  else if (code == -6)
    return ERR_error_string(ERR_peek_last_error(), NULL);
  return "unknown";
}


x86 assembly (clang, -O0):
<err_ssl_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1155 <err_ssl_str+0x25>
lea    0xeb4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122c <err_ssl_str+0xfc>
cmpl   $0xffffffff,-0xc(%rbp)
jne    116f <err_ssl_str+0x3f>
lea    0xea4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122c <err_ssl_str+0xfc>
cmpl   $0xfffffffe,-0xc(%rbp)
jne    1189 <err_ssl_str+0x59>
lea    0xe9c(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122c <err_ssl_str+0xfc>
cmpl   $0xfffffffd,-0xc(%rbp)
jne    11a3 <err_ssl_str+0x73>
lea    0xe93(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122c <err_ssl_str+0xfc>
cmpl   $0xfffffffc,-0xc(%rbp)
jne    11bd <err_ssl_str+0x8d>
lea    0xe95(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    122c <err_ssl_str+0xfc>
cmpl   $0xfffffffb,-0xc(%rbp)
jne    11de <err_ssl_str+0xae>
mov    0x2e12(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    %rax,-0x8(%rbp)
jmp    122c <err_ssl_str+0xfc>
cmpl   $0xfffffffa,-0xc(%rbp)
jne    1203 <err_ssl_str+0xd3>
mov    $0x0,%al
call   1030 <ERR_peek_last_error@plt>
mov    %eax,%edi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <ERR_error_string@plt>
mov    %rax,-0x8(%rbp)
jmp    122c <err_ssl_str+0xfc>
jmp    1208 <err_ssl_str+0xd8>
jmp    120d <err_ssl_str+0xdd>
jmp    1212 <err_ssl_str+0xe2>
jmp    1217 <err_ssl_str+0xe7>
jmp    121c <err_ssl_str+0xec>
jmp    1221 <err_ssl_str+0xf1>
lea    0xe30(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<err_ssl_str>:
push   %rax
add    $0x6,%edi
cmp    $0x6,%edi
ja     1161 <err_ssl_str+0x31>
lea    0xedc(%rip),%rax
lea    0xeb9(%rip),%rcx
movslq (%rcx,%rdi,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
xor    %eax,%eax
call   1030 <ERR_peek_last_error@plt>
mov    %eax,%edi
xor    %esi,%esi
pop    %rax
jmp    1040 <ERR_error_string@plt>
lea    0xf0c(%rip),%rax
pop    %rcx
ret
mov    0x2e6f(%rip),%rax
mov    (%rax),%edi
pop    %rax
jmp    1050 <strerror@plt>
lea    0xee5(%rip),%rax
pop    %rcx
ret
lea    0xec0(%rip),%rax
pop    %rcx
ret
lea    0xea6(%rip),%rax
pop    %rcx
ret
lea    0xe8b(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [10 x i8] c"Try again\00"
@.str.1 = [18 x i8] c"Connection closed\00"
@.str.2 = [17 x i8] c"Want X509 lookup\00"
@.str.3 = [28 x i8] c"Protocol violation with EOF\00"
@.str.4 = [15 x i8] c"Protocol error\00"
@errno = global i32 0
@.str.5 = [8 x i8] c"unknown\00"
define i8* @err_ssl_str(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %2
br label %42
7: ; preds = %1
%8 = load i32, i32* %3
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %11
10: ; preds = %7
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %42
11: ; preds = %7
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, -2
br i1 %13, label %14, label %15
14: ; preds = %11
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %42
15: ; preds = %11
%16 = load i32, i32* %3
%17 = icmp eq i32 %16, -3
br i1 %17, label %18, label %19
18: ; preds = %15
store i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %42
19: ; preds = %15
%20 = load i32, i32* %3
%21 = icmp eq i32 %20, -4
br i1 %21, label %22, label %23
22: ; preds = %19
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %42
23: ; preds = %19
%24 = load i32, i32* %3
%25 = icmp eq i32 %24, -5
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = load i32, i32* @errno
%28 = call i8* @strerror(i32 %27)
store i8* %28, i8** %2
br label %42
29: ; preds = %23
%30 = load i32, i32* %3
%31 = icmp eq i32 %30, -6
br i1 %31, label %32, label %35
32: ; preds = %29
%33 = call i32 (...) @ERR_peek_last_error()
%34 = call i8* @ERR_error_string(i32 %33, i32* null)
store i8* %34, i8** %2
br label %42
35: ; preds = %29
br label %36
36: ; preds = %35
br label %37
37: ; preds = %36
br label %38
38: ; preds = %37
br label %39
39: ; preds = %38
br label %40
40: ; preds = %39
br label %41
41: ; preds = %40
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %42
42: ; preds = %41, %32, %26, %22, %18, %14, %10, %6
%43 = load i8*, i8** %2
ret i8* %43
}

LLVM IR (-O2):
@.str = [10 x i8] c"Try again\00"
@.str.1 = [18 x i8] c"Connection closed\00"
@.str.2 = [17 x i8] c"Want X509 lookup\00"
@.str.3 = [28 x i8] c"Protocol violation with EOF\00"
@.str.4 = [15 x i8] c"Protocol error\00"
@errno = global i32 0
@.str.5 = [8 x i8] c"unknown\00"
define i8* @err_ssl_str(i32 %0) {
switch i32 %0, label %12 [
i32 0, label %13
i32 -1, label %2
i32 -2, label %3
i32 -3, label %4
i32 -4, label %5
i32 -5, label %6
i32 -6, label %9
]
2: ; preds = %1
br label %13
3: ; preds = %1
br label %13
4: ; preds = %1
br label %13
5: ; preds = %1
br label %13
6: ; preds = %1
%7 = load i32, i32* @errno
%8 = tail call i8* @strerror(i32 %7)
br label %13
9: ; preds = %1
%10 = tail call i32 (...) @ERR_peek_last_error()
%11 = tail call i8* @ERR_error_string(i32 %10, i32* null)
br label %13
12: ; preds = %1
br label %13
13: ; preds = %1, %12, %9, %6, %5, %4, %3, %2
%14 = phi i8* [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), %3 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), %4 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), %5 ], [ %8, %6 ], [ %11, %9 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), %12 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %14
}