// File: 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
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movslq 0x2c35(%rip), %rax      # 0x71e8
imulq $0x68, %rax, %rdi
callq 0x21b0
movq %rax, 0x2c4d(%rip)      # 0x7210
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
cmpl 0x2c15(%rip), %eax      # 0x71e8
jge 0x48b5
movl -0xc(%rbp), %ecx
movq 0x2c2d(%rip), %rax      # 0x7210
movslq -0xc(%rbp), %rdx
imulq $0x68, %rdx, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movl 0x2bf6(%rip), %ecx      # 0x71ec
movq 0x2c13(%rip), %rax      # 0x7210
movslq -0xc(%rbp), %rdx
imulq $0x68, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x40(%rax)
movl 0x2be7(%rip), %ecx      # 0x71f8
movq 0x2bf8(%rip), %rax      # 0x7210
movslq -0xc(%rbp), %rdx
imulq $0x68, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x50(%rax)
movsd 0x2bc2(%rip), %xmm0     # 0x71f0
movq 0x2bdb(%rip), %rax      # 0x7210
movslq -0xc(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x48(%rax)
cvtsi2sdl -0xc(%rbp), %xmm0
cvtsi2sdl 0x2b96(%rip), %xmm1 # 0x71e8
divsd %xmm1, %xmm0
movq 0x2bb3(%rip), %rax      # 0x7210
movslq -0xc(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movsd %xmm0, 0x18(%rax)
movq 0x2b9c(%rip), %rax      # 0x7210
movslq -0xc(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x20(%rax)
movq 0x2b82(%rip), %rax      # 0x7210
movslq -0xc(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movsd 0x977(%rip), %xmm0      # 0x5018
movsd %xmm0, 0x28(%rax)
movq 0x2b63(%rip), %rax      # 0x7210
movslq -0xc(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movsd 0xad0(%rip), %xmm0      # 0x5190
movsd %xmm0, 0x30(%rax)
movq 0x2b44(%rip), %rax      # 0x7210
movslq -0xc(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movsd 0x939(%rip), %xmm0      # 0x5018
movsd %xmm0, 0x38(%rax)
movslq 0x2b01(%rip), %rdi      # 0x71ec
callq 0x27b0
movq %rax, %rcx
movq 0x2b16(%rip), %rax      # 0x7210
movslq -0xc(%rbp), %rdx
imulq $0x68, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x58(%rax)
movq 0x2b00(%rip), %rax      # 0x7210
movslq -0xc(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movslq 0x50(%rax), %rdi
movq 0x2aea(%rip), %rax      # 0x7210
movslq -0xc(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movl 0x40(%rax), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x2880
movq %rax, %rcx
movq 0x2ac7(%rip), %rax      # 0x7210
movslq -0xc(%rbp), %rdx
imulq $0x68, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x60(%rax)
movq 0x2ab1(%rip), %rax      # 0x7210
movslq -0xc(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movq 0x58(%rax), %rax
movsd 0xa12(%rip), %xmm0      # 0x5188
movsd %xmm0, (%rax)
movl $0x1, -0x10(%rbp)
movl -0x10(%rbp), %eax
movq 0x2a85(%rip), %rcx      # 0x7210
movslq -0xc(%rbp), %rdx
imulq $0x68, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x40(%rcx), %eax
jge 0x47f1
movq 0x2a6e(%rip), %rax      # 0x7210
movslq -0xc(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movq 0x58(%rax), %rax
movl -0x10(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd 0x9d6(%rip), %xmm0      # 0x5198
addsd (%rax,%rcx,8), %xmm0
movq 0x2a42(%rip), %rax      # 0x7210
movslq -0xc(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movq 0x58(%rax), %rax
movslq -0x10(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x4781
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq 0x2a0e(%rip), %rcx      # 0x7210
movslq -0xc(%rbp), %rdx
imulq $0x68, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x50(%rcx), %eax
jge 0x48a5
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
movq 0x29e9(%rip), %rcx      # 0x7210
movslq -0xc(%rbp), %rdx
imulq $0x68, %rdx, %rdx
addq %rdx, %rcx
movl 0x40(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x4895
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %ecx
movl 0x29a3(%rip), %edx      # 0x71ec
subl $0x1, %edx
imull %edx, %ecx
addl -0x10(%rbp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x29af(%rip), %rax      # 0x7210
movslq -0xc(%rbp), %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movq 0x60(%rax), %rax
movl -0x14(%rbp), %ecx
movl 0x2973(%rip), %edx      # 0x71ec
subl $0x1, %edx
imull %edx, %ecx
addl -0x10(%rbp), %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x481d
jmp 0x4897
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x47f8
jmp 0x48a7
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x45ca
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)