#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 rq_pricing_blackscholes_gen(short, double, double, double, double,
                                   double, double);
double sqrt(int);
double rq_pricing_average_rate_geometric(short call, double S, double SA,
                                         double X, double r, double rf,
                                         double v, double T, double T2) {
  double t1 = T - T2;
  double b = r - rf;
  double bA = 1.0 / 2.0 * (b - (v * v) / 6.0);
  double vA = v / sqrt(3);
  double ret = 0.0;
  if (t1 > 0) {
    X = (t1 + T2) / T2 * X - t1 / T2 * SA;
    ret =
        rq_pricing_blackscholes_gen(call, S, X, T2, r, bA, vA) * T2 / (t1 + T2);
  } else if (t1 == 0)
    ret = rq_pricing_blackscholes_gen(call, S, SA, T, r, bA, vA);
  return ret;
}


x86 assembly (clang, -O0):
<rq_pricing_average_rate_geometric>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%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  %xmm7,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
subsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  0xe79(%rip),%xmm2
divsd  %xmm2,%xmm0
subsd  %xmm0,%xmm1
movsd  0xe61(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
mov    $0x3,%edi
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x78(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x50(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1275 <rq_pricing_average_rate_geometric+0x155>
movsd  -0x50(%rbp),%xmm0
addsd  -0x48(%rbp),%xmm0
divsd  -0x48(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm1
divsd  -0x48(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x2(%rbp),%ax
movsd  -0x10(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm3
movsd  -0x60(%rbp),%xmm4
movsd  -0x68(%rbp),%xmm5
movswl %ax,%edi
call   1030 <rq_pricing_blackscholes_gen@plt>
mulsd  -0x48(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
addsd  -0x48(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
jmp    12c1 <rq_pricing_average_rate_geometric+0x1a1>
movsd  -0x50(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    12bc <rq_pricing_average_rate_geometric+0x19c>
jp     12bc <rq_pricing_average_rate_geometric+0x19c>
mov    -0x2(%rbp),%ax
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm3
movsd  -0x60(%rbp),%xmm4
movsd  -0x68(%rbp),%xmm5
movswl %ax,%edi
call   1030 <rq_pricing_blackscholes_gen@plt>
movsd  %xmm0,-0x70(%rbp)
jmp    12c1 <rq_pricing_average_rate_geometric+0x1a1>
movsd  -0x70(%rbp),%xmm0
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rq_pricing_average_rate_geometric>:
push   %rbx
sub    $0x50,%rsp
movsd  %xmm5,0x8(%rsp)
movsd  %xmm2,0x40(%rsp)
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x20(%rsp)
mov    %edi,%ebx
movsd  %xmm6,0x38(%rsp)
movsd  %xmm3,0x28(%rsp)
movapd %xmm3,%xmm0
subsd  %xmm4,%xmm0
movapd %xmm5,%xmm1
mulsd  %xmm5,%xmm1
divsd  0xe9d(%rip),%xmm1
movsd  %xmm7,0x30(%rsp)
subsd  %xmm7,%xmm6
movsd  %xmm6,0x48(%rsp)
addsd  %xmm0,%xmm1
mulsd  0xe89(%rip),%xmm1
movsd  %xmm1,0x18(%rsp)
mov    $0x3,%edi
call   1040 <sqrt@plt>
movsd  0x48(%rsp),%xmm2
movsd  0x8(%rsp),%xmm5
divsd  %xmm0,%xmm5
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
jbe    1201 <rq_pricing_average_rate_geometric+0xe1>
movapd %xmm2,%xmm1
movsd  0x30(%rsp),%xmm3
addsd  %xmm3,%xmm1
movsd  %xmm1,0x8(%rsp)
divsd  %xmm3,%xmm1
divsd  %xmm3,%xmm2
mulsd  0x10(%rsp),%xmm2
mulsd  0x40(%rsp),%xmm1
subsd  %xmm2,%xmm1
movswl %bx,%edi
movsd  0x20(%rsp),%xmm0
movapd %xmm3,%xmm2
movsd  0x28(%rsp),%xmm3
movsd  0x18(%rsp),%xmm4
call   1030 <rq_pricing_blackscholes_gen@plt>
mulsd  0x30(%rsp),%xmm0
divsd  0x8(%rsp),%xmm0
jmp    123c <rq_pricing_average_rate_geometric+0x11c>
movsd  0x38(%rsp),%xmm6
movsd  0x10(%rsp),%xmm2
movsd  0x20(%rsp),%xmm1
movsd  0x18(%rsp),%xmm4
movsd  0x28(%rsp),%xmm3
jne    123c <rq_pricing_average_rate_geometric+0x11c>
jp     123c <rq_pricing_average_rate_geometric+0x11c>
movswl %bx,%edi
movapd %xmm1,%xmm0
movapd %xmm2,%xmm1
movapd %xmm6,%xmm2
add    $0x50,%rsp
pop    %rbx
jmp    1030 <rq_pricing_blackscholes_gen@plt>
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @rq_pricing_average_rate_geometric(i16 signext %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, double %8) {
%10 = alloca i16
%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
store i16 %0, i16* %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
%24 = load double, double* %17
%25 = load double, double* %18
%26 = fsub double %24, %25
store double %26, double* %19
%27 = load double, double* %14
%28 = load double, double* %15
%29 = fsub double %27, %28
store double %29, double* %20
%30 = load double, double* %20
%31 = load double, double* %16
%32 = load double, double* %16
%33 = fmul double %31, %32
%34 = fdiv double %33, 6.000000e+00
%35 = fsub double %30, %34
%36 = fmul double 5.000000e-01, %35
store double %36, double* %21
%37 = load double, double* %16
%38 = call double @sqrt(i32 3)
%39 = fdiv double %37, %38
store double %39, double* %22
store double 0.000000e+00, double* %23
%40 = load double, double* %19
%41 = fcmp ogt double %40, 0.000000e+00
br i1 %41, label %42, label %70
42: ; preds = %9
%43 = load double, double* %19
%44 = load double, double* %18
%45 = fadd double %43, %44
%46 = load double, double* %18
%47 = fdiv double %45, %46
%48 = load double, double* %13
%49 = load double, double* %19
%50 = load double, double* %18
%51 = fdiv double %49, %50
%52 = load double, double* %12
%53 = fmul double %51, %52
%54 = fneg double %53
%55 = call double @llvm.fmuladd.f64(double %47, double %48, double %54)
store double %55, double* %13
%56 = load i16, i16* %10
%57 = load double, double* %11
%58 = load double, double* %13
%59 = load double, double* %18
%60 = load double, double* %14
%61 = load double, double* %21
%62 = load double, double* %22
%63 = call double @rq_pricing_blackscholes_gen(i16 signext %56, double %57, double %58, double %59, double %60, double %61, double %62)
%64 = load double, double* %18
%65 = fmul double %63, %64
%66 = load double, double* %19
%67 = load double, double* %18
%68 = fadd double %66, %67
%69 = fdiv double %65, %68
store double %69, double* %23
br label %83
70: ; preds = %9
%71 = load double, double* %19
%72 = fcmp oeq double %71, 0.000000e+00
br i1 %72, label %73, label %82
73: ; preds = %70
%74 = load i16, i16* %10
%75 = load double, double* %11
%76 = load double, double* %12
%77 = load double, double* %17
%78 = load double, double* %14
%79 = load double, double* %21
%80 = load double, double* %22
%81 = call double @rq_pricing_blackscholes_gen(i16 signext %74, double %75, double %76, double %77, double %78, double %79, double %80)
store double %81, double* %23
br label %82
82: ; preds = %73, %70
br label %83
83: ; preds = %82, %42
%84 = load double, double* %23
ret double %84
}

LLVM IR (-O2):
define double @rq_pricing_average_rate_geometric(i16 signext %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, double %8) {
%10 = fsub double %7, %8
%11 = fsub double %4, %5
%12 = fmul double %6, %6
%13 = fdiv double %12, 6.000000e+00
%14 = fsub double %11, %13
%15 = fmul double %14, 5.000000e-01
%16 = tail call double @sqrt(i32 3)
%17 = fdiv double %6, %16
%18 = fcmp ogt double %10, 0.000000e+00
br i1 %18, label %19, label %29
19: ; preds = %9
%20 = fadd double %10, %8
%21 = fdiv double %20, %8
%22 = fneg double %10
%23 = fdiv double %22, %8
%24 = fmul double %23, %2
%25 = tail call double @llvm.fmuladd.f64(double %21, double %3, double %24)
%26 = tail call double @rq_pricing_blackscholes_gen(i16 signext %0, double %1, double %25, double %8, double %4, double %15, double %17)
%27 = fmul double %26, %8
%28 = fdiv double %27, %20
br label %33
29: ; preds = %9
%30 = fcmp oeq double %10, 0.000000e+00
br i1 %30, label %31, label %33
31: ; preds = %29
%32 = tail call double @rq_pricing_blackscholes_gen(i16 signext %0, double %1, double %2, double %7, double %4, double %15, double %17)
br label %33
33: ; preds = %29, %31, %19
%34 = phi double [ %28, %19 ], [ %32, %31 ], [ 0.000000e+00, %29 ]
ret double %34
}