// File: /workspace/github_cpp_makefile_star2_O2/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
subq $0x18, %rsp
movq %rdi, %rbx
movslq 0x2a28(%rip), %rbp      # 0x50d8
imulq $0x68, %rbp, %rdi
callq 0x10f0
movq %rax, 0x2a40(%rip)      # 0x5100
xorl %r14d, %r14d
xorpd %xmm0, %xmm0
movhpd 0x949(%rip), %xmm0      # xmm0 = xmm0[0],mem[0]
movapd %xmm0, (%rsp)
movabsq $0x3fb999999999999a, %r15 # imm = 0x3FB999999999999A
pushq $0x1
popq %r12
xorl %r13d, %r13d
movslq %ebp, %rcx
cmpq %rcx, %r13
jge 0x2827
imulq $0x68, %r13, %rbp
movl %r13d, (%rax,%rbp)
movl 0x29dd(%rip), %ecx      # 0x50dc
movl %ecx, 0x40(%rax,%rbp)
movl 0x29df(%rip), %ecx      # 0x50e8
movl %ecx, 0x50(%rax,%rbp)
movsd 0x29cb(%rip), %xmm0     # 0x50e0
cvtsi2sd %r13d, %xmm1
movsd %xmm0, 0x48(%rax,%rbp)
cvtsi2sdl 0x29b0(%rip), %xmm0 # 0x50d8
divsd %xmm0, %xmm1
movsd %xmm1, 0x18(%rax,%rbp)
movaps (%rsp), %xmm0
movups %xmm0, 0x20(%rax,%rbp)
movapd 0xb0d(%rip), %xmm0      # 0x3250
movupd %xmm0, 0x30(%rax,%rbp)
movslq 0x298c(%rip), %rdi      # 0x50dc
callq 0x14e5
movq 0x29a4(%rip), %rcx      # 0x5100
movq %rax, 0x58(%rcx,%rbp)
movq 0x2998(%rip), %rax      # 0x5100
movslq 0x50(%rax,%rbp), %rdi
movslq 0x40(%rax,%rbp), %rsi
decq %rsi
callq 0x152b
movsd 0xa1e(%rip), %xmm1      # 0x31a0
movq 0x2977(%rip), %rcx      # 0x5100
movq %rax, 0x60(%rcx,%rbp)
movq 0x296b(%rip), %rax      # 0x5100
leaq (%rax,%rbp), %rcx
movq 0x58(%rax,%rbp), %rsi
movq %r15, (%rsi)
movslq 0x40(%rax,%rbp), %rdx
movq %r12, %rdi
cmpq %rdx, %rdi
jge 0x27c2
movsd -0x8(%rsi,%rdi,8), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rsi,%rdi,8)
incq %rdi
jmp 0x27a9
decl %edx
movl 0x2912(%rip), %edi      # 0x50dc
decl %edi
testl %edx, %edx
cmovlel %r14d, %edx
movl 0x50(%rax,%rbp), %esi
testl %esi, %esi
cmovlel %r14d, %esi
movslq %edi, %rdi
shlq $0x3, %rdi
xorl %r8d, %r8d
xorl %r9d, %r9d
cmpq %rsi, %r9
je 0x2819
movq %r8, %r10
movq %rdx, %r11
subq $0x1, %r11
jb 0x2811
movsd (%rbx,%r10), %xmm0
movq 0x60(%rcx), %rbp
movsd %xmm0, (%rbp,%r10)
addq $0x8, %r10
jmp 0x27f4
incq %r9
addq %rdi, %r8
jmp 0x27e9
incq %r13
movl 0x28b6(%rip), %ebp      # 0x50d8
jmp 0x26e5
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq