// File: /workspace/github_cpp_makefile_star2_O3/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movslq 0x281e(%rip), %r14      # 0x50d8
imulq $0x68, %r14, %rdi
callq 0x10f0
movq %rax, 0x2836(%rip)      # 0x5100
testq %r14, %r14
jle 0x2a3b
xorpd %xmm0, %xmm0
movhpd 0x739(%rip), %xmm0      # xmm0 = xmm0[0],mem[0]
movapd %xmm0, (%rsp)
xorl %r14d, %r14d
movabsq $0x3fb999999999999a, %r15 # imm = 0x3FB999999999999A
imulq $0x68, %r14, %r12
movl %r14d, (%rax,%r12)
movl 0x27dd(%rip), %ecx      # 0x50dc
movl %ecx, 0x40(%rax,%r12)
movl 0x27de(%rip), %ecx      # 0x50e8
movl %ecx, 0x50(%rax,%r12)
movsd 0x27c9(%rip), %xmm0     # 0x50e0
xorps %xmm1, %xmm1
cvtsi2sd %r14d, %xmm1
movsd %xmm0, 0x48(%rax,%r12)
xorps %xmm0, %xmm0
cvtsi2sdl 0x27a7(%rip), %xmm0 # 0x50d8
divsd %xmm0, %xmm1
movsd %xmm1, 0x18(%rax,%r12)
movaps (%rsp), %xmm0
movups %xmm0, 0x20(%rax,%r12)
movapd 0x932(%rip), %xmm0      # 0x3280
movupd %xmm0, 0x30(%rax,%r12)
movslq 0x2780(%rip), %rdi      # 0x50dc
callq 0x15de
movq 0x2798(%rip), %rcx      # 0x5100
movq %rax, 0x58(%rcx,%r12)
movq 0x278c(%rip), %rax      # 0x5100
movslq 0x50(%rax,%r12), %rdi
movslq 0x40(%rax,%r12), %rsi
decq %rsi
callq 0x162f
movsd 0x842(%rip), %xmm1      # 0x31d0
movq 0x276b(%rip), %rcx      # 0x5100
movq %rax, 0x60(%rcx,%r12)
movq 0x275f(%rip), %rax      # 0x5100
movq 0x58(%rax,%r12), %rdx
movq %r15, (%rdx)
movslq 0x40(%rax,%r12), %rcx
cmpq $0x2, %rcx
jl 0x29ce
movsd (%rdx), %xmm0
movl $0x1, %esi
addsd %xmm1, %xmm0
movsd %xmm0, (%rdx,%rsi,8)
incq %rsi
cmpq %rsi, %rcx
jne 0x29bd
movslq 0x50(%rax,%r12), %rdx
testq %rdx, %rdx
jle 0x2a28
addq %rax, %r12
leal -0x1(%rcx), %esi
movl 0x26f8(%rip), %edi      # 0x50dc
decl %edi
movslq %edi, %rdi
shlq $0x3, %rdi
xorl %r8d, %r8d
movq %rbx, %r9
xorl %r10d, %r10d
cmpl $0x2, %ecx
jl 0x2a1a
movq 0x60(%r12), %r11
addq %r8, %r11
xorl %r13d, %r13d
movsd (%r9,%r13,8), %xmm0
movsd %xmm0, (%r11,%r13,8)
incq %r13
cmpq %r13, %rsi
jne 0x2a06
incq %r10
addq %rdi, %r9
addq %rdi, %r8
cmpq %rdx, %r10
jne 0x29f6
incq %r14
movslq 0x26a6(%rip), %rcx      # 0x50d8
cmpq %rcx, %r14
jl 0x28f1
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq