char *time_unit(double t) {
  if (t > 60.0 * 60.0)
    return "h";
  if (t > 60)
    return "m";
  if (t < 0.0001)
    return "us";
  if (t < 0.1)
    return "ms";
  return "s";
}


x86 assembly (clang, -O0):
<time_unit>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xeea(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1130 <time_unit+0x30>
lea    0xef9(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11a8 <time_unit+0xa8>
movsd  -0x10(%rbp),%xmm0
movsd  0xecb(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1157 <time_unit+0x57>
lea    0xed4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11a8 <time_unit+0xa8>
movsd  0xeb1(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    117a <time_unit+0x7a>
lea    0xeb3(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11a8 <time_unit+0xa8>
movsd  0xe96(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    119d <time_unit+0x9d>
lea    0xe93(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11a8 <time_unit+0xa8>
lea    0xe84(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<time_unit>:
ucomisd 0xef8(%rip),%xmm0
jbe    1112 <time_unit+0x12>
lea    0xf0f(%rip),%rax
ret
ucomisd 0xeee(%rip),%xmm0
jbe    1124 <time_unit+0x24>
lea    0xeff(%rip),%rax
ret
movsd  0xee4(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    113a <time_unit+0x3a>
lea    0xeeb(%rip),%rax
ret
movsd  0xed6(%rip),%xmm1
ucomisd %xmm0,%xmm1
lea    0xeda(%rip),%rcx
lea    0xed4(%rip),%rax
cmova  %rcx,%rax
ret

LLVM IR (-O0):
@.str = [2 x i8] c"h\00"
@.str.1 = [2 x i8] c"m\00"
@.str.2 = [3 x i8] c"us\00"
@.str.3 = [3 x i8] c"ms\00"
@.str.4 = [2 x i8] c"s\00"
define i8* @time_unit(double %0) {
%2 = alloca i8*
%3 = alloca double
store double %0, double* %3
%4 = load double, double* %3
%5 = fcmp ogt double %4, 3.600000e+03
br i1 %5, label %6, label %7
6: ; preds = %1
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %2
br label %20
7: ; preds = %1
%8 = load double, double* %3
%9 = fcmp ogt double %8, 6.000000e+01
br i1 %9, label %10, label %11
10: ; preds = %7
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %20
11: ; preds = %7
%12 = load double, double* %3
%13 = fcmp olt double %12, 1.000000e-04
br i1 %13, label %14, label %15
14: ; preds = %11
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %20
15: ; preds = %11
%16 = load double, double* %3
%17 = fcmp olt double %16, 1.000000e-01
br i1 %17, label %18, label %19
18: ; preds = %15
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %20
19: ; preds = %15
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %20
20: ; preds = %19, %18, %14, %10, %6
%21 = load i8*, i8** %2
ret i8* %21
}

LLVM IR (-O2):
@.str = [2 x i8] c"h\00"
@.str.1 = [2 x i8] c"m\00"
@.str.2 = [3 x i8] c"us\00"
@.str.3 = [3 x i8] c"ms\00"
@.str.4 = [2 x i8] c"s\00"
define i8* @time_unit(double %0) {
%2 = fcmp ogt double %0, 3.600000e+03
br i1 %2, label %10, label %3
3: ; preds = %1
%4 = fcmp ogt double %0, 6.000000e+01
br i1 %4, label %10, label %5
5: ; preds = %3
%6 = fcmp olt double %0, 1.000000e-04
br i1 %6, label %10, label %7
7: ; preds = %5
%8 = fcmp olt double %0, 1.000000e-01
%9 = select i1 %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0)
br label %10
10: ; preds = %7, %5, %3, %1
%11 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), %3 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), %5 ], [ %9, %7 ]
ret i8* %11
}