#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 */
int /*<<< orphan*/ ERR_error_string(int, char *);
int ERR_get_error();
#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 /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
void SSL_errmsg(SSL *ssl, int err) {
  int e;
  char buf[128];
  switch (err) {
  case SSL_ERROR_NONE:
    fprintf(stderr, "SSL_ERROR_NONE SSL_get_error: %d\n", err);
    break;
  case SSL_ERROR_ZERO_RETURN:
    fprintf(stderr,
            "SSL_ERROR_ZERO_RETURN: SSL connection closed SSL_get_error: %d\n",
            err);
    break;
  case SSL_ERROR_WANT_READ:
    fprintf(stderr,
            "SSL_ERROR_WANT_READ: operation could not complete -- retry "
            "SSL_get_error: %d\n",
            err);
    break;
  case SSL_ERROR_WANT_WRITE:
    fprintf(stderr,
            "SSL_ERROR_WANT_WRITE: operation could not complete -- retry "
            "SSL_get_error: %d\n",
            err);
    break;
  case SSL_ERROR_WANT_CONNECT:
    fprintf(stderr,
            "SSL_ERROR_WANT_CONNECT: operation could not complete (not "
            "connected SSL_get_error: %d\n",
            err);
    break;
  case SSL_ERROR_WANT_ACCEPT:
    fprintf(stderr,
            "SSL_ERROR_WANT_ACCEPT: operation could not complete (not "
            "accepted) SSL_get_error: %d\n",
            err);
    break;
  case SSL_ERROR_WANT_X509_LOOKUP:
    fprintf(stderr, "SSL_ERROR_WANT_X509_LOOKUP SSL_get_error: %d\n", err);
    break;
  case SSL_ERROR_SYSCALL:
    fprintf(stderr, "SSL_ERROR_SYSCALL SSL_get_error: %d\n", err);
    while ((e = ERR_get_error())) {
      ERR_error_string(e, buf);
      fprintf(stderr, "SSL_error_queue, %s\n", buf);
    }
    break;
  case SSL_ERROR_SSL:
    fprintf(stderr, "SSL_ERROR_SSL SSL_get_error: %d\n", err);
    while ((e = ERR_get_error())) {
      ERR_error_string(e, buf);
      fprintf(stderr, "SSL_error_queue, %s\n", buf);
    }
    break;
  default:
    fprintf(stderr, "unk SSL_get_error: %d\n", err);
    break;
  }
  return;
}


