// File: 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
subq $0x150, %rsp            # imm = 0x150
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movsd %xmm0, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq %r9, -0x30(%rbp)
movq $0x0, -0x50(%rbp)
leaq -0x51(%rbp), %rdi
movq %rdi, -0x88(%rbp)
callq 0x58a0
movq -0x88(%rbp), %rcx
leaq -0x48(%rbp), %rdi
movl $0x13, %esi
leaq -0x50(%rbp), %rdx
callq 0x26390
jmp 0x2e6a9
leaq -0x51(%rbp), %rdi
callq 0x5930
movq -0x30(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2f3f0
movq %rax, -0x90(%rbp)
jmp 0x2e6c8
movq -0x90(%rbp), %rax
movsd 0x7931(%rip), %xmm0     # 0x36008
movsd %xmm0, (%rax)
movl $0x1, -0x68(%rbp)
movl -0x68(%rbp), %eax
cmpl -0x18(%rbp), %eax
jg 0x2ea69
movl $0x1, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
cmpl -0x68(%rbp), %eax
jg 0x2e79a
movq -0x30(%rbp), %rdi
movl -0x6c(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x2f3f0
movq %rax, -0x98(%rbp)
jmp 0x2e71b
movq -0x98(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0xa8(%rbp)
movl -0x6c(%rbp), %eax
decl %eax
movslq %eax, %rsi
leaq -0x48(%rbp), %rdi
callq 0x2f3f0
movq %rax, -0xa0(%rbp)
jmp 0x2e748
movq -0xa0(%rbp), %rax
movsd -0xa8(%rbp), %xmm0
movsd %xmm0, (%rax)
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x2e6f5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x51(%rbp), %rdi
callq 0x5930
jmp 0x2ea7b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x59b0
jmp 0x2ea7b
movq -0x30(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2f3f0
movq %rax, -0xb0(%rbp)
jmp 0x2e7b0
movq -0xb0(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
movl $0x1, -0x70(%rbp)
movl -0x70(%rbp), %eax
cmpl -0x68(%rbp), %eax
jg 0x2ea59
movl -0x24(%rbp), %eax
movl -0x70(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x74(%rbp)
movl -0x74(%rbp), %eax
movl -0x68(%rbp), %ecx
subl %ecx, %eax
movl %eax, -0x78(%rbp)
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x2f490
movq %rax, -0xb8(%rbp)
jmp 0x2e801
movq -0xb8(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0xc8(%rbp)
movq -0x10(%rbp), %rdi
movl -0x78(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x2f490
movq %rax, -0xc0(%rbp)
jmp 0x2e82e
movsd -0xc8(%rbp), %xmm0
movq -0xc0(%rbp), %rax
ucomisd (%rax), %xmm0
jne 0x2e84a
jp 0x2e84a
jmp 0x2ea25
movl -0x70(%rbp), %eax
decl %eax
movslq %eax, %rsi
leaq -0x48(%rbp), %rdi
callq 0x2f3f0
movq %rax, -0xd0(%rbp)
jmp 0x2e864
movq -0xd0(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0xe0(%rbp)
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x2f490
movq %rax, -0xd8(%rbp)
jmp 0x2e891
movq -0xd8(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0xf0(%rbp)
movq -0x10(%rbp), %rdi
movl -0x78(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x2f490
movq %rax, -0xe8(%rbp)
jmp 0x2e8be
movsd -0xe0(%rbp), %xmm0
movsd -0xf0(%rbp), %xmm1
movq -0xe8(%rbp), %rax
movsd (%rax), %xmm2
subsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x80(%rbp)
movq -0x30(%rbp), %rdi
movl -0x70(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x2f3f0
movq %rax, -0xf8(%rbp)
jmp 0x2e900
movq -0xf8(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x110(%rbp)
movsd -0x80(%rbp), %xmm0
movsd %xmm0, -0x108(%rbp)
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x2f490
movq %rax, -0x100(%rbp)
jmp 0x2e93a
movsd -0x110(%rbp), %xmm1
movsd -0x108(%rbp), %xmm0
movq -0x100(%rbp), %rax
movsd (%rax), %xmm2
movsd -0x20(%rbp), %xmm3
subsd %xmm3, %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x120(%rbp)
movq -0x30(%rbp), %rdi
movl -0x70(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x2f3f0
movq %rax, -0x118(%rbp)
jmp 0x2e988
movq -0x118(%rbp), %rax
movsd -0x120(%rbp), %xmm0
movsd %xmm0, (%rax)
movsd -0x80(%rbp), %xmm0
movsd %xmm0, -0x138(%rbp)
movsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x130(%rbp)
movq -0x10(%rbp), %rdi
movl -0x78(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x2f490
movq %rax, -0x128(%rbp)
jmp 0x2e9cf
movsd -0x138(%rbp), %xmm0
movsd -0x130(%rbp), %xmm1
movq -0x128(%rbp), %rax
movsd (%rax), %xmm2
subsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x148(%rbp)
movq -0x30(%rbp), %rdi
movslq -0x70(%rbp), %rsi
callq 0x2f3f0
movq %rax, -0x140(%rbp)
jmp 0x2ea10
movq -0x140(%rbp), %rax
movsd -0x148(%rbp), %xmm0
movsd %xmm0, (%rax)
jmp 0x2ea49
movq -0x30(%rbp), %rdi
movslq -0x70(%rbp), %rsi
callq 0x2f3f0
movq %rax, -0x150(%rbp)
jmp 0x2ea3b
movq -0x150(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
jmp 0x2ea4b
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x2e7c5
jmp 0x2ea5b
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0x2e6e2
leaq -0x48(%rbp), %rdi
callq 0x59b0
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
movq -0x60(%rbp), %rdi
callq 0x45e0
nopw %cs:(%rax,%rax)