double draincap(width, nchannel, stack)
double width;
int nchannel;
int stack;
{
  double Cdiffside, Cdiffarea, Coverlap, cap;
  Cdiffside = (nchannel) ? 0.275e-15 : 0.275e-15;
  Cdiffarea = (nchannel) ? 0.137e-15 : 0.343e-15;
  Coverlap = (nchannel) ? (0.138e-15 + 0.263e-15) : (0.138e-15 + 0.338e-15);
  if (width >= 10) {
    cap = 3.0 * 0.8 * width / 2.0 * Cdiffarea + 6.0 * 0.8 * Cdiffside +
          width * Coverlap;
    cap +=
        (double)(stack - 1) * (0.8 * width * Cdiffarea + 4.0 * 0.8 * Cdiffside +
                               2.0 * width * Coverlap);
  } else {
    cap = 3.0 * 0.8 * width * Cdiffarea + (6.0 * 0.8 + width) * Cdiffside +
          width * Coverlap;
    cap +=
        (double)(stack - 1) * (0.8 * width * Cdiffarea + 2.0 * 0.8 * Cdiffside +
                               2.0 * width * Coverlap);
  }
  return (cap);
}


x86 assembly (clang, -O0):
<draincap>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    -0xc(%rbp),%eax
movsd  0xf0e(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
cmp    $0x0,%eax
movsd  %xmm0,-0x38(%rbp)
jne    1137 <draincap+0x37>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0xc(%rbp),%eax
movsd  0xecc(%rip),%xmm0
movsd  0xecc(%rip),%xmm1
movsd  %xmm1,-0x50(%rbp)
cmp    $0x0,%eax
movsd  %xmm0,-0x48(%rbp)
jne    1171 <draincap+0x71>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0xc(%rbp),%eax
movsd  0xe82(%rip),%xmm0
movsd  0xe82(%rip),%xmm1
movsd  %xmm1,-0x60(%rbp)
cmp    $0x0,%eax
movsd  %xmm0,-0x58(%rbp)
jne    11ab <draincap+0xab>
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xe3e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1278 <draincap+0x178>
movsd  0xe7c(%rip),%xmm1
mulsd  -0x8(%rbp),%xmm1
movsd  0xe4f(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm2
movsd  0xe56(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x8(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe18(%rip),%xmm1
mulsd  -0x8(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm3
movsd  0xe1e(%rip),%xmm2
mulsd  -0x18(%rbp),%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movsd  0xde1(%rip),%xmm2
mulsd  -0x8(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm3
mulsd  %xmm3,%xmm2
addsd  %xmm1,%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    1318 <draincap+0x218>
movsd  0xdd0(%rip),%xmm1
mulsd  -0x8(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movsd  0xdb6(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x8(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  0xd73(%rip),%xmm1
mulsd  -0x8(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm3
movsd  0xd59(%rip),%xmm2
mulsd  -0x18(%rbp),%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movsd  0xd3c(%rip),%xmm2
mulsd  -0x8(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm3
mulsd  %xmm3,%xmm2
addsd  %xmm1,%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<draincap>:
xor    %eax,%eax
test   %edi,%edi
sete   %al
lea    0xef2(%rip),%rcx
movsd  (%rcx,%rax,8),%xmm2
ucomisd 0xf05(%rip),%xmm0
lea    0xeee(%rip),%rcx
movsd  (%rcx,%rax,8),%xmm1
movsd  0xef9(%rip),%xmm3
mulsd  %xmm0,%xmm3
jae    1181 <draincap+0x81>
movsd  0xf13(%rip),%xmm4
addsd  %xmm0,%xmm4
mulsd  0xf0f(%rip),%xmm4
mulsd  %xmm2,%xmm3
addsd  %xmm4,%xmm3
movapd %xmm0,%xmm4
mulsd  %xmm1,%xmm4
addsd  %xmm3,%xmm4
add    $0xffffffff,%esi
xorps  %xmm3,%xmm3
cvtsi2sd %esi,%xmm3
movsd  0xed1(%rip),%xmm5
mulsd  %xmm0,%xmm5
mulsd  %xmm2,%xmm5
addsd  0xee1(%rip),%xmm5
jmp    11c3 <draincap+0xc3>
mulsd  0xea7(%rip),%xmm3
mulsd  %xmm2,%xmm3
addsd  0xea3(%rip),%xmm3
movapd %xmm0,%xmm4
mulsd  %xmm1,%xmm4
addsd  %xmm3,%xmm4
add    $0xffffffff,%esi
xorps  %xmm3,%xmm3
cvtsi2sd %esi,%xmm3
movsd  0xe8d(%rip),%xmm5
mulsd  %xmm0,%xmm5
mulsd  %xmm2,%xmm5
addsd  0xe85(%rip),%xmm5
addsd  %xmm0,%xmm0
mulsd  %xmm1,%xmm0
addsd  %xmm5,%xmm0
mulsd  %xmm3,%xmm0
addsd  %xmm4,%xmm0
ret

LLVM IR (-O0):
define double @draincap(double %0, i32 %1, i32 %2) {
%4 = alloca double
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
store double %0, double* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%11 = load i32, i32* %5
%12 = icmp ne i32 %11, 0
%13 = zext i1 %12 to i64
%14 = select i1 %12, double 2.750000e-16, double 2.750000e-16
store double %14, double* %7
%15 = load i32, i32* %5
%16 = icmp ne i32 %15, 0
%17 = zext i1 %16 to i64
%18 = select i1 %16, double 1.370000e-16, double 3.430000e-16
store double %18, double* %8
%19 = load i32, i32* %5
%20 = icmp ne i32 %19, 0
%21 = zext i1 %20 to i64
%22 = select i1 %20, double 4.010000e-16, double 4.760000e-16
store double %22, double* %9
%23 = load double, double* %4
%24 = fcmp oge double %23, 1.000000e+01
br i1 %24, label %25, label %51
25: ; preds = %3
%26 = load double, double* %4
%27 = fmul double 0x4003333333333334, %26
%28 = fdiv double %27, 2.000000e+00
%29 = load double, double* %8
%30 = load double, double* %7
%31 = fmul double 0x4013333333333334, %30
%32 = call double @llvm.fmuladd.f64(double %28, double %29, double %31)
%33 = load double, double* %4
%34 = load double, double* %9
%35 = call double @llvm.fmuladd.f64(double %33, double %34, double %32)
store double %35, double* %10
%36 = load i32, i32* %6
%37 = sub nsw i32 %36, 1
%38 = sitofp i32 %37 to double
%39 = load double, double* %4
%40 = fmul double 8.000000e-01, %39
%41 = load double, double* %8
%42 = load double, double* %7
%43 = fmul double 3.200000e+00, %42
%44 = call double @llvm.fmuladd.f64(double %40, double %41, double %43)
%45 = load double, double* %4
%46 = fmul double 2.000000e+00, %45
%47 = load double, double* %9
%48 = call double @llvm.fmuladd.f64(double %46, double %47, double %44)
%49 = load double, double* %10
%50 = call double @llvm.fmuladd.f64(double %38, double %48, double %49)
store double %50, double* %10
br label %78
51: ; preds = %3
%52 = load double, double* %4
%53 = fmul double 0x4003333333333334, %52
%54 = load double, double* %8
%55 = load double, double* %4
%56 = fadd double 0x4013333333333334, %55
%57 = load double, double* %7
%58 = fmul double %56, %57
%59 = call double @llvm.fmuladd.f64(double %53, double %54, double %58)
%60 = load double, double* %4
%61 = load double, double* %9
%62 = call double @llvm.fmuladd.f64(double %60, double %61, double %59)
store double %62, double* %10
%63 = load i32, i32* %6
%64 = sub nsw i32 %63, 1
%65 = sitofp i32 %64 to double
%66 = load double, double* %4
%67 = fmul double 8.000000e-01, %66
%68 = load double, double* %8
%69 = load double, double* %7
%70 = fmul double 1.600000e+00, %69
%71 = call double @llvm.fmuladd.f64(double %67, double %68, double %70)
%72 = load double, double* %4
%73 = fmul double 2.000000e+00, %72
%74 = load double, double* %9
%75 = call double @llvm.fmuladd.f64(double %73, double %74, double %71)
%76 = load double, double* %10
%77 = call double @llvm.fmuladd.f64(double %65, double %75, double %76)
store double %77, double* %10
br label %78
78: ; preds = %51, %25
%79 = load double, double* %10
ret double %79
}

LLVM IR (-O2):
define double @draincap(double %0, i32 %1, i32 %2) {
%4 = icmp eq i32 %1, 0
%5 = select i1 %4, double 3.430000e-16, double 1.370000e-16
%6 = select i1 %4, double 4.760000e-16, double 4.010000e-16
%7 = fcmp ult double %0, 1.000000e+01
%8 = fmul double %0, 0x4003333333333334
br i1 %7, label %20, label %9
9: ; preds = %3
%10 = fmul double %8, 5.000000e-01
%11 = tail call double @llvm.fmuladd.f64(double %10, double %5, double 0x3CD7C76CF0790B3C)
%12 = tail call double @llvm.fmuladd.f64(double %0, double %6, double %11)
%13 = add nsw i32 %2, -1
%14 = sitofp i32 %13 to double
%15 = fmul double %0, 8.000000e-01
%16 = tail call double @llvm.fmuladd.f64(double %15, double %5, double 8.800000e-16)
%17 = fmul double %0, 2.000000e+00
%18 = tail call double @llvm.fmuladd.f64(double %17, double %6, double %16)
%19 = tail call double @llvm.fmuladd.f64(double %14, double %18, double %12)
br label %32
20: ; preds = %3
%21 = fadd double %0, 0x4013333333333334
%22 = fmul double %21, 2.750000e-16
%23 = tail call double @llvm.fmuladd.f64(double %8, double %5, double %22)
%24 = tail call double @llvm.fmuladd.f64(double %0, double %6, double %23)
%25 = add nsw i32 %2, -1
%26 = sitofp i32 %25 to double
%27 = fmul double %0, 8.000000e-01
%28 = tail call double @llvm.fmuladd.f64(double %27, double %5, double 4.400000e-16)
%29 = fmul double %0, 2.000000e+00
%30 = tail call double @llvm.fmuladd.f64(double %29, double %6, double %28)
%31 = tail call double @llvm.fmuladd.f64(double %26, double %30, double %24)
br label %32
32: ; preds = %20, %9
%33 = phi double [ %19, %9 ], [ %31, %20 ]
ret double %33
}