#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_futureopt(int call, double F, double X, double r_dom,
                            double sigma, double tau_e, double tau_d) {
  double m = (call ? 1.0 : -1.0);
  double sigma_sqr = sigma * sigma;
  double time_sqrt = sqrt(tau_e);
  double d1 = (log(F / X) + 0.5 * sigma_sqr * tau_e) / (sigma * time_sqrt);
  double d2 = d1 - sigma * time_sqrt * m;
  d1 *= m;
  return exp(-r_dom * tau_d) * ((F * rq_pricing_cumul_norm_dist(d1) * m) +
                                (X * rq_pricing_cumul_norm_dist(d2) * -m));
}


x86 assembly (clang, -O0):
<rq_pricing_futureopt>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%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)
mov    -0x4(%rbp),%eax
movsd  0xe91(%rip),%xmm0
movsd  0xe91(%rip),%xmm1
movsd  %xmm1,-0x70(%rbp)
cmp    $0x0,%eax
movsd  %xmm0,-0x68(%rbp)
jne    119c <rq_pricing_futureopt+0x5c>
movsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
call   1050 <log@plt>
movaps %xmm0,%xmm1
movsd  0xe22(%rip),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x28(%rbp),%xmm1
mulsd  -0x50(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x40(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x38(%rbp),%xmm0
call   1040 <exp@plt>
movsd  %xmm0,-0x78(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x58(%rbp),%xmm0
call   1030 <rq_pricing_cumul_norm_dist@plt>
movaps %xmm0,%xmm1
movsd  -0x98(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x60(%rbp),%xmm0
call   1030 <rq_pricing_cumul_norm_dist@plt>
movsd  -0x90(%rbp),%xmm2
ff
movsd  -0x88(%rbp),%xmm1
ff
movsd  -0x80(%rbp),%xmm3
movaps %xmm0,%xmm4
movsd  -0x78(%rbp),%xmm0
mulsd  %xmm4,%xmm2
movsd  -0x40(%rbp),%xmm4
movq   %xmm4,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm4
mulsd  %xmm4,%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rq_pricing_futureopt>:
sub    $0x58,%rsp
movsd  %xmm5,0x18(%rsp)
movaps %xmm2,0x40(%rsp)
movsd  %xmm1,0x30(%rsp)
movsd  %xmm0,(%rsp)
xor    %eax,%eax
test   %edi,%edi
sete   %al
lea    0xe98(%rip),%rcx
movsd  (%rcx,%rax,8),%xmm0
movsd  %xmm0,0x28(%rsp)
movsd  %xmm3,0x10(%rsp)
mulsd  %xmm3,%xmm3
movsd  %xmm3,0x38(%rsp)
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm4
movsd  %xmm4,0x8(%rsp)
jb     119c <rq_pricing_futureopt+0x5c>
xorps  %xmm0,%xmm0
sqrtsd %xmm4,%xmm0
jmp    11a5 <rq_pricing_futureopt+0x65>
movapd %xmm4,%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,0x20(%rsp)
movsd  (%rsp),%xmm0
divsd  0x30(%rsp),%xmm0
call   1050 <log@plt>
movsd  0x38(%rsp),%xmm1
mulsd  0xe57(%rip),%xmm1
mulsd  0x8(%rsp),%xmm1
addsd  %xmm1,%xmm0
movsd  0x20(%rsp),%xmm2
mulsd  0x10(%rsp),%xmm2
divsd  %xmm2,%xmm0
movsd  0x28(%rsp),%xmm1
mulsd  %xmm1,%xmm2
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
subsd  %xmm2,%xmm0
movsd  %xmm0,0x10(%rsp)
movapd 0x40(%rsp),%xmm0
xorpd  0xe01(%rip),%xmm0
mulsd  0x18(%rsp),%xmm0
call   1040 <exp@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <rq_pricing_cumul_norm_dist@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <rq_pricing_cumul_norm_dist@plt>
mulsd  0x30(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
mulsd  %xmm1,%xmm0
movsd  (%rsp),%xmm2
mulsd  %xmm1,%xmm2
subsd  %xmm0,%xmm2
mulsd  0x18(%rsp),%xmm2
movapd %xmm2,%xmm0
add    $0x58,%rsp
ret

LLVM IR (-O0):
define double @rq_pricing_futureopt(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
%17 = alloca double
%18 = alloca double
%19 = 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
%20 = load i32, i32* %8
%21 = icmp ne i32 %20, 0
%22 = zext i1 %21 to i64
%23 = select i1 %21, double 1.000000e+00, double -1.000000e+00
store double %23, double* %15
%24 = load double, double* %12
%25 = load double, double* %12
%26 = fmul double %24, %25
store double %26, double* %16
%27 = load double, double* %13
%28 = call double @sqrt(double %27)
store double %28, double* %17
%29 = load double, double* %9
%30 = load double, double* %10
%31 = fdiv double %29, %30
%32 = call double @log(double %31)
%33 = load double, double* %16
%34 = fmul double 5.000000e-01, %33
%35 = load double, double* %13
%36 = call double @llvm.fmuladd.f64(double %34, double %35, double %32)
%37 = load double, double* %12
%38 = load double, double* %17
%39 = fmul double %37, %38
%40 = fdiv double %36, %39
store double %40, double* %18
%41 = load double, double* %18
%42 = load double, double* %12
%43 = load double, double* %17
%44 = fmul double %42, %43
%45 = load double, double* %15
%46 = fneg double %44
%47 = call double @llvm.fmuladd.f64(double %46, double %45, double %41)
store double %47, double* %19
%48 = load double, double* %15
%49 = load double, double* %18
%50 = fmul double %49, %48
store double %50, double* %18
%51 = load double, double* %11
%52 = fneg double %51
%53 = load double, double* %14
%54 = fmul double %52, %53
%55 = call double @exp(double %54)
%56 = load double, double* %9
%57 = load double, double* %18
%58 = call double @rq_pricing_cumul_norm_dist(double %57)
%59 = fmul double %56, %58
%60 = load double, double* %15
%61 = load double, double* %10
%62 = load double, double* %19
%63 = call double @rq_pricing_cumul_norm_dist(double %62)
%64 = fmul double %61, %63
%65 = load double, double* %15
%66 = fneg double %65
%67 = fmul double %64, %66
%68 = call double @llvm.fmuladd.f64(double %59, double %60, double %67)
%69 = fmul double %55, %68
ret double %69
}

LLVM IR (-O2):
define double @rq_pricing_futureopt(i32 %0, double %1, double %2, double %3, double %4, double %5, double %6) {
%8 = icmp eq i32 %0, 0
%9 = select i1 %8, double -1.000000e+00, double 1.000000e+00
%10 = fmul double %4, %4
%11 = tail call double @sqrt(double %5)
%12 = fdiv double %1, %2
%13 = tail call double @log(double %12)
%14 = fmul double %10, 5.000000e-01
%15 = tail call double @llvm.fmuladd.f64(double %14, double %5, double %13)
%16 = fmul double %11, %4
%17 = fdiv double %15, %16
%18 = fneg double %16
%19 = tail call double @llvm.fmuladd.f64(double %18, double %9, double %17)
%20 = fmul double %9, %17
%21 = fneg double %3
%22 = fmul double %21, %6
%23 = tail call double @exp(double %22)
%24 = tail call double @rq_pricing_cumul_norm_dist(double %20)
%25 = fmul double %24, %1
%26 = tail call double @rq_pricing_cumul_norm_dist(double %19)
%27 = fmul double %26, %2
%28 = fneg double %9
%29 = fmul double %27, %28
%30 = tail call double @llvm.fmuladd.f64(double %25, double %9, double %29)
%31 = fmul double %23, %30
ret double %31
}