#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 rq_pricing_fx_ccir(double S, double K, double r_dom, double r_for,
                          double tau_d) {
  if (tau_d > 0) {
    double df_dom = exp(-r_dom * tau_d);
    double df_for = exp(-r_for * tau_d);
    double c = K * df_dom / df_for;
    return c - S;
  } else if (tau_d == 0)
    return K - S;
  else
    return 0.0;
}


x86 assembly (clang, -O0):
<rq_pricing_fx_ccir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  %xmm4,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11c1 <rq_pricing_fx_ccir+0xb1>
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x30(%rbp),%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x30(%rbp),%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11f5 <rq_pricing_fx_ccir+0xe5>
movsd  -0x30(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11ed <rq_pricing_fx_ccir+0xdd>
jp     11ed <rq_pricing_fx_ccir+0xdd>
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11f5 <rq_pricing_fx_ccir+0xe5>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rq_pricing_fx_ccir>:
xorpd  %xmm5,%xmm5
ucomisd %xmm5,%xmm4
jbe    1186 <rq_pricing_fx_ccir+0x76>
sub    $0x38,%rsp
xorpd  0xeda(%rip),%xmm2
mulsd  %xmm4,%xmm2
movsd  %xmm0,0x18(%rsp)
movapd %xmm2,%xmm0
movsd  %xmm1,0x10(%rsp)
movaps %xmm3,0x20(%rsp)
movsd  %xmm4,(%rsp)
call   1030 <exp@plt>
movsd  %xmm0,0x8(%rsp)
movapd 0x20(%rsp),%xmm0
xorpd  0xea3(%rip),%xmm0
mulsd  (%rsp),%xmm0
call   1030 <exp@plt>
movsd  0x8(%rsp),%xmm5
mulsd  0x10(%rsp),%xmm5
divsd  %xmm0,%xmm5
subsd  0x18(%rsp),%xmm5
add    $0x38,%rsp
movapd %xmm5,%xmm0
ret
jne    1192 <rq_pricing_fx_ccir+0x82>
jp     1192 <rq_pricing_fx_ccir+0x82>
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm5
movapd %xmm5,%xmm0
ret

LLVM IR (-O0):
define double @rq_pricing_fx_ccir(double %0, double %1, double %2, double %3, double %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
store double %0, double* %7
store double %1, double* %8
store double %2, double* %9
store double %3, double* %10
store double %4, double* %11
%15 = load double, double* %11
%16 = fcmp ogt double %15, 0.000000e+00
br i1 %16, label %17, label %36
17: ; preds = %5
%18 = load double, double* %9
%19 = fneg double %18
%20 = load double, double* %11
%21 = fmul double %19, %20
%22 = call double @exp(double %21)
store double %22, double* %12
%23 = load double, double* %10
%24 = fneg double %23
%25 = load double, double* %11
%26 = fmul double %24, %25
%27 = call double @exp(double %26)
store double %27, double* %13
%28 = load double, double* %8
%29 = load double, double* %12
%30 = fmul double %28, %29
%31 = load double, double* %13
%32 = fdiv double %30, %31
store double %32, double* %14
%33 = load double, double* %14
%34 = load double, double* %7
%35 = fsub double %33, %34
store double %35, double* %6
br label %44
36: ; preds = %5
%37 = load double, double* %11
%38 = fcmp oeq double %37, 0.000000e+00
br i1 %38, label %39, label %43
39: ; preds = %36
%40 = load double, double* %8
%41 = load double, double* %7
%42 = fsub double %40, %41
store double %42, double* %6
br label %44
43: ; preds = %36
store double 0.000000e+00, double* %6
br label %44
44: ; preds = %43, %39, %17
%45 = load double, double* %6
ret double %45
}

LLVM IR (-O2):
define double @rq_pricing_fx_ccir(double %0, double %1, double %2, double %3, double %4) {
%6 = fcmp ogt double %4, 0.000000e+00
br i1 %6, label %7, label %17
7: ; preds = %5
%8 = fneg double %2
%9 = fmul double %8, %4
%10 = tail call double @exp(double %9)
%11 = fneg double %3
%12 = fmul double %11, %4
%13 = tail call double @exp(double %12)
%14 = fmul double %10, %1
%15 = fdiv double %14, %13
%16 = fsub double %15, %0
br label %21
17: ; preds = %5
%18 = fcmp oeq double %4, 0.000000e+00
br i1 %18, label %19, label %21
19: ; preds = %17
%20 = fsub double %1, %0
br label %21
21: ; preds = %17, %19, %7
%22 = phi double [ %16, %7 ], [ %20, %19 ], [ 0.000000e+00, %17 ]
ret double %22
}