double save_money(double elecal) {
  if (elecal <= 2880)
    return elecal * 0.48;
  if (elecal > 2880 && elecal <= 4800)
    return 0.48 * 2880 + (elecal - 2880) * 0.53;
  if (elecal > 4800)
    return 0.48 * 2880 + 0.53 * 1920 + (elecal - 4800) * 0.78;
}


x86 assembly (clang, -O0):
<save_money>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  0xeef(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     1133 <save_money+0x33>
movsd  0xf0c(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11d5 <save_money+0xd5>
movsd  -0x10(%rbp),%xmm0
movsd  0xec0(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1190 <save_money+0x90>
movsd  0xeb6(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     1190 <save_money+0x90>
movsd  -0x10(%rbp),%xmm0
movsd  0xe96(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xeaa(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xea6(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11d5 <save_money+0xd5>
movsd  -0x10(%rbp),%xmm0
movsd  0xe6b(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11d5 <save_money+0xd5>
movsd  -0x10(%rbp),%xmm0
movsd  0xe54(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xe50(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe4c(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<save_money>:
movsd  0xef8(%rip),%xmm1
ucomisd %xmm0,%xmm1
jae    113f <save_money+0x3f>
ucomisd 0xeea(%rip),%xmm0
jbe    1148 <save_money+0x48>
movsd  0xef0(%rip),%xmm1
ucomisd %xmm0,%xmm1
jb     1148 <save_money+0x48>
addsd  0xf02(%rip),%xmm0
mulsd  0xf02(%rip),%xmm0
addsd  0xf02(%rip),%xmm0
ret
mulsd  0xec1(%rip),%xmm0
ret
ucomisd 0xec0(%rip),%xmm0
jbe    116a <save_money+0x6a>
addsd  0xebe(%rip),%xmm0
mulsd  0xebe(%rip),%xmm0
addsd  0xebe(%rip),%xmm0
ret

LLVM IR (-O0):
define double @save_money(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %3
%4 = load double, double* %3
%5 = fcmp ole double %4, 2.880000e+03
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = load double, double* %3
%8 = fmul double %7, 4.800000e-01
store double %8, double* %2
br label %26
9: ; preds = %1
%10 = load double, double* %3
%11 = fcmp ogt double %10, 2.880000e+03
br i1 %11, label %12, label %19
12: ; preds = %9
%13 = load double, double* %3
%14 = fcmp ole double %13, 4.800000e+03
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = load double, double* %3
%17 = fsub double %16, 2.880000e+03
%18 = call double @llvm.fmuladd.f64(double %17, double 5.300000e-01, double 0x4095999999999999)
store double %18, double* %2
br label %26
19: ; preds = %12, %9
%20 = load double, double* %3
%21 = fcmp ogt double %20, 4.800000e+03
br i1 %21, label %22, label %26
22: ; preds = %19
%23 = load double, double* %3
%24 = fsub double %23, 4.800000e+03
%25 = call double @llvm.fmuladd.f64(double %24, double 7.800000e-01, double 2.400000e+03)
store double %25, double* %2
br label %26
26: ; preds = %6, %15, %22, %19
%27 = load double, double* %2
ret double %27
}

LLVM IR (-O2):
define double @save_money(double %0) {
%2 = fcmp ugt double %0, 2.880000e+03
br i1 %2, label %5, label %3
3: ; preds = %1
%4 = fmul double %0, 4.800000e-01
br label %17
5: ; preds = %1
%6 = fcmp ogt double %0, 2.880000e+03
%7 = fcmp ole double %0, 4.800000e+03
%8 = and i1 %6, %7
br i1 %8, label %9, label %12
9: ; preds = %5
%10 = fadd double %0, -2.880000e+03
%11 = tail call double @llvm.fmuladd.f64(double %10, double 5.300000e-01, double 0x4095999999999999)
br label %17
12: ; preds = %5
%13 = fcmp ogt double %0, 4.800000e+03
br i1 %13, label %14, label %17
14: ; preds = %12
%15 = fadd double %0, -4.800000e+03
%16 = tail call double @llvm.fmuladd.f64(double %15, double 7.800000e-01, double 2.400000e+03)
br label %17
17: ; preds = %3, %9, %14, %12
%18 = phi double [ %4, %3 ], [ %11, %9 ], [ %16, %14 ], [ undef, %12 ]
ret double %18
}