double EuropeanExchangeOption(double S1, double S2, double Q1, double Q2,
                              double T, double r, double b1, double b2,
                              double v1, double v2, double Rho) {
  const double v = sqrt(((v1) * (v1)) + ((v2) * (v2)) - 2.0 * Rho * v1 * v2);
  const double vsT = v * sqrt(T);
  const double d1 =
      (log(Q1 * S1 / (Q2 * S2)) + (b1 - b2 + ((v) * (v)) / 2.0) * T) / vsT;
  const double d2 = d1 - vsT;
  return Q1 * S1 * exp((b1 - r) * T) * cnd(d1) -
         Q2 * S2 * exp((b2 - r) * T) * cnd(d2);
}


x86 assembly (clang, -O0):
<EuropeanExchangeOption>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movsd  0x20(%rbp),%xmm8
movsd  0x18(%rbp),%xmm8
movsd  0x10(%rbp),%xmm8
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
movsd  %xmm5,-0x30(%rbp)
movsd  %xmm6,-0x38(%rbp)
movsd  %xmm7,-0x40(%rbp)
movsd  0x10(%rbp),%xmm1
movsd  0x10(%rbp),%xmm2
movsd  0x18(%rbp),%xmm0
mulsd  0x18(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xe57(%rip),%xmm0
mulsd  0x20(%rbp),%xmm0
mulsd  0x10(%rbp),%xmm0
movsd  0x18(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x28(%rbp),%xmm0
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x90(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1040 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
mulsd  -0x48(%rbp),%xmm2
movsd  0xdb8(%rip),%xmm3
divsd  %xmm3,%xmm2
addsd  %xmm2,%xmm0
movsd  -0x28(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
subsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x38(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x88(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x58(%rbp),%xmm0
mov    $0x1,%al
call   1050 <cnd@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x40(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x80(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x60(%rbp),%xmm0
mov    $0x1,%al
call   1050 <cnd@plt>
movsd  -0x78(%rbp),%xmm1
movsd  -0x70(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm2
cvtsi2sd %eax,%xmm3
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<EuropeanExchangeOption>:
sub    $0x58,%rsp
movsd  %xmm7,0x38(%rsp)
movsd  %xmm6,0x50(%rsp)
movsd  %xmm5,0x30(%rsp)
movsd  %xmm3,0x20(%rsp)
movsd  %xmm2,0x48(%rsp)
movsd  %xmm1,0x28(%rsp)
movsd  %xmm0,0x8(%rsp)
movsd  0x70(%rsp),%xmm0
movsd  0x60(%rsp),%xmm1
movsd  0x68(%rsp),%xmm2
mulsd  0xe78(%rip),%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm2,%xmm0
mulsd  %xmm2,%xmm2
mulsd  %xmm1,%xmm1
addsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
movsd  %xmm4,0x18(%rsp)
jb     11b6 <EuropeanExchangeOption+0x76>
sqrtsd %xmm0,%xmm0
jmp    11c5 <EuropeanExchangeOption+0x85>
call   1060 <sqrt@plt>
xorpd  %xmm1,%xmm1
movsd  0x18(%rsp),%xmm4
movsd  %xmm0,0x10(%rsp)
ucomisd %xmm1,%xmm4
jb     11da <EuropeanExchangeOption+0x9a>
xorps  %xmm0,%xmm0
sqrtsd %xmm4,%xmm0
jmp    11e3 <EuropeanExchangeOption+0xa3>
movapd %xmm4,%xmm0
call   1060 <sqrt@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x40(%rsp)
movsd  0x8(%rsp),%xmm2
mulsd  0x48(%rsp),%xmm2
movsd  %xmm2,0x8(%rsp)
movsd  0x28(%rsp),%xmm1
mulsd  0x20(%rsp),%xmm1
movsd  %xmm1,0x28(%rsp)
movapd %xmm2,%xmm0
divsd  %xmm1,%xmm0
call   1040 <log@plt>
movapd %xmm0,%xmm3
movsd  0x50(%rsp),%xmm0
movapd %xmm0,%xmm1
movsd  0x10(%rsp),%xmm2
mulsd  %xmm2,%xmm2
mulsd  0xdc8(%rip),%xmm2
subsd  0x38(%rsp),%xmm1
addsd  %xmm1,%xmm2
movsd  0x18(%rsp),%xmm1
mulsd  %xmm1,%xmm2
addsd  %xmm2,%xmm3
movsd  0x40(%rsp),%xmm4
divsd  %xmm4,%xmm3
movsd  %xmm3,0x20(%rsp)
subsd  %xmm4,%xmm3
movsd  %xmm3,0x10(%rsp)
subsd  0x30(%rsp),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <exp@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x20(%rsp),%xmm0
mov    $0x1,%al
call   1050 <cnd@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x38(%rsp),%xmm0
subsd  0x30(%rsp),%xmm0
mulsd  0x18(%rsp),%xmm0
call   1030 <exp@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x10(%rsp),%xmm0
mov    $0x1,%al
call   1050 <cnd@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x18(%rsp),%xmm1
mulsd  0x28(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
subsd  %xmm1,%xmm0
add    $0x58,%rsp
ret

LLVM IR (-O0):
define double @EuropeanExchangeOption(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, double %8, double %9, double %10) {
%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
%23 = alloca double
%24 = alloca double
%25 = alloca double
%26 = alloca double
store double %0, double* %12
store double %1, double* %13
store double %2, double* %14
store double %3, double* %15
store double %4, double* %16
store double %5, double* %17
store double %6, double* %18
store double %7, double* %19
store double %8, double* %20
store double %9, double* %21
store double %10, double* %22
%27 = load double, double* %20
%28 = load double, double* %20
%29 = load double, double* %21
%30 = load double, double* %21
%31 = fmul double %29, %30
%32 = call double @llvm.fmuladd.f64(double %27, double %28, double %31)
%33 = load double, double* %22
%34 = fmul double 2.000000e+00, %33
%35 = load double, double* %20
%36 = fmul double %34, %35
%37 = load double, double* %21
%38 = fneg double %36
%39 = call double @llvm.fmuladd.f64(double %38, double %37, double %32)
%40 = call double @sqrt(double %39)
store double %40, double* %23
%41 = load double, double* %23
%42 = load double, double* %16
%43 = call double @sqrt(double %42)
%44 = fmul double %41, %43
store double %44, double* %24
%45 = load double, double* %14
%46 = load double, double* %12
%47 = fmul double %45, %46
%48 = load double, double* %15
%49 = load double, double* %13
%50 = fmul double %48, %49
%51 = fdiv double %47, %50
%52 = call double @log(double %51)
%53 = load double, double* %18
%54 = load double, double* %19
%55 = fsub double %53, %54
%56 = load double, double* %23
%57 = load double, double* %23
%58 = fmul double %56, %57
%59 = fdiv double %58, 2.000000e+00
%60 = fadd double %55, %59
%61 = load double, double* %16
%62 = call double @llvm.fmuladd.f64(double %60, double %61, double %52)
%63 = load double, double* %24
%64 = fdiv double %62, %63
store double %64, double* %25
%65 = load double, double* %25
%66 = load double, double* %24
%67 = fsub double %65, %66
store double %67, double* %26
%68 = load double, double* %14
%69 = load double, double* %12
%70 = fmul double %68, %69
%71 = load double, double* %18
%72 = load double, double* %17
%73 = fsub double %71, %72
%74 = load double, double* %16
%75 = fmul double %73, %74
%76 = call double @exp(double %75)
%77 = fmul double %70, %76
%78 = load double, double* %25
%79 = call i32 (double, ...) bitcast (i32 (...)* @cnd to i32 (double, ...)*)(double %78)
%80 = sitofp i32 %79 to double
%81 = load double, double* %15
%82 = load double, double* %13
%83 = fmul double %81, %82
%84 = load double, double* %19
%85 = load double, double* %17
%86 = fsub double %84, %85
%87 = load double, double* %16
%88 = fmul double %86, %87
%89 = call double @exp(double %88)
%90 = fmul double %83, %89
%91 = load double, double* %26
%92 = call i32 (double, ...) bitcast (i32 (...)* @cnd to i32 (double, ...)*)(double %91)
%93 = sitofp i32 %92 to double
%94 = fmul double %90, %93
%95 = fneg double %94
%96 = call double @llvm.fmuladd.f64(double %77, double %80, double %95)
ret double %96
}

LLVM IR (-O2):
define double @EuropeanExchangeOption(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, double %8, double %9, double %10) {
%12 = fmul double %9, %9
%13 = tail call double @llvm.fmuladd.f64(double %8, double %8, double %12)
%14 = fmul double %10, -2.000000e+00
%15 = fmul double %14, %8
%16 = tail call double @llvm.fmuladd.f64(double %15, double %9, double %13)
%17 = tail call double @sqrt(double %16)
%18 = tail call double @sqrt(double %4)
%19 = fmul double %17, %18
%20 = fmul double %0, %2
%21 = fmul double %1, %3
%22 = fdiv double %20, %21
%23 = tail call double @log(double %22)
%24 = fsub double %6, %7
%25 = fmul double %17, %17
%26 = fmul double %25, 5.000000e-01
%27 = fadd double %24, %26
%28 = tail call double @llvm.fmuladd.f64(double %27, double %4, double %23)
%29 = fdiv double %28, %19
%30 = fsub double %29, %19
%31 = fsub double %6, %5
%32 = fmul double %31, %4
%33 = tail call double @exp(double %32)
%34 = fmul double %20, %33
%35 = tail call i32 (double, ...) bitcast (i32 (...)* @cnd to i32 (double, ...)*)(double %29)
%36 = sitofp i32 %35 to double
%37 = fsub double %7, %5
%38 = fmul double %37, %4
%39 = tail call double @exp(double %38)
%40 = tail call i32 (double, ...) bitcast (i32 (...)* @cnd to i32 (double, ...)*)(double %30)
%41 = sitofp i32 %40 to double
%42 = fneg double %21
%43 = fmul double %39, %42
%44 = fmul double %43, %41
%45 = tail call double @llvm.fmuladd.f64(double %34, double %36, double %44)
ret double %45
}