char *likert(x, y)
int x, y;
{
  switch ((x / y)) {
  case -3:
  case -2:
  case -1:
    return ("Very Bad");
  case 0:
  case 1:
    return ("Bad");
  case 2:
    return ("Poor");
  case 3:
  case 4:
    return ("Fair");
  case 5:
    return ("Good");
  case 6:
    return ("Very Good");
  case 7:
  case 8:
    return ("Excellent");
  default:
    return ("Superb");
  }
}


x86 assembly (clang, -O0):
<likert>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x10(%rbp),%ecx
cltd
idiv   %ecx
add    $0x3,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0xb,%eax
ja     11a9 <likert+0xa9>
mov    -0x18(%rbp),%rax
lea    0xed0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xef0(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11b4 <likert+0xb4>
lea    0xee5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11b4 <likert+0xb4>
lea    0xed9(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11b4 <likert+0xb4>
lea    0xece(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11b4 <likert+0xb4>
lea    0xec8(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11b4 <likert+0xb4>
lea    0xeb3(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11b4 <likert+0xb4>
lea    0xead(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11b4 <likert+0xb4>
lea    0xea7(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<likert>:
mov    %edi,%eax
cltd
idiv   %esi
add    $0x3,%eax
cmp    $0xb,%eax
ja     111e <likert+0x1e>
cltq
lea    0xf1a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
ret
lea    0xf02(%rip),%rax
ret

LLVM IR (-O0):
@.str = [9 x i8] c"Very Bad\00"
@.str.1 = [4 x i8] c"Bad\00"
@.str.2 = [5 x i8] c"Poor\00"
@.str.3 = [5 x i8] c"Fair\00"
@.str.4 = [5 x i8] c"Good\00"
@.str.5 = [10 x i8] c"Very Good\00"
@.str.6 = [10 x i8] c"Excellent\00"
@.str.7 = [7 x i8] c"Superb\00"
define i8* @likert(i32 %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %4
%7 = load i32, i32* %5
%8 = sdiv i32 %6, %7
switch i32 %8, label %16 [
i32 -3, label %9
i32 -2, label %9
i32 -1, label %9
i32 0, label %10
i32 1, label %10
i32 2, label %11
i32 3, label %12
i32 4, label %12
i32 5, label %13
i32 6, label %14
i32 7, label %15
i32 8, label %15
]
9: ; preds = %2, %2, %2
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8** %3
br label %17
10: ; preds = %2, %2
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %17
11: ; preds = %2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %17
12: ; preds = %2, %2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %3
br label %17
13: ; preds = %2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8** %3
br label %17
14: ; preds = %2
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8** %3
br label %17
15: ; preds = %2, %2
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8** %3
br label %17
16: ; preds = %2
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8** %3
br label %17
17: ; preds = %16, %15, %14, %13, %12, %11, %10, %9
%18 = load i8*, i8** %3
ret i8* %18
}

LLVM IR (-O2):
@.str = [9 x i8] c"Very Bad\00"
@.str.1 = [4 x i8] c"Bad\00"
@.str.2 = [5 x i8] c"Poor\00"
@.str.3 = [5 x i8] c"Fair\00"
@.str.4 = [5 x i8] c"Good\00"
@.str.5 = [10 x i8] c"Very Good\00"
@.str.6 = [10 x i8] c"Excellent\00"
@.str.7 = [7 x i8] c"Superb\00"
@reltable.likert = [12 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str to i64), i64 ptrtoint ([12 x i32]* @reltable.likert to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str to i64), i64 ptrtoint ([12 x i32]* @reltable.likert to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str to i64), i64 ptrtoint ([12 x i32]* @reltable.likert to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.1 to i64), i64 ptrtoint ([12 x i32]* @reltable.likert to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.1 to i64), i64 ptrtoint ([12 x i32]* @reltable.likert to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.2 to i64), i64 ptrtoint ([12 x i32]* @reltable.likert to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.3 to i64), i64 ptrtoint ([12 x i32]* @reltable.likert to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.3 to i64), i64 ptrtoint ([12 x i32]* @reltable.likert to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.4 to i64), i64 ptrtoint ([12 x i32]* @reltable.likert to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.5 to i64), i64 ptrtoint ([12 x i32]* @reltable.likert to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.6 to i64), i64 ptrtoint ([12 x i32]* @reltable.likert to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.6 to i64), i64 ptrtoint ([12 x i32]* @reltable.likert to i64)) to i32)]
define i8* @likert(i32 %0, i32 %1) {
%3 = sdiv i32 %0, %1
%4 = add i32 %3, 3
%5 = icmp ult i32 %4, 12
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = sext i32 %4 to i64
%8 = shl i64 %7, 2
%9 = call i8* @llvm.load.relative.i64(i8* bitcast ([12 x i32]* @reltable.likert to i8*), i64 %8)
br label %10
10: ; preds = %2, %6
%11 = phi i8* [ %9, %6 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), %2 ]
ret i8* %11
}