#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 fact(int);
double pow(double, int);
double rq_pricing_blackscholes_gen(short, double, double, double, double,
                                   double, double);
double sqrt(double);
double rq_pricing_jump_diffusion(short call, double S, double X, double T,
                                 double r, double v, double lambda,
                                 double gamma) {
  double v_sqr = v * v;
  double delta = sqrt(gamma * v_sqr / lambda);
  double delta_sqr = delta * delta;
  double sum = 0.0;
  double z = sqrt(v_sqr - lambda * delta_sqr);
  double z_sqr = z * z;
  int i;
  for (i = 0; i <= 10; i++) {
    double vi = sqrt(z_sqr + delta_sqr * (i / T));
    sum = sum + exp(-lambda * T) * pow((lambda * T), i) / fact(i) *
                    rq_pricing_blackscholes_gen(call, S, X, T, r, r, vi);
  }
  return sum;
}


x86 assembly (clang, -O0):
<rq_pricing_jump_diffusion>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%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)
movsd  -0x30(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
divsd  -0x38(%rbp),%xmm0
call   1070 <sqrt@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x48(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1070 <sqrt@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
mulsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movl   $0x0,-0x74(%rbp)
cmpl   $0xa,-0x74(%rbp)
jg     131d <rq_pricing_jump_diffusion+0x1cd>
movsd  -0x70(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm0
cvtsi2sdl -0x74(%rbp),%xmm2
divsd  -0x20(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1070 <sqrt@plt>
movsd  %xmm0,-0x80(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x38(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x38(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
mov    -0x74(%rbp),%edi
call   1060 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0xa0(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
mov    -0x74(%rbp),%edi
call   1040 <fact@plt>
movaps %xmm0,%xmm1
movsd  -0x98(%rbp),%xmm0
ff
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
mov    -0x2(%rbp),%ax
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm3
movsd  -0x28(%rbp),%xmm4
movsd  -0x80(%rbp),%xmm5
movswl %ax,%edi
call   1050 <rq_pricing_blackscholes_gen@plt>
movsd  -0x90(%rbp),%xmm1
ff
movaps %xmm0,%xmm2
movsd  -0x88(%rbp),%xmm0
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    1212 <rq_pricing_jump_diffusion+0xc2>
movsd  -0x60(%rbp),%xmm0
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rq_pricing_jump_diffusion>:
push   %rbp
push   %rbx
sub    $0x78,%rsp
movsd  %xmm3,0x60(%rsp)
movsd  %xmm2,0x10(%rsp)
movsd  %xmm1,0x58(%rsp)
movsd  %xmm0,0x50(%rsp)
mov    %edi,%ebp
mulsd  %xmm4,%xmm4
mulsd  %xmm4,%xmm6
movapd %xmm5,0x20(%rsp)
divsd  %xmm5,%xmm6
xorpd  %xmm3,%xmm3
ucomisd %xmm3,%xmm6
jb     1195 <rq_pricing_jump_diffusion+0x45>
xorps  %xmm1,%xmm1
sqrtsd %xmm6,%xmm1
jmp    11b2 <rq_pricing_jump_diffusion+0x62>
movapd %xmm6,%xmm0
movsd  %xmm4,0x8(%rsp)
call   1070 <sqrt@plt>
xorpd  %xmm3,%xmm3
movsd  0x8(%rsp),%xmm4
movapd %xmm0,%xmm1
mulsd  %xmm1,%xmm1
movapd 0xe42(%rip),%xmm2
movapd 0x20(%rsp),%xmm0
xorpd  %xmm0,%xmm2
movapd %xmm2,0x30(%rsp)
movsd  %xmm1,0x48(%rsp)
mulsd  %xmm1,%xmm0
subsd  %xmm0,%xmm4
ucomisd %xmm3,%xmm4
jb     11eb <rq_pricing_jump_diffusion+0x9b>
xorps  %xmm2,%xmm2
sqrtsd %xmm4,%xmm2
jmp    11f8 <rq_pricing_jump_diffusion+0xa8>
movapd %xmm4,%xmm0
call   1070 <sqrt@plt>
movapd %xmm0,%xmm2
movsd  0x10(%rsp),%xmm1
mulsd  %xmm2,%xmm2
movapd 0x30(%rsp),%xmm0
mulsd  %xmm1,%xmm0
movapd %xmm0,0x30(%rsp)
movapd 0x20(%rsp),%xmm0
mulsd  %xmm1,%xmm0
movapd %xmm0,0x20(%rsp)
xor    %ebx,%ebx
movswl %bp,%ebp
xorpd  %xmm3,%xmm3
xorpd  %xmm4,%xmm4
movsd  %xmm2,0x40(%rsp)
jmp    12e5 <rq_pricing_jump_diffusion+0x195>
nopw   0x0(%rax,%rax,1)
call   1070 <sqrt@plt>
movsd  %xmm0,0x18(%rsp)
movaps 0x30(%rsp),%xmm0
call   1030 <exp@plt>
movsd  %xmm0,0x8(%rsp)
movapd 0x20(%rsp),%xmm0
mov    %ebx,%edi
call   1060 <pow@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %ebx,%edi
call   1040 <fact@plt>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
mov    %ebp,%edi
movsd  0x50(%rsp),%xmm0
movsd  0x58(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
movsd  0x60(%rsp),%xmm3
movaps %xmm3,%xmm4
movsd  0x18(%rsp),%xmm5
call   1050 <rq_pricing_blackscholes_gen@plt>
movsd  0x10(%rsp),%xmm1
mulsd  0x8(%rsp),%xmm0
movsd  0x70(%rsp),%xmm3
addsd  %xmm0,%xmm3
movsd  0x68(%rsp),%xmm4
addsd  0xd39(%rip),%xmm4
add    $0x1,%ebx
cmp    $0xb,%ebx
movsd  0x40(%rsp),%xmm2
je     131a <rq_pricing_jump_diffusion+0x1ca>
movapd %xmm4,%xmm0
divsd  %xmm1,%xmm0
mulsd  0x48(%rsp),%xmm0
addsd  %xmm2,%xmm0
ucomisd 0xd19(%rip),%xmm0
movsd  %xmm3,0x70(%rsp)
movsd  %xmm4,0x68(%rsp)
jb     1240 <rq_pricing_jump_diffusion+0xf0>
sqrtsd %xmm0,%xmm0
jmp    1245 <rq_pricing_jump_diffusion+0xf5>
movapd %xmm3,%xmm0
add    $0x78,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define double @rq_pricing_jump_diffusion(i16 signext %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7) {
%9 = fmul double %5, %5
%10 = fmul double %9, %7
%11 = fdiv double %10, %6
%12 = tail call double @sqrt(double %11)
%13 = fmul double %12, %12
%14 = fneg double %6
%15 = tail call double @llvm.fmuladd.f64(double %14, double %13, double %9)
%16 = tail call double @sqrt(double %15)
%17 = fmul double %16, %16
%18 = fmul double %14, %3
%19 = fmul double %3, %6
br label %20
20: ; preds = %8, %20
%21 = phi double [ 0.000000e+00, %8 ], [ %33, %20 ]
%22 = phi i32 [ 0, %8 ], [ %34, %20 ]
%23 = sitofp i32 %22 to double
%24 = fdiv double %23, %3
%25 = tail call double @llvm.fmuladd.f64(double %13, double %24, double %17)
%26 = tail call double @sqrt(double %25)
%27 = tail call double @exp(double %18)
%28 = tail call double @pow(double %19, i32 %22)
%29 = fmul double %27, %28
%30 = tail call double @fact(i32 %22)
%31 = fdiv double %29, %30
%32 = tail call double @rq_pricing_blackscholes_gen(i16 signext %0, double %1, double %2, double %3, double %4, double %4, double %26)
%33 = tail call double @llvm.fmuladd.f64(double %31, double %32, double %21)
%34 = add nuw nsw i32 %22, 1
%35 = icmp eq i32 %34, 11
br i1 %35, label %36, label %20
36: ; preds = %20
ret double %33
}