#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
double exp(double);
double log(double);
double rq_pricing_cumul_norm_dist(double);
double sqrt(double);
double rq_pricing_spread(int call, double f1, double f2, double k, double T,
                         double r, double v1, double v2, double rho) {
  double f = f1 / (f2 + k);
  double f2_part = f2 / (f2 + k);
  double v2_f2 = v2 * f2_part;
  double v = sqrt((v1 * v1) + (v2_f2 * v2_f2) - (2 * rho * v1 * v2 * f2_part));
  double v_sqrt_t = v * sqrt(T);
  double d1 = (log(f) + ((v * v) / 2.0) * T) / v_sqrt_t;
  double d2 = d1 - v_sqrt_t;
  double ret;
  if (call)
    ret = (f2 + k) * (exp(-r * T) * (f * rq_pricing_cumul_norm_dist(d1) -
                                     rq_pricing_cumul_norm_dist(d2)));
  else
    ret = (f2 + k) * (exp(-r * T) * (rq_pricing_cumul_norm_dist(-d2) -
                                     f * rq_pricing_cumul_norm_dist(-d1)));
  return ret;
}


x86 assembly (clang, -O0):
<rq_pricing_spread>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%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  %xmm6,-0x40(%rbp)
movsd  %xmm7,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
addsd  -0x20(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
addsd  -0x20(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x40(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x38(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
movsd  -0x60(%rbp),%xmm0
mulsd  -0x60(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xe27(%rip),%xmm0
mulsd  -0x48(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  -0x58(%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,-0x68(%rbp)
movsd  -0x68(%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,-0x70(%rbp)
movsd  -0x50(%rbp),%xmm0
call   1050 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
mulsd  -0x68(%rbp),%xmm0
movsd  0xda0(%rip),%xmm2
divsd  %xmm2,%xmm0
movsd  -0x28(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x78(%rbp),%xmm0
subsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1354 <rq_pricing_spread+0x214>
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x30(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x28(%rbp),%xmm0
call   1040 <exp@plt>
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0x78(%rbp),%xmm0
call   1030 <rq_pricing_cumul_norm_dist@plt>
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0x80(%rbp),%xmm0
call   1030 <rq_pricing_cumul_norm_dist@plt>
movsd  -0xb0(%rbp),%xmm2
ff
movsd  -0xa8(%rbp),%xmm4
ff
movsd  -0xa0(%rbp),%xmm1
ff
movaps %xmm0,%xmm3
movsd  -0x98(%rbp),%xmm0
ff
movq   %xmm3,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm3
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
jmp    143d <rq_pricing_spread+0x2fd>
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
movsd  -0x30(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x28(%rbp),%xmm0
call   1040 <exp@plt>
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  -0x80(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1030 <rq_pricing_cumul_norm_dist@plt>
movsd  %xmm0,-0xc8(%rbp)
ff
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
movsd  -0x78(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1030 <rq_pricing_cumul_norm_dist@plt>
movsd  -0xd0(%rbp),%xmm2
ff
movsd  -0xc8(%rbp),%xmm3
ff
movsd  -0xc0(%rbp),%xmm1
ff
movaps %xmm0,%xmm4
movsd  -0xb8(%rbp),%xmm0
ff
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x88(%rbp),%xmm0
ff
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rq_pricing_spread>:
push   %rbx
sub    $0x50,%rsp
movapd %xmm0,%xmm8
mov    %edi,%ebx
addsd  %xmm1,%xmm2
mulsd  0xea8(%rip),%xmm7
divsd  %xmm2,%xmm1
mulsd  %xmm5,%xmm7
mulsd  %xmm6,%xmm7
mulsd  %xmm1,%xmm7
mulsd  %xmm6,%xmm1
mulsd  %xmm1,%xmm1
mulsd  %xmm5,%xmm5
addsd  %xmm1,%xmm5
addsd  %xmm5,%xmm7
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm7
movsd  %xmm2,0x28(%rsp)
movaps %xmm4,0x40(%rsp)
movsd  %xmm3,0x8(%rsp)
jb     11a0 <rq_pricing_spread+0x60>
xorps  %xmm0,%xmm0
sqrtsd %xmm7,%xmm0
jmp    11c5 <rq_pricing_spread+0x85>
movapd %xmm7,%xmm0
movsd  %xmm8,(%rsp)
call   1060 <sqrt@plt>
xorpd  %xmm1,%xmm1
movsd  0x8(%rsp),%xmm3
movsd  (%rsp),%xmm8
movsd  0x28(%rsp),%xmm2
divsd  %xmm2,%xmm8
ucomisd %xmm1,%xmm3
movsd  %xmm8,(%rsp)
movapd %xmm0,0x10(%rsp)
jb     11e5 <rq_pricing_spread+0xa5>
xorps  %xmm1,%xmm1
sqrtsd %xmm3,%xmm1
jmp    11fe <rq_pricing_spread+0xbe>
movapd %xmm3,%xmm0
call   1060 <sqrt@plt>
movsd  (%rsp),%xmm8
movapd %xmm0,%xmm1
movapd 0x10(%rsp),%xmm0
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x30(%rsp)
movapd %xmm8,%xmm0
call   1050 <log@plt>
movapd 0x10(%rsp),%xmm2
mulsd  %xmm2,%xmm2
mulsd  0xde4(%rip),%xmm2
movsd  0x8(%rsp),%xmm1
mulsd  %xmm1,%xmm2
addsd  %xmm0,%xmm2
movsd  0x30(%rsp),%xmm3
divsd  %xmm3,%xmm2
movapd %xmm2,0x10(%rsp)
movapd %xmm2,%xmm0
subsd  %xmm3,%xmm0
movapd %xmm0,0x30(%rsp)
movapd 0x40(%rsp),%xmm0
xorpd  0xdb2(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1040 <exp@plt>
movsd  %xmm0,0x8(%rsp)
test   %ebx,%ebx
je     12a1 <rq_pricing_spread+0x161>
movaps 0x10(%rsp),%xmm0
call   1030 <rq_pricing_cumul_norm_dist@plt>
movsd  %xmm0,0x10(%rsp)
movapd 0x30(%rsp),%xmm0
call   1030 <rq_pricing_cumul_norm_dist@plt>
movsd  (%rsp),%xmm1
mulsd  0x10(%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
jmp    12de <rq_pricing_spread+0x19e>
movaps 0x30(%rsp),%xmm0
xorps  0xd63(%rip),%xmm0
call   1030 <rq_pricing_cumul_norm_dist@plt>
movsd  %xmm0,0x40(%rsp)
movapd 0x10(%rsp),%xmm0
xorpd  0xd4a(%rip),%xmm0
call   1030 <rq_pricing_cumul_norm_dist@plt>
movsd  (%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  0x40(%rsp),%xmm0
subsd  %xmm1,%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  0x28(%rsp),%xmm0
mulsd  %xmm1,%xmm0
add    $0x50,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define double @rq_pricing_spread(i32 %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, double %8) {
%10 = fadd double %2, %3
%11 = fdiv double %1, %10
%12 = fdiv double %2, %10
%13 = fmul double %12, %7
%14 = fmul double %13, %13
%15 = tail call double @llvm.fmuladd.f64(double %6, double %6, double %14)
%16 = fmul double %8, -2.000000e+00
%17 = fmul double %16, %6
%18 = fmul double %17, %7
%19 = tail call double @llvm.fmuladd.f64(double %18, double %12, double %15)
%20 = tail call double @sqrt(double %19)
%21 = tail call double @sqrt(double %4)
%22 = fmul double %20, %21
%23 = tail call double @log(double %11)
%24 = fmul double %20, %20
%25 = fmul double %24, 5.000000e-01
%26 = tail call double @llvm.fmuladd.f64(double %25, double %4, double %23)
%27 = fdiv double %26, %22
%28 = fsub double %27, %22
%29 = icmp eq i32 %0, 0
%30 = fneg double %5
%31 = fmul double %30, %4
%32 = tail call double @exp(double %31)
br i1 %29, label %38, label %33
33: ; preds = %9
%34 = tail call double @rq_pricing_cumul_norm_dist(double %27)
%35 = tail call double @rq_pricing_cumul_norm_dist(double %28)
%36 = fneg double %35
%37 = tail call double @llvm.fmuladd.f64(double %11, double %34, double %36)
br label %45
38: ; preds = %9
%39 = fneg double %28
%40 = tail call double @rq_pricing_cumul_norm_dist(double %39)
%41 = fneg double %27
%42 = tail call double @rq_pricing_cumul_norm_dist(double %41)
%43 = fneg double %11
%44 = tail call double @llvm.fmuladd.f64(double %43, double %42, double %40)
br label %45
45: ; preds = %38, %33
%46 = phi double [ %44, %38 ], [ %37, %33 ]
%47 = fmul double %32, %46
%48 = fmul double %10, %47
ret double %48
}