double MAP_PIECEWISE(double x_n, int iteration) {
  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):
<MAP_PIECEWISE>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xee7(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1159 <MAP_PIECEWISE+0x59>
movsd  0xedd(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1159 <MAP_PIECEWISE+0x59>
movsd  0xeca(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  0xecd(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    120d <MAP_PIECEWISE+0x10d>
movsd  -0x10(%rbp),%xmm0
movsd  0xeaa(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11a6 <MAP_PIECEWISE+0xa6>
movsd  0xe88(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11a6 <MAP_PIECEWISE+0xa6>
movsd  0xe75(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  0xe88(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    120d <MAP_PIECEWISE+0x10d>
movsd  -0x10(%rbp),%xmm0
movsd  0xe65(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11f7 <MAP_PIECEWISE+0xf7>
movsd  0xe4b(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11f7 <MAP_PIECEWISE+0xf7>
movsd  -0x10(%rbp),%xmm0
movsd  0xe3b(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xe37(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    120d <MAP_PIECEWISE+0x10d>
movsd  -0x10(%rbp),%xmm0
movsd  0xe14(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

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

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

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