double GeometricAverageRateOption(int fCall, double S, double SA, double X,
                                  double T, double T2, double r, double b,
                                  double v) {
  double bA, vA, t1;
  assert(((S) == (S)) && (S) >= 0.000001 && (S) <= 1000000000000.0);
  assert(((X) == (X)) && (X) >= 0.000001 && (X) <= 1000000000000.0);
  assert(((T) == (T)) && (T) >= (1.0 / (253.0 * 24.0)) && (T) <= (20.0));
  bA = 0.5 * (b - ((v) * (v)) / 6.0);
  vA = v / sqrt(3.0);
  t1 = T - T2;
  if (t1 > 0.0) {
    X = (t1 + T2) / T2 * X - t1 / T2 * SA;
    return gbs(fCall, S, X, T2, r, bA, vA) * T2 / (t1 + T2);
  } else if (t1 == 0.0)
    return gbs(fCall, S, X, T, r, bA, vA);
  else
    abort();
}


x86 assembly (clang, -O0):
<GeometricAverageRateOption>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  %xmm2,-0x28(%rbp)
movsd  %xmm3,-0x30(%rbp)
movsd  %xmm4,-0x38(%rbp)
movsd  %xmm5,-0x40(%rbp)
movsd  %xmm6,-0x48(%rbp)
movsd  %xmm7,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
xor    %eax,%eax
ucomisd -0x18(%rbp),%xmm0
mov    %al,-0x69(%rbp)
jne    11c0 <GeometricAverageRateOption+0x80>
jp     11c0 <GeometricAverageRateOption+0x80>
movsd  -0x18(%rbp),%xmm0
xor    %eax,%eax
movsd  0xe60(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x69(%rbp)
jb     11c0 <GeometricAverageRateOption+0x80>
movsd  0xe53(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
setae  %al
mov    %al,-0x69(%rbp)
mov    -0x69(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1040 <assert@plt>
movsd  -0x28(%rbp),%xmm0
xor    %eax,%eax
ucomisd -0x28(%rbp),%xmm0
mov    %al,-0x6a(%rbp)
jne    1219 <GeometricAverageRateOption+0xd9>
jp     1219 <GeometricAverageRateOption+0xd9>
movsd  -0x28(%rbp),%xmm0
xor    %eax,%eax
movsd  0xe07(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x6a(%rbp)
jb     1219 <GeometricAverageRateOption+0xd9>
movsd  0xdfa(%rip),%xmm0
ucomisd -0x28(%rbp),%xmm0
setae  %al
mov    %al,-0x6a(%rbp)
mov    -0x6a(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1040 <assert@plt>
movsd  -0x30(%rbp),%xmm0
xor    %eax,%eax
ucomisd -0x30(%rbp),%xmm0
mov    %al,-0x6b(%rbp)
jne    1272 <GeometricAverageRateOption+0x132>
jp     1272 <GeometricAverageRateOption+0x132>
movsd  -0x30(%rbp),%xmm0
xor    %eax,%eax
movsd  0xdbe(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x6b(%rbp)
jb     1272 <GeometricAverageRateOption+0x132>
movsd  0xdb1(%rip),%xmm0
ucomisd -0x30(%rbp),%xmm0
setae  %al
mov    %al,-0x6b(%rbp)
mov    -0x6b(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1040 <assert@plt>
movsd  -0x48(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  0xd98(%rip),%xmm2
divsd  %xmm2,%xmm0
subsd  %xmm0,%xmm1
movsd  0xd80(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  0xd5d(%rip),%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x78(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x30(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    138a <GeometricAverageRateOption+0x24a>
movsd  -0x68(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
divsd  -0x38(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
movsd  -0x68(%rbp),%xmm1
divsd  -0x38(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0xc(%rbp),%edi
movsd  -0x18(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm3
movsd  -0x58(%rbp),%xmm4
movsd  -0x60(%rbp),%xmm5
mov    $0x6,%al
call   1060 <gbs@plt>
cvtsi2sd %eax,%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm1
addsd  -0x38(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    13dd <GeometricAverageRateOption+0x29d>
movsd  -0x68(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    13d8 <GeometricAverageRateOption+0x298>
jp     13d8 <GeometricAverageRateOption+0x298>
mov    -0xc(%rbp),%edi
movsd  -0x18(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm3
movsd  -0x58(%rbp),%xmm4
movsd  -0x60(%rbp),%xmm5
mov    $0x6,%al
call   1060 <gbs@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    13dd <GeometricAverageRateOption+0x29d>
call   1030 <abort@plt>
movsd  -0x8(%rbp),%xmm0
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GeometricAverageRateOption>:
push   %rbx
sub    $0x40,%rsp
ucomisd %xmm0,%xmm0
setnp  %al
ucomisd 0xebc(%rip),%xmm0
setae  %cl
and    %al,%cl
movsd  0xeb6(%rip),%xmm8
movsd  %xmm0,0x18(%rsp)
ucomisd %xmm0,%xmm8
movsd  %xmm7,0x30(%rsp)
movsd  %xmm6,0x38(%rsp)
movsd  %xmm5,0x10(%rsp)
movsd  %xmm4,0x20(%rsp)
movsd  %xmm3,(%rsp)
movsd  %xmm2,0x8(%rsp)
movsd  %xmm1,0x28(%rsp)
mov    %edi,%ebx
setae  %al
and    %cl,%al
movzbl %al,%edi
xor    %eax,%eax
call   1040 <assert@plt>
movsd  0x8(%rsp),%xmm1
ucomisd %xmm1,%xmm1
setnp  %al
ucomisd 0xe54(%rip),%xmm1
setae  %cl
and    %al,%cl
movsd  0xe4f(%rip),%xmm0
ucomisd %xmm1,%xmm0
setae  %al
and    %cl,%al
movzbl %al,%edi
xor    %eax,%eax
call   1040 <assert@plt>
movsd  (%rsp),%xmm1
ucomisd %xmm1,%xmm1
setnp  %al
ucomisd 0xe30(%rip),%xmm1
setae  %cl
and    %al,%cl
movsd  0xe2b(%rip),%xmm0
ucomisd %xmm1,%xmm0
setae  %al
and    %cl,%al
movzbl %al,%edi
xor    %eax,%eax
call   1040 <assert@plt>
movsd  (%rsp),%xmm2
movsd  0x30(%rsp),%xmm5
movapd %xmm5,%xmm4
mulsd  %xmm5,%xmm4
divsd  0xe05(%rip),%xmm4
addsd  0x38(%rsp),%xmm4
mulsd  0xdff(%rip),%xmm4
divsd  0xdff(%rip),%xmm5
movapd %xmm2,%xmm0
movsd  0x20(%rsp),%xmm1
movapd %xmm1,%xmm3
subsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    129f <GeometricAverageRateOption+0x16f>
movapd %xmm0,%xmm1
addsd  %xmm3,%xmm1
movsd  %xmm1,(%rsp)
divsd  %xmm3,%xmm1
divsd  %xmm3,%xmm0
movapd %xmm3,%xmm2
mulsd  0x28(%rsp),%xmm0
mulsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
mov    %ebx,%edi
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm3
mov    $0x6,%al
call   1050 <gbs@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x20(%rsp),%xmm0
divsd  (%rsp),%xmm0
jmp    12c5 <GeometricAverageRateOption+0x195>
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm3
movsd  0x18(%rsp),%xmm0
jne    12cb <GeometricAverageRateOption+0x19b>
jp     12cb <GeometricAverageRateOption+0x19b>
mov    %ebx,%edi
mov    $0x6,%al
call   1050 <gbs@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
add    $0x40,%rsp
pop    %rbx
ret
call   1030 <abort@plt>

LLVM IR (-O0):
define double @GeometricAverageRateOption(i32 %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, double %8) {
%10 = alloca double
%11 = alloca i32
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
store i32 %0, i32* %11
store double %1, double* %12
store double %2, double* %13
store double %3, double* %14
store double %4, double* %15
store double %5, double* %16
store double %6, double* %17
store double %7, double* %18
store double %8, double* %19
%23 = load double, double* %12
%24 = load double, double* %12
%25 = fcmp oeq double %23, %24
br i1 %25, label %26, label %32
26: ; preds = %9
%27 = load double, double* %12
%28 = fcmp oge double %27, 0x3EB0C6F7A0B5ED8D
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = load double, double* %12
%31 = fcmp ole double %30, 1.000000e+12
br label %32
32: ; preds = %29, %26, %9
%33 = phi i1 [ false, %26 ], [ false, %9 ], [ %31, %29 ]
%34 = zext i1 %33 to i32
%35 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %34)
%36 = load double, double* %14
%37 = load double, double* %14
%38 = fcmp oeq double %36, %37
br i1 %38, label %39, label %45
39: ; preds = %32
%40 = load double, double* %14
%41 = fcmp oge double %40, 0x3EB0C6F7A0B5ED8D
br i1 %41, label %42, label %45
42: ; preds = %39
%43 = load double, double* %14
%44 = fcmp ole double %43, 1.000000e+12
br label %45
45: ; preds = %42, %39, %32
%46 = phi i1 [ false, %39 ], [ false, %32 ], [ %44, %42 ]
%47 = zext i1 %46 to i32
%48 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %47)
%49 = load double, double* %15
%50 = load double, double* %15
%51 = fcmp oeq double %49, %50
br i1 %51, label %52, label %58
52: ; preds = %45
%53 = load double, double* %15
%54 = fcmp oge double %53, 0x3F2596179C29D2CE
br i1 %54, label %55, label %58
55: ; preds = %52
%56 = load double, double* %15
%57 = fcmp ole double %56, 2.000000e+01
br label %58
58: ; preds = %55, %52, %45
%59 = phi i1 [ false, %52 ], [ false, %45 ], [ %57, %55 ]
%60 = zext i1 %59 to i32
%61 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %60)
%62 = load double, double* %18
%63 = load double, double* %19
%64 = load double, double* %19
%65 = fmul double %63, %64
%66 = fdiv double %65, 6.000000e+00
%67 = fsub double %62, %66
%68 = fmul double 5.000000e-01, %67
store double %68, double* %20
%69 = load double, double* %19
%70 = call double @sqrt(double 3.000000e+00)
%71 = fdiv double %69, %70
store double %71, double* %21
%72 = load double, double* %15
%73 = load double, double* %16
%74 = fsub double %72, %73
store double %74, double* %22
%75 = load double, double* %22
%76 = fcmp ogt double %75, 0.000000e+00
br i1 %76, label %77, label %106
77: ; preds = %58
%78 = load double, double* %22
%79 = load double, double* %16
%80 = fadd double %78, %79
%81 = load double, double* %16
%82 = fdiv double %80, %81
%83 = load double, double* %14
%84 = load double, double* %22
%85 = load double, double* %16
%86 = fdiv double %84, %85
%87 = load double, double* %13
%88 = fmul double %86, %87
%89 = fneg double %88
%90 = call double @llvm.fmuladd.f64(double %82, double %83, double %89)
store double %90, double* %14
%91 = load i32, i32* %11
%92 = load double, double* %12
%93 = load double, double* %14
%94 = load double, double* %16
%95 = load double, double* %17
%96 = load double, double* %20
%97 = load double, double* %21
%98 = call i32 (i32, double, double, double, double, double, double, ...) bitcast (i32 (...)* @gbs to i32 (i32, double, double, double, double, double, double, ...)*)(i32 %91, double %92, double %93, double %94, double %95, double %96, double %97)
%99 = sitofp i32 %98 to double
%100 = load double, double* %16
%101 = fmul double %99, %100
%102 = load double, double* %22
%103 = load double, double* %16
%104 = fadd double %102, %103
%105 = fdiv double %101, %104
store double %105, double* %10
br label %120
106: ; preds = %58
%107 = load double, double* %22
%108 = fcmp oeq double %107, 0.000000e+00
br i1 %108, label %109, label %119
109: ; preds = %106
%110 = load i32, i32* %11
%111 = load double, double* %12
%112 = load double, double* %14
%113 = load double, double* %15
%114 = load double, double* %17
%115 = load double, double* %20
%116 = load double, double* %21
%117 = call i32 (i32, double, double, double, double, double, double, ...) bitcast (i32 (...)* @gbs to i32 (i32, double, double, double, double, double, double, ...)*)(i32 %110, double %111, double %112, double %113, double %114, double %115, double %116)
%118 = sitofp i32 %117 to double
store double %118, double* %10
br label %120
119: ; preds = %106
unreachable
120: ; preds = %109, %77
%121 = load double, double* %10
ret double %121
}

LLVM IR (-O2):
define double @GeometricAverageRateOption(i32 %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, double %8) {
%10 = fcmp ord double %1, 0.000000e+00
%11 = fcmp oge double %1, 0x3EB0C6F7A0B5ED8D
%12 = and i1 %10, %11
%13 = fcmp ole double %1, 1.000000e+12
%14 = and i1 %13, %12
%15 = zext i1 %14 to i32
%16 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %15)
%17 = fcmp ord double %3, 0.000000e+00
%18 = fcmp oge double %3, 0x3EB0C6F7A0B5ED8D
%19 = and i1 %17, %18
%20 = fcmp ole double %3, 1.000000e+12
%21 = and i1 %20, %19
%22 = zext i1 %21 to i32
%23 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %22)
%24 = fcmp ord double %4, 0.000000e+00
%25 = fcmp oge double %4, 0x3F2596179C29D2CE
%26 = and i1 %24, %25
%27 = fcmp ole double %4, 2.000000e+01
%28 = and i1 %27, %26
%29 = zext i1 %28 to i32
%30 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %29)
%31 = fmul double %8, %8
%32 = fdiv double %31, 6.000000e+00
%33 = fsub double %7, %32
%34 = fmul double %33, 5.000000e-01
%35 = fdiv double %8, 0x3FFBB67AE8584CAA
%36 = fsub double %4, %5
%37 = fcmp ogt double %36, 0.000000e+00
br i1 %37, label %38, label %49
38: ; preds = %9
%39 = fadd double %36, %5
%40 = fdiv double %39, %5
%41 = fneg double %36
%42 = fdiv double %41, %5
%43 = fmul double %42, %2
%44 = tail call double @llvm.fmuladd.f64(double %40, double %3, double %43)
%45 = tail call i32 (i32, double, double, double, double, double, double, ...) bitcast (i32 (...)* @gbs to i32 (i32, double, double, double, double, double, double, ...)*)(i32 %0, double %1, double %44, double %5, double %6, double %34, double %35)
%46 = sitofp i32 %45 to double
%47 = fmul double %46, %5
%48 = fdiv double %47, %39
br label %55
49: ; preds = %9
%50 = fcmp oeq double %36, 0.000000e+00
br i1 %50, label %51, label %54
51: ; preds = %49
%52 = tail call i32 (i32, double, double, double, double, double, double, ...) bitcast (i32 (...)* @gbs to i32 (i32, double, double, double, double, double, double, ...)*)(i32 %0, double %1, double %3, double %4, double %6, double %34, double %35)
%53 = sitofp i32 %52 to double
br label %55
54: ; preds = %49
tail call void @abort()
unreachable
55: ; preds = %51, %38
%56 = phi double [ %48, %38 ], [ %53, %51 ]
ret double %56
}