// File: /workspace/github_cpp_makefile_star2_O3/TBody[P]atomicpp/atomicpp/Spline/BivariateBSpline.cpp
// Function: atomicpp::BivariateBSpline::fpbspl(std::vector<double, std::allocator<double>> const&, int, int, double, int, std::vector<double, std::allocator<double>>&)
void BivariateBSpline::fpbspl(const std::vector<double>& t,const int n, const int k, const double x, const int l, std::vector<double>& h){
  std::vector<double> hh(19,0.0);

  //  subroutine fpbspl evaluates the (k+1) non-zero b-splines of
  //  degree k at t(l) <= x < t(l+1) using the stable recurrence
  //  relation of de boor and cox.
  //  Travis Oliphant  2007
  //    changed so that weighting of 0 is used when knots with
  //      multiplicity are present.
  //    Also, notice that l+k <= n and 1 <= l+1-k
  //      or else the routine will be accessing memory outside t
  //      Thus it is imperative that that k <= l <= n-k but this
  //      is not checked.

  h.at(1-1) = 1;

  for(int j = 1; j <= k; ++j){
    for(int i = 1; i <= j; ++i){
      hh.at(i-1) = h.at(i-1);
    }
    h.at(1-1) = 0;
    for(int i = 1; i <= j; ++i){
      int li = l+i;
      int lj = li-j;

      if(t.at(li-1) != t.at(lj-1)){
        double f = hh.at(i-1) / (t.at(li-1)-t.at(lj-1));
        h.at(i-1) = h.at(i-1)+f*(t.at(li-1)-x);
        h.at(i) = f*(x-t.at(lj-1));
      } else {
        h.at(i) = 0;
      }
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %r9, %r13
movl %r8d, %ebx
movsd %xmm0, -0x68(%rbp)
movq %rcx, -0x48(%rbp)
movq %rsi, %r15
leaq -0xa8(%rbp), %r14
movq $0x0, (%r14)
leaq -0x29(%rbp), %r12
movq %r12, %rdi
callq 0x533c
leaq -0xa0(%rbp), %rdi
movl $0x13, %esi
movq %r14, %rdx
movq %r12, %rcx
callq 0x1802a
leaq -0x29(%rbp), %rdi
callq 0x5a80
movq %r13, %rdi
xorl %esi, %esi
callq 0x1d102
movabsq $0x3ff0000000000000, %rcx # imm = 0x3FF0000000000000
movq %rcx, (%rax)
cmpl $0x0, -0x48(%rbp)
jle 0x1cbec
movq %r13, %r14
movslq %ebx, %rcx
movq -0x48(%rbp), %rax
addl $0x2, %eax
movq %rax, -0x48(%rbp)
movq %rcx, -0x78(%rbp)
leal -0x1(%rcx), %eax
movq %rax, -0x58(%rbp)
movl $0x2, %r12d
movl $0x1, %r13d
movq %r14, -0x40(%rbp)
xorl %ebx, %ebx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1d102
movsd (%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
leaq -0xa0(%rbp), %rdi
movq %rbx, %rsi
callq 0x1d102
movsd -0x38(%rbp), %xmm0
movsd %xmm0, (%rax)
incq %rbx
cmpq %rbx, %r13
jne 0x1ca37
movq %r13, -0x60(%rbp)
movq %r12, -0x70(%rbp)
movq %r14, %rdi
xorl %esi, %esi
callq 0x1d102
movq $0x0, (%rax)
xorl %r13d, %r13d
movq -0x78(%rbp), %rax
leaq (%rax,%r13), %rbx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1d15e
movsd (%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x58(%rbp), %rax
addl %r13d, %eax
movslq %eax, %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x1d15e
leaq 0x1(%r13), %r14
movsd -0x38(%rbp), %xmm0
ucomisd (%rax), %xmm0
jne 0x1cacd
jnp 0x1cbac
leaq -0xa0(%rbp), %rdi
movq %r13, %rsi
callq 0x1d102
movsd (%rax), %xmm0
movsd %xmm0, -0x50(%rbp)
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1d15e
movsd (%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x1d15e
movsd -0x38(%rbp), %xmm0
subsd (%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x40(%rbp), %rdi
movq %r13, %rsi
callq 0x1d102
movsd (%rax), %xmm0
movsd %xmm0, -0x88(%rbp)
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1d15e
movsd (%rax), %xmm0
movsd %xmm0, -0x80(%rbp)
movq -0x40(%rbp), %rdi
movq %r13, %rsi
callq 0x1d102
movsd -0x50(%rbp), %xmm0
divsd -0x38(%rbp), %xmm0
movsd -0x80(%rbp), %xmm1
subsd -0x68(%rbp), %xmm1
movsd %xmm0, -0x50(%rbp)
mulsd %xmm0, %xmm1
addsd -0x88(%rbp), %xmm1
movsd %xmm1, (%rax)
movq %r15, %rdi
movq %r12, %rsi
callq 0x1d15e
movsd (%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x40(%rbp), %rdi
movq %r14, %rsi
callq 0x1d102
movsd -0x68(%rbp), %xmm0
subsd -0x38(%rbp), %xmm0
movsd -0x50(%rbp), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, (%rax)
jmp 0x1cbbf
movq -0x40(%rbp), %rdi
movq %r14, %rsi
callq 0x1d102
movq $0x0, (%rax)
movq %r14, %r13
cmpq %r14, -0x60(%rbp)
jne 0x1ca87
movq -0x70(%rbp), %r12
incq %r12
movq -0x60(%rbp), %r13
incq %r13
decq -0x58(%rbp)
cmpq -0x48(%rbp), %r12
movq -0x40(%rbp), %r14
jne 0x1ca35
leaq -0xa0(%rbp), %rdi
callq 0x53c6
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1cc20
movq %rax, %rbx
leaq -0x29(%rbp), %rdi
callq 0x5a80
jmp 0x1cc2f
jmp 0x1cc20
jmp 0x1cc20
jmp 0x1cc20
movq %rax, %rbx
leaq -0xa0(%rbp), %rdi
callq 0x53c6
movq %rbx, %rdi
callq 0x45a0
nop