// 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, int, std::vector<double, std::allocator<double>>&, int, int)
void BivariateBSpline::fpback(const std::vector<std::vector<double>>& a, const std::vector<double>& z, const int z_start, const int n, const int k, std::vector<double>& C, const int c_start, const int nest){
  // Switch from Fortran to C++ indexing
  // Supply start as '1' to not apply a shift
  int z_shifted = z_start - 1;
  int c_shifted = c_start - 1;

  C.at(c_shifted + n-1) = z.at(z_shifted + 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(z_shifted + 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(c_shifted + m-1)*a.at(i-1).at(l);
      }
      C.at(c_shifted + i-1) = store/a.at(i-1).at(0);
      i -= 1;
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movl 0x20(%rbp), %eax
movl 0x18(%rbp), %eax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movl %r9d, -0x24(%rbp)
movl -0x1c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x28(%rbp)
movl 0x18(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x2c(%rbp)
movq -0x18(%rbp), %rdi
movl -0x28(%rbp), %eax
addl -0x20(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x2f490
movsd (%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
movq -0x10(%rbp), %rdi
movl -0x20(%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 0x10(%rbp), %rdi
movl -0x2c(%rbp), %eax
addl -0x20(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x2f3f0
movsd -0x50(%rbp), %xmm0
movsd %xmm0, (%rax)
movl -0x20(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
je 0x2e43e
movl $0x2, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jg 0x2e43c
movq -0x18(%rbp), %rdi
movl -0x28(%rbp), %eax
addl -0x30(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x2f490
movsd (%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movl -0x24(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x40(%rbp)
movl -0x3c(%rbp), %eax
movl -0x24(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jg 0x2e329
movl -0x3c(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x40(%rbp)
movl -0x30(%rbp), %eax
movl %eax, -0x44(%rbp)
movl $0x1, -0x48(%rbp)
movl -0x48(%rbp), %eax
cmpl -0x40(%rbp), %eax
jg 0x2e3d1
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
movsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
movq 0x10(%rbp), %rdi
movl -0x2c(%rbp), %eax
addl -0x44(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x2f3f0
movsd (%rax), %xmm0
movsd %xmm0, -0x68(%rbp)
movq -0x10(%rbp), %rdi
movl -0x30(%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 0x2e336
movsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x78(%rbp)
movq -0x10(%rbp), %rdi
movl -0x30(%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 0x10(%rbp), %rdi
movl -0x2c(%rbp), %eax
addl -0x30(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x2f3f0
movsd -0x70(%rbp), %xmm0
movsd %xmm0, (%rax)
movl -0x30(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x30(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x2e2e0
jmp 0x2e43e
addq $0x80, %rsp
popq %rbp
retq
nopw (%rax,%rax)