double carry(int fCall, double S, double X, double T, double r, double b,
             double v) {
  double d1, result;
  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));
  assert(r >= 0.0);
  assert(b >= 0.0);
  assert(v > 0.0 && v <= 100.0);
  d1 = (log(S / X) + (b + ((v) * (v)) / 2.0) * T) / (v * sqrt(T));
  if (fCall)
    result = T * S * exp((b - r) * T) * cnd(d1);
  else
    result = -T * S * exp((b - r) * T) * cnd(-d1);
  return result;
}


x86 assembly (clang, -O0):
<carry>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  %xmm4,-0x30(%rbp)
movsd  %xmm5,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
xor    %eax,%eax
ucomisd -0x10(%rbp),%xmm0
mov    %al,-0x49(%rbp)
jne    11c6 <carry+0x76>
jp     11c6 <carry+0x76>
movsd  -0x10(%rbp),%xmm0
xor    %eax,%eax
movsd  0xe5a(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x49(%rbp)
jb     11c6 <carry+0x76>
movsd  0xe4d(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
setae  %al
mov    %al,-0x49(%rbp)
mov    -0x49(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1030 <assert@plt>
movsd  -0x18(%rbp),%xmm0
xor    %eax,%eax
ucomisd -0x18(%rbp),%xmm0
mov    %al,-0x4a(%rbp)
jne    121f <carry+0xcf>
jp     121f <carry+0xcf>
movsd  -0x18(%rbp),%xmm0
xor    %eax,%eax
movsd  0xe01(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x4a(%rbp)
jb     121f <carry+0xcf>
movsd  0xdf4(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
setae  %al
mov    %al,-0x4a(%rbp)
mov    -0x4a(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1030 <assert@plt>
movsd  -0x20(%rbp),%xmm0
xor    %eax,%eax
ucomisd -0x20(%rbp),%xmm0
mov    %al,-0x4b(%rbp)
jne    1278 <carry+0x128>
jp     1278 <carry+0x128>
movsd  -0x20(%rbp),%xmm0
xor    %eax,%eax
movsd  0xdb8(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x4b(%rbp)
jb     1278 <carry+0x128>
movsd  0xdab(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
setae  %al
mov    %al,-0x4b(%rbp)
mov    -0x4b(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1030 <assert@plt>
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1030 <assert@plt>
movsd  -0x30(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1030 <assert@plt>
movsd  -0x38(%rbp),%xmm0
xor    %eax,%eax
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x4c(%rbp)
jbe    12e7 <carry+0x197>
movsd  0xd44(%rip),%xmm0
ucomisd -0x38(%rbp),%xmm0
setae  %al
mov    %al,-0x4c(%rbp)
mov    -0x4c(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1030 <assert@plt>
movsd  -0x10(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
call   1050 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
mulsd  -0x38(%rbp),%xmm2
movsd  0xd09(%rip),%xmm3
divsd  %xmm3,%xmm2
addsd  %xmm2,%xmm0
movsd  -0x20(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1070 <sqrt@plt>
movsd  -0x60(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     13c8 <carry+0x278>
movsd  -0x20(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x30(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1040 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x40(%rbp),%xmm0
mov    $0x1,%al
call   1060 <cnd@plt>
movsd  -0x68(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    1448 <carry+0x2f8>
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x30(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1040 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x80(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x40(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    $0x1,%al
call   1060 <cnd@plt>
movsd  -0x78(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<carry>:
push   %rbx
sub    $0x50,%rsp
movsd  %xmm0,(%rsp)
ucomisd %xmm0,%xmm0
setnp  %al
ucomisd 0xe97(%rip),%xmm0
setae  %cl
and    %al,%cl
movsd  0xe92(%rip),%xmm6
ucomisd %xmm0,%xmm6
movsd  %xmm5,0x30(%rsp)
movsd  %xmm4,0x38(%rsp)
movsd  %xmm3,0x28(%rsp)
movaps %xmm2,0x40(%rsp)
movsd  %xmm1,0x10(%rsp)
mov    %edi,%ebx
setae  %al
and    %cl,%al
movzbl %al,%edi
xor    %eax,%eax
call   1030 <assert@plt>
movsd  0x10(%rsp),%xmm0
ucomisd %xmm0,%xmm0
setnp  %al
ucomisd 0xe43(%rip),%xmm0
setae  %cl
and    %al,%cl
movsd  0xe3e(%rip),%xmm1
ucomisd %xmm0,%xmm1
setae  %al
and    %cl,%al
movzbl %al,%edi
xor    %eax,%eax
call   1030 <assert@plt>
movapd 0x40(%rsp),%xmm1
ucomisd %xmm1,%xmm1
setnp  %al
ucomisd 0xe1e(%rip),%xmm1
setae  %cl
and    %al,%cl
movsd  0xe19(%rip),%xmm0
ucomisd %xmm1,%xmm0
setae  %al
and    %cl,%al
movzbl %al,%edi
xor    %eax,%eax
call   1030 <assert@plt>
xorpd  %xmm0,%xmm0
xor    %edi,%edi
movsd  0x28(%rsp),%xmm1
ucomisd %xmm0,%xmm1
setae  %dil
xor    %eax,%eax
call   1030 <assert@plt>
xor    %edi,%edi
movsd  0x38(%rsp),%xmm0
ucomisd 0xdf3(%rip),%xmm0
setae  %dil
xor    %eax,%eax
call   1030 <assert@plt>
movsd  0x30(%rsp),%xmm1
ucomisd 0xdda(%rip),%xmm1
seta   %al
movsd  0xdbf(%rip),%xmm0
ucomisd %xmm1,%xmm0
setae  %cl
and    %al,%cl
movzbl %cl,%edi
xor    %eax,%eax
call   1030 <assert@plt>
movsd  (%rsp),%xmm0
divsd  0x10(%rsp),%xmm0
call   1050 <log@plt>
movsd  0x30(%rsp),%xmm4
movapd 0x40(%rsp),%xmm2
movsd  0x38(%rsp),%xmm1
movapd %xmm4,%xmm5
mulsd  %xmm4,%xmm5
mulsd  0xd82(%rip),%xmm5
addsd  %xmm1,%xmm5
mulsd  %xmm2,%xmm5
addsd  %xmm0,%xmm5
ucomisd 0xd76(%rip),%xmm2
jb     12c5 <carry+0x175>
xorps  %xmm0,%xmm0
sqrtsd %xmm2,%xmm0
jmp    12ec <carry+0x19c>
movapd %xmm2,%xmm0
movapd %xmm5,0x10(%rsp)
call   1070 <sqrt@plt>
movapd 0x10(%rsp),%xmm5
movsd  0x30(%rsp),%xmm4
movapd 0x40(%rsp),%xmm2
movsd  0x38(%rsp),%xmm1
movsd  0x28(%rsp),%xmm3
mulsd  %xmm4,%xmm0
divsd  %xmm0,%xmm5
movapd %xmm5,0x10(%rsp)
test   %ebx,%ebx
je     1334 <carry+0x1e4>
movsd  (%rsp),%xmm0
mulsd  %xmm2,%xmm0
movsd  %xmm0,(%rsp)
subsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm1
movapd %xmm1,%xmm0
call   1040 <exp@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movaps 0x10(%rsp),%xmm0
jmp    1371 <carry+0x221>
movapd %xmm2,%xmm0
xorpd  0xd00(%rip),%xmm0
mulsd  (%rsp),%xmm0
movapd %xmm0,(%rsp)
subsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm1
movapd %xmm1,%xmm0
call   1040 <exp@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movaps 0x10(%rsp),%xmm0
xorps  0xccf(%rip),%xmm0
mov    $0x1,%al
call   1060 <cnd@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  (%rsp),%xmm0
add    $0x50,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define double @carry(i32 %0, double %1, double %2, double %3, double %4, double %5, double %6) {
%8 = fcmp ord double %1, 0.000000e+00
%9 = fcmp oge double %1, 0x3EB0C6F7A0B5ED8D
%10 = and i1 %8, %9
%11 = fcmp ole double %1, 1.000000e+12
%12 = and i1 %11, %10
%13 = zext i1 %12 to i32
%14 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %13)
%15 = fcmp ord double %2, 0.000000e+00
%16 = fcmp oge double %2, 0x3EB0C6F7A0B5ED8D
%17 = and i1 %15, %16
%18 = fcmp ole double %2, 1.000000e+12
%19 = and i1 %18, %17
%20 = zext i1 %19 to i32
%21 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %20)
%22 = fcmp ord double %3, 0.000000e+00
%23 = fcmp oge double %3, 0x3F2596179C29D2CE
%24 = and i1 %22, %23
%25 = fcmp ole double %3, 2.000000e+01
%26 = and i1 %25, %24
%27 = zext i1 %26 to i32
%28 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %27)
%29 = fcmp oge double %4, 0.000000e+00
%30 = zext i1 %29 to i32
%31 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %30)
%32 = fcmp oge double %5, 0.000000e+00
%33 = zext i1 %32 to i32
%34 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %33)
%35 = fcmp ogt double %6, 0.000000e+00
%36 = fcmp ole double %6, 1.000000e+02
%37 = and i1 %35, %36
%38 = zext i1 %37 to i32
%39 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %38)
%40 = fdiv double %1, %2
%41 = tail call double @log(double %40)
%42 = fmul double %6, %6
%43 = fmul double %42, 5.000000e-01
%44 = fadd double %43, %5
%45 = tail call double @llvm.fmuladd.f64(double %44, double %3, double %41)
%46 = tail call double @sqrt(double %3)
%47 = fmul double %46, %6
%48 = fdiv double %45, %47
%49 = icmp eq i32 %0, 0
br i1 %49, label %56, label %50
50: ; preds = %7
%51 = fmul double %1, %3
%52 = fsub double %5, %4
%53 = fmul double %52, %3
%54 = tail call double @exp(double %53)
%55 = fmul double %51, %54
br label %64
56: ; preds = %7
%57 = fneg double %3
%58 = fmul double %57, %1
%59 = fsub double %5, %4
%60 = fmul double %59, %3
%61 = tail call double @exp(double %60)
%62 = fmul double %58, %61
%63 = fneg double %48
br label %64
64: ; preds = %56, %50
%65 = phi double [ %63, %56 ], [ %48, %50 ]
%66 = phi double [ %62, %56 ], [ %55, %50 ]
%67 = tail call i32 (double, ...) bitcast (i32 (...)* @cnd to i32 (double, ...)*)(double %65)
%68 = sitofp i32 %67 to double
%69 = fmul double %66, %68
ret double %69
}