double smoothStep(double a, double b, double x) {
  if (x < a)
    return 0;
  if (x >= b)
    return 1;
  x = (x - a) / (b - a);
  return x * x * (3 - 2 * x);
}


x86 assembly (clang, -O0):
<smoothStep>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1134 <smoothStep+0x34>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    119b <smoothStep+0x9b>
movsd  -0x20(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     1156 <smoothStep+0x56>
movsd  0xebc(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    119b <smoothStep+0x9b>
movsd  -0x20(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
addsd  %xmm2,%xmm2
movsd  0xe72(%rip),%xmm1
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<smoothStep>:
movapd %xmm0,%xmm3
xorpd  %xmm0,%xmm0
ucomisd %xmm2,%xmm3
ja     113c <smoothStep+0x3c>
ucomisd %xmm1,%xmm2
jae    113d <smoothStep+0x3d>
subsd  %xmm3,%xmm2
subsd  %xmm3,%xmm1
divsd  %xmm1,%xmm2
movapd %xmm2,%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm2,%xmm2
movsd  0xed4(%rip),%xmm0
subsd  %xmm2,%xmm0
mulsd  %xmm1,%xmm0
ret
movsd  0xebb(%rip),%xmm0
ret

LLVM IR (-O0):
define double @smoothStep(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
%8 = load double, double* %7
%9 = load double, double* %5
%10 = fcmp olt double %8, %9
br i1 %10, label %11, label %12
11: ; preds = %3
store double 0.000000e+00, double* %4
br label %31
12: ; preds = %3
%13 = load double, double* %7
%14 = load double, double* %6
%15 = fcmp oge double %13, %14
br i1 %15, label %16, label %17
16: ; preds = %12
store double 1.000000e+00, double* %4
br label %31
17: ; preds = %12
%18 = load double, double* %7
%19 = load double, double* %5
%20 = fsub double %18, %19
%21 = load double, double* %6
%22 = load double, double* %5
%23 = fsub double %21, %22
%24 = fdiv double %20, %23
store double %24, double* %7
%25 = load double, double* %7
%26 = load double, double* %7
%27 = fmul double %25, %26
%28 = load double, double* %7
%29 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %28, double 3.000000e+00)
%30 = fmul double %27, %29
store double %30, double* %4
br label %31
31: ; preds = %17, %16, %11
%32 = load double, double* %4
ret double %32
}

LLVM IR (-O2):
define double @smoothStep(double %0, double %1, double %2) {
%4 = fcmp olt double %2, %0
br i1 %4, label %14, label %5
5: ; preds = %3
%6 = fcmp ult double %2, %1
br i1 %6, label %7, label %14
7: ; preds = %5
%8 = fsub double %2, %0
%9 = fsub double %1, %0
%10 = fdiv double %8, %9
%11 = fmul double %10, %10
%12 = tail call double @llvm.fmuladd.f64(double %10, double -2.000000e+00, double 3.000000e+00)
%13 = fmul double %11, %12
br label %14
14: ; preds = %5, %3, %7
%15 = phi double [ %13, %7 ], [ 0.000000e+00, %3 ], [ 1.000000e+00, %5 ]
ret double %15
}