#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_blackscholes_rho(int call, double S, double X, double r,
                                   double b, double v, double tv, double td) {
  double m = (call ? 1.0 : -1.0);
  if (tv <= 0.0 || td <= 0.0)
    return 0.0;
  return m * X * td * exp(-r * td) *
         rq_pricing_cumul_norm_dist(
             m * ((log(S / X) + (b * td) - (((v * v) / 2.0) * tv)) /
                  (v * sqrt(tv))));
}


x86 assembly (clang, -O0):
<rq_pricing_blackscholes_rho>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %edi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  %xmm2,-0x28(%rbp)
movsd  %xmm3,-0x30(%rbp)
movsd  %xmm4,-0x38(%rbp)
movsd  %xmm5,-0x40(%rbp)
movsd  %xmm6,-0x48(%rbp)
mov    -0xc(%rbp),%eax
movsd  0xe84(%rip),%xmm0
movsd  0xe84(%rip),%xmm1
movsd  %xmm1,-0x60(%rbp)
cmp    $0x0,%eax
movsd  %xmm0,-0x58(%rbp)
jne    11a1 <rq_pricing_blackscholes_rho+0x61>
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x40(%rbp),%xmm0
jae    11c7 <rq_pricing_blackscholes_rho+0x87>
xorps  %xmm0,%xmm0
ucomisd -0x48(%rbp),%xmm0
jb     11d4 <rq_pricing_blackscholes_rho+0x94>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12d7 <rq_pricing_blackscholes_rho+0x197>
movsd  -0x50(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x48(%rbp),%xmm0
call   1040 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x88(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x18(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
call   1050 <log@plt>
movsd  -0x30(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  0xdae(%rip),%xmm2
divsd  %xmm2,%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,-0x78(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1060 <sqrt@plt>
movsd  -0x80(%rbp),%xmm2
movsd  -0x78(%rbp),%xmm1
movaps %xmm0,%xmm3
movsd  -0x70(%rbp),%xmm0
mulsd  %xmm3,%xmm2
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
call   1030 <rq_pricing_cumul_norm_dist@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rq_pricing_blackscholes_rho>:
movapd %xmm0,%xmm8
xor    %eax,%eax
test   %edi,%edi
sete   %cl
xorpd  %xmm0,%xmm0
ucomisd %xmm5,%xmm0
jae    1274 <rq_pricing_blackscholes_rho+0x134>
xorpd  %xmm7,%xmm7
ucomisd %xmm6,%xmm7
jae    1274 <rq_pricing_blackscholes_rho+0x134>
sub    $0x48,%rsp
mov    %cl,%al
lea    0xe8b(%rip),%rcx
movsd  (%rcx,%rax,8),%xmm0
movsd  %xmm0,0x40(%rsp)
mulsd  %xmm1,%xmm0
mulsd  %xmm6,%xmm0
movsd  %xmm0,0x10(%rsp)
xorpd  0xe7a(%rip),%xmm2
mulsd  %xmm6,%xmm2
movapd %xmm2,%xmm0
movsd  %xmm4,0x18(%rsp)
movsd  %xmm5,0x8(%rsp)
movsd  %xmm3,0x30(%rsp)
movsd  %xmm6,0x38(%rsp)
movsd  %xmm8,0x20(%rsp)
movsd  %xmm1,0x28(%rsp)
call   1040 <exp@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x20(%rsp),%xmm0
divsd  0x28(%rsp),%xmm0
call   1050 <log@plt>
movsd  0x8(%rsp),%xmm2
movsd  0x18(%rsp),%xmm1
movsd  0x30(%rsp),%xmm3
mulsd  0x38(%rsp),%xmm3
addsd  %xmm0,%xmm3
movapd %xmm3,%xmm0
movapd %xmm1,%xmm3
mulsd  %xmm1,%xmm3
mulsd  0xe0b(%rip),%xmm3
mulsd  %xmm2,%xmm3
addsd  %xmm0,%xmm3
ucomisd 0xe03(%rip),%xmm2
jb     1230 <rq_pricing_blackscholes_rho+0xf0>
xorps  %xmm0,%xmm0
sqrtsd %xmm2,%xmm0
jmp    124b <rq_pricing_blackscholes_rho+0x10b>
movapd %xmm2,%xmm0
movsd  %xmm3,0x8(%rsp)
call   1060 <sqrt@plt>
movsd  0x8(%rsp),%xmm3
movsd  0x18(%rsp),%xmm1
mulsd  %xmm1,%xmm0
divsd  %xmm0,%xmm3
movsd  0x40(%rsp),%xmm0
mulsd  %xmm3,%xmm0
call   1030 <rq_pricing_cumul_norm_dist@plt>
movsd  0x10(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x48,%rsp
ret

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

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