#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 */
int exp(double);
double log(double);
int pow(int, double);
double rq_pricing_cumul_norm_dist(double);
double sqrt(double);
double rq_pricing_swaption(short call, double t1, double m, double F, double X,
                           double T, double r, double v) {
  double d1;
  double d2;
  double ret = 0.0;
  d1 = (log(F / X) + (v * v) / 2 * T) / (v * sqrt(T));
  d2 = d1 - v * sqrt(T);
  if (call)
    ret = ((1 - 1 / pow((1 + F / m), (t1 * m))) / F) * exp(-r * T) *
          (F * rq_pricing_cumul_norm_dist(d1) -
           X * rq_pricing_cumul_norm_dist(d2));
  else
    ret = ((1 - 1 / pow((1 + F / m), (t1 * m))) / F) * exp(-r * T) *
          (X * rq_pricing_cumul_norm_dist(-d2) -
           F * rq_pricing_cumul_norm_dist(-d1));
  return ret;
}


x86 assembly (clang, -O0):
<rq_pricing_swaption>:
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)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x20(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
call   1050 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  0xe4f(%rip),%xmm2
divsd  %xmm2,%xmm0
movsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1070 <sqrt@plt>
movsd  -0x78(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x70(%rbp),%xmm0
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1070 <sqrt@plt>
movsd  -0x68(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x60(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
cmpw   $0x0,-0x2(%rbp)
je     135e <rq_pricing_swaption+0x20e>
movsd  -0x20(%rbp),%xmm1
divsd  -0x18(%rbp),%xmm1
movsd  0xda7(%rip),%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
movsd  -0x10(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
call   1060 <pow@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cltd
idiv   %ecx
mov    %eax,%ecx
mov    $0x1,%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x38(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x30(%rbp),%xmm0
call   1040 <exp@plt>
movsd  -0xa0(%rbp),%xmm0
ff
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x48(%rbp),%xmm0
call   1030 <rq_pricing_cumul_norm_dist@plt>
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x50(%rbp),%xmm0
call   1030 <rq_pricing_cumul_norm_dist@plt>
movsd  -0x98(%rbp),%xmm2
ff
movsd  -0x90(%rbp),%xmm1
ff
movsd  -0x88(%rbp),%xmm3
ff
movaps %xmm0,%xmm4
movsd  -0x80(%rbp),%xmm0
mulsd  %xmm4,%xmm2
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    149c <rq_pricing_swaption+0x34c>
movsd  -0x20(%rbp),%xmm1
divsd  -0x18(%rbp),%xmm1
movsd  0xc98(%rip),%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
movsd  -0x10(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
call   1060 <pow@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cltd
idiv   %ecx
mov    %eax,%ecx
mov    $0x1,%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
movsd  -0x38(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x30(%rbp),%xmm0
call   1040 <exp@plt>
movsd  -0xc8(%rbp),%xmm0
ff
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
movsd  -0x50(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1030 <rq_pricing_cumul_norm_dist@plt>
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  -0x48(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1030 <rq_pricing_cumul_norm_dist@plt>
movsd  -0xc0(%rbp),%xmm2
ff
movsd  -0xb8(%rbp),%xmm1
ff
movsd  -0xb0(%rbp),%xmm3
ff
movaps %xmm0,%xmm4
movsd  -0xa8(%rbp),%xmm0
ff
mulsd  %xmm4,%xmm2
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rq_pricing_swaption>:
push   %rbp
push   %r14
push   %rbx
sub    $0x60,%rsp
movsd  %xmm6,0x10(%rsp)
movapd %xmm5,0x50(%rsp)
movsd  %xmm4,(%rsp)
movsd  %xmm1,0x40(%rsp)
movsd  %xmm0,0x48(%rsp)
mov    %edi,%r14d
movsd  %xmm2,0x8(%rsp)
movapd %xmm2,%xmm0
movsd  %xmm3,0x30(%rsp)
divsd  %xmm3,%xmm0
call   1050 <log@plt>
movsd  0x10(%rsp),%xmm2
movapd %xmm2,%xmm1
mulsd  %xmm2,%xmm1
mulsd  0xe59(%rip),%xmm1
movsd  (%rsp),%xmm4
mulsd  %xmm4,%xmm1
addsd  %xmm0,%xmm1
xorps  %xmm3,%xmm3
sqrtsd %xmm4,%xmm3
xorpd  %xmm5,%xmm5
ucomisd %xmm5,%xmm4
movapd %xmm3,%xmm0
jae    11f5 <rq_pricing_swaption+0xa5>
movsd  (%rsp),%xmm0
movapd %xmm1,0x20(%rsp)
movsd  %xmm3,0x38(%rsp)
call   1070 <sqrt@plt>
xorpd  %xmm5,%xmm5
movsd  0x38(%rsp),%xmm3
movsd  0x10(%rsp),%xmm2
movapd 0x20(%rsp),%xmm1
mulsd  %xmm2,%xmm0
divsd  %xmm0,%xmm1
movsd  (%rsp),%xmm0
ucomisd %xmm5,%xmm0
movapd %xmm1,0x20(%rsp)
jae    1228 <rq_pricing_swaption+0xd8>
movsd  (%rsp),%xmm0
call   1070 <sqrt@plt>
movsd  0x10(%rsp),%xmm2
movapd 0x20(%rsp),%xmm1
movapd %xmm0,%xmm3
mulsd  %xmm3,%xmm2
movapd %xmm1,%xmm4
movsd  0x8(%rsp),%xmm0
movsd  0x40(%rsp),%xmm3
divsd  %xmm3,%xmm0
addsd  0xdc0(%rip),%xmm0
subsd  %xmm2,%xmm4
movapd %xmm4,0x10(%rsp)
cvttsd2si %xmm0,%edi
movsd  0x48(%rsp),%xmm0
mulsd  %xmm3,%xmm0
call   1060 <pow@plt>
mov    %eax,%ebp
movapd 0x50(%rsp),%xmm0
xorpd  0xd9b(%rip),%xmm0
mulsd  (%rsp),%xmm0
call   1040 <exp@plt>
mov    %eax,%ebx
test   %r14w,%r14w
je     12c0 <rq_pricing_swaption+0x170>
movaps 0x20(%rsp),%xmm0
call   1030 <rq_pricing_cumul_norm_dist@plt>
movsd  %xmm0,(%rsp)
movapd 0x10(%rsp),%xmm0
call   1030 <rq_pricing_cumul_norm_dist@plt>
movsd  (%rsp),%xmm3
mulsd  0x30(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  %xmm1,%xmm3
subsd  %xmm0,%xmm3
movapd %xmm1,%xmm0
jmp    130a <rq_pricing_swaption+0x1ba>
movaps 0x10(%rsp),%xmm0
xorps  0xd44(%rip),%xmm0
call   1030 <rq_pricing_cumul_norm_dist@plt>
movsd  %xmm0,(%rsp)
movapd 0x20(%rsp),%xmm0
xorpd  0xd2c(%rip),%xmm0
call   1030 <rq_pricing_cumul_norm_dist@plt>
movsd  0x8(%rsp),%xmm2
mulsd  %xmm2,%xmm0
movsd  0x30(%rsp),%xmm1
mulsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm3
movapd %xmm2,%xmm0
mov    $0x1,%eax
mov    $0x1,%ecx
sub    %ebp,%ecx
add    $0x1,%ebp
cmp    $0x3,%ebp
cmovae %eax,%ecx
xorps  %xmm1,%xmm1
cvtsi2sd %ecx,%xmm1
divsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm3,%xmm0
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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