int main() {
  double a, y;
  while (~scanf("%lf", &a)) {
    if (a < 2)
      y = 2.5 - a;
    else if (a < 4)
      y = 2 - 1.5 * (a - 3) * (a - 3);
    else
      y = a / 2 - 1.5;
    printf("%.3lf\n", y);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xef2(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
xor    $0xffffffff,%eax
cmp    $0x0,%eax
je     1228 <main+0x108>
movsd  0xeab(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1177 <main+0x57>
movsd  0xeb8(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1210 <main+0xf0>
movsd  0xe89(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11e9 <main+0xc9>
movsd  -0x10(%rbp),%xmm1
movsd  0xe81(%rip),%xmm0
subsd  %xmm0,%xmm1
movsd  0xe6d(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  0xe64(%rip),%xmm2
subsd  %xmm2,%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe25(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    120b <main+0xeb>
movsd  -0x10(%rbp),%xmm0
movsd  0xe0a(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe0e(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1210 <main+0xf0>
movsd  -0x18(%rbp),%xmm0
lea    0xe10(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    112f <main+0xf>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xf00(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmp    $0xffffffff,%eax
je     11e6 <main+0xc6>
lea    0xee8(%rip),%r14
lea    0xedd(%rip),%r15
lea    0x8(%rsp),%rbx
jmp    1188 <main+0x68>
nopw   0x0(%rax,%rax,1)
movsd  0xec0(%rip),%xmm0
subsd  %xmm1,%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmp    $0xffffffff,%eax
je     11e6 <main+0xc6>
movsd  0x8(%rsp),%xmm1
movsd  0xe6a(%rip),%xmm0
ucomisd %xmm1,%xmm0
ja     1160 <main+0x40>
movsd  0xe64(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11d0 <main+0xb0>
addsd  0xe6e(%rip),%xmm1
movapd %xmm1,%xmm0
mulsd  0xe5a(%rip),%xmm0
mulsd  %xmm1,%xmm0
addsd  0xe36(%rip),%xmm0
jmp    116c <main+0x4c>
nopl   0x0(%rax)
mulsd  0xe38(%rip),%xmm1
addsd  0xe38(%rip),%xmm1
movapd %xmm1,%xmm0
jmp    116c <main+0x4c>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%lf\00"
@.str.1 = [7 x i8] c"%.3lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
store i32 0, i32* %1
br label %4
4: ; preds = %30, %0
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %2)
%6 = xor i32 %5, -1
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %33
8: ; preds = %4
%9 = load double, double* %2
%10 = fcmp olt double %9, 2.000000e+00
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = load double, double* %2
%13 = fsub double 2.500000e+00, %12
store double %13, double* %3
br label %30
14: ; preds = %8
%15 = load double, double* %2
%16 = fcmp olt double %15, 4.000000e+00
br i1 %16, label %17, label %25
17: ; preds = %14
%18 = load double, double* %2
%19 = fsub double %18, 3.000000e+00
%20 = fmul double 1.500000e+00, %19
%21 = load double, double* %2
%22 = fsub double %21, 3.000000e+00
%23 = fneg double %20
%24 = call double @llvm.fmuladd.f64(double %23, double %22, double 2.000000e+00)
store double %24, double* %3
br label %29
25: ; preds = %14
%26 = load double, double* %2
%27 = fdiv double %26, 2.000000e+00
%28 = fsub double %27, 1.500000e+00
store double %28, double* %3
br label %29
29: ; preds = %25, %17
br label %30
30: ; preds = %29, %11
%31 = load double, double* %3
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %31)
br label %4
33: ; preds = %4
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%lf\00"
@.str.1 = [7 x i8] c"%.3lf\0A\00"
define i32 @main() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
%3 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %1)
%4 = icmp eq i32 %3, -1
br i1 %4, label %24, label %5
5: ; preds = %0, %19
%6 = load double, double* %1
%7 = fcmp olt double %6, 2.000000e+00
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = fsub double 2.500000e+00, %6
br label %19
10: ; preds = %5
%11 = fcmp olt double %6, 4.000000e+00
br i1 %11, label %12, label %16
12: ; preds = %10
%13 = fadd double %6, -3.000000e+00
%14 = fmul double %13, -1.500000e+00
%15 = call double @llvm.fmuladd.f64(double %14, double %13, double 2.000000e+00)
br label %19
16: ; preds = %10
%17 = fmul double %6, 5.000000e-01
%18 = fadd double %17, -1.500000e+00
br label %19
19: ; preds = %12, %16, %8
%20 = phi double [ %9, %8 ], [ %15, %12 ], [ %18, %16 ]
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %20)
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %1)
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %5
24: ; preds = %19, %0
ret i32 0
}