double calcularIR(double salario) {
  if (salario <= 2000.0) {
    return 0;
  } else if (salario <= 3000.0) {
    return (salario - 2000.0) * 0.08;
  } else if (salario <= 4500.0) {
    return calcularIR(3000.0) + (salario - 3000.0) * 0.18;
  } else {
    return calcularIR(4500.0) + (salario - 4500.0) * 0.28;
  }
}


x86 assembly (clang, -O0):
<calcularIR>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  0xedb(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     113d <calcularIR+0x2d>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11fb <calcularIR+0xeb>
movsd  0xec3(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     1177 <calcularIR+0x67>
movsd  -0x10(%rbp),%xmm0
movsd  0xea3(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xebf(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11fb <calcularIR+0xeb>
movsd  0xe91(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     11c5 <calcularIR+0xb5>
movsd  0xe76(%rip),%xmm0
call   1030 <calcularIR@plt>
movaps %xmm0,%xmm1
movsd  -0x10(%rbp),%xmm0
movsd  0xe61(%rip),%xmm2
subsd  %xmm2,%xmm0
movsd  0xe6d(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11fb <calcularIR+0xeb>
movsd  0xe43(%rip),%xmm0
call   1030 <calcularIR@plt>
movaps %xmm0,%xmm1
movsd  -0x10(%rbp),%xmm0
movsd  0xe2e(%rip),%xmm2
subsd  %xmm2,%xmm0
movsd  0xe2a(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calcularIR>:
xorpd  %xmm1,%xmm1
movsd  0xef4(%rip),%xmm2
ucomisd %xmm0,%xmm2
jae    115b <calcularIR+0x5b>
movsd  0xeee(%rip),%xmm1
ucomisd %xmm0,%xmm1
jae    1147 <calcularIR+0x47>
movsd  0xef8(%rip),%xmm1
ucomisd %xmm0,%xmm1
jae    1160 <calcularIR+0x60>
addsd  0xf0a(%rip),%xmm0
mulsd  0xf0a(%rip),%xmm0
addsd  0xf0a(%rip),%xmm0
ret
addsd  0xec1(%rip),%xmm0
mulsd  0xec1(%rip),%xmm0
movapd %xmm0,%xmm1
movapd %xmm1,%xmm0
ret
addsd  0xec0(%rip),%xmm0
mulsd  0xec0(%rip),%xmm0
addsd  0xec0(%rip),%xmm0
ret

LLVM IR (-O0):
define double @calcularIR(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %3
%4 = load double, double* %3
%5 = fcmp ole double %4, 2.000000e+03
br i1 %5, label %6, label %7
6: ; preds = %1
store double 0.000000e+00, double* %2
br label %27
7: ; preds = %1
%8 = load double, double* %3
%9 = fcmp ole double %8, 3.000000e+03
br i1 %9, label %10, label %14
10: ; preds = %7
%11 = load double, double* %3
%12 = fsub double %11, 2.000000e+03
%13 = fmul double %12, 8.000000e-02
store double %13, double* %2
br label %27
14: ; preds = %7
%15 = load double, double* %3
%16 = fcmp ole double %15, 4.500000e+03
br i1 %16, label %17, label %22
17: ; preds = %14
%18 = call double @calcularIR(double 3.000000e+03)
%19 = load double, double* %3
%20 = fsub double %19, 3.000000e+03
%21 = call double @llvm.fmuladd.f64(double %20, double 1.800000e-01, double %18)
store double %21, double* %2
br label %27
22: ; preds = %14
%23 = call double @calcularIR(double 4.500000e+03)
%24 = load double, double* %3
%25 = fsub double %24, 4.500000e+03
%26 = call double @llvm.fmuladd.f64(double %25, double 2.800000e-01, double %23)
store double %26, double* %2
br label %27
27: ; preds = %22, %17, %10, %6
%28 = load double, double* %2
ret double %28
}

LLVM IR (-O2):
define double @calcularIR(double %0) {
%2 = fcmp ugt double %0, 2.000000e+03
br i1 %2, label %3, label %16
3: ; preds = %1
%4 = fcmp ugt double %0, 3.000000e+03
br i1 %4, label %8, label %5
5: ; preds = %3
%6 = fadd double %0, -2.000000e+03
%7 = fmul double %6, 8.000000e-02
br label %16
8: ; preds = %3
%9 = fcmp ugt double %0, 4.500000e+03
br i1 %9, label %13, label %10
10: ; preds = %8
%11 = fadd double %0, -3.000000e+03
%12 = tail call double @llvm.fmuladd.f64(double %11, double 1.800000e-01, double 8.000000e+01)
br label %16
13: ; preds = %8
%14 = fadd double %0, -4.500000e+03
%15 = tail call double @llvm.fmuladd.f64(double %14, double 2.800000e-01, double 3.500000e+02)
br label %16
16: ; preds = %1, %13, %10, %5
%17 = phi double [ %7, %5 ], [ %12, %10 ], [ %15, %13 ], [ 0.000000e+00, %1 ]
ret double %17
}