#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_lookback(short call, double S, double Smin, double r_dom,
                           double r_for, double sigma, double tau_e,
                           double tau_d) {
  double sigma_sqr = sigma * sigma;
  double tau_e_sqrt = sqrt(tau_e);
  double a1 = (log(S / Smin) + (r_dom - r_for + sigma_sqr / 2.0) * tau_e) /
              (sigma * tau_e_sqrt);
  double a2 = a1 - sigma * tau_e_sqrt;
  double a3 = (log(S / Smin) + ((-r_dom + r_for) * tau_d) +
               ((sigma_sqr / 2.0) * tau_e)) /
              (sigma * tau_e_sqrt);
  double Y1 =
      2.0 * (r_dom - r_for - sigma_sqr / 2.0) * log(S / Smin) / sigma_sqr;
  return S * exp(-r_for * tau_d) * rq_pricing_cumul_norm_dist(a1) -
         S * exp(-r_for * tau_d) * (sigma_sqr / (2.0 * (r_dom - r_for))) *
             rq_pricing_cumul_norm_dist(-a1) -
         Smin * exp(-r_dom * tau_d) *
             (rq_pricing_cumul_norm_dist(a2) -
              (sigma_sqr / (2 * (r_dom - r_for))) * exp(Y1) *
                  rq_pricing_cumul_norm_dist(-a3));
}


