// File: /workspace/github_cpp_makefile_star2_O1/jc-kim[P]swaptions/HJM_Securities.cpp
// Function: initSwaption(double*)
void initSwaption(FTYPE* factors) {
  // setting up multiple swaptions
  int i, j, k;
  swaptions = (parm*)malloc(sizeof(parm) * nSwaptions);

  for (i = 0; i < nSwaptions; i++) {
    swaptions[i].Id = i;
    swaptions[i].iN = iN;
    swaptions[i].iFactors = iFactors;
    swaptions[i].dYears = dYears;

    swaptions[i].dStrike = (double)i / (double)nSwaptions;
    swaptions[i].dCompounding = 0;
    swaptions[i].dMaturity = 1;
    swaptions[i].dTenor = 2.0;
    swaptions[i].dPaymentInterval = 1.0;

    swaptions[i].pdYield = dvector(iN);
    swaptions[i].ppdFactors = dmatrix(swaptions[i].iFactors, swaptions[i].iN - 1);

    swaptions[i].pdYield[0] = 0.1;
    for(j = 1; j < swaptions[i].iN; j++) swaptions[i].pdYield[j] = swaptions[i].pdYield[j - 1] + 0.005;

    for(k = 0; k < swaptions[i].iFactors; k++)
      for(j = 0; j < swaptions[i].iN - 1; j++)
        swaptions[i].ppdFactors[k * (iN - 1) + j] = factors[k * (iN - 1) + j];
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movslq 0x27ca(%rip), %r14      # 0x50d8
imulq $0x68, %r14, %rdi
callq 0x10f0
movq %rax, 0x27e2(%rip)      # 0x5100
testq %r14, %r14
jle 0x2a97
xorl %r14d, %r14d
movabsq $0x3ff0000000000000, %r15 # imm = 0x3FF0000000000000
movabsq $0x4000000000000000, %r12 # imm = 0x4000000000000000
movabsq $0x3fb999999999999a, %r13 # imm = 0x3FB999999999999A
movq 0x27b1(%rip), %rax      # 0x5100
imulq $0x68, %r14, %rbp
movl %r14d, (%rax,%rbp)
movl 0x277f(%rip), %ecx      # 0x50dc
movl %ecx, 0x40(%rax,%rbp)
movl 0x2781(%rip), %ecx      # 0x50e8
movl %ecx, 0x50(%rax,%rbp)
movsd 0x276d(%rip), %xmm0     # 0x50e0
movsd %xmm0, 0x48(%rax,%rbp)
xorps %xmm0, %xmm0
cvtsi2sd %r14d, %xmm0
xorps %xmm1, %xmm1
cvtsi2sdl 0x274c(%rip), %xmm1 # 0x50d8
divsd %xmm1, %xmm0
movsd %xmm0, 0x18(%rax,%rbp)
movq $0x0, 0x20(%rax,%rbp)
movq %r15, 0x28(%rax,%rbp)
movq %r12, 0x30(%rax,%rbp)
movq %r15, 0x38(%rax,%rbp)
movslq 0x2727(%rip), %rdi      # 0x50dc
callq 0x15e2
movq 0x273f(%rip), %rcx      # 0x5100
movq %rax, 0x58(%rcx,%rbp)
movq 0x2733(%rip), %rax      # 0x5100
movslq 0x50(%rax,%rbp), %rdi
movslq 0x40(%rax,%rbp), %rsi
decq %rsi
callq 0x1633
movsd 0x7b1(%rip), %xmm1      # 0x3198
movq 0x2712(%rip), %rcx      # 0x5100
movq %rax, 0x60(%rcx,%rbp)
movq 0x2706(%rip), %rdx      # 0x5100
leaq (%rdx,%rbp), %rax
movq 0x58(%rdx,%rbp), %rcx
movq %r13, (%rcx)
movslq 0x40(%rdx,%rbp), %rcx
cmpq $0x2, %rcx
jl 0x2a2f
movq 0x58(%rax), %rsi
movsd (%rsi), %xmm0
movl $0x1, %edi
addsd %xmm1, %xmm0
movsd %xmm0, (%rsi,%rdi,8)
incq %rdi
cmpq %rdi, %rcx
jne 0x2a1e
movslq 0x50(%rdx,%rbp), %rdx
testq %rdx, %rdx
jle 0x2a84
leal -0x1(%rcx), %esi
movl 0x269a(%rip), %edi      # 0x50dc
decl %edi
movslq %edi, %rdi
shlq $0x3, %rdi
xorl %r8d, %r8d
movq %rbx, %r9
xorl %r10d, %r10d
cmpl $0x2, %ecx
jl 0x2a76
movq 0x60(%rax), %r11
addq %r8, %r11
xorl %ebp, %ebp
movsd (%r9,%rbp,8), %xmm0
movsd %xmm0, (%r11,%rbp,8)
incq %rbp
cmpq %rbp, %rsi
jne 0x2a62
incq %r10
addq %rdi, %r9
addq %rdi, %r8
cmpq %rdx, %r10
jne 0x2a54
incq %r14
movslq 0x264a(%rip), %rax      # 0x50d8
cmpq %rax, %r14
jl 0x2948
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq