char *GetRecordType(const char *msg) {
  if (msg[0] == 0x16) {
    if (msg[13] == 0x01)
      return "Client Hello";
    else if (msg[13] == 0x00)
      return "Hello Request";
    else if (msg[13] == 0x03)
      return "Hello Verify Request";
    else if (msg[13] == 0x04)
      return "Session Ticket";
    else if (msg[13] == 0x0b)
      return "Certificate";
    else if (msg[13] == 0x0d)
      return "Certificate Request";
    else if (msg[13] == 0x0f)
      return "Certificate Verify";
    else if (msg[13] == 0x02)
      return "Server Hello";
    else if (msg[13] == 0x0e)
      return "Server Hello Done";
    else if (msg[13] == 0x10)
      return "Client Key Exchange";
    else if (msg[13] == 0x0c)
      return "Server Key Exchange";
    else
      return "Encrypted Handshake Message";
  } else if (msg[0] == 0x14)
    return "Change Cipher Spec";
  else if (msg[0] == 0x17)
    return "Application Data";
  else if (msg[0] == 0x15)
    return "Alert";
  return "Unknown";
}


x86 assembly (clang, -O0):
<GetRecordType>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x16,%eax
jne    1293 <GetRecordType+0x193>
mov    -0x10(%rbp),%rax
movsbl 0xd(%rax),%eax
cmp    $0x1,%eax
jne    1139 <GetRecordType+0x39>
lea    0xed0(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    130d <GetRecordType+0x20d>
mov    -0x10(%rbp),%rax
movsbl 0xd(%rax),%eax
cmp    $0x0,%eax
jne    115a <GetRecordType+0x5a>
lea    0xebc(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    130d <GetRecordType+0x20d>
mov    -0x10(%rbp),%rax
movsbl 0xd(%rax),%eax
cmp    $0x3,%eax
jne    117b <GetRecordType+0x7b>
lea    0xea9(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    130d <GetRecordType+0x20d>
mov    -0x10(%rbp),%rax
movsbl 0xd(%rax),%eax
cmp    $0x4,%eax
jne    119c <GetRecordType+0x9c>
lea    0xe9d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    130d <GetRecordType+0x20d>
mov    -0x10(%rbp),%rax
movsbl 0xd(%rax),%eax
cmp    $0xb,%eax
jne    11bd <GetRecordType+0xbd>
lea    0xe8b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    130d <GetRecordType+0x20d>
mov    -0x10(%rbp),%rax
movsbl 0xd(%rax),%eax
cmp    $0xd,%eax
jne    11de <GetRecordType+0xde>
lea    0xe76(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    130d <GetRecordType+0x20d>
mov    -0x10(%rbp),%rax
movsbl 0xd(%rax),%eax
cmp    $0xf,%eax
jne    11ff <GetRecordType+0xff>
lea    0xe69(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    130d <GetRecordType+0x20d>
mov    -0x10(%rbp),%rax
movsbl 0xd(%rax),%eax
cmp    $0x2,%eax
jne    1220 <GetRecordType+0x120>
lea    0xe5b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    130d <GetRecordType+0x20d>
mov    -0x10(%rbp),%rax
movsbl 0xd(%rax),%eax
cmp    $0xe,%eax
jne    1241 <GetRecordType+0x141>
lea    0xe47(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    130d <GetRecordType+0x20d>
mov    -0x10(%rbp),%rax
movsbl 0xd(%rax),%eax
cmp    $0x10,%eax
jne    1262 <GetRecordType+0x162>
lea    0xe38(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    130d <GetRecordType+0x20d>
mov    -0x10(%rbp),%rax
movsbl 0xd(%rax),%eax
cmp    $0xc,%eax
jne    1283 <GetRecordType+0x183>
lea    0xe2b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    130d <GetRecordType+0x20d>
lea    0xe2f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    130d <GetRecordType+0x20d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x14,%eax
jne    12b3 <GetRecordType+0x1b3>
lea    0xe2b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    130d <GetRecordType+0x20d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x17,%eax
jne    12d3 <GetRecordType+0x1d3>
lea    0xe1e(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    130d <GetRecordType+0x20d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x15,%eax
jne    12f3 <GetRecordType+0x1f3>
lea    0xe0f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    130d <GetRecordType+0x20d>
jmp    12f8 <GetRecordType+0x1f8>
jmp    12fd <GetRecordType+0x1fd>
jmp    1302 <GetRecordType+0x202>
lea    0xdf6(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetRecordType>:
mov    (%rdi),%cl
add    $0xec,%cl
cmp    $0x3,%cl
ja     112c <GetRecordType+0x2c>
lea    0x1018(%rip),%rax
movzbl %cl,%ecx
lea    0xee5(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
lea    0x1022(%rip),%rax
ret
lea    0x1020(%rip),%rax
ret
movsbq 0xd(%rdi),%rax
cmp    $0x11,%rax
jae    1156 <GetRecordType+0x56>
lea    0xeca(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
ret
lea    0xfe7(%rip),%rax
ret
lea    0xfb0(%rip),%rax
ret

LLVM IR (-O0):
@.str = [13 x i8] c"Client Hello\00"
@.str.1 = [14 x i8] c"Hello Request\00"
@.str.2 = [21 x i8] c"Hello Verify Request\00"
@.str.3 = [15 x i8] c"Session Ticket\00"
@.str.4 = [12 x i8] c"Certificate\00"
@.str.5 = [20 x i8] c"Certificate Request\00"
@.str.6 = [19 x i8] c"Certificate Verify\00"
@.str.7 = [13 x i8] c"Server Hello\00"
@.str.8 = [18 x i8] c"Server Hello Done\00"
@.str.9 = [20 x i8] c"Client Key Exchange\00"
@.str.10 = [20 x i8] c"Server Key Exchange\00"
@.str.11 = [28 x i8] c"Encrypted Handshake Message\00"
@.str.12 = [19 x i8] c"Change Cipher Spec\00"
@.str.13 = [17 x i8] c"Application Data\00"
@.str.14 = [6 x i8] c"Alert\00"
@.str.15 = [8 x i8] c"Unknown\00"
define i8* @GetRecordType(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = getelementptr inbounds i8, i8* %4, i64 0
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = icmp eq i32 %7, 22
br i1 %8, label %9, label %87
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = getelementptr inbounds i8, i8* %10, i64 13
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %16
15: ; preds = %9
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %2
br label %112
16: ; preds = %9
%17 = load i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i64 13
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %16
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %112
23: ; preds = %16
%24 = load i8*, i8** %3
%25 = getelementptr inbounds i8, i8* %24, i64 13
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 3
br i1 %28, label %29, label %30
29: ; preds = %23
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %112
30: ; preds = %23
%31 = load i8*, i8** %3
%32 = getelementptr inbounds i8, i8* %31, i64 13
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 4
br i1 %35, label %36, label %37
36: ; preds = %30
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %112
37: ; preds = %30
%38 = load i8*, i8** %3
%39 = getelementptr inbounds i8, i8* %38, i64 13
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp eq i32 %41, 11
br i1 %42, label %43, label %44
43: ; preds = %37
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %112
44: ; preds = %37
%45 = load i8*, i8** %3
%46 = getelementptr inbounds i8, i8* %45, i64 13
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp eq i32 %48, 13
br i1 %49, label %50, label %51
50: ; preds = %44
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %112
51: ; preds = %44
%52 = load i8*, i8** %3
%53 = getelementptr inbounds i8, i8* %52, i64 13
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = icmp eq i32 %55, 15
br i1 %56, label %57, label %58
57: ; preds = %51
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %112
58: ; preds = %51
%59 = load i8*, i8** %3
%60 = getelementptr inbounds i8, i8* %59, i64 13
%61 = load i8, i8* %60
%62 = sext i8 %61 to i32
%63 = icmp eq i32 %62, 2
br i1 %63, label %64, label %65
64: ; preds = %58
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %112
65: ; preds = %58
%66 = load i8*, i8** %3
%67 = getelementptr inbounds i8, i8* %66, i64 13
%68 = load i8, i8* %67
%69 = sext i8 %68 to i32
%70 = icmp eq i32 %69, 14
br i1 %70, label %71, label %72
71: ; preds = %65
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i8** %2
br label %112
72: ; preds = %65
%73 = load i8*, i8** %3
%74 = getelementptr inbounds i8, i8* %73, i64 13
%75 = load i8, i8* %74
%76 = sext i8 %75 to i32
%77 = icmp eq i32 %76, 16
br i1 %77, label %78, label %79
78: ; preds = %72
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i8** %2
br label %112
79: ; preds = %72
%80 = load i8*, i8** %3
%81 = getelementptr inbounds i8, i8* %80, i64 13
%82 = load i8, i8* %81
%83 = sext i8 %82 to i32
%84 = icmp eq i32 %83, 12
br i1 %84, label %85, label %86
85: ; preds = %79
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0), i8** %2
br label %112
86: ; preds = %79
store i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0), i8** %2
br label %112
87: ; preds = %1
%88 = load i8*, i8** %3
%89 = getelementptr inbounds i8, i8* %88, i64 0
%90 = load i8, i8* %89
%91 = sext i8 %90 to i32
%92 = icmp eq i32 %91, 20
br i1 %92, label %93, label %94
93: ; preds = %87
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0), i8** %2
br label %112
94: ; preds = %87
%95 = load i8*, i8** %3
%96 = getelementptr inbounds i8, i8* %95, i64 0
%97 = load i8, i8* %96
%98 = sext i8 %97 to i32
%99 = icmp eq i32 %98, 23
br i1 %99, label %100, label %101
100: ; preds = %94
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0), i8** %2
br label %112
101: ; preds = %94
%102 = load i8*, i8** %3
%103 = getelementptr inbounds i8, i8* %102, i64 0
%104 = load i8, i8* %103
%105 = sext i8 %104 to i32
%106 = icmp eq i32 %105, 21
br i1 %106, label %107, label %108
107: ; preds = %101
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i64 0, i64 0), i8** %2
br label %112
108: ; preds = %101
br label %109
109: ; preds = %108
br label %110
110: ; preds = %109
br label %111
111: ; preds = %110
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.15, i64 0, i64 0), i8** %2
br label %112
112: ; preds = %111, %107, %100, %93, %86, %85, %78, %71, %64, %57, %50, %43, %36, %29, %22, %15
%113 = load i8*, i8** %2
ret i8* %113
}

LLVM IR (-O2):
@.str = [13 x i8] c"Client Hello\00"
@.str.1 = [14 x i8] c"Hello Request\00"
@.str.2 = [21 x i8] c"Hello Verify Request\00"
@.str.3 = [15 x i8] c"Session Ticket\00"
@.str.4 = [12 x i8] c"Certificate\00"
@.str.5 = [20 x i8] c"Certificate Request\00"
@.str.6 = [19 x i8] c"Certificate Verify\00"
@.str.7 = [13 x i8] c"Server Hello\00"
@.str.8 = [18 x i8] c"Server Hello Done\00"
@.str.9 = [20 x i8] c"Client Key Exchange\00"
@.str.10 = [20 x i8] c"Server Key Exchange\00"
@.str.11 = [28 x i8] c"Encrypted Handshake Message\00"
@.str.12 = [19 x i8] c"Change Cipher Spec\00"
@.str.13 = [17 x i8] c"Application Data\00"
@.str.14 = [6 x i8] c"Alert\00"
@.str.15 = [8 x i8] c"Unknown\00"
@reltable.GetRecordType = [17 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.1 to i64), i64 ptrtoint ([17 x i32]* @reltable.GetRecordType to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str to i64), i64 ptrtoint ([17 x i32]* @reltable.GetRecordType to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.7 to i64), i64 ptrtoint ([17 x i32]* @reltable.GetRecordType to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([21 x i8]* @.str.2 to i64), i64 ptrtoint ([17 x i32]* @reltable.GetRecordType to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str.3 to i64), i64 ptrtoint ([17 x i32]* @reltable.GetRecordType to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([28 x i8]* @.str.11 to i64), i64 ptrtoint ([17 x i32]* @reltable.GetRecordType to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([28 x i8]* @.str.11 to i64), i64 ptrtoint ([17 x i32]* @reltable.GetRecordType to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([28 x i8]* @.str.11 to i64), i64 ptrtoint ([17 x i32]* @reltable.GetRecordType to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([28 x i8]* @.str.11 to i64), i64 ptrtoint ([17 x i32]* @reltable.GetRecordType to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([28 x i8]* @.str.11 to i64), i64 ptrtoint ([17 x i32]* @reltable.GetRecordType to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([28 x i8]* @.str.11 to i64), i64 ptrtoint ([17 x i32]* @reltable.GetRecordType to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.4 to i64), i64 ptrtoint ([17 x i32]* @reltable.GetRecordType to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([20 x i8]* @.str.10 to i64), i64 ptrtoint ([17 x i32]* @reltable.GetRecordType to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([20 x i8]* @.str.5 to i64), i64 ptrtoint ([17 x i32]* @reltable.GetRecordType to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.8 to i64), i64 ptrtoint ([17 x i32]* @reltable.GetRecordType to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str.6 to i64), i64 ptrtoint ([17 x i32]* @reltable.GetRecordType to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([20 x i8]* @.str.9 to i64), i64 ptrtoint ([17 x i32]* @reltable.GetRecordType to i64)) to i32)]
define i8* @GetRecordType(i8* nocapture %0) {
%2 = load i8, i8* %0
switch i8 %2, label %9 [
i8 22, label %3
i8 20, label %14
i8 23, label %7
i8 21, label %8
]
3: ; preds = %1
%4 = getelementptr inbounds i8, i8* %0, i64 13
%5 = load i8, i8* %4
%6 = icmp ult i8 %5, 17
br i1 %6, label %10, label %14
7: ; preds = %1
br label %14
8: ; preds = %1
br label %14
9: ; preds = %1
br label %14
10: ; preds = %3
%11 = sext i8 %5 to i64
%12 = shl i64 %11, 2
%13 = call i8* @llvm.load.relative.i64(i8* bitcast ([17 x i32]* @reltable.GetRecordType to i8*), i64 %12)
br label %14
14: ; preds = %3, %10, %1, %9, %8, %7
%15 = phi i8* [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0), %7 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i64 0, i64 0), %8 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.15, i64 0, i64 0), %9 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0), %1 ], [ %13, %10 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0), %3 ]
ret i8* %15
}