char *units_name(int units) {
  switch (units) {
  case 0:
    return "times";
  case 1:
    return "seconds";
  case 60:
    return "minutes";
  case 3600:
    return "hours";
  case 86400:
    return "days";
  default:
    return "???";
  }
}


x86 assembly (clang, -O0):
<units_name>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
test   %eax,%eax
je     1162 <units_name+0x62>
jmp    111a <units_name+0x1a>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
je     1172 <units_name+0x72>
jmp    112b <units_name+0x2b>
mov    -0x10(%rbp),%eax
sub    $0x3c,%eax
je     1182 <units_name+0x82>
jmp    113c <units_name+0x3c>
mov    -0x10(%rbp),%eax
sub    $0xe10,%eax
je     1192 <units_name+0x92>
jmp    114f <units_name+0x4f>
mov    -0x10(%rbp),%eax
sub    $0x15180,%eax
je     11a2 <units_name+0xa2>
jmp    11b2 <units_name+0xb2>
lea    0xe97(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11bd <units_name+0xbd>
lea    0xe8d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11bd <units_name+0xbd>
lea    0xe85(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11bd <units_name+0xbd>
lea    0xe7d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11bd <units_name+0xbd>
lea    0xe73(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11bd <units_name+0xbd>
lea    0xe68(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<units_name>:
cmp    $0x3b,%edi
jle    1122 <units_name+0x22>
cmp    $0x3c,%edi
je     1133 <units_name+0x33>
cmp    $0xe10,%edi
je     113b <units_name+0x3b>
cmp    $0x15180,%edi
jne    114b <units_name+0x4b>
lea    0xefb(%rip),%rax
ret
test   %edi,%edi
je     1143 <units_name+0x43>
cmp    $0x1,%edi
jne    114b <units_name+0x4b>
lea    0xed4(%rip),%rax
ret
lea    0xed4(%rip),%rax
ret
lea    0xed4(%rip),%rax
ret
lea    0xeb6(%rip),%rax
ret
lea    0xecf(%rip),%rax
ret

LLVM IR (-O0):
@.str = [6 x i8] c"times\00"
@.str.1 = [8 x i8] c"seconds\00"
@.str.2 = [8 x i8] c"minutes\00"
@.str.3 = [6 x i8] c"hours\00"
@.str.4 = [5 x i8] c"days\00"
@.str.5 = [4 x i8] c"???\00"
define i8* @units_name(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %10 [
i32 0, label %5
i32 1, label %6
i32 60, label %7
i32 3600, label %8
i32 86400, label %9
]
5: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %2
br label %11
6: ; preds = %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %11
7: ; preds = %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %11
8: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %11
9: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %11
10: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %11
11: ; preds = %10, %9, %8, %7, %6, %5
%12 = load i8*, i8** %2
ret i8* %12
}

LLVM IR (-O2):
@.str = [6 x i8] c"times\00"
@.str.1 = [8 x i8] c"seconds\00"
@.str.2 = [8 x i8] c"minutes\00"
@.str.3 = [6 x i8] c"hours\00"
@.str.4 = [5 x i8] c"days\00"
@.str.5 = [4 x i8] c"???\00"
define i8* @units_name(i32 %0) {
switch i32 %0, label %6 [
i32 0, label %7
i32 1, label %2
i32 60, label %3
i32 3600, label %4
i32 86400, label %5
]
2: ; preds = %1
br label %7
3: ; preds = %1
br label %7
4: ; preds = %1
br label %7
5: ; preds = %1
br label %7
6: ; preds = %1
br label %7
7: ; preds = %1, %6, %5, %4, %3, %2
%8 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), %6 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), %5 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), %4 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), %3 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %8
}