// File: TBody[P]atomicpp/atomicpp/Spline/BivariateBSpline.cpp
// Function: atomicpp::BivariateBSpline::fpback(std::vector<std::vector<double, std::allocator<double>>, std::allocator<std::vector<double, std::allocator<double>>>> const&, std::vector<double, std::allocator<double>> const&, int, int, std::vector<double, std::allocator<double>>&, int)
void BivariateBSpline::fpback(const std::vector<std::vector<double>>& a, const std::vector<double>& z, const int n, const int k, std::vector<double>& C, const int nest){
  //No shift version of fpback - overloaded

  // std::cout << "fpback called" << std::endl;

  C.at(n-1) = z.at(n-1)/a.at(n-1).at(0);
  
  int i = n-1;
  double store;

  if(i!=0){
    for(int j=2; j <= n; ++j){
      store = z.at(i-1);
      int i1 = k-1;

      if(j <= k-1){
        i1 = j-1;
      }
      int m = i;
      for(int l=1; l <= i1; ++l){
        m = m+1;
        store = store - C.at(m-1)*a.at(i-1).at(l);
      }
      C.at(i-1) = store/a.at(i-1).at(0);
      i -= 1;
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x2f490
movsd (%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
movq -0x10(%rbp), %rdi
movl -0x1c(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x2f4d0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2f490
movsd -0x58(%rbp), %xmm0
divsd (%rax), %xmm0
movsd %xmm0, -0x50(%rbp)
movq -0x28(%rbp), %rdi
movl -0x1c(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x2f3f0
movsd -0x50(%rbp), %xmm0
movsd %xmm0, (%rax)
movl -0x1c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x2e646
movl $0x2, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jg 0x2e644
movq -0x18(%rbp), %rdi
movl -0x2c(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x2f490
movsd (%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movl -0x20(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x40(%rbp)
movl -0x3c(%rbp), %eax
movl -0x20(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jg 0x2e537
movl -0x3c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x40(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x44(%rbp)
movl $0x1, -0x48(%rbp)
movl -0x48(%rbp), %eax
cmpl -0x40(%rbp), %eax
jg 0x2e5dc
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
movsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
movq -0x28(%rbp), %rdi
movl -0x44(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x2f3f0
movsd (%rax), %xmm0
movsd %xmm0, -0x68(%rbp)
movq -0x10(%rbp), %rdi
movl -0x2c(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x2f4d0
movq %rax, %rdi
movslq -0x48(%rbp), %rsi
callq 0x2f490
movsd -0x68(%rbp), %xmm0
movsd -0x60(%rbp), %xmm1
movsd (%rax), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x2e544
movsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x78(%rbp)
movq -0x10(%rbp), %rdi
movl -0x2c(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x2f4d0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2f490
movsd -0x78(%rbp), %xmm0
divsd (%rax), %xmm0
movsd %xmm0, -0x70(%rbp)
movq -0x28(%rbp), %rdi
movl -0x2c(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x2f3f0
movsd -0x70(%rbp), %xmm0
movsd %xmm0, (%rax)
movl -0x2c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x2e4f1
jmp 0x2e646
addq $0x80, %rsp
popq %rbp
retq
nop