const char *getMessageName(int i) {
  switch (i) {
  case 1:
    return "CLIENT_VALUE";
  case 2:
    return "PROPOSAL";
  case 4:
    return "ACCEPTED_PROPOSAL";
  case 8:
    return "REJECTED_PROPOSAL";
  case 16:
    return "ACCEPTOR_SET";
  case 32:
    return "SET";
  case 64:
    return "GET";
  case 128:
    return "READ_SUCCESS";
  case 256:
    return "READ_FAILED";
  case 512:
    return "WRITE_SUCCESS";
  case 1024:
    return "WRITE_FAILED";
  case 2048:
    return "EXIT";
  default:
    return "UNKNOWN";
  }
}


x86 assembly (clang, -O0):
<getMessageName>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0x1,%eax
je     11e0 <getMessageName+0xe0>
jmp    111b <getMessageName+0x1b>
mov    -0x10(%rbp),%eax
sub    $0x2,%eax
je     11f0 <getMessageName+0xf0>
jmp    112c <getMessageName+0x2c>
mov    -0x10(%rbp),%eax
sub    $0x4,%eax
je     1200 <getMessageName+0x100>
jmp    113d <getMessageName+0x3d>
mov    -0x10(%rbp),%eax
sub    $0x8,%eax
je     1210 <getMessageName+0x110>
jmp    114e <getMessageName+0x4e>
mov    -0x10(%rbp),%eax
sub    $0x10,%eax
je     1220 <getMessageName+0x120>
jmp    115f <getMessageName+0x5f>
mov    -0x10(%rbp),%eax
sub    $0x20,%eax
je     1230 <getMessageName+0x130>
jmp    1170 <getMessageName+0x70>
mov    -0x10(%rbp),%eax
sub    $0x40,%eax
je     1240 <getMessageName+0x140>
jmp    1181 <getMessageName+0x81>
mov    -0x10(%rbp),%eax
sub    $0x80,%eax
je     1250 <getMessageName+0x150>
jmp    1194 <getMessageName+0x94>
mov    -0x10(%rbp),%eax
sub    $0x100,%eax
je     1260 <getMessageName+0x160>
jmp    11a7 <getMessageName+0xa7>
mov    -0x10(%rbp),%eax
sub    $0x200,%eax
je     1270 <getMessageName+0x170>
jmp    11ba <getMessageName+0xba>
mov    -0x10(%rbp),%eax
sub    $0x400,%eax
je     1280 <getMessageName+0x180>
jmp    11cd <getMessageName+0xcd>
mov    -0x10(%rbp),%eax
sub    $0x800,%eax
je     1290 <getMessageName+0x190>
jmp    12a0 <getMessageName+0x1a0>
lea    0xe19(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12ab <getMessageName+0x1ab>
lea    0xe31(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12ab <getMessageName+0x1ab>
lea    0xe06(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12ab <getMessageName+0x1ab>
lea    0xe08(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12ab <getMessageName+0x1ab>
lea    0xe0a(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12ab <getMessageName+0x1ab>
lea    0xe03(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12ab <getMessageName+0x1ab>
lea    0xdf7(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12ab <getMessageName+0x1ab>
lea    0xdeb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12ab <getMessageName+0x1ab>
lea    0xde8(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12ab <getMessageName+0x1ab>
lea    0xde4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12ab <getMessageName+0x1ab>
lea    0xde2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12ab <getMessageName+0x1ab>
lea    0xddf(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    12ab <getMessageName+0x1ab>
lea    0xdd4(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<getMessageName>:
cmp    $0x7f,%edi
jg     1130 <getMessageName+0x30>
add    $0xffffffff,%edi
cmp    $0x3f,%edi
ja     11b0 <getMessageName+0xb0>
lea    0xfe8(%rip),%rax
lea    0xee1(%rip),%rcx
movslq (%rcx,%rdi,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
lea    0xff9(%rip),%rax
ret
cmp    $0x1ff,%edi
jle    1158 <getMessageName+0x58>
cmp    $0x200,%edi
je     1198 <getMessageName+0x98>
cmp    $0x400,%edi
je     11a0 <getMessageName+0xa0>
cmp    $0x800,%edi
jne    11b0 <getMessageName+0xb0>
lea    0x101f(%rip),%rax
ret
cmp    $0x80,%edi
je     11a8 <getMessageName+0xa8>
cmp    $0x100,%edi
jne    11b0 <getMessageName+0xb0>
lea    0xfe0(%rip),%rax
ret
lea    0xf96(%rip),%rax
ret
lea    0xfa0(%rip),%rax
ret
lea    0xfaa(%rip),%rax
ret
lea    0xfab(%rip),%rax
ret
lea    0xfa7(%rip),%rax
ret
lea    0xfbc(%rip),%rax
ret
lea    0xfc2(%rip),%rax
ret
lea    0xf93(%rip),%rax
ret
lea    0xfc4(%rip),%rax
ret

LLVM IR (-O0):
@.str = [13 x i8] c"CLIENT_VALUE\00"
@.str.1 = [9 x i8] c"PROPOSAL\00"
@.str.2 = [18 x i8] c"ACCEPTED_PROPOSAL\00"
@.str.3 = [18 x i8] c"REJECTED_PROPOSAL\00"
@.str.4 = [13 x i8] c"ACCEPTOR_SET\00"
@.str.5 = [4 x i8] c"SET\00"
@.str.6 = [4 x i8] c"GET\00"
@.str.7 = [13 x i8] c"READ_SUCCESS\00"
@.str.8 = [12 x i8] c"READ_FAILED\00"
@.str.9 = [14 x i8] c"WRITE_SUCCESS\00"
@.str.10 = [13 x i8] c"WRITE_FAILED\00"
@.str.11 = [5 x i8] c"EXIT\00"
@.str.12 = [8 x i8] c"UNKNOWN\00"
define i8* @getMessageName(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %17 [
i32 1, label %5
i32 2, label %6
i32 4, label %7
i32 8, label %8
i32 16, label %9
i32 32, label %10
i32 64, label %11
i32 128, label %12
i32 256, label %13
i32 512, label %14
i32 1024, label %15
i32 2048, label %16
]
5: ; preds = %1
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %2
br label %18
6: ; preds = %1
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %18
7: ; preds = %1
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %18
8: ; preds = %1
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %18
9: ; preds = %1
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %18
10: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %18
11: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %18
12: ; preds = %1
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %18
13: ; preds = %1
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i8** %2
br label %18
14: ; preds = %1
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i8** %2
br label %18
15: ; preds = %1
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0), i8** %2
br label %18
16: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0), i8** %2
br label %18
17: ; preds = %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0), i8** %2
br label %18
18: ; preds = %17, %16, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5
%19 = load i8*, i8** %2
ret i8* %19
}

LLVM IR (-O2):
@.str = [13 x i8] c"CLIENT_VALUE\00"
@.str.1 = [9 x i8] c"PROPOSAL\00"
@.str.2 = [18 x i8] c"ACCEPTED_PROPOSAL\00"
@.str.3 = [18 x i8] c"REJECTED_PROPOSAL\00"
@.str.4 = [13 x i8] c"ACCEPTOR_SET\00"
@.str.5 = [4 x i8] c"SET\00"
@.str.6 = [4 x i8] c"GET\00"
@.str.7 = [13 x i8] c"READ_SUCCESS\00"
@.str.8 = [12 x i8] c"READ_FAILED\00"
@.str.9 = [14 x i8] c"WRITE_SUCCESS\00"
@.str.10 = [13 x i8] c"WRITE_FAILED\00"
@.str.11 = [5 x i8] c"EXIT\00"
@.str.12 = [8 x i8] c"UNKNOWN\00"
define i8* @getMessageName(i32 %0) {
switch i32 %0, label %13 [
i32 1, label %14
i32 2, label %2
i32 4, label %3
i32 8, label %4
i32 16, label %5
i32 32, label %6
i32 64, label %7
i32 128, label %8
i32 256, label %9
i32 512, label %10
i32 1024, label %11
i32 2048, label %12
]
2: ; preds = %1
br label %14
3: ; preds = %1
br label %14
4: ; preds = %1
br label %14
5: ; preds = %1
br label %14
6: ; preds = %1
br label %14
7: ; preds = %1
br label %14
8: ; preds = %1
br label %14
9: ; preds = %1
br label %14
10: ; preds = %1
br label %14
11: ; preds = %1
br label %14
12: ; preds = %1
br label %14
13: ; preds = %1
br label %14
14: ; preds = %1, %13, %12, %11, %10, %9, %8, %7, %6, %5, %4, %3, %2
%15 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0), %13 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0), %12 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0), %11 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), %10 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), %9 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), %8 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), %7 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), %6 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), %5 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), %4 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), %3 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %15
}