// File: /workspace/github_cpp_makefile_star2_O2/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, -0x38(%rbp)
movsd %xmm0, -0x60(%rbp)
movl %ecx, %ebx
movq %rsi, %r15
leaq -0xa8(%rbp), %r14
andq $0x0, (%r14)
leaq -0x29(%rbp), %r12
movq %r12, %rdi
callq 0x531c
leaq -0xa0(%rbp), %rdi
pushq $0x13
popq %rsi
movq %r14, %rdx
movq %r12, %rcx
callq 0x17a40
leaq -0x29(%rbp), %rdi
callq 0x5a64
xorl %r14d, %r14d
movq %r13, -0x40(%rbp)
movq %r13, %rdi
xorl %esi, %esi
callq 0x1c982
movabsq $0x3ff0000000000000, %rcx # imm = 0x3FF0000000000000
movq %rcx, (%rax)
movslq -0x38(%rbp), %rax
testl %ebx, %ebx
cmovlel %r14d, %ebx
addl $0x2, %ebx
movq %rbx, -0x68(%rbp)
movq %rax, -0x78(%rbp)
decl %eax
movq %rax, -0x58(%rbp)
pushq $0x2
popq %r13
pushq $0x1
popq %rax
movq %rax, -0x48(%rbp)
cmpq -0x68(%rbp), %r13
je 0x1c464
movq -0x48(%rbp), %r14
pushq $0x1
popq %r12
subq $0x1, %r14
jb 0x1c2f3
leaq -0x1(%r12), %rbx
movq -0x40(%rbp), %rdi
movq %rbx, %rsi
callq 0x1c982
movsd (%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
leaq -0xa0(%rbp), %rdi
movq %rbx, %rsi
callq 0x1c982
movsd -0x38(%rbp), %xmm0
movsd %xmm0, (%rax)
incq %r12
jmp 0x1c2b6
movq %r13, -0x70(%rbp)
movq -0x40(%rbp), %rdi
xorl %esi, %esi
callq 0x1c982
andq $0x0, (%rax)
xorl %r13d, %r13d
cmpq %r13, -0x48(%rbp)
je 0x1c450
movq -0x78(%rbp), %rax
leaq (%rax,%r13), %rbx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1c9de
movsd (%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x58(%rbp), %rax
addl %r13d, %eax
movslq %eax, %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x1c9de
leaq 0x1(%r13), %r14
movsd -0x38(%rbp), %xmm0
ucomisd (%rax), %xmm0
jne 0x1c359
jnp 0x1c438
leaq -0xa0(%rbp), %rdi
movq %r13, %rsi
callq 0x1c982
movsd (%rax), %xmm0
movsd %xmm0, -0x50(%rbp)
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1c9de
movsd (%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x1c9de
movsd -0x38(%rbp), %xmm0
subsd (%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x40(%rbp), %rdi
movq %r13, %rsi
callq 0x1c982
movsd (%rax), %xmm0
movsd %xmm0, -0x88(%rbp)
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1c9de
movsd (%rax), %xmm0
movsd %xmm0, -0x80(%rbp)
movq -0x40(%rbp), %rdi
movq %r13, %rsi
callq 0x1c982
movsd -0x50(%rbp), %xmm0
divsd -0x38(%rbp), %xmm0
movsd -0x80(%rbp), %xmm1
subsd -0x60(%rbp), %xmm1
movsd %xmm0, -0x50(%rbp)
mulsd %xmm0, %xmm1
addsd -0x88(%rbp), %xmm1
movsd %xmm1, (%rax)
movq %r15, %rdi
movq %r12, %rsi
callq 0x1c9de
movsd (%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x40(%rbp), %rdi
movq %r14, %rsi
callq 0x1c982
movsd -0x60(%rbp), %xmm0
subsd -0x38(%rbp), %xmm0
movsd -0x50(%rbp), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, (%rax)
jmp 0x1c448
movq -0x40(%rbp), %rdi
movq %r14, %rsi
callq 0x1c982
andq $0x0, (%rax)
movq %r14, %r13
jmp 0x1c309
movq -0x70(%rbp), %r13
incq %r13
incq -0x48(%rbp)
decq -0x58(%rbp)
jmp 0x1c2a4
leaq -0xa0(%rbp), %rdi
callq 0x53a6
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1c498
movq %rax, %rbx
leaq -0x29(%rbp), %rdi
callq 0x5a64
jmp 0x1c4a7
jmp 0x1c498
jmp 0x1c498
jmp 0x1c498
movq %rax, %rbx
leaq -0xa0(%rbp), %rdi
callq 0x53a6
movq %rbx, %rdi
callq 0x45a0
nop