#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;
typedef int /*<<< orphan*/ BIO;

/* Variables and functions */
int /*<<< orphan*/ BIO_dump(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ BIO_flush(int /*<<< orphan*/ *);
int /*<<< orphan*/ BIO_printf(int /*<<< orphan*/ *, char *, char *, char *, int,
                              int);
#define TLSEXT_TYPE_cert_type 145
#define TLSEXT_TYPE_client_authz 144
#define TLSEXT_TYPE_client_certificate_url 143
#define TLSEXT_TYPE_ec_point_formats 142
#define TLSEXT_TYPE_elliptic_curves 141
#define TLSEXT_TYPE_heartbeat 140
#define TLSEXT_TYPE_max_fragment_length 139
#define TLSEXT_TYPE_renegotiate 138
#define TLSEXT_TYPE_server_authz 137
#define TLSEXT_TYPE_server_name 136
#define TLSEXT_TYPE_session_ticket 135
#define TLSEXT_TYPE_signature_algorithms 134
#define TLSEXT_TYPE_srp 133
#define TLSEXT_TYPE_status_request 132
#define TLSEXT_TYPE_truncated_hmac 131
#define TLSEXT_TYPE_trusted_ca_keys 130
#define TLSEXT_TYPE_use_srtp 129
#define TLSEXT_TYPE_user_mapping 128
void tlsext_cb(SSL *s, int client_server, int type, unsigned char *data,
               int len, void *arg) {
  BIO *bio = arg;
  char *extname;
  switch (type) {
  case TLSEXT_TYPE_server_name:
    extname = "server name";
    break;
  case TLSEXT_TYPE_max_fragment_length:
    extname = "max fragment length";
    break;
  case TLSEXT_TYPE_client_certificate_url:
    extname = "client certificate URL";
    break;
  case TLSEXT_TYPE_trusted_ca_keys:
    extname = "trusted CA keys";
    break;
  case TLSEXT_TYPE_truncated_hmac:
    extname = "truncated HMAC";
    break;
  case TLSEXT_TYPE_status_request:
    extname = "status request";
    break;
  case TLSEXT_TYPE_user_mapping:
    extname = "user mapping";
    break;
  case TLSEXT_TYPE_client_authz:
    extname = "client authz";
    break;
  case TLSEXT_TYPE_server_authz:
    extname = "server authz";
    break;
  case TLSEXT_TYPE_cert_type:
    extname = "cert type";
    break;
  case TLSEXT_TYPE_elliptic_curves:
    extname = "elliptic curves";
    break;
  case TLSEXT_TYPE_ec_point_formats:
    extname = "EC point formats";
    break;
  case TLSEXT_TYPE_srp:
    extname = "SRP";
    break;
  case TLSEXT_TYPE_signature_algorithms:
    extname = "signature algorithms";
    break;
  case TLSEXT_TYPE_use_srtp:
    extname = "use SRTP";
    break;
  case TLSEXT_TYPE_heartbeat:
    extname = "heartbeat";
    break;
  case TLSEXT_TYPE_session_ticket:
    extname = "session ticket";
    break;
  case TLSEXT_TYPE_renegotiate:
    extname = "renegotiation info";
    break;
  default:
    extname = "unknown";
    break;
  }
  BIO_printf(bio, "TLS %s extension \"%s\" (id=%d), len=%d\n",
             client_server ? "server" : "client", extname, type, len);
  BIO_dump(bio, (char *)data, len);
  (void)BIO_flush(bio);
}


x86 assembly (clang, -O0):
<tlsext_cb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x40(%rbp)
sub    $0x11,%eax
ja     129f <tlsext_cb+0x16f>
mov    -0x40(%rbp),%rax
lea    0xe8a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xec2(%rip),%rax
mov    %rax,-0x38(%rbp)
jmp    12aa <tlsext_cb+0x17a>
lea    0xebe(%rip),%rax
mov    %rax,-0x38(%rbp)
jmp    12aa <tlsext_cb+0x17a>
lea    0xec2(%rip),%rax
mov    %rax,-0x38(%rbp)
jmp    12aa <tlsext_cb+0x17a>
lea    0xec9(%rip),%rax
mov    %rax,-0x38(%rbp)
jmp    12aa <tlsext_cb+0x17a>
lea    0xec9(%rip),%rax
mov    %rax,-0x38(%rbp)
jmp    12aa <tlsext_cb+0x17a>
lea    0xec8(%rip),%rax
mov    %rax,-0x38(%rbp)
jmp    12aa <tlsext_cb+0x17a>
lea    0xec7(%rip),%rax
mov    %rax,-0x38(%rbp)
jmp    12aa <tlsext_cb+0x17a>
lea    0xec4(%rip),%rax
mov    %rax,-0x38(%rbp)
jmp    12aa <tlsext_cb+0x17a>
lea    0xec1(%rip),%rax
mov    %rax,-0x38(%rbp)
jmp    12aa <tlsext_cb+0x17a>
lea    0xebe(%rip),%rax
mov    %rax,-0x38(%rbp)
jmp    12aa <tlsext_cb+0x17a>
lea    0xeb8(%rip),%rax
mov    %rax,-0x38(%rbp)
jmp    12aa <tlsext_cb+0x17a>
lea    0xeb8(%rip),%rax
mov    %rax,-0x38(%rbp)
jmp    12aa <tlsext_cb+0x17a>
lea    0xeb9(%rip),%rax
mov    %rax,-0x38(%rbp)
jmp    12aa <tlsext_cb+0x17a>
lea    0xead(%rip),%rax
mov    %rax,-0x38(%rbp)
jmp    12aa <tlsext_cb+0x17a>
lea    0xeb2(%rip),%rax
mov    %rax,-0x38(%rbp)
jmp    12aa <tlsext_cb+0x17a>
lea    0xeab(%rip),%rax
mov    %rax,-0x38(%rbp)
jmp    12aa <tlsext_cb+0x17a>
lea    0xea5(%rip),%rax
mov    %rax,-0x38(%rbp)
jmp    12aa <tlsext_cb+0x17a>
lea    0xea4(%rip),%rax
mov    %rax,-0x38(%rbp)
jmp    12aa <tlsext_cb+0x17a>
lea    0xea7(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0xc(%rbp),%ecx
lea    0xecb(%rip),%rdx
lea    0xebd(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
mov    -0x38(%rbp),%rcx
mov    -0x10(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
lea    0xe7c(%rip),%rsi
call   1030 <BIO_printf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1040 <BIO_dump@plt>
mov    -0x30(%rbp),%rdi
call   1050 <BIO_flush@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tlsext_cb>:
push   %rbp
push   %r14
push   %rbx
mov    %r9,%rbx
mov    %r8d,%ebp
mov    %rcx,%r14
mov    %edx,%r8d
lea    -0x80(%r8),%eax
cmp    $0x11,%eax
ja     115b <tlsext_cb+0x2b>
cltq
lea    0xff2(%rip),%rdx
movslq (%rdx,%rax,4),%rcx
add    %rdx,%rcx
jmp    1162 <tlsext_cb+0x32>
lea    0xfa3(%rip),%rcx
test   %esi,%esi
lea    0xfd0(%rip),%rax
lea    0xfc2(%rip),%rdx
cmove  %rax,%rdx
lea    0xf90(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%r9d
call   1030 <BIO_printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1040 <BIO_dump@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <BIO_flush@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"server name\00"
@.str.1 = [20 x i8] c"max fragment length\00"
@.str.2 = [23 x i8] c"client certificate URL\00"
@.str.3 = [16 x i8] c"trusted CA keys\00"
@.str.4 = [15 x i8] c"truncated HMAC\00"
@.str.5 = [15 x i8] c"status request\00"
@.str.6 = [13 x i8] c"user mapping\00"
@.str.7 = [13 x i8] c"client authz\00"
@.str.8 = [13 x i8] c"server authz\00"
@.str.9 = [10 x i8] c"cert type\00"
@.str.10 = [16 x i8] c"elliptic curves\00"
@.str.11 = [17 x i8] c"EC point formats\00"
@.str.12 = [4 x i8] c"SRP\00"
@.str.13 = [21 x i8] c"signature algorithms\00"
@.str.14 = [9 x i8] c"use SRTP\00"
@.str.15 = [10 x i8] c"heartbeat\00"
@.str.16 = [15 x i8] c"session ticket\00"
@.str.17 = [19 x i8] c"renegotiation info\00"
@.str.18 = [8 x i8] c"unknown\00"
@.str.19 = [39 x i8] c"TLS %s extension \22%s\22 (id=%d), len=%d\0A\00"
@.str.20 = [7 x i8] c"server\00"
@.str.21 = [7 x i8] c"client\00"
define void @tlsext_cb(i32* %0, i32 %1, i32 %2, i8* %3, i32 %4, i8* %5) {
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32*
%14 = alloca i8*
store i32* %0, i32** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i8* %3, i8** %10
store i32 %4, i32* %11
store i8* %5, i8** %12
%15 = load i8*, i8** %12
%16 = bitcast i8* %15 to i32*
store i32* %16, i32** %13
%17 = load i32, i32* %9
switch i32 %17, label %36 [
i32 136, label %18
i32 139, label %19
i32 143, label %20
i32 130, label %21
i32 131, label %22
i32 132, label %23
i32 128, label %24
i32 144, label %25
i32 137, label %26
i32 145, label %27
i32 141, label %28
i32 142, label %29
i32 133, label %30
i32 134, label %31
i32 129, label %32
i32 140, label %33
i32 135, label %34
i32 138, label %35
]
18: ; preds = %6
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %14
br label %37
19: ; preds = %6
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8** %14
br label %37
20: ; preds = %6
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8** %14
br label %37
21: ; preds = %6
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8** %14
br label %37
22: ; preds = %6
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8** %14
br label %37
23: ; preds = %6
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8** %14
br label %37
24: ; preds = %6
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i8** %14
br label %37
25: ; preds = %6
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8** %14
br label %37
26: ; preds = %6
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8** %14
br label %37
27: ; preds = %6
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i8** %14
br label %37
28: ; preds = %6
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i8** %14
br label %37
29: ; preds = %6
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0), i8** %14
br label %37
30: ; preds = %6
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i8** %14
br label %37
31: ; preds = %6
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.13, i64 0, i64 0), i8** %14
br label %37
32: ; preds = %6
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.14, i64 0, i64 0), i8** %14
br label %37
33: ; preds = %6
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.15, i64 0, i64 0), i8** %14
br label %37
34: ; preds = %6
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.16, i64 0, i64 0), i8** %14
br label %37
35: ; preds = %6
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.17, i64 0, i64 0), i8** %14
br label %37
36: ; preds = %6
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.18, i64 0, i64 0), i8** %14
br label %37
37: ; preds = %36, %35, %34, %33, %32, %31, %30, %29, %28, %27, %26, %25, %24, %23, %22, %21, %20, %19, %18
%38 = load i32*, i32** %13
%39 = load i32, i32* %8
%40 = icmp ne i32 %39, 0
%41 = zext i1 %40 to i64
%42 = select i1 %40, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.20, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.21, i64 0, i64 0)
%43 = load i8*, i8** %14
%44 = load i32, i32* %9
%45 = load i32, i32* %11
%46 = call i32 @BIO_printf(i32* %38, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.19, i64 0, i64 0), i8* %42, i8* %43, i32 %44, i32 %45)
%47 = load i32*, i32** %13
%48 = load i8*, i8** %10
%49 = load i32, i32* %11
%50 = call i32 @BIO_dump(i32* %47, i8* %48, i32 %49)
%51 = load i32*, i32** %13
%52 = call i32 @BIO_flush(i32* %51)
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"server name\00"
@.str.1 = [20 x i8] c"max fragment length\00"
@.str.2 = [23 x i8] c"client certificate URL\00"
@.str.3 = [16 x i8] c"trusted CA keys\00"
@.str.4 = [15 x i8] c"truncated HMAC\00"
@.str.5 = [15 x i8] c"status request\00"
@.str.6 = [13 x i8] c"user mapping\00"
@.str.7 = [13 x i8] c"client authz\00"
@.str.8 = [13 x i8] c"server authz\00"
@.str.9 = [10 x i8] c"cert type\00"
@.str.10 = [16 x i8] c"elliptic curves\00"
@.str.11 = [17 x i8] c"EC point formats\00"
@.str.12 = [4 x i8] c"SRP\00"
@.str.13 = [21 x i8] c"signature algorithms\00"
@.str.14 = [9 x i8] c"use SRTP\00"
@.str.15 = [10 x i8] c"heartbeat\00"
@.str.16 = [15 x i8] c"session ticket\00"
@.str.17 = [19 x i8] c"renegotiation info\00"
@.str.18 = [8 x i8] c"unknown\00"
@.str.19 = [39 x i8] c"TLS %s extension \22%s\22 (id=%d), len=%d\0A\00"
@.str.20 = [7 x i8] c"server\00"
@.str.21 = [7 x i8] c"client\00"
@reltable.tlsext_cb = [18 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.6 to i64), i64 ptrtoint ([18 x i32]* @reltable.tlsext_cb to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.14 to i64), i64 ptrtoint ([18 x i32]* @reltable.tlsext_cb to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([16 x i8]* @.str.3 to i64), i64 ptrtoint ([18 x i32]* @reltable.tlsext_cb to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str.4 to i64), i64 ptrtoint ([18 x i32]* @reltable.tlsext_cb to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str.5 to i64), i64 ptrtoint ([18 x i32]* @reltable.tlsext_cb to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.12 to i64), i64 ptrtoint ([18 x i32]* @reltable.tlsext_cb to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([21 x i8]* @.str.13 to i64), i64 ptrtoint ([18 x i32]* @reltable.tlsext_cb to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str.16 to i64), i64 ptrtoint ([18 x i32]* @reltable.tlsext_cb to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str to i64), i64 ptrtoint ([18 x i32]* @reltable.tlsext_cb to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.8 to i64), i64 ptrtoint ([18 x i32]* @reltable.tlsext_cb to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str.17 to i64), i64 ptrtoint ([18 x i32]* @reltable.tlsext_cb to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([20 x i8]* @.str.1 to i64), i64 ptrtoint ([18 x i32]* @reltable.tlsext_cb to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.15 to i64), i64 ptrtoint ([18 x i32]* @reltable.tlsext_cb to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([16 x i8]* @.str.10 to i64), i64 ptrtoint ([18 x i32]* @reltable.tlsext_cb to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str.11 to i64), i64 ptrtoint ([18 x i32]* @reltable.tlsext_cb to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([23 x i8]* @.str.2 to i64), i64 ptrtoint ([18 x i32]* @reltable.tlsext_cb to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.7 to i64), i64 ptrtoint ([18 x i32]* @reltable.tlsext_cb to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.9 to i64), i64 ptrtoint ([18 x i32]* @reltable.tlsext_cb to i64)) to i32)]
define void @tlsext_cb(i32* nocapture readnone %0, i32 %1, i32 %2, i8* %3, i32 %4, i8* %5) {
%7 = bitcast i8* %5 to i32*
%8 = add i32 %2, -128
%9 = icmp ult i32 %8, 18
br i1 %9, label %10, label %14
10: ; preds = %6
%11 = sext i32 %8 to i64
%12 = shl i64 %11, 2
%13 = call i8* @llvm.load.relative.i64(i8* bitcast ([18 x i32]* @reltable.tlsext_cb to i8*), i64 %12)
br label %14
14: ; preds = %6, %10
%15 = phi i8* [ %13, %10 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.18, i64 0, i64 0), %6 ]
%16 = icmp eq i32 %1, 0
%17 = select i1 %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.21, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.20, i64 0, i64 0)
%18 = tail call i32 @BIO_printf(i32* %7, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.19, i64 0, i64 0), i8* %17, i8* %15, i32 %2, i32 %4)
%19 = tail call i32 @BIO_dump(i32* %7, i8* %3, i32 %4)
%20 = tail call i32 @BIO_flush(i32* %7)
ret void
}