char *GetEapolMsgType(char msg) {
  if (msg == 1)
    return "Pairwise Message 1";
  else if (msg == 2)
    return "Pairwise Message 2";
  else if (msg == 3)
    return "Pairwise Message 3";
  else if (msg == 4)
    return "Pairwise Message 4";
  else if (msg == 5)
    return "Group Message 1";
  else if (msg == 6)
    return "Group Message 2";
  else
    return "Invalid Message";
}


x86 assembly (clang, -O0):
<GetEapolMsgType>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0x1,%eax
jne    1127 <GetEapolMsgType+0x27>
lea    0xee2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11c3 <GetEapolMsgType+0xc3>
movsbl -0x9(%rbp),%eax
cmp    $0x2,%eax
jne    1144 <GetEapolMsgType+0x44>
lea    0xed8(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11c3 <GetEapolMsgType+0xc3>
movsbl -0x9(%rbp),%eax
cmp    $0x3,%eax
jne    1161 <GetEapolMsgType+0x61>
lea    0xece(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11c3 <GetEapolMsgType+0xc3>
movsbl -0x9(%rbp),%eax
cmp    $0x4,%eax
jne    117e <GetEapolMsgType+0x7e>
lea    0xec4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11c3 <GetEapolMsgType+0xc3>
movsbl -0x9(%rbp),%eax
cmp    $0x5,%eax
jne    119b <GetEapolMsgType+0x9b>
lea    0xeba(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11c3 <GetEapolMsgType+0xc3>
movsbl -0x9(%rbp),%eax
cmp    $0x6,%eax
jne    11b8 <GetEapolMsgType+0xb8>
lea    0xead(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11c3 <GetEapolMsgType+0xc3>
lea    0xead(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetEapolMsgType>:
add    $0xff,%dil
cmp    $0x5,%dil
ja     111d <GetEapolMsgType+0x1d>
movsbq %dil,%rax
lea    0xf67(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
ret
lea    0xf48(%rip),%rax
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Pairwise Message 1\00"
@.str.1 = [19 x i8] c"Pairwise Message 2\00"
@.str.2 = [19 x i8] c"Pairwise Message 3\00"
@.str.3 = [19 x i8] c"Pairwise Message 4\00"
@.str.4 = [16 x i8] c"Group Message 1\00"
@.str.5 = [16 x i8] c"Group Message 2\00"
@.str.6 = [16 x i8] c"Invalid Message\00"
define i8* @GetEapolMsgType(i8 signext %0) {
%2 = alloca i8*
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = sext i8 %4 to i32
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %8
7: ; preds = %1
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8** %2
br label %34
8: ; preds = %1
%9 = load i8, i8* %3
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 2
br i1 %11, label %12, label %13
12: ; preds = %8
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %34
13: ; preds = %8
%14 = load i8, i8* %3
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 3
br i1 %16, label %17, label %18
17: ; preds = %13
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %34
18: ; preds = %13
%19 = load i8, i8* %3
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 4
br i1 %21, label %22, label %23
22: ; preds = %18
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %34
23: ; preds = %18
%24 = load i8, i8* %3
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 5
br i1 %26, label %27, label %28
27: ; preds = %23
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %34
28: ; preds = %23
%29 = load i8, i8* %3
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 6
br i1 %31, label %32, label %33
32: ; preds = %28
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %34
33: ; preds = %28
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %34
34: ; preds = %33, %32, %27, %22, %17, %12, %7
%35 = load i8*, i8** %2
ret i8* %35
}

LLVM IR (-O2):
@.str = [19 x i8] c"Pairwise Message 1\00"
@.str.1 = [19 x i8] c"Pairwise Message 2\00"
@.str.2 = [19 x i8] c"Pairwise Message 3\00"
@.str.3 = [19 x i8] c"Pairwise Message 4\00"
@.str.4 = [16 x i8] c"Group Message 1\00"
@.str.5 = [16 x i8] c"Group Message 2\00"
@.str.6 = [16 x i8] c"Invalid Message\00"
@reltable.GetEapolMsgType = [6 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str to i64), i64 ptrtoint ([6 x i32]* @reltable.GetEapolMsgType to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str.1 to i64), i64 ptrtoint ([6 x i32]* @reltable.GetEapolMsgType to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str.2 to i64), i64 ptrtoint ([6 x i32]* @reltable.GetEapolMsgType to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str.3 to i64), i64 ptrtoint ([6 x i32]* @reltable.GetEapolMsgType to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([16 x i8]* @.str.4 to i64), i64 ptrtoint ([6 x i32]* @reltable.GetEapolMsgType to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([16 x i8]* @.str.5 to i64), i64 ptrtoint ([6 x i32]* @reltable.GetEapolMsgType to i64)) to i32)]
define i8* @GetEapolMsgType(i8 signext %0) {
%2 = add i8 %0, -1
%3 = icmp ult i8 %2, 6
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = sext i8 %2 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([6 x i32]* @reltable.GetEapolMsgType to i8*), i64 %6)
br label %8
8: ; preds = %1, %4
%9 = phi i8* [ %7, %4 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), %1 ]
ret i8* %9
}