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


x86 assembly (clang, -O0):
<rq_pricing_blackscholes_delta>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%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)
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  0xe5f(%rip),%xmm2
divsd  %xmm2,%xmm0
movsd  -0x40(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1060 <sqrt@plt>
movsd  -0x60(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x40(%rbp),%xmm0
jae    1201 <rq_pricing_blackscholes_delta+0xc1>
xorps  %xmm0,%xmm0
ucomisd -0x48(%rbp),%xmm0
jb     120e <rq_pricing_blackscholes_delta+0xce>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1291 <rq_pricing_blackscholes_delta+0x151>
cmpl   $0x0,-0xc(%rbp)
je     1251 <rq_pricing_blackscholes_delta+0x111>
movsd  -0x30(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
call   1040 <exp@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  -0x50(%rbp),%xmm0
call   1030 <rq_pricing_cumul_norm_dist@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1291 <rq_pricing_blackscholes_delta+0x151>
movsd  -0x30(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
call   1040 <exp@plt>
movsd  %xmm0,-0x70(%rbp)
movsd  -0x50(%rbp),%xmm0
call   1030 <rq_pricing_cumul_norm_dist@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
movsd  0xd84(%rip),%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rq_pricing_blackscholes_delta>:
push   %rbx
sub    $0x30,%rsp
movsd  %xmm6,0x28(%rsp)
movsd  %xmm5,(%rsp)
movsd  %xmm4,0x8(%rsp)
movsd  %xmm3,0x20(%rsp)
movsd  %xmm2,0x18(%rsp)
mov    %edi,%ebx
divsd  %xmm1,%xmm0
call   1050 <log@plt>
movsd  (%rsp),%xmm4
movapd %xmm0,%xmm5
xorpd  %xmm3,%xmm3
ucomisd %xmm3,%xmm4
jb     1189 <rq_pricing_blackscholes_delta+0x49>
xorps  %xmm0,%xmm0
sqrtsd %xmm4,%xmm0
jmp    11a7 <rq_pricing_blackscholes_delta+0x67>
movapd %xmm4,%xmm0
movsd  %xmm5,0x10(%rsp)
call   1060 <sqrt@plt>
movsd  0x10(%rsp),%xmm5
xorpd  %xmm3,%xmm3
movsd  (%rsp),%xmm4
ucomisd %xmm4,%xmm3
movsd  0x28(%rsp),%xmm2
jae    122f <rq_pricing_blackscholes_delta+0xef>
xorpd  %xmm1,%xmm1
ucomisd %xmm2,%xmm1
jae    122f <rq_pricing_blackscholes_delta+0xef>
movsd  0x8(%rsp),%xmm6
mulsd  %xmm6,%xmm0
mulsd  %xmm6,%xmm6
mulsd  0xe2d(%rip),%xmm6
movsd  0x20(%rsp),%xmm3
movapd %xmm3,%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm5,%xmm1
mulsd  %xmm4,%xmm6
addsd  %xmm1,%xmm6
divsd  %xmm0,%xmm6
movsd  %xmm6,0x8(%rsp)
subsd  0x18(%rsp),%xmm3
mulsd  %xmm2,%xmm3
movapd %xmm3,%xmm0
call   1040 <exp@plt>
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <rq_pricing_cumul_norm_dist@plt>
test   %ebx,%ebx
jne    1226 <rq_pricing_blackscholes_delta+0xe6>
addsd  0xde2(%rip),%xmm0
movsd  (%rsp),%xmm3
mulsd  %xmm0,%xmm3
movapd %xmm3,%xmm0
add    $0x30,%rsp
pop    %rbx
ret

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

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