float calculaCargo(float tiempo) {
  float coste, precio = 0.5;
  if (tiempo > 3 && tiempo < 19)
    coste = 2 + (precio * (tiempo - 3));
  else if (tiempo <= 3)
    coste = 2;
  else if (tiempo >= 19)
    coste = 10;
  return coste;
}


x86 assembly (clang, -O0):
<calculaCargo>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x4(%rbp)
movss  0xef3(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x4(%rbp),%xmm0
movss  0xedd(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    116e <calculaCargo+0x6e>
movss  0xed4(%rip),%xmm0
ucomiss -0x4(%rbp),%xmm0
jbe    116e <calculaCargo+0x6e>
movss  -0xc(%rbp),%xmm0
movss  -0x4(%rbp),%xmm1
movss  0xeb0(%rip),%xmm2
subss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
movss  0xeb0(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    11bf <calculaCargo+0xbf>
movss  0xe8a(%rip),%xmm0
ucomiss -0x4(%rbp),%xmm0
jb     1192 <calculaCargo+0x92>
movss  0xe88(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    11ba <calculaCargo+0xba>
movss  -0x4(%rbp),%xmm0
movss  0xe69(%rip),%xmm1
ucomiss %xmm1,%xmm0
jb     11b5 <calculaCargo+0xb5>
movss  0xe5c(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    11ba <calculaCargo+0xba>
jmp    11bf <calculaCargo+0xbf>
movss  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<calculaCargo>:
ucomiss 0xef9(%rip),%xmm0
jbe    112f <calculaCargo+0x2f>
movss  0xef3(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    112f <calculaCargo+0x2f>
addss  0xef2(%rip),%xmm0
mulss  0xeee(%rip),%xmm0
addss  0xeda(%rip),%xmm0
ret
movss  0xec9(%rip),%xmm1
ucomiss %xmm0,%xmm1
jae    1145 <calculaCargo+0x45>
movss  0xec8(%rip),%xmm0
ret
movss  0xebb(%rip),%xmm0
ret

LLVM IR (-O0):
define float @calculaCargo(float %0) {
%2 = alloca float
%3 = alloca float
%4 = alloca float
store float %0, float* %2
store float 5.000000e-01, float* %4
%5 = load float, float* %2
%6 = fcmp ogt float %5, 3.000000e+00
br i1 %6, label %7, label %15
7: ; preds = %1
%8 = load float, float* %2
%9 = fcmp olt float %8, 1.900000e+01
br i1 %9, label %10, label %15
10: ; preds = %7
%11 = load float, float* %4
%12 = load float, float* %2
%13 = fsub float %12, 3.000000e+00
%14 = call float @llvm.fmuladd.f32(float %11, float %13, float 2.000000e+00)
store float %14, float* %3
br label %25
15: ; preds = %7, %1
%16 = load float, float* %2
%17 = fcmp ole float %16, 3.000000e+00
br i1 %17, label %18, label %19
18: ; preds = %15
store float 2.000000e+00, float* %3
br label %24
19: ; preds = %15
%20 = load float, float* %2
%21 = fcmp oge float %20, 1.900000e+01
br i1 %21, label %22, label %23
22: ; preds = %19
store float 1.000000e+01, float* %3
br label %23
23: ; preds = %22, %19
br label %24
24: ; preds = %23, %18
br label %25
25: ; preds = %24, %10
%26 = load float, float* %3
ret float %26
}

LLVM IR (-O2):
define float @calculaCargo(float %0) {
%2 = fcmp ogt float %0, 3.000000e+00
%3 = fcmp olt float %0, 1.900000e+01
%4 = and i1 %2, %3
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = fadd float %0, -3.000000e+00
%7 = tail call float @llvm.fmuladd.f32(float %6, float 5.000000e-01, float 2.000000e+00)
br label %11
8: ; preds = %1
%9 = fcmp ugt float %0, 3.000000e+00
br i1 %9, label %10, label %11
10: ; preds = %8
br label %11
11: ; preds = %10, %8, %5
%12 = phi float [ %7, %5 ], [ 2.000000e+00, %8 ], [ 1.000000e+01, %10 ]
ret float %12
}