double iterate(double x_n) {
  if (x_n >= (1.0 - 0.4) && x_n < 1.0) {
    return ((1.0 - x_n) / 0.4);
  } else if (x_n >= 0.5 && x_n < 1.0 - 0.4) {
    return ((1.0 - 0.4 - x_n) / (0.5 - 0.4));
  } else if (x_n >= 0.4 && x_n < 0.5) {
    return ((x_n - 0.4) / (0.5 - 0.4));
  } else {
    return (x_n / 0.4);
  }
}


x86 assembly (clang, -O0):
<iterate>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xeea(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1156 <iterate+0x56>
movsd  0xee0(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1156 <iterate+0x56>
movsd  0xecd(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  0xed0(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    120a <iterate+0x10a>
movsd  -0x10(%rbp),%xmm0
movsd  0xead(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11a3 <iterate+0xa3>
movsd  0xe8b(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11a3 <iterate+0xa3>
movsd  0xe78(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  0xe8b(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    120a <iterate+0x10a>
movsd  -0x10(%rbp),%xmm0
movsd  0xe68(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11f4 <iterate+0xf4>
movsd  0xe4e(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11f4 <iterate+0xf4>
movsd  -0x10(%rbp),%xmm0
movsd  0xe3e(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xe3a(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    120a <iterate+0x10a>
movsd  -0x10(%rbp),%xmm0
movsd  0xe17(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<iterate>:
ucomisd 0xef8(%rip),%xmm0
jb     1129 <iterate+0x29>
movsd  0xef6(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1129 <iterate+0x29>
subsd  %xmm0,%xmm1
divsd  0xef4(%rip),%xmm1
movapd %xmm1,%xmm0
ret
ucomisd 0xedf(%rip),%xmm0
jb     1152 <iterate+0x52>
movsd  0xec5(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1152 <iterate+0x52>
subsd  %xmm0,%xmm1
divsd  0xedb(%rip),%xmm1
movapd %xmm1,%xmm0
ret
ucomisd 0xebe(%rip),%xmm0
jb     117b <iterate+0x7b>
movsd  0xeac(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    117b <iterate+0x7b>
addsd  0xeae(%rip),%xmm0
divsd  0xeae(%rip),%xmm0
ret
divsd  0xe95(%rip),%xmm0
ret

LLVM IR (-O0):
define double @iterate(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %3
%4 = load double, double* %3
%5 = fcmp oge double %4, 6.000000e-01
br i1 %5, label %6, label %13
6: ; preds = %1
%7 = load double, double* %3
%8 = fcmp olt double %7, 1.000000e+00
br i1 %8, label %9, label %13
9: ; preds = %6
%10 = load double, double* %3
%11 = fsub double 1.000000e+00, %10
%12 = fdiv double %11, 4.000000e-01
store double %12, double* %2
br label %36
13: ; preds = %6, %1
%14 = load double, double* %3
%15 = fcmp oge double %14, 5.000000e-01
br i1 %15, label %16, label %23
16: ; preds = %13
%17 = load double, double* %3
%18 = fcmp olt double %17, 6.000000e-01
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = load double, double* %3
%21 = fsub double 6.000000e-01, %20
%22 = fdiv double %21, 0x3FB9999999999998
store double %22, double* %2
br label %36
23: ; preds = %16, %13
%24 = load double, double* %3
%25 = fcmp oge double %24, 4.000000e-01
br i1 %25, label %26, label %33
26: ; preds = %23
%27 = load double, double* %3
%28 = fcmp olt double %27, 5.000000e-01
br i1 %28, label %29, label %33
29: ; preds = %26
%30 = load double, double* %3
%31 = fsub double %30, 4.000000e-01
%32 = fdiv double %31, 0x3FB9999999999998
store double %32, double* %2
br label %36
33: ; preds = %26, %23
%34 = load double, double* %3
%35 = fdiv double %34, 4.000000e-01
store double %35, double* %2
br label %36
36: ; preds = %33, %29, %19, %9
%37 = load double, double* %2
ret double %37
}

LLVM IR (-O2):
define double @iterate(double %0) {
%2 = fcmp oge double %0, 6.000000e-01
%3 = fcmp olt double %0, 1.000000e+00
%4 = and i1 %2, %3
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = fsub double 1.000000e+00, %0
%7 = fdiv double %6, 4.000000e-01
br label %24
8: ; preds = %1
%9 = fcmp oge double %0, 5.000000e-01
%10 = fcmp olt double %0, 6.000000e-01
%11 = and i1 %9, %10
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = fsub double 6.000000e-01, %0
%14 = fdiv double %13, 0x3FB9999999999998
br label %24
15: ; preds = %8
%16 = fcmp oge double %0, 4.000000e-01
%17 = fcmp olt double %0, 5.000000e-01
%18 = and i1 %16, %17
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = fadd double %0, -4.000000e-01
%21 = fdiv double %20, 0x3FB9999999999998
br label %24
22: ; preds = %15
%23 = fdiv double %0, 4.000000e-01
br label %24
24: ; preds = %22, %19, %12, %5
%25 = phi double [ %7, %5 ], [ %14, %12 ], [ %21, %19 ], [ %23, %22 ]
ret double %25
}