#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_digital(short cash, short call, double S, double X,
                          double r_dom, double r_for, double sigma,
                          double tau_e, double tau_d) {
  double m = (call ? 1.0 : -1.0);
  double f = S * exp(r_dom * tau_d) / exp(r_for * tau_d);
  double sigma_tau_sqrt = sigma * sqrt(tau_e);
  double d1 = (log(f / X) + (0.5 * sigma * sigma * tau_e)) / sigma_tau_sqrt;
  double d2 = (d1 - sigma_tau_sqrt) * m;
  d1 *= m;
  if (!cash)
    return S * exp(-r_for * tau_d) * rq_pricing_cumul_norm_dist(d1);
  else
    return X * exp(-r_dom * tau_d) * rq_pricing_cumul_norm_dist(d2);
}


x86 assembly (clang, -O0):
<rq_pricing_digital>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %si,%ax
mov    %di,%cx
mov    %cx,-0xa(%rbp)
mov    %ax,-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)
movswl -0xc(%rbp),%eax
movsd  0xe80(%rip),%xmm0
movsd  0xe80(%rip),%xmm1
movsd  %xmm1,-0x80(%rbp)
cmp    $0x0,%eax
movsd  %xmm0,-0x78(%rbp)
jne    11ad <rq_pricing_digital+0x6d>
movsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x28(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
call   1040 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x98(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x30(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
call   1040 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x90(%rbp),%xmm0
ff
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x40(%rbp),%xmm0
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x88(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x58(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
call   1050 <log@plt>
movaps %xmm0,%xmm1
movsd  0xdae(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
subsd  -0x60(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x50(%rbp),%xmm0
mulsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
cmpw   $0x0,-0xa(%rbp)
jne    130e <rq_pricing_digital+0x1ce>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0x30(%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  -0xa8(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x68(%rbp),%xmm0
call   1030 <rq_pricing_cumul_norm_dist@plt>
movaps %xmm0,%xmm1
movsd  -0xa0(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1376 <rq_pricing_digital+0x236>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0xb8(%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  -0xb8(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0x70(%rbp),%xmm0
call   1030 <rq_pricing_cumul_norm_dist@plt>
movaps %xmm0,%xmm1
movsd  -0xb0(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rq_pricing_digital>:
push   %rbp
push   %rbx
sub    $0x68,%rsp
movsd  %xmm6,0x38(%rsp)
movsd  %xmm5,0x30(%rsp)
movsd  %xmm4,0x28(%rsp)
movapd %xmm3,0x50(%rsp)
movsd  %xmm1,0x20(%rsp)
movsd  %xmm0,0x8(%rsp)
mov    %esi,%ebx
mov    %edi,%ebp
movsd  %xmm2,0x40(%rsp)
movapd %xmm2,%xmm0
mulsd  %xmm6,%xmm0
call   1040 <exp@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movapd 0x50(%rsp),%xmm0
mulsd  0x38(%rsp),%xmm0
call   1040 <exp@plt>
movsd  0x30(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
divsd  %xmm0,%xmm2
movsd  %xmm2,0x10(%rsp)
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jb     11c7 <rq_pricing_digital+0x87>
xorps  %xmm0,%xmm0
sqrtsd %xmm1,%xmm0
jmp    11d0 <rq_pricing_digital+0x90>
movapd %xmm1,%xmm0
call   1060 <sqrt@plt>
mulsd  0x28(%rsp),%xmm0
movsd  %xmm0,0x48(%rsp)
movsd  0x10(%rsp),%xmm0
divsd  0x20(%rsp),%xmm0
call   1050 <log@plt>
movsd  0x48(%rsp),%xmm4
test   %bp,%bp
movapd 0x50(%rsp),%xmm1
xorpd  %xmm3,%xmm3
je     1218 <rq_pricing_digital+0xd8>
movapd %xmm4,%xmm3
movsd  0x40(%rsp),%xmm1
movsd  0x20(%rsp),%xmm2
movsd  %xmm2,0x8(%rsp)
movsd  0xde0(%rip),%xmm5
movsd  0x28(%rsp),%xmm2
mulsd  %xmm2,%xmm5
mulsd  %xmm2,%xmm5
mulsd  0x30(%rsp),%xmm5
addsd  %xmm0,%xmm5
divsd  %xmm4,%xmm5
subsd  %xmm3,%xmm5
movapd 0xdc8(%rip),%xmm0
test   %bx,%bx
jne    1251 <rq_pricing_digital+0x111>
xorpd  %xmm0,%xmm5
movapd %xmm5,0x10(%rsp)
xorpd  %xmm0,%xmm1
mulsd  0x38(%rsp),%xmm1
movapd %xmm1,%xmm0
call   1040 <exp@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movapd 0x10(%rsp),%xmm0
call   1030 <rq_pricing_cumul_norm_dist@plt>
mulsd  0x8(%rsp),%xmm0
add    $0x68,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define double @rq_pricing_digital(i16 signext %0, i16 signext %1, double %2, double %3, double %4, double %5, double %6, double %7, double %8) {
%10 = icmp eq i16 %1, 0
%11 = fmul double %4, %8
%12 = tail call double @exp(double %11)
%13 = fmul double %12, %2
%14 = fmul double %5, %8
%15 = tail call double @exp(double %14)
%16 = fdiv double %13, %15
%17 = tail call double @sqrt(double %7)
%18 = fmul double %17, %6
%19 = fdiv double %16, %3
%20 = tail call double @log(double %19)
%21 = fmul double %6, 5.000000e-01
%22 = fmul double %21, %6
%23 = tail call double @llvm.fmuladd.f64(double %22, double %7, double %20)
%24 = fdiv double %23, %18
%25 = icmp eq i16 %0, 0
%26 = select i1 %25, double 0.000000e+00, double %18
%27 = fsub double %24, %26
%28 = select i1 %25, double %5, double %4
%29 = select i1 %25, double %2, double %3
%30 = fneg double %27
%31 = select i1 %10, double %30, double %27
%32 = fneg double %28
%33 = fmul double %32, %8
%34 = tail call double @exp(double %33)
%35 = fmul double %34, %29
%36 = tail call double @rq_pricing_cumul_norm_dist(double %31)
%37 = fmul double %35, %36
ret double %37
}