x86 assembly (clang, -O0):
<rq_pricing_lookback>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    %di,%ax
mov    %ax,-0x2(%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  -0x30(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x38(%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  -0x20(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
movsd  0xe44(%rip),%xmm3
divsd  %xmm3,%xmm2
addsd  %xmm2,%xmm0
movsd  -0x38(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x30(%rbp),%xmm1
mulsd  -0x50(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
movsd  -0x50(%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  -0x10(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
call   1050 <log@plt>
movsd  -0x20(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
addsd  -0x28(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
movsd  0xd9f(%rip),%xmm2
divsd  %xmm2,%xmm0
movsd  -0x38(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x30(%rbp),%xmm1
mulsd  -0x50(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x20(%rbp),%xmm1
subsd  -0x28(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
movsd  0xd64(%rip),%xmm2
divsd  %xmm2,%xmm0
subsd  %xmm0,%xmm1
movsd  0xd54(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
movsd  -0x10(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
call   1050 <log@plt>
movaps %xmm0,%xmm1
movsd  -0xd0(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
divsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x40(%rbp),%xmm0
call   1040 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0xc8(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0x58(%rbp),%xmm0
call   1030 <rq_pricing_cumul_norm_dist@plt>
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x40(%rbp),%xmm0
call   1040 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0xc0(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm3
subsd  -0x28(%rbp),%xmm3
movsd  0xc6b(%rip),%xmm2
mulsd  %xmm3,%xmm2
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
movsd  -0x58(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1030 <rq_pricing_cumul_norm_dist@plt>
movsd  -0xb8(%rbp),%xmm1
ff
movsd  -0xb0(%rbp),%xmm2
ff
movaps %xmm0,%xmm3
movsd  -0xa8(%rbp),%xmm0
ff
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x40(%rbp),%xmm0
call   1040 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0xa0(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x60(%rbp),%xmm0
call   1030 <rq_pricing_cumul_norm_dist@plt>
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x48(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
subsd  -0x28(%rbp),%xmm2
movsd  0xb83(%rip),%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x70(%rbp),%xmm0
call   1040 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x98(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x68(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1030 <rq_pricing_cumul_norm_dist@plt>
movsd  -0x90(%rbp),%xmm2
ff
movsd  -0x88(%rbp),%xmm3
ff
movsd  -0x80(%rbp),%xmm1
movaps %xmm0,%xmm4
movsd  -0x78(%rbp),%xmm0
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rq_pricing_lookback>:
sub    $0xb8,%rsp
movsd  %xmm6,0x8(%rsp)
movaps %xmm3,0x10(%rsp)
movaps %xmm2,0x50(%rsp)
movsd  %xmm1,0x68(%rsp)
movsd  %xmm0,0x48(%rsp)
movsd  %xmm4,0x70(%rsp)
movapd %xmm4,%xmm0
mulsd  %xmm4,%xmm0
movsd  %xmm0,(%rsp)
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm5
movsd  %xmm5,0x30(%rsp)
jb     118f <rq_pricing_lookback+0x4f>
xorps  %xmm0,%xmm0
sqrtsd %xmm5,%xmm0
jmp    1198 <rq_pricing_lookback+0x58>
movapd %xmm5,%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,0x28(%rsp)
movsd  0x48(%rsp),%xmm0
divsd  0x68(%rsp),%xmm0
movsd  %xmm0,0x20(%rsp)
call   1050 <log@plt>
movapd 0x50(%rsp),%xmm1
subsd  0x10(%rsp),%xmm1
movapd %xmm1,0x80(%rsp)
movsd  0xe2e(%rip),%xmm2
mulsd  (%rsp),%xmm2
movsd  %xmm2,0x40(%rsp)
addsd  %xmm2,%xmm1
mulsd  0x30(%rsp),%xmm1
addsd  %xmm1,%xmm0
movsd  0x28(%rsp),%xmm2
mulsd  0x70(%rsp),%xmm2
movsd  %xmm2,0x28(%rsp)
divsd  %xmm2,%xmm0
movapd %xmm0,0x70(%rsp)
movapd %xmm0,%xmm1
subsd  %xmm2,%xmm1
movapd %xmm1,0xa0(%rsp)
movsd  0x20(%rsp),%xmm0
call   1050 <log@plt>
movapd 0x10(%rsp),%xmm2
movapd 0x50(%rsp),%xmm1
subsd  %xmm1,%xmm2
xorpd  0xdd5(%rip),%xmm1
movapd %xmm1,0x50(%rsp)
mulsd  0x8(%rsp),%xmm2
addsd  %xmm2,%xmm0
movsd  0x40(%rsp),%xmm1
movsd  0x30(%rsp),%xmm2
mulsd  %xmm1,%xmm2
addsd  %xmm2,%xmm0
movapd %xmm0,0x90(%rsp)
movapd 0x80(%rsp),%xmm0
subsd  %xmm1,%xmm0
addsd  %xmm0,%xmm0
movapd %xmm0,0x30(%rsp)
movsd  0x20(%rsp),%xmm0
call   1050 <log@plt>
mulsd  0x30(%rsp),%xmm0
divsd  (%rsp),%xmm0
movsd  %xmm0,0x20(%rsp)
movapd 0x10(%rsp),%xmm0
xorpd  0xd67(%rip),%xmm0
mulsd  0x8(%rsp),%xmm0
movapd %xmm0,0x10(%rsp)
call   1040 <exp@plt>
mulsd  0x48(%rsp),%xmm0
movsd  %xmm0,0x40(%rsp)
movaps 0x70(%rsp),%xmm0
call   1030 <rq_pricing_cumul_norm_dist@plt>
movsd  %xmm0,0x30(%rsp)
movaps 0x10(%rsp),%xmm0
call   1040 <exp@plt>
movsd  %xmm0,0x10(%rsp)
movapd 0x80(%rsp),%xmm1
addsd  %xmm1,%xmm1
movsd  (%rsp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
movapd 0x70(%rsp),%xmm0
xorpd  0xd01(%rip),%xmm0
call   1030 <rq_pricing_cumul_norm_dist@plt>
movsd  0x10(%rsp),%xmm1
mulsd  0x48(%rsp),%xmm1
mulsd  (%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  0x30(%rsp),%xmm0
mulsd  0x40(%rsp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,0x30(%rsp)
movapd 0x50(%rsp),%xmm0
mulsd  0x8(%rsp),%xmm0
call   1040 <exp@plt>
movsd  %xmm0,0x10(%rsp)
movaps 0xa0(%rsp),%xmm0
call   1030 <rq_pricing_cumul_norm_dist@plt>
movsd  %xmm0,0x50(%rsp)
movsd  0x20(%rsp),%xmm0
call   1040 <exp@plt>
movsd  %xmm0,0x8(%rsp)
movapd 0x90(%rsp),%xmm0
xorpd  0xc85(%rip),%xmm0
divsd  0x28(%rsp),%xmm0
call   1030 <rq_pricing_cumul_norm_dist@plt>
movsd  0x8(%rsp),%xmm1
mulsd  (%rsp),%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
movsd  0x50(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  0x10(%rsp),%xmm0
mulsd  0x68(%rsp),%xmm0
mulsd  %xmm1,%xmm0
movapd %xmm0,%xmm1
movsd  0x30(%rsp),%xmm0
subsd  %xmm1,%xmm0
add    $0xb8,%rsp
ret

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

LLVM IR (-O2):
define double @rq_pricing_lookback(i16 signext %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7) {
%9 = fmul double %5, %5
%10 = tail call double @sqrt(double %6)
%11 = fdiv double %1, %2
%12 = tail call double @log(double %11)
%13 = fsub double %3, %4
%14 = fmul double %9, 5.000000e-01
%15 = fadd double %13, %14
%16 = tail call double @llvm.fmuladd.f64(double %15, double %6, double %12)
%17 = fmul double %10, %5
%18 = fdiv double %16, %17
%19 = fneg double %5
%20 = tail call double @llvm.fmuladd.f64(double %19, double %10, double %18)
%21 = tail call double @log(double %11)
%22 = fneg double %3
%23 = fsub double %4, %3
%24 = tail call double @llvm.fmuladd.f64(double %23, double %7, double %21)
%25 = tail call double @llvm.fmuladd.f64(double %14, double %6, double %24)
%26 = fsub double %13, %14
%27 = fmul double %26, 2.000000e+00
%28 = tail call double @log(double %11)
%29 = fmul double %27, %28
%30 = fdiv double %29, %9
%31 = fneg double %4
%32 = fmul double %31, %7
%33 = tail call double @exp(double %32)
%34 = fmul double %33, %1
%35 = tail call double @rq_pricing_cumul_norm_dist(double %18)
%36 = tail call double @exp(double %32)
%37 = fmul double %13, 2.000000e+00
%38 = fdiv double %9, %37
%39 = fneg double %18
%40 = tail call double @rq_pricing_cumul_norm_dist(double %39)
%41 = fneg double %36
%42 = fmul double %41, %1
%43 = fmul double %38, %42
%44 = fmul double %40, %43
%45 = tail call double @llvm.fmuladd.f64(double %34, double %35, double %44)
%46 = fmul double %22, %7
%47 = tail call double @exp(double %46)
%48 = tail call double @rq_pricing_cumul_norm_dist(double %20)
%49 = tail call double @exp(double %30)
%50 = fneg double %25
%51 = fdiv double %50, %17
%52 = tail call double @rq_pricing_cumul_norm_dist(double %51)
%53 = fneg double %38
%54 = fmul double %49, %53
%55 = tail call double @llvm.fmuladd.f64(double %54, double %52, double %48)
%56 = fneg double %47
%57 = fmul double %56, %2
%58 = tail call double @llvm.fmuladd.f64(double %57, double %55, double %45)
ret double %58
}