double shell_capt_factor(double aheavy, double zheavy) {
  double nheavy = aheavy - zheavy;
  double nh, np;
  if (zheavy < 20) {
    np = 0;
  }
  if (zheavy >= 20 && zheavy < 28) {
    np = zheavy - 20;
  }
  if (zheavy >= 28) {
    np = 8;
  }
  if (nheavy < 34) {
    nh = 6;
  }
  if (nheavy >= 34 && nheavy < 40) {
    nh = 40 - nheavy;
  }
  if (nheavy >= 40) {
    nh = 0;
  }
  return nh * np;
}


x86 assembly (clang, -O0):
<shell_capt_factor>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xedb(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1138 <shell_capt_factor+0x38>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xebb(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1178 <shell_capt_factor+0x78>
movsd  0xeb1(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1178 <shell_capt_factor+0x78>
movsd  -0x10(%rbp),%xmm0
movsd  0xe91(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe83(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     119c <shell_capt_factor+0x9c>
movsd  0xe79(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe74(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11bc <shell_capt_factor+0xbc>
movsd  0xe69(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe4f(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11f8 <shell_capt_factor+0xf8>
movsd  0xe4d(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11f8 <shell_capt_factor+0xf8>
movsd  0xe3a(%rip),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe23(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1217 <shell_capt_factor+0x117>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<shell_capt_factor>:
subsd  %xmm1,%xmm0
movsd  0xef4(%rip),%xmm3
addsd  %xmm1,%xmm3
movsd  0xef0(%rip),%xmm4
cmplesd %xmm1,%xmm4
movsd  0xeeb(%rip),%xmm2
movapd %xmm1,%xmm5
cmpltsd %xmm2,%xmm5
andpd  %xmm3,%xmm5
andpd  %xmm4,%xmm5
cmpnlesd %xmm1,%xmm2
andpd  %xmm2,%xmm5
movsd  0xed1(%rip),%xmm1
andnpd %xmm1,%xmm2
orpd   %xmm5,%xmm2
movsd  0xec9(%rip),%xmm1
movapd %xmm1,%xmm3
subsd  %xmm0,%xmm3
movapd %xmm0,%xmm4
cmpltsd %xmm1,%xmm4
andpd  %xmm4,%xmm3
movsd  0xeb4(%rip),%xmm5
andnpd %xmm5,%xmm4
orpd   %xmm3,%xmm4
movsd  0xeac(%rip),%xmm3
cmplesd %xmm0,%xmm3
andpd  %xmm3,%xmm4
andnpd %xmm5,%xmm3
orpd   %xmm4,%xmm3
cmpnlesd %xmm0,%xmm1
andpd  %xmm3,%xmm1
mulsd  %xmm2,%xmm1
movapd %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @shell_capt_factor(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %3
store double %1, double* %4
%8 = load double, double* %3
%9 = load double, double* %4
%10 = fsub double %8, %9
store double %10, double* %5
%11 = load double, double* %4
%12 = fcmp olt double %11, 2.000000e+01
br i1 %12, label %13, label %14
13: ; preds = %2
store double 0.000000e+00, double* %7
br label %14
14: ; preds = %13, %2
%15 = load double, double* %4
%16 = fcmp oge double %15, 2.000000e+01
br i1 %16, label %17, label %23
17: ; preds = %14
%18 = load double, double* %4
%19 = fcmp olt double %18, 2.800000e+01
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load double, double* %4
%22 = fsub double %21, 2.000000e+01
store double %22, double* %7
br label %23
23: ; preds = %20, %17, %14
%24 = load double, double* %4
%25 = fcmp oge double %24, 2.800000e+01
br i1 %25, label %26, label %27
26: ; preds = %23
store double 8.000000e+00, double* %7
br label %27
27: ; preds = %26, %23
%28 = load double, double* %5
%29 = fcmp olt double %28, 3.400000e+01
br i1 %29, label %30, label %31
30: ; preds = %27
store double 6.000000e+00, double* %6
br label %31
31: ; preds = %30, %27
%32 = load double, double* %5
%33 = fcmp oge double %32, 3.400000e+01
br i1 %33, label %34, label %40
34: ; preds = %31
%35 = load double, double* %5
%36 = fcmp olt double %35, 4.000000e+01
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = load double, double* %5
%39 = fsub double 4.000000e+01, %38
store double %39, double* %6
br label %40
40: ; preds = %37, %34, %31
%41 = load double, double* %5
%42 = fcmp oge double %41, 4.000000e+01
br i1 %42, label %43, label %44
43: ; preds = %40
store double 0.000000e+00, double* %6
br label %44
44: ; preds = %43, %40
%45 = load double, double* %6
%46 = load double, double* %7
%47 = fmul double %45, %46
ret double %47
}

LLVM IR (-O2):
define double @shell_capt_factor(double %0, double %1) {
%3 = fsub double %0, %1
%4 = fcmp oge double %1, 2.000000e+01
%5 = fcmp olt double %1, 2.800000e+01
%6 = and i1 %4, %5
%7 = fadd double %1, -2.000000e+01
%8 = select i1 %6, double %7, double 0.000000e+00
%9 = fcmp ult double %1, 2.800000e+01
%10 = select i1 %9, double %8, double 8.000000e+00
%11 = fcmp oge double %3, 3.400000e+01
%12 = fcmp olt double %3, 4.000000e+01
%13 = and i1 %11, %12
%14 = fsub double 4.000000e+01, %3
%15 = select i1 %13, double %14, double 6.000000e+00
%16 = fcmp ult double %3, 4.000000e+01
%17 = select i1 %16, double %15, double 0.000000e+00
%18 = fmul double %10, %17
ret double %18
}