x86 assembly (clang, -O0):
<SSL_errmsg>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x98(%rbp)
sub    $0x8,%eax
ja     1312 <SSL_errmsg+0x1e2>
mov    -0x98(%rbp),%rax
lea    0xe98(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2e68(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0xea0(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    132c <SSL_errmsg+0x1fc>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0xea3(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    132c <SSL_errmsg+0x1fc>
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0xec4(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    132c <SSL_errmsg+0x1fc>
mov    0x2e0b(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0xef3(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    132c <SSL_errmsg+0x1fc>
mov    0x2dec(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0xf23(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    132c <SSL_errmsg+0x1fc>
mov    0x2dcd(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0xf5b(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    132c <SSL_errmsg+0x1fc>
mov    0x2dae(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0xf92(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    132c <SSL_errmsg+0x1fc>
mov    0x2d8f(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0xfa1(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    $0x0,%al
call   1050 <ERR_get_error@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
je     12a9 <SSL_errmsg+0x179>
mov    -0x10(%rbp),%edi
lea    -0x90(%rbp),%rsi
call   1040 <ERR_error_string@plt>
mov    0x2d53(%rip),%rax
mov    (%rax),%edi
lea    -0x90(%rbp),%rdx
lea    0xf86(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1264 <SSL_errmsg+0x134>
jmp    132c <SSL_errmsg+0x1fc>
mov    0x2d2b(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0xf77(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    $0x0,%al
call   1050 <ERR_get_error@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
je     130d <SSL_errmsg+0x1dd>
mov    -0x10(%rbp),%edi
lea    -0x90(%rbp),%rsi
call   1040 <ERR_error_string@plt>
mov    0x2cef(%rip),%rax
mov    (%rax),%edi
lea    -0x90(%rbp),%rdx
lea    0xf22(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    12c8 <SSL_errmsg+0x198>
jmp    132c <SSL_errmsg+0x1fc>
mov    0x2cc7(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0xf34(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SSL_errmsg>:
push   %r15
push   %r14
push   %rbx
sub    $0x80,%rsp
mov    %esi,%edx
lea    -0x80(%rdx),%eax
cmp    $0x8,%eax
ja     1170 <SSL_errmsg+0x40>
lea    0xeb3(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2e83(%rip),%rax
mov    (%rax),%edi
lea    0xee0(%rip),%rsi
mov    $0x80,%edx
jmp    12e7 <SSL_errmsg+0x1b7>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
lea    0x10d9(%rip),%rsi
jmp    12e7 <SSL_errmsg+0x1b7>
mov    0x2e54(%rip),%rax
mov    (%rax),%edi
lea    0x103b(%rip),%rsi
mov    $0x81,%edx
jmp    12e7 <SSL_errmsg+0x1b7>
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
lea    0xf25(%rip),%rsi
mov    $0x82,%edx
jmp    12e7 <SSL_errmsg+0x1b7>
mov    0x2e20(%rip),%rax
mov    (%rax),%edi
lea    0xebd(%rip),%rsi
mov    $0x83,%edx
jmp    12e7 <SSL_errmsg+0x1b7>
mov    0x2e06(%rip),%rax
mov    (%rax),%edi
lea    0xf40(%rip),%rsi
mov    $0x84,%edx
jmp    12e7 <SSL_errmsg+0x1b7>
mov    0x2dec(%rip),%rax
mov    (%rax),%edi
lea    0xf7d(%rip),%rsi
mov    $0x85,%edx
jmp    12e7 <SSL_errmsg+0x1b7>
mov    0x2dd2(%rip),%r15
mov    (%r15),%edi
lea    0xfe6(%rip),%rsi
mov    $0x86,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
xor    %eax,%eax
call   1050 <ERR_get_error@plt>
test   %eax,%eax
je     12c5 <SSL_errmsg+0x195>
mov    %rsp,%rbx
lea    0xfe6(%rip),%r14
nopl   (%rax)
mov    %eax,%edi
mov    %rbx,%rsi
call   1040 <ERR_error_string@plt>
mov    (%r15),%edi
mov    %r14,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
xor    %eax,%eax
call   1050 <ERR_get_error@plt>
test   %eax,%eax
jne    1240 <SSL_errmsg+0x110>
jmp    12c5 <SSL_errmsg+0x195>
mov    0x2d72(%rip),%r15
mov    (%r15),%edi
lea    0xfc0(%rip),%rsi
mov    $0x87,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
xor    %eax,%eax
call   1050 <ERR_get_error@plt>
test   %eax,%eax
je     12c5 <SSL_errmsg+0x195>
mov    %rsp,%rbx
lea    0xf8a(%rip),%r14
nopl   0x0(%rax)
mov    %eax,%edi
mov    %rbx,%rsi
call   1040 <ERR_error_string@plt>
mov    (%r15),%edi
mov    %r14,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
xor    %eax,%eax
call   1050 <ERR_get_error@plt>
test   %eax,%eax
jne    12a0 <SSL_errmsg+0x170>
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2d07(%rip),%rax
mov    (%rax),%edi
lea    0xd42(%rip),%rsi
mov    $0x88,%edx
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [34 x i8] c"SSL_ERROR_NONE SSL_get_error: %d\0A\00"
@.str.1 = [64 x i8] c"SSL_ERROR_ZERO_RETURN: SSL connection closed SSL_get_error: %d\0A\00"
@.str.2 = [78 x i8] c"SSL_ERROR_WANT_READ: operation could not complete -- retry SSL_get_error: %d\0A\00"
@.str.3 = [79 x i8] c"SSL_ERROR_WANT_WRITE: operation could not complete -- retry SSL_get_error: %d\0A\00"
@.str.4 = [87 x i8] c"SSL_ERROR_WANT_CONNECT: operation could not complete (not connected SSL_get_error: %d\0A\00"
@.str.5 = [86 x i8] c"SSL_ERROR_WANT_ACCEPT: operation could not complete (not accepted) SSL_get_error: %d\0A\00"
@.str.6 = [46 x i8] c"SSL_ERROR_WANT_X509_LOOKUP SSL_get_error: %d\0A\00"
@.str.7 = [37 x i8] c"SSL_ERROR_SYSCALL SSL_get_error: %d\0A\00"
@.str.8 = [21 x i8] c"SSL_error_queue, %s\0A\00"
@.str.9 = [33 x i8] c"SSL_ERROR_SSL SSL_get_error: %d\0A\00"
@.str.10 = [23 x i8] c"unk SSL_get_error: %d\0A\00"
define void @SSL_errmsg(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca [128 x i8]
store i32* %0, i32** %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
switch i32 %7, label %66 [
i32 136, label %8
i32 128, label %12
i32 131, label %16
i32 130, label %20
i32 132, label %24
i32 133, label %28
i32 129, label %32
i32 134, label %36
i32 135, label %51
]
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i32, i32* %4
%11 = call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %10)
br label %70
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i32, i32* %4
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.1, i64 0, i64 0), i32 %14)
br label %70
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = load i32, i32* %4
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.2, i64 0, i64 0), i32 %18)
br label %70
20: ; preds = %2
%21 = load i32, i32* @stderr
%22 = load i32, i32* %4
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.3, i64 0, i64 0), i32 %22)
br label %70
24: ; preds = %2
%25 = load i32, i32* @stderr
%26 = load i32, i32* %4
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str.4, i64 0, i64 0), i32 %26)
br label %70
28: ; preds = %2
%29 = load i32, i32* @stderr
%30 = load i32, i32* %4
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([86 x i8], [86 x i8]* @.str.5, i64 0, i64 0), i32 %30)
br label %70
32: ; preds = %2
%33 = load i32, i32* @stderr
%34 = load i32, i32* %4
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.6, i64 0, i64 0), i32 %34)
br label %70
36: ; preds = %2
%37 = load i32, i32* @stderr
%38 = load i32, i32* %4
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %43, %36
%41 = call i32 (...) @ERR_get_error()
store i32 %41, i32* %5
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %50
43: ; preds = %40
%44 = load i32, i32* %5
%45 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%46 = call i32 @ERR_error_string(i32 %44, i8* %45)
%47 = load i32, i32* @stderr
%48 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%49 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i8* %48)
br label %40
50: ; preds = %40
br label %70
51: ; preds = %2
%52 = load i32, i32* @stderr
%53 = load i32, i32* %4
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0), i32 %53)
br label %55
55: ; preds = %58, %51
%56 = call i32 (...) @ERR_get_error()
store i32 %56, i32* %5
%57 = icmp ne i32 %56, 0
br i1 %57, label %58, label %65
58: ; preds = %55
%59 = load i32, i32* %5
%60 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%61 = call i32 @ERR_error_string(i32 %59, i8* %60)
%62 = load i32, i32* @stderr
%63 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%64 = call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i8* %63)
br label %55
65: ; preds = %55
br label %70
66: ; preds = %2
%67 = load i32, i32* @stderr
%68 = load i32, i32* %4
%69 = call i32 (i32, i8*, ...) @fprintf(i32 %67, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0), i32 %68)
br label %70
70: ; preds = %66, %65, %50, %32, %28, %24, %20, %16, %12, %8
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [34 x i8] c"SSL_ERROR_NONE SSL_get_error: %d\0A\00"
@.str.1 = [64 x i8] c"SSL_ERROR_ZERO_RETURN: SSL connection closed SSL_get_error: %d\0A\00"
@.str.2 = [78 x i8] c"SSL_ERROR_WANT_READ: operation could not complete -- retry SSL_get_error: %d\0A\00"
@.str.3 = [79 x i8] c"SSL_ERROR_WANT_WRITE: operation could not complete -- retry SSL_get_error: %d\0A\00"
@.str.4 = [87 x i8] c"SSL_ERROR_WANT_CONNECT: operation could not complete (not connected SSL_get_error: %d\0A\00"
@.str.5 = [86 x i8] c"SSL_ERROR_WANT_ACCEPT: operation could not complete (not accepted) SSL_get_error: %d\0A\00"
@.str.6 = [46 x i8] c"SSL_ERROR_WANT_X509_LOOKUP SSL_get_error: %d\0A\00"
@.str.7 = [37 x i8] c"SSL_ERROR_SYSCALL SSL_get_error: %d\0A\00"
@.str.8 = [21 x i8] c"SSL_error_queue, %s\0A\00"
@.str.9 = [33 x i8] c"SSL_ERROR_SSL SSL_get_error: %d\0A\00"
@.str.10 = [23 x i8] c"unk SSL_get_error: %d\0A\00"
define void @SSL_errmsg(i32* nocapture readnone %0, i32 %1) {
%3 = alloca [128 x i8]
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
switch i32 %1, label %50 [
i32 136, label %5
i32 128, label %8
i32 131, label %11
i32 130, label %14
i32 132, label %17
i32 133, label %20
i32 129, label %23
i32 134, label %26
i32 135, label %38
]
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 136)
br label %53
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.1, i64 0, i64 0), i32 128)
br label %53
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.2, i64 0, i64 0), i32 131)
br label %53
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.3, i64 0, i64 0), i32 130)
br label %53
17: ; preds = %2
%18 = load i32, i32* @stderr
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str.4, i64 0, i64 0), i32 132)
br label %53
20: ; preds = %2
%21 = load i32, i32* @stderr
%22 = tail call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([86 x i8], [86 x i8]* @.str.5, i64 0, i64 0), i32 133)
br label %53
23: ; preds = %2
%24 = load i32, i32* @stderr
%25 = tail call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.6, i64 0, i64 0), i32 129)
br label %53
26: ; preds = %2
%27 = load i32, i32* @stderr
%28 = tail call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i32 134)
%29 = call i32 (...) @ERR_get_error()
%30 = icmp eq i32 %29, 0
br i1 %30, label %53, label %31
31: ; preds = %26, %31
%32 = phi i32 [ %36, %31 ], [ %29, %26 ]
%33 = call i32 @ERR_error_string(i32 %32, i8* %4)
%34 = load i32, i32* @stderr
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i8* %4)
%36 = call i32 (...) @ERR_get_error()
%37 = icmp eq i32 %36, 0
br i1 %37, label %53, label %31
38: ; preds = %2
%39 = load i32, i32* @stderr
%40 = tail call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0), i32 135)
%41 = call i32 (...) @ERR_get_error()
%42 = icmp eq i32 %41, 0
br i1 %42, label %53, label %43
43: ; preds = %38, %43
%44 = phi i32 [ %48, %43 ], [ %41, %38 ]
%45 = call i32 @ERR_error_string(i32 %44, i8* %4)
%46 = load i32, i32* @stderr
%47 = call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i8* %4)
%48 = call i32 (...) @ERR_get_error()
%49 = icmp eq i32 %48, 0
br i1 %49, label %53, label %43
50: ; preds = %2
%51 = load i32, i32* @stderr
%52 = tail call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0), i32 %1)
br label %53
53: ; preds = %43, %31, %38, %26, %50, %23, %20, %17, %14, %11, %8, %5
ret void